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