### this file is sourced not run
PKGVER=2.1.3
PKGBUILD=1
PKGARCH=i686

# source: post BLFS 7.8 2015-12-31
TARBALL=cups-$PKGVER-source.tar.bz2
MD5SUM=62b8fafd590e75f72316915790b0850a
SRC_URL=http://www.cups.org/software/$PKGVER/$TARBALL
BUNDLE=

SLACKREQ='openssl32 cups-filters32 dbus32 libusb32'
SLACKDESC="cups-std32: cups-std32 $PKGVER (CUPS - Common Unix Printing System)  
cups-std32:  
cups-std32: The Common Unix Printing System (CUPS) is a print spooler and associated 
cups-std32: utilities. It is based on the \"Internet Printing Protocol\" and provides 
cups-std32: printing services to most PostScript and raster printers.  
cups-std32: 
cups-std32: This is the version of CUPS that does not have dependency on
cups-std32: mdns-responder or avahi. But it cannot find Zeroconf/Bounjour printers.
cups-std32: 
cups-std32: 
cups-std32: 
"
SLACKSUG=xdg-utils
SLACKCON=cups

### default pkg_download
### default pkg_prepare

pkg_package() {
	rm -rf etc bin sbin usr/bin usr/sbin usr/include usr/share var
	mkdir -p usr/bin
	mv tmp/*-32 usr/bin
}

### build
pkg_build() {
	# note: NO CONFFLAGS here!!! Edit !!!

	# create users (must be the same as the one we will use in the running system)
	echo lp::111: >> /etc/group
	echo lpadmin::112: >> /etc/group
	echo lp:x:9:111:lp:/var/spool/cups:/bin/false >> /etc/passwd
	#return 1
	
	cd /tmp/cups* &&
	#sed -i -e '/CUPS_SERVERBIN/ s|/lib/|/lib64/|' \
	#config-scripts/cups-directories.m4 && # lib64 patch
	
	# re-generate configure
	aclocal -I config-scripts &&
	autoconf -I config-scripts &&
	./configure --libdir=/usr/$LIBDIR \
            --with-rcdir=/tmp/cupsinit \
            --with-docdir=/usr/share/cups/doc \
            --with-system-groups=lpadmin \
            --disable-dbus \
            --disable-gnutls --enable-openssl \
            --disable-dnssd \
            --disable-avahi \
            --enable-libusb --enable-relro &&
#           --disable-libusb # they say in cups after 1.7.3 both usblp and libusb works
	make $MAKEFLAGS &&
	make $MAKEINSTALLFLAGS install &&
	
	ln -sfv ../cups/doc /usr/share/doc/cups-$PKGVER &&
	echo "ServerName /var/run/cups/cups.sock" > /etc/cups/client.conf &&
	rm -rf /usr/share/cups/banners &&
	rm -rf /usr/share/cups/data--disable-avahi \/testprint &&
	rm /etc/passwd /etc/group &&
	pkg_build_slackdesc &&
	
	# multilib
	mv -v /usr/bin/cups-config /tmp/cups-config-32

}
