Add a dlopen option that allows toggling what libraries libkmod should
attempt to dlopen. If -Ddlopen=foo is passed, it means that library is
required to build, regardless of -Dfoo=*. However that library will
only be linked in if it's not set as dlopen.
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
[ with disagreement on the need to toggle each one individually,
it'd be better to be all-or-nothing dlopen'ed ]
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/262
])
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@:>@]),
])
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@:>@]),
])
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@:>@]),
* 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 <errno.h>
#include <lzma.h>
* 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 <errno.h>
#include <stdio.h>
* 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 <errno.h>
#include <stdio.h>
features = []
dep_map = {}
+# keep in sync with meson_options.txt
+dlopen_all = get_option('dlopen').contains('all')
+
#-------------------------------------------------------------------------------
# Directories
#-------------------------------------------------------------------------------
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)
'build-tests' : get_option('build-tests'),
'manpages' : get_option('manpages'),
'docs' : get_option('docs'),
+ 'dlopen' : get_option('dlopen'),
}, section : 'Options')
summary({
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',