-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
50 lines (34 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
CFLAGS = -Wall -Wextra -DNANAC_TRACE -std=c89 -pedantic
ifdef RELEASE
OPTFLAGS = -fuse-linker-plugin -flto -O2 -fdata-sections -ffunction-sections -Wl,--gc-sections
endif
all: nanac.exe test
.PHONY: test
test: nanac.exe $(patsubst %.asm,%.test,$(wildcard test/*.asm))
libnanac.a: nanac_vm.o nanac_builtins.o
$(AR) r $@ $+
%.o: %.c
$(CC) $(CFLAGS) $(OPTFLAGS) -o $@ -c $<
nanac.exe: main.o libnanac.a
$(CC) $(CFLAGS) $(OPTFLAGS) -o $@ $< -L. -lnanac
clean:
rm -f *.o *.bin *.exe *.pyc *.a test/*.bin test/*.c test/*.out test/*.exe test/*.exe.tst
%.bin: %.asm
./assemble.py $<
@echo ""
test/%.out: test/%.bin
./nanac.exe $< > $@
test/%.c: test/%.bin tocfile.py
./tocfile.py $< > $@
test/%.exe.out: test/%.exe
./$< | cut -f 1 -d ' ' > test/$*.exe.out
test/%.exe.tst: test/%.tst
cat test/$*.tst | cut -f 1 -d ' ' > test/$*.exe.tst
test/%.exe: test/%.c test/%.out
$(CC) $(CFLAGS) $(OPTFLAGS) -I. -o $@ $< nanac_vm.c test_main.c
test/%.exe.diff: test/%.exe.tst test/%.exe.out
diff test/$*.exe.tst test/$*.exe.out
test/%.test: test/%.diff test/%.exe.diff
@echo "Done"
test/%.diff: test/%.out
diff test/$*.tst $<