]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[linker] Add mechanism for subsystem-dependent configuration options
authorJoshua Oreman <oremanj@rwcr.net>
Fri, 7 Aug 2009 01:52:06 +0000 (18:52 -0700)
committerMarty Connor <mdc@etherboot.org>
Sat, 21 Nov 2009 01:30:58 +0000 (20:30 -0500)
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>
src/Makefile
src/config/config.c [moved from src/core/config.c with 85% similarity]
src/include/compiler.h

index 16759ca017a7043f5438ec3b43f05376b3f33f8d..72b0e64c1243cb1b895cf686c39439c342a40466 100644 (file)
@@ -73,6 +73,7 @@ SRCDIRS               += crypto crypto/axtls crypto/matrixssl
 SRCDIRS                += hci hci/commands hci/tui
 SRCDIRS                += hci/mucurses hci/mucurses/widgets
 SRCDIRS                += usr
+SRCDIRS                += config
 
 # NON_AUTO_SRCS lists files that are excluded from the normal
 # automatic build system.
similarity index 85%
rename from src/core/config.c
rename to src/config/config.c
index e4c05613750f6525cfa797a08daa39f9004a8188..3c43dfbc59ef5b7e59e220a6d0ff845be4c4cffa 100644 (file)
@@ -10,6 +10,24 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <config/general.h>
 #include <config/console.h>
 
+/** @file
+ *
+ * Configuration options
+ *
+ * This file contains macros that pull various objects into the link
+ * based on definitions in configuration header files. Ideally it
+ * should be the only place in gPXE where one might need to use #ifdef
+ * for compile-time options.
+ *
+ * In the fairly common case where an object should only be considered
+ * for inclusion if the subsystem it depends on is present, its
+ * configuration macros should be placed in a file named
+ * <tt>config_<i>subsystem</i>.c</tt>, where @e subsystem is the
+ * object basename of the main source file for that subsystem. The
+ * build system will pull in that file if @c subsystem.c is included
+ * in the final gPXE executable built.
+ */
+
 /*
  * Build ID string calculations
  *
index 5ba7f441c62e86571c35b98dc52be8ee040eb7ff..f481f38ae6217d8d786a72781a57c7d53b469683 100644 (file)
 
 #define PREFIX_OBJECT( _prefix ) _C2 ( _prefix, OBJECT )
 #define OBJECT_SYMBOL PREFIX_OBJECT ( obj_ )
+#define REQUEST_EXPANDED( _sym ) REQUEST_SYMBOL ( _sym )
+#define CONFIG_SYMBOL PREFIX_OBJECT ( obj_config_ )
 
 /** Always provide the symbol for the current object (defined by -DOBJECT) */
 PROVIDE_SYMBOL ( OBJECT_SYMBOL );
 
+/** Pull in an object-specific configuration file if available */
+REQUEST_EXPANDED ( CONFIG_SYMBOL );
+
 /** Explicitly require another object */
 #define REQUIRE_OBJECT( _obj ) REQUIRE_SYMBOL ( obj_ ## _obj )