public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Anthony G. Basile" <blueness@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/musl:master commit in: media-libs/mesa/files/, media-libs/mesa/
Date: Sun, 27 Jan 2019 17:52:22 +0000 (UTC)	[thread overview]
Message-ID: <1548611525.7a73006b48b30e36d961bd1417b1e7d5cc3e554f.blueness@gentoo> (raw)

commit:     7a73006b48b30e36d961bd1417b1e7d5cc3e554f
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 27 17:48:19 2019 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sun Jan 27 17:52:05 2019 +0000
URL:        https://gitweb.gentoo.org/proj/musl.git/commit/?id=7a73006b

Revert "media-libs/mesa: revbump and sync with tree"

This reverts commit 89c1adfdef658652e452c76a8b98931e4a2cf131.

Signed-off-by: Anthony G. Basile <blueness <AT> gentoo.org>

 media-libs/mesa/Manifest                           |   5 +-
 media-libs/mesa/files/mesa-11-execinfo.patch       |  68 +++
 media-libs/mesa/files/mesa-13-musl_endian.patch    |  12 +
 .../mesa/files/mesa-17-musl-invocation_name.patch  |  47 ++
 media-libs/mesa/files/mesa-17-musl-pthread.patch   |  39 ++
 media-libs/mesa/files/mesa-17-musl_endian.patch    |  12 +
 .../mesa/files/mesa-18-intel-missing-time_t.patch  |  11 +
 .../mesa/files/mesa-18-missing-includes.patch      |  53 +++
 ...2.4-meson-link-gallium-nine-with-pthreads.patch |  34 ++
 media-libs/mesa/mesa-18.1.6-r1.ebuild              | 520 +++++++++++++++++++++
 media-libs/mesa/mesa-18.1.6.ebuild                 | 519 ++++++++++++++++++++
 media-libs/mesa/mesa-18.1.9-r1.ebuild              | 520 +++++++++++++++++++++
 media-libs/mesa/mesa-18.1.9.ebuild                 | 519 ++++++++++++++++++++
 .../{mesa-18.2.8.ebuild => mesa-18.2.1.ebuild}     |  70 ++-
 .../{mesa-18.2.8.ebuild => mesa-18.2.4.ebuild}     |  17 +-
 media-libs/mesa/metadata.xml                       |   1 +
 16 files changed, 2425 insertions(+), 22 deletions(-)

diff --git a/media-libs/mesa/Manifest b/media-libs/mesa/Manifest
index aebf196..2e5ff61 100644
--- a/media-libs/mesa/Manifest
+++ b/media-libs/mesa/Manifest
@@ -1 +1,4 @@
-DIST mesa-18.2.8.tar.xz 11385224 BLAKE2B c6fbf71e2ab6837f91dfa996cf7e89e9cae22e219cac56bd4201f7a62c787ddd2f65e7d162a329971018f0b1a796ee1a5b252ee6b43bb3b27a233d67b6cdf615 SHA512 04d5ada9ba3acea853def3ebcbb53ee76936a4cd4229ae753d2ce1b5cf543bea1e5764f2ef2b19735d47d041ba6b0582841bc89e2c9331fdfbd89386f599a1f7
+DIST mesa-18.1.6.tar.xz 11142884 BLAKE2B fdd156fe7debf5223285dfa238070a2bd7d8ec684dec168afab78b9d2d38d53c10d939aaa64f34c2910e542dce3869adfca6383fca6a854c6dd03287a044b0e3 SHA512 2966210800215f5ced2720691063a8519b51ebeab9fb1e99bde4b1bd7ccc719d6395a1c29f25c88efe62d1592cf14ceafc163aca349490b1f8cee81070d46fcc
+DIST mesa-18.1.9.tar.xz 11146188 BLAKE2B 753f0fa3780502d56927f9b0e6124b4728cb5aa3600de78585487fb8e178c6987a72b79fb56e6c310757d157f9f85f12b73a6889bd361b51b62fb1dc1c20eecd SHA512 22db2950d25a3d9393e7c622c783bd177c21695569c8a95683bf77e92318e1db85672a134d4bea30c1f49a24e52bc3a2c1a0ac15deafb3a8fcbfb6de6a18adc2
+DIST mesa-18.2.1.tar.xz 11374476 BLAKE2B f0f3b766d68550f8c395a1b1d1ffc7a9e532c22ee6b91d698db33a270c152e03ab656d4219301bc2e0e95ba6f0583017c4361add928ad8ab26378a1ec6958f36 SHA512 d249bdf79aad36db9a8d291b3a1a100d283893ac741f58f85ae7e5c90ca25c37f80a5fa6fc57945ffeb0b67b788e7ea146543ec790b22f144578fc4c1525b84d
+DIST mesa-18.2.4.tar.xz 11377556 BLAKE2B b11c33ade744fb976862fecccbcc4c97196a005e40a00ef02bd8d409b66b3aa11f97baee13f2aa92f2d7c5461b2ef44beae3103687dea9ee29e92439a068f08a SHA512 088d43b087f4005752e4db75eaa6897e0fcb6de7b9a1f2d2b2ce3b5557d1dff829022e0092e8b1038ff01182c863ca0f26c97b9adde34bca462d3fa24502bfde

diff --git a/media-libs/mesa/files/mesa-11-execinfo.patch b/media-libs/mesa/files/mesa-11-execinfo.patch
new file mode 100644
index 0000000..0eefba8
--- /dev/null
+++ b/media-libs/mesa/files/mesa-11-execinfo.patch
@@ -0,0 +1,68 @@
+diff -Naur mesa-11.1.2.orig/configure.ac mesa-11.1.2/configure.ac
+--- mesa-11.1.2.orig/configure.ac	2016-02-10 15:57:54.000000000 -0800
++++ mesa-11.1.2/configure.ac	2016-03-09 13:27:47.979302937 -0800
+@@ -681,6 +681,7 @@
+ AC_CHECK_HEADER([sys/sysctl.h], [DEFINES="$DEFINES -DHAVE_SYS_SYSCTL_H"])
+ AC_CHECK_FUNC([strtof], [DEFINES="$DEFINES -DHAVE_STRTOF"])
+ AC_CHECK_FUNC([mkostemp], [DEFINES="$DEFINES -DHAVE_MKOSTEMP"])
++AC_CHECK_HEADER([execinfo.h], [DEFINES="$DEFINES -DHAVE_EXECINFO_H"])
+ 
+ dnl Check to see if dlopen is in default libraries (like Solaris, which
+ dnl has it in libc), or if libdl is needed to get it.
+diff -Naur mesa-11.1.2.orig/src/gallium/auxiliary/util/u_debug_symbol.c mesa-11.1.2/src/gallium/auxiliary/util/u_debug_symbol.c
+--- mesa-11.1.2.orig/src/gallium/auxiliary/util/u_debug_symbol.c	2016-01-17 23:39:26.000000000 -0800
++++ mesa-11.1.2/src/gallium/auxiliary/util/u_debug_symbol.c	2016-03-09 13:29:27.255060988 -0800
+@@ -219,7 +219,7 @@
+ #endif /* PIPE_OS_WINDOWS */
+ 
+ 
+-#if defined(__GLIBC__) && !defined(__UCLIBC__)
++#if defined(HAVE_EXECINFO_H)
+ 
+ #include <execinfo.h>
+ 
+@@ -240,7 +240,7 @@
+    return TRUE;
+ }
+ 
+-#endif /* defined(__GLIBC__) && !defined(__UCLIBC__) */
++#endif /* defined(HAVE_EXECINFO_H) */
+ 
+ 
+ void
+diff -Naur mesa-11.1.2.orig/src/mapi/glapi/gen/gl_gentable.py mesa-11.1.2/src/mapi/glapi/gen/gl_gentable.py
+--- mesa-11.1.2.orig/src/mapi/glapi/gen/gl_gentable.py	2016-02-10 15:57:54.000000000 -0800
++++ mesa-11.1.2/src/mapi/glapi/gen/gl_gentable.py	2016-03-09 13:28:14.624506395 -0800
+@@ -44,7 +44,7 @@
+ #endif
+ 
+ #if (defined(GLXEXT) && defined(HAVE_BACKTRACE)) \\
+-	|| (!defined(GLXEXT) && defined(DEBUG) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__))
++	|| (!defined(GLXEXT) && defined(DEBUG) && defined(HAVE_EXECINFO_H))
+ #define USE_BACKTRACE
+ #endif
+ 
+diff -Naur mesa-11.1.2.orig/src/mapi/glapi/glapi_gentable.c mesa-11.1.2/src/mapi/glapi/glapi_gentable.c
+--- mesa-11.1.2.orig/src/mapi/glapi/glapi_gentable.c	2016-02-10 16:24:49.000000000 -0800
++++ mesa-11.1.2/src/mapi/glapi/glapi_gentable.c	2016-03-09 13:28:38.411688029 -0800
+@@ -36,7 +36,7 @@
+ #endif
+ 
+ #if (defined(GLXEXT) && defined(HAVE_BACKTRACE)) \
+-	|| (!defined(GLXEXT) && defined(DEBUG) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__))
++	|| (!defined(GLXEXT) && defined(DEBUG) && defined(HAVE_EXECINFO_H))
+ #define USE_BACKTRACE
+ #endif
+ 
+diff -Naur mesa-11.1.2.orig/src/mesa/drivers/dri/i915/intel_regions.c mesa-11.1.2/src/mesa/drivers/dri/i915/intel_regions.c
+--- mesa-11.1.2.orig/src/mesa/drivers/dri/i915/intel_regions.c	2016-01-17 23:39:26.000000000 -0800
++++ mesa-11.1.2/src/mesa/drivers/dri/i915/intel_regions.c	2016-03-09 13:30:18.483460168 -0800
+@@ -57,7 +57,7 @@
+  */
+ #define DEBUG_BACKTRACE_SIZE 0
+ 
+-#if DEBUG_BACKTRACE_SIZE == 0
++#if DEBUG_BACKTRACE_SIZE == 0 || !defined(HAVE_EXECINFO_H)
+ /* Use the standard debug output */
+ #define _DBG(...) DBG(__VA_ARGS__)
+ #else

diff --git a/media-libs/mesa/files/mesa-13-musl_endian.patch b/media-libs/mesa/files/mesa-13-musl_endian.patch
new file mode 100644
index 0000000..1276605
--- /dev/null
+++ b/media-libs/mesa/files/mesa-13-musl_endian.patch
@@ -0,0 +1,12 @@
+diff -Naur mesa-13.0.5.orig/src/util/u_endian.h mesa-13.0.5/src/util/u_endian.h
+--- mesa-13.0.5.orig/src/util/u_endian.h	2017-03-19 12:40:43.808781967 -0700
++++ mesa-13.0.5/src/util/u_endian.h	2017-03-19 12:49:01.731158551 -0700
+@@ -27,7 +27,7 @@
+ #ifndef U_ENDIAN_H
+ #define U_ENDIAN_H
+ 
+-#if defined(__GLIBC__) || defined(ANDROID)
++#if defined(__linux__)
+ #include <endian.h>
+ 
+ #if __BYTE_ORDER == __LITTLE_ENDIAN

diff --git a/media-libs/mesa/files/mesa-17-musl-invocation_name.patch b/media-libs/mesa/files/mesa-17-musl-invocation_name.patch
new file mode 100644
index 0000000..80b02f5
--- /dev/null
+++ b/media-libs/mesa/files/mesa-17-musl-invocation_name.patch
@@ -0,0 +1,47 @@
+diff -Naur mesa-17.3.0.orig/src/gallium/auxiliary/os/os_process.c mesa-17.3.0/src/gallium/auxiliary/os/os_process.c
+--- mesa-17.3.0.orig/src/gallium/auxiliary/os/os_process.c	2017-12-08 05:49:11.000000000 -0800
++++ mesa-17.3.0/src/gallium/auxiliary/os/os_process.c	2017-12-11 14:24:35.200797607 -0800
+@@ -32,7 +32,7 @@
+ 
+ #if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+ #  include <windows.h>
+-#elif defined(__GLIBC__) || defined(__CYGWIN__)
++#elif defined(__linux__) || defined(__CYGWIN__)
+ #  include <errno.h>
+ #elif defined(PIPE_OS_BSD) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_ANDROID)
+ #  include <stdlib.h>
+@@ -84,7 +84,7 @@
+ 
+       name = lpProcessName;
+ 
+-#elif defined(__GLIBC__) || defined(__CYGWIN__)
++#elif defined(__linux__) || defined(__CYGWIN__)
+       name = program_invocation_short_name;
+ #elif defined(PIPE_OS_BSD) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_ANDROID)
+       /* *BSD and OS X */
+diff -Naur mesa-17.3.0.orig/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c mesa-17.3.0/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c
+--- mesa-17.3.0.orig/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c	2017-12-08 05:49:11.000000000 -0800
++++ mesa-17.3.0/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c	2017-12-11 14:23:35.312798680 -0800
+@@ -84,7 +84,7 @@
+    ret = os_get_process_name(cmdline, 63);
+    if (ret == FALSE)
+       strcpy(cmdline, nstr);
+-#if defined(__GLIBC__) || defined(__CYGWIN__)
++#if defined(__linux__) || defined(__CYGWIN__)
+    if (!strcmp(cmdline, "shader_runner")) {
+       const char *name;
+       /* hack to get better testname */
+diff -Naur mesa-17.3.0.orig/src/util/xmlconfig.c mesa-17.3.0/src/util/xmlconfig.c
+--- mesa-17.3.0.orig/src/util/xmlconfig.c	2017-12-08 05:49:11.000000000 -0800
++++ mesa-17.3.0/src/util/xmlconfig.c	2017-12-11 14:22:54.052799419 -0800
+@@ -40,8 +40,8 @@
+ 
+ #undef GET_PROGRAM_NAME
+ 
+-#if (defined(__GNU_LIBRARY__) || defined(__GLIBC__)) && !defined(__UCLIBC__)
+-#    if !defined(__GLIBC__) || (__GLIBC__ < 2)
++#if defined(__linux__)
++#    if defined(__GLIBC__) && (__GLIBC__ < 2)
+ /* These aren't declared in any libc5 header */
+ extern char *program_invocation_name, *program_invocation_short_name;
+ #    endif

diff --git a/media-libs/mesa/files/mesa-17-musl-pthread.patch b/media-libs/mesa/files/mesa-17-musl-pthread.patch
new file mode 100644
index 0000000..aac95af
--- /dev/null
+++ b/media-libs/mesa/files/mesa-17-musl-pthread.patch
@@ -0,0 +1,39 @@
+diff -Naur mesa-17.3.0.orig/src/gallium/state_trackers/nine/nine_debug.c mesa-17.3.0/src/gallium/state_trackers/nine/nine_debug.c
+--- mesa-17.3.0.orig/src/gallium/state_trackers/nine/nine_debug.c	2017-12-12 16:55:53.885552821 -0800
++++ mesa-17.3.0/src/gallium/state_trackers/nine/nine_debug.c	2017-12-12 17:09:36.048538098 -0800
+@@ -73,8 +73,8 @@
+     }
+ 
+ #if defined(HAVE_PTHREAD)
+-#  if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \
+-      (__GLIBC__ >= 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 12))
++#  if defined(__linux__) && !(defined(__GLIBC__) || \
++      (__GLIBC__ < 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 12)))
+     if (dbg_flags & DBG_TID)
+         tid = pthread_self();
+ #  endif
+diff -Naur mesa-17.3.0.orig/src/util/u_thread.h mesa-17.3.0/src/util/u_thread.h
+--- mesa-17.3.0.orig/src/util/u_thread.h	2017-12-12 16:55:53.915552820 -0800
++++ mesa-17.3.0/src/util/u_thread.h	2017-12-12 17:09:34.079538133 -0800
+@@ -61,8 +61,8 @@
+ static inline void u_thread_setname( const char *name )
+ {
+ #if defined(HAVE_PTHREAD)
+-#  if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \
+-      (__GLIBC__ >= 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 12))
++#  if defined(__linux__) && !(defined(__GLIBC__) || \
++      (__GLIBC__ < 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 12)))
+    pthread_setname_np(pthread_self(), name);
+ #  endif
+ #endif
+@@ -92,8 +92,8 @@
+ static inline bool u_thread_is_self(thrd_t thread)
+ {
+ #if defined(HAVE_PTHREAD)
+-#  if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \
+-      (__GLIBC__ >= 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 12))
++#  if defined(__linux__) && !(defined(__GLIBC__) || \
++      (__GLIBC__ < 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 12)))
+    return pthread_equal(pthread_self(), thread);
+ #  endif
+ #endif

diff --git a/media-libs/mesa/files/mesa-17-musl_endian.patch b/media-libs/mesa/files/mesa-17-musl_endian.patch
new file mode 100644
index 0000000..74e3d1d
--- /dev/null
+++ b/media-libs/mesa/files/mesa-17-musl_endian.patch
@@ -0,0 +1,12 @@
+diff -Naur mesa-17.3.1.orig/src/util/u_endian.h mesa-17.3.1/src/util/u_endian.h
+--- mesa-17.3.1.orig/src/util/u_endian.h	2017-12-29 14:19:33.532915798 -0800
++++ mesa-17.3.1/src/util/u_endian.h	2017-12-29 14:21:55.547913255 -0800
+@@ -27,7 +27,7 @@
+ #ifndef U_ENDIAN_H
+ #define U_ENDIAN_H
+ 
+-#if defined(__GLIBC__) || defined(ANDROID) || defined(__CYGWIN__)
++#if defined(__linux__) || defined(__CYGWIN__)
+ #include <endian.h>
+ 
+ #if __BYTE_ORDER == __LITTLE_ENDIAN

diff --git a/media-libs/mesa/files/mesa-18-intel-missing-time_t.patch b/media-libs/mesa/files/mesa-18-intel-missing-time_t.patch
new file mode 100644
index 0000000..353f8f2
--- /dev/null
+++ b/media-libs/mesa/files/mesa-18-intel-missing-time_t.patch
@@ -0,0 +1,11 @@
+diff -Naur mesa-18.1.0-rc1.orig/src/mesa/drivers/dri/i965/brw_bufmgr.h mesa-18.1.0-rc1/src/mesa/drivers/dri/i965/brw_bufmgr.h
+--- mesa-18.1.0-rc1.orig/src/mesa/drivers/dri/i965/brw_bufmgr.h	2018-04-22 12:42:46.505947484 -0700
++++ mesa-18.1.0-rc1/src/mesa/drivers/dri/i965/brw_bufmgr.h	2018-04-22 12:44:09.720945994 -0700
+@@ -37,6 +37,7 @@
+ #include <stdbool.h>
+ #include <stdint.h>
+ #include <stdio.h>
++#include <time.h>
+ #include "util/u_atomic.h"
+ #include "util/list.h"
+ 

diff --git a/media-libs/mesa/files/mesa-18-missing-includes.patch b/media-libs/mesa/files/mesa-18-missing-includes.patch
new file mode 100644
index 0000000..3f7bd62
--- /dev/null
+++ b/media-libs/mesa/files/mesa-18-missing-includes.patch
@@ -0,0 +1,53 @@
+From 456b660306e475a30f170a3bcecc0445124d7e2b Mon Sep 17 00:00:00 2001
+From: 
+Date: Sun, 8 Jul 2018 03:57:11 -0500
+Subject: [PATCH] Fix all missing includes for mesa
+
+Signed-off-by: 
+---
+ src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h | 1 +
+ src/gallium/winsys/svga/drm/vmw_screen.h          | 2 +-
+ src/util/rand_xor.c                               | 2 ++
+ 3 files changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h
+index d6af605..6eee83f 100644
+--- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h
++++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h
+@@ -32,6 +32,7 @@
+ #include "ac_gpu_info.h"
+ #include "addrlib/addrinterface.h"
+ #include <amdgpu.h>
++#include <pthread.h>
+ #include "util/list.h"
+ 
+ struct radv_amdgpu_winsys {
+diff --git a/src/gallium/winsys/svga/drm/vmw_screen.h b/src/gallium/winsys/svga/drm/vmw_screen.h
+index f21cabb..20d03f8 100644
+--- a/src/gallium/winsys/svga/drm/vmw_screen.h
++++ b/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"
+ 
+diff --git a/src/util/rand_xor.c b/src/util/rand_xor.c
+index de04bbc..08d507f 100644
+--- a/src/util/rand_xor.c
++++ b/src/util/rand_xor.c
+@@ -24,6 +24,8 @@
+ 
+ #if defined(__linux__)
+ #include <sys/file.h>
++#include <sys/types.h>
++#include <sys/stat.h>
+ #include <unistd.h>
+ #include <fcntl.h>
+ #else
+-- 
+2.18.0
+

diff --git a/media-libs/mesa/files/mesa-18.2.4-meson-link-gallium-nine-with-pthreads.patch b/media-libs/mesa/files/mesa-18.2.4-meson-link-gallium-nine-with-pthreads.patch
new file mode 100644
index 0000000..11d4f9c
--- /dev/null
+++ b/media-libs/mesa/files/mesa-18.2.4-meson-link-gallium-nine-with-pthreads.patch
@@ -0,0 +1,34 @@
+From 7652931d33b36c93b2e84713baa8c283d568402e Mon Sep 17 00:00:00 2001
+From: Dylan Baker <dylan@pnwbakers.com>
+Date: Thu, 1 Nov 2018 14:12:57 -0700
+Subject: [PATCH] meson: link gallium nine with pthreads
+
+In some cases (not building with llvm, which automatically pulls in
+pthreads) nine needs to be directly linked with pthreads. Fixes building
+on x86 (32 bit) without llvm.
+
+Distro bug: https://bugs.gentoo.org/670094
+Fixes: 6b4c7047d57178d3362a710ad503057c6a582ca3
+       ("meson: build gallium nine state_tracker")
+Tested-by: Rafal Lalik <rafallalik@gmail.com>
+Reviewed-by: Matt Turner <mattst88@gmail.com>
+---
+ src/gallium/targets/d3dadapter9/meson.build | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/gallium/targets/d3dadapter9/meson.build b/src/gallium/targets/d3dadapter9/meson.build
+index bd05b4f9692..bc72b1110a0 100644
+--- a/src/gallium/targets/d3dadapter9/meson.build
++++ b/src/gallium/targets/d3dadapter9/meson.build
+@@ -53,7 +53,7 @@ libgallium_nine = shared_library(
+     libswkmsdri,
+   ],
+   dependencies : [
+-    dep_selinux, dep_expat, dep_libdrm, dep_llvm,
++    dep_selinux, dep_expat, dep_libdrm, dep_llvm, dep_thread,
+     driver_swrast, driver_r300, driver_r600, driver_radeonsi, driver_nouveau,
+     driver_i915, driver_svga,
+   ],
+-- 
+2.16.4
+

diff --git a/media-libs/mesa/mesa-18.1.6-r1.ebuild b/media-libs/mesa/mesa-18.1.6-r1.ebuild
new file mode 100644
index 0000000..8e43662
--- /dev/null
+++ b/media-libs/mesa/mesa-18.1.6-r1.ebuild
@@ -0,0 +1,520 @@
+# Copyright 1999-2018 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+EGIT_REPO_URI="https://gitlab.freedesktop.org/mesa/mesa.git"
+
+if [[ ${PV} = 9999 ]]; then
+	GIT_ECLASS="git-r3"
+	EXPERIMENTAL="true"
+fi
+
+PYTHON_COMPAT=( python2_7 )
+
+inherit autotools llvm multilib-minimal python-any-r1 pax-utils ${GIT_ECLASS}
+
+OPENGL_DIR="xorg-x11"
+
+MY_P="${P/_/-}"
+
+DESCRIPTION="OpenGL-like graphic library for Linux"
+HOMEPAGE="https://www.mesa3d.org/ https://mesa.freedesktop.org/"
+
+if [[ $PV == 9999 ]]; then
+	SRC_URI=""
+else
+	SRC_URI="https://mesa.freedesktop.org/archive/${MY_P}.tar.xz"
+	KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~x86"
+fi
+
+LICENSE="MIT"
+SLOT="0"
+RESTRICT="!bindist? ( bindist )"
+
+RADEON_CARDS="r100 r200 r300 r600 radeon radeonsi"
+VIDEO_CARDS="${RADEON_CARDS} freedreno i915 i965 imx intel nouveau vc4 virgl vivante vmware"
+for card in ${VIDEO_CARDS}; do
+	IUSE_VIDEO_CARDS+=" video_cards_${card}"
+done
+
+IUSE="${IUSE_VIDEO_CARDS}
+	bindist +classic d3d9 debug +dri3 +egl +gallium +gbm gles1 gles2 unwind
+	+llvm +nptl opencl osmesa pax_kernel pic selinux vaapi valgrind
+	vdpau vulkan wayland xvmc xa"
+
+REQUIRED_USE="
+	d3d9?   ( dri3 gallium )
+	llvm?   ( gallium )
+	opencl? ( gallium llvm || ( video_cards_r600 video_cards_radeonsi ) )
+	gles1?  ( egl )
+	gles2?  ( egl )
+	vaapi? ( gallium )
+	vdpau? ( gallium )
+	vulkan? ( || ( video_cards_i965 video_cards_radeonsi )
+			  video_cards_radeonsi? ( llvm ) )
+	wayland? ( egl gbm )
+	xa?  ( gallium )
+	video_cards_freedreno?  ( gallium )
+	video_cards_intel?  ( classic )
+	video_cards_i915?   ( || ( classic gallium ) )
+	video_cards_i965?   ( classic )
+	video_cards_imx?    ( gallium video_cards_vivante )
+	video_cards_nouveau? ( || ( classic gallium ) )
+	video_cards_radeon? ( || ( classic gallium )
+						  gallium? ( x86? ( llvm ) amd64? ( llvm ) ) )
+	video_cards_r100?   ( classic )
+	video_cards_r200?   ( classic )
+	video_cards_r300?   ( gallium x86? ( llvm ) amd64? ( llvm ) )
+	video_cards_r600?   ( gallium )
+	video_cards_radeonsi?   ( gallium llvm )
+	video_cards_vc4? ( gallium )
+	video_cards_virgl? ( gallium )
+	video_cards_vivante? ( gallium gbm )
+	video_cards_vmware? ( gallium )
+"
+
+LIBDRM_DEPSTRING=">=x11-libs/libdrm-2.4.91"
+RDEPEND="
+	!app-eselect/eselect-mesa
+	>=app-eselect/eselect-opengl-1.3.0
+	>=dev-libs/expat-2.1.0-r3:=[${MULTILIB_USEDEP}]
+	>=sys-libs/zlib-1.2.8[${MULTILIB_USEDEP}]
+	>=x11-libs/libX11-1.6.2:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libxshmfence-1.1:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libXdamage-1.1.4-r1:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libXext-1.3.2:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libXxf86vm-1.1.3:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libxcb-1.13:=[${MULTILIB_USEDEP}]
+	x11-libs/libXfixes:=[${MULTILIB_USEDEP}]
+	unwind? ( sys-libs/libunwind[${MULTILIB_USEDEP}] )
+	llvm? (
+		video_cards_radeonsi? (
+			virtual/libelf:0=[${MULTILIB_USEDEP}]
+		)
+		video_cards_r600? (
+			virtual/libelf:0=[${MULTILIB_USEDEP}]
+		)
+		video_cards_radeon? (
+			virtual/libelf:0=[${MULTILIB_USEDEP}]
+		)
+	)
+	opencl? (
+				app-eselect/eselect-opencl
+				dev-libs/libclc
+				virtual/libelf:0=[${MULTILIB_USEDEP}]
+			)
+	vaapi? (
+		>=x11-libs/libva-1.7.3:=[${MULTILIB_USEDEP}]
+		video_cards_nouveau? ( !<=x11-libs/libva-vdpau-driver-0.7.4-r3 )
+	)
+	vdpau? ( >=x11-libs/libvdpau-1.1:=[${MULTILIB_USEDEP}] )
+	wayland? (
+		>=dev-libs/wayland-1.15.0:=[${MULTILIB_USEDEP}]
+		>=dev-libs/wayland-protocols-1.8
+	)
+	xvmc? ( >=x11-libs/libXvMC-1.0.8:=[${MULTILIB_USEDEP}] )
+	${LIBDRM_DEPSTRING}[video_cards_freedreno?,video_cards_nouveau?,video_cards_vc4?,video_cards_vivante?,video_cards_vmware?,${MULTILIB_USEDEP}]
+
+	video_cards_intel? (
+		!video_cards_i965? ( ${LIBDRM_DEPSTRING}[video_cards_intel] )
+	)
+	video_cards_i915? ( ${LIBDRM_DEPSTRING}[video_cards_intel] )
+"
+for card in ${RADEON_CARDS}; do
+	RDEPEND="${RDEPEND}
+		video_cards_${card}? ( ${LIBDRM_DEPSTRING}[video_cards_radeon] )
+	"
+done
+RDEPEND="${RDEPEND}
+	video_cards_radeonsi? ( ${LIBDRM_DEPSTRING}[video_cards_amdgpu] )
+"
+
+# Please keep the LLVM dependency block separate. Since LLVM is slotted,
+# we need to *really* make sure we're not pulling one than more slot
+# simultaneously.
+#
+# How to use it:
+# 1. List all the working slots (with min versions) in ||, newest first.
+# 2. Update the := to specify *max* version, e.g. < 7.
+# 3. Specify LLVM_MAX_SLOT, e.g. 6.
+LLVM_MAX_SLOT="6"
+LLVM_DEPSTR="
+	|| (
+		sys-devel/llvm:7[${MULTILIB_USEDEP}]
+		sys-devel/llvm:6[${MULTILIB_USEDEP}]
+		sys-devel/llvm:5[${MULTILIB_USEDEP}]
+		sys-devel/llvm:4[${MULTILIB_USEDEP}]
+		>=sys-devel/llvm-3.9.0:0[${MULTILIB_USEDEP}]
+	)
+	sys-devel/llvm:=[${MULTILIB_USEDEP}]
+"
+LLVM_DEPSTR_AMDGPU=${LLVM_DEPSTR//]/,llvm_targets_AMDGPU(-)]}
+CLANG_DEPSTR=${LLVM_DEPSTR//llvm/clang}
+CLANG_DEPSTR_AMDGPU=${CLANG_DEPSTR//]/,llvm_targets_AMDGPU(-)]}
+RDEPEND="${RDEPEND}
+	llvm? (
+		opencl? (
+			video_cards_r600? (
+				${CLANG_DEPSTR_AMDGPU}
+			)
+			!video_cards_r600? (
+				video_cards_radeonsi? (
+					${CLANG_DEPSTR_AMDGPU}
+				)
+			)
+			!video_cards_r600? (
+				!video_cards_radeonsi? (
+					video_cards_radeon? (
+						${CLANG_DEPSTR_AMDGPU}
+					)
+				)
+			)
+			!video_cards_r600? (
+				!video_cards_radeon? (
+					!video_cards_radeonsi? (
+						${CLANG_DEPSTR}
+					)
+				)
+			)
+		)
+		!opencl? (
+			video_cards_r600? (
+				${LLVM_DEPSTR_AMDGPU}
+			)
+			!video_cards_r600? (
+				video_cards_radeonsi? (
+					${LLVM_DEPSTR_AMDGPU}
+				)
+			)
+			!video_cards_r600? (
+				!video_cards_radeonsi? (
+					video_cards_radeon? (
+						${LLVM_DEPSTR_AMDGPU}
+					)
+				)
+			)
+			!video_cards_r600? (
+				!video_cards_radeon? (
+					!video_cards_radeonsi? (
+						${LLVM_DEPSTR}
+					)
+				)
+			)
+		)
+	)
+"
+unset {LLVM,CLANG}_DEPSTR{,_AMDGPU}
+
+DEPEND="${RDEPEND}
+	${PYTHON_DEPS}
+	opencl? (
+		>=sys-devel/gcc-4.6
+	)
+	sys-devel/gettext
+	virtual/pkgconfig
+	valgrind? ( dev-util/valgrind )
+	x11-base/xorg-proto
+	vulkan? (
+		$(python_gen_any_dep ">=dev-python/mako-0.7.3[\${PYTHON_USEDEP}]")
+	)
+"
+[[ ${PV} == 9999 ]] && DEPEND+="
+	sys-devel/bison
+	sys-devel/flex
+	$(python_gen_any_dep ">=dev-python/mako-0.7.3[\${PYTHON_USEDEP}]")
+"
+
+S="${WORKDIR}/${MY_P}"
+EGIT_CHECKOUT_DIR=${S}
+
+QA_WX_LOAD="
+x86? (
+	!pic? (
+		usr/lib*/libglapi.so.0.0.0
+		usr/lib*/libGLESv1_CM.so.1.1.0
+		usr/lib*/libGLESv2.so.2.0.0
+		usr/lib*/libGL.so.1.2.0
+		usr/lib*/libOSMesa.so.8.0.0
+	)
+)"
+
+llvm_check_deps() {
+	local flags=${MULTILIB_USEDEP}
+	if use video_cards_r600 || use video_cards_radeon || use video_cards_radeonsi
+	then
+		flags+=",llvm_targets_AMDGPU(-)"
+	fi
+
+	if use opencl; then
+		has_version "sys-devel/clang[${flags}]" || return 1
+	fi
+	has_version "sys-devel/llvm[${flags}]"
+}
+
+pkg_setup() {
+	# warning message for bug 459306
+	if use llvm && has_version sys-devel/llvm[!debug=]; then
+		ewarn "Mismatch between debug USE flags in media-libs/mesa and sys-devel/llvm"
+		ewarn "detected! This can cause problems. For details, see bug 459306."
+	fi
+
+	if use llvm; then
+		llvm_pkg_setup
+	fi
+	python-any-r1_pkg_setup
+}
+
+src_prepare() {
+	eapply "${FILESDIR}"/${PN}-17-execinfo.patch
+	eapply "${FILESDIR}"/${PN}-17-musl-string_h.patch
+	eapply "${FILESDIR}"/${PN}-17-musl-invocation_name.patch
+	eapply "${FILESDIR}"/${PN}-18-musl-pthread.patch
+	eapply "${FILESDIR}"/${PN}-18-intel-missing-time_t.patch
+	eapply "${FILESDIR}"/${PN}-18-musl-amdgpu-include-pthread.patch
+	eapply "${FILESDIR}"/${PN}-18-musl-larger-stacksize.patch
+	eapply_user
+	eautoreconf
+}
+
+multilib_src_configure() {
+	local myconf
+
+	if use classic; then
+		# Configurable DRI drivers
+		driver_enable swrast
+
+		# Intel code
+		driver_enable video_cards_i915 i915
+		driver_enable video_cards_i965 i965
+		if ! use video_cards_i915 && \
+			! use video_cards_i965; then
+			driver_enable video_cards_intel i915 i965
+		fi
+
+		# Nouveau code
+		driver_enable video_cards_nouveau nouveau
+
+		# ATI code
+		driver_enable video_cards_r100 radeon
+		driver_enable video_cards_r200 r200
+		if ! use video_cards_r100 && \
+				! use video_cards_r200; then
+			driver_enable video_cards_radeon radeon r200
+		fi
+	fi
+
+	if use egl; then
+		myconf+=" --with-platforms=x11,surfaceless$(use wayland && echo ",wayland")$(use gbm && echo ",drm")"
+	fi
+
+	if use gallium; then
+		myconf+="
+			$(use_enable d3d9 nine)
+			$(use_enable llvm)
+			$(use_enable vaapi va)
+			$(use_enable vdpau)
+			$(use_enable xa)
+			$(use_enable xvmc)
+		"
+		use vaapi && myconf+=" --with-va-libdir=/usr/$(get_libdir)/va/drivers"
+
+		gallium_enable swrast
+		gallium_enable video_cards_vc4 vc4
+		gallium_enable video_cards_vivante etnaviv
+		gallium_enable video_cards_vmware svga
+		gallium_enable video_cards_nouveau nouveau
+		gallium_enable video_cards_i915 i915
+		gallium_enable video_cards_imx imx
+		if ! use video_cards_i915 && \
+			! use video_cards_i965; then
+			gallium_enable video_cards_intel i915
+		fi
+
+		gallium_enable video_cards_r300 r300
+		gallium_enable video_cards_r600 r600
+		gallium_enable video_cards_radeonsi radeonsi
+		if ! use video_cards_r300 && \
+				! use video_cards_r600; then
+			gallium_enable video_cards_radeon r300 r600
+		fi
+
+		gallium_enable video_cards_freedreno freedreno
+		# opencl stuff
+		if use opencl; then
+			myconf+="
+				$(use_enable opencl)
+				--with-clang-libdir="${EPREFIX}/usr/lib"
+				"
+		fi
+
+		gallium_enable video_cards_virgl virgl
+	fi
+
+	if use vulkan; then
+		vulkan_enable video_cards_i965 intel
+		vulkan_enable video_cards_radeonsi radeon
+	fi
+
+	# x86 hardened pax_kernel needs glx-rts, bug 240956
+	if [[ ${ABI} == x86 ]]; then
+		myconf+=" $(use_enable pax_kernel glx-read-only-text)"
+	fi
+
+	# on abi_x86_32 hardened we need to have asm disable
+	if [[ ${ABI} == x86* ]] && use pic; then
+		myconf+=" --disable-asm"
+	fi
+
+	if use gallium; then
+		myconf+=" $(use_enable osmesa gallium-osmesa)"
+	else
+		myconf+=" $(use_enable osmesa)"
+	fi
+
+	# build fails with BSD indent, bug #428112
+	use userland_GNU || export INDENT=cat
+
+	ECONF_SOURCE="${S}" \
+	econf \
+		--enable-dri \
+		--enable-glx \
+		--enable-shared-glapi \
+		$(use_enable !bindist texture-float) \
+		$(use_enable d3d9 nine) \
+		$(use_enable debug) \
+		$(use_enable dri3) \
+		$(use_enable egl) \
+		$(use_enable gbm) \
+		$(use_enable gles1) \
+		$(use_enable gles2) \
+		$(use_enable nptl glx-tls) \
+		$(use_enable unwind libunwind) \
+		--enable-valgrind=$(usex valgrind auto no) \
+		--enable-llvm-shared-libs \
+		--disable-opencl-icd \
+		--with-dri-drivers=${DRI_DRIVERS} \
+		--with-gallium-drivers=${GALLIUM_DRIVERS} \
+		--with-vulkan-drivers=${VULKAN_DRIVERS} \
+		PYTHON2="${PYTHON}" \
+		${myconf}
+}
+
+multilib_src_install() {
+	emake install DESTDIR="${D}"
+
+	if use wayland; then
+		# These files are now provided by >=dev-libs/wayland-1.15.0
+		rm "${ED}/usr/$(get_libdir)/libwayland-egl.so" || die
+		rm "${ED}/usr/$(get_libdir)/libwayland-egl.so.1" || die
+		rm "${ED}/usr/$(get_libdir)/libwayland-egl.so.1.0.0" || die
+		rm "${ED}/usr/$(get_libdir)/pkgconfig/wayland-egl.pc" || die
+	fi
+
+	if use opencl; then
+		ebegin "Moving Gallium/Clover OpenCL implementation for dynamic switching"
+		local cl_dir="/usr/$(get_libdir)/OpenCL/vendors/mesa"
+		dodir ${cl_dir}/{lib,include}
+		if [ -f "${ED}/usr/$(get_libdir)/libOpenCL.so" ]; then
+			mv -f "${ED}"/usr/$(get_libdir)/libOpenCL.so* \
+			"${ED}"${cl_dir}
+		fi
+		if [ -f "${ED}/usr/include/CL/opencl.h" ]; then
+			mv -f "${ED}"/usr/include/CL \
+			"${ED}"${cl_dir}/include
+		fi
+		eend $?
+	fi
+}
+
+multilib_src_install_all() {
+	find "${ED}" -name '*.la' -delete
+	einstalldocs
+
+	if use !bindist; then
+		dodoc docs/patents.txt
+	fi
+}
+
+multilib_src_test() {
+	if use llvm; then
+		local llvm_tests='lp_test_arit lp_test_arit lp_test_blend lp_test_blend lp_test_conv lp_test_conv lp_test_format lp_test_format lp_test_printf lp_test_printf'
+		pushd src/gallium/drivers/llvmpipe >/dev/null || die
+		emake ${llvm_tests}
+		pax-mark m ${llvm_tests}
+		popd >/dev/null || die
+	fi
+	emake check
+}
+
+pkg_postinst() {
+	# Switch to the xorg implementation.
+	echo
+	eselect opengl set --use-old ${OPENGL_DIR}
+
+	# Switch to mesa opencl
+	if use opencl; then
+		eselect opencl set --use-old ${PN}
+	fi
+
+	# warn about patent encumbered texture-float
+	if use !bindist; then
+		elog "USE=\"bindist\" was not set. Potentially patent encumbered code was"
+		elog "enabled. Please see /usr/share/doc/${P}/patents.txt.bz2 for an"
+		elog "explanation."
+	fi
+}
+
+# $1 - VIDEO_CARDS flag
+# other args - names of DRI drivers to enable
+# TODO: avoid code duplication for a more elegant implementation
+driver_enable() {
+	case $# in
+		# for enabling unconditionally
+		1)
+			DRI_DRIVERS+=",$1"
+			;;
+		*)
+			if use $1; then
+				shift
+				for i in $@; do
+					DRI_DRIVERS+=",${i}"
+				done
+			fi
+			;;
+	esac
+}
+
+gallium_enable() {
+	case $# in
+		# for enabling unconditionally
+		1)
+			GALLIUM_DRIVERS+=",$1"
+			;;
+		*)
+			if use $1; then
+				shift
+				for i in $@; do
+					GALLIUM_DRIVERS+=",${i}"
+				done
+			fi
+			;;
+	esac
+}
+
+vulkan_enable() {
+	case $# in
+		# for enabling unconditionally
+		1)
+			VULKAN_DRIVERS+=",$1"
+			;;
+		*)
+			if use $1; then
+				shift
+				for i in $@; do
+					VULKAN_DRIVERS+=",${i}"
+				done
+			fi
+			;;
+	esac
+}

