X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=exercises%2Fch01%2FMakefile;h=8587a0482c1819fa2fb0110d9df2b33b191d0a98;hb=958f72687df932030c5dfafc7066889982497729;hp=d376e05c2f3ed048bf478b7be4f7e224694b711d;hpb=b743073dd14888990ca5a144e3b745ff9e4f4d84;p=tiger.ml.git diff --git a/exercises/ch01/Makefile b/exercises/ch01/Makefile index d376e05..8587a04 100644 --- a/exercises/ch01/Makefile +++ b/exercises/ch01/Makefile @@ -4,27 +4,51 @@ OCAMLC_OPTIONS := -w A -warn-error A OCAMLC_BYTE := ocamlc.opt $(OCAMLC_OPTIONS) EXECUTABLES := \ - straight_line_program_interpreter \ - tree + straight_line_program_interpreter \ + tree_demo +EXECUTABLES := $(addsuffix .byte,$(EXECUTABLES)) -.PHONY: build clean demo_unbalanced +SET_MEMBERS := \ + a b c d e f g h i j k l m n o p q r s t u v foo bar kgkvbkvg \ + lkhjlk gfjyfjf fdtrdchfhtr trhfgfch hjlilijhl iygkyugkgkhy -build : $(EXECUTABLES) -%: %.ml %.cmo %.cmi - $(OCAMLC_BYTE) -o $@ $*.cmo +.PHONY: \ + all \ + clean \ + build \ + demos -%.cmi: %.mli - $(OCAMLC_BYTE) -o $@ -c $< - -%.cmo: %.ml %.cmi - $(OCAMLC_BYTE) -c $< +all: + $(MAKE) clean + $(MAKE) build + $(MAKE) demos clean: + rm -rf ./_build/ rm -f $(EXECUTABLES) + # There're also tree demo PNGs, but I want to keep them around, for + # referencing without having to build the project. + +build: + ocamlbuild $(EXECUTABLES) + +demos: \ + run_straight_line_program_interpreter \ + tree_demo_unbalanced.png \ + tree_demo_balanced.png + +run_straight_line_program_interpreter: straight_line_program_interpreter.byte + ./$< + +tree_demo_unbalanced.dot: tree_demo.byte + ./$< unbalanced $(SET_MEMBERS) > $@ + +tree_demo_unbalanced.png: tree_demo_unbalanced.dot + neato -T png $< > $@ -tree.png: tree - ./tree a b c d e f g h i j k l m n o p q r s t u v foo bar kgkvbkvg lkhjlk gfjyfjf fdtrdchfhtr trhfgfch hjlilijhl iygkyugkgkhy | neato -T png > tree.png +tree_demo_balanced.dot: tree_demo.byte + ./$< balanced $(SET_MEMBERS) > $@ -demo_unbalanced: tree.png - sxiv ./tree.png +tree_demo_balanced.png: tree_demo_balanced.dot + neato -T png $< > $@