# Description: CUPS - Common UNIX Printing System
# URL: https://openprinting.github.io/cups/
# Maintainer: Juergen Daubert, jue at crux dot nu
# Depends on: acl libusb zlib linux-pam
# Optional: dbus gnutls openssl

name=cups
version=2.4.7
release=1
source=(https://github.com/OpenPrinting/cups/releases/download/v$version/$name-$version-source.tar.gz
	cups.rc cups.pam)

build() {
	cd $name-$version

	PKGMK_CUPS=' --with-tls=openssl'
	prt-get isinst gnutls && PKGMK_CUPS=' --with-tls=gnutls'

	CC=cc CXX=c++ \
	./configure $PKGMK_CUPS \
		--prefix=/usr \
		--sysconfdir=/etc \
		--libdir=/usr/lib \
		--localstatedir=/var \
		--with-rundir=/run/cups \
		--with-docdir=/usr/share/cups/doc \
		--with-logdir=/var/log/cups \
		--with-cups-user=daemon \
		--with-cups-group=lp \
		--with-languages="" \
		--without-rcdir \
		--with-optim="$CFLAGS" \
		--enable-acl \
		--without-systemd

	make
	make BUILDROOT=$PKG install

	# conflict with cups-filters
	rm -r $PKG/usr/share/cups/{banners,data}

	# cleanup
	rm -r $PKG/usr/share/{applications,icons}
	rm -r $PKG/run
	chmod 0755 $PKG/var/{cache,spool}   
	chmod -R +w $PKG

	# start script and pam module
	install -D -m 755 $SRC/cups.rc $PKG/etc/rc.d/cups
	install -D -m 644 $SRC/cups.pam $PKG/etc/pam.d/cups

	# blacklist usblp kernel module
	install -d $PKG/etc/modprobe.d
	echo 'blacklist usblp' > $PKG/etc/modprobe.d/cups.conf
}
