r5257 jmb - in /trunk/libparserutils: Makefile Makefile-riscos build/Makefile.common test/Makefile

netsurf at semichrome.net netsurf at semichrome.net
Fri Sep 5 12:53:56 BST 2008


Author: jmb
Date: Fri Sep  5 06:53:56 2008
New Revision: 5257

URL: http://source.netsurf-browser.org?rev=5257&view=rev
Log:
Dependency tracking

Modified:
    trunk/libparserutils/Makefile
    trunk/libparserutils/Makefile-riscos
    trunk/libparserutils/build/Makefile.common
    trunk/libparserutils/test/Makefile

Modified: trunk/libparserutils/Makefile
URL: http://source.netsurf-browser.org/trunk/libparserutils/Makefile?rev=5257&r1=5256&r2=5257&view=diff
==============================================================================
--- trunk/libparserutils/Makefile (original)
+++ trunk/libparserutils/Makefile Fri Sep  5 06:53:56 2008
@@ -13,6 +13,7 @@
 PKGCONFIG := pkg-config
 INSTALL := install
 SED := sed
+TOUCH := touch
 LCOV := lcov
 GENHTML := genhtml
 
@@ -33,6 +34,7 @@
 ECHOFLAGS := 
 MAKEFLAGS :=
 PKGCONFIGFLAGS :=
+TOUCHFLAGS :=
 
 EXEEXT :=
 

Modified: trunk/libparserutils/Makefile-riscos
URL: http://source.netsurf-browser.org/trunk/libparserutils/Makefile-riscos?rev=5257&r1=5256&r2=5257&view=diff
==============================================================================
--- trunk/libparserutils/Makefile-riscos (original)
+++ trunk/libparserutils/Makefile-riscos Fri Sep  5 06:53:56 2008
@@ -16,6 +16,7 @@
 PKGCONFIG := $(GCCSDK_INSTALL_ENV)/ro-pkg-config
 INSTALL := install
 SED := sed
+TOUCH := touch
 LCOV := echo
 GENHTML := echo
 
@@ -37,6 +38,7 @@
 ECHOFLAGS := 
 MAKEFLAGS :=
 PKGCONFIGFLAGS :=
+TOUCHFLAGS :=
 
 EXEEXT := ,ff8
 

Modified: trunk/libparserutils/build/Makefile.common
URL: http://source.netsurf-browser.org/trunk/libparserutils/build/Makefile.common?rev=5257&r1=5256&r2=5257&view=diff
==============================================================================
--- trunk/libparserutils/build/Makefile.common (original)
+++ trunk/libparserutils/build/Makefile.common Fri Sep  5 06:53:56 2008
@@ -46,10 +46,11 @@
 
 # Rules
 release: setup $(addprefix $(RELEASEDIR)/,$(OBJECTS))