diff --git a/media-libs/mesa/mesa-18.1.6.ebuild b/media-libs/mesa/mesa-18.1.6.ebuild
new file mode 100644
index 0000000..3145d0d
--- /dev/null
+++ b/media-libs/mesa/mesa-18.1.6.ebuild
@@ -0,0 +1,519 @@
+# Copyright 1999-2018 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+EGIT_REPO_URI="https://gitlab.freedesktop.org/mesa/mesa.git"
+
+if [[ ${PV} = 9999 ]]; then
+	GIT_ECLASS="git-r3"
+	EXPERIMENTAL="true"
+fi
+
+PYTHON_COMPAT=( python2_7 )
+
+inherit autotools llvm multilib-minimal python-any-r1 pax-utils ${GIT_ECLASS}
+
+OPENGL_DIR="xorg-x11"
+
+MY_P="${P/_/-}"
+
+DESCRIPTION="OpenGL-like graphic library for Linux"
+HOMEPAGE="https://www.mesa3d.org/ https://mesa.freedesktop.org/"
+
+if [[ $PV == 9999 ]]; then
+	SRC_URI=""
+else
+	SRC_URI="https://mesa.freedesktop.org/archive/${MY_P}.tar.xz"
+	KEYWORDS="amd64 ~arm ~arm64 ~ppc x86"
+fi
+
+LICENSE="MIT"
+SLOT="0"
+RESTRICT="!bindist? ( bindist )"
+
+RADEON_CARDS="r100 r200 r300 r600 radeon radeonsi"
+VIDEO_CARDS="${RADEON_CARDS} freedreno i915 i965 imx intel nouveau vc4 virgl vivante vmware"
+for card in ${VIDEO_CARDS}; do
+	IUSE_VIDEO_CARDS+=" video_cards_${card}"
+done
+
+IUSE="${IUSE_VIDEO_CARDS}
+	bindist +classic d3d9 debug +dri3 +egl +gallium +gbm gles1 gles2 unwind
+	+llvm +nptl opencl osmesa pax_kernel pic selinux vaapi valgrind
+	vdpau vulkan wayland xvmc xa"
+
+REQUIRED_USE="
+	d3d9?   ( dri3 gallium )
+	llvm?   ( gallium )
+	opencl? ( gallium llvm || ( video_cards_r600 video_cards_radeonsi ) )
+	gles1?  ( egl )
+	gles2?  ( egl )
+	vaapi? ( gallium )
+	vdpau? ( gallium )
+	vulkan? ( || ( video_cards_i965 video_cards_radeonsi )
+			  video_cards_radeonsi? ( llvm ) )
+	wayland? ( egl gbm )
+	xa?  ( gallium )
+	video_cards_freedreno?  ( gallium )
+	video_cards_intel?  ( classic )
+	video_cards_i915?   ( || ( classic gallium ) )
+	video_cards_i965?   ( classic )
+	video_cards_imx?    ( gallium video_cards_vivante )
+	video_cards_nouveau? ( || ( classic gallium ) )
+	video_cards_radeon? ( || ( classic gallium )
+						  gallium? ( x86? ( llvm ) amd64? ( llvm ) ) )
+	video_cards_r100?   ( classic )
+	video_cards_r200?   ( classic )
+	video_cards_r300?   ( gallium x86? ( llvm ) amd64? ( llvm ) )
+	video_cards_r600?   ( gallium )
+	video_cards_radeonsi?   ( gallium llvm )
+	video_cards_vc4? ( gallium )
+	video_cards_virgl? ( gallium )
+	video_cards_vivante? ( gallium gbm )
+	video_cards_vmware? ( gallium )
+"
+
+LIBDRM_DEPSTRING=">=x11-libs/libdrm-2.4.91"
+RDEPEND="
+	!app-eselect/eselect-mesa
+	>=app-eselect/eselect-opengl-1.3.0
+	>=dev-libs/expat-2.1.0-r3:=[${MULTILIB_USEDEP}]
+	>=sys-libs/zlib-1.2.8[${MULTILIB_USEDEP}]
+	>=x11-libs/libX11-1.6.2:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libxshmfence-1.1:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libXdamage-1.1.4-r1:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libXext-1.3.2:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libXxf86vm-1.1.3:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libxcb-1.13:=[${MULTILIB_USEDEP}]
+	x11-libs/libXfixes:=[${MULTILIB_USEDEP}]
+	unwind? ( sys-libs/libunwind[${MULTILIB_USEDEP}] )
+	llvm? (
+		video_cards_radeonsi? (
+			virtual/libelf:0=[${MULTILIB_USEDEP}]
+		)
+		video_cards_r600? (
+			virtual/libelf:0=[${MULTILIB_USEDEP}]
+		)
+		video_cards_radeon? (
+			virtual/libelf:0=[${MULTILIB_USEDEP}]
+		)
+	)
+	opencl? (
+				app-eselect/eselect-opencl
+				dev-libs/libclc
+				virtual/libelf:0=[${MULTILIB_USEDEP}]
+			)
+	vaapi? (
+		>=x11-libs/libva-1.7.3:=[${MULTILIB_USEDEP}]
+		video_cards_nouveau? ( !<=x11-libs/libva-vdpau-driver-0.7.4-r3 )
+	)
+	vdpau? ( >=x11-libs/libvdpau-1.1:=[${MULTILIB_USEDEP}] )
+	wayland? (
+		>=dev-libs/wayland-1.15.0:=[${MULTILIB_USEDEP}]
+		>=dev-libs/wayland-protocols-1.8
+	)
+	xvmc? ( >=x11-libs/libXvMC-1.0.8:=[${MULTILIB_USEDEP}] )
+	${LIBDRM_DEPSTRING}[video_cards_freedreno?,video_cards_nouveau?,video_cards_vc4?,video_cards_vivante?,video_cards_vmware?,${MULTILIB_USEDEP}]
+
+	video_cards_intel? (
+		!video_cards_i965? ( ${LIBDRM_DEPSTRING}[video_cards_intel] )
+	)
+	video_cards_i915? ( ${LIBDRM_DEPSTRING}[video_cards_intel] )
+"
+for card in ${RADEON_CARDS}; do
+	RDEPEND="${RDEPEND}
+		video_cards_${card}? ( ${LIBDRM_DEPSTRING}[video_cards_radeon] )
+	"
+done
+RDEPEND="${RDEPEND}
+	video_cards_radeonsi? ( ${LIBDRM_DEPSTRING}[video_cards_amdgpu] )
+"
+
+# Please keep the LLVM dependency block separate. Since LLVM is slotted,
+# we need to *really* make sure we're not pulling one than more slot
+# simultaneously.
+#
+# How to use it:
+# 1. List all the working slots (with min versions) in ||, newest first.
+# 2. Update the := to specify *max* version, e.g. < 7.
+# 3. Specify LLVM_MAX_SLOT, e.g. 6.
+LLVM_MAX_SLOT="6"
+LLVM_DEPSTR="
+	|| (
+		sys-devel/llvm:7[${MULTILIB_USEDEP}]
+		sys-devel/llvm:6[${MULTILIB_USEDEP}]
+		sys-devel/llvm:5[${MULTILIB_USEDEP}]
+		sys-devel/llvm:4[${MULTILIB_USEDEP}]
+		>=sys-devel/llvm-3.9.0:0[${MULTILIB_USEDEP}]
+	)
+	sys-devel/llvm:=[${MULTILIB_USEDEP}]
+"
+LLVM_DEPSTR_AMDGPU=${LLVM_DEPSTR//]/,llvm_targets_AMDGPU(-)]}
+CLANG_DEPSTR=${LLVM_DEPSTR//llvm/clang}
+CLANG_DEPSTR_AMDGPU=${CLANG_DEPSTR//]/,llvm_targets_AMDGPU(-)]}
+RDEPEND="${RDEPEND}
+	llvm? (
+		opencl? (
+			video_cards_r600? (
+				${CLANG_DEPSTR_AMDGPU}
+			)
+			!video_cards_r600? (
+				video_cards_radeonsi? (
+					${CLANG_DEPSTR_AMDGPU}
+				)
+			)
+			!video_cards_r600? (
+				!video_cards_radeonsi? (
+					video_cards_radeon? (
+						${CLANG_DEPSTR_AMDGPU}
+					)
+				)
+			)
+			!video_cards_r600? (
+				!video_cards_radeon? (
+					!video_cards_radeonsi? (
+						${CLANG_DEPSTR}
+					)
+				)
+			)
+		)
+		!opencl? (
+			video_cards_r600? (
+				${LLVM_DEPSTR_AMDGPU}
+			)
+			!video_cards_r600? (
+				video_cards_radeonsi? (
+					${LLVM_DEPSTR_AMDGPU}
+				)
+			)
+			!video_cards_r600? (
+				!video_cards_radeonsi? (
+					video_cards_radeon? (
+						${LLVM_DEPSTR_AMDGPU}
+					)
+				)
+			)
+			!video_cards_r600? (
+				!video_cards_radeon? (
+					!video_cards_radeonsi? (
+						${LLVM_DEPSTR}
+					)
+				)
+			)
+		)
+	)
+"
+unset {LLVM,CLANG}_DEPSTR{,_AMDGPU}
+
+DEPEND="${RDEPEND}
+	${PYTHON_DEPS}
+	opencl? (
+		>=sys-devel/gcc-4.6
+	)
+	sys-devel/gettext
+	virtual/pkgconfig
+	valgrind? ( dev-util/valgrind )
+	x11-base/xorg-proto
+	vulkan? (
+		$(python_gen_any_dep ">=dev-python/mako-0.7.3[\${PYTHON_USEDEP}]")
+	)
+"
+[[ ${PV} == 9999 ]] && DEPEND+="
+	sys-devel/bison
+	sys-devel/flex
+	$(python_gen_any_dep ">=dev-python/mako-0.7.3[\${PYTHON_USEDEP}]")
+"
+
+S="${WORKDIR}/${MY_P}"
+EGIT_CHECKOUT_DIR=${S}
+
+QA_WX_LOAD="
+x86? (
+	!pic? (
+		usr/lib*/libglapi.so.0.0.0
+		usr/lib*/libGLESv1_CM.so.1.1.0
+		usr/lib*/libGLESv2.so.2.0.0
+		usr/lib*/libGL.so.1.2.0
+		usr/lib*/libOSMesa.so.8.0.0
+	)
+)"
+
+llvm_check_deps() {
+	local flags=${MULTILIB_USEDEP}
+	if use video_cards_r600 || use video_cards_radeon || use video_cards_radeonsi
+	then
+		flags+=",llvm_targets_AMDGPU(-)"
+	fi
+
+	if use opencl; then
+		has_version "sys-devel/clang[${flags}]" || return 1
+	fi
+	has_version "sys-devel/llvm[${flags}]"
+}
+
+pkg_setup() {
+	# warning message for bug 459306
+	if use llvm && has_version sys-devel/llvm[!debug=]; then
+		ewarn "Mismatch between debug USE flags in media-libs/mesa and sys-devel/llvm"
+		ewarn "detected! This can cause problems. For details, see bug 459306."
+	fi
+
+	if use llvm; then
+		llvm_pkg_setup
+	fi
+	python-any-r1_pkg_setup
+}
+
+src_prepare() {
+	eapply "${FILESDIR}"/${PN}-17-execinfo.patch
+	eapply "${FILESDIR}"/${PN}-17-musl-string_h.patch
+	eapply "${FILESDIR}"/${PN}-17-musl-invocation_name.patch
+	eapply "${FILESDIR}"/${PN}-18-musl-pthread.patch
+	eapply "${FILESDIR}"/${PN}-18-intel-missing-time_t.patch
+	eapply "${FILESDIR}"/${PN}-18-musl-amdgpu-include-pthread.patch
+	eapply_user
+	eautoreconf
+}
+
+multilib_src_configure() {
+	local myconf
+
+	if use classic; then
+		# Configurable DRI drivers
+		driver_enable swrast
+
+		# Intel code
+		driver_enable video_cards_i915 i915
+		driver_enable video_cards_i965 i965
+		if ! use video_cards_i915 && \
+			! use video_cards_i965; then
+			driver_enable video_cards_intel i915 i965
+		fi
+
+		# Nouveau code
+		driver_enable video_cards_nouveau nouveau
+
+		# ATI code
+		driver_enable video_cards_r100 radeon
+		driver_enable video_cards_r200 r200
+		if ! use video_cards_r100 && \
+				! use video_cards_r200; then
+			driver_enable video_cards_radeon radeon r200
+		fi
+	fi
+
+	if use egl; then
+		myconf+=" --with-platforms=x11,surfaceless$(use wayland && echo ",wayland")$(use gbm && echo ",drm")"
+	fi
+
+	if use gallium; then
+		myconf+="
+			$(use_enable d3d9 nine)
+			$(use_enable llvm)
+			$(use_enable vaapi va)
+			$(use_enable vdpau)
+			$(use_enable xa)
+			$(use_enable xvmc)
+		"
+		use vaapi && myconf+=" --with-va-libdir=/usr/$(get_libdir)/va/drivers"
+
+		gallium_enable swrast
+		gallium_enable video_cards_vc4 vc4
+		gallium_enable video_cards_vivante etnaviv
+		gallium_enable video_cards_vmware svga
+		gallium_enable video_cards_nouveau nouveau
+		gallium_enable video_cards_i915 i915
+		gallium_enable video_cards_imx imx
+		if ! use video_cards_i915 && \
+			! use video_cards_i965; then
+			gallium_enable video_cards_intel i915
+		fi
+
+		gallium_enable video_cards_r300 r300
+		gallium_enable video_cards_r600 r600
+		gallium_enable video_cards_radeonsi radeonsi
+		if ! use video_cards_r300 && \
+				! use video_cards_r600; then
+			gallium_enable video_cards_radeon r300 r600
+		fi
+
+		gallium_enable video_cards_freedreno freedreno
+		# opencl stuff
+		if use opencl; then
+			myconf+="
+				$(use_enable opencl)
+				--with-clang-libdir="${EPREFIX}/usr/lib"
+				"
+		fi
+
+		gallium_enable video_cards_virgl virgl
+	fi
+
+	if use vulkan; then
+		vulkan_enable video_cards_i965 intel
+		vulkan_enable video_cards_radeonsi radeon
+	fi
+
+	# x86 hardened pax_kernel needs glx-rts, bug 240956
+	if [[ ${ABI} == x86 ]]; then
+		myconf+=" $(use_enable pax_kernel glx-read-only-text)"
+	fi
+
+	# on abi_x86_32 hardened we need to have asm disable
+	if [[ ${ABI} == x86* ]] && use pic; then
+		myconf+=" --disable-asm"
+	fi
+
+	if use gallium; then
+		myconf+=" $(use_enable osmesa gallium-osmesa)"
+	else
+		myconf+=" $(use_enable osmesa)"
+	fi
+
+	# build fails with BSD indent, bug #428112
+	use userland_GNU || export INDENT=cat
+
+	ECONF_SOURCE="${S}" \
+	econf \
+		--enable-dri \
+		--enable-glx \
+		--enable-shared-glapi \
+		$(use_enable !bindist texture-float) \
+		$(use_enable d3d9 nine) \
+		$(use_enable debug) \
+		$(use_enable dri3) \
+		$(use_enable egl) \
+		$(use_enable gbm) \
+		$(use_enable gles1) \
+		$(use_enable gles2) \
+		$(use_enable nptl glx-tls) \
+		$(use_enable unwind libunwind) \
+		--enable-valgrind=$(usex valgrind auto no) \
+		--enable-llvm-shared-libs \
+		--disable-opencl-icd \
+		--with-dri-drivers=${DRI_DRIVERS} \
+		--with-gallium-drivers=${GALLIUM_DRIVERS} \
+		--with-vulkan-drivers=${VULKAN_DRIVERS} \
+		PYTHON2="${PYTHON}" \
+		${myconf}
+}
+
+multilib_src_install() {
+	emake install DESTDIR="${D}"
+
+	if use wayland; then
+		# These files are now provided by >=dev-libs/wayland-1.15.0
+		rm "${ED}/usr/$(get_libdir)/libwayland-egl.so" || die
+		rm "${ED}/usr/$(get_libdir)/libwayland-egl.so.1" || die
+		rm "${ED}/usr/$(get_libdir)/libwayland-egl.so.1.0.0" || die
+		rm "${ED}/usr/$(get_libdir)/pkgconfig/wayland-egl.pc" || die
+	fi
+
+	if use opencl; then
+		ebegin "Moving Gallium/Clover OpenCL implementation for dynamic switching"
+		local cl_dir="/usr/$(get_libdir)/OpenCL/vendors/mesa"
+		dodir ${cl_dir}/{lib,include}
+		if [ -f "${ED}/usr/$(get_libdir)/libOpenCL.so" ]; then
+			mv -f "${ED}"/usr/$(get_libdir)/libOpenCL.so* \
+			"${ED}"${cl_dir}
+		fi
+		if [ -f "${ED}/usr/include/CL/opencl.h" ]; then
+			mv -f "${ED}"/usr/include/CL \
+			"${ED}"${cl_dir}/include
+		fi
+		eend $?
+	fi
+}
+
+multilib_src_install_all() {
+	find "${ED}" -name '*.la' -delete
+	einstalldocs
+
+	if use !bindist; then
+		dodoc docs/patents.txt
+	fi
+}
+
+multilib_src_test() {
+	if use llvm; then
+		local llvm_tests='lp_test_arit lp_test_arit lp_test_blend lp_test_blend lp_test_conv lp_test_conv lp_test_format lp_test_format lp_test_printf lp_test_printf'
+		pushd src/gallium/drivers/llvmpipe >/dev/null || die
+		emake ${llvm_tests}
+		pax-mark m ${llvm_tests}
+		popd >/dev/null || die
+	fi
+	emake check
+}
+
+pkg_postinst() {
+	# Switch to the xorg implementation.
+	echo
+	eselect opengl set --use-old ${OPENGL_DIR}
+
+	# Switch to mesa opencl
+	if use opencl; then
+		eselect opencl set --use-old ${PN}
+	fi
+
+	# warn about patent encumbered texture-float
+	if use !bindist; then
+		elog "USE=\"bindist\" was not set. Potentially patent encumbered code was"
+		elog "enabled. Please see /usr/share/doc/${P}/patents.txt.bz2 for an"
+		elog "explanation."
+	fi
+}
+
+# $1 - VIDEO_CARDS flag
+# other args - names of DRI drivers to enable
+# TODO: avoid code duplication for a more elegant implementation
+driver_enable() {
+	case $# in
+		# for enabling unconditionally
+		1)
+			DRI_DRIVERS+=",$1"
+			;;
+		*)
+			if use $1; then
+				shift
+				for i in $@; do
+					DRI_DRIVERS+=",${i}"
+				done
+			fi
+			;;
+	esac
+}
+
+gallium_enable() {
+	case $# in
+		# for enabling unconditionally
+		1)
+			GALLIUM_DRIVERS+=",$1"
+			;;
+		*)
+			if use $1; then
+				shift
+				for i in $@; do
+					GALLIUM_DRIVERS+=",${i}"
+				done
+			fi
+			;;
+	esac
+}
+
+vulkan_enable() {
+	case $# in
+		# for enabling unconditionally
+		1)
+			VULKAN_DRIVERS+=",$1"
+			;;
+		*)
+			if use $1; then
+				shift
+				for i in $@; do
+					VULKAN_DRIVERS+=",${i}"
+				done
+			fi
+			;;
+	esac
+}

