# packages/busybox/auxbuild
#

# download and unpack tarball
TARVERSION="1.15.3"
TARDIR="${BUILD_PACKAGE}-${TARVERSION}"
TARBALL="${TARDIR}.tar.bz2"
build_download "http://www.busybox.net/downloads/${TARBALL}"
build_unpack "${TARBALL}"

# apply patches matching pattern (repository, patch prefix)
build_patch "${TARDIR}" "${BUILD_PACKAGE}-ALL-"
build_patch "${TARDIR}" "${BUILD_PACKAGE}-${TARVERSION}-"

# copy in custom configuration
cp "busybox.config" "Distn/${TARDIR}/.config"

# helper functions for per-machine options
config_enable() {
    for opt in "$@"
    do
        sed -e "s,^.*CONFIG_${opt}[ =].*\$,CONFIG_${opt}=y," -i "Distn/${TARDIR}/.config"
    done
}

# per-machine options
case "${BUILD_MACHINE}" in
CMG-NAM)
    config_enable MKSWAP SWAPONOFF
    ;;
CMG-NAM64)
    config_enable MKSWAP SWAPONOFF
    ;;
esac

# set up crosscompiler
export ARCH="${ARCH_HOST/-*}"
export CROSS_COMPILE="${ARCH_CC_PREFIX}"

# run make, make install (directory, extra arguments)
build_make "${TARDIR}"
build_make "${TARDIR}" "CONFIG_PREFIX=\"${BUILDROOT}\"" "install"

true
# vim: ts=4:sw=4:expandtab:syntax=sh
