diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-05-09 04:22:48 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-05-09 04:22:48 +0200 |
| commit | 7fb68f199f037cb69363c8df5c934a27adc699f7 (patch) | |
| tree | 2eb01a3bc4b3caf6bd7dd4fed6984716fd7ca89a /scripts | |
| parent | 6774386d95cec54258f23f69bc287c99e205ebdf (diff) | |
| download | busybox-w32-7fb68f199f037cb69363c8df5c934a27adc699f7.tar.gz busybox-w32-7fb68f199f037cb69363c8df5c934a27adc699f7.tar.bz2 busybox-w32-7fb68f199f037cb69363c8df5c934a27adc699f7.zip | |
make it possible to keep Config/Kbuild snippets in *.c files
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/gen_build_files.sh | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/scripts/gen_build_files.sh b/scripts/gen_build_files.sh new file mode 100644 index 000000000..300d90c2a --- /dev/null +++ b/scripts/gen_build_files.sh | |||
| @@ -0,0 +1,55 @@ | |||
| 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 | ||
