-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
117 lines (90 loc) · 2.64 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
CC=clang
CFLAGS=-g3 -static
MAKEFILE_DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
COMPILER=$(MAKEFILE_DIR)/target/debug/ironcc
WASM_COMPILER=$(MAKEFILE_DIR)/target/wasm32_wasi/debug/ironcc.wasm
LEMOLA_CC_PATH=$(MAKEFILE_DIR)validation/lemola_cc
$(COMPILER): FORCE
cargo build
build_wasm: $(WASM_COMPILER)
$(WASM_COMPILER): FORCE
cargo build --target=wasm32-wasi
tmp.s: tmp.c $(COMPILER)
cargo run tmp.c
a.out: tmp.s link.c
$(CC) tmp.s -o a.out $(CFLAGS)
run: a.out $(COMPILER)
./a.out
fmt: FORCE
cargo fmt
clang-format -i tests/insta_srcs/*.c test/*.c samples/*.c
test: $(COMPILER)
./test/test.sh
testc: $(COMPILER) test/test.c
$(COMPILER) test/test.c && \
$(CC) test.s test/test_utils.c $(CFLAGS) -o a.out && \
./a.out
# Samples
life_game.s: $(COMPILER) life_game.c
cargo run life_game.c
life: life_game.s
clang -g3 life_game.s
./a.out
life2: samples/cellular_automaton.c
cargo run samples/cellular_automaton.c
clang cellular_automaton.s
./a.out
donut: rotate.c
cargo run rotate.c
clang rotate.s
./a.out
sl: samples/sl.c samples/sl.h
cargo run samples/sl.c
$(CC) sl.s -lcurses
./a.out
ls: samples/ls.c
cargo run samples/ls.c
$(CC) ls.s
./a.out
tetris.s: $(COMPILER) tetris.c
gcc -E tetris.c > prpr_tetris.c
cargo run prpr_tetris.c
mv prpr_tetris.s tetris.s
tetris: tetris.s
clang -g3 tetris.s
./a.out
clang_test: test/test.c test/test_utils.c
clang test/test.c test/test_utils.c
./a.out
cargo_test: FORCE
cargo test
main.s: $(LEMOLA_CC_PATH)/src/main.c $(COMPILER)
$(COMPILER) $(LEMOLA_CC_PATH)/src/main.c
tokenizer.s: $(LEMOLA_CC_PATH)/src/tokenizer.c $(COMPILER)
$(COMPILER) $(LEMOLA_CC_PATH)/src/tokenizer.c
parser.s: $(LEMOLA_CC_PATH)/src/parser.c $(COMPILER)
$(COMPILER) $(LEMOLA_CC_PATH)/src/parser.c
code_gen.s: $(LEMOLA_CC_PATH)/src/code_gen.c $(COMPILER)
$(COMPILER) $(LEMOLA_CC_PATH)/src/code_gen.c
utils.s: $(LEMOLA_CC_PATH)/src/utils.c $(COMPILER)
$(COMPILER) $(LEMOLA_CC_PATH)/src/utils.c
main.o: main.s
$(CC) main.s -c -o main.o
tokenizer.o: tokenizer.s
$(CC) tokenizer.s -c -o tokenizer.o
parser.o: parser.s
$(CC) parser.s -c -o parser.o
code_gen.o: code_gen.s
$(CC) code_gen.s -c -o code_gen.o
utils.o: utils.s
$(CC) utils.s -c -o utils.o
lemola_cc: main.o tokenizer.o parser.o code_gen.o utils.o
$(CC) $(CFLAGS) main.o tokenizer.o parser.o code_gen.o utils.o -o lemola_cc
lemola_cc_test: lemola_cc $(LEMOLA_CC_PATH)/test/test.c $(LEMOLA_CC_PATH)/test/test_utils.c
cd $(LEMOLA_CC_PATH)/test && \
$(MAKEFILE_DIR)/lemola_cc test.c && \
$(CC) -c test_utils.c -g3 && \
$(CC) src.s test_utils.o -o tmp -g3 && \
./tmp
testall: cargo_test test testc
.PHONY: FORCE test cargo_test testall run testc