# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer:
pkgname=gutenprint
pkgver=5.2.11
pkgrel=0
pkgdesc="Printer Drivers Package"
url="http://gimp-print.sourceforge.net/"
arch="all"
license="GPL-2.0-or-later"
depends=""
depends_dev=""
makedepends="$depends_dev cups-dev tiff-dev libjpeg-turbo-dev libpng-dev
	ghostscript-dev libusb-dev autoconf automake libtool gettext-dev"
install=""
subpackages="$pkgname-dev $pkgname-doc $pkgname-lang $pkgname-libs
	$pkgname-cups $pkgname-samples"
source="http://downloads.sourceforge.net/gimp-print/gutenprint-$pkgver.tar.bz2
	musl-fix-header.patch
	pagesize-name-clash.patch
	gutenprint-O6.patch
	"

_builddir="$srcdir"/gutenprint-$pkgver
prepare() {
	local i
	cd "$_builddir"
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
	mkdir -p m4local
	autoreconf -vif || return 1
}

build() {
	cd "$_builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--disable-nls \
		--disable-cups-ppds \
		--enable-simplified-cups-ppds \
		|| return 1
	make || return 1
}

package() {
	cd "$_builddir"
	make DESTDIR="$pkgdir" install || return 1
	rm -r "$pkgdir"/usr/share/gutenprint/doc \
		"$pkgdir"/etc/cups/command.types \
		|| return 1
}

cups() {
	pkgdesc="CUPS drivers for Canon, Epson, HP and compatible printers"
	for d in usr/share usr/lib usr/bin usr/sbin etc; do
		mkdir -p "$subpkgdir"/$d || return 1
		mv "$pkgdir"/$d/cups* "$subpkgdir"/$d/ || return 1
	done
}

samples() {
	pkgdesc="Sample test pattern generator for gutenprint-dev"
	mkdir -p "$subpkgdir"/usr/share/gutenprint "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/share/gutenprint/samples \
		"$subpkgdir"/usr/share/gutenprint/ || return 1
	mv "$pkgdir"/usr/bin/testpattern "$subpkgdir"/usr/bin/ || return 1

}

md5sums="fa6083535b7235fe531cd57e7345a81f  gutenprint-5.2.11.tar.bz2
8bf8113137aca7ae6b14d7247fd4df53  musl-fix-header.patch
ccedfc1a47b3e05534fbd7fe63d808f8  pagesize-name-clash.patch
bc3422ed9a1f2fe251449bf727ca4d72  gutenprint-O6.patch"
sha256sums="c1a34cd2e02527de4d2a9bf6c14732cb9aa11b333f771eb6043fdc974de24df9  gutenprint-5.2.11.tar.bz2
a79e23f424494073fc0e940ae275fd2ca53f9de1d2fb931db96711bec943b313  musl-fix-header.patch
1eda1a8e300185dace67b663ac571c6992dd680355bd0a125701c4368736ac34  pagesize-name-clash.patch
d7208080f43199930df7abff9e68513e85b548c3bc362c7a392646abfb0c8285  gutenprint-O6.patch"
sha512sums="f4010e489dd6763b19113abf1d55e84cea8d36b920d03dbe204dba30ab0d3fb3e3391e739cd1a56e2f63581c8ce4a856a7f747deb6e7b18d7e1f7a3d87901c60  gutenprint-5.2.11.tar.bz2
97c38aa2d7931af25e577e27949f659bd45be3e9deab0af86e437587a526d5d37006d0fddd57ad22e1bbe39f25dfa34926e75690a243c7736840cf85ca5ae2df  musl-fix-header.patch
8b17b4d3dd3f9dbeff7c3a3da38395cde8bea51abe5a8ebeac62b9e442dc451341b3571de02437d035a63da83d10316a4ce0da143cc90a935678a01fb5efb224  pagesize-name-clash.patch
81cdbd3ff271fec2d7d17313772db6d2617da90bd532a6e2d834e8bfde9e5329a62b01876714be145dbf23071a053374b1b78dd173ea999d0e873b895b49d0a6  gutenprint-O6.patch"
