3 # Note: was using sed OPTS CMD -- FILES
4 # but users complain that many sed implementations
5 # are misinterpreting --.
7 test $# -ge 2 || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
10 cd -- "$2" || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
11 # In separate objtree build, include/ might not exist yet
12 mkdir include 2>/dev/null
16 status() { printf ' %-8s%s\n' "$1" "$2"; }
17 gen() { status "GEN" "$@"; }
18 chk() { status "CHK" "$@"; }
20 # scripts in the 'embed' directory are treated as fake applets
24 if [ -d "$custom_loc" ]
26 for i in $(cd "$custom_loc"; ls * 2>/dev/null)
28 printf "IF_FEATURE_SH_EMBEDDED_SCRIPTS(APPLET_SCRIPTED(%s, scripted, BB_DIR_USR_BIN, BB_SUID_DROP, scripted))\n" $i;
35 # NB: data to be inserted at INSERT line is coming on stdin
42 # Need to use printf: different shells have inconsistent
43 # rules re handling of "\n" in echo params.
44 printf "%s\n" "${header}"
45 # print everything up to INSERT line
46 sed -n '/^INSERT$/ q; p' "${src}"
47 # copy stdin to stdout
53 # print everything after INSERT line
61 if ! cmp -s "${dst}" "${dst}.tmp"; then
63 mv "${dst}.tmp" "${dst}"
69 # (Re)generate include/applets.h
70 sed -n 's@^//applet:@@p' "$srctree"/*/*.c "$srctree"/*/*/*.c \
72 "$srctree/include/applets.src.h" \
74 "/* DO NOT EDIT. This file is generated from applets.src.h */" \
77 # (Re)generate include/usage.h
78 # We add line continuation backslash after each line,
79 # and insert empty line before each line which doesn't start
85 sed -n -e 's@^//usage:\([ '"$TAB"'].*\)$@\1 \\@p' \
86 -e 's@^//usage:\([^ '"$TAB"'].*\)$@\'"$LF"'\1 \\@p' \
87 "$srctree"/*/*.c "$srctree"/*/*/*.c \
89 "$srctree/include/usage.src.h" \
91 "/* DO NOT EDIT. This file is generated from usage.src.h */"
93 # (Re)generate */Kbuild and */Config.in
94 # We skip .dotdirs - makes git/svn/etc users happier
95 { cd -- "$srctree" && find . -type d ! '(' -name '.?*' -prune ')'; } \
99 src="$srctree/$d/Kbuild.src"
101 if test -f "$src"; then
102 mkdir -p -- "$d" 2>/dev/null
104 sed -n 's@^//kbuild:@@p' "$srctree/$d"/*.c \
107 "# DO NOT EDIT. This file is generated from Kbuild.src"
110 src="$srctree/$d/Config.src"
112 if test -f "$src"; then
113 mkdir -p -- "$d" 2>/dev/null
115 sed -n 's@^//config:@@p' "$srctree/$d"/*.c \
118 "# DO NOT EDIT. This file is generated from Config.src"
122 # Last read failed. This is normal. Don't exit with its error code: