-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
36 lines (27 loc) · 910 Bytes
/
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
CFLAGS=-Wall -std=gnu99 -g -I. -no-pie
OBJS=lex.o string.o util.o gen.o parse.o list.o debug.o dict.o cpp.o
TESTS := $(patsubst %.c,%.bin,$(wildcard test/*.c))
8cc: 8cc.h main.o $(OBJS) /sys/kernel # should not run on macOS
$(CC) $(CFLAGS) -o $@ main.o $(OBJS)
$(OBJS) utiltest.o main.o: 8cc.h
utiltest: 8cc.h utiltest.o $(OBJS)
$(CC) $(CFLAGS) -o $@ utiltest.o $(OBJS)
test: utiltest $(TESTS) sample/nqueen
@echo
./utiltest
@for test in $(TESTS); do \
./$$test; \
done
./test.sh
test/%.s: test/%.c 8cc
./8cc < $< > $@
test/%.bin: test/%.s test/util/util.o 8cc
@$(CC) $(CFLAGS) -o $@ $< test/util/util.o
sample/nqueen: 8cc sample/nqueen.c
./8cc < sample/nqueen.c > sample/nqueen.s
$(CC) $(CFLAGS) -o sample/nqueen sample/nqueen.s
.PHONY: clean test all
clean:
rm -f 8cc *.o tmp.* test/*.s test/*.o sample/*.o utiltest sample/nqueen.s sample/nqueen
rm -f $(TESTS)
all: 8cc