-	@$(AR) $(ARFLAGS) $(COMPONENT).a $(RELEASEDIR)/*
+	@$(AR) $(ARFLAGS) $(COMPONENT).a $(addprefix $(RELEASEDIR)/,$(OBJECTS))
 
 debug: setup $(addprefix $(DEBUGDIR)/,$(OBJECTS))
-	@$(AR) $(ARFLAGS) $(COMPONENT)-debug.a $(DEBUGDIR)/*
+	@$(AR) $(ARFLAGS) $(COMPONENT)-debug.a \
+			$(addprefix $(DEBUGDIR)/,$(OBJECTS))
 
 test: debug $(TARGET_TESTS)
 
@@ -83,8 +84,8 @@
 	-@$(RM) $(RMFLAGS) -r $(TOP)/dist
 
 setup:
-	@$(MKDIR) $(MKDIRFLAGS) $(RELEASEDIR)
-	@$(MKDIR) $(MKDIRFLAGS) $(DEBUGDIR)
+	@$(MKDIR) $(MKDIRFLAGS) $(RELEASEDIR)/deps
+	@$(MKDIR) $(MKDIRFLAGS) $(DEBUGDIR)/deps
 	@$(MKDIR) $(MKDIRFLAGS) $(COVERAGEDIR)
 
 export:
@@ -111,6 +112,34 @@
 	@$(RM) $(RMFLAGS) $(PREFIX)/lib/pkgconfig/$(COMPONENT).pc
 	@$(RM) $(RMFLAGS) -r $(PREFIX)/include/parserutils
 
+$(RELEASEDIR)/deps/created:
+	@$(MKDIR) $(MKDIRFLAGS) $(RELEASEDIR)/deps
+	@$(TOUCH) $(TOUCHFLAGS) $(RELEASEDIR)/deps/created
+
+$(DEBUGDIR)/deps/created:
+	@$(MKDIR) $(MKDIRFLAGS) $(DEBUGDIR)/deps
+	@$(TOUCH) $(TOUCHFLAGS) $(DEBUGDIR)/deps/created
+
+DEPFILES :=
+
+define do_dep
+DEPFILES += $(2)
+$$(RELEASEDIR)/deps/$(2): $$(RELEASEDIR)/deps/created $(1)
+	@$$(ECHO) $$(ECHOFLAGS) "DEP $(1)"
+	@$$(RM) $$(RMFLAGS) $$(RELEASEDIR)/deps/$(2)
+	@$$(CC) $$(RELEASECFLAGS) -MM -MT \
+		'$$(RELEASEDIR)/deps/$(2) $$(RELEASEDIR)/$(3)' \
+		-MF $$(RELEASEDIR)/deps/$(2) $(1)
+
+$$(DEBUGDIR)/deps/$(2): $$(DEBUGDIR)/deps/created $(1)
+	@$$(ECHO) $$(ECHOFLAGS) "DEP $(1)"
+	@$$(RM) $$(RMFLAGS) $$(DEBUGDIR)/deps/$(2)
+	@$$(CC) $$(DEBUGCFLAGS) -MM -MT \
+		'$$(DEBUGDIR)/deps/$(2) $$(DEBUGDIR)/$(3)' \
+		-MF $$(DEBUGDIR)/deps/$(2) $(1)
+
+endef
+
 # Finally, build rules for compilation
 define do_compile
 $$(RELEASEDIR)/$(2): $(1)
@@ -124,5 +153,13 @@
 endef
 
 $(eval $(foreach SOURCE,$(filter %.c,$(SOURCES)), \
+	$(call do_dep,$(SOURCE),$(subst /,_,$(SOURCE:.c=.d)),$(subst /,_,$(SOURCE:.c=.o)))))
+
+ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
+-include $(sort $(addprefix $(RELEASEDIR)/deps/,$(DEPFILES)))
+-include $(sort $(addprefix $(DEBUGDIR)/deps/,$(DEPFILES)))
+endif
+
+$(eval $(foreach SOURCE,$(filter %.c,$(SOURCES)), \
 	$(call do_compile,$(SOURCE),$(subst /,_,$(SOURCE:.c=.o)))))
 

Modified: trunk/libparserutils/test/Makefile
URL: http://source.netsurf-browser.org/trunk/libparserutils/test/Makefile?rev=5257&r1=5256&r2=5257&view=diff
==============================================================================
--- trunk/libparserutils/test/Makefile (original)
+++ trunk/libparserutils/test/Makefile Fri Sep  5 06:53:56 2008
@@ -44,7 +44,8 @@
 ITEMS_CLEAN := $(ITEMS_CLEAN) \
 	$(addprefix $(d), $(addsuffix $(EXEEXT), $(TESTS_$(d)))) \
 	$(addprefix $(d), $(addsuffix .gcda, $(TESTS_$(d)))) \
-	$(addprefix $(d), $(addsuffix .gcno, $(TESTS_$(d))))
+	$(addprefix $(d), $(addsuffix .gcno, $(TESTS_$(d)))) \
+	$(addprefix $(d), $(addsuffix .d, $(TESTS_$(d))))
 ITEMS_DISTCLEAN := $(ITEMS_DISTCLEAN) $(d)log
 
 # Targets for top-level makefile to run
@@ -59,6 +60,16 @@
 test_$(d): $(d) $(addprefix $(d), $(TESTS_$(d)))
 	@$(PERL) $(TOP)/$<testrunner.pl $(TOP)/$< $(EXEEXT)
 
+DEP_$(d) :=
+
+define dep_test
+DEP_$(d) += $(2)
+$(2): $(1)
+	@$$(RM) $$(RMFLAGS) $(2)
+	@$$(CC) $$(DEBUGCFLAGS) -MM -MT '$(2) $(3)' -MF $(2) $(1)
+
+endef
+
 # Build rules for each test binary -- they all depend on the debug library
 define compile_test
 $(2): $$(TOP)/$$(COMPONENT)-debug.a $(1)
@@ -70,6 +81,13 @@
 endef
 
 $(eval $(foreach TEST,$(addprefix $(d), $(TESTS_$(d))), \
+	$(call dep_test,$(addsuffix .c, $(TEST)),$(addsuffix .d, $(TEST)),$(TEST))))
+
+ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
+-include $(sort $(DEP_$(d)))
+endif
+
+$(eval $(foreach TEST,$(addprefix $(d), $(TESTS_$(d))), \
 	$(call compile_test,$(addsuffix .c, $(TEST)),$(TEST))))
 
 # Now include any children we may have




More information about the netsurf-commits mailing list