[at-spi2-core/wip/lantw/meson-only-link-to-libdl-when-it-is-necessary] meson: Only link to libdl when it is necessary



commit 67b167aa7c9c6b4ecf542f4c2d584ef48cdea3f8
Author: Ting-Wei Lan <lantw src gnome org>
Date:   Mon Sep 2 22:18:52 2019 +0800

    meson: Only link to libdl when it is necessary
    
    Recent FreeBSD releases add libdl to the system, which just includes a
    few stub functions already included in libc. Since it only exists for
    GNU/Linux compatibility and does nothing useful, it may be better to
    avoid linking to it when dlopen can be found in libc.
    
    This commit modifies the libdl check to mimic the code in the removed
    configure.ac file, so libdl is only used when dlopen can't be found
    without using -ldl.

 meson.build | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/meson.build b/meson.build
index 0834d1f..9939180 100644
--- a/meson.build
+++ b/meson.build
@@ -52,7 +52,13 @@ libdbus_dep = dependency('dbus-1', version: libdbus_req_version)
 glib_dep = dependency('glib-2.0', version: glib_req_version)
 gobject_dep = dependency('gobject-2.0', version: gobject_req_version)
 gio_dep = dependency('gio-2.0', version: gio_req_version)
-dl_dep = cc.find_library('dl', required: false)
+if cc.has_function('dlopen')
+  dl_dep = []
+elif cc.has_function('dlopen', args: '-ldl')
+  dl_dep = cc.find_library('dl')
+else
+  error('Could not find a library with the dlopen function')
+endif
 
 x11_deps = []
 x11_option = get_option('x11')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]