aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorGravatar Denys Vlasenko <vda.linux@googlemail.com>2010-06-06 01:53:38 +0200
committerGravatar Denys Vlasenko <vda.linux@googlemail.com>2010-06-06 01:53:38 +0200
commitf0f94700610eba964441ce4a112134e03c76eb89 (patch)
tree2823e4cd344df7f85f0cd94dc87f1133d05fcc19 /scripts
parent6c5bf0d347faded028e15d523c26a0d64c6d3920 (diff)
downloadbusybox-f0f94700610eba964441ce4a112134e03c76eb89.tar.gz
busybox-f0f94700610eba964441ce4a112134e03c76eb89.tar.bz2
make it possible to keep usage texts in .c files
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.IMA2
-rwxr-xr-xscripts/gen_build_files.sh26
2 files changed, 26 insertions, 2 deletions
diff --git a/scripts/Makefile.IMA b/scripts/Makefile.IMA
index bddd70229..11ae39eae 100644
--- a/scripts/Makefile.IMA
+++ b/scripts/Makefile.IMA
@@ -200,7 +200,7 @@ applets/usage: include/autoconf.h
applets/applet_tables: include/autoconf.h
$(HOSTCC) -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -I$(srctree)/include -o applets/applet_tables applets/applet_tables.c
-include/usage_compressed.h: $(srctree)/include/usage.h applets/usage
+include/usage_compressed.h: include/usage.h applets/usage
$(srctree)/applets/usage_compressed include/usage_compressed.h applets
include/applet_tables.h: include/applets.h
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"
# (Re)generate include/applets.h
src="$srctree/include/applets.src.h"
dst="include/applets.h"
-s=`sed -n 's@^//applet:@@p' -- */*.c */*/*.c`
+s=`sed -n 's@^//applet:@@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c`
echo "/* DO NOT EDIT. This file is generated from applets.src.h */" >"$dst.$$.tmp"
# Why "IFS='' read -r REPLY"??
# This atrocity is needed to read lines without mangling.
@@ -27,6 +27,30 @@ else
mv -- "$dst.$$.tmp" "$dst"
fi
+# (Re)generate include/usage.h
+src="$srctree/include/usage.src.h"
+dst="include/usage.h"
+# We add line continuation backslash after each line,
+# and insert empty line before each line which doesn't start
+# with space or tab
+# (note: we need to use \\\\ because of ``)
+s=`sed -n -e 's@^//usage:\([ \t].*\)$@\1 \\\\@p' -e 's@^//usage:\([^ \t].*\)$@\n\1 \\\\@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c`
+echo "/* DO NOT EDIT. This file is generated from usage.src.h */" >"$dst.$$.tmp"
+# Why "IFS='' read -r REPLY"??
+# This atrocity is needed to read lines without mangling.
+# IFS='' prevents whitespace trimming,
+# -r suppresses backslash handling.
+while IFS='' read -r REPLY; do
+ test x"$REPLY" = x"INSERT" && REPLY="$s"
+ printf "%s\n" "$REPLY"
+done <"$src" >>"$dst.$$.tmp"
+if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then
+ rm -- "$dst.$$.tmp"
+else
+ echo " GEN $dst"
+ mv -- "$dst.$$.tmp" "$dst"
+fi
+
# (Re)generate */Kbuild and */Config.in
find -type d | while read -r d; do
d="${d#./}"