Rob Landley | 7e21d5f | 2006-04-27 23:34:46 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Denis Vlasenko | 7d219aa | 2006-10-05 10:17:08 +0000 | [diff] [blame] | 3 | target="$1" |
| 4 | loc="$2" |
Rob Landley | 7e21d5f | 2006-04-27 23:34:46 +0000 | [diff] [blame] | 5 | |
Denis Vlasenko | 7d219aa | 2006-10-05 10:17:08 +0000 | [diff] [blame] | 6 | test "$target" || exit 1 |
Rob Landley | 7e21d5f | 2006-04-27 23:34:46 +0000 | [diff] [blame] | 7 | test "$loc" || loc=. |
Bernhard Reutner-Fischer | a1e130f | 2006-05-21 10:45:01 +0000 | [diff] [blame] | 8 | test -x "$loc/usage" || exit 1 |
Denis Vlasenko | 7d219aa | 2006-10-05 10:17:08 +0000 | [diff] [blame] | 9 | test "$SED" || SED=sed |
| 10 | |
| 11 | sz=`"$loc/usage" | wc -c` || exit 1 |
| 12 | |
| 13 | exec >"$target" |
Rob Landley | 7e21d5f | 2006-04-27 23:34:46 +0000 | [diff] [blame] | 14 | |
Denis Vlasenko | 937b10f | 2008-02-09 09:26:43 +0000 | [diff] [blame] | 15 | echo 'static const char packed_usage[] ALIGN1 = {' |
| 16 | |
Denis Vlasenko | 63e49fa | 2008-08-09 20:31:57 +0000 | [diff] [blame] | 17 | ## Breaks on big-endian systems! |
| 18 | ## # Extra effort to avoid using "od -t x1": -t is not available |
| 19 | ## # in non-CONFIG_DESKTOPed busybox od |
| 20 | ## |
| 21 | ## "$loc/usage" | bzip2 -1 | od -v -x \ |
| 22 | ## | $SED -e 's/^[^ ]*//' \ |
| 23 | ## | $SED -e 's/ //g' \ |
| 24 | ## | grep -v '^$' \ |
| 25 | ## | $SED -e 's/\(..\)\(..\)/0x\2,0x\1,/g' |
Denis Vlasenko | 937b10f | 2008-02-09 09:26:43 +0000 | [diff] [blame] | 26 | |
Denis Vlasenko | 63e49fa | 2008-08-09 20:31:57 +0000 | [diff] [blame] | 27 | "$loc/usage" | bzip2 -1 | od -v -t x1 \ |
Denis Vlasenko | 937b10f | 2008-02-09 09:26:43 +0000 | [diff] [blame] | 28 | | $SED -e 's/^[^ ]*//' \ |
| 29 | | $SED -e 's/ //g' \ |
| 30 | | grep -v '^$' \ |
Denis Vlasenko | 63e49fa | 2008-08-09 20:31:57 +0000 | [diff] [blame] | 31 | | $SED -e 's/\(..\)/0x\1,/g' |
Denis Vlasenko | 937b10f | 2008-02-09 09:26:43 +0000 | [diff] [blame] | 32 | |
| 33 | echo '};' |
Bernhard Reutner-Fischer | 7fca7e3 | 2006-05-26 13:28:39 +0000 | [diff] [blame] | 34 | echo '#define SIZEOF_usage_messages' `expr 0 + $sz` |