divert(-1) changequote([,]) divert(0) # rules cflags = -Wall -Wextra -g -I. bin = bin leak = valgrind -s --leak-check=full --show-leak-kinds=all rule cc depfile = $out.d command = gcc -MD -MF $out.d $cflags $in -o $out rule shared depfile = $out.d command = gcc -MD -MF $out.d $cflags -shared -fPIC $in -o $out rule m4 command = m4 $m4flags $in > $out build $bin/generate-parser: cc demos/generate-parser.c cflags = $cflags -rdynamic rule parser_gen command = $leak $bin/generate-parser -o $$(echo $out | cut -f1 -d'.') -t $tabletype $in define([gbuild], [ifelse( [$1], [from-gram], [ build $bin/$2-gram.c: gram_parse $3/$2.g | $bin/gram-parser build $bin/$2-gram.so: shared $bin/$2-gram.c], [$1], [from-defs], [ build $bin/$2-gram.so: shared $3/$2-defs.c]) build $bin/$2.c $bin/$2.h: parser_gen $bin/$2-gram.so | $bin/generate-parser tables tabletype = lalr-table build $bin/$2-parser: cc $3/$2-skeleton.c $5 | $bin/$2.c $bin/$2.h build $2: phony $bin/$2-parser ]) # building tools build $bin/slr-table.so: shared slr-table.c build $bin/clr-table.so: shared clr-table.c build $bin/lalr-table.so: shared clr-table.c cflags = $cflags -D_LAZY_LALR build tables: phony $bin/slr-table.so $bin/clr-table.so $bin/lalr-table.so gbuild(from-defs, gram, demos/sample-files, lalr-table) rule gram_parse command = $leak $bin/gram-parser < $in > $out # build actual gbuild(from-gram, lbp, demos/sample-files, lalr-table, util/dict.c) rule lbp_parse command = $leak $bin/lbp-parser < $in build lbp_test: lbp_parse demos/sample-files/lbp-code.lbp | lbp gbuild(from-gram, calc, demos/sample-files, lalr-table) # skeleton doesn't work rule calc_parse command = $leak $bin/calc-parser 5+3 build calc_test: calc_parse | calc # targets rule ninja_clean command = ninja -t clean build clean: ninja_clean default lbp_test # regeneration rule regen command = m4 ninja.m4 > build.ninja generator = 1 description = Regen build.ninja build build.ninja: regen ninja.m4 build configure: regen