about summary refs log tree commit diff stats
path: root/makefile
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-08-14 21:35:25 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-08-14 21:35:25 -0700
commite53787f51a058270c6125be35172d8fb6341a549 (patch)
tree7c87f91ec5a26035876b20bbdb84f06a01feebba /makefile
parente74a2940522e37d63043f662f38fba3620c01780 (diff)
downloadmu-e53787f51a058270c6125be35172d8fb6341a549.tar.gz
2001
Let's stop hackily editing compiler flags in makefile.

I considered modifying the 'mu' script as well, with cases like this:
  1. mu test -- don't optimize
  2. mu test edit.mu -- optimize
  3. mu test edit.mu just-one-test -- don't optimize
  4. mu edit.mu -- interactive; optimize
  5. mu -- just help message; don't optimize

But that seems brittle for all the added complexity. From now on to
build quickly just do:

  $ make dbg && mu test

etc.
Diffstat (limited to 'makefile')
-rw-r--r--makefile58
1 files changed, 31 insertions, 27 deletions
diff --git a/makefile b/makefile
index 3c45c949..26259a40 100644
--- a/makefile
+++ b/makefile
@@ -1,7 +1,7 @@
 all: mu_bin core.mu
 
 mu_bin: makefile enumerate/enumerate tangle/tangle mu.cc termbox/libtermbox.a
-	c++ -g -O3 -Wall -Wextra -fno-strict-aliasing mu.cc termbox/libtermbox.a -o mu_bin
+	@make --no-print-directory dbg+opt
 
 # To see what the program looks like after all layers have been applied, read
 # mu.cc
@@ -21,32 +21,6 @@ tangle/tangle:
 termbox/libtermbox.a: termbox/*.c termbox/*.h termbox/*.inl
 	cd termbox && make
 
-.PHONY: all autogenerated_lists test valgrind clang opt clang+opt clena
-
-test: mu_bin core.mu
-	./mu_bin test
-
-valgrind: clang+opt
-	valgrind --leak-check=yes -q --error-exitcode=1 ./mu_bin test
-
-clang: makefile mu.cc termbox/libtermbox.a autogenerated_lists
-	clang++ -g -fsanitize=undefined mu.cc termbox/libtermbox.a -o mu_bin
-
-clang+opt: makefile mu.cc termbox/libtermbox.a autogenerated_lists
-	clang++ -O3 -fsanitize=undefined mu.cc termbox/libtermbox.a -o mu_bin
-
-opt: makefile enumerate/enumerate tangle/tangle mu.cc termbox/libtermbox.a autogenerated_lists
-	c++ -O3 -Wall -Wextra -fno-strict-aliasing mu.cc termbox/libtermbox.a -o mu_bin
-
-prof: makefile enumerate/enumerate tangle/tangle mu.cc termbox/libtermbox.a autogenerated_lists
-	c++ -pg -Wall -Wextra -fno-strict-aliasing mu.cc termbox/libtermbox.a -o mu_bin
-
-opt+prof: makefile enumerate/enumerate tangle/tangle mu.cc termbox/libtermbox.a autogenerated_lists
-	c++ -O3 -pg -Wall -Wextra -fno-strict-aliasing mu.cc termbox/libtermbox.a -o mu_bin
-
-dbg+opt+prof: makefile enumerate/enumerate tangle/tangle mu.cc termbox/libtermbox.a autogenerated_lists
-	c++ -g -O3 -pg -Wall -Wextra -fno-strict-aliasing mu.cc termbox/libtermbox.a -o mu_bin
-
 # auto-generated files; by convention they end in '_list'.
 autogenerated_lists: mu.cc function_list test_list
 
@@ -66,6 +40,36 @@ 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
 
+# turning optimizations/profiling/sanitization-checking on/off
+.PHONY: all autogenerated_lists test valgrind clang dbg opt prof opt+prof dbg+opt+prof clang+opt clena
+
+dbg:
+	c++ -g -Wall -Wextra -fno-strict-aliasing mu.cc termbox/libtermbox.a -o mu_bin
+
+opt:
+	c++ -O3 -Wall -Wextra -fno-strict-aliasing mu.cc termbox/libtermbox.a -o mu_bin
+
+dbg+opt:
+	c++ -g -O3 -Wall -Wextra -fno-strict-aliasing mu.cc termbox/libtermbox.a -o mu_bin
+
+prof:
+	c++ -pg -Wall -Wextra -fno-strict-aliasing mu.cc termbox/libtermbox.a -o mu_bin
+
+opt+prof:
+	c++ -O3 -pg -Wall -Wextra -fno-strict-aliasing mu.cc termbox/libtermbox.a -o mu_bin
+
+dbg+opt+prof:
+	c++ -g -O3 -pg -Wall -Wextra -fno-strict-aliasing mu.cc termbox/libtermbox.a -o mu_bin
+
+clang:
+	clang++ -g -fsanitize=undefined mu.cc termbox/libtermbox.a -o mu_bin
+
+clang+opt:
+	clang++ -O3 -fsanitize=undefined mu.cc termbox/libtermbox.a -o mu_bin
+
+valgrind: clang+opt
+	valgrind --leak-check=yes -q --error-exitcode=1 ./mu_bin test
+
 clena: clean
 clean:
 	cd enumerate && make clean