# SliTaz package receipt.

PACKAGE="mesa"
VERSION="20.3.4"
CATEGORY="x-window"
SHORT_DESC="3D Graphics Library that is an open-source implementaton of OpenGL."
MAINTAINER="pascal.bellard@slitaz.org"
SUGGESTED="nvidia"
TARBALL="$PACKAGE-$VERSION.tar.xz"
WEB_SITE="http://www.mesa3d.org/"
WGET_URL="https://mesa.freedesktop.org/archive/$TARBALL"
PROVIDE="libgl"

DEPENDS="expat libdrm xorg-libX11 libxcb xorg-libXdamage xorg-libXext \
xorg-libXfixes xorg-libxshmfence xorg-libXxf86vm llvm-lib-base libatomic"
BUILD_DEPENDS="bison flex elfutils-dev python3-setuptools python3-mako meson \
ninja libdrm-dev eudev-dev xorg-xproto expat-dev elfutils-dev libxcb-dev \
xorg-libxshmfence-dev xorg-libX11-dev llvm xorg-libXext-dev xorg-libXdamage-dev \
xorg-libXfixes-dev xorg-libXxf86vm-dev xorg-libpciaccess-dev libva-dev \
libvdpau-dev zlib-dev xorg-libXi-dev xorg-libXrandr-dev libatomic"

# Rules to configure and make the package.
compile_rules()
{
	# Remove intel vulkan (failed with -march=i486)
	# https://gitlab.freedesktop.org/mesa/mesa/-/issues/997
	GALLIUM_DRV="i915,nouveau,r300,r600,radeonsi,svga,swrast,virgl"
	DRI_DRIVERS="i965,nouveau"

	mkdir build && cd build

	meson --prefix=/usr                \
      	    -Dbuildtype=release            \
            -Ddri-drivers=$DRI_DRIVERS     \
            -Dgallium-drivers=$GALLIUM_DRV \
            -Dgallium-nine=false           \
            -Dglx=dri                      \
            -Dosmesa=gallium               \
            -Dvulkan-drivers="amd,swrast"  \
	    -Dplatforms="x11"              \
            -Dvalgrind=disabled            \
            -Dlibunwind=disabled           \
      .. && ninja && ninja install || return 1

}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	mkdir -p $fs/usr/lib
	cp -a $_pkg/usr/lib/*.so* $fs/usr/lib

	# DRI drivers are include in the package mesa-dri-*
	#cp -a $_pkg/usr/lib/dri $fs/usr/lib

	# libGLU && libGLw removed from Mesa 20.3.4

	# libOSMesa is included in the package libos-mesa
        rm -r -f $fs/usr/lib/libOS*
	
	# libxatracker is included in the package libxatracker-mesa
	rm -r -f $fs/usr/lib/libxatracker*

	# libgbm is included in the package libgbm-mesa
	rm -r -f $fs/usr/lib/libgbm*

	# VDPAU drivers are include in the package mesa-vdpau-*
	# cp -a $_pkg/usr/lib/vdpau $fs/usr/lib

	#libEGL is included in the package libegl-mesa
	rm -r -f $fs/usr/lib/libEGL*
}