New USE() macros

For each CONFIG_SYMBOL, include/bb_config.h now has both ENABLE_SYMBOL
and USE_SYMBOL(x).  ENABLE_SYMBOL is still always defined (1 or 0) so that
if(ENABLE) should optimize out when it's zero.  The USE_SYMBOL(X) will only
splice in X if the symbol is defined, otherwise it'll be empty.

Thus we can convert this:

#ifdef CONFIG_ARGS
    opt = bb_getopt_ulflags(argc, argv, "ab:c"
#ifdef CONFIG_THINGY
        "d:"
#endif
        , &bvalue
#ifdef CONFIG_THINGY
        , &thingy
#endif
    );
#endif

into this:
    if (ENABLE_ARGS) {
        opt = bb_getopt_ulflags(argc, argv, "ab:c" USE_THINGY("d:"), &bvalue
                USE_THINGY(, &thingy));
    }

And it should produce the same code.

Unlike the old versions in include/_usage.h, the new USE_SYMBOL(x) can handle
commas in its arguments (as shown above).  (The _usage.h file is obsolete and
no longer generated.)

Nobody should need to include config.h directly anymore, bb_config.h should
define all the configuration stuff we need.  Someday, the CONFIG_SYMBOL
versions should go away in favor of ENABLE_SYMBOL and USE_SYMBOL().

Thanks to vodz for the new version of bb_mkdep.c that works with function
macros.
This commit is contained in:
Rob Landley 2006-02-13 19:16:41 +00:00
parent f251ec6847
commit 7bfa88f315
3 changed files with 885 additions and 98 deletions

View File

@ -185,7 +185,6 @@ randconfig: scripts/config/conf
allyesconfig: scripts/config/conf
@./scripts/config/conf -y $(CONFIG_CONFIG_IN)
sed -i -r -e "s/^(USING_CROSS_COMPILER)=.*/# \1 is not set/" .config
echo "CONFIG_FEATURE_SHARED_BUSYBOX=y" >> .config
@./scripts/config/conf -o $(CONFIG_CONFIG_IN)
allnoconfig: scripts/config/conf
@ -197,7 +196,7 @@ allnoconfig: scripts/config/conf
defconfig: scripts/config/conf
@./scripts/config/conf -y $(CONFIG_CONFIG_IN)
sed -i -r -e "s/^(USING_CROSS_COMPILER|CONFIG_(DEBUG.*|STATIC|SELINUX|BUILD_(AT_ONCE|LIBBUSYBOX)|FEATURE_(DEVFS|FULL_LIBBUSYBOX|SHARED_BUSYBOX|MTAB_SUPPORT|CLEAN_UP)))=.*/# \1 is not set/" .config
sed -i -r -e "s/^(USING_CROSS_COMPILER|CONFIG_(DEBUG.*|STATIC|SELINUX|BUILD_(AT_ONCE|LIBBUSYBOX)|FEATURE_(DEVFS|FULL_LIBBUSYBOX|SHARED_BUSYBOX|MTAB_SUPPORT|CLEAN_UP|UDHCP_DEBUG)))=.*/# \1 is not set/" .config
@./scripts/config/conf -o $(CONFIG_CONFIG_IN)
@ -387,7 +386,7 @@ docs/busybox.net/BusyBox.html: docs/busybox.pod
scripts/bb_mkdep: $(top_srcdir)/scripts/bb_mkdep.c
$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
DEP_INCLUDES := include/config.h include/bb_config.h include/_usage.h
DEP_INCLUDES := include/config.h include/bb_config.h
ifeq ($(strip $(CONFIG_BBCONFIG)),y)
DEP_INCLUDES += include/bbconfigopts.h
@ -414,21 +413,13 @@ include/config.h: .config
include/bb_config.h: include/config.h
@echo -e "#ifndef BB_CONFIG_H\n#define BB_CONFIG_H" > $@
@sed -e 's/#undef CONFIG_\(.*\)/#define ENABLE_\1 0/' \
-e 's/#define CONFIG_\(.*\)/#define CONFIG_\1\n#define ENABLE_\1/' \
< $< >> $@
@sed -e h -e 's/#undef CONFIG_\(.*\)/#define ENABLE_\1 0/p' -e g \
-e 's/#undef CONFIG_\(.*\)/#define USE_\1(...)/p' -e g \
-e 's/#define CONFIG_\([^ ]*\).*/#define ENABLE_\1 1/p' -e g -e \
's/#define CONFIG_\([^ ]*\).*/#define USE_\1(...) __VA_ARGS__/p' \
-e g $< >> $@
@echo "#endif" >> $@
# Create macros for usage.h, e.g.:
#if ENABLE_HAVE_DOT_CONFIG
#define USAGE_HAVE_DOT_CONFIG(a) a
#else
#define USAGE_HAVE_DOT_CONFIG(a)
#endif
include/_usage.h: .config
$(disp_gen)
$(Q)awk '/CONFIG|BB_APPLET/{gsub("#[[:space:]]*|=y|.*CONFIG_|.*BB_APPLET_","");if(!/=/){print("#if ENABLE_"$$1"\n#define USAGE_"$$1"(a) a\n#else\n#define USAGE_"$$1"(a)\n#endif");}}' $(<) > $(@)
clean:
- $(MAKE) -C scripts/config $@
- $(RM_F) docs/busybox.dvi docs/busybox.ps \

View File

@ -78,9 +78,4 @@
# endif
#endif
/* include USAGE_APPLET_x helper macros for usage.h. */
/*
#include "_usage.h"
*/
#endif /* platform.h */

File diff suppressed because it is too large Load Diff