# Template file for 'libxslt'
pkgname=libxslt
version=1.1.34
revision=5
build_style=gnu-configure
configure_args="--disable-static --disable-dependency-tracking"
hostmakedepends="docbook-xml docbook-xsl libtool python-devel
 libxml2-python pkg-config"
makedepends="python-devel libxml2-devel libxml2-python libgcrypt-devel"
short_desc="XSLT parser library from the GNOME project"
maintainer="Orphaned <orphan@voidlinux.org>"
license="MIT"
homepage="http://xmlsoft.org/XSLT/"
distfiles="http://xmlsoft.org/sources/libxslt-${version}.tar.gz
	ftp://xmlsoft.org/${pkgname}/${pkgname}-${version}.tar.gz"
checksum="98b1bd46d6792925ad2dfe9a87452ea2adebf69dcb9919ffd55bf926a7f93f7f
 98b1bd46d6792925ad2dfe9a87452ea2adebf69dcb9919ffd55bf926a7f93f7f"

if [ "$CROSS_BUILD" ]; then
	hostmakedepends+=" libxslt"
fi

post_configure() {
	# Remove missing seperators and errors
	# on don't know how to make target, needed
	# by Usage:
	# Makefile is created after configure so fix here
	find ${wrksrc} -type f -name Makefile | xargs sed -i '/Usage/,/--version/d'
	if [ "$CROSS_BUILD" ]; then
		sed -e "s|/usr/include/python2.7|$XBPS_CROSS_BASE/&|g" \
			-e "s|/usr/lib/python2.7/site-packages|$XBPS_CROSS_BASE/&|g" \
			-i python/Makefile
	fi
}

post_build() {
	if [ "$CROSS_BUILD" ]; then
		XSLTPROC=/usr/bin/xsltproc
	else
		XSLTPROC=${wrksrc}/xsltproc/xsltproc
	fi
	make -C doc XSLTPROC=$XSLTPROC
}

post_install() {
	if [ "$CROSS_BUILD" ]; then
		# Remove $XBPS_CROSS_BASE in pkg-config
		vsed -i -e "s,-I${XBPS_CROSS_BASE}/usr/include,-I\${includedir}," \
			$DESTDIR/usr/bin/xslt-config
		vsed -i -e "s,$XBPS_CROSS_BASE,,g" \
			$DESTDIR/usr/lib/pkgconfig/libexslt.pc
	fi
	vlicense COPYING
}

libxslt-devel_package() {
	depends="libxml2-devel ${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/bin/xslt-config
		vmove usr/lib/xsltConf.sh
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.so"
		vmove usr/share/aclocal
		vmove usr/share/doc/${sourcepkg}-${version}
		vmove usr/share/man/man3
	}
}

libxslt-python_package() {
	lib32disabled=yes
	short_desc+=" - python extension"
	pkg_install() {
		vmove "usr/lib/python*"
		vmove usr/share/doc/${sourcepkg}-python-${version}
	}
}
