blob: 7242707819458032839155ce77a439b4d0b54c73 [file] [log] [blame]
Paul Brookbd9141b2010-11-26 18:47:45 +00001#! /bin/sh
2# Construct a target device config file from a default, pulling in any
3# files from include directives.
4
5dest=$1.tmp
Andreas Färber88070802013-02-21 16:26:46 +01006dep=`dirname $1`-`basename $1`.d
Paul Brookbd9141b2010-11-26 18:47:45 +00007src=$2
8src_dir=`dirname $src`
9all_includes=
10
11process_includes () {
12 cat $1 | grep '^include' | \
13 while read include file ; do
14 all_includes="$all_includes $src_dir/$file"
15 process_includes $src_dir/$file
16 done
17}
18
19f=$src
20while [ -n "$f" ] ; do
Gerd Hoffmannf4ece402013-02-01 10:48:34 +010021 f=`cat $f | tr -d '\r' | awk '/^include / {printf "'$src_dir'/%s ", $2}'`
Paul Brookcf669242010-11-27 00:43:04 +000022 [ $? = 0 ] || exit 1
Paul Brookbd9141b2010-11-26 18:47:45 +000023 all_includes="$all_includes $f"
24done
25process_includes $src > $dest
26
27cat $src $all_includes | grep -v '^include' > $dest
Andreas Färber1b304812013-02-21 16:26:45 +010028echo "$1: $all_includes" > $dep