summaryrefslogtreecommitdiff
path: root/scripts/gen_build_files.sh
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-06-06 01:53:38 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-06-06 01:53:38 +0200
commitf0f94700610eba964441ce4a112134e03c76eb89 (patch)
tree2823e4cd344df7f85f0cd94dc87f1133d05fcc19 /scripts/gen_build_files.sh
parent6c5bf0d347faded028e15d523c26a0d64c6d3920 (diff)
downloadbusybox-w32-f0f94700610eba964441ce4a112134e03c76eb89.tar.gz
busybox-w32-f0f94700610eba964441ce4a112134e03c76eb89.tar.bz2
busybox-w32-f0f94700610eba964441ce4a112134e03c76eb89.zip
make it possible to keep usage texts in .c files
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'scripts/gen_build_files.sh')
-rwxr-xr-xscripts/gen_build_files.sh26
1 files changed, 25 insertions, 1 deletions
diff --git a/scripts/gen_build_files.sh b/scripts/gen_build_files.sh
index 44e8c1744..647c7daf7 100755
--- a/scripts/gen_build_files.sh
+++ b/scripts/gen_build_files.sh
@@ -10,7 +10,7 @@ srctree="$1"
10# (Re)generate include/applets.h 10# (Re)generate include/applets.h
11src="$srctree/include/applets.src.h" 11src="$srctree/include/applets.src.h"
12dst="include/applets.h" 12dst="include/applets.h"
13s=`sed -n 's@^//applet:@@p' -- */*.c */*/*.c` 13s=`sed -n 's@^//applet:@@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c`
14echo "/* DO NOT EDIT. This file is generated from applets.src.h */" >"$dst.$$.tmp" 14echo "/* DO NOT EDIT. This file is generated from applets.src.h */" >"$dst.$$.tmp"
15# Why "IFS='' read -r REPLY"?? 15# Why "IFS='' read -r REPLY"??
16# This atrocity is needed to read lines without mangling. 16# This atrocity is needed to read lines without mangling.
@@ -27,6 +27,30 @@ else
27 mv -- "$dst.$$.tmp" "$dst" 27 mv -- "$dst.$$.tmp" "$dst"
28fi 28fi
29 29
30# (Re)generate include/usage.h
31src="$srctree/include/usage.src.h"
32dst="include/usage.h"
33# We add line continuation backslash after each line,
34# and insert empty line before each line which doesn't start
35# with space or tab
36# (note: we need to use \\\\ because of ``)
37s=`sed -n -e 's@^//usage:\([ \t].*\)$@\1 \\\\@p' -e 's@^//usage:\([^ \t].*\)$@\n\1 \\\\@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c`
38echo "/* DO NOT EDIT. This file is generated from usage.src.h */" >"$dst.$$.tmp"
39# Why "IFS='' read -r REPLY"??
40# This atrocity is needed to read lines without mangling.
41# IFS='' prevents whitespace trimming,
42# -r suppresses backslash handling.
43while IFS='' read -r REPLY; do
44 test x"$REPLY" = x"INSERT" && REPLY="$s"
45 printf "%s\n" "$REPLY"
46done <"$src" >>"$dst.$$.tmp"
47if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then
48 rm -- "$dst.$$.tmp"
49else
50 echo " GEN $dst"
51 mv -- "$dst.$$.tmp" "$dst"
52fi
53
30# (Re)generate */Kbuild and */Config.in 54# (Re)generate */Kbuild and */Config.in
31find -type d | while read -r d; do 55find -type d | while read -r d; do
32 d="${d#./}" 56 d="${d#./}"