diff --git a/media-libs/mesa/mesa-18.1.9-r1.ebuild b/media-libs/mesa/mesa-18.1.9-r1.ebuild
new file mode 100644
index 0000000..ca6486f
--- /dev/null
+++ b/media-libs/mesa/mesa-18.1.9-r1.ebuild
@@ -0,0 +1,520 @@
+# Copyright 1999-2018 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+EGIT_REPO_URI="https://gitlab.freedesktop.org/mesa/mesa.git"
+
+if [[ ${PV} = 9999 ]]; then
+	GIT_ECLASS="git-r3"
+	EXPERIMENTAL="true"
+fi
+
+PYTHON_COMPAT=( python2_7 )
+
+inherit autotools llvm multilib-minimal python-any-r1 pax-utils ${GIT_ECLASS}
+
+OPENGL_DIR="xorg-x11"
+
+MY_P="${P/_/-}"
+
+DESCRIPTION="OpenGL-like graphic library for Linux"
+HOMEPAGE="https://www.mesa3d.org/ https://mesa.freedesktop.org/"
+
+if [[ $PV == 9999 ]]; then
+	SRC_URI=""
+else
+	SRC_URI="https://mesa.freedesktop.org/archive/${MY_P}.tar.xz"
+	KEYWORDS="~amd64 ~arm ~arm64 ~mips ~ppc ~x86"
+fi
+
+LICENSE="MIT"
+SLOT="0"
+RESTRICT="!bindist? ( bindist )"
+
+RADEON_CARDS="r100 r200 r300 r600 radeon radeonsi"
+VIDEO_CARDS="${RADEON_CARDS} freedreno i915 i965 imx intel nouveau vc4 virgl vivante vmware"
+for card in ${VIDEO_CARDS}; do
+	IUSE_VIDEO_CARDS+=" video_cards_${card}"
+done
+
+IUSE="${IUSE_VIDEO_CARDS}
+	bindist +classic d3d9 debug +dri3 +egl +gallium +gbm gles1 gles2 unwind
+	+llvm +nptl opencl osmesa pax_kernel pic selinux vaapi valgrind
+	vdpau vulkan wayland xvmc xa"
+
+REQUIRED_USE="
+	d3d9?   ( dri3 gallium )
+	llvm?   ( gallium )
+	opencl? ( gallium llvm || ( video_cards_r600 video_cards_radeonsi ) )
+	gles1?  ( egl )
+	gles2?  ( egl )
+	vaapi? ( gallium )
+	vdpau? ( gallium )
+	vulkan? ( || ( video_cards_i965 video_cards_radeonsi )
+			  video_cards_radeonsi? ( llvm ) )
+	wayland? ( egl gbm )
+	xa?  ( gallium )
+	video_cards_freedreno?  ( gallium )
+	video_cards_intel?  ( classic )
+	video_cards_i915?   ( || ( classic gallium ) )
+	video_cards_i965?   ( classic )
+	video_cards_imx?    ( gallium video_cards_vivante )
+	video_cards_nouveau? ( || ( classic gallium ) )
+	video_cards_radeon? ( || ( classic gallium )
+						  gallium? ( x86? ( llvm ) amd64? ( llvm ) ) )
+	video_cards_r100?   ( classic )
+	video_cards_r200?   ( classic )
+	video_cards_r300?   ( gallium x86? ( llvm ) amd64? ( llvm ) )
+	video_cards_r600?   ( gallium )
+	video_cards_radeonsi?   ( gallium llvm )
+	video_cards_vc4? ( gallium )
+	video_cards_virgl? ( gallium )
+	video_cards_vivante? ( gallium gbm )
+	video_cards_vmware? ( gallium )
+"
+
+LIBDRM_DEPSTRING=">=x11-libs/libdrm-2.4.91"
+RDEPEND="
+	!app-eselect/eselect-mesa
+	>=app-eselect/eselect-opengl-1.3.0
+	>=dev-libs/expat-2.1.0-r3:=[${MULTILIB_USEDEP}]
+	>=sys-libs/zlib-1.2.8[${MULTILIB_USEDEP}]
+	>=x11-libs/libX11-1.6.2:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libxshmfence-1.1:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libXdamage-1.1.4-r1:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libXext-1.3.2:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libXxf86vm-1.1.3:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libxcb-1.13:=[${MULTILIB_USEDEP}]
+	x11-libs/libXfixes:=[${MULTILIB_USEDEP}]
+	unwind? ( sys-libs/libunwind[${MULTILIB_USEDEP}] )
+	llvm? (
+		video_cards_radeonsi? (
+			virtual/libelf:0=[${MULTILIB_USEDEP}]
+		)
+		video_cards_r600? (
+			virtual/libelf:0=[${MULTILIB_USEDEP}]
+		)
+		video_cards_radeon? (
+			virtual/libelf:0=[${MULTILIB_USEDEP}]
+		)
+	)
+	opencl? (
+				app-eselect/eselect-opencl
+				dev-libs/libclc
+				virtual/libelf:0=[${MULTILIB_USEDEP}]
+			)
+	vaapi? (
+		>=x11-libs/libva-1.7.3:=[${MULTILIB_USEDEP}]
+		video_cards_nouveau? ( !<=x11-libs/libva-vdpau-driver-0.7.4-r3 )
+	)
+	vdpau? ( >=x11-libs/libvdpau-1.1:=[${MULTILIB_USEDEP}] )
+	wayland? (
+		>=dev-libs/wayland-1.15.0:=[${MULTILIB_USEDEP}]
+		>=dev-libs/wayland-protocols-1.8
+	)
+	xvmc? ( >=x11-libs/libXvMC-1.0.8:=[${MULTILIB_USEDEP}] )
+	${LIBDRM_DEPSTRING}[video_cards_freedreno?,video_cards_nouveau?,video_cards_vc4?,video_cards_vivante?,video_cards_vmware?,${MULTILIB_USEDEP}]
+
+	video_cards_intel? (
+		!video_cards_i965? ( ${LIBDRM_DEPSTRING}[video_cards_intel] )
+	)
+	video_cards_i915? ( ${LIBDRM_DEPSTRING}[video_cards_intel] )
+"
+for card in ${RADEON_CARDS}; do
+	RDEPEND="${RDEPEND}
+		video_cards_${card}? ( ${LIBDRM_DEPSTRING}[video_cards_radeon] )
+	"
+done
+RDEPEND="${RDEPEND}
+	video_cards_radeonsi? ( ${LIBDRM_DEPSTRING}[video_cards_amdgpu] )
+"
+
+# Please keep the LLVM dependency block separate. Since LLVM is slotted,
+# we need to *really* make sure we're not pulling one than more slot
+# simultaneously.
+#
+# How to use it:
+# 1. List all the working slots (with min versions) in ||, newest first.
+# 2. Update the := to specify *max* version, e.g. < 7.
+# 3. Specify LLVM_MAX_SLOT, e.g. 6.
+LLVM_MAX_SLOT="6"
+LLVM_DEPSTR="
+	|| (
+		sys-devel/llvm:7[${MULTILIB_USEDEP}]
+		sys-devel/llvm:6[${MULTILIB_USEDEP}]
+		sys-devel/llvm:5[${MULTILIB_USEDEP}]
+		sys-devel/llvm:4[${MULTILIB_USEDEP}]
+		>=sys-devel/llvm-3.9.0:0[${MULTILIB_USEDEP}]
+	)
+	sys-devel/llvm:=[${MULTILIB_USEDEP}]
+"
+LLVM_DEPSTR_AMDGPU=${LLVM_DEPSTR//]/,llvm_targets_AMDGPU(-)]}
+CLANG_DEPSTR=${LLVM_DEPSTR//llvm/clang}
+CLANG_DEPSTR_AMDGPU=${CLANG_DEPSTR//]/,llvm_targets_AMDGPU(-)]}
+RDEPEND="${RDEPEND}
+	llvm? (
+		opencl? (
+			video_cards_r600? (
+				${CLANG_DEPSTR_AMDGPU}
+			)
+			!video_cards_r600? (
+				video_cards_radeonsi? (
+					${CLANG_DEPSTR_AMDGPU}
+				)
+			)
+			!video_cards_r600? (
+				!video_cards_radeonsi? (
+					video_cards_radeon? (
+						${CLANG_DEPSTR_AMDGPU}
+					)
+				)
+			)
+			!video_cards_r600? (
+				!video_cards_radeon? (
+					!video_cards_radeonsi? (
+						${CLANG_DEPSTR}
+					)
+				)
+			)
+		)
+		!opencl? (
+			video_cards_r600? (
+				${LLVM_DEPSTR_AMDGPU}
+			)
+			!video_cards_r600? (
+				video_cards_radeonsi? (
+					${LLVM_DEPSTR_AMDGPU}
+				)
+			)
+			!video_cards_r600? (
+				!video_cards_radeonsi? (
+					video_cards_radeon? (
+						${LLVM_DEPSTR_AMDGPU}
+					)
+				)
+			)
+			!video_cards_r600? (
+				!video_cards_radeon? (
+					!video_cards_radeonsi? (
+						${LLVM_DEPSTR}
+					)
+				)
+			)
+		)
+	)
+"
+unset {LLVM,CLANG}_DEPSTR{,_AMDGPU}
+
+DEPEND="${RDEPEND}
+	${PYTHON_DEPS}
+	opencl? (
+		>=sys-devel/gcc-4.6
+	)
+	sys-devel/gettext
+	virtual/pkgconfig
+	valgrind? ( dev-util/valgrind )
+	x11-base/xorg-proto
+	vulkan? (
+		$(python_gen_any_dep ">=dev-python/mako-0.7.3[\${PYTHON_USEDEP}]")
+	)
+"
+[[ ${PV} == 9999 ]] && DEPEND+="
+	sys-devel/bison
+	sys-devel/flex
+	$(python_gen_any_dep ">=dev-python/mako-0.7.3[\${PYTHON_USEDEP}]")
+"
+
+S="${WORKDIR}/${MY_P}"
+EGIT_CHECKOUT_DIR=${S}
+
+QA_WX_LOAD="
+x86? (
+	!pic? (
+		usr/lib*/libglapi.so.0.0.0
+		usr/lib*/libGLESv1_CM.so.1.1.0
+		usr/lib*/libGLESv2.so.2.0.0
+		usr/lib*/libGL.so.1.2.0
+		usr/lib*/libOSMesa.so.8.0.0
+	)
+)"
+
+llvm_check_deps() {
+	local flags=${MULTILIB_USEDEP}
+	if use video_cards_r600 || use video_cards_radeon || use video_cards_radeonsi
+	then
+		flags+=",llvm_targets_AMDGPU(-)"
+	fi
+
+	if use opencl; then
+		has_version "sys-devel/clang[${flags}]" || return 1
+	fi
+	has_version "sys-devel/llvm[${flags}]"
+}
+
+pkg_setup() {
+	# warning message for bug 459306
+	if use llvm && has_version sys-devel/llvm[!debug=]; then
+		ewarn "Mismatch between debug USE flags in media-libs/mesa and sys-devel/llvm"
+		ewarn "detected! This can cause problems. For details, see bug 459306."
+	fi
+
+	if use llvm; then
+		llvm_pkg_setup
+	fi
+	python-any-r1_pkg_setup
+}
+
+src_prepare() {
+	eapply "${FILESDIR}"/${PN}-17-execinfo.patch
+	eapply "${FILESDIR}"/${PN}-17-musl-string_h.patch
+	eapply "${FILESDIR}"/${PN}-17-musl-invocation_name.patch
+	eapply "${FILESDIR}"/${PN}-18-musl-pthread.patch
+	eapply "${FILESDIR}"/${PN}-18-intel-missing-time_t.patch
+	eapply "${FILESDIR}"/${PN}-18-musl-amdgpu-include-pthread.patch
+	eapply "${FILESDIR}"/${PN}-18-musl-larger-stacksize.patch
+	eapply_user
+	eautoreconf
+}
+
+multilib_src_configure() {
+	local myconf
+
+	if use classic; then
+		# Configurable DRI drivers
+		driver_enable swrast
+
+		# Intel code
+		driver_enable video_cards_i915 i915
+		driver_enable video_cards_i965 i965
+		if ! use video_cards_i915 && \
+			! use video_cards_i965; then
+			driver_enable video_cards_intel i915 i965
+		fi
+
+		# Nouveau code
+		driver_enable video_cards_nouveau nouveau
+
+		# ATI code
+		driver_enable video_cards_r100 radeon
+		driver_enable video_cards_r200 r200
+		if ! use video_cards_r100 && \
+				! use video_cards_r200; then
+			driver_enable video_cards_radeon radeon r200
+		fi
+	fi
+
+	if use egl; then
+		myconf+=" --with-platforms=x11,surfaceless$(use wayland && echo ",wayland")$(use gbm && echo ",drm")"
+	fi
+
+	if use gallium; then
+		myconf+="
+			$(use_enable d3d9 nine)
+			$(use_enable llvm)
+			$(use_enable vaapi va)
+			$(use_enable vdpau)
+			$(use_enable xa)
+			$(use_enable xvmc)
+		"
+		use vaapi && myconf+=" --with-va-libdir=/usr/$(get_libdir)/va/drivers"
+
+		gallium_enable swrast
+		gallium_enable video_cards_vc4 vc4
+		gallium_enable video_cards_vivante etnaviv
+		gallium_enable video_cards_vmware svga
+		gallium_enable video_cards_nouveau nouveau
+		gallium_enable video_cards_i915 i915
+		gallium_enable video_cards_imx imx
+		if ! use video_cards_i915 && \
+			! use video_cards_i965; then
+			gallium_enable video_cards_intel i915
+		fi
+
+		gallium_enable video_cards_r300 r300
+		gallium_enable video_cards_r600 r600
+		gallium_enable video_cards_radeonsi radeonsi
+		if ! use video_cards_r300 && \
+				! use video_cards_r600; then
+			gallium_enable video_cards_radeon r300 r600
+		fi
+
+		gallium_enable video_cards_freedreno freedreno
+		# opencl stuff
+		if use opencl; then
+			myconf+="
+				$(use_enable opencl)
+				--with-clang-libdir="${EPREFIX}/usr/lib"
+				"
+		fi
+
+		gallium_enable video_cards_virgl virgl
+	fi
+
+	if use vulkan; then
+		vulkan_enable video_cards_i965 intel
+		vulkan_enable video_cards_radeonsi radeon
+	fi
+
+	# x86 hardened pax_kernel needs glx-rts, bug 240956
+	if [[ ${ABI} == x86 ]]; then
+		myconf+=" $(use_enable pax_kernel glx-read-only-text)"
+	fi
+
+	# on abi_x86_32 hardened we need to have asm disable
+	if [[ ${ABI} == x86* ]] && use pic; then
+		myconf+=" --disable-asm"
+	fi
+
+	if use gallium; then
+		myconf+=" $(use_enable osmesa gallium-osmesa)"
+	else
+		myconf+=" $(use_enable osmesa)"
+	fi
+
+	# build fails with BSD indent, bug #428112
+	use userland_GNU || export INDENT=cat
+
+	ECONF_SOURCE="${S}" \
+	econf \
+		--enable-dri \
+		--enable-glx \
+		--enable-shared-glapi \
+		$(use_enable !bindist texture-float) \
+		$(use_enable d3d9 nine) \
+		$(use_enable debug) \
+		$(use_enable dri3) \
+		$(use_enable egl) \
+		$(use_enable gbm) \
+		$(use_enable gles1) \
+		$(use_enable gles2) \
+		$(use_enable nptl glx-tls) \
+		$(use_enable unwind libunwind) \
+		--enable-valgrind=$(usex valgrind auto no) \
+		--enable-llvm-shared-libs \
+		--disable-opencl-icd \
+		--with-dri-drivers=${DRI_DRIVERS} \
+		--with-gallium-drivers=${GALLIUM_DRIVERS} \
+		--with-vulkan-drivers=${VULKAN_DRIVERS} \
+		PYTHON2="${PYTHON}" \
+		${myconf}
+}
+
+multilib_src_install() {
+	emake install DESTDIR="${D}"
+
+	if use wayland; then
+		# These files are now provided by >=dev-libs/wayland-1.15.0
+		rm "${ED}/usr/$(get_libdir)/libwayland-egl.so" || die
+		rm "${ED}/usr/$(get_libdir)/libwayland-egl.so.1" || die
+		rm "${ED}/usr/$(get_libdir)/libwayland-egl.so.1.0.0" || die
+		rm "${ED}/usr/$(get_libdir)/pkgconfig/wayland-egl.pc" || die
+	fi
+
+	if use opencl; then
+		ebegin "Moving Gallium/Clover OpenCL implementation for dynamic switching"
+		local cl_dir="/usr/$(get_libdir)/OpenCL/vendors/mesa"
+		dodir ${cl_dir}/{lib,include}
+		if [ -f "${ED}/usr/$(get_libdir)/libOpenCL.so" ]; then
+			mv -f "${ED}"/usr/$(get_libdir)/libOpenCL.so* \
+			"${ED}"${cl_dir}
+		fi
+		if [ -f "${ED}/usr/include/CL/opencl.h" ]; then
+			mv -f "${ED}"/usr/include/CL \
+			"${ED}"${cl_dir}/include
+		fi
+		eend $?
+	fi
+}
+
+multilib_src_install_all() {
+	find "${ED}" -name '*.la' -delete
+	einstalldocs
+
+	if use !bindist; then
+		dodoc docs/patents.txt
+	fi
+}
+
+multilib_src_test() {
+	if use llvm; then
+		local llvm_tests='lp_test_arit lp_test_arit lp_test_blend lp_test_blend lp_test_conv lp_test_conv lp_test_format lp_test_format lp_test_printf lp_test_printf'
+		pushd src/gallium/drivers/llvmpipe >/dev/null || die
+		emake ${llvm_tests}
+		pax-mark m ${llvm_tests}
+		popd >/dev/null || die
+	fi
+	emake check
+}
+
+pkg_postinst() {
+	# Switch to the xorg implementation.
+	echo
+	eselect opengl set --use-old ${OPENGL_DIR}
+
+	# Switch to mesa opencl
+	if use opencl; then
+		eselect opencl set --use-old ${PN}
+	fi
+
+	# warn about patent encumbered texture-float
+	if use !bindist; then
+		elog "USE=\"bindist\" was not set. Potentially patent encumbered code was"
+		elog "enabled. Please see /usr/share/doc/${P}/patents.txt.bz2 for an"
+		elog "explanation."
+	fi
+}
+
+# $1 - VIDEO_CARDS flag
+# other args - names of DRI drivers to enable
+# TODO: avoid code duplication for a more elegant implementation
+driver_enable() {
+	case $# in
+		# for enabling unconditionally
+		1)
+			DRI_DRIVERS+=",$1"
+			;;
+		*)
+			if use $1; then
+				shift
+				for i in $@; do
+					DRI_DRIVERS+=",${i}"
+				done
+			fi
+			;;
+	esac
+}
+
+gallium_enable() {
+	case $# in
+		# for enabling unconditionally
+		1)
+			GALLIUM_DRIVERS+=",$1"
+			;;
+		*)
+			if use $1; then
+				shift
+				for i in $@; do
+					GALLIUM_DRIVERS+=",${i}"
+				done
+			fi
+			;;
+	esac
+}
+
+vulkan_enable() {
+	case $# in
+		# for enabling unconditionally
+		1)
+			VULKAN_DRIVERS+=",$1"
+			;;
+		*)
+			if use $1; then
+				shift
+				for i in $@; do
+					VULKAN_DRIVERS+=",${i}"
+				done
+			fi
+			;;
+	esac
+}

