Merge remote-tracking branch 'remotes/armbru/tags/pull-hw-2015-04-02' into staging
[qemu/qmp-unstable.git] / scripts / make_device_config.sh
blobc1afb3ffaa4d02897e3fe4fb2d94c232f9892018
1 #! /bin/sh
2 # Writes a target device config file to stdout, from a default and from
3 # include directives therein. Also emits Makefile dependencies.
5 # Usage: make_device_config.sh SRC DEPFILE-NAME DEPFILE-TARGET > DEST
7 src=$1
8 dep=$2
9 target=$3
10 src_dir=`dirname $src`
11 all_includes=
13 process_includes () {
14 cat $1 | grep '^include' | \
15 while read include file ; do
16 all_includes="$all_includes $src_dir/$file"
17 process_includes $src_dir/$file
18 done
21 f=$src
22 while [ -n "$f" ] ; do
23 f=`cat $f | tr -d '\r' | awk '/^include / {printf "'$src_dir'/%s ", $2}'`
24 [ $? = 0 ] || exit 1
25 all_includes="$all_includes $f"
26 done
27 process_includes $src
29 cat $src $all_includes | grep -v '^include'
30 echo "$target: $all_includes" > $dep