Denys Vlasenko | 3015a13 | 2010-05-17 01:59:16 +0200 | [diff] [blame] | 1 | #!/bin/sh |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 2 | |
Denys Vlasenko | 572b9a3 | 2010-05-09 16:20:52 +0200 | [diff] [blame] | 3 | test $# -ge 2 || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; } |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 4 | |
| 5 | # cd to objtree |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 6 | cd -- "$2" || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; } |
Denys Vlasenko | 1883cb1 | 2010-07-09 01:25:36 +0200 | [diff] [blame] | 7 | # In separate objtree build, include/ might not exist yet |
| 8 | mkdir include 2>/dev/null |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 9 | |
| 10 | srctree="$1" |
| 11 | |
Denys Vlasenko | 6c5bf0d | 2010-06-06 00:53:45 +0200 | [diff] [blame] | 12 | # (Re)generate include/applets.h |
| 13 | src="$srctree/include/applets.src.h" |
| 14 | dst="include/applets.h" |
Denys Vlasenko | f0f9470 | 2010-06-06 01:53:38 +0200 | [diff] [blame] | 15 | s=`sed -n 's@^//applet:@@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c` |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame] | 16 | old=`cat "$dst" 2>/dev/null` |
Denys Vlasenko | 6c5bf0d | 2010-06-06 00:53:45 +0200 | [diff] [blame] | 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. |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame] | 21 | new=`echo "/* DO NOT EDIT. This file is generated from applets.src.h */" |
Denys Vlasenko | 6c5bf0d | 2010-06-06 00:53:45 +0200 | [diff] [blame] | 22 | while IFS='' read -r REPLY; do |
| 23 | test x"$REPLY" = x"INSERT" && REPLY="$s" |
| 24 | printf "%s\n" "$REPLY" |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame] | 25 | done <"$src"` |
| 26 | if test x"$new" != x"$old"; then |
Denys Vlasenko | 6c5bf0d | 2010-06-06 00:53:45 +0200 | [diff] [blame] | 27 | echo " GEN $dst" |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame] | 28 | printf "%s\n" "$new" >"$dst" |
Denys Vlasenko | 6c5bf0d | 2010-06-06 00:53:45 +0200 | [diff] [blame] | 29 | fi |
| 30 | |
Denys Vlasenko | f0f9470 | 2010-06-06 01:53:38 +0200 | [diff] [blame] | 31 | # (Re)generate include/usage.h |
| 32 | src="$srctree/include/usage.src.h" |
| 33 | dst="include/usage.h" |
| 34 | # We add line continuation backslash after each line, |
| 35 | # and insert empty line before each line which doesn't start |
| 36 | # with space or tab |
| 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` |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame] | 39 | old=`cat "$dst" 2>/dev/null` |
| 40 | new=`echo "/* DO NOT EDIT. This file is generated from usage.src.h */" |
Denys Vlasenko | f0f9470 | 2010-06-06 01:53:38 +0200 | [diff] [blame] | 41 | while IFS='' read -r REPLY; do |
| 42 | test x"$REPLY" = x"INSERT" && REPLY="$s" |
| 43 | printf "%s\n" "$REPLY" |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame] | 44 | done <"$src"` |
| 45 | if test x"$new" != x"$old"; then |
Denys Vlasenko | f0f9470 | 2010-06-06 01:53:38 +0200 | [diff] [blame] | 46 | echo " GEN $dst" |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame] | 47 | printf "%s\n" "$new" >"$dst" |
Denys Vlasenko | f0f9470 | 2010-06-06 01:53:38 +0200 | [diff] [blame] | 48 | fi |
| 49 | |
Denys Vlasenko | 6c5bf0d | 2010-06-06 00:53:45 +0200 | [diff] [blame] | 50 | # (Re)generate */Kbuild and */Config.in |
Waldemar Brodkorb | 95b83ba | 2010-08-06 09:17:26 +0200 | [diff] [blame] | 51 | { cd -- "$srctree" && find . -type d; } | while read -r d; do |
Denys Vlasenko | 76c936f | 2010-05-27 02:33:31 +0200 | [diff] [blame] | 52 | d="${d#./}" |
Denys Vlasenko | 1883cb1 | 2010-07-09 01:25:36 +0200 | [diff] [blame] | 53 | |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 54 | src="$srctree/$d/Kbuild.src" |
| 55 | dst="$d/Kbuild" |
| 56 | if test -f "$src"; then |
Alexander Shishkin | daf286c | 2010-07-15 17:39:24 +0300 | [diff] [blame] | 57 | mkdir -p -- "$d" 2>/dev/null |
Denys Vlasenko | 76c936f | 2010-05-27 02:33:31 +0200 | [diff] [blame] | 58 | #echo " CHK $dst" |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 59 | |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 60 | s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c` |
Denys Vlasenko | a1db8b8 | 2010-05-18 00:24:17 +0200 | [diff] [blame] | 61 | |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame] | 62 | old=`cat "$dst" 2>/dev/null` |
| 63 | new=`echo "# DO NOT EDIT. This file is generated from Kbuild.src" |
Denys Vlasenko | a1db8b8 | 2010-05-18 00:24:17 +0200 | [diff] [blame] | 64 | while IFS='' read -r REPLY; do |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 65 | test x"$REPLY" = x"INSERT" && REPLY="$s" |
| 66 | printf "%s\n" "$REPLY" |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame] | 67 | done <"$src"` |
| 68 | if test x"$new" != x"$old"; then |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 69 | echo " GEN $dst" |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame] | 70 | printf "%s\n" "$new" >"$dst" |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 71 | fi |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 72 | fi |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 73 | |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 74 | src="$srctree/$d/Config.src" |
| 75 | dst="$d/Config.in" |
| 76 | if test -f "$src"; then |
Alexander Shishkin | daf286c | 2010-07-15 17:39:24 +0300 | [diff] [blame] | 77 | mkdir -p -- "$d" 2>/dev/null |
Denys Vlasenko | 76c936f | 2010-05-27 02:33:31 +0200 | [diff] [blame] | 78 | #echo " CHK $dst" |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 79 | |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 80 | s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c` |
Denys Vlasenko | a1db8b8 | 2010-05-18 00:24:17 +0200 | [diff] [blame] | 81 | |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame] | 82 | old=`cat "$dst" 2>/dev/null` |
| 83 | new=`echo "# DO NOT EDIT. This file is generated from Config.src" |
Denys Vlasenko | a1db8b8 | 2010-05-18 00:24:17 +0200 | [diff] [blame] | 84 | while IFS='' read -r REPLY; do |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 85 | test x"$REPLY" = x"INSERT" && REPLY="$s" |
| 86 | printf "%s\n" "$REPLY" |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame] | 87 | done <"$src"` |
| 88 | if test x"$new" != x"$old"; then |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 89 | echo " GEN $dst" |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame] | 90 | printf "%s\n" "$new" >"$dst" |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 91 | fi |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 92 | fi |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 93 | done |
| 94 | |
| 95 | # Last read failed. This is normal. Don't exit with its error code: |
| 96 | exit 0 |