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 old=`cat "$dst" 2>/dev/null`
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 new=`echo "/* DO NOT EDIT. This file is generated from applets.src.h */"
20 while IFS='' read -r REPLY; do
21 test x"$REPLY" = x"INSERT" && REPLY="$s"
22 printf "%s\n" "$REPLY"
24 if test x"$new" != x"$old"; then
26 printf "%s\n" "$new" >"$dst"
29 # (Re)generate include/usage.h
30 src="$srctree/include/usage.src.h"
32 # We add line continuation backslash after each line,
33 # and insert empty line before each line which doesn't start
35 # (note: we need to use \\\\ because of ``)
36 s=`sed -n -e 's@^//usage:\([ \t].*\)$@\1 \\\\@p' -e 's@^//usage:\([^ \t].*\)$@\n\1 \\\\@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c`
37 old=`cat "$dst" 2>/dev/null`
38 new=`echo "/* DO NOT EDIT. This file is generated from usage.src.h */"
39 while IFS='' read -r REPLY; do
40 test x"$REPLY" = x"INSERT" && REPLY="$s"
41 printf "%s\n" "$REPLY"
43 if test x"$new" != x"$old"; then
45 printf "%s\n" "$new" >"$dst"
48 # (Re)generate */Kbuild and */Config.in
49 find -type d | while read -r d; do
51 src="$srctree/$d/Kbuild.src"
53 if test -f "$src"; then
56 s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c`
58 old=`cat "$dst" 2>/dev/null`
59 new=`echo "# DO NOT EDIT. This file is generated from Kbuild.src"
60 while IFS='' read -r REPLY; do
61 test x"$REPLY" = x"INSERT" && REPLY="$s"
62 printf "%s\n" "$REPLY"
64 if test x"$new" != x"$old"; then
66 printf "%s\n" "$new" >"$dst"
70 src="$srctree/$d/Config.src"
72 if test -f "$src"; then
75 s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c`
77 old=`cat "$dst" 2>/dev/null`
78 new=`echo "# DO NOT EDIT. This file is generated from Config.src"
79 while IFS='' read -r REPLY; do
80 test x"$REPLY" = x"INSERT" && REPLY="$s"
81 printf "%s\n" "$REPLY"
83 if test x"$new" != x"$old"; then
85 printf "%s\n" "$new" >"$dst"
90 # Last read failed. This is normal. Don't exit with its error code: