X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=exercises%2Fch01%2FMakefile;h=8587a0482c1819fa2fb0110d9df2b33b191d0a98;hb=fd2204fa98928a900f303209818dce7f2bae3c8a;hp=fa3761e53e4875b40e877bad083ae4879774942d;hpb=88cc262a0a05de03560b35950b763f41717b79b1;p=tiger.ml.git diff --git a/exercises/ch01/Makefile b/exercises/ch01/Makefile index fa3761e..8587a04 100644 --- a/exercises/ch01/Makefile +++ b/exercises/ch01/Makefile @@ -4,42 +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 $< +all: + $(MAKE) clean + $(MAKE) build + $(MAKE) demos -%.cmo: %.ml %.cmi - $(OCAMLC_BYTE) -c $< - -tree : tree.ml tree.cmo tree_sig.cmo tree_unbalanced_vanilla.cmo tree_balanced_red_black.cmo - $(OCAMLC_BYTE) -o tree tree_sig.cmo tree_unbalanced_vanilla.cmo tree_balanced_red_black.cmo tree.cmo +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. -tree.cmo : tree.ml tree.cmi tree_sig.cmo tree_unbalanced_vanilla.cmo tree_balanced_red_black.cmo - $(OCAMLC_BYTE) -c $< +build: + ocamlbuild $(EXECUTABLES) -tree_balanced_red_black.cmo : tree_balanced_red_black.ml tree_balanced_red_black.cmi tree_sig.cmo - ocamlc.opt -w A -warn-error A-4 -c $< +demos: \ + run_straight_line_program_interpreter \ + tree_demo_unbalanced.png \ + tree_demo_balanced.png -tree_sig.cmo tree_sig.cmi: tree_sig.ml - $(OCAMLC_BYTE) -c $< +run_straight_line_program_interpreter: straight_line_program_interpreter.byte + ./$< -clean: - rm -f $(EXECUTABLES) tree.dot # There's also tree.png, but I'm keeping it. +tree_demo_unbalanced.dot: tree_demo.byte + ./$< unbalanced $(SET_MEMBERS) > $@ -tree.dot: 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 > tree.dot +tree_demo_unbalanced.png: tree_demo_unbalanced.dot + neato -T png $< > $@ -tree.png: tree.dot - neato -T png tree.dot > 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 $< > $@