summaryrefslogtreecommitdiffstats
path: root/src/Makefile.housekeeping
diff options
context:
space:
mode:
authorMichael Brown2012-04-24 14:11:21 +0200
committerMichael Brown2012-04-24 14:15:44 +0200
commit0e59417cec7f474b4cce8ca896c1ee1a0ea96729 (patch)
treee9c6a4152a6712cc1287a720be366fd953118ffc /src/Makefile.housekeeping
parent[util] Remove obsolete Makefile rule for util/prototester.c (diff)
downloadipxe-0e59417cec7f474b4cce8ca896c1ee1a0ea96729.tar.gz
ipxe-0e59417cec7f474b4cce8ca896c1ee1a0ea96729.tar.xz
ipxe-0e59417cec7f474b4cce8ca896c1ee1a0ea96729.zip
[build] Use $(xxx_DEPS) for additional dependency information
Some objects (embedded.o, rootcert.o, and clientcert.o) define additional dependencies on external files, using syntax such as: $(BIN)/clientcert.o : $(CERT_LIST) This dependency can be missed when using debug builds. For example, if DEBUG=clientcert is used, then the relevant object is $(BIN)/clientcert.dbg1.o rather than $(BIN)/clientcert.o. Fix by adding dependencies to $(clientcert_DEPS) instead: clientcert_DEPS += $(CERT_LIST) Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/Makefile.housekeeping')
-rw-r--r--src/Makefile.housekeeping190
1 files changed, 95 insertions, 95 deletions
diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping
index bf4b93c5..d2b4ee38 100644
--- a/src/Makefile.housekeeping
+++ b/src/Makefile.housekeeping
@@ -517,95 +517,6 @@ RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
DEBUG_TARGETS += dbg%.o c s
-# We automatically generate rules for any file mentioned in AUTO_SRCS
-# using the following set of templates. It would be cleaner to use
-# $(eval ...), but this function exists only in GNU make >= 3.80.
-
-# deps_template : generate dependency list for a given source file
-#
-# $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
-# $(2) is the source type (e.g. "c")
-# $(3) is the source base name (e.g. "rtl8139")
-#
-define deps_template
- @$(ECHO) " [DEPS] $(1)"
- @$(MKDIR) -p $(BIN)/deps/$(dir $(1))
- @$(CPP) $(CFLAGS) $(CFLAGS_$(2)) $(CFLAGS_$(3)) -DOBJECT=$(3) \
- -Wno-error -M $(1) -MG -MP | \
- sed 's/\.o\s*:/_DEPS =/' > $(BIN)/deps/$(1).d
-endef
-
-# rules_template : generate rules for a given source file
-#
-# $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
-# $(2) is the source type (e.g. "c")
-# $(3) is the source base name (e.g. "rtl8139")
-#
-define rules_template
- @$(ECHO) " [RULES] $(1)"
- @$(MKDIR) -p $(BIN)/rules/$(dir $(1))
- @$(ECHO_E) '\n$$(BIN)/$(3).o :' \
- '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)' \
- '\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \
- '\n\t$$(RULE_$(2))\n' \
- '\nBOBJS += $$(BIN)/$(3).o\n' \
- $(foreach TGT,$(DEBUG_TARGETS), \
- $(if $(RULE_$(2)_to_$(TGT)), \
- '\n$$(BIN)/$(3).$(TGT) :' \
- '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)' \
- '\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \
- '\n\t$$(RULE_$(2)_to_$(TGT))\n' \
- '\n$(TGT)_OBJS += $$(BIN)/$(3).$(TGT)\n' ) ) \
- '\n$(BIN)/deps/$(1).d : $$($(3)_DEPS)\n' \
- '\nTAGS : $$($(3)_DEPS)\n' > $(BIN)/rules/$(1).r
- @$(if $(findstring drivers/,$(1)),\
- $(PERL) $(PARSEROM) $(1) >> $(BIN)/rules/$(1).r)
-endef
-
-# Rule to generate the dependency list file
-#
-$(BIN)/deps/%.d : % $(MAKEDEPS)
- $(call deps_template,$<,$(subst .,,$(suffix $<)),$(basename $(notdir $<)))
-
-# Calculate and include the list of dependency list files
-#
-AUTO_DEPS = $(patsubst %,$(BIN)/deps/%.d,$(AUTO_SRCS))
-ifdef NEED_DEPS
-ifneq ($(AUTO_DEPS),)
--include $(AUTO_DEPS)
-endif
-endif
-autodeps :
- @$(ECHO) $(AUTO_DEPS)
-VERYCLEANUP += $(BIN)/deps
-
-# Rule to generate the rules file
-#
-$(BIN)/rules/%.r : % $(MAKEDEPS) $(PARSEROM)
- $(call rules_template,$<,$(subst .,,$(suffix $<)),$(basename $(notdir $<)))
-
-# Calculate and include the list of rules files
-#
-AUTO_RULES = $(patsubst %,$(BIN)/rules/%.r,$(AUTO_SRCS))
-ifdef NEED_DEPS
-ifneq ($(AUTO_RULES),)
--include $(AUTO_RULES)
-endif
-endif
-autorules :
- @$(ECHO) $(AUTO_RULES)
-VERYCLEANUP += $(BIN)/rules
-
-# The following variables are created by the rules files
-#
-bobjs :
- @$(ECHO) $(BOBJS)
-drivers :
- @$(ECHO) $(DRIVERS)
-.PHONY : drivers
-roms :
- @$(ECHO) $(ROMS)
-
# List of embedded images included in the last build of embedded.o.
# This is needed in order to correctly rebuild embedded.o whenever the
# list of objects changes.
@@ -630,7 +541,7 @@ EMBED_ALL := $(foreach i,$(call seq,1,$(words $(EMBEDDED_FILES))),\
EMBED ( $(i), \"$(word $(i), $(EMBEDDED_FILES))\",\
\"$(notdir $(word $(i),$(EMBEDDED_FILES)))\" ))
-$(BIN)/embedded.o : $(EMBEDDED_FILES) $(EMBEDDED_LIST)
+embedded_DEPS += $(EMBEDDED_FILES) $(EMBEDDED_LIST)
CFLAGS_embedded = -DEMBED_ALL="$(EMBED_ALL)"
@@ -658,7 +569,7 @@ TRUSTED_FPS := $(foreach CERT,$(TRUSTED_CERTS),\
$(shell $(OPENSSL) x509 -in $(CERT) -noout -sha256 \
-fingerprint))))$(COMMA))
-$(BIN)/rootcert.o : $(TRUSTED_FILES) $(TRUSTED_LIST)
+rootcert_DEPS += $(TRUSTED_FILES) $(TRUSTED_LIST)
CFLAGS_rootcert = $(if $(TRUSTED_FPS),-DTRUSTED="$(TRUSTED_FPS)")
@@ -686,12 +597,12 @@ ifdef CERT
$(CERT_INC) : $(CERT) $(CERT_LIST)
$(Q)$(OPENSSL) x509 -in $< -outform DER -out $@
-$(BIN)/clientcert.o : $(CERT_INC)
+clientcert_DEPS += $(CERT_INC)
endif
CLEANUP += $(CERT_INC)
-$(BIN)/clientcert.o : $(CERT_LIST)
+clientcert_DEPS += $(CERT_LIST)
CFLAGS_clientcert += $(if $(CERT),-DCERTIFICATE="\"$(CERT_INC)\"")
@@ -719,12 +630,12 @@ ifdef KEY
$(KEY_INC) : $(KEY) $(KEY_LIST)
$(Q)$(OPENSSL) rsa -in $< -outform DER -out $@
-$(BIN)/clientcert.o : $(KEY_INC)
+clientcert_DEPS += $(KEY_INC)
endif
CLEANUP += $(KEY_INC)
-$(BIN)/clientcert.o : $(KEY_LIST)
+clientcert_DEPS += $(KEY_LIST)
CFLAGS_clientcert += $(if $(KEY),-DPRIVATE_KEY="\"$(KEY_INC)\"")
@@ -736,6 +647,95 @@ $(BIN)/embedded.o : override CC := env CCACHE_DISABLE=1 $(CC)
$(BIN)/clientcert.o : override CC := env CCACHE_DISABLE=1 $(CC)
+# We automatically generate rules for any file mentioned in AUTO_SRCS
+# using the following set of templates. It would be cleaner to use
+# $(eval ...), but this function exists only in GNU make >= 3.80.
+
+# deps_template : generate dependency list for a given source file
+#
+# $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
+# $(2) is the source type (e.g. "c")
+# $(3) is the source base name (e.g. "rtl8139")
+#
+define deps_template
+ @$(ECHO) " [DEPS] $(1)"
+ @$(MKDIR) -p $(BIN)/deps/$(dir $(1))
+ @$(CPP) $(CFLAGS) $(CFLAGS_$(2)) $(CFLAGS_$(3)) -DOBJECT=$(3) \
+ -Wno-error -M $(1) -MG -MP | \
+ sed 's/\.o\s*:/_DEPS +=/' > $(BIN)/deps/$(1).d
+endef
+
+# rules_template : generate rules for a given source file
+#
+# $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
+# $(2) is the source type (e.g. "c")
+# $(3) is the source base name (e.g. "rtl8139")
+#
+define rules_template
+ @$(ECHO) " [RULES] $(1)"
+ @$(MKDIR) -p $(BIN)/rules/$(dir $(1))
+ @$(ECHO_E) '\n$$(BIN)/$(3).o :' \
+ '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)' \
+ '\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \
+ '\n\t$$(RULE_$(2))\n' \
+ '\nBOBJS += $$(BIN)/$(3).o\n' \
+ $(foreach TGT,$(DEBUG_TARGETS), \
+ $(if $(RULE_$(2)_to_$(TGT)), \
+ '\n$$(BIN)/$(3).$(TGT) :' \
+ '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)' \
+ '\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \
+ '\n\t$$(RULE_$(2)_to_$(TGT))\n' \
+ '\n$(TGT)_OBJS += $$(BIN)/$(3).$(TGT)\n' ) ) \
+ '\n$(BIN)/deps/$(1).d : $$($(3)_DEPS)\n' \
+ '\nTAGS : $$($(3)_DEPS)\n' > $(BIN)/rules/$(1).r
+ @$(if $(findstring drivers/,$(1)),\
+ $(PERL) $(PARSEROM) $(1) >> $(BIN)/rules/$(1).r)
+endef
+
+# Rule to generate the dependency list file
+#
+$(BIN)/deps/%.d : % $(MAKEDEPS)
+ $(call deps_template,$<,$(subst .,,$(suffix $<)),$(basename $(notdir $<)))
+
+# Calculate and include the list of dependency list files
+#
+AUTO_DEPS = $(patsubst %,$(BIN)/deps/%.d,$(AUTO_SRCS))
+ifdef NEED_DEPS
+ifneq ($(AUTO_DEPS),)
+-include $(AUTO_DEPS)
+endif
+endif
+autodeps :
+ @$(ECHO) $(AUTO_DEPS)
+VERYCLEANUP += $(BIN)/deps
+
+# Rule to generate the rules file
+#
+$(BIN)/rules/%.r : % $(MAKEDEPS) $(PARSEROM)
+ $(call rules_template,$<,$(subst .,,$(suffix $<)),$(basename $(notdir $<)))
+
+# Calculate and include the list of rules files
+#
+AUTO_RULES = $(patsubst %,$(BIN)/rules/%.r,$(AUTO_SRCS))
+ifdef NEED_DEPS
+ifneq ($(AUTO_RULES),)
+-include $(AUTO_RULES)
+endif
+endif
+autorules :
+ @$(ECHO) $(AUTO_RULES)
+VERYCLEANUP += $(BIN)/rules
+
+# The following variables are created by the rules files
+#
+bobjs :
+ @$(ECHO) $(BOBJS)
+drivers :
+ @$(ECHO) $(DRIVERS)
+.PHONY : drivers
+roms :
+ @$(ECHO) $(ROMS)
+
# Generate error usage information
#
$(BIN)/%.einfo : $(BIN)/%.o