Statistics
| Branch: | Revision:

root / scripts / make_device_config.sh @ f53ec699

History | View | Annotate | Download (667 Bytes)

1 bd9141bb Paul Brook
#! /bin/sh
2 bd9141bb Paul Brook
# Construct a target device config file from a default, pulling in any
3 bd9141bb Paul Brook
# files from include directives.
4 bd9141bb Paul Brook
5 bd9141bb Paul Brook
dest=$1.tmp
6 88070801 Andreas Färber
dep=`dirname $1`-`basename $1`.d
7 bd9141bb Paul Brook
src=$2
8 bd9141bb Paul Brook
src_dir=`dirname $src`
9 bd9141bb Paul Brook
all_includes=
10 bd9141bb Paul Brook
11 bd9141bb Paul Brook
process_includes () {
12 bd9141bb Paul Brook
  cat $1 | grep '^include' | \
13 bd9141bb Paul Brook
  while read include file ; do
14 bd9141bb Paul Brook
    all_includes="$all_includes $src_dir/$file"
15 bd9141bb Paul Brook
    process_includes $src_dir/$file
16 bd9141bb Paul Brook
  done
17 bd9141bb Paul Brook
}
18 bd9141bb Paul Brook
19 bd9141bb Paul Brook
f=$src
20 bd9141bb Paul Brook
while [ -n "$f" ] ; do
21 f4ece404 Gerd Hoffmann
  f=`cat $f | tr -d '\r' | awk '/^include / {printf "'$src_dir'/%s ", $2}'`
22 cf66924f Paul Brook
  [ $? = 0 ] || exit 1
23 bd9141bb Paul Brook
  all_includes="$all_includes $f"
24 bd9141bb Paul Brook
done
25 bd9141bb Paul Brook
process_includes $src > $dest
26 bd9141bb Paul Brook
27 bd9141bb Paul Brook
cat $src $all_includes | grep -v '^include' > $dest
28 1b304817 Andreas Färber
echo "$1: $all_includes" > $dep