3 test $# -ge 2 || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
6 cd -- "$2" || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
10 # (Re)generate include/applets.h
11 src="$srctree/include/applets.src.h"
12 dst="include/applets.h"
13 s=`sed -n 's@^//applet:@@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c`
14 echo "/* 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.
19 while IFS='' read -r REPLY; do
20 test x"$REPLY" = x"INSERT" && REPLY="$s"
21 printf "%s\n" "$REPLY"
22 done <"$src" >>"$dst.$$.tmp"
23 if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then
27 mv -- "$dst.$$.tmp" "$dst"
30 # (Re)generate include/usage.h
31 src="$srctree/include/usage.src.h"
33 # We add line continuation backslash after each line,
34 # and insert empty line before each line which doesn't start
36 # (note: we need to use \\\\ because of ``)
37 s=`sed -n -e 's@^//usage:\([ \t].*\)$@\1 \\\\@p' -e 's@^//usage:\([^ \t].*\)$@\n\1 \\\\@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c`
38 echo "/* 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.
43 while IFS='' read -r REPLY; do
44 test x"$REPLY" = x"INSERT" && REPLY="$s"
45 printf "%s\n" "$REPLY"
46 done <"$src" >>"$dst.$$.tmp"
47 if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then
51 mv -- "$dst.$$.tmp" "$dst"
54 # (Re)generate */Kbuild and */Config.in
55 find -type d | while read -r d; do
57 src="$srctree/$d/Kbuild.src"
59 if test -f "$src"; then
62 s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c`
64 echo "# DO NOT EDIT. This file is generated from Kbuild.src" >"$dst.$$.tmp"
65 while IFS='' read -r REPLY; do
66 test x"$REPLY" = x"INSERT" && REPLY="$s"
67 printf "%s\n" "$REPLY"
68 done <"$src" >>"$dst.$$.tmp"
69 if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then
73 mv -- "$dst.$$.tmp" "$dst"
77 src="$srctree/$d/Config.src"
79 if test -f "$src"; then
82 s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c`
84 echo "# DO NOT EDIT. This file is generated from Config.src" >"$dst.$$.tmp"
85 while IFS='' read -r REPLY; do
86 test x"$REPLY" = x"INSERT" && REPLY="$s"
87 printf "%s\n" "$REPLY"
88 done <"$src" >>"$dst.$$.tmp"
89 if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then
93 mv -- "$dst.$$.tmp" "$dst"
98 # Last read failed. This is normal. Don't exit with its error code: