# packages/dosfstools/auxbuild
#

# download and unpack tarball
TARVERSION="2.11"
TARDIR="${BUILD_PACKAGE}-${TARVERSION}"
TARBALL="${TARDIR}.src.tar.gz"
build_download "ftp://ftp.uni-erlangen.de/pub/Linux/LOCAL/dosfstools/${TARBALL}"

# 2.11 has a tarball which doesn't have a directory entry for the root directory
rm -rf "Distn/${TARDIR}"
build_unpack "${TARBALL}"

# dynamically fix the makefile for crosscompiling
sed \
    -e "s,^CC *=.*$,CC = ${ARCH_CC_PREFIX}gcc," \
    -e "s,^CFLAGS *=.*$,CFLAGS = ${ARCH_CFLAGS} -D_FILE_OFFSET_BITS=64," \
    -e "s,^LDFLAGS *=.*$,LDFLAGS = ${ARCH_LDFLAGS}," \
    -e "s,^PREFIX *=.*$,PREFIX = ${BUILDROOT}/usr," \
    -i "Distn/${TARDIR}/Makefile"

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

# invoke configure (directory, prefix, extra arguments)
#build_autoconf "${TARDIR}"

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

# clean up unwanted files
rm -rf "${BUILDROOT}/usr/usr"

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