r5258 jmb - in /trunk/libcss: Makefile Makefile-riscos build/Makefile.common test/Makefile

netsurf at semichrome.net netsurf at semichrome.net
Fri Sep 5 12:58:29 BST 2008


Author: jmb
Date: Fri Sep  5 06:58:29 2008
New Revision: 5258

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

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

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

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

Modified: trunk/libcss/build/Makefile.common
URL: http://source.netsurf-browser.org/trunk/libcss/build/Makefile.common?rev=5258&r1=5257&r2=5258&view=diff
==============================================================================
--- trunk/libcss/build/Makefile.common (original)
+++ trunk/libcss/build/Makefile.common Fri Sep  5 06:58:29 2008
@@ -43,10 +43,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)
 
@@ -80,8 +81,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:
@@ -101,6 +102,34 @@
 	@$(RM) $(RMFLAGS) $(PREFIX)/lib/pkgconfig/$(COMPONENT).pc
 	@$(RM) $(RMFLAGS) -r $(PREFIX)/include/libcss
 
+$(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)
@@ -114,5 +143,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/libcss/test/Makefile
URL: http://source.netsurf-browser.org/trunk/libcss/test/Makefile?rev=5258&r1=5257&r2=5258&view=diff
==============================================================================
--- trunk/libcss/test/Makefile (original)
+++ trunk/libcss/test/Makefile Fri Sep  5 06:58:29 2008
@@ -42,7 +42,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
@@ -57,6 +58,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)
@@ -68,6 +79,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