From 6c5bf0d347faded028e15d523c26a0d64c6d3920 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 6 Jun 2010 00:53:45 +0200 Subject: 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 --- scripts/Makefile.IMA | 2 +- scripts/gen_build_files.sh | 31 +++++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.IMA b/scripts/Makefile.IMA index a34db50f4..bddd70229 100644 --- a/scripts/Makefile.IMA +++ b/scripts/Makefile.IMA @@ -203,5 +203,5 @@ applets/applet_tables: include/autoconf.h include/usage_compressed.h: $(srctree)/include/usage.h applets/usage $(srctree)/applets/usage_compressed include/usage_compressed.h applets -include/applet_tables.h: $(srctree)/include/applets.h +include/applet_tables.h: include/applets.h applets/applet_tables include/applet_tables.h 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; } 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` +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. +# 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#./}" src="$srctree/$d/Kbuild.src" @@ -15,17 +36,12 @@ find -type d | while read -r d; do #echo " CHK $dst" s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c` - echo "# DO NOT EDIT. This file is generated from Kbuild.src" >"$dst.$$.tmp" - # Why "IFS='' read -r REPLY"?? - # This atrocity is needed to read lines without mangling. - # IFS='' prevents whitespace trimming, - # -r suppresses backslash handling. + echo "# DO NOT EDIT. This file is generated from Kbuild.src" >"$dst.$$.tmp" 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 @@ -40,13 +56,12 @@ find -type d | while read -r d; do #echo " CHK $dst" s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c` - echo "# DO NOT EDIT. This file is generated from Config.src" >"$dst.$$.tmp" + echo "# DO NOT EDIT. This file is generated from Config.src" >"$dst.$$.tmp" 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 -- cgit v1.2.3