# Maintainer: Bruno Pagani <archange@archlinux.org>
# Maintainer: Daniel Bermond <dbermond@archlinux.org>

pkgname=intel-gmmlib
pkgver=22.3.19
pkgrel=1
pkgdesc="Intel Graphics Memory Management Library"
arch=(x86_64 aarch64)
url="https://github.com/intel/gmmlib/"
license=(MIT)
depends=(gcc-libs)
makedepends=(cmake)
provides=(gmmlib)
conflicts=(gmmlib)
replaces=(gmmlib)
options=(!emptydirs)
source=(https://github.com/${pkgname/-//}/archive/${pkgname}-${pkgver}.tar.gz
        aarch64-no-sign-extend.patch)
sha256sums=('ea9c418b0fd84a982850f230cb2d783dfe2e1f9923065f54b2fcaad1e9b33417'
            'SKIP')

prepare() {
  cd gmmlib-${pkgname}-${pkgver}
  patch -Np1 < ../aarch64-no-sign-extend.patch
}

build() {
  cmake -B build -S gmmlib-${pkgname}-${pkgver} \
    -G 'Unix Makefiles' \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DRUN_TEST_SUITE=ON \
    -Wno-dev
  cmake --build build
}

package() {
  DESTDIR="${pkgdir}" cmake --install build
  install -Dm644 gmmlib-${pkgname}-${pkgver}/LICENSE.md -t "${pkgdir}"/usr/share/licenses/${pkgname}/
}
