# Contributor: Valery Kartel <valery.kartel@gmail.com>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@alpinelinux.org>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=tidyhtml
pkgver=5.8.0
pkgrel=4
pkgdesc="Tool to tidy down your HTML code to a clean style"
url="https://www.html-tidy.org"
arch="all"
license="W3C"
makedepends="cmake libxslt samurai"
subpackages="$pkgname-doc $pkgname-static $pkgname-dev $pkgname-libs"
source="$pkgname-$pkgver.tar.gz::https://github.com/htacg/tidy-html5/archive/$pkgver.tar.gz"
builddir="$srcdir/tidy-html5-$pkgver"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		local crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DSUPPORT_LOCALIZATIONS=OFF \
		-DTIDY_CONSOLE_SHARED=ON \
		$crossopts
	cmake --build build
}

check() {
	cd build
	./tidy --help > /dev/null
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
f352165bdda5d1fca7bba3365560b64d6f70a4e010821cd246cde43bed5c23cea3408d461d3f889110fd35ec9b68aa2b4e95412b07775eb852b7ee1745007a44  tidyhtml-5.8.0.tar.gz
"
