]> git.proxmox.com Git - mirror_lxc.git/blob - meson.build
build: tweak build flags
[mirror_lxc.git] / meson.build
1 # SPDX-License-Identifier: LGPL-2.1-or-later
2
3 # Project.
4 project(
5 'lxc',
6 'c',
7 version: '4.0.0-devel',
8 license: 'LGPLv2+',
9 default_options: [
10 'b_lto=true',
11 'b_lto_mode=thin',
12 'b_colorout=always',
13 'b_asneeded=true',
14 'b_pie=true',
15 'b_staticpic=true',
16 'c_std=gnu11',
17 'warning_level=2',
18 ],
19 meson_version: '>= 0.61')
20
21 cc = meson.get_compiler('c')
22 pkgconfig = import('pkgconfig')
23 pkgconfig_libs = []
24
25 # Version.
26 liblxc_version = '1.7.0'
27 version_data = configuration_data()
28 version_data.set('LXC_VERSION_MAJOR', '4')
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())
35
36 # Path handling.
37 project_source_root = meson.current_source_dir()
38 project_build_root = meson.current_build_dir()
39 prefixdir = get_option('prefix')
40
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')
49
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'))
61
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')
82
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)
88 srcconf.set_quoted('APPARMOR_CACHE_DIR', lxcapparmorcachedir)
89 srcconf.set_quoted('LIBEXECDIR', libexecdir)
90 srcconf.set_quoted('LOGPATH', lxclogpath)
91 srcconf.set_quoted('LXC_DEFAULT_CONFIG', lxcdefaultconfig)
92 srcconf.set_quoted('LXC_GLOBAL_CONF', lxcglobalconfig)
93 srcconf.set_quoted('LXCINITDIR', libexecdir)
94 srcconf.set_quoted('LXCPATH', lxcpath)
95 srcconf.set_quoted('LXCROOTFSMOUNT', lxcrootfsmount)
96 srcconf.set_quoted('LXCTEMPLATECONFIG', lxctemplateconfdir)
97 srcconf.set_quoted('LXCTEMPLATECONFIG', lxctemplateconfdir)
98 srcconf.set_quoted('LXCTEMPLATEDIR', lxctemplatedir)
99 srcconf.set_quoted('LXC_USERNIC_CONF', lxc_user_network_conf)
100 srcconf.set_quoted('LXC_USERNIC_DB', lxc_user_network_db)
101 srcconf.set_quoted('RUNTIME_PATH', runtimepath)
102 srcconf.set_quoted('SBINDIR', sbindir)
103
104 conf = configuration_data()
105 conf.set('BINDIR', bindir)
106 conf.set('LIBEXECDIR', libexecdir)
107 conf.set('LOCALSTATEDIR', localstatedir)
108 conf.set('LXC_GLOBAL_CONF', lxcglobalconfig)
109 conf.set('LXCHOOKDIR', lxchookdir)
110 conf.set('LXCINITDIR', libexecdir)
111 conf.set('LXCROOTFSMOUNT', lxcrootfsmount)
112 conf.set('LXCTEMPLATECONFIG', lxctemplateconfdir)
113 conf.set('LXCTEMPLATEDIR', lxctemplatedir)
114 conf.set('PACKAGE_VERSION', meson.project_version())
115 conf.set('RUNTIME_PATH', runtimepath)
116 conf.set('SYSCONFDIR', sysconfdir)
117
118 # Set sysconfdir
119 fs = import('fs')
120 if fs.is_dir('/etc/sysconfig')
121 distrosysconfdir = join_paths(sysconfdir, 'sysconfig')
122 conf.set('LXC_DISTRO_SYSCONF', distrosysconfdir)
123 elif fs.is_dir('/etc/default')
124 distrosysconfdir = join_paths(sysconfdir, 'default')
125 conf.set('LXC_DISTRO_SYSCONF', distrosysconfdir)
126 else
127 distrosysconfdir = ''
128 endif
129
130 # Cross-compile on Android.
131 srcconf.set10('IS_BIONIC', host_machine.system() == 'android')
132
133 # Custom configuration.
134 cgrouppattern = get_option('cgroup-pattern')
135 coverity = get_option('coverity-build')
136 init_script = get_option('init-script')
137 sanitize = get_option('b_sanitize')
138 want_examples = get_option('examples')
139 want_io_uring = get_option('io-uring-event-loop')
140 want_pam_cgroup = get_option('pam-cgroup')
141 want_mans = get_option('man')
142 want_tests = get_option('tests')
143 want_tools = get_option('tools')
144 want_commands = get_option('commands')
145 want_capabilities = get_option('capabilities')
146 want_apparmor = get_option('apparmor')
147 want_openssl = get_option('openssl')
148 want_selinux = get_option('selinux')
149
150 srcconf.set_quoted('DEFAULT_CGROUP_PATTERN', cgrouppattern)
151 if coverity
152 srcconf.set('ENABLE_COVERITY_BUILD', 1)
153 endif
154
155 dummy_config_data = configuration_data()
156 dummy_config_data.set_quoted('DUMMY_VARIABLE', '1')
157
158 # Those generate many false positives, and we do not want to change the code to
159 # avoid them.
160 basic_disabled_warnings = [
161 '-Wno-format-signedness',
162 '-Wno-missing-field-initializers',
163 '-Wno-unused-parameter',
164 ]
165
166 # Build flags.
167 possible_cc_flags = [
168 '-Wvla',
169 '-Wimplicit-fallthrough=5',
170 '-Wcast-align',
171 '-Wstrict-prototypes',
172 '-fno-strict-aliasing',
173 '-fstack-clash-protection',
174 '-fstack-protector-strong',
175 '--param=ssp-buffer-size=4',
176 '--mcet -fcf-protection',
177 '-Werror=implicit-function-declaration',
178 '-Wlogical-op',
179 '-Wmissing-include-dirs',
180 '-Wold-style-definition',
181 '-Winit-self',
182 '-Wunused-but-set-variable',
183 '-Wno-unused-parameter',
184 '-Wfloat-equal',
185 '-Wsuggest-attribute=noreturn',
186 '-Werror=return-type',
187 '-Werror=incompatible-pointer-types',
188 '-Wformat=2',
189 '-Wshadow',
190 '-Wendif-labels',
191 '-Werror=overflow',
192 '-fdiagnostics-show-option',
193 '-Werror=shift-count-overflow',
194 '-Werror=shift-overflow=2',
195 '-Wdate-time',
196 '-Wnested-externs',
197 '-fasynchronous-unwind-tables',
198 '-fexceptions',
199 '-Warray-bounds',
200 '-Wrestrict',
201 '-Wreturn-local-addr',
202 '-fsanitize=cfi',
203 '-Wstringop-overflow',
204 ]
205
206 possible_link_flags = [
207 '-Wl,--gc-sections',
208 '-Wl,-z,relro',
209 '-Wl,-z,now',
210 '-Wl,-fuse-ld=gold',
211 '-fstack-protector',
212 ]
213
214 if sanitize == 'none'
215 possible_link_flags += '-Wl,--warn-common'
216 endif
217
218 if cc.get_id() == 'clang'
219 possible_cc_flags += [
220 '-Wno-typedef-redefinition',
221 '-Wno-gnu-variable-sized-type-not-at-end',
222 ]
223 endif
224
225 if meson.version().version_compare('>=0.46')
226 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language: 'c')
227 else
228 add_project_link_arguments(possible_link_flags, language: 'c')
229 endif
230
231 add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
232 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language: 'c')
233
234 # Feature detection
235 ## I/O uring.
236 if want_io_uring
237 liburing = dependency('liburing')
238 if cc.has_function('io_uring_prep_poll_add', prefix: '#include <liburing.h>', dependencies: liburing) == false
239 error('liburing version does not support IORING_POLL_ADD_MULTI')
240 endif
241
242 srcconf.set10('HAVE_LIBURING', true)
243 else
244 srcconf.set10('HAVE_LIBURING', false)
245 endif
246
247 ## Time EPOCH.
248 sh = find_program('sh')
249 date = find_program('date')
250 git = find_program('git', required: false)
251 time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check: true).stdout().strip()
252 if time_epoch == '' and git.found() and run_command('test', '-e', '.git', check: false).returncode() == 0
253 # If we're in a git repository, use the creation time of the latest git tag.
254 latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags', check: false).stdout().strip()
255 if latest_tag != ''
256 time_epoch = run_command(git, 'log', '--no-show-signature', '-1', '--format=%at', latest_tag, check: true).stdout()
257 endif
258 endif
259
260 # Fallback to current epoch.
261 if time_epoch == ''
262 time_epoch = run_command(date, '+%s', check: true).stdout()
263 endif
264 generate_date = run_command(date, '--utc', '--date=@' + time_epoch, '+%Y-%m-%d', check: true).stdout().strip()
265
266 ## Manpages.
267 sgml2man = find_program('docbook2X2man', 'docbook2x-man', 'db2x_docbook2man', 'docbook2man', 'docbook-to-man', required: want_mans)
268 docbook2man = find_program('docbook2man', required: false)
269
270 docconf = configuration_data()
271 docconf.set('builddir', '.')
272 docconf.set('BINDIR', bindir)
273 docconf.set('DATADIR', datadir)
274 docconf.set('DOCDIR', docdir)
275 docconf.set('LOGPATH', lxclogpath)
276 docconf.set('LXC_DEFAULT_CONFIG', lxcdefaultconfig)
277 docconf.set('LXC_GENERATE_DATE', generate_date)
278 docconf.set('LXC_GLOBAL_CONF', lxcglobalconfig)
279 docconf.set('LXCPATH', lxcpath)
280 docconf.set('LXCTEMPLATEDIR', lxctemplatedir)
281 docconf.set('LXC_USERNIC_CONF', lxc_user_network_conf)
282 docconf.set('LXC_USERNIC_DB', lxc_user_network_db)
283 docconf.set('PACKAGE_VERSION', version_data.get('LXC_VERSION'))
284 if sgml2man.found() and docbook2man.found() and sgml2man.full_path() == docbook2man.full_path()
285 docconf.set('docdtd', '"-//Davenport//DTD DocBook V3.0//EN"')
286 else
287 docconf.set('docdtd', '"-//OASIS//DTD DocBook XML" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"')
288 endif
289
290 ## Threads.
291 threads = dependency('threads')
292
293 ## Seccomp.
294 libseccomp = dependency('libseccomp', required: false)
295 srcconf.set10('HAVE_SECCOMP', libseccomp.found())
296 pkgconfig_libs += libseccomp
297 if libseccomp.found()
298 if libseccomp.version().version_compare('>=2.5.0')
299 # https://github.com/seccomp/libseccomp/commit/dead12bc788b259b148cc4d93b970ef0bd602b1a
300 srcconf.set10('HAVE_DECL_SECCOMP_NOTIFY_FD', true)
301 else
302 srcconf.set10('HAVE_DECL_SECCOMP_NOTIFY_FD', false)
303 endif
304
305 if libseccomp.version().version_compare('>=2.0.0')
306 # https://github.com/seccomp/libseccomp/commit/6220c8c0fc479d97b6d3e3166a4e46fbfe25a3c0
307 srcconf.set10('HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH', true)
308 else
309 srcconf.set10('HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH', false)
310 endif
311
312 seccomp_headers = '''
313 #include <seccomp.h>
314 '''
315
316 foreach decl: [
317 'scmp_filter_ctx',
318 'struct seccomp_notif_sizes',
319 'struct clone_args',
320 ]
321
322 # We get -1 if the size cannot be determined
323 if cc.sizeof(decl, prefix: seccomp_headers, args: '-D_GNU_SOURCE') > 0
324 srcconf.set10('HAVE_' + decl.underscorify().to_upper(), true)
325 else
326 srcconf.set10('HAVE_' + decl.underscorify().to_upper(), false)
327 endif
328 endforeach
329 endif
330
331 ## SELinux.
332 if want_selinux
333 libselinux = dependency('libselinux', required: false)
334 srcconf.set10('HAVE_SELINUX', libselinux.found())
335 pkgconfig_libs += libselinux
336 else
337 srcconf.set10('HAVE_SELINUX', false)
338 endif
339
340 ## AppArmor.
341 if want_apparmor
342 libapparmor = dependency('libapparmor', required: false)
343 srcconf.set10('HAVE_APPARMOR', libapparmor.found())
344 else
345 srcconf.set10('HAVE_APPARMOR', false)
346 endif
347
348 ## OpenSSL.
349 if want_openssl
350 libopenssl = dependency('openssl', required: false)
351 srcconf.set10('HAVE_OPENSSL', libopenssl.found())
352 pkgconfig_libs += libopenssl
353 else
354 srcconf.set10('HAVE_OPENSSL', false)
355 endif
356
357 ## Libcap..
358 if want_capabilities
359 libcap = dependency('libcap', required: false)
360 if not libcap.found()
361 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
362 libcap = cc.find_library('cap', required: false)
363 endif
364 srcconf.set10('HAVE_LIBCAP', libcap.found())
365 pkgconfig_libs += libcap
366
367 libcap_static = dependency('libcap', required: false, static: true)
368 if not libcap_static.found()
369 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
370 libcap_static = cc.find_library('cap', required: false, static: true)
371 endif
372 srcconf.set10('HAVE_STATIC_LIBCAP', libcap_static.found())
373 else
374 srcconf.set10('HAVE_LIBCAP', false)
375 srcconf.set10('HAVE_STATIC_LIBCAP', false)
376 endif
377
378 ## PAM.
379 pam = cc.find_library('pam', has_headers: 'security/pam_modules.h', required: want_pam_cgroup)
380 srcconf.set10('HAVE_PAM', pam.found())
381 pkgconfig_libs += pam
382
383 ## Others.
384 have = cc.has_function('strchrnul', prefix: '#include <string.h>', args: '-D_GNU_SOURCE')
385 srcconf.set10('HAVE_STRCHRNUL', have)
386
387 have = cc.has_function('openpty', prefix: '#include <pty.h>', args: '-D_GNU_SOURCE')
388 srcconf.set10('HAVE_OPENPTY', have)
389
390 ## Compiler attributes.
391 foreach ccattr: [
392 'fallthrough',
393 'nonnull',
394 'returns_nonnull',
395 ]
396
397 srcconf.set10('HAVE_COMPILER_ATTR_' + ccattr.underscorify().to_upper(), cc.has_function_attribute(ccattr))
398 endforeach
399
400 ## Syscalls.
401 found_syscalls = []
402 missing_syscalls = []
403 foreach tuple: [
404 ['bpf'],
405 ['close_range'],
406 ['endmntent'],
407 ['execveat'],
408 ['faccessat'],
409 ['strchrnul'],
410 ['fgetln'],
411 ['fsconfig'],
412 ['fsmount'],
413 ['fsopen'],
414 ['fspick'],
415 ['getgrgid_r'],
416 ['getline'],
417 ['getsubopt'],
418 ['gettid'],
419 ['hasmntopt'],
420 ['kcmp'],
421 ['keyctl'],
422 ['memfd_create'],
423 ['mount_setattr'],
424 ['move_mount'],
425 ['openat2'],
426 ['open_tree'],
427 ['personality'],
428 ['pidfd_open'],
429 ['pidfd_send_signal'],
430 ['pivot_root'],
431 ['prlimit'],
432 ['prlimit64'],
433 ['renameat2'],
434 ['sethostname'],
435 ['setmntent'],
436 ['setns'],
437 ['sigdescr_np'],
438 ['signalfd'],
439 ['statx'],
440 ['strlcat'],
441 ['strlcpy'],
442 ['unshare'],
443 ]
444
445 if tuple.length() >= 2
446 cond = tuple[1]
447 else
448 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
449 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
450 cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1
451 endif
452
453 if cond
454 found_syscalls += tuple[0]
455 else
456 missing_syscalls += tuple[0]
457 endif
458 endforeach
459
460 ## Types.
461 decl_headers = '''
462 #include <uchar.h>
463 #include <sys/mount.h>
464 #include <sys/stat.h>
465 #include <linux/fs.h>
466 #include <linux/types.h>
467 #include <linux/openat2.h>
468 #include <linux/sched.h>
469 '''
470
471 foreach decl: [
472 '__aligned_u64',
473 'struct mount_attr',
474 'struct open_how',
475 'struct clone_args',
476 ]
477
478 # We get -1 if the size cannot be determined
479 if cc.sizeof(decl, prefix: decl_headers, args: '-D_GNU_SOURCE') > 0
480 srcconf.set10('HAVE_' + decl.underscorify().to_upper(), true)
481 else
482 srcconf.set10('HAVE_' + decl.underscorify().to_upper(), false)
483 endif
484 endforeach
485
486 found_types = []
487 missing_types = []
488 foreach tuple: [
489 ['scmp_filter_ctx'],
490 ['struct seccomp_notif_sizes'],
491 ['struct clone_args'],
492 ['__aligned_u64'],
493 ['struct mount_attr'],
494 ['struct open_how'],
495 ]
496
497 if tuple.length() >= 2
498 cond = tuple[1]
499 else
500 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
501 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
502 cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1
503 endif
504
505 if cond
506 found_types += tuple[0]
507 else
508 missing_types += tuple[0]
509 endif
510 endforeach
511
512 ## Headers.
513 foreach ident: [
514 ['bpf', '''#include <sys/syscall.h>
515 #include <unistd.h>'''],
516 ['close_range', '''#include <unistd.h>'''],
517 ['execveat', '''#include <unistd.h>'''],
518 ['endmntent', '''#include <stdio.h>
519 #include <mntent.h>'''],
520 ['faccessat', '''#include <fcntl.h>
521 #include <unistd.h>'''],
522 ['fexecve', '''#include <unistd.h>'''],
523 ['fgetln', '''#include <stdio.h>'''],
524 ['fsconfig', '''#include <sys/mount.h>'''],
525 ['fsmount', '''#include <sys/mount.h>'''],
526 ['fsopen', '''#include <sys/mount.h>'''],
527 ['fspick', '''#include <sys/mount.h>'''],
528 ['getgrgid_r', '''#include <sys/types.h>
529 #include <grp.h>'''],
530 ['getline', '''#include <stdio.h>'''],
531 ['getsubopt', '''#include <stdlib.h>'''],
532 ['gettid', '''#include <sys/types.h>
533 #include <unistd.h>'''],
534 ['hasmntopt', '''#include <stdio.h>
535 #include <mntent.h>'''],
536 ['kcmp', '''#include <linux/kcmp.h>'''],
537 ['keyctl', '''#include <sys/types.h>
538 #include <keyutils.h>'''],
539 ['memfd_create', '''#include <sys/mman.h>'''],
540 ['mount_setattr', '''#include <sys/mount.h>'''],
541 ['move_mount', '''#include <sys/mount.h>'''],
542 ['openat2', '''#include <sys/types.h>
543 #include <sys/stat.h>
544 #include <fctnl.h>'''],
545 ['open_tree', '''#include <sys/mount.h>'''],
546 ['personality', '''#include <sys/personality.h>'''],
547 ['pidfd_open', '''#include <stdlib.h>
548 #include <unistd.h>
549 #include <signal.h>
550 #include <sys/wait.h>'''],
551 ['pidfd_send_signal', '''#include <stdlib.h>
552 #include <unistd.h>
553 #include <signal.h>
554 #include <sys/wait.h>'''],
555 ['pivot_root', '''#include <stdlib.h>
556 #include <unistd.h>'''], # no known header declares pivot_root
557 ['prlimit', '''#include <sys/time.h>
558 #include <sys/resource.h>'''],
559 ['prlimit64', '''#include <sys/time.h>
560 #include <sys/resource.h>'''],
561 ['renameat2', '''#include <stdio.h>
562 #include <fcntl.h>'''],
563 ['sethostname', '''#include <unistd.h>'''],
564 ['setmntent', '''#include <stdio.h>
565 #include <mntent.h>'''],
566 ['setns', '''#include <sched.h>'''],
567 ['sigdescr_np', '''#include <string.h>'''],
568 ['signalfd', '''#include <sys/signalfd.h>'''],
569 ['statx', '''#include <sys/types.h>
570 #include <sys/stat.h>
571 #include <unistd.h>'''],
572 ['strchrnul', '''#include <string.h>'''],
573 ['strlcat', '''#include <string.h>'''],
574 ['strlcpy', '''#include <string.h>'''],
575 ['unshare', '''#include <sched.h>'''],
576 ]
577
578 have = cc.has_function(ident[0], prefix: ident[1], args: '-D_GNU_SOURCE')
579 srcconf.set10('HAVE_' + ident[0].to_upper(), have)
580 endforeach
581
582 found_headers = []
583 missing_headers = []
584 foreach tuple: [
585 ['sys/resource.h'],
586 ['sys/memfd.h'],
587 ['sys/personality.h'],
588 ['sys/signalfd.h'],
589 ['sys/timerfd.h'],
590 ['pty.h'],
591 ['utmpx.h'],
592 ]
593 srcconf.set10('HAVE_' + tuple[0].underscorify().to_upper(), cc.has_header(tuple[0]))
594
595 if tuple.length() >= 2
596 cond = tuple[1]
597 else
598 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
599 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
600 cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1
601 endif
602
603 if cond
604 found_headers += tuple[0]
605 else
606 missing_headers += tuple[0]
607 endif
608 endforeach
609
610 ## Deps.
611 found_deps = []
612 missing_deps = []
613 foreach tuple: [
614 ['AppArmor'],
615 ['SECCOMP'],
616 ['SELinux'],
617 ['libcap'],
618 ['static libcap'],
619 ['pam'],
620 ['openssl'],
621 ['liburing'],
622 ]
623
624 if tuple.length() >= 2
625 cond = tuple[1]
626 else
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
630 endif
631
632 if cond
633 found_deps += tuple[0]
634 else
635 missing_deps += tuple[0]
636 endif
637 endforeach
638
639 # Generate config.h
640 config_h = configure_file(
641 output: 'config.h',
642 configuration: srcconf)
643
644 add_project_arguments('-include', 'config.h', language: 'c')
645
646 # Binaries.
647 cmd_programs = []
648 hook_programs = []
649 public_programs = []
650 template_scripts = []
651 test_programs = []
652
653 # Includes.
654 liblxc_includes = include_directories(
655 '.',
656 'src',
657 'src/include',
658 'src/lxc',
659 'src/lxc/cgroups',
660 'src/lxc/storage')
661
662 # Early sub-directories.
663 subdir('src/include')
664 subdir('src/lxc')
665 subdir('src/lxc/pam')
666
667 # Library.
668 liblxc_dependencies = [
669 threads,
670 libseccomp,
671 libcap,
672 libopenssl,
673 libselinux,
674 libapparmor,
675 ]
676
677 if want_io_uring
678 liblxc_dependencies += [liburing]
679 endif
680
681 liblxc_link_whole = []
682 if sanitize == 'none'
683 liblxc_link_whole = [liblxc_static]
684 endif
685
686 liblxc = shared_library(
687 'lxc',
688 version: liblxc_version,
689 include_directories: liblxc_includes,
690 link_args: ['-DPIC'],
691 c_args: ['-DPIC'],
692 link_whole: liblxc_link_whole,
693 dependencies: liblxc_dependencies,
694 install: true)
695
696 liblxc_dep = declare_dependency(
697 link_with: liblxc,
698 dependencies: liblxc_dependencies)
699
700 # Rest of sub-directories.
701 subdir('config/apparmor')
702 subdir('config/apparmor/abstractions')
703 subdir('config/apparmor/profiles')
704 subdir('config/bash')
705 subdir('config/etc')
706 subdir('config/init/common')
707 subdir('config/init/systemd')
708 subdir('config/init/sysvinit')
709 subdir('config/init/upstart')
710 subdir('config/selinux')
711 subdir('config/sysconfig')
712 subdir('config/templates')
713 subdir('config/templates/common.conf.d')
714 subdir('config/yum')
715 subdir('doc')
716 subdir('doc/ja')
717 subdir('doc/ko')
718 subdir('doc/examples')
719 subdir('doc/rootfs')
720 subdir('hooks')
721 if want_commands
722 subdir('src/lxc/cmd')
723 endif
724 if want_tools
725 subdir('src/lxc/tools')
726 endif
727 subdir('src/lxc/tools/include')
728 subdir('src/tests')
729 subdir('templates')
730
731 # Pkg-config.
732 pkg_config_file = pkgconfig.generate(liblxc,
733 description: 'linux container tools',
734 version: version_data.get('LXC_VERSION'),
735 url: 'http://linuxcontainers.org',
736 libraries: '-lutil -lpthread -ldl',
737 libraries_private: pkgconfig_libs,
738 )
739
740 # Empty dirs.
741 install_emptydir(join_paths(localstatedir, 'cache', 'lxc'))
742 install_emptydir(join_paths(localstatedir, 'lib', 'lxc'))
743
744 # RPM spec file.
745 specconf = configuration_data()
746 specconf.set('LXC_VERSION_BASE', meson.project_version())
747 specconf.set('LXC_VERSION_BETA', version_data.get('LXC_VERSION_BETA'))
748 specconf.set('PACKAGE', meson.project_name())
749 specconf.set('LXC_DISTRO_SYSCONF', conf.get('LXC_DISTRO_SYSCONF'))
750
751 configure_file(
752 configuration: specconf,
753 input: 'lxc.spec.in',
754 output: 'lxc.spec',
755 install: false)
756
757 # Build overview.
758 status = [
759 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
760
761 'Meson version: @0@'.format(meson.version()),
762
763 'prefix directory: @0@'.format(prefixdir),
764 'bin directory: @0@'.format(bindir),
765 'data directory: @0@'.format(datadir),
766 'doc directory: @0@'.format(docdir),
767 'include directory: @0@'.format(includedir),
768 'lib directory: @0@'.format(libdir),
769 'libexec directory: @0@'.format(libexecdir),
770 'local state directory: @0@'.format(localstatedir),
771 'sbin directory: @0@'.format(sbindir),
772 'sysconf directory: @0@'.format(sysconfdir),
773
774 'lxc cgroup pattern: @0@'.format(cgrouppattern),
775 'lxc init directory: @0@'.format(libexecdir),
776 'runtime path: @0@'.format(runtimepath),
777
778 'lxc default config: @0@'.format(lxcdefaultconfig),
779 'lxc global config: @0@'.format(lxcglobalconfig),
780 'lxc hook directory: @0@'.format(lxchookdir),
781 'lxc hook bin directory: @0@'.format(lxchookbindir),
782 'lxc rootfs mount directory: @0@'.format(lxcrootfsmount),
783 'log path: @0@'.format(lxclogpath),
784 'lxc path: @0@'.format(lxcpath),
785 'lxc template config: @0@'.format(lxctemplateconfdir),
786 'lxc template directory: @0@'.format(lxctemplatedir),
787 'lxc user network config: @0@'.format(lxc_user_network_conf),
788 'lxc user network database: @0@'.format(lxc_user_network_db)]
789
790 alt_time_epoch = run_command('date', '-Is', '-u', '-d',
791 '@@0@'.format(time_epoch), check: true).stdout().strip()
792 status += [
793 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
794
795 status += [
796 '',
797 'supported dependencies: @0@'.format(', '.join(found_deps)),
798 '',
799 'unsupported dependencies: @0@'.format(', '.join(missing_deps)),
800 '']
801
802 status += [
803 '',
804 'supported headers: @0@'.format(', '.join(found_headers)),
805 '',
806 'unsupported headers: @0@'.format(', '.join(missing_headers)),
807 '']
808
809 status += [
810 '',
811 'supported calls: @0@'.format(', '.join(found_syscalls)),
812 '',
813 'unsupported calls: @0@'.format(', '.join(missing_syscalls)),
814 '']
815
816 status += [
817 '',
818 'supported types: @0@'.format(', '.join(found_types)),
819 '',
820 'unsupported types: @0@'.format(', '.join(missing_types)),
821 '']
822
823 message('\n '.join(status))