From a6f4554656d24d488627c713274e2cae82fc51d3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 7 Aug 2014 16:10:23 +0200 Subject: [PATCH 1/3] Add support for order-only dependencies --- libraries.mk | 12 ++++++++++++ programs.mk | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/libraries.mk b/libraries.mk index 4b8292cc..3b91c699 100644 --- a/libraries.mk +++ b/libraries.mk @@ -21,6 +21,9 @@ endif # # - $(1)_CXXFLAGS: additional C++ compiler flags. # +# - $(1)_ORDER_AFTER: a set of targets on which the object files of +# this libraries will have an order-only dependency. +# # - $(1)_LIBS: the symbolic names of other libraries on which this # library depends. # @@ -89,6 +92,8 @@ define build-library $(1)_LDFLAGS_USE_INSTALLED += -L$$(DESTDIR)$$($(1)_INSTALL_DIR) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME))) ifeq ($(SET_RPATH_TO_LIBS), 1) $(1)_LDFLAGS_USE_INSTALLED += -Wl,-rpath,$$($(1)_INSTALL_DIR) + else + $(1)_LDFLAGS_USE_INSTALLED += -Wl,-rpath-link,$$($(1)_INSTALL_DIR) endif ifdef $(1)_FORCE_INSTALL @@ -118,6 +123,13 @@ define build-library # Make each object file depend on the common dependencies. $$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj): $$($(1)_COMMON_DEPS) $$(GLOBAL_COMMON_DEPS))) + # Make each object file have order-only dependencies on the common + # order-only dependencies. This includes the order-only dependencies + # of libraries we're depending on. + $(1)_ORDER_AFTER_CLOSED = $$($(1)_ORDER_AFTER) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_ORDER_AFTER_CLOSED)) + + $$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj): | $$($(1)_ORDER_AFTER_CLOSED) $$(GLOBAL_ORDER_AFTER))) + # Include .dep files, if they exist. $(1)_DEPS := $$(foreach fn, $$($(1)_OBJS), $$(call filename-to-dep, $$(fn))) -include $$($(1)_DEPS) diff --git a/programs.mk b/programs.mk index b6de0689..72afdf95 100644 --- a/programs.mk +++ b/programs.mk @@ -12,6 +12,9 @@ programs-list := # # - $(1)_CXXFLAGS: additional C++ compiler flags. # +# - $(1)_ORDER_AFTER: a set of targets on which the object files of +# this program will have an order-only dependency. +# # - $(1)_LIBS: the symbolic names of libraries on which this program # depends. # @@ -59,6 +62,13 @@ define build-program # Make each object file depend on the common dependencies. $$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj): $$($(1)_COMMON_DEPS) $$(GLOBAL_COMMON_DEPS))) + # Make each object file have order-only dependencies on the common + # order-only dependencies. This includes the order-only dependencies + # of libraries we're depending on. + $(1)_ORDER_AFTER_CLOSED = $$($(1)_ORDER_AFTER) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_ORDER_AFTER_CLOSED)) + + $$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj): | $$($(1)_ORDER_AFTER_CLOSED) $$(GLOBAL_ORDER_AFTER))) + # Include .dep files, if they exist. $(1)_DEPS := $$(foreach fn, $$($(1)_OBJS), $$(call filename-to-dep, $$(fn))) -include $$($(1)_DEPS) From ab4eba5b91a25c7b6c225758334219cb3f2e4547 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 20 Aug 2014 18:39:48 +0200 Subject: [PATCH 2/3] Handle header file instantiation --- templates.mk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates.mk b/templates.mk index 8e8b2864..84364297 100644 --- a/templates.mk +++ b/templates.mk @@ -8,5 +8,8 @@ define instantiate-template endef +%.h: %.h.in + $(trace-gen) ./config.status --quiet --header=$@ + %: %.in - $(trace-gen) ./config.status --quiet --file $@ + $(trace-gen) ./config.status --quiet --file=$@ From 2aa93858afee22e0c32d8f4366970976374091ac Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 20 Aug 2014 18:44:15 +0200 Subject: [PATCH 3/3] Force template regeneration --- templates.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates.mk b/templates.mk index 84364297..ab99168b 100644 --- a/templates.mk +++ b/templates.mk @@ -9,7 +9,7 @@ define instantiate-template endef %.h: %.h.in - $(trace-gen) ./config.status --quiet --header=$@ + $(trace-gen) rm -f $@ && ./config.status --quiet --header=$@ %: %.in - $(trace-gen) ./config.status --quiet --file=$@ + $(trace-gen) rm -f $@ && ./config.status --quiet --file=$@