1 # SPDX-License-Identifier: LGPL-2.1-or-later
19 meson_version: '>= 0.61')
21 cc = meson.get_compiler('c')
22 pkgconfig = import('pkgconfig')
25 liblxc_dependencies = []
26 oss_fuzz_dependencies = []
29 liblxc_version = '1.7.0'
30 version_data = configuration_data()
31 version_data.set('LXC_VERSION_MAJOR', '5')
32 version_data.set('LXC_VERSION_MINOR', '0')
33 version_data.set('LXC_VERSION_MICRO', '0')
34 version_data.set('LXC_VERSION_BETA', '')
35 version_data.set('LXC_ABI', liblxc_version)
36 version_data.set('LXC_DEVEL', '1')
37 version_data.set('LXC_VERSION', meson.project_version())
40 project_source_root = meson.current_source_dir()
41 project_build_root = meson.current_build_dir()
42 prefixdir = get_option('prefix')
44 apparmorcachedir = get_option('apparmor-cache-path')
45 globalconfig = get_option('global-config-path')
46 localstatedir = join_paths('/', get_option('localstatedir'))
47 logpath = get_option('log-path')
48 lxcpathprefix = get_option('data-path')
49 rootfsmount = get_option('rootfs-mount-path')
50 user_network_db_opt = get_option('usernet-db-path')
51 user_network_conf_opt = get_option('usernet-config-path')
53 bashcompletiondir = join_paths('/', 'usr', 'share', 'bash-completion', 'completions')
54 bindir = join_paths(prefixdir, get_option('bindir'))
55 datadir = join_paths(prefixdir, get_option('datadir'))
56 mandir = join_paths(prefixdir, get_option('mandir'))
57 docdir = join_paths(datadir, get_option('doc-path'))
58 includedir = join_paths(prefixdir, get_option('includedir'))
59 libdir = join_paths(prefixdir, get_option('libdir'))
60 libexecdir = join_paths(prefixdir, get_option('libexecdir'))
61 runtimepath = join_paths(prefixdir, get_option('runtime-path'))
62 sbindir = join_paths(prefixdir, get_option('sbindir'))
63 sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
65 lxcapparmorcachedir = join_paths(localstatedir, apparmorcachedir)
66 lxcconfdir = join_paths(sysconfdir, globalconfig)
67 lxcdefaultconfig = join_paths(lxcconfdir, 'default.conf')
68 lxcglobalconfig = join_paths(lxcconfdir, 'lxc.conf')
69 lxcexamplesdir = join_paths(docdir, 'examples')
70 lxchookbindir = join_paths(libexecdir, 'lxc/hooks')
71 lxcinclude = join_paths(includedir, 'lxc')
72 lxclibexec = join_paths(libexecdir, 'lxc')
73 lxclogpath = join_paths(localstatedir, logpath)
74 lxcpath = join_paths(localstatedir, lxcpathprefix)
75 lxcrootfsmount = join_paths(libdir, rootfsmount)
76 lxcdatadir = join_paths(datadir, 'lxc')
77 lxchookdir = join_paths(lxcdatadir, 'hooks')
78 lxcselinuxdir = join_paths(lxcdatadir, 'selinux')
79 lxctemplateconfdir = join_paths(lxcdatadir, 'config')
80 lxctemplateconfcommondir = join_paths(lxctemplateconfdir, 'common.conf.d')
81 lxctemplatedir = join_paths(lxcdatadir, 'templates')
82 lxc_user_network_conf = join_paths(sysconfdir, user_network_conf_opt)
83 lxc_user_network_db = join_paths(runtimepath, user_network_db_opt)
84 pam_security = join_paths(libdir, 'security')
86 # Configuration options.
87 srcconf = configuration_data()
88 srcconf.set('_GNU_SOURCE', true)
89 srcconf.set('_FILE_OFFSET_BITS', 64)
90 srcconf.set('__STDC_FORMAT_MACROS', true)
92 ## This is a hack to prevent any inclusion ofr linux/mount.h which causes
93 ## conflicts with sys/mount.h all over the place
94 srcconf.set('_LINUX_MOUNT_H', true)
96 srcconf.set_quoted('APPARMOR_CACHE_DIR', lxcapparmorcachedir)
97 srcconf.set_quoted('LIBEXECDIR', libexecdir)
98 srcconf.set_quoted('LOGPATH', lxclogpath)
99 srcconf.set_quoted('LXC_DEFAULT_CONFIG', lxcdefaultconfig)
100 srcconf.set_quoted('LXC_GLOBAL_CONF', lxcglobalconfig)
101 srcconf.set_quoted('LXCINITDIR', libexecdir)
102 srcconf.set_quoted('LXCPATH', lxcpath)
103 srcconf.set_quoted('LXCROOTFSMOUNT', lxcrootfsmount)
104 srcconf.set_quoted('LXCTEMPLATECONFIG', lxctemplateconfdir)
105 srcconf.set_quoted('LXCTEMPLATECONFIG', lxctemplateconfdir)
106 srcconf.set_quoted('LXCTEMPLATEDIR', lxctemplatedir)
107 srcconf.set_quoted('LXC_USERNIC_CONF', lxc_user_network_conf)
108 srcconf.set_quoted('LXC_USERNIC_DB', lxc_user_network_db)
109 srcconf.set_quoted('RUNTIME_PATH', runtimepath)
110 srcconf.set_quoted('SBINDIR', sbindir)
112 conf = configuration_data()
113 conf.set('BINDIR', bindir)
114 conf.set('LIBEXECDIR', libexecdir)
115 conf.set('LOCALSTATEDIR', localstatedir)
116 conf.set('LXC_GLOBAL_CONF', lxcglobalconfig)
117 conf.set('LXCHOOKDIR', lxchookdir)
118 conf.set('LXCINITDIR', libexecdir)
119 conf.set('LXCROOTFSMOUNT', lxcrootfsmount)
120 conf.set('LXCTEMPLATECONFIG', lxctemplateconfdir)
121 conf.set('LXCTEMPLATEDIR', lxctemplatedir)
122 conf.set('PACKAGE_VERSION', meson.project_version())
123 conf.set('RUNTIME_PATH', runtimepath)
124 conf.set('SYSCONFDIR', sysconfdir)
128 distrosysconfdir = get_option('distrosysconfdir')
129 if distrosysconfdir != ''
130 distrosysconfdir = join_paths(sysconfdir, distrosysconfdir)
131 conf.set('LXC_DISTRO_SYSCONF', distrosysconfdir)
132 elif fs.is_dir('/etc/sysconfig')
133 distrosysconfdir = join_paths(sysconfdir, 'sysconfig')
134 conf.set('LXC_DISTRO_SYSCONF', distrosysconfdir)
135 elif fs.is_dir('/etc/default')
136 distrosysconfdir = join_paths(sysconfdir, 'default')
137 conf.set('LXC_DISTRO_SYSCONF', distrosysconfdir)
139 error('"distrosysconfdir" is not set')
142 # Cross-compile on Android.
143 srcconf.set10('IS_BIONIC', host_machine.system() == 'android')
145 # Custom configuration.
146 cgrouppattern = get_option('cgroup-pattern')
147 coverity = get_option('coverity-build')
148 init_script = get_option('init-script')
149 sanitize = get_option('b_sanitize')
150 want_examples = get_option('examples')
151 want_io_uring = get_option('io-uring-event-loop')
152 want_pam_cgroup = get_option('pam-cgroup')
153 want_mans = get_option('man')
154 want_tests = get_option('tests')
155 want_tools = get_option('tools')
156 want_tools_multicall = get_option('tools-multicall')
157 want_commands = get_option('commands')
158 want_capabilities = get_option('capabilities')
159 want_apparmor = get_option('apparmor')
160 want_openssl = get_option('openssl')
161 want_selinux = get_option('selinux')
162 want_oss_fuzz = get_option('oss-fuzz')
163 want_seccomp = get_option('seccomp')
164 want_thread_safety = get_option('thread-safety')
165 want_memfd_rexec = get_option('memfd-rexec')
166 want_sd_bus = get_option('sd-bus')
168 srcconf.set_quoted('DEFAULT_CGROUP_PATTERN', cgrouppattern)
170 srcconf.set('ENABLE_COVERITY_BUILD', 1)
173 dummy_config_data = configuration_data()
174 dummy_config_data.set_quoted('DUMMY_VARIABLE', '1')
176 # Those generate many false positives, and we do not want to change the code to
178 basic_disabled_warnings = [
179 '-Wno-format-signedness',
180 '-Wno-missing-field-initializers',
181 '-Wno-unused-parameter',
185 possible_cc_flags = [
187 '-Wimplicit-fallthrough=5',
189 '-Wstrict-prototypes',
190 '-fno-strict-aliasing',
191 '-fstack-clash-protection',
192 '--param=ssp-buffer-size=4',
193 '--mcet -fcf-protection',
194 '-Werror=implicit-function-declaration',
196 '-Wmissing-include-dirs',
197 '-Wold-style-definition',
199 '-Wunused-but-set-variable',
200 '-Wno-unused-parameter',
202 '-Wsuggest-attribute=noreturn',
203 '-Werror=return-type',
204 '-Werror=incompatible-pointer-types',
209 '-fdiagnostics-show-option',
210 '-Werror=shift-count-overflow',
211 '-Werror=shift-overflow=2',
214 '-fasynchronous-unwind-tables',
218 '-Wreturn-local-addr',
220 '-Wstringop-overflow',
223 possible_link_flags = [
229 '-fstack-protector-strong',
232 if sanitize == 'none'
233 possible_link_flags += '-Wl,--warn-common'
236 if cc.get_id() == 'clang'
237 possible_cc_flags += [
238 '-Wno-typedef-redefinition',
239 '-Wno-gnu-variable-sized-type-not-at-end',
243 if meson.version().version_compare('>=0.46')
244 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language: 'c')
246 add_project_link_arguments(possible_link_flags, language: 'c')
249 add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
250 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language: 'c')
252 if add_languages('cpp', required : want_oss_fuzz)
253 # Used only for tests
254 cxx = meson.get_compiler('cpp')
255 cxx_cmd = ' '.join(cxx.cmd_array())
256 add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
262 liburing = dependency('liburing')
263 if cc.has_function('io_uring_prep_poll_add', prefix: '#include <liburing.h>', dependencies: liburing) == false
264 error('liburing version does not support IORING_POLL_ADD_MULTI')
266 pkgconfig_libs += liburing
267 liblxc_dependencies += liburing
269 srcconf.set10('HAVE_LIBURING', true)
271 srcconf.set10('HAVE_LIBURING', false)
274 if not want_sd_bus.disabled()
276 sd_bus_optional = want_sd_bus.auto()
278 libsystemd = dependency('libsystemd', required: not sd_bus_optional)
279 if not libsystemd.found()
280 if not sd_bus_optional
281 error('missing required libsystemd dependency')
287 if not cc.has_header('systemd/sd-bus.h')
288 if not sd_bus_optional
289 error('libsystemd misses required systemd/sd-bus.h header')
295 if not cc.has_header('systemd/sd-event.h')
296 if not sd_bus_optional
297 error('libsystemd misses required systemd/sd-event.h header')
303 if not cc.has_function('sd_bus_call_method_async', prefix: '#include <systemd/sd-bus.h>', dependencies: libsystemd)
304 if not sd_bus_optional
305 error('libsystemd misses required sd_bus_call_method_async function')
312 liblxc_dependencies += libsystemd
314 oss_fuzz_dependencies += libsystemd
318 srcconf.set10('HAVE_LIBSYSTEMD', has_sd_bus)
321 srcconf.set10('HAVE_LIBSYSTEMD', false)
325 sh = find_program('sh')
326 date = find_program('date')
327 git = find_program('git', required: false)
328 time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check: true).stdout().strip()
329 if time_epoch == '' and git.found() and run_command('test', '-e', '.git', check: false).returncode() == 0
330 # If we're in a git repository, use the creation time of the latest git tag.
331 latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags', check: false).stdout().strip()
333 time_epoch = run_command(git, 'log', '--no-show-signature', '-1', '--format=%at', latest_tag, check: true).stdout().strip()
337 # Fallback to current epoch.
339 time_epoch = run_command(date, '+%s', check: true).stdout().strip()
341 generate_date = run_command(date, '--utc', '--date=@' + time_epoch, '+%Y-%m-%d', check: true).stdout().strip()
344 docconf = configuration_data()
345 docconf.set('builddir', '.')
346 docconf.set('BINDIR', bindir)
347 docconf.set('DATADIR', datadir)
348 docconf.set('DOCDIR', docdir)
349 docconf.set('LOGPATH', lxclogpath)
350 docconf.set('LXC_DEFAULT_CONFIG', lxcdefaultconfig)
351 docconf.set('LXC_GENERATE_DATE', generate_date)
352 docconf.set('LXC_GLOBAL_CONF', lxcglobalconfig)
353 docconf.set('LXCPATH', lxcpath)
354 docconf.set('LXCTEMPLATEDIR', lxctemplatedir)
355 docconf.set('LXC_USERNIC_CONF', lxc_user_network_conf)
356 docconf.set('LXC_USERNIC_DB', lxc_user_network_db)
357 docconf.set('PACKAGE_VERSION', version_data.get('LXC_VERSION'))
358 docconf.set('docdtd', '"-//OASIS//DTD DocBook XML" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"')
359 sgml2man = find_program('docbook2X2man', 'docbook2x-man', 'db2x_docbook2man', 'docbook2man', 'docbook-to-man', required: false, version: '>=0.8')
360 if not sgml2man.found()
361 sgml2man = find_program('docbook2man', required: false, version: '<0.8')
363 docconf.set('docdtd', '"-//Davenport//DTD DocBook V3.0//EN"')
365 error('missing required docbook2x or docbook-utils dependency')
370 threads = dependency('threads')
371 liblxc_dependencies += threads
375 libseccomp = dependency('libseccomp', required: false)
376 srcconf.set10('HAVE_SECCOMP', libseccomp.found())
377 pkgconfig_libs += libseccomp
378 liblxc_dependencies += libseccomp
379 if libseccomp.found()
380 if libseccomp.version().version_compare('>=2.5.0')
381 # https://github.com/seccomp/libseccomp/commit/dead12bc788b259b148cc4d93b970ef0bd602b1a
382 srcconf.set10('HAVE_DECL_SECCOMP_NOTIFY_FD', true)
384 srcconf.set10('HAVE_DECL_SECCOMP_NOTIFY_FD', false)
387 if libseccomp.version().version_compare('>=2.0.0')
388 # https://github.com/seccomp/libseccomp/commit/6220c8c0fc479d97b6d3e3166a4e46fbfe25a3c0
389 srcconf.set10('HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH', true)
391 srcconf.set10('HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH', false)
394 seccomp_headers = '''
400 'struct seccomp_notif_sizes',
404 # We get -1 if the size cannot be determined
405 if cc.sizeof(decl, prefix: seccomp_headers, args: '-D_GNU_SOURCE', dependencies: libseccomp) > 0
406 srcconf.set10('HAVE_' + decl.underscorify().to_upper(), true)
408 srcconf.set10('HAVE_' + decl.underscorify().to_upper(), false)
413 srcconf.set10('HAVE_SECCOMP', false)
418 libselinux = dependency('libselinux', required: false)
419 srcconf.set10('HAVE_SELINUX', libselinux.found())
420 pkgconfig_libs += libselinux
421 liblxc_dependencies += libselinux
423 srcconf.set10('HAVE_SELINUX', false)
428 libapparmor = dependency('libapparmor', required: false)
429 srcconf.set10('HAVE_APPARMOR', libapparmor.found())
430 # We do not use the AppArmor library at runtime, so it's not in our pkg-config.
431 liblxc_dependencies += libapparmor
433 srcconf.set10('HAVE_APPARMOR', false)
438 libopenssl = dependency('openssl', required: false)
439 srcconf.set10('HAVE_OPENSSL', libopenssl.found())
440 pkgconfig_libs += libopenssl
441 liblxc_dependencies += libopenssl
443 srcconf.set10('HAVE_OPENSSL', false)
448 libcap = dependency('libcap', required: false)
449 if not libcap.found()
450 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
451 libcap = cc.find_library('cap', required: false)
453 have = cc.has_function('cap_get_file', dependencies: libcap, prefix: '#include <sys/capability.h>')
454 srcconf.set10('LIBCAP_SUPPORTS_FILE_CAPABILITIES', have)
456 srcconf.set10('HAVE_LIBCAP', libcap.found())
457 pkgconfig_libs += libcap
458 liblxc_dependencies += libcap
460 libcap_static = dependency('libcap', required: false, static: true)
461 if not libcap_static.found()
462 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
463 libcap_static = cc.find_library('cap', required: false, static: true)
467 int main(int argc, char *argv[]) { return 0; };
469 if libcap_static.found()
470 libcap_static_linkable = cc.links(code, args: '-static', dependencies: libcap_static)
472 libcap_static_linkable = false
474 srcconf.set10('HAVE_STATIC_LIBCAP', libcap_static_linkable)
477 libcap_static_linkable = false
478 srcconf.set10('HAVE_LIBCAP', false)
479 srcconf.set10('HAVE_STATIC_LIBCAP', false)
482 libutil = cc.find_library('util', required: false)
485 srcconf.set10('FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION', true)
486 srcconf.set10('RUN_ON_OSS_FUZZ', true)
487 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
490 srcconf.set10('ENFORCE_THREAD_SAFETY', want_thread_safety)
491 srcconf.set10('ENFORCE_MEMFD_REXEC', want_memfd_rexec)
494 pam = cc.find_library('pam', has_headers: 'security/pam_modules.h', required: want_pam_cgroup)
495 srcconf.set10('HAVE_PAM', pam.found())
496 pkgconfig_libs += pam
499 have = cc.has_function('fmemopen', prefix: '#include <stdio.h>', args: '-D_GNU_SOURCE')
500 srcconf.set10('HAVE_FMEMOPEN', have)
502 have = cc.has_function('openpty', dependencies: libutil, prefix: '#include <pty.h>')
503 srcconf.set10('HAVE_OPENPTY', have)
505 liblxc_dependencies += libutil
507 oss_fuzz_dependencies += libutil
511 have = cc.has_function('pthread_setcancelstate', prefix: '#include <pthread.h>')
512 srcconf.set10('HAVE_PTHREAD_SETCANCELSTATE', have)
514 have = cc.has_function('rand_r')
515 srcconf.set10('HAVE_RAND_R', have)
517 have = cc.has_function('strchrnul', prefix: '#include <string.h>', args: '-D_GNU_SOURCE')
518 srcconf.set10('HAVE_STRCHRNUL', have)
520 have_func_strerror_r = cc.has_function('strerror_r', prefix: '#include <string.h>', args: '-D_GNU_SOURCE')
521 srcconf.set10('HAVE_STRERROR_R', have_func_strerror_r)
523 have_func_strerror_r_char_p = false
525 if have_func_strerror_r
530 char error_string[256];
531 char *ptr = strerror_r (-2, error_string, 256);
532 char c = *strerror_r (-2, error_string, 256);
533 return c != 0 && ptr != (void*) 0L;
537 have_func_strerror_r_char_p = cc.compiles(code, name : 'strerror_r() returns char *')
540 srcconf.set10('STRERROR_R_CHAR_P', have_func_strerror_r_char_p)
542 ## Compiler attributes.
549 srcconf.set10('HAVE_COMPILER_ATTR_' + ccattr.underscorify().to_upper(), cc.has_function_attribute(ccattr))
554 missing_syscalls = []
582 ['pidfd_send_signal'],
599 if tuple.length() >= 2
602 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
603 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
604 cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1
608 found_syscalls += tuple[0]
610 missing_syscalls += tuple[0]
617 #include <sys/mount.h>
618 #include <sys/stat.h>
619 #include <linux/if_link.h>
620 #include <linux/types.h>
627 'struct rtnl_link_stats64',
630 # We get -1 if the size cannot be determined
631 if cc.sizeof(decl, prefix: decl_headers, args: '-D_GNU_SOURCE') > 0
632 srcconf.set10('HAVE_' + decl.underscorify().to_upper(), true)
634 srcconf.set10('HAVE_' + decl.underscorify().to_upper(), false)
642 ['struct seccomp_notif_sizes'],
643 ['struct clone_args'],
646 ['struct rtnl_link_stats64'],
649 if tuple.length() >= 2
652 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
653 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
654 cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1
658 found_types += tuple[0]
660 missing_types += tuple[0]
665 #include <sys/mount.h>
668 # We get -1 if the size cannot be determined
669 if cc.sizeof('struct mount_attr', prefix: decl_headers, args: '-D_GNU_SOURCE') > 0
670 srcconf.set10('HAVE_' + 'struct mount_attr'.underscorify().to_upper(), true)
671 found_types += 'struct mount_attr (sys/mount.h)'
673 srcconf.set10('HAVE_' + 'struct mount_attr'.underscorify().to_upper(), false)
674 missing_types += 'struct mount_attr (sys/mount.h)' endif
676 ## Check if sys/mount.h defines the fsconfig commands
677 if cc.get_define('FSCONFIG_SET_FLAG', prefix: decl_headers) != ''
678 srcconf.set10('HAVE_' + 'FSCONFIG_SET_FLAG'.underscorify().to_upper(), true)
679 found_types += 'FSCONFIG_SET_FLAG (sys/mount.h)'
681 srcconf.set10('HAVE_' + 'FSCONFIG_SET_FLAG'.underscorify().to_upper(), false)
682 missing_types += 'FSCONFIG_SET_FLAG (sys/mount.h)'
685 if cc.get_define('FS_CONFIG_SET_STRING', prefix: decl_headers) != ''
686 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_STRING'.underscorify().to_upper(), true)
687 found_types += 'FS_CONFIG_SET_STRING (sys/mount.h)'
689 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_STRING'.underscorify().to_upper(), false)
690 missing_types += 'FS_CONFIG_SET_STRING (sys/mount.h)'
693 if cc.get_define('FS_CONFIG_SET_BINARY', prefix: decl_headers) != ''
694 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_BINARY'.underscorify().to_upper(), true)
695 found_types += 'FS_CONFIG_SET_BINARY (sys/mount.h)'
697 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_BINARY'.underscorify().to_upper(), false)
698 missing_types += 'FS_CONFIG_SET_BINARY (sys/mount.h)'
701 if cc.get_define('FS_CONFIG_SET_PATH_EMPTY', prefix: decl_headers) != ''
702 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_PATH_EMPTY'.underscorify().to_upper(), true)
703 found_types += 'FS_CONFIG_SET_PATH_EMPTY (sys/mount.h)'
705 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_PATH_EMPTY'.underscorify().to_upper(), false)
706 missing_types += 'FS_CONFIG_SET_PATH_EMPTY (sys/mount.h)'
709 if cc.get_define('FS_CONFIG_SET_PATH_FD', prefix: decl_headers) != ''
710 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_PATH_FD'.underscorify().to_upper(), true)
711 found_types += 'FS_CONFIG_SET_PATH_FD (sys/mount.h)'
713 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_PATH_FD'.underscorify().to_upper(), false)
714 missing_types += 'FS_CONFIG_SET_PATH_FD (sys/mount.h)'
717 if cc.get_define('FS_CONFIG_SET_CMD_CREATE', prefix: decl_headers) != ''
718 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_CMD_CREATE'.underscorify().to_upper(), true)
719 found_types += 'FS_CONFIG_SET_CMD_CREAT (sys/mount.h)'
721 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_CMD_CREATE'.underscorify().to_upper(), false)
722 missing_types += 'FS_CONFIG_SET_CMD_CREATE (sys/mount.h)'
725 if cc.get_define('FS_CONFIG_SET_CMD_RECONFIGURE', prefix: decl_headers) != ''
726 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_CMD_RECONFIGURE'.underscorify().to_upper(), true)
727 found_types += 'FS_CONFIG_SET_CMD_RECONFIGURE (sys/mount.h)'
729 srcconf.set10('HAVE_' + 'FS_CONFIG_SET_CMD_RECONFIGURE'.underscorify().to_upper(), false)
730 missing_types += 'FS_CONFIG_SET_CMD_RECONFIGURE (sys/mount.h)'
735 ['bpf', '''#include <sys/syscall.h>
736 #include <unistd.h>'''],
737 ['close_range', '''#include <unistd.h>'''],
738 ['execveat', '''#include <unistd.h>'''],
739 ['endmntent', '''#include <stdio.h>
740 #include <mntent.h>'''],
741 ['faccessat', '''#include <fcntl.h>
742 #include <unistd.h>'''],
743 ['fexecve', '''#include <unistd.h>'''],
744 ['fgetln', '''#include <stdio.h>'''],
745 ['fsconfig', '''#include <sys/mount.h>'''],
746 ['fsmount', '''#include <sys/mount.h>'''],
747 ['fsopen', '''#include <sys/mount.h>'''],
748 ['fspick', '''#include <sys/mount.h>'''],
749 ['getgrgid_r', '''#include <sys/types.h>
750 #include <grp.h>'''],
751 ['getline', '''#include <stdio.h>'''],
752 ['getsubopt', '''#include <stdlib.h>'''],
753 ['gettid', '''#include <sys/types.h>
754 #include <unistd.h>'''],
755 ['hasmntopt', '''#include <stdio.h>
756 #include <mntent.h>'''],
757 ['kcmp', '''#include <linux/kcmp.h>'''],
758 ['keyctl', '''#include <sys/types.h>
759 #include <keyutils.h>'''],
760 ['memfd_create', '''#include <sys/mman.h>'''],
761 ['mount_setattr', '''#include <sys/mount.h>'''],
762 ['move_mount', '''#include <sys/mount.h>'''],
763 ['openat2', '''#include <sys/types.h>
764 #include <sys/stat.h>
765 #include <fctnl.h>'''],
766 ['open_tree', '''#include <sys/mount.h>'''],
767 ['personality', '''#include <sys/personality.h>'''],
768 ['pidfd_open', '''#include <stdlib.h>
771 #include <sys/wait.h>'''],
772 ['pidfd_send_signal', '''#include <stdlib.h>
775 #include <sys/wait.h>'''],
776 ['pivot_root', '''#include <stdlib.h>
777 #include <unistd.h>'''], # no known header declares pivot_root
778 ['prlimit', '''#include <sys/time.h>
779 #include <sys/resource.h>'''],
780 ['prlimit64', '''#include <sys/time.h>
781 #include <sys/resource.h>'''],
782 ['renameat2', '''#include <stdio.h>
783 #include <fcntl.h>'''],
784 ['sethostname', '''#include <unistd.h>'''],
785 ['setmntent', '''#include <stdio.h>
786 #include <mntent.h>'''],
787 ['setns', '''#include <sched.h>'''],
788 ['sigdescr_np', '''#include <string.h>'''],
789 ['signalfd', '''#include <sys/signalfd.h>'''],
790 ['statvfs', '''#include <sys/statvfs.h>'''],
791 ['statx', '''#include <sys/types.h>
792 #include <sys/stat.h>
793 #include <unistd.h>'''],
794 ['strchrnul', '''#include <string.h>'''],
795 ['strlcat', '''#include <string.h>'''],
796 ['strlcpy', '''#include <string.h>'''],
797 ['unshare', '''#include <sched.h>'''],
800 have = cc.has_function(ident[0], prefix: ident[1], args: '-D_GNU_SOURCE')
801 srcconf.set10('HAVE_' + ident[0].to_upper(), have)
807 ['systemd/sd-bus.h'],
808 ['systemd/sd-event.h'],
811 ['sys/personality.h'],
818 srcconf.set10('HAVE_' + tuple[0].underscorify().to_upper(), cc.has_header(tuple[0]))
820 if tuple.length() >= 2
823 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
824 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
825 cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1
829 found_headers += tuple[0]
831 missing_headers += tuple[0]
850 if tuple.length() >= 2
853 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
854 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
855 cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1
859 found_deps += tuple[0]
861 missing_deps += tuple[0]
866 config_h = configure_file(
868 configuration: srcconf)
870 add_project_arguments('-include', 'config.h', language: 'c')
876 template_scripts = []
880 liblxc_includes = include_directories(
888 # Our static sub-project binaries don't (and in fact can't) link to our
889 # dependencies directly, but need access to the headers when compiling (most
890 # notably seccomp headers).
891 liblxc_dependency_headers = []
892 foreach dep: liblxc_dependencies
893 liblxc_dependency_headers += dep.partial_dependency(compile_args: true)
896 # Early sub-directories.
897 subdir('src/include')
899 subdir('src/lxc/pam')
901 liblxc_link_whole = [liblxc_static]
903 liblxc = shared_library(
905 version: liblxc_version,
906 include_directories: liblxc_includes,
907 link_args: ['-DPIC'],
909 link_whole: liblxc_link_whole,
910 dependencies: liblxc_dependencies,
913 liblxc_dep = declare_dependency(
915 dependencies: liblxc_dependencies)
917 # Rest of sub-directories.
919 subdir('config/apparmor')
920 subdir('config/apparmor/abstractions')
921 subdir('config/apparmor/profiles')
923 subdir('config/bash')
925 subdir('config/init/common')
926 subdir('config/init/systemd')
927 subdir('config/init/sysvinit')
928 subdir('config/init/upstart')
930 subdir('config/selinux')
932 subdir('config/sysconfig')
933 subdir('config/templates')
934 subdir('config/templates/common.conf.d')
939 subdir('doc/examples')
943 subdir('src/lxc/cmd')
945 if want_tools or want_tools_multicall
946 subdir('src/lxc/tools')
948 subdir('src/lxc/tools/include')
953 pkg_config_file = pkgconfig.generate(liblxc,
954 description: 'linux container tools',
955 version: version_data.get('LXC_VERSION'),
956 url: 'http://linuxcontainers.org',
957 libraries: '-lutil -lpthread -ldl',
958 libraries_private: pkgconfig_libs,
962 install_emptydir(join_paths(localstatedir, 'cache', 'lxc'))
963 install_emptydir(join_paths(localstatedir, 'lib', 'lxc'))
966 specconf = configuration_data()
967 specconf.set('LXC_VERSION_BASE', meson.project_version())
968 specconf.set('LXC_VERSION_BETA', version_data.get('LXC_VERSION_BETA'))
969 specconf.set('PACKAGE', meson.project_name())
970 specconf.set('LXC_DISTRO_SYSCONF', conf.get('LXC_DISTRO_SYSCONF'))
973 configuration: specconf,
974 input: 'lxc.spec.in',
980 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
982 'Meson version: @0@'.format(meson.version()),
984 'prefix directory: @0@'.format(prefixdir),
985 'bin directory: @0@'.format(bindir),
986 'data directory: @0@'.format(datadir),
987 'doc directory: @0@'.format(docdir),
988 'include directory: @0@'.format(includedir),
989 'lib directory: @0@'.format(libdir),
990 'libexec directory: @0@'.format(libexecdir),
991 'local state directory: @0@'.format(localstatedir),
992 'sbin directory: @0@'.format(sbindir),
993 'sysconf directory: @0@'.format(sysconfdir),
995 'lxc cgroup pattern: @0@'.format(cgrouppattern),
996 'lxc init directory: @0@'.format(libexecdir),
997 'runtime path: @0@'.format(runtimepath),
999 'lxc default config: @0@'.format(lxcdefaultconfig),
1000 'lxc global config: @0@'.format(lxcglobalconfig),
1001 'lxc hook directory: @0@'.format(lxchookdir),
1002 'lxc hook bin directory: @0@'.format(lxchookbindir),
1003 'lxc rootfs mount directory: @0@'.format(lxcrootfsmount),
1004 'log path: @0@'.format(lxclogpath),
1005 'lxc path: @0@'.format(lxcpath),
1006 'lxc template config: @0@'.format(lxctemplateconfdir),
1007 'lxc template directory: @0@'.format(lxctemplatedir),
1008 'lxc user network config: @0@'.format(lxc_user_network_conf),
1009 'lxc user network database: @0@'.format(lxc_user_network_db)]
1011 alt_time_epoch = run_command('date', '-Is', '-u', '-d',
1012 '@@0@'.format(time_epoch), check: true).stdout().strip()
1014 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
1018 'supported dependencies: @0@'.format(', '.join(found_deps)),
1020 'unsupported dependencies: @0@'.format(', '.join(missing_deps)),
1025 'supported headers: @0@'.format(', '.join(found_headers)),
1027 'unsupported headers: @0@'.format(', '.join(missing_headers)),
1032 'supported calls: @0@'.format(', '.join(found_syscalls)),
1034 'unsupported calls: @0@'.format(', '.join(missing_syscalls)),
1039 'supported types: @0@'.format(', '.join(found_types)),
1041 'unsupported types: @0@'.format(', '.join(missing_types)),
1044 message('\n '.join(status))