# mesa - the graphics stack for AMD, Intel and everything else free.
name=mesa
version=26.0.2
release=2
desc="Open source OpenGL and Vulkan implementation"
url="https://mesa3d.org/"
license="MIT"
# mesa is not split here the way other distributions split it: the Vulkan
# ICDs, the VA driver and the software rasteriser are all in this package,
# and these names are what an installer or a profile asks for.
provides="vulkan-radeon vulkan-intel vulkan-swrast libva-mesa-driver"
depend="glibc libdrm wayland libx11 zlib zstd expat llvm libclc spirv-llvm-translator"
makedepend="meson ninja clang lld python"
_old_provides="opengl vulkan"
source="https://archive.mesa3d.org/mesa-$version.tar.xz"
sha256="SKIP"

build() {
	cd "mesa-$version"
	# One build covers AMD, Intel and the software fallback. ScrapLinux enables
	# every free driver so a single package works on any machine.
	#
	# Two drivers are deliberately absent. nouveau's Vulkan driver (NVK) is
	# written in Rust and its build wants bindgen, and ScrapLinux has no Rust
	# toolchain - nouveau's gallium driver is C and stays. VDPAU is gone from
	# mesa 26 entirely, and meson stops on the unknown option rather than
	# ignoring it.
	#
	# Every option is on one continued command: a comment between two
	# backslash-continued lines is not a comment at all, it swallows the rest
	# of the command - which is how -Dvulkan-drivers went missing, left
	# vulkan-drivers at "auto", and put NVK back in.
	meson setup build --prefix=/usr --buildtype=release \
		--libdir=lib \
		-Dgallium-drivers=iris,crocus,radeonsi,r300,r600,nouveau,llvmpipe,softpipe,zink,virgl,svga \
		-Dvulkan-drivers=amd,intel,intel_hasvk,swrast \
		-Dplatforms=wayland,x11 \
		-Dglx=dri \
		-Degl=enabled \
		-Dgbm=enabled \
		-Dllvm=enabled \
		-Dshared-llvm=enabled \
		-Dvideo-codecs=all \
		-Dgallium-va=enabled
	ninja -C build -j"$JOBS"
}

package() {
	cd "mesa-$version"
	DESTDIR="$pkgdir" ninja -C build install
}
