]>
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 | |
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 = [ | |
20b03401 SG |
224 | '-Wl,--gc-sections', |
225 | '-Wl,-z,relro', | |
226 | '-Wl,-z,now', | |
227 | '-Wl,-fuse-ld=gold', | |
abc5e6bb | 228 | '-fstack-protector', |
5e704fe3 | 229 | '-fstack-protector-strong', |
9b9d56e6 CB |
230 | ] |
231 | ||
abc5e6bb CB |
232 | if sanitize == 'none' |
233 | possible_link_flags += '-Wl,--warn-common' | |
234 | endif | |
235 | ||
236 | if cc.get_id() == 'clang' | |
237 | possible_cc_flags += [ | |
238 | '-Wno-typedef-redefinition', | |
239 | '-Wno-gnu-variable-sized-type-not-at-end', | |
240 | ] | |
241 | endif | |
242 | ||
9b9d56e6 | 243 | if meson.version().version_compare('>=0.46') |
20b03401 | 244 | add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language: 'c') |
9b9d56e6 | 245 | else |
20b03401 | 246 | add_project_link_arguments(possible_link_flags, language: 'c') |
9b9d56e6 CB |
247 | endif |
248 | ||
abc5e6bb | 249 | add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c') |
20b03401 | 250 | add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language: 'c') |
9b9d56e6 | 251 | |
d42a3b13 CB |
252 | if add_languages('cpp', required : want_oss_fuzz) |
253 | # Used only for tests | |
254 | cxx = meson.get_compiler('cpp') | |
255 | cxx_cmd = ' '.join(cxx.cmd_array()) | |
256 | add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp') | |
257 | endif | |
258 | ||
20b03401 SG |
259 | # Feature detection |
260 | ## I/O uring. | |
7d8a38b2 | 261 | if want_io_uring |
20b03401 SG |
262 | liburing = dependency('liburing') |
263 | if cc.has_function('io_uring_prep_poll_add', prefix: '#include <liburing.h>', dependencies: liburing) == false | |
264 | error('liburing version does not support IORING_POLL_ADD_MULTI') | |
265 | endif | |
c1f87c81 AS |
266 | pkgconfig_libs += liburing |
267 | liblxc_dependencies += liburing | |
20b03401 | 268 | |
eba7f7a6 | 269 | srcconf.set10('HAVE_LIBURING', true) |
4c96107d SG |
270 | else |
271 | srcconf.set10('HAVE_LIBURING', false) | |
747bc634 CB |
272 | endif |
273 | ||
c55353f8 SH |
274 | if not want_sd_bus.disabled() |
275 | has_sd_bus = true | |
276 | sd_bus_optional = want_sd_bus.auto() | |
277 | ||
278 | libsystemd = dependency('libsystemd', required: not sd_bus_optional) | |
279 | if not libsystemd.found() | |
280 | if not sd_bus_optional | |
281 | error('missing required libsystemd dependency') | |
282 | endif | |
283 | ||
284 | has_sd_bus = false | |
285 | endif | |
286 | ||
287 | if not cc.has_header('systemd/sd-bus.h') | |
288 | if not sd_bus_optional | |
289 | error('libsystemd misses required systemd/sd-bus.h header') | |
290 | endif | |
291 | ||
292 | has_sd_bus = false | |
293 | endif | |
294 | ||
295 | if not cc.has_header('systemd/sd-event.h') | |
296 | if not sd_bus_optional | |
297 | error('libsystemd misses required systemd/sd-event.h header') | |
298 | endif | |
299 | ||
300 | has_sd_bus = false | |
301 | endif | |
302 | ||
c1f87c81 | 303 | if not cc.has_function('sd_bus_call_method_async', prefix: '#include <systemd/sd-bus.h>', dependencies: libsystemd) |
c55353f8 | 304 | if not sd_bus_optional |
b0abedf6 | 305 | error('libsystemd misses required sd_bus_call_method_async function') |
c55353f8 SH |
306 | endif |
307 | ||
308 | has_sd_bus = false | |
309 | endif | |
310 | ||
c1f87c81 AS |
311 | if has_sd_bus |
312 | liblxc_dependencies += libsystemd | |
313 | if want_oss_fuzz | |
314 | oss_fuzz_dependencies += libsystemd | |
315 | endif | |
316 | endif | |
317 | ||
c55353f8 SH |
318 | srcconf.set10('HAVE_LIBSYSTEMD', has_sd_bus) |
319 | else | |
320 | has_sd_bus = false | |
321 | srcconf.set10('HAVE_LIBSYSTEMD', false) | |
322 | endif | |
323 | ||
20b03401 | 324 | ## Time EPOCH. |
ea6da257 | 325 | sh = find_program('sh') |
23ba778f | 326 | date = find_program('date') |
20b03401 | 327 | git = find_program('git', required: false) |
aa326e18 SG |
328 | time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check: true).stdout().strip() |
329 | if time_epoch == '' and git.found() and run_command('test', '-e', '.git', check: false).returncode() == 0 | |
20b03401 | 330 | # If we're in a git repository, use the creation time of the latest git tag. |
f7de7d7a SG |
331 | latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags', check: false).stdout().strip() |
332 | if latest_tag != '' | |
8aac5886 | 333 | time_epoch = run_command(git, 'log', '--no-show-signature', '-1', '--format=%at', latest_tag, check: true).stdout().strip() |
f7de7d7a SG |
334 | endif |
335 | endif | |
336 | ||
337 | # Fallback to current epoch. | |
338 | if time_epoch == '' | |
dcf85308 | 339 | time_epoch = run_command(date, '+%s', check: true).stdout().strip() |
ea6da257 | 340 | endif |
47c56c50 | 341 | generate_date = run_command(date, '--utc', '--date=@' + time_epoch, '+%Y-%m-%d', check: true).stdout().strip() |
ea6da257 | 342 | |
2bd9ab6f | 343 | ## Manpages. |
2bd9ab6f SG |
344 | docconf = configuration_data() |
345 | docconf.set('builddir', '.') | |
f80af4e1 SG |
346 | docconf.set('BINDIR', bindir) |
347 | docconf.set('DATADIR', datadir) | |
348 | docconf.set('DOCDIR', docdir) | |
349 | docconf.set('LOGPATH', lxclogpath) | |
350 | docconf.set('LXC_DEFAULT_CONFIG', lxcdefaultconfig) | |
2bd9ab6f | 351 | docconf.set('LXC_GENERATE_DATE', generate_date) |
f80af4e1 SG |
352 | docconf.set('LXC_GLOBAL_CONF', lxcglobalconfig) |
353 | docconf.set('LXCPATH', lxcpath) | |
354 | docconf.set('LXCTEMPLATEDIR', lxctemplatedir) | |
355 | docconf.set('LXC_USERNIC_CONF', lxc_user_network_conf) | |
356 | docconf.set('LXC_USERNIC_DB', lxc_user_network_db) | |
2bd9ab6f | 357 | docconf.set('PACKAGE_VERSION', version_data.get('LXC_VERSION')) |
06f99c25 CN |
358 | docconf.set('docdtd', '"-//OASIS//DTD DocBook XML" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"') |
359 | sgml2man = find_program('docbook2X2man', 'docbook2x-man', 'db2x_docbook2man', 'docbook2man', 'docbook-to-man', required: false, version: '>=0.8') | |
360 | if not sgml2man.found() | |
361 | sgml2man = find_program('docbook2man', required: false, version: '<0.8') | |
362 | if sgml2man.found() | |
363 | docconf.set('docdtd', '"-//Davenport//DTD DocBook V3.0//EN"') | |
364 | elif want_mans | |
365 | error('missing required docbook2x or docbook-utils dependency') | |
366 | endif | |
2bd9ab6f SG |
367 | endif |
368 | ||
20b03401 | 369 | ## Threads. |
9b9d56e6 | 370 | threads = dependency('threads') |
c1f87c81 | 371 | liblxc_dependencies += threads |
20b03401 SG |
372 | |
373 | ## Seccomp. | |
0b9adfda CB |
374 | if want_seccomp |
375 | libseccomp = dependency('libseccomp', required: false) | |
376 | srcconf.set10('HAVE_SECCOMP', libseccomp.found()) | |
377 | pkgconfig_libs += libseccomp | |
c1f87c81 | 378 | liblxc_dependencies += libseccomp |
0b9adfda CB |
379 | if libseccomp.found() |
380 | if libseccomp.version().version_compare('>=2.5.0') | |
381 | # https://github.com/seccomp/libseccomp/commit/dead12bc788b259b148cc4d93b970ef0bd602b1a | |
382 | srcconf.set10('HAVE_DECL_SECCOMP_NOTIFY_FD', true) | |
383 | else | |
384 | srcconf.set10('HAVE_DECL_SECCOMP_NOTIFY_FD', false) | |
385 | endif | |
20b03401 | 386 | |
0b9adfda CB |
387 | if libseccomp.version().version_compare('>=2.0.0') |
388 | # https://github.com/seccomp/libseccomp/commit/6220c8c0fc479d97b6d3e3166a4e46fbfe25a3c0 | |
389 | srcconf.set10('HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH', true) | |
20b03401 | 390 | else |
0b9adfda | 391 | srcconf.set10('HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH', false) |
20b03401 | 392 | endif |
0b9adfda CB |
393 | |
394 | seccomp_headers = ''' | |
395 | #include <seccomp.h> | |
396 | ''' | |
397 | ||
398 | foreach decl: [ | |
399 | 'scmp_filter_ctx', | |
400 | 'struct seccomp_notif_sizes', | |
401 | 'struct clone_args', | |
402 | ] | |
403 | ||
404 | # We get -1 if the size cannot be determined | |
c1f87c81 | 405 | if cc.sizeof(decl, prefix: seccomp_headers, args: '-D_GNU_SOURCE', dependencies: libseccomp) > 0 |
0b9adfda CB |
406 | srcconf.set10('HAVE_' + decl.underscorify().to_upper(), true) |
407 | else | |
408 | srcconf.set10('HAVE_' + decl.underscorify().to_upper(), false) | |
409 | endif | |
410 | endforeach | |
411 | endif | |
412 | else | |
413 | srcconf.set10('HAVE_SECCOMP', false) | |
9b9d56e6 CB |
414 | endif |
415 | ||
20b03401 | 416 | ## SELinux. |
575d0e34 CB |
417 | if want_selinux |
418 | libselinux = dependency('libselinux', required: false) | |
419 | srcconf.set10('HAVE_SELINUX', libselinux.found()) | |
420 | pkgconfig_libs += libselinux | |
c1f87c81 | 421 | liblxc_dependencies += libselinux |
575d0e34 CB |
422 | else |
423 | srcconf.set10('HAVE_SELINUX', false) | |
424 | endif | |
9b9d56e6 | 425 | |
20b03401 | 426 | ## AppArmor. |
575d0e34 CB |
427 | if want_apparmor |
428 | libapparmor = dependency('libapparmor', required: false) | |
429 | srcconf.set10('HAVE_APPARMOR', libapparmor.found()) | |
c1f87c81 AS |
430 | # We do not use the AppArmor library at runtime, so it's not in our pkg-config. |
431 | liblxc_dependencies += libapparmor | |
575d0e34 CB |
432 | else |
433 | srcconf.set10('HAVE_APPARMOR', false) | |
434 | endif | |
9b9d56e6 | 435 | |
20b03401 | 436 | ## OpenSSL. |
575d0e34 CB |
437 | if want_openssl |
438 | libopenssl = dependency('openssl', required: false) | |
439 | srcconf.set10('HAVE_OPENSSL', libopenssl.found()) | |
440 | pkgconfig_libs += libopenssl | |
c1f87c81 | 441 | liblxc_dependencies += libopenssl |
575d0e34 CB |
442 | else |
443 | srcconf.set10('HAVE_OPENSSL', false) | |
444 | endif | |
9b9d56e6 | 445 | |
20b03401 | 446 | ## Libcap.. |
575d0e34 CB |
447 | if want_capabilities |
448 | libcap = dependency('libcap', required: false) | |
449 | if not libcap.found() | |
450 | # Compat with Ubuntu 14.04 which ships libcap w/o .pc file | |
451 | libcap = cc.find_library('cap', required: false) | |
353f0f99 WB |
452 | else |
453 | have = cc.has_function('cap_get_file', dependencies: libcap, prefix: '#include <sys/capability.h>') | |
454 | srcconf.set10('LIBCAP_SUPPORTS_FILE_CAPABILITIES', have) | |
575d0e34 CB |
455 | endif |
456 | srcconf.set10('HAVE_LIBCAP', libcap.found()) | |
457 | pkgconfig_libs += libcap | |
c1f87c81 | 458 | liblxc_dependencies += libcap |
9b9d56e6 | 459 | |
575d0e34 CB |
460 | libcap_static = dependency('libcap', required: false, static: true) |
461 | if not libcap_static.found() | |
462 | # Compat with Ubuntu 14.04 which ships libcap w/o .pc file | |
463 | libcap_static = cc.find_library('cap', required: false, static: true) | |
464 | endif | |
de4543d8 CB |
465 | |
466 | code = ''' | |
467 | int main(int argc, char *argv[]) { return 0; }; | |
468 | ''' | |
469 | if libcap_static.found() | |
470 | libcap_static_linkable = cc.links(code, args: '-static', dependencies: libcap_static) | |
de4543d8 | 471 | else |
5aff4ea3 | 472 | libcap_static_linkable = false |
de4543d8 | 473 | endif |
5aff4ea3 | 474 | srcconf.set10('HAVE_STATIC_LIBCAP', libcap_static_linkable) |
575d0e34 | 475 | else |
7d723548 | 476 | libcap_static = [] |
5aff4ea3 | 477 | libcap_static_linkable = false |
575d0e34 CB |
478 | srcconf.set10('HAVE_LIBCAP', false) |
479 | srcconf.set10('HAVE_STATIC_LIBCAP', false) | |
d0a16061 | 480 | endif |
d0a16061 | 481 | |
353f0f99 WB |
482 | libutil = cc.find_library('util', required: false) |
483 | ||
d42a3b13 CB |
484 | if want_oss_fuzz |
485 | srcconf.set10('FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION', true) | |
486 | srcconf.set10('RUN_ON_OSS_FUZZ', true) | |
487 | fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine') | |
488 | endif | |
489 | ||
0c4549a3 | 490 | srcconf.set10('ENFORCE_THREAD_SAFETY', want_thread_safety) |
493bf2de | 491 | srcconf.set10('ENFORCE_MEMFD_REXEC', want_memfd_rexec) |
0c4549a3 | 492 | |
0860988e | 493 | ## PAM. |
8c48813a | 494 | pam = cc.find_library('pam', has_headers: 'security/pam_modules.h', required: want_pam_cgroup) |
eba7f7a6 | 495 | srcconf.set10('HAVE_PAM', pam.found()) |
181cd6dc | 496 | pkgconfig_libs += pam |
0860988e | 497 | |
20b03401 | 498 | ## Others. |
353f0f99 WB |
499 | have = cc.has_function('fmemopen', prefix: '#include <stdio.h>', args: '-D_GNU_SOURCE') |
500 | srcconf.set10('HAVE_FMEMOPEN', have) | |
501 | ||
c1f87c81 AS |
502 | have = cc.has_function('openpty', dependencies: libutil, prefix: '#include <pty.h>') |
503 | srcconf.set10('HAVE_OPENPTY', have) | |
504 | if have | |
505 | liblxc_dependencies += libutil | |
506 | if want_oss_fuzz | |
507 | oss_fuzz_dependencies += libutil | |
508 | endif | |
509 | endif | |
353f0f99 WB |
510 | |
511 | have = cc.has_function('pthread_setcancelstate', prefix: '#include <pthread.h>') | |
512 | srcconf.set10('HAVE_PTHREAD_SETCANCELSTATE', have) | |
513 | ||
514 | have = cc.has_function('rand_r') | |
515 | srcconf.set10('HAVE_RAND_R', have) | |
516 | ||
20b03401 | 517 | have = cc.has_function('strchrnul', prefix: '#include <string.h>', args: '-D_GNU_SOURCE') |
eba7f7a6 | 518 | srcconf.set10('HAVE_STRCHRNUL', have) |
db4af8c5 | 519 | |
0c4549a3 | 520 | have_func_strerror_r = cc.has_function('strerror_r', prefix: '#include <string.h>', args: '-D_GNU_SOURCE') |
9fea6122 | 521 | srcconf.set10('HAVE_STRERROR_R', have_func_strerror_r) |
0c4549a3 CB |
522 | |
523 | have_func_strerror_r_char_p = false | |
524 | ||
525 | if have_func_strerror_r | |
526 | code = ''' | |
527 | #define _GNU_SOURCE | |
528 | #include <string.h> | |
529 | int func (void) { | |
530 | char error_string[256]; | |
531 | char *ptr = strerror_r (-2, error_string, 256); | |
532 | char c = *strerror_r (-2, error_string, 256); | |
533 | return c != 0 && ptr != (void*) 0L; | |
534 | } | |
535 | ''' | |
536 | ||
537 | have_func_strerror_r_char_p = cc.compiles(code, name : 'strerror_r() returns char *') | |
538 | endif | |
539 | ||
540 | srcconf.set10('STRERROR_R_CHAR_P', have_func_strerror_r_char_p) | |
541 | ||
20b03401 SG |
542 | ## Compiler attributes. |
543 | foreach ccattr: [ | |
544 | 'fallthrough', | |
545 | 'nonnull', | |
546 | 'returns_nonnull', | |
547 | ] | |
ae13cb3b | 548 | |
eba7f7a6 | 549 | srcconf.set10('HAVE_COMPILER_ATTR_' + ccattr.underscorify().to_upper(), cc.has_function_attribute(ccattr)) |
ae13cb3b | 550 | endforeach |
5c26176d | 551 | |
20b03401 | 552 | ## Syscalls. |
ea6da257 CB |
553 | found_syscalls = [] |
554 | missing_syscalls = [] | |
20b03401 SG |
555 | foreach tuple: [ |
556 | ['bpf'], | |
557 | ['close_range'], | |
558 | ['endmntent'], | |
559 | ['execveat'], | |
560 | ['faccessat'], | |
561 | ['strchrnul'], | |
0c4549a3 | 562 | ['strerror_r'], |
20b03401 SG |
563 | ['fgetln'], |
564 | ['fsconfig'], | |
565 | ['fsmount'], | |
566 | ['fsopen'], | |
567 | ['fspick'], | |
568 | ['getgrgid_r'], | |
569 | ['getline'], | |
570 | ['getsubopt'], | |
571 | ['gettid'], | |
572 | ['hasmntopt'], | |
573 | ['kcmp'], | |
574 | ['keyctl'], | |
575 | ['memfd_create'], | |
576 | ['mount_setattr'], | |
577 | ['move_mount'], | |
578 | ['openat2'], | |
579 | ['open_tree'], | |
580 | ['personality'], | |
581 | ['pidfd_open'], | |
582 | ['pidfd_send_signal'], | |
583 | ['pivot_root'], | |
584 | ['prlimit'], | |
585 | ['prlimit64'], | |
586 | ['renameat2'], | |
587 | ['sethostname'], | |
588 | ['setmntent'], | |
589 | ['setns'], | |
590 | ['sigdescr_np'], | |
591 | ['signalfd'], | |
592 | ['statx'], | |
8ee615c2 | 593 | ['statvfs'], |
20b03401 SG |
594 | ['strlcat'], |
595 | ['strlcpy'], | |
596 | ['unshare'], | |
597 | ] | |
598 | ||
599 | if tuple.length() >= 2 | |
600 | cond = tuple[1] | |
601 | else | |
602 | ident1 = 'HAVE_' + tuple[0].underscorify().to_upper() | |
603 | ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper() | |
eba7f7a6 | 604 | cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1 |
20b03401 SG |
605 | endif |
606 | ||
607 | if cond | |
608 | found_syscalls += tuple[0] | |
609 | else | |
610 | missing_syscalls += tuple[0] | |
611 | endif | |
612 | endforeach | |
613 | ||
614 | ## Types. | |
615 | decl_headers = ''' | |
616 | #include <uchar.h> | |
617 | #include <sys/mount.h> | |
618 | #include <sys/stat.h> | |
353f0f99 | 619 | #include <linux/if_link.h> |
353f0f99 | 620 | #include <linux/types.h> |
20b03401 | 621 | ''' |
ea6da257 | 622 | |
20b03401 SG |
623 | foreach decl: [ |
624 | '__aligned_u64', | |
353f0f99 | 625 | 'struct clone_args', |
20b03401 | 626 | 'struct open_how', |
353f0f99 | 627 | 'struct rtnl_link_stats64', |
ea6da257 CB |
628 | ] |
629 | ||
20b03401 SG |
630 | # We get -1 if the size cannot be determined |
631 | if cc.sizeof(decl, prefix: decl_headers, args: '-D_GNU_SOURCE') > 0 | |
eba7f7a6 | 632 | srcconf.set10('HAVE_' + decl.underscorify().to_upper(), true) |
20b03401 | 633 | else |
eba7f7a6 | 634 | srcconf.set10('HAVE_' + decl.underscorify().to_upper(), false) |
20b03401 | 635 | endif |
ea6da257 CB |
636 | endforeach |
637 | ||
638 | found_types = [] | |
639 | missing_types = [] | |
20b03401 SG |
640 | foreach tuple: [ |
641 | ['scmp_filter_ctx'], | |
642 | ['struct seccomp_notif_sizes'], | |
643 | ['struct clone_args'], | |
644 | ['__aligned_u64'], | |
20b03401 | 645 | ['struct open_how'], |
353f0f99 | 646 | ['struct rtnl_link_stats64'], |
20b03401 | 647 | ] |
ea6da257 | 648 | |
20b03401 SG |
649 | if tuple.length() >= 2 |
650 | cond = tuple[1] | |
651 | else | |
652 | ident1 = 'HAVE_' + tuple[0].underscorify().to_upper() | |
653 | ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper() | |
eba7f7a6 | 654 | cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1 |
20b03401 SG |
655 | endif |
656 | ||
657 | if cond | |
658 | found_types += tuple[0] | |
659 | else | |
660 | missing_types += tuple[0] | |
661 | endif | |
662 | endforeach | |
663 | ||
c1115e15 CB |
664 | decl_headers = ''' |
665 | #include <sys/mount.h> | |
666 | ''' | |
667 | ||
668 | # We get -1 if the size cannot be determined | |
669 | if cc.sizeof('struct mount_attr', prefix: decl_headers, args: '-D_GNU_SOURCE') > 0 | |
670 | srcconf.set10('HAVE_' + 'struct mount_attr'.underscorify().to_upper(), true) | |
671 | found_types += 'struct mount_attr (sys/mount.h)' | |
672 | else | |
673 | srcconf.set10('HAVE_' + 'struct mount_attr'.underscorify().to_upper(), false) | |
cbabe8ab | 674 | missing_types += 'struct mount_attr (sys/mount.h)' endif |
c1115e15 | 675 | |
4771699f | 676 | ## Check if sys/mount.h defines the fsconfig commands |
f321cd61 | 677 | if cc.get_define('FSCONFIG_SET_FLAG', prefix: decl_headers) != '' |
cbabe8ab | 678 | srcconf.set10('HAVE_' + 'FSCONFIG_SET_FLAG'.underscorify().to_upper(), true) |
4771699f | 679 | found_types += 'FSCONFIG_SET_FLAG (sys/mount.h)' |
cbabe8ab CB |
680 | else |
681 | srcconf.set10('HAVE_' + 'FSCONFIG_SET_FLAG'.underscorify().to_upper(), false) | |
4771699f | 682 | missing_types += 'FSCONFIG_SET_FLAG (sys/mount.h)' |
cbabe8ab CB |
683 | endif |
684 | ||
f321cd61 | 685 | if cc.get_define('FS_CONFIG_SET_STRING', prefix: decl_headers) != '' |
cbabe8ab | 686 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_STRING'.underscorify().to_upper(), true) |
4771699f | 687 | found_types += 'FS_CONFIG_SET_STRING (sys/mount.h)' |
cbabe8ab CB |
688 | else |
689 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_STRING'.underscorify().to_upper(), false) | |
4771699f | 690 | missing_types += 'FS_CONFIG_SET_STRING (sys/mount.h)' |
cbabe8ab CB |
691 | endif |
692 | ||
f321cd61 | 693 | if cc.get_define('FS_CONFIG_SET_BINARY', prefix: decl_headers) != '' |
cbabe8ab | 694 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_BINARY'.underscorify().to_upper(), true) |
4771699f | 695 | found_types += 'FS_CONFIG_SET_BINARY (sys/mount.h)' |
cbabe8ab CB |
696 | else |
697 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_BINARY'.underscorify().to_upper(), false) | |
4771699f | 698 | missing_types += 'FS_CONFIG_SET_BINARY (sys/mount.h)' |
cbabe8ab CB |
699 | endif |
700 | ||
f321cd61 | 701 | if cc.get_define('FS_CONFIG_SET_PATH_EMPTY', prefix: decl_headers) != '' |
cbabe8ab | 702 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_PATH_EMPTY'.underscorify().to_upper(), true) |
4771699f | 703 | found_types += 'FS_CONFIG_SET_PATH_EMPTY (sys/mount.h)' |
cbabe8ab CB |
704 | else |
705 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_PATH_EMPTY'.underscorify().to_upper(), false) | |
4771699f | 706 | missing_types += 'FS_CONFIG_SET_PATH_EMPTY (sys/mount.h)' |
cbabe8ab CB |
707 | endif |
708 | ||
f321cd61 | 709 | if cc.get_define('FS_CONFIG_SET_PATH_FD', prefix: decl_headers) != '' |
cbabe8ab | 710 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_PATH_FD'.underscorify().to_upper(), true) |
4771699f | 711 | found_types += 'FS_CONFIG_SET_PATH_FD (sys/mount.h)' |
cbabe8ab CB |
712 | else |
713 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_PATH_FD'.underscorify().to_upper(), false) | |
4771699f | 714 | missing_types += 'FS_CONFIG_SET_PATH_FD (sys/mount.h)' |
cbabe8ab CB |
715 | endif |
716 | ||
f321cd61 | 717 | if cc.get_define('FS_CONFIG_SET_CMD_CREATE', prefix: decl_headers) != '' |
cbabe8ab | 718 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_CMD_CREATE'.underscorify().to_upper(), true) |
4771699f | 719 | found_types += 'FS_CONFIG_SET_CMD_CREAT (sys/mount.h)' |
cbabe8ab CB |
720 | else |
721 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_CMD_CREATE'.underscorify().to_upper(), false) | |
4771699f | 722 | missing_types += 'FS_CONFIG_SET_CMD_CREATE (sys/mount.h)' |
cbabe8ab CB |
723 | endif |
724 | ||
f321cd61 | 725 | if cc.get_define('FS_CONFIG_SET_CMD_RECONFIGURE', prefix: decl_headers) != '' |
cbabe8ab | 726 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_CMD_RECONFIGURE'.underscorify().to_upper(), true) |
4771699f | 727 | found_types += 'FS_CONFIG_SET_CMD_RECONFIGURE (sys/mount.h)' |
cbabe8ab CB |
728 | else |
729 | srcconf.set10('HAVE_' + 'FS_CONFIG_SET_CMD_RECONFIGURE'.underscorify().to_upper(), false) | |
4771699f | 730 | missing_types += 'FS_CONFIG_SET_CMD_RECONFIGURE (sys/mount.h)' |
cbabe8ab CB |
731 | endif |
732 | ||
20b03401 SG |
733 | ## Headers. |
734 | foreach ident: [ | |
735 | ['bpf', '''#include <sys/syscall.h> | |
736 | #include <unistd.h>'''], | |
737 | ['close_range', '''#include <unistd.h>'''], | |
738 | ['execveat', '''#include <unistd.h>'''], | |
739 | ['endmntent', '''#include <stdio.h> | |
740 | #include <mntent.h>'''], | |
741 | ['faccessat', '''#include <fcntl.h> | |
742 | #include <unistd.h>'''], | |
743 | ['fexecve', '''#include <unistd.h>'''], | |
744 | ['fgetln', '''#include <stdio.h>'''], | |
745 | ['fsconfig', '''#include <sys/mount.h>'''], | |
746 | ['fsmount', '''#include <sys/mount.h>'''], | |
747 | ['fsopen', '''#include <sys/mount.h>'''], | |
748 | ['fspick', '''#include <sys/mount.h>'''], | |
749 | ['getgrgid_r', '''#include <sys/types.h> | |
750 | #include <grp.h>'''], | |
751 | ['getline', '''#include <stdio.h>'''], | |
752 | ['getsubopt', '''#include <stdlib.h>'''], | |
753 | ['gettid', '''#include <sys/types.h> | |
754 | #include <unistd.h>'''], | |
755 | ['hasmntopt', '''#include <stdio.h> | |
756 | #include <mntent.h>'''], | |
757 | ['kcmp', '''#include <linux/kcmp.h>'''], | |
758 | ['keyctl', '''#include <sys/types.h> | |
759 | #include <keyutils.h>'''], | |
760 | ['memfd_create', '''#include <sys/mman.h>'''], | |
761 | ['mount_setattr', '''#include <sys/mount.h>'''], | |
762 | ['move_mount', '''#include <sys/mount.h>'''], | |
763 | ['openat2', '''#include <sys/types.h> | |
764 | #include <sys/stat.h> | |
765 | #include <fctnl.h>'''], | |
766 | ['open_tree', '''#include <sys/mount.h>'''], | |
767 | ['personality', '''#include <sys/personality.h>'''], | |
768 | ['pidfd_open', '''#include <stdlib.h> | |
769 | #include <unistd.h> | |
770 | #include <signal.h> | |
771 | #include <sys/wait.h>'''], | |
772 | ['pidfd_send_signal', '''#include <stdlib.h> | |
773 | #include <unistd.h> | |
774 | #include <signal.h> | |
775 | #include <sys/wait.h>'''], | |
776 | ['pivot_root', '''#include <stdlib.h> | |
777 | #include <unistd.h>'''], # no known header declares pivot_root | |
778 | ['prlimit', '''#include <sys/time.h> | |
779 | #include <sys/resource.h>'''], | |
780 | ['prlimit64', '''#include <sys/time.h> | |
781 | #include <sys/resource.h>'''], | |
782 | ['renameat2', '''#include <stdio.h> | |
783 | #include <fcntl.h>'''], | |
784 | ['sethostname', '''#include <unistd.h>'''], | |
785 | ['setmntent', '''#include <stdio.h> | |
786 | #include <mntent.h>'''], | |
787 | ['setns', '''#include <sched.h>'''], | |
788 | ['sigdescr_np', '''#include <string.h>'''], | |
789 | ['signalfd', '''#include <sys/signalfd.h>'''], | |
8ee615c2 | 790 | ['statvfs', '''#include <sys/statvfs.h>'''], |
20b03401 SG |
791 | ['statx', '''#include <sys/types.h> |
792 | #include <sys/stat.h> | |
793 | #include <unistd.h>'''], | |
794 | ['strchrnul', '''#include <string.h>'''], | |
795 | ['strlcat', '''#include <string.h>'''], | |
796 | ['strlcpy', '''#include <string.h>'''], | |
797 | ['unshare', '''#include <sched.h>'''], | |
ea6da257 CB |
798 | ] |
799 | ||
20b03401 | 800 | have = cc.has_function(ident[0], prefix: ident[1], args: '-D_GNU_SOURCE') |
eba7f7a6 | 801 | srcconf.set10('HAVE_' + ident[0].to_upper(), have) |
ea6da257 CB |
802 | endforeach |
803 | ||
804 | found_headers = [] | |
805 | missing_headers = [] | |
20b03401 | 806 | foreach tuple: [ |
c55353f8 SH |
807 | ['systemd/sd-bus.h'], |
808 | ['systemd/sd-event.h'], | |
20b03401 SG |
809 | ['sys/resource.h'], |
810 | ['sys/memfd.h'], | |
811 | ['sys/personality.h'], | |
ef1e0607 | 812 | ['sys/pidfd.h'], |
20b03401 SG |
813 | ['sys/signalfd.h'], |
814 | ['sys/timerfd.h'], | |
815 | ['pty.h'], | |
816 | ['utmpx.h'], | |
ea6da257 | 817 | ] |
eba7f7a6 | 818 | srcconf.set10('HAVE_' + tuple[0].underscorify().to_upper(), cc.has_header(tuple[0])) |
20b03401 SG |
819 | |
820 | if tuple.length() >= 2 | |
821 | cond = tuple[1] | |
822 | else | |
823 | ident1 = 'HAVE_' + tuple[0].underscorify().to_upper() | |
824 | ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper() | |
eba7f7a6 | 825 | cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1 |
20b03401 SG |
826 | endif |
827 | ||
828 | if cond | |
829 | found_headers += tuple[0] | |
830 | else | |
831 | missing_headers += tuple[0] | |
832 | endif | |
ea6da257 CB |
833 | endforeach |
834 | ||
20b03401 | 835 | ## Deps. |
ea6da257 CB |
836 | found_deps = [] |
837 | missing_deps = [] | |
20b03401 SG |
838 | foreach tuple: [ |
839 | ['AppArmor'], | |
840 | ['SECCOMP'], | |
841 | ['SELinux'], | |
842 | ['libcap'], | |
843 | ['static libcap'], | |
8c48813a | 844 | ['pam'], |
20b03401 SG |
845 | ['openssl'], |
846 | ['liburing'], | |
c55353f8 | 847 | ['libsystemd'], |
ea6da257 CB |
848 | ] |
849 | ||
20b03401 SG |
850 | if tuple.length() >= 2 |
851 | cond = tuple[1] | |
852 | else | |
853 | ident1 = 'HAVE_' + tuple[0].underscorify().to_upper() | |
854 | ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper() | |
eba7f7a6 | 855 | cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1 |
20b03401 SG |
856 | endif |
857 | ||
858 | if cond | |
859 | found_deps += tuple[0] | |
860 | else | |
861 | missing_deps += tuple[0] | |
862 | endif | |
ea6da257 CB |
863 | endforeach |
864 | ||
20b03401 SG |
865 | # Generate config.h |
866 | config_h = configure_file( | |
867 | output: 'config.h', | |
eba7f7a6 | 868 | configuration: srcconf) |
20b03401 SG |
869 | |
870 | add_project_arguments('-include', 'config.h', language: 'c') | |
871 | ||
872 | # Binaries. | |
873 | cmd_programs = [] | |
874 | hook_programs = [] | |
875 | public_programs = [] | |
876 | template_scripts = [] | |
877 | test_programs = [] | |
878 | ||
879 | # Includes. | |
8d77f43f | 880 | liblxc_includes = include_directories( |
20b03401 SG |
881 | '.', |
882 | 'src', | |
8d77f43f SG |
883 | 'src/include', |
884 | 'src/lxc', | |
20b03401 | 885 | 'src/lxc/cgroups', |
8d77f43f | 886 | 'src/lxc/storage') |
20b03401 | 887 | |
c1f87c81 AS |
888 | # Our static sub-project binaries don't (and in fact can't) link to our |
889 | # dependencies directly, but need access to the headers when compiling (most | |
890 | # notably seccomp headers). | |
891 | liblxc_dependency_headers = [] | |
892 | foreach dep: liblxc_dependencies | |
893 | liblxc_dependency_headers += dep.partial_dependency(compile_args: true) | |
894 | endforeach | |
895 | ||
20b03401 SG |
896 | # Early sub-directories. |
897 | subdir('src/include') | |
898 | subdir('src/lxc') | |
24dcd86d | 899 | subdir('src/lxc/pam') |
20b03401 | 900 | |
d42a3b13 | 901 | liblxc_link_whole = [liblxc_static] |
5055c73d | 902 | |
20b03401 SG |
903 | liblxc = shared_library( |
904 | 'lxc', | |
905 | version: liblxc_version, | |
906 | include_directories: liblxc_includes, | |
907 | link_args: ['-DPIC'], | |
908 | c_args: ['-DPIC'], | |
5055c73d | 909 | link_whole: liblxc_link_whole, |
20b03401 SG |
910 | dependencies: liblxc_dependencies, |
911 | install: true) | |
912 | ||
913 | liblxc_dep = declare_dependency( | |
914 | link_with: liblxc, | |
915 | dependencies: liblxc_dependencies) | |
916 | ||
917 | # Rest of sub-directories. | |
826391b2 CB |
918 | if want_apparmor |
919 | subdir('config/apparmor') | |
920 | subdir('config/apparmor/abstractions') | |
921 | subdir('config/apparmor/profiles') | |
922 | endif | |
4a858b56 | 923 | subdir('config/bash') |
9d18059b | 924 | subdir('config/etc') |
e4e52844 SG |
925 | subdir('config/init/common') |
926 | subdir('config/init/systemd') | |
8131bb44 SG |
927 | subdir('config/init/sysvinit') |
928 | subdir('config/init/upstart') | |
826391b2 CB |
929 | if want_selinux |
930 | subdir('config/selinux') | |
931 | endif | |
36a53f30 | 932 | subdir('config/sysconfig') |
c2931f74 SG |
933 | subdir('config/templates') |
934 | subdir('config/templates/common.conf.d') | |
d9121fff | 935 | subdir('config/yum') |
47c56c50 SG |
936 | subdir('doc') |
937 | subdir('doc/ja') | |
938 | subdir('doc/ko') | |
b3da01d7 | 939 | subdir('doc/examples') |
6dfabed1 | 940 | subdir('doc/rootfs') |
20b03401 | 941 | subdir('hooks') |
575d0e34 CB |
942 | if want_commands |
943 | subdir('src/lxc/cmd') | |
944 | endif | |
f4d02217 | 945 | if want_tools or want_tools_multicall |
575d0e34 CB |
946 | subdir('src/lxc/tools') |
947 | endif | |
20b03401 SG |
948 | subdir('src/lxc/tools/include') |
949 | subdir('src/tests') | |
950 | subdir('templates') | |
951 | ||
0860988e SG |
952 | # Pkg-config. |
953 | pkg_config_file = pkgconfig.generate(liblxc, | |
954 | description: 'linux container tools', | |
955 | version: version_data.get('LXC_VERSION'), | |
956 | url: 'http://linuxcontainers.org', | |
957 | libraries: '-lutil -lpthread -ldl', | |
958 | libraries_private: pkgconfig_libs, | |
0860988e SG |
959 | ) |
960 | ||
1404fcb8 SG |
961 | # Empty dirs. |
962 | install_emptydir(join_paths(localstatedir, 'cache', 'lxc')) | |
963 | install_emptydir(join_paths(localstatedir, 'lib', 'lxc')) | |
964 | ||
9c562440 | 965 | # RPM spec file. |
e18dbec7 SG |
966 | specconf = configuration_data() |
967 | specconf.set('LXC_VERSION_BASE', meson.project_version()) | |
968 | specconf.set('LXC_VERSION_BETA', version_data.get('LXC_VERSION_BETA')) | |
969 | specconf.set('PACKAGE', meson.project_name()) | |
970 | specconf.set('LXC_DISTRO_SYSCONF', conf.get('LXC_DISTRO_SYSCONF')) | |
971 | ||
9c562440 | 972 | configure_file( |
e18dbec7 | 973 | configuration: specconf, |
9c562440 SG |
974 | input: 'lxc.spec.in', |
975 | output: 'lxc.spec', | |
976 | install: false) | |
977 | ||
20b03401 | 978 | # Build overview. |
bf1f3470 | 979 | status = [ |
20b03401 SG |
980 | '@0@ @1@'.format(meson.project_name(), meson.project_version()), |
981 | ||
982 | 'Meson version: @0@'.format(meson.version()), | |
983 | ||
984 | 'prefix directory: @0@'.format(prefixdir), | |
985 | 'bin directory: @0@'.format(bindir), | |
986 | 'data directory: @0@'.format(datadir), | |
987 | 'doc directory: @0@'.format(docdir), | |
988 | 'include directory: @0@'.format(includedir), | |
989 | 'lib directory: @0@'.format(libdir), | |
990 | 'libexec directory: @0@'.format(libexecdir), | |
991 | 'local state directory: @0@'.format(localstatedir), | |
992 | 'sbin directory: @0@'.format(sbindir), | |
993 | 'sysconf directory: @0@'.format(sysconfdir), | |
994 | ||
995 | 'lxc cgroup pattern: @0@'.format(cgrouppattern), | |
996 | 'lxc init directory: @0@'.format(libexecdir), | |
997 | 'runtime path: @0@'.format(runtimepath), | |
998 | ||
999 | 'lxc default config: @0@'.format(lxcdefaultconfig), | |
1000 | 'lxc global config: @0@'.format(lxcglobalconfig), | |
1001 | 'lxc hook directory: @0@'.format(lxchookdir), | |
1002 | 'lxc hook bin directory: @0@'.format(lxchookbindir), | |
1003 | 'lxc rootfs mount directory: @0@'.format(lxcrootfsmount), | |
1004 | 'log path: @0@'.format(lxclogpath), | |
1005 | 'lxc path: @0@'.format(lxcpath), | |
51f90ad9 | 1006 | 'lxc template config: @0@'.format(lxctemplateconfdir), |
20b03401 SG |
1007 | 'lxc template directory: @0@'.format(lxctemplatedir), |
1008 | 'lxc user network config: @0@'.format(lxc_user_network_conf), | |
1009 | 'lxc user network database: @0@'.format(lxc_user_network_db)] | |
bf1f3470 | 1010 | |
ea6da257 | 1011 | alt_time_epoch = run_command('date', '-Is', '-u', '-d', |
aa326e18 | 1012 | '@@0@'.format(time_epoch), check: true).stdout().strip() |
ea6da257 | 1013 | status += [ |
20b03401 | 1014 | 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)] |
ea6da257 CB |
1015 | |
1016 | status += [ | |
20b03401 SG |
1017 | '', |
1018 | 'supported dependencies: @0@'.format(', '.join(found_deps)), | |
1019 | '', | |
1020 | 'unsupported dependencies: @0@'.format(', '.join(missing_deps)), | |
1021 | ''] | |
ea6da257 CB |
1022 | |
1023 | status += [ | |
20b03401 SG |
1024 | '', |
1025 | 'supported headers: @0@'.format(', '.join(found_headers)), | |
1026 | '', | |
1027 | 'unsupported headers: @0@'.format(', '.join(missing_headers)), | |
1028 | ''] | |
ea6da257 CB |
1029 | |
1030 | status += [ | |
20b03401 SG |
1031 | '', |
1032 | 'supported calls: @0@'.format(', '.join(found_syscalls)), | |
1033 | '', | |
1034 | 'unsupported calls: @0@'.format(', '.join(missing_syscalls)), | |
1035 | ''] | |
ea6da257 CB |
1036 | |
1037 | status += [ | |
20b03401 SG |
1038 | '', |
1039 | 'supported types: @0@'.format(', '.join(found_types)), | |
1040 | '', | |
1041 | 'unsupported types: @0@'.format(', '.join(missing_types)), | |
1042 | ''] | |
ea6da257 | 1043 | |
20b03401 | 1044 | message('\n '.join(status)) |