2019-08-03 05:29:50 +03:00
|
|
|
CFLAGS=-std=c11 -g -fno-common
|
2020-09-04 13:03:01 +03:00
|
|
|
|
2020-10-07 14:11:16 +03:00
|
|
|
SRCS=$(wildcard *.c)
|
|
|
|
OBJS=$(SRCS:.c=.o)
|
2019-08-03 05:29:50 +03:00
|
|
|
|
2020-09-04 13:03:01 +03:00
|
|
|
TEST_SRCS=$(wildcard test/*.c)
|
|
|
|
TESTS=$(TEST_SRCS:.c=.exe)
|
|
|
|
|
2020-10-07 14:11:16 +03:00
|
|
|
chibicc: $(OBJS)
|
|
|
|
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
|
|
|
|
|
|
|
$(OBJS): chibicc.h
|
2019-08-03 05:29:50 +03:00
|
|
|
|
2020-09-04 13:03:01 +03:00
|
|
|
test/%.exe: chibicc test/%.c
|
|
|
|
$(CC) -o- -E -P -C test/$*.c | ./chibicc -o test/$*.s -
|
|
|
|
$(CC) -o $@ test/$*.s -xc test/common
|
|
|
|
|
|
|
|
test: $(TESTS)
|
|
|
|
for i in $^; do echo $$i; ./$$i || exit 1; echo; done
|
|
|
|
test/driver.sh
|
2019-08-03 05:29:50 +03:00
|
|
|
|
|
|
|
clean:
|
2020-09-04 13:03:01 +03:00
|
|
|
rm -rf chibicc tmp* $(TESTS) test/*.s test/*.exe
|
|
|
|
find * -type f '(' -name '*~' -o -name '*.o' ')' -exec rm {} ';'
|
2019-08-03 05:29:50 +03:00
|
|
|
|
|
|
|
.PHONY: test clean
|