# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=uchardet
pkgver=0.0.8
pkgrel=2
pkgdesc="Encoding detector library ported from Mozilla"
url="https://www.freedesktop.org/wiki/Software/uchardet"
arch="all"
license="MPL-1.1"
makedepends="cmake samurai"
subpackages="$pkgname-static $pkgname-libs $pkgname-dev $pkgname-doc"
source="https://www.freedesktop.org/software/uchardet/releases/uchardet-$pkgver.tar.xz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_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 \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	ctest --test-dir build
}

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

sha512sums="
4a5dcc9ff021352f3b252e103ff1475cec62c974294b264ee9243f024633c3ae44be8c7733608624066113e635f8b156ecb08c8ff87c736d04b07641eb166382  uchardet-0.0.8.tar.xz
"
