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

pkgname=libcpuid
pkgver=0.7.1
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=('2773250decbba656ffbf95a1d59ac061726117a79aed4a86ad1083041bd745abf00556e8138f5f494ba9e6848a547b969f6dd77062ac20a4524f753b2079c5c1')
b2sums=('54729f400d88a02ab57ce0a7766fbb6b3c9ec136355cbbe47351f213bea410e7190b856b9b8354ee9637e8982aaf8806e7d39ae9fe36e0e12897b2ad0e5da8cd')

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
}
