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