Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Denys Vlasenko | 572b9a3 | 2010-05-09 16:20:52 +0200 | [diff] [blame] | 3 | test $# -ge 2 || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; } |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 4 | |
| 5 | # cd to objtree |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 6 | cd -- "$2" || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; } |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 7 | |
| 8 | srctree="$1" |
| 9 | |
Denys Vlasenko | 572b9a3 | 2010-05-09 16:20:52 +0200 | [diff] [blame] | 10 | find -type d | while read; do |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 11 | d="$REPLY" |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 12 | |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 13 | src="$srctree/$d/Kbuild.src" |
| 14 | dst="$d/Kbuild" |
| 15 | if test -f "$src"; then |
| 16 | echo " CHK $dst" |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 17 | |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 18 | s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c` |
| 19 | echo "# DO NOT EDIT. This file is generated from Kbuild.src" >"$dst.$$.tmp" |
| 20 | while read; do |
| 21 | test x"$REPLY" = x"INSERT" && REPLY="$s" |
| 22 | printf "%s\n" "$REPLY" |
| 23 | done <"$src" >>"$dst.$$.tmp" |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 24 | |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 25 | if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then |
| 26 | rm -- "$dst.$$.tmp" |
| 27 | else |
| 28 | echo " GEN $dst" |
| 29 | mv -- "$dst.$$.tmp" "$dst" |
| 30 | fi |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 31 | fi |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 32 | |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 33 | src="$srctree/$d/Config.src" |
| 34 | dst="$d/Config.in" |
| 35 | if test -f "$src"; then |
| 36 | echo " CHK $dst" |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 37 | |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 38 | s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c` |
| 39 | echo "# DO NOT EDIT. This file is generated from Config.src" >"$dst.$$.tmp" |
| 40 | while read; do |
| 41 | test x"$REPLY" = x"INSERT" && REPLY="$s" |
| 42 | printf "%s\n" "$REPLY" |
| 43 | done <"$src" >>"$dst.$$.tmp" |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 44 | |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 45 | if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then |
| 46 | rm -- "$dst.$$.tmp" |
| 47 | else |
| 48 | echo " GEN $dst" |
| 49 | mv -- "$dst.$$.tmp" "$dst" |
| 50 | fi |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 51 | fi |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 52 | |
| 53 | done |
| 54 | |
| 55 | # Last read failed. This is normal. Don't exit with its error code: |
| 56 | exit 0 |