### this file is sourced not run
PKGVER=0.999debian5
PKGBUILD=1
PKGARCH=x86_64

# source: BLFS 7.5 + debian
TARBALL=xsane-0.999.tar.gz
MD5SUM=9927f21e1ab6ba96315e7f0e30746deb 
#SRC_URL=http://www.xsane.org/download/$TARBALL # dead
SRC_URL=http://distro.ibiblio.org/fatdog/source/800/$TARBALL # dead
BUNDLE=

SLACKREQ='gtk2 sane-backend'
SLACKDESC="xsane: xsane $PKGVER (SANE GUI)  
xsane:  
xsane: XSane is another front end for SANE. It has additional features 
xsane: to improve the image quality and ease of use compared to xscanimage 
xsane: (from sane-frontend package).  
xsane: 
xsane: 
xsane: 
xsane: 
xsane: 
xsane:  
"

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/xsane*
	tar -xf ../pkg/xsane*debian.tar.xz &&
	for p in $(cat debian/patches/series); do
		patch -Np1 -i debian/patches/$p || return 1
	done
}

### default pkg_package
### build
pkg_build() {
	cd /tmp/xsane*
	
	# BLFS fix building with newer PNG - debian patch 0145-fix_png15.patch does the same
	#sed -i -e 's/png_ptr->jmpbuf/png_jmpbuf(png_ptr)/' src/xsane-save.c &&
	
	# Fatdog: running as root is OK
	sed -i -e 's/!getuid()/0/' src/xsane.c &&

	# build it
	./configure $CONFFLAGS && make $MAKEFLAGS && 
	make xsanedocdir=/usr/share/doc/xsane-0.999 install &&

	# gimp plugin
	mkdir -p /usr/$LIBDIR/gimp/2.0/plug-ins/ &&
	ln -v -s /usr/bin/xsane /usr/$LIBDIR/gimp/2.0/plug-ins/ &&
	
	ln -v -s ../../doc/xsane-0.999 /usr/share/sane/xsane/doc &&
	
	# fix double menu entries
	sed -i 's/^Categories=.*/Categories=Graphics/' /usr/share/applications/xsane.desktop &&

	pkg_build_slackdesc
}


