Przeglądaj źródła

[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>
tags/v1.20.1
Michael Brown 10 lat temu
rodzic
commit
c801cb29d6

+ 38
- 2
src/Makefile.housekeeping Wyświetl plik

@@ -689,6 +689,34 @@ privkey_DEPS += $(PRIVKEY_LIST)
689 689
 
690 690
 CFLAGS_privkey += $(if $(PRIVKEY),-DPRIVATE_KEY="\"$(PRIVKEY_INC)\"")
691 691
 
692
+# (Single-element) list of named configurations
693
+#
694
+CONFIG_LIST := $(BIN)/.config.list
695
+ifeq ($(wildcard $(CONFIG_LIST)),)
696
+CONFIG_OLD := <invalid>
697
+else
698
+CONFIG_OLD := $(shell cat $(CONFIG_LIST))
699
+endif
700
+ifneq ($(CONFIG_OLD),$(CONFIG))
701
+$(shell $(ECHO) "$(CONFIG)" > $(CONFIG_LIST))
702
+endif
703
+
704
+$(CONFIG_LIST) : $(MAKEDEPS)
705
+
706
+VERYCLEANUP += $(CONFIG_LIST)
707
+
708
+# Named configurations
709
+#
710
+ifneq ($(CONFIG),)
711
+ifneq ($(wildcard config/$(CONFIG)),)
712
+CFLAGS	+= -DCONFIG=$(CONFIG)
713
+endif
714
+CFLAGS	+= -DLOCAL_CONFIG=$(CONFIG)
715
+endif
716
+
717
+config/named.h : $(CONFIG_LIST)
718
+	$(Q)$(TOUCH) $@
719
+
692 720
 # These files use .incbin inline assembly to include a binary file.
693 721
 # Unfortunately ccache does not detect this dependency and caches
694 722
 # builds even when the binary file has changed.
@@ -1260,8 +1288,16 @@ CLEANUP += $(EINFO)
1260 1288
 #
1261 1289
 # Local configs
1262 1290
 #
1263
-config/local/%.h :
1264
-	$(Q)touch $@
1291
+CONFIG_HEADERS := $(patsubst config/%,%,$(wildcard config/*.h))
1292
+
1293
+$(foreach HEADER,$(CONFIG_HEADERS),config/local/$(HEADER)) :
1294
+	$(Q)$(TOUCH) $@
1295
+
1296
+ifneq ($(CONFIG),)
1297
+$(foreach HEADER,$(CONFIG_HEADERS),config/local/$(CONFIG)/$(HEADER)) :
1298
+	$(Q)$(MKDIR) -p $(dir $@)
1299
+	$(Q)$(TOUCH) $@
1300
+endif
1265 1301
 
1266 1302
 ###############################################################################
1267 1303
 #

+ 3
- 0
src/config/colour.h Wyświetl plik

@@ -30,6 +30,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
30 30
 #define COLOR_PXE_FG		COLOR_BLACK
31 31
 #define COLOR_PXE_BG		COLOR_WHITE
32 32
 
33
+#include <config/named.h>
34
+#include NAMED_CONFIG(colour.h)
33 35
 #include <config/local/colour.h>
36
+#include LOCAL_NAMED_CONFIG(colour.h)
34 37
 
35 38
 #endif /* CONFIG_COLOUR_H */

+ 3
- 0
src/config/console.h Wyświetl plik

@@ -28,6 +28,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
28 28
 
29 29
 #define	LOG_LEVEL	LOG_NONE
30 30
 
31
+#include <config/named.h>
32
+#include NAMED_CONFIG(console.h)
31 33
 #include <config/local/console.h>
34
+#include LOCAL_NAMED_CONFIG(console.h)
32 35
 
33 36
 #endif /* CONFIG_CONSOLE_H */

+ 3
- 0
src/config/crypto.h Wyświetl plik

@@ -17,6 +17,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
17 17
  */
18 18
 #define TIMESTAMP_ERROR_MARGIN ( ( 12 * 60 + 30 ) * 60 )
19 19
 
20
+#include <config/named.h>
21
+#include NAMED_CONFIG(crypto.h)
20 22
 #include <config/local/crypto.h>
23
+#include LOCAL_NAMED_CONFIG(crypto.h)
21 24
 
22 25
 #endif /* CONFIG_CRYPTO_H */

+ 3
- 0
src/config/general.h Wyświetl plik

@@ -182,6 +182,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
182 182
 #undef	GDBUDP			/* Remote GDB debugging over UDP
183 183
 				 * (both may be set) */
184 184
 
185
+#include <config/named.h>
186
+#include NAMED_CONFIG(general.h)
185 187
 #include <config/local/general.h>
188
+#include LOCAL_NAMED_CONFIG(general.h)
186 189
 
187 190
 #endif /* CONFIG_GENERAL_H */

+ 26
- 0
src/config/named.h Wyświetl plik

@@ -0,0 +1,26 @@
1
+#ifndef CONFIG_NAMED_H
2
+#define CONFIG_NAMED_H
3
+
4
+/** @file
5
+ *
6
+ * Named configurations
7
+ *
8
+ */
9
+
10
+FILE_LICENCE ( GPL2_OR_LATER );
11
+
12
+/* config/<name>/<header>.h */
13
+#ifdef CONFIG
14
+#define NAMED_CONFIG(_header) <config/CONFIG/_header>
15
+#else
16
+#define NAMED_CONFIG(_header) <config/_header>
17
+#endif
18
+
19
+/* config/local/<name>/<header>.h */
20
+#ifdef LOCAL_CONFIG
21
+#define LOCAL_NAMED_CONFIG(_header) <config/local/LOCAL_CONFIG/_header>
22
+#else
23
+#define LOCAL_NAMED_CONFIG(_header) <config/_header>
24
+#endif
25
+
26
+#endif /* CONFIG_NAMED_H */

+ 3
- 0
src/config/serial.h Wyświetl plik

@@ -32,6 +32,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
32 32
 #define	COMSTOP		1		/* Stop bits */
33 33
 #endif
34 34
 
35
+#include <config/named.h>
36
+#include NAMED_CONFIG(serial.h)
35 37
 #include <config/local/serial.h>
38
+#include LOCAL_NAMED_CONFIG(serial.h)
36 39
 
37 40
 #endif /* CONFIG_SERIAL_H */

+ 3
- 0
src/config/settings.h Wyświetl plik

@@ -14,6 +14,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
14 14
 //#define	MEMMAP_SETTINGS	/* Memory map settings */
15 15
 //#define	VMWARE_SETTINGS	/* VMware GuestInfo settings */
16 16
 
17
+#include <config/named.h>
18
+#include NAMED_CONFIG(settings.h)
17 19
 #include <config/local/settings.h>
20
+#include LOCAL_NAMED_CONFIG(settings.h)
18 21
 
19 22
 #endif /* CONFIG_SETTINGS_H */

+ 3
- 0
src/config/sideband.h Wyświetl plik

@@ -11,6 +11,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
11 11
 
12 12
 //#define	CONFIG_BOFM	/* IBM's BladeCenter Open Fabric Manager */
13 13
 
14
+#include <config/named.h>
15
+#include NAMED_CONFIG(sideband.h)
14 16
 #include <config/local/sideband.h>
17
+#include LOCAL_NAMED_CONFIG(sideband.h)
15 18
 
16 19
 #endif /* CONFIG_SIDEBAND_H */

Ładowanie…
Anuluj
Zapisz