]>
Commit | Line | Data |
---|---|---|
9b9d56e6 CB |
1 | # SPDX-License-Identifier: LGPL-2.1-or-later |
2 | ||
20b03401 SG |
3 | # Project. |
4 | project( | |
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 |
21 | cc = meson.get_compiler('c') |
22 | pkgconfig = import('pkgconfig') | |
0860988e | 23 | pkgconfig_libs = [] |
9b9d56e6 | 24 | |
20b03401 | 25 | # Version. |
9b9d56e6 CB |
26 | version_data = configuration_data() |
27 | version_data.set('LXC_VERSION_MAJOR', '4') | |
28 | version_data.set('LXC_VERSION_MINOR', '0') | |
29 | version_data.set('LXC_VERSION_MICRO', '7') | |
30 | version_data.set('LXC_ABI', '4.0.7') | |
31 | version_data.set('LXC_DEVEL', '1') | |
32 | version_data.set('LXC_VERSION', '4.0.7-devel') | |
4c7c1431 | 33 | liblxc_version = '1.7.0' |
20b03401 SG |
34 | |
35 | # Configuration options. | |
36 | conf = configuration_data() | |
37 | conf.set_quoted('PROJECT', meson.project_name()) | |
38 | conf.set_quoted('PROJECT_URL', 'https://linuxcontainers.org/lxc/') | |
39 | conf.set_quoted('PROJECT_VERSION', meson.project_version()) | |
40 | conf.set_quoted('PACKAGE_VERSION', meson.project_version()) | |
41 | conf.set('_GNU_SOURCE', true) | |
42 | conf.set('_FILE_OFFSET_BITS', 64) | |
43 | conf.set('__STDC_FORMAT_MACROS', true) | |
9b9d56e6 CB |
44 | |
45 | project_source_root = meson.current_source_dir() | |
46 | project_build_root = meson.current_build_dir() | |
47 | ||
20b03401 | 48 | # Path handling. |
9b9d56e6 | 49 | prefixdir = get_option('prefix') |
20b03401 | 50 | |
7609de18 SG |
51 | apparmorcachedir = get_option('apparmor-cache-path') |
52 | globalconfig = get_option('global-config-path') | |
20b03401 SG |
53 | localstatedir = join_paths('/', get_option('localstatedir')) |
54 | logpath = get_option('log-path') | |
7609de18 SG |
55 | lxcpathprefix = get_option('data-path') |
56 | rootfsmount = get_option('rootfs-mount-path') | |
57 | user_network_db_opt = get_option('usernet-db-path') | |
58 | user_network_conf_opt = get_option('usernet-config-path') | |
20b03401 | 59 | |
4a858b56 | 60 | bashcompletiondir = join_paths('/', 'usr', 'share', 'bash-completion', 'completions') |
9b9d56e6 | 61 | bindir = join_paths(prefixdir, get_option('bindir')) |
bf1f3470 | 62 | datadir = join_paths(prefixdir, get_option('datadir')) |
47c56c50 | 63 | mandir = join_paths(prefixdir, get_option('mandir')) |
7609de18 | 64 | docdir = join_paths(datadir, get_option('doc-path')) |
9b9d56e6 CB |
65 | includedir = join_paths(prefixdir, get_option('includedir')) |
66 | libdir = join_paths(prefixdir, get_option('libdir')) | |
67 | libexecdir = join_paths(prefixdir, get_option('libexecdir')) | |
20b03401 | 68 | runtimepath = join_paths(prefixdir, get_option('runtime-path')) |
bf1f3470 CB |
69 | sbindir = join_paths(prefixdir, get_option('sbindir')) |
70 | sysconfdir = join_paths(prefixdir, get_option('sysconfdir')) | |
71 | ||
7609de18 | 72 | lxcapparmorcachedir = join_paths(localstatedir, apparmorcachedir) |
9d18059b SG |
73 | lxcconfdir = join_paths(sysconfdir, globalconfig) |
74 | lxcdefaultconfig = join_paths(lxcconfdir, 'default.conf') | |
75 | lxcglobalconfig = join_paths(lxcconfdir, 'lxc.conf') | |
7609de18 | 76 | lxcexamplesdir = join_paths(docdir, 'examples') |
7609de18 | 77 | lxchookbindir = join_paths(libexecdir, 'lxc/hooks') |
1a9afacc | 78 | lxcinclude = join_paths(includedir, 'lxc') |
2f1bf5f5 | 79 | lxclibexec = join_paths(libexecdir, 'lxc') |
bf1f3470 | 80 | lxclogpath = join_paths(localstatedir, logpath) |
bf1f3470 | 81 | lxcpath = join_paths(localstatedir, lxcpathprefix) |
7609de18 | 82 | lxcrootfsmount = join_paths(libdir, rootfsmount) |
51f90ad9 SG |
83 | lxcdatadir = join_paths(datadir, 'lxc') |
84 | lxchookdir = join_paths(lxcdatadir, 'hooks') | |
85 | lxcselinuxdir = join_paths(lxcdatadir, 'selinux') | |
86 | lxctemplateconfdir = join_paths(lxcdatadir, 'config') | |
87 | lxctemplateconfcommondir = join_paths(lxctemplateconfdir, 'common.conf.d') | |
88 | lxctemplatedir = join_paths(lxcdatadir, 'templates') | |
72f1c44a | 89 | lxc_user_network_conf = join_paths(sysconfdir, user_network_conf_opt) |
72f1c44a | 90 | lxc_user_network_db = join_paths(runtimepath, user_network_db_opt) |
8c48813a | 91 | pam_security = join_paths(libdir, 'security') |
72f1c44a | 92 | |
20b03401 SG |
93 | conf.set_quoted('BINDIR', bindir) |
94 | conf.set_quoted('DATADIR', datadir) | |
95 | conf.set_quoted('DOCDIR', docdir) | |
96 | conf.set_quoted('INCLUDEDIR', includedir) | |
97 | conf.set_quoted('LIBDIR', libdir) | |
98 | conf.set_quoted('LIBEXECDIR', libexecdir) | |
99 | conf.set_quoted('LOCALSTATEDIR', localstatedir) | |
100 | conf.set_quoted('RUNTIME_PATH', runtimepath) | |
101 | conf.set_quoted('SBINDIR', sbindir) | |
102 | conf.set_quoted('SYSCONFDIR', sysconfdir) | |
103 | ||
104 | conf.set_quoted('APPARMOR_CACHE_DIR', lxcapparmorcachedir) | |
105 | conf.set_quoted('LOGPATH', lxclogpath) | |
106 | conf.set_quoted('LXCBINHOOKDIR', lxchookbindir) | |
107 | conf.set_quoted('LXC_DEFAULT_CONFIG', lxcdefaultconfig) | |
108 | conf.set_quoted('LXC_GLOBAL_CONF', lxcglobalconfig) | |
109 | conf.set_quoted('LXCHOOKDIR', lxchookdir) | |
110 | conf.set_quoted('LXCINITDIR', libexecdir) | |
111 | conf.set_quoted('LXCPATH', lxcpath) | |
112 | conf.set_quoted('LXCROOTFSMOUNT', lxcrootfsmount) | |
51f90ad9 | 113 | conf.set_quoted('LXCTEMPLATECONFIG', lxctemplateconfdir) |
20b03401 SG |
114 | conf.set_quoted('LXCTEMPLATEDIR', lxctemplatedir) |
115 | conf.set_quoted('LXC_USERNIC_CONF', lxc_user_network_conf) | |
116 | conf.set_quoted('LXC_USERNIC_DB', lxc_user_network_db) | |
117 | ||
299f3f80 SG |
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 | ||
20b03401 SG |
130 | # Custom configuration. |
131 | cgrouppattern = get_option('cgroup-pattern') | |
8131bb44 | 132 | init_script = get_option('init-script') |
7609de18 | 133 | want_examples = get_option('examples') |
7d8a38b2 | 134 | want_io_uring = get_option('io-uring-event-loop') |
8c48813a | 135 | want_pam_cgroup = get_option('pam-cgroup') |
7609de18 | 136 | want_mans = get_option('man') |
20b03401 | 137 | want_tests = get_option('tests') |
b3d18992 | 138 | want_tools = get_option('tools') |
20b03401 SG |
139 | |
140 | conf.set_quoted('DEFAULT_CGROUP_PATTERN', cgrouppattern) | |
9b9d56e6 | 141 | |
20b03401 SG |
142 | dummy_config_data = configuration_data() |
143 | dummy_config_data.set_quoted('DUMMY_VARIABLE', '1') | |
9b9d56e6 | 144 | |
20b03401 | 145 | # Build flags. |
9b9d56e6 | 146 | possible_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 | ||
185 | possible_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 | ||
192 | if meson.version().version_compare('>=0.46') | |
20b03401 | 193 | add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language: 'c') |
9b9d56e6 | 194 | else |
20b03401 | 195 | add_project_link_arguments(possible_link_flags, language: 'c') |
9b9d56e6 CB |
196 | endif |
197 | ||
20b03401 | 198 | add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language: 'c') |
9b9d56e6 | 199 | |
20b03401 SG |
200 | # Feature detection |
201 | ## I/O uring. | |
7d8a38b2 | 202 | if 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 |
209 | endif |
210 | ||
20b03401 | 211 | ## Time EPOCH. |
ea6da257 | 212 | sh = find_program('sh') |
23ba778f | 213 | date = find_program('date') |
20b03401 | 214 | git = find_program('git', required: false) |
aa326e18 SG |
215 | time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check: true).stdout().strip() |
216 | if 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 |
220 | else |
221 | # Fallback to current epoch | |
222 | time_epoch = run_command(date, '+%s', check: true).stdout() | |
ea6da257 | 223 | endif |
47c56c50 | 224 | generate_date = run_command(date, '--utc', '--date=@' + time_epoch, '+%Y-%m-%d', check: true).stdout().strip() |
ea6da257 CB |
225 | time_epoch = time_epoch.to_int() |
226 | conf.set('TIME_EPOCH', time_epoch) | |
227 | ||
2bd9ab6f | 228 | ## Manpages. |
4412d151 | 229 | sgml2man = find_program('docbook2X2man', 'docbook2x-man', 'db2x_docbook2man', 'docbook2man', 'docbook-to-man', required: want_mans) |
2bd9ab6f SG |
230 | docbook2man = find_program('docbook2man', required: false) |
231 | ||
232 | docconf = configuration_data() | |
233 | docconf.set('builddir', '.') | |
f80af4e1 SG |
234 | docconf.set('BINDIR', bindir) |
235 | docconf.set('DATADIR', datadir) | |
236 | docconf.set('DOCDIR', docdir) | |
237 | docconf.set('LOGPATH', lxclogpath) | |
238 | docconf.set('LXC_DEFAULT_CONFIG', lxcdefaultconfig) | |
2bd9ab6f | 239 | docconf.set('LXC_GENERATE_DATE', generate_date) |
f80af4e1 SG |
240 | docconf.set('LXC_GLOBAL_CONF', lxcglobalconfig) |
241 | docconf.set('LXCPATH', lxcpath) | |
242 | docconf.set('LXCTEMPLATEDIR', lxctemplatedir) | |
243 | docconf.set('LXC_USERNIC_CONF', lxc_user_network_conf) | |
244 | docconf.set('LXC_USERNIC_DB', lxc_user_network_db) | |
2bd9ab6f SG |
245 | docconf.set('PACKAGE_VERSION', version_data.get('LXC_VERSION')) |
246 | if sgml2man.found() and docbook2man.found() and sgml2man.full_path() == docbook2man.full_path() | |
247 | docconf.set('docdtd', '"-//Davenport//DTD DocBook V3.0//EN"') | |
248 | else | |
249 | docconf.set('docdtd', '"-//OASIS//DTD DocBook XML" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"') | |
250 | endif | |
251 | ||
20b03401 | 252 | ## Threads. |
9b9d56e6 | 253 | threads = dependency('threads') |
20b03401 SG |
254 | |
255 | ## Seccomp. | |
e4384f1c | 256 | libseccomp = dependency('libseccomp') |
c597905e | 257 | conf.set10('HAVE_SECCOMP', libseccomp.found()) |
181cd6dc | 258 | pkgconfig_libs += libseccomp |
9b9d56e6 | 259 | if 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 |
291 | endif |
292 | ||
20b03401 SG |
293 | ## SELinux. |
294 | libselinux = dependency('libselinux', required: false) | |
c597905e | 295 | conf.set10('HAVE_SELINUX', libselinux.found()) |
181cd6dc | 296 | pkgconfig_libs += libselinux |
9b9d56e6 | 297 | |
20b03401 SG |
298 | ## AppArmor. |
299 | libapparmor = dependency('libapparmor', required: false) | |
c597905e | 300 | conf.set10('HAVE_APPARMOR', libapparmor.found()) |
9b9d56e6 | 301 | |
20b03401 SG |
302 | ## OpenSSL. |
303 | libopenssl = dependency('openssl', required: false) | |
c597905e | 304 | conf.set10('HAVE_OPENSSL', libopenssl.found()) |
181cd6dc | 305 | pkgconfig_libs += libopenssl |
9b9d56e6 | 306 | |
20b03401 SG |
307 | ## Libcap.. |
308 | libcap = dependency('libcap', required: false) | |
9b9d56e6 | 309 | if 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 | 312 | endif |
c597905e | 313 | conf.set10('HAVE_LIBCAP', libcap.found()) |
181cd6dc | 314 | pkgconfig_libs += libcap |
9b9d56e6 | 315 | |
20b03401 | 316 | libcap_static = dependency('libcap', required: false, static: true) |
d0a16061 | 317 | if 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 | 320 | endif |
c597905e | 321 | conf.set10('HAVE_STATIC_LIBCAP', libcap_static.found()) |
d0a16061 | 322 | |
0860988e | 323 | ## PAM. |
8c48813a | 324 | pam = cc.find_library('pam', has_headers: 'security/pam_modules.h', required: want_pam_cgroup) |
0860988e | 325 | conf.set10('HAVE_PAM', pam.found()) |
181cd6dc | 326 | pkgconfig_libs += pam |
0860988e | 327 | |
20b03401 SG |
328 | ## Others. |
329 | have = cc.has_function('strchrnul', prefix: '#include <string.h>', args: '-D_GNU_SOURCE') | |
db4af8c5 CB |
330 | conf.set10('HAVE_STRCHRNUL', have) |
331 | ||
20b03401 | 332 | have = cc.has_function('openpty', prefix: '#include <pty.h>', args: '-D_GNU_SOURCE') |
db4af8c5 CB |
333 | conf.set10('HAVE_OPENPTY', have) |
334 | ||
20b03401 SG |
335 | ## Compiler attributes. |
336 | foreach 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 | 343 | endforeach |
5c26176d | 344 | |
20b03401 | 345 | ## Syscalls. |
ea6da257 CB |
346 | found_syscalls = [] |
347 | missing_syscalls = [] | |
20b03401 SG |
348 | foreach 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 | |
403 | endforeach | |
404 | ||
405 | ## Types. | |
406 | decl_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 |
416 | foreach 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 |
429 | endforeach |
430 | ||
431 | found_types = [] | |
432 | missing_types = [] | |
20b03401 SG |
433 | foreach 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 | |
455 | endforeach | |
456 | ||
457 | ## Headers. | |
458 | foreach 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 |
525 | endforeach |
526 | ||
527 | found_headers = [] | |
528 | missing_headers = [] | |
20b03401 SG |
529 | foreach 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 |
553 | endforeach |
554 | ||
20b03401 | 555 | ## Deps. |
ea6da257 CB |
556 | found_deps = [] |
557 | missing_deps = [] | |
20b03401 SG |
558 | foreach 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 |
582 | endforeach |
583 | ||
20b03401 SG |
584 | # Generate config.h |
585 | config_h = configure_file( | |
586 | output: 'config.h', | |
587 | configuration: conf) | |
588 | ||
589 | add_project_arguments('-include', 'config.h', language: 'c') | |
590 | ||
591 | # Binaries. | |
592 | cmd_programs = [] | |
593 | hook_programs = [] | |
594 | public_programs = [] | |
595 | template_scripts = [] | |
596 | test_programs = [] | |
597 | ||
598 | # Includes. | |
599 | basic_includes = include_directories( | |
600 | '.', | |
601 | 'src', | |
602 | 'src/include') | |
603 | ||
604 | liblxc_includes = [basic_includes, include_directories( | |
605 | 'src/lxc/cgroups', | |
606 | 'src/lxc/lsm', | |
607 | 'src/lxc/storage')] | |
608 | ||
609 | # Early sub-directories. | |
610 | subdir('src/include') | |
611 | subdir('src/lxc') | |
24dcd86d | 612 | subdir('src/lxc/pam') |
20b03401 SG |
613 | |
614 | # Library. | |
615 | liblxc_dependencies = [ | |
616 | threads, | |
617 | libseccomp, | |
618 | libcap, | |
619 | libopenssl, | |
620 | libselinux, | |
621 | libapparmor, | |
622 | ] | |
623 | ||
7d8a38b2 | 624 | if want_io_uring |
20b03401 SG |
625 | liblxc_dependencies += [liburing] |
626 | endif | |
627 | ||
628 | liblxc = 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 | ||
638 | liblxc_dep = declare_dependency( | |
639 | link_with: liblxc, | |
640 | dependencies: liblxc_dependencies) | |
641 | ||
642 | # Rest of sub-directories. | |
6105cc7f SG |
643 | subdir('config/apparmor') |
644 | subdir('config/apparmor/abstractions') | |
645 | subdir('config/apparmor/profiles') | |
4a858b56 | 646 | subdir('config/bash') |
9d18059b | 647 | subdir('config/etc') |
e4e52844 SG |
648 | subdir('config/init/common') |
649 | subdir('config/init/systemd') | |
8131bb44 SG |
650 | subdir('config/init/sysvinit') |
651 | subdir('config/init/upstart') | |
7c927048 | 652 | subdir('config/selinux') |
36a53f30 | 653 | subdir('config/sysconfig') |
c2931f74 SG |
654 | subdir('config/templates') |
655 | subdir('config/templates/common.conf.d') | |
d9121fff | 656 | subdir('config/yum') |
47c56c50 SG |
657 | subdir('doc') |
658 | subdir('doc/ja') | |
659 | subdir('doc/ko') | |
b3da01d7 | 660 | subdir('doc/examples') |
6dfabed1 | 661 | subdir('doc/rootfs') |
20b03401 SG |
662 | subdir('hooks') |
663 | subdir('src/lxc/cmd') | |
664 | subdir('src/lxc/tools') | |
665 | subdir('src/lxc/tools/include') | |
666 | subdir('src/tests') | |
667 | subdir('templates') | |
668 | ||
0860988e SG |
669 | # Pkg-config. |
670 | pkg_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. |
679 | install_emptydir(join_paths(localstatedir, 'cache', 'lxc')) | |
680 | install_emptydir(join_paths(localstatedir, 'lib', 'lxc')) | |
681 | ||
20b03401 | 682 | # Build overview. |
bf1f3470 | 683 | status = [ |
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 | 715 | alt_time_epoch = run_command('date', '-Is', '-u', '-d', |
aa326e18 | 716 | '@@0@'.format(time_epoch), check: true).stdout().strip() |
ea6da257 | 717 | status += [ |
20b03401 | 718 | 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)] |
ea6da257 CB |
719 | |
720 | status += [ | |
20b03401 SG |
721 | '', |
722 | 'supported dependencies: @0@'.format(', '.join(found_deps)), | |
723 | '', | |
724 | 'unsupported dependencies: @0@'.format(', '.join(missing_deps)), | |
725 | ''] | |
ea6da257 CB |
726 | |
727 | status += [ | |
20b03401 SG |
728 | '', |
729 | 'supported headers: @0@'.format(', '.join(found_headers)), | |
730 | '', | |
731 | 'unsupported headers: @0@'.format(', '.join(missing_headers)), | |
732 | ''] | |
ea6da257 CB |
733 | |
734 | status += [ | |
20b03401 SG |
735 | '', |
736 | 'supported calls: @0@'.format(', '.join(found_syscalls)), | |
737 | '', | |
738 | 'unsupported calls: @0@'.format(', '.join(missing_syscalls)), | |
739 | ''] | |
ea6da257 CB |
740 | |
741 | status += [ | |
20b03401 SG |
742 | '', |
743 | 'supported types: @0@'.format(', '.join(found_types)), | |
744 | '', | |
745 | 'unsupported types: @0@'.format(', '.join(missing_types)), | |
746 | ''] | |
ea6da257 | 747 | |
20b03401 | 748 | message('\n '.join(status)) |