]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[build] Allow for named configurations at build time
authorMichael Brown <mcb30@ipxe.org>
Tue, 19 Aug 2014 15:17:25 +0000 (16:17 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 20 Aug 2014 11:36:44 +0000 (12:36 +0100)
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>
src/Makefile.housekeeping
src/config/colour.h
src/config/console.h
src/config/crypto.h
src/config/general.h
src/config/named.h [new file with mode: 0644]
src/config/serial.h
src/config/settings.h
src/config/sideband.h

index 0dce8d06fd3a9bbdfface2f1a65e96cb94e10e82..b07a8d967536488b6a8131e3082a515993b19f2e 100644 (file)
@@ -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
 
 ###############################################################################
 #
index c75f65e6dd0667e098c353fd1ddc1100054c8856..57d20c1dba171957efcbf6820845acd7df40b827 100644 (file)
@@ -30,6 +30,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #define COLOR_PXE_FG           COLOR_BLACK
 #define COLOR_PXE_BG           COLOR_WHITE
 
+#include <config/named.h>
+#include NAMED_CONFIG(colour.h)
 #include <config/local/colour.h>
+#include LOCAL_NAMED_CONFIG(colour.h)
 
 #endif /* CONFIG_COLOUR_H */
index 5d2cc1dceadeec989705468d9d1b6a1c56941152..908ec5a0b2b76f537de8dc46e2c72c1d80ad1761 100644 (file)
@@ -28,6 +28,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
 
 #define        LOG_LEVEL       LOG_NONE
 
+#include <config/named.h>
+#include NAMED_CONFIG(console.h)
 #include <config/local/console.h>
+#include LOCAL_NAMED_CONFIG(console.h)
 
 #endif /* CONFIG_CONSOLE_H */
index 95c73d477544458616e1089836845b2997e18008..1e021b0fb9a26d750cdd71cabb73f051dd844093 100644 (file)
@@ -17,6 +17,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
  */
 #define TIMESTAMP_ERROR_MARGIN ( ( 12 * 60 + 30 ) * 60 )
 
+#include <config/named.h>
+#include NAMED_CONFIG(crypto.h)
 #include <config/local/crypto.h>
+#include LOCAL_NAMED_CONFIG(crypto.h)
 
 #endif /* CONFIG_CRYPTO_H */
index 72cfc3b86f01b4cf5720710d11aa63bec361dae5..5392034577a5033e14d7cf192e74d7e7f52082ae 100644 (file)
@@ -182,6 +182,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #undef GDBUDP                  /* Remote GDB debugging over UDP
                                 * (both may be set) */
 
+#include <config/named.h>
+#include NAMED_CONFIG(general.h)
 #include <config/local/general.h>
+#include LOCAL_NAMED_CONFIG(general.h)
 
 #endif /* CONFIG_GENERAL_H */
diff --git a/src/config/named.h b/src/config/named.h
new file mode 100644 (file)
index 0000000..36efdab
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef CONFIG_NAMED_H
+#define CONFIG_NAMED_H
+
+/** @file
+ *
+ * Named configurations
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+/* config/<name>/<header>.h */
+#ifdef CONFIG
+#define NAMED_CONFIG(_header) <config/CONFIG/_header>
+#else
+#define NAMED_CONFIG(_header) <config/_header>
+#endif
+
+/* config/local/<name>/<header>.h */
+#ifdef LOCAL_CONFIG
+#define LOCAL_NAMED_CONFIG(_header) <config/local/LOCAL_CONFIG/_header>
+#else
+#define LOCAL_NAMED_CONFIG(_header) <config/_header>
+#endif
+
+#endif /* CONFIG_NAMED_H */
index 8bb9311f15760fc7682cb11cedab89a03dfa86ad..08368efdb670180016041112f1fd0a1c4bb8a477 100644 (file)
@@ -32,6 +32,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #define        COMSTOP         1               /* Stop bits */
 #endif
 
+#include <config/named.h>
+#include NAMED_CONFIG(serial.h)
 #include <config/local/serial.h>
+#include LOCAL_NAMED_CONFIG(serial.h)
 
 #endif /* CONFIG_SERIAL_H */
index b06f2901b0cf3c291615c553ed569918f43c576d..42fe9cc8102b383ceacca5f4fc24d0508d1c0d35 100644 (file)
@@ -14,6 +14,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
 //#define      MEMMAP_SETTINGS /* Memory map settings */
 //#define      VMWARE_SETTINGS /* VMware GuestInfo settings */
 
+#include <config/named.h>
+#include NAMED_CONFIG(settings.h)
 #include <config/local/settings.h>
+#include LOCAL_NAMED_CONFIG(settings.h)
 
 #endif /* CONFIG_SETTINGS_H */
index 2e2a8d41921e478809d66e8a2850f39c24f7ae73..039bb5d095639032bb29811e2ad908589c22bd94 100644 (file)
@@ -11,6 +11,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
 
 //#define      CONFIG_BOFM     /* IBM's BladeCenter Open Fabric Manager */
 
+#include <config/named.h>
+#include NAMED_CONFIG(sideband.h)
 #include <config/local/sideband.h>
+#include LOCAL_NAMED_CONFIG(sideband.h)
 
 #endif /* CONFIG_SIDEBAND_H */