]>
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', | |
1f8c3557 | 7 | version: '5.0.0', |
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 | 27 | version_data = configuration_data() |
1f8c3557 | 28 | version_data.set('LXC_VERSION_MAJOR', '5') |
9b9d56e6 | 29 | version_data.set('LXC_VERSION_MINOR', '0') |
eba7f7a6 | 30 | version_data.set('LXC_VERSION_MICRO', '0') |
e18dbec7 | 31 | version_data.set('LXC_VERSION_BETA', '') |
eba7f7a6 | 32 | version_data.set('LXC_ABI', liblxc_version) |
e73520ad | 33 | version_data.set('LXC_DEVEL', '1') |
eba7f7a6 | 34 | version_data.set('LXC_VERSION', meson.project_version()) |
9b9d56e6 | 35 | |
eba7f7a6 | 36 | # Path handling. |
9b9d56e6 CB |
37 | project_source_root = meson.current_source_dir() |
38 | project_build_root = meson.current_build_dir() | |
9b9d56e6 | 39 | prefixdir = get_option('prefix') |
20b03401 | 40 | |
7609de18 SG |
41 | apparmorcachedir = get_option('apparmor-cache-path') |
42 | globalconfig = get_option('global-config-path') | |
20b03401 SG |
43 | localstatedir = join_paths('/', get_option('localstatedir')) |
44 | logpath = get_option('log-path') | |
7609de18 SG |
45 | lxcpathprefix = get_option('data-path') |
46 | rootfsmount = get_option('rootfs-mount-path') | |
47 | user_network_db_opt = get_option('usernet-db-path') | |
48 | user_network_conf_opt = get_option('usernet-config-path') | |
20b03401 | 49 | |
4a858b56 | 50 | bashcompletiondir = join_paths('/', 'usr', 'share', 'bash-completion', 'completions') |
9b9d56e6 | 51 | bindir = join_paths(prefixdir, get_option('bindir')) |
bf1f3470 | 52 | datadir = join_paths(prefixdir, get_option('datadir')) |
47c56c50 | 53 | mandir = join_paths(prefixdir, get_option('mandir')) |
7609de18 | 54 | docdir = join_paths(datadir, get_option('doc-path')) |
9b9d56e6 CB |
55 | includedir = join_paths(prefixdir, get_option('includedir')) |
56 | libdir = join_paths(prefixdir, get_option('libdir')) | |
57 | libexecdir = join_paths(prefixdir, get_option('libexecdir')) | |
20b03401 | 58 | runtimepath = join_paths(prefixdir, get_option('runtime-path')) |
bf1f3470 CB |
59 | sbindir = join_paths(prefixdir, get_option('sbindir')) |
60 | sysconfdir = join_paths(prefixdir, get_option('sysconfdir')) | |
61 | ||
7609de18 | 62 | lxcapparmorcachedir = join_paths(localstatedir, apparmorcachedir) |
9d18059b SG |
63 | lxcconfdir = join_paths(sysconfdir, globalconfig) |
64 | lxcdefaultconfig = join_paths(lxcconfdir, 'default.conf') | |
65 | lxcglobalconfig = join_paths(lxcconfdir, 'lxc.conf') | |
7609de18 | 66 | lxcexamplesdir = join_paths(docdir, 'examples') |
7609de18 | 67 | lxchookbindir = join_paths(libexecdir, 'lxc/hooks') |
1a9afacc | 68 | lxcinclude = join_paths(includedir, 'lxc') |
2f1bf5f5 | 69 | lxclibexec = join_paths(libexecdir, 'lxc') |
bf1f3470 | 70 | lxclogpath = join_paths(localstatedir, logpath) |
bf1f3470 | 71 | lxcpath = join_paths(localstatedir, lxcpathprefix) |
7609de18 | 72 | lxcrootfsmount = join_paths(libdir, rootfsmount) |
51f90ad9 SG |
73 | lxcdatadir = join_paths(datadir, 'lxc') |
74 | lxchookdir = join_paths(lxcdatadir, 'hooks') | |
75 | lxcselinuxdir = join_paths(lxcdatadir, 'selinux') | |
76 | lxctemplateconfdir = join_paths(lxcdatadir, 'config') | |
77 | lxctemplateconfcommondir = join_paths(lxctemplateconfdir, 'common.conf.d') | |
78 | lxctemplatedir = join_paths(lxcdatadir, 'templates') | |
72f1c44a | 79 | lxc_user_network_conf = join_paths(sysconfdir, user_network_conf_opt) |
72f1c44a | 80 | lxc_user_network_db = join_paths(runtimepath, user_network_db_opt) |
8c48813a | 81 | pam_security = join_paths(libdir, 'security') |
72f1c44a | 82 | |
eba7f7a6 SG |
83 | # Configuration options. |
84 | srcconf = configuration_data() | |
85 | srcconf.set('_GNU_SOURCE', true) | |
86 | srcconf.set('_FILE_OFFSET_BITS', 64) | |
87 | srcconf.set('__STDC_FORMAT_MACROS', true) | |
7b1836bc CB |
88 | |
89 | ## This is a hack to prevent any inclusion ofr linux/mount.h which causes | |
90 | ## conflicts with sys/mount.h all over the place | |
91 | srcconf.set('_LINUX_MOUNT_H', true) | |
92 | ||
eba7f7a6 SG |
93 | srcconf.set_quoted('APPARMOR_CACHE_DIR', lxcapparmorcachedir) |
94 | srcconf.set_quoted('LIBEXECDIR', libexecdir) | |
95 | srcconf.set_quoted('LOGPATH', lxclogpath) | |
96 | srcconf.set_quoted('LXC_DEFAULT_CONFIG', lxcdefaultconfig) | |
97 | srcconf.set_quoted('LXC_GLOBAL_CONF', lxcglobalconfig) | |
98 | srcconf.set_quoted('LXCINITDIR', libexecdir) | |
99 | srcconf.set_quoted('LXCPATH', lxcpath) | |
100 | srcconf.set_quoted('LXCROOTFSMOUNT', lxcrootfsmount) | |
101 | srcconf.set_quoted('LXCTEMPLATECONFIG', lxctemplateconfdir) | |
102 | srcconf.set_quoted('LXCTEMPLATECONFIG', lxctemplateconfdir) | |
103 | srcconf.set_quoted('LXCTEMPLATEDIR', lxctemplatedir) | |
104 | srcconf.set_quoted('LXC_USERNIC_CONF', lxc_user_network_conf) | |
105 | srcconf.set_quoted('LXC_USERNIC_DB', lxc_user_network_db) | |
106 | srcconf.set_quoted('RUNTIME_PATH', runtimepath) | |
107 | srcconf.set_quoted('SBINDIR', sbindir) | |
108 | ||
109 | conf = configuration_data() | |
110 | conf.set('BINDIR', bindir) | |
111 | conf.set('LIBEXECDIR', libexecdir) | |
112 | conf.set('LOCALSTATEDIR', localstatedir) | |
113 | conf.set('LXC_GLOBAL_CONF', lxcglobalconfig) | |
114 | conf.set('LXCHOOKDIR', lxchookdir) | |
115 | conf.set('LXCINITDIR', libexecdir) | |
116 | conf.set('LXCROOTFSMOUNT', lxcrootfsmount) | |
117 | conf.set('LXCTEMPLATECONFIG', lxctemplateconfdir) | |
118 | conf.set('LXCTEMPLATEDIR', lxctemplatedir) | |
119 | conf.set('PACKAGE_VERSION', meson.project_version()) | |
120 | conf.set('RUNTIME_PATH', runtimepath) | |
121 | conf.set('SYSCONFDIR', sysconfdir) | |
20b03401 | 122 | |
299f3f80 SG |
123 | # Set sysconfdir |
124 | fs = import('fs') | |
16ebb29d ĐTCD |
125 | distrosysconfdir = get_option('distrosysconfdir') |
126 | if distrosysconfdir != '' | |
127 | distrosysconfdir = join_paths(sysconfdir, distrosysconfdir) | |
128 | conf.set('LXC_DISTRO_SYSCONF', distrosysconfdir) | |
129 | elif fs.is_dir('/etc/sysconfig') | |
299f3f80 SG |
130 | distrosysconfdir = join_paths(sysconfdir, 'sysconfig') |
131 | conf.set('LXC_DISTRO_SYSCONF', distrosysconfdir) | |
132 | elif fs.is_dir('/etc/default') | |
133 | distrosysconfdir = join_paths(sysconfdir, 'default') | |
134 | conf.set('LXC_DISTRO_SYSCONF', distrosysconfdir) | |
135 | else | |
16ebb29d | 136 | error('"distrosysconfdir" is not set') |
299f3f80 SG |
137 | endif |
138 | ||
d5dff814 | 139 | # Cross-compile on Android. |
cd3d6515 | 140 | srcconf.set10('IS_BIONIC', host_machine.system() == 'android') |
d5dff814 | 141 | |
20b03401 SG |
142 | # Custom configuration. |
143 | cgrouppattern = get_option('cgroup-pattern') | |
4dd5e0cf | 144 | coverity = get_option('coverity-build') |
8131bb44 | 145 | init_script = get_option('init-script') |
5055c73d | 146 | sanitize = get_option('b_sanitize') |
7609de18 | 147 | want_examples = get_option('examples') |
7d8a38b2 | 148 | want_io_uring = get_option('io-uring-event-loop') |
8c48813a | 149 | want_pam_cgroup = get_option('pam-cgroup') |
7609de18 | 150 | want_mans = get_option('man') |
20b03401 | 151 | want_tests = get_option('tests') |
b3d18992 | 152 | want_tools = get_option('tools') |
f4d02217 | 153 | want_tools_multicall = get_option('tools-multicall') |
575d0e34 CB |
154 | want_commands = get_option('commands') |
155 | want_capabilities = get_option('capabilities') | |
156 | want_apparmor = get_option('apparmor') | |
157 | want_openssl = get_option('openssl') | |
158 | want_selinux = get_option('selinux') | |
d42a3b13 | 159 | want_oss_fuzz = get_option('oss-fuzz') |
0b9adfda | 160 | want_seccomp = get_option('seccomp') |
0c4549a3 | 161 | want_thread_safety = get_option('thread-safety') |
493bf2de | 162 | want_memfd_rexec = get_option('memfd-rexec') |
c55353f8 | 163 | want_sd_bus = get_option('sd-bus') |
20b03401 | 164 | |
eba7f7a6 | 165 | srcconf.set_quoted('DEFAULT_CGROUP_PATTERN', cgrouppattern) |
4dd5e0cf SG |
166 | if coverity |
167 | srcconf.set('ENABLE_COVERITY_BUILD', 1) | |
168 | endif | |
9b9d56e6 | 169 | |
20b03401 SG |
170 | dummy_config_data = configuration_data() |
171 | dummy_config_data.set_quoted('DUMMY_VARIABLE', '1') | |
9b9d56e6 | 172 | |
abc5e6bb CB |
173 | # Those generate many false positives, and we do not want to change the code to |
174 | # avoid them. | |
175 | basic_disabled_warnings = [ | |
176 | '-Wno-format-signedness', | |
177 | '-Wno-missing-field-initializers', | |
178 | '-Wno-unused-parameter', | |
179 | ] | |
180 | ||
20b03401 | 181 | # Build flags. |
9b9d56e6 | 182 | possible_cc_flags = [ |
20b03401 SG |
183 | '-Wvla', |
184 | '-Wimplicit-fallthrough=5', | |
185 | '-Wcast-align', | |
186 | '-Wstrict-prototypes', | |
187 | '-fno-strict-aliasing', | |
188 | '-fstack-clash-protection', | |
20b03401 SG |
189 | '--param=ssp-buffer-size=4', |
190 | '--mcet -fcf-protection', | |
191 | '-Werror=implicit-function-declaration', | |
192 | '-Wlogical-op', | |
193 | '-Wmissing-include-dirs', | |
194 | '-Wold-style-definition', | |
195 | '-Winit-self', | |
196 | '-Wunused-but-set-variable', | |
197 | '-Wno-unused-parameter', | |
198 | '-Wfloat-equal', | |
199 | '-Wsuggest-attribute=noreturn', | |
200 | '-Werror=return-type', | |
201 | '-Werror=incompatible-pointer-types', | |
202 | '-Wformat=2', | |
203 | '-Wshadow', | |
204 | '-Wendif-labels', | |
205 | '-Werror=overflow', | |
206 | '-fdiagnostics-show-option', | |
207 | '-Werror=shift-count-overflow', | |
208 | '-Werror=shift-overflow=2', | |
209 | '-Wdate-time', | |
210 | '-Wnested-externs', | |
211 | '-fasynchronous-unwind-tables', | |
212 | '-fexceptions', | |
213 | '-Warray-bounds', | |
214 | '-Wrestrict', | |
215 | '-Wreturn-local-addr', | |
216 | '-fsanitize=cfi', | |
217 | '-Wstringop-overflow', | |
9b9d56e6 CB |
218 | ] |
219 | ||
220 | possible_link_flags = [ | |
20b03401 SG |
221 | '-Wl,--gc-sections', |
222 | '-Wl,-z,relro', | |
223 | '-Wl,-z,now', | |
224 | '-Wl,-fuse-ld=gold', | |
abc5e6bb | 225 | '-fstack-protector', |
5e704fe3 | 226 | '-fstack-protector-strong', |
9b9d56e6 CB |
227 | ] |
228 | ||
abc5e6bb CB |
229 | if sanitize == 'none' |
230 | possible_link_flags += '-Wl,--warn-common' | |
231 | endif | |
232 | ||
233 | if cc.get_id() == 'clang' | |
234 | possible_cc_flags += [ | |
235 | '-Wno-typedef-redefinition', | |
236 | '-Wno-gnu-variable-sized-type-not-at-end', | |
237 | ] | |
238 | endif | |
239 | ||
9b9d56e6 | 240 | if meson.version().version_compare('>=0.46') |
20b03401 | 241 | add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language: 'c') |
9b9d56e6 | 242 | else |
20b03401 | 243 | add_project_link_arguments(possible_link_flags, language: 'c') |
9b9d56e6 CB |
244 | endif |
245 | ||
abc5e6bb | 246 | add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c') |
20b03401 | 247 | add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language: 'c') |
9b9d56e6 | 248 | |
d42a3b13 CB |
249 | if add_languages('cpp', required : want_oss_fuzz) |
250 | # Used only for tests | |
251 | cxx = meson.get_compiler('cpp') | |
252 | cxx_cmd = ' '.join(cxx.cmd_array()) | |
253 | add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp') | |
254 | endif | |
255 | ||
20b03401 SG |
256 | # Feature detection |
257 | ## I/O uring. | |
7d8a38b2 | 258 | if want_io_uring |
20b03401 SG |
259 | liburing = dependency('liburing') |
260 | if cc.has_function('io_uring_prep_poll_add', prefix: '#include <liburing.h>', dependencies: liburing) == false | |
261 | error('liburing version does not support IORING_POLL_ADD_MULTI') | |
262 | endif | |
263 | ||
eba7f7a6 | 264 | srcconf.set10('HAVE_LIBURING', true) |
4c96107d SG |
265 | else |
266 | srcconf.set10('HAVE_LIBURING', false) | |
747bc634 CB |
267 | endif |
268 | ||
c55353f8 SH |
269 | if not want_sd_bus.disabled() |
270 | has_sd_bus = true | |
271 | sd_bus_optional = want_sd_bus.auto() | |
272 | ||
273 | libsystemd = dependency('libsystemd', required: not sd_bus_optional) | |
274 | if not libsystemd.found() | |
275 | if not sd_bus_optional | |
276 | error('missing required libsystemd dependency') | |
277 | endif | |
278 | ||
279 | has_sd_bus = false | |
280 | endif | |
281 | ||
282 | if not cc.has_header('systemd/sd-bus.h') | |
283 | if not sd_bus_optional | |
284 | error('libsystemd misses required systemd/sd-bus.h header') | |
285 | endif | |
286 | ||
287 | has_sd_bus = false | |
288 | endif | |
289 | ||
290 | if not cc.has_header('systemd/sd-event.h') | |
291 | if not sd_bus_optional | |
292 | error('libsystemd misses required systemd/sd-event.h header') | |
293 | endif | |
294 | ||
295 | has_sd_bus = false | |
296 | endif | |
297 | ||
298 | if not cc.has_function('sd_bus_call_method_asyncv', prefix: '#include <systemd/sd-bus.h>', dependencies: libsystemd) | |
299 | if not sd_bus_optional | |
300 | error('libsystemd misses required sd_bus_call_method_asyncv function') | |
301 | endif | |
302 | ||
303 | has_sd_bus = false | |
304 | endif | |
305 | ||
306 | srcconf.set10('HAVE_LIBSYSTEMD', has_sd_bus) | |
307 | else | |
308 | has_sd_bus = false | |
309 | srcconf.set10('HAVE_LIBSYSTEMD', false) | |
310 | endif | |
311 | ||
20b03401 | 312 | ## Time EPOCH. |
ea6da257 | 313 | sh = find_program('sh') |
23ba778f | 314 | date = find_program('date') |
20b03401 | 315 | git = find_program('git', required: false) |
aa326e18 SG |
316 | time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check: true).stdout().strip() |
317 | if time_epoch == '' and git.found() and run_command('test', '-e', '.git', check: false).returncode() == 0 | |
20b03401 | 318 | # If we're in a git repository, use the creation time of the latest git tag. |
f7de7d7a SG |
319 | latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags', check: false).stdout().strip() |
320 | if latest_tag != '' | |
321 | time_epoch = run_command(git, 'log', '--no-show-signature', '-1', '--format=%at', latest_tag, check: true).stdout() | |
322 | endif | |
323 | endif | |
324 | ||
325 | # Fallback to current epoch. | |
326 | if time_epoch == '' | |
23ba778f | 327 | time_epoch = run_command(date, '+%s', check: true).stdout() |
ea6da257 | 328 | endif |
47c56c50 | 329 | generate_date = run_command(date, '--utc', '--date=@' + time_epoch, '+%Y-%m-%d', check: true).stdout().strip() |
ea6da257 | 330 | |
2bd9ab6f | 331 | ## Manpages. |
2bd9ab6f SG |
332 | docconf = configuration_data() |
333 | docconf.set('builddir', '.') | |
f80af4e1 SG |
334 | docconf.set('BINDIR', bindir) |
335 | docconf.set('DATADIR', datadir) | |
336 | docconf.set('DOCDIR', docdir) | |
337 | docconf.set('LOGPATH', lxclogpath) | |
338 | docconf.set('LXC_DEFAULT_CONFIG', lxcdefaultconfig) | |
2bd9ab6f | 339 | docconf.set('LXC_GENERATE_DATE', generate_date) |
f80af4e1 SG |
340 | docconf.set('LXC_GLOBAL_CONF', lxcglobalconfig) |
341 | docconf.set('LXCPATH', lxcpath) | |
342 | docconf.set('LXCTEMPLATEDIR', lxctemplatedir) | |
343 | docconf.set('LXC_USERNIC_CONF', lxc_user_network_conf) | |
344 | docconf.set('LXC_USERNIC_DB', lxc_user_network_db) | |
2bd9ab6f | 345 | docconf.set('PACKAGE_VERSION', version_data.get('LXC_VERSION')) |
06f99c25 CN |
346 | docconf.set('docdtd', '"-//OASIS//DTD DocBook XML" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"') |
347 | sgml2man = find_program('docbook2X2man', 'docbook2x-man', 'db2x_docbook2man', 'docbook2man', 'docbook-to-man', required: false, version: '>=0.8') | |
348 | if not sgml2man.found() | |
349 | sgml2man = find_program('docbook2man', required: false, version: '<0.8') | |
350 | if sgml2man.found() | |
351 | docconf.set('docdtd', '"-//Davenport//DTD DocBook V3.0//EN"') | |
352 | elif want_mans | |
353 | error('missing required docbook2x or docbook-utils dependency') | |
354 | endif | |
2bd9ab6f SG |
355 | endif |
356 | ||
20b03401 | 357 | ## Threads. |
9b9d56e6 | 358 | threads = dependency('threads') |
20b03401 SG |
359 | |
360 | ## Seccomp. | |
0b9adfda CB |
361 | if want_seccomp |
362 | libseccomp = dependency('libseccomp', required: false) | |
363 | srcconf.set10('HAVE_SECCOMP', libseccomp.found()) | |
364 | pkgconfig_libs += libseccomp | |
365 | if libseccomp.found() | |
366 | if libseccomp.version().version_compare('>=2.5.0') | |
367 | # https://github.com/seccomp/libseccomp/commit/dead12bc788b259b148cc4d93b970ef0bd602b1a | |
368 | srcconf.set10('HAVE_DECL_SECCOMP_NOTIFY_FD', true) | |
369 | else | |
370 | srcconf.set10('HAVE_DECL_SECCOMP_NOTIFY_FD', false) | |
371 | endif | |
20b03401 | 372 | |
0b9adfda CB |
373 | if libseccomp.version().version_compare('>=2.0.0') |
374 | # https://github.com/seccomp/libseccomp/commit/6220c8c0fc479d97b6d3e3166a4e46fbfe25a3c0 | |
375 | srcconf.set10('HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH', true) | |
20b03401 | 376 | else |
0b9adfda | 377 | srcconf.set10('HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH', false) |
20b03401 | 378 | endif |
0b9adfda CB |
379 | |
380 | seccomp_headers = ''' | |
381 | #include <seccomp.h> | |
382 | ''' | |
383 | ||
384 | foreach decl: [ | |
385 | 'scmp_filter_ctx', | |
386 | 'struct seccomp_notif_sizes', | |
387 | 'struct clone_args', | |
388 | ] | |
389 | ||
390 | # We get -1 if the size cannot be determined | |
391 | if cc.sizeof(decl, prefix: seccomp_headers, args: '-D_GNU_SOURCE') > 0 | |
392 | srcconf.set10('HAVE_' + decl.underscorify().to_upper(), true) | |
393 | else | |
394 | srcconf.set10('HAVE_' + decl.underscorify().to_upper(), false) | |
395 | endif | |
396 | endforeach | |
397 | endif | |
398 | else | |
399 | srcconf.set10('HAVE_SECCOMP', false) | |
9b9d56e6 CB |
400 | endif |
401 | ||
20b03401 | 402 | ## SELinux. |
575d0e34 CB |
403 | if want_selinux |
404 | libselinux = dependency('libselinux', required: false) | |
405 | srcconf.set10('HAVE_SELINUX', libselinux.found()) | |
406 | pkgconfig_libs += libselinux | |
407 | else | |
408 | srcconf.set10('HAVE_SELINUX', false) | |
409 | endif | |
9b9d56e6 | 410 | |
20b03401 | 411 | ## AppArmor. |
575d0e34 CB |
412 | if want_apparmor |
413 | libapparmor = dependency('libapparmor', required: false) | |
414 | srcconf.set10('HAVE_APPARMOR', libapparmor.found()) | |
415 | else | |
416 | srcconf.set10('HAVE_APPARMOR', false) | |
417 | endif | |
9b9d56e6 | 418 | |
20b03401 | 419 | ## OpenSSL. |
575d0e34 CB |
420 | if want_openssl |
421 | libopenssl = dependency('openssl', required: false) | |
422 | srcconf.set10('HAVE_OPENSSL', libopenssl.found()) | |
423 | pkgconfig_libs += libopenssl | |
424 | else | |
425 | srcconf.set10('HAVE_OPENSSL', false) | |
426 | endif | |
9b9d56e6 | 427 | |
20b03401 | 428 | ## Libcap.. |
575d0e34 CB |
429 | if want_capabilities |
430 | libcap = dependency('libcap', required: false) | |
431 | if not libcap.found() | |
432 | # Compat with Ubuntu 14.04 which ships libcap w/o .pc file | |
433 | libcap = cc.find_library('cap', required: false) | |
353f0f99 WB |
434 | else |
435 | have = cc.has_function('cap_get_file', dependencies: libcap, prefix: '#include <sys/capability.h>') | |
436 | srcconf.set10('LIBCAP_SUPPORTS_FILE_CAPABILITIES', have) | |
575d0e34 CB |
437 | endif |
438 | srcconf.set10('HAVE_LIBCAP', libcap.found()) | |
439 | pkgconfig_libs += libcap | |
9b9d56e6 | 440 | |
575d0e34 CB |
441 | libcap_static = dependency('libcap', required: false, static: true) |
442 | if not libcap_static.found() | |
443 | # Compat with Ubuntu 14.04 which ships libcap w/o .pc file | |
444 | libcap_static = cc.find_library('cap', required: false, static: true) | |
445 | endif | |
de4543d8 CB |
446 | |
447 | code = ''' | |
448 | int main(int argc, char *argv[]) { return 0; }; | |
449 | ''' | |
450 | if libcap_static.found() | |
451 | libcap_static_linkable = cc.links(code, args: '-static', dependencies: libcap_static) | |
452 | srcconf.set10('HAVE_STATIC_LIBCAP', libcap_static_linkable) | |
453 | else | |
454 | srcconf.set10('HAVE_STATIC_LIBCAP', false) | |
455 | endif | |
575d0e34 | 456 | else |
7d723548 | 457 | libcap_static = [] |
575d0e34 CB |
458 | srcconf.set10('HAVE_LIBCAP', false) |
459 | srcconf.set10('HAVE_STATIC_LIBCAP', false) | |
d0a16061 | 460 | endif |
d0a16061 | 461 | |
353f0f99 WB |
462 | libutil = cc.find_library('util', required: false) |
463 | ||
464 | oss_fuzz_dependencies = [] | |
d42a3b13 CB |
465 | if want_oss_fuzz |
466 | srcconf.set10('FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION', true) | |
467 | srcconf.set10('RUN_ON_OSS_FUZZ', true) | |
468 | fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine') | |
469 | endif | |
470 | ||
0c4549a3 | 471 | srcconf.set10('ENFORCE_THREAD_SAFETY', want_thread_safety) |
493bf2de | 472 | srcconf.set10('ENFORCE_MEMFD_REXEC', want_memfd_rexec) |
0c4549a3 | 473 | |
0860988e | 474 | ## PAM. |
8c48813a | 475 | pam = cc.find_library('pam', has_headers: 'security/pam_modules.h', required: want_pam_cgroup) |
eba7f7a6 | 476 | srcconf.set10('HAVE_PAM', pam.found()) |
181cd6dc | 477 | pkgconfig_libs += pam |
0860988e | 478 | |
20b03401 | 479 | ## Others. |
353f0f99 WB |
480 | have = cc.has_function('fmemopen', prefix: '#include <stdio.h>', args: '-D_GNU_SOURCE') |
481 | srcconf.set10('HAVE_FMEMOPEN', have) | |
482 | ||
483 | have_openpty = cc.has_function('openpty', dependencies: libutil, prefix: '#include <pty.h>') | |
484 | srcconf.set10('HAVE_OPENPTY', have_openpty) | |
485 | ||
486 | have = cc.has_function('pthread_setcancelstate', prefix: '#include <pthread.h>') | |
487 | srcconf.set10('HAVE_PTHREAD_SETCANCELSTATE', have) | |
488 | ||
489 | have = cc.has_function('rand_r') | |
490 | srcconf.set10('HAVE_RAND_R', have) | |
491 | ||
20b03401 | 492 | have = cc.has_function('strchrnul', prefix: '#include <string.h>', args: '-D_GNU_SOURCE') |
eba7f7a6 | 493 | srcconf.set10('HAVE_STRCHRNUL', have) |
db4af8c5 | 494 | |
0c4549a3 | 495 | have_func_strerror_r = cc.has_function('strerror_r', prefix: '#include <string.h>', args: '-D_GNU_SOURCE') |
9fea6122 | 496 | srcconf.set10('HAVE_STRERROR_R', have_func_strerror_r) |
0c4549a3 CB |
497 | |
498 | have_func_strerror_r_char_p = false | |
499 | ||
500 | if have_func_strerror_r | |
501 | code = ''' | |
502 | #define _GNU_SOURCE | |
503 | #include <string.h> | |
504 | int func (void) { | |
505 | char error_string[256]; | |
506 | char *ptr = strerror_r (-2, error_string, 256); | |
507 | char c = *strerror_r (-2, error_string, 256); | |
508 | return c != 0 && ptr != (void*) 0L; | |
509 | } | |
510 | ''' | |
511 | ||
512 | have_func_strerror_r_char_p = cc.compiles(code, name : 'strerror_r() returns char *') | |
513 | endif | |
514 | ||
515 | srcconf.set10('STRERROR_R_CHAR_P', have_func_strerror_r_char_p) | |
516 | ||
20b03401 SG |
517 | ## Compiler attributes. |
518 | foreach ccattr: [ | |
519 | 'fallthrough', | |
520 | 'nonnull', | |
521 | 'returns_nonnull', | |
522 | ] | |
ae13cb3b | 523 | |
eba7f7a6 | 524 | srcconf.set10('HAVE_COMPILER_ATTR_' + ccattr.underscorify().to_upper(), cc.has_function_attribute(ccattr)) |
ae13cb3b | 525 | endforeach |
5c26176d | 526 | |
20b03401 | 527 | ## Syscalls. |
ea6da257 CB |
528 | found_syscalls = [] |
529 | missing_syscalls = [] | |
20b03401 SG |
530 | foreach tuple: [ |
531 | ['bpf'], | |
532 | ['close_range'], | |
533 | ['endmntent'], | |
534 | ['execveat'], | |
535 | ['faccessat'], | |
536 | ['strchrnul'], | |
0c4549a3 | 537 | ['strerror_r'], |
20b03401 SG |
538 | ['fgetln'], |
539 | ['fsconfig'], | |
540 | ['fsmount'], | |
541 | ['fsopen'], | |
542 | ['fspick'], | |
543 | ['getgrgid_r'], | |
544 | ['getline'], | |
545 | ['getsubopt'], | |
546 | ['gettid'], | |
547 | ['hasmntopt'], | |
548 | ['kcmp'], | |
549 | ['keyctl'], | |
550 | ['memfd_create'], | |
551 | ['mount_setattr'], | |
552 | ['move_mount'], | |
553 | ['openat2'], | |
554 | ['open_tree'], | |
555 | ['personality'], | |
556 | ['pidfd_open'], | |
557 | ['pidfd_send_signal'], | |
558 | ['pivot_root'], | |
559 | ['prlimit'], | |
560 | ['prlimit64'], | |
561 | ['renameat2'], | |
562 | ['sethostname'], | |
563 | ['setmntent'], | |
564 | ['setns'], | |
565 | ['sigdescr_np'], | |
566 | ['signalfd'], | |
567 | ['statx'], | |
8ee615c2 | 568 | ['statvfs'], |
20b03401 SG |
569 | ['strlcat'], |
570 | ['strlcpy'], | |
571 | ['unshare'], | |
572 | ] | |
573 | ||
574 | if tuple.length() >= 2 | |
575 | cond = tuple[1] | |
576 | else | |
577 | ident1 = 'HAVE_' + tuple[0].underscorify().to_upper() | |
578 | ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper() | |
eba7f7a6 | 579 | cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1 |
20b03401 SG |
580 | endif |
581 | ||
582 | if cond | |
583 | found_syscalls += tuple[0] | |
584 | else | |
585 | missing_syscalls += tuple[0] | |
586 | endif | |
587 | endforeach | |
588 | ||
589 | ## Types. | |
590 | decl_headers = ''' | |
591 | #include <uchar.h> | |
592 | #include <sys/mount.h> | |
593 | #include <sys/stat.h> | |
353f0f99 | 594 | #include <linux/if_link.h> |
353f0f99 | 595 | #include <linux/types.h> |
20b03401 | 596 | ''' |
ea6da257 | 597 | |
20b03401 SG |
598 | foreach decl: [ |
599 | '__aligned_u64', | |
353f0f99 | 600 | 'struct clone_args', |
20b03401 | 601 | 'struct open_how', |
353f0f99 | 602 | 'struct rtnl_link_stats64', |
ea6da257 CB |
603 | ] |
604 | ||
20b03401 SG |
605 | # We get -1 if the size cannot be determined |
606 | if cc.sizeof(decl, prefix: decl_headers, args: '-D_GNU_SOURCE') > 0 | |
eba7f7a6 | 607 | srcconf.set10('HAVE_' + decl.underscorify().to_upper(), true) |
20b03401 | 608 | else |
eba7f7a6 | 609 | srcconf.set10('HAVE_' + decl.underscorify().to_upper(), false) |
20b03401 | 610 | endif |
ea6da257 CB |
611 | endforeach |
612 | ||
613 | found_types = [] | |
614 | missing_types = [] | |
20b03401 SG |
615 | foreach tuple: [ |
616 | ['scmp_filter_ctx'], | |
617 | ['struct seccomp_notif_sizes'], | |
618 | ['struct clone_args'], | |
619 | ['__aligned_u64'], | |
20b03401 | 620 | ['struct open_how'], |
353f0f99 | 621 | ['struct rtnl_link_stats64'], |
20b03401 | 622 | ] |
ea6da257 | 623 | |
20b03401 SG |
624 | if tuple.length() >= 2 |
625 | cond = tuple[1] | |
626 | else | |
627 | ident1 = 'HAVE_' + tuple[0].underscorify().to_upper() | |
628 | ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper() | |
eba7f7a6 | 629 | cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1 |
20b03401 SG |
630 | endif |
631 | ||
632 | if cond | |
633 | found_types += tuple[0] | |
634 | else | |
635 | missing_types += tuple[0] | |
636 | endif | |
637 | endforeach | |
638 | ||
c1115e15 CB |
639 | decl_headers = ''' |
640 | #include <sys/mount.h> | |
641 | ''' | |
642 | ||
643 | # We get -1 if the size cannot be determined | |
644 | if cc.sizeof('struct mount_attr', prefix: decl_headers, args: '-D_GNU_SOURCE') > 0 | |
645 | srcconf.set10('HAVE_' + 'struct mount_attr'.underscorify().to_upper(), true) | |
646 | found_types += 'struct mount_attr (sys/mount.h)' | |
647 | else | |
648 | srcconf.set10('HAVE_' + 'struct mount_attr'.underscorify().to_upper(), false) | |
cbabe8ab | 649 | missing_types += 'struct mount_attr (sys/mount.h)' endif |
c1115e15 | 650 | |
4771699f | 651 | ## Check if sys/mount.h defines the fsconfig commands |
cbabe8ab CB |
652 | if cc.has_header_symbol('sys/mount.h', 'FSCONFIG_SET_FLAG') |
653 | srcconf.set10('HAVE_' + 'FSCONFIG_SET_FLAG'.underscorify().to_upper(), true) | |
4771699f | 654 | found_types += 'FSCONFIG_SET_FLAG (sys/mount.h)' |
cbabe8ab CB |
655 | else |
656 | srcconf.set10('HAVE_' + 'FSCONFIG_SET_FLAG'.underscorify().to_upper(), false) | |
4771699f | 657 | missing_types += 'FSCONFIG_SET_FLAG (sys/mount.h)' |
cbabe8ab CB |
658 | endif |
659 | ||
660 | if cc.has_header_symbol('sys/mount.h', 'FS_CONFIG_SET_STRING') | |
661 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_STRING'.underscorify().to_upper(), true) | |
4771699f | 662 | found_types += 'FS_CONFIG_SET_STRING (sys/mount.h)' |
cbabe8ab CB |
663 | else |
664 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_STRING'.underscorify().to_upper(), false) | |
4771699f | 665 | missing_types += 'FS_CONFIG_SET_STRING (sys/mount.h)' |
cbabe8ab CB |
666 | endif |
667 | ||
668 | if cc.has_header_symbol('sys/mount.h', 'FS_CONFIG_SET_BINARY') | |
669 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_BINARY'.underscorify().to_upper(), true) | |
4771699f | 670 | found_types += 'FS_CONFIG_SET_BINARY (sys/mount.h)' |
cbabe8ab CB |
671 | else |
672 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_BINARY'.underscorify().to_upper(), false) | |
4771699f | 673 | missing_types += 'FS_CONFIG_SET_BINARY (sys/mount.h)' |
cbabe8ab CB |
674 | endif |
675 | ||
676 | if cc.has_header_symbol('sys/mount.h', 'FS_CONFIG_SET_PATH_EMPTY') | |
677 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_PATH_EMPTY'.underscorify().to_upper(), true) | |
4771699f | 678 | found_types += 'FS_CONFIG_SET_PATH_EMPTY (sys/mount.h)' |
cbabe8ab CB |
679 | else |
680 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_PATH_EMPTY'.underscorify().to_upper(), false) | |
4771699f | 681 | missing_types += 'FS_CONFIG_SET_PATH_EMPTY (sys/mount.h)' |
cbabe8ab CB |
682 | endif |
683 | ||
684 | if cc.has_header_symbol('sys/mount.h', 'FS_CONFIG_SET_PATH_FD') | |
685 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_PATH_FD'.underscorify().to_upper(), true) | |
4771699f | 686 | found_types += 'FS_CONFIG_SET_PATH_FD (sys/mount.h)' |
cbabe8ab CB |
687 | else |
688 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_PATH_FD'.underscorify().to_upper(), false) | |
4771699f | 689 | missing_types += 'FS_CONFIG_SET_PATH_FD (sys/mount.h)' |
cbabe8ab CB |
690 | endif |
691 | ||
692 | if cc.has_header_symbol('sys/mount.h', 'FS_CONFIG_SET_CMD_CREATE') | |
693 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_CMD_CREATE'.underscorify().to_upper(), true) | |
4771699f | 694 | found_types += 'FS_CONFIG_SET_CMD_CREAT (sys/mount.h)' |
cbabe8ab CB |
695 | else |
696 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_CMD_CREATE'.underscorify().to_upper(), false) | |
4771699f | 697 | missing_types += 'FS_CONFIG_SET_CMD_CREATE (sys/mount.h)' |
cbabe8ab CB |
698 | endif |
699 | ||
700 | if cc.has_header_symbol('sys/mount.h', 'FS_CONFIG_SET_CMD_RECONFIGURE') | |
701 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_CMD_RECONFIGURE'.underscorify().to_upper(), true) | |
4771699f | 702 | found_types += 'FS_CONFIG_SET_CMD_RECONFIGURE (sys/mount.h)' |
cbabe8ab CB |
703 | else |
704 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_CMD_RECONFIGURE'.underscorify().to_upper(), false) | |
4771699f | 705 | missing_types += 'FS_CONFIG_SET_CMD_RECONFIGURE (sys/mount.h)' |
cbabe8ab CB |
706 | endif |
707 | ||
20b03401 SG |
708 | ## Headers. |
709 | foreach ident: [ | |
710 | ['bpf', '''#include <sys/syscall.h> | |
711 | #include <unistd.h>'''], | |
712 | ['close_range', '''#include <unistd.h>'''], | |
713 | ['execveat', '''#include <unistd.h>'''], | |
714 | ['endmntent', '''#include <stdio.h> | |
715 | #include <mntent.h>'''], | |
716 | ['faccessat', '''#include <fcntl.h> | |
717 | #include <unistd.h>'''], | |
718 | ['fexecve', '''#include <unistd.h>'''], | |
719 | ['fgetln', '''#include <stdio.h>'''], | |
720 | ['fsconfig', '''#include <sys/mount.h>'''], | |
721 | ['fsmount', '''#include <sys/mount.h>'''], | |
722 | ['fsopen', '''#include <sys/mount.h>'''], | |
723 | ['fspick', '''#include <sys/mount.h>'''], | |
724 | ['getgrgid_r', '''#include <sys/types.h> | |
725 | #include <grp.h>'''], | |
726 | ['getline', '''#include <stdio.h>'''], | |
727 | ['getsubopt', '''#include <stdlib.h>'''], | |
728 | ['gettid', '''#include <sys/types.h> | |
729 | #include <unistd.h>'''], | |
730 | ['hasmntopt', '''#include <stdio.h> | |
731 | #include <mntent.h>'''], | |
732 | ['kcmp', '''#include <linux/kcmp.h>'''], | |
733 | ['keyctl', '''#include <sys/types.h> | |
734 | #include <keyutils.h>'''], | |
735 | ['memfd_create', '''#include <sys/mman.h>'''], | |
736 | ['mount_setattr', '''#include <sys/mount.h>'''], | |
737 | ['move_mount', '''#include <sys/mount.h>'''], | |
738 | ['openat2', '''#include <sys/types.h> | |
739 | #include <sys/stat.h> | |
740 | #include <fctnl.h>'''], | |
741 | ['open_tree', '''#include <sys/mount.h>'''], | |
742 | ['personality', '''#include <sys/personality.h>'''], | |
743 | ['pidfd_open', '''#include <stdlib.h> | |
744 | #include <unistd.h> | |
745 | #include <signal.h> | |
746 | #include <sys/wait.h>'''], | |
747 | ['pidfd_send_signal', '''#include <stdlib.h> | |
748 | #include <unistd.h> | |
749 | #include <signal.h> | |
750 | #include <sys/wait.h>'''], | |
751 | ['pivot_root', '''#include <stdlib.h> | |
752 | #include <unistd.h>'''], # no known header declares pivot_root | |
753 | ['prlimit', '''#include <sys/time.h> | |
754 | #include <sys/resource.h>'''], | |
755 | ['prlimit64', '''#include <sys/time.h> | |
756 | #include <sys/resource.h>'''], | |
757 | ['renameat2', '''#include <stdio.h> | |
758 | #include <fcntl.h>'''], | |
759 | ['sethostname', '''#include <unistd.h>'''], | |
760 | ['setmntent', '''#include <stdio.h> | |
761 | #include <mntent.h>'''], | |
762 | ['setns', '''#include <sched.h>'''], | |
763 | ['sigdescr_np', '''#include <string.h>'''], | |
764 | ['signalfd', '''#include <sys/signalfd.h>'''], | |
8ee615c2 | 765 | ['statvfs', '''#include <sys/statvfs.h>'''], |
20b03401 SG |
766 | ['statx', '''#include <sys/types.h> |
767 | #include <sys/stat.h> | |
768 | #include <unistd.h>'''], | |
769 | ['strchrnul', '''#include <string.h>'''], | |
770 | ['strlcat', '''#include <string.h>'''], | |
771 | ['strlcpy', '''#include <string.h>'''], | |
772 | ['unshare', '''#include <sched.h>'''], | |
ea6da257 CB |
773 | ] |
774 | ||
20b03401 | 775 | have = cc.has_function(ident[0], prefix: ident[1], args: '-D_GNU_SOURCE') |
eba7f7a6 | 776 | srcconf.set10('HAVE_' + ident[0].to_upper(), have) |
ea6da257 CB |
777 | endforeach |
778 | ||
779 | found_headers = [] | |
780 | missing_headers = [] | |
20b03401 | 781 | foreach tuple: [ |
c55353f8 SH |
782 | ['systemd/sd-bus.h'], |
783 | ['systemd/sd-event.h'], | |
20b03401 SG |
784 | ['sys/resource.h'], |
785 | ['sys/memfd.h'], | |
786 | ['sys/personality.h'], | |
ef1e0607 | 787 | ['sys/pidfd.h'], |
20b03401 SG |
788 | ['sys/signalfd.h'], |
789 | ['sys/timerfd.h'], | |
790 | ['pty.h'], | |
791 | ['utmpx.h'], | |
ea6da257 | 792 | ] |
eba7f7a6 | 793 | srcconf.set10('HAVE_' + tuple[0].underscorify().to_upper(), cc.has_header(tuple[0])) |
20b03401 SG |
794 | |
795 | if tuple.length() >= 2 | |
796 | cond = tuple[1] | |
797 | else | |
798 | ident1 = 'HAVE_' + tuple[0].underscorify().to_upper() | |
799 | ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper() | |
eba7f7a6 | 800 | cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1 |
20b03401 SG |
801 | endif |
802 | ||
803 | if cond | |
804 | found_headers += tuple[0] | |
805 | else | |
806 | missing_headers += tuple[0] | |
807 | endif | |
ea6da257 CB |
808 | endforeach |
809 | ||
20b03401 | 810 | ## Deps. |
ea6da257 CB |
811 | found_deps = [] |
812 | missing_deps = [] | |
20b03401 SG |
813 | foreach tuple: [ |
814 | ['AppArmor'], | |
815 | ['SECCOMP'], | |
816 | ['SELinux'], | |
817 | ['libcap'], | |
818 | ['static libcap'], | |
8c48813a | 819 | ['pam'], |
20b03401 SG |
820 | ['openssl'], |
821 | ['liburing'], | |
c55353f8 | 822 | ['libsystemd'], |
ea6da257 CB |
823 | ] |
824 | ||
20b03401 SG |
825 | if tuple.length() >= 2 |
826 | cond = tuple[1] | |
827 | else | |
828 | ident1 = 'HAVE_' + tuple[0].underscorify().to_upper() | |
829 | ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper() | |
eba7f7a6 | 830 | cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1 |
20b03401 SG |
831 | endif |
832 | ||
833 | if cond | |
834 | found_deps += tuple[0] | |
835 | else | |
836 | missing_deps += tuple[0] | |
837 | endif | |
ea6da257 CB |
838 | endforeach |
839 | ||
20b03401 SG |
840 | # Generate config.h |
841 | config_h = configure_file( | |
842 | output: 'config.h', | |
eba7f7a6 | 843 | configuration: srcconf) |
20b03401 SG |
844 | |
845 | add_project_arguments('-include', 'config.h', language: 'c') | |
846 | ||
847 | # Binaries. | |
848 | cmd_programs = [] | |
849 | hook_programs = [] | |
850 | public_programs = [] | |
851 | template_scripts = [] | |
852 | test_programs = [] | |
853 | ||
854 | # Includes. | |
8d77f43f | 855 | liblxc_includes = include_directories( |
20b03401 SG |
856 | '.', |
857 | 'src', | |
8d77f43f SG |
858 | 'src/include', |
859 | 'src/lxc', | |
20b03401 | 860 | 'src/lxc/cgroups', |
8d77f43f | 861 | 'src/lxc/storage') |
20b03401 SG |
862 | |
863 | # Early sub-directories. | |
864 | subdir('src/include') | |
865 | subdir('src/lxc') | |
24dcd86d | 866 | subdir('src/lxc/pam') |
20b03401 SG |
867 | |
868 | # Library. | |
869 | liblxc_dependencies = [ | |
870 | threads, | |
20b03401 SG |
871 | ] |
872 | ||
0b9adfda CB |
873 | if want_seccomp |
874 | liblxc_dependencies += libseccomp | |
875 | endif | |
876 | ||
826391b2 CB |
877 | if want_capabilities |
878 | liblxc_dependencies += [libcap] | |
879 | endif | |
880 | ||
881 | if want_openssl | |
882 | liblxc_dependencies += [libopenssl] | |
883 | endif | |
884 | ||
885 | if want_selinux | |
886 | liblxc_dependencies += [libselinux] | |
887 | endif | |
888 | ||
889 | if want_apparmor | |
890 | liblxc_dependencies += [libapparmor] | |
891 | endif | |
892 | ||
7d8a38b2 | 893 | if want_io_uring |
20b03401 SG |
894 | liblxc_dependencies += [liburing] |
895 | endif | |
896 | ||
c55353f8 SH |
897 | if has_sd_bus |
898 | liblxc_dependencies += [libsystemd] | |
899 | endif | |
900 | ||
353f0f99 WB |
901 | if have_openpty |
902 | liblxc_dependencies += [libutil] | |
903 | if want_oss_fuzz | |
904 | oss_fuzz_dependencies += [libutil] | |
905 | endif | |
906 | endif | |
907 | ||
d42a3b13 | 908 | liblxc_link_whole = [liblxc_static] |
5055c73d | 909 | |
20b03401 SG |
910 | liblxc = shared_library( |
911 | 'lxc', | |
912 | version: liblxc_version, | |
913 | include_directories: liblxc_includes, | |
914 | link_args: ['-DPIC'], | |
915 | c_args: ['-DPIC'], | |
5055c73d | 916 | link_whole: liblxc_link_whole, |
20b03401 SG |
917 | dependencies: liblxc_dependencies, |
918 | install: true) | |
919 | ||
920 | liblxc_dep = declare_dependency( | |
921 | link_with: liblxc, | |
922 | dependencies: liblxc_dependencies) | |
923 | ||
924 | # Rest of sub-directories. | |
826391b2 CB |
925 | if want_apparmor |
926 | subdir('config/apparmor') | |
927 | subdir('config/apparmor/abstractions') | |
928 | subdir('config/apparmor/profiles') | |
929 | endif | |
4a858b56 | 930 | subdir('config/bash') |
9d18059b | 931 | subdir('config/etc') |
e4e52844 SG |
932 | subdir('config/init/common') |
933 | subdir('config/init/systemd') | |
8131bb44 SG |
934 | subdir('config/init/sysvinit') |
935 | subdir('config/init/upstart') | |
826391b2 CB |
936 | if want_selinux |
937 | subdir('config/selinux') | |
938 | endif | |
36a53f30 | 939 | subdir('config/sysconfig') |
c2931f74 SG |
940 | subdir('config/templates') |
941 | subdir('config/templates/common.conf.d') | |
d9121fff | 942 | subdir('config/yum') |
47c56c50 SG |
943 | subdir('doc') |
944 | subdir('doc/ja') | |
945 | subdir('doc/ko') | |
b3da01d7 | 946 | subdir('doc/examples') |
6dfabed1 | 947 | subdir('doc/rootfs') |
20b03401 | 948 | subdir('hooks') |
575d0e34 CB |
949 | if want_commands |
950 | subdir('src/lxc/cmd') | |
951 | endif | |
f4d02217 | 952 | if want_tools or want_tools_multicall |
575d0e34 CB |
953 | subdir('src/lxc/tools') |
954 | endif | |
20b03401 SG |
955 | subdir('src/lxc/tools/include') |
956 | subdir('src/tests') | |
957 | subdir('templates') | |
958 | ||
0860988e SG |
959 | # Pkg-config. |
960 | pkg_config_file = pkgconfig.generate(liblxc, | |
961 | description: 'linux container tools', | |
962 | version: version_data.get('LXC_VERSION'), | |
963 | url: 'http://linuxcontainers.org', | |
964 | libraries: '-lutil -lpthread -ldl', | |
965 | libraries_private: pkgconfig_libs, | |
0860988e SG |
966 | ) |
967 | ||
1404fcb8 SG |
968 | # Empty dirs. |
969 | install_emptydir(join_paths(localstatedir, 'cache', 'lxc')) | |
970 | install_emptydir(join_paths(localstatedir, 'lib', 'lxc')) | |
971 | ||
9c562440 | 972 | # RPM spec file. |
e18dbec7 SG |
973 | specconf = configuration_data() |
974 | specconf.set('LXC_VERSION_BASE', meson.project_version()) | |
975 | specconf.set('LXC_VERSION_BETA', version_data.get('LXC_VERSION_BETA')) | |
976 | specconf.set('PACKAGE', meson.project_name()) | |
977 | specconf.set('LXC_DISTRO_SYSCONF', conf.get('LXC_DISTRO_SYSCONF')) | |
978 | ||
9c562440 | 979 | configure_file( |
e18dbec7 | 980 | configuration: specconf, |
9c562440 SG |
981 | input: 'lxc.spec.in', |
982 | output: 'lxc.spec', | |
983 | install: false) | |
984 | ||
20b03401 | 985 | # Build overview. |
bf1f3470 | 986 | status = [ |
20b03401 SG |
987 | '@0@ @1@'.format(meson.project_name(), meson.project_version()), |
988 | ||
989 | 'Meson version: @0@'.format(meson.version()), | |
990 | ||
991 | 'prefix directory: @0@'.format(prefixdir), | |
992 | 'bin directory: @0@'.format(bindir), | |
993 | 'data directory: @0@'.format(datadir), | |
994 | 'doc directory: @0@'.format(docdir), | |
995 | 'include directory: @0@'.format(includedir), | |
996 | 'lib directory: @0@'.format(libdir), | |
997 | 'libexec directory: @0@'.format(libexecdir), | |
998 | 'local state directory: @0@'.format(localstatedir), | |
999 | 'sbin directory: @0@'.format(sbindir), | |
1000 | 'sysconf directory: @0@'.format(sysconfdir), | |
1001 | ||
1002 | 'lxc cgroup pattern: @0@'.format(cgrouppattern), | |
1003 | 'lxc init directory: @0@'.format(libexecdir), | |
1004 | 'runtime path: @0@'.format(runtimepath), | |
1005 | ||
1006 | 'lxc default config: @0@'.format(lxcdefaultconfig), | |
1007 | 'lxc global config: @0@'.format(lxcglobalconfig), | |
1008 | 'lxc hook directory: @0@'.format(lxchookdir), | |
1009 | 'lxc hook bin directory: @0@'.format(lxchookbindir), | |
1010 | 'lxc rootfs mount directory: @0@'.format(lxcrootfsmount), | |
1011 | 'log path: @0@'.format(lxclogpath), | |
1012 | 'lxc path: @0@'.format(lxcpath), | |
51f90ad9 | 1013 | 'lxc template config: @0@'.format(lxctemplateconfdir), |
20b03401 SG |
1014 | 'lxc template directory: @0@'.format(lxctemplatedir), |
1015 | 'lxc user network config: @0@'.format(lxc_user_network_conf), | |
1016 | 'lxc user network database: @0@'.format(lxc_user_network_db)] | |
bf1f3470 | 1017 | |
ea6da257 | 1018 | alt_time_epoch = run_command('date', '-Is', '-u', '-d', |
aa326e18 | 1019 | '@@0@'.format(time_epoch), check: true).stdout().strip() |
ea6da257 | 1020 | status += [ |
20b03401 | 1021 | 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)] |
ea6da257 CB |
1022 | |
1023 | status += [ | |
20b03401 SG |
1024 | '', |
1025 | 'supported dependencies: @0@'.format(', '.join(found_deps)), | |
1026 | '', | |
1027 | 'unsupported dependencies: @0@'.format(', '.join(missing_deps)), | |
1028 | ''] | |
ea6da257 CB |
1029 | |
1030 | status += [ | |
20b03401 SG |
1031 | '', |
1032 | 'supported headers: @0@'.format(', '.join(found_headers)), | |
1033 | '', | |
1034 | 'unsupported headers: @0@'.format(', '.join(missing_headers)), | |
1035 | ''] | |
ea6da257 CB |
1036 | |
1037 | status += [ | |
20b03401 SG |
1038 | '', |
1039 | 'supported calls: @0@'.format(', '.join(found_syscalls)), | |
1040 | '', | |
1041 | 'unsupported calls: @0@'.format(', '.join(missing_syscalls)), | |
1042 | ''] | |
ea6da257 CB |
1043 | |
1044 | status += [ | |
20b03401 SG |
1045 | '', |
1046 | 'supported types: @0@'.format(', '.join(found_types)), | |
1047 | '', | |
1048 | 'unsupported types: @0@'.format(', '.join(missing_types)), | |
1049 | ''] | |
ea6da257 | 1050 | |
20b03401 | 1051 | message('\n '.join(status)) |