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