]>
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 | ||
118 | # Custom configuration. | |
119 | cgrouppattern = get_option('cgroup-pattern') | |
7609de18 | 120 | want_examples = get_option('examples') |
7d8a38b2 | 121 | want_io_uring = get_option('io-uring-event-loop') |
8c48813a | 122 | want_pam_cgroup = get_option('pam-cgroup') |
7609de18 | 123 | want_mans = get_option('man') |
20b03401 | 124 | want_tests = get_option('tests') |
b3d18992 | 125 | want_tools = get_option('tools') |
20b03401 SG |
126 | |
127 | conf.set_quoted('DEFAULT_CGROUP_PATTERN', cgrouppattern) | |
9b9d56e6 | 128 | |
20b03401 SG |
129 | dummy_config_data = configuration_data() |
130 | dummy_config_data.set_quoted('DUMMY_VARIABLE', '1') | |
9b9d56e6 | 131 | |
20b03401 | 132 | # Build flags. |
9b9d56e6 | 133 | possible_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 | ||
172 | possible_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 | ||
179 | if meson.version().version_compare('>=0.46') | |
20b03401 | 180 | add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language: 'c') |
9b9d56e6 | 181 | else |
20b03401 | 182 | add_project_link_arguments(possible_link_flags, language: 'c') |
9b9d56e6 CB |
183 | endif |
184 | ||
20b03401 | 185 | add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language: 'c') |
9b9d56e6 | 186 | |
20b03401 SG |
187 | # Feature detection |
188 | ## I/O uring. | |
7d8a38b2 | 189 | if 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 |
196 | endif |
197 | ||
20b03401 | 198 | ## Time EPOCH. |
ea6da257 | 199 | sh = find_program('sh') |
23ba778f | 200 | date = find_program('date') |
20b03401 | 201 | git = find_program('git', required: false) |
aa326e18 SG |
202 | time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check: true).stdout().strip() |
203 | if 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 |
207 | else |
208 | # Fallback to current epoch | |
209 | time_epoch = run_command(date, '+%s', check: true).stdout() | |
ea6da257 | 210 | endif |
47c56c50 | 211 | generate_date = run_command(date, '--utc', '--date=@' + time_epoch, '+%Y-%m-%d', check: true).stdout().strip() |
ea6da257 CB |
212 | time_epoch = time_epoch.to_int() |
213 | conf.set('TIME_EPOCH', time_epoch) | |
214 | ||
2bd9ab6f | 215 | ## Manpages. |
4412d151 | 216 | sgml2man = find_program('docbook2X2man', 'docbook2x-man', 'db2x_docbook2man', 'docbook2man', 'docbook-to-man', required: want_mans) |
2bd9ab6f SG |
217 | docbook2man = find_program('docbook2man', required: false) |
218 | ||
219 | docconf = configuration_data() | |
220 | docconf.set('builddir', '.') | |
221 | docconf.set('LXC_GENERATE_DATE', generate_date) | |
222 | docconf.set('PACKAGE_VERSION', version_data.get('LXC_VERSION')) | |
223 | if sgml2man.found() and docbook2man.found() and sgml2man.full_path() == docbook2man.full_path() | |
224 | docconf.set('docdtd', '"-//Davenport//DTD DocBook V3.0//EN"') | |
225 | else | |
226 | docconf.set('docdtd', '"-//OASIS//DTD DocBook XML" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"') | |
227 | endif | |
228 | ||
20b03401 | 229 | ## Threads. |
9b9d56e6 | 230 | threads = dependency('threads') |
20b03401 SG |
231 | |
232 | ## Seccomp. | |
e4384f1c | 233 | libseccomp = dependency('libseccomp') |
c597905e | 234 | conf.set10('HAVE_SECCOMP', libseccomp.found()) |
181cd6dc | 235 | pkgconfig_libs += libseccomp |
9b9d56e6 | 236 | if 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 |
268 | endif |
269 | ||
20b03401 SG |
270 | ## SELinux. |
271 | libselinux = dependency('libselinux', required: false) | |
c597905e | 272 | conf.set10('HAVE_SELINUX', libselinux.found()) |
181cd6dc | 273 | pkgconfig_libs += libselinux |
9b9d56e6 | 274 | |
20b03401 SG |
275 | ## AppArmor. |
276 | libapparmor = dependency('libapparmor', required: false) | |
c597905e | 277 | conf.set10('HAVE_APPARMOR', libapparmor.found()) |
9b9d56e6 | 278 | |
20b03401 SG |
279 | ## OpenSSL. |
280 | libopenssl = dependency('openssl', required: false) | |
c597905e | 281 | conf.set10('HAVE_OPENSSL', libopenssl.found()) |
181cd6dc | 282 | pkgconfig_libs += libopenssl |
9b9d56e6 | 283 | |
20b03401 SG |
284 | ## Libcap.. |
285 | libcap = dependency('libcap', required: false) | |
9b9d56e6 | 286 | if 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 | 289 | endif |
c597905e | 290 | conf.set10('HAVE_LIBCAP', libcap.found()) |
181cd6dc | 291 | pkgconfig_libs += libcap |
9b9d56e6 | 292 | |
20b03401 | 293 | libcap_static = dependency('libcap', required: false, static: true) |
d0a16061 | 294 | if 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 | 297 | endif |
c597905e | 298 | conf.set10('HAVE_STATIC_LIBCAP', libcap_static.found()) |
d0a16061 | 299 | |
0860988e | 300 | ## PAM. |
8c48813a | 301 | pam = cc.find_library('pam', has_headers: 'security/pam_modules.h', required: want_pam_cgroup) |
0860988e | 302 | conf.set10('HAVE_PAM', pam.found()) |
181cd6dc | 303 | pkgconfig_libs += pam |
0860988e | 304 | |
20b03401 SG |
305 | ## Others. |
306 | have = cc.has_function('strchrnul', prefix: '#include <string.h>', args: '-D_GNU_SOURCE') | |
db4af8c5 CB |
307 | conf.set10('HAVE_STRCHRNUL', have) |
308 | ||
20b03401 | 309 | have = cc.has_function('openpty', prefix: '#include <pty.h>', args: '-D_GNU_SOURCE') |
db4af8c5 CB |
310 | conf.set10('HAVE_OPENPTY', have) |
311 | ||
20b03401 SG |
312 | ## Compiler attributes. |
313 | foreach 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 | 320 | endforeach |
5c26176d | 321 | |
20b03401 | 322 | ## Syscalls. |
ea6da257 CB |
323 | found_syscalls = [] |
324 | missing_syscalls = [] | |
20b03401 SG |
325 | foreach 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 | |
380 | endforeach | |
381 | ||
382 | ## Types. | |
383 | decl_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 |
393 | foreach 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 |
406 | endforeach |
407 | ||
408 | found_types = [] | |
409 | missing_types = [] | |
20b03401 SG |
410 | foreach 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 | |
432 | endforeach | |
433 | ||
434 | ## Headers. | |
435 | foreach 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 |
502 | endforeach |
503 | ||
504 | found_headers = [] | |
505 | missing_headers = [] | |
20b03401 SG |
506 | foreach 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 |
530 | endforeach |
531 | ||
20b03401 | 532 | ## Deps. |
ea6da257 CB |
533 | found_deps = [] |
534 | missing_deps = [] | |
20b03401 SG |
535 | foreach 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 |
559 | endforeach |
560 | ||
20b03401 SG |
561 | # Generate config.h |
562 | config_h = configure_file( | |
563 | output: 'config.h', | |
564 | configuration: conf) | |
565 | ||
566 | add_project_arguments('-include', 'config.h', language: 'c') | |
567 | ||
568 | # Binaries. | |
569 | cmd_programs = [] | |
570 | hook_programs = [] | |
571 | public_programs = [] | |
572 | template_scripts = [] | |
573 | test_programs = [] | |
574 | ||
575 | # Includes. | |
576 | basic_includes = include_directories( | |
577 | '.', | |
578 | 'src', | |
579 | 'src/include') | |
580 | ||
581 | liblxc_includes = [basic_includes, include_directories( | |
582 | 'src/lxc/cgroups', | |
583 | 'src/lxc/lsm', | |
584 | 'src/lxc/storage')] | |
585 | ||
586 | # Early sub-directories. | |
587 | subdir('src/include') | |
588 | subdir('src/lxc') | |
24dcd86d | 589 | subdir('src/lxc/pam') |
20b03401 SG |
590 | |
591 | # Library. | |
592 | liblxc_dependencies = [ | |
593 | threads, | |
594 | libseccomp, | |
595 | libcap, | |
596 | libopenssl, | |
597 | libselinux, | |
598 | libapparmor, | |
599 | ] | |
600 | ||
7d8a38b2 | 601 | if want_io_uring |
20b03401 SG |
602 | liblxc_dependencies += [liburing] |
603 | endif | |
604 | ||
605 | liblxc = 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 | ||
615 | liblxc_dep = declare_dependency( | |
616 | link_with: liblxc, | |
617 | dependencies: liblxc_dependencies) | |
618 | ||
619 | # Rest of sub-directories. | |
4a858b56 | 620 | subdir('config/bash') |
9d18059b | 621 | subdir('config/etc') |
e4e52844 SG |
622 | subdir('config/init/common') |
623 | subdir('config/init/systemd') | |
7c927048 | 624 | subdir('config/selinux') |
c2931f74 SG |
625 | subdir('config/templates') |
626 | subdir('config/templates/common.conf.d') | |
d9121fff | 627 | subdir('config/yum') |
47c56c50 SG |
628 | subdir('doc') |
629 | subdir('doc/ja') | |
630 | subdir('doc/ko') | |
b3da01d7 | 631 | subdir('doc/examples') |
6dfabed1 | 632 | subdir('doc/rootfs') |
20b03401 SG |
633 | subdir('hooks') |
634 | subdir('src/lxc/cmd') | |
635 | subdir('src/lxc/tools') | |
636 | subdir('src/lxc/tools/include') | |
637 | subdir('src/tests') | |
638 | subdir('templates') | |
639 | ||
0860988e SG |
640 | # Pkg-config. |
641 | pkg_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. |
650 | install_emptydir(join_paths(localstatedir, 'cache', 'lxc')) | |
651 | install_emptydir(join_paths(localstatedir, 'lib', 'lxc')) | |
652 | ||
20b03401 | 653 | # Build overview. |
bf1f3470 | 654 | status = [ |
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 | 686 | alt_time_epoch = run_command('date', '-Is', '-u', '-d', |
aa326e18 | 687 | '@@0@'.format(time_epoch), check: true).stdout().strip() |
ea6da257 | 688 | status += [ |
20b03401 | 689 | 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)] |
ea6da257 CB |
690 | |
691 | status += [ | |
20b03401 SG |
692 | '', |
693 | 'supported dependencies: @0@'.format(', '.join(found_deps)), | |
694 | '', | |
695 | 'unsupported dependencies: @0@'.format(', '.join(missing_deps)), | |
696 | ''] | |
ea6da257 CB |
697 | |
698 | status += [ | |
20b03401 SG |
699 | '', |
700 | 'supported headers: @0@'.format(', '.join(found_headers)), | |
701 | '', | |
702 | 'unsupported headers: @0@'.format(', '.join(missing_headers)), | |
703 | ''] | |
ea6da257 CB |
704 | |
705 | status += [ | |
20b03401 SG |
706 | '', |
707 | 'supported calls: @0@'.format(', '.join(found_syscalls)), | |
708 | '', | |
709 | 'unsupported calls: @0@'.format(', '.join(missing_syscalls)), | |
710 | ''] | |
ea6da257 CB |
711 | |
712 | status += [ | |
20b03401 SG |
713 | '', |
714 | 'supported types: @0@'.format(', '.join(found_types)), | |
715 | '', | |
716 | 'unsupported types: @0@'.format(', '.join(missing_types)), | |
717 | ''] | |
ea6da257 | 718 | |
20b03401 | 719 | message('\n '.join(status)) |