changeset 75:edc279c4f7f9

makefile cleanup
author thomask
date Thu, 28 Oct 2004 06:07:57 +0000
parents 70e83b304ac7
children 5aab0626a3e9
files Makefile complex/command_line/complex.mak complex/debug/complex.mak complex/private_import/complex.mak complex/unittest/complex.mak
diffstat 5 files changed, 84 insertions(+), 153 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Thu Oct 28 06:07:37 2004 +0000
+++ b/Makefile	Thu Oct 28 06:07:57 2004 +0000
@@ -68,10 +68,8 @@
 # settings
 to_log = >> $(LOG) 2>&1
 ext_run = exe
-ext_unittest_run = unittest.$(ext_run)
 ext_norun = bin
 ext_nocompile = no
-ext_unittest_nocompile = unittest.$(ext_nocompile)
 ext_compile = o
 ext_source = d
 ext_source_html = html
@@ -110,84 +108,62 @@
 #
 nocompile : Makefile $(sort $(subst .$(ext_source),.$(ext_nocompile),$(shell $(FIND) nocompile -regex ".*\\.$(ext_source)" ) ) $(subst .$(ext_source_html),.$(ext_nocompile),$(shell $(FIND) nocompile -regex ".*\\.$(ext_source_html)" ) ) )
 
-%.$(ext_nocompile) : %.$(ext_source) basic_tools
-	$(eval z_name = $(subst .$(ext_nocompile),,$@))
-	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -c -of$@ $< $(to_log)"))
-	@if $(ifeq__) $(z_return) 0 ; then \
-		$(ECHO) "XPASS: $(z_name)"; $(RM) $@; \
-	else \
-		if $(ifeq__) $(z_return) 256 ; then \
-			$(ECHO) "XFAIL: $(z_name)"; $(TOUCH) $@; \
-		else \
-			$(ECHO) "ERROR: $(z_name)"; $(RM) $@; \
-		fi \
-	fi
-
-%.$(ext_nocompile) : %.$(ext_source_html) basic_tools
-	$(eval z_name = $(subst .$(ext_nocompile),,$@))
-	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -c -of$@ $< $(to_log)"))
-	@if $(ifeq__) $(z_return) 0 ; then \
-		$(ECHO) "XPASS: $(z_name)"; $(RM) $@; \
-	else \
-		if $(ifeq__) $(z_return) 256 ; then \
-			$(ECHO) "XFAIL: $(z_name)"; $(TOUCH) $@; \
-		else \
-			$(ECHO) "ERROR: $(z_name)"; $(RM) $@; \
-		fi \
-	fi
-
-%.$(ext_unittest_nocompile) : %.$(ext_source) basic_tools
-	$(eval z_name = $(subst .$(ext_unittest_nocompile),,$@))
-	$(eval z_return = $(shell $(return__) "$(DMD) -unittest $(DFLAGS) -c -of$@ $< $(to_log)"))
+define analyse_nocompile
 	@if $(ifeq__) $(z_return) 0 ; then \
 		$(ECHO) "XPASS: $(z_name)"; $(RM) $@; \
 	else \
 		if $(ifeq__) $(z_return) 256 ; then \
 			$(ECHO) "XFAIL: $(z_name)"; $(TOUCH) $@; \
 		else \
-			$(ECHO) "ERROR: $(z_name)"; $(RM) $@; \
+			$(ECHO) "ERROR: $(z_name) [$(z_return)]"; $(RM) $@; \
 		fi \
 	fi
+endef
+
+%.$(ext_nocompile) : %.$(ext_source) basic_tools
+	$(eval z_name = $(subst .$(ext_nocompile),,$@))
+	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -c -of$@ $< $(to_log)"))
+	$(analyse_nocompile)
+
+%.$(ext_nocompile) : %.$(ext_source_html) basic_tools
+	$(eval z_name = $(subst .$(ext_nocompile),,$@))
+	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -c -of$@ $< $(to_log)"))
+	$(analyse_nocompile)
 
 #
 # target should compile (excludes linking)
 #
 compile : Makefile $(sort $(subst .$(ext_source),.$(ext_compile),$(shell $(FIND) compile -regex ".*\\.$(ext_source)" ) ) $(subst .$(ext_source_html),.$(ext_compile),$(shell $(FIND) compile -regex ".*\\.$(ext_source_html)" ) ) )
 
