-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
94 lines (70 loc) · 1.92 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
MAKEFILE_DIR := ${CURDIR}
# Try to figure out the host system
HOST_OS :=
ifeq ($(OS),Windows_NT)
HOST_OS = windows
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
HOST_OS := linux
endif
ifeq ($(UNAME_S),Darwin)
HOST_OS := osx
endif
endif
HOST_ARCH := $(shell if [[ $(shell uname -m) =~ i[345678]86 ]]; then echo x86_32; else echo $(shell uname -m); fi)
TARGET := $(HOST_OS)
TARGET_ARCH := $(HOST_ARCH)
CXXFLAGS := -O3 --std=c++11 #-march=rv64gv
CFLAGS := ${CXXFLAGS}
CFLAGS :=
ARFLAGS := -r
TARGET_TOOLCHAIN_PREFIX :=
C_PREFIX :=
#CXX := riscv64-unknown-elf-g++
#CC := riscv64-unknown-elf-gcc
LDFLAGS := -lm
INCLUDES := \
-I. \
-I $(MAKEFILE_DIR)/includes/
include $(wildcard $(MAKEFILE_DIR)/targets/*_makefile.inc)
CXX := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}g++
CC := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}gcc
AR := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}ar
#Benchmark sources
BENCHMARK_SRCS := \
$(wildcard $(MAKEFILE_DIR)/src/*.cc)
#GEM5 sources
GEM5_SRCS := \
$(MAKEFILE_DIR)/gem5_files/m5op_arm_A64.S
GENDIR := $(MAKEFILE_DIR)/gen/$(TARGET)_$(TARGET_ARCH)/
OBJDIR := $(GENDIR)obj/
BINDIR := $(GENDIR)bin/
BENCHMARK_BINARY := $(addprefix $(BINDIR), \
$(patsubst %.cc,%,$(patsubst %.c,%,$(BENCHMARK_SRCS))))
BENCHMARK_OBJS := $(addprefix $(OBJDIR), \
$(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(BENCHMARK_SRCS))))
GEM5_OBJ := $(addprefix $(OBJDIR), \
$(patsubst %.S,%.o, $(GEM5_SRCS)))
$(OBJDIR)%.o: %.cc
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
$(OBJDIR)%.o: %.c
@mkdir -p $(dir $@)
$(CC) $(CCFLAGS) $(INCLUDES) -c $< -o $@
$(OBJDIR)%.o: %.S
@mkdir -p $(dir $@)
$(CC) $(CCFLAGS) $(INCLUDES) -c $< -o $@
$(BENCHMARK_BINARY): $(BINDIR)% : $(OBJDIR)%.o $(GEM5_OBJ)
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(INCLUDES) \
-o $@ $^ \
$(LDFLAGS)
benchmark: $(BENCHMARK_BINARY)
all: $(BENCHMARK_BINARY)
.PHONY: clean
clean:
rm -rf $(MAKEFILE_DIR)/gen
cleantarget:
rm -rf $(OBJDIR)
rm -rf $(BINDIR)