# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=libcpuid
pkgver=0.6.5
pkgrel=0
pkgdesc="C library for x86 CPU detection and feature extraction"
url="https://github.com/anrieff/libcpuid"
arch="x86 x86_64"
license="BSD-2-Clause"
makedepends="cmake samurai"
checkdepends="python3"
subpackages="$pkgname-dev $pkgname-tool"
source="https://github.com/anrieff/libcpuid/releases/download/v$pkgver/libcpuid-$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DLIBCPUID_TESTS="$(want_check && echo ON || echo OFF)" \
		$crossopts
	cmake --build build
}

check() {
	ninja -C build test-old
}

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

tool() {
	pkgdesc="$pkgdesc (CLI tool)"

	amove usr/bin
}

sha512sums="
5d7660abbf71e8582a723ccfc308f787887be5eeac36582bf0e85dd3a432984740870b91c99fab3a36ae3cfd79261ca0bab1bdf5c6b1ae41a9682d6f91d57d26  libcpuid-0.6.5.tar.gz
"