-%.$(ext_compile) : %.$(ext_source) basic_tools
-	$(eval z_name = $(subst .$(ext_compile),,$@))
-	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -c -of$@ $< $(to_log)"))
+define analyse_compile
 	@if $(ifeq__) $(z_return) 0 ; then \
 		$(ECHO) "PASS:  $(z_name)"; \
 	else \
 		if $(ifeq__) $(z_return) 256 ; then \
 			$(ECHO) "FAIL:  $(z_name)"; $(RM) $@; \
 		else \
-			$(ECHO) "ERROR: $(z_name)"; $(RM) $@; \
+			$(ECHO) "ERROR: $(z_name) [$(z_return)]"; $(RM) $@; \
 		fi \
 	fi
+endef
+
+%.$(ext_compile) : %.$(ext_source) basic_tools
+	$(eval z_name = $(subst .$(ext_compile),,$@))
+	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -c -of$@ $< $(to_log)"))
+	$(analyse_compile)
+
 
 %.$(ext_compile) : %.$(ext_source_html) basic_tools
 	$(eval z_name = $(subst .$(ext_compile),,$@))
 	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -c -of$@ $< $(to_log)"))
-	@if $(ifeq__) $(z_return) 0 ; then \
-		$(ECHO) "PASS:  $(z_name)"; \
-	else \
-		if $(ifeq__) $(z_return) 256 ; then \
-			$(ECHO) "FAIL:  $(z_name)"; $(RM) $@; \
-		else \
-			$(ECHO) "ERROR: $(z_name)"; $(RM) $@; \
-		fi \
-	fi
+	$(analyse_compile)
 
 # 
 # target should compile, link and run
 # 
 run : Makefile $(sort $(subst .$(ext_source),.$(ext_run),$(shell $(FIND) run -regex ".*\\.$(ext_source)" ) ) $(subst .$(ext_source_html),.$(ext_run),$(shell $(FIND) run -regex ".*\\.$(ext_source_html)" ) ) )
 
-%.$(ext_run) : %.$(ext_source) basic_tools
-	$(eval z_name = $(subst .$(ext_run),,$@))
-	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -od$(OBJ_DIR) -of$@ $< $(to_log)"))
+define analyse_run
 	@if $(ifeq__) $(z_return) 0 ; then \
 		if ./$@ $(to_log); then \
 			$(ECHO) "PASS:  $(z_name)"; \
@@ -198,52 +174,27 @@
 		if $(ifeq__) $(z_return) 256 ; then \
 			$(ECHO) "FAIL:  $(z_name) (compiling error)"; \
 		else \
-			$(ECHO) "ERROR: $(z_name)"; \
+			$(ECHO) "ERROR: $(z_name) [$(z_return)]"; \
 		fi \
 	fi
+endef
 
-%.$(ext_unittest_run) :  %.$(ext_source) basic_tools
+%.$(ext_run) : %.$(ext_source) basic_tools
 	$(eval z_name = $(subst .$(ext_run),,$@))
-	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -unittest -od$(OBJ_DIR) -of$@ $< $(to_log)"))
-	@if $(ifeq__) $(z_return) 0 ; then \
-		if ./$@ $(to_log); then \
-			$(ECHO) "PASS:  $(z_name)"; \
-		else \
-			$(ECHO) "FAIL:  $(z_name)"; $(RM) $@; \
-		fi \
-	else \
-		if $(ifeq__) $(z_return) 256 ; then \
-			$(ECHO) "FAIL:  $(z_name) (compiling error)"; \
-		else \
-			$(ECHO) "ERROR: $(z_name)"; \
-		fi \
-	fi
+	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -od$(OBJ_DIR) -of$@ $< $(to_log)"))
+	$(analyse_run)
 
 %.$(ext_run) : %.$(ext_source_html) basic_tools
 	$(eval z_name = $(subst .$(ext_run),,$@))
 	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -od$(OBJ_DIR) -of$@ $< $(to_log)"))
-	@if $(ifeq__) $(z_return) 0 ; then \
-		if ./$@ $(to_log); then \
-			$(ECHO) "PASS:  $(z_name)"; \
-		else \
-			$(ECHO) "FAIL:  $(z_name)"; $(RM) $@; \
-		fi \
-	else \
-		if $(ifeq__) $(z_return) 256 ; then \
-			$(ECHO) "FAIL:  $(z_name) (compiling error)"; \
-		else \
-			$(ECHO) "ERROR: $(z_name)"; \
-		fi \
-	fi
+	$(analyse_run)
 
 #
 # target should compile and link but fail to run
 # 
 norun : Makefile $(sort $(subst .$(ext_source),.$(ext_norun),$(shell $(FIND) norun -regex ".*\\.$(ext_source)" ) ) $(subst .$(ext_source_html),.$(ext_norun),$(shell $(FIND) norun -regex ".*\\.$(ext_source_html)" ) ) )
 
