blob: 05ceafd4a96c9bfb0aeefb6bfe31057b28d1b0ea [file] [log] [blame]
Rob Landley7e21d5f2006-04-27 23:34:46 +00001#!/bin/sh
2
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00003target="$1"
4loc="$2"
Rob Landley7e21d5f2006-04-27 23:34:46 +00005
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00006test "$target" || exit 1
Rob Landley7e21d5f2006-04-27 23:34:46 +00007test "$loc" || loc=.
Bernhard Reutner-Fischera1e130f2006-05-21 10:45:01 +00008test -x "$loc/usage" || exit 1
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00009test "$SED" || SED=sed
10
11sz=`"$loc/usage" | wc -c` || exit 1
12
13exec >"$target"
Rob Landley7e21d5f2006-04-27 23:34:46 +000014
Denis Vlasenko937b10f2008-02-09 09:26:43 +000015echo 'static const char packed_usage[] ALIGN1 = {'
16
Denis Vlasenko63e49fa2008-08-09 20:31:57 +000017## 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 Vlasenko937b10f2008-02-09 09:26:43 +000026
Denis Vlasenko63e49fa2008-08-09 20:31:57 +000027"$loc/usage" | bzip2 -1 | od -v -t x1 \
Denis Vlasenko937b10f2008-02-09 09:26:43 +000028| $SED -e 's/^[^ ]*//' \
29| $SED -e 's/ //g' \
30| grep -v '^$' \
Denis Vlasenko63e49fa2008-08-09 20:31:57 +000031| $SED -e 's/\(..\)/0x\1,/g'
Denis Vlasenko937b10f2008-02-09 09:26:43 +000032
33echo '};'
Bernhard Reutner-Fischer7fca7e32006-05-26 13:28:39 +000034echo '#define SIZEOF_usage_messages' `expr 0 + $sz`