handling multi-object source files in libbb/

Robert P. J. Day rpjday at mindspring.com
Tue Mar 28 14:20:00 UTC 2006

 the following basic structure would appear to handle building
multiple object files from a single source file in libbb/:

define gen-obj-names
$(addsuffix .o,$(sort $(shell grep -h "^\#ifdef L_" ${1} | sed -e "s/^\#ifdef L_"//)))

define multisrc-rule-template
$(call gen-obj-names,${1}) : ${1}
	gcc -DL_$$(basename $$@) $$< -o $$@

MULTISRCS := $(shell grep -l "^\#ifdef L_" $(wildcard *.c))
$(foreach src,${MULTISRCS},$(eval $(call multisrc-rule-template,${src})))

  i can whip up a corresponding patch if there's interest.


More information about the busybox mailing list