[coreboot-gerrit] Patch set updated for coreboot: 429a6bb buildsystem: use more granular dependencies

Patrick Georgi (patrick@georgi-clan.de) gerrit at coreboot.org
Sat May 10 14:30:58 CEST 2014


Patrick Georgi (patrick at georgi-clan.de) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5485

-gerrit

commit 429a6bbc087b6d791d4269afb3d9ed34da1cbf54
Author: Patrick Georgi <patrick.georgi at 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).
    
    FIXME: uses $(CC) which might not be what we want anymore.
    Also: create separate dependency files for rom/ramstage/smm/...?
    
    Change-Id: I061bcef62fd9b556be84557080a47766981cffaf
    Signed-off-by: Patrick Georgi <patrick.georgi at secunet.com>
---
 Makefile                     |  7 ++++++-
 Makefile.inc                 | 33 ++++++++++++++++++++++++++++++---
 util/fixdep/fixdep           | 19 +++++++++++++++++++
 util/fixdep/gen_fixdep_cache | 27 +++++++++++++++++++++++++++
 4 files changed, 82 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index c9648c0..a8dcda0 100644
--- a/Makefile
+++ b/Makefile
@@ -240,9 +240,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_$(1)) $(3) -MMD $$$$(CFLAGS_$(1)) -c -o $$$$@ $$$$<
+	$(CC_$(1)) $(3) $$$$(CFLAGS_$(1)) -c -o $$$$@ $$$$<
 en$(EMPTY)def
 end$(EMPTY)if
 endef
diff --git a/Makefile.inc b/Makefile.inc
index 3205a10..7949b35 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -309,9 +309,36 @@ $(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"
@@ -319,11 +346,11 @@ $(obj)/%.ramstage.o $(abspath $(obj))/%.ramstage.o: $(obj)/%.c $(obj)/config.h $
 
 $(obj)/%.romstage.o $(abspath $(obj))/%.romstage.o: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H)
 	@printf "    CC         $(subst $(obj)/,,$(@))\n"
-	$(CC_romstage) -MMD -D__PRE_RAM__ $(CFLAGS_romstage) -c -o $@ $<
+	$(CC_romstage) -D__PRE_RAM__ $(CFLAGS_romstage) -c -o $@ $<
 
 $(obj)/%.bootblock.o $(abspath $(obj))/%.bootblock.o: $(obj)/%.c $(obj)/config.h $(OPTION_TABLE_H)
 	@printf "    CC         $(subst $(obj)/,,$(@))\n"
-	$(CC_bootblock) -MMD $(bootblock-c-ccopts) $(CFLAGS_bootblock) -c -o $@ $<
+	$(CC_bootblock) $(bootblock-c-ccopts) $(CFLAGS_bootblock) -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 at 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 at 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 ""



More information about the coreboot-gerrit mailing list