Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
127 lines (81 loc) · 2.96 KB
/
Copy pathMakefile
File metadata and controls
127 lines (81 loc) · 2.96 KB
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
SRCS=alloc.c bitint.c codegen.c hashmap.c main.c parse.c platform.c preprocess.c strings.c tokenize.c type.c unicode.c
TEST_SRCS!=ls test/*.c
STG2_FLAGS=
SAN_FLAGS=-fsanitize=address,undefined -fno-sanitize=alignment -fno-sanitize-recover=undefined
.SUFFIXES: .exe .stage2.o .stage2.exe .san.o .san.exe .filc.o .filc.exe
# Stage 1
OBJS=$(SRCS:.c=.o)
slimcc: $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS)
$(OBJS): slimcc.h
TESTS=$(TEST_SRCS:.c=.exe)
test/host/common.o: test/host/common.c
$(CC) -o $@ -c $<
$(TESTS): slimcc test/host/common.o
.c.exe:
$(SHELL) scripts/test_helper.sh ./slimcc $< $@
test: $(TESTS)
for i in $(TESTS); do echo $$i; ./$$i || exit 1; done
$(SHELL) scripts/test_driver.sh $(PWD)/slimcc $(CC)
./slimcc -hashmap-test
# Stage 2
OBJS_S2=$(SRCS:.c=.stage2.o)
$(OBJS_S2): slimcc
.c.stage2.o:
./slimcc $(STG2_FLAGS) -o $@ -c $<
slimcc-stage2: $(OBJS_S2)
./slimcc $(STG2_FLAGS) -o $@ $(OBJS_S2) $(LDFLAGS)
TESTS_S2=$(TEST_SRCS:.c=.stage2.exe)
$(TESTS_S2): slimcc-stage2 test/host/common.o
.c.stage2.exe:
$(SHELL) scripts/test_helper.sh ./slimcc-stage2 $< $@
test-stage2: $(TESTS_S2)
for i in $(TESTS_S2); do echo $$i; ./$$i || exit 1; done
$(SHELL) scripts/test_driver.sh $(PWD)/slimcc-stage2 $(CC)
./slimcc-stage2 -hashmap-test
# -fsanitize build
OBJS_SAN=$(SRCS:.c=.san.o)
$(OBJS_SAN): slimcc.h
.c.san.o:
$(CC) $(SAN_FLAGS) -g -fno-omit-frame-pointer -o $@ -c $<
slimcc-san: $(OBJS_SAN)
$(CC) $(SAN_FLAGS) -g -fno-omit-frame-pointer -o $@ $(OBJS_SAN)
TESTS_SAN=$(TEST_SRCS:.c=.san.exe)
$(TESTS_SAN): slimcc-san test/host/common.o
.c.san.exe:
$(SHELL) scripts/test_helper.sh ./slimcc-san $< $@
test-san: $(TESTS_SAN)
for i in $(TESTS_SAN); do echo $$i; ./$$i || exit 1; done
$(SHELL) scripts/test_driver.sh $(PWD)/slimcc-san $(CC)
./slimcc-san scripts/amalgamation.c -c -o/dev/null
./slimcc-san -hashmap-test
test-misc: slimcc-san test/host/common.o
$(SHELL) scripts/test_abi.sh $(PWD)/slimcc-san $(CC)
$(SHELL) scripts/test_abi.sh $(CC) $(PWD)/slimcc-san
$(SHELL) scripts/test_include_next.sh $(PWD)/slimcc-san
FILE=file $(SHELL) scripts/test_linker.sh $(PWD)/slimcc-san
# Fil-C build
OBJS_FILC=$(SRCS:.c=.filc.o)
$(OBJS_FILC): slimcc.h
.c.filc.o:
$(FILC) -g -o $@ -c $<
slimcc-filc: $(OBJS_FILC)
$(FILC) -g -o $@ $(OBJS_FILC)
TESTS_FILC=$(TEST_SRCS:.c=.filc.exe)
$(TESTS_FILC): slimcc-filc test/host/common.o
.c.filc.exe:
$(SHELL) scripts/test_helper.sh ./slimcc-filc $< $@
test-filc: $(TESTS_FILC)
for i in $(TESTS_FILC); do echo $$i; ./$$i || exit 1; done
$(SHELL) scripts/test_driver.sh $(PWD)/slimcc-filc $(CC)
./slimcc-filc scripts/amalgamation.c -c -o/dev/null
./slimcc-filc -hashmap-test
# Misc.
test-all: test test-stage2
format:
$(CLANG_FORMAT) -i $(SRCS) slimcc.h platform/*.c
perl -i -p0e 's|\:[ ]+\{\n|: {\n|g' $(SRCS) slimcc.h platform/*.c
clean:
rm -f slimcc slimcc-stage2 slimcc-san slimcc-filc
rm -f *.o test/*.o test/*.exe test/host/*.o test/abi/*.o
.PHONY: clean test test-stage2 test-all test-san test-filc