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