From 16875ea5b9170f2213fd486d763f27a9d6dfc1b5 Mon Sep 17 00:00:00 2001
From: Nicolas Chauvet <kwizart@gmail.com>
Date: Tue, 25 Oct 2016 09:35:13 +0200
Subject: [PATCH 1/3] glapi: Link with glapi when built shared

This patch explicitly links to libglapi when built shared.
This was specially needed to avoid undefined non-weak-symbol as shown
with:

ldd  -r /usr/lib64/dri/i915_dri.so
	linux-vdso.so.1 (0x00007fff821f4000)
	libdrm_intel.so.1 => /lib64/libdrm_intel.so.1 (0x00007f6adf2c7000)
	libdrm_nouveau.so.2 => /lib64/libdrm_nouveau.so.2 (0x00007f6adf0be000)
	libdrm_radeon.so.1 => /lib64/libdrm_radeon.so.1 (0x00007f6adeeb2000)
	libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f6adec8b000)
	libdrm.so.2 => /lib64/libdrm.so.2 (0x00007f6adea7c000)
	libexpat.so.1 => /lib64/libexpat.so.1 (0x00007f6ade84f000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f6ade633000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f6ade42f000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f6ade125000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f6addf0e000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f6addb4c000)
	/lib64/ld-linux-x86-64.so.2 (0x000056274e913000)
	libpciaccess.so.0 => /lib64/libpciaccess.so.0 (0x00007f6add941000)
	libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f6add6ce000)
undefined symbol: _glapi_get_dispatch_table_size	(/usr/lib64/dri/i915_dri.so)
undefined symbol: _glapi_get_context	(/usr/lib64/dri/i915_dri.so)
undefined symbol: _glapi_add_dispatch	(/usr/lib64/dri/i915_dri.so)
undefined symbol: _glapi_check_multithread	(/usr/lib64/dri/i915_dri.so)
undefined symbol: _glapi_tls_Context	(/usr/lib64/dri/i915_dri.so)
undefined symbol: _glapi_set_context	(/usr/lib64/dri/i915_dri.so)
undefined symbol: _glapi_set_dispatch	(/usr/lib64/dri/i915_dri.so)
undefined symbol: _glapi_tls_Dispatch	(/usr/lib64/dri/i915_dri.so)

v3: Add gallium counterpart for radeon cases
Reported-by: Jonathan Dieter <jdieter@lesbg.com>

v2: Add Bugzilla and Signed-off

Fixes: 0cbc90c57c ("mesa: dri: Add shared glapi to LIBADD on Android")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98428
Signed-off-by: Nicolas Chauvet <kwizart@gmail.com>
---
 src/gallium/targets/dri/Makefile.am | 2 --
 src/mesa/drivers/dri/Makefile.am    | 3 ---
 2 files changed, 5 deletions(-)

diff --git a/src/gallium/targets/dri/Makefile.am b/src/gallium/targets/dri/Makefile.am
index bca747f..05f6c8c 100644
--- a/src/gallium/targets/dri/Makefile.am
+++ b/src/gallium/targets/dri/Makefile.am
@@ -1,10 +1,8 @@
 include $(top_srcdir)/src/gallium/Automake.inc
 
-if HAVE_ANDROID
 if HAVE_SHARED_GLAPI
 SHARED_GLAPI_LIB = $(top_builddir)/src/mapi/shared-glapi/libglapi.la
 endif
-endif
 
 AM_CFLAGS = \
 	-I$(top_srcdir)/src/mapi \
diff --git a/src/mesa/drivers/dri/Makefile.am b/src/mesa/drivers/dri/Makefile.am
index 1c6dd08..8e68fc0 100644
--- a/src/mesa/drivers/dri/Makefile.am
+++ b/src/mesa/drivers/dri/Makefile.am
@@ -6,12 +6,9 @@ MEGADRIVERS_DEPS =
 
 SUBDIRS+=common
 
-# On Android, we need to explicitly link to libglapi.so.
-if HAVE_ANDROID
 if HAVE_SHARED_GLAPI
 SHARED_GLAPI_LIB = $(top_builddir)/src/mapi/shared-glapi/libglapi.la
 endif
-endif
 
 if HAVE_I915_DRI
 SUBDIRS += i915
-- 
2.7.4
