1 # SPDX-License-Identifier: LGPL-2.1-or-later
19 meson_version: '>= 0.61')
21 cc = meson.get_compiler('c')
22 pkgconfig = import('pkgconfig')
26 liblxc_version = '1.7.0'
27 version_data = configuration_data()
28 version_data.set('LXC_VERSION_MAJOR', '5')
29 version_data.set('LXC_VERSION_MINOR', '0')
30 version_data.set('LXC_VERSION_MICRO', '0')
31 version_data.set('LXC_VERSION_BETA', '')
32 version_data.set('LXC_ABI', liblxc_version)
33 version_data.set('LXC_DEVEL', '1')
34 version_data.set('LXC_VERSION', meson.project_version())
37 project_source_root = meson.current_source_dir()
38 project_build_root = meson.current_build_dir()
39 prefixdir = get_option('prefix')
41 apparmorcachedir = get_option('apparmor-cache-path')
42 globalconfig = get_option('global-config-path')
43 localstatedir = join_paths('/', get_option('localstatedir'))
44 logpath = get_option('log-path')
45 lxcpathprefix = get_option('data-path')
46 rootfsmount = get_option('rootfs-mount-path')
47 user_network_db_opt = get_option('usernet-db-path')
48 user_network_conf_opt = get_option('usernet-config-path')
50 bashcompletiondir = join_paths('/', 'usr', 'share', 'bash-completion', 'completions')
51 bindir = join_paths(prefixdir, get_option('bindir'))
52 datadir = join_paths(prefixdir, get_option('datadir'))
53 mandir = join_paths(prefixdir, get_option('mandir'))
54 docdir = join_paths(datadir, get_option('doc-path'))
55 includedir = join_paths(prefixdir, get_option('includedir'))
56 libdir = join_paths(prefixdir, get_option('libdir'))
57 libexecdir = join_paths(prefixdir, get_option('libexecdir'))
58 runtimepath = join_paths(prefixdir, get_option('runtime-path'))
59 sbindir = join_paths(prefixdir, get_option('sbindir'))
60 sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
62 lxcapparmorcachedir = join_paths(localstatedir, apparmorcachedir)
63 lxcconfdir = join_paths(sysconfdir, globalconfig)
64 lxcdefaultconfig = join_paths(lxcconfdir, 'default.conf')
65 lxcglobalconfig = join_paths(lxcconfdir, 'lxc.conf')
66 lxcexamplesdir = join_paths(docdir, 'examples')
67 lxchookbindir = join_paths(libexecdir, 'lxc/hooks')
68 lxcinclude = join_paths(includedir, 'lxc')
69 lxclibexec = join_paths(libexecdir, 'lxc')
70 lxclogpath = join_paths(localstatedir, logpath)
71 lxcpath = join_paths(localstatedir, lxcpathprefix)
72 lxcrootfsmount = join_paths(libdir, rootfsmount)
73 lxcdatadir = join_paths(datadir, 'lxc')
74 lxchookdir = join_paths(lxcdatadir, 'hooks')
75 lxcselinuxdir = join_paths(lxcdatadir, 'selinux')
76 lxctemplateconfdir = join_paths(lxcdatadir, 'config')
77 lxctemplateconfcommondir = join_paths(lxctemplateconfdir, 'common.conf.d')
78 lxctemplatedir = join_paths(lxcdatadir, 'templates')
79 lxc_user_network_conf = join_paths(sysconfdir, user_network_conf_opt)
80 lxc_user_network_db = join_paths(runtimepath, user_network_db_opt)
81 pam_security = join_paths(libdir, 'security')
83 # Configuration options.
84 srcconf = configuration_data()
85 srcconf.set('_GNU_SOURCE', true)
86 srcconf.set('_FILE_OFFSET_BITS', 64)
87 srcconf.set('__STDC_FORMAT_MACROS', true)
89 ## This is a hack to prevent any inclusion ofr linux/mount.h which causes
90 ## conflicts with sys/mount.h all over the place
91 srcconf.set('_LINUX_MOUNT_H', true)
93 srcconf.set_quoted('APPARMOR_CACHE_DIR', lxcapparmorcachedir)
94 srcconf.set_quoted('LIBEXECDIR', libexecdir)
95 srcconf.set_quoted('LOGPATH', lxclogpath)
96 srcconf.set_quoted('LXC_DEFAULT_CONFIG', lxcdefaultconfig)
97 srcconf.set_quoted('LXC_GLOBAL_CONF', lxcglobalconfig)
98 srcconf.set_quoted('LXCINITDIR', libexecdir)
99 srcconf.set_quoted('LXCPATH', lxcpath)
100 srcconf.set_quoted('LXCROOTFSMOUNT', lxcrootfsmount)
101 srcconf.set_quoted('LXCTEMPLATECONFIG', lxctemplateconfdir)
102 srcconf.set_quoted('LXCTEMPLATECONFIG', lxctemplateconfdir)
103 srcconf.set_quoted('LXCTEMPLATEDIR', lxctemplatedir)
104 srcconf.set_quoted('LXC_USERNIC_CONF', lxc_user_network_conf)
105 srcconf.set_quoted('LXC_USERNIC_DB', lxc_user_network_db)
106 srcconf.set_quoted('RUNTIME_PATH', runtimepath)
107 srcconf.set_quoted('SBINDIR', sbindir)
109 conf = configuration_data()
110 conf.set('BINDIR', bindir)
111 conf.set('LIBEXECDIR', libexecdir)
112 conf.set('LOCALSTATEDIR', localstatedir)
113 conf.set('LXC_GLOBAL_CONF', lxcglobalconfig)
114 conf.set('LXCHOOKDIR', lxchookdir)
115 conf.set('LXCINITDIR', libexecdir)
116 conf.set('LXCROOTFSMOUNT', lxcrootfsmount)
117 conf.set('LXCTEMPLATECONFIG', lxctemplateconfdir)
118 conf.set('LXCTEMPLATEDIR', lxctemplatedir)
119 conf.set('PACKAGE_VERSION', meson.project_version())
120 conf.set('RUNTIME_PATH', runtimepath)
121 conf.set('SYSCONFDIR', sysconfdir)
125 distrosysconfdir = get_option('distrosysconfdir')
126 if distrosysconfdir != ''
127 distrosysconfdir = join_paths(sysconfdir, distrosysconfdir)
128 conf.set('LXC_DISTRO_SYSCONF', distrosysconfdir)
129 elif fs.is_dir('/etc/sysconfig')
130 distrosysconfdir = join_paths(sysconfdir, 'sysconfig')
131 conf.set('LXC_DISTRO_SYSCONF', distrosysconfdir)
132 elif fs.is_dir('/etc/default')
133 distrosysconfdir = join_paths(sysconfdir, 'default')
134 conf.set('LXC_DISTRO_SYSCONF', distrosysconfdir)
136 error('"distrosysconfdir" is not set')
139 # Cross-compile on Android.
140 srcconf.set10('IS_BIONIC', host_machine.system() == 'android')
142 # Custom configuration.
143 cgrouppattern = get_option('cgroup-pattern')
144 coverity = get_option('coverity-build')
145 init_script = get_option('init-script')
146 sanitize = get_option('b_sanitize')
147 want_examples = get_option('examples')
148 want_io_uring = get_option('io-uring-event-loop')
149 want_pam_cgroup = get_option('pam-cgroup')
150 want_mans = get_option('man')
151 want_tests = get_option('tests')
152 want_tools = get_option('tools')
153 want_tools_multicall = get_option('tools-multicall')
154 want_commands = get_option('commands')
155 want_capabilities = get_option('capabilities')
156 want_apparmor = get_option('apparmor')
157 want_openssl = get_option('openssl')
158 want_selinux = get_option('selinux')
159 want_oss_fuzz = get_option('oss-fuzz')
160 want_seccomp = get_option('seccomp')
161 want_thread_safety = get_option('thread-safety')
162 want_memfd_rexec = get_option('memfd-rexec')
163 want_sd_bus = get_option('sd-bus')
165 srcconf.set_quoted('DEFAULT_CGROUP_PATTERN', cgrouppattern)
167 srcconf.set('ENABLE_COVERITY_BUILD', 1)
170 dummy_config_data = configuration_data()
171 dummy_config_data.set_quoted('DUMMY_VARIABLE', '1')
173 # Those generate many false positives, and we do not want to change the code to
175 basic_disabled_warnings = [
176 '-Wno-format-signedness',
177 '-Wno-missing-field-initializers',
178 '-Wno-unused-parameter',
182 possible_cc_flags = [
184 '-Wimplicit-fallthrough=5',
186 '-Wstrict-prototypes',
187 '-fno-strict-aliasing',
188 '-fstack-clash-protection',
189 '--param=ssp-buffer-size=4',
190 '--mcet -fcf-protection',
191 '-Werror=implicit-function-declaration',
193 '-Wmissing-include-dirs',
194 '-Wold-style-definition',
196 '-Wunused-but-set-variable',
197 '-Wno-unused-parameter',
199 '-Wsuggest-attribute=noreturn',
200 '-Werror=return-type',
201 '-Werror=incompatible-pointer-types',
206 '-fdiagnostics-show-option',
207 '-Werror=shift-count-overflow',
208 '-Werror=shift-overflow=2',
211 '-fasynchronous-unwind-tables',
215 '-Wreturn-local-addr',
217 '-Wstringop-overflow',
220 possible_link_flags = [
226 '-fstack-protector-strong',
229 if sanitize == 'none'
230 possible_link_flags += '-Wl,--warn-common'
233 if cc.get_id() == 'clang'
234 possible_cc_flags += [
235 '-Wno-typedef-redefinition',
236 '-Wno-gnu-variable-sized-type-not-at-end',
240 if meson.version().version_compare('>=0.46')
241 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language: 'c')
243 add_project_link_arguments(possible_link_flags, language: 'c')
246 add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
247 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language: 'c')
249 if add_languages('cpp', required : want_oss_fuzz)
250 # Used only for tests
251 cxx = meson.get_compiler('cpp')
252 cxx_cmd = ' '.join(cxx.cmd_array())
253 add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
259 liburing = dependency('liburing')
260 if cc.has_function('io_uring_prep_poll_add', prefix: '#include <liburing.h>', dependencies: liburing) == false
261 error('liburing version does not support IORING_POLL_ADD_MULTI')
264 srcconf.set10('HAVE_LIBURING', true)
266 srcconf.set10('HAVE_LIBURING', false)
269 if not want_sd_bus.disabled()
271 sd_bus_optional = want_sd_bus.auto()
273 libsystemd = dependency('libsystemd', required: not sd_bus_optional)
274 if not libsystemd.found()
275 if not sd_bus_optional
276 error('missing required libsystemd dependency')
282 if not cc.has_header('systemd/sd-bus.h')
283 if not sd_bus_optional
284 error('libsystemd misses required systemd/sd-bus.h header')
290 if not cc.has_header('systemd/sd-event.h')
291 if not sd_bus_optional
292 error('libsystemd misses required systemd/sd-event.h header')
298 if not cc.has_function('sd_bus_call_method_async', prefix: '#include <systemd/sd-bus.h>', dependencies: libsystemd)
299 if not sd_bus_optional
300 error('libsystemd misses required sd_bus_call_method_async function')
306 srcconf.set10('HAVE_LIBSYSTEMD', has_sd_bus)
309 srcconf.set10('HAVE_LIBSYSTEMD', false)
313 sh = find_program('sh')
314 date = find_program('date')
315 git = find_program('git', required: false)
316 time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check: true).stdout().strip()
317 if time_epoch == '' and git.found() and run_command('test', '-e', '.git', check: false).returncode() == 0
318 # If we're in a git repository, use the creation time of the latest git tag.
319 latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags', check: false).stdout().strip()
321 time_epoch = run_command(git, 'log', '--no-show-signature', '-1', '--format=%at', latest_tag, check: true).stdout()
325 # Fallback to current epoch.
327 time_epoch = run_command(date, '+%s', check: true).stdout()
329 generate_date = run_command(date, '--utc', '--date=@' + time_epoch, '+%Y-%m-%d', check: true).stdout().strip()
332 docconf = configuration_data()
333 docconf.set('builddir', '.')
334 docconf.set('BINDIR', bindir)
335 docconf.set('DATADIR', datadir)
336 docconf.set('DOCDIR', docdir)
337 docconf.set('LOGPATH', lxclogpath)
338 docconf.set('LXC_DEFAULT_CONFIG', lxcdefaultconfig)
339 docconf.set('LXC_GENERATE_DATE', generate_date)
340 docconf.set('LXC_GLOBAL_CONF', lxcglobalconfig)
341 docconf.set('LXCPATH', lxcpath)
342 docconf.set('LXCTEMPLATEDIR', lxctemplatedir)
343 docconf.set('LXC_USERNIC_CONF', lxc_user_network_conf)
344 docconf.set('LXC_USERNIC_DB', lxc_user_network_db)
345 docconf.set('PACKAGE_VERSION', version_data.get('LXC_VERSION'))
346 docconf.set('docdtd', '"-//OASIS//DTD DocBook XML" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"')
347 sgml2man = find_program('docbook2X2man', 'docbook2x-man', 'db2x_docbook2man', 'docbook2man', 'docbook-to-man', required: false, version: '>=0.8')
348 if not sgml2man.found()
349 sgml2man = find_program('docbook2man', required: false, version: '<0.8')
351 docconf.set('docdtd', '"-//Davenport//DTD DocBook V3.0//EN"')
353 error('missing required docbook2x or docbook-utils dependency')
358 threads = dependency('threads')
362 libseccomp = dependency('libseccomp', required: false)
363 srcconf.set10('HAVE_SECCOMP', libseccomp.found())
364 pkgconfig_libs += libseccomp
365 if libseccomp.found()
366 if libseccomp.version().version_compare('>=2.5.0')
367 # https://github.com/seccomp/libseccomp/commit/dead12bc788b259b148cc4d93b970ef0bd602b1a
368 srcconf.set10('HAVE_DECL_SECCOMP_NOTIFY_FD', true)
370 srcconf.set10('HAVE_DECL_SECCOMP_NOTIFY_FD', false)
373 if libseccomp.version().version_compare('>=2.0.0')
374 # https://github.com/seccomp/libseccomp/commit/6220c8c0fc479d97b6d3e3166a4e46fbfe25a3c0
375 srcconf.set10('HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH', true)
377 srcconf.set10('HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH', false)
380 seccomp_headers = '''
386 'struct seccomp_notif_sizes',
390 # We get -1 if the size cannot be determined
391 if cc.sizeof(decl, prefix: seccomp_headers, args: '-D_GNU_SOURCE') > 0
392 srcconf.set10('HAVE_' + decl.underscorify().to_upper(), true)
394 srcconf.set10('HAVE_' + decl.underscorify().to_upper(), false)
399 srcconf.set10('HAVE_SECCOMP', false)
404 libselinux = dependency('libselinux', required: false)
405 srcconf.set10('HAVE_SELINUX', libselinux.found())
406 pkgconfig_libs += libselinux
408 srcconf.set10('HAVE_SELINUX', false)
413 libapparmor = dependency('libapparmor', required: false)
414 srcconf.set10('HAVE_APPARMOR', libapparmor.found())
416 srcconf.set10('HAVE_APPARMOR', false)
421 libopenssl = dependency('openssl', required: false)
422 srcconf.set10('HAVE_OPENSSL', libopenssl.found())
423 pkgconfig_libs += libopenssl
425 srcconf.set10('HAVE_OPENSSL', false)
430 libcap = dependency('libcap', required: false)
431 if not libcap.found()
432 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
433 libcap = cc.find_library('cap', required: false)
435 have = cc.has_function('cap_get_file', dependencies: libcap, prefix: '#include <sys/capability.h>')
436 srcconf.set10('LIBCAP_SUPPORTS_FILE_CAPABILITIES', have)
438 srcconf.set10('HAVE_LIBCAP', libcap.found())
439 pkgconfig_libs += libcap
441 libcap_static = dependency('libcap', required: false, static: true)
442 if not libcap_static.found()
443 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
444 libcap_static = cc.find_library('cap', required: false, static: true)
448 int main(int argc, char *argv[]) { return 0; };
450 if libcap_static.found()
451 libcap_static_linkable = cc.links(code, args: '-static', dependencies: libcap_static)
452 srcconf.set10('HAVE_STATIC_LIBCAP', libcap_static_linkable)
454 srcconf.set10('HAVE_STATIC_LIBCAP', false)
458 srcconf.set10('HAVE_LIBCAP', false)
459 srcconf.set10('HAVE_STATIC_LIBCAP', false)
462 libutil = cc.find_library('util', required: false)
464 oss_fuzz_dependencies = []
466 srcconf.set10('FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION', true)
467 srcconf.set10('RUN_ON_OSS_FUZZ', true)
468 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
471 srcconf.set10('ENFORCE_THREAD_SAFETY', want_thread_safety)
472 srcconf.set10('ENFORCE_MEMFD_REXEC', want_memfd_rexec)
475 pam = cc.find_library('pam', has_headers: 'security/pam_modules.h', required: want_pam_cgroup)
476 srcconf.set10('HAVE_PAM', pam.found())
477 pkgconfig_libs += pam
480 have = cc.has_function('fmemopen', prefix: '#include <stdio.h>', args: '-D_GNU_SOURCE')
481 srcconf.set10('HAVE_FMEMOPEN', have)
483 have_openpty = cc.has_function('openpty', dependencies: libutil, prefix: '#include <pty.h>')
484 srcconf.set10('HAVE_OPENPTY', have_openpty)
486 have = cc.has_function('pthread_setcancelstate', prefix: '#include <pthread.h>')
487 srcconf.set10('HAVE_PTHREAD_SETCANCELSTATE', have)
489 have = cc.has_function('rand_r')
490 srcconf.set10('HAVE_RAND_R', have)
492 have = cc.has_function('strchrnul', prefix: '#include <string.h>', args: '-D_GNU_SOURCE')
493 srcconf.set10('HAVE_STRCHRNUL', have)
495 have_func_strerror_r = cc.has_function('strerror_r', prefix: '#include <string.h>', args: '-D_GNU_SOURCE')
496 srcconf.set10('HAVE_STRERROR_R', have_func_strerror_r)
498 have_func_strerror_r_char_p = false
500 if have_func_strerror_r
505 char error_string[256];
506 char *ptr = strerror_r (-2, error_string, 256);
507 char c = *strerror_r (-2, error_string, 256);
508 return c != 0 && ptr != (void*) 0L;
512 have_func_strerror_r_char_p = cc.compiles(code, name : 'strerror_r() returns char *')
515 srcconf.set10('STRERROR_R_CHAR_P', have_func_strerror_r_char_p)
517 ## Compiler attributes.
524 srcconf.set10('HAVE_COMPILER_ATTR_' + ccattr.underscorify().to_upper(), cc.has_function_attribute(ccattr))
529 missing_syscalls = []
557 ['pidfd_send_signal'],
574 if tuple.length() >= 2
577 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
578 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
579 cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1
583 found_syscalls += tuple[0]
585 missing_syscalls += tuple[0]
592 #include <sys/mount.h>
593 #include <sys/stat.h>
594 #include <linux/if_link.h>
595 #include <linux/types.h>
602 'struct rtnl_link_stats64',
605 # We get -1 if the size cannot be determined
606 if cc.sizeof(decl, prefix: decl_headers, args: '-D_GNU_SOURCE') > 0
607 srcconf.set10('HAVE_' + decl.underscorify().to_upper(), true)
609 srcconf.set10('HAVE_' + decl.underscorify().to_upper(), false)
617 ['struct seccomp_notif_sizes'],
618 ['struct clone_args'],
621 ['struct rtnl_link_stats64'],
624 if tuple.length() >= 2
627 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
628 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
629 cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1
633 found_types += tuple[0]
635 missing_types += tuple[0]
640 #include <sys/mount.h>
643 # We get -1 if the size cannot be determined
644 if cc.sizeof('struct mount_attr', prefix: decl_headers, args: '-D_GNU_SOURCE') > 0
645 srcconf.set10('HAVE_' + 'struct mount_attr'.underscorify().to_upper(), true)
646 found_types += 'struct mount_attr (sys/mount.h)'
648 srcconf.set10('HAVE_' + 'struct mount_attr'.underscorify().to_upper(), false)
649 missing_types += 'struct mount_attr (sys/mount.h)' endif
651 ## Check if sys/mount.h defines the fsconfig commands
652 if cc.has_header_symbol('sys/mount.h', 'FSCONFIG_SET_FLAG')
653 srcconf.set10('HAVE_' + 'FSCONFIG_SET_FLAG'.underscorify().to_upper(), true)
654 found_types += 'FSCONFIG_SET_FLAG (sys/mount.h)'
656 srcconf.set10('HAVE_' + 'FSCONFIG_SET_FLAG'.underscorify().to_upper(), false)
657 missing_types += 'FSCONFIG_SET_FLAG (sys/mount.h)'
660 if cc.has_header_symbol('sys/mount.h', 'FS_CONFIG_SET_STRING')
661 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_STRING'.underscorify().to_upper(), true)
662 found_types += 'FS_CONFIG_SET_STRING (sys/mount.h)'
664 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_STRING'.underscorify().to_upper(), false)
665 missing_types += 'FS_CONFIG_SET_STRING (sys/mount.h)'
668 if cc.has_header_symbol('sys/mount.h', 'FS_CONFIG_SET_BINARY')
669 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_BINARY'.underscorify().to_upper(), true)
670 found_types += 'FS_CONFIG_SET_BINARY (sys/mount.h)'
672 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_BINARY'.underscorify().to_upper(), false)
673 missing_types += 'FS_CONFIG_SET_BINARY (sys/mount.h)'
676 if cc.has_header_symbol('sys/mount.h', 'FS_CONFIG_SET_PATH_EMPTY')
677 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_PATH_EMPTY'.underscorify().to_upper(), true)
678 found_types += 'FS_CONFIG_SET_PATH_EMPTY (sys/mount.h)'
680 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_PATH_EMPTY'.underscorify().to_upper(), false)
681 missing_types += 'FS_CONFIG_SET_PATH_EMPTY (sys/mount.h)'
684 if cc.has_header_symbol('sys/mount.h', 'FS_CONFIG_SET_PATH_FD')
685 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_PATH_FD'.underscorify().to_upper(), true)
686 found_types += 'FS_CONFIG_SET_PATH_FD (sys/mount.h)'
688 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_PATH_FD'.underscorify().to_upper(), false)
689 missing_types += 'FS_CONFIG_SET_PATH_FD (sys/mount.h)'
692 if cc.has_header_symbol('sys/mount.h', 'FS_CONFIG_SET_CMD_CREATE')
693 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_CMD_CREATE'.underscorify().to_upper(), true)
694 found_types += 'FS_CONFIG_SET_CMD_CREAT (sys/mount.h)'
696 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_CMD_CREATE'.underscorify().to_upper(), false)
697 missing_types += 'FS_CONFIG_SET_CMD_CREATE (sys/mount.h)'
700 if cc.has_header_symbol('sys/mount.h', 'FS_CONFIG_SET_CMD_RECONFIGURE')
701 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_CMD_RECONFIGURE'.underscorify().to_upper(), true)
702 found_types += 'FS_CONFIG_SET_CMD_RECONFIGURE (sys/mount.h)'
704 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_CMD_RECONFIGURE'.underscorify().to_upper(), false)
705 missing_types += 'FS_CONFIG_SET_CMD_RECONFIGURE (sys/mount.h)'
710 ['bpf', '''#include <sys/syscall.h>
711 #include <unistd.h>'''],
712 ['close_range', '''#include <unistd.h>'''],
713 ['execveat', '''#include <unistd.h>'''],
714 ['endmntent', '''#include <stdio.h>
715 #include <mntent.h>'''],
716 ['faccessat', '''#include <fcntl.h>
717 #include <unistd.h>'''],
718 ['fexecve', '''#include <unistd.h>'''],
719 ['fgetln', '''#include <stdio.h>'''],
720 ['fsconfig', '''#include <sys/mount.h>'''],
721 ['fsmount', '''#include <sys/mount.h>'''],
722 ['fsopen', '''#include <sys/mount.h>'''],
723 ['fspick', '''#include <sys/mount.h>'''],
724 ['getgrgid_r', '''#include <sys/types.h>
725 #include <grp.h>'''],
726 ['getline', '''#include <stdio.h>'''],
727 ['getsubopt', '''#include <stdlib.h>'''],
728 ['gettid', '''#include <sys/types.h>
729 #include <unistd.h>'''],
730 ['hasmntopt', '''#include <stdio.h>
731 #include <mntent.h>'''],
732 ['kcmp', '''#include <linux/kcmp.h>'''],
733 ['keyctl', '''#include <sys/types.h>
734 #include <keyutils.h>'''],
735 ['memfd_create', '''#include <sys/mman.h>'''],
736 ['mount_setattr', '''#include <sys/mount.h>'''],
737 ['move_mount', '''#include <sys/mount.h>'''],
738 ['openat2', '''#include <sys/types.h>
739 #include <sys/stat.h>
740 #include <fctnl.h>'''],
741 ['open_tree', '''#include <sys/mount.h>'''],
742 ['personality', '''#include <sys/personality.h>'''],
743 ['pidfd_open', '''#include <stdlib.h>
746 #include <sys/wait.h>'''],
747 ['pidfd_send_signal', '''#include <stdlib.h>
750 #include <sys/wait.h>'''],
751 ['pivot_root', '''#include <stdlib.h>
752 #include <unistd.h>'''], # no known header declares pivot_root
753 ['prlimit', '''#include <sys/time.h>
754 #include <sys/resource.h>'''],
755 ['prlimit64', '''#include <sys/time.h>
756 #include <sys/resource.h>'''],
757 ['renameat2', '''#include <stdio.h>
758 #include <fcntl.h>'''],
759 ['sethostname', '''#include <unistd.h>'''],
760 ['setmntent', '''#include <stdio.h>
761 #include <mntent.h>'''],
762 ['setns', '''#include <sched.h>'''],
763 ['sigdescr_np', '''#include <string.h>'''],
764 ['signalfd', '''#include <sys/signalfd.h>'''],
765 ['statvfs', '''#include <sys/statvfs.h>'''],
766 ['statx', '''#include <sys/types.h>
767 #include <sys/stat.h>
768 #include <unistd.h>'''],
769 ['strchrnul', '''#include <string.h>'''],
770 ['strlcat', '''#include <string.h>'''],
771 ['strlcpy', '''#include <string.h>'''],
772 ['unshare', '''#include <sched.h>'''],
775 have = cc.has_function(ident[0], prefix: ident[1], args: '-D_GNU_SOURCE')
776 srcconf.set10('HAVE_' + ident[0].to_upper(), have)
782 ['systemd/sd-bus.h'],
783 ['systemd/sd-event.h'],
786 ['sys/personality.h'],
793 srcconf.set10('HAVE_' + tuple[0].underscorify().to_upper(), cc.has_header(tuple[0]))
795 if tuple.length() >= 2
798 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
799 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
800 cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1
804 found_headers += tuple[0]
806 missing_headers += tuple[0]
825 if tuple.length() >= 2
828 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
829 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
830 cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1
834 found_deps += tuple[0]
836 missing_deps += tuple[0]
841 config_h = configure_file(
843 configuration: srcconf)
845 add_project_arguments('-include', 'config.h', language: 'c')
851 template_scripts = []
855 liblxc_includes = include_directories(
863 # Early sub-directories.
864 subdir('src/include')
866 subdir('src/lxc/pam')
869 liblxc_dependencies = [
874 liblxc_dependencies += libseccomp
878 liblxc_dependencies += [libcap]
882 liblxc_dependencies += [libopenssl]
886 liblxc_dependencies += [libselinux]
890 liblxc_dependencies += [libapparmor]
894 liblxc_dependencies += [liburing]
898 liblxc_dependencies += [libsystemd]
900 oss_fuzz_dependencies += [libsystemd]
905 liblxc_dependencies += [libutil]
907 oss_fuzz_dependencies += [libutil]
911 liblxc_link_whole = [liblxc_static]
913 liblxc = shared_library(
915 version: liblxc_version,
916 include_directories: liblxc_includes,
917 link_args: ['-DPIC'],
919 link_whole: liblxc_link_whole,
920 dependencies: liblxc_dependencies,
923 liblxc_dep = declare_dependency(
925 dependencies: liblxc_dependencies)
927 # Rest of sub-directories.
929 subdir('config/apparmor')
930 subdir('config/apparmor/abstractions')
931 subdir('config/apparmor/profiles')
933 subdir('config/bash')
935 subdir('config/init/common')
936 subdir('config/init/systemd')
937 subdir('config/init/sysvinit')
938 subdir('config/init/upstart')
940 subdir('config/selinux')
942 subdir('config/sysconfig')
943 subdir('config/templates')
944 subdir('config/templates/common.conf.d')
949 subdir('doc/examples')
953 subdir('src/lxc/cmd')
955 if want_tools or want_tools_multicall
956 subdir('src/lxc/tools')
958 subdir('src/lxc/tools/include')
963 pkg_config_file = pkgconfig.generate(liblxc,
964 description: 'linux container tools',
965 version: version_data.get('LXC_VERSION'),
966 url: 'http://linuxcontainers.org',
967 libraries: '-lutil -lpthread -ldl',
968 libraries_private: pkgconfig_libs,
972 install_emptydir(join_paths(localstatedir, 'cache', 'lxc'))
973 install_emptydir(join_paths(localstatedir, 'lib', 'lxc'))
976 specconf = configuration_data()
977 specconf.set('LXC_VERSION_BASE', meson.project_version())
978 specconf.set('LXC_VERSION_BETA', version_data.get('LXC_VERSION_BETA'))
979 specconf.set('PACKAGE', meson.project_name())
980 specconf.set('LXC_DISTRO_SYSCONF', conf.get('LXC_DISTRO_SYSCONF'))
983 configuration: specconf,
984 input: 'lxc.spec.in',
990 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
992 'Meson version: @0@'.format(meson.version()),
994 'prefix directory: @0@'.format(prefixdir),
995 'bin directory: @0@'.format(bindir),
996 'data directory: @0@'.format(datadir),
997 'doc directory: @0@'.format(docdir),
998 'include directory: @0@'.format(includedir),
999 'lib directory: @0@'.format(libdir),
1000 'libexec directory: @0@'.format(libexecdir),
1001 'local state directory: @0@'.format(localstatedir),
1002 'sbin directory: @0@'.format(sbindir),
1003 'sysconf directory: @0@'.format(sysconfdir),
1005 'lxc cgroup pattern: @0@'.format(cgrouppattern),
1006 'lxc init directory: @0@'.format(libexecdir),
1007 'runtime path: @0@'.format(runtimepath),
1009 'lxc default config: @0@'.format(lxcdefaultconfig),
1010 'lxc global config: @0@'.format(lxcglobalconfig),
1011 'lxc hook directory: @0@'.format(lxchookdir),
1012 'lxc hook bin directory: @0@'.format(lxchookbindir),
1013 'lxc rootfs mount directory: @0@'.format(lxcrootfsmount),
1014 'log path: @0@'.format(lxclogpath),
1015 'lxc path: @0@'.format(lxcpath),
1016 'lxc template config: @0@'.format(lxctemplateconfdir),
1017 'lxc template directory: @0@'.format(lxctemplatedir),
1018 'lxc user network config: @0@'.format(lxc_user_network_conf),
1019 'lxc user network database: @0@'.format(lxc_user_network_db)]
1021 alt_time_epoch = run_command('date', '-Is', '-u', '-d',
1022 '@@0@'.format(time_epoch), check: true).stdout().strip()
1024 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
1028 'supported dependencies: @0@'.format(', '.join(found_deps)),
1030 'unsupported dependencies: @0@'.format(', '.join(missing_deps)),
1035 'supported headers: @0@'.format(', '.join(found_headers)),
1037 'unsupported headers: @0@'.format(', '.join(missing_headers)),
1042 'supported calls: @0@'.format(', '.join(found_syscalls)),
1044 'unsupported calls: @0@'.format(', '.join(missing_syscalls)),
1049 'supported types: @0@'.format(', '.join(found_types)),
1051 'unsupported types: @0@'.format(', '.join(missing_types)),
1054 message('\n '.join(status))