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 status() { printf ' %-8s%s\n' "$1" "$2"; }
13 gen() { status "GEN" "$@"; }
14 chk() { status "CHK" "$@"; }
18 local src="$1" dst="$2" header="$3" insert="$4"
21 # need to use printf: different shells have inconsistent
22 # rules re handling of "\n" in their params,
23 # and ${insert} definitely contains "\n"
24 printf "%s\n" "${header}"
25 if grep -qs '^INSERT$' "${src}"; then
26 sed -n '1,/^INSERT$/p' "${src}"
27 printf "%s\n" "${insert}"
28 sed -n '/^INSERT$/,$p' "${src}"
30 if [ -n "${insert}" ]; then
31 printf "%s\n" "ERROR: INSERT line missing in: ${src}" 1>&2
35 ) | sed '/^INSERT$/d' > "${dst}.tmp"
36 if ! cmp -s "${dst}" "${dst}.tmp"; then
38 mv "${dst}.tmp" "${dst}"
44 # (Re)generate include/applets.h
45 s=`sed -n 's@^//applet:@@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c`
47 "$srctree/include/applets.src.h" \
49 "/* DO NOT EDIT. This file is generated from applets.src.h */" \
52 # (Re)generate include/usage.h
53 # We add line continuation backslash after each line,
54 # and insert empty line before each line which doesn't start
56 # (note: we need to use \\\\ because of ``)
57 s=`sed -n -e 's@^//usage:\([ \t].*\)$@\1 \\\\@p' -e 's@^//usage:\([^ \t].*\)$@\n\1 \\\\@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c`
59 "$srctree/include/usage.src.h" \
61 "/* DO NOT EDIT. This file is generated from usage.src.h */" \
64 # (Re)generate */Kbuild and */Config.in
65 { cd -- "$srctree" && find . -type d; } | while read -r d; do
68 src="$srctree/$d/Kbuild.src"
70 if test -f "$src"; then
71 mkdir -p -- "$d" 2>/dev/null
73 s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c`
76 "# DO NOT EDIT. This file is generated from Kbuild.src" \
80 src="$srctree/$d/Config.src"
82 if test -f "$src"; then
83 mkdir -p -- "$d" 2>/dev/null
85 s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c`
88 "# DO NOT EDIT. This file is generated from Config.src" \
93 # Last read failed. This is normal. Don't exit with its error code: