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

pkgname=intel-gmmlib
pkgver=22.8.2
pkgrel=1
pkgdesc="Intel Graphics Memory Management Library"
arch=(x86_64 aarch64)
url="https://github.com/intel/gmmlib/"
license=(MIT)
depends=(gcc-libs glibc)
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=('2e43e538a002574f45d480a24e02297c960963dc7914b7328791d9836832ff43'
            '258b358e69048bcb522a59cbff4c7a9cd2fff0725890849edf6a53568d1e7fbb')

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}/
}