diff --git a/media-libs/mesa/mesa-18.1.9.ebuild b/media-libs/mesa/mesa-18.1.9.ebuild
new file mode 100644
index 0000000..e61e3fd
--- /dev/null
+++ b/media-libs/mesa/mesa-18.1.9.ebuild
@@ -0,0 +1,519 @@
+# Copyright 1999-2018 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+EGIT_REPO_URI="https://gitlab.freedesktop.org/mesa/mesa.git"
+
+if [[ ${PV} = 9999 ]]; then
+	GIT_ECLASS="git-r3"
+	EXPERIMENTAL="true"
+fi
+
+PYTHON_COMPAT=( python2_7 )
+
+inherit autotools llvm multilib-minimal python-any-r1 pax-utils ${GIT_ECLASS}
+
+OPENGL_DIR="xorg-x11"
+
+MY_P="${P/_/-}"
+
+DESCRIPTION="OpenGL-like graphic library for Linux"
+HOMEPAGE="https://www.mesa3d.org/ https://mesa.freedesktop.org/"
+
+if [[ $PV == 9999 ]]; then
+	SRC_URI=""
+else
+	SRC_URI="https://mesa.freedesktop.org/archive/${MY_P}.tar.xz"
+	KEYWORDS="amd64 ~arm ~arm64 ~mips ~ppc x86"
+fi
+
+LICENSE="MIT"
+SLOT="0"
+RESTRICT="!bindist? ( bindist )"
+
+RADEON_CARDS="r100 r200 r300 r600 radeon radeonsi"
+VIDEO_CARDS="${RADEON_CARDS} freedreno i915 i965 imx intel nouveau vc4 virgl vivante vmware"
+for card in ${VIDEO_CARDS}; do
+	IUSE_VIDEO_CARDS+=" video_cards_${card}"
+done
+
+IUSE="${IUSE_VIDEO_CARDS}
+	bindist +classic d3d9 debug +dri3 +egl +gallium +gbm gles1 gles2 unwind
+	+llvm +nptl opencl osmesa pax_kernel pic selinux vaapi valgrind
+	vdpau vulkan wayland xvmc xa"
+
+REQUIRED_USE="
+	d3d9?   ( dri3 gallium )
+	llvm?   ( gallium )
+	opencl? ( gallium llvm || ( video_cards_r600 video_cards_radeonsi ) )
+	gles1?  ( egl )
+	gles2?  ( egl )
+	vaapi? ( gallium )
+	vdpau? ( gallium )
+	vulkan? ( || ( video_cards_i965 video_cards_radeonsi )
+			  video_cards_radeonsi? ( llvm ) )
+	wayland? ( egl gbm )
+	xa?  ( gallium )
+	video_cards_freedreno?  ( gallium )
+	video_cards_intel?  ( classic )
+	video_cards_i915?   ( || ( classic gallium ) )
+	video_cards_i965?   ( classic )
+	video_cards_imx?    ( gallium video_cards_vivante )
+	video_cards_nouveau? ( || ( classic gallium ) )
+	video_cards_radeon? ( || ( classic gallium )
+						  gallium? ( x86? ( llvm ) amd64? ( llvm ) ) )
+	video_cards_r100?   ( classic )
+	video_cards_r200?   ( classic )
+	video_cards_r300?   ( gallium x86? ( llvm ) amd64? ( llvm ) )
+	video_cards_r600?   ( gallium )
+	video_cards_radeonsi?   ( gallium llvm )
+	video_cards_vc4? ( gallium )
+	video_cards_virgl? ( gallium )
+	video_cards_vivante? ( gallium gbm )
+	video_cards_vmware? ( gallium )
+"
+
+LIBDRM_DEPSTRING=">=x11-libs/libdrm-2.4.91"
+RDEPEND="
+	!app-eselect/eselect-mesa
+	>=app-eselect/eselect-opengl-1.3.0
+	>=dev-libs/expat-2.1.0-r3:=[${MULTILIB_USEDEP}]
+	>=sys-libs/zlib-1.2.8[${MULTILIB_USEDEP}]
+	>=x11-libs/libX11-1.6.2:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libxshmfence-1.1:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libXdamage-1.1.4-r1:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libXext-1.3.2:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libXxf86vm-1.1.3:=[${MULTILIB_USEDEP}]
+	>=x11-libs/libxcb-1.13:=[${MULTILIB_USEDEP}]
+	x11-libs/libXfixes:=[${MULTILIB_USEDEP}]
+	unwind? ( sys-libs/libunwind[${MULTILIB_USEDEP}] )
+	llvm? (
+		video_cards_radeonsi? (
+			virtual/libelf:0=[${MULTILIB_USEDEP}]
+		)
+		video_cards_r600? (
+			virtual/libelf:0=[${MULTILIB_USEDEP}]
+		)
+		video_cards_radeon? (
+			virtual/libelf:0=[${MULTILIB_USEDEP}]
+		)
+	)
+	opencl? (
+				app-eselect/eselect-opencl
+				dev-libs/libclc
+				virtual/libelf:0=[${MULTILIB_USEDEP}]
+			)
+	vaapi? (
+		>=x11-libs/libva-1.7.3:=[${MULTILIB_USEDEP}]
+		video_cards_nouveau? ( !<=x11-libs/libva-vdpau-driver-0.7.4-r3 )
+	)
+	vdpau? ( >=x11-libs/libvdpau-1.1:=[${MULTILIB_USEDEP}] )
+	wayland? (
+		>=dev-libs/wayland-1.15.0:=[${MULTILIB_USEDEP}]
+		>=dev-libs/wayland-protocols-1.8
+	)
+	xvmc? ( >=x11-libs/libXvMC-1.0.8:=[${MULTILIB_USEDEP}] )
+	${LIBDRM_DEPSTRING}[video_cards_freedreno?,video_cards_nouveau?,video_cards_vc4?,video_cards_vivante?,video_cards_vmware?,${MULTILIB_USEDEP}]
+
+	video_cards_intel? (
+		!video_cards_i965? ( ${LIBDRM_DEPSTRING}[video_cards_intel] )
+	)
+	video_cards_i915? ( ${LIBDRM_DEPSTRING}[video_cards_intel] )
+"
+for card in ${RADEON_CARDS}; do
+	RDEPEND="${RDEPEND}
+		video_cards_${card}? ( ${LIBDRM_DEPSTRING}[video_cards_radeon] )
+	"
+done
+RDEPEND="${RDEPEND}
+	video_cards_radeonsi? ( ${LIBDRM_DEPSTRING}[video_cards_amdgpu] )
+"
+
+# Please keep the LLVM dependency block separate. Since LLVM is slotted,
+# we need to *really* make sure we're not pulling one than more slot
+# simultaneously.
+#
+# How to use it:
+# 1. List all the working slots (with min versions) in ||, newest first.
+# 2. Update the := to specify *max* version, e.g. < 7.
+# 3. Specify LLVM_MAX_SLOT, e.g. 6.
+LLVM_MAX_SLOT="6"
+LLVM_DEPSTR="
+	|| (
+		sys-devel/llvm:7[${MULTILIB_USEDEP}]
+		sys-devel/llvm:6[${MULTILIB_USEDEP}]
+		sys-devel/llvm:5[${MULTILIB_USEDEP}]
+		sys-devel/llvm:4[${MULTILIB_USEDEP}]
+		>=sys-devel/llvm-3.9.0:0[${MULTILIB_USEDEP}]
+	)
+	sys-devel/llvm:=[${MULTILIB_USEDEP}]
+"
+LLVM_DEPSTR_AMDGPU=${LLVM_DEPSTR//]/,llvm_targets_AMDGPU(-)]}
+CLANG_DEPSTR=${LLVM_DEPSTR//llvm/clang}
+CLANG_DEPSTR_AMDGPU=${CLANG_DEPSTR//]/,llvm_targets_AMDGPU(-)]}
+RDEPEND="${RDEPEND}
+	llvm? (
+		opencl? (
+			video_cards_r600? (
+				${CLANG_DEPSTR_AMDGPU}
+			)
+			!video_cards_r600? (
+				video_cards_radeonsi? (
+					${CLANG_DEPSTR_AMDGPU}
+				)
+			)
+			!video_cards_r600? (
+				!video_cards_radeonsi? (
+					video_cards_radeon? (
+						${CLANG_DEPSTR_AMDGPU}
+					)
+				)
+			)
+			!video_cards_r600? (
+				!video_cards_radeon? (
+					!video_cards_radeonsi? (
+						${CLANG_DEPSTR}
+					)
+				)
+			)
+		)
+		!opencl? (
+			video_cards_r600? (
+				${LLVM_DEPSTR_AMDGPU}
+			)
+			!video_cards_r600? (
+				video_cards_radeonsi? (
+					${LLVM_DEPSTR_AMDGPU}
+				)
+			)
+			!video_cards_r600? (
+				!video_cards_radeonsi? (
+					video_cards_radeon? (
+						${LLVM_DEPSTR_AMDGPU}
+					)
+				)
+			)
+			!video_cards_r600? (
+				!video_cards_radeon? (
+					!video_cards_radeonsi? (
+						${LLVM_DEPSTR}
+					)
+				)
+			)
+		)
+	)
+"
+unset {LLVM,CLANG}_DEPSTR{,_AMDGPU}
+
+DEPEND="${RDEPEND}
+	${PYTHON_DEPS}
+	opencl? (
+		>=sys-devel/gcc-4.6
+	)
+	sys-devel/gettext
+	virtual/pkgconfig
+	valgrind? ( dev-util/valgrind )
+	x11-base/xorg-proto
+	vulkan? (
+		$(python_gen_any_dep ">=dev-python/mako-0.7.3[\${PYTHON_USEDEP}]")
+	)
+"
+[[ ${PV} == 9999 ]] && DEPEND+="
+	sys-devel/bison
+	sys-devel/flex
+	$(python_gen_any_dep ">=dev-python/mako-0.7.3[\${PYTHON_USEDEP}]")
+"
+
+S="${WORKDIR}/${MY_P}"
+EGIT_CHECKOUT_DIR=${S}
+
+QA_WX_LOAD="
+x86? (
+	!pic? (
+		usr/lib*/libglapi.so.0.0.0
+		usr/lib*/libGLESv1_CM.so.1.1.0
+		usr/lib*/libGLESv2.so.2.0.0
+		usr/lib*/libGL.so.1.2.0
+		usr/lib*/libOSMesa.so.8.0.0
+	)
+)"
+
+llvm_check_deps() {
+	local flags=${MULTILIB_USEDEP}
+	if use video_cards_r600 || use video_cards_radeon || use video_cards_radeonsi
+	then
+		flags+=",llvm_targets_AMDGPU(-)"
+	fi
+
+	if use opencl; then
+		has_version "sys-devel/clang[${flags}]" || return 1
+	fi
+	has_version "sys-devel/llvm[${flags}]"
+}
+
+pkg_setup() {
+	# warning message for bug 459306
+	if use llvm && has_version sys-devel/llvm[!debug=]; then
+		ewarn "Mismatch between debug USE flags in media-libs/mesa and sys-devel/llvm"
+		ewarn "detected! This can cause problems. For details, see bug 459306."
+	fi
+
+	if use llvm; then
+		llvm_pkg_setup
+	fi
+	python-any-r1_pkg_setup
+}
+
+src_prepare() {
+	eapply "${FILESDIR}"/${PN}-17-execinfo.patch
+	eapply "${FILESDIR}"/${PN}-17-musl-string_h.patch
+	eapply "${FILESDIR}"/${PN}-17-musl-invocation_name.patch
+	eapply "${FILESDIR}"/${PN}-18-musl-pthread.patch
+	eapply "${FILESDIR}"/${PN}-18-intel-missing-time_t.patch
+	eapply "${FILESDIR}"/${PN}-18-musl-amdgpu-include-pthread.patch
+	eapply_user
+	eautoreconf
+}
+
+multilib_src_configure() {
+	local myconf
+
+	if use classic; then
+		# Configurable DRI drivers
+		driver_enable swrast
+
+		# Intel code
+		driver_enable video_cards_i915 i915
+		driver_enable video_cards_i965 i965
+		if ! use video_cards_i915 && \
+			! use video_cards_i965; then
+			driver_enable video_cards_intel i915 i965
+		fi
+
+		# Nouveau code
+		driver_enable video_cards_nouveau nouveau
+
+		# ATI code
+		driver_enable video_cards_r100 radeon
+		driver_enable video_cards_r200 r200
+		if ! use video_cards_r100 && \
+				! use video_cards_r200; then
+			driver_enable video_cards_radeon radeon r200
+		fi
+	fi
+
+	if use egl; then
+		myconf+=" --with-platforms=x11,surfaceless$(use wayland && echo ",wayland")$(use gbm && echo ",drm")"
+	fi
+
+	if use gallium; then
+		myconf+="
+			$(use_enable d3d9 nine)
+			$(use_enable llvm)
+			$(use_enable vaapi va)
+			$(use_enable vdpau)
+			$(use_enable xa)
+			$(use_enable xvmc)
+		"
+		use vaapi && myconf+=" --with-va-libdir=/usr/$(get_libdir)/va/drivers"
+
+		gallium_enable swrast
+		gallium_enable video_cards_vc4 vc4
+		gallium_enable video_cards_vivante etnaviv
+		gallium_enable video_cards_vmware svga
+		gallium_enable video_cards_nouveau nouveau
+		gallium_enable video_cards_i915 i915
+		gallium_enable video_cards_imx imx
+		if ! use video_cards_i915 && \
+			! use video_cards_i965; then
+			gallium_enable video_cards_intel i915
+		fi
+
+		gallium_enable video_cards_r300 r300
+		gallium_enable video_cards_r600 r600
+		gallium_enable video_cards_radeonsi radeonsi
+		if ! use video_cards_r300 && \
+				! use video_cards_r600; then
+			gallium_enable video_cards_radeon r300 r600
+		fi
+
+		gallium_enable video_cards_freedreno freedreno
+		# opencl stuff
+		if use opencl; then
+			myconf+="
+				$(use_enable opencl)
+				--with-clang-libdir="${EPREFIX}/usr/lib"
+				"
+		fi
+
+		gallium_enable video_cards_virgl virgl
+	fi
+
+	if use vulkan; then
+		vulkan_enable video_cards_i965 intel
+		vulkan_enable video_cards_radeonsi radeon
+	fi
+
+	# x86 hardened pax_kernel needs glx-rts, bug 240956
+	if [[ ${ABI} == x86 ]]; then
+		myconf+=" $(use_enable pax_kernel glx-read-only-text)"
+	fi
+
+	# on abi_x86_32 hardened we need to have asm disable
+	if [[ ${ABI} == x86* ]] && use pic; then
+		myconf+=" --disable-asm"
+	fi
+
+	if use gallium; then
+		myconf+=" $(use_enable osmesa gallium-osmesa)"
+	else
+		myconf+=" $(use_enable osmesa)"
+	fi
+
+	# build fails with BSD indent, bug #428112
+	use userland_GNU || export INDENT=cat
+
+	ECONF_SOURCE="${S}" \
+	econf \
+		--enable-dri \
+		--enable-glx \
+		--enable-shared-glapi \
+		$(use_enable !bindist texture-float) \
+		$(use_enable d3d9 nine) \
+		$(use_enable debug) \
+		$(use_enable dri3) \
+		$(use_enable egl) \
+		$(use_enable gbm) \
+		$(use_enable gles1) \
+		$(use_enable gles2) \
+		$(use_enable nptl glx-tls) \
+		$(use_enable unwind libunwind) \
+		--enable-valgrind=$(usex valgrind auto no) \
+		--enable-llvm-shared-libs \
+		--disable-opencl-icd \
+		--with-dri-drivers=${DRI_DRIVERS} \
+		--with-gallium-drivers=${GALLIUM_DRIVERS} \
+		--with-vulkan-drivers=${VULKAN_DRIVERS} \
+		PYTHON2="${PYTHON}" \
+		${myconf}
+}
+
+multilib_src_install() {
+	emake install DESTDIR="${D}"
+
+	if use wayland; then
+		# These files are now provided by >=dev-libs/wayland-1.15.0
+		rm "${ED}/usr/$(get_libdir)/libwayland-egl.so" || die
+		rm "${ED}/usr/$(get_libdir)/libwayland-egl.so.1" || die
+		rm "${ED}/usr/$(get_libdir)/libwayland-egl.so.1.0.0" || die
+		rm "${ED}/usr/$(get_libdir)/pkgconfig/wayland-egl.pc" || die
+	fi
+
+	if use opencl; then
+		ebegin "Moving Gallium/Clover OpenCL implementation for dynamic switching"
+		local cl_dir="/usr/$(get_libdir)/OpenCL/vendors/mesa"
+		dodir ${cl_dir}/{lib,include}
+		if [ -f "${ED}/usr/$(get_libdir)/libOpenCL.so" ]; then
+			mv -f "${ED}"/usr/$(get_libdir)/libOpenCL.so* \
+			"${ED}"${cl_dir}
+		fi
+		if [ -f "${ED}/usr/include/CL/opencl.h" ]; then
+			mv -f "${ED}"/usr/include/CL \
+			"${ED}"${cl_dir}/include
+		fi
+		eend $?
+	fi
+}
+
+multilib_src_install_all() {
+	find "${ED}" -name '*.la' -delete
+	einstalldocs
+
+	if use !bindist; then
+		dodoc docs/patents.txt
+	fi
+}
+
+multilib_src_test() {
+	if use llvm; then
+		local llvm_tests='lp_test_arit lp_test_arit lp_test_blend lp_test_blend lp_test_conv lp_test_conv lp_test_format lp_test_format lp_test_printf lp_test_printf'
+		pushd src/gallium/drivers/llvmpipe >/dev/null || die
+		emake ${llvm_tests}
+		pax-mark m ${llvm_tests}
+		popd >/dev/null || die
+	fi
+	emake check
+}
+
+pkg_postinst() {
+	# Switch to the xorg implementation.
+	echo
+	eselect opengl set --use-old ${OPENGL_DIR}
+
+	# Switch to mesa opencl
+	if use opencl; then
+		eselect opencl set --use-old ${PN}
+	fi
+
+	# warn about patent encumbered texture-float
+	if use !bindist; then
+		elog "USE=\"bindist\" was not set. Potentially patent encumbered code was"
+		elog "enabled. Please see /usr/share/doc/${P}/patents.txt.bz2 for an"
+		elog "explanation."
+	fi
+}
+
+# $1 - VIDEO_CARDS flag
+# other args - names of DRI drivers to enable
+# TODO: avoid code duplication for a more elegant implementation
+driver_enable() {
+	case $# in
+		# for enabling unconditionally
+		1)
+			DRI_DRIVERS+=",$1"
+			;;
+		*)
+			if use $1; then
+				shift
+				for i in $@; do
+					DRI_DRIVERS+=",${i}"
+				done
+			fi
+			;;
+	esac
+}
+
+gallium_enable() {
+	case $# in
+		# for enabling unconditionally
+		1)
+			GALLIUM_DRIVERS+=",$1"
+			;;
+		*)
+			if use $1; then
+				shift
+				for i in $@; do
+					GALLIUM_DRIVERS+=",${i}"
+				done
+			fi
+			;;
+	esac
+}
+
+vulkan_enable() {
+	case $# in
+		# for enabling unconditionally
+		1)
+			VULKAN_DRIVERS+=",$1"
+			;;
+		*)
+			if use $1; then
+				shift
+				for i in $@; do
+					VULKAN_DRIVERS+=",${i}"
+				done
+			fi
+			;;
+	esac
+}

