summaryrefslogtreecommitdiffstats
path: root/src/Makefile.housekeeping
diff options
context:
space:
mode:
authorMichael Brown2014-08-19 17:17:25 +0200
committerMichael Brown2014-08-20 13:36:44 +0200
commitc801cb29d64764fa8082ec2ab17dd12f74b3143f (patch)
treedde1548393981062a33054083daddfecbd2a0c9b /src/Makefile.housekeeping
parent[smc9000] Avoid using CONFIG as a preprocessor macro (diff)
downloadipxe-c801cb29d64764fa8082ec2ab17dd12f74b3143f.tar.gz
ipxe-c801cb29d64764fa8082ec2ab17dd12f74b3143f.tar.xz
ipxe-c801cb29d64764fa8082ec2ab17dd12f74b3143f.zip
[build] Allow for named configurations at build time
Allow named configurations to be specified via the CONFIG=... build parameter. For headers in config/*.h which support named configurations, the following files will be included when building with CONFIG=<name>: - config/defaults/<platform>.h (e.g. config/defaults/pcbios.h) - config/<header>.h - config/<name>/<header>.h (only if the directory config/<name> exists) - config/local/<header>.h (autocreated if necessary) - config/local/<name>/<header>.h (autocreated if necessary) This mechanism allows for predefined named configurations to be checked in to the source tree, as a directory config/<name> containing all of the required header files. The mechanism also allows for users to define multiple local configurations, by creating header files in the directory config/local/<name>. Note that the config/*.h files which are used only to configure internal iPXE APIs (e.g. config/ioapi.h) cannot be modified via a named configuration. This avoids rebuilding the entire iPXE codebase whenever switching to a different named configuration. Inspired-by: Robin Smidsrød <robin@smidsrod.no> Tested-by: Robin Smidsrød <robin@smidsrod.no> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/Makefile.housekeeping')
-rw-r--r--src/Makefile.housekeeping40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping
index 0dce8d06..b07a8d96 100644
--- a/src/Makefile.housekeeping
+++ b/src/Makefile.housekeeping
@@ -689,6 +689,34 @@ privkey_DEPS += $(PRIVKEY_LIST)
CFLAGS_privkey += $(if $(PRIVKEY),-DPRIVATE_KEY="\"$(PRIVKEY_INC)\"")
+# (Single-element) list of named configurations
+#
+CONFIG_LIST := $(BIN)/.config.list
+ifeq ($(wildcard $(CONFIG_LIST)),)
+CONFIG_OLD := <invalid>
+else
+CONFIG_OLD := $(shell cat $(CONFIG_LIST))
+endif
+ifneq ($(CONFIG_OLD),$(CONFIG))
+$(shell $(ECHO) "$(CONFIG)" > $(CONFIG_LIST))
+endif
+
+$(CONFIG_LIST) : $(MAKEDEPS)
+
+VERYCLEANUP += $(CONFIG_LIST)
+
+# Named configurations
+#
+ifneq ($(CONFIG),)
+ifneq ($(wildcard config/$(CONFIG)),)
+CFLAGS += -DCONFIG=$(CONFIG)
+endif
+CFLAGS += -DLOCAL_CONFIG=$(CONFIG)
+endif
+
+config/named.h : $(CONFIG_LIST)
+ $(Q)$(TOUCH) $@
+
# These files use .incbin inline assembly to include a binary file.
# Unfortunately ccache does not detect this dependency and caches
# builds even when the binary file has changed.
@@ -1260,8 +1288,16 @@ CLEANUP += $(EINFO)
#
# Local configs
#
-config/local/%.h :
- $(Q)touch $@
+CONFIG_HEADERS := $(patsubst config/%,%,$(wildcard config/*.h))
+
+$(foreach HEADER,$(CONFIG_HEADERS),config/local/$(HEADER)) :
+ $(Q)$(TOUCH) $@
+
+ifneq ($(CONFIG),)
+$(foreach HEADER,$(CONFIG_HEADERS),config/local/$(CONFIG)/$(HEADER)) :
+ $(Q)$(MKDIR) -p $(dir $@)
+ $(Q)$(TOUCH) $@
+endif
###############################################################################
#