-.PHONY: clean default
-
-## Special targets to build a program from multiple source files
-##
-ifdef PROG
- default: $(PROG)
- .SECONDARY: $(PROG).clean.bc ## keep %.clean.bc from being deleted
-
- $(PROG).bc: $(OBJS)
- $(LLINK) -f $(OBJS) -o $@
+##----------------------------------------------------------*- Makefile -*-===##
+##
+## Common rules for generating, linking, and compiling via LLVM. This is
+## used to implement a robust testing framework for LLVM
+##
+##-------------------------------------------------------------------------===##
+
+# If the user specified a TEST= option on the command line, we do not want to do
+# the default testing type. Instead, we change the default target to be the
+# test:: target.
+#
+ifdef TEST
+test::