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