-%.$(ext_norun) : %.$(ext_source) basic_tools
-	$(eval z_name = $(subst .$(ext_norun),,$@))
-	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -od$(OBJ_DIR) -of$@ $< $(to_log)"))
+define analyse_norun
 	@if $(ifeq__) $(z_return) 0; then \
 		if ./$@ $(to_log); \
 			then $(ECHO) "XPASS: $(z_name)"; $(RM) $@; \
@@ -254,26 +205,21 @@
 		if $(ifeq__) $(z_return) 256 ; then \
 			$(ECHO) "FAIL:  $(z_name) (compiling error)"; $(RM) $@; \
 		else \
-			$(ECHO) "ERROR: $(z_name)"; \
+			$(ECHO) "ERROR: $(z_name) [$(z_return)]"; \
 		fi \
 	fi
+endef
+
+%.$(ext_norun) : %.$(ext_source) basic_tools
+	$(eval z_name = $(subst .$(ext_norun),,$@))
+	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -od$(OBJ_DIR) -of$@ $< $(to_log)"))
+	$(analyse_norun)
 
 %.$(ext_norun) : %.$(ext_source_html) Makefile 
 	$(eval z_name = $(subst .$(ext_norun),,$@))
 	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -od$(OBJ_DIR) -of$@ $< $(to_log)"))
-	@if $(ifeq__) $(z_return) 0; then \
-		if ./$@ $(to_log); \
-			then $(ECHO) "XPASS: $(z_name)"; $(RM) $@; \
-		else \
-			$(ECHO) "XFAIL: $(z_name)"; \
-		fi \
-	else \
-		if $(ifeq__) $(z_return) 256 ; then \
-			$(ECHO) "FAIL:  $(z_name) (compiling error)"; $(RM) $@; \
-		else \
-			$(ECHO) "ERROR: $(z_name)"; \
-		fi \
-	fi
+	$(analyse_norun)
+
 
 #
 # run all complex test cases
--- a/complex/command_line/complex.mak	Thu Oct 28 06:07:37 2004 +0000
+++ b/complex/command_line/complex.mak	Thu Oct 28 06:07:57 2004 +0000
@@ -22,7 +22,7 @@
 	complex/command_line/clean
 
 complex/command_line/warning :
-	@echo "don't invoke this file directly, instead use DStress' root Makefile with the target \"coplex/command_line/coplex.done\", \"complex\" or \"all\""
+	@echo "don't invoke this file directly, instead use DStress' root Makefile with the target \"complex/command_line/complex.done\", \"complex\" or \"all\""
 
 #
 # name__command__line__arguments.cmdrun
@@ -53,29 +53,23 @@
 # try running with "dummy.d" as the source
 # (should succeed)
 # 
-%.cmdrun : complex/command_line/dummy.$(ext_source)
+%.cmdrun : complex/command_line/dummy.$(ext_source) basic_tools
 	$(eval z_raw = $(subst __, ,$*))
 	$(eval z_name = $(word 1,$(z_raw)))
 	$(eval z_arg = $(subst $(z_name),,$(z_raw)))
-	@if $(DMD) $(z_arg) complex/command_line/dummy.$(ext_source) $(to_log); then \
-		$(ECHO) "PASS:  $(z_name)"; \
-	else \
-		$(ECHO) "FAIL: $(z_name)"; \
-	fi
+	$(eval z_return = $(shell $(return__) "$(DMD) $(z_arg) complex/command_line/dummy.$(ext_source) $(to_log)"))
+	$(analyse_compile)
 
 #
 # try running with "dummy.d" as the source
 # (should fail)
 #
-%.cmdfail : complex/command_line/dummy.$(ext_source)
+%.cmdfail : complex/command_line/dummy.$(ext_source) basic_tools
 	$(eval z_raw = $(subst __, ,$*))
 	$(eval z_name = $(word 1,$(z_raw)))
 	$(eval z_arg = $(subst $(z_name),,$(z_raw)))
