# Template build file for 'poppler'.
pkgname=poppler
version=0.22.3
revision=2
build_style=gnu-configure
configure_args="--enable-zlib --enable-libcurl --enable-libjpeg
--enable-libtiff --disable-libopenjpeg --enable-cairo-output
--enable-xpdf-headers --disable-poppler-qt4 --disable-gtk-test"
hostmakedepends="pkg-config poppler-data"
makedepends="libpng-devel>=1.6 glib-devel cairo-devel tiff-devel lcms2-devel libcurl-devel"
short_desc="PDF rendering library"
maintainer="Juan RP <xtraeme@gmail.com>"
license="GPL-2"
homepage="http://poppler.freedesktop.org"
distfiles="${homepage}/$pkgname-$version.tar.gz"
checksum=916a931cbef951366014f13d5f4a574657ccc064ac41051df96dd58e22934431
long_desc="
 This is poppler, a PDF rendering library. It is a fork of the xpdf
 3.0 PDF viewer developed by Derek Noonburg of Glyph and Cog, LLC.

 Poppler provides PDF rendering functionality as a shared library,
 to centralize the maintenence effort and to reduce duplicated
 effort. And the poppler developers would like to move libpoppler
 forward in a number of areas that doesn't fit within the goals of xpdf."

if [ "$CROSS_BUILD" ]; then
	# needs glib-mkenums
	hostmakedepends+=" automake libtool gtk-doc gettext-devel glib-devel"
	pre_configure() {
		autoreconf -fi
	}
fi

# Package build options
build_options="gir"
desc_option_gir="Enable support for building gobject introspection data"

# Disable gir for cross builds.
if [ -z "$CROSS_BUILD" ]; then
	build_options_default="gir"
fi

if [ "$build_option_gir" ]; then
	configure_args+=" --enable-introspection"
	makedepends+=" gobject-introspection"
else
	configure_args+=" --disable-introspection"
fi

poppler-cpp-devel_package() {
	depends="libstdc++-devel zlib-devel poppler-devel>=${version}"
	short_desc+=" -- C++ bindings (development files)"
	pkg_install() {
		vmove usr/include/poppler/cpp
		vmove usr/lib/libpoppler-cpp.a
		vmove usr/lib/pkgconfig/poppler-cpp.pc
	}
}

poppler-cpp_package() {
	short_desc+=" -- C++ bindings"
	pkg_install() {
		vmove "usr/lib/libpoppler-cpp.so*"
	}
}

poppler-devel_package() {
	depends="libglib-devel poppler>=${version}"
	short_desc+=" -- development files"
	pkg_install() {
		vmove "usr/include/poppler/*.h"
		vmove usr/include/poppler/splash
		vmove usr/include/poppler/fofi
		vmove usr/include/poppler/goo
		vmove usr/lib/libpoppler.a
		vmove usr/lib/pkgconfig/poppler.pc
		vmove usr/lib/pkgconfig/poppler-splash.pc
		vmove usr/share/gtk-doc
	}
}

poppler-glib-devel_package() {
	depends="poppler-devel>=${version} poppler-glib>=${version}"
	short_desc+=" -- GLib bindings (development files)"
	pkg_install() {
		vmove usr/include/poppler/glib
		vmove usr/lib/libpoppler-glib.a
		if [ "$build_option_gir" ]; then
			vmove usr/share/gir-1.0
		fi
		vmove usr/lib/pkgconfig/poppler-cairo.pc
		vmove usr/lib/pkgconfig/poppler-glib.pc
	}
}

poppler-glib_package() {
	short_desc+=" -- GLib bindings"
	pkg_install() {
		vmove "usr/lib/libpoppler-glib.so*"
		if [ "$build_option_gir" ]; then
			vmove usr/lib/girepository-1.0
		fi
	}
}

poppler-utils_package() {
	short_desc+=" -- utilities"
	pkg_install() {
		vmove usr/bin
		vmove usr/share/man
	}
}

poppler_package() {
	depends="poppler-data"
	pkg_install() {
		vmove all
	}
}
