Load this library instead of always loading libvulkan.so.1.
Signed-off-by: Chip Davis cdavis@codeweavers.com ---
Notes: I cribbed WINE_CHECK_SONAME for this.
configure.ac | 6 ++--- libs/vkd3d/device.c | 2 +- m4/check-soname.m4 | 55 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 m4/check-soname.m4
diff --git a/configure.ac b/configure.ac index e4d0d24..6eb8a76 100644 --- a/configure.ac +++ b/configure.ac @@ -75,9 +75,9 @@ AC_CHECK_LIB([pthread], [pthread_create], [AC_MSG_ERROR([libpthread not found.])])
AC_SUBST([VULKAN_LIBS]) -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.])])
HAVE_SPIRV_TOOLS=no AS_IF([test "x$with_spirv_tools" = "xyes"], diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 6fa0017..047c298 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -212,7 +212,7 @@ 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"); return E_FAIL; diff --git a/m4/check-soname.m4 b/m4/check-soname.m4 new file mode 100644 index 0000000..94efc4b --- /dev/null +++ b/m4/check-soname.m4 @@ -0,0 +1,55 @@ +dnl +dnl Copyright 2002 Alexandre Julliard +dnl +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 +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 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +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 +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_PATH_SONAME_TOOLS +AC_DEFUN([VKD3D_PATH_SONAME_TOOLS], +[AC_PATH_PROG(LDD,ldd,true,/sbin:/usr/sbin:$PATH) +AC_CHECK_TOOL(OTOOL,otool,otool) +AC_CHECK_TOOL(READELF,[readelf],true)]) + +dnl VKD3D_CHECK_SONAME(library, function, [action-if-found, [action-if-not-found, [other_libraries, [pattern]]]]) +dnl +AC_DEFUN([VKD3D_CHECK_SONAME], +[AC_REQUIRE([VKD3D_PATH_SONAME_TOOLS])dnl +AS_VAR_PUSHDEF([ac_Lib],[ac_cv_lib_soname_$1])dnl +m4_pushdef([ac_lib_pattern],m4_default([$6],[lib$1]))dnl +AC_MSG_CHECKING([for -l$1]) +AC_CACHE_VAL(ac_Lib, +[ac_check_soname_save_LIBS=$LIBS + LIBS="-l$1 $5 $LIBS" + AC_LINK_IFELSE([AC_LANG_CALL([], [$2])], + [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[\.$LIBEXT" | sed -e "s/^.*\m4_dquote(\(]ac_lib_pattern[\.$LIBEXT[[^ ]]*\)\).*$/\1/"';2,$d'`]) + AS_VAR_IF([ac_Lib],[], + [AS_VAR_SET(ac_Lib,[`$LDD conftest$ac_exeext | grep "]ac_lib_pattern[\.$LIBEXT" | sed -e "s/^.*(]ac_lib_pattern[.$LIBEXT[[^ ]]*).*$/\1/"';2,$d'`])])])]) + LIBS=$ac_check_soname_save_LIBS])dnl +AS_VAR_IF([ac_Lib],[], + [AC_MSG_RESULT([not found]) + $4], + [AC_MSG_RESULT(AS_VAR_GET(ac_Lib)) + AC_DEFINE_UNQUOTED(AS_TR_CPP(SONAME_LIB$1),["]AS_VAR_GET(ac_Lib)["], + [Define to the soname of the lib$1 library.]) + $3])dnl +m4_popdef([ac_lib_pattern])dnl +AS_VAR_POPDEF([ac_Lib])])