# Maintainer: Developer <dev@opalos.org>
# Maintainer: Developer <dev@opalos.org>

pkgname=numactl
pkgver=%version%
pkgrel=%release%
pkgdesc="Simple NUMA policy support"
arch=(x86_64)
url="https://github.com/numactl/numactl"
license=(
  GPL-2.0-only
  LGPL-2.1-only
)
depends=(glibc)
provides=(libnuma.so)
source=($pkgname-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz)
sha512sums=('fc062e7fcfd90e3d26d0e3b144b4c4328b54874aef6ad0c91d7740e5989787a182037c5d409ce9271f0a6459d4d7e70f49cc5f701d93b64a15d3b7772accb9b4')
b2sums=('743f02c91897cdc90d2b0b7da4d3a51be1e1eb796fc09c6cdd321d0f9f13afffb9745ca005ac82e3448f4017f2aefd6b8e562abaebe11cef3e1ffc01c412174a')

prepare(){
  cd $pkgname-$pkgver
  autoreconf -fiv
}

build() {
  cd $pkgname-$pkgver
  ./configure --prefix=/usr
  # prevent excessive overlinking due to libtool
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  make -k test -C $pkgname-$pkgver || echo "Tests known to fail depending on system load."
}

package() {
  make DESTDIR="$pkgdir" install -C $pkgname-$pkgver
  install -vDm 644 $pkgname-$pkgver/README.md -t "$pkgdir/usr/share/doc/$pkgname/"
  # move_pages(2) is provided by man-pages and is more up-to-date there anyway
  rm -rf "$pkgdir/usr/share/man/man2"
}
