new custom dependency lookup for libdl

This commit is contained in:
Andrew Krasavin 2022-02-01 06:13:09 +03:00 committed by Eli Schwartz
parent 248e6cf473
commit b564e34221
4 changed files with 47 additions and 0 deletions

View File

@ -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)*

View File

@ -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).

View File

@ -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,

View File

@ -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],