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