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"
22 if grep -qs '^INSERT$' "${src}"; then
23 sed -n '1,/^INSERT$/p' "${src}"
25 sed -n '/^INSERT$/,$p' "${src}"
27 if [ -n "${insert}" ]; then
28 echo "ERROR: INSERT line missing in: ${src}" 1>&2
32 ) | sed '/^INSERT$/d' > "${dst}.tmp"
33 if ! cmp -s "${dst}" "${dst}.tmp"; then
35 mv "${dst}.tmp" "${dst}"
41 # (Re)generate include/applets.h
42 s=`sed -n 's@^//applet:@@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c`
44 "$srctree/include/applets.src.h" \
46 "/* DO NOT EDIT. This file is generated from applets.src.h */" \
49 # (Re)generate include/usage.h
50 # We add line continuation backslash after each line,
51 # and insert empty line before each line which doesn't start
53 # (note: we need to use \\\\ because of ``)
54 s=`sed -n -e 's@^//usage:\([ \t].*\)$@\1 \\\\@p' -e 's@^//usage:\([^ \t].*\)$@\n\1 \\\\@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c`
56 "$srctree/include/usage.src.h" \
58 "/* DO NOT EDIT. This file is generated from usage.src.h */" \
61 # (Re)generate */Kbuild and */Config.in
62 { cd -- "$srctree" && find . -type d; } | while read -r d; do
65 src="$srctree/$d/Kbuild.src"
67 if test -f "$src"; then
68 mkdir -p -- "$d" 2>/dev/null
70 s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c`
73 "# DO NOT EDIT. This file is generated from Kbuild.src" \
77 src="$srctree/$d/Config.src"
79 if test -f "$src"; then
80 mkdir -p -- "$d" 2>/dev/null
82 s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c`
85 "# DO NOT EDIT. This file is generated from Config.src" \