[PATCH] make it possible to keep Config/Kbuild snippets in *.c files
Rob Landley
rob at landley.net
Fri May 14 06:22:45 UTC 2010
On Sunday 09 May 2010 09:19:58 Denys Vlasenko wrote:
> On Sunday 09 May 2010 07:31, Rob Landley wrote:
> > I note that CONFIG_APPNAME += appname.o is the common case, which could
> > presumably be generated automatically for 90% of the commands. (You only
> > really need to specify something like this when there's more than one .o
> > file, or if the .o file is a different name...)
>
> Yes, de do have those 10%
>
> > Again, this looks like a default case. If you're going to do this for
> > more than one directory, possibly this should be emitted by the script
> > rather than appended to, and only non-default stuff should go in here.
> >
> > The Config.src file had a reason to exist because it was naming the menu,
> > but this one isn't actually doing anything.
>
> applets/ and archival/ have non-trivial Kbuilds
>
> > Also, since these files are generated you don't really need one per
> > directory. You could just make one big one. (Which brings us back to the
> > generated directory, mentioned earlier.)
> >
> > Still, that sort of thing could easily be done in stages. (Cleanup on
> > top of cleanup, this is fine for now...) The important thing is getting
> > the syntax that goes into the .c files right, so that conversion doesn't
> > have to be redone.
>
> Right.
>
> > This rebuilds every time. Wouldn't it be better to do dependencies on
> > the .c files, ala:
> >
> > gen_build_files: findutils/*.c
>
> Tried that:
>
> gen_build_files: $(wildcard */*.c)
>
> It attempted to rebuild a host tool:
>
> $ make
> HOSTCC scripts/basic/fixdep
> HOSTCC scripts/basic/split-include
> HOSTCC scripts/basic/docproc
> HOSTCC applets/usage
> applets/usage.c:11:22: error: autoconf.h: No such file or directory
> In file included from applets/usage.c:27:
> include/applets.h:70: error: expected ',' or ';' before 'IF_TEST'
> make[2]: *** [applets/usage] Error 1
> make[1]: *** [applets_dir] Error 2
> make: *** [include/autoconf.h] Error 2
>
> > > # To make sure we do not include .config for any of the *config
> > > targets # catch them early, and hand them over to
> > > scripts/kconfig/Makefile # It is allowed to specify more targets when
> > > calling make, including @@ -428,7 +433,7 @@ ifeq ($(config-targets),1)
> > > -include $(srctree)/arch/$(ARCH)/Makefile
> > > export KBUILD_DEFCONFIG
> > >
> > > -config %config: scripts_basic outputmakefile FORCE
> > > +config %config: scripts_basic outputmakefile gen_build_files FORCE
> > > $(Q)mkdir -p include
> > > $(Q)$(MAKE) $(build)=scripts/kconfig $@
> > > $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease
> > > @@ -443,7 +448,7 @@ ifeq ($(KBUILD_EXTMOD),)
> > > # Carefully list dependencies so we do not try to build scripts twice
> > > # in parrallel
> > > PHONY += scripts
> > > -scripts: scripts_basic include/config/MARKER
> > > +scripts: gen_build_files scripts_basic include/config/MARKER
> > > $(Q)$(MAKE) $(build)=$(@)
> > >
> > > scripts_basic: include/autoconf.h
> >
> > It seems like that first hunk would have been sufficient, but the busybox
> > makefiles have always been a bit overcomplicated, haven't they?
>
> (1) I don't know.
> (2) Yes.
>
> > > diff -ad -urpN busybox.0/scripts/gen_build_files.sh
> > > busybox.1/scripts/gen_build_files.sh ---
> > > busybox.0/scripts/gen_build_files.sh 1970-01-01
> > > 01:00:00.000000000 +0100 +++ busybox.1/scripts/gen_build_files.sh
> > > 2010-05-09 03:58:09.000000000 +0200 @@ -0,0 +1,51 @@
> > > +#!/bin/sh
> > > +
> > > +test $# -ge 2 || exit 1
> > > +
> >
> > Might want to emit a usage message there. Just a thought.
>
> Ok. New version of the script:
>
>
> #!/bin/sh
>
> test $# -ge 2 || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
>
> # cd to objtree
> cd "$2" || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
>
> srctree="$1"
>
> find -type d | while read; do
> d="$REPLY"
To get this technique to stop modifying the data going through it, you have to
export IFS="$(echo -e "\n")" to get it to stop trimming leading spaces, and
then you have to feed -r to the read command to get it to stop doing this:
+ PATH="$(pwd)/distcc_links" "$(which distccd)" --no-detach --daemon --
listen 127.0.0.1 -a 127.0.0.1 -p $PORT --jobs $CPUS --log-stderr --verbose
2>distccd.log &
- PATH="$(pwd)/distcc_links" "$(which distccd)" --no-detach --daemon \
- --listen 127.0.0.1 -a 127.0.0.1 -p $PORT --jobs $CPUS \
- --log-stderr --verbose 2>distccd.log &
+DISTCC_PATH="$(which $ARCH-cc 2>/dev/null | sed 's@(.*)/.*@1@')"
-DISTCC_PATH="$(which $ARCH-cc 2>/dev/null | sed 's@\(.*\)/.*@\1@')"
FYI.
Rob
--
Latency is more important than throughput. It's that simple. - Linus Torvalds
More information about the busybox
mailing list