9 test "$target" || exit 1
10 test "$SED" || SED=sed
13 if [ x"$CONFIG_FEATURE_SH_EMBEDDED_SCRIPTS" != x"y" ]
15 printf '#define NUM_SCRIPTS 0\n' >"$target"
19 # Some people were bitten by their system lacking a (proper) od
20 od -v -b </dev/null >/dev/null
22 echo 'od tool is not installed or cannot accept "-v -b" options'
27 if [ -d "$custom_loc" ]
29 custom_scripts=$(cd $custom_loc; ls * 2>/dev/null)
31 all_scripts=$($srctree/applets/busybox.mkscripts)
33 # all_scripts includes applet scripts and custom scripts, sort them out
38 for j in $custom_scripts
48 # anything that isn't a custom script is an applet script
49 applet_scripts="$applet_scripts $i"
53 # we know the custom scripts are present but applet scripts might have
54 # become detached from their configuration
55 for i in $applet_scripts
57 #if [ ! -f "$applet_loc/$i" -a ! -f "$custom_loc/$i" ]
58 if [ ! -f "$applet_loc/$i" ]
60 echo "missing applet script $i"
65 n=$(echo $custom_scripts $applet_scripts | wc -w)
66 nall=$(echo $all_scripts | wc -w)
70 echo "script mismatch $n != $nall"
74 concatenate_scripts() {
75 for i in $custom_scripts
80 for i in $applet_scripts
91 printf '#ifdef DEFINE_SCRIPT_DATA\n'
92 printf 'const uint16_t applet_numbers[] = {\n'
93 for i in $custom_scripts $applet_scripts
95 # TODO support applets with names including invalid characters
96 printf '\tAPPLET_NO_%s,\n' $i
100 printf 'extern const uint16_t applet_numbers[];\n'
105 printf '#define NUM_SCRIPTS %d\n' $n
110 printf '#define UNPACKED_SCRIPTS_LENGTH '
111 concatenate_scripts | wc -c
113 printf '#define PACKED_SCRIPTS \\\n'
114 concatenate_scripts | bzip2 -1 | $DD bs=2 skip=1 2>/dev/null | \
117 | $SED -e 's/^[^ ]*//' \
120 -e 's/\(...\)/0\1,/g' \
125 mv -- "$target.$$" "$target"