]> git.ipfire.org Git - thirdparty/systemd.git/blob - meson.build
tpm2-util: pick up Esys_PCR_Extend() symbol too
[thirdparty/systemd.git] / meson.build
1 # SPDX-License-Identifier: LGPL-2.1-or-later
2
3 project('systemd', 'c',
4 version : '251',
5 license : 'LGPLv2+',
6 default_options: [
7 'c_std=gnu11',
8 'prefix=/usr',
9 'sysconfdir=/etc',
10 'localstatedir=/var',
11 'warning_level=2',
12 ],
13 meson_version : '>= 0.53.2',
14 )
15
16 libsystemd_version = '0.34.0'
17 libudev_version = '1.7.4'
18
19 conf = configuration_data()
20 conf.set_quoted('PROJECT_URL', 'https://systemd.io/')
21 conf.set('PROJECT_VERSION', meson.project_version(),
22 description : 'Numerical project version (used where a simple number is expected)')
23
24 # This is to be used instead of meson.source_root(), as the latter will return
25 # the wrong result when systemd is being built as a meson subproject
26 project_source_root = meson.current_source_dir()
27 project_build_root = meson.current_build_dir()
28 relative_source_path = run_command('realpath',
29 '--relative-to=@0@'.format(project_build_root),
30 project_source_root,
31 check : true).stdout().strip()
32 conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)
33
34 conf.set10('BUILD_MODE_DEVELOPER', get_option('mode') == 'developer',
35 description : 'tailor build to development or release builds')
36 verification = get_option('log-message-verification')
37 if verification == 'auto'
38 verification = conf.get('BUILD_MODE_DEVELOPER') == 1
39 else
40 verification = verification == 'true'
41 endif
42 conf.set10('LOG_MESSAGE_VERIFICATION', verification)
43
44 want_ossfuzz = get_option('oss-fuzz')
45 want_libfuzzer = get_option('llvm-fuzz')
46 if want_ossfuzz and want_libfuzzer
47 error('only one of oss-fuzz or llvm-fuzz can be specified')
48 endif
49
50 skip_deps = want_ossfuzz or get_option('skip-deps')
51 fuzzer_build = want_ossfuzz or want_libfuzzer
52
53 # If we're building *not* for actual fuzzing, allow input samples of any size
54 # (for testing and for reproduction of issues discovered with previously-higher
55 # limits).
56 conf.set10('FUZZ_USE_SIZE_LIMIT', fuzzer_build)
57
58 # Create a title-less summary section early, so it ends up first in the output.
59 # More items are added later after they have been detected.
60 summary({'build mode' : get_option('mode')})
61
62 #####################################################################
63
64 # Try to install the git pre-commit hook
65 add_git_hook_sh = find_program('tools/add-git-hook.sh', required : false)
66 if add_git_hook_sh.found()
67 git_hook = run_command(add_git_hook_sh, check : false)
68 if git_hook.returncode() == 0
69 message(git_hook.stdout().strip())
70 endif
71 endif
72
73 #####################################################################
74
75 fs = import('fs')
76 if get_option('split-usr') == 'auto'
77 split_usr = not fs.is_symlink('/bin')
78 else
79 split_usr = get_option('split-usr') == 'true'
80 endif
81 if split_usr
82 warning('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n\n'
83 + ' split-usr mode is going to be removed\n' +
84 '\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
85 endif
86 conf.set10('HAVE_SPLIT_USR', split_usr,
87 description : '/usr/bin and /bin directories are separate')
88
89 if get_option('split-bin') == 'auto'
90 split_bin = not fs.is_symlink('/usr/sbin')
91 else
92 split_bin = get_option('split-bin') == 'true'
93 endif
94 conf.set10('HAVE_SPLIT_BIN', split_bin,
95 description : 'bin and sbin directories are separate')
96
97 rootprefixdir = get_option('rootprefix')
98 # Unusual rootprefixdir values are used by some distros
99 # (see https://github.com/systemd/systemd/pull/7461).
100 rootprefix_default = split_usr ? '/' : '/usr'
101 if rootprefixdir == ''
102 rootprefixdir = rootprefix_default
103 endif
104 rootprefixdir_noslash = rootprefixdir == '/' ? '' : rootprefixdir
105
106 have_standalone_binaries = get_option('standalone-binaries')
107
108 sysvinit_path = get_option('sysvinit-path')
109 sysvrcnd_path = get_option('sysvrcnd-path')
110 conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '',
111 description : 'SysV init scripts and rcN.d links are supported')
112 conf.set10('CREATE_LOG_DIRS', get_option('create-log-dirs'))
113
114 if get_option('hibernate') and not get_option('initrd')
115 error('hibernate depends on initrd')
116 endif
117
118 conf.set10('BUMP_PROC_SYS_FS_FILE_MAX', get_option('bump-proc-sys-fs-file-max'))
119 conf.set10('BUMP_PROC_SYS_FS_NR_OPEN', get_option('bump-proc-sys-fs-nr-open'))
120 conf.set('HIGH_RLIMIT_NOFILE', 512*1024)
121
122 # Meson ignores the preceding arguments when joining paths if an absolute
123 # component is encountered, so this should canonicalize various paths when they
124 # are absolute or relative.
125 prefixdir = get_option('prefix')
126 if not prefixdir.startswith('/')
127 error('Prefix is not absolute: "@0@"'.format(prefixdir))
128 endif
129 if prefixdir != rootprefixdir and rootprefixdir != '/' and not prefixdir.strip('/').startswith(rootprefixdir.strip('/') + '/')
130 error('Prefix is not below root prefix (now rootprefix=@0@ prefix=@1@)'.format(
131 rootprefixdir, prefixdir))
132 endif
133
134 bindir = prefixdir / get_option('bindir')
135 libdir = prefixdir / get_option('libdir')
136 sysconfdir = prefixdir / get_option('sysconfdir')
137 includedir = prefixdir / get_option('includedir')
138 datadir = prefixdir / get_option('datadir')
139 localstatedir = '/' / get_option('localstatedir')
140
141 rootbindir = rootprefixdir / 'bin'
142 rootsbindir = rootprefixdir / (split_bin ? 'sbin' : 'bin')
143 rootlibexecdir = rootprefixdir / 'lib/systemd'
144
145 rootlibdir = get_option('rootlibdir')
146 if rootlibdir == ''
147 # This will be a relative path if libdir is in prefix.
148 rootlibdir = get_option('libdir')
149 endif
150 if not rootlibdir.startswith('/')
151 # If we have a relative path, add rootprefixdir to the front.
152 rootlibdir = rootprefixdir / rootlibdir
153 endif
154 rootpkglibdir = rootlibdir / 'systemd'
155
156 install_sysconfdir = get_option('install-sysconfdir') != 'false'
157 install_sysconfdir_samples = get_option('install-sysconfdir') == 'true'
158 # Dirs of external packages
159 pkgconfigdatadir = get_option('pkgconfigdatadir') != '' ? get_option('pkgconfigdatadir') : datadir / 'pkgconfig'
160 pkgconfiglibdir = get_option('pkgconfiglibdir') != '' ? get_option('pkgconfiglibdir') : libdir / 'pkgconfig'
161 polkitpolicydir = datadir / 'polkit-1/actions'
162 polkitrulesdir = datadir / 'polkit-1/rules.d'
163 polkitpkladir = localstatedir / 'lib/polkit-1/localauthority/10-vendor.d'
164 xinitrcdir = get_option('xinitrcdir') != '' ? get_option('xinitrcdir') : sysconfdir / 'X11/xinit/xinitrc.d'
165 rpmmacrosdir = get_option('rpmmacrosdir')
166 if rpmmacrosdir != 'no'
167 rpmmacrosdir = prefixdir / rpmmacrosdir
168 endif
169 modprobedir = rootprefixdir / 'lib/modprobe.d'
170
171 # Our own paths
172 pkgdatadir = datadir / 'systemd'
173 environmentdir = prefixdir / 'lib/environment.d'
174 pkgsysconfdir = sysconfdir / 'systemd'
175 userunitdir = prefixdir / 'lib/systemd/user'
176 userpresetdir = prefixdir / 'lib/systemd/user-preset'
177 tmpfilesdir = prefixdir / 'lib/tmpfiles.d'
178 usertmpfilesdir = prefixdir / 'share/user-tmpfiles.d'
179 sysusersdir = prefixdir / 'lib/sysusers.d'
180 sysctldir = prefixdir / 'lib/sysctl.d'
181 binfmtdir = prefixdir / 'lib/binfmt.d'
182 modulesloaddir = prefixdir / 'lib/modules-load.d'
183 networkdir = rootprefixdir / 'lib/systemd/network'
184 pkgincludedir = includedir / 'systemd'
185 systemgeneratordir = rootlibexecdir / 'system-generators'
186 usergeneratordir = prefixdir / 'lib/systemd/user-generators'
187 systemenvgeneratordir = prefixdir / 'lib/systemd/system-environment-generators'
188 userenvgeneratordir = prefixdir / 'lib/systemd/user-environment-generators'
189 systemshutdowndir = rootlibexecdir / 'system-shutdown'
190 systemsleepdir = rootlibexecdir / 'system-sleep'
191 systemunitdir = rootprefixdir / 'lib/systemd/system'
192 systempresetdir = rootprefixdir / 'lib/systemd/system-preset'
193 udevlibexecdir = rootprefixdir / 'lib/udev'
194 udevrulesdir = udevlibexecdir / 'rules.d'
195 udevhwdbdir = udevlibexecdir / 'hwdb.d'
196 catalogdir = prefixdir / 'lib/systemd/catalog'
197 kerneldir = prefixdir / 'lib/kernel'
198 kernelinstalldir = kerneldir / 'install.d'
199 factorydir = datadir / 'factory'
200 bootlibdir = prefixdir / 'lib/systemd/boot/efi'
201 testsdir = prefixdir / 'lib/systemd/tests'
202 systemdstatedir = localstatedir / 'lib/systemd'
203 catalogstatedir = systemdstatedir / 'catalog'
204 randomseeddir = localstatedir / 'lib/systemd'
205 profiledir = rootlibexecdir / 'portable' / 'profile'
206 ntpservicelistdir = rootprefixdir / 'lib/systemd/ntp-units.d'
207
208 docdir = get_option('docdir')
209 if docdir == ''
210 docdir = datadir / 'doc/systemd'
211 endif
212
213 pamlibdir = get_option('pamlibdir')
214 if pamlibdir == ''
215 pamlibdir = rootlibdir / 'security'
216 endif
217
218 pamconfdir = get_option('pamconfdir')
219 if pamconfdir == ''
220 pamconfdir = prefixdir / 'lib/pam.d'
221 endif
222
223 libcryptsetup_plugins_dir = get_option('libcryptsetup-plugins-dir')
224 if libcryptsetup_plugins_dir == ''
225 libcryptsetup_plugins_dir = rootlibdir / 'cryptsetup'
226 endif
227
228 memory_accounting_default = get_option('memory-accounting-default')
229 status_unit_format_default = get_option('status-unit-format-default')
230 if status_unit_format_default == 'auto'
231 status_unit_format_default = conf.get('BUILD_MODE_DEVELOPER') == 1 ? 'name' : 'description'
232 endif
233
234 conf.set_quoted('BINFMT_DIR', binfmtdir)
235 conf.set_quoted('BOOTLIBDIR', bootlibdir)
236 conf.set_quoted('CATALOG_DATABASE', catalogstatedir / 'database')
237 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
238 conf.set_quoted('DOC_DIR', docdir)
239 conf.set_quoted('DOCUMENT_ROOT', pkgdatadir / 'gatewayd')
240 conf.set_quoted('ENVIRONMENT_DIR', environmentdir)
241 conf.set_quoted('INCLUDE_DIR', includedir)
242 conf.set_quoted('LIBDIR', libdir)
243 conf.set_quoted('MODPROBE_DIR', modprobedir)
244 conf.set_quoted('MODULESLOAD_DIR', modulesloaddir)
245 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
246 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', bindir / 'pkttyagent')
247 conf.set_quoted('PREFIX', prefixdir)
248 conf.set_quoted('RANDOM_SEED', randomseeddir / 'random-seed')
249 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
250 conf.set_quoted('RC_LOCAL_PATH', get_option('rc-local'))
251 conf.set_quoted('ROOTBINDIR', rootbindir)
252 conf.set_quoted('ROOTLIBDIR', rootlibdir)
253 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
254 conf.set_quoted('ROOTPREFIX', rootprefixdir)
255 conf.set_quoted('ROOTPREFIX_NOSLASH', rootprefixdir_noslash)
256 conf.set_quoted('SYSCONF_DIR', sysconfdir)
257 conf.set_quoted('SYSCTL_DIR', sysctldir)
258 conf.set_quoted('SYSTEMCTL_BINARY_PATH', rootbindir / 'systemctl')
259 conf.set_quoted('SYSTEMD_BINARY_PATH', rootlibexecdir / 'systemd')
260 conf.set_quoted('SYSTEMD_CATALOG_DIR', catalogdir)
261 conf.set_quoted('SYSTEMD_CGROUPS_AGENT_PATH', rootlibexecdir / 'systemd-cgroups-agent')
262 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', rootlibexecdir / 'systemd-cryptsetup')
263 conf.set_quoted('SYSTEMD_EXPORT_PATH', rootlibexecdir / 'systemd-export')
264 conf.set_quoted('SYSTEMD_FSCK_PATH', rootlibexecdir / 'systemd-fsck')
265 conf.set_quoted('SYSTEMD_GROWFS_PATH', rootlibexecdir / 'systemd-growfs')
266 conf.set_quoted('SYSTEMD_HOMEWORK_PATH', rootlibexecdir / 'systemd-homework')
267 conf.set_quoted('SYSTEMD_IMPORT_FS_PATH', rootlibexecdir / 'systemd-import-fs')
268 conf.set_quoted('SYSTEMD_IMPORT_PATH', rootlibexecdir / 'systemd-import')
269 conf.set_quoted('SYSTEMD_INTEGRITYSETUP_PATH', rootlibexecdir / 'systemd-integritysetup')
270 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', pkgdatadir / 'kbd-model-map')
271 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', pkgdatadir / 'language-fallback-map')
272 conf.set_quoted('SYSTEMD_MAKEFS_PATH', rootlibexecdir / 'systemd-makefs')
273 conf.set_quoted('SYSTEMD_PULL_PATH', rootlibexecdir / 'systemd-pull')
274 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', rootlibexecdir / 'systemd-shutdown')
275 conf.set_quoted('SYSTEMD_TEST_DATA', testsdir / 'testdata')
276 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', rootbindir / 'systemd-tty-ask-password-agent')
277 conf.set_quoted('SYSTEMD_UPDATE_HELPER_PATH', rootlibexecdir / 'systemd-update-helper')
278 conf.set_quoted('SYSTEMD_USERWORK_PATH', rootlibexecdir / 'systemd-userwork')
279 conf.set_quoted('SYSTEMD_VERITYSETUP_PATH', rootlibexecdir / 'systemd-veritysetup')
280 conf.set_quoted('SYSTEM_CONFIG_UNIT_DIR', pkgsysconfdir / 'system')
281 conf.set_quoted('SYSTEM_DATA_UNIT_DIR', systemunitdir)
282 conf.set_quoted('SYSTEM_ENV_GENERATOR_DIR', systemenvgeneratordir)
283 conf.set_quoted('SYSTEM_GENERATOR_DIR', systemgeneratordir)
284 conf.set_quoted('SYSTEM_PRESET_DIR', systempresetdir)
285 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
286 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
287 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
288 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
289 conf.set_quoted('SYSUSERS_DIR', sysusersdir)
290 conf.set_quoted('TMPFILES_DIR', tmpfilesdir)
291 conf.set_quoted('USER_TMPFILES_DIR', usertmpfilesdir)
292 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
293 conf.set_quoted('UDEV_HWDB_DIR', udevhwdbdir)
294 conf.set_quoted('UDEV_RULES_DIR', udevrulesdir)
295 conf.set_quoted('UPDATE_HELPER_USER_TIMEOUT', get_option('update-helper-user-timeout'))
296 conf.set_quoted('USER_CONFIG_UNIT_DIR', pkgsysconfdir / 'user')
297 conf.set_quoted('USER_DATA_UNIT_DIR', userunitdir)
298 conf.set_quoted('USER_ENV_GENERATOR_DIR', userenvgeneratordir)
299 conf.set_quoted('USER_GENERATOR_DIR', usergeneratordir)
300 conf.set_quoted('USER_KEYRING_PATH', pkgsysconfdir / 'import-pubring.gpg')
301 conf.set_quoted('USER_PRESET_DIR', userpresetdir)
302 conf.set_quoted('VENDOR_KEYRING_PATH', rootlibexecdir / 'import-pubring.gpg')
303
304 conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
305 conf.set10('ENABLE_URLIFY', get_option('urlify'))
306 conf.set10('ENABLE_FEXECVE', get_option('fexecve'))
307 conf.set10('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default)
308 conf.set('STATUS_UNIT_FORMAT_DEFAULT', 'STATUS_UNIT_FORMAT_' + status_unit_format_default.to_upper())
309 conf.set_quoted('STATUS_UNIT_FORMAT_DEFAULT_STR', status_unit_format_default)
310
311 conf.set10('FIRST_BOOT_FULL_PRESET', get_option('first-boot-full-preset'))
312
313 conf.set10('EFI_TPM_PCR_COMPAT', get_option('efi-tpm-pcr-compat'))
314
315 #####################################################################
316
317 cc = meson.get_compiler('c')
318 pkgconfig = import('pkgconfig')
319 meson_build_sh = find_program('tools/meson-build.sh')
320
321 want_tests = get_option('tests')
322 slow_tests = want_tests != 'false' and get_option('slow-tests')
323 fuzz_tests = want_tests != 'false' and get_option('fuzz-tests')
324 install_tests = get_option('install-tests')
325
326 if add_languages('cpp', required : fuzzer_build)
327 # Used only for tests
328 cxx = meson.get_compiler('cpp')
329 cxx_cmd = ' '.join(cxx.cmd_array())
330 else
331 cxx_cmd = ''
332 endif
333
334 if want_libfuzzer
335 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer', required : false)
336 if fuzzing_engine.found()
337 add_project_arguments('-fsanitize-coverage=trace-pc-guard,trace-cmp', language : 'c')
338 elif cc.has_argument('-fsanitize=fuzzer-no-link')
339 add_project_arguments('-fsanitize=fuzzer-no-link', language : 'c')
340 else
341 error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported')
342 endif
343 elif want_ossfuzz
344 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
345 endif
346
347 # Those generate many false positives, and we do not want to change the code to
348 # avoid them.
349 basic_disabled_warnings = [
350 '-Wno-missing-field-initializers',
351 '-Wno-unused-parameter',
352 ]
353
354 possible_common_cc_flags = [
355 '-Wdate-time',
356 '-Wendif-labels',
357 '-Werror=format=2',
358 '-Werror=format-signedness',
359 '-Werror=implicit-function-declaration',
360 '-Werror=incompatible-pointer-types',
361 '-Werror=int-conversion',
362 '-Werror=overflow',
363 '-Werror=override-init',
364 '-Werror=return-type',
365 '-Werror=shift-count-overflow',
366 '-Werror=shift-overflow=2',
367 '-Werror=undef',
368 '-Wfloat-equal',
369 # gperf prevents us from enabling this because it does not emit fallthrough
370 # attribute with clang.
371 #'-Wimplicit-fallthrough',
372 '-Wimplicit-fallthrough=5',
373 '-Winit-self',
374 '-Wlogical-op',
375 '-Wmissing-include-dirs',
376 '-Wmissing-noreturn',
377 '-Wnested-externs',
378 '-Wold-style-definition',
379 '-Wpointer-arith',
380 '-Wredundant-decls',
381 '-Wshadow',
382 '-Wstrict-aliasing=2',
383 '-Wstrict-prototypes',
384 '-Wsuggest-attribute=noreturn',
385 '-Wunused-function',
386 '-Wwrite-strings',
387
388 # negative arguments are correctly detected starting with meson 0.46.
389 '-Wno-error=#warnings', # clang
390 '-Wno-string-plus-int', # clang
391 ]
392
393 c_args = get_option('c_args')
394
395 # Our json library does not support -ffinite-math-only, which is enabled by -Ofast or -ffast-math.
396 if (('-Ofast' in c_args or '-ffast-math' in c_args or '-ffinite-math-only' in c_args) and '-fno-finite-math-only' not in c_args)
397 error('-Ofast, -ffast-math, or -ffinite-math-only is specified in c_args.')
398 endif
399
400 # Disable -Wmaybe-uninitialized when compiling with -Os/-O1/-O3/etc. There are
401 # too many false positives with gcc >= 8. Effectively, we only test with -O0
402 # and -O2; this should be enough to catch most important cases without too much
403 # busywork. See https://github.com/systemd/systemd/pull/19226.
404 if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or
405 cc.version().version_compare('<10') or
406 '-Os' in c_args or
407 '-O1' in c_args or
408 '-O3' in c_args or
409 '-Og' in c_args)
410 possible_common_cc_flags += '-Wno-maybe-uninitialized'
411 endif
412
413 # Disable -Wno-unused-result with gcc, see
414 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425.
415 if cc.get_id() == 'gcc'
416 possible_common_cc_flags += '-Wno-unused-result'
417 endif
418
419 # --as-needed and --no-undefined are provided by meson by default,
420 # run 'meson configure' to see what is enabled
421 possible_link_flags = [
422 '-Wl,--fatal-warnings',
423 '-Wl,-z,now',
424 '-Wl,-z,relro',
425 '-fstack-protector',
426 ]
427
428 if get_option('b_sanitize') == 'none'
429 possible_link_flags += '-Wl,--warn-common'
430 endif
431
432 if cc.get_id() == 'clang'
433 possible_common_cc_flags += [
434 '-Wno-typedef-redefinition',
435 '-Wno-gnu-variable-sized-type-not-at-end',
436 ]
437 endif
438
439 if get_option('mode') == 'release'
440 # We could enable 'pattern' for developer mode, but that can interfere with
441 # valgrind and sanitizer builds. Also, clang does not zero-initialize unions,
442 # breaking some of our code (https://reviews.llvm.org/D68115).
443 possible_common_cc_flags += '-ftrivial-auto-var-init=zero'
444 endif
445
446 possible_cc_flags = possible_common_cc_flags + [
447 '-Werror=missing-declarations',
448 '-Werror=missing-prototypes',
449 '-fdiagnostics-show-option',
450 '-fno-common',
451 '-fno-strict-aliasing',
452 '-fstack-protector',
453 '-fstack-protector-strong',
454 '-fvisibility=hidden',
455 '--param=ssp-buffer-size=4',
456 ]
457
458 if get_option('buildtype') != 'debug'
459 possible_cc_flags += [
460 '-ffunction-sections',
461 '-fdata-sections',
462 ]
463
464 possible_link_flags += '-Wl,--gc-sections'
465 endif
466
467 if get_option('mode') == 'developer'
468 possible_cc_flags += '-fno-omit-frame-pointer'
469 endif
470
471 add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
472 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
473 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
474
475 have = cc.has_argument('-Wzero-length-bounds')
476 conf.set10('HAVE_ZERO_LENGTH_BOUNDS', have)
477
478 if cc.compiles('''
479 #include <time.h>
480 #include <inttypes.h>
481 typedef uint64_t usec_t;
482 usec_t now(clockid_t clock);
483 int main(void) {
484 struct timespec now;
485 return 0;
486 }
487 ''', args: '-Werror=shadow', name : '-Werror=shadow with local shadowing')
488 add_project_arguments('-Werror=shadow', language : 'c')
489 endif
490
491 if cxx_cmd != ''
492 add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
493 endif
494
495 cpp = ' '.join(cc.cmd_array()) + ' -E'
496
497 has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
498
499 #####################################################################
500 # compilation result tests
501
502 conf.set('_GNU_SOURCE', true)
503 conf.set('__SANE_USERSPACE_TYPES__', true)
504 conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)
505
506 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
507 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
508 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
509 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
510 conf.set('SIZEOF_TIMEX_MEMBER', cc.sizeof('typeof(((struct timex *)0)->freq)', prefix : '#include <sys/timex.h>'))
511
512 decl_headers = '''
513 #include <uchar.h>
514 #include <sys/mount.h>
515 #include <sys/stat.h>
516 '''
517
518 foreach decl : ['char16_t',
519 'char32_t',
520 'struct mount_attr',
521 'struct statx',
522 ]
523
524 # We get -1 if the size cannot be determined
525 have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
526
527 if decl == 'struct mount_attr'
528 if have
529 want_linux_fs_h = false
530 else
531 have = cc.sizeof(decl,
532 prefix : decl_headers + '#include <linux/fs.h>',
533 args : '-D_GNU_SOURCE') > 0
534 want_linux_fs_h = have
535 endif
536 endif
537
538 if decl == 'struct statx'
539 if have
540 want_linux_stat_h = false
541 else
542 have = cc.sizeof(decl,
543 prefix : decl_headers + '#include <linux/stat.h>',
544 args : '-D_GNU_SOURCE') > 0
545 want_linux_stat_h = have
546 endif
547 endif
548
549 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
550 endforeach
551
552 conf.set10('WANT_LINUX_STAT_H', want_linux_stat_h)
553 conf.set10('WANT_LINUX_FS_H', want_linux_fs_h)
554
555 foreach ident : ['secure_getenv', '__secure_getenv']
556 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
557 endforeach
558
559 foreach ident : [
560 ['memfd_create', '''#include <sys/mman.h>'''],
561 ['gettid', '''#include <sys/types.h>
562 #include <unistd.h>'''],
563 ['pivot_root', '''#include <stdlib.h>
564 #include <unistd.h>'''], # no known header declares pivot_root
565 ['ioprio_get', '''#include <sched.h>'''], # no known header declares ioprio_get
566 ['ioprio_set', '''#include <sched.h>'''], # no known header declares ioprio_set
567 ['name_to_handle_at', '''#include <sys/types.h>
568 #include <sys/stat.h>
569 #include <fcntl.h>'''],
570 ['setns', '''#include <sched.h>'''],
571 ['renameat2', '''#include <stdio.h>
572 #include <fcntl.h>'''],
573 ['kcmp', '''#include <linux/kcmp.h>'''],
574 ['keyctl', '''#include <sys/types.h>
575 #include <keyutils.h>'''],
576 ['copy_file_range', '''#include <sys/syscall.h>
577 #include <unistd.h>'''],
578 ['bpf', '''#include <sys/syscall.h>
579 #include <unistd.h>'''],
580 ['statx', '''#include <sys/types.h>
581 #include <sys/stat.h>
582 #include <unistd.h>'''],
583 ['explicit_bzero' , '''#include <string.h>'''],
584 ['reallocarray', '''#include <stdlib.h>'''],
585 ['set_mempolicy', '''#include <stdlib.h>
586 #include <unistd.h>'''],
587 ['get_mempolicy', '''#include <stdlib.h>
588 #include <unistd.h>'''],
589 ['pidfd_send_signal', '''#include <stdlib.h>
590 #include <unistd.h>
591 #include <signal.h>
592 #include <sys/wait.h>'''],
593 ['pidfd_open', '''#include <stdlib.h>
594 #include <unistd.h>
595 #include <signal.h>
596 #include <sys/wait.h>'''],
597 ['rt_sigqueueinfo', '''#include <stdlib.h>
598 #include <unistd.h>
599 #include <signal.h>
600 #include <sys/wait.h>'''],
601 ['mallinfo', '''#include <malloc.h>'''],
602 ['mallinfo2', '''#include <malloc.h>'''],
603 ['execveat', '''#include <unistd.h>'''],
604 ['close_range', '''#include <unistd.h>'''],
605 ['epoll_pwait2', '''#include <sys/epoll.h>'''],
606 ['mount_setattr', '''#include <sys/mount.h>'''],
607 ['move_mount', '''#include <sys/mount.h>'''],
608 ['open_tree', '''#include <sys/mount.h>'''],
609 ['getdents64', '''#include <dirent.h>'''],
610 ]
611
612 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
613 conf.set10('HAVE_' + ident[0].to_upper(), have)
614 endforeach
615
616 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
617 conf.set10('USE_SYS_RANDOM_H', true)
618 conf.set10('HAVE_GETRANDOM', true)
619 else
620 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
621 conf.set10('USE_SYS_RANDOM_H', false)
622 conf.set10('HAVE_GETRANDOM', have)
623 endif
624
625 #####################################################################
626
627 version_tag = get_option('version-tag')
628 if version_tag != ''
629 vcs_data = configuration_data()
630 vcs_data.set('VCS_TAG', version_tag)
631 version_h = configure_file(configuration : vcs_data,
632 input : 'src/version/version.h.in',
633 output : 'version.h')
634 else
635 vcs_tagger = [
636 project_source_root + '/tools/meson-vcs-tag.sh',
637 project_source_root,
638 meson.project_version()]
639
640 version_h = vcs_tag(
641 input : 'src/version/version.h.in',
642 output : 'version.h',
643 command: vcs_tagger)
644 endif
645
646 versiondep = declare_dependency(sources: version_h)
647
648 shared_lib_tag = get_option('shared-lib-tag')
649 if shared_lib_tag == ''
650 shared_lib_tag = meson.project_version()
651 endif
652
653 sh = find_program('sh')
654 echo = find_program('echo')
655 sed = find_program('sed')
656 awk = find_program('awk')
657 stat = find_program('stat')
658 ln = find_program('ln')
659 git = find_program('git', required : false)
660 env = find_program('env')
661 perl = find_program('perl', required : false)
662 rsync = find_program('rsync', required : false)
663 meson_make_symlink = project_source_root + '/tools/meson-make-symlink.sh'
664
665 mkdir_p = 'mkdir -p $DESTDIR/@0@'
666
667 # If -Dxxx-path option is found, use that. Otherwise, check in $PATH,
668 # /usr/sbin, /sbin, and fall back to the default from middle column.
669 progs = [['quotaon', '/usr/sbin/quotaon' ],
670 ['quotacheck', '/usr/sbin/quotacheck' ],
671 ['kmod', '/usr/bin/kmod' ],
672 ['kexec', '/usr/sbin/kexec' ],
673 ['sulogin', '/usr/sbin/sulogin' ],
674 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
675 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
676 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
677 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
678 ['nologin', '/usr/sbin/nologin', ],
679 ]
680 foreach prog : progs
681 path = get_option(prog[0] + '-path')
682 if path != ''
683 message('Using @1@ for @0@'.format(prog[0], path))
684 else
685 exe = find_program(prog[0],
686 '/usr/sbin/' + prog[0],
687 '/sbin/' + prog[0],
688 required: false)
689 path = exe.found() ? exe.path() : prog[1]
690 endif
691 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
692 conf.set_quoted(name, path)
693 endforeach
694
695 conf.set_quoted('TELINIT', get_option('telinit-path'))
696
697 if run_command(ln, '--relative', '--help', check : false).returncode() != 0
698 error('ln does not support --relative (added in coreutils 8.16)')
699 endif
700
701 ############################################################
702
703 python = find_program('python3')
704 if run_command(python, '-c', 'import jinja2', check : false).returncode() != 0
705 error('python3 jinja2 missing')
706 endif
707
708 ############################################################
709
710 gperf = find_program('gperf')
711
712 gperf_test_format = '''
713 #include <string.h>
714 const char * in_word_set(const char *, @0@);
715 @1@
716 '''
717 gperf_snippet = run_command(sh, '-c', 'echo foo,bar | "$1" -L ANSI-C', '_', gperf,
718 check : true)
719 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
720 if cc.compiles(gperf_test)
721 gperf_len_type = 'size_t'
722 else
723 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
724 if cc.compiles(gperf_test)
725 gperf_len_type = 'unsigned'
726 else
727 error('unable to determine gperf len type')
728 endif
729 endif
730 message('gperf len type is @0@'.format(gperf_len_type))
731 conf.set('GPERF_LEN_TYPE', gperf_len_type,
732 description : 'The type of gperf "len" parameter')
733
734 ############################################################
735
736 if not cc.has_header('sys/capability.h')
737 error('POSIX caps headers not found')
738 endif
739 foreach header : ['crypt.h',
740 'linux/memfd.h',
741 'linux/vm_sockets.h',
742 'sys/auxv.h',
743 'valgrind/memcheck.h',
744 'valgrind/valgrind.h',
745 'linux/time_types.h',
746 'sys/sdt.h',
747 ]
748
749 conf.set10('HAVE_' + header.underscorify().to_upper(),
750 cc.has_header(header))
751 endforeach
752
753 ############################################################
754
755 fallback_hostname = get_option('fallback-hostname')
756 if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0] == '-'
757 error('Invalid fallback-hostname configuration')
758 # A more extensive test is done in test-hostname-util. Let's catch
759 # the most obvious errors here so we don't fail with an assert later.
760 endif
761 conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
762
763 default_hierarchy = get_option('default-hierarchy')
764 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
765 description : 'default cgroup hierarchy as string')
766 if default_hierarchy == 'legacy'
767 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
768 elif default_hierarchy == 'hybrid'
769 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
770 else
771 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
772 endif
773
774 extra_net_naming_schemes = []
775 extra_net_naming_map = []
776 foreach scheme: get_option('extra-net-naming-schemes').split(',')
777 if scheme != ''
778 name = scheme.split('=')[0]
779 value = scheme.split('=')[1]
780 NAME = name.underscorify().to_upper()
781 VALUE = []
782 foreach field: value.split('+')
783 VALUE += 'NAMING_' + field.underscorify().to_upper()
784 endforeach
785 extra_net_naming_schemes += 'NAMING_@0@ = @1@,'.format(NAME, '|'.join(VALUE))
786 extra_net_naming_map += '{ "@0@", NAMING_@1@ },'.format(name, NAME)
787 endif
788 endforeach
789 conf.set('EXTRA_NET_NAMING_SCHEMES', ' '.join(extra_net_naming_schemes))
790 conf.set('EXTRA_NET_NAMING_MAP', ' '.join(extra_net_naming_map))
791
792 default_net_naming_scheme = get_option('default-net-naming-scheme')
793 conf.set_quoted('DEFAULT_NET_NAMING_SCHEME', default_net_naming_scheme)
794 if default_net_naming_scheme != 'latest'
795 conf.set('_DEFAULT_NET_NAMING_SCHEME_TEST',
796 'NAMING_' + default_net_naming_scheme.underscorify().to_upper())
797 endif
798
799 time_epoch = get_option('time-epoch')
800 if time_epoch <= 0
801 time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check : true).stdout().strip()
802 if time_epoch == '' and git.found() and fs.exists('.git')
803 # If we're in a git repository, use the creation time of the latest git tag.
804 latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags',
805 check : false)
806 if latest_tag.returncode() == 0
807 time_epoch = run_command(
808 git, 'log', '--no-show-signature', '-1', '--format=%at',
809 latest_tag.stdout().strip(),
810 check : false).stdout()
811 endif
812 endif
813 if time_epoch == ''
814 NEWS = files('NEWS')
815 time_epoch = run_command(stat, '-c', '%Y', NEWS,
816 check : true).stdout()
817 endif
818 time_epoch = time_epoch.strip().to_int()
819 endif
820 conf.set('TIME_EPOCH', time_epoch)
821
822 conf.set('CLOCK_VALID_RANGE_USEC_MAX', get_option('clock-valid-range-usec-max'))
823
824 default_user_shell = get_option('default-user-shell')
825 conf.set_quoted('DEFAULT_USER_SHELL', default_user_shell)
826 conf.set_quoted('DEFAULT_USER_SHELL_NAME', fs.name(default_user_shell))
827
828 foreach tuple : [['system-alloc-uid-min', 'SYS_UID_MIN', 1], # Also see login.defs(5).
829 ['system-uid-max', 'SYS_UID_MAX', 999],
830 ['system-alloc-gid-min', 'SYS_GID_MIN', 1],
831 ['system-gid-max', 'SYS_GID_MAX', 999]]
832 v = get_option(tuple[0])
833 if v <= 0
834 v = run_command(
835 awk,
836 '/^\s*@0@\s+/ { uid=$2 } END { print uid }'.format(tuple[1]),
837 '/etc/login.defs',
838 check : false).stdout().strip()
839 if v == ''
840 v = tuple[2]
841 else
842 v = v.to_int()
843 endif
844 endif
845 conf.set(tuple[0].underscorify().to_upper(), v)
846 endforeach
847 if conf.get('SYSTEM_ALLOC_UID_MIN') >= conf.get('SYSTEM_UID_MAX')
848 error('Invalid uid allocation range')
849 endif
850 if conf.get('SYSTEM_ALLOC_GID_MIN') >= conf.get('SYSTEM_GID_MAX')
851 error('Invalid gid allocation range')
852 endif
853
854 dynamic_uid_min = get_option('dynamic-uid-min')
855 dynamic_uid_max = get_option('dynamic-uid-max')
856 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
857 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
858
859 container_uid_base_min = get_option('container-uid-base-min')
860 container_uid_base_max = get_option('container-uid-base-max')
861 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
862 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
863
864 nobody_user = get_option('nobody-user')
865 nobody_group = get_option('nobody-group')
866
867 if not meson.is_cross_build()
868 getent_result = run_command('getent', 'passwd', '65534', check : false)
869 if getent_result.returncode() == 0
870 name = getent_result.stdout().split(':')[0]
871 if name != nobody_user
872 warning('\n' +
873 '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) +
874 'Your build will result in an user table setup that is incompatible with the local system.')
875 endif
876 endif
877 id_result = run_command('id', '-u', nobody_user, check : false)
878 if id_result.returncode() == 0
879 id = id_result.stdout().strip().to_int()
880 if id != 65534
881 warning('\n' +
882 '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) +
883 'Your build will result in an user table setup that is incompatible with the local system.')
884 endif
885 endif
886
887 getent_result = run_command('getent', 'group', '65534', check : false)
888 if getent_result.returncode() == 0
889 name = getent_result.stdout().split(':')[0]
890 if name != nobody_group
891 warning('\n' +
892 '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) +
893 'Your build will result in an group table setup that is incompatible with the local system.')
894 endif
895 endif
896 id_result = run_command('id', '-g', nobody_group, check : false)
897 if id_result.returncode() == 0
898 id = id_result.stdout().strip().to_int()
899 if id != 65534
900 warning('\n' +
901 'The local group with the configured group name "@0@" of the nobody group does not have GID 65534 (it has @1@).\n'.format(nobody_group, id) +
902 'Your build will result in an group table setup that is incompatible with the local system.')
903 endif
904 endif
905 endif
906 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
907 warning('\n' +
908 'The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
909 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
910 endif
911
912 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
913 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
914
915 static_ugids = []
916 foreach option : ['adm-gid',
917 'audio-gid',
918 'cdrom-gid',
919 'dialout-gid',
920 'disk-gid',
921 'input-gid',
922 'kmem-gid',
923 'kvm-gid',
924 'lp-gid',
925 'render-gid',
926 'sgx-gid',
927 'tape-gid',
928 'tty-gid',
929 'users-gid',
930 'utmp-gid',
931 'video-gid',
932 'wheel-gid',
933 'systemd-journal-gid',
934 'systemd-network-uid',
935 'systemd-resolve-uid',
936 'systemd-timesync-uid']
937 name = option.underscorify().to_upper()
938 val = get_option(option)
939
940 # Ensure provided GID argument is numeric, otherwise fall back to default assignment
941 conf.set(name, val > 0 ? val : '-')
942 if val > 0
943 static_ugids += '@0@:@1@'.format(option, val)
944 endif
945 endforeach
946
947 conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
948 conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
949
950 dev_kvm_mode = get_option('dev-kvm-mode')
951 conf.set_quoted('DEV_KVM_MODE', dev_kvm_mode) # FIXME: convert to 0o… notation
952 conf.set10('DEV_KVM_UACCESS', dev_kvm_mode != '0666')
953 group_render_mode = get_option('group-render-mode')
954 conf.set_quoted('GROUP_RENDER_MODE', group_render_mode)
955 conf.set10('GROUP_RENDER_UACCESS', group_render_mode != '0666')
956
957 kill_user_processes = get_option('default-kill-user-processes')
958 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
959
960 dns_servers = get_option('dns-servers')
961 conf.set_quoted('DNS_SERVERS', dns_servers)
962
963 ntp_servers = get_option('ntp-servers')
964 conf.set_quoted('NTP_SERVERS', ntp_servers)
965
966 default_locale = get_option('default-locale')
967 conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale)
968
969 nspawn_locale = get_option('nspawn-locale')
970 conf.set_quoted('SYSTEMD_NSPAWN_LOCALE', nspawn_locale)
971
972 localegen_path = get_option('localegen-path')
973 if localegen_path != ''
974 conf.set_quoted('LOCALEGEN_PATH', localegen_path)
975 endif
976 conf.set10('HAVE_LOCALEGEN', localegen_path != '')
977
978 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
979
980 service_watchdog = get_option('service-watchdog')
981 watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
982 conf.set_quoted('SERVICE_WATCHDOG', watchdog_value)
983
984 conf.set_quoted('SUSHELL', get_option('debug-shell'))
985 conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
986
987 enable_debug_hashmap = false
988 enable_debug_mmap_cache = false
989 enable_debug_siphash = false
990 foreach name : get_option('debug-extra')
991 if name == 'hashmap'
992 enable_debug_hashmap = true
993 elif name == 'mmap-cache'
994 enable_debug_mmap_cache = true
995 elif name == 'siphash'
996 enable_debug_siphash = true
997 else
998 message('unknown debug option "@0@", ignoring'.format(name))
999 endif
1000 endforeach
1001 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
1002 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
1003 conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash)
1004
1005 conf.set10('VALGRIND', get_option('valgrind'))
1006 conf.set10('LOG_TRACE', get_option('log-trace'))
1007
1008 default_user_path = get_option('user-path')
1009 if default_user_path != ''
1010 conf.set_quoted('DEFAULT_USER_PATH', default_user_path)
1011 endif
1012
1013
1014 #####################################################################
1015
1016 libatomic = []
1017 if not cc.links('''#include <stdint.h>
1018 int main() {
1019 char i;
1020 __atomic_exchange_1(&i, 1, 0);
1021 return 1;
1022 }''',
1023 name : 'Atomic builtin requires -latomic')
1024 libatomic = cc.find_library('atomic')
1025 endif
1026 threads = dependency('threads')
1027 librt = cc.find_library('rt')
1028 libm = cc.find_library('m')
1029 libdl = cc.find_library('dl')
1030 libcrypt = cc.find_library('crypt')
1031
1032 crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
1033 foreach ident : [
1034 ['crypt_ra', crypt_header],
1035 ['crypt_preferred_method', crypt_header],
1036 ['crypt_gensalt_ra', crypt_header]]
1037
1038 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
1039 dependencies : libcrypt)
1040 conf.set10('HAVE_' + ident[0].to_upper(), have)
1041 endforeach
1042
1043 libcap = dependency('libcap', required : false)
1044 if not libcap.found()
1045 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
1046 libcap = cc.find_library('cap')
1047 endif
1048
1049 want_bpf_framework = get_option('bpf-framework')
1050 bpf_framework_required = want_bpf_framework == 'true'
1051
1052 libbpf = dependency('libbpf', required : bpf_framework_required, version : '>= 0.2')
1053 conf.set10('HAVE_LIBBPF', libbpf.found())
1054
1055 if want_bpf_framework == 'false' or not libbpf.found() or skip_deps
1056 conf.set10('BPF_FRAMEWORK', false)
1057 else
1058 bpf_compiler = get_option('bpf-compiler')
1059 clang_found = false
1060 clang_supports_bpf = false
1061 bpf_gcc_found = false
1062 deps_found = false
1063
1064 if bpf_compiler == 'clang'
1065 # Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu
1066 # (like clang-10/llvm-strip-10)
1067 if meson.is_cross_build() or cc.get_id() != 'clang' or cc.cmd_array()[0].contains('afl-clang') or cc.cmd_array()[0].contains('hfuzz-clang')
1068 r = find_program('clang', required : bpf_framework_required, version : '>= 10.0.0')
1069 clang_found = r.found()
1070 if clang_found
1071 clang = r.path()
1072 endif
1073 # Assume that the required flags are supported by the found clang.
1074 clang_supports_flags = clang_found
1075 else
1076 clang_found = true
1077 clang = cc.cmd_array()
1078 clang_supports_flags = cc.has_argument('-Wno-compare-distinct-pointer-types')
1079 endif
1080
1081 if clang_found
1082 # Check if 'clang -target bpf' is supported.
1083 clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0
1084 endif
1085 elif bpf_compiler == 'gcc'
1086 warning('GCC BPF Compiler support is experimental and not recommended.')
1087 bpf_gcc = find_program('bpf-gcc',
1088 required : true,
1089 version : '>= 12.1.0')
1090 bpf_gcc_found = bpf_gcc.found()
1091 endif
1092
1093 if clang_supports_bpf or bpf_gcc_found
1094 # Debian installs this in /usr/sbin/ which is not in $PATH.
1095 # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian.
1096 # We use 'bpftool gen object' subcommand for bpftool strip, it was added by d80b2fcbe0a023619e0fc73112f2a02c2662f6ab (v5.13).
1097 bpftool = find_program('bpftool',
1098 '/usr/sbin/bpftool',
1099 required : false,
1100 version : '>= 5.13.0')
1101
1102 if bpftool.found()
1103 bpftool_strip = true
1104 deps_found = true
1105 else
1106 bpftool_strip = false
1107 # We require the 'bpftool gen skeleton' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6).
1108 bpftool = find_program('bpftool',
1109 '/usr/sbin/bpftool',
1110 required : bpf_framework_required,
1111 version : '>= 5.6.0')
1112 endif
1113
1114 # We use `llvm-strip` as a fallback if `bpftool gen object` strip support is not available.
1115 if not bpftool_strip and bpftool.found() and clang_supports_bpf
1116 if not meson.is_cross_build()
1117 llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip',
1118 check : true).stdout().strip()
1119 else
1120 llvm_strip_bin = 'llvm-strip'
1121 endif
1122 llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0')
1123 deps_found = llvm_strip.found()
1124 endif
1125 endif
1126
1127 # Can build BPF program from source code in restricted C
1128 conf.set10('BPF_FRAMEWORK', deps_found)
1129 endif
1130
1131 libmount = dependency('mount',
1132 version : fuzzer_build ? '>= 0' : '>= 2.30')
1133
1134 want_libfdisk = get_option('fdisk')
1135 if want_libfdisk != 'false' and not skip_deps
1136 libfdisk = dependency('fdisk',
1137 version : '>= 2.32',
1138 required : want_libfdisk == 'true')
1139 have = libfdisk.found()
1140 else
1141 have = false
1142 libfdisk = []
1143 endif
1144 conf.set10('HAVE_LIBFDISK', have)
1145
1146 want_pwquality = get_option('pwquality')
1147 if want_pwquality != 'false' and not skip_deps
1148 libpwquality = dependency('pwquality', required : want_pwquality == 'true')
1149 have = libpwquality.found()
1150 else
1151 have = false
1152 libpwquality = []
1153 endif
1154 conf.set10('HAVE_PWQUALITY', have)
1155
1156 want_seccomp = get_option('seccomp')
1157 if want_seccomp != 'false' and not skip_deps
1158 libseccomp = dependency('libseccomp',
1159 version : '>= 2.3.1',
1160 required : want_seccomp == 'true')
1161 have = libseccomp.found()
1162 else
1163 have = false
1164 libseccomp = []
1165 endif
1166 conf.set10('HAVE_SECCOMP', have)
1167
1168 want_selinux = get_option('selinux')
1169 if want_selinux != 'false' and not skip_deps
1170 libselinux = dependency('libselinux',
1171 version : '>= 2.1.9',
1172 required : want_selinux == 'true')
1173 have = libselinux.found()
1174 else
1175 have = false
1176 libselinux = []
1177 endif
1178 conf.set10('HAVE_SELINUX', have)
1179
1180 want_apparmor = get_option('apparmor')
1181 if want_apparmor != 'false' and not skip_deps
1182 libapparmor = dependency('libapparmor',
1183 version : '>= 2.13',
1184 required : want_apparmor == 'true')
1185 have = libapparmor.found()
1186 else
1187 have = false
1188 libapparmor = []
1189 endif
1190 conf.set10('HAVE_APPARMOR', have)
1191
1192 have = get_option('smack') and get_option('smack-run-label') != ''
1193 conf.set10('HAVE_SMACK_RUN_LABEL', have)
1194 if have
1195 conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
1196 endif
1197
1198 have = get_option('smack') and get_option('smack-default-process-label') != ''
1199 if have
1200 conf.set_quoted('SMACK_DEFAULT_PROCESS_LABEL', get_option('smack-default-process-label'))
1201 endif
1202
1203 want_polkit = get_option('polkit')
1204 install_polkit = false
1205 install_polkit_pkla = false
1206 if want_polkit != 'false' and not skip_deps
1207 install_polkit = true
1208
1209 libpolkit = dependency('polkit-gobject-1',
1210 required : false)
1211 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
1212 message('Old polkit detected, will install pkla files')
1213 install_polkit_pkla = true
1214 endif
1215 endif
1216 conf.set10('ENABLE_POLKIT', install_polkit)
1217
1218 want_acl = get_option('acl')
1219 if want_acl != 'false' and not skip_deps
1220 libacl = cc.find_library('acl', required : want_acl == 'true')
1221 have = libacl.found()
1222 else
1223 have = false
1224 libacl = []
1225 endif
1226 conf.set10('HAVE_ACL', have)
1227
1228 want_audit = get_option('audit')
1229 if want_audit != 'false' and not skip_deps
1230 libaudit = dependency('audit', required : want_audit == 'true')
1231 have = libaudit.found()
1232 else
1233 have = false
1234 libaudit = []
1235 endif
1236 conf.set10('HAVE_AUDIT', have)
1237
1238 want_blkid = get_option('blkid')
1239 if want_blkid != 'false' and not skip_deps
1240 libblkid = dependency('blkid', required : want_blkid == 'true')
1241 have = libblkid.found()
1242
1243 conf.set10('HAVE_BLKID_PROBE_SET_HINT',
1244 have and cc.has_function('blkid_probe_set_hint', dependencies : libblkid))
1245 else
1246 have = false
1247 libblkid = []
1248 endif
1249 conf.set10('HAVE_BLKID', have)
1250
1251 want_kmod = get_option('kmod')
1252 if want_kmod != 'false' and not skip_deps
1253 libkmod = dependency('libkmod',
1254 version : '>= 15',
1255 required : want_kmod == 'true')
1256 have = libkmod.found()
1257 else
1258 have = false
1259 libkmod = []
1260 endif
1261 conf.set10('HAVE_KMOD', have)
1262
1263 want_pam = get_option('pam')
1264 if want_pam != 'false' and not skip_deps
1265 libpam = cc.find_library('pam', required : want_pam == 'true')
1266 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1267 have = libpam.found() and libpam_misc.found()
1268 else
1269 have = false
1270 libpam = []
1271 libpam_misc = []
1272 endif
1273 conf.set10('HAVE_PAM', have)
1274
1275 want_microhttpd = get_option('microhttpd')
1276 if want_microhttpd != 'false' and not skip_deps
1277 libmicrohttpd = dependency('libmicrohttpd',
1278 version : '>= 0.9.33',
1279 required : want_microhttpd == 'true')
1280 have = libmicrohttpd.found()
1281 else
1282 have = false
1283 libmicrohttpd = []
1284 endif
1285 conf.set10('HAVE_MICROHTTPD', have)
1286
1287 want_libcryptsetup = get_option('libcryptsetup')
1288 want_libcryptsetup_plugins = get_option('libcryptsetup-plugins')
1289
1290 if want_libcryptsetup_plugins == 'true' and want_libcryptsetup == 'false'
1291 error('libcryptsetup-plugins can not be requested without libcryptsetup')
1292 endif
1293
1294 if want_libcryptsetup != 'false' and not skip_deps
1295 libcryptsetup = dependency('libcryptsetup',
1296 version : want_libcryptsetup_plugins == 'true' ? '>= 2.4.0' : '>= 2.0.1',
1297 required : want_libcryptsetup == 'true' or want_libcryptsetup_plugins == 'true')
1298 have = libcryptsetup.found()
1299
1300 foreach ident : ['crypt_set_metadata_size',
1301 'crypt_activate_by_signed_key',
1302 'crypt_token_max']
1303 have_ident = have and cc.has_function(
1304 ident,
1305 prefix : '#include <libcryptsetup.h>',
1306 dependencies : libcryptsetup)
1307 conf.set10('HAVE_' + ident.to_upper(), have_ident)
1308 endforeach
1309 else
1310 have = false
1311 libcryptsetup = []
1312 endif
1313 conf.set10('HAVE_LIBCRYPTSETUP', have)
1314
1315 if want_libcryptsetup_plugins != 'false' and not skip_deps
1316 have = (cc.has_function(
1317 'crypt_activate_by_token_pin',
1318 prefix : '#include <libcryptsetup.h>',
1319 dependencies : libcryptsetup) and
1320 cc.has_function(
1321 'crypt_token_external_path',
1322 prefix : '#include <libcryptsetup.h>',
1323 dependencies : libcryptsetup))
1324 else
1325 have = false
1326 endif
1327 conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have)
1328
1329 want_libcurl = get_option('libcurl')
1330 if want_libcurl != 'false' and not skip_deps
1331 libcurl = dependency('libcurl',
1332 version : '>= 7.32.0',
1333 required : want_libcurl == 'true')
1334 have = libcurl.found()
1335 else
1336 have = false
1337 libcurl = []
1338 endif
1339 conf.set10('HAVE_LIBCURL', have)
1340 conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
1341
1342 want_libidn = get_option('libidn')
1343 want_libidn2 = get_option('libidn2')
1344 if want_libidn == 'true' and want_libidn2 == 'true'
1345 error('libidn and libidn2 cannot be requested simultaneously')
1346 endif
1347
1348 if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps
1349 libidn = dependency('libidn2',
1350 required : want_libidn2 == 'true')
1351 have = libidn.found()
1352 else
1353 have = false
1354 libidn = []
1355 endif
1356 conf.set10('HAVE_LIBIDN2', have)
1357 if not have and want_libidn != 'false' and not skip_deps
1358 # libidn is used for both libidn and libidn2 objects
1359 libidn = dependency('libidn',
1360 required : want_libidn == 'true')
1361 have = libidn.found()
1362 else
1363 have = false
1364 endif
1365 conf.set10('HAVE_LIBIDN', have)
1366
1367 want_libiptc = get_option('libiptc')
1368 if want_libiptc != 'false' and not skip_deps
1369 libiptc = dependency('libiptc',
1370 required : want_libiptc == 'true')
1371 have = libiptc.found()
1372 else
1373 have = false
1374 libiptc = []
1375 endif
1376 conf.set10('HAVE_LIBIPTC', have)
1377
1378 want_qrencode = get_option('qrencode')
1379 if want_qrencode != 'false' and not skip_deps
1380 libqrencode = dependency('libqrencode',
1381 version : '>= 4',
1382 required : want_qrencode == 'true')
1383 have = libqrencode.found()
1384 else
1385 have = false
1386 libqrencode = []
1387 endif
1388 conf.set10('HAVE_QRENCODE', have)
1389
1390 want_gcrypt = get_option('gcrypt')
1391 if want_gcrypt != 'false' and not skip_deps
1392 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1393 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1394 have = libgcrypt.found() and libgpg_error.found()
1395 else
1396 have = false
1397 endif
1398 if not have
1399 # link to neither of the libs if one is not found
1400 libgcrypt = []
1401 libgpg_error = []
1402 endif
1403 conf.set10('HAVE_GCRYPT', have)
1404
1405 want_gnutls = get_option('gnutls')
1406 if want_gnutls != 'false' and not skip_deps
1407 libgnutls = dependency('gnutls',
1408 version : '>= 3.1.4',
1409 required : want_gnutls == 'true')
1410 have = libgnutls.found()
1411 else
1412 have = false
1413 libgnutls = []
1414 endif
1415 conf.set10('HAVE_GNUTLS', have)
1416
1417 want_openssl = get_option('openssl')
1418 if want_openssl != 'false' and not skip_deps
1419 libopenssl = dependency('openssl',
1420 version : '>= 1.1.0',
1421 required : want_openssl == 'true')
1422 have = libopenssl.found()
1423 else
1424 have = false
1425 libopenssl = []
1426 endif
1427 conf.set10('HAVE_OPENSSL', have)
1428
1429 want_p11kit = get_option('p11kit')
1430 if want_p11kit != 'false' and not skip_deps
1431 libp11kit = dependency('p11-kit-1',
1432 version : '>= 0.23.3',
1433 required : want_p11kit == 'true')
1434 have = libp11kit.found()
1435 else
1436 have = false
1437 libp11kit = []
1438 endif
1439 conf.set10('HAVE_P11KIT', have)
1440
1441 want_libfido2 = get_option('libfido2')
1442 if want_libfido2 != 'false' and not skip_deps
1443 libfido2 = dependency('libfido2',
1444 required : want_libfido2 == 'true')
1445 have = libfido2.found()
1446 else
1447 have = false
1448 libfido2 = []
1449 endif
1450 conf.set10('HAVE_LIBFIDO2', have)
1451
1452 want_tpm2 = get_option('tpm2')
1453 if want_tpm2 != 'false' and not skip_deps
1454 tpm2 = dependency('tss2-esys tss2-rc tss2-mu',
1455 required : want_tpm2 == 'true')
1456 have = tpm2.found()
1457 else
1458 have = false
1459 tpm2 = []
1460 endif
1461 conf.set10('HAVE_TPM2', have)
1462
1463 want_elfutils = get_option('elfutils')
1464 if want_elfutils != 'false' and not skip_deps
1465 libdw = dependency('libdw',
1466 required : want_elfutils == 'true')
1467 have = libdw.found()
1468
1469 # New in elfutils 0.177
1470 conf.set10('HAVE_DWELF_ELF_E_MACHINE_STRING',
1471 have and cc.has_function('dwelf_elf_e_machine_string', dependencies : libdw))
1472 else
1473 have = false
1474 libdw = []
1475 endif
1476 conf.set10('HAVE_ELFUTILS', have)
1477
1478 want_zlib = get_option('zlib')
1479 if want_zlib != 'false' and not skip_deps
1480 libz = dependency('zlib',
1481 required : want_zlib == 'true')
1482 have = libz.found()
1483 else
1484 have = false
1485 libz = []
1486 endif
1487 conf.set10('HAVE_ZLIB', have)
1488
1489 want_bzip2 = get_option('bzip2')
1490 if want_bzip2 != 'false' and not skip_deps
1491 libbzip2 = cc.find_library('bz2',
1492 required : want_bzip2 == 'true')
1493 have = libbzip2.found()
1494 else
1495 have = false
1496 libbzip2 = []
1497 endif
1498 conf.set10('HAVE_BZIP2', have)
1499
1500 want_xz = get_option('xz')
1501 if want_xz != 'false' and not skip_deps
1502 libxz = dependency('liblzma',
1503 required : want_xz == 'true')
1504 have_xz = libxz.found()
1505 else
1506 have_xz = false
1507 libxz = []
1508 endif
1509 conf.set10('HAVE_XZ', have_xz)
1510
1511 want_lz4 = get_option('lz4')
1512 if want_lz4 != 'false' and not skip_deps
1513 liblz4 = dependency('liblz4',
1514 version : '>= 1.3.0',
1515 required : want_lz4 == 'true')
1516 have_lz4 = liblz4.found()
1517 else
1518 have_lz4 = false
1519 liblz4 = []
1520 endif
1521 conf.set10('HAVE_LZ4', have_lz4)
1522
1523 want_zstd = get_option('zstd')
1524 if want_zstd != 'false' and not skip_deps
1525 libzstd = dependency('libzstd',
1526 required : want_zstd == 'true',
1527 version : '>= 1.4.0')
1528 have_zstd = libzstd.found()
1529 else
1530 have_zstd = false
1531 libzstd = []
1532 endif
1533 conf.set10('HAVE_ZSTD', have_zstd)
1534
1535 conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
1536
1537 compression = get_option('default-compression')
1538 if compression == 'auto'
1539 if have_zstd
1540 compression = 'zstd'
1541 elif have_lz4
1542 compression = 'lz4'
1543 elif have_xz
1544 compression = 'xz'
1545 else
1546 compression = 'none'
1547 endif
1548 elif compression == 'zstd' and not have_zstd
1549 error('default-compression=zstd requires zstd')
1550 elif compression == 'lz4' and not have_lz4
1551 error('default-compression=lz4 requires lz4')
1552 elif compression == 'xz' and not have_xz
1553 error('default-compression=xz requires xz')
1554 endif
1555 conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper()))
1556
1557 want_xkbcommon = get_option('xkbcommon')
1558 if want_xkbcommon != 'false' and not skip_deps
1559 libxkbcommon = dependency('xkbcommon',
1560 version : '>= 0.3.0',
1561 required : want_xkbcommon == 'true')
1562 have = libxkbcommon.found()
1563 else
1564 have = false
1565 libxkbcommon = []
1566 endif
1567 conf.set10('HAVE_XKBCOMMON', have)
1568
1569 want_pcre2 = get_option('pcre2')
1570 if want_pcre2 != 'false' and not skip_deps
1571 libpcre2 = dependency('libpcre2-8',
1572 required : want_pcre2 == 'true')
1573 have = libpcre2.found()
1574 else
1575 have = false
1576 libpcre2 = []
1577 endif
1578 conf.set10('HAVE_PCRE2', have)
1579
1580 want_glib = get_option('glib')
1581 if want_glib != 'false' and not skip_deps
1582 libglib = dependency('glib-2.0',
1583 version : '>= 2.22.0',
1584 required : want_glib == 'true')
1585 libgobject = dependency('gobject-2.0',
1586 version : '>= 2.22.0',
1587 required : want_glib == 'true')
1588 libgio = dependency('gio-2.0',
1589 required : want_glib == 'true')
1590 have = libglib.found() and libgobject.found() and libgio.found()
1591 else
1592 have = false
1593 libglib = []
1594 libgobject = []
1595 libgio = []
1596 endif
1597 conf.set10('HAVE_GLIB', have)
1598
1599 want_dbus = get_option('dbus')
1600 if want_dbus != 'false' and not skip_deps
1601 libdbus = dependency('dbus-1',
1602 version : '>= 1.3.2',
1603 required : want_dbus == 'true')
1604 have = libdbus.found()
1605 else
1606 have = false
1607 libdbus = []
1608 endif
1609 conf.set10('HAVE_DBUS', have)
1610
1611 dbusdatadir = datadir / 'dbus-1'
1612 if conf.get('HAVE_DBUS') == 1
1613 dbusdatadir = libdbus.get_variable(pkgconfig: 'datadir', default_value: datadir) / 'dbus-1'
1614 endif
1615
1616 dbuspolicydir = get_option('dbuspolicydir')
1617 if dbuspolicydir == ''
1618 dbuspolicydir = dbusdatadir / 'system.d'
1619 endif
1620
1621 dbussessionservicedir = get_option('dbussessionservicedir')
1622 if dbussessionservicedir == ''
1623 dbussessionservicedir = dbusdatadir / 'services'
1624 if conf.get('HAVE_DBUS') == 1
1625 dbussessionservicedir = libdbus.get_variable(pkgconfig: 'session_bus_services_dir', default_value: dbussessionservicedir)
1626 endif
1627 endif
1628
1629 dbussystemservicedir = get_option('dbussystemservicedir')
1630 if dbussystemservicedir == ''
1631 dbussystemservicedir = dbusdatadir / 'system-services'
1632 if conf.get('HAVE_DBUS') == 1
1633 dbussystemservicedir = libdbus.get_variable(pkgconfig: 'system_bus_services_dir', default_value: dbussystemservicedir)
1634 endif
1635 endif
1636
1637 dbus_interfaces_dir = get_option('dbus-interfaces-dir')
1638 if dbus_interfaces_dir == '' or dbus_interfaces_dir == 'yes'
1639 if meson.is_cross_build() and dbus_interfaces_dir != 'yes'
1640 dbus_interfaces_dir = 'no'
1641 warning('Exporting D-Bus interface XML files is disabled during cross build. Pass path or "yes" to force enable.')
1642 else
1643 dbus_interfaces_dir = dbusdatadir / 'interfaces'
1644 if conf.get('HAVE_DBUS') == 1
1645 dbus_interfaces_dir = libdbus.get_variable(pkgconfig: 'interfaces_dir', default_value: dbus_interfaces_dir)
1646 endif
1647 endif
1648 endif
1649
1650 # We support one or the other. If gcrypt is available, we assume it's there to
1651 # be used, and use it in preference.
1652 opt = get_option('cryptolib')
1653 if opt == 'openssl' and conf.get('HAVE_OPENSSL') == 0
1654 error('openssl requested as the default cryptolib, but not available')
1655 endif
1656 conf.set10('PREFER_OPENSSL',
1657 opt == 'openssl' or (opt == 'auto' and conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_GCRYPT') == 0))
1658 conf.set10('HAVE_OPENSSL_OR_GCRYPT',
1659 conf.get('HAVE_OPENSSL') == 1 or conf.get('HAVE_GCRYPT') == 1)
1660 lib_openssl_or_gcrypt = conf.get('PREFER_OPENSSL') == 1 ? [libopenssl] : [libgcrypt, libgpg_error]
1661
1662 dns_over_tls = get_option('dns-over-tls')
1663 if dns_over_tls != 'false'
1664 if dns_over_tls == 'gnutls' and conf.get('PREFER_OPENSSL') == 1
1665 error('Sorry, -Ddns-over-tls=gnutls is not supported when openssl is used as the cryptolib')
1666 endif
1667
1668 if dns_over_tls == 'gnutls'
1669 have_openssl = false
1670 else
1671 have_openssl = conf.get('HAVE_OPENSSL') == 1
1672 if dns_over_tls == 'openssl' and not have_openssl
1673 error('DNS-over-TLS support was requested with openssl, but dependencies are not available')
1674 endif
1675 endif
1676 if dns_over_tls == 'openssl' or have_openssl
1677 have_gnutls = false
1678 else
1679 have_gnutls = conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0')
1680 if dns_over_tls != 'auto' and not have_gnutls
1681 str = dns_over_tls == 'gnutls' ? ' with gnutls' : ''
1682 error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
1683 endif
1684 endif
1685 have = have_gnutls or have_openssl
1686 else
1687 have = false
1688 have_gnutls = false
1689 have_openssl = false
1690 endif
1691 conf.set10('ENABLE_DNS_OVER_TLS', have)
1692 conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1693 conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
1694
1695 default_dns_over_tls = get_option('default-dns-over-tls')
1696 if skip_deps
1697 default_dns_over_tls = 'no'
1698 endif
1699 if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
1700 message('default-dns-over-tls cannot be enabled or set to opportunistic when DNS-over-TLS support is disabled. Setting default-dns-over-tls to no.')
1701 default_dns_over_tls = 'no'
1702 endif
1703 conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1704 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
1705 conf.set_quoted('DEFAULT_DNS_OVER_TLS_MODE_STR', default_dns_over_tls)
1706
1707 default_mdns = get_option('default-mdns')
1708 conf.set('DEFAULT_MDNS_MODE',
1709 'RESOLVE_SUPPORT_' + default_mdns.to_upper())
1710 conf.set_quoted('DEFAULT_MDNS_MODE_STR', default_mdns)
1711
1712 default_llmnr = get_option('default-llmnr')
1713 conf.set('DEFAULT_LLMNR_MODE',
1714 'RESOLVE_SUPPORT_' + default_llmnr.to_upper())
1715 conf.set_quoted('DEFAULT_LLMNR_MODE_STR', default_llmnr)
1716
1717 want_repart = get_option('repart')
1718 if want_repart != 'false'
1719 have = conf.get('HAVE_LIBFDISK') == 1
1720 if want_repart == 'true' and not have
1721 error('repart support was requested, but dependencies are not available')
1722 endif
1723 else
1724 have = false
1725 endif
1726 conf.set10('ENABLE_REPART', have)
1727
1728 default_dnssec = get_option('default-dnssec')
1729 if skip_deps
1730 default_dnssec = 'no'
1731 endif
1732 if default_dnssec != 'no' and conf.get('HAVE_OPENSSL_OR_GCRYPT') == 0
1733 message('default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.')
1734 default_dnssec = 'no'
1735 endif
1736 conf.set('DEFAULT_DNSSEC_MODE',
1737 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1738 conf.set_quoted('DEFAULT_DNSSEC_MODE_STR', default_dnssec)
1739
1740 want_sysupdate = get_option('sysupdate')
1741 if want_sysupdate != 'false'
1742 have = (conf.get('HAVE_OPENSSL') == 1 and
1743 conf.get('HAVE_LIBFDISK') == 1)
1744 if want_sysupdate == 'true' and not have
1745 error('sysupdate support was requested, but dependencies are not available')
1746 endif
1747 else
1748 have = false
1749 endif
1750 conf.set10('ENABLE_SYSUPDATE', have)
1751
1752 want_importd = get_option('importd')
1753 if want_importd != 'false'
1754 have = (conf.get('HAVE_LIBCURL') == 1 and
1755 conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and
1756 conf.get('HAVE_ZLIB') == 1 and
1757 conf.get('HAVE_XZ') == 1)
1758 if want_importd == 'true' and not have
1759 error('importd support was requested, but dependencies are not available')
1760 endif
1761 else
1762 have = false
1763 endif
1764 conf.set10('ENABLE_IMPORTD', have)
1765
1766 want_kernel_install = get_option('kernel-install')
1767 conf.set10('ENABLE_KERNEL_INSTALL', want_kernel_install)
1768
1769 want_homed = get_option('homed')
1770 if want_homed != 'false'
1771 have = (conf.get('HAVE_OPENSSL') == 1 and
1772 conf.get('HAVE_LIBFDISK') == 1 and
1773 conf.get('HAVE_LIBCRYPTSETUP') == 1)
1774 if want_homed == 'true' and not have
1775 error('homed support was requested, but dependencies are not available')
1776 endif
1777 else
1778 have = false
1779 endif
1780 conf.set10('ENABLE_HOMED', have)
1781
1782 have = have and conf.get('HAVE_PAM') == 1
1783 conf.set10('ENABLE_PAM_HOME', have)
1784
1785 have = get_option('oomd')
1786 conf.set10('ENABLE_OOMD', have)
1787
1788 want_remote = get_option('remote')
1789 if want_remote != 'false'
1790 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1791 conf.get('HAVE_LIBCURL') == 1]
1792 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1793 # it's possible to build one without the other. Complain only if
1794 # support was explicitly requested. The auxiliary files like sysusers
1795 # config should be installed when any of the programs are built.
1796 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1797 error('remote support was requested, but dependencies are not available')
1798 endif
1799 have = have_deps[0] or have_deps[1]
1800 else
1801 have = false
1802 endif
1803 conf.set10('ENABLE_REMOTE', have)
1804
1805 foreach term : ['analyze',
1806 'backlight',
1807 'binfmt',
1808 'coredump',
1809 'efi',
1810 'environment-d',
1811 'firstboot',
1812 'gshadow',
1813 'hibernate',
1814 'hostnamed',
1815 'hwdb',
1816 'idn',
1817 'ima',
1818 'initrd',
1819 'compat-mutable-uid-boundaries',
1820 'nscd',
1821 'ldconfig',
1822 'localed',
1823 'logind',
1824 'machined',
1825 'networkd',
1826 'nss-myhostname',
1827 'nss-systemd',
1828 'portabled',
1829 'sysext',
1830 'pstore',
1831 'quotacheck',
1832 'randomseed',
1833 'resolve',
1834 'rfkill',
1835 'smack',
1836 'sysusers',
1837 'timedated',
1838 'timesyncd',
1839 'tmpfiles',
1840 'tpm',
1841 'userdb',
1842 'utmp',
1843 'vconsole',
1844 'xdg-autostart']
1845 have = get_option(term)
1846 name = 'ENABLE_' + term.underscorify().to_upper()
1847 conf.set10(name, have)
1848 endforeach
1849
1850 enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
1851
1852 foreach tuple : [['nss-mymachines', 'machined'],
1853 ['nss-resolve', 'resolve']]
1854 want = get_option(tuple[0])
1855 if want != 'false'
1856 have = get_option(tuple[1])
1857 if want == 'true' and not have
1858 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1859 endif
1860 else
1861 have = false
1862 endif
1863 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1864 conf.set10(name, have)
1865 endforeach
1866
1867 enable_nss = false
1868 foreach term : ['ENABLE_NSS_MYHOSTNAME',
1869 'ENABLE_NSS_MYMACHINES',
1870 'ENABLE_NSS_RESOLVE',
1871 'ENABLE_NSS_SYSTEMD']
1872 if conf.get(term) == 1
1873 enable_nss = true
1874 endif
1875 endforeach
1876 conf.set10('ENABLE_NSS', enable_nss)
1877
1878 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1879
1880 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1881
1882 ############################################################
1883
1884 tests = []
1885 fuzzers = []
1886 catalogs = []
1887
1888 ############################################################
1889
1890 # Include these now as they provide gnu-efi detection.
1891 subdir('src/fundamental')
1892 subdir('src/boot/efi')
1893
1894 ############################################################
1895
1896 generate_gperfs = find_program('tools/generate-gperfs.py')
1897 make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
1898 make_directive_index_py = find_program('tools/make-directive-index.py')
1899 make_man_index_py = find_program('tools/make-man-index.py')
1900 meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
1901 update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
1902 update_man_rules_py = find_program('tools/update-man-rules.py')
1903 update_hwdb_sh = find_program('tools/update-hwdb.sh')
1904 update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
1905 update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
1906 xml_helper_py = find_program('tools/xml_helper.py')
1907 export_dbus_interfaces_py = find_program('tools/dbus_exporter.py')
1908
1909 ############################################################
1910
1911 if get_option('b_coverage')
1912 add_project_arguments('-include', 'src/basic/coverage.h', language : 'c')
1913 endif
1914
1915 ############################################################
1916
1917 config_h = configure_file(
1918 output : 'config.h',
1919 configuration : conf)
1920
1921 add_project_arguments('-include', 'config.h', language : 'c')
1922
1923 jinja2_cmdline = [meson_render_jinja2, config_h, version_h]
1924
1925 ############################################################
1926
1927 # binaries that have --help and are intended for use by humans,
1928 # usually, but not always, installed in /bin.
1929 public_programs = []
1930
1931 # D-Bus introspection XML export
1932 dbus_programs = []
1933
1934 basic_includes = include_directories(
1935 'src/basic',
1936 'src/fundamental',
1937 'src/systemd',
1938 '.')
1939
1940 libsystemd_includes = [basic_includes, include_directories(
1941 'src/libsystemd/sd-bus',
1942 'src/libsystemd/sd-device',
1943 'src/libsystemd/sd-event',
1944 'src/libsystemd/sd-hwdb',
1945 'src/libsystemd/sd-id128',
1946 'src/libsystemd/sd-journal',
1947 'src/libsystemd/sd-netlink',
1948 'src/libsystemd/sd-network',
1949 'src/libsystemd/sd-resolve')]
1950
1951 includes = [libsystemd_includes, include_directories('src/shared')]
1952
1953 subdir('po')
1954 subdir('catalog')
1955 subdir('src/basic')
1956 subdir('src/libsystemd')
1957 subdir('src/shared')
1958 subdir('src/udev')
1959 subdir('src/libudev')
1960 subdir('src/cryptsetup/cryptsetup-tokens')
1961
1962 alias_target('devel', libsystemd_pc, libudev_pc)
1963
1964 libsystemd = shared_library(
1965 'systemd',
1966 version : libsystemd_version,
1967 include_directories : libsystemd_includes,
1968 link_args : ['-shared',
1969 '-Wl,--version-script=' + libsystemd_sym_path],
1970 link_with : [libbasic,
1971 libbasic_gcrypt,
1972 libbasic_compress],
1973 link_whole : [libsystemd_static],
1974 dependencies : [threads,
1975 librt],
1976 link_depends : libsystemd_sym,
1977 install : true,
1978 install_tag: 'libsystemd',
1979 install_dir : rootlibdir)
1980
1981 alias_target('libsystemd', libsystemd)
1982
1983 install_libsystemd_static = static_library(
1984 'systemd',
1985 libsystemd_sources,
1986 basic_sources,
1987 basic_gcrypt_sources,
1988 basic_compress_sources,
1989 fundamental_sources,
1990 include_directories : libsystemd_includes,
1991 build_by_default : static_libsystemd != 'false',
1992 install : static_libsystemd != 'false',
1993 install_tag: 'libsystemd',
1994 install_dir : rootlibdir,
1995 pic : static_libsystemd_pic,
1996 dependencies : [threads,
1997 librt,
1998 libxz,
1999 libzstd,
2000 liblz4,
2001 libdl,
2002 libcap,
2003 libblkid,
2004 libmount,
2005 libgcrypt,
2006 libopenssl],
2007 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
2008
2009 libudev = shared_library(
2010 'udev',
2011 version : libudev_version,
2012 include_directories : includes,
2013 link_args : ['-shared',
2014 '-Wl,--version-script=' + libudev_sym_path],
2015 link_with : [libsystemd_static, libshared_static],
2016 link_whole : libudev_basic,
2017 dependencies : [threads],
2018 link_depends : libudev_sym,
2019 install : true,
2020 install_tag: 'libudev',
2021 install_dir : rootlibdir)
2022
2023 alias_target('libudev', libudev)
2024
2025 install_libudev_static = static_library(
2026 'udev',
2027 basic_sources,
2028 fundamental_sources,
2029 shared_sources,
2030 libsystemd_sources,
2031 libudev_sources,
2032 include_directories : includes,
2033 build_by_default : static_libudev != 'false',
2034 install : static_libudev != 'false',
2035 install_tag: 'libudev',
2036 install_dir : rootlibdir,
2037 link_depends : libudev_sym,
2038 dependencies : libshared_deps + [libmount],
2039 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
2040 pic : static_libudev_pic)
2041
2042 if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
2043 if conf.get('HAVE_TPM2') == 1
2044 cryptsetup_token_systemd_tpm2 = shared_library(
2045 'cryptsetup-token-systemd-tpm2',
2046 cryptsetup_token_systemd_tpm2_sources,
2047 include_directories : includes,
2048 link_args : ['-shared',
2049 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2050 link_with : [lib_cryptsetup_token_common,
2051 libshared],
2052 dependencies : [libcryptsetup,
2053 tpm2,
2054 versiondep],
2055 link_depends : cryptsetup_token_sym,
2056 install_rpath : rootpkglibdir,
2057 install : true,
2058 install_dir : libcryptsetup_plugins_dir)
2059 endif
2060
2061 if conf.get('HAVE_LIBFIDO2') == 1
2062 cryptsetup_token_systemd_fido2 = shared_library(
2063 'cryptsetup-token-systemd-fido2',
2064 cryptsetup_token_systemd_fido2_sources,
2065 include_directories : includes,
2066 link_args : ['-shared',
2067 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2068 link_with : [lib_cryptsetup_token_common,
2069 libshared],
2070 dependencies : [libcryptsetup,
2071 libfido2,
2072 versiondep],
2073 link_depends : cryptsetup_token_sym,
2074 install_rpath : rootpkglibdir,
2075 install : true,
2076 install_dir : libcryptsetup_plugins_dir)
2077 endif
2078
2079 if conf.get('HAVE_P11KIT') == 1
2080 cryptsetup_token_systemd_pkcs11 = shared_library(
2081 'cryptsetup-token-systemd-pkcs11',
2082 cryptsetup_token_systemd_pkcs11_sources,
2083 include_directories : includes,
2084 link_args : ['-shared',
2085 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2086 link_with : [lib_cryptsetup_token_common,
2087 libshared],
2088 dependencies : [libcryptsetup,
2089 libp11kit,
2090 versiondep],
2091 link_depends : cryptsetup_token_sym,
2092 install_rpath : rootpkglibdir,
2093 install : true,
2094 install_dir : libcryptsetup_plugins_dir)
2095 endif
2096 endif
2097
2098 ############################################################
2099
2100 # systemd-analyze requires 'libcore'
2101 subdir('src/core')
2102 # systemd-journal-remote requires 'libjournal_core'
2103 subdir('src/journal')
2104 # systemd-networkd requires 'libsystemd_network'
2105 subdir('src/libsystemd-network')
2106
2107 subdir('src/analyze')
2108 subdir('src/busctl')
2109 subdir('src/coredump')
2110 subdir('src/cryptenroll')
2111 subdir('src/cryptsetup')
2112 subdir('src/home')
2113 subdir('src/hostname')
2114 subdir('src/import')
2115 subdir('src/journal-remote')
2116 subdir('src/kernel-install')
2117 subdir('src/locale')
2118 subdir('src/login')
2119 subdir('src/machine')
2120 subdir('src/network')
2121 subdir('src/nspawn')
2122 subdir('src/oom')
2123 subdir('src/partition')
2124 subdir('src/portable')
2125 subdir('src/pstore')
2126 subdir('src/resolve')
2127 subdir('src/rpm')
2128 subdir('src/shutdown')
2129 subdir('src/sysext')
2130 subdir('src/systemctl')
2131 subdir('src/sysupdate')
2132 subdir('src/timedate')
2133 subdir('src/timesync')
2134 subdir('src/tmpfiles')
2135 subdir('src/userdb')
2136 subdir('src/xdg-autostart-generator')
2137
2138 subdir('src/systemd')
2139
2140 subdir('src/test')
2141 subdir('src/fuzz')
2142 subdir('rules.d')
2143 subdir('test')
2144
2145 ############################################################
2146
2147 # only static linking apart from libdl, to make sure that the
2148 # module is linked to all libraries that it uses.
2149 test_dlopen = executable(
2150 'test-dlopen',
2151 test_dlopen_c,
2152 include_directories : includes,
2153 link_with : [libbasic],
2154 dependencies : [libdl],
2155 build_by_default : want_tests != 'false')
2156
2157 foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
2158 ['systemd', 'ENABLE_NSS_SYSTEMD', ['nss-systemd.h', 'userdb-glue.c', 'userdb-glue.h']],
2159 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
2160 ['resolve', 'ENABLE_NSS_RESOLVE', [], resolve_includes]]
2161
2162 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
2163 if condition
2164 module = tuple[0]
2165
2166 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
2167 version_script_arg = project_source_root / sym
2168
2169 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
2170 if tuple.length() > 2
2171 foreach s : tuple[2]
2172 sources += ['src/nss-@0@/@1@'.format(module, s)]
2173 endforeach
2174 endif
2175
2176 incs = tuple.length() > 3 ? tuple[3] : includes
2177
2178 nss = shared_library(
2179 'nss_' + module,
2180 sources,
2181 version : '2',
2182 include_directories : incs,
2183 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
2184 link_args : ['-Wl,-z,nodelete',
2185 '-shared',
2186 '-Wl,--version-script=' + version_script_arg],
2187 link_with : [libsystemd_static,
2188 libshared_static,
2189 libbasic],
2190 dependencies : [threads,
2191 librt],
2192 link_depends : sym,
2193 install : true,
2194 install_tag : 'nss',
2195 install_dir : rootlibdir)
2196
2197 # We cannot use shared_module because it does not support version suffix.
2198 # Unfortunately shared_library insists on creating the symlink…
2199 meson.add_install_script('sh', '-c',
2200 'rm $DESTDIR@0@/libnss_@1@.so'
2201 .format(rootlibdir, module),
2202 install_tag : 'nss'
2203 )
2204
2205 if want_tests != 'false'
2206 test('dlopen-nss_' + module,
2207 test_dlopen,
2208 # path to dlopen must include a slash
2209 args : nss.full_path(),
2210 depends : nss)
2211 endif
2212 endif
2213 endforeach
2214
2215 ############################################################
2216
2217 exe = executable(
2218 'systemd',
2219 systemd_sources,
2220 include_directories : includes,
2221 link_with : [libcore,
2222 libshared],
2223 dependencies : [versiondep,
2224 libseccomp],
2225 install_rpath : rootpkglibdir,
2226 install : true,
2227 install_dir : rootlibexecdir)
2228 dbus_programs += exe
2229 public_programs += exe
2230
2231 meson.add_install_script(meson_make_symlink,
2232 rootlibexecdir / 'systemd',
2233 rootsbindir / 'init')
2234
2235 exe = executable(
2236 'systemd-analyze',
2237 systemd_analyze_sources,
2238 include_directories : core_includes,
2239 link_with : [libcore,
2240 libshared],
2241 dependencies : [versiondep,
2242 libseccomp],
2243 install_rpath : rootpkglibdir,
2244 install : conf.get('ENABLE_ANALYZE') == 1)
2245 public_programs += exe
2246
2247 if want_tests != 'false'
2248 test('test-compare-versions',
2249 test_compare_versions_sh,
2250 args : exe.full_path())
2251 endif
2252
2253 executable(
2254 'systemd-journald',
2255 systemd_journald_sources,
2256 include_directories : includes,
2257 link_with : [libjournal_core,
2258 libshared],
2259 dependencies : [threads,
2260 libxz,
2261 liblz4,
2262 libselinux,
2263 libzstd],
2264 install_rpath : rootpkglibdir,
2265 install : true,
2266 install_dir : rootlibexecdir)
2267
2268 public_programs += executable(
2269 'systemd-cat',
2270 systemd_cat_sources,
2271 include_directories : includes,
2272 link_with : [libjournal_core,
2273 libshared],
2274 dependencies : [threads],
2275 install_rpath : rootpkglibdir,
2276 install : true)
2277
2278 if get_option('link-journalctl-shared')
2279 journalctl_link_with = [libshared]
2280 else
2281 journalctl_link_with = [libsystemd_static,
2282 libshared_static,
2283 libbasic_gcrypt]
2284 endif
2285
2286 public_programs += executable(
2287 'journalctl',
2288 journalctl_sources,
2289 include_directories : includes,
2290 link_with : [journalctl_link_with],
2291 dependencies : [threads,
2292 libdl,
2293 libxz,
2294 liblz4,
2295 libzstd,
2296 libdl],
2297 install_rpath : rootpkglibdir,
2298 install : true,
2299 install_dir : rootbindir)
2300
2301 executable(
2302 'systemd-getty-generator',
2303 'src/getty-generator/getty-generator.c',
2304 include_directories : includes,
2305 link_with : [libshared],
2306 install_rpath : rootpkglibdir,
2307 install : true,
2308 install_dir : systemgeneratordir)
2309
2310 executable(
2311 'systemd-debug-generator',
2312 'src/debug-generator/debug-generator.c',
2313 include_directories : includes,
2314 link_with : [libshared],
2315 install_rpath : rootpkglibdir,
2316 install : true,
2317 install_dir : systemgeneratordir)
2318
2319 executable(
2320 'systemd-run-generator',
2321 'src/run-generator/run-generator.c',
2322 include_directories : includes,
2323 link_with : [libshared],
2324 install_rpath : rootpkglibdir,
2325 install : true,
2326 install_dir : systemgeneratordir)
2327
2328 exe = executable(
2329 'systemd-fstab-generator',
2330 'src/fstab-generator/fstab-generator.c',
2331 include_directories : includes,
2332 link_with : [libshared],
2333 install_rpath : rootpkglibdir,
2334 install : true,
2335 install_dir : systemgeneratordir)
2336
2337 meson.add_install_script(meson_make_symlink,
2338 systemgeneratordir / 'systemd-fstab-generator',
2339 rootlibexecdir / 'systemd-sysroot-fstab-check')
2340
2341 if want_tests != 'false'
2342 test('test-fstab-generator',
2343 test_fstab_generator_sh,
2344 # https://github.com/mesonbuild/meson/issues/2681
2345 args : exe.full_path(),
2346 depends : exe)
2347 endif
2348
2349 if conf.get('ENABLE_ENVIRONMENT_D') == 1
2350 executable(
2351 '30-systemd-environment-d-generator',
2352 'src/environment-d-generator/environment-d-generator.c',
2353 include_directories : includes,
2354 link_with : [libshared],
2355 install_rpath : rootpkglibdir,
2356 install : true,
2357 install_dir : userenvgeneratordir)
2358
2359 meson.add_install_script(meson_make_symlink,
2360 sysconfdir / 'environment',
2361 environmentdir / '99-environment.conf')
2362 endif
2363
2364 if conf.get('ENABLE_HIBERNATE') == 1
2365 executable(
2366 'systemd-hibernate-resume-generator',
2367 'src/hibernate-resume/hibernate-resume-generator.c',
2368 include_directories : includes,
2369 link_with : [libshared],
2370 install_rpath : rootpkglibdir,
2371 install : true,
2372 install_dir : systemgeneratordir)
2373
2374 executable(
2375 'systemd-hibernate-resume',
2376 'src/hibernate-resume/hibernate-resume.c',
2377 include_directories : includes,
2378 link_with : [libshared],
2379 install_rpath : rootpkglibdir,
2380 install : true,
2381 install_dir : rootlibexecdir)
2382 endif
2383
2384 if conf.get('HAVE_BLKID') == 1
2385 executable(
2386 'systemd-gpt-auto-generator',
2387 'src/gpt-auto-generator/gpt-auto-generator.c',
2388 include_directories : includes,
2389 link_with : [libshared],
2390 dependencies : libblkid,
2391 install_rpath : rootpkglibdir,
2392 install : true,
2393 install_dir : systemgeneratordir)
2394
2395 public_programs += executable(
2396 'systemd-dissect',
2397 'src/dissect/dissect.c',
2398 include_directories : includes,
2399 link_with : [libshared],
2400 install_rpath : rootpkglibdir,
2401 install : true)
2402 endif
2403
2404 if conf.get('ENABLE_RESOLVE') == 1
2405 dbus_programs += executable(
2406 'systemd-resolved',
2407 systemd_resolved_sources,
2408 include_directories : resolve_includes,
2409 link_with : [libshared,
2410 libbasic_gcrypt,
2411 libsystemd_resolve_core],
2412 dependencies : systemd_resolved_dependencies,
2413 install_rpath : rootpkglibdir,
2414 install : true,
2415 install_dir : rootlibexecdir)
2416
2417 public_programs += executable(
2418 'resolvectl',
2419 resolvectl_sources,
2420 include_directories : includes,
2421 link_with : [libshared,
2422 libbasic_gcrypt,
2423 libsystemd_resolve_core],
2424 dependencies : [threads,
2425 lib_openssl_or_gcrypt,
2426 libm,
2427 libidn],
2428 install_rpath : rootpkglibdir,
2429 install : true)
2430
2431 meson.add_install_script(meson_make_symlink,
2432 bindir / 'resolvectl',
2433 rootsbindir / 'resolvconf')
2434
2435 meson.add_install_script(meson_make_symlink,
2436 bindir / 'resolvectl',
2437 bindir / 'systemd-resolve')
2438 endif
2439
2440 if conf.get('ENABLE_LOGIND') == 1
2441 dbus_programs += executable(
2442 'systemd-logind',
2443 systemd_logind_sources,
2444 include_directories : includes,
2445 link_with : [liblogind_core,
2446 libshared],
2447 dependencies : [threads,
2448 libacl],
2449 install_rpath : rootpkglibdir,
2450 install : true,
2451 install_dir : rootlibexecdir)
2452
2453 public_programs += executable(
2454 'loginctl',
2455 loginctl_sources,
2456 include_directories : includes,
2457 link_with : [libshared],
2458 dependencies : [threads,
2459 liblz4,
2460 libxz,
2461 libzstd],
2462 install_rpath : rootpkglibdir,
2463 install : true,
2464 install_dir : rootbindir)
2465
2466 public_programs += executable(
2467 'systemd-inhibit',
2468 'src/login/inhibit.c',
2469 include_directories : includes,
2470 link_with : [libshared],
2471 install_rpath : rootpkglibdir,
2472 install : true,
2473 install_dir : rootbindir)
2474
2475 if conf.get('HAVE_PAM') == 1
2476 version_script_arg = project_source_root / pam_systemd_sym
2477 pam_systemd = shared_library(
2478 'pam_systemd',
2479 pam_systemd_c,
2480 name_prefix : '',
2481 include_directories : includes,
2482 link_args : ['-shared',
2483 '-Wl,--version-script=' + version_script_arg],
2484 link_with : [libsystemd_static,
2485 libshared_static],
2486 dependencies : [threads,
2487 libpam,
2488 libpam_misc],
2489 link_depends : pam_systemd_sym,
2490 install : true,
2491 install_tag : 'pam',
2492 install_dir : pamlibdir)
2493
2494 if want_tests != 'false'
2495 test('dlopen-pam_systemd',
2496 test_dlopen,
2497 # path to dlopen must include a slash
2498 args : pam_systemd.full_path(),
2499 depends : pam_systemd)
2500 endif
2501 endif
2502
2503 executable(
2504 'systemd-user-runtime-dir',
2505 user_runtime_dir_sources,
2506 include_directories : includes,
2507 link_with : [libshared],
2508 install_rpath : rootpkglibdir,
2509 install : true,
2510 install_dir : rootlibexecdir)
2511 endif
2512
2513 if conf.get('HAVE_PAM') == 1
2514 executable(
2515 'systemd-user-sessions',
2516 'src/user-sessions/user-sessions.c',
2517 include_directories : includes,
2518 link_with : [libshared],
2519 install_rpath : rootpkglibdir,
2520 install : true,
2521 install_dir : rootlibexecdir)
2522 endif
2523
2524 if conf.get('HAVE_BLKID') == 1 and conf.get('HAVE_GNU_EFI') == 1
2525 if get_option('link-boot-shared')
2526 boot_link_with = [libshared]
2527 else
2528 boot_link_with = [libsystemd_static, libshared_static]
2529 endif
2530
2531 public_programs += executable(
2532 'bootctl',
2533 'src/boot/bootctl.c',
2534 include_directories : includes,
2535 link_with : [boot_link_with],
2536 dependencies : [libblkid],
2537 install_rpath : rootpkglibdir,
2538 install : true)
2539
2540 public_programs += executable(
2541 'systemd-bless-boot',
2542 'src/boot/bless-boot.c',
2543 include_directories : includes,
2544 link_with : [boot_link_with],
2545 dependencies : [libblkid],
2546 install_rpath : rootpkglibdir,
2547 install : true,
2548 install_dir : rootlibexecdir)
2549
2550 executable(
2551 'systemd-bless-boot-generator',
2552 'src/boot/bless-boot-generator.c',
2553 include_directories : includes,
2554 link_with : [boot_link_with],
2555 install_rpath : rootpkglibdir,
2556 install : true,
2557 install_dir : systemgeneratordir)
2558
2559 if conf.get('HAVE_OPENSSL') == 1
2560 executable(
2561 'systemd-measure',
2562 'src/boot/measure.c',
2563 include_directories : includes,
2564 link_with : [libshared],
2565 dependencies : [libopenssl],
2566 install_rpath : rootpkglibdir,
2567 install : true,
2568 install_dir : rootlibexecdir)
2569 endif
2570 endif
2571
2572 executable(
2573 'systemd-boot-check-no-failures',
2574 'src/boot/boot-check-no-failures.c',
2575 include_directories : includes,
2576 link_with : [libshared],
2577 dependencies : [libblkid],
2578 install_rpath : rootpkglibdir,
2579 install : true,
2580 install_dir : rootlibexecdir)
2581
2582 public_programs += executable(
2583 'systemd-socket-activate',
2584 'src/activate/activate.c',
2585 include_directories : includes,
2586 link_with : [libshared],
2587 dependencies : [threads],
2588 install_rpath : rootpkglibdir,
2589 install : true)
2590
2591 systemctl = executable(
2592 'systemctl',
2593 systemctl_sources,
2594 include_directories : includes,
2595 link_with : systemctl_link_with,
2596 dependencies : [threads,
2597 libcap,
2598 libselinux,
2599 libxz,
2600 liblz4,
2601 libzstd],
2602 install_rpath : rootpkglibdir,
2603 install : true,
2604 install_dir : rootbindir)
2605 public_programs += systemctl
2606
2607 if conf.get('ENABLE_PORTABLED') == 1
2608 dbus_programs += executable(
2609 'systemd-portabled',
2610 systemd_portabled_sources,
2611 include_directories : includes,
2612 link_with : [libshared],
2613 dependencies : [threads, libselinux],
2614 install_rpath : rootpkglibdir,
2615 install : true,
2616 install_dir : rootlibexecdir)
2617
2618 public_programs += executable(
2619 'portablectl',
2620 'src/portable/portablectl.c',
2621 include_directories : includes,
2622 link_with : [libshared],
2623 dependencies : [threads],
2624 install_rpath : rootpkglibdir,
2625 install : true,
2626 install_dir : rootbindir)
2627 endif
2628
2629 if conf.get('ENABLE_SYSEXT') == 1
2630 public_programs += executable(
2631 'systemd-sysext',
2632 systemd_sysext_sources,
2633 include_directories : includes,
2634 link_with : [libshared],
2635 install_rpath : rootpkglibdir,
2636 install : true,
2637 install_dir : rootbindir)
2638 endif
2639
2640 if conf.get('ENABLE_USERDB') == 1
2641 executable(
2642 'systemd-userwork',
2643 systemd_userwork_sources,
2644 include_directories : includes,
2645 link_with : [libshared],
2646 dependencies : [threads],
2647 install_rpath : rootpkglibdir,
2648 install : true,
2649 install_dir : rootlibexecdir)
2650
2651 executable(
2652 'systemd-userdbd',
2653 systemd_userdbd_sources,
2654 include_directories : includes,
2655 link_with : [libshared],
2656 dependencies : [threads],
2657 install_rpath : rootpkglibdir,
2658 install : true,
2659 install_dir : rootlibexecdir)
2660
2661 public_programs += executable(
2662 'userdbctl',
2663 userdbctl_sources,
2664 include_directories : includes,
2665 link_with : [libshared],
2666 dependencies : [threads],
2667 install_rpath : rootpkglibdir,
2668 install : true)
2669 endif
2670
2671 if conf.get('ENABLE_HOMED') == 1
2672 executable(
2673 'systemd-homework',
2674 systemd_homework_sources,
2675 include_directories : includes,
2676 link_with : [libshared],
2677 dependencies : [threads,
2678 libblkid,
2679 libcrypt,
2680 libopenssl,
2681 libfdisk,
2682 libp11kit],
2683 install_rpath : rootpkglibdir,
2684 install : true,
2685 install_dir : rootlibexecdir)
2686
2687 dbus_programs += executable(
2688 'systemd-homed',
2689 systemd_homed_sources,
2690 include_directories : home_includes,
2691 link_with : [libshared],
2692 dependencies : [threads,
2693 libcrypt,
2694 libopenssl,
2695 libm],
2696 install_rpath : rootpkglibdir,
2697 install : true,
2698 install_dir : rootlibexecdir)
2699
2700 public_programs += executable(
2701 'homectl',
2702 homectl_sources,
2703 include_directories : includes,
2704 link_with : [libshared],
2705 dependencies : [threads,
2706 libcrypt,
2707 libopenssl,
2708 libp11kit,
2709 libdl],
2710 install_rpath : rootpkglibdir,
2711 install : true)
2712
2713 if conf.get('HAVE_PAM') == 1
2714 version_script_arg = project_source_root / pam_systemd_home_sym
2715 pam_systemd_home = shared_library(
2716 'pam_systemd_home',
2717 pam_systemd_home_c,
2718 name_prefix : '',
2719 include_directories : includes,
2720 link_args : ['-shared',
2721 '-Wl,--version-script=' + version_script_arg],
2722 link_with : [libsystemd_static,
2723 libshared_static],
2724 dependencies : [threads,
2725 libpam,
2726 libpam_misc,
2727 libcrypt],
2728 link_depends : pam_systemd_home_sym,
2729 install : true,
2730 install_tag : 'pam',
2731 install_dir : pamlibdir)
2732
2733 if want_tests != 'false'
2734 test('dlopen-pam_systemd_home',
2735 test_dlopen,
2736 # path to dlopen must include a slash
2737 args : pam_systemd_home.full_path(),
2738 depends : pam_systemd_home)
2739 endif
2740 endif
2741 endif
2742
2743 foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
2744 (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
2745 meson.add_install_script(meson_make_symlink,
2746 rootbindir / 'systemctl',
2747 rootsbindir / alias)
2748 endforeach
2749
2750 meson.add_install_script(meson_make_symlink,
2751 rootbindir / 'udevadm',
2752 rootlibexecdir / 'systemd-udevd')
2753
2754 if conf.get('ENABLE_BACKLIGHT') == 1
2755 executable(
2756 'systemd-backlight',
2757 'src/backlight/backlight.c',
2758 include_directories : includes,
2759 link_with : [libshared],
2760 install_rpath : rootpkglibdir,
2761 install : true,
2762 install_dir : rootlibexecdir)
2763 endif
2764
2765 if conf.get('ENABLE_RFKILL') == 1
2766 executable(
2767 'systemd-rfkill',
2768 'src/rfkill/rfkill.c',
2769 include_directories : includes,
2770 link_with : [libshared],
2771 install_rpath : rootpkglibdir,
2772 install : true,
2773 install_dir : rootlibexecdir)
2774 endif
2775
2776 executable(
2777 'systemd-system-update-generator',
2778 'src/system-update-generator/system-update-generator.c',
2779 include_directories : includes,
2780 link_with : [libshared],
2781 install_rpath : rootpkglibdir,
2782 install : true,
2783 install_dir : systemgeneratordir)
2784
2785 if conf.get('HAVE_LIBCRYPTSETUP') == 1
2786 executable(
2787 'systemd-cryptsetup',
2788 systemd_cryptsetup_sources,
2789 include_directories : includes,
2790 link_with : [libshared],
2791 dependencies : [libcryptsetup,
2792 libp11kit],
2793 install_rpath : rootpkglibdir,
2794 install : true,
2795 install_dir : rootlibexecdir)
2796
2797 executable(
2798 'systemd-cryptsetup-generator',
2799 'src/cryptsetup/cryptsetup-generator.c',
2800 include_directories : includes,
2801 link_with : [libshared],
2802 install_rpath : rootpkglibdir,
2803 install : true,
2804 install_dir : systemgeneratordir)
2805
2806 executable(
2807 'systemd-veritysetup',
2808 'src/veritysetup/veritysetup.c',
2809 include_directories : includes,
2810 link_with : [libshared],
2811 dependencies : [libcryptsetup],
2812 install_rpath : rootpkglibdir,
2813 install : true,
2814 install_dir : rootlibexecdir)
2815
2816 executable(
2817 'systemd-veritysetup-generator',
2818 'src/veritysetup/veritysetup-generator.c',
2819 include_directories : includes,
2820 link_with : [libshared],
2821 install_rpath : rootpkglibdir,
2822 install : true,
2823 install_dir : systemgeneratordir)
2824
2825 public_programs += executable(
2826 'systemd-cryptenroll',
2827 systemd_cryptenroll_sources,
2828 include_directories : includes,
2829 link_with : [libshared],
2830 dependencies : [libcryptsetup,
2831 libdl,
2832 libopenssl,
2833 libp11kit],
2834 install_rpath : rootpkglibdir,
2835 install : true)
2836
2837 executable(
2838 'systemd-integritysetup',
2839 ['src/integritysetup/integritysetup.c', 'src/integritysetup/integrity-util.c'],
2840 include_directories : includes,
2841 link_with : [libshared],
2842 dependencies : [libcryptsetup],
2843 install_rpath : rootpkglibdir,
2844 install : true,
2845 install_dir : rootlibexecdir)
2846
2847 executable(
2848 'systemd-integritysetup-generator',
2849 ['src/integritysetup/integritysetup-generator.c', 'src/integritysetup/integrity-util.c'],
2850 include_directories : includes,
2851 link_with : [libshared],
2852 install_rpath : rootpkglibdir,
2853 install : true,
2854 install_dir : systemgeneratordir)
2855 endif
2856
2857 if conf.get('HAVE_SYSV_COMPAT') == 1
2858 exe = executable(
2859 'systemd-sysv-generator',
2860 'src/sysv-generator/sysv-generator.c',
2861 include_directories : includes,
2862 link_with : [libshared],
2863 install_rpath : rootpkglibdir,
2864 install : true,
2865 install_dir : systemgeneratordir)
2866
2867 sysv_generator_test_py = find_program('test/sysv-generator-test.py')
2868 if want_tests != 'false'
2869 test('sysv-generator-test',
2870 sysv_generator_test_py,
2871 depends : exe)
2872 endif
2873
2874 executable(
2875 'systemd-rc-local-generator',
2876 'src/rc-local-generator/rc-local-generator.c',
2877 include_directories : includes,
2878 link_with : [libshared],
2879 install_rpath : rootpkglibdir,
2880 install : true,
2881 install_dir : systemgeneratordir)
2882 endif
2883
2884 if conf.get('ENABLE_XDG_AUTOSTART') == 1
2885 executable(
2886 'systemd-xdg-autostart-generator',
2887 systemd_xdg_autostart_generator_sources,
2888 include_directories : includes,
2889 link_with : [libshared],
2890 install_rpath : rootpkglibdir,
2891 install : true,
2892 install_dir : usergeneratordir)
2893
2894 executable(
2895 'systemd-xdg-autostart-condition',
2896 'src/xdg-autostart-generator/xdg-autostart-condition.c',
2897 include_directories : includes,
2898 link_with : [libshared],
2899 install_rpath : rootpkglibdir,
2900 install : true,
2901 install_dir : rootlibexecdir)
2902 endif
2903
2904 if conf.get('ENABLE_HOSTNAMED') == 1
2905 dbus_programs += executable(
2906 'systemd-hostnamed',
2907 'src/hostname/hostnamed.c',
2908 include_directories : includes,
2909 link_with : [libshared],
2910 install_rpath : rootpkglibdir,
2911 install : true,
2912 install_dir : rootlibexecdir)
2913
2914 public_programs += executable(
2915 'hostnamectl',
2916 'src/hostname/hostnamectl.c',
2917 include_directories : includes,
2918 link_with : [libshared],
2919 install_rpath : rootpkglibdir,
2920 install : true)
2921 endif
2922
2923 if conf.get('ENABLE_LOCALED') == 1
2924 if conf.get('HAVE_XKBCOMMON') == 1
2925 # logind will load libxkbcommon.so dynamically on its own, but we still
2926 # need to specify where the headers are
2927 deps = [libdl, libxkbcommon.partial_dependency(compile_args: true)]
2928 else
2929 deps = []
2930 endif
2931
2932 dbus_programs += executable(
2933 'systemd-localed',
2934 systemd_localed_sources,
2935 include_directories : includes,
2936 link_with : [libshared],
2937 dependencies : deps,
2938 install_rpath : rootpkglibdir,
2939 install : true,
2940 install_dir : rootlibexecdir)
2941
2942 public_programs += executable(
2943 'localectl',
2944 localectl_sources,
2945 include_directories : includes,
2946 link_with : [libshared],
2947 install_rpath : rootpkglibdir,
2948 install : true)
2949 endif
2950
2951 if conf.get('ENABLE_TIMEDATED') == 1
2952 dbus_programs += executable(
2953 'systemd-timedated',
2954 'src/timedate/timedated.c',
2955 include_directories : includes,
2956 link_with : [libshared],
2957 install_rpath : rootpkglibdir,
2958 install : true,
2959 install_dir : rootlibexecdir)
2960 endif
2961
2962 if conf.get('ENABLE_TIMEDATECTL') == 1
2963 public_programs += executable(
2964 'timedatectl',
2965 'src/timedate/timedatectl.c',
2966 include_directories : includes,
2967 install_rpath : rootpkglibdir,
2968 link_with : [libshared],
2969 dependencies : [libm],
2970 install : true)
2971 endif
2972
2973 if conf.get('ENABLE_TIMESYNCD') == 1
2974 executable(
2975 'systemd-timesyncd',
2976 systemd_timesyncd_sources,
2977 include_directories : includes,
2978 link_with : [libtimesyncd_core],
2979 dependencies : [threads,
2980 libm],
2981 install_rpath : rootpkglibdir,
2982 install : true,
2983 install_dir : rootlibexecdir)
2984
2985 executable(
2986 'systemd-time-wait-sync',
2987 'src/timesync/wait-sync.c',
2988 include_directories : includes,
2989 link_with : [libtimesyncd_core],
2990 install_rpath : rootpkglibdir,
2991 install : true,
2992 install_dir : rootlibexecdir)
2993 endif
2994
2995 if conf.get('ENABLE_MACHINED') == 1
2996 dbus_programs += executable(
2997 'systemd-machined',
2998 systemd_machined_sources,
2999 include_directories : includes,
3000 link_with : [libmachine_core,
3001 libshared],
3002 install_rpath : rootpkglibdir,
3003 install : true,
3004 install_dir : rootlibexecdir)
3005
3006 public_programs += executable(
3007 'machinectl',
3008 'src/machine/machinectl.c',
3009 include_directories : includes,
3010 link_with : [libshared],
3011 dependencies : [threads,
3012 libxz,
3013 liblz4,
3014 libzstd],
3015 install_rpath : rootpkglibdir,
3016 install : true,
3017 install_dir : rootbindir)
3018 endif
3019
3020 if conf.get('ENABLE_IMPORTD') == 1
3021 dbus_programs += executable(
3022 'systemd-importd',
3023 systemd_importd_sources,
3024 include_directories : includes,
3025 link_with : [libshared],
3026 dependencies : [threads],
3027 install_rpath : rootpkglibdir,
3028 install : true,
3029 install_dir : rootlibexecdir)
3030
3031 systemd_pull = executable(
3032 'systemd-pull',
3033 systemd_pull_sources,
3034 include_directories : includes,
3035 link_with : [libshared,
3036 lib_import_common],
3037 dependencies : [versiondep,
3038 libcurl,
3039 lib_openssl_or_gcrypt,
3040 libz,
3041 libbzip2,
3042 libxz],
3043 install_rpath : rootpkglibdir,
3044 install : true,
3045 install_dir : rootlibexecdir)
3046
3047 systemd_import = executable(
3048 'systemd-import',
3049 systemd_import_sources,
3050 include_directories : includes,
3051 link_with : [libshared,
3052 lib_import_common],
3053 dependencies : [libcurl,
3054 libz,
3055 libbzip2,
3056 libxz],
3057 install_rpath : rootpkglibdir,
3058 install : true,
3059 install_dir : rootlibexecdir)
3060
3061 systemd_import_fs = executable(
3062 'systemd-import-fs',
3063 systemd_import_fs_sources,
3064 include_directories : includes,
3065 link_with : [libshared,
3066 lib_import_common],
3067 install_rpath : rootpkglibdir,
3068 install : true,
3069 install_dir : rootlibexecdir)
3070
3071 systemd_export = executable(
3072 'systemd-export',
3073 systemd_export_sources,
3074 include_directories : includes,
3075 link_with : [libshared,
3076 lib_import_common],
3077 dependencies : [libcurl,
3078 libz,
3079 libbzip2,
3080 libxz],
3081 install_rpath : rootpkglibdir,
3082 install : true,
3083 install_dir : rootlibexecdir)
3084
3085 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
3086 endif
3087
3088 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
3089 public_programs += executable(
3090 'systemd-journal-upload',
3091 systemd_journal_upload_sources,
3092 include_directories : includes,
3093 link_with : [libshared],
3094 dependencies : [versiondep,
3095 threads,
3096 libcurl,
3097 libgnutls,
3098 libxz,
3099 liblz4,
3100 libzstd],
3101 install_rpath : rootpkglibdir,
3102 install : true,
3103 install_dir : rootlibexecdir)
3104 endif
3105
3106 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
3107 public_programs += executable(
3108 'systemd-journal-remote',
3109 systemd_journal_remote_sources,
3110 include_directories : journal_includes,
3111 link_with : [libshared,
3112 libsystemd_journal_remote],
3113 dependencies : [threads,
3114 libmicrohttpd,
3115 libgnutls,
3116 libxz,
3117 liblz4,
3118 libzstd],
3119 install_rpath : rootpkglibdir,
3120 install : true,
3121 install_dir : rootlibexecdir)
3122
3123 public_programs += executable(
3124 'systemd-journal-gatewayd',
3125 systemd_journal_gatewayd_sources,
3126 include_directories : journal_includes,
3127 link_with : [libshared],
3128 dependencies : [threads,
3129 libmicrohttpd,
3130 libgnutls,
3131 libxz,
3132 liblz4,
3133 libzstd],
3134 install_rpath : rootpkglibdir,
3135 install : true,
3136 install_dir : rootlibexecdir)
3137 endif
3138
3139 if conf.get('ENABLE_COREDUMP') == 1
3140 executable(
3141 'systemd-coredump',
3142 systemd_coredump_sources,
3143 include_directories : includes,
3144 link_with : [libshared,
3145 libbasic_compress],
3146 dependencies : [threads,
3147 libacl,
3148 libxz,
3149 liblz4,
3150 libzstd],
3151 install_rpath : rootpkglibdir,
3152 install : true,
3153 install_dir : rootlibexecdir)
3154
3155 public_programs += executable(
3156 'coredumpctl',
3157 coredumpctl_sources,
3158 include_directories : includes,
3159 link_with : [libshared,
3160 libbasic_compress],
3161 dependencies : [threads,
3162 libxz,
3163 liblz4,
3164 libzstd],
3165 install_rpath : rootpkglibdir,
3166 install : true)
3167 endif
3168
3169 if conf.get('ENABLE_PSTORE') == 1
3170 executable(
3171 'systemd-pstore',
3172 systemd_pstore_sources,
3173 include_directories : includes,
3174 link_with : [libshared],
3175 dependencies : [threads,
3176 libacl,
3177 libxz,
3178 liblz4,
3179 libzstd],
3180 install_rpath : rootpkglibdir,
3181 install : true,
3182 install_dir : rootlibexecdir)
3183 endif
3184
3185 if conf.get('ENABLE_OOMD') == 1
3186 dbus_programs += executable('systemd-oomd',
3187 systemd_oomd_sources,
3188 include_directories : includes,
3189 link_with : [libshared],
3190 dependencies : [libatomic],
3191 install_rpath : rootpkglibdir,
3192 install : true,
3193 install_dir : rootlibexecdir)
3194
3195 public_programs += executable(
3196 'oomctl',
3197 oomctl_sources,
3198 include_directories : includes,
3199 link_with : [libshared],
3200 dependencies : [],
3201 install_rpath : rootpkglibdir,
3202 install : true)
3203 endif
3204
3205 if conf.get('ENABLE_BINFMT') == 1
3206 public_programs += executable(
3207 'systemd-binfmt',
3208 'src/binfmt/binfmt.c',
3209 include_directories : includes,
3210 link_with : [libshared],
3211 install_rpath : rootpkglibdir,
3212 install : true,
3213 install_dir : rootlibexecdir)
3214
3215 meson.add_install_script('sh', '-c',
3216 mkdir_p.format(binfmtdir))
3217 if install_sysconfdir
3218 meson.add_install_script('sh', '-c',
3219 mkdir_p.format(sysconfdir / 'binfmt.d'))
3220 endif
3221 endif
3222
3223 if conf.get('ENABLE_SYSUPDATE') == 1
3224 exe = executable(
3225 'systemd-sysupdate',
3226 systemd_sysupdate_sources,
3227 include_directories : includes,
3228 link_with : [libshared],
3229 dependencies : [threads,
3230 libblkid,
3231 libfdisk,
3232 libopenssl],
3233 install_rpath : rootpkglibdir,
3234 install : true,
3235 install_dir : rootlibexecdir)
3236 public_programs += exe
3237 endif
3238
3239 if conf.get('ENABLE_VCONSOLE') == 1
3240 executable(
3241 'systemd-vconsole-setup',
3242 'src/vconsole/vconsole-setup.c',
3243 include_directories : includes,
3244 link_with : [libshared],
3245 install_rpath : rootpkglibdir,
3246 install : true,
3247 install_dir : rootlibexecdir)
3248 endif
3249
3250 if conf.get('ENABLE_RANDOMSEED') == 1
3251 executable(
3252 'systemd-random-seed',
3253 'src/random-seed/random-seed.c',
3254 include_directories : includes,
3255 link_with : [libshared],
3256 install_rpath : rootpkglibdir,
3257 install : true,
3258 install_dir : rootlibexecdir)
3259 endif
3260
3261 if conf.get('ENABLE_FIRSTBOOT') == 1
3262 public_programs += executable(
3263 'systemd-firstboot',
3264 'src/firstboot/firstboot.c',
3265 include_directories : includes,
3266 link_with : [libshared],
3267 dependencies : [libcrypt],
3268 install_rpath : rootpkglibdir,
3269 install : true,
3270 install_dir : rootbindir)
3271 endif
3272
3273 executable(
3274 'systemd-remount-fs',
3275 'src/remount-fs/remount-fs.c',
3276 include_directories : includes,
3277 link_with : [libshared],
3278 install_rpath : rootpkglibdir,
3279 install : true,
3280 install_dir : rootlibexecdir)
3281
3282 executable(
3283 'systemd-machine-id-setup',
3284 'src/machine-id-setup/machine-id-setup-main.c',
3285 include_directories : includes,
3286 link_with : [libshared],
3287 install_rpath : rootpkglibdir,
3288 install : true,
3289 install_dir : rootbindir)
3290
3291 executable(
3292 'systemd-fsck',
3293 'src/fsck/fsck.c',
3294 include_directories : includes,
3295 link_with : [libshared],
3296 install_rpath : rootpkglibdir,
3297 install : true,
3298 install_dir : rootlibexecdir)
3299
3300 executable('systemd-growfs',
3301 'src/partition/growfs.c',
3302 include_directories : includes,
3303 link_with : [libshared],
3304 install_rpath : rootpkglibdir,
3305 install : true,
3306 install_dir : rootlibexecdir)
3307
3308 executable(
3309 'systemd-makefs',
3310 'src/partition/makefs.c',
3311 include_directories : includes,
3312 link_with : [libshared],
3313 install_rpath : rootpkglibdir,
3314 install : true,
3315 install_dir : rootlibexecdir)
3316
3317 executable(
3318 'systemd-sleep',
3319 'src/sleep/sleep.c',
3320 include_directories : includes,
3321 link_with : [libshared],
3322 install_rpath : rootpkglibdir,
3323 install : true,
3324 install_dir : rootlibexecdir)
3325
3326 if install_sysconfdir_samples
3327 install_data('src/sleep/sleep.conf',
3328 install_dir : pkgsysconfdir)
3329 endif
3330
3331 public_programs += executable(
3332 'systemd-sysctl',
3333 'src/sysctl/sysctl.c',
3334 include_directories : includes,
3335 link_with : [libshared],
3336 install_rpath : rootpkglibdir,
3337 install : true,
3338 install_dir : rootlibexecdir)
3339
3340 executable(
3341 'systemd-ac-power',
3342 'src/ac-power/ac-power.c',
3343 include_directories : includes,
3344 link_with : [libshared],
3345 install_rpath : rootpkglibdir,
3346 install : true,
3347 install_dir : rootlibexecdir)
3348
3349 public_programs += executable(
3350 'systemd-detect-virt',
3351 'src/detect-virt/detect-virt.c',
3352 include_directories : includes,
3353 link_with : [libshared],
3354 install_rpath : rootpkglibdir,
3355 install : true)
3356
3357 public_programs += executable(
3358 'systemd-delta',
3359 'src/delta/delta.c',
3360 include_directories : includes,
3361 link_with : [libshared],
3362 install_rpath : rootpkglibdir,
3363 install : true)
3364
3365 public_programs += executable(
3366 'systemd-escape',
3367 'src/escape/escape.c',
3368 include_directories : includes,
3369 link_with : [libshared],
3370 install_rpath : rootpkglibdir,
3371 install : true,
3372 install_dir : rootbindir)
3373
3374 public_programs += executable(
3375 'systemd-notify',
3376 'src/notify/notify.c',
3377 include_directories : includes,
3378 link_with : [libshared],
3379 install_rpath : rootpkglibdir,
3380 install : true,
3381 install_dir : rootbindir)
3382
3383 public_programs += executable(
3384 'systemd-creds',
3385 'src/creds/creds.c',
3386 include_directories : includes,
3387 link_with : [libshared],
3388 dependencies : [threads,
3389 libopenssl],
3390 install_rpath : rootpkglibdir,
3391 install : true,
3392 install_dir : rootbindir)
3393
3394 executable(
3395 'systemd-volatile-root',
3396 'src/volatile-root/volatile-root.c',
3397 include_directories : includes,
3398 link_with : [libshared],
3399 install_rpath : rootpkglibdir,
3400 install : conf.get('ENABLE_INITRD') == 1,
3401 install_dir : rootlibexecdir)
3402
3403 executable(
3404 'systemd-cgroups-agent',
3405 'src/cgroups-agent/cgroups-agent.c',
3406 include_directories : includes,
3407 link_with : [libshared],
3408 install_rpath : rootpkglibdir,
3409 install : true,
3410 install_dir : rootlibexecdir)
3411
3412 systemd_id128 = executable(
3413 'systemd-id128',
3414 'src/id128/id128.c',
3415 include_directories : includes,
3416 link_with : [libshared],
3417 install_rpath : rootpkglibdir,
3418 install : true)
3419 public_programs += systemd_id128
3420
3421 if want_tests != 'false'
3422 test('test-systemctl-enable',
3423 test_systemctl_enable_sh,
3424 # https://github.com/mesonbuild/meson/issues/2681
3425 args : [systemctl.full_path(),
3426 systemd_id128.full_path()])
3427 endif
3428
3429 public_programs += executable(
3430 'systemd-path',
3431 'src/path/path.c',
3432 include_directories : includes,
3433 link_with : [libshared],
3434 install_rpath : rootpkglibdir,
3435 install : true)
3436
3437 public_programs += executable(
3438 'systemd-ask-password',
3439 'src/ask-password/ask-password.c',
3440 include_directories : includes,
3441 link_with : [libshared],
3442 install_rpath : rootpkglibdir,
3443 install : true,
3444 install_dir : rootbindir)
3445
3446 executable(
3447 'systemd-reply-password',
3448 'src/reply-password/reply-password.c',
3449 include_directories : includes,
3450 link_with : [libshared],
3451 install_rpath : rootpkglibdir,
3452 install : true,
3453 install_dir : rootlibexecdir)
3454
3455 public_programs += executable(
3456 'systemd-tty-ask-password-agent',
3457 'src/tty-ask-password-agent/tty-ask-password-agent.c',
3458 include_directories : includes,
3459 link_with : [libshared],
3460 install_rpath : rootpkglibdir,
3461 install : true,
3462 install_dir : rootbindir)
3463
3464 public_programs += executable(
3465 'systemd-cgls',
3466 'src/cgls/cgls.c',
3467 include_directories : includes,
3468 link_with : [libshared],
3469 install_rpath : rootpkglibdir,
3470 install : true)
3471
3472 public_programs += executable(
3473 'systemd-cgtop',
3474 'src/cgtop/cgtop.c',
3475 include_directories : includes,
3476 link_with : [libshared],
3477 install_rpath : rootpkglibdir,
3478 install : true)
3479
3480 executable(
3481 'systemd-initctl',
3482 'src/initctl/initctl.c',
3483 include_directories : includes,
3484 link_with : [libshared],
3485 install_rpath : rootpkglibdir,
3486 install : (conf.get('HAVE_SYSV_COMPAT') == 1),
3487 install_dir : rootlibexecdir)
3488
3489 public_programs += executable(
3490 'systemd-mount',
3491 'src/mount/mount-tool.c',
3492 include_directories : includes,
3493 link_with : [libshared],
3494 dependencies: [libmount],
3495 install_rpath : rootpkglibdir,
3496 install : true)
3497
3498 meson.add_install_script(meson_make_symlink,
3499 'systemd-mount', bindir / 'systemd-umount')
3500
3501 public_programs += executable(
3502 'systemd-run',
3503 'src/run/run.c',
3504 include_directories : includes,
3505 link_with : [libshared],
3506 install_rpath : rootpkglibdir,
3507 install : true)
3508
3509 public_programs += executable(
3510 'systemd-stdio-bridge',
3511 'src/stdio-bridge/stdio-bridge.c',
3512 include_directories : includes,
3513 link_with : [libshared],
3514 dependencies : [versiondep],
3515 install_rpath : rootpkglibdir,
3516 install : true)
3517
3518 public_programs += executable(
3519 'busctl',
3520 busctl_sources,
3521 include_directories : includes,
3522 link_with : [libshared],
3523 dependencies : [versiondep],
3524 install_rpath : rootpkglibdir,
3525 install : true)
3526
3527 if enable_sysusers
3528 exe = executable(
3529 'systemd-sysusers',
3530 'src/sysusers/sysusers.c',
3531 include_directories : includes,
3532 link_with : [libshared],
3533 install_rpath : rootpkglibdir,
3534 install : true,
3535 install_dir : rootbindir)
3536 public_programs += exe
3537
3538 if want_tests != 'false'
3539 test('test-sysusers',
3540 test_sysusers_sh,
3541 # https://github.com/mesonbuild/meson/issues/2681
3542 args : exe.full_path())
3543 endif
3544
3545 if have_standalone_binaries
3546 exe = executable(
3547 'systemd-sysusers.standalone',
3548 'src/sysusers/sysusers.c',
3549 include_directories : includes,
3550 c_args : '-DSTANDALONE',
3551 link_with : [libshared_static,
3552 libbasic,
3553 libbasic_gcrypt,
3554 libsystemd_static],
3555 install : true,
3556 install_dir : rootbindir)
3557 public_programs += exe
3558
3559 if want_tests != 'false'
3560 test('test-sysusers.standalone',
3561 test_sysusers_sh,
3562 # https://github.com/mesonbuild/meson/issues/2681
3563 args : exe.full_path())
3564 endif
3565 endif
3566 endif
3567
3568 if conf.get('ENABLE_TMPFILES') == 1
3569 exe = executable(
3570 'systemd-tmpfiles',
3571 systemd_tmpfiles_sources,
3572 include_directories : includes,
3573 link_with : [libshared],
3574 dependencies : [libacl],
3575 install_rpath : rootpkglibdir,
3576 install : true,
3577 install_dir : rootbindir)
3578 public_programs += exe
3579
3580 if want_tests != 'false'
3581 test('test-systemd-tmpfiles',
3582 test_systemd_tmpfiles_py,
3583 # https://github.com/mesonbuild/meson/issues/2681
3584 args : exe.full_path())
3585 endif
3586
3587 if have_standalone_binaries
3588 exe = executable(
3589 'systemd-tmpfiles.standalone',
3590 systemd_tmpfiles_sources,
3591 include_directories : includes,
3592 c_args : '-DSTANDALONE',
3593 link_with : [libshared_static,
3594 libbasic,
3595 libbasic_gcrypt,
3596 libsystemd_static],
3597 dependencies : [libacl],
3598 install : true,
3599 install_dir : rootbindir)
3600 public_programs += exe
3601
3602 if want_tests != 'false'
3603 test('test-systemd-tmpfiles.standalone',
3604 test_systemd_tmpfiles_py,
3605 # https://github.com/mesonbuild/meson/issues/2681
3606 args : exe.full_path())
3607 endif
3608 endif
3609 endif
3610
3611 if conf.get('ENABLE_HWDB') == 1
3612 systemd_hwdb = executable(
3613 'systemd-hwdb',
3614 'src/hwdb/hwdb.c',
3615 include_directories : includes,
3616 link_with : udev_link_with,
3617 install_rpath : udev_rpath,
3618 install : true,
3619 install_dir : rootbindir)
3620 public_programs += systemd_hwdb
3621
3622 if want_tests != 'false'
3623 test('hwdb-test',
3624 hwdb_test_sh,
3625 suite : 'dist-check',
3626 args : [systemd_hwdb.full_path()],
3627 timeout : 90)
3628 endif
3629 endif
3630
3631 if conf.get('ENABLE_QUOTACHECK') == 1
3632 executable(
3633 'systemd-quotacheck',
3634 'src/quotacheck/quotacheck.c',
3635 include_directories : includes,
3636 link_with : [libshared],
3637 install_rpath : rootpkglibdir,
3638 install : true,
3639 install_dir : rootlibexecdir)
3640 endif
3641
3642 public_programs += executable(
3643 'systemd-socket-proxyd',
3644 'src/socket-proxy/socket-proxyd.c',
3645 include_directories : includes,
3646 link_with : [libshared],
3647 dependencies : [threads],
3648 install_rpath : rootpkglibdir,
3649 install : true,
3650 install_dir : rootlibexecdir)
3651
3652 udevadm = executable(
3653 'udevadm',
3654 udevadm_sources,
3655 include_directories : includes,
3656 link_with : [libudevd_core],
3657 dependencies : [versiondep,
3658 threads,
3659 libkmod,
3660 libidn,
3661 libacl,
3662 libblkid],
3663 install_rpath : udev_rpath,
3664 install : true,
3665 install_dir : rootbindir)
3666 public_programs += udevadm
3667
3668 if conf.get('ENABLE_REPART') == 1
3669 exe = executable(
3670 'systemd-repart',
3671 systemd_repart_sources,
3672 include_directories : includes,
3673 link_with : [libshared],
3674 dependencies : [threads,
3675 libblkid,
3676 libfdisk],
3677 install_rpath : rootpkglibdir,
3678 install : true,
3679 install_dir : rootbindir)
3680 public_programs += exe
3681 endif
3682
3683 executable(
3684 'systemd-shutdown',
3685 systemd_shutdown_sources,
3686 include_directories : includes,
3687 link_with : [libshared],
3688 dependencies : [libmount],
3689 install_rpath : rootpkglibdir,
3690 install : true,
3691 install_dir : rootlibexecdir)
3692
3693 executable(
3694 'systemd-update-done',
3695 'src/update-done/update-done.c',
3696 include_directories : includes,
3697 link_with : [libshared],
3698 install_rpath : rootpkglibdir,
3699 install : true,
3700 install_dir : rootlibexecdir)
3701
3702 executable(
3703 'systemd-update-utmp',
3704 'src/update-utmp/update-utmp.c',
3705 include_directories : includes,
3706 link_with : [libshared],
3707 dependencies : [libaudit],
3708 install_rpath : rootpkglibdir,
3709 install : (conf.get('ENABLE_UTMP') == 1),
3710 install_dir : rootlibexecdir)
3711
3712 if conf.get('HAVE_KMOD') == 1
3713 executable(
3714 'systemd-modules-load',
3715 'src/modules-load/modules-load.c',
3716 include_directories : includes,
3717 link_with : [libshared],
3718 dependencies : [libkmod],
3719 install_rpath : rootpkglibdir,
3720 install : true,
3721 install_dir : rootlibexecdir)
3722
3723 meson.add_install_script('sh', '-c',
3724 mkdir_p.format(modulesloaddir))
3725 if install_sysconfdir
3726 meson.add_install_script('sh', '-c',
3727 mkdir_p.format(sysconfdir / 'modules-load.d'))
3728 endif
3729 endif
3730
3731 public_programs += executable(
3732 'systemd-nspawn',
3733 systemd_nspawn_sources,
3734 include_directories : includes,
3735 link_with : [libnspawn_core,
3736 libshared],
3737 dependencies : [libblkid,
3738 libseccomp],
3739 install_rpath : rootpkglibdir,
3740 install : true)
3741
3742 if conf.get('ENABLE_NETWORKD') == 1
3743 dbus_programs += executable(
3744 'systemd-networkd',
3745 systemd_networkd_sources,
3746 include_directories : network_includes,
3747 link_with : [libnetworkd_core,
3748 libsystemd_network,
3749 networkd_link_with],
3750 dependencies : [threads],
3751 install_rpath : rootpkglibdir,
3752 install : true,
3753 install_dir : rootlibexecdir)
3754
3755 public_programs += executable(
3756 'systemd-networkd-wait-online',
3757 systemd_networkd_wait_online_sources,
3758 include_directories : includes,
3759 link_with : [networkd_link_with],
3760 install_rpath : rootpkglibdir,
3761 install : true,
3762 install_dir : rootlibexecdir)
3763
3764 public_programs += executable(
3765 'networkctl',
3766 networkctl_sources,
3767 include_directories : libsystemd_network_includes,
3768 link_with : [libsystemd_network,
3769 networkd_link_with],
3770 install_rpath : rootpkglibdir,
3771 install : true,
3772 install_dir : rootbindir)
3773 endif
3774
3775 exe = executable(
3776 'systemd-network-generator',
3777 network_generator_sources,
3778 include_directories : includes,
3779 link_with : [networkd_link_with],
3780 install_rpath : rootpkglibdir,
3781 install : true,
3782 install_dir : rootlibexecdir)
3783
3784 if want_tests != 'false'
3785 test('test-network-generator-conversion',
3786 test_network_generator_conversion_sh,
3787 # https://github.com/mesonbuild/meson/issues/2681
3788 args : exe.full_path(),
3789 depends : exe)
3790 endif
3791
3792 executable(
3793 'systemd-sulogin-shell',
3794 'src/sulogin-shell/sulogin-shell.c',
3795 include_directories : includes,
3796 link_with : [libshared],
3797 install_rpath : rootpkglibdir,
3798 install : true,
3799 install_dir : rootlibexecdir)
3800
3801 exe = custom_target(
3802 'kernel-install',
3803 input : kernel_install_in,
3804 output : 'kernel-install',
3805 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
3806 install : want_kernel_install,
3807 install_mode : 'rwxr-xr-x',
3808 install_dir : bindir)
3809 public_programs += exe
3810
3811 if want_tests != 'false'
3812 test('test-kernel-install',
3813 test_kernel_install_sh,
3814 args : [exe.full_path(), loaderentry_install])
3815 endif
3816
3817 ############################################################
3818
3819 runtest_env = custom_target(
3820 'systemd-runtest.env',
3821 output : 'systemd-runtest.env',
3822 command : [sh, '-c',
3823 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
3824 project_source_root / 'test',
3825 project_build_root / 'catalog')],
3826 depends : catalogs,
3827 build_by_default : true)
3828
3829 test_cflags = ['-DTEST_CODE=1']
3830 # We intentionally do not do inline initializations with definitions for a
3831 # bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
3832 # use the variable unexpectedly. This triggers a lot of maybe-uninitialized
3833 # false positives when the combination of -O2 and -flto is used. Suppress them.
3834 if '-O2' in c_args and '-flto=auto' in c_args
3835 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
3836 endif
3837
3838 foreach tuple : tests
3839 sources = tuple[0]
3840 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3841 dependencies = tuple.length() > 2 ? tuple[2] : []
3842 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3843 condition = tuple.length() > 4 ? tuple[4] : ''
3844 type = tuple.length() > 5 ? tuple[5] : ''
3845 defs = tuple.length() > 6 ? tuple[6] : []
3846 defs += test_cflags
3847 parallel = tuple.length() > 7 ? tuple[7] : true
3848 timeout = 30
3849
3850 # FIXME: Use fs.stem() with meson >= 0.54.0
3851 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
3852 if type.startswith('timeout=')
3853 timeout = type.split('=')[1].to_int()
3854 type = ''
3855 endif
3856
3857 suite = fs.name(fs.parent('@0@'.format(sources[0])))
3858 # FIXME: Use str.replace() with meson >= 0.58.0
3859 suite = suite.split('sd-')[-1]
3860
3861 if condition == '' or conf.get(condition) == 1
3862 exe = executable(
3863 name,
3864 sources,
3865 include_directories : incs,
3866 link_with : link_with,
3867 dependencies : [versiondep,
3868 dependencies],
3869 c_args : defs,
3870 build_by_default : want_tests != 'false',
3871 install_rpath : rootpkglibdir,
3872 install : install_tests,
3873 install_dir : testsdir / type,
3874 link_depends : runtest_env)
3875
3876 if type == 'manual'
3877 message('@0@ is a manual test'.format(name))
3878 elif type == 'unsafe' and want_tests != 'unsafe'
3879 message('@0@ is an unsafe test'.format(name))
3880 elif want_tests != 'false'
3881 test(name, exe,
3882 env : test_env,
3883 timeout : timeout,
3884 suite : suite,
3885 is_parallel : parallel)
3886 endif
3887 else
3888 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
3889 endif
3890 endforeach
3891
3892 exe = executable(
3893 'test-libsystemd-sym',
3894 test_libsystemd_sym_c,
3895 include_directories : includes,
3896 link_with : [libsystemd],
3897 build_by_default : want_tests != 'false',
3898 install : install_tests,
3899 install_dir : testsdir)
3900 if want_tests != 'false'
3901 test('test-libsystemd-sym', exe)
3902 endif
3903
3904 exe = executable(
3905 'test-libsystemd-static-sym',
3906 test_libsystemd_sym_c,
3907 include_directories : includes,
3908 link_with : [install_libsystemd_static],
3909 dependencies : [threads], # threads is already included in dependencies on the library,
3910 # but does not seem to get propagated. Add here as a work-around.
3911 build_by_default : want_tests != 'false' and static_libsystemd_pic,
3912 install : install_tests and static_libsystemd_pic,
3913 install_dir : testsdir)
3914 if want_tests != 'false' and static_libsystemd_pic
3915 test('test-libsystemd-static-sym', exe)
3916 endif
3917
3918 exe = executable(
3919 'test-libudev-sym',
3920 test_libudev_sym_c,
3921 include_directories : libudev_includes,
3922 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
3923 link_with : [libudev],
3924 build_by_default : want_tests != 'false',
3925 install : install_tests,
3926 install_dir : testsdir)
3927 if want_tests != 'false'
3928 test('test-libudev-sym', exe)
3929 endif
3930
3931 exe = executable(
3932 'test-libudev-static-sym',
3933 test_libudev_sym_c,
3934 include_directories : libudev_includes,
3935 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
3936 link_with : [install_libudev_static],
3937 build_by_default : want_tests != 'false' and static_libudev_pic,
3938 install : install_tests and static_libudev_pic,
3939 install_dir : testsdir)
3940 if want_tests != 'false' and static_libudev_pic
3941 test('test-libudev-static-sym', exe)
3942 endif
3943
3944 ############################################################
3945
3946 fuzzer_exes = []
3947
3948 foreach tuple : fuzzers
3949 sources = tuple[0]
3950 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3951 dependencies = tuple.length() > 2 ? tuple[2] : []
3952 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3953 defs = tuple.length() > 4 ? tuple[4] : []
3954 link_args = []
3955
3956 if want_ossfuzz
3957 dependencies += fuzzing_engine
3958 elif want_libfuzzer
3959 if fuzzing_engine.found()
3960 dependencies += fuzzing_engine
3961 else
3962 link_args += ['-fsanitize=fuzzer']
3963 endif
3964 else
3965 sources += 'src/fuzz/fuzz-main.c'
3966 endif
3967
3968 # FIXME: Use fs.stem() with meson >= 0.54.0
3969 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
3970
3971 exe = executable(
3972 name,
3973 sources,
3974 include_directories : [incs, include_directories('src/fuzz')],
3975 link_with : link_with,
3976 dependencies : dependencies,
3977 c_args : defs + test_cflags,
3978 link_args: link_args,
3979 install : false,
3980 build_by_default : fuzzer_build)
3981 fuzzer_exes += exe
3982
3983 if want_tests != 'false'
3984 # Run the fuzz regression tests without any sanitizers enabled.
3985 # Additional invocations with sanitizers may be added below.
3986 foreach p : fuzz_regression_tests
3987 b = p.split('/')[-2]
3988 c = p.split('/')[-1]
3989
3990 if b == name
3991 test('@0@_@1@'.format(b, c),
3992 exe,
3993 suite : 'fuzzers',
3994 args : [project_source_root / p])
3995 endif
3996 endforeach
3997 endif
3998 endforeach
3999
4000 alias_target('fuzzers', fuzzer_exes)
4001
4002 ############################################################
4003
4004 subdir('modprobe.d')
4005 subdir('sysctl.d')
4006 subdir('sysusers.d')
4007 subdir('tmpfiles.d')
4008 subdir('hwdb.d')
4009 subdir('units')
4010 subdir('presets')
4011 subdir('network')
4012 subdir('man')
4013 subdir('shell-completion/bash')
4014 subdir('shell-completion/zsh')
4015 subdir('docs/sysvinit')
4016 subdir('docs/var-log')
4017
4018 install_subdir('factory/etc',
4019 install_dir : factorydir)
4020 subdir('factory/templates')
4021
4022 if install_sysconfdir
4023 install_data('xorg/50-systemd-user.sh',
4024 install_dir : xinitrcdir)
4025 endif
4026 install_data('LICENSE.GPL2',
4027 'LICENSE.LGPL2.1',
4028 'NEWS',
4029 'README',
4030 'docs/CODING_STYLE.md',
4031 'docs/DISTRO_PORTING.md',
4032 'docs/ENVIRONMENT.md',
4033 'docs/HACKING.md',
4034 'docs/TRANSIENT-SETTINGS.md',
4035 'docs/TRANSLATORS.md',
4036 'docs/UIDS-GIDS.md',
4037 install_dir : docdir)
4038
4039 install_subdir('LICENSES',
4040 install_dir : docdir)
4041
4042 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
4043 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
4044
4045 ############################################################
4046
4047 # Ensure that changes to the docs/ directory do not break the
4048 # basic Github pages build. But only run it in developer mode,
4049 # as it might be fragile due to changes in the tooling, and it is
4050 # not generally useful for users.
4051 jekyll = find_program('jekyll', required : false)
4052 if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
4053 test('github-pages',
4054 jekyll,
4055 suite : 'dist-check',
4056 args : ['build',
4057 '--source', project_source_root / 'docs',
4058 '--destination', project_build_root / '_site'])
4059 endif
4060
4061 ############################################################
4062
4063 check_help = find_program('tools/check-help.sh')
4064 check_version = find_program('tools/check-version.sh')
4065
4066 foreach exec : public_programs
4067 name = exec.full_path().split('/')[-1]
4068 if want_tests != 'false'
4069 test('check-help-' + name,
4070 check_help,
4071 suite : 'dist-check',
4072 args : exec.full_path(),
4073 depends: exec)
4074
4075 test('check-version-' + name,
4076 check_version,
4077 suite : 'dist-check',
4078 args : [exec.full_path(),
4079 meson.project_version()],
4080 depends: exec)
4081 endif
4082 endforeach
4083
4084 ############################################################
4085
4086 check_directives_sh = find_program('tools/check-directives.sh')
4087
4088 if want_tests != 'false'
4089 test('check-directives',
4090 check_directives_sh,
4091 suite : 'dist-check',
4092 args : [project_source_root, project_build_root])
4093 endif
4094
4095 ############################################################
4096
4097 # Enable tests for all supported sanitizers
4098 foreach tuple : sanitizers
4099 sanitizer = tuple[0]
4100 build = tuple[1]
4101
4102 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
4103 prev = ''
4104 foreach p : fuzz_regression_tests
4105 b = p.split('/')[-2]
4106 c = p.split('/')[-1]
4107
4108 name = '@0@:@1@'.format(b, sanitizer)
4109
4110 if name != prev
4111 if want_tests == 'false'
4112 message('Not compiling @0@ because tests is set to false'.format(name))
4113 elif fuzz_tests
4114 exe = custom_target(
4115 name,
4116 output : name,
4117 depends : build,
4118 command : [ln, '-fs',
4119 build.full_path() / b,
4120 '@OUTPUT@'],
4121 build_by_default : true)
4122 else
4123 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
4124 endif
4125 endif
4126 prev = name
4127
4128 if fuzz_tests
4129 test('@0@_@1@_@2@'.format(b, c, sanitizer),
4130 env,
4131 suite : 'fuzz+san',
4132 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
4133 timeout : 60,
4134 args : [exe.full_path(),
4135 project_source_root / p])
4136 endif
4137 endforeach
4138 endif
4139 endforeach
4140
4141
4142 ############################################################
4143
4144 if git.found()
4145 all_files = run_command(
4146 env, '-u', 'GIT_WORK_TREE',
4147 git, '--git-dir=@0@/.git'.format(project_source_root),
4148 'ls-files', ':/*.[ch]',
4149 check : false)
4150 if all_files.returncode() == 0
4151 all_files = files(all_files.stdout().split())
4152
4153 custom_target(
4154 'tags',
4155 output : 'tags',
4156 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
4157 run_target(
4158 'ctags',
4159 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
4160 endif
4161 endif
4162
4163 if git.found()
4164 git_contrib_sh = find_program('tools/git-contrib.sh')
4165 run_target(
4166 'git-contrib',
4167 command : [git_contrib_sh])
4168 endif
4169
4170 if git.found()
4171 git_head = run_command(
4172 git, '--git-dir=@0@/.git'.format(project_source_root),
4173 'rev-parse', 'HEAD',
4174 check : false).stdout().strip()
4175 git_head_short = run_command(
4176 git, '--git-dir=@0@/.git'.format(project_source_root),
4177 'rev-parse', '--short=7', 'HEAD',
4178 check : false).stdout().strip()
4179
4180 run_target(
4181 'git-snapshot',
4182 command : [git, 'archive',
4183 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
4184 git_head_short),
4185 '--prefix', 'systemd-@0@/'.format(git_head),
4186 'HEAD'])
4187 endif
4188
4189 ############################################################
4190
4191 check_api_docs_sh = find_program('tools/check-api-docs.sh')
4192 run_target(
4193 'check-api-docs',
4194 depends : [man, libsystemd, libudev],
4195 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
4196
4197 alias_target('update-dbus-docs', update_dbus_docs)
4198 alias_target('update-man-rules', update_man_rules)
4199
4200 if not meson.is_cross_build()
4201 custom_target(
4202 'export-dbus-interfaces',
4203 output : fs.name(dbus_interfaces_dir),
4204 install : dbus_interfaces_dir != 'no',
4205 install_dir : fs.parent(dbus_interfaces_dir),
4206 command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
4207 endif
4208
4209 ############################################################
4210
4211 alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
4212 check : true).stdout().strip()
4213
4214 summary({
4215 'split /usr' : split_usr,
4216 'split bin-sbin' : split_bin,
4217 'prefix directory' : prefixdir,
4218 'rootprefix directory' : rootprefixdir,
4219 'sysconf directory' : sysconfdir,
4220 'include directory' : includedir,
4221 'lib directory' : libdir,
4222 'rootlib directory' : rootlibdir,
4223 'SysV init scripts' : sysvinit_path,
4224 'SysV rc?.d directories' : sysvrcnd_path,
4225 'PAM modules directory' : pamlibdir,
4226 'PAM configuration directory' : pamconfdir,
4227 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
4228 'RPM macros directory' : rpmmacrosdir,
4229 'modprobe.d directory' : modprobedir,
4230 'D-Bus policy directory' : dbuspolicydir,
4231 'D-Bus session directory' : dbussessionservicedir,
4232 'D-Bus system directory' : dbussystemservicedir,
4233 'D-Bus interfaces directory' : dbus_interfaces_dir,
4234 'bash completions directory' : bashcompletiondir,
4235 'zsh completions directory' : zshcompletiondir,
4236 'private shared lib version tag' : shared_lib_tag,
4237 'extra start script' : get_option('rc-local'),
4238 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
4239 get_option('debug-tty')),
4240 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
4241 conf.get('SYSTEM_ALLOC_UID_MIN')),
4242 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
4243 conf.get('SYSTEM_ALLOC_GID_MIN')),
4244 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
4245 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
4246 'static UID/GID allocations' : ' '.join(static_ugids),
4247 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
4248 'render group access mode' : get_option('group-render-mode'),
4249 'certificate root directory' : get_option('certificate-root'),
4250 'support URL' : support_url,
4251 'nobody user name' : nobody_user,
4252 'nobody group name' : nobody_group,
4253 'fallback hostname' : get_option('fallback-hostname'),
4254 'default compression method' : compression,
4255 'default DNSSEC mode' : default_dnssec,
4256 'default DNS-over-TLS mode' : default_dns_over_tls,
4257 'default mDNS mode' : default_mdns,
4258 'default LLMNR mode' : default_llmnr,
4259 'default DNS servers' : dns_servers.split(' '),
4260 'default NTP servers' : ntp_servers.split(' '),
4261 'default cgroup hierarchy' : default_hierarchy,
4262 'default net.naming-scheme value' : default_net_naming_scheme,
4263 'default KillUserProcesses value' : kill_user_processes,
4264 'default locale' : default_locale,
4265 'default nspawn locale' : nspawn_locale,
4266 'default status unit format' : status_unit_format_default,
4267 'default user $PATH' :
4268 default_user_path != '' ? default_user_path : '(same as system services)',
4269 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
4270 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
4271
4272 # TODO:
4273 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
4274 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
4275 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
4276
4277 found = []
4278 missing = []
4279
4280 foreach tuple : [
4281 # dependencies
4282 ['ACL'],
4283 ['AUDIT'],
4284 ['AppArmor'],
4285 ['IMA'],
4286 ['PAM'],
4287 ['SECCOMP'],
4288 ['SELinux'],
4289 ['SMACK'],
4290 ['blkid'],
4291 ['elfutils'],
4292 ['gcrypt'],
4293 ['gnutls'],
4294 ['libbpf'],
4295 ['libcryptsetup'],
4296 ['libcryptsetup-plugins'],
4297 ['libcurl'],
4298 ['libfdisk'],
4299 ['libfido2'],
4300 ['libidn'],
4301 ['libidn2'],
4302 ['libiptc'],
4303 ['microhttpd'],
4304 ['openssl'],
4305 ['p11kit'],
4306 ['pcre2'],
4307 ['pwquality'],
4308 ['qrencode'],
4309 ['tpm2'],
4310 ['xkbcommon'],
4311
4312 # compression libs
4313 ['zstd'],
4314 ['lz4'],
4315 ['xz'],
4316 ['zlib'],
4317 ['bzip2'],
4318
4319 # components
4320 ['backlight'],
4321 ['binfmt'],
4322 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
4323 ['coredump'],
4324 ['environment.d'],
4325 ['efi'],
4326 ['gnu-efi'],
4327 ['firstboot'],
4328 ['hibernate'],
4329 ['homed'],
4330 ['hostnamed'],
4331 ['hwdb'],
4332 ['importd'],
4333 ['initrd'],
4334 ['kernel-install'],
4335 ['localed'],
4336 ['logind'],
4337 ['machined'],
4338 ['networkd'],
4339 ['nss-myhostname'],
4340 ['nss-mymachines'],
4341 ['nss-resolve'],
4342 ['nss-systemd'],
4343 ['oomd'],
4344 ['portabled'],
4345 ['pstore'],
4346 ['quotacheck'],
4347 ['randomseed'],
4348 ['repart'],
4349 ['resolve'],
4350 ['rfkill'],
4351 ['sysext'],
4352 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
4353 ['sysupdate'],
4354 ['sysusers'],
4355 ['timedated'],
4356 ['timesyncd'],
4357 ['tmpfiles'],
4358 ['userdb'],
4359 ['vconsole'],
4360 ['xdg-autostart'],
4361
4362 # optional features
4363 ['idn'],
4364 ['polkit'],
4365 ['nscd'],
4366 ['legacy-pkla', install_polkit_pkla],
4367 ['kmod'],
4368 ['dbus'],
4369 ['glib'],
4370 ['tpm'],
4371 ['man pages', want_man],
4372 ['html pages', want_html],
4373 ['man page indices', want_man and have_lxml],
4374 ['SysV compat'],
4375 ['compat-mutable-uid-boundaries'],
4376 ['utmp'],
4377 ['ldconfig'],
4378 ['adm group', get_option('adm-group')],
4379 ['wheel group', get_option('wheel-group')],
4380 ['gshadow'],
4381 ['debug hashmap'],
4382 ['debug mmap cache'],
4383 ['debug siphash'],
4384 ['valgrind', conf.get('VALGRIND') == 1],
4385 ['trace logging', conf.get('LOG_TRACE') == 1],
4386 ['install tests', install_tests],
4387 ['link-udev-shared', get_option('link-udev-shared')],
4388 ['link-systemctl-shared', get_option('link-systemctl-shared')],
4389 ['link-networkd-shared', get_option('link-networkd-shared')],
4390 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
4391 ['link-journalctl-shared', get_option('link-journalctl-shared')],
4392 ['link-boot-shared', get_option('link-boot-shared')],
4393 ['first-boot-full-preset'],
4394 ['fexecve'],
4395 ['standalone-binaries', get_option('standalone-binaries')],
4396 ['coverage', get_option('b_coverage')],
4397 ]
4398
4399 if tuple.length() >= 2
4400 cond = tuple[1]
4401 else
4402 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
4403 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
4404 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
4405 endif
4406 if cond
4407 found += tuple[0]
4408 else
4409 missing += tuple[0]
4410 endif
4411 endforeach
4412
4413 if static_libsystemd == 'false'
4414 missing += 'static-libsystemd'
4415 else
4416 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
4417 endif
4418
4419 if static_libudev == 'false'
4420 missing += 'static-libudev'
4421 else
4422 found += 'static-libudev(@0@)'.format(static_libudev)
4423 endif
4424
4425 if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
4426 found += 'cryptolib(openssl)'
4427 elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
4428 found += 'cryptolib(gcrypt)'
4429 else
4430 missing += 'cryptolib'
4431 endif
4432
4433 if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
4434 found += 'DNS-over-TLS(gnutls)'
4435 elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
4436 found += 'DNS-over-TLS(openssl)'
4437 else
4438 missing += 'DNS-over-TLS'
4439 endif
4440
4441 summary({
4442 'enabled' : ', '.join(found),
4443 'disabled' : ', '.join(missing)},
4444 section : 'Features')
4445
4446 if rootprefixdir != rootprefix_default
4447 warning('\n' +
4448 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
4449 'systemd used fixed names for unit file directories and other paths, so anything\n' +
4450 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))
4451 endif