#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobextra/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=mesa-amber
pkgdesc="classic OpenGL (non-Gallium3D) drivers -no ZSTD"
pkgver=21.3.8
pkgrel=05
arch=('x86_64')
makedepends=('python-mako' 'libxml2' 'libx11' 'xorgproto' 'libdrm' 'libxshmfence' 'libxxf86vm'
             'libxdamage' 'wayland' 'wayland-protocols' 'elfutils' 'llvm'
             'libglvnd' 'libunwind' 'libxrandr' 'valgrind' 'cmake' 'meson')
url="https://www.mesa3d.org/"
source=(https://mesa.freedesktop.org/archive/mesa-${pkgver}.tar.xz{,.sig}
        LICENSE)

prepare() {
  cd mesa-$pkgver
}

build() {
  arch-meson mesa-$pkgver build \
    -D b_lto=true \
    -D b_ndebug=true \
    -D amber=true \
    -D platforms=auto \
    -D dri-drivers=i915,i965,r100,r200,nouveau \
    -D gallium-drivers=swrast \
    -D vulkan-drivers=auto \
    -D dri3=enabled \
    -D egl=enabled \
    -D gbm=enabled \
    -D gles1=disabled \
    -D gles2=enabled \
    -D glvnd=auto \
    -D glx=dri \
    -D libunwind=enabled \
    -D llvm=enabled \
    -D zstd=disabled \
    -D lmsensors=disabled \
    -D osmesa=true \
    -D shared-glapi=enabled \
    -D microsoft-clc=disabled \
    -D valgrind=enabled

  # Print config
  meson configure build

  ninja -C build
  meson compile -C build
}

package() {
  depends=('libglvnd')
  conflicts=('mesa')
  provides=("mesa=${pkgver}" "opengl-driver")
  DESTDIR="${pkgdir}" meson install -C build
 
  # indirect rendering
  ln -s /usr/lib/libGLX_amber.so.0 "${pkgdir}/usr/lib/libGLX_indirect.so.0"

  install -m644 -Dt "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
}

#---- license gpg-key sha256sums ----

license=('custom')

validpgpkeys=('57551DE15B968F6341C248F68D8E31AFC32428A6') # Eric Engestrom <eric@engestrom.ch>

sha256sums=(e70d273bdc53a4e931871bb5550ba3900e6a3deab2fff64184107c33e92d9da7 # mesa-21.3.8.tar.xz
	e07d6dc4856cdac895fe96a8a5d34ac0558f93a3c6900fc203bbd1a84632296f # mesa-21.3.8.tar.xz.sig
	7052ba73bb07ea78873a2431ee4e828f4e72bda7d176d07f770fa48373dec537) # LICENSE
 
 
