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 | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 7 | |
| 8 | srctree="$1" |
| 9 | |
Denys Vlasenko | 6c5bf0d | 2010-06-06 00:53:45 +0200 | [diff] [blame] | 10 | # (Re)generate include/applets.h |
| 11 | src="$srctree/include/applets.src.h" |
| 12 | dst="include/applets.h" |
Denys Vlasenko | f0f9470 | 2010-06-06 01:53:38 +0200 | [diff] [blame] | 13 | s=`sed -n 's@^//applet:@@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c` |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame^] | 14 | old=`cat "$dst" 2>/dev/null` |
Denys Vlasenko | 6c5bf0d | 2010-06-06 00:53:45 +0200 | [diff] [blame] | 15 | # Why "IFS='' read -r REPLY"?? |
| 16 | # This atrocity is needed to read lines without mangling. |
| 17 | # IFS='' prevents whitespace trimming, |
| 18 | # -r suppresses backslash handling. |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame^] | 19 | 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] | 20 | while IFS='' read -r REPLY; do |
| 21 | test x"$REPLY" = x"INSERT" && REPLY="$s" |
| 22 | printf "%s\n" "$REPLY" |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame^] | 23 | done <"$src"` |
| 24 | if test x"$new" != x"$old"; then |
Denys Vlasenko | 6c5bf0d | 2010-06-06 00:53:45 +0200 | [diff] [blame] | 25 | echo " GEN $dst" |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame^] | 26 | printf "%s\n" "$new" >"$dst" |
Denys Vlasenko | 6c5bf0d | 2010-06-06 00:53:45 +0200 | [diff] [blame] | 27 | fi |
| 28 | |
Denys Vlasenko | f0f9470 | 2010-06-06 01:53:38 +0200 | [diff] [blame] | 29 | # (Re)generate include/usage.h |
| 30 | src="$srctree/include/usage.src.h" |
| 31 | dst="include/usage.h" |
| 32 | # We add line continuation backslash after each line, |
| 33 | # and insert empty line before each line which doesn't start |
| 34 | # with space or tab |
| 35 | # (note: we need to use \\\\ because of ``) |
| 36 | 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^] | 37 | old=`cat "$dst" 2>/dev/null` |
| 38 | 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] | 39 | while IFS='' read -r REPLY; do |
| 40 | test x"$REPLY" = x"INSERT" && REPLY="$s" |
| 41 | printf "%s\n" "$REPLY" |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame^] | 42 | done <"$src"` |
| 43 | if test x"$new" != x"$old"; then |
Denys Vlasenko | f0f9470 | 2010-06-06 01:53:38 +0200 | [diff] [blame] | 44 | echo " GEN $dst" |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame^] | 45 | printf "%s\n" "$new" >"$dst" |
Denys Vlasenko | f0f9470 | 2010-06-06 01:53:38 +0200 | [diff] [blame] | 46 | fi |
| 47 | |
Denys Vlasenko | 6c5bf0d | 2010-06-06 00:53:45 +0200 | [diff] [blame] | 48 | # (Re)generate */Kbuild and */Config.in |
Denys Vlasenko | 084e228 | 2010-05-15 21:08:51 +0200 | [diff] [blame] | 49 | find -type d | while read -r d; do |
Denys Vlasenko | 76c936f | 2010-05-27 02:33:31 +0200 | [diff] [blame] | 50 | d="${d#./}" |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 51 | src="$srctree/$d/Kbuild.src" |
| 52 | dst="$d/Kbuild" |
| 53 | if test -f "$src"; then |
Denys Vlasenko | 76c936f | 2010-05-27 02:33:31 +0200 | [diff] [blame] | 54 | #echo " CHK $dst" |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 55 | |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 56 | s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c` |
Denys Vlasenko | a1db8b8 | 2010-05-18 00:24:17 +0200 | [diff] [blame] | 57 | |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame^] | 58 | old=`cat "$dst" 2>/dev/null` |
| 59 | new=`echo "# DO NOT EDIT. This file is generated from Kbuild.src" |
Denys Vlasenko | a1db8b8 | 2010-05-18 00:24:17 +0200 | [diff] [blame] | 60 | while IFS='' read -r REPLY; do |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 61 | test x"$REPLY" = x"INSERT" && REPLY="$s" |
| 62 | printf "%s\n" "$REPLY" |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame^] | 63 | done <"$src"` |
| 64 | if test x"$new" != x"$old"; then |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 65 | echo " GEN $dst" |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame^] | 66 | printf "%s\n" "$new" >"$dst" |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 67 | fi |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 68 | fi |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 69 | |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 70 | src="$srctree/$d/Config.src" |
| 71 | dst="$d/Config.in" |
| 72 | if test -f "$src"; then |
Denys Vlasenko | 76c936f | 2010-05-27 02:33:31 +0200 | [diff] [blame] | 73 | #echo " CHK $dst" |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 74 | |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 75 | s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c` |
Denys Vlasenko | a1db8b8 | 2010-05-18 00:24:17 +0200 | [diff] [blame] | 76 | |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame^] | 77 | old=`cat "$dst" 2>/dev/null` |
| 78 | new=`echo "# DO NOT EDIT. This file is generated from Config.src" |
Denys Vlasenko | a1db8b8 | 2010-05-18 00:24:17 +0200 | [diff] [blame] | 79 | while IFS='' read -r REPLY; do |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 80 | test x"$REPLY" = x"INSERT" && REPLY="$s" |
| 81 | printf "%s\n" "$REPLY" |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame^] | 82 | done <"$src"` |
| 83 | if test x"$new" != x"$old"; then |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 84 | echo " GEN $dst" |
Denys Vlasenko | 1d72d43 | 2010-06-25 13:30:59 +0200 | [diff] [blame^] | 85 | printf "%s\n" "$new" >"$dst" |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 86 | fi |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 87 | fi |
Denys Vlasenko | 7fb68f1 | 2010-05-09 04:22:48 +0200 | [diff] [blame] | 88 | done |
| 89 | |
| 90 | # Last read failed. This is normal. Don't exit with its error code: |
| 91 | exit 0 |