thoughts on coalescing libbb/ source files

Robert P. J. Day rpjday at mindspring.com
Mon Mar 27 11:00:28 PST 2006


On Mon, 27 Mar 2006, Rob Landley wrote:

> On Monday 27 March 2006 8:43 am, Paul Fox wrote:
> >  >   it would seem to make more sense to pack all these error routines
> >  > into a single source file (called "bb_error.c"?) so one could, if one
> >  > wanted, peruse all of those related routines by scrolling through a
> >  > single file, no?  at the very least, i don't see any immediate
> >  > drawback to it but maybe i'm just not looking closely enough.
> >
> > it does seem as if some sort of multi-source technique (i.e., one
> > source file, with preprocessor controls to allow rendering many
> > different small objects) could be useful.
>
> We already do that.  Look at xfuncs.c.
>
> (It would be nice if there was a less ugly way to do this, of course...)

a cleaner variation of the following will have the same effect (i'm
not done yet, so no sniping at the quality of code. :-)

=========================
MULTISRCS := $(shell grep -l "^\#ifdef L_" $(wildcard $(srcdir)/*.c))
MULTIOBJS := $(addsuffix .o,$(shell grep -h "^\#ifdef L_" $(wildcard $(srcdir)/*.c) | sed -e "s/^\#ifdef L_//"))
${MULTIOBJS} := $(patsubst %,${LIBBB_DIR}/%, ${MULTIOBJS})

allobjs: ${MULTIOBJS}

${MULTIOBJS} : ${MULTISRCS}
	echo CC -DL_$(notdir $@) $^
=========================

  this would replace *all* of the explicit multi-object rules in
libbb/Makefile.in.

rday


More information about the busybox mailing list