diff --git a/media-libs/mesa/mesa-18.2.8.ebuild b/media-libs/mesa/mesa-18.2.1.ebuild
similarity index 89%
copy from media-libs/mesa/mesa-18.2.8.ebuild
copy to media-libs/mesa/mesa-18.2.1.ebuild
index 39fa4bc..e128919 100644
--- a/media-libs/mesa/mesa-18.2.8.ebuild
+++ b/media-libs/mesa/mesa-18.2.1.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2018 Gentoo Authors
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=6
@@ -20,7 +20,7 @@ if [[ ${PV} == 9999 ]]; then
 	inherit git-r3
 else
 	SRC_URI="https://mesa.freedesktop.org/archive/${MY_P}.tar.xz"
-	KEYWORDS="amd64 arm ~arm64 ~mips ppc x86"
+	KEYWORDS="~amd64 ~arm ~arm64 ~mips ~ppc ~x86"
 fi
 
 LICENSE="MIT"
@@ -41,7 +41,7 @@ IUSE="${IUSE_VIDEO_CARDS}
 	vulkan wayland xa xvmc"
 
 REQUIRED_USE="
-	d3d9?   ( dri3 || ( video_cards_r300 video_cards_r600 video_cards_radeonsi video_cards_nouveau video_cards_vmware ) )
+	d3d9?   ( dri3 )
 	gles1?  ( egl )
 	gles2?  ( egl )
 	vulkan? ( dri3
@@ -95,7 +95,7 @@ RDEPEND="
 		)
 		lm_sensors? ( sys-apps/lm_sensors:=[${MULTILIB_USEDEP}] )
 		opencl? (
-					dev-libs/ocl-icd[khronos-headers,${MULTILIB_USEDEP}]
+					app-eselect/eselect-opencl
 					dev-libs/libclc
 					virtual/libelf:0=[${MULTILIB_USEDEP}]
 				)