-	@if $(DMD) $(z_arg) complex/command_line/dummy.$(ext_source) $(to_log); then \
-		$(ECHO) "XPASS: $(z_name)"; \
-	else \
-		$(ECHO) "XFAIL:  $(z_name)"; \
-	fi
+	$(eval z_return = $(shell $(return__) "$(DMD) $(z_arg) complex/command_line/dummy.$(ext_source) $(to_log)"))
+	$(analyse_nocompile)
 
 #
 # try running without any additional source agruments
@@ -88,10 +82,10 @@
 	@if $(CD) complex/command_line ; $(DMD) $(z_arg) $(to_log); then \
 		$(ECHO) "XPASS: $(z_name)"; \
 	else \
-		$(ECHO) "XFAIL:  $(z_name)"; \
-	fi	
+		$(ECHO) "XFAIL: $(z_name)"; \
+	fi 
 	
 # this will be called by root's "clean" target
 complex/command_line/clean :
-	$(RM) complex/command_line/*.done complex/command_line/*.xxxx complex/command_line/*.$(ext_compile) complex/command_line/.?*$(ext_compile)
+	$(RM) complex/command_line/*.done complex/command_line/*.xxxx complex/command_line/*.$(ext_compile) complex/command_line/.?*$(ext_compile) complex/command_line/?*.cmdnullfail
 
--- a/complex/debug/complex.mak	Thu Oct 28 06:07:37 2004 +0000
+++ b/complex/debug/complex.mak	Thu Oct 28 06:07:57 2004 +0000
@@ -27,41 +27,20 @@
 # this will be called by root's "all" / "complex" target
 complex/debug/$(complex_done) : complex/debug/debug_01.$(ext_run) complex/debug/debug_02.$(ext_run) complex/debug/debug_03.$(ext_run)
 	
-complex/debug/debug_01.$(ext_run) :  complex/debug/debug_01.$(ext_source)
+complex/debug/debug_01.$(ext_run) :  complex/debug/debug_01.$(ext_source) basic_tools
 	$(eval z_name = $(subst .$(ext_run),,$@))
-	@if $(DMD) $(DFLAGS) -debug -od$(OBJ_DIR) -of$@ $< $(to_log); then \
-		if $@ $(to_log); then \
-			$(ECHO) "PASS:  $(z_name)"; \
-		else \
-			$(ECHO) "FAIL: $(z_name)"; $(RM) $@; \
-		fi \
-	else \
-		$(ECHO) "FAIL: $(z_name) (compiling error)"; \
-	fi
+	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -debug -od$(OBJ_DIR) -of$@ $< $(to_log)"))
+	$(analyse_run)
 
-complex/debug/debug_02.$(ext_run) :  complex/debug/debug_02.$(ext_source) complex/debug/$(complex_todo)
+complex/debug/debug_02.$(ext_run) :  complex/debug/debug_02.$(ext_source) basic_tools
 	$(eval z_name = $(subst .$(ext_run),,$@))
-	@if $(DMD) $(DFLAGS) -debug=2 -od$(OBJ_DIR) -of$@ $< $(to_log); then \
-		if $@ $(to_log); then \
-			$(ECHO) "PASS:  $(z_name)"; \
-		else \
-			$(ECHO) "FAIL: $(z_name)"; $(RM) $@; \
-		fi \
-	else \
-		$(ECHO) "FAIL: debug_02 (compiling error)"; \
-	fi
+	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -debug=2 -od$(OBJ_DIR) -of$@ $< $(to_log)"))
+	$(analyse_run)
 
-complex/debug/debug_03.$(ext_run) :  complex/debug/debug_03.$(ext_source) complex/debug/$(complex_todo)
+complex/debug/debug_03.$(ext_run) :  complex/debug/debug_03.$(ext_source) basic_tools
 	$(eval z_name = $(subst .$(ext_run),,$@))
-	@if $(DMD) $(DFLAGS) -debug=a -od$(OBJ_DIR) -of$@ $< $(to_log); then \
-		if $@ $(to_log); then \
-			$(ECHO) "PASS:  $(z_name)"; \
-		else \
-			$(ECHO) "FAIL: $(z_name)"; $(RM) $@; \
-		fi \
-	else \
-		$(ECHO) "FAIL: $(z_name) (compiling error)"; \
-	fi
+	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -debug=a -od$(OBJ_DIR) -of$@ $< $(to_log)"))
+	$(analyse_run)
 
 
 # this will be called by root's "clean" target
--- a/complex/private_import/complex.mak	Thu Oct 28 06:07:37 2004 +0000
+++ b/complex/private_import/complex.mak	Thu Oct 28 06:07:57 2004 +0000
@@ -30,24 +30,18 @@
 #
 # compile only the 3rd file
 #
-complex/private_import/private_import_01.done : complex/private_import/a.$(ext_source) complex/private_import/b.$(ext_source) complex/private_import/c.$(ext_source) complex/private_import/$(complex_todo)
+complex/private_import/private_import_01.done : complex/private_import/a.$(ext_source) complex/private_import/b.$(ext_source) complex/private_import/c.$(ext_source) complex/private_import/$(complex_todo) basic_tools
 	$(eval z_name = $(subst .done,,$@))
-	@if $(DMD) $(DFLAGS) -c -Icomplex/private_import/ -ofcomplex/private_import/c.$(ext_compile) complex/private_import/c.$(ext_source) $(to_log); then \
-		$(ECHO) "XPASS: $(z_name)"; \
-	else \
-		$(ECHO) "XFAIL:  $(z_name)"; $(TOUCH) $@; \
-	fi
+	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -c -Icomplex/private_import/ -ofcomplex/private_import/c.$(ext_compile) complex/private_import/c.$(ext_source) $(to_log)"))
+	$(analyse_nocompile)
 
 #
 # compile all 3 files at the same time
 #
-complex/private_import/private_import_02.done : complex/private_import/a.$(ext_source) complex/private_import/b.$(ext_source) complex/private_import/c.$(ext_source) complex/private_import/$(complex_todo)
+complex/private_import/private_import_02.done : complex/private_import/a.$(ext_source) complex/private_import/b.$(ext_source) complex/private_import/c.$(ext_source) complex/private_import/$(complex_todo) basic_tools
 	$(eval z_name = $(subst .done,,$@))
-	@if $(DMD) $(DFLAGS) -c -od$(OBJ_DIR) complex/private_import/a.$(ext_source) complex/private_import/b.$(ext_source) complex/private_import/c.$(ext_source) $(to_log); then \
-		$(ECHO) "XPASS: $(z_name)"; \
-	else \
-		$(ECHO) "XFAIL:  $(z_name)"; $(TOUCH) $@; \
-	fi
+	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -c -od$(OBJ_DIR) complex/private_import/a.$(ext_source) complex/private_import/b.$(ext_source) complex/private_import/c.$(ext_source) $(to_log)"))
+	$(analyse_nocompile)
 
 
 # this will be called by root's "clean" target
--- a/complex/unittest/complex.mak	Thu Oct 28 06:07:37 2004 +0000
+++ b/complex/unittest/complex.mak	Thu Oct 28 06:07:57 2004 +0000
@@ -26,7 +26,8 @@
 complex/unittest/warning :
 	@echo "don't invoke this file directly, instead use DStress' root Makefile with the target \"complex/unittest/complex.done\", \"complex\" or \"all\""
 
-ext_unittest_run = unit.$(ext_run)
+ext_unittest_run = unittest.$(ext_run)
+ext_unittest_nocompile = unittest.$(ext_nocompile)
 
 # this will be called by root's "all" / "complex" target
 complex/unittest/$(complex_done) : complex/unittest/run complex/unittest/nocompile
@@ -35,6 +36,23 @@
 
 complex/unittest/nocompile : $(sort $(subst .$(ext_source),.$(ext_unittest_nocompile),$(shell $(FIND) complex/unittest/nocompile -regex ".*\\.$(ext_source)" )))
 
+#
+# target should fail to compile
+#
+%.$(ext_unittest_nocompile) : %.$(ext_source) basic_tools
+	$(eval z_name = $(subst .$(ext_unittest_nocompile),,$@))
+	$(eval z_return = $(shell $(return__) "$(DMD) -unittest $(DFLAGS) -c -of$@ $< $(to_log)"))
+	$(analyse_nocompile)
+
+# 
+# target should compile, link and run
+# 
+%.$(ext_unittest_run) :  %.$(ext_source) basic_tools
+	$(eval z_name = $(subst .$(ext_unittest_run),,$@))
+	$(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -unittest -od$(OBJ_DIR) -of$@ $< $(to_log)"))
+	$(analyse_run)
+
+
 # this will be called by root's "clean" target
 complex/unittest/clean :
 	$(RM) complex/unittest/$(complex_done) complex/unittest/run/*.$(ext_unittest_run) complex/unittest/nocompile/?*.$(ext_nocompile)