@@ -1,6 +1,8 @@
#! /bin/sh
# Construct a target device config file from a default, pulling in any
-# files from include directives.
+# files from include directives. The include files are inlined in the order
+# they are found in the source file so you can reverse a sub-set of
+# settings afterwards.
dest=$1.tmp
dep=`dirname $1`-`basename $1`.d
@@ -8,21 +10,26 @@ src=$2
src_dir=`dirname $src`
all_includes=
-process_includes () {
- cat $1 | grep '^include' | \
- while read include file ; do
- all_includes="$all_includes $src_dir/$file"
- process_includes $src_dir/$file
- done
+process_file () {
+ local in=$1
+ local out=$2
+ while read first second; do
+ if [ "$first" = "include" ]; then
+ local inc="$src_dir/$second"
+ all_includes="$all_includes $inc"
+ echo "# include file: $inc" >> $out
+ process_file $inc $out
+ echo "# end of include: $inc" >> $out
+ else
+ if [ "x$second" = "x" ]; then
+ echo $first >> $out
+ else
+ echo "$first $second" >> $out
+ fi
+ fi
+ done < $in
}
-f=$src
-while [ -n "$f" ] ; do
- f=`cat $f | tr -d '\r' | awk '/^include / {printf "'$src_dir'/%s ", $2}'`
- [ $? = 0 ] || exit 1
- all_includes="$all_includes $f"
-done
-process_includes $src > $dest
-
-cat $src $all_includes | grep -v '^include' > $dest
+echo "# This file is auto-generated by make_device_config.sh" > $dest
+process_file $src $dest
echo "$1: $all_includes" > $dep
Previously we processed all the includes at first and then just concatenated them to the end of the eventual file. This meant if you wanted to include a set of configs but only turn off some you couldn't. Now you can do (for example): # We support most of the 32 bit boards so need all their config include arm-softmmu.mak # we explicitly disable ones that require old ARMv5 support CONFIG_ARMV5_BOARDS=n Signed-off-by: Alex Bennée <alex.bennee@linaro.org>