aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/markdown/Dependencies.md11
-rw-r--r--docs/markdown/snippets/libdl-dependency.md8
-rw-r--r--mesonbuild/dependencies/__init__.py2
-rw-r--r--mesonbuild/dependencies/misc.py26
4 files changed, 47 insertions, 0 deletions
diff --git a/docs/markdown/Dependencies.md b/docs/markdown/Dependencies.md
index 0cbed5c..9dabef8 100644
--- a/docs/markdown/Dependencies.md
+++ b/docs/markdown/Dependencies.md
@@ -393,6 +393,17 @@ foreach h : check_headers
endforeach
```
+## dl (libdl)
+
+*(added 0.62.0)*
+
+Provides access to the dynamic link interface (functions: dlopen,
+dlclose, dlsym and others). On systems where this is not built
+into libc (mostly glibc < 2.34), tries to find an external library
+providing them instead.
+
+`method` may be `auto`, `builtin` or `system`.
+
## Fortran Coarrays
*(added 0.50.0)*
diff --git a/docs/markdown/snippets/libdl-dependency.md b/docs/markdown/snippets/libdl-dependency.md
new file mode 100644
index 0000000..fee780c
--- /dev/null
+++ b/docs/markdown/snippets/libdl-dependency.md
@@ -0,0 +1,8 @@
+## New custom dependency for libdl
+
+```
+dependency('dl')
+```
+
+will now check for the functionality of libdl.so, but first check if it is
+provided in the libc (for example in libc on OpenBSD or in musl libc on linux).
diff --git a/mesonbuild/dependencies/__init__.py b/mesonbuild/dependencies/__init__.py
index ff0bd30..b0c25b1 100644
--- a/mesonbuild/dependencies/__init__.py
+++ b/mesonbuild/dependencies/__init__.py
@@ -36,6 +36,7 @@ from .misc import (
BlocksDependency, OpenMPDependency, cups_factory, curses_factory, gpgme_factory,
libgcrypt_factory, libwmf_factory, netcdf_factory, pcap_factory, python3_factory,
shaderc_factory, threads_factory, ThreadDependency, iconv_factory, intl_factory,
+ dl_factory
)
from .platform import AppleFrameworks
from .qt import qt4_factory, qt5_factory, qt6_factory
@@ -254,6 +255,7 @@ packages.update({
'shaderc': shaderc_factory,
'iconv': iconv_factory,
'intl': intl_factory,
+ 'dl': dl_factory,
# From platform:
'appleframeworks': AppleFrameworks,
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py
index 470305e..c95f7da 100644
--- a/mesonbuild/dependencies/misc.py
+++ b/mesonbuild/dependencies/misc.py
@@ -60,6 +60,25 @@ def netcdf_factory(env: 'Environment',
return candidates
+class DlBuiltinDependency(BuiltinDependency):
+ def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]):
+ super().__init__(name, env, kwargs)
+
+ if self.clib_compiler.has_function('dlopen', '#include <dlfcn.h>', env)[0]:
+ self.is_found = True
+
+
+class DlSystemDependency(SystemDependency):
+ def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]):
+ super().__init__(name, env, kwargs)
+
+ h = self.clib_compiler.has_header('dlfcn.h', '', env)
+ self.link_args = self.clib_compiler.find_library('dl', env, [], self.libtype)
+
+ if h[0] and self.link_args:
+ self.is_found = True
+
+
class OpenMPDependency(SystemDependency):
# Map date of specification release (which is the macro value) to a version.
VERSIONS = {
@@ -559,6 +578,13 @@ cups_factory = DependencyFactory(
cmake_name='Cups',
)
+dl_factory = DependencyFactory(
+ 'dl',
+ [DependencyMethods.BUILTIN, DependencyMethods.SYSTEM],
+ builtin_class=DlBuiltinDependency,
+ system_class=DlSystemDependency,
+)
+
gpgme_factory = DependencyFactory(
'gpgme',
[DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL],