# http://www.linuxfromscratch.org/blfs/view/svn/x/mesa.html

description="Mesa is an OpenGL compatible 3D graphics library."
url="http://www.xorg-mesa3d.org"

license="custom"

packager="spiky <spiky@nutyx.org>"
contributors="Pierre,Rems,Tnut"

makedepends=(meson ninja libclc python-ply rust-bindgen cbindgen
             xorgproto pkgconf libtool xorg-xrandr wayland python-mako
             wayland-protocols xorg-libx11 xorg-libdrm xorg-libxext
             xorg-libxdamage expat llvm elfutils xorg-libxshmfence python-yaml
             libva libvdpau valgrind lm-sensors xorg-libxvmc libunwind vulkan-icd-loader glslang)

run=(libglvnd)
alias=(xorg-mesa Mesa mesa3d Mesa3D mesa3)

name=mesa
version=24.2.3

source=(LICENSE
        https://mesa.freedesktop.org/archive/mesa-$version.tar.xz)

build() {
cd $name-$version

mkdir build
cd    build

meson setup                          \
      --prefix=/usr                  \
      -Dbuildtype=release            \
      -Dgallium-drivers="crocus,iris,nouveau,r300,r600,radeonsi,svga,swrast,virgl,zink" \
      -Dvulkan-drivers=auto \
      -Dgallium-nine=false       \
      -Dgallium-vdpau=true       \
      -Dgallium-va=enabled       \
      -Dglx=dri                  \
      -Dosmesa=true              \
      -Dvalgrind=false           \
      -Dlibunwind=false          \
      -Dplatforms="x11,wayland"  \
      -Ddri3=enabled             \
      -Dglvnd=true               \
      -Dglx-direct=true          \
      ..
ninja
DESTDIR=$PKG ninja install

install -m644 -Dt $PKG/usr/share/licenses/$name \
../../LICENSE

install -v -dm755 $PKG/usr/share/doc/mesa-$version
cp -rfv ../docs/* $PKG/usr/share/doc/mesa-$version

# indirect rendering symlink
ln -s libGLX_mesa.so.0 $PKG/usr/lib/libGLX_indirect.so.0
}
