# Template file for 'tidy5'
# This project has an identity crisis, it's "Tidy",
# "HTML Tidy" and "Tidy HTML5". Binaries are tidy5.
pkgname=tidy5
version=5.1.25
revision=1
_reponame=tidy-html5
wrksrc=${_reponame}-${version}
build_style=cmake
cmake_builddir=build/cmake
hostmakedepends="cmake libxslt"
short_desc="HTML Tidy with HTML5 support"
maintainer="beefcurtains <beefcurtains@voidlinux.eu>"
license="W3C"
homepage="http://www.htacg.org/${_reponame}/"
distfiles="https://github.com/htacg/${_reponame}/archive/${version}.tar.gz"
checksum=be81e967537984fbd207b4b19d02e7be73cbf201f07bf55aa5560c9b1d19b106

pre_configure() {
	# the $(man) target requires tidy5 to run on the host
	ln -s ${cmake_builddir}/tidy
	if [ -n "$CROSS_BUILD" ]; then
		rm -f tidy
		cd ${cmake_builddir}

		env - PATH=/usr/bin cmake -DBUILD_SHARED_LIB:BOOL=FALSE ${wrksrc}
		make ${makejobs} tidy

		cp tidy ${wrksrc}
		cd ${wrksrc}
		rm -rf ${cmake_builddir}
	fi
}

post_install() {
	vlicense README/LICENSE.txt LICENSE
	mv ${DESTDIR}/usr/bin/tidy{,5}
	mv ${DESTDIR}/usr/share/man/man1/tidy{,5}.1
}

libtidy5_package() {
	short_desc+=" - library files"
	pkg_install() {
		vmove usr/lib/*.so.*
	}
}

libtidy5-devel_package() {
	depends="libtidy5>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/*.a
		vmove usr/lib/*.so
	}
}
