7 test "$target" || exit 1
11 # Some people were bitten by their system lacking a (proper) od
12 od -v -b </dev/null >/dev/null
14 echo 'od tool is not installed or cannot accept "-v -b" options'
19 if [ -d "$custom_loc" ]
21 custom_scripts=$(cd $custom_loc; ls * 2>/dev/null)
23 all_scripts=$($srctree/applets/busybox.mkscripts)
25 # all_scripts includes applet scripts and custom scripts, sort them out
30 for j in $custom_scripts
40 # anything that isn't a custom script is an applet script
41 applet_scripts="$applet_scripts $i"
45 # we know the custom scripts are present but applet scripts might have
46 # become detached from their configuration
47 for i in $applet_scripts
49 #if [ ! -f "$applet_loc/$i" -a ! -f "$custom_loc/$i" ]
50 if [ ! -f "$applet_loc/$i" ]
52 echo "missing applet script $i"
57 n=$(echo $custom_scripts $applet_scripts | wc -w)
58 nall=$(echo $all_scripts | wc -w)
62 echo "script mismatch $n != $nall"
66 concatenate_scripts() {
67 for i in $custom_scripts
72 for i in $applet_scripts
83 printf '#ifdef DEFINE_SCRIPT_DATA\n'
86 printf 'const uint16_t applet_numbers[] = {\n'
87 for i in $custom_scripts $applet_scripts
89 # TODO support applets with names including invalid characters
90 printf '\tAPPLET_NO_%s,\n' $i
97 printf 'extern const uint16_t applet_numbers[];\n'
103 printf '#define NUM_SCRIPTS %d\n' $n
108 printf '#define UNPACKED_SCRIPTS_LENGTH '
109 concatenate_scripts | wc -c
111 printf '#define PACKED_SCRIPTS \\\n'
112 concatenate_scripts | bzip2 -1 | $DD bs=2 skip=1 2>/dev/null | \
115 | $SED -e 's/^[^ ]*//' \
118 -e 's/\(...\)/0\1,/g' \
123 mv -- "$target.$$" "$target"