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