@@ -231,15 +231,6 @@ x86? (
 	)
 )"
 
-PATCHES=(
-	"${FILESDIR}"/${PN}-17-execinfo.patch
-	"${FILESDIR}"/${PN}-17-musl-string_h.patch
-	"${FILESDIR}"/${PN}-18-musl-invocation_name.patch
-	"${FILESDIR}"/${PN}-18-musl-pthread.patch
-	"${FILESDIR}"/${PN}-18-musl-amdgpu-include-pthread.patch
-	"${FILESDIR}"/${PN}-18-musl-larger-stacksize.patch
-)
-
 llvm_check_deps() {
 	local flags=${MULTILIB_USEDEP}
 	if use video_cards_r600 || use video_cards_radeon || use video_cards_radeonsi
@@ -254,6 +245,16 @@ llvm_check_deps() {
 }
 
 pkg_pretend() {
+	if use d3d9; then
+		if ! use video_cards_r300 &&
+		   ! use video_cards_r600 &&
+		   ! use video_cards_radeonsi &&
+		   ! use video_cards_nouveau &&
+		   ! use video_cards_vmware; then
+			ewarn "Ignoring USE=d3d9       since VIDEO_CARDS does not contain r300, r600, radeonsi, nouveau, or vmware"
+		fi
+	fi
+
 	if use opencl; then
 		if ! use video_cards_r600 &&
 		   ! use video_cards_radeonsi; then
@@ -294,6 +295,7 @@ pkg_pretend() {
 	fi
 
 	if ! use gallium; then
+		use d3d9       && ewarn "Ignoring USE=d3d9       since USE does not contain gallium"
 		use lm_sensors && ewarn "Ignoring USE=lm_sensors since USE does not contain gallium"
 		use llvm       && ewarn "Ignoring USE=llvm       since USE does not contain gallium"
 		use opencl     && ewarn "Ignoring USE=opencl     since USE does not contain gallium"
@@ -322,6 +324,16 @@ pkg_setup() {
 	python-any-r1_pkg_setup
 }
 
+src_prepare() {
+	eapply "${FILESDIR}"/${PN}-17-execinfo.patch
+	eapply "${FILESDIR}"/${PN}-17-musl-string_h.patch
+	eapply "${FILESDIR}"/${PN}-18-musl-invocation_name.patch
+	eapply "${FILESDIR}"/${PN}-18-musl-pthread.patch
+	#eapply "${FILESDIR}"/${PN}-18-intel-missing-time_t.patch
+	eapply "${FILESDIR}"/${PN}-18-musl-amdgpu-include-pthread.patch
+	eapply_user
+}
+
 multilib_src_configure() {
 	local emesonargs=()
 
@@ -422,12 +434,14 @@ multilib_src_configure() {
 		fi
 
 		gallium_enable video_cards_freedreno freedreno
-		gallium_enable video_cards_virgl virgl
-
 		# opencl stuff
-		emesonargs+=(
-			-Dgallium-opencl="$(usex opencl icd disabled)"
-		)
+		if use opencl; then
+			emesonargs+=(
+				-Dgallium-opencl="$(usex opencl standalone disabled)"
+			)
+		fi
+
+		gallium_enable video_cards_virgl virgl
 	fi
 
 	if use vulkan; then
@@ -484,6 +498,21 @@ multilib_src_compile() {
 
 multilib_src_install() {
 	meson_src_install
+
+	if use opencl; then
+		ebegin "Moving Gallium/Clover OpenCL implementation for dynamic switching"
+		local cl_dir="/usr/$(get_libdir)/OpenCL/vendors/mesa"
+		dodir ${cl_dir}/{lib,include}
+		if [ -f "${ED}/usr/$(get_libdir)/libOpenCL.so" ]; then
+			mv -f "${ED}"/usr/$(get_libdir)/libOpenCL.so* \
+			"${ED}"${cl_dir}
+		fi
+		if [ -f "${ED}/usr/include/CL/opencl.h" ]; then
+			mv -f "${ED}"/usr/include/CL \
+			"${ED}"${cl_dir}/include
+		fi
+		eend $?
+	fi
 }
 
 multilib_src_install_all() {
@@ -498,6 +527,11 @@ pkg_postinst() {
 	# Switch to the xorg implementation.
 	echo
 	eselect opengl set --use-old ${OPENGL_DIR}
+
+	# Switch to mesa opencl
+	if use opencl; then
+		eselect opencl set --use-old ${PN}
+	fi
 }
 
 # $1 - VIDEO_CARDS flag (check skipped for "--")

diff --git a/media-libs/mesa/mesa-18.2.8.ebuild b/media-libs/mesa/mesa-18.2.4.ebuild
similarity index 96%
rename from media-libs/mesa/mesa-18.2.8.ebuild
rename to media-libs/mesa/mesa-18.2.4.ebuild
index 39fa4bc..ab4c917 100644
--- a/media-libs/mesa/mesa-18.2.8.ebuild
+++ b/media-libs/mesa/mesa-18.2.4.ebuild
@@ -20,7 +20,7 @@ if [[ ${PV} == 9999 ]]; then
 	inherit git-r3
 else
 	SRC_URI="https://mesa.freedesktop.org/archive/${MY_P}.tar.xz"
-	KEYWORDS="amd64 arm ~arm64 ~mips ppc x86"
+	KEYWORDS="~amd64 ~arm ~arm64 ~mips ~ppc ~x86"
 fi
 
 LICENSE="MIT"
@@ -41,7 +41,7 @@ IUSE="${IUSE_VIDEO_CARDS}
 	vulkan wayland xa xvmc"
 
 REQUIRED_USE="
-	d3d9?   ( dri3 || ( video_cards_r300 video_cards_r600 video_cards_radeonsi video_cards_nouveau video_cards_vmware ) )
+	d3d9?   ( dri3 )
 	gles1?  ( egl )
 	gles2?  ( egl )
 	vulkan? ( dri3
@@ -232,12 +232,12 @@ x86? (
 )"
 
 PATCHES=(
+	"${FILESDIR}"/${P}-meson-link-gallium-nine-with-pthreads.patch
 	"${FILESDIR}"/${PN}-17-execinfo.patch
 	"${FILESDIR}"/${PN}-17-musl-string_h.patch
 	"${FILESDIR}"/${PN}-18-musl-invocation_name.patch
 	"${FILESDIR}"/${PN}-18-musl-pthread.patch
 	"${FILESDIR}"/${PN}-18-musl-amdgpu-include-pthread.patch
-	"${FILESDIR}"/${PN}-18-musl-larger-stacksize.patch
 )
 
 llvm_check_deps() {
@@ -254,6 +254,16 @@ llvm_check_deps() {
 }
 
 pkg_pretend() {
+	if use d3d9; then
+		if ! use video_cards_r300 &&
+		   ! use video_cards_r600 &&
+		   ! use video_cards_radeonsi &&
+		   ! use video_cards_nouveau &&
+		   ! use video_cards_vmware; then
+			ewarn "Ignoring USE=d3d9       since VIDEO_CARDS does not contain r300, r600, radeonsi, nouveau, or vmware"
+		fi
+	fi
+
 	if use opencl; then
 		if ! use video_cards_r600 &&
 		   ! use video_cards_radeonsi; then
@@ -294,6 +304,7 @@ pkg_pretend() {
 	fi
 
 	if ! use gallium; then
+		use d3d9       && ewarn "Ignoring USE=d3d9       since USE does not contain gallium"
 		use lm_sensors && ewarn "Ignoring USE=lm_sensors since USE does not contain gallium"
 		use llvm       && ewarn "Ignoring USE=llvm       since USE does not contain gallium"
 		use opencl     && ewarn "Ignoring USE=opencl     since USE does not contain gallium"

diff --git a/media-libs/mesa/metadata.xml b/media-libs/mesa/metadata.xml
index ea7584d..f978f99 100644
--- a/media-libs/mesa/metadata.xml
+++ b/media-libs/mesa/metadata.xml
@@ -6,6 +6,7 @@
 		<name>X11</name>
 	</maintainer>
 	<use>
+		<flag name="bindist">Disable patent-encumbered ARB_texture_float, EXT_texture_shared_exponent, and EXT_packed_float extensions.</flag>
 		<flag name="classic">Build drivers based on the classic architecture.</flag>
 		<flag name="d3d9">Enable Direct 3D9 API through Nine state tracker. Can be used together with patched wine.</flag>
 		<flag name="dri3">Enable DRI3 support.</flag>


             reply	other threads:[~2019-01-27 17:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-27 17:52 Anthony G. Basile [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-07-19  1:08 [gentoo-commits] proj/musl:master commit in: media-libs/mesa/files/, media-libs/mesa/ Anthony G. Basile
2021-08-20 14:14 Jory Pratt
2021-07-06 13:17 Jory Pratt
2021-03-10 15:06 Jory Pratt
2020-09-19 12:45 Jory Pratt
2020-03-09  0:53 Jory Pratt
2019-11-06 19:35 Jory Pratt
2019-08-11 22:46 Jory Pratt
2019-07-02 17:27 Jory Pratt
2019-01-23 19:29 Anthony G. Basile
2018-11-09 13:16 Anthony G. Basile
2018-10-29 11:48 Anthony G. Basile
2018-10-05  0:12 Anthony G. Basile
2018-07-08 21:58 Anthony G. Basile
2018-01-24 21:25 Aric Belsito
2017-12-29 22:23 Aric Belsito
2017-12-13  0:50 Aric Belsito
2017-12-11 22:29 Aric Belsito
2017-05-10  0:41 Aric Belsito
2016-03-14  2:22 Anthony G. Basile

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1548611525.7a73006b48b30e36d961bd1417b1e7d5cc3e554f.blueness@gentoo \
    --to=blueness@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox