]> git.ipfire.org Git - thirdparty/systemd.git/blob - meson.build
Merge pull request #8898 from poettering/nspawn-mount-block
[thirdparty/systemd.git] / meson.build
1 # SPDX-License-Identifier: LGPL-2.1+
2 #
3 # Copyright 2017 Zbigniew Jędrzejewski-Szmek
4
5 project('systemd', 'c',
6 version : '238',
7 license : 'LGPLv2+',
8 default_options: [
9 'c_std=gnu99',
10 'prefix=/usr',
11 'sysconfdir=/etc',
12 'localstatedir=/var',
13 ],
14 meson_version : '>= 0.41',
15 )
16
17 libsystemd_version = '0.22.0'
18 libudev_version = '1.6.10'
19
20 # We need the same data in two different formats, ugh!
21 # Also, for hysterical reasons, we use different variable
22 # names, sometimes. Not all variables are included in every
23 # set. Ugh, ugh, ugh!
24 conf = configuration_data()
25 conf.set_quoted('PACKAGE_STRING', meson.project_name() + ' ' + meson.project_version())
26 conf.set_quoted('PACKAGE_VERSION', meson.project_version())
27
28 substs = configuration_data()
29 substs.set('PACKAGE_URL', 'https://www.freedesktop.org/wiki/Software/systemd')
30 substs.set('PACKAGE_VERSION', meson.project_version())
31
32 #####################################################################
33
34 # Try to install the git pre-commit hook
35 git_hook = run_command(join_paths(meson.source_root(), 'tools/add-git-hook.sh'))
36 if git_hook.returncode() == 0
37 message(git_hook.stdout().strip())
38 endif
39
40 #####################################################################
41
42 if get_option('split-usr') == 'auto'
43 split_usr = run_command('test', '-L', '/bin').returncode() != 0
44 else
45 split_usr = get_option('split-usr') == 'true'
46 endif
47 conf.set10('HAVE_SPLIT_USR', split_usr,
48 description : '/usr/bin and /bin directories are separate')
49
50 if get_option('split-bin') == 'auto'
51 split_bin = run_command('test', '-L', '/usr/sbin').returncode() != 0
52 else
53 split_bin = get_option('split-bin') == 'true'
54 endif
55 conf.set10('HAVE_SPLIT_BIN', split_bin,
56 description : 'bin and sbin directories are separate')
57
58 rootprefixdir = get_option('rootprefix')
59 # Unusual rootprefixdir values are used by some distros
60 # (see https://github.com/systemd/systemd/pull/7461).
61 rootprefix_default = split_usr ? '/' : '/usr'
62 if rootprefixdir == ''
63 rootprefixdir = rootprefix_default
64 endif
65
66 sysvinit_path = get_option('sysvinit-path')
67 sysvrcnd_path = get_option('sysvrcnd-path')
68 conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '',
69 description : 'SysV init scripts and rcN.d links are supported')
70
71 # join_paths ignore the preceding arguments if an absolute component is
72 # encountered, so this should canonicalize various paths when they are
73 # absolute or relative.
74 prefixdir = get_option('prefix')
75 if not prefixdir.startswith('/')
76 error('Prefix is not absolute: "@0@"'.format(prefixdir))
77 endif
78 bindir = join_paths(prefixdir, get_option('bindir'))
79 libdir = join_paths(prefixdir, get_option('libdir'))
80 sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
81 includedir = join_paths(prefixdir, get_option('includedir'))
82 datadir = join_paths(prefixdir, get_option('datadir'))
83 localstatedir = join_paths('/', get_option('localstatedir'))
84
85 rootbindir = join_paths(rootprefixdir, 'bin')
86 rootsbindir = join_paths(rootprefixdir, split_bin ? 'sbin' : 'bin')
87 rootlibexecdir = join_paths(rootprefixdir, 'lib/systemd')
88
89 rootlibdir = get_option('rootlibdir')
90 if rootlibdir == ''
91 rootlibdir = join_paths(rootprefixdir, libdir.split('/')[-1])
92 endif
93
94 # Dirs of external packages
95 pkgconfigdatadir = join_paths(datadir, 'pkgconfig')
96 pkgconfiglibdir = join_paths(libdir, 'pkgconfig')
97 polkitpolicydir = join_paths(datadir, 'polkit-1/actions')
98 polkitrulesdir = join_paths(datadir, 'polkit-1/rules.d')
99 polkitpkladir = join_paths(localstatedir, 'lib/polkit-1/localauthority/10-vendor.d')
100 varlogdir = join_paths(localstatedir, 'log')
101 xinitrcdir = join_paths(sysconfdir, 'X11/xinit/xinitrc.d')
102 rpmmacrosdir = get_option('rpmmacrosdir')
103 if rpmmacrosdir != 'no'
104 rpmmacrosdir = join_paths(prefixdir, rpmmacrosdir)
105 endif
106 modprobedir = join_paths(rootprefixdir, 'lib/modprobe.d')
107
108 # Our own paths
109 pkgdatadir = join_paths(datadir, 'systemd')
110 environmentdir = join_paths(prefixdir, 'lib/environment.d')
111 pkgsysconfdir = join_paths(sysconfdir, 'systemd')
112 userunitdir = join_paths(prefixdir, 'lib/systemd/user')
113 userpresetdir = join_paths(prefixdir, 'lib/systemd/user-preset')
114 tmpfilesdir = join_paths(prefixdir, 'lib/tmpfiles.d')
115 sysusersdir = join_paths(prefixdir, 'lib/sysusers.d')
116 sysctldir = join_paths(prefixdir, 'lib/sysctl.d')
117 binfmtdir = join_paths(prefixdir, 'lib/binfmt.d')
118 modulesloaddir = join_paths(prefixdir, 'lib/modules-load.d')
119 networkdir = join_paths(rootprefixdir, 'lib/systemd/network')
120 pkgincludedir = join_paths(includedir, 'systemd')
121 systemgeneratordir = join_paths(rootlibexecdir, 'system-generators')
122 usergeneratordir = join_paths(prefixdir, 'lib/systemd/user-generators')
123 systemenvgeneratordir = join_paths(prefixdir, 'lib/systemd/system-environment-generators')
124 userenvgeneratordir = join_paths(prefixdir, 'lib/systemd/user-environment-generators')
125 systemshutdowndir = join_paths(rootlibexecdir, 'system-shutdown')
126 systemsleepdir = join_paths(rootlibexecdir, 'system-sleep')
127 systemunitdir = join_paths(rootprefixdir, 'lib/systemd/system')
128 systempresetdir = join_paths(rootprefixdir, 'lib/systemd/system-preset')
129 udevlibexecdir = join_paths(rootprefixdir, 'lib/udev')
130 udevhomedir = udevlibexecdir
131 udevrulesdir = join_paths(udevlibexecdir, 'rules.d')
132 udevhwdbdir = join_paths(udevlibexecdir, 'hwdb.d')
133 catalogdir = join_paths(prefixdir, 'lib/systemd/catalog')
134 kernelinstalldir = join_paths(prefixdir, 'lib/kernel/install.d')
135 factorydir = join_paths(datadir, 'factory')
136 bootlibdir = join_paths(prefixdir, 'lib/systemd/boot/efi')
137 testsdir = join_paths(prefixdir, 'lib/systemd/tests')
138 systemdstatedir = join_paths(localstatedir, 'lib/systemd')
139 catalogstatedir = join_paths(systemdstatedir, 'catalog')
140 randomseeddir = join_paths(localstatedir, 'lib/systemd')
141
142 docdir = get_option('docdir')
143 if docdir == ''
144 docdir = join_paths(datadir, 'doc/systemd')
145 endif
146
147 dbuspolicydir = get_option('dbuspolicydir')
148 if dbuspolicydir == ''
149 dbuspolicydir = join_paths(datadir, 'dbus-1/system.d')
150 endif
151
152 dbussessionservicedir = get_option('dbussessionservicedir')
153 if dbussessionservicedir == ''
154 dbussessionservicedir = join_paths(datadir, 'dbus-1/services')
155 endif
156
157 dbussystemservicedir = get_option('dbussystemservicedir')
158 if dbussystemservicedir == ''
159 dbussystemservicedir = join_paths(datadir, 'dbus-1/system-services')
160 endif
161
162 pamlibdir = get_option('pamlibdir')
163 if pamlibdir == ''
164 pamlibdir = join_paths(rootlibdir, 'security')
165 endif
166
167 pamconfdir = get_option('pamconfdir')
168 if pamconfdir == ''
169 pamconfdir = join_paths(sysconfdir, 'pam.d')
170 endif
171
172 memory_accounting_default = get_option('memory-accounting-default')
173
174 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
175 conf.set_quoted('SYSTEM_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'system'))
176 conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
177 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
178 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
179 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
180 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
181
182 conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
183
184 conf.set_quoted('USER_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'user'))
185 conf.set_quoted('USER_DATA_UNIT_PATH', userunitdir)
186 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
187 conf.set_quoted('CATALOG_DATABASE', join_paths(catalogstatedir, 'database'))
188 conf.set_quoted('SYSTEMD_CGROUP_AGENT_PATH', join_paths(rootlibexecdir, 'systemd-cgroups-agent'))
189 conf.set_quoted('SYSTEMD_BINARY_PATH', join_paths(rootlibexecdir, 'systemd'))
190 conf.set_quoted('SYSTEMD_FSCK_PATH', join_paths(rootlibexecdir, 'systemd-fsck'))
191 conf.set_quoted('SYSTEMD_MAKEFS_PATH', join_paths(rootlibexecdir, 'systemd-makefs'))
192 conf.set_quoted('SYSTEMD_GROWFS_PATH', join_paths(rootlibexecdir, 'systemd-growfs'))
193 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-shutdown'))
194 conf.set_quoted('SYSTEMD_SLEEP_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-sleep'))
195 conf.set_quoted('SYSTEMCTL_BINARY_PATH', join_paths(rootbindir, 'systemctl'))
196 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', join_paths(rootbindir, 'systemd-tty-ask-password-agent'))
197 conf.set_quoted('SYSTEMD_STDIO_BRIDGE_BINARY_PATH', join_paths(bindir, 'systemd-stdio-bridge'))
198 conf.set_quoted('ROOTPREFIX', rootprefixdir)
199 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
200 conf.set_quoted('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
201 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', join_paths(rootlibexecdir, 'systemd-cryptsetup'))
202 conf.set_quoted('SYSTEM_GENERATOR_PATH', systemgeneratordir)
203 conf.set_quoted('USER_GENERATOR_PATH', usergeneratordir)
204 conf.set_quoted('SYSTEM_ENV_GENERATOR_PATH', systemenvgeneratordir)
205 conf.set_quoted('USER_ENV_GENERATOR_PATH', userenvgeneratordir)
206 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
207 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
208 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', join_paths(pkgdatadir, 'kbd-model-map'))
209 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', join_paths(pkgdatadir, 'language-fallback-map'))
210 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
211 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', join_paths(bindir, 'pkttyagent'))
212 conf.set_quoted('LIBDIR', libdir)
213 conf.set_quoted('ROOTLIBDIR', rootlibdir)
214 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
215 conf.set_quoted('BOOTLIBDIR', bootlibdir)
216 conf.set_quoted('SYSTEMD_PULL_PATH', join_paths(rootlibexecdir, 'systemd-pull'))
217 conf.set_quoted('SYSTEMD_IMPORT_PATH', join_paths(rootlibexecdir, 'systemd-import'))
218 conf.set_quoted('SYSTEMD_EXPORT_PATH', join_paths(rootlibexecdir, 'systemd-export'))
219 conf.set_quoted('VENDOR_KEYRING_PATH', join_paths(rootlibexecdir, 'import-pubring.gpg'))
220 conf.set_quoted('USER_KEYRING_PATH', join_paths(pkgsysconfdir, 'import-pubring.gpg'))
221 conf.set_quoted('DOCUMENT_ROOT', join_paths(pkgdatadir, 'gatewayd'))
222 conf.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'true' : 'false')
223 conf.set_quoted('MEMORY_ACCOUNTING_DEFAULT_YES_NO', memory_accounting_default ? 'yes' : 'no')
224
225 conf.set_quoted('ABS_BUILD_DIR', meson.build_root())
226 conf.set_quoted('ABS_SRC_DIR', meson.source_root())
227
228 substs.set('prefix', prefixdir)
229 substs.set('exec_prefix', prefixdir)
230 substs.set('libdir', libdir)
231 substs.set('rootlibdir', rootlibdir)
232 substs.set('includedir', includedir)
233 substs.set('pkgsysconfdir', pkgsysconfdir)
234 substs.set('bindir', bindir)
235 substs.set('rootbindir', rootbindir)
236 substs.set('rootlibexecdir', rootlibexecdir)
237 substs.set('systemunitdir', systemunitdir)
238 substs.set('userunitdir', userunitdir)
239 substs.set('systempresetdir', systempresetdir)
240 substs.set('userpresetdir', userpresetdir)
241 substs.set('udevhwdbdir', udevhwdbdir)
242 substs.set('udevrulesdir', udevrulesdir)
243 substs.set('udevlibexecdir', udevlibexecdir)
244 substs.set('catalogdir', catalogdir)
245 substs.set('tmpfilesdir', tmpfilesdir)
246 substs.set('sysusersdir', sysusersdir)
247 substs.set('sysctldir', sysctldir)
248 substs.set('binfmtdir', binfmtdir)
249 substs.set('modulesloaddir', modulesloaddir)
250 substs.set('systemgeneratordir', systemgeneratordir)
251 substs.set('usergeneratordir', usergeneratordir)
252 substs.set('systemenvgeneratordir', systemenvgeneratordir)
253 substs.set('userenvgeneratordir', userenvgeneratordir)
254 substs.set('systemshutdowndir', systemshutdowndir)
255 substs.set('systemsleepdir', systemsleepdir)
256 substs.set('VARLOGDIR', varlogdir)
257 substs.set('CERTIFICATEROOT', get_option('certificate-root'))
258 substs.set('SYSTEMCTL', join_paths(rootbindir, 'systemctl'))
259 substs.set('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
260 substs.set('SYSTEM_SYSVINIT_PATH', sysvinit_path)
261 substs.set('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
262 substs.set('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
263 substs.set('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
264 substs.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'yes' : 'no')
265
266 #####################################################################
267
268 cc = meson.get_compiler('c')
269 pkgconfig = import('pkgconfig')
270 check_compilation_sh = find_program('tools/meson-check-compilation.sh')
271 meson_build_sh = find_program('tools/meson-build.sh')
272
273 if get_option('tests') != 'false'
274 cxx = find_program('c++', required : false)
275 if cxx.found()
276 # Used only for tests
277 add_languages('cpp')
278 endif
279 endif
280
281 want_ossfuzz = get_option('oss-fuzz')
282 want_libfuzzer = get_option('llvm-fuzz')
283 fuzzer_build = want_ossfuzz or want_libfuzzer
284 if want_ossfuzz and want_libfuzzer
285 error('only one of oss-fuzz and llvm-fuzz can be specified')
286 endif
287 if want_libfuzzer
288 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer')
289 endif
290 if want_ossfuzz
291 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
292 endif
293
294 foreach arg : ['-Wextra',
295 '-Werror=undef',
296 '-Wlogical-op',
297 '-Wmissing-include-dirs',
298 '-Wold-style-definition',
299 '-Wpointer-arith',
300 '-Winit-self',
301 '-Wdeclaration-after-statement',
302 '-Wfloat-equal',
303 '-Wsuggest-attribute=noreturn',
304 '-Werror=missing-prototypes',
305 '-Werror=implicit-function-declaration',
306 '-Werror=missing-declarations',
307 '-Werror=return-type',
308 '-Werror=incompatible-pointer-types',
309 '-Werror=format=2',
310 '-Wstrict-prototypes',
311 '-Wredundant-decls',
312 '-Wmissing-noreturn',
313 '-Wimplicit-fallthrough=5',
314 '-Wshadow',
315 '-Wendif-labels',
316 '-Wstrict-aliasing=2',
317 '-Wwrite-strings',
318 '-Werror=overflow',
319 '-Wdate-time',
320 '-Wnested-externs',
321 '-ffast-math',
322 '-fno-common',
323 '-fdiagnostics-show-option',
324 '-fno-strict-aliasing',
325 '-fvisibility=hidden',
326 '-fstack-protector',
327 '-fstack-protector-strong',
328 '--param=ssp-buffer-size=4',
329 ]
330 if cc.has_argument(arg)
331 add_project_arguments(arg, language : 'c')
332 endif
333 endforeach
334
335 # the oss-fuzz fuzzers are not built with -fPIE, so don't
336 # enable it when we are linking against them
337 if not fuzzer_build
338 if cc.has_argument('-fPIE')
339 add_project_arguments('-fPIE', language : 'c')
340 endif
341 endif
342
343 # "negative" arguments: gcc on purpose does not return an error for "-Wno-"
344 # arguments, just emits a warnings. So test for the "positive" version instead.
345 foreach arg : ['unused-parameter',
346 'missing-field-initializers',
347 'unused-result',
348 'format-signedness',
349 'error=nonnull', # work-around for gcc 7.1 turning this on on its own
350 ]
351 if cc.has_argument('-W' + arg)
352 add_project_arguments('-Wno-' + arg, language : 'c')
353 endif
354 endforeach
355
356 if cc.compiles('''
357 #include <time.h>
358 #include <inttypes.h>
359 typedef uint64_t usec_t;
360 usec_t now(clockid_t clock);
361 int main(void) {
362 struct timespec now;
363 return 0;
364 }
365 ''', name : '-Werror=shadow with local shadowing')
366 add_project_arguments('-Werror=shadow', language : 'c')
367 endif
368
369 if cc.get_id() == 'clang'
370 foreach arg : ['-Wno-typedef-redefinition',
371 '-Wno-gnu-variable-sized-type-not-at-end',
372 ]
373 if cc.has_argument(arg)
374 add_project_arguments(arg, language : 'c')
375 endif
376 endforeach
377 endif
378
379 link_test_c = files('tools/meson-link-test.c')
380
381 # --as-needed and --no-undefined are provided by meson by default,
382 # run mesonconf to see what is enabled
383 foreach arg : ['-Wl,-z,relro',
384 '-Wl,-z,now',
385 '-pie',
386 ]
387
388 have = run_command(check_compilation_sh,
389 cc.cmd_array(), '-x', 'c', arg,
390 '-include', link_test_c).returncode() == 0
391 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
392 if have and (arg != '-pie' or not fuzzer_build)
393 add_project_link_arguments(arg, language : 'c')
394 endif
395 endforeach
396
397 if get_option('buildtype') != 'debug'
398 foreach arg : ['-ffunction-sections',
399 '-fdata-sections']
400 if cc.has_argument(arg)
401 add_project_arguments(arg, language : 'c')
402 endif
403 endforeach
404
405 foreach arg : ['-Wl,--gc-sections']
406 have = run_command(check_compilation_sh,
407 cc.cmd_array(), '-x', 'c', arg,
408 '-include', link_test_c).returncode() == 0
409 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
410 if have
411 add_project_link_arguments(arg, language : 'c')
412 endif
413 endforeach
414 endif
415
416 cpp = ' '.join(cc.cmd_array()) + ' -E'
417
418 #####################################################################
419 # compilation result tests
420
421 conf.set('_GNU_SOURCE', true)
422 conf.set('__SANE_USERSPACE_TYPES__', true)
423
424 conf.set('SIZEOF_PID_T', cc.sizeof('pid_t', prefix : '#include <sys/types.h>'))
425 conf.set('SIZEOF_UID_T', cc.sizeof('uid_t', prefix : '#include <sys/types.h>'))
426 conf.set('SIZEOF_GID_T', cc.sizeof('gid_t', prefix : '#include <sys/types.h>'))
427 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
428 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
429 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
430 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
431
432 decl_headers = '''
433 #include <uchar.h>
434 #include <linux/ethtool.h>
435 #include <linux/fib_rules.h>
436 #include <linux/stat.h>
437 #include <sys/stat.h>
438 '''
439 # FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
440
441 foreach decl : ['char16_t',
442 'char32_t',
443 'key_serial_t',
444 'struct ethtool_link_settings',
445 'struct fib_rule_uid_range',
446 'struct statx',
447 ]
448
449 # We get -1 if the size cannot be determined
450 have = cc.sizeof(decl, prefix : decl_headers) > 0
451 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
452 endforeach
453
454 foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'],
455 ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
456 ['IFLA_VRF_TABLE', 'linux/if_link.h'],
457 ['IFLA_MACVLAN_FLAGS', 'linux/if_link.h'],
458 ['IFLA_IPVLAN_FLAGS', 'linux/if_link.h'],
459 ['IFLA_PHYS_PORT_ID', 'linux/if_link.h'],
460 ['IFLA_BOND_AD_INFO', 'linux/if_link.h'],
461 ['IFLA_VLAN_PROTOCOL', 'linux/if_link.h'],
462 ['IFLA_VXLAN_REMCSUM_NOPARTIAL', 'linux/if_link.h'],
463 ['IFLA_VXLAN_GPE', 'linux/if_link.h'],
464 ['IFLA_GENEVE_LABEL', 'linux/if_link.h'],
465 # if_tunnel.h is buggy and cannot be included on its own
466 ['IFLA_VTI_REMOTE', 'linux/if_tunnel.h', '#include <net/if.h>'],
467 ['IFLA_IPTUN_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
468 ['IFLA_GRE_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
469 ['IFLA_BRIDGE_VLAN_INFO', 'linux/if_bridge.h'],
470 ['IFLA_BRPORT_PROXYARP', 'linux/if_link.h'],
471 ['IFLA_BRPORT_LEARNING_SYNC', 'linux/if_link.h'],
472 ['IFLA_BR_VLAN_DEFAULT_PVID', 'linux/if_link.h'],
473 ['IPVLAN_F_PRIVATE', 'linux/if_link.h'],
474 ['NDA_IFINDEX', 'linux/neighbour.h'],
475 ['IFA_FLAGS', 'linux/if_addr.h'],
476 ['FRA_UID_RANGE', 'linux/fib_rules.h'],
477 ['LO_FLAGS_PARTSCAN', 'linux/loop.h'],
478 ['VXCAN_INFO_PEER', 'linux/can/vxcan.h'],
479 ]
480 prefix = decl.length() > 2 ? decl[2] : ''
481 have = cc.has_header_symbol(decl[1], decl[0], prefix : prefix)
482 conf.set10('HAVE_' + decl[0], have)
483 endforeach
484
485 foreach ident : ['secure_getenv', '__secure_getenv']
486 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
487 endforeach
488
489 foreach ident : [
490 ['memfd_create', '''#include <sys/mman.h>'''],
491 ['gettid', '''#include <sys/types.h>
492 #include <unistd.h>'''],
493 ['pivot_root', '''#include <stdlib.h>
494 #include <unistd.h>'''], # no known header declares pivot_root
495 ['name_to_handle_at', '''#include <sys/types.h>
496 #include <sys/stat.h>
497 #include <fcntl.h>'''],
498 ['setns', '''#include <sched.h>'''],
499 ['renameat2', '''#include <stdio.h>
500 #include <fcntl.h>'''],
501 ['kcmp', '''#include <linux/kcmp.h>'''],
502 ['keyctl', '''#include <sys/types.h>
503 #include <keyutils.h>'''],
504 ['copy_file_range', '''#include <sys/syscall.h>
505 #include <unistd.h>'''],
506 ['bpf', '''#include <sys/syscall.h>
507 #include <unistd.h>'''],
508 ['statx', '''#include <sys/types.h>
509 #include <sys/stat.h>
510 #include <unistd.h>'''],
511 ['explicit_bzero' , '''#include <string.h>'''],
512 ['reallocarray', '''#include <malloc.h>'''],
513 ]
514
515 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
516 conf.set10('HAVE_' + ident[0].to_upper(), have)
517 endforeach
518
519 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
520 conf.set10('USE_SYS_RANDOM_H', true)
521 conf.set10('HAVE_GETRANDOM', true)
522 else
523 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
524 conf.set10('USE_SYS_RANDOM_H', false)
525 conf.set10('HAVE_GETRANDOM', have)
526 endif
527
528 #####################################################################
529
530 sed = find_program('sed')
531 awk = find_program('awk')
532 m4 = find_program('m4')
533 stat = find_program('stat')
534 git = find_program('git', required : false)
535 env = find_program('env')
536 perl = find_program('perl', required : false)
537
538 meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
539 mkdir_p = 'mkdir -p $DESTDIR/@0@'
540 test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
541 splash_bmp = files('test/splash.bmp')
542
543 # if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
544 # /usr/sbin, /sbin, and fall back to the default from middle column.
545 progs = [['quotaon', '/usr/sbin/quotaon' ],
546 ['quotacheck', '/usr/sbin/quotacheck' ],
547 ['kmod', '/usr/bin/kmod' ],
548 ['kexec', '/usr/sbin/kexec' ],
549 ['sulogin', '/usr/sbin/sulogin' ],
550 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
551 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
552 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
553 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
554 ]
555 foreach prog : progs
556 path = get_option(prog[0] + '-path')
557 if path != ''
558 message('Using @1@ for @0@'.format(prog[0], path))
559 else
560 exe = find_program(prog[0],
561 '/usr/sbin/' + prog[0],
562 '/sbin/' + prog[0],
563 required: false)
564 path = exe.found() ? exe.path() : prog[1]
565 endif
566 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
567 conf.set_quoted(name, path)
568 substs.set(name, path)
569 endforeach
570
571 conf.set_quoted('TELINIT', get_option('telinit-path'))
572
573 if run_command('ln', '--relative', '--help').returncode() != 0
574 error('ln does not support --relative (added in coreutils 8.16)')
575 endif
576
577 ############################################################
578
579 gperf = find_program('gperf')
580
581 gperf_test_format = '''
582 #include <string.h>
583 const char * in_word_set(const char *, @0@);
584 @1@
585 '''
586 gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
587 gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
588 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
589 if cc.compiles(gperf_test)
590 gperf_len_type = 'size_t'
591 else
592 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
593 if cc.compiles(gperf_test)
594 gperf_len_type = 'unsigned'
595 else
596 error('unable to determine gperf len type')
597 endif
598 endif
599 message('gperf len type is @0@'.format(gperf_len_type))
600 conf.set('GPERF_LEN_TYPE', gperf_len_type,
601 description : 'The type of gperf "len" parameter')
602
603 ############################################################
604
605 if not cc.has_header('sys/capability.h')
606 error('POSIX caps headers not found')
607 endif
608 foreach header : ['crypt.h',
609 'linux/btrfs.h',
610 'linux/memfd.h',
611 'linux/vm_sockets.h',
612 'sys/auxv.h',
613 'valgrind/memcheck.h',
614 'valgrind/valgrind.h',
615 ]
616
617 conf.set10('HAVE_' + header.underscorify().to_upper(),
618 cc.has_header(header))
619 endforeach
620
621 ############################################################
622
623 conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
624 conf.set10('ENABLE_COMPAT_GATEWAY_HOSTNAME', get_option('compat-gateway-hostname'))
625 gateway_hostnames = ['_gateway'] + (conf.get('ENABLE_COMPAT_GATEWAY_HOSTNAME') == 1 ? ['gateway'] : [])
626
627 default_hierarchy = get_option('default-hierarchy')
628 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
629 description : 'default cgroup hierarchy as string')
630 if default_hierarchy == 'legacy'
631 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
632 elif default_hierarchy == 'hybrid'
633 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
634 else
635 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
636 endif
637
638 time_epoch = get_option('time-epoch')
639 if time_epoch == ''
640 NEWS = files('NEWS')
641 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
642 endif
643 time_epoch = time_epoch.to_int()
644 conf.set('TIME_EPOCH', time_epoch)
645
646 system_uid_max = get_option('system-uid-max')
647 if system_uid_max == ''
648 system_uid_max = run_command(
649 awk,
650 '/^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
651 '/etc/login.defs').stdout().strip()
652 if system_uid_max == ''
653 system_uid_max = '999'
654 endif
655 endif
656 system_uid_max = system_uid_max.to_int()
657 conf.set('SYSTEM_UID_MAX', system_uid_max)
658 substs.set('systemuidmax', system_uid_max)
659 message('maximum system UID is @0@'.format(system_uid_max))
660
661 system_gid_max = get_option('system-gid-max')
662 if system_gid_max == ''
663 system_gid_max = run_command(
664 awk,
665 '/^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
666 '/etc/login.defs').stdout().strip()
667 if system_gid_max == ''
668 system_gid_max = '999'
669 endif
670 endif
671 system_gid_max = system_gid_max.to_int()
672 conf.set('SYSTEM_GID_MAX', system_gid_max)
673 substs.set('systemgidmax', system_gid_max)
674 message('maximum system GID is @0@'.format(system_gid_max))
675
676 dynamic_uid_min = get_option('dynamic-uid-min').to_int()
677 dynamic_uid_max = get_option('dynamic-uid-max').to_int()
678 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
679 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
680 substs.set('dynamicuidmin', dynamic_uid_min)
681 substs.set('dynamicuidmax', dynamic_uid_max)
682
683 container_uid_base_min = get_option('container-uid-base-min').to_int()
684 container_uid_base_max = get_option('container-uid-base-max').to_int()
685 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
686 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
687 substs.set('containeruidbasemin', container_uid_base_min)
688 substs.set('containeruidbasemax', container_uid_base_max)
689
690 nobody_user = get_option('nobody-user')
691 nobody_group = get_option('nobody-group')
692
693 getent_result = run_command('getent', 'passwd', '65534')
694 if getent_result.returncode() == 0
695 name = getent_result.stdout().split(':')[0]
696 if name != nobody_user
697 message('WARNING:\n' +
698 ' The local user with the UID 65534 does not match the configured user name "@0@" of the nobody user (its name is @1@).\n'.format(nobody_user, name) +
699 ' Your build will result in an user table setup that is incompatible with the local system.')
700 endif
701 endif
702 id_result = run_command('id', '-u', nobody_user)
703 if id_result.returncode() == 0
704 id = id_result.stdout().to_int()
705 if id != 65534
706 message('WARNING:\n' +
707 ' The local user with the configured user name "@0@" of the nobody user does not have UID 65534 (it has @1@).\n'.format(nobody_user, id) +
708 ' Your build will result in an user table setup that is incompatible with the local system.')
709 endif
710 endif
711
712 getent_result = run_command('getent', 'group', '65534')
713 if getent_result.returncode() == 0
714 name = getent_result.stdout().split(':')[0]
715 if name != nobody_group
716 message('WARNING:\n' +
717 ' The local group with the GID 65534 does not match the configured group name "@0@" of the nobody group (its name is @1@).\n'.format(nobody_group, name) +
718 ' Your build will result in an group table setup that is incompatible with the local system.')
719 endif
720 endif
721 id_result = run_command('id', '-g', nobody_group)
722 if id_result.returncode() == 0
723 id = id_result.stdout().to_int()
724 if id != 65534
725 message('WARNING:\n' +
726 ' The local group with the configured group name "@0@" of the nobody group does not have UID 65534 (it has @1@).\n'.format(nobody_group, id) +
727 ' Your build will result in an group table setup that is incompatible with the local system.')
728 endif
729 endif
730 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
731 message('WARNING:\n' +
732 ' The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
733 ' Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
734 endif
735
736 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
737 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
738 substs.set('NOBODY_USER_NAME', nobody_user)
739 substs.set('NOBODY_GROUP_NAME', nobody_group)
740
741 tty_gid = get_option('tty-gid')
742 conf.set('TTY_GID', tty_gid)
743 substs.set('TTY_GID', tty_gid)
744
745 # Ensure provided GID argument is numeric, otherwise fallback to default assignment
746 if get_option('users-gid') != ''
747 users_gid = get_option('users-gid').to_int()
748 else
749 users_gid = '-'
750 endif
751 substs.set('USERS_GID', users_gid)
752
753 conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
754 conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
755
756 substs.set('DEV_KVM_MODE', get_option('dev-kvm-mode'))
757 substs.set('GROUP_RENDER_MODE', get_option('group-render-mode'))
758
759 kill_user_processes = get_option('default-kill-user-processes')
760 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
761 conf.set_quoted('KILL_USER_PROCESSES_YES_NO', kill_user_processes ? 'yes' : 'no')
762 substs.set('KILL_USER_PROCESSES', kill_user_processes ? 'yes' : 'no')
763
764 dns_servers = get_option('dns-servers')
765 conf.set_quoted('DNS_SERVERS', dns_servers)
766 substs.set('DNS_SERVERS', dns_servers)
767
768 ntp_servers = get_option('ntp-servers')
769 conf.set_quoted('NTP_SERVERS', ntp_servers)
770 substs.set('NTP_SERVERS', ntp_servers)
771
772 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
773
774 substs.set('SUSHELL', get_option('debug-shell'))
775 substs.set('DEBUGTTY', get_option('debug-tty'))
776
777 debug = get_option('debug')
778 enable_debug_hashmap = false
779 enable_debug_mmap_cache = false
780 if debug != ''
781 foreach name : debug.split(',')
782 if name == 'hashmap'
783 enable_debug_hashmap = true
784 elif name == 'mmap-cache'
785 enable_debug_mmap_cache = true
786 else
787 message('unknown debug option "@0@", ignoring'.format(name))
788 endif
789 endforeach
790 endif
791 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
792 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
793
794 #####################################################################
795
796 threads = dependency('threads')
797 librt = cc.find_library('rt')
798 libm = cc.find_library('m')
799 libdl = cc.find_library('dl')
800 libcrypt = cc.find_library('crypt')
801
802 libcap = dependency('libcap', required : false)
803 if not libcap.found()
804 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
805 libcap = cc.find_library('cap')
806 endif
807
808 libmount = dependency('mount',
809 version : fuzzer_build ? '>= 0' : '>= 2.30')
810
811 want_seccomp = get_option('seccomp')
812 if want_seccomp != 'false' and not fuzzer_build
813 libseccomp = dependency('libseccomp',
814 version : '>= 2.3.1',
815 required : want_seccomp == 'true')
816 have = libseccomp.found()
817 else
818 have = false
819 libseccomp = []
820 endif
821 conf.set10('HAVE_SECCOMP', have)
822
823 want_selinux = get_option('selinux')
824 if want_selinux != 'false' and not fuzzer_build
825 libselinux = dependency('libselinux',
826 version : '>= 2.1.9',
827 required : want_selinux == 'true')
828 have = libselinux.found()
829 else
830 have = false
831 libselinux = []
832 endif
833 conf.set10('HAVE_SELINUX', have)
834
835 want_apparmor = get_option('apparmor')
836 if want_apparmor != 'false' and not fuzzer_build
837 libapparmor = dependency('libapparmor',
838 required : want_apparmor == 'true')
839 have = libapparmor.found()
840 else
841 have = false
842 libapparmor = []
843 endif
844 conf.set10('HAVE_APPARMOR', have)
845
846 smack_run_label = get_option('smack-run-label')
847 if smack_run_label != ''
848 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
849 endif
850
851 want_polkit = get_option('polkit')
852 install_polkit = false
853 install_polkit_pkla = false
854 if want_polkit != 'false' and not fuzzer_build
855 install_polkit = true
856
857 libpolkit = dependency('polkit-gobject-1',
858 required : false)
859 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
860 message('Old polkit detected, will install pkla files')
861 install_polkit_pkla = true
862 endif
863 endif
864 conf.set10('ENABLE_POLKIT', install_polkit)
865
866 want_acl = get_option('acl')
867 if want_acl != 'false' and not fuzzer_build
868 libacl = cc.find_library('acl', required : want_acl == 'true')
869 have = libacl.found()
870 else
871 have = false
872 libacl = []
873 endif
874 conf.set10('HAVE_ACL', have)
875
876 want_audit = get_option('audit')
877 if want_audit != 'false' and not fuzzer_build
878 libaudit = dependency('audit', required : want_audit == 'true')
879 have = libaudit.found()
880 else
881 have = false
882 libaudit = []
883 endif
884 conf.set10('HAVE_AUDIT', have)
885
886 want_blkid = get_option('blkid')
887 if want_blkid != 'false' and not fuzzer_build
888 libblkid = dependency('blkid', required : want_blkid == 'true')
889 have = libblkid.found()
890 else
891 have = false
892 libblkid = []
893 endif
894 conf.set10('HAVE_BLKID', have)
895
896 want_kmod = get_option('kmod')
897 if want_kmod != 'false' and not fuzzer_build
898 libkmod = dependency('libkmod',
899 version : '>= 15',
900 required : want_kmod == 'true')
901 have = libkmod.found()
902 else
903 have = false
904 libkmod = []
905 endif
906 conf.set10('HAVE_KMOD', have)
907
908 want_pam = get_option('pam')
909 if want_pam != 'false' and not fuzzer_build
910 libpam = cc.find_library('pam', required : want_pam == 'true')
911 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
912 have = libpam.found() and libpam_misc.found()
913 else
914 have = false
915 libpam = []
916 libpam_misc = []
917 endif
918 conf.set10('HAVE_PAM', have)
919
920 want_microhttpd = get_option('microhttpd')
921 if want_microhttpd != 'false' and not fuzzer_build
922 libmicrohttpd = dependency('libmicrohttpd',
923 version : '>= 0.9.33',
924 required : want_microhttpd == 'true')
925 have = libmicrohttpd.found()
926 else
927 have = false
928 libmicrohttpd = []
929 endif
930 conf.set10('HAVE_MICROHTTPD', have)
931
932 want_libcryptsetup = get_option('libcryptsetup')
933 if want_libcryptsetup != 'false' and not fuzzer_build
934 libcryptsetup = dependency('libcryptsetup',
935 version : '>= 1.6.0',
936 required : want_libcryptsetup == 'true')
937 have = libcryptsetup.found()
938 else
939 have = false
940 libcryptsetup = []
941 endif
942 conf.set10('HAVE_LIBCRYPTSETUP', have)
943
944 want_libcurl = get_option('libcurl')
945 if want_libcurl != 'false' and not fuzzer_build
946 libcurl = dependency('libcurl',
947 version : '>= 7.32.0',
948 required : want_libcurl == 'true')
949 have = libcurl.found()
950 else
951 have = false
952 libcurl = []
953 endif
954 conf.set10('HAVE_LIBCURL', have)
955
956 want_libidn = get_option('libidn')
957 want_libidn2 = get_option('libidn2')
958 if want_libidn == 'true' and want_libidn2 == 'true'
959 error('libidn and libidn2 cannot be requested simultaneously')
960 endif
961
962 if want_libidn != 'false' and want_libidn2 != 'true' and not fuzzer_build
963 libidn = dependency('libidn',
964 required : want_libidn == 'true')
965 have = libidn.found()
966 else
967 have = false
968 libidn = []
969 endif
970 conf.set10('HAVE_LIBIDN', have)
971 if not have and want_libidn2 != 'false' and not fuzzer_build
972 # libidn is used for both libidn and libidn2 objects
973 libidn = dependency('libidn2',
974 required : want_libidn2 == 'true')
975 have = libidn.found()
976 else
977 have = false
978 endif
979 conf.set10('HAVE_LIBIDN2', have)
980
981 want_libiptc = get_option('libiptc')
982 if want_libiptc != 'false' and not fuzzer_build
983 libiptc = dependency('libiptc',
984 required : want_libiptc == 'true')
985 have = libiptc.found()
986 else
987 have = false
988 libiptc = []
989 endif
990 conf.set10('HAVE_LIBIPTC', have)
991
992 want_qrencode = get_option('qrencode')
993 if want_qrencode != 'false' and not fuzzer_build
994 libqrencode = dependency('libqrencode',
995 required : want_qrencode == 'true')
996 have = libqrencode.found()
997 else
998 have = false
999 libqrencode = []
1000 endif
1001 conf.set10('HAVE_QRENCODE', have)
1002
1003 want_gcrypt = get_option('gcrypt')
1004 if want_gcrypt != 'false' and not fuzzer_build
1005 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1006 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1007 have = libgcrypt.found() and libgpg_error.found()
1008 else
1009 have = false
1010 endif
1011 if not have
1012 # link to neither of the libs if one is not found
1013 libgcrypt = []
1014 libgpg_error = []
1015 endif
1016 conf.set10('HAVE_GCRYPT', have)
1017
1018 want_gnutls = get_option('gnutls')
1019 if want_gnutls != 'false' and not fuzzer_build
1020 libgnutls = dependency('gnutls',
1021 version : '>= 3.1.4',
1022 required : want_gnutls == 'true')
1023 have = libgnutls.found()
1024 else
1025 have = false
1026 libgnutls = []
1027 endif
1028 conf.set10('HAVE_GNUTLS', have)
1029
1030 want_elfutils = get_option('elfutils')
1031 if want_elfutils != 'false' and not fuzzer_build
1032 libdw = dependency('libdw',
1033 required : want_elfutils == 'true')
1034 have = libdw.found()
1035 else
1036 have = false
1037 libdw = []
1038 endif
1039 conf.set10('HAVE_ELFUTILS', have)
1040
1041 want_zlib = get_option('zlib')
1042 if want_zlib != 'false' and not fuzzer_build
1043 libz = dependency('zlib',
1044 required : want_zlib == 'true')
1045 have = libz.found()
1046 else
1047 have = false
1048 libz = []
1049 endif
1050 conf.set10('HAVE_ZLIB', have)
1051
1052 want_bzip2 = get_option('bzip2')
1053 if want_bzip2 != 'false' and not fuzzer_build
1054 libbzip2 = cc.find_library('bz2',
1055 required : want_bzip2 == 'true')
1056 have = libbzip2.found()
1057 else
1058 have = false
1059 libbzip2 = []
1060 endif
1061 conf.set10('HAVE_BZIP2', have)
1062
1063 want_xz = get_option('xz')
1064 if want_xz != 'false' and not fuzzer_build
1065 libxz = dependency('liblzma',
1066 required : want_xz == 'true')
1067 have = libxz.found()
1068 else
1069 have = false
1070 libxz = []
1071 endif
1072 conf.set10('HAVE_XZ', have)
1073
1074 want_lz4 = get_option('lz4')
1075 if want_lz4 != 'false' and not fuzzer_build
1076 liblz4 = dependency('liblz4',
1077 required : want_lz4 == 'true')
1078 have = liblz4.found()
1079 else
1080 have = false
1081 liblz4 = []
1082 endif
1083 conf.set10('HAVE_LZ4', have)
1084
1085 want_xkbcommon = get_option('xkbcommon')
1086 if want_xkbcommon != 'false' and not fuzzer_build
1087 libxkbcommon = dependency('xkbcommon',
1088 version : '>= 0.3.0',
1089 required : want_xkbcommon == 'true')
1090 have = libxkbcommon.found()
1091 else
1092 have = false
1093 libxkbcommon = []
1094 endif
1095 conf.set10('HAVE_XKBCOMMON', have)
1096
1097 want_pcre2 = get_option('pcre2')
1098 if want_pcre2 != 'false'
1099 libpcre2 = dependency('libpcre2-8',
1100 required : want_pcre2 == 'true')
1101 have = libpcre2.found()
1102 else
1103 have = false
1104 libpcre2 = []
1105 endif
1106 conf.set10('HAVE_PCRE2', have)
1107
1108 want_glib = get_option('glib')
1109 if want_glib != 'false' and not fuzzer_build
1110 libglib = dependency('glib-2.0',
1111 version : '>= 2.22.0',
1112 required : want_glib == 'true')
1113 libgobject = dependency('gobject-2.0',
1114 version : '>= 2.22.0',
1115 required : want_glib == 'true')
1116 libgio = dependency('gio-2.0',
1117 required : want_glib == 'true')
1118 have = libglib.found() and libgobject.found() and libgio.found()
1119 else
1120 have = false
1121 libglib = []
1122 libgobject = []
1123 libgio = []
1124 endif
1125 conf.set10('HAVE_GLIB', have)
1126
1127 want_dbus = get_option('dbus')
1128 if want_dbus != 'false' and not fuzzer_build
1129 libdbus = dependency('dbus-1',
1130 version : '>= 1.3.2',
1131 required : want_dbus == 'true')
1132 have = libdbus.found()
1133 else
1134 have = false
1135 libdbus = []
1136 endif
1137 conf.set10('HAVE_DBUS', have)
1138
1139 default_dnssec = get_option('default-dnssec')
1140 if fuzzer_build
1141 default_dnssec = 'no'
1142 endif
1143 if default_dnssec != 'no' and conf.get('HAVE_GCRYPT') == 0
1144 message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.')
1145 default_dnssec = 'no'
1146 endif
1147 conf.set('DEFAULT_DNSSEC_MODE',
1148 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1149 substs.set('DEFAULT_DNSSEC_MODE', default_dnssec)
1150
1151 want_importd = get_option('importd')
1152 if want_importd != 'false'
1153 have = (conf.get('HAVE_LIBCURL') == 1 and
1154 conf.get('HAVE_ZLIB') == 1 and
1155 conf.get('HAVE_BZIP2') == 1 and
1156 conf.get('HAVE_XZ') == 1 and
1157 conf.get('HAVE_GCRYPT') == 1)
1158 if want_importd == 'true' and not have
1159 error('importd support was requested, but dependencies are not available')
1160 endif
1161 else
1162 have = false
1163 endif
1164 conf.set10('ENABLE_IMPORTD', have)
1165
1166 want_remote = get_option('remote')
1167 if want_remote != 'false'
1168 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1169 conf.get('HAVE_LIBCURL') == 1]
1170 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1171 # it's possible to build one without the other. Complain only if
1172 # support was explictly requested. The auxiliary files like sysusers
1173 # config should be installed when any of the programs are built.
1174 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1175 error('remote support was requested, but dependencies are not available')
1176 endif
1177 have = have_deps[0] or have_deps[1]
1178 else
1179 have = false
1180 endif
1181 conf.set10('ENABLE_REMOTE', have)
1182
1183 foreach term : ['utmp',
1184 'hibernate',
1185 'environment-d',
1186 'binfmt',
1187 'coredump',
1188 'resolve',
1189 'logind',
1190 'hostnamed',
1191 'localed',
1192 'machined',
1193 'networkd',
1194 'timedated',
1195 'timesyncd',
1196 'myhostname',
1197 'firstboot',
1198 'randomseed',
1199 'backlight',
1200 'vconsole',
1201 'quotacheck',
1202 'sysusers',
1203 'tmpfiles',
1204 'hwdb',
1205 'rfkill',
1206 'ldconfig',
1207 'efi',
1208 'tpm',
1209 'ima',
1210 'smack',
1211 'gshadow',
1212 'idn',
1213 'nss-systemd']
1214 have = get_option(term)
1215 name = 'ENABLE_' + term.underscorify().to_upper()
1216 conf.set10(name, have)
1217 endforeach
1218
1219 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1220
1221 want_tests = get_option('tests')
1222 install_tests = get_option('install-tests')
1223 slow_tests = get_option('slow-tests')
1224 tests = []
1225 fuzzers = []
1226
1227 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1228
1229 #####################################################################
1230
1231 if get_option('efi')
1232 efi_arch = host_machine.cpu_family()
1233
1234 if efi_arch == 'x86'
1235 EFI_MACHINE_TYPE_NAME = 'ia32'
1236 gnu_efi_arch = 'ia32'
1237 elif efi_arch == 'x86_64'
1238 EFI_MACHINE_TYPE_NAME = 'x64'
1239 gnu_efi_arch = 'x86_64'
1240 elif efi_arch == 'arm'
1241 EFI_MACHINE_TYPE_NAME = 'arm'
1242 gnu_efi_arch = 'arm'
1243 elif efi_arch == 'aarch64'
1244 EFI_MACHINE_TYPE_NAME = 'aa64'
1245 gnu_efi_arch = 'aarch64'
1246 else
1247 EFI_MACHINE_TYPE_NAME = ''
1248 gnu_efi_arch = ''
1249 endif
1250
1251 have = true
1252 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
1253
1254 conf.set('SD_TPM_PCR', get_option('tpm-pcrindex').to_int())
1255 else
1256 have = false
1257 endif
1258 conf.set10('ENABLE_EFI', have)
1259
1260 #####################################################################
1261
1262 config_h = configure_file(
1263 output : 'config.h',
1264 configuration : conf)
1265
1266 meson_apply_m4 = find_program('tools/meson-apply-m4.sh')
1267
1268 includes = include_directories('src/basic',
1269 'src/shared',
1270 'src/systemd',
1271 'src/journal',
1272 'src/resolve',
1273 'src/timesync',
1274 'src/time-wait-sync',
1275 'src/login',
1276 'src/udev',
1277 'src/libudev',
1278 'src/core',
1279 'src/libsystemd/sd-bus',
1280 'src/libsystemd/sd-device',
1281 'src/libsystemd/sd-hwdb',
1282 'src/libsystemd/sd-id128',
1283 'src/libsystemd/sd-netlink',
1284 'src/libsystemd/sd-network',
1285 'src/libsystemd-network',
1286 '.')
1287
1288 add_project_arguments('-include', 'config.h', language : 'c')
1289
1290 subdir('po')
1291 subdir('catalog')
1292 subdir('src/systemd')
1293 subdir('src/basic')
1294 subdir('src/libsystemd')
1295 subdir('src/libsystemd-network')
1296 subdir('src/journal')
1297 subdir('src/login')
1298
1299 libjournal_core = static_library(
1300 'journal-core',
1301 libjournal_core_sources,
1302 journald_gperf_c,
1303 include_directories : includes,
1304 install : false)
1305
1306 libsystemd_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym)
1307 libsystemd = shared_library(
1308 'systemd',
1309 'src/systemd/sd-id128.h', # pick a header file at random to work around old meson bug
1310 version : libsystemd_version,
1311 include_directories : includes,
1312 link_args : ['-shared',
1313 '-Wl,--version-script=' + libsystemd_sym_path],
1314 link_with : [libbasic,
1315 libbasic_gcrypt],
1316 link_whole : [libsystemd_static,
1317 libjournal_client],
1318 dependencies : [threads,
1319 librt,
1320 libxz,
1321 liblz4],
1322 link_depends : libsystemd_sym,
1323 install : true,
1324 install_dir : rootlibdir)
1325
1326 ############################################################
1327
1328 # binaries that have --help and are intended for use by humans,
1329 # usually, but not always, installed in /bin.
1330 public_programs = []
1331
1332 subdir('src/libudev')
1333 subdir('src/shared')
1334 subdir('src/core')
1335 subdir('src/udev')
1336 subdir('src/network')
1337
1338 subdir('src/analyze')
1339 subdir('src/journal-remote')
1340 subdir('src/coredump')
1341 subdir('src/hostname')
1342 subdir('src/import')
1343 subdir('src/kernel-install')
1344 subdir('src/locale')
1345 subdir('src/machine')
1346 subdir('src/nspawn')
1347 subdir('src/resolve')
1348 subdir('src/timedate')
1349 subdir('src/timesync')
1350 subdir('src/vconsole')
1351 subdir('src/boot/efi')
1352
1353 subdir('src/test')
1354 subdir('src/fuzz')
1355 subdir('rules')
1356 subdir('test')
1357
1358 ############################################################
1359
1360 # only static linking apart from libdl, to make sure that the
1361 # module is linked to all libraries that it uses.
1362 test_dlopen = executable(
1363 'test-dlopen',
1364 test_dlopen_c,
1365 include_directories : includes,
1366 link_with : [libbasic],
1367 dependencies : [libdl])
1368
1369 foreach tuple : [['myhostname', 'ENABLE_MYHOSTNAME'],
1370 ['systemd', 'ENABLE_NSS_SYSTEMD'],
1371 ['mymachines', 'ENABLE_MACHINED'],
1372 ['resolve', 'ENABLE_RESOLVE']]
1373
1374 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
1375 if condition
1376 module = tuple[0]
1377
1378 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1379 version_script_arg = join_paths(meson.current_source_dir(), sym)
1380
1381 nss = shared_library(
1382 'nss_' + module,
1383 'src/nss-@0@/nss-@0@.c'.format(module),
1384 version : '2',
1385 include_directories : includes,
1386 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
1387 link_args : ['-Wl,-z,nodelete',
1388 '-shared',
1389 '-Wl,--version-script=' + version_script_arg,
1390 '-Wl,--undefined'],
1391 link_with : [libsystemd_static,
1392 libbasic],
1393 dependencies : [threads,
1394 librt],
1395 link_depends : sym,
1396 install : true,
1397 install_dir : rootlibdir)
1398
1399 # We cannot use shared_module because it does not support version suffix.
1400 # Unfortunately shared_library insists on creating the symlink…
1401 meson.add_install_script('sh', '-c',
1402 'rm $DESTDIR@0@/libnss_@1@.so'
1403 .format(rootlibdir, module))
1404
1405 test('dlopen-nss_' + module,
1406 test_dlopen,
1407 args : [nss.full_path()]) # path to dlopen must include a slash
1408 endif
1409 endforeach
1410
1411 ############################################################
1412
1413 executable('systemd',
1414 systemd_sources,
1415 include_directories : includes,
1416 link_with : [libcore,
1417 libshared],
1418 dependencies : [threads,
1419 librt,
1420 libseccomp,
1421 libselinux,
1422 libmount,
1423 libblkid],
1424 install_rpath : rootlibexecdir,
1425 install : true,
1426 install_dir : rootlibexecdir)
1427
1428 meson.add_install_script(meson_make_symlink,
1429 join_paths(rootlibexecdir, 'systemd'),
1430 join_paths(rootsbindir, 'init'))
1431
1432 exe = executable('systemd-analyze',
1433 systemd_analyze_sources,
1434 include_directories : includes,
1435 link_with : [libcore,
1436 libshared],
1437 dependencies : [threads,
1438 librt,
1439 libseccomp,
1440 libselinux,
1441 libmount,
1442 libblkid],
1443 install_rpath : rootlibexecdir,
1444 install : true)
1445 public_programs += [exe]
1446
1447 executable('systemd-journald',
1448 systemd_journald_sources,
1449 include_directories : includes,
1450 link_with : [libjournal_core,
1451 libshared],
1452 dependencies : [threads,
1453 libxz,
1454 liblz4,
1455 libselinux],
1456 install_rpath : rootlibexecdir,
1457 install : true,
1458 install_dir : rootlibexecdir)
1459
1460 exe = executable('systemd-cat',
1461 systemd_cat_sources,
1462 include_directories : includes,
1463 link_with : [libjournal_core,
1464 libshared],
1465 dependencies : [threads],
1466 install_rpath : rootlibexecdir,
1467 install : true)
1468 public_programs += [exe]
1469
1470 exe = executable('journalctl',
1471 journalctl_sources,
1472 include_directories : includes,
1473 link_with : [libshared],
1474 dependencies : [threads,
1475 libqrencode,
1476 libxz,
1477 liblz4,
1478 libpcre2],
1479 install_rpath : rootlibexecdir,
1480 install : true,
1481 install_dir : rootbindir)
1482 public_programs += [exe]
1483
1484 executable('systemd-getty-generator',
1485 'src/getty-generator/getty-generator.c',
1486 include_directories : includes,
1487 link_with : [libshared],
1488 install_rpath : rootlibexecdir,
1489 install : true,
1490 install_dir : systemgeneratordir)
1491
1492 executable('systemd-debug-generator',
1493 'src/debug-generator/debug-generator.c',
1494 include_directories : includes,
1495 link_with : [libshared],
1496 install_rpath : rootlibexecdir,
1497 install : true,
1498 install_dir : systemgeneratordir)
1499
1500 executable('systemd-fstab-generator',
1501 'src/fstab-generator/fstab-generator.c',
1502 'src/core/mount-setup.c',
1503 include_directories : includes,
1504 link_with : [libshared],
1505 install_rpath : rootlibexecdir,
1506 install : true,
1507 install_dir : systemgeneratordir)
1508
1509 if conf.get('ENABLE_ENVIRONMENT_D') == 1
1510 executable('30-systemd-environment-d-generator',
1511 'src/environment-d-generator/environment-d-generator.c',
1512 include_directories : includes,
1513 link_with : [libshared],
1514 install_rpath : rootlibexecdir,
1515 install : true,
1516 install_dir : userenvgeneratordir)
1517
1518 meson.add_install_script(meson_make_symlink,
1519 join_paths(sysconfdir, 'environment'),
1520 join_paths(environmentdir, '99-environment.conf'))
1521 endif
1522
1523 if conf.get('ENABLE_HIBERNATE') == 1
1524 executable('systemd-hibernate-resume-generator',
1525 'src/hibernate-resume/hibernate-resume-generator.c',
1526 include_directories : includes,
1527 link_with : [libshared],
1528 install_rpath : rootlibexecdir,
1529 install : true,
1530 install_dir : systemgeneratordir)
1531
1532 executable('systemd-hibernate-resume',
1533 'src/hibernate-resume/hibernate-resume.c',
1534 include_directories : includes,
1535 link_with : [libshared],
1536 install_rpath : rootlibexecdir,
1537 install : true,
1538 install_dir : rootlibexecdir)
1539 endif
1540
1541 if conf.get('HAVE_BLKID') == 1
1542 executable('systemd-gpt-auto-generator',
1543 'src/gpt-auto-generator/gpt-auto-generator.c',
1544 'src/basic/blkid-util.h',
1545 include_directories : includes,
1546 link_with : [libshared],
1547 dependencies : libblkid,
1548 install_rpath : rootlibexecdir,
1549 install : true,
1550 install_dir : systemgeneratordir)
1551
1552 exe = executable('systemd-dissect',
1553 'src/dissect/dissect.c',
1554 include_directories : includes,
1555 link_with : [libshared],
1556 install_rpath : rootlibexecdir,
1557 install : true,
1558 install_dir : rootlibexecdir)
1559 public_programs += [exe]
1560 endif
1561
1562 if conf.get('ENABLE_RESOLVE') == 1
1563 executable('systemd-resolved',
1564 systemd_resolved_sources,
1565 include_directories : includes,
1566 link_with : [libshared,
1567 libbasic_gcrypt,
1568 libsystemd_resolve_core],
1569 dependencies : [threads,
1570 libgpg_error,
1571 libm,
1572 libidn],
1573 install_rpath : rootlibexecdir,
1574 install : true,
1575 install_dir : rootlibexecdir)
1576
1577 exe = executable('resolvectl',
1578 resolvectl_sources,
1579 include_directories : includes,
1580 link_with : [libshared,
1581 libbasic_gcrypt,
1582 libsystemd_resolve_core],
1583 dependencies : [threads,
1584 libgpg_error,
1585 libm,
1586 libidn],
1587 install_rpath : rootlibexecdir,
1588 install : true)
1589 public_programs += [exe]
1590
1591 meson.add_install_script(meson_make_symlink,
1592 join_paths(bindir, 'resolvectl'),
1593 join_paths(rootsbindir, 'resolvconf'))
1594
1595 meson.add_install_script(meson_make_symlink,
1596 join_paths(bindir, 'resolvectl'),
1597 join_paths(bindir, 'systemd-resolve'))
1598 endif
1599
1600 if conf.get('ENABLE_LOGIND') == 1
1601 executable('systemd-logind',
1602 systemd_logind_sources,
1603 include_directories : includes,
1604 link_with : [liblogind_core,
1605 libshared],
1606 dependencies : [threads,
1607 libacl],
1608 install_rpath : rootlibexecdir,
1609 install : true,
1610 install_dir : rootlibexecdir)
1611
1612 exe = executable('loginctl',
1613 loginctl_sources,
1614 include_directories : includes,
1615 link_with : [libshared],
1616 dependencies : [threads,
1617 liblz4,
1618 libxz],
1619 install_rpath : rootlibexecdir,
1620 install : true,
1621 install_dir : rootbindir)
1622 public_programs += [exe]
1623
1624 exe = executable('systemd-inhibit',
1625 'src/login/inhibit.c',
1626 include_directories : includes,
1627 link_with : [libshared],
1628 install_rpath : rootlibexecdir,
1629 install : true,
1630 install_dir : rootbindir)
1631 public_programs += [exe]
1632
1633 if conf.get('HAVE_PAM') == 1
1634 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
1635 pam_systemd = shared_library(
1636 'pam_systemd',
1637 pam_systemd_c,
1638 name_prefix : '',
1639 include_directories : includes,
1640 link_args : ['-shared',
1641 '-Wl,--version-script=' + version_script_arg],
1642 link_with : [libsystemd_static,
1643 libshared_static],
1644 dependencies : [threads,
1645 libpam,
1646 libpam_misc],
1647 link_depends : pam_systemd_sym,
1648 install : true,
1649 install_dir : pamlibdir)
1650
1651 test('dlopen-pam_systemd',
1652 test_dlopen,
1653 args : [pam_systemd.full_path()]) # path to dlopen must include a slash
1654 endif
1655 endif
1656
1657 executable('systemd-user-runtime-dir',
1658 user_runtime_dir_sources,
1659 include_directories : includes,
1660 link_with : [libshared, liblogind_core],
1661 install_rpath : rootlibexecdir,
1662 install : true,
1663 install_dir : rootlibexecdir)
1664
1665 if conf.get('HAVE_PAM') == 1
1666 executable('systemd-user-sessions',
1667 'src/user-sessions/user-sessions.c',
1668 include_directories : includes,
1669 link_with : [libshared],
1670 install_rpath : rootlibexecdir,
1671 install : true,
1672 install_dir : rootlibexecdir)
1673 endif
1674
1675 if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
1676 exe = executable('bootctl',
1677 'src/boot/bootctl.c',
1678 include_directories : includes,
1679 link_with : [libshared],
1680 dependencies : [libblkid],
1681 install_rpath : rootlibexecdir,
1682 install : true)
1683 public_programs += [exe]
1684 endif
1685
1686 exe = executable('systemd-socket-activate', 'src/activate/activate.c',
1687 include_directories : includes,
1688 link_with : [libshared],
1689 dependencies : [threads],
1690 install_rpath : rootlibexecdir,
1691 install : true)
1692 public_programs += [exe]
1693
1694 exe = executable('systemctl', 'src/systemctl/systemctl.c',
1695 include_directories : includes,
1696 link_with : [libshared],
1697 dependencies : [threads,
1698 libcap,
1699 libselinux,
1700 libxz,
1701 liblz4],
1702 install_rpath : rootlibexecdir,
1703 install : true,
1704 install_dir : rootbindir)
1705 public_programs += [exe]
1706
1707 foreach alias : ['halt', 'poweroff', 'reboot', 'runlevel', 'shutdown', 'telinit']
1708 meson.add_install_script(meson_make_symlink,
1709 join_paths(rootbindir, 'systemctl'),
1710 join_paths(rootsbindir, alias))
1711 endforeach
1712
1713 if conf.get('ENABLE_BACKLIGHT') == 1
1714 executable('systemd-backlight',
1715 'src/backlight/backlight.c',
1716 include_directories : includes,
1717 link_with : [libshared],
1718 install_rpath : rootlibexecdir,
1719 install : true,
1720 install_dir : rootlibexecdir)
1721 endif
1722
1723 if conf.get('ENABLE_RFKILL') == 1
1724 executable('systemd-rfkill',
1725 'src/rfkill/rfkill.c',
1726 include_directories : includes,
1727 link_with : [libshared],
1728 install_rpath : rootlibexecdir,
1729 install : true,
1730 install_dir : rootlibexecdir)
1731 endif
1732
1733 executable('systemd-system-update-generator',
1734 'src/system-update-generator/system-update-generator.c',
1735 include_directories : includes,
1736 link_with : [libshared],
1737 install_rpath : rootlibexecdir,
1738 install : true,
1739 install_dir : systemgeneratordir)
1740
1741 if conf.get('HAVE_LIBCRYPTSETUP') == 1
1742 executable('systemd-cryptsetup',
1743 'src/cryptsetup/cryptsetup.c',
1744 include_directories : includes,
1745 link_with : [libshared],
1746 dependencies : [libcryptsetup],
1747 install_rpath : rootlibexecdir,
1748 install : true,
1749 install_dir : rootlibexecdir)
1750
1751 executable('systemd-cryptsetup-generator',
1752 'src/cryptsetup/cryptsetup-generator.c',
1753 include_directories : includes,
1754 link_with : [libshared],
1755 dependencies : [libcryptsetup],
1756 install_rpath : rootlibexecdir,
1757 install : true,
1758 install_dir : systemgeneratordir)
1759
1760 executable('systemd-veritysetup',
1761 'src/veritysetup/veritysetup.c',
1762 include_directories : includes,
1763 link_with : [libshared],
1764 dependencies : [libcryptsetup],
1765 install_rpath : rootlibexecdir,
1766 install : true,
1767 install_dir : rootlibexecdir)
1768
1769 executable('systemd-veritysetup-generator',
1770 'src/veritysetup/veritysetup-generator.c',
1771 include_directories : includes,
1772 link_with : [libshared],
1773 dependencies : [libcryptsetup],
1774 install_rpath : rootlibexecdir,
1775 install : true,
1776 install_dir : systemgeneratordir)
1777 endif
1778
1779 if conf.get('HAVE_SYSV_COMPAT') == 1
1780 executable('systemd-sysv-generator',
1781 'src/sysv-generator/sysv-generator.c',
1782 include_directories : includes,
1783 link_with : [libshared],
1784 install_rpath : rootlibexecdir,
1785 install : true,
1786 install_dir : systemgeneratordir)
1787
1788 executable('systemd-rc-local-generator',
1789 'src/rc-local-generator/rc-local-generator.c',
1790 include_directories : includes,
1791 link_with : [libshared],
1792 install_rpath : rootlibexecdir,
1793 install : true,
1794 install_dir : systemgeneratordir)
1795 endif
1796
1797 if conf.get('ENABLE_HOSTNAMED') == 1
1798 executable('systemd-hostnamed',
1799 'src/hostname/hostnamed.c',
1800 include_directories : includes,
1801 link_with : [libshared],
1802 install_rpath : rootlibexecdir,
1803 install : true,
1804 install_dir : rootlibexecdir)
1805
1806 exe = executable('hostnamectl',
1807 'src/hostname/hostnamectl.c',
1808 include_directories : includes,
1809 link_with : [libshared],
1810 install_rpath : rootlibexecdir,
1811 install : true)
1812 public_programs += [exe]
1813 endif
1814
1815 if conf.get('ENABLE_LOCALED') == 1
1816 if conf.get('HAVE_XKBCOMMON') == 1
1817 # logind will load libxkbcommon.so dynamically on its own
1818 deps = [libdl]
1819 else
1820 deps = []
1821 endif
1822
1823 executable('systemd-localed',
1824 systemd_localed_sources,
1825 include_directories : includes,
1826 link_with : [libshared],
1827 dependencies : deps,
1828 install_rpath : rootlibexecdir,
1829 install : true,
1830 install_dir : rootlibexecdir)
1831
1832 exe = executable('localectl',
1833 localectl_sources,
1834 include_directories : includes,
1835 link_with : [libshared],
1836 install_rpath : rootlibexecdir,
1837 install : true)
1838 public_programs += [exe]
1839 endif
1840
1841 if conf.get('ENABLE_TIMEDATED') == 1
1842 executable('systemd-timedated',
1843 'src/timedate/timedated.c',
1844 include_directories : includes,
1845 link_with : [libshared],
1846 install_rpath : rootlibexecdir,
1847 install : true,
1848 install_dir : rootlibexecdir)
1849 endif
1850
1851 if conf.get('ENABLE_TIMEDATECTL') == 1
1852 exe = executable('timedatectl',
1853 'src/timedate/timedatectl.c',
1854 include_directories : includes,
1855 install_rpath : rootlibexecdir,
1856 link_with : [libshared],
1857 dependencies : [libm],
1858 install : true)
1859 public_programs += [exe]
1860 endif
1861
1862 if conf.get('ENABLE_TIMESYNCD') == 1
1863 executable('systemd-timesyncd',
1864 systemd_timesyncd_sources,
1865 include_directories : includes,
1866 link_with : [libshared],
1867 dependencies : [threads,
1868 libm],
1869 install_rpath : rootlibexecdir,
1870 install : true,
1871 install_dir : rootlibexecdir)
1872
1873 executable('systemd-time-wait-sync',
1874 'src/time-wait-sync/time-wait-sync.c',
1875 include_directories : includes,
1876 link_with : [libshared],
1877 install_rpath : rootlibexecdir,
1878 install : true,
1879 install_dir : rootlibexecdir)
1880 endif
1881
1882 if conf.get('ENABLE_MACHINED') == 1
1883 executable('systemd-machined',
1884 systemd_machined_sources,
1885 include_directories : includes,
1886 link_with : [libmachine_core,
1887 libshared],
1888 install_rpath : rootlibexecdir,
1889 install : true,
1890 install_dir : rootlibexecdir)
1891
1892 exe = executable('machinectl',
1893 'src/machine/machinectl.c',
1894 include_directories : includes,
1895 link_with : [libshared],
1896 dependencies : [threads,
1897 libxz,
1898 liblz4],
1899 install_rpath : rootlibexecdir,
1900 install : true,
1901 install_dir : rootbindir)
1902 public_programs += [exe]
1903 endif
1904
1905 if conf.get('ENABLE_IMPORTD') == 1
1906 executable('systemd-importd',
1907 systemd_importd_sources,
1908 include_directories : includes,
1909 link_with : [libshared],
1910 dependencies : [threads],
1911 install_rpath : rootlibexecdir,
1912 install : true,
1913 install_dir : rootlibexecdir)
1914
1915 systemd_pull = executable('systemd-pull',
1916 systemd_pull_sources,
1917 include_directories : includes,
1918 link_with : [libshared],
1919 dependencies : [libcurl,
1920 libz,
1921 libbzip2,
1922 libxz,
1923 libgcrypt],
1924 install_rpath : rootlibexecdir,
1925 install : true,
1926 install_dir : rootlibexecdir)
1927
1928 systemd_import = executable('systemd-import',
1929 systemd_import_sources,
1930 include_directories : includes,
1931 link_with : [libshared],
1932 dependencies : [libcurl,
1933 libz,
1934 libbzip2,
1935 libxz],
1936 install_rpath : rootlibexecdir,
1937 install : true,
1938 install_dir : rootlibexecdir)
1939
1940 systemd_export = executable('systemd-export',
1941 systemd_export_sources,
1942 include_directories : includes,
1943 link_with : [libshared],
1944 dependencies : [libcurl,
1945 libz,
1946 libbzip2,
1947 libxz],
1948 install_rpath : rootlibexecdir,
1949 install : true,
1950 install_dir : rootlibexecdir)
1951 public_programs += [systemd_pull, systemd_import, systemd_export]
1952 endif
1953
1954 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
1955 exe = executable('systemd-journal-upload',
1956 systemd_journal_upload_sources,
1957 include_directories : includes,
1958 link_with : [libshared],
1959 dependencies : [threads,
1960 libcurl,
1961 libgnutls,
1962 libxz,
1963 liblz4],
1964 install_rpath : rootlibexecdir,
1965 install : true,
1966 install_dir : rootlibexecdir)
1967 public_programs += [exe]
1968 endif
1969
1970 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
1971 s_j_remote = executable('systemd-journal-remote',
1972 systemd_journal_remote_sources,
1973 include_directories : includes,
1974 link_with : [libshared],
1975 dependencies : [threads,
1976 libmicrohttpd,
1977 libgnutls,
1978 libxz,
1979 liblz4],
1980 install_rpath : rootlibexecdir,
1981 install : true,
1982 install_dir : rootlibexecdir)
1983
1984 s_j_gatewayd = executable('systemd-journal-gatewayd',
1985 systemd_journal_gatewayd_sources,
1986 include_directories : includes,
1987 link_with : [libshared],
1988 dependencies : [threads,
1989 libmicrohttpd,
1990 libgnutls,
1991 libxz,
1992 liblz4],
1993 install_rpath : rootlibexecdir,
1994 install : true,
1995 install_dir : rootlibexecdir)
1996 public_programs += [s_j_remote, s_j_gatewayd]
1997 endif
1998
1999 if conf.get('ENABLE_COREDUMP') == 1
2000 executable('systemd-coredump',
2001 systemd_coredump_sources,
2002 include_directories : includes,
2003 link_with : [libshared],
2004 dependencies : [threads,
2005 libacl,
2006 libdw,
2007 libxz,
2008 liblz4],
2009 install_rpath : rootlibexecdir,
2010 install : true,
2011 install_dir : rootlibexecdir)
2012
2013 exe = executable('coredumpctl',
2014 coredumpctl_sources,
2015 include_directories : includes,
2016 link_with : [libshared],
2017 dependencies : [threads,
2018 libxz,
2019 liblz4],
2020 install_rpath : rootlibexecdir,
2021 install : true)
2022 public_programs += [exe]
2023 endif
2024
2025 if conf.get('ENABLE_BINFMT') == 1
2026 exe = executable('systemd-binfmt',
2027 'src/binfmt/binfmt.c',
2028 include_directories : includes,
2029 link_with : [libshared],
2030 install_rpath : rootlibexecdir,
2031 install : true,
2032 install_dir : rootlibexecdir)
2033 public_programs += [exe]
2034
2035 meson.add_install_script('sh', '-c',
2036 mkdir_p.format(binfmtdir))
2037 meson.add_install_script('sh', '-c',
2038 mkdir_p.format(join_paths(sysconfdir, 'binfmt.d')))
2039 endif
2040
2041 if conf.get('ENABLE_VCONSOLE') == 1
2042 executable('systemd-vconsole-setup',
2043 'src/vconsole/vconsole-setup.c',
2044 include_directories : includes,
2045 link_with : [libshared],
2046 install_rpath : rootlibexecdir,
2047 install : true,
2048 install_dir : rootlibexecdir)
2049 endif
2050
2051 if conf.get('ENABLE_RANDOMSEED') == 1
2052 executable('systemd-random-seed',
2053 'src/random-seed/random-seed.c',
2054 include_directories : includes,
2055 link_with : [libshared],
2056 install_rpath : rootlibexecdir,
2057 install : true,
2058 install_dir : rootlibexecdir)
2059 endif
2060
2061 if conf.get('ENABLE_FIRSTBOOT') == 1
2062 executable('systemd-firstboot',
2063 'src/firstboot/firstboot.c',
2064 include_directories : includes,
2065 link_with : [libshared],
2066 dependencies : [libcrypt],
2067 install_rpath : rootlibexecdir,
2068 install : true,
2069 install_dir : rootbindir)
2070 endif
2071
2072 executable('systemd-remount-fs',
2073 'src/remount-fs/remount-fs.c',
2074 'src/core/mount-setup.c',
2075 'src/core/mount-setup.h',
2076 include_directories : includes,
2077 link_with : [libshared],
2078 install_rpath : rootlibexecdir,
2079 install : true,
2080 install_dir : rootlibexecdir)
2081
2082 executable('systemd-machine-id-setup',
2083 'src/machine-id-setup/machine-id-setup-main.c',
2084 'src/core/machine-id-setup.c',
2085 'src/core/machine-id-setup.h',
2086 include_directories : includes,
2087 link_with : [libshared],
2088 install_rpath : rootlibexecdir,
2089 install : true,
2090 install_dir : rootbindir)
2091
2092 executable('systemd-fsck',
2093 'src/fsck/fsck.c',
2094 include_directories : includes,
2095 link_with : [libshared],
2096 install_rpath : rootlibexecdir,
2097 install : true,
2098 install_dir : rootlibexecdir)
2099
2100 executable('systemd-growfs',
2101 'src/partition/growfs.c',
2102 include_directories : includes,
2103 link_with : [libshared],
2104 dependencies : [libcryptsetup],
2105 install_rpath : rootlibexecdir,
2106 install : true,
2107 install_dir : rootlibexecdir)
2108
2109 executable('systemd-makefs',
2110 'src/partition/makefs.c',
2111 include_directories : includes,
2112 link_with : [libshared],
2113 install_rpath : rootlibexecdir,
2114 install : true,
2115 install_dir : rootlibexecdir)
2116
2117 executable('systemd-sleep',
2118 'src/sleep/sleep.c',
2119 include_directories : includes,
2120 link_with : [libshared],
2121 install_rpath : rootlibexecdir,
2122 install : true,
2123 install_dir : rootlibexecdir)
2124
2125 exe = executable('systemd-sysctl',
2126 'src/sysctl/sysctl.c',
2127 include_directories : includes,
2128 link_with : [libshared],
2129 install_rpath : rootlibexecdir,
2130 install : true,
2131 install_dir : rootlibexecdir)
2132 public_programs += [exe]
2133
2134 executable('systemd-ac-power',
2135 'src/ac-power/ac-power.c',
2136 include_directories : includes,
2137 link_with : [libshared],
2138 install_rpath : rootlibexecdir,
2139 install : true,
2140 install_dir : rootlibexecdir)
2141
2142 exe = executable('systemd-detect-virt',
2143 'src/detect-virt/detect-virt.c',
2144 include_directories : includes,
2145 link_with : [libshared],
2146 install_rpath : rootlibexecdir,
2147 install : true)
2148 public_programs += [exe]
2149
2150 exe = executable('systemd-delta',
2151 'src/delta/delta.c',
2152 include_directories : includes,
2153 link_with : [libshared],
2154 install_rpath : rootlibexecdir,
2155 install : true)
2156 public_programs += [exe]
2157
2158 exe = executable('systemd-escape',
2159 'src/escape/escape.c',
2160 include_directories : includes,
2161 link_with : [libshared],
2162 install_rpath : rootlibexecdir,
2163 install : true,
2164 install_dir : rootbindir)
2165 public_programs += [exe]
2166
2167 exe = executable('systemd-notify',
2168 'src/notify/notify.c',
2169 include_directories : includes,
2170 link_with : [libshared],
2171 install_rpath : rootlibexecdir,
2172 install : true,
2173 install_dir : rootbindir)
2174 public_programs += [exe]
2175
2176 executable('systemd-volatile-root',
2177 'src/volatile-root/volatile-root.c',
2178 include_directories : includes,
2179 link_with : [libshared],
2180 install_rpath : rootlibexecdir,
2181 install : true,
2182 install_dir : rootlibexecdir)
2183
2184 executable('systemd-cgroups-agent',
2185 'src/cgroups-agent/cgroups-agent.c',
2186 include_directories : includes,
2187 link_with : [libshared],
2188 install_rpath : rootlibexecdir,
2189 install : true,
2190 install_dir : rootlibexecdir)
2191
2192 exe = executable('systemd-path',
2193 'src/path/path.c',
2194 include_directories : includes,
2195 link_with : [libshared],
2196 install_rpath : rootlibexecdir,
2197 install : true)
2198 public_programs += [exe]
2199
2200 exe = executable('systemd-ask-password',
2201 'src/ask-password/ask-password.c',
2202 include_directories : includes,
2203 link_with : [libshared],
2204 install_rpath : rootlibexecdir,
2205 install : true,
2206 install_dir : rootbindir)
2207 public_programs += [exe]
2208
2209 executable('systemd-reply-password',
2210 'src/reply-password/reply-password.c',
2211 include_directories : includes,
2212 link_with : [libshared],
2213 install_rpath : rootlibexecdir,
2214 install : true,
2215 install_dir : rootlibexecdir)
2216
2217 exe = executable('systemd-tty-ask-password-agent',
2218 'src/tty-ask-password-agent/tty-ask-password-agent.c',
2219 include_directories : includes,
2220 link_with : [libshared],
2221 install_rpath : rootlibexecdir,
2222 install : true,
2223 install_dir : rootbindir)
2224 public_programs += [exe]
2225
2226 exe = executable('systemd-cgls',
2227 'src/cgls/cgls.c',
2228 include_directories : includes,
2229 link_with : [libshared],
2230 install_rpath : rootlibexecdir,
2231 install : true)
2232 public_programs += [exe]
2233
2234 exe = executable('systemd-cgtop',
2235 'src/cgtop/cgtop.c',
2236 include_directories : includes,
2237 link_with : [libshared],
2238 install_rpath : rootlibexecdir,
2239 install : true)
2240 public_programs += [exe]
2241
2242 executable('systemd-initctl',
2243 'src/initctl/initctl.c',
2244 include_directories : includes,
2245 link_with : [libshared],
2246 install_rpath : rootlibexecdir,
2247 install : true,
2248 install_dir : rootlibexecdir)
2249
2250 exe = executable('systemd-mount',
2251 'src/mount/mount-tool.c',
2252 include_directories : includes,
2253 link_with : [libshared],
2254 install_rpath : rootlibexecdir,
2255 install : true)
2256 public_programs += [exe]
2257
2258 meson.add_install_script(meson_make_symlink,
2259 'systemd-mount', join_paths(bindir, 'systemd-umount'))
2260
2261 exe = executable('systemd-run',
2262 'src/run/run.c',
2263 include_directories : includes,
2264 link_with : [libshared],
2265 install_rpath : rootlibexecdir,
2266 install : true)
2267 public_programs += [exe]
2268
2269 exe = executable('systemd-stdio-bridge',
2270 'src/stdio-bridge/stdio-bridge.c',
2271 include_directories : includes,
2272 link_with : [libshared],
2273 install_rpath : rootlibexecdir,
2274 install : true)
2275 public_programs += [exe]
2276
2277 exe = executable('busctl',
2278 'src/busctl/busctl.c',
2279 'src/busctl/busctl-introspect.c',
2280 'src/busctl/busctl-introspect.h',
2281 include_directories : includes,
2282 link_with : [libshared],
2283 install_rpath : rootlibexecdir,
2284 install : true)
2285 public_programs += [exe]
2286
2287 if conf.get('ENABLE_SYSUSERS') == 1
2288 exe = executable('systemd-sysusers',
2289 'src/sysusers/sysusers.c',
2290 include_directories : includes,
2291 link_with : [libshared],
2292 install_rpath : rootlibexecdir,
2293 install : true,
2294 install_dir : rootbindir)
2295 public_programs += [exe]
2296 endif
2297
2298 if conf.get('ENABLE_TMPFILES') == 1
2299 exe = executable('systemd-tmpfiles',
2300 'src/tmpfiles/tmpfiles.c',
2301 include_directories : includes,
2302 link_with : [libshared],
2303 dependencies : [libacl],
2304 install_rpath : rootlibexecdir,
2305 install : true,
2306 install_dir : rootbindir)
2307 public_programs += [exe]
2308
2309 test('test-systemd-tmpfiles',
2310 test_systemd_tmpfiles_py,
2311 args : exe.full_path())
2312 # https://github.com/mesonbuild/meson/issues/2681
2313 endif
2314
2315 if conf.get('ENABLE_HWDB') == 1
2316 exe = executable('systemd-hwdb',
2317 'src/hwdb/hwdb.c',
2318 'src/libsystemd/sd-hwdb/hwdb-internal.h',
2319 include_directories : includes,
2320 link_with : [libudev_static],
2321 install_rpath : udev_rpath,
2322 install : true,
2323 install_dir : rootbindir)
2324 public_programs += [exe]
2325 endif
2326
2327 if conf.get('ENABLE_QUOTACHECK') == 1
2328 executable('systemd-quotacheck',
2329 'src/quotacheck/quotacheck.c',
2330 include_directories : includes,
2331 link_with : [libshared],
2332 install_rpath : rootlibexecdir,
2333 install : true,
2334 install_dir : rootlibexecdir)
2335 endif
2336
2337 exe = executable('systemd-socket-proxyd',
2338 'src/socket-proxy/socket-proxyd.c',
2339 include_directories : includes,
2340 link_with : [libshared],
2341 dependencies : [threads],
2342 install_rpath : rootlibexecdir,
2343 install : true,
2344 install_dir : rootlibexecdir)
2345 public_programs += [exe]
2346
2347 exe = executable('systemd-udevd',
2348 systemd_udevd_sources,
2349 include_directories : includes,
2350 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2351 link_with : [libudev_core,
2352 libsystemd_network,
2353 libudev_static],
2354 dependencies : [threads,
2355 libkmod,
2356 libidn,
2357 libacl,
2358 libblkid],
2359 install_rpath : udev_rpath,
2360 install : true,
2361 install_dir : rootlibexecdir)
2362 public_programs += [exe]
2363
2364 exe = executable('udevadm',
2365 udevadm_sources,
2366 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2367 include_directories : includes,
2368 link_with : [libudev_core,
2369 libsystemd_network,
2370 libudev_static],
2371 dependencies : [threads,
2372 libkmod,
2373 libidn,
2374 libacl,
2375 libblkid],
2376 install_rpath : udev_rpath,
2377 install : true,
2378 install_dir : rootbindir)
2379 public_programs += [exe]
2380
2381 executable('systemd-shutdown',
2382 systemd_shutdown_sources,
2383 include_directories : includes,
2384 link_with : [libshared],
2385 dependencies : [libmount],
2386 install_rpath : rootlibexecdir,
2387 install : true,
2388 install_dir : rootlibexecdir)
2389
2390 executable('systemd-update-done',
2391 'src/update-done/update-done.c',
2392 include_directories : includes,
2393 link_with : [libshared],
2394 install_rpath : rootlibexecdir,
2395 install : true,
2396 install_dir : rootlibexecdir)
2397
2398 executable('systemd-update-utmp',
2399 'src/update-utmp/update-utmp.c',
2400 include_directories : includes,
2401 link_with : [libshared],
2402 dependencies : [libaudit],
2403 install_rpath : rootlibexecdir,
2404 install : true,
2405 install_dir : rootlibexecdir)
2406
2407 if conf.get('HAVE_KMOD') == 1
2408 executable('systemd-modules-load',
2409 'src/modules-load/modules-load.c',
2410 include_directories : includes,
2411 link_with : [libshared],
2412 dependencies : [libkmod],
2413 install_rpath : rootlibexecdir,
2414 install : true,
2415 install_dir : rootlibexecdir)
2416
2417 meson.add_install_script('sh', '-c',
2418 mkdir_p.format(modulesloaddir))
2419 meson.add_install_script('sh', '-c',
2420 mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
2421 endif
2422
2423 exe = executable('systemd-nspawn',
2424 systemd_nspawn_sources,
2425 'src/core/mount-setup.c', # FIXME: use a variable?
2426 'src/core/mount-setup.h',
2427 'src/core/loopback-setup.c',
2428 'src/core/loopback-setup.h',
2429 include_directories : [includes, include_directories('src/nspawn')],
2430 link_with : [libshared],
2431 dependencies : [libacl,
2432 libblkid,
2433 libseccomp,
2434 libselinux],
2435 install_rpath : rootlibexecdir,
2436 install : true)
2437 public_programs += [exe]
2438
2439 if conf.get('ENABLE_NETWORKD') == 1
2440 executable('systemd-networkd',
2441 systemd_networkd_sources,
2442 include_directories : includes,
2443 link_with : [libnetworkd_core,
2444 libsystemd_network,
2445 libudev_static,
2446 libshared],
2447 dependencies : [threads],
2448 install_rpath : rootlibexecdir,
2449 install : true,
2450 install_dir : rootlibexecdir)
2451
2452 executable('systemd-networkd-wait-online',
2453 systemd_networkd_wait_online_sources,
2454 include_directories : includes,
2455 link_with : [libnetworkd_core,
2456 libshared],
2457 install_rpath : rootlibexecdir,
2458 install : true,
2459 install_dir : rootlibexecdir)
2460
2461 exe = executable('networkctl',
2462 networkctl_sources,
2463 include_directories : includes,
2464 link_with : [libsystemd_network,
2465 libshared],
2466 install_rpath : rootlibexecdir,
2467 install : true,
2468 install_dir : rootbindir)
2469 public_programs += [exe]
2470 endif
2471
2472 executable('systemd-sulogin-shell',
2473 ['src/sulogin-shell/sulogin-shell.c'],
2474 include_directories : includes,
2475 link_with : [libshared],
2476 install_rpath : rootlibexecdir,
2477 install : true,
2478 install_dir : rootlibexecdir)
2479
2480 ############################################################
2481
2482 foreach tuple : tests
2483 sources = tuple[0]
2484 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2485 dependencies = tuple[2]
2486 condition = tuple.length() >= 4 ? tuple[3] : ''
2487 type = tuple.length() >= 5 ? tuple[4] : ''
2488 defs = tuple.length() >= 6 ? tuple[5] : []
2489 incs = tuple.length() >= 7 ? tuple[6] : includes
2490 timeout = 30
2491
2492 name = sources[0].split('/')[-1].split('.')[0]
2493 if type.startswith('timeout=')
2494 timeout = type.split('=')[1].to_int()
2495 type = ''
2496 endif
2497 if want_tests == 'false'
2498 message('Not compiling @0@ because tests is set to false'.format(name))
2499 elif condition == '' or conf.get(condition) == 1
2500 exe = executable(
2501 name,
2502 sources,
2503 include_directories : incs,
2504 link_with : link_with,
2505 dependencies : dependencies,
2506 c_args : defs,
2507 install_rpath : rootlibexecdir,
2508 install : install_tests,
2509 install_dir : join_paths(testsdir, type))
2510
2511 if type == 'manual'
2512 message('@0@ is a manual test'.format(name))
2513 elif type == 'unsafe' and want_tests != 'unsafe'
2514 message('@0@ is an unsafe test'.format(name))
2515 else
2516 test(name, exe,
2517 env : test_env,
2518 timeout : timeout)
2519 endif
2520 else
2521 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
2522 endif
2523 endforeach
2524
2525 test_libsystemd_sym = executable(
2526 'test-libsystemd-sym',
2527 test_libsystemd_sym_c,
2528 include_directories : includes,
2529 link_with : [libsystemd],
2530 install : install_tests,
2531 install_dir : testsdir)
2532 test('test-libsystemd-sym',
2533 test_libsystemd_sym)
2534
2535 test_libudev_sym = executable(
2536 'test-libudev-sym',
2537 test_libudev_sym_c,
2538 include_directories : includes,
2539 c_args : ['-Wno-deprecated-declarations'],
2540 link_with : [libudev],
2541 install : install_tests,
2542 install_dir : testsdir)
2543 test('test-libudev-sym',
2544 test_libudev_sym)
2545
2546 ############################################################
2547
2548 fuzzer_exes = []
2549
2550 foreach tuple : fuzzers
2551 sources = tuple[0]
2552 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2553 dependencies = tuple[2]
2554 defs = tuple.length() >= 4 ? tuple[3] : []
2555 incs = tuple.length() >= 5 ? tuple[4] : includes
2556
2557 if fuzzer_build
2558 dependencies += fuzzing_engine
2559 else
2560 sources += 'src/fuzz/fuzz-main.c'
2561 endif
2562
2563 name = sources[0].split('/')[-1].split('.')[0]
2564
2565 fuzzer_exes += executable(
2566 name,
2567 sources,
2568 include_directories : [incs, include_directories('src/fuzz')],
2569 link_with : link_with,
2570 dependencies : dependencies,
2571 c_args : defs,
2572 install : false)
2573 endforeach
2574
2575 run_target('fuzzers',
2576 depends : fuzzer_exes,
2577 command : ['true'])
2578
2579 ############################################################
2580
2581 make_directive_index_py = find_program('tools/make-directive-index.py')
2582 make_man_index_py = find_program('tools/make-man-index.py')
2583 xml_helper_py = find_program('tools/xml_helper.py')
2584 hwdb_update_sh = find_program('tools/meson-hwdb-update.sh')
2585
2586 subdir('units')
2587 subdir('sysctl.d')
2588 subdir('sysusers.d')
2589 subdir('tmpfiles.d')
2590 subdir('presets')
2591 subdir('hwdb')
2592 subdir('network')
2593 subdir('man')
2594 subdir('shell-completion/bash')
2595 subdir('shell-completion/zsh')
2596 subdir('doc/sysvinit')
2597 subdir('doc/var-log')
2598
2599 # FIXME: figure out if the warning is true:
2600 # https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
2601 install_subdir('factory/etc',
2602 install_dir : factorydir)
2603
2604
2605 install_data('xorg/50-systemd-user.sh',
2606 install_dir : xinitrcdir)
2607 install_data('modprobe.d/systemd.conf',
2608 install_dir : modprobedir)
2609 install_data('LICENSE.GPL2',
2610 'LICENSE.LGPL2.1',
2611 'NEWS',
2612 'README',
2613 'doc/CODING_STYLE',
2614 'doc/DISTRO_PORTING',
2615 'doc/ENVIRONMENT.md',
2616 'doc/HACKING',
2617 'doc/TRANSIENT-SETTINGS.md',
2618 'doc/TRANSLATORS',
2619 'doc/UIDS-GIDS.md',
2620 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
2621 install_dir : docdir)
2622
2623 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
2624 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
2625
2626 ############################################################
2627
2628 meson_check_help = find_program('tools/meson-check-help.sh')
2629
2630 foreach exec : public_programs
2631 name = exec.full_path().split('/')[-1]
2632 test('check-help-' + name,
2633 meson_check_help,
2634 args : [exec.full_path()])
2635 endforeach
2636
2637 ############################################################
2638
2639 # Enable tests for all supported sanitizers
2640 foreach tuple : sanitizers
2641 sanitizer = tuple[0]
2642 build = tuple[1]
2643
2644 have = run_command(check_compilation_sh,
2645 cc.cmd_array(), '-x', 'c',
2646 '-fsanitize=@0@'.format(sanitizer),
2647 '-include', link_test_c).returncode() == 0
2648 message('@0@ sanitizer supported: @1@'.format(sanitizer, have ? 'yes' : 'no'))
2649
2650 if have
2651 prev = ''
2652 foreach p : fuzz_regression_tests
2653 b = p.split('/')[-2]
2654 c = p.split('/')[-1]
2655
2656 name = '@0@:@1@'.format(b, sanitizer)
2657
2658 if name != prev
2659 if want_tests == 'false'
2660 message('Not compiling @0@ because tests is set to false'.format(name))
2661 elif slow_tests
2662 exe = custom_target(
2663 name,
2664 output : name,
2665 depends : build,
2666 command : [env, 'ln', '-fs',
2667 join_paths(build.full_path(), b),
2668 '@OUTPUT@'],
2669 build_by_default : true)
2670 else
2671 message('Not compiling @0@ because slow-tests is set to false'.format(name))
2672 endif
2673 endif
2674 prev = name
2675
2676 if want_tests != 'false' and slow_tests
2677 test('@0@:@1@:@2@'.format(b, c, sanitizer),
2678 env,
2679 args : [exe.full_path(),
2680 join_paths(meson.source_root(),
2681 'test/fuzz-regressions',
2682 p)])
2683 endif
2684 endforeach
2685 endif
2686 endforeach
2687
2688
2689 ############################################################
2690
2691 if git.found()
2692 all_files = run_command(
2693 git,
2694 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2695 'ls-files',
2696 ':/*.[ch]'])
2697 all_files = files(all_files.stdout().split())
2698
2699 custom_target(
2700 'tags',
2701 output : 'tags',
2702 command : [env, 'etags', '-o', '@0@/TAGS'.format(meson.current_source_dir())] + all_files)
2703 custom_target(
2704 'ctags',
2705 output : 'ctags',
2706 command : [env, 'ctags', '-o', '@0@/tags'.format(meson.current_source_dir())] + all_files)
2707 endif
2708
2709 if git.found()
2710 meson_git_contrib_sh = find_program('tools/meson-git-contrib.sh')
2711 run_target(
2712 'git-contrib',
2713 command : [meson_git_contrib_sh])
2714 endif
2715
2716 if git.found()
2717 git_head = run_command(
2718 git,
2719 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2720 'rev-parse', 'HEAD']).stdout().strip()
2721 git_head_short = run_command(
2722 git,
2723 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2724 'rev-parse', '--short=7', 'HEAD']).stdout().strip()
2725
2726 run_target(
2727 'git-snapshot',
2728 command : ['git', 'archive',
2729 '-o', '@0@/systemd-@1@.tar.gz'.format(meson.current_source_dir(),
2730 git_head_short),
2731 '--prefix', 'systemd-@0@/'.format(git_head),
2732 'HEAD'])
2733 endif
2734
2735 ############################################################
2736
2737 meson_check_api_docs_sh = find_program('tools/meson-check-api-docs.sh')
2738 run_target(
2739 'check-api-docs',
2740 depends : [man, libsystemd, libudev],
2741 command : [meson_check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
2742
2743 ############################################################
2744
2745 status = [
2746 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
2747
2748 'split /usr: @0@'.format(split_usr),
2749 'split bin-sbin: @0@'.format(split_bin),
2750 'prefix directory: @0@'.format(prefixdir),
2751 'rootprefix directory: @0@'.format(rootprefixdir),
2752 'sysconf directory: @0@'.format(sysconfdir),
2753 'include directory: @0@'.format(includedir),
2754 'lib directory: @0@'.format(libdir),
2755 'rootlib directory: @0@'.format(rootlibdir),
2756 'SysV init scripts: @0@'.format(sysvinit_path),
2757 'SysV rc?.d directories: @0@'.format(sysvrcnd_path),
2758 'PAM modules directory: @0@'.format(pamlibdir),
2759 'PAM configuration directory: @0@'.format(pamconfdir),
2760 'RPM macros directory: @0@'.format(rpmmacrosdir),
2761 'modprobe.d directory: @0@'.format(modprobedir),
2762 'D-Bus policy directory: @0@'.format(dbuspolicydir),
2763 'D-Bus session directory: @0@'.format(dbussessionservicedir),
2764 'D-Bus system directory: @0@'.format(dbussystemservicedir),
2765 'bash completions directory: @0@'.format(bashcompletiondir),
2766 'zsh completions directory: @0@'.format(zshcompletiondir),
2767 'extra start script: @0@'.format(get_option('rc-local')),
2768 'extra stop script: @0@'.format(get_option('halt-local')),
2769 'debug shell: @0@ @ @1@'.format(get_option('debug-shell'),
2770 get_option('debug-tty')),
2771 'TTY GID: @0@'.format(tty_gid),
2772 'users GID: @0@'.format(users_gid),
2773 'maximum system UID: @0@'.format(system_uid_max),
2774 'maximum system GID: @0@'.format(system_gid_max),
2775 'minimum dynamic UID: @0@'.format(dynamic_uid_min),
2776 'maximum dynamic UID: @0@'.format(dynamic_uid_max),
2777 'minimum container UID base: @0@'.format(container_uid_base_min),
2778 'maximum container UID base: @0@'.format(container_uid_base_max),
2779 '/dev/kvm access mode: @0@'.format(get_option('dev-kvm-mode')),
2780 'render group access mode: @0@'.format(get_option('group-render-mode')),
2781 'certificate root directory: @0@'.format(get_option('certificate-root')),
2782 'support URL: @0@'.format(support_url),
2783 'nobody user name: @0@'.format(nobody_user),
2784 'nobody group name: @0@'.format(nobody_group),
2785 'fallback hostname: @0@'.format(get_option('fallback-hostname')),
2786 'symbolic gateway hostnames: @0@'.format(', '.join(gateway_hostnames)),
2787
2788 'default DNSSEC mode: @0@'.format(default_dnssec),
2789 'default cgroup hierarchy: @0@'.format(default_hierarchy),
2790 'default KillUserProcesses setting: @0@'.format(kill_user_processes)]
2791
2792 alt_dns_servers = '\n '.join(dns_servers.split(' '))
2793 alt_ntp_servers = '\n '.join(ntp_servers.split(' '))
2794 status += [
2795 'default DNS servers: @0@'.format(alt_dns_servers),
2796 'default NTP servers: @0@'.format(alt_ntp_servers)]
2797
2798 alt_time_epoch = run_command('date', '-Is', '-u', '-d',
2799 '@@0@'.format(time_epoch)).stdout().strip()
2800 status += [
2801 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
2802
2803 # TODO:
2804 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
2805 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
2806 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
2807
2808 if conf.get('ENABLE_EFI') == 1
2809 status += [
2810 'efi arch: @0@'.format(efi_arch)]
2811
2812 if have_gnu_efi
2813 status += [
2814 'EFI machine type: @0@'.format(EFI_MACHINE_TYPE_NAME),
2815 'EFI CC @0@'.format(efi_cc),
2816 'EFI lib directory: @0@'.format(efi_libdir),
2817 'EFI lds directory: @0@'.format(efi_ldsdir),
2818 'EFI include directory: @0@'.format(efi_incdir)]
2819 endif
2820 endif
2821
2822 found = []
2823 missing = []
2824
2825 foreach tuple : [
2826 ['libcryptsetup'],
2827 ['PAM'],
2828 ['AUDIT'],
2829 ['IMA'],
2830 ['AppArmor'],
2831 ['SELinux'],
2832 ['SECCOMP'],
2833 ['SMACK'],
2834 ['zlib'],
2835 ['xz'],
2836 ['lz4'],
2837 ['bzip2'],
2838 ['ACL'],
2839 ['gcrypt'],
2840 ['qrencode'],
2841 ['microhttpd'],
2842 ['gnutls'],
2843 ['libcurl'],
2844 ['idn'],
2845 ['libidn2'],
2846 ['libidn'],
2847 ['nss-systemd'],
2848 ['libiptc'],
2849 ['elfutils'],
2850 ['binfmt'],
2851 ['vconsole'],
2852 ['quotacheck'],
2853 ['tmpfiles'],
2854 ['environment.d'],
2855 ['sysusers'],
2856 ['firstboot'],
2857 ['randomseed'],
2858 ['backlight'],
2859 ['rfkill'],
2860 ['logind'],
2861 ['machined'],
2862 ['importd'],
2863 ['hostnamed'],
2864 ['timedated'],
2865 ['timesyncd'],
2866 ['localed'],
2867 ['networkd'],
2868 ['resolve'],
2869 ['coredump'],
2870 ['polkit'],
2871 ['legacy pkla', install_polkit_pkla],
2872 ['efi'],
2873 ['gnu-efi', have_gnu_efi],
2874 ['kmod'],
2875 ['xkbcommon'],
2876 ['pcre2'],
2877 ['blkid'],
2878 ['dbus'],
2879 ['glib'],
2880 ['nss-myhostname', conf.get('ENABLE_MYHOSTNAME') == 1],
2881 ['hwdb'],
2882 ['tpm'],
2883 ['man pages', want_man],
2884 ['html pages', want_html],
2885 ['man page indices', want_man and have_lxml],
2886 ['SysV compat'],
2887 ['utmp'],
2888 ['ldconfig'],
2889 ['hibernate'],
2890 ['adm group', get_option('adm-group')],
2891 ['wheel group', get_option('wheel-group')],
2892 ['gshadow'],
2893 ['debug hashmap'],
2894 ['debug mmap cache'],
2895 ]
2896
2897 if tuple.length() >= 2
2898 cond = tuple[1]
2899 else
2900 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
2901 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
2902 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
2903 endif
2904 if cond
2905 found += [tuple[0]]
2906 else
2907 missing += [tuple[0]]
2908 endif
2909 endforeach
2910
2911 status += [
2912 '',
2913 'enabled features: @0@'.format(', '.join(found)),
2914 '',
2915 'disabled features: @0@'.format(', '.join(missing)),
2916 '']
2917 message('\n '.join(status))
2918
2919 if rootprefixdir != rootprefix_default
2920 message('WARNING:\n' +
2921 ' Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
2922 ' systemd used fixed names for unit file directories and other paths, so anything\n' +
2923 ' except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))
2924 endif