# Maintainer: Dinosaur <ancient dash dinosaurus at proton dot me>
# Maintainer: Laurent Carlier <lordheavym@gmail.com>

_pkgname=xf86-video-amdgpu
pkgname=$_pkgname-enhanced
pkgver=25.0.0
pkgrel=1
pkgdesc="X.org amdgpu video driver - enhanced"
arch=('x86_64')
url="https://xorg.freedesktop.org/"
license=('MIT')
depends=('dbus' 'mesa' 'libdrm' 'glibc')
makedepends=('xorg-server-devel-enhanced' 'dbus' 'X-ABI-VIDEODRV_VERSION=28.0' 'meson')
conflicts=('xorg-server<26.0.0.901' 'X-ABI-VIDEODRV_VERSION<28' 'X-ABI-VIDEODRV_VERSION>=29' "${_pkgname}")
provides=("${_pkgname}")
groups=('xorg-drivers-enhanced')
source=(${url}/releases/individual/driver/${_pkgname}-${pkgver}.tar.xz{,.sig})
sha512sums=('d143294fead7073c14100299ccab20d1f5eab8b7e36c1770b12aaade958211e1961f4353dc47123c3b9af9f7a911d913def71d25b83dab3dee1d289043869891'
            'SKIP')
#validpgpkeys=('B09FAF35BE914521980951145A81AF8E6ADBB200') # Michel Daenzer <michel@daenzer.net>
#validpgpkeys=('017E91A875CBA321258380F19B4EE4F98474DE40') # "Alex Deucher <alexdeucher@gmail.com>"
validpgpkeys=('F1111E4AAF984C9763795FFE4B25B5180522B8D9') # Shashank Sharma <contactshashanksharma@gmail.com>

build() {
  # Since pacman 5.0.2-2, hardened flags are now enabled in makepkg.conf
  # With them, module fail to load with undefined symbol.
  # See https://bugs.archlinux.org/task/55102 / https://bugs.archlinux.org/task/54845
  export CFLAGS=${CFLAGS/-fno-plt}
  export CXXFLAGS=${CXXFLAGS/-fno-plt}
  export LDFLAGS=${LDFLAGS/-Wl,-z,now}

  arch-meson $_pkgname-$pkgver build \
    -D glamor=enabled

  # Print config
  meson configure build

  meson compile -C build
}

check() {
  meson test -C build --print-errorlogs
}

package() {
  meson install -C build --destdir "$pkgdir"
  install -Dvm644 $_pkgname-$pkgver/COPYING \
    "$pkgdir/usr/share/licenses/$_pkgname/COPYING"
}
