]> git.proxmox.com Git - mirror_lxc.git/blame - meson.build
meson: Rename want_io_uring
[mirror_lxc.git] / meson.build
CommitLineData
9b9d56e6
CB
1# SPDX-License-Identifier: LGPL-2.1-or-later
2
20b03401
SG
3# Project.
4project(
5 'lxc',
6 'c',
7 version: '4.0.0',
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 ],
d841229e 19 meson_version: '>= 0.61')
9b9d56e6 20
20b03401
SG
21cc = meson.get_compiler('c')
22pkgconfig = import('pkgconfig')
0860988e 23pkgconfig_libs = []
9b9d56e6 24
20b03401 25# Version.
9b9d56e6
CB
26version_data = configuration_data()
27version_data.set('LXC_VERSION_MAJOR', '4')
28version_data.set('LXC_VERSION_MINOR', '0')
29version_data.set('LXC_VERSION_MICRO', '7')
30version_data.set('LXC_ABI', '4.0.7')
31version_data.set('LXC_DEVEL', '1')
32version_data.set('LXC_VERSION', '4.0.7-devel')
4c7c1431 33liblxc_version = '1.7.0'
20b03401
SG
34
35# Configuration options.
36conf = configuration_data()
37conf.set_quoted('PROJECT', meson.project_name())
38conf.set_quoted('PROJECT_URL', 'https://linuxcontainers.org/lxc/')
39conf.set_quoted('PROJECT_VERSION', meson.project_version())
40conf.set_quoted('PACKAGE_VERSION', meson.project_version())
41conf.set('_GNU_SOURCE', true)
42conf.set('_FILE_OFFSET_BITS', 64)
43conf.set('__STDC_FORMAT_MACROS', true)
9b9d56e6
CB
44
45project_source_root = meson.current_source_dir()
46project_build_root = meson.current_build_dir()
47
20b03401 48# Path handling.
9b9d56e6 49prefixdir = get_option('prefix')
20b03401 50
7609de18
SG
51apparmorcachedir = get_option('apparmor-cache-path')
52globalconfig = get_option('global-config-path')
20b03401
SG
53localstatedir = join_paths('/', get_option('localstatedir'))
54logpath = get_option('log-path')
7609de18
SG
55lxcpathprefix = get_option('data-path')
56rootfsmount = get_option('rootfs-mount-path')
57user_network_db_opt = get_option('usernet-db-path')
58user_network_conf_opt = get_option('usernet-config-path')
20b03401 59
4a858b56 60bashcompletiondir = join_paths('/', 'usr', 'share', 'bash-completion', 'completions')
9b9d56e6 61bindir = join_paths(prefixdir, get_option('bindir'))
bf1f3470 62datadir = join_paths(prefixdir, get_option('datadir'))
47c56c50 63mandir = join_paths(prefixdir, get_option('mandir'))
7609de18 64docdir = join_paths(datadir, get_option('doc-path'))
9b9d56e6
CB
65includedir = join_paths(prefixdir, get_option('includedir'))
66libdir = join_paths(prefixdir, get_option('libdir'))
67libexecdir = join_paths(prefixdir, get_option('libexecdir'))
20b03401 68runtimepath = join_paths(prefixdir, get_option('runtime-path'))
bf1f3470
CB
69sbindir = join_paths(prefixdir, get_option('sbindir'))
70sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
71
7609de18 72lxcapparmorcachedir = join_paths(localstatedir, apparmorcachedir)
9d18059b
SG
73lxcconfdir = join_paths(sysconfdir, globalconfig)
74lxcdefaultconfig = join_paths(lxcconfdir, 'default.conf')
75lxcglobalconfig = join_paths(lxcconfdir, 'lxc.conf')
7609de18 76lxcexamplesdir = join_paths(docdir, 'examples')
7609de18 77lxchookbindir = join_paths(libexecdir, 'lxc/hooks')
1a9afacc 78lxcinclude = join_paths(includedir, 'lxc')
2f1bf5f5 79lxclibexec = join_paths(libexecdir, 'lxc')
bf1f3470 80lxclogpath = join_paths(localstatedir, logpath)
bf1f3470 81lxcpath = join_paths(localstatedir, lxcpathprefix)
7609de18 82lxcrootfsmount = join_paths(libdir, rootfsmount)
51f90ad9
SG
83lxcdatadir = join_paths(datadir, 'lxc')
84lxchookdir = join_paths(lxcdatadir, 'hooks')
85lxcselinuxdir = join_paths(lxcdatadir, 'selinux')
86lxctemplateconfdir = join_paths(lxcdatadir, 'config')
87lxctemplateconfcommondir = join_paths(lxctemplateconfdir, 'common.conf.d')
88lxctemplatedir = join_paths(lxcdatadir, 'templates')
72f1c44a 89lxc_user_network_conf = join_paths(sysconfdir, user_network_conf_opt)
72f1c44a 90lxc_user_network_db = join_paths(runtimepath, user_network_db_opt)
8c48813a 91pam_security = join_paths(libdir, 'security')
72f1c44a 92
20b03401
SG
93conf.set_quoted('BINDIR', bindir)
94conf.set_quoted('DATADIR', datadir)
95conf.set_quoted('DOCDIR', docdir)
96conf.set_quoted('INCLUDEDIR', includedir)
97conf.set_quoted('LIBDIR', libdir)
98conf.set_quoted('LIBEXECDIR', libexecdir)
99conf.set_quoted('LOCALSTATEDIR', localstatedir)
100conf.set_quoted('RUNTIME_PATH', runtimepath)
101conf.set_quoted('SBINDIR', sbindir)
102conf.set_quoted('SYSCONFDIR', sysconfdir)
103
104conf.set_quoted('APPARMOR_CACHE_DIR', lxcapparmorcachedir)
105conf.set_quoted('LOGPATH', lxclogpath)
106conf.set_quoted('LXCBINHOOKDIR', lxchookbindir)
107conf.set_quoted('LXC_DEFAULT_CONFIG', lxcdefaultconfig)
108conf.set_quoted('LXC_GLOBAL_CONF', lxcglobalconfig)
109conf.set_quoted('LXCHOOKDIR', lxchookdir)
110conf.set_quoted('LXCINITDIR', libexecdir)
111conf.set_quoted('LXCPATH', lxcpath)
112conf.set_quoted('LXCROOTFSMOUNT', lxcrootfsmount)
51f90ad9 113conf.set_quoted('LXCTEMPLATECONFIG', lxctemplateconfdir)
20b03401
SG
114conf.set_quoted('LXCTEMPLATEDIR', lxctemplatedir)
115conf.set_quoted('LXC_USERNIC_CONF', lxc_user_network_conf)
116conf.set_quoted('LXC_USERNIC_DB', lxc_user_network_db)
117
118# Custom configuration.
119cgrouppattern = get_option('cgroup-pattern')
7609de18 120want_examples = get_option('examples')
7d8a38b2 121want_io_uring = get_option('io-uring-event-loop')
8c48813a 122want_pam_cgroup = get_option('pam-cgroup')
7609de18 123want_mans = get_option('man')
20b03401 124want_tests = get_option('tests')
b3d18992 125want_tools = get_option('tools')
20b03401
SG
126
127conf.set_quoted('DEFAULT_CGROUP_PATTERN', cgrouppattern)
9b9d56e6 128
20b03401
SG
129dummy_config_data = configuration_data()
130dummy_config_data.set_quoted('DUMMY_VARIABLE', '1')
9b9d56e6 131
20b03401 132# Build flags.
9b9d56e6 133possible_cc_flags = [
20b03401
SG
134 '-Wvla',
135 '-Wimplicit-fallthrough=5',
136 '-Wcast-align',
137 '-Wstrict-prototypes',
138 '-fno-strict-aliasing',
139 '-fstack-clash-protection',
140 '-fstack-protector-strong',
141 '--param=ssp-buffer-size=4',
142 '--mcet -fcf-protection',
143 '-Werror=implicit-function-declaration',
144 '-Wlogical-op',
145 '-Wmissing-include-dirs',
146 '-Wold-style-definition',
147 '-Winit-self',
148 '-Wunused-but-set-variable',
149 '-Wno-unused-parameter',
150 '-Wfloat-equal',
151 '-Wsuggest-attribute=noreturn',
152 '-Werror=return-type',
153 '-Werror=incompatible-pointer-types',
154 '-Wformat=2',
155 '-Wshadow',
156 '-Wendif-labels',
157 '-Werror=overflow',
158 '-fdiagnostics-show-option',
159 '-Werror=shift-count-overflow',
160 '-Werror=shift-overflow=2',
161 '-Wdate-time',
162 '-Wnested-externs',
163 '-fasynchronous-unwind-tables',
164 '-fexceptions',
165 '-Warray-bounds',
166 '-Wrestrict',
167 '-Wreturn-local-addr',
168 '-fsanitize=cfi',
169 '-Wstringop-overflow',
9b9d56e6
CB
170]
171
172possible_link_flags = [
20b03401
SG
173 '-Wl,--gc-sections',
174 '-Wl,-z,relro',
175 '-Wl,-z,now',
176 '-Wl,-fuse-ld=gold',
9b9d56e6
CB
177]
178
179if meson.version().version_compare('>=0.46')
20b03401 180 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language: 'c')
9b9d56e6 181else
20b03401 182 add_project_link_arguments(possible_link_flags, language: 'c')
9b9d56e6
CB
183endif
184
20b03401 185add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language: 'c')
9b9d56e6 186
20b03401
SG
187# Feature detection
188## I/O uring.
7d8a38b2 189if want_io_uring
20b03401
SG
190 liburing = dependency('liburing')
191 if cc.has_function('io_uring_prep_poll_add', prefix: '#include <liburing.h>', dependencies: liburing) == false
192 error('liburing version does not support IORING_POLL_ADD_MULTI')
193 endif
194
195 conf.set10('HAVE_LIBURING', true)
747bc634
CB
196endif
197
20b03401 198## Time EPOCH.
ea6da257 199sh = find_program('sh')
23ba778f 200date = find_program('date')
20b03401 201git = find_program('git', required: false)
aa326e18
SG
202time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check: true).stdout().strip()
203if time_epoch == '' and git.found() and run_command('test', '-e', '.git', check: false).returncode() == 0
20b03401 204 # If we're in a git repository, use the creation time of the latest git tag.
aa326e18
SG
205 latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags', check: true).stdout().strip()
206 time_epoch = run_command(git, 'log', '--no-show-signature', '-1', '--format=%at', latest_tag, check: true).stdout()
23ba778f
SG
207else
208 # Fallback to current epoch
209 time_epoch = run_command(date, '+%s', check: true).stdout()
ea6da257 210endif
47c56c50 211generate_date = run_command(date, '--utc', '--date=@' + time_epoch, '+%Y-%m-%d', check: true).stdout().strip()
ea6da257
CB
212time_epoch = time_epoch.to_int()
213conf.set('TIME_EPOCH', time_epoch)
214
2bd9ab6f 215## Manpages.
4412d151 216sgml2man = find_program('docbook2X2man', 'docbook2x-man', 'db2x_docbook2man', 'docbook2man', 'docbook-to-man', required: want_mans)
2bd9ab6f
SG
217docbook2man = find_program('docbook2man', required: false)
218
219docconf = configuration_data()
220docconf.set('builddir', '.')
221docconf.set('LXC_GENERATE_DATE', generate_date)
222docconf.set('PACKAGE_VERSION', version_data.get('LXC_VERSION'))
223if sgml2man.found() and docbook2man.found() and sgml2man.full_path() == docbook2man.full_path()
224 docconf.set('docdtd', '"-//Davenport//DTD DocBook V3.0//EN"')
225else
226 docconf.set('docdtd', '"-//OASIS//DTD DocBook XML" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"')
227endif
228
20b03401 229## Threads.
9b9d56e6 230threads = dependency('threads')
20b03401
SG
231
232## Seccomp.
e4384f1c 233libseccomp = dependency('libseccomp')
c597905e 234conf.set10('HAVE_SECCOMP', libseccomp.found())
181cd6dc 235pkgconfig_libs += libseccomp
9b9d56e6 236if libseccomp.found()
20b03401
SG
237 if libseccomp.version().version_compare('>=2.5.0')
238 # https://github.com/seccomp/libseccomp/commit/dead12bc788b259b148cc4d93b970ef0bd602b1a
239 conf.set10('HAVE_DECL_SECCOMP_NOTIFY_FD', true)
240 else
241 conf.set10('HAVE_DECL_SECCOMP_NOTIFY_FD', false)
242 endif
243
244 if libseccomp.version().version_compare('>=2.0.0')
245 # https://github.com/seccomp/libseccomp/commit/6220c8c0fc479d97b6d3e3166a4e46fbfe25a3c0
246 conf.set10('HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH', true)
247 else
248 conf.set10('HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH', false)
249 endif
250
251 seccomp_headers = '''
252 #include <seccomp.h>
253 '''
254
255 foreach decl: [
256 'scmp_filter_ctx',
257 'struct seccomp_notif_sizes',
258 'struct clone_args',
259 ]
260
261 # We get -1 if the size cannot be determined
262 if cc.sizeof(decl, prefix: seccomp_headers, args: '-D_GNU_SOURCE') > 0
263 conf.set10('HAVE_' + decl.underscorify().to_upper(), true)
264 else
265 conf.set10('HAVE_' + decl.underscorify().to_upper(), false)
266 endif
267 endforeach
9b9d56e6
CB
268endif
269
20b03401
SG
270## SELinux.
271libselinux = dependency('libselinux', required: false)
c597905e 272conf.set10('HAVE_SELINUX', libselinux.found())
181cd6dc 273pkgconfig_libs += libselinux
9b9d56e6 274
20b03401
SG
275## AppArmor.
276libapparmor = dependency('libapparmor', required: false)
c597905e 277conf.set10('HAVE_APPARMOR', libapparmor.found())
9b9d56e6 278
20b03401
SG
279## OpenSSL.
280libopenssl = dependency('openssl', required: false)
c597905e 281conf.set10('HAVE_OPENSSL', libopenssl.found())
181cd6dc 282pkgconfig_libs += libopenssl
9b9d56e6 283
20b03401
SG
284## Libcap..
285libcap = dependency('libcap', required: false)
9b9d56e6 286if not libcap.found()
20b03401
SG
287 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
288 libcap = cc.find_library('cap', required: false)
9b9d56e6 289endif
c597905e 290conf.set10('HAVE_LIBCAP', libcap.found())
181cd6dc 291pkgconfig_libs += libcap
9b9d56e6 292
20b03401 293libcap_static = dependency('libcap', required: false, static: true)
d0a16061 294if not libcap_static.found()
20b03401
SG
295 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
296 libcap_static = cc.find_library('cap', required: false, static: true)
d0a16061 297endif
c597905e 298conf.set10('HAVE_STATIC_LIBCAP', libcap_static.found())
d0a16061 299
0860988e 300## PAM.
8c48813a 301pam = cc.find_library('pam', has_headers: 'security/pam_modules.h', required: want_pam_cgroup)
0860988e 302conf.set10('HAVE_PAM', pam.found())
181cd6dc 303pkgconfig_libs += pam
0860988e 304
20b03401
SG
305## Others.
306have = cc.has_function('strchrnul', prefix: '#include <string.h>', args: '-D_GNU_SOURCE')
db4af8c5
CB
307conf.set10('HAVE_STRCHRNUL', have)
308
20b03401 309have = cc.has_function('openpty', prefix: '#include <pty.h>', args: '-D_GNU_SOURCE')
db4af8c5
CB
310conf.set10('HAVE_OPENPTY', have)
311
20b03401
SG
312## Compiler attributes.
313foreach ccattr: [
314 'fallthrough',
315 'nonnull',
316 'returns_nonnull',
317]
ae13cb3b 318
20b03401 319 conf.set10('HAVE_COMPILER_ATTR_' + ccattr.underscorify().to_upper(), cc.has_function_attribute(ccattr))
ae13cb3b 320endforeach
5c26176d 321
20b03401 322## Syscalls.
ea6da257
CB
323found_syscalls = []
324missing_syscalls = []
20b03401
SG
325foreach tuple: [
326 ['bpf'],
327 ['close_range'],
328 ['endmntent'],
329 ['execveat'],
330 ['faccessat'],
331 ['strchrnul'],
332 ['fgetln'],
333 ['fsconfig'],
334 ['fsmount'],
335 ['fsopen'],
336 ['fspick'],
337 ['getgrgid_r'],
338 ['getline'],
339 ['getsubopt'],
340 ['gettid'],
341 ['hasmntopt'],
342 ['kcmp'],
343 ['keyctl'],
344 ['memfd_create'],
345 ['mount_setattr'],
346 ['move_mount'],
347 ['openat2'],
348 ['open_tree'],
349 ['personality'],
350 ['pidfd_open'],
351 ['pidfd_send_signal'],
352 ['pivot_root'],
353 ['prlimit'],
354 ['prlimit64'],
355 ['renameat2'],
356 ['sethostname'],
357 ['setmntent'],
358 ['setns'],
359 ['sigdescr_np'],
360 ['signalfd'],
361 ['statx'],
362 ['strlcat'],
363 ['strlcpy'],
364 ['unshare'],
365]
366
367 if tuple.length() >= 2
368 cond = tuple[1]
369 else
370 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
371 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
372 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
373 endif
374
375 if cond
376 found_syscalls += tuple[0]
377 else
378 missing_syscalls += tuple[0]
379 endif
380endforeach
381
382## Types.
383decl_headers = '''
384#include <uchar.h>
385#include <sys/mount.h>
386#include <sys/stat.h>
387#include <linux/fs.h>
388#include <linux/types.h>
389#include <linux/openat2.h>
390#include <linux/sched.h>
391'''
ea6da257 392
20b03401
SG
393foreach decl: [
394 '__aligned_u64',
395 'struct mount_attr',
396 'struct open_how',
397 'struct clone_args',
ea6da257
CB
398]
399
20b03401
SG
400 # We get -1 if the size cannot be determined
401 if cc.sizeof(decl, prefix: decl_headers, args: '-D_GNU_SOURCE') > 0
402 conf.set10('HAVE_' + decl.underscorify().to_upper(), true)
403 else
404 conf.set10('HAVE_' + decl.underscorify().to_upper(), false)
405 endif
ea6da257
CB
406endforeach
407
408found_types = []
409missing_types = []
20b03401
SG
410foreach tuple: [
411 ['scmp_filter_ctx'],
412 ['struct seccomp_notif_sizes'],
413 ['struct clone_args'],
414 ['__aligned_u64'],
415 ['struct mount_attr'],
416 ['struct open_how'],
417]
ea6da257 418
20b03401
SG
419 if tuple.length() >= 2
420 cond = tuple[1]
421 else
422 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
423 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
424 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
425 endif
426
427 if cond
428 found_types += tuple[0]
429 else
430 missing_types += tuple[0]
431 endif
432endforeach
433
434## Headers.
435foreach ident: [
436 ['bpf', '''#include <sys/syscall.h>
437 #include <unistd.h>'''],
438 ['close_range', '''#include <unistd.h>'''],
439 ['execveat', '''#include <unistd.h>'''],
440 ['endmntent', '''#include <stdio.h>
441 #include <mntent.h>'''],
442 ['faccessat', '''#include <fcntl.h>
443 #include <unistd.h>'''],
444 ['fexecve', '''#include <unistd.h>'''],
445 ['fgetln', '''#include <stdio.h>'''],
446 ['fsconfig', '''#include <sys/mount.h>'''],
447 ['fsmount', '''#include <sys/mount.h>'''],
448 ['fsopen', '''#include <sys/mount.h>'''],
449 ['fspick', '''#include <sys/mount.h>'''],
450 ['getgrgid_r', '''#include <sys/types.h>
451 #include <grp.h>'''],
452 ['getline', '''#include <stdio.h>'''],
453 ['getsubopt', '''#include <stdlib.h>'''],
454 ['gettid', '''#include <sys/types.h>
455 #include <unistd.h>'''],
456 ['hasmntopt', '''#include <stdio.h>
457 #include <mntent.h>'''],
458 ['kcmp', '''#include <linux/kcmp.h>'''],
459 ['keyctl', '''#include <sys/types.h>
460 #include <keyutils.h>'''],
461 ['memfd_create', '''#include <sys/mman.h>'''],
462 ['mount_setattr', '''#include <sys/mount.h>'''],
463 ['move_mount', '''#include <sys/mount.h>'''],
464 ['openat2', '''#include <sys/types.h>
465 #include <sys/stat.h>
466 #include <fctnl.h>'''],
467 ['open_tree', '''#include <sys/mount.h>'''],
468 ['personality', '''#include <sys/personality.h>'''],
469 ['pidfd_open', '''#include <stdlib.h>
470 #include <unistd.h>
471 #include <signal.h>
472 #include <sys/wait.h>'''],
473 ['pidfd_send_signal', '''#include <stdlib.h>
474 #include <unistd.h>
475 #include <signal.h>
476 #include <sys/wait.h>'''],
477 ['pivot_root', '''#include <stdlib.h>
478 #include <unistd.h>'''], # no known header declares pivot_root
479 ['prlimit', '''#include <sys/time.h>
480 #include <sys/resource.h>'''],
481 ['prlimit64', '''#include <sys/time.h>
482 #include <sys/resource.h>'''],
483 ['renameat2', '''#include <stdio.h>
484 #include <fcntl.h>'''],
485 ['sethostname', '''#include <unistd.h>'''],
486 ['setmntent', '''#include <stdio.h>
487 #include <mntent.h>'''],
488 ['setns', '''#include <sched.h>'''],
489 ['sigdescr_np', '''#include <string.h>'''],
490 ['signalfd', '''#include <sys/signalfd.h>'''],
491 ['statx', '''#include <sys/types.h>
492 #include <sys/stat.h>
493 #include <unistd.h>'''],
494 ['strchrnul', '''#include <string.h>'''],
495 ['strlcat', '''#include <string.h>'''],
496 ['strlcpy', '''#include <string.h>'''],
497 ['unshare', '''#include <sched.h>'''],
ea6da257
CB
498]
499
20b03401
SG
500 have = cc.has_function(ident[0], prefix: ident[1], args: '-D_GNU_SOURCE')
501 conf.set10('HAVE_' + ident[0].to_upper(), have)
ea6da257
CB
502endforeach
503
504found_headers = []
505missing_headers = []
20b03401
SG
506foreach tuple: [
507 ['sys/resource.h'],
508 ['sys/memfd.h'],
509 ['sys/personality.h'],
510 ['sys/signalfd.h'],
511 ['sys/timerfd.h'],
512 ['pty.h'],
513 ['utmpx.h'],
ea6da257 514]
20b03401
SG
515 conf.set10('HAVE_' + tuple[0].underscorify().to_upper(), cc.has_header(tuple[0]))
516
517 if tuple.length() >= 2
518 cond = tuple[1]
519 else
520 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
521 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
522 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
523 endif
524
525 if cond
526 found_headers += tuple[0]
527 else
528 missing_headers += tuple[0]
529 endif
ea6da257
CB
530endforeach
531
20b03401 532## Deps.
ea6da257
CB
533found_deps = []
534missing_deps = []
20b03401
SG
535foreach tuple: [
536 ['AppArmor'],
537 ['SECCOMP'],
538 ['SELinux'],
539 ['libcap'],
540 ['static libcap'],
8c48813a 541 ['pam'],
20b03401
SG
542 ['openssl'],
543 ['liburing'],
ea6da257
CB
544]
545
20b03401
SG
546 if tuple.length() >= 2
547 cond = tuple[1]
548 else
549 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
550 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
551 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
552 endif
553
554 if cond
555 found_deps += tuple[0]
556 else
557 missing_deps += tuple[0]
558 endif
ea6da257
CB
559endforeach
560
20b03401
SG
561# Generate config.h
562config_h = configure_file(
563 output: 'config.h',
564 configuration: conf)
565
566add_project_arguments('-include', 'config.h', language: 'c')
567
568# Binaries.
569cmd_programs = []
570hook_programs = []
571public_programs = []
572template_scripts = []
573test_programs = []
574
575# Includes.
576basic_includes = include_directories(
577 '.',
578 'src',
579 'src/include')
580
581liblxc_includes = [basic_includes, include_directories(
582 'src/lxc/cgroups',
583 'src/lxc/lsm',
584 'src/lxc/storage')]
585
586# Early sub-directories.
587subdir('src/include')
588subdir('src/lxc')
24dcd86d 589subdir('src/lxc/pam')
20b03401
SG
590
591# Library.
592liblxc_dependencies = [
593 threads,
594 libseccomp,
595 libcap,
596 libopenssl,
597 libselinux,
598 libapparmor,
599]
600
7d8a38b2 601if want_io_uring
20b03401
SG
602 liblxc_dependencies += [liburing]
603endif
604
605liblxc = shared_library(
606 'lxc',
607 version: liblxc_version,
608 include_directories: liblxc_includes,
609 link_args: ['-DPIC'],
610 c_args: ['-DPIC'],
611 link_whole: [liblxc_static],
612 dependencies: liblxc_dependencies,
613 install: true)
614
615liblxc_dep = declare_dependency(
616 link_with: liblxc,
617 dependencies: liblxc_dependencies)
618
619# Rest of sub-directories.
4a858b56 620subdir('config/bash')
9d18059b 621subdir('config/etc')
e4e52844
SG
622subdir('config/init/common')
623subdir('config/init/systemd')
7c927048 624subdir('config/selinux')
c2931f74
SG
625subdir('config/templates')
626subdir('config/templates/common.conf.d')
d9121fff 627subdir('config/yum')
47c56c50
SG
628subdir('doc')
629subdir('doc/ja')
630subdir('doc/ko')
b3da01d7 631subdir('doc/examples')
6dfabed1 632subdir('doc/rootfs')
20b03401
SG
633subdir('hooks')
634subdir('src/lxc/cmd')
635subdir('src/lxc/tools')
636subdir('src/lxc/tools/include')
637subdir('src/tests')
638subdir('templates')
639
0860988e
SG
640# Pkg-config.
641pkg_config_file = pkgconfig.generate(liblxc,
642 description: 'linux container tools',
643 version: version_data.get('LXC_VERSION'),
644 url: 'http://linuxcontainers.org',
645 libraries: '-lutil -lpthread -ldl',
646 libraries_private: pkgconfig_libs,
0860988e
SG
647)
648
1404fcb8
SG
649# Empty dirs.
650install_emptydir(join_paths(localstatedir, 'cache', 'lxc'))
651install_emptydir(join_paths(localstatedir, 'lib', 'lxc'))
652
20b03401 653# Build overview.
bf1f3470 654status = [
20b03401
SG
655 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
656
657 'Meson version: @0@'.format(meson.version()),
658
659 'prefix directory: @0@'.format(prefixdir),
660 'bin directory: @0@'.format(bindir),
661 'data directory: @0@'.format(datadir),
662 'doc directory: @0@'.format(docdir),
663 'include directory: @0@'.format(includedir),
664 'lib directory: @0@'.format(libdir),
665 'libexec directory: @0@'.format(libexecdir),
666 'local state directory: @0@'.format(localstatedir),
667 'sbin directory: @0@'.format(sbindir),
668 'sysconf directory: @0@'.format(sysconfdir),
669
670 'lxc cgroup pattern: @0@'.format(cgrouppattern),
671 'lxc init directory: @0@'.format(libexecdir),
672 'runtime path: @0@'.format(runtimepath),
673
674 'lxc default config: @0@'.format(lxcdefaultconfig),
675 'lxc global config: @0@'.format(lxcglobalconfig),
676 'lxc hook directory: @0@'.format(lxchookdir),
677 'lxc hook bin directory: @0@'.format(lxchookbindir),
678 'lxc rootfs mount directory: @0@'.format(lxcrootfsmount),
679 'log path: @0@'.format(lxclogpath),
680 'lxc path: @0@'.format(lxcpath),
51f90ad9 681 'lxc template config: @0@'.format(lxctemplateconfdir),
20b03401
SG
682 'lxc template directory: @0@'.format(lxctemplatedir),
683 'lxc user network config: @0@'.format(lxc_user_network_conf),
684 'lxc user network database: @0@'.format(lxc_user_network_db)]
bf1f3470 685
ea6da257 686alt_time_epoch = run_command('date', '-Is', '-u', '-d',
aa326e18 687 '@@0@'.format(time_epoch), check: true).stdout().strip()
ea6da257 688status += [
20b03401 689 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
ea6da257
CB
690
691status += [
20b03401
SG
692 '',
693 'supported dependencies: @0@'.format(', '.join(found_deps)),
694 '',
695 'unsupported dependencies: @0@'.format(', '.join(missing_deps)),
696 '']
ea6da257
CB
697
698status += [
20b03401
SG
699 '',
700 'supported headers: @0@'.format(', '.join(found_headers)),
701 '',
702 'unsupported headers: @0@'.format(', '.join(missing_headers)),
703 '']
ea6da257
CB
704
705status += [
20b03401
SG
706 '',
707 'supported calls: @0@'.format(', '.join(found_syscalls)),
708 '',
709 'unsupported calls: @0@'.format(', '.join(missing_syscalls)),
710 '']
ea6da257
CB
711
712status += [
20b03401
SG
713 '',
714 'supported types: @0@'.format(', '.join(found_types)),
715 '',
716 'unsupported types: @0@'.format(', '.join(missing_types)),
717 '']
ea6da257 718
20b03401 719message('\n '.join(status))