[56e3db]: / Makefile  Maximize  Restore  History

Download this file

79 lines (60 with data), 1.6 kB

 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
C2IEC=c2iec
TESTS=$(patsubst %.c, %.test, $(wildcard test/*.c))
TEST_LOGS=$(patsubst %.c, %.test.log, $(wildcard test/*.c))
CC?=gcc
EMCC?=emcc
# if parameter "DEBUG" is set, we set debug flags for lex/yacc
ifneq (${DEBUG},)
DEBUG_FLAGS += -d
CFLAGS += -DDEBUG
endif
all: ${C2IEC} ${C2IEC}.js ${C2IEC}.wasm ${C2IEC}.html
${C2IEC}: lex.yy.c y.tab.c
$(CC) ${CFLAGS} -o $@ $^
${C2IEC}.js: lex.yy.c y.tab.c
${EMCC} ${CFLAGS} -o $@ $^
${C2IEC}.wasm ${C2IEC}.html: lex.yy.c y.tab.c
${EMCC} ${CFLAGS} -s WASM=1 -o $@ $^
lex.yy.c: ${C2IEC}.l
flex ${DEBUG_FLAGS} $^
y.tab.c: ${C2IEC}.y
yacc -dy ${DEBUG_FLAGS} $^
y.dot: ${C2IEC}.y
yacc -g $^
commit: ${TEST_LOGS}
for i in ${TEST_LOGS}; do \
cp $$i $$(dirname $$i)/$$(basename $$i .log).expected; \
done
clean:
rm -f ${C2IEC}
rm -f ${TEST_LOGS}
rm -f lex.yy.c
rm -f y.tab.c
.PHONY: test
test: ${TESTS}
%.test: %.test.log
@echo "========================================"
@echo "checking output of test $*"
@diff -u $*.test.expected $< || cat $<
%.test.log: %.test.txt
@echo "========================================"
@echo "output of test $*"
@echo "========================================"
@cat $< | tee $@
%.test.txt: %.c ${C2IEC}
./${C2IEC} < $< > $@
# preprocessing rule for foreign code (to test)
%.pre.c: %.c
gcc -o $@ \
-Ispark \
-D__builtin_va_list=int \
-D"__extension__=" \
-D"__signed__=signed" \
-D"__inline=" \
-D"__inline__=" \
-D"__attribute__(...)=" \
-D"__alignof__(...)=4" \
-D"__asm__(...)={}" \
-D"__uint128_t=long long" \
-E \
$<