# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: X0rg

pkgname=libcpuid
pkgver=0.7.0
pkgrel=1
pkgdesc='A small C library for x86 CPU detection and feature extraction'
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
url='http://libcpuid.sourceforge.net'
license=('BSD-2-Clause')
depends=('glibc')
makedepends=(
  'git'
  'cmake'
  'ninja'
  'doxygen'
  'python'
  'graphviz'
)
provides=('libcpuid.so')
source=("$pkgname::git+https://github.com/anrieff/libcpuid#tag=v$pkgver")
sha512sums=('ea4f6c499c11f924b3481272f8dc6ffeabf5371d24a6b0fb1109fe103a00a9cf78a8022a4c4a4ecf9ea1e39e7c4d55fc8a5bd13aff4bfb1ff8f29e7f00898f1f')
b2sums=('d6acf0f3671ad9385e5d3ddd15825ef87cdf81540b310401bfa591ab9e5b3df702ae3d3cd7e069b505aadb53f150273a6402e528310dcc17692c34be638d1633')

build() {
  cd "$pkgname"

	cmake \
    -S . \
    -B build \
    -G Ninja \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_INSTALL_PREFIX=/usr \
    -D LIBCPUID_SHARED=ON \
    -D LIBCPUID_ENABLE_TESTS=ON

	cmake --build build
}

check() {
  cd "$pkgname/build"

  ninja consistency
}

package() {
  cd "$pkgname"

	DESTDIR="$pkgdir" cmake --install build

  # license
	install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" COPYING
}
