Makefile (1797B)
1 .PRECIOUS: out/%.impl.c out/%.type.h out/%.decl.h 2 3 all: out/compiler0 out/compiler1 4 5 test: out/test/summary.txt 6 7 # compiler0: bootstrap SPL->C transpiler 8 # 9 out/compiler0: bootstrap/compiler0.c 10 @mkdir -p out 11 gcc -Wall -O0 -g -o out/compiler0 bootstrap/compiler0.c 12 13 14 # compiler1: SPL compiler written in SPL 15 # 16 COMPILER_SRC := compiler/stdlib.spl compiler/types.spl compiler/lexer.spl compiler/parser.spl compiler/main.spl 17 18 out/compiler1: $(COMPILER_SRC) ./out/compiler0 19 @mkdir -p out/ out/compiler 20 ./out/compiler0 -o out/compiler/compiler $(COMPILER_SRC) 21 gcc -g -O0 -Wall -I. -Ibootstrap/inc -Iout -o $@ out/compiler/compiler.impl.c 22 23 # rules for building out/.../foo.bin from .../foo.spl 24 # 25 out/%.impl.c out/%.type.h out/%.decl.h: %.spl ./out/compiler0 26 @mkdir -p $(dir $(patsubst %.spl,out/%.impl.c,$<)) 27 ./out/compiler0 -o $(patsubst %.spl,out/%,$<) $< 28 29 out/%.bin: out/%.impl.c out/%.type.h out/%.decl.h 30 gcc -g -O0 -Wall -I. -Ibootstrap/inc -Iout -o $@ $< 31 32 out/compiler2: out/compiler1 $(COMPILER_SRC) 33 out/compiler1 $(COMPILER_SRC) 34 35 clean:: 36 rm -rf bin out 37 38 # have to have two rules here otherwise tests without .log files 39 # fail to be compiled by the rule that depends on spl+log *or* 40 # we fail to depend on the .log for tests with both... 41 42 TESTDEPS := out/compiler0 build/runtest0 build/compile0 43 TESTDEPS += $(wildcard bootstrap/inc/*.h) $(wildcard bootstrap/inc/*.c) 44 45 out/test/%.txt: test/%.spl test/%.log $(TESTDEPS) 46 @mkdir -p out/test 47 @rm -f $@ 48 @build/runtest0 $< $@ 49 50 out/test/%.txt: test/%.spl $(TESTDEPS) 51 @mkdir -p out/test 52 @rm -f $@ 53 @build/runtest0 $< $@ 54 55 56 SRCTESTS := $(sort $(wildcard test/*.spl)) 57 ALLTESTS := $(patsubst test/%.spl,out/test/%.txt,$(SRCTESTS)) 58 59 out/test/summary.txt: $(ALLTESTS) 60 @cat $(ALLTESTS) > $@ 61 62 %: test/%.spl 63 @$(MAKE) $(patsubst %.spl,out/%.txt,$<)