5d6b423c5c
QEMU source code with CRLF line endings which is quite common on windows hosts fails with current make_device_config.sh. The awk script gets the name of the included file with \r, so instead of pci.mak it will search for pci.mak\r which of course does not work. Fix this by removing any \r. v2: Avoid using sub() and \r with awk because they are unsupported on some platforms. Use tr to remove \r. This new solution improves portability and was suggested by Paolo Bonzini. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Acked-by: Andreas Färber <andreas.faerber@web.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
29 lines
643 B
Bash
29 lines
643 B
Bash
#! /bin/sh
|
|
# Construct a target device config file from a default, pulling in any
|
|
# files from include directives.
|
|
|
|
dest=$1.tmp
|
|
dep=$1.d
|
|
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
|
|
}
|
|
|
|
f=$src
|
|
while [ -n "$f" ] ; do
|
|
f=`tr -d '\r' < $f | awk '/^include / {ORS=" "; print "'$src_dir'/" $2}'`
|
|
[ $? = 0 ] || exit 1
|
|
all_includes="$all_includes $f"
|
|
done
|
|
process_includes $src > $dest
|
|
|
|
cat $src $all_includes | grep -v '^include' > $dest
|
|
echo "$1: $all_includes" > $dep
|