-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
97 lines (71 loc) · 2.63 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
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
all: bin/cold bin/cast bin/cir bin/fs bin/r5d bin/r5e bin/mkinstab
runtests: out/test/summary.txt
clean:
rm -rf bin out
out/compiler.src: out/compiler.txt bin/rewriter
@mkdir -p out
bin/rewriter out/compiler.txt > out/compiler.src
out/compiler.txt: src/compiler.c bin/preproc
@mkdir -p out
bin/preproc < src/compiler.c > out/compiler.txt
CFLAGS := -Wall -g -Iexternal/oberon-risc-emu -Isrc -fno-builtin
CFLAGS += -Wno-unused-but-set-variable -Wno-unused-variable
#CFLAGS := -O2
CC := gcc
bin/cold: src/compiler.c src/risc5dis.c out/risc5ins.h
@mkdir -p bin
$(CC) -o $@ $(CFLAGS) -Wno-unused-result -DC src/compiler.c src/risc5dis.c
bin/cast: src/compiler2.c src/codegen-risc5-simple.c src/risc5dis.c out/risc5ins.h
@mkdir -p bin
$(CC) -o $@ $(CFLAGS) -Wno-unused-result -DC src/compiler2.c src/risc5dis.c
bin/cir: src/compiler2.c src/codegen-ir.c src/risc5dis.c out/risc5ins.h src/ir.h
@mkdir -p bin
$(CC) -o $@ $(CFLAGS) -Wno-unused-result -DIR -DC src/compiler2.c src/risc5dis.c
bin/rewriter: src/rewriter.c
@mkdir -p bin
$(CC) -o $@ $(CFLAGS) src/rewriter.c
bin/preproc: src/preproc.c
@mkdir -p bin
$(CC) -o $@ $(CFLAGS) src/preproc.c
bin/fs: src/fs.c src/fs.h
@mkdir -p bin
$(CC) -o $@ $(CFLAGS) src/fs.c
bin/r5d: src/r5d.c src/risc5dis.c out/risc5ins.h
@mkdir -p bin
$(CC) -o $@ $(CFLAGS) src/r5d.c src/risc5dis.c
RISC5EMU_SRC := \
external/oberon-risc-emu/risc5emu.c \
external/oberon-risc-emu/risc5emu-fp.c \
bin/r5e: src/r5e.c src/risc5dis.c $(RISC5EMU_SRC)
@mkdir -p bin
$(CC) -o $@ $(CFLAGS) -O2 src/r5e.c src/risc5dis.c $(RISC5EMU_SRC)
bin/mkinstab: src/mkinstab.c
@mkdir -p bin
$(CC) -o $@ $(CFLAGS) src/mkinstab.c
out/risc5ins.h: src/risc5ins.txt bin/mkinstab
@mkdir -p out
bin/mkinstab < src/risc5ins.txt > $@
# have to have two rules here otherwise tests without .log files
# fail to be compiled by the rule that depends on src+log *or*
# we fail to depend on the .log for tests with both...
out/test/%.txt: test/%.src test/%.log bin/cold bin/r5e test/runtest.sh
@mkdir -p out/test
@rm -f $@
@test/runtest.sh $< $@
out/test/%.txt: test/%.src bin/cold bin/r5e test/runtest.sh
@mkdir -p out/test
@rm -f $@
@test/runtest.sh $< $@
out/test2/%.txt: test/%.src test/%.log bin/cast bin/r5e test/runtest2.sh
@mkdir -p out/test2
@rm -f $@
@test/runtest2.sh $< $@
out/test2/%.txt: test/%.src bin/cast bin/r5e test/runtest2.sh
@mkdir -p out/test2
@rm -f $@
@test/runtest2.sh $< $@
SRCTESTS := $(sort $(wildcard test/*.src))
ALLTESTS := $(patsubst test/%.src,out/test/%.txt,$(SRCTESTS))
ALLTESTS += $(patsubst test/%.src,out/test2/%.txt,$(SRCTESTS))
out/test/summary.txt: $(ALLTESTS)
@cat $(ALLTESTS) > out/test/summary.txt