aboutsummaryrefslogtreecommitdiff
path: root/scripts/gen_build_files.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/gen_build_files.sh')
-rwxr-xr-xscripts/gen_build_files.sh55
1 files changed, 47 insertions, 8 deletions
diff --git a/scripts/gen_build_files.sh b/scripts/gen_build_files.sh
index b3aa132a3..647c7daf7 100755
--- a/scripts/gen_build_files.sh
+++ b/scripts/gen_build_files.sh
@@ -7,6 +7,51 @@ 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' -- "$srctree"/*/*.c "$srctree"/*/*/*.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 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
54# (Re)generate */Kbuild and */Config.in
10find -type d | while read -r d; do 55find -type d | while read -r d; do
11 d="${d#./}" 56 d="${d#./}"
12 src="$srctree/$d/Kbuild.src" 57 src="$srctree/$d/Kbuild.src"
@@ -15,17 +60,12 @@ find -type d | while read -r d; do
15 #echo " CHK $dst" 60 #echo " CHK $dst"
16 61
17 s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c` 62 s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c`
18 echo "# DO NOT EDIT. This file is generated from Kbuild.src" >"$dst.$$.tmp"
19 63
20 # Why "IFS='' read -r REPLY"?? 64 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 65 while IFS='' read -r REPLY; do
25 test x"$REPLY" = x"INSERT" && REPLY="$s" 66 test x"$REPLY" = x"INSERT" && REPLY="$s"
26 printf "%s\n" "$REPLY" 67 printf "%s\n" "$REPLY"
27 done <"$src" >>"$dst.$$.tmp" 68 done <"$src" >>"$dst.$$.tmp"
28
29 if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then 69 if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then
30 rm -- "$dst.$$.tmp" 70 rm -- "$dst.$$.tmp"
31 else 71 else
@@ -40,13 +80,12 @@ find -type d | while read -r d; do
40 #echo " CHK $dst" 80 #echo " CHK $dst"
41 81
42 s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c` 82 s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c`
43 echo "# DO NOT EDIT. This file is generated from Config.src" >"$dst.$$.tmp"
44 83
84 echo "# DO NOT EDIT. This file is generated from Config.src" >"$dst.$$.tmp"
45 while IFS='' read -r REPLY; do 85 while IFS='' read -r REPLY; do
46 test x"$REPLY" = x"INSERT" && REPLY="$s" 86 test x"$REPLY" = x"INSERT" && REPLY="$s"
47 printf "%s\n" "$REPLY" 87 printf "%s\n" "$REPLY"
48 done <"$src" >>"$dst.$$.tmp" 88 done <"$src" >>"$dst.$$.tmp"
49
50 if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then 89 if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then
51 rm -- "$dst.$$.tmp" 90 rm -- "$dst.$$.tmp"
52 else 91 else