CFLAGS=-Wall -O3

SRC=HEADER.html Makefile brew-sequences.c gforth9.burg gforth9.c gforth9.h main.c

test: gforth9 brew-sequences.bin
	for i in 0 1 2 3 4 5 6 7 8; do  gforth9 brew-sequences.bin test.rules test.costs $$i; cmp test.costs brew-sequences$$i.costs; done

perf: gforth9 brew-sequences.bin
	perf stat -r 10 -e cycles:u -e instructions:u -e branch-misses:u -e L1-dcache-load-misses:u gforth9 brew-sequences.bin test.rules test.costs 0

dist:  gforth9 brew-sequences.bin
	for i in 0 1 2 3 4 5 6 7 8; do  gforth9 brew-sequences.bin brew-sequences$$i.rules brew-sequences$$i.costs $$i; done
	rm -rf effizienz-aufgabe20
	mkdir effizienz-aufgabe20
	cp -p $(SRC) brew-sequences*.costs brew-sequences.bin effizienz-aufgabe20
	tar cfJ effizienz-aufgabe20.tar.xz effizienz-aufgabe20

gforth9: gforth9.o main.o
	gcc -o $@ gforth9.o main.o

gforth9.c: gforth9.burg
	iburg -I <$< >$@

gforth9.o: gforth9.c gforth9.h

main.o: main.c gforth9.h

brew-sequences: brew-sequences.c

brew-sequences.bin: brew-sequences
	brew-sequences

clean:
	rm *.o gforth9.c brew-sequences brew-sequences.bin gforth9
