# packages/lcdproc/auxbuild
#

# download and unpack tarball
TARVERSION="0.5.3"
TARDIR="${BUILD_PACKAGE}-${TARVERSION}"
TARBALL="${TARDIR}.tar.gz"
build_download "http://downloads.sourceforge.net/lcdproc/${TARBALL}"
build_unpack "${TARBALL}"
PKGDIR="${TARDIR}"

# Add our driver sources and patches
cp src/* Distn/$PKGDIR/server/drivers/

build_patch "${PKGDIR}" "${BUILD_PACKAGE}-ALL-" 

# Since we've patched some of the autoconf sources we need to rebuild configure
(
    cd "Distn/${PKGDIR}"
    aclocal
    autoconf
    automake
)

# The hd44780 driver has been modified to support the E2AM I2C LCD display via 
# libgsli2c this introduces a dependency that we only support on the EAM at
# present.
if [ "${BUILD_MACHINE%-eabi}" == "CMG-DCM-mk4" ]
then
    DLIST="CFontz,CFontzPacket,hd44780"
    DOPTS="--enable-libgsli2c --disable-libftdi --disable-ethlcd --disable-libusb"
else
    DLIST="CFontz,CFontzPacket"
    DOPTS=""
fi

# invoke configure (directory, prefix, extra arguments)
build_autoconf "${PKGDIR}" "/usr" \
	"--enable-drivers=$DLIST $DOPTS --sysconfdir=/etc/lcdproc"

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

# Install GSL specific support files
cp -r static/* "Buildroot/${BUILD_MACHINE}/"

# remove unwanted files, install config file symlink
rm "${BUILDROOT}/usr/bin/"*.pl "${BUILDROOT}/etc/lcdproc/LCDd.conf"
ln -sf "LCDd.conf.local" "${BUILDROOT}/etc/lcdproc/LCDd.conf"

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