# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=qpdf
pkgver=7.0.0
pkgrel=0
pkgdesc="Command-line tools and library for transforming PDF files"
url="http://qpdf.sourceforge.net/"
arch="all"
license="Artistic-2.0"
depends=""
# coreutils needed for tests
makedepends="zlib-dev libjpeg-turbo-dev bash coreutils perl"
install=""
subpackages="$pkgname-dev $pkgname-doc $pkgname-libs $pkgname-fix-qdf:fix_qdf:noarch"
source="http://downloads.sourceforge.net/sourceforge/qpdf/qpdf-$pkgver.tar.gz"

builddir="$srcdir"/qpdf-$pkgver

prepare() {
	update_config_sub
	default_prepare
}

build() {
	cd "$builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--disable-static
	make
}

check() {
	cd "$builddir"
	make check
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install
}

fix_qdf() {
	depends="qpdf perl"
	pkgdesc="Repair PDF files in QDF form after editing"
	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/fix-qdf "$subpkgdir"/usr/bin/
}

sha512sums="7b52d67b4d2c428a7b0c1cd03b03a23f05d38d7e3c81041079a137919019ea5158f12bf95fdcfcff6b43ffdefe93a85127ced2a363a6b4b380cbaa02a3840256  qpdf-7.0.0.tar.gz"
