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, 26 insertions, 29 deletions
diff --git a/scripts/gen_build_files.sh b/scripts/gen_build_files.sh
index 647c7daf7..968158758 100755
--- a/scripts/gen_build_files.sh
+++ b/scripts/gen_build_files.sh
@@ -4,6 +4,8 @@ test $# -ge 2 || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
4 4
5# cd to objtree 5# cd to objtree
6cd -- "$2" || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; } 6cd -- "$2" || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
7# In separate objtree build, include/ might not exist yet
8mkdir include 2>/dev/null
7 9
8srctree="$1" 10srctree="$1"
9 11
@@ -11,20 +13,19 @@ srctree="$1"
11src="$srctree/include/applets.src.h" 13src="$srctree/include/applets.src.h"
12dst="include/applets.h" 14dst="include/applets.h"
13s=`sed -n 's@^//applet:@@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c` 15s=`sed -n 's@^//applet:@@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c`
14echo "/* DO NOT EDIT. This file is generated from applets.src.h */" >"$dst.$$.tmp" 16old=`cat "$dst" 2>/dev/null`
15# Why "IFS='' read -r REPLY"?? 17# Why "IFS='' read -r REPLY"??
16# This atrocity is needed to read lines without mangling. 18# This atrocity is needed to read lines without mangling.
17# IFS='' prevents whitespace trimming, 19# IFS='' prevents whitespace trimming,
18# -r suppresses backslash handling. 20# -r suppresses backslash handling.
21new=`echo "/* DO NOT EDIT. This file is generated from applets.src.h */"
19while IFS='' read -r REPLY; do 22while IFS='' read -r REPLY; do
20 test x"$REPLY" = x"INSERT" && REPLY="$s" 23 test x"$REPLY" = x"INSERT" && REPLY="$s"
21 printf "%s\n" "$REPLY" 24 printf "%s\n" "$REPLY"
22done <"$src" >>"$dst.$$.tmp" 25done <"$src"`
23if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then 26if test x"$new" != x"$old"; then
24 rm -- "$dst.$$.tmp"
25else
26 echo " GEN $dst" 27 echo " GEN $dst"
27 mv -- "$dst.$$.tmp" "$dst" 28 printf "%s\n" "$new" >"$dst"
28fi 29fi
29 30
30# (Re)generate include/usage.h 31# (Re)generate include/usage.h
@@ -35,62 +36,58 @@ dst="include/usage.h"
35# with space or tab 36# with space or tab
36# (note: we need to use \\\\ because of ``) 37# (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` 38s=`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" 39old=`cat "$dst" 2>/dev/null`
39# Why "IFS='' read -r REPLY"?? 40new=`echo "/* DO NOT EDIT. This file is generated from usage.src.h */"
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 41while IFS='' read -r REPLY; do
44 test x"$REPLY" = x"INSERT" && REPLY="$s" 42 test x"$REPLY" = x"INSERT" && REPLY="$s"
45 printf "%s\n" "$REPLY" 43 printf "%s\n" "$REPLY"
46done <"$src" >>"$dst.$$.tmp" 44done <"$src"`
47if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then 45if test x"$new" != x"$old"; then
48 rm -- "$dst.$$.tmp"
49else
50 echo " GEN $dst" 46 echo " GEN $dst"
51 mv -- "$dst.$$.tmp" "$dst" 47 printf "%s\n" "$new" >"$dst"
52fi 48fi
53 49
54# (Re)generate */Kbuild and */Config.in 50# (Re)generate */Kbuild and */Config.in
55find -type d | while read -r d; do 51{ cd -- "$srctree" && find -type d; } | while read -r d; do
56 d="${d#./}" 52 d="${d#./}"
53
57 src="$srctree/$d/Kbuild.src" 54 src="$srctree/$d/Kbuild.src"
58 dst="$d/Kbuild" 55 dst="$d/Kbuild"
56 mkdir -p -- "$d" 2>/dev/null
59 if test -f "$src"; then 57 if test -f "$src"; then
60 #echo " CHK $dst" 58 #echo " CHK $dst"
61 59
62 s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c` 60 s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c`
63 61
64 echo "# DO NOT EDIT. This file is generated from Kbuild.src" >"$dst.$$.tmp" 62 old=`cat "$dst" 2>/dev/null`
63 new=`echo "# DO NOT EDIT. This file is generated from Kbuild.src"
65 while IFS='' read -r REPLY; do 64 while IFS='' read -r REPLY; do
66 test x"$REPLY" = x"INSERT" && REPLY="$s" 65 test x"$REPLY" = x"INSERT" && REPLY="$s"
67 printf "%s\n" "$REPLY" 66 printf "%s\n" "$REPLY"
68 done <"$src" >>"$dst.$$.tmp" 67 done <"$src"`
69 if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then 68 if test x"$new" != x"$old"; then
70 rm -- "$dst.$$.tmp"
71 else
72 echo " GEN $dst" 69 echo " GEN $dst"
73 mv -- "$dst.$$.tmp" "$dst" 70 printf "%s\n" "$new" >"$dst"
74 fi 71 fi
75 fi 72 fi
76 73
77 src="$srctree/$d/Config.src" 74 src="$srctree/$d/Config.src"
78 dst="$d/Config.in" 75 dst="$d/Config.in"
76 mkdir -p -- "$d" 2>/dev/null
79 if test -f "$src"; then 77 if test -f "$src"; then
80 #echo " CHK $dst" 78 #echo " CHK $dst"
81 79
82 s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c` 80 s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c`
83 81
84 echo "# DO NOT EDIT. This file is generated from Config.src" >"$dst.$$.tmp" 82 old=`cat "$dst" 2>/dev/null`
83 new=`echo "# DO NOT EDIT. This file is generated from Config.src"
85 while IFS='' read -r REPLY; do 84 while IFS='' read -r REPLY; do
86 test x"$REPLY" = x"INSERT" && REPLY="$s" 85 test x"$REPLY" = x"INSERT" && REPLY="$s"
87 printf "%s\n" "$REPLY" 86 printf "%s\n" "$REPLY"
88 done <"$src" >>"$dst.$$.tmp" 87 done <"$src"`
89 if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then 88 if test x"$new" != x"$old"; then
90 rm -- "$dst.$$.tmp"
91 else
92 echo " GEN $dst" 89 echo " GEN $dst"
93 mv -- "$dst.$$.tmp" "$dst" 90 printf "%s\n" "$new" >"$dst"
94 fi 91 fi
95 fi 92 fi
96done 93done