# Template file for 'libxslt'
pkgname=libxslt
version=1.1.39
revision=2
build_style=gnu-configure
configure_args="--enable-static --disable-dependency-tracking"
hostmakedepends="docbook-xml docbook-xsl libtool pkg-config python3"
makedepends="libxml2-devel libgcrypt-devel python3-devel"
checkdepends="libxml2-python3"
short_desc="XSLT parser library from the GNOME project"
maintainer="Orphaned <orphan@voidlinux.org>"
license="MIT"
homepage="https://gitlab.gnome.org/GNOME/libxslt"
distfiles="${GNOME_SITE}/libxslt/${version%.*}/libxslt-${version}.tar.xz"
checksum=2a20ad621148339b0759c4d4e96719362dee64c9a096dbba625ba053846349f0
python_version=3
CFLAGS="-I$XBPS_CROSS_BASE/usr/include/python$py3_ver"
CFLAGS+=" -D_LARGE_FILE_SOURCE=1 -D_FILE_OFFSET_BITS=64"

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'
}

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
	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/lib/*.a"
		vmove usr/share/aclocal
		vmove usr/share/doc
		vmove usr/share/man/man3
		vmove usr/share/gtk-doc
		vmove usr/lib/cmake
	}
}

libxslt-python3_package() {
	depends="python3 ${sourcepkg}>=${version}"
	short_desc+=" - Python 3 bindings"
	pkg_install() {
		vmove "${py3_lib}"
	}
}
