# NOT WORKING as it still produces dynamic libraries
# Building this as static library is also not useful, see https://gitlab.freedesktop.org/glvnd/libglvnd/-/issues/212

_pkgname=libglvnd
pkgname=$_pkgname-static
pkgver=1.3.2
pkgrel=1
pkgdesc="The GL Vendor-Neutral Dispatch library"
arch=('x86_64')
url="https://github.com/NVIDIA/libglvnd"
license=('custom:BSD-like')
depends=('libxext-static' 'mesa' 'opengl-driver')
makedepends=('libx11' 'xorgproto' 'python' 'meson')
options=(staticlibs)
source=("$_pkgname-$pkgver.tar.gz::https://gitlab.freedesktop.org/glvnd/libglvnd/-/archive/v${pkgver}/libglvnd-v${pkgver}.tar.gz"
        LICENSE)
sha512sums=('01db155f02fa21f4217ee5ca6dd8eeed3d20672c8aaa43475bd112921716ee8d4124e01f80a89587ddc8ebfa4a552c5e02d70726222702cce1601a6e6f4bc22b'
            'bf0f4a7e04220a407400f89226ecc1f798cc43035f2538cc8860e5088e1f84140baf0d4b0b28f66e4b802d4d6925769a1297c24e1ba39c1c093902b2931781a5')

build() {
  export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/static/lib/pkgconfig
  arch-meson $_pkgname-v$pkgver build \
    -D gles1=false \
    --prefix /usr/static \
    --default-library static

  ninja -C build
}

package() {
  # libglvnd needs mesa for indirect rendering
  DESTDIR="$pkgdir" ninja -C build install
  
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
