CONFIG_* defines
Rob Landley
rob at landley.net
Thu Sep 8 05:39:03 UTC 2005
On Wednesday 07 September 2005 02:38, Allan Clark wrote:
> >http://www.literateprogramming.com/ifdefs.pdf
>
> You're preaching to the choir here... but then, the Makefile hack is
> still just a hack. Someone said they needed some make-fu... :)
Very much so, in my case.
I'm learning (slowly), but I find mixing declarative an imperative code
together in the same place distasteful, so it's hard to really get in there
and shovel...
> I asusme you are not arguing for
>
> const unsigned char bb_var = 1;
Nope, tried that. Even a static const has space assigned for it and bloats
things. That's why we went with #defines.
There was a discussion about this on the list, starting back in July.
> Is it therefore possible to implement
>
> #define BB_var {0|1}
Do an "svn log -v Makefile" in the main busybox directory, and pay attention
to changesets 10929, 10944, and 11023.
And then to fix "make allnoconfig", get the log of scripts/conf/configdata.c
and look at 11324 and 11329.
> If there is a move, do it for the last time, with some bbconfig.h -foo
> that lets us continue to build, then slowly weed-out the #defines that
> do not conform.
That would be what I'm doing, yes.
Tito sent 11382 to move over four applets just today... (Well, now
yesterday.)
> I assume I'm simply retelling another's wisdom here,
> rather than inventing a fabulous labour-saving device called "wheel".
>
> My real concern is the .config, Kconfig, Config.in stuff: something like
> this does not clash with buildroot, so buildroot could include busybox
> Config.in directly, reducing configuration to a (wow!) single config
> file again. Granted, a REALLY BIG config file, but dependencies upon
> BB_* variables could actually be done then, allowing, for example,
> Qtopia's QPE to require BB_INIT (ie CONFIG_INIT in busybox).
Right now, the top level Makefile contains the following magic:
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/' \
< $< >> $@
echo "#endif" >> $@
I.E. we convert config.h into bb_config.h with sed. At some point in the
future, we may be able to stop #including config.h entirely once all the
symbols get switched over, but the build system will still generate it.
In reality, the changes to the scripts directory are because the linux kernel
config system optimizes away "hidden" directories (which are guarded by other
config symbols), but the ENABLE method still needs to set those symbols to 0,
so it needs the config system to write them out...
There are apparently still some teething troubles with this. (I'd have an
easier time if I had hardware to test the other platforms on, right now I'm
trying to find a fix for a problem I can't personally reproduce...)
Rob
More information about the busybox
mailing list