about summary refs log tree commit diff stats
path: root/makefile
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-05 21:17:24 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-05 21:17:24 -0700
commitb96af395b9af2ff9df94b3e82213171f30827c8d (patch)
tree17c8c12648ccc25625e2534ec8d74fbe8f1542cc /makefile
parent2e3b597fe85b654e82b891c22d50754fa5a26156 (diff)
downloadmu-b96af395b9af2ff9df94b3e82213171f30827c8d.tar.gz
1276 - make C++ version the default
I've tried to update the Readme, but there are at least a couple of issues.
Diffstat (limited to 'makefile')
-rw-r--r--makefile52
1 files changed, 52 insertions, 0 deletions
diff --git a/makefile b/makefile
new file mode 100644
index 00000000..9ef7c92c
--- /dev/null
+++ b/makefile
@@ -0,0 +1,52 @@
+mu: makefile enumerate/enumerate tangle/tangle mu.cc termbox/libtermbox.a
+	@make autogenerated_lists >/dev/null
+	g++ -g -Wall -Wextra -fno-strict-aliasing mu.cc termbox/libtermbox.a -o mu
+
+# To see what the program looks like after all layers have been applied, read
+# mu.cc
+mu.cc: 0*
+	./tangle/tangle $$(./enumerate/enumerate --until 9999 |grep -v '.mu$$') > mu.cc
+	cat $$(./enumerate/enumerate --until 9999 |grep '.mu$$') > core.mu
+
+enumerate/enumerate:
+	cd enumerate && make && ./enumerate test
+
+tangle/tangle:
+	cd tangle && make && ./tangle test
+
+termbox/libtermbox.a:
+	cd termbox && make
+
+.PHONY: autogenerated_lists test valgrind clena
+
+test: mu
+	./mu test
+
+valgrind: mu
+	valgrind --leak-check=yes -q --error-exitcode=1 ./mu test
+
+# auto-generated files; by convention they end in '_list'.
+autogenerated_lists: mu.cc function_list test_list
+
+# autogenerated list of function declarations, so I can define them in any order
+function_list: mu.cc
+	# functions start out unindented, have all args on the same line, and end in ') {'
+	#  																		ignore methods
+	@grep -h "^[^[:space:]#].*) {" mu.cc |grep -v ":.*(" |perl -pwe 's/ {.*/;/' > function_list
+	# occasionally we need to modify a declaration in a later layer without messing with ugly unbalanced brackets
+	# assume such functions move the '{' to column 0 of the very next line
+	@grep -v "^#line" mu.cc |grep -B1 "^{" |grep -v "^{" |perl -pwe 's/$$/;/' >> function_list
+	# test functions
+	@grep -h "^\s*TEST(" mu.cc |perl -pwe 's/^\s*TEST\((.*)\)$$/void test_$$1();/' >> function_list
+
+# autogenerated list of tests to run
+test_list: mu.cc
+	@grep -h "^\s*void test_" mu.cc |perl -pwe 's/^\s*void (.*)\(\) {.*/$$1,/' > test_list
+	@grep -h "^\s*TEST(" mu.cc |perl -pwe 's/^\s*TEST\((.*)\)$$/test_$$1,/' >> test_list
+
+clena: clean
+clean:
+	cd enumerate && make clean
+	cd tangle && make clean
+	cd termbox && make clean
+	-rm mu.cc core.mu mu *_list