# Template file for 'sane'
pkgname=sane
version=1.0.25
revision=2
wrksrc="sane-backends-${version}"
build_style=gnu-configure
build_options="snmp"
configure_args="--disable-locking --enable-avahi --disable-latex --enable-ipv6
 --with-docdir=/usr/share/doc/sane --enable-libusb_1_0 --enable-pthread
 ac_cv_func_mmap_fixed_mapped=yes
 $(vopt_with snmp)"
hostmakedepends="pkg-config"
makedepends="avahi-libs-devel libjpeg-turbo-devel tiff-devel libgphoto2-devel
 v4l-utils-devel libusb-devel libressl-devel $(vopt_if snmp net-snmp-devel)"
depends="$(vopt_if snmp net-snmp)"
replaces="sane-udev-rules>=0"
conf_files="/etc/sane.d/*.conf"
short_desc="Scanner Access Now Easy"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
homepage="http://www.sane-project.org/"
license="GPL-2"
distfiles="http://ftp.lfs-matrix.net/pub/blfs/conglomeration/sane-backends/sane-backends-${version}.tar.gz"
checksum=a4d7ba8d62b2dea702ce76be85699940992daf3f44823ddc128812da33dc6e2c

post_install() {
	# fix hp officejets
	echo "#hpaio" >> ${DESTDIR}/etc/sane.d/dll.conf

	vinstall ${FILESDIR}/saned.xinetd 644 etc/xinetd.d saned.conf
	vinstall ${wrksrc}/tools/sane-backends.pc 644 usr/lib/pkgconfig

	# generate udev file
	cd tools
	mkdir -p udev
	make udev/libsane.rules
	# install udev file
	vinstall udev/libsane.rules 644 usr/lib/udev/rules.d 49-sane.rules
	# fix udev rules
	sed -i 's|NAME="%k", ||g' ${DESTDIR}/usr/lib/udev/rules.d/49-sane.rules
}

libsane_package() {
	short_desc+=" - runtime shared library"
	pkg_install() {
		vmove usr/lib/libsane.so.*
	}
}
sane-devel_package() {
	depends="libsane>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/bin/sane-config
		vmove usr/share/man/man1/sane-config.1
		vmove usr/lib/pkgconfig
		vmove usr/lib/*.so
	}
}
