-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.template
79 lines (62 loc) · 2.54 KB
/
Makefile.template
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
.SUFFIXES : .cpp .o
#Set variable
CORE_SRC=$(wildcard src/core/*.cpp)
PASSES_SRC=$(wildcard src/passes/*.cpp)
TEST_SRC=$(wildcard src/test/*.cpp)
VANILLA_SRC=src/passes/RemoveUnsupportedOps.cpp src/passes/CheckConstExpr.cpp src/test/vanilla_main.cpp src/test/SimpleBackend.cpp src/test/AssemblyEmitter.cpp
CORE_OBJ=$(CORE_SRC:src/core/%.cpp=obj/core/%.o)
PASSES_OBJ=$(PASSES_SRC:src/passes/%.cpp=obj/passes/%.o)
TEST_OBJ=$(filter-out obj/core/main.o, $(CORE_OBJ)) $(filter-out $(VANILLA_OBJ), $(TEST_SRC:src/test/%.cpp=obj/test/%.o)) obj/test/gtest_all.o
VANILLA_OBJ=$(VANILLA_SRC:src/%.cpp=obj/%.o)
_dummy := $(shell mkdir -p obj) $(shell mkdir -p obj/core) $(shell mkdir -p obj/passes) $(shell mkdir -p obj/test) $(shell mkdir -p bin)
all: bin/sf-compiler-team7 bin/sf-compiler-test-team7 bin/sf-compiler-vanilla bin/interpreter
help:
@echo make help: print these message
@echo make core: build sf-compiler-team7
@echo make test: build sf-compiler-test-team7 and execute
@echo make all: build core, test, interpreter
#Build Core
bin/sf-compiler-team7: $(PASSES_OBJ) $(CORE_OBJ)
@echo Linking sf-compiler-team7 ...
@$(CXX) $(LDFLAGS) -o bin/sf-compiler-team7 $(CORE_OBJ) $(PASSES_OBJ)
#Build Test Core
bin/sf-compiler-test-team7: $(PASSES_OBJ) $(TEST_OBJ)
@echo Linking sf-compiler-test-team7 ...
@$(CXX) $(LDFLAGS) -o bin/sf-compiler-test-team7 $(PASSES_OBJ) $(TEST_OBJ)
#Build Vanilla Core
bin/sf-compiler-vanilla: $(VANILLA_OBJ)
@echo Linking sf-compiler-vanilla ...
@$(CXX) $(LDFLAGS) -o bin/sf-compiler-vanilla $(VANILLA_OBJ)
#Build Interpreter
bin/interpreter:
@rm -r -f ./interpreter/build
@./interpreter/build.sh
#Build Objects
obj/core/%.o: src/core/%.cpp
@echo Building $@ ...
@$(CXX) $(CXXFLAGS) -c -o $@ $<
obj/passes/%.o: src/passes/%.cpp src/passes/%.h
@echo Building $@ ...
@$(CXX) $(CXXFLAGS) -c -o $@ $<
obj/test/gtest_all.o: $(GTESTSRC)
@echo Building obj/test/gtest_all.o ...
@$(CXX) $(CXXFLAGS) -c -o $@ $<
obj/test/%.o: src/test/%.cpp
@echo Building $@ ...
@$(CXX) $(CXXFLAGS) -c -o $@ $<
#Alias
core: bin/sf-compiler-team7
test: all
@echo Googletest
@printf "======================================================\n"
@./bin/sf-compiler-test-team7
@printf "\nUnit test(except Googletest)\n"
@printf "======================================================\n"
@python3 test/loops_unit_test/test.py
@test/backend_bugfix_unittests/test.sh $(LLVM_BIN)
@printf "\nCase test\n"
@printf "======================================================\n"
@test/checker_only_benchmarks.sh test/testcases $(PASSES)
#clean
clean:
rm -rf bin obj