[PATCH v2 vkd3d 6/8] build: Detect soname of libvulkan at configure time.

Józef Kucia joseph.kucia at gmail.com
Tue Aug 21 11:08:04 CDT 2018

From: Chip Davis <cdavis at codeweavers.com>

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>

Version 2: Remove usage of $LIBEXT.

 configure.ac        |  6 +++---
 libs/vkd3d/device.c |  4 ++--
 m4/check-soname.m4  | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 59 insertions(+), 5 deletions(-)
 create mode 100644 m4/check-soname.m4

diff --git a/configure.ac b/configure.ac
index b5123b8d11de..90557ee42e68 100644
--- a/configure.ac
+++ b/configure.ac
@@ -77,9 +77,9 @@ AC_CHECK_LIB([pthread], [pthread_create],
              [AC_MSG_ERROR([libpthread not found.])])
-AC_CHECK_LIB([vulkan], [vkGetInstanceProcAddr],
-             [VULKAN_LIBS="-lvulkan"],
-             [AC_MSG_ERROR([libvulkan not found.])])
+VKD3D_CHECK_SONAME([vulkan], [vkGetInstanceProcAddr],
+                   [VULKAN_LIBS="-lvulkan"],
+                   [AC_MSG_ERROR([libvulkan not found.])])
 AS_IF([test "x$with_spirv_tools" = "xyes"],
       [PKG_CHECK_MODULES([SPIRV_TOOLS], [SPIRV-Tools-shared],
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index 8280fd5d03be..c11f474a28d2 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -283,9 +283,9 @@ static HRESULT vkd3d_init_vk_global_procs(struct vkd3d_instance *instance,
     if (!vkGetInstanceProcAddr)
-        if (!(instance->libvulkan = dlopen("libvulkan.so.1", RTLD_NOW)))
+        if (!(instance->libvulkan = dlopen(SONAME_LIBVULKAN, RTLD_NOW)))
-            ERR("Failed to load libvulkan.\n");
+            ERR("Failed to load libvulkan: %s.\n", dlerror());
             return E_FAIL;
diff --git a/m4/check-soname.m4 b/m4/check-soname.m4
new file mode 100644
index 000000000000..f1953413fa75
--- /dev/null
+++ b/m4/check-soname.m4
@@ -0,0 +1,54 @@
+dnl Copyright 2002 Alexandre Julliard
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License, or (at your option) any later version.
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl Lesser General Public License for more details.
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+dnl As a special exception to the GNU Lesser General Public License,
+dnl if you distribute this file as part of a program that contains a
+dnl configuration script generated by Autoconf, you may include it
+dnl under the same distribution terms that you use for the rest of
+dnl that program.
+dnl VKD3D_CHECK_SONAME(library, function, [action-if-found, [action-if-not-found, [other_libraries, [pattern]]]])
+AC_MSG_CHECKING([for -l$1])
+  LIBS="-l$1 $5 $LIBS"
+  [AS_CASE(["$host_os"],
+           [darwin*|macosx*], [AS_VAR_SET(ac_Lib,[`$OTOOL -L conftest$ac_exeext | grep "]ac_lib_pattern[\\.[[0-9A-Za-z.]]*dylib" | sed -e "s/^.*\/\(]ac_lib_pattern[\.[[0-9A-Za-z.]]*dylib\).*$/\1/"';2,$d'`])],
+           [AS_VAR_SET(ac_Lib,[`$READELF -d conftest$ac_exeext | grep "NEEDED.*]ac_lib_pattern[" | sed -e "s/^.*\\m4_dquote(\\(]ac_lib_pattern[[[^	 ]]*\\)\\).*$/\1/"';2,$d'`])
+            AS_VAR_IF([ac_Lib],[],
+                     [AS_VAR_SET(ac_Lib,[`$LDD conftest$ac_exeext | grep "]ac_lib_pattern[" | sed -e "s/^.*\(]ac_lib_pattern[[[^	 ]]*\).*$/\1/"';2,$d'`])])])])
+  LIBS=$ac_check_soname_save_LIBS])dnl
+      [AC_MSG_RESULT([not found])
+       $4],
+      [AC_MSG_RESULT(AS_VAR_GET(ac_Lib))
+                          [Define to the soname of the lib$1 library.])
+       $3])dnl

More information about the wine-devel mailing list