# Description: Hewlett-Packard's Linux Imaging and Printing software (HPLIP).
# URL: http://hplipopensource.com/hplip-web/index.html
# Packager: tnut at nutyx dot org
# Depends on: sip avahi python ghostscript foomatic-db foomatic-db-engine usbutils sane cups cups-filters libusb-compat net-snmp dbus-python python-gobject2 python-notify python-pillow python-reportlab python-xml

run=(sip avahi python ghostscript foomatic-db foomatic-db-engine usbutils sane cups cups-filters libusb-compat net-snmp dbus-python python-gobject2 python-notify python-pillow python-reportlab python-xml)

name=hplip
version=3.16.5
release=1

source=(http://downloads.sourceforge.net/$name/$name-$version.tar.gz)

build() {
        cd $name-$version

        # Use system foomatic-rip for hpijs driver instead of foomatic-rip-hplip
        # The hpcups driver does not use foomatic-rip
        local i
        for i in ppd/hpijs/*.ppd.gz ; do
                rm -f ${i}.temp
                gunzip -c ${i} | sed 's/foomatic-rip-hplip/foomatic-rip/g' | \
                        gzip > ${i}.temp || return 1
                mv ${i}.temp ${i}
        done

        export AUTOMAKE='automake --foreign'
        autoreconf --force --install

        ./configure --prefix=/usr \
                --enable-qt4 \
                --disable-foomatic-rip-hplip-install \
                --enable-foomatic-ppd-install \
                --enable-hpcups-install \
                --enable-new-hpcups \
                --enable-cups-ppd-install \
                --enable-cups-drv-install \
                --enable-hpijs-install \
                --enable-foomatic-drv-install \
                --enable-pp-build \
                --enable-udev-acl-rules \
                --enable-dbus-build  \
                --enable-scan-build \
                --enable-fax-build \
                --enable-network-build
        make
	make DESTDIR=$PKG install || make -j1 DESTDIR=$PKG install

        # remove config provided by sane and autostart of hp-daemon
        rm -rf $PKG/etc/{sane.d,xdg}

        # remove HAL .fdi file because HAL is no longer used
        rm -vrf $PKG/usr/share/hal
}
