forked from rui314/8cc
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
56 lines (44 loc) · 1.11 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
CFLAGS=-Wall -std=gnu99 -g -I. -O0
OBJS=cpp.o debug.o dict.o gen.o lex.o list.o parse.o string.o error.o
SELF=cpp.s debug.s dict.s gen.s lex.s list.s parse.s string.s error.s main.s
TESTS := $(patsubst %.c,%.bin,$(wildcard test/*.c))
8cc: 8cc.h main.o $(OBJS)
$(CC) -o $@ main.o $(OBJS) $(LDFLAGS)
$(OBJS) utiltest.o main.o: 8cc.h
utiltest: 8cc.h utiltest.o $(OBJS)
$(CC) -o $@ utiltest.o $(OBJS) $(LDFLAGS)
test: utiltest $(TESTS)
@echo
./utiltest
@for test in $(TESTS); do \
./$$test || exit; \
done
./test.sh
test/%.o: test/%.c 8cc
./8cc -c $<
test/%.bin: test/%.o test/main/testmain.s 8cc
$(CC) -o $@ $< test/main/testmain.o $(LDFLAGS)
$(SELF) test/main/testmain.s: 8cc test/main/testmain.c
./8cc -c $(@:s=c)
self: $(SELF)
rm -f 8cc utiltest
$(MAKE) 8cc
fulltest:
$(MAKE) clean
$(MAKE) test
cp 8cc gen1
rm $(OBJS) main.o
$(MAKE) self
$(MAKE) test
cp 8cc gen2
rm $(OBJS) main.o
$(MAKE) self
$(MAKE) test
cp 8cc gen3
diff gen2 gen3
clean:
rm -f 8cc *.o *.s tmp.* test/*.s test/*.o sample/*.o
rm -f utiltest gen[1-9] test/util/testmain.[os]
rm -f $(TESTS)
all: 8cc
.PHONY: clean test all