3 test $# -ge 2 || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
6 cd -- "$2" || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
7 # In separate objtree build, include/ might not exist yet
8 mkdir include 2>/dev/null
12 # (Re)generate include/applets.h
13 src="$srctree/include/applets.src.h"
14 dst="include/applets.h"
15 s=`sed -n 's@^//applet:@@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c`
16 old=`cat "$dst" 2>/dev/null`
17 # Why "IFS='' read -r REPLY"??
18 # This atrocity is needed to read lines without mangling.
19 # IFS='' prevents whitespace trimming,
20 # -r suppresses backslash handling.
21 new=`echo "/* DO NOT EDIT. This file is generated from applets.src.h */"
22 while IFS='' read -r REPLY; do
23 test x"$REPLY" = x"INSERT" && REPLY="$s"
24 printf "%s\n" "$REPLY"
26 if test x"$new" != x"$old"; then
28 printf "%s\n" "$new" >"$dst"
31 # (Re)generate include/usage.h
32 src="$srctree/include/usage.src.h"
34 # We add line continuation backslash after each line,
35 # and insert empty line before each line which doesn't start
37 # (note: we need to use \\\\ because of ``)
38 s=`sed -n -e 's@^//usage:\([ \t].*\)$@\1 \\\\@p' -e 's@^//usage:\([^ \t].*\)$@\n\1 \\\\@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c`
39 old=`cat "$dst" 2>/dev/null`
40 new=`echo "/* DO NOT EDIT. This file is generated from usage.src.h */"
41 while IFS='' read -r REPLY; do
42 test x"$REPLY" = x"INSERT" && REPLY="$s"
43 printf "%s\n" "$REPLY"
45 if test x"$new" != x"$old"; then
47 printf "%s\n" "$new" >"$dst"
50 # (Re)generate */Kbuild and */Config.in
51 { cd -- "$srctree" && find . -type d; } | while read -r d; do
54 src="$srctree/$d/Kbuild.src"
56 if test -f "$src"; then
57 mkdir -p -- "$d" 2>/dev/null
60 s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c`
62 old=`cat "$dst" 2>/dev/null`
63 new=`echo "# DO NOT EDIT. This file is generated from Kbuild.src"
64 while IFS='' read -r REPLY; do
65 test x"$REPLY" = x"INSERT" && REPLY="$s"
66 printf "%s\n" "$REPLY"
68 if test x"$new" != x"$old"; then
70 printf "%s\n" "$new" >"$dst"
74 src="$srctree/$d/Config.src"
76 if test -f "$src"; then
77 mkdir -p -- "$d" 2>/dev/null
80 s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c`
82 old=`cat "$dst" 2>/dev/null`
83 new=`echo "# DO NOT EDIT. This file is generated from Config.src"
84 while IFS='' read -r REPLY; do
85 test x"$REPLY" = x"INSERT" && REPLY="$s"
86 printf "%s\n" "$REPLY"
88 if test x"$new" != x"$old"; then
90 printf "%s\n" "$new" >"$dst"
95 # Last read failed. This is normal. Don't exit with its error code: