From 9a0bd0711f9e5d0a555fa35de8eb07cb29dc83a9 Mon Sep 17 00:00:00 2001 From: Joshua Oreman Date: Thu, 6 Aug 2009 18:52:06 -0700 Subject: [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 --- src/Makefile | 1 + src/config/config.c | 256 +++++++++++++++++++++++++++++++++++++++++++++++++ src/core/config.c | 238 --------------------------------------------- src/include/compiler.h | 5 + 4 files changed, 262 insertions(+), 238 deletions(-) create mode 100644 src/config/config.c delete mode 100644 src/core/config.c (limited to 'src') diff --git a/src/Makefile b/src/Makefile index 16759ca01..72b0e64c1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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. diff --git a/src/config/config.c b/src/config/config.c new file mode 100644 index 000000000..3c43dfbc5 --- /dev/null +++ b/src/config/config.c @@ -0,0 +1,256 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + */ + +FILE_LICENCE ( GPL2_OR_LATER ); + +#include +#include + +/** @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 + * config_subsystem.c, 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 + * + */ +#undef XSTR +#undef STR +#define XSTR(s) STR(s) +#define STR(s) #s + +#ifdef BUILD_SERIAL +#include "config/.buildserial.h" +#define BUILD_SERIAL_STR " #" XSTR(BUILD_SERIAL_NUM) +#else +#define BUILD_SERIAL_STR "" +#endif + +#ifdef BUILD_ID +#define BUILD_ID_STR " " BUILD_ID +#else +#define BUILD_ID_STR "" +#endif + +#if defined(BUILD_ID) || defined(BUILD_SERIAL) +#define BUILD_STRING " [build" BUILD_ID_STR BUILD_SERIAL_STR "]" +#else +#define BUILD_STRING "" +#endif + +/* + * Drag in all requested console types + * + */ + +#ifdef CONSOLE_PCBIOS +REQUIRE_OBJECT ( bios_console ); +#endif +#ifdef CONSOLE_SERIAL +REQUIRE_OBJECT ( serial_console ); +#endif +#ifdef CONSOLE_DIRECT_VGA +REQUIRE_OBJECT ( video_subr ); +#endif +#ifdef CONSOLE_BTEXT +REQUIRE_OBJECT ( btext ); +#endif +#ifdef CONSOLE_PC_KBD +REQUIRE_OBJECT ( pc_kbd ); +#endif +#ifdef CONSOLE_SYSLOG +REQUIRE_OBJECT ( syslog ); +#endif +#ifdef CONSOLE_EFI +REQUIRE_OBJECT ( efi_console ); +#endif + +/* + * Drag in all requested network protocols + * + */ +#ifdef NET_PROTO_IPV4 +REQUIRE_OBJECT ( ipv4 ); +#endif + +/* + * Drag in all requested download protocols + * + */ +#ifdef DOWNLOAD_PROTO_TFTP +REQUIRE_OBJECT ( tftp ); +#endif +#ifdef DOWNLOAD_PROTO_NFS +REQUIRE_OBJECT ( nfs ); +#endif +#ifdef DOWNLOAD_PROTO_HTTP +REQUIRE_OBJECT ( http ); +#endif +#ifdef DOWNLOAD_PROTO_HTTPS +REQUIRE_OBJECT ( https ); +#endif +#ifdef DOWNLOAD_PROTO_FTP +REQUIRE_OBJECT ( ftp ); +#endif +#ifdef DOWNLOAD_PROTO_TFTM +REQUIRE_OBJECT ( tftm ); +#endif +#ifdef DOWNLOAD_PROTO_SLAM +REQUIRE_OBJECT ( slam ); +#endif + +/* + * Drag in all requested SAN boot protocols + * + */ +#ifdef SANBOOT_PROTO_ISCSI +REQUIRE_OBJECT ( iscsiboot ); +#endif +#ifdef SANBOOT_PROTO_AOE +REQUIRE_OBJECT ( aoeboot ); +#endif +#ifdef SANBOOT_PROTO_IB_SRP +REQUIRE_OBJECT ( ib_srpboot ); +#endif + +/* + * Drag in all requested resolvers + * + */ +#ifdef DNS_RESOLVER +REQUIRE_OBJECT ( dns ); +#endif +#ifdef NMB_RESOLVER +REQUIRE_OBJECT ( nmb ); +#endif + +/* + * Drag in all requested image formats + * + */ +#ifdef IMAGE_NBI +REQUIRE_OBJECT ( nbi ); +#endif +#ifdef IMAGE_ELF +REQUIRE_OBJECT ( elfboot ); +#endif +#ifdef IMAGE_FREEBSD +REQUIRE_OBJECT ( freebsd ); +#endif +#ifdef IMAGE_MULTIBOOT +REQUIRE_OBJECT ( multiboot ); +#endif +#ifdef IMAGE_AOUT +REQUIRE_OBJECT ( aout ); +#endif +#ifdef IMAGE_WINCE +REQUIRE_OBJECT ( wince ); +#endif +#ifdef IMAGE_PXE +REQUIRE_OBJECT ( pxe_image ); +#endif +#ifdef IMAGE_SCRIPT +REQUIRE_OBJECT ( script ); +#endif +#ifdef IMAGE_BZIMAGE +REQUIRE_OBJECT ( bzimage ); +#endif +#ifdef IMAGE_ELTORITO +REQUIRE_OBJECT ( eltorito ); +#endif +#ifdef IMAGE_COMBOOT +REQUIRE_OBJECT ( comboot ); +REQUIRE_OBJECT ( com32 ); +REQUIRE_OBJECT ( comboot_call ); +REQUIRE_OBJECT ( com32_call ); +REQUIRE_OBJECT ( com32_wrapper ); +REQUIRE_OBJECT ( comboot_resolv ); +#endif +#ifdef IMAGE_EFI +REQUIRE_OBJECT ( efi_image ); +#endif + +/* + * Drag in all requested commands + * + */ +#ifdef AUTOBOOT_CMD +REQUIRE_OBJECT ( autoboot_cmd ); +#endif +#ifdef NVO_CMD +REQUIRE_OBJECT ( nvo_cmd ); +#endif +#ifdef CONFIG_CMD +REQUIRE_OBJECT ( config_cmd ); +#endif +#ifdef IFMGMT_CMD +REQUIRE_OBJECT ( ifmgmt_cmd ); +#endif +#ifdef ROUTE_CMD +REQUIRE_OBJECT ( route_cmd ); +#endif +#ifdef IMAGE_CMD +REQUIRE_OBJECT ( image_cmd ); +#endif +#ifdef DHCP_CMD +REQUIRE_OBJECT ( dhcp_cmd ); +#endif +#ifdef SANBOOT_CMD +REQUIRE_OBJECT ( sanboot_cmd ); +#endif +#ifdef LOGIN_CMD +REQUIRE_OBJECT ( login_cmd ); +#endif +#ifdef TIME_CMD +REQUIRE_OBJECT ( time_cmd ); +#endif +#ifdef DIGEST_CMD +REQUIRE_OBJECT ( digest_cmd ); +#endif +#ifdef PXE_CMD +REQUIRE_OBJECT ( pxe_cmd ); +#endif + +/* + * Drag in miscellaneous objects + * + */ +#ifdef NULL_TRAP +REQUIRE_OBJECT ( nulltrap ); +#endif +#ifdef GDBSERIAL +REQUIRE_OBJECT ( gdbidt ); +REQUIRE_OBJECT ( gdbserial ); +REQUIRE_OBJECT ( gdbstub_cmd ); +#endif +#ifdef GDBUDP +REQUIRE_OBJECT ( gdbidt ); +REQUIRE_OBJECT ( gdbudp ); +REQUIRE_OBJECT ( gdbstub_cmd ); +#endif + +/* + * Drag in objects that are always required, but not dragged in via + * symbol dependencies. + * + */ +REQUIRE_OBJECT ( device ); +REQUIRE_OBJECT ( embedded ); diff --git a/src/core/config.c b/src/core/config.c deleted file mode 100644 index e4c056137..000000000 --- a/src/core/config.c +++ /dev/null @@ -1,238 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2, or (at - * your option) any later version. - */ - -FILE_LICENCE ( GPL2_OR_LATER ); - -#include -#include - -/* - * Build ID string calculations - * - */ -#undef XSTR -#undef STR -#define XSTR(s) STR(s) -#define STR(s) #s - -#ifdef BUILD_SERIAL -#include "config/.buildserial.h" -#define BUILD_SERIAL_STR " #" XSTR(BUILD_SERIAL_NUM) -#else -#define BUILD_SERIAL_STR "" -#endif - -#ifdef BUILD_ID -#define BUILD_ID_STR " " BUILD_ID -#else -#define BUILD_ID_STR "" -#endif - -#if defined(BUILD_ID) || defined(BUILD_SERIAL) -#define BUILD_STRING " [build" BUILD_ID_STR BUILD_SERIAL_STR "]" -#else -#define BUILD_STRING "" -#endif - -/* - * Drag in all requested console types - * - */ - -#ifdef CONSOLE_PCBIOS -REQUIRE_OBJECT ( bios_console ); -#endif -#ifdef CONSOLE_SERIAL -REQUIRE_OBJECT ( serial_console ); -#endif -#ifdef CONSOLE_DIRECT_VGA -REQUIRE_OBJECT ( video_subr ); -#endif -#ifdef CONSOLE_BTEXT -REQUIRE_OBJECT ( btext ); -#endif -#ifdef CONSOLE_PC_KBD -REQUIRE_OBJECT ( pc_kbd ); -#endif -#ifdef CONSOLE_SYSLOG -REQUIRE_OBJECT ( syslog ); -#endif -#ifdef CONSOLE_EFI -REQUIRE_OBJECT ( efi_console ); -#endif - -/* - * Drag in all requested network protocols - * - */ -#ifdef NET_PROTO_IPV4 -REQUIRE_OBJECT ( ipv4 ); -#endif - -/* - * Drag in all requested download protocols - * - */ -#ifdef DOWNLOAD_PROTO_TFTP -REQUIRE_OBJECT ( tftp ); -#endif -#ifdef DOWNLOAD_PROTO_NFS -REQUIRE_OBJECT ( nfs ); -#endif -#ifdef DOWNLOAD_PROTO_HTTP -REQUIRE_OBJECT ( http ); -#endif -#ifdef DOWNLOAD_PROTO_HTTPS -REQUIRE_OBJECT ( https ); -#endif -#ifdef DOWNLOAD_PROTO_FTP -REQUIRE_OBJECT ( ftp ); -#endif -#ifdef DOWNLOAD_PROTO_TFTM -REQUIRE_OBJECT ( tftm ); -#endif -#ifdef DOWNLOAD_PROTO_SLAM -REQUIRE_OBJECT ( slam ); -#endif - -/* - * Drag in all requested SAN boot protocols - * - */ -#ifdef SANBOOT_PROTO_ISCSI -REQUIRE_OBJECT ( iscsiboot ); -#endif -#ifdef SANBOOT_PROTO_AOE -REQUIRE_OBJECT ( aoeboot ); -#endif -#ifdef SANBOOT_PROTO_IB_SRP -REQUIRE_OBJECT ( ib_srpboot ); -#endif - -/* - * Drag in all requested resolvers - * - */ -#ifdef DNS_RESOLVER -REQUIRE_OBJECT ( dns ); -#endif -#ifdef NMB_RESOLVER -REQUIRE_OBJECT ( nmb ); -#endif - -/* - * Drag in all requested image formats - * - */ -#ifdef IMAGE_NBI -REQUIRE_OBJECT ( nbi ); -#endif -#ifdef IMAGE_ELF -REQUIRE_OBJECT ( elfboot ); -#endif -#ifdef IMAGE_FREEBSD -REQUIRE_OBJECT ( freebsd ); -#endif -#ifdef IMAGE_MULTIBOOT -REQUIRE_OBJECT ( multiboot ); -#endif -#ifdef IMAGE_AOUT -REQUIRE_OBJECT ( aout ); -#endif -#ifdef IMAGE_WINCE -REQUIRE_OBJECT ( wince ); -#endif -#ifdef IMAGE_PXE -REQUIRE_OBJECT ( pxe_image ); -#endif -#ifdef IMAGE_SCRIPT -REQUIRE_OBJECT ( script ); -#endif -#ifdef IMAGE_BZIMAGE -REQUIRE_OBJECT ( bzimage ); -#endif -#ifdef IMAGE_ELTORITO -REQUIRE_OBJECT ( eltorito ); -#endif -#ifdef IMAGE_COMBOOT -REQUIRE_OBJECT ( comboot ); -REQUIRE_OBJECT ( com32 ); -REQUIRE_OBJECT ( comboot_call ); -REQUIRE_OBJECT ( com32_call ); -REQUIRE_OBJECT ( com32_wrapper ); -REQUIRE_OBJECT ( comboot_resolv ); -#endif -#ifdef IMAGE_EFI -REQUIRE_OBJECT ( efi_image ); -#endif - -/* - * Drag in all requested commands - * - */ -#ifdef AUTOBOOT_CMD -REQUIRE_OBJECT ( autoboot_cmd ); -#endif -#ifdef NVO_CMD -REQUIRE_OBJECT ( nvo_cmd ); -#endif -#ifdef CONFIG_CMD -REQUIRE_OBJECT ( config_cmd ); -#endif -#ifdef IFMGMT_CMD -REQUIRE_OBJECT ( ifmgmt_cmd ); -#endif -#ifdef ROUTE_CMD -REQUIRE_OBJECT ( route_cmd ); -#endif -#ifdef IMAGE_CMD -REQUIRE_OBJECT ( image_cmd ); -#endif -#ifdef DHCP_CMD -REQUIRE_OBJECT ( dhcp_cmd ); -#endif -#ifdef SANBOOT_CMD -REQUIRE_OBJECT ( sanboot_cmd ); -#endif -#ifdef LOGIN_CMD -REQUIRE_OBJECT ( login_cmd ); -#endif -#ifdef TIME_CMD -REQUIRE_OBJECT ( time_cmd ); -#endif -#ifdef DIGEST_CMD -REQUIRE_OBJECT ( digest_cmd ); -#endif -#ifdef PXE_CMD -REQUIRE_OBJECT ( pxe_cmd ); -#endif - -/* - * Drag in miscellaneous objects - * - */ -#ifdef NULL_TRAP -REQUIRE_OBJECT ( nulltrap ); -#endif -#ifdef GDBSERIAL -REQUIRE_OBJECT ( gdbidt ); -REQUIRE_OBJECT ( gdbserial ); -REQUIRE_OBJECT ( gdbstub_cmd ); -#endif -#ifdef GDBUDP -REQUIRE_OBJECT ( gdbidt ); -REQUIRE_OBJECT ( gdbudp ); -REQUIRE_OBJECT ( gdbstub_cmd ); -#endif - -/* - * Drag in objects that are always required, but not dragged in via - * symbol dependencies. - * - */ -REQUIRE_OBJECT ( device ); -REQUIRE_OBJECT ( embedded ); diff --git a/src/include/compiler.h b/src/include/compiler.h index 5ba7f441c..f481f38ae 100644 --- a/src/include/compiler.h +++ b/src/include/compiler.h @@ -159,10 +159,15 @@ #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 ) -- cgit v1.2.3-55-g7522