Subject: [alpine-aports] [PATCH] new port: testing/mesa (updated to 13.0.1)

From: Jens Staal <[email-masked]>
Date: Wed, 16 Nov 2016 22:07:08 +0100

This testing variant with the latest mesa sources also have gallium nine and
virgl activated.

>From 56b6a081fc9202295bcbc5c538617963ddef033f Mon Sep 17 00:00:00 2001
From: Jens Staal <[email-masked]>
Date: Wed, 16 Nov 2016 22:01:07 +0100
Subject: [PATCH] testing/mesa: new port

www.mesa3d.org
Mesa DRI OpenGL library
---
 testing/mesa/APKBUILD               | 233 ++++++++++++++++++++++++++++++++++++
 testing/mesa/glx_ro_text_segm.patch |  28 +++++
 testing/mesa/musl-fixes.patch       |  11 ++
 3 files changed, 272 insertions(+)
 create mode 100644 testing/mesa/APKBUILD
 create mode 100644 testing/mesa/glx_ro_text_segm.patch
 create mode 100644 testing/mesa/musl-fixes.patch

diff --git a/testing/mesa/APKBUILD b/testing/mesa/APKBUILD
new file mode 100644
index 0000000..04a56c8
--- /dev/null
+++ b/testing/mesa/APKBUILD
@@ -0,0 +1,233 @@
+# Maintainer: Jens Staal <[email-masked]>
+# Adopted from: Natanael Copa <[email-masked]>
+pkgname=mesa
+pkgver=13.0.1
+pkgrel=0
+pkgdesc="Mesa DRI OpenGL library"
+url="http://www.mesa3d.org"
+arch="all"
+license="LGPL"
+depends=
+
+subpackages="$pkgname-dev
+	$pkgname-dri-ati:ati
+	$pkgname-dri-nouveau:nouveau
+	$pkgname-dri-swrast:swrast
+	$pkgname-dri-vmwgfx:vmwgfx
+	$pkgname-dricore $pkgname-glapi $pkgname-egl $pkgname-gl $pkgname-gles
+	$pkgname-xatracker $pkgname-osmesa $pkgname-gbm
+	$pkgname-libwayland-egl:_wayland
+	"
+
+depends_dev="libdrm-dev dri2proto libx11-dev libxext-dev libxxf86vm-dev
+	libxdamage-dev libxfixes-dev libxcb-dev glproto dri3proto presentproto
+	libxshmfence-dev"
+makedepends="$depends_dev expat-dev xextproto python2 libxt-dev makedepend
+	talloc-dev py-libxml2 flex bison llvm-dev eudev-dev libvdpau-dev
+	libxvmc-dev gettext zlib-dev wayland-dev libelf-dev py-mako
+	autoconf automake libtool"
+source="https://mesa.freedesktop.org/archive/${pkgver}/mesa-$pkgver.tar.xz
+	glx_ro_text_segm.patch
+	musl-fixes.patch
+	"
+
+_dri_driverdir=/usr/lib/xorg/modules/dri
+_dri_drivers="r200,radeon,nouveau,swrast"
+_gallium_drivers="r300,r600,radeonsi,nouveau,svga,swrast,virgl"
+
+_builddir="$srcdir/mesa-$pkgver"
+
+_intel_dri=
+case "$CARCH" in
+x86*)
+	_dri_drivers="${_dri_drivers},i915,i965"
+	subpackages="$subpackages $pkgname-dri-intel:intel"
+	export _endian="LITTLEENDIAN_CPU"
+	;;
+arm*)
+	_gallium_drivers="${_gallium_drivers},vc4"
+	export _endian="BIGENDIAN_CPU"
+	;;
+esac
+
+prepare() {
+	cd "$_builddir"
+	for i in $source; do
+		case $i in
+		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+		esac
+	done
+	
+	#hack to fix ENDIAN_CPU issue
+	_annoying_header="${_builddir}/src/amd/addrlib/inc/chip/r800/si_gb_reg.h"
+	echo -e "#define $_endian 1\n$(cat $_annoying_header)" > $_annoying_header
+
+	libtoolize --force \
+		&& aclocal \
+		&& automake --add-missing \
+		&& autoreconf || return 1
+}
+
+build() {
+	cd "$_builddir"
+
+	[ "$CLIBC" = "musl" ] && export CFLAGS="$CFLAGS -D_XOPEN_SOURCE=700 -D$_endian"
+	./configure \
+		--build=$CBUILD \
+		--host=$CHOST \
+		--prefix=/usr \
+		--sysconfdir=/etc \
+		--with-dri-driverdir=$_dri_driverdir \
+		--disable-asm \
+		--disable-xvmc \
+		--enable-glx-rts \
+		--with-gallium-drivers=${_gallium_drivers} \
+		--with-dri-drivers=${_dri_drivers} \
+		--enable-llvm-shared-libs \
+		--enable-gallium-llvm \
+		--with-egl-platforms=x11,drm,wayland \
+		--enable-shared-glapi \
+		--enable-gbm \
+		--disable-glx-tls \
+		--enable-dri \
+		--enable-dri3 \
+		--enable-glx \
+		--enable-vdpau \
+		--enable-osmesa \
+		--enable-gles1 \
+		--enable-gles2 \
+		--enable-egl \
+		--enable-texture-float \
+		--enable-xa \
+		--enable-vdpau \
+		--enable-nine \
+		|| return 1
+
+	make || return 1
+}
+
+package() {
+	cd "$_builddir"
+	make -j1 DESTDIR="$pkgdir" install || return 1
+}
+
+dricore() {
+	pkgdesc="Mesa dricore runtime libraries"
+	install -d "$subpkgdir"/usr/lib "$subpkgdir"/etc
+	mv "$pkgdir"/usr/lib/libdricore*.so.* \
+		"$subpkgdir"/usr/lib/
+	mv "$pkgdir"/etc/drirc "$subpkgdir"/etc/drirc
+}
+
+egl() {
+	replaces="mesa"
+	pkgdesc="Mesa libEGL runtime libraries"
+	install -d "$subpkgdir"/usr/lib
+	mv "$pkgdir"/usr/lib/libEGL.so* \
+		"$subpkgdir"/usr/lib/
+}
+
+gl() {
+	replaces="mesa"
+	pkgdesc="Mesa libGL runtime libraries"
+	install -d "$subpkgdir"/usr/lib
+	mv "$pkgdir"/usr/lib/libGL.so* \
+		"$subpkgdir"/usr/lib/
+}
+
+glapi() {
+	replaces="$pkgname-gles"
+	pkgdesc="Mesa shared glapi"
+	install -d "$subpkgdir"/usr/lib
+	mv "$pkgdir"/usr/lib/libglapi.so.* \
+		"$subpkgdir"/usr/lib/
+}
+
+gles() {
+	replaces="mesa"
+	pkgdesc="Mesa libGLESv2 runtime libraries"
+	install -d "$subpkgdir"/usr/lib
+	mv "$pkgdir"/usr/lib/libGLES*.so* \
+		"$subpkgdir"/usr/lib/
+}
+
+xatracker() {
+	pkgdesc="Mesa XA state tracker for vmware"
+	install -d "$subpkgdir"/usr/lib
+	mv "$pkgdir"/usr/lib/libxatracker*.so.* \
+		"$subpkgdir"/usr/lib/
+}
+
+osmesa() {
+	pkgdesc="Mesa offscreen rendering libraries"
+	install -d "$subpkgdir"/usr/lib
+	mv "$pkgdir"/usr/lib/libOSMesa.so.* \
+		"$subpkgdir"/usr/lib/
+}
+
+gbm() {
+	pkgdesc="Mesa gbm library"
+	replaces="mesa"
+	install -d "$subpkgdir"/usr/lib
+	mv "$pkgdir"/usr/lib/libgbm.so.* \
+		"$subpkgdir"/usr/lib/
+}
+
+_mv_dri() {
+	pkgdesc="Mesa DRI driver for $@"
+	install -d "$subpkgdir"/$_dri_driverdir
+
+	while [ $# -gt 0 ]; do
+		mv "$pkgdir"/$_dri_driverdir/${1}.so \
+			"$subpkgdir"/$_dri_driverdir/ || return 1
+		shift
+	done
+}
+
+_mv_vdpau() {
+	local i
+	install -d "$subpkgdir"/usr/lib/vdpau
+	for i in "$@"; do
+		mv "$pkgdir"/usr/lib/vdpau/libvdpau_$i.* \
+			"$subpkgdir"/usr/lib/vdpau/ || return 1
+	done
+}
+
+_mv_gpipe() {
+	return 0
+	# http://cgit.freedesktop.org/mesa/mesa/commit/?id=44ec468e8033553c26a112cebba41c343db00eb1
+	# https://code.google.com/p/chromium/issues/detail?id=412089
+#	local i
+#	install -d "$subpkgdir"/usr/lib/gallium-pipe
+#	for i in "$@"; do
+#		mv "$pkgdir"/usr/lib/gallium-pipe/pipe_$i.* \
+#			"$subpkgdir"/usr/lib/gallium-pipe/ || return 1
+#	done
+}
+
+ati() {		_mv_dri radeon_dri r200_dri r300_dri r600_dri radeonsi_dri \
+		&& _mv_vdpau r300 r600 radeonsi \
+		&& _mv_gpipe r300 r600; }
+intel() {	_mv_dri i915_dri i965_dri; }
+nouveau() {	_mv_dri nouveau_dri nouveau_vieux_dri \
+		&& _mv_vdpau nouveau \
+		&& _mv_gpipe nouveau; }
+swrast() {	_mv_dri swrast_dri kms_swrast_dri && _mv_gpipe swrast; }
+vmwgfx() {	_mv_dri vmwgfx_dri && _mv_gpipe vmwgfx; }
+
+_wayland() {
+	pkgdesc="Mesa libwayland-egl library"
+	mkdir -p "$subpkgdir"/usr/lib
+	mv "$pkgdir"/usr/lib/libwayland-egl.so.* "$subpkgdir"/usr/lib/ \
+		|| return 1
+}
+
+md5sums="72b7f4d0c2407f367484abd201cb8276  mesa-13.0.1.tar.xz
+a1a766b4c6a96d67cad9bd7ad5c578e8  glx_ro_text_segm.patch
+924983cef0c3ede76e5011a179bac155  musl-fixes.patch"
+sha256sums="71962fb2bf77d33b0ad4a565b490dbbeaf4619099c6d9722f04a73187957a731  mesa-13.0.1.tar.xz
+004f52adefaeccfd4553e0b1d09ad769891d69d05880094c7a45d19623e674a6  glx_ro_text_segm.patch
+aecc3d03d00d34bfb26f54679000fdb8719571b14161e4be4db962fba0f96d24  musl-fixes.patch"
+sha512sums="00ae0eaef742a3954c1461b50cdcc8b9f933e829c89784d66bfcc0890e7e2793350efcad1a06f28bd3c115f04702a43a6f1ac6ce86270ca7799a90f1a5cf5127  mesa-13.0.1.tar.xz
+c3d4804ebc24c7216e4c9d4995fb92e116be7f478024b44808ee134a4c93bb51d1f66fe5fb6eca254f124c4abf6f81272b027824b3e2650a9607818bf793035a  glx_ro_text_segm.patch
+9f7a050f09571a2b17098d495b82e2e85b293fb7285e7d6d7c3c48cd4220a1bdcc61a7321ba78dd14860939ecabe7e89b32d6110f3728f793273e1e26b78a553  musl-fixes.patch"
diff --git a/testing/mesa/glx_ro_text_segm.patch b/testing/mesa/glx_ro_text_segm.patch
new file mode 100644
index 0000000..8cad487
--- /dev/null
+++ b/testing/mesa/glx_ro_text_segm.patch
@@ -0,0 +1,28 @@
+2011-02-09	Jeremy Huddleston <[email-masked]
+
+	#240956
+	* configure.ac	add support to enable readonly test segment on x86
+
+--- ./configure.ac.orig	2008-11-17 23:19:38.000000000 +0100
++++ ./configure.ac	2008-11-17 23:20:17.000000000 +0100
+@@ -499,6 +499,20 @@
+     enable_xcb=no
+ fi
+ 
++
++dnl readonly text segment on x86 hardened platforms
++AC_ARG_ENABLE([glx_rts],
++    [AS_HELP_STRING([--enable-glx-rts],
++        [on x86, use a readonly text segment for libGL @<:@default=disabled@:>@])],
++    [enable_glx_rts="$enableval"],
++    [enable_glx_rts=no])
++if test "x$enable_glx_rts" = xyes; then
++    DEFINES="$DEFINES -DGLX_X86_READONLY_TEXT"
++else
++    enable_glx_rts=no
++fi
++
++
+ dnl
+ dnl libGL configuration per driver
+ dnl
diff --git a/testing/mesa/musl-fixes.patch b/testing/mesa/musl-fixes.patch
new file mode 100644
index 0000000..dd3e6bb
--- /dev/null
+++ b/testing/mesa/musl-fixes.patch
@@ -0,0 +1,11 @@
+--- ./src/gallium/winsys/svga/drm/vmw_screen.h.orig
++++ ./src/gallium/winsys/svga/drm/vmw_screen.h
+@@ -34,7 +34,7 @@
+ #ifndef VMW_SCREEN_H_
+ #define VMW_SCREEN_H_
+ 
+-
++#include <sys/stat.h>
+ #include "pipe/p_compiler.h"
+ #include "pipe/p_state.h"
+ 
-- 
2.10.2