-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
72 lines (61 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
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"
SRC_DIR = "$(CURDIR)/src"
TEST_DIR = "$(CURDIR)/test"
MAIN_EXE = "$(BUILD_DIR)/main"
MAKEFLAGS = --no-print-directory
.PHONY: build clean veryclean rebuild compile run-llvm run-rpi
build:
@cd $(SRC_DIR); \
cmake -G Ninja -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=Release; \
cd $(BUILD_DIR) && ninja; \
cd $(CURDIR)
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 "*.rpi" -o -name "*.arm" \
-o -name "*.s" \
\) -exec $(RM) {} \;
veryclean: clean
@$(RM) $(BUILD_DIR)
rebuild: veryclean build
compile: clean
@cd $(TEST_DIR)/tmp; \
for file in $$(ls .); do \
if [ "$${file##*.}" = "fmj" ]; then \
echo "Compiling [$${file%%.*}]"; \
$(MAIN_EXE) "$${file%%.*}" < "$${file%%.*}".fmj; \
fi \
done; \
cd $(CURDIR)
run-llvm: rebuild
@cd $(TEST_DIR); \
for file in $$(ls .); do \
if [ "$${file##*.}" = "fmj" ]; then \
echo "Run on llvm for [$${file%%.*}]"; \
$(MAIN_EXE) "$${file%%.*}" < "$${file%%.*}".fmj; \
$(LLVMLINK) --opaque-pointers "$${file%%.*}".6.ssa $(BUILD_DIR)/vendor/libsysy/libsysy64.ll -S -o "$${file%%.*}".ll && \
$(LLI) -opaque-pointers "$${file%%.*}".ll > "$${file%%.*}".output && \
echo $$?; \
fi \
done; \
cd $(CURDIR)
run-rpi: rebuild
@cd $(TEST_DIR); \
for file in $$(ls .); do \
if [ "$${file##*.}" = "fmj" ]; then \
echo "Run on arm for [$${file%%.*}]"; \
$(MAIN_EXE) "$${file%%.*}" < "$${file%%.*}".fmj; \
$(ARMCC) -mcpu=cortex-a72 "$${file%%.*}".8.s $(BUILD_DIR)/vendor/libsysy/libsysy32.s --static -o "$${file%%.*}".s && \
$(QEMU) -B 0x1000 "$${file%%.*}".s > "$${file%%.*}".output && \
echo $$?; \
fi \
done; \
cd $(CURDIR)