summaryrefslogtreecommitdiff
path: root/scripts/gen_build_files.sh
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-06-06 00:53:45 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-06-06 00:53:45 +0200
commit6c5bf0d347faded028e15d523c26a0d64c6d3920 (patch)
tree9dbe0229ec0d941c9efabb88571e6140d8e71951 /scripts/gen_build_files.sh
parent0e5ba0843b86a78d2d98a5fbaac8d33fe041f10e (diff)
downloadbusybox-w32-6c5bf0d347faded028e15d523c26a0d64c6d3920.tar.gz
busybox-w32-6c5bf0d347faded028e15d523c26a0d64c6d3920.tar.bz2
busybox-w32-6c5bf0d347faded028e15d523c26a0d64c6d3920.zip
make it possible to have include/applets.h-esque entries in .c files
As an example, bunzip2 and bzcat is changed to use it. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'scripts/gen_build_files.sh')
-rwxr-xr-xscripts/gen_build_files.sh31
1 files changed, 23 insertions, 8 deletions
diff --git a/scripts/gen_build_files.sh b/scripts/gen_build_files.sh
index b3aa132a3..44e8c1744 100755
--- a/scripts/gen_build_files.sh
+++ b/scripts/gen_build_files.sh
@@ -7,6 +7,27 @@ cd -- "$2" || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
7 7
8srctree="$1" 8srctree="$1"
9 9
10# (Re)generate include/applets.h
11src="$srctree/include/applets.src.h"
12dst="include/applets.h"
13s=`sed -n 's@^//applet:@@p' -- */*.c */*/*.c`
14echo "/* DO NOT EDIT. This file is generated from applets.src.h */" >"$dst.$$.tmp"
15# Why "IFS='' read -r REPLY"??
16# This atrocity is needed to read lines without mangling.
17# IFS='' prevents whitespace trimming,
18# -r suppresses backslash handling.
19while IFS='' read -r REPLY; do
20 test x"$REPLY" = x"INSERT" && REPLY="$s"
21 printf "%s\n" "$REPLY"
22done <"$src" >>"$dst.$$.tmp"
23if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then
24 rm -- "$dst.$$.tmp"
25else
26 echo " GEN $dst"
27 mv -- "$dst.$$.tmp" "$dst"
28fi
29
30# (Re)generate */Kbuild and */Config.in
10find -type d | while read -r d; do 31find -type d | while read -r d; do
11 d="${d#./}" 32 d="${d#./}"
12 src="$srctree/$d/Kbuild.src" 33 src="$srctree/$d/Kbuild.src"
@@ -15,17 +36,12 @@ find -type d | while read -r d; do
15 #echo " CHK $dst" 36 #echo " CHK $dst"
16 37
17 s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c` 38 s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c`
18 echo "# DO NOT EDIT. This file is generated from Kbuild.src" >"$dst.$$.tmp"
19 39
20 # Why "IFS='' read -r REPLY"?? 40 echo "# DO NOT EDIT. This file is generated from Kbuild.src" >"$dst.$$.tmp"
21 # This atrocity is needed to read lines without mangling.
22 # IFS='' prevents whitespace trimming,
23 # -r suppresses backslash handling.
24 while IFS='' read -r REPLY; do 41 while IFS='' read -r REPLY; do
25 test x"$REPLY" = x"INSERT" && REPLY="$s" 42 test x"$REPLY" = x"INSERT" && REPLY="$s"
26 printf "%s\n" "$REPLY" 43 printf "%s\n" "$REPLY"
27 done <"$src" >>"$dst.$$.tmp" 44 done <"$src" >>"$dst.$$.tmp"
28
29 if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then 45 if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then
30 rm -- "$dst.$$.tmp" 46 rm -- "$dst.$$.tmp"
31 else 47 else
@@ -40,13 +56,12 @@ find -type d | while read -r d; do
40 #echo " CHK $dst" 56 #echo " CHK $dst"
41 57
42 s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c` 58 s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c`
43 echo "# DO NOT EDIT. This file is generated from Config.src" >"$dst.$$.tmp"
44 59
60 echo "# DO NOT EDIT. This file is generated from Config.src" >"$dst.$$.tmp"
45 while IFS='' read -r REPLY; do 61 while IFS='' read -r REPLY; do
46 test x"$REPLY" = x"INSERT" && REPLY="$s" 62 test x"$REPLY" = x"INSERT" && REPLY="$s"
47 printf "%s\n" "$REPLY" 63 printf "%s\n" "$REPLY"
48 done <"$src" >>"$dst.$$.tmp" 64 done <"$src" >>"$dst.$$.tmp"
49
50 if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then 65 if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then
51 rm -- "$dst.$$.tmp" 66 rm -- "$dst.$$.tmp"
52 else 67 else