Paul Brook | bd9141b | 2010-11-26 18:47:45 +0000 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | # Construct a target device config file from a default, pulling in any |
| 3 | # files from include directives. |
| 4 | |
| 5 | dest=$1.tmp |
Andreas Färber | 8807080 | 2013-02-21 16:26:46 +0100 | [diff] [blame] | 6 | dep=`dirname $1`-`basename $1`.d |
Paul Brook | bd9141b | 2010-11-26 18:47:45 +0000 | [diff] [blame] | 7 | src=$2 |
| 8 | src_dir=`dirname $src` |
| 9 | all_includes= |
| 10 | |
| 11 | process_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 | |
| 19 | f=$src |
| 20 | while [ -n "$f" ] ; do |
Gerd Hoffmann | f4ece40 | 2013-02-01 10:48:34 +0100 | [diff] [blame] | 21 | f=`cat $f | tr -d '\r' | awk '/^include / {printf "'$src_dir'/%s ", $2}'` |
Paul Brook | cf66924 | 2010-11-27 00:43:04 +0000 | [diff] [blame] | 22 | [ $? = 0 ] || exit 1 |
Paul Brook | bd9141b | 2010-11-26 18:47:45 +0000 | [diff] [blame] | 23 | all_includes="$all_includes $f" |
| 24 | done |
| 25 | process_includes $src > $dest |
| 26 | |
| 27 | cat $src $all_includes | grep -v '^include' > $dest |
Andreas Färber | 1b30481 | 2013-02-21 16:26:45 +0100 | [diff] [blame] | 28 | echo "$1: $all_includes" > $dep |