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