NAME="mesa"
DESC="OpenGL compatible 3D graphics library"
VERSION="23.1.6"
FILES=(
  "https://mesa.freedesktop.org/archive/mesa-$VERSION.tar.xz"
  "https://www.linuxfromscratch.org/patches/blfs/12.0/mesa-add_xdemos-2.patch"
)
HASHES=(
  "5dd176e3f283143cc193b5a8264a206e"
  "52c375052d14dc879b70da4881f8ed32ecba1c8b58a4865386e05c1003aed343"
)
DEPENDS=("libdrm" "libxxf86vm" "libxshmfence" "zstd")

PACKAGE() {
  tar xf $NAME-$VERSION.tar.xz
  cd $NAME-$VERSION

  patch -Np1 -i ../mesa-add_xdemos-2.patch
  mkdir build
  cd    build

  meson setup                 \
      --prefix=/usr           \
      --buildtype=release     \
      -Dplatforms=x11,wayland \
      -Dgallium-drivers=auto  \
      -Dvulkan-drivers=""     \
      -Dvalgrind=disabled     \
      -Dlibunwind=disabled    \
      ..                     

  ninja && DESTDIR=${ROOTDIR} ninja install
  install -v -dm755 $ROOTDIR/usr/share/doc/mesa-$VERSION
  cp -rfv ../docs/* $ROOTDIR/usr/share/doc/mesa-$VERSION

  cd ../.. && rm -rf $NAME-$VERSION
}
