Browse Source

[linker] Add mechanism for subsystem-dependent configuration options

It is often the case that some module of gPXE is only relevant if the
subsystem it depends on is already being included. For instance,
commands to manage wireless interfaces are quite useless if no
compiled-in driver has pulled in the wireless networking stack. There
may be a user-modifiable configuration options for these dependent
modules, but even if enabled, they should not be included when they
would be useless.

Solve this by allowing the creation of config_subsystem.c, for
configuration directives like those in the global config.c that should
only be considered when subsystem.c is included in the final gPXE
build.

For consistency, move core/config.c to the config/ directory, where
the other config_subsystem.c files will eventually reside.

Signed-off-by: Marty Connor <mdc@etherboot.org>
tags/v1.0.0-rc1
Joshua Oreman 14 years ago
parent
commit
9a0bd0711f
3 changed files with 24 additions and 0 deletions
  1. 1
    0
      src/Makefile
  2. 18
    0
      src/config/config.c
  3. 5
    0
      src/include/compiler.h

+ 1
- 0
src/Makefile View File

@@ -73,6 +73,7 @@ SRCDIRS		+= crypto crypto/axtls crypto/matrixssl
73 73
 SRCDIRS		+= hci hci/commands hci/tui
74 74
 SRCDIRS		+= hci/mucurses hci/mucurses/widgets
75 75
 SRCDIRS		+= usr
76
+SRCDIRS		+= config
76 77
 
77 78
 # NON_AUTO_SRCS lists files that are excluded from the normal
78 79
 # automatic build system.

src/core/config.c → src/config/config.c View File

@@ -10,6 +10,24 @@ FILE_LICENCE ( GPL2_OR_LATER );
10 10
 #include <config/general.h>
11 11
 #include <config/console.h>
12 12
 
13
+/** @file
14
+ *
15
+ * Configuration options
16
+ *
17
+ * This file contains macros that pull various objects into the link
18
+ * based on definitions in configuration header files. Ideally it
19
+ * should be the only place in gPXE where one might need to use #ifdef
20
+ * for compile-time options.
21
+ *
22
+ * In the fairly common case where an object should only be considered
23
+ * for inclusion if the subsystem it depends on is present, its
24
+ * configuration macros should be placed in a file named
25
+ * <tt>config_<i>subsystem</i>.c</tt>, where @e subsystem is the
26
+ * object basename of the main source file for that subsystem. The
27
+ * build system will pull in that file if @c subsystem.c is included
28
+ * in the final gPXE executable built.
29
+ */
30
+
13 31
 /*
14 32
  * Build ID string calculations
15 33
  *

+ 5
- 0
src/include/compiler.h View File

@@ -159,10 +159,15 @@
159 159
 
160 160
 #define PREFIX_OBJECT( _prefix ) _C2 ( _prefix, OBJECT )
161 161
 #define OBJECT_SYMBOL PREFIX_OBJECT ( obj_ )
162
+#define REQUEST_EXPANDED( _sym ) REQUEST_SYMBOL ( _sym )
163
+#define CONFIG_SYMBOL PREFIX_OBJECT ( obj_config_ )
162 164
 
163 165
 /** Always provide the symbol for the current object (defined by -DOBJECT) */
164 166
 PROVIDE_SYMBOL ( OBJECT_SYMBOL );
165 167
 
168
+/** Pull in an object-specific configuration file if available */
169
+REQUEST_EXPANDED ( CONFIG_SYMBOL );
170
+
166 171
 /** Explicitly require another object */
167 172
 #define REQUIRE_OBJECT( _obj ) REQUIRE_SYMBOL ( obj_ ## _obj )
168 173
 

Loading…
Cancel
Save