Patrick Georgi (patrick@georgi-clan.de) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5485
-gerrit
commit 055d0c7c8ce9a84153655e40d0666a8fb3d6e824 Author: Patrick Georgi patrick.georgi@secunet.com Date: Fri Apr 11 13:25:48 2014 +0200
buildsystem: use more granular dependencies
Filter generated dependencies so they don't point to config.h but to individual files for each Kconfig symbol (as emitted by the kconf tools).
Change-Id: I061bcef62fd9b556be84557080a47766981cffaf Signed-off-by: Patrick Georgi patrick.georgi@secunet.com --- Makefile | 7 ++++++- Makefile.inc | 35 +++++++++++++++++++++++++++++++---- util/fixdep/fixdep | 19 +++++++++++++++++++ util/fixdep/gen_fixdep_cache | 27 +++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile index 1393f08..9d2ea36 100644 --- a/Makefile +++ b/Makefile @@ -265,9 +265,14 @@ define create_cc_template # $4 additional dependencies ifn$(EMPTY)def $(1)-objs_$(2)_template de$(EMPTY)fine $(1)-objs_$(2)_template +$(obj)/$$(1).$(1).d: src/$$(1).$(2) $(obj)/config.h $(4) + mkdir -p $$$$(dir $$$$@) + $(CC) $(3) $$$$(CFLAGS) -MM $$$$< | \ + util/fixdep/fixdep $(FIXDEP_CACHE) $(obj)/config.h $(obj)/config/ > $$$$@ + $(obj)/$$(1).$(1).o: src/$$(1).$(2) $(obj)/config.h $(4) @printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n" - $(CC) $(3) -MMD $$$$(CFLAGS) -c -o $$$$@ $$$$< + $(CC) $(3) $$$$(CFLAGS) -c -o $$$$@ $$$$< en$(EMPTY)def end$(EMPTY)if endef diff --git a/Makefile.inc b/Makefile.inc index fcd680d..6030a25 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -297,21 +297,48 @@ $(obj)/mainboard/$(MAINBOARDDIR)/static.c: $(src)/mainboard/$(MAINBOARDDIR)/devi ramstage-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c romstage-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c
+FIXDEP_CACHE = .fixdep_cache + +-include $(FIXDEP_CACHE).d + +$(FIXDEP_CACHE): + util/fixdep/gen_fixdep_cache Kconfig $@ "" > $@.d + +$(objutil)/%.d: $(objutil)/%.c $(FIXDEP_CACHE) + mkdir -p $(dir $@) + $(HOSTCC) -I$(subst $(objutil)/,util/,$(dir $<)) -I$(dir $<) $(HOSTCFLAGS) -MM $< | \ + util/fixdep/fixdep $(FIXDEP_CACHE) $(obj)/config.h $(obj)/config/ > $@ + +$(obj)/%.ramstage.d $(abspath $(obj))/%.ramstage.d: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H) + mkdir -p $(dir $@) + $(CC) $(CFLAGS) -MM $< | \ + util/fixdep/fixdep $(FIXDEP_CACHE) $(obj)/config.h $(obj)/config/ > $@ + +$(obj)/%.romstage.d $(abspath $(obj))/%.romstage.d: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H) + mkdir -p $(dir $@) + $(CC) $(CFLAGS) -MM $< | \ + util/fixdep/fixdep $(FIXDEP_CACHE) $(obj)/config.h $(obj)/config/ > $@ + +$(obj)/%.bootblock.d $(abspath $(obj))/%.bootblock.d: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H) + mkdir -p $(dir $@) + $(CC) $(bootblock-c-ccopts) $(CFLAGS) -MM $< | \ + util/fixdep/fixdep $(FIXDEP_CACHE) $(obj)/config.h $(obj)/config/ > $@ + $(objutil)/%.o: $(objutil)/%.c @printf " HOSTCC $(subst $(objutil)/,,$(@))\n" - $(HOSTCC) -MMD -I$(subst $(objutil)/,util/,$(dir $<)) -I$(dir $<) $(HOSTCFLAGS) -c -o $@ $< + $(HOSTCC) -I$(subst $(objutil)/,util/,$(dir $<)) -I$(dir $<) $(HOSTCFLAGS) -c -o $@ $<
$(obj)/%.ramstage.o $(abspath $(obj))/%.ramstage.o: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H) @printf " CC $(subst $(obj)/,,$(@))\n" - $(CC) -MMD $(CFLAGS) -c -o $@ $< + $(CC) $(CFLAGS) -c -o $@ $<
$(obj)/%.romstage.o $(abspath $(obj))/%.romstage.o: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H) @printf " CC $(subst $(obj)/,,$(@))\n" - $(CC) -MMD -D__PRE_RAM__ $(CFLAGS) -c -o $@ $< + $(CC) -D__PRE_RAM__ $(CFLAGS) -c -o $@ $<
$(obj)/%.bootblock.o $(abspath $(obj))/%.bootblock.o: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H) @printf " CC $(subst $(obj)/,,$(@))\n" - $(CC) -MMD $(bootblock-c-ccopts) $(CFLAGS) -c -o $@ $< + $(CC) $(bootblock-c-ccopts) $(CFLAGS) -c -o $@ $<
####################################################################### # Clean up rules diff --git a/util/fixdep/fixdep b/util/fixdep/fixdep new file mode 100755 index 0000000..b20c1e6 --- /dev/null +++ b/util/fixdep/fixdep @@ -0,0 +1,19 @@ +#!/bin/bash +# copyright (C) 2014 secunet Security Networks AG +# written by Patrick Georgi patrick.georgi@secunet.com +# Licensed under GPL-v2 +# +# $1: fixdep cache +# $2: config header to prune +# $3: prefix to kconfig includes +# stdin: dependency rule to prune +# stdout: pruned dependency rule + +source $1 + +LINE=$(cat | sed 's,\$,,' |tr -d '\012') +PRE=$(echo $LINE|cut -d: -f1) +POST=$(echo $LINE|cut -d: -f2- | sed "s,<$2>,,") + +printf "$PRE: $POST " +grep -whEo "$SYMBOL_RULE" $POST |sed "s,^$KCONFIG_PREFIX,," |sort -u |tr 'A-Z_' 'a-z/' | sed "s,^.*$,$3&.h," | tr '\012' ' ' diff --git a/util/fixdep/gen_fixdep_cache b/util/fixdep/gen_fixdep_cache new file mode 100755 index 0000000..0923147 --- /dev/null +++ b/util/fixdep/gen_fixdep_cache @@ -0,0 +1,27 @@ +#!/bin/bash +# copyright (C) 2014 secunet Security Networks AG +# written by Patrick Georgi patrick.georgi@secunet.com +# Licensed under GPL-v2 +# +# $1: root Kconfig file +# $2: cache filename +# $3: Kconfig prefix (normally CONFIG_) +# stdout: rule to regenerate cache +OLD_KCONFIGS="" +KCONFIGS=$1 + +# collect all Kconfig files, avoid endless loops +while [ "$OLD_KCONFIGS" != "$KCONFIGS" ]; do + OLD_KCONFIGS=$KCONFIGS + KCONFIGS="$KCONFIGS $(sed '/<source>/ {s,.*<source> "*([^ "]*).*,\1,; p}; d' $OLD_KCONFIGS)" + KCONFIGS="$(echo $KCONFIGS |tr ' ' '\012' |sort -u)" + KCONFIGS="$(ls -d $KCONFIGS 2>/dev/null )" +done +SYMBOLS=$(sed "{s,#.*$,,; /^[[:space:]]*config[[:space:]]*[[:alnum:]_][[:alnum:]_]*[[:space:]]*$/ {s,^[[:space:]]*config[[:space:]]*,$3,; p} };d" $KCONFIGS | sort -u) + +echo "KCONFIG_PREFIX=$3" > $2 +printf "SYMBOL_RULE='($SYMBOLS)'" |tr '\012' '|' >> $2 +echo "" >> $2 + +echo "$2: $KCONFIGS" | tr '\012' ' ' +echo ""