C2IEC=c99
TEST_LOGS=$(patsubst %.c, %.test.log, $(wildcard test/*.c))

check:
	echo ${TEST_LOGS}

all: c99

c99: lex.yy.c y.tab.c
	gcc -o $@ $^

lex.yy.c: c99.l
	flex $^

y.tab.c: c99.y
	yacc -d $^

y.dot: c99.y
	yacc -g $^


.PHONY: test
test: ${TEST_LOGS}
	grep failed $^ && false || true

%.test.log: %.test.txt
	cat $< | tee $@

%.test.txt: %.c ${C2IEC}
	./${C2IEC} < $< > $@

test2: c99
	./c99 < test2.c

test3: c99
	./c99 < test3.c

