BB standards for CONFIG_*, ENABLE_* and HAVE_* config options?

Robert P. J. Day rpjday at mindspring.com
Mon Jun 19 18:43:48 UTC 2006


  if i understand this correctly, there's a method to the current
naming convention of BB config options.  originally, there was
CONFIG_*, which would be set by the actual configuration process in
the ".config" file.  these macros would not necessarily be set to have
any value (mostly, though, they would be set to "y"), and they would
be tested with "ifdef".

  from there, we have the newer ENABLE_* options, which are
*specifically* set to either 0 or 1 so that:

1) they can (should?) be tested with only "#if", or
2) they can be incorporated into the actual C conditionals

  finally, looking at networking/interface.c, i see some config macros
of the form "HAVE_*", like HAVE_AFINET, HAVE_AFINET6 and HAVE_AFUNIX.
are these some sort of standard?

  given all of the above, it would seem that there should be a few
rules governing the use of configuration conditionals.  first, there
seems to be little reason to be hard-coding any config values, like
you find in that source file:

#define HAVE_AFINET 1
...
#define HAVE_HWETHER 1
#define HAVE_HWPPP 1

i would think that anything that represents a config option should
either be selectable during the config process, or it should be
removed entirely.  (making that recursive, it would seem that nothing
should conditionally depend on anything that isn't ultimately
user-selectable.)

  next, i'm not sure what's happening with those "HAVE_*" options in
that source file. they're not user-selectable and they're not used
anywhere else.  what are they doing there?

  staying on that note, what is the point of

...
#ifdef CONFIG_FEATURE_IPV6
# define HAVE_AFINET6 1
#else
# undef HAVE_AFINET6
#endif
...

followed by several instances of

#if HAVE_AFINET6

why not just conditionally include based on "CONFIG_FEATURE_IPV6"?
it's effectively the same thing, no? or, perhaps better yet, based on
"ENABLE_FEATURE_IPV6"?

  there's more but, as a start, a few suggestions to clean up just
that source file:

1) remove those initial hard-coded definitions (HAVE_AFINET,
HAVE_HWETHER, HAVE_HWPPP) and all conditionals based on them

2) [personal taste] remove any usage of HAVE_AFINET6 and base the
conditional inclusions on ENABLE_FEATURE_IPV6

3) unless there's a compelling reason to keep it, remove any and all
references to HAVE_AFUNIX since it appears to be perpetually false

  anything obviously silly about any of the above?

rday



More information about the busybox mailing list