Nicholas Chin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/84386?usp=email )
Change subject: Makefile: Allow defining order-only prerequisites in create_cc_template ......................................................................
Makefile: Allow defining order-only prerequisites in create_cc_template
Generated header files such as static.h are currently added as prerequisites for all compilation units to ensure that they exist and are up to date before anything that might need them is compiled. However, this has the side effect of forcing every compilation unit out of date when the headers are regenerated, even if the object has no dependency on the header. GNU make has order-only prerequisites [1] which are used to define prerequisites that must be updated before a given target, but which don't force the target out of date when the prerequisite is updated.
Add a new argument to create_cc_template, similar to the "additional dependencies" argument, which allows order-only dependencies for a specified object class and source suffix to be defined. This new functionality will be utilized in subsequent commits to fix up the dependencies on generated header files.
Objects that do depend on generated headers will still be handled correctly due to the .d dependency files that are generated by the compiler during the build, which declare normal prerequisites to any headers an object directly or indirectly includes. As per the GNU make documentation, normal prerequisites take precedence over order-only prerequisites, so the header dependencies declared in the .d files will override the order-only one declared through create_cc_template.
[1] https://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html
Change-Id: I50d87b3d9012967eefb197be12b2e0f096b0b67c Signed-off-by: Nicholas Chin nic.c3.14@gmail.com --- M Makefile 1 file changed, 4 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/86/84386/1
diff --git a/Makefile b/Makefile index cc73900..dd97d83 100644 --- a/Makefile +++ b/Makefile @@ -392,16 +392,17 @@ # $2 source suffix (c, S, ld, ...) # $3 additional compiler flags # $4 additional dependencies +# $5 additional order only dependencies ifn$(EMPTY)def $(1)-objs_$(2)_template de$(EMPTY)fine $(1)-objs_$(2)_template ifn$(EMPTY)eq ($(filter ads adb,$(2)),) -$$(call src-to-obj,$1,$$(1).$2): $$(1).$2 $$(call create_ada_deps,$1,$$(call src-to-ali,$1,$$(1).$2)) $(4) +$$(call src-to-obj,$1,$$(1).$2): $$(1).$2 $$(call create_ada_deps,$1,$$(call src-to-ali,$1,$$(1).$2)) $(4) | $(5) @printf " GCC $$$$(subst $$$$(obj)/,,$$$$(@))\n" $(GCC_$(1)) \ $$$$(ADAFLAGS_$(1)) $$$$(addprefix -I,$$$$($(1)-ada-dirs)) \ $(3) -c -o $$$$@ $$$$< el$(EMPTY)se -$$(call src-to-obj,$1,$$(1).$2): $$(1).$2 $(KCONFIG_AUTOHEADER) $(4) +$$(call src-to-obj,$1,$$(1).$2): $$(1).$2 $(KCONFIG_AUTOHEADER) $(4) | $(5) @printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n" $(CC_$(1)) \ -MMD $$$$(CPPFLAGS_$(1)) $$$$(CFLAGS_$(1)) -MT $$$$(@) \ @@ -416,7 +417,7 @@ $(foreach type,$(call filetypes-of-class,$(class)), \ $(eval $(class)-$(type)-ccopts += $(generic-$(type)-ccopts) $($(class)-generic-ccopts)) \ $(if $(generic-objs_$(type)_template_gen),$(eval $(call generic-objs_$(type)_template_gen,$(class))),\ - $(eval $(call create_cc_template,$(class),$(type),$($(class)-$(type)-ccopts),$($(class)-$(type)-deps)))))) + $(eval $(call create_cc_template,$(class),$(type),$($(class)-$(type)-ccopts),$($(class)-$(type)-deps),$($(class)-$(type)-order-deps))))))
foreach-src=$(foreach file,$($(1)-srcs),$(eval $(call $(1)-objs_$(subst .,,$(suffix $(file)))_template,$(basename $(file))))) $(eval $(foreach class,$(classes),$(call foreach-src,$(class))))