diff --git a/configure.ac b/configure.ac index 368a59ce..7e35f1be 100644 --- a/configure.ac +++ b/configure.ac @@ -119,6 +119,7 @@ AS_IF([test "x$with_zstd" != "xno"], [ ]) CC_FEATURE_APPEND([with_features], [with_zstd], [ZSTD]) AM_CONDITIONAL([ENABLE_ZSTD], [test "x$with_zstd" != "xno"]) +AC_DEFINE([ENABLE_ZSTD_DLOPEN], [0], [dlopen zstd]) AC_ARG_WITH([xz], AS_HELP_STRING([--with-xz], [handle Xz-compressed modules @<:@default=disabled@:>@]), @@ -133,6 +134,7 @@ AS_IF([test "x$with_xz" != "xno"], [ ]) CC_FEATURE_APPEND([with_features], [with_xz], [XZ]) AM_CONDITIONAL([ENABLE_XZ], [test "x$with_xz" != "xno"]) +AC_DEFINE([ENABLE_XZ_DLOPEN], [0], [dlopen xz]) AC_ARG_WITH([zlib], AS_HELP_STRING([--with-zlib], [handle gzipped modules @<:@default=disabled@:>@]), @@ -147,6 +149,7 @@ AS_IF([test "x$with_zlib" != "xno"], [ ]) CC_FEATURE_APPEND([with_features], [with_zlib], [ZLIB]) AM_CONDITIONAL([ENABLE_ZLIB], [test "x$with_zlib" != "xno"]) +AC_DEFINE([ENABLE_ZLIB_DLOPEN], [0], [dlopen zlib]) AC_ARG_WITH([openssl], AS_HELP_STRING([--with-openssl], [handle PKCS7 signatures @<:@default=disabled@:>@]), diff --git a/libkmod/libkmod-file-xz.c b/libkmod/libkmod-file-xz.c index 3f44b43d..f769f835 100644 --- a/libkmod/libkmod-file-xz.c +++ b/libkmod/libkmod-file-xz.c @@ -3,8 +3,7 @@ * Copyright © 2024 Intel Corporation */ -/* TODO: replace with build system define once supported */ -#define DLSYM_LOCALLY_ENABLED 0 +#define DLSYM_LOCALLY_ENABLED ENABLE_XZ_DLOPEN #include #include diff --git a/libkmod/libkmod-file-zlib.c b/libkmod/libkmod-file-zlib.c index fd382939..f8ead1b9 100644 --- a/libkmod/libkmod-file-zlib.c +++ b/libkmod/libkmod-file-zlib.c @@ -3,8 +3,7 @@ * Copyright © 2024 Intel Corporation */ -/* TODO: replace with build system define once supported */ -#define DLSYM_LOCALLY_ENABLED 0 +#define DLSYM_LOCALLY_ENABLED ENABLE_ZLIB_DLOPEN #include #include diff --git a/libkmod/libkmod-file-zstd.c b/libkmod/libkmod-file-zstd.c index 5bccf761..a2eece7d 100644 --- a/libkmod/libkmod-file-zstd.c +++ b/libkmod/libkmod-file-zstd.c @@ -3,8 +3,7 @@ * Copyright © 2024 Intel Corporation */ -/* TODO: replace with build system define once supported */ -#define DLSYM_LOCALLY_ENABLED 0 +#define DLSYM_LOCALLY_ENABLED ENABLE_ZSTD_DLOPEN #include #include diff --git a/meson.build b/meson.build index 25029d6c..64288dd9 100644 --- a/meson.build +++ b/meson.build @@ -176,6 +176,9 @@ module_signatures = '' features = [] dep_map = {} +# keep in sync with meson_options.txt +dlopen_all = get_option('dlopen').contains('all') + #------------------------------------------------------------------------------- # Directories #------------------------------------------------------------------------------- @@ -299,10 +302,19 @@ foreach tuple : _compression pkg_dep = tuple[1] pkg_dep_version = tuple[2] + dlopen = dlopen_all or get_option('dlopen').contains(opt) + if not dlopen_all and dlopen and get_option(opt).disabled() + error('Incompatiable options: dlopen=@0@ for disabled @0@'.format(opt)) + endif + dep = dependency(pkg_dep, version : pkg_dep_version, required : get_option(opt)) have = dep.found() + if have and dlopen + dep = dep.partial_dependency(compile_args : true, includes : true) + endif cdata.set10('ENABLE_' + opt.to_upper(), have) + cdata.set10('ENABLE_' + opt.to_upper() + '_DLOPEN', have and dlopen) if have module_compressions += '@0@ '.format(opt) @@ -567,6 +579,7 @@ summary({ 'build-tests' : get_option('build-tests'), 'manpages' : get_option('manpages'), 'docs' : get_option('docs'), + 'dlopen' : get_option('dlopen'), }, section : 'Options') summary({ diff --git a/meson_options.txt b/meson_options.txt index 0522d95c..3d41fae2 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -67,6 +67,14 @@ option( description : 'Build the tools - kmod, depmod, lsmod ... Default: true', ) +option( + 'dlopen', + type : 'array', + choices : ['zstd', 'xz', 'zlib', 'all'], + value : [], + description : 'Libraries to dlopen rather than linking. Use \'all\' to . Default: none', +) + option( 'logging', type : 'boolean',