-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
141 lines (129 loc) · 4.35 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
RM = rm -rf
CLANG = clang-14
LLVMLINK = llvm-link-14
LLI = lli-14
ARMCC = arm-linux-gnueabihf-gcc
QEMU = qemu-arm
BUILD_DIR = $(CURDIR)/build
MAIN_EXE_LLVM = $(BUILD_DIR)/tools/mainLLVM
MAIN_EXE_RPI = $(BUILD_DIR)/tools/mainRPi
TEST_DIR = $(CURDIR)/test
FMJ2AST = "$(CURDIR)/vendor/tools/fmj2ast"
AST2IRP = "$(CURDIR)/vendor/tools/ast2irp"
IRP2LLVM = "$(CURDIR)/vendor/tools/irp2llvm"
MAKEFLAGS = --no-print-directory
.PHONY: compile clean veryclean test-llvm test-rpi handin run-llvm run-rpi
compile:
@cmake -G Ninja -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=Release; \
cd $(BUILD_DIR) && ninja
clean:
@find $(TEST_DIR) -type f \( \
-name "*.ll" -o -name "*.xml" -o -name "*.output" \
-o -name "*.src" -o -name "*.ast" -o -name "*.irp" \
-o -name "*.stm" -o -name "*.ins" -o -name "*.ssa" \
-o -name "*.cfg" -o -name "*.arm" -o -name "*.s" \
-o -name "*.itf" \
\) -exec $(RM) {} \;
veryclean: clean
@$(RM) $(BUILD_DIR)
test-llvm: clean
@cd $(TEST_DIR); \
if [ -z "$(TEST)" ]; then \
for file in $$(ls .); do \
if [ "$${file##*.}" = "fmj" ]; then \
echo "[$${file%%.*}]"; \
$(MAIN_EXE_LLVM) "$${file%%.*}" < "$${file%%.*}".fmj; \
fi \
done; \
else \
file=$(TEST); \
if [ "$${file##*.}" = "fmj" ]; then \
echo "[$${file%%.*}]"; \
$(MAIN_EXE_LLVM) "$${file%%.*}" < "$${file}"; \
else \
echo "Error: Specified file does not exist"; \
exit 1; \
fi \
fi; \
cd $(CURDIR)
test-rpi: clean
@cd $(TEST_DIR); \
if [ -z "$(TEST)" ]; then \
for file in $$(ls .); do \
if [ "$${file##*.}" = "fmj" ]; then \
echo "[$${file%%.*}]"; \
$(MAIN_EXE_RPI) "$${file%%.*}" < "$${file%%.*}".fmj; \
fi \
done; \
else \
file=$(TEST); \
if [ "$${file##*.}" = "fmj" ]; then \
echo "[$${file%%.*}]"; \
$(MAIN_EXE_RPI) "$${file%%.*}" < "$${file}"; \
else \
echo "Error: Specified file does not exist"; \
exit 1; \
fi \
fi; \
cd $(CURDIR)
run-llvm: clean
@cd $(TEST_DIR); \
if [ -z "$(TEST)" ]; then \
for file in $$(ls .); do \
if [ "$${file##*.}" = "fmj" ]; then \
echo "[$${file%%.*}]"; \
$(MAIN_EXE_LLVM) "$${file%%.*}" < "$${file%%.*}".fmj; \
$(LLVMLINK) --opaque-pointers "$${file%%.*}".7.ssa $(BUILD_DIR)/vendor/libsysy/libsysy64.ll -S -o "$${file%%.*}".ll && \
$(LLI) -opaque-pointers "$${file%%.*}".ll > "$${file%%.*}".output && \
echo $$?; \
fi \
done; \
else \
file=$(TEST); \
if [ "$${file##*.}" = "fmj" ]; then \
echo "[$${file%%.*}]"; \
$(MAIN_EXE_LLVM) "$${file%%.*}" < "$${file}"; \
$(LLVMLINK) --opaque-pointers "$${file%%.*}".7.ssa $(BUILD_DIR)/vendor/libsysy/libsysy64.ll -S -o "$${file%%.*}".ll && \
$(LLI) -opaque-pointers "$${file%%.*}".ll > "$${file%%.*}".output && \
echo $$?; \
else \
echo "Error: Specified file does not exist"; \
exit 1; \
fi \
fi; \
cd $(CURDIR)
run-rpi: clean
@cd $(TEST_DIR); \
if [ -z "$(TEST)" ]; then \
for file in $$(ls .); do \
if [ "$${file##*.}" = "fmj" ]; then \
echo "[$${file%%.*}]"; \
$(MAIN_EXE_RPI) "$${file%%.*}" < "$${file%%.*}".fmj; \
$(ARMCC) -mcpu=cortex-a72 "$${file%%.*}".9.s $(BUILD_DIR)/vendor/libsysy/libsysy32.s --static -o "$${file%%.*}".s && \
$(QEMU) -B 0x1000 "$${file%%.*}".s > "$${file%%.*}".output && \
echo $$?; \
fi \
done; \
else \
file=$(TEST); \
if [ "$${file##*.}" = "fmj" ]; then \
echo "[$${file%%.*}]"; \
$(MAIN_EXE_RPI) "$${file%%.*}" < "$${file}"; \
$(ARMCC) -mcpu=cortex-a72 "$${file%%.*}".9.s $(BUILD_DIR)/vendor/libsysy/libsysy32.s --static -o "$${file%%.*}".s && \
$(QEMU) -B 0x1000 "$${file%%.*}".s > "$${file%%.*}".output && \
echo $$?; \
else \
echo "Error: Specified file does not exist"; \
exit 1; \
fi \
fi; \
cd $(CURDIR)
handin:
@if [ ! -f docs/report.pdf ]; then \
echo "请先在docs文件夹下攥写报告, 并转换为'report.pdf'"; \
exit 1; \
fi; \
echo "请输入'学号-姓名' (例如: 12345678910-某个人)"; \
read filename; \
zip -q -r "docs/$$filename-final.zip" \
include lib tools vendor test CMakeLists.txt Makefile README.md docs/report.pdf