about summary refs log tree commit diff stats
path: root/cpp/makefile
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/makefile')
-rw-r--r--cpp/makefile37
1 files changed, 19 insertions, 18 deletions
diff --git a/cpp/makefile b/cpp/makefile
index 0dcdbce5..97187383 100644
--- a/cpp/makefile
+++ b/cpp/makefile
@@ -1,25 +1,26 @@
-mu: makefile type_list function_list file_list test_file_list test_list
-	g++ -O3 -Wall -Wextra -fno-strict-aliasing boot.cc -o mu
+mu: makefile tangle/tangle mu.cc
+	g++ -g -Wall -Wextra -fno-strict-aliasing mu.cc -o mu
+	-@./mu test
 
-type_list: boot.cc [0-9]*.cc
-	@# assumes struct decl has space before '{'
-	@grep -h "^struct .* {" [0-9]*.cc |perl -pwe 's/(struct *[^ ]*).*/$$1;/' > type_list
-	@grep -h typedef [0-9]*.cc >> type_list
+# To see what the program looks like after all layers have been applied, read
+# mu.cc
+mu.cc: 0*
+	./tangle/tangle --until 999 > mu.cc
+	@make autogenerated_lists >/dev/null
 
-function_list: boot.cc [0-9]*.cc
-	@# assumes function decl has space before '{'
-	@grep -h "^[^ #].*) {" [0-9]*.cc |perl -pwe 's/ {.*/;/' > function_list
-	@grep -h "^[[:space:]]*TEST(" [0-9]*.cc |perl -pwe 's/^\s*TEST\((.*)\)$$/void test_$$1();/' >> function_list
+tangle/tangle:
+	cd tangle && make
 
-file_list: boot.cc [0-9]*.cc
-	@ls [0-9]*.cc |grep -v "\.test\.cc$$" |perl -pwe 's/.*/#include "$$&"/' > file_list
+# auto-generated files; by convention they end in '_list'.
+.PHONY: autogenerated_lists
+autogenerated_lists: mu.cc function_list test_list
 
-test_file_list: [0-9]*.test.cc
-	@ls [0-9]*.test.cc |perl -pwe 's/.*/#include "$$&"/' > test_file_list
+function_list: mu.cc
+	@grep -h "^[^ #].*) {" mu.cc |perl -pwe 's/ {.*/;/' > function_list
 
-test_list: [0-9]*.cc
-	@grep -h "^[[:space:]]*void test_" [0-9]*.cc |perl -pwe 's/^\s*void (.*)\(\) {$$/$$1,/' > test_list
-	@grep -h "^[[:space:]]*TEST(" [0-9]*.cc |perl -pwe 's/^\s*TEST\((.*)\)$$/test_$$1,/' >> test_list
+test_list: mu.cc
+	@grep -h "^[[:space:]]*void test_" mu.cc |perl -pwe 's/^\s*void (.*)\(\) {.*/$$1,/' > test_list
 
 clean:
-	rm -rf mu* *_list
+	cd tangle && make clean
+	rm -rf mu.cc mu *_list