1 # SPDX-License-Identifier: LGPL-2.1-or-later
3 project('systemd', 'c',
13 meson_version : '>= 0.53.2',
16 libsystemd_version = '0.36.0'
17 libudev_version = '1.7.6'
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)')
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),
31 check : true).stdout().strip()
32 conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)
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
40 verification = verification == 'true'
42 conf.set10('LOG_MESSAGE_VERIFICATION', verification)
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')
50 skip_deps = want_ossfuzz or get_option('skip-deps')
51 fuzzer_build = want_ossfuzz or want_libfuzzer
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
56 conf.set10('FUZZ_USE_SIZE_LIMIT', fuzzer_build)
58 # We'll set this to '1' for EFI builds in a different place.
59 conf.set10('SD_BOOT', false)
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')})
65 #####################################################################
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())
76 #####################################################################
79 if get_option('split-usr') == 'auto'
80 split_usr = not fs.is_symlink('/bin')
82 split_usr = get_option('split-usr') == 'true'
85 warning('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n\n'
86 + ' split-usr mode is going to be removed\n' +
87 '\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
89 conf.set10('HAVE_SPLIT_USR', split_usr,
90 description : '/usr/bin and /bin directories are separate')
92 if get_option('split-bin') == 'auto'
93 split_bin = not fs.is_symlink('/usr/sbin')
95 split_bin = get_option('split-bin') == 'true'
97 conf.set10('HAVE_SPLIT_BIN', split_bin,
98 description : 'bin and sbin directories are separate')
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
107 rootprefixdir_noslash = rootprefixdir == '/' ? '' : rootprefixdir
109 have_standalone_binaries = get_option('standalone-binaries')
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'))
117 if get_option('hibernate') and not get_option('initrd')
118 error('hibernate depends on initrd')
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)
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))
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))
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')
144 rootbindir = rootprefixdir / 'bin'
145 rootsbindir = rootprefixdir / (split_bin ? 'sbin' : 'bin')
146 rootlibexecdir = rootprefixdir / 'lib/systemd'
148 rootlibdir = get_option('rootlibdir')
150 # This will be a relative path if libdir is in prefix.
151 rootlibdir = get_option('libdir')
153 if not rootlibdir.startswith('/')
154 # If we have a relative path, add rootprefixdir to the front.
155 rootlibdir = rootprefixdir / rootlibdir
157 rootpkglibdir = rootlibdir / 'systemd'
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
172 modprobedir = rootprefixdir / 'lib/modprobe.d'
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'
212 docdir = get_option('docdir')
214 docdir = datadir / 'doc/systemd'
217 pamlibdir = get_option('pamlibdir')
219 pamlibdir = rootlibdir / 'security'
222 pamconfdir = get_option('pamconfdir')
224 pamconfdir = prefixdir / 'lib/pam.d'
227 libcryptsetup_plugins_dir = get_option('libcryptsetup-plugins-dir')
228 if libcryptsetup_plugins_dir == ''
229 libcryptsetup_plugins_dir = rootlibdir / 'cryptsetup'
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'
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')
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)
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'))
318 conf.set10('FIRST_BOOT_FULL_PRESET', get_option('first-boot-full-preset'))
320 #####################################################################
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')
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')
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())
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'
347 error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported')
350 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
353 # Those generate many false positives, and we do not want to change the code to
355 basic_disabled_warnings = [
356 '-Wno-missing-field-initializers',
357 '-Wno-unused-parameter',
360 possible_common_cc_flags = [
361 '-Warray-bounds', # clang
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',
374 '-Werror=override-init',
375 '-Werror=return-type',
376 '-Werror=shift-count-overflow',
377 '-Werror=shift-overflow=2',
380 # gperf prevents us from enabling this because it does not emit fallthrough
381 # attribute with clang.
382 #'-Wimplicit-fallthrough',
383 '-Wimplicit-fallthrough=5',
386 '-Wmissing-include-dirs',
387 '-Wmissing-noreturn',
389 '-Wold-style-definition',
393 '-Wstrict-aliasing=2',
394 '-Wstrict-prototypes',
395 '-Wsuggest-attribute=noreturn',
398 '-Wzero-length-bounds',
400 # negative arguments are correctly detected starting with meson 0.46.
401 '-Wno-error=#warnings', # clang
402 '-Wno-string-plus-int', # clang
404 '-fdiagnostics-show-option',
407 '-fstack-protector-strong',
408 '-fstrict-flex-arrays',
409 '--param=ssp-buffer-size=4',
412 possible_common_link_flags = [
416 c_args = get_option('c_args')
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.')
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
433 possible_common_cc_flags += '-Wno-maybe-uninitialized'
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'
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',
450 if get_option('b_sanitize') == 'none'
451 possible_link_flags += '-Wl,--warn-common'
454 if cc.get_id() == 'clang'
455 possible_common_cc_flags += [
456 '-Wno-typedef-redefinition',
457 '-Wno-gnu-variable-sized-type-not-at-end',
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'
468 possible_cc_flags = [
469 '-fno-strict-aliasing',
470 '-fstrict-flex-arrays=1',
471 '-fvisibility=hidden',
474 if get_option('buildtype') != 'debug'
475 possible_cc_flags += [
476 '-ffunction-sections',
480 possible_link_flags += '-Wl,--gc-sections'
483 if get_option('mode') == 'developer'
484 possible_cc_flags += '-fno-omit-frame-pointer'
487 add_project_arguments(
488 cc.get_supported_arguments(
489 basic_disabled_warnings,
490 possible_common_cc_flags
494 add_project_link_arguments(
495 cc.get_supported_link_arguments(possible_common_link_flags),
498 userspace_c_args += cc.get_supported_arguments(possible_cc_flags)
499 userspace_c_ld_args += cc.get_supported_link_arguments(possible_link_flags)
501 have = cc.has_argument('-Wzero-length-bounds')
502 conf.set10('HAVE_ZERO_LENGTH_BOUNDS', have)
506 #include <inttypes.h>
507 typedef uint64_t usec_t;
508 usec_t now(clockid_t clock);
513 ''', args: '-Werror=shadow', name : '-Werror=shadow with local shadowing')
514 add_project_arguments('-Werror=shadow', language : 'c')
518 add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
521 cpp = ' '.join(cc.cmd_array()) + ' -E'
523 has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
525 #####################################################################
526 # compilation result tests
528 conf.set('_GNU_SOURCE', true)
529 conf.set('__SANE_USERSPACE_TYPES__', true)
530 conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)
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>'))
538 long_max = cc.compute_int(
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))
548 #include <sys/mount.h>
549 #include <sys/stat.h>
552 foreach decl : ['char16_t',
558 # We get -1 if the size cannot be determined
559 have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
561 if decl == 'struct mount_attr'
563 want_linux_fs_h = false
565 have = cc.sizeof(decl,
566 prefix : decl_headers + '#include <linux/fs.h>',
567 args : '-D_GNU_SOURCE') > 0
568 want_linux_fs_h = have
572 if decl == 'struct statx'
574 want_linux_stat_h = false
576 have = cc.sizeof(decl,
577 prefix : decl_headers + '#include <linux/stat.h>',
578 args : '-D_GNU_SOURCE') > 0
579 want_linux_stat_h = have
583 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
586 conf.set10('WANT_LINUX_STAT_H', want_linux_stat_h)
587 conf.set10('WANT_LINUX_FS_H', want_linux_fs_h)
589 foreach ident : ['secure_getenv', '__secure_getenv']
590 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
594 ['memfd_create', '''#include <sys/mman.h>'''],
595 ['gettid', '''#include <sys/types.h>
596 #include <unistd.h>'''],
597 ['pivot_root', '''#include <stdlib.h>
598 #include <unistd.h>'''], # no known header declares pivot_root
599 ['ioprio_get', '''#include <sched.h>'''], # no known header declares ioprio_get
600 ['ioprio_set', '''#include <sched.h>'''], # no known header declares ioprio_set
601 ['name_to_handle_at', '''#include <sys/types.h>
602 #include <sys/stat.h>
603 #include <fcntl.h>'''],
604 ['setns', '''#include <sched.h>'''],
605 ['renameat2', '''#include <stdio.h>
606 #include <fcntl.h>'''],
607 ['kcmp', '''#include <linux/kcmp.h>'''],
608 ['keyctl', '''#include <sys/types.h>
609 #include <keyutils.h>'''],
610 ['copy_file_range', '''#include <sys/syscall.h>
611 #include <unistd.h>'''],
612 ['bpf', '''#include <sys/syscall.h>
613 #include <unistd.h>'''],
614 ['statx', '''#include <sys/types.h>
615 #include <sys/stat.h>
616 #include <unistd.h>'''],
617 ['explicit_bzero' , '''#include <string.h>'''],
618 ['reallocarray', '''#include <stdlib.h>'''],
619 ['set_mempolicy', '''#include <stdlib.h>
620 #include <unistd.h>'''],
621 ['get_mempolicy', '''#include <stdlib.h>
622 #include <unistd.h>'''],
623 ['pidfd_send_signal', '''#include <stdlib.h>
626 #include <sys/wait.h>'''],
627 ['pidfd_open', '''#include <stdlib.h>
630 #include <sys/wait.h>'''],
631 ['rt_sigqueueinfo', '''#include <stdlib.h>
634 #include <sys/wait.h>'''],
635 ['rt_tgsigqueueinfo', '''#include <stdlib.h>
638 #include <sys/wait.h>'''],
639 ['mallinfo', '''#include <malloc.h>'''],
640 ['mallinfo2', '''#include <malloc.h>'''],
641 ['execveat', '''#include <unistd.h>'''],
642 ['close_range', '''#include <unistd.h>'''],
643 ['epoll_pwait2', '''#include <sys/epoll.h>'''],
644 ['mount_setattr', '''#include <sys/mount.h>'''],
645 ['move_mount', '''#include <sys/mount.h>'''],
646 ['open_tree', '''#include <sys/mount.h>'''],
647 ['fsopen', '''#include <sys/mount.h>'''],
648 ['fsconfig', '''#include <sys/mount.h>'''],
649 ['fsmount', '''#include <sys/mount.h>'''],
650 ['getdents64', '''#include <dirent.h>'''],
653 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
654 conf.set10('HAVE_' + ident[0].to_upper(), have)
657 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
658 conf.set10('USE_SYS_RANDOM_H', true)
659 conf.set10('HAVE_GETRANDOM', true)
661 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
662 conf.set10('USE_SYS_RANDOM_H', false)
663 conf.set10('HAVE_GETRANDOM', have)
666 #####################################################################
668 version_tag = get_option('version-tag')
670 vcs_data = configuration_data()
671 vcs_data.set('VCS_TAG', version_tag)
672 version_h = configure_file(configuration : vcs_data,
673 input : 'src/version/version.h.in',
674 output : 'version.h')
677 project_source_root + '/tools/meson-vcs-tag.sh',
679 meson.project_version()]
682 input : 'src/version/version.h.in',
683 output : 'version.h',
687 versiondep = declare_dependency(
689 include_directories : include_directories('.'))
691 shared_lib_tag = get_option('shared-lib-tag')
692 if shared_lib_tag == ''
693 shared_lib_tag = meson.project_version()
696 sh = find_program('sh')
697 echo = find_program('echo')
698 sed = find_program('sed')
699 awk = find_program('awk')
700 stat = find_program('stat')
701 ln = find_program('ln')
702 git = find_program('git', required : false)
703 env = find_program('env')
704 perl = find_program('perl', required : false)
705 rsync = find_program('rsync', required : false)
706 meson_make_symlink = project_source_root + '/tools/meson-make-symlink.sh'
708 mkdir_p = 'mkdir -p $DESTDIR/@0@'
710 # If -Dxxx-path option is found, use that. Otherwise, check in $PATH,
711 # /usr/sbin, /sbin, and fall back to the default from middle column.
712 progs = [['quotaon', '/usr/sbin/quotaon' ],
713 ['quotacheck', '/usr/sbin/quotacheck' ],
714 ['kmod', '/usr/bin/kmod' ],
715 ['kexec', '/usr/sbin/kexec' ],
716 ['sulogin', '/usr/sbin/sulogin' ],
717 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
718 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
719 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
720 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
721 ['nologin', '/usr/sbin/nologin', ],
724 path = get_option(prog[0] + '-path')
726 message('Using @1@ for @0@'.format(prog[0], path))
728 exe = find_program(prog[0],
729 '/usr/sbin/' + prog[0],
732 path = exe.found() ? exe.path() : prog[1]
734 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
735 conf.set_quoted(name, path)
738 conf.set_quoted('TELINIT', get_option('telinit-path'))
740 if run_command(ln, '--relative', '--help', check : false).returncode() != 0
741 error('ln does not support --relative (added in coreutils 8.16)')
744 ############################################################
746 gperf = find_program('gperf')
748 gperf_test_format = '''
750 const char * in_word_set(const char *, @0@);
753 gperf_snippet = run_command(sh, '-c', 'echo foo,bar | "$1" -L ANSI-C', '_', gperf,
755 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
756 if cc.compiles(gperf_test)
757 gperf_len_type = 'size_t'
759 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
760 if cc.compiles(gperf_test)
761 gperf_len_type = 'unsigned'
763 error('unable to determine gperf len type')
766 message('gperf len type is @0@'.format(gperf_len_type))
767 conf.set('GPERF_LEN_TYPE', gperf_len_type,
768 description : 'The type of gperf "len" parameter')
770 ############################################################
772 if not cc.has_header('sys/capability.h')
773 error('POSIX caps headers not found')
775 foreach header : ['crypt.h',
777 'linux/vm_sockets.h',
780 'valgrind/memcheck.h',
781 'valgrind/valgrind.h',
782 'linux/time_types.h',
786 conf.set10('HAVE_' + header.underscorify().to_upper(),
787 cc.has_header(header))
790 ############################################################
792 fallback_hostname = get_option('fallback-hostname')
793 if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0] == '-'
794 error('Invalid fallback-hostname configuration')
795 # A more extensive test is done in test-hostname-util. Let's catch
796 # the most obvious errors here so we don't fail with an assert later.
798 conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
800 default_hierarchy = get_option('default-hierarchy')
801 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
802 description : 'default cgroup hierarchy as string')
803 if default_hierarchy == 'legacy'
804 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
805 elif default_hierarchy == 'hybrid'
806 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
808 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
811 extra_net_naming_schemes = []
812 extra_net_naming_map = []
813 foreach scheme: get_option('extra-net-naming-schemes').split(',')
815 name = scheme.split('=')[0]
816 value = scheme.split('=')[1]
817 NAME = name.underscorify().to_upper()
819 foreach field: value.split('+')
820 VALUE += 'NAMING_' + field.underscorify().to_upper()
822 extra_net_naming_schemes += 'NAMING_@0@ = @1@,'.format(NAME, '|'.join(VALUE))
823 extra_net_naming_map += '{ "@0@", NAMING_@1@ },'.format(name, NAME)
826 conf.set('EXTRA_NET_NAMING_SCHEMES', ' '.join(extra_net_naming_schemes))
827 conf.set('EXTRA_NET_NAMING_MAP', ' '.join(extra_net_naming_map))
829 default_net_naming_scheme = get_option('default-net-naming-scheme')
830 conf.set_quoted('DEFAULT_NET_NAMING_SCHEME', default_net_naming_scheme)
831 if default_net_naming_scheme != 'latest'
832 conf.set('_DEFAULT_NET_NAMING_SCHEME_TEST',
833 'NAMING_' + default_net_naming_scheme.underscorify().to_upper())
836 time_epoch = get_option('time-epoch')
838 time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check : true).stdout().strip()
839 if time_epoch == '' and git.found() and fs.is_dir('.git')
840 # If we're in a git repository, use the creation time of the latest git tag.
841 latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags',
843 if latest_tag.returncode() == 0
844 time_epoch = run_command(
845 git, 'log', '--no-show-signature', '-1', '--format=%at',
846 latest_tag.stdout().strip(),
847 check : false).stdout()
852 time_epoch = run_command(stat, '-c', '%Y', NEWS,
853 check : true).stdout()
855 time_epoch = time_epoch.strip().to_int()
857 conf.set('TIME_EPOCH', time_epoch)
859 conf.set('CLOCK_VALID_RANGE_USEC_MAX', get_option('clock-valid-range-usec-max'))
861 default_user_shell = get_option('default-user-shell')
862 conf.set_quoted('DEFAULT_USER_SHELL', default_user_shell)
863 conf.set_quoted('DEFAULT_USER_SHELL_NAME', fs.name(default_user_shell))
865 foreach tuple : [['system-alloc-uid-min', 'SYS_UID_MIN', 1], # Also see login.defs(5).
866 ['system-uid-max', 'SYS_UID_MAX', 999],
867 ['system-alloc-gid-min', 'SYS_GID_MIN', 1],
868 ['system-gid-max', 'SYS_GID_MAX', 999]]
869 v = get_option(tuple[0])
873 '/^\s*@0@\s+/ { uid=$2 } END { print uid }'.format(tuple[1]),
875 check : false).stdout().strip()
882 conf.set(tuple[0].underscorify().to_upper(), v)
884 if conf.get('SYSTEM_ALLOC_UID_MIN') >= conf.get('SYSTEM_UID_MAX')
885 error('Invalid uid allocation range')
887 if conf.get('SYSTEM_ALLOC_GID_MIN') >= conf.get('SYSTEM_GID_MAX')
888 error('Invalid gid allocation range')
891 dynamic_uid_min = get_option('dynamic-uid-min')
892 dynamic_uid_max = get_option('dynamic-uid-max')
893 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
894 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
896 container_uid_base_min = get_option('container-uid-base-min')
897 container_uid_base_max = get_option('container-uid-base-max')
898 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
899 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
901 nobody_user = get_option('nobody-user')
902 nobody_group = get_option('nobody-group')
904 if not meson.is_cross_build()
905 getent_result = run_command('getent', 'passwd', '65534', check : false)
906 if getent_result.returncode() == 0
907 name = getent_result.stdout().split(':')[0]
908 if name != nobody_user
910 '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) +
911 'Your build will result in an user table setup that is incompatible with the local system.')
914 id_result = run_command('id', '-u', nobody_user, check : false)
915 if id_result.returncode() == 0
916 id = id_result.stdout().strip().to_int()
919 '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) +
920 'Your build will result in an user table setup that is incompatible with the local system.')
924 getent_result = run_command('getent', 'group', '65534', check : false)
925 if getent_result.returncode() == 0
926 name = getent_result.stdout().split(':')[0]
927 if name != nobody_group
929 '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) +
930 'Your build will result in an group table setup that is incompatible with the local system.')
933 id_result = run_command('id', '-g', nobody_group, check : false)
934 if id_result.returncode() == 0
935 id = id_result.stdout().strip().to_int()
938 '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) +
939 'Your build will result in an group table setup that is incompatible with the local system.')
943 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
945 'The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
946 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
949 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
950 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
953 foreach option : ['adm-gid',
970 'systemd-journal-gid',
971 'systemd-network-uid',
972 'systemd-resolve-uid',
973 'systemd-timesync-uid']
974 name = option.underscorify().to_upper()
975 val = get_option(option)
977 # Ensure provided GID argument is numeric, otherwise fall back to default assignment
978 conf.set(name, val > 0 ? val : '-')
980 static_ugids += '@0@:@1@'.format(option, val)
984 conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
985 conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
987 dev_kvm_mode = get_option('dev-kvm-mode')
988 conf.set_quoted('DEV_KVM_MODE', dev_kvm_mode) # FIXME: convert to 0o… notation
989 conf.set10('DEV_KVM_UACCESS', dev_kvm_mode != '0666')
990 group_render_mode = get_option('group-render-mode')
991 conf.set_quoted('GROUP_RENDER_MODE', group_render_mode)
992 conf.set10('GROUP_RENDER_UACCESS', group_render_mode != '0666')
994 kill_user_processes = get_option('default-kill-user-processes')
995 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
997 dns_servers = get_option('dns-servers')
998 conf.set_quoted('DNS_SERVERS', dns_servers)
1000 ntp_servers = get_option('ntp-servers')
1001 conf.set_quoted('NTP_SERVERS', ntp_servers)
1003 default_locale = get_option('default-locale')
1004 conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale)
1006 nspawn_locale = get_option('nspawn-locale')
1007 conf.set_quoted('SYSTEMD_NSPAWN_LOCALE', nspawn_locale)
1009 default_keymap = get_option('default-keymap')
1010 conf.set_quoted('SYSTEMD_DEFAULT_KEYMAP', default_keymap)
1012 localegen_path = get_option('localegen-path')
1013 if localegen_path != ''
1014 conf.set_quoted('LOCALEGEN_PATH', localegen_path)
1016 conf.set10('HAVE_LOCALEGEN', localegen_path != '')
1018 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
1020 service_watchdog = get_option('service-watchdog')
1021 watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
1022 conf.set_quoted('SERVICE_WATCHDOG', watchdog_value)
1024 conf.set_quoted('SUSHELL', get_option('debug-shell'))
1025 conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
1027 enable_debug_hashmap = false
1028 enable_debug_mmap_cache = false
1029 enable_debug_siphash = false
1030 foreach name : get_option('debug-extra')
1031 if name == 'hashmap'
1032 enable_debug_hashmap = true
1033 elif name == 'mmap-cache'
1034 enable_debug_mmap_cache = true
1035 elif name == 'siphash'
1036 enable_debug_siphash = true
1038 message('unknown debug option "@0@", ignoring'.format(name))
1041 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
1042 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
1043 conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash)
1044 conf.set10('LOG_TRACE', get_option('log-trace'))
1046 default_user_path = get_option('user-path')
1047 if default_user_path != ''
1048 conf.set_quoted('DEFAULT_USER_PATH', default_user_path)
1052 #####################################################################
1054 threads = dependency('threads')
1055 librt = cc.find_library('rt')
1056 libm = cc.find_library('m')
1057 libdl = cc.find_library('dl')
1058 libcrypt = cc.find_library('crypt')
1060 # On some architectures, libatomic is required. But on some installations,
1061 # it is found, but actual linking fails. So let's try to use it opportunistically.
1062 # If it is installed, but not needed, it will be dropped because of --as-needed.
1063 if cc.links('''int main(int argc, char **argv) { return 0; }''',
1066 libatomic = declare_dependency(link_args : '-latomic')
1071 crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
1073 ['crypt_ra', crypt_header],
1074 ['crypt_preferred_method', crypt_header],
1075 ['crypt_gensalt_ra', crypt_header]]
1077 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
1078 dependencies : libcrypt)
1079 conf.set10('HAVE_' + ident[0].to_upper(), have)
1082 libcap = dependency('libcap', required : false)
1083 if not libcap.found()
1084 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
1085 libcap = cc.find_library('cap')
1088 want_bpf_framework = get_option('bpf-framework')
1089 bpf_compiler = get_option('bpf-compiler')
1090 bpf_framework_required = want_bpf_framework == 'true'
1092 libbpf_version_requirement = '>= 0.1.0'
1093 if bpf_compiler == 'gcc'
1094 libbpf_version_requirement = '>= 1.0.0'
1096 libbpf = dependency('libbpf', required : bpf_framework_required, version : libbpf_version_requirement)
1097 conf.set10('HAVE_LIBBPF', libbpf.found())
1099 bpftool_strip_version_requirement = '>= 5.13.0'
1100 if bpf_compiler == 'gcc'
1101 bpftool_strip_version_requirement = '>= 7.0.0'
1104 if want_bpf_framework == 'false' or not libbpf.found() or skip_deps
1105 conf.set10('BPF_FRAMEWORK', false)
1108 clang_supports_bpf = false
1109 bpf_gcc_found = false
1110 bpftool_strip = false
1113 if bpf_compiler == 'clang'
1114 # Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu
1115 # (like clang-10/llvm-strip-10)
1116 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')
1117 r = find_program('clang', required : bpf_framework_required, version : '>= 10.0.0')
1118 clang_found = r.found()
1124 clang = cc.cmd_array()
1128 # Check if 'clang -target bpf' is supported.
1129 clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0
1131 elif bpf_compiler == 'gcc'
1132 warning('GCC BPF Compiler support is experimental and not recommended.')
1133 bpf_gcc = find_program('bpf-gcc',
1135 version : '>= 12.1.0')
1136 bpf_gcc_found = bpf_gcc.found()
1139 if clang_supports_bpf or bpf_gcc_found
1140 # Debian installs this in /usr/sbin/ which is not in $PATH.
1141 # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian.
1142 # We use 'bpftool gen object' subcommand for bpftool strip, it was added by d80b2fcbe0a023619e0fc73112f2a02c2662f6ab (v5.13).
1143 bpftool_strip_required = bpf_framework_required and bpf_compiler == 'gcc'
1144 bpftool = find_program('bpftool',
1145 '/usr/sbin/bpftool',
1146 required : bpftool_strip_required,
1147 version : bpftool_strip_version_requirement)
1150 bpftool_strip = true
1152 elif bpf_compiler == 'clang'
1153 # We require the 'bpftool gen skeleton' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6).
1154 bpftool = find_program('bpftool',
1155 '/usr/sbin/bpftool',
1156 required : bpf_framework_required,
1157 version : '>= 5.6.0')
1160 # We use `llvm-strip` as a fallback if `bpftool gen object` strip support is not available.
1161 if not bpftool_strip and bpftool.found() and clang_supports_bpf
1162 if not meson.is_cross_build()
1163 llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip',
1164 check : true).stdout().strip()
1166 llvm_strip_bin = 'llvm-strip'
1168 llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0')
1169 deps_found = llvm_strip.found()
1173 # Can build BPF program from source code in restricted C
1174 conf.set10('BPF_FRAMEWORK', deps_found)
1177 libmount = dependency('mount',
1178 version : fuzzer_build ? '>= 0' : '>= 2.30')
1180 want_libfdisk = get_option('fdisk')
1181 if want_libfdisk != 'false' and not skip_deps
1182 libfdisk = dependency('fdisk',
1183 version : '>= 2.32',
1184 required : want_libfdisk == 'true')
1185 have = libfdisk.found()
1190 conf.set10('HAVE_LIBFDISK', have)
1192 want_pwquality = get_option('pwquality')
1193 if want_pwquality != 'false' and not skip_deps
1194 libpwquality = dependency('pwquality', required : want_pwquality == 'true')
1195 have = libpwquality.found()
1200 conf.set10('HAVE_PWQUALITY', have)
1202 want_seccomp = get_option('seccomp')
1203 if want_seccomp != 'false' and not skip_deps
1204 libseccomp = dependency('libseccomp',
1205 version : '>= 2.3.1',
1206 required : want_seccomp == 'true')
1207 have = libseccomp.found()
1212 conf.set10('HAVE_SECCOMP', have)
1214 want_selinux = get_option('selinux')
1215 if want_selinux != 'false' and not skip_deps
1216 libselinux = dependency('libselinux',
1217 version : '>= 2.1.9',
1218 required : want_selinux == 'true')
1219 have = libselinux.found()
1224 conf.set10('HAVE_SELINUX', have)
1226 want_apparmor = get_option('apparmor')
1227 if want_apparmor != 'false' and not skip_deps
1228 libapparmor = dependency('libapparmor',
1229 version : '>= 2.13',
1230 required : want_apparmor == 'true')
1231 have = libapparmor.found()
1236 conf.set10('HAVE_APPARMOR', have)
1238 have = get_option('smack') and get_option('smack-run-label') != ''
1239 conf.set10('HAVE_SMACK_RUN_LABEL', have)
1241 conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
1244 have = get_option('smack') and get_option('smack-default-process-label') != ''
1246 conf.set_quoted('SMACK_DEFAULT_PROCESS_LABEL', get_option('smack-default-process-label'))
1249 want_polkit = get_option('polkit')
1250 install_polkit = false
1251 install_polkit_pkla = false
1252 if want_polkit != 'false' and not skip_deps
1253 install_polkit = true
1255 libpolkit = dependency('polkit-gobject-1',
1257 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
1258 message('Old polkit detected, will install pkla files')
1259 install_polkit_pkla = true
1262 conf.set10('ENABLE_POLKIT', install_polkit)
1264 want_acl = get_option('acl')
1265 if want_acl != 'false' and not skip_deps
1266 libacl = cc.find_library('acl', required : want_acl == 'true')
1267 have = libacl.found()
1272 conf.set10('HAVE_ACL', have)
1274 want_audit = get_option('audit')
1275 if want_audit != 'false' and not skip_deps
1276 libaudit = dependency('audit', required : want_audit == 'true')
1277 have = libaudit.found()
1282 conf.set10('HAVE_AUDIT', have)
1284 want_blkid = get_option('blkid')
1285 if want_blkid != 'false' and not skip_deps
1286 libblkid = dependency('blkid', required : want_blkid == 'true')
1287 have = libblkid.found()
1289 conf.set10('HAVE_BLKID_PROBE_SET_HINT',
1290 have and cc.has_function('blkid_probe_set_hint', dependencies : libblkid))
1295 conf.set10('HAVE_BLKID', have)
1297 want_kmod = get_option('kmod')
1298 if want_kmod != 'false' and not skip_deps
1299 libkmod = dependency('libkmod',
1301 required : want_kmod == 'true')
1302 have = libkmod.found()
1307 conf.set10('HAVE_KMOD', have)
1309 want_xenctrl = get_option('xenctrl')
1310 if want_xenctrl != 'false' and not skip_deps
1311 libxenctrl = dependency('xencontrol',
1313 required : want_xenctrl == 'true')
1314 have = libxenctrl.found()
1319 conf.set10('HAVE_XENCTRL', have)
1321 want_pam = get_option('pam')
1322 if want_pam != 'false' and not skip_deps
1323 libpam = cc.find_library('pam', required : want_pam == 'true')
1324 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1325 have = libpam.found() and libpam_misc.found()
1331 conf.set10('HAVE_PAM', have)
1333 want_microhttpd = get_option('microhttpd')
1334 if want_microhttpd != 'false' and not skip_deps
1335 libmicrohttpd = dependency('libmicrohttpd',
1336 version : '>= 0.9.33',
1337 required : want_microhttpd == 'true')
1338 have = libmicrohttpd.found()
1343 conf.set10('HAVE_MICROHTTPD', have)
1345 want_libcryptsetup = get_option('libcryptsetup')
1346 want_libcryptsetup_plugins = get_option('libcryptsetup-plugins')
1348 if want_libcryptsetup_plugins == 'true' and want_libcryptsetup == 'false'
1349 error('libcryptsetup-plugins can not be requested without libcryptsetup')
1352 if want_libcryptsetup != 'false' and not skip_deps
1353 libcryptsetup = dependency('libcryptsetup',
1354 version : want_libcryptsetup_plugins == 'true' ? '>= 2.4.0' : '>= 2.0.1',
1355 required : want_libcryptsetup == 'true' or want_libcryptsetup_plugins == 'true')
1356 have = libcryptsetup.found()
1358 foreach ident : ['crypt_set_metadata_size',
1359 'crypt_activate_by_signed_key',
1361 'crypt_reencrypt_init_by_passphrase',
1363 'crypt_set_data_offset']
1364 have_ident = have and cc.has_function(
1366 prefix : '#include <libcryptsetup.h>',
1367 dependencies : libcryptsetup)
1368 conf.set10('HAVE_' + ident.to_upper(), have_ident)
1374 conf.set10('HAVE_LIBCRYPTSETUP', have)
1376 if want_libcryptsetup_plugins != 'false' and not skip_deps
1377 have = (cc.has_function(
1378 'crypt_activate_by_token_pin',
1379 prefix : '#include <libcryptsetup.h>',
1380 dependencies : libcryptsetup) and
1382 'crypt_token_external_path',
1383 prefix : '#include <libcryptsetup.h>',
1384 dependencies : libcryptsetup))
1388 conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have)
1390 want_libcurl = get_option('libcurl')
1391 if want_libcurl != 'false' and not skip_deps
1392 libcurl = dependency('libcurl',
1393 version : '>= 7.32.0',
1394 required : want_libcurl == 'true')
1395 have = libcurl.found()
1400 conf.set10('HAVE_LIBCURL', have)
1401 conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
1403 want_libidn = get_option('libidn')
1404 want_libidn2 = get_option('libidn2')
1405 if want_libidn == 'true' and want_libidn2 == 'true'
1406 error('libidn and libidn2 cannot be requested simultaneously')
1409 if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps
1410 libidn = dependency('libidn2',
1411 required : want_libidn2 == 'true')
1412 have = libidn.found()
1417 conf.set10('HAVE_LIBIDN2', have)
1418 if not have and want_libidn != 'false' and not skip_deps
1419 # libidn is used for both libidn and libidn2 objects
1420 libidn = dependency('libidn',
1421 required : want_libidn == 'true')
1422 have = libidn.found()
1426 conf.set10('HAVE_LIBIDN', have)
1428 want_libiptc = get_option('libiptc')
1429 if want_libiptc != 'false' and not skip_deps
1430 libiptc = dependency('libiptc',
1431 required : want_libiptc == 'true')
1432 have = libiptc.found()
1437 conf.set10('HAVE_LIBIPTC', have)
1439 want_qrencode = get_option('qrencode')
1440 if want_qrencode != 'false' and not skip_deps
1441 libqrencode = dependency('libqrencode',
1443 required : want_qrencode == 'true')
1444 have = libqrencode.found()
1449 conf.set10('HAVE_QRENCODE', have)
1451 want_gcrypt = get_option('gcrypt')
1452 if want_gcrypt != 'false' and not skip_deps
1453 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1454 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1455 have = libgcrypt.found() and libgpg_error.found()
1460 # link to neither of the libs if one is not found
1464 conf.set10('HAVE_GCRYPT', have)
1466 want_gnutls = get_option('gnutls')
1467 if want_gnutls != 'false' and not skip_deps
1468 libgnutls = dependency('gnutls',
1469 version : '>= 3.1.4',
1470 required : want_gnutls == 'true')
1471 have = libgnutls.found()
1476 conf.set10('HAVE_GNUTLS', have)
1478 want_openssl = get_option('openssl')
1479 if want_openssl != 'false' and not skip_deps
1480 libopenssl = dependency('openssl',
1481 version : '>= 1.1.0',
1482 required : want_openssl == 'true')
1483 have = libopenssl.found()
1488 conf.set10('HAVE_OPENSSL', have)
1490 want_p11kit = get_option('p11kit')
1491 if want_p11kit != 'false' and not skip_deps
1492 libp11kit = dependency('p11-kit-1',
1493 version : '>= 0.23.3',
1494 required : want_p11kit == 'true')
1495 have = libp11kit.found()
1496 libp11kit_cflags = libp11kit.partial_dependency(includes: true, compile_args: true)
1499 libp11kit_cflags = []
1502 conf.set10('HAVE_P11KIT', have)
1504 want_libfido2 = get_option('libfido2')
1505 if want_libfido2 != 'false' and not skip_deps
1506 if conf.get('HAVE_OPENSSL') == 1
1507 libfido2 = dependency('libfido2',
1508 required : want_libfido2 == 'true')
1509 have = libfido2.found()
1510 elif want_libfido2 == 'true'
1511 error('libfido2=true requires openssl')
1520 conf.set10('HAVE_LIBFIDO2', have)
1522 want_tpm2 = get_option('tpm2')
1523 if want_tpm2 != 'false' and not skip_deps
1524 tpm2 = dependency('tss2-esys tss2-rc tss2-mu',
1525 required : want_tpm2 == 'true')
1527 have_esys3 = tpm2.version().version_compare('>= 3.0.0')
1533 conf.set10('HAVE_TPM2', have)
1534 conf.set10('HAVE_TSS2_ESYS3', have_esys3)
1536 want_elfutils = get_option('elfutils')
1537 if want_elfutils != 'false' and not skip_deps
1538 libdw = dependency('libdw',
1539 required : want_elfutils == 'true')
1540 have = libdw.found()
1542 # New in elfutils 0.177
1543 conf.set10('HAVE_DWELF_ELF_E_MACHINE_STRING',
1544 have and cc.has_function('dwelf_elf_e_machine_string', dependencies : libdw))
1549 conf.set10('HAVE_ELFUTILS', have)
1551 want_zlib = get_option('zlib')
1552 if want_zlib != 'false' and not skip_deps
1553 libz = dependency('zlib',
1554 required : want_zlib == 'true')
1560 conf.set10('HAVE_ZLIB', have)
1562 want_bzip2 = get_option('bzip2')
1563 if want_bzip2 != 'false' and not skip_deps
1564 libbzip2 = cc.find_library('bz2',
1565 required : want_bzip2 == 'true')
1566 have = libbzip2.found()
1571 conf.set10('HAVE_BZIP2', have)
1573 want_xz = get_option('xz')
1574 if want_xz != 'false' and not skip_deps
1575 libxz = dependency('liblzma',
1576 required : want_xz == 'true')
1577 have_xz = libxz.found()
1582 conf.set10('HAVE_XZ', have_xz)
1584 want_lz4 = get_option('lz4')
1585 if want_lz4 != 'false' and not skip_deps
1586 liblz4 = dependency('liblz4',
1587 version : '>= 1.3.0',
1588 required : want_lz4 == 'true')
1589 have_lz4 = liblz4.found()
1594 conf.set10('HAVE_LZ4', have_lz4)
1596 want_zstd = get_option('zstd')
1597 if want_zstd != 'false' and not skip_deps
1598 libzstd = dependency('libzstd',
1599 required : want_zstd == 'true',
1600 version : '>= 1.4.0')
1601 have_zstd = libzstd.found()
1606 conf.set10('HAVE_ZSTD', have_zstd)
1608 conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
1610 compression = get_option('default-compression')
1611 if compression == 'auto'
1613 compression = 'zstd'
1619 compression = 'none'
1621 elif compression == 'zstd' and not have_zstd
1622 error('default-compression=zstd requires zstd')
1623 elif compression == 'lz4' and not have_lz4
1624 error('default-compression=lz4 requires lz4')
1625 elif compression == 'xz' and not have_xz
1626 error('default-compression=xz requires xz')
1628 conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper()))
1630 want_xkbcommon = get_option('xkbcommon')
1631 if want_xkbcommon != 'false' and not skip_deps
1632 libxkbcommon = dependency('xkbcommon',
1633 version : '>= 0.3.0',
1634 required : want_xkbcommon == 'true')
1635 have = libxkbcommon.found()
1640 conf.set10('HAVE_XKBCOMMON', have)
1642 want_pcre2 = get_option('pcre2')
1643 if want_pcre2 != 'false' and not skip_deps
1644 libpcre2 = dependency('libpcre2-8',
1645 required : want_pcre2 == 'true')
1646 have = libpcre2.found()
1651 conf.set10('HAVE_PCRE2', have)
1653 want_glib = get_option('glib')
1654 if want_glib != 'false' and not skip_deps
1655 libglib = dependency('glib-2.0',
1656 version : '>= 2.22.0',
1657 required : want_glib == 'true')
1658 libgobject = dependency('gobject-2.0',
1659 version : '>= 2.22.0',
1660 required : want_glib == 'true')
1661 libgio = dependency('gio-2.0',
1662 required : want_glib == 'true')
1663 have = libglib.found() and libgobject.found() and libgio.found()
1670 conf.set10('HAVE_GLIB', have)
1672 want_dbus = get_option('dbus')
1673 if want_dbus != 'false' and not skip_deps
1674 libdbus = dependency('dbus-1',
1675 version : '>= 1.3.2',
1676 required : want_dbus == 'true')
1677 have = libdbus.found()
1682 conf.set10('HAVE_DBUS', have)
1684 dbusdatadir = datadir / 'dbus-1'
1685 if conf.get('HAVE_DBUS') == 1
1686 dbusdatadir = libdbus.get_variable(pkgconfig: 'datadir', default_value: datadir) / 'dbus-1'
1689 dbuspolicydir = get_option('dbuspolicydir')
1690 if dbuspolicydir == ''
1691 dbuspolicydir = dbusdatadir / 'system.d'
1694 dbussessionservicedir = get_option('dbussessionservicedir')
1695 if dbussessionservicedir == ''
1696 dbussessionservicedir = dbusdatadir / 'services'
1697 if conf.get('HAVE_DBUS') == 1
1698 dbussessionservicedir = libdbus.get_variable(pkgconfig: 'session_bus_services_dir', default_value: dbussessionservicedir)
1702 dbussystemservicedir = get_option('dbussystemservicedir')
1703 if dbussystemservicedir == ''
1704 dbussystemservicedir = dbusdatadir / 'system-services'
1705 if conf.get('HAVE_DBUS') == 1
1706 dbussystemservicedir = libdbus.get_variable(pkgconfig: 'system_bus_services_dir', default_value: dbussystemservicedir)
1710 dbus_interfaces_dir = get_option('dbus-interfaces-dir')
1711 if dbus_interfaces_dir == '' or dbus_interfaces_dir == 'yes'
1712 if meson.is_cross_build() and dbus_interfaces_dir != 'yes'
1713 dbus_interfaces_dir = 'no'
1714 warning('Exporting D-Bus interface XML files is disabled during cross build. Pass path or "yes" to force enable.')
1716 dbus_interfaces_dir = dbusdatadir / 'interfaces'
1717 if conf.get('HAVE_DBUS') == 1
1718 dbus_interfaces_dir = libdbus.get_variable(pkgconfig: 'interfaces_dir', default_value: dbus_interfaces_dir)
1723 # We support one or the other. If gcrypt is available, we assume it's there to
1724 # be used, and use it in preference.
1725 opt = get_option('cryptolib')
1726 if opt == 'openssl' and conf.get('HAVE_OPENSSL') == 0
1727 error('openssl requested as the default cryptolib, but not available')
1729 conf.set10('PREFER_OPENSSL',
1730 opt == 'openssl' or (opt == 'auto' and conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_GCRYPT') == 0))
1731 conf.set10('HAVE_OPENSSL_OR_GCRYPT',
1732 conf.get('HAVE_OPENSSL') == 1 or conf.get('HAVE_GCRYPT') == 1)
1733 lib_openssl_or_gcrypt = conf.get('PREFER_OPENSSL') == 1 ? [libopenssl] : [libgcrypt, libgpg_error]
1735 dns_over_tls = get_option('dns-over-tls')
1736 if dns_over_tls != 'false'
1737 if dns_over_tls == 'gnutls' and conf.get('PREFER_OPENSSL') == 1
1738 error('Sorry, -Ddns-over-tls=gnutls is not supported when openssl is used as the cryptolib')
1741 if dns_over_tls == 'gnutls'
1742 have_openssl = false
1744 have_openssl = conf.get('HAVE_OPENSSL') == 1
1745 if dns_over_tls == 'openssl' and not have_openssl
1746 error('DNS-over-TLS support was requested with openssl, but dependencies are not available')
1749 if dns_over_tls == 'openssl' or have_openssl
1752 have_gnutls = conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0')
1753 if dns_over_tls != 'auto' and not have_gnutls
1754 str = dns_over_tls == 'gnutls' ? ' with gnutls' : ''
1755 error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
1758 have = have_gnutls or have_openssl
1762 have_openssl = false
1764 conf.set10('ENABLE_DNS_OVER_TLS', have)
1765 conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1766 conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
1768 default_dns_over_tls = get_option('default-dns-over-tls')
1770 default_dns_over_tls = 'no'
1772 if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
1773 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.')
1774 default_dns_over_tls = 'no'
1776 conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1777 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
1778 conf.set_quoted('DEFAULT_DNS_OVER_TLS_MODE_STR', default_dns_over_tls)
1780 default_mdns = get_option('default-mdns')
1781 conf.set('DEFAULT_MDNS_MODE',
1782 'RESOLVE_SUPPORT_' + default_mdns.to_upper())
1783 conf.set_quoted('DEFAULT_MDNS_MODE_STR', default_mdns)
1785 default_llmnr = get_option('default-llmnr')
1786 conf.set('DEFAULT_LLMNR_MODE',
1787 'RESOLVE_SUPPORT_' + default_llmnr.to_upper())
1788 conf.set_quoted('DEFAULT_LLMNR_MODE_STR', default_llmnr)
1790 want_repart = get_option('repart')
1791 if want_repart != 'false'
1792 have = conf.get('HAVE_LIBFDISK') == 1
1793 if want_repart == 'true' and not have
1794 error('repart support was requested, but dependencies are not available')
1799 conf.set10('ENABLE_REPART', have)
1801 default_dnssec = get_option('default-dnssec')
1803 default_dnssec = 'no'
1805 if default_dnssec != 'no' and conf.get('HAVE_OPENSSL_OR_GCRYPT') == 0
1806 message('default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.')
1807 default_dnssec = 'no'
1809 conf.set('DEFAULT_DNSSEC_MODE',
1810 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1811 conf.set_quoted('DEFAULT_DNSSEC_MODE_STR', default_dnssec)
1813 want_sysupdate = get_option('sysupdate')
1814 if want_sysupdate != 'false'
1815 have = (conf.get('HAVE_OPENSSL') == 1 and
1816 conf.get('HAVE_LIBFDISK') == 1)
1817 if want_sysupdate == 'true' and not have
1818 error('sysupdate support was requested, but dependencies are not available')
1823 conf.set10('ENABLE_SYSUPDATE', have)
1825 want_importd = get_option('importd')
1826 if want_importd != 'false'
1827 have = (conf.get('HAVE_LIBCURL') == 1 and
1828 conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and
1829 conf.get('HAVE_ZLIB') == 1 and
1830 conf.get('HAVE_XZ') == 1)
1831 if want_importd == 'true' and not have
1832 error('importd support was requested, but dependencies are not available')
1837 conf.set10('ENABLE_IMPORTD', have)
1839 want_kernel_install = get_option('kernel-install')
1840 conf.set10('ENABLE_KERNEL_INSTALL', want_kernel_install)
1842 want_homed = get_option('homed')
1843 if want_homed != 'false'
1844 have = (conf.get('HAVE_OPENSSL') == 1 and
1845 conf.get('HAVE_LIBFDISK') == 1 and
1846 conf.get('HAVE_LIBCRYPTSETUP') == 1)
1847 if want_homed == 'true' and not have
1848 error('homed support was requested, but dependencies are not available')
1853 conf.set10('ENABLE_HOMED', have)
1855 have = have and conf.get('HAVE_PAM') == 1
1856 conf.set10('ENABLE_PAM_HOME', have)
1858 have = get_option('oomd')
1859 conf.set10('ENABLE_OOMD', have)
1861 want_remote = get_option('remote')
1862 if want_remote != 'false'
1863 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1864 conf.get('HAVE_LIBCURL') == 1]
1865 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1866 # it's possible to build one without the other. Complain only if
1867 # support was explicitly requested. The auxiliary files like sysusers
1868 # config should be installed when any of the programs are built.
1869 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1870 error('remote support was requested, but dependencies are not available')
1872 have = have_deps[0] or have_deps[1]
1876 conf.set10('ENABLE_REMOTE', have)
1878 foreach term : ['analyze',
1881 'compat-mutable-uid-boundaries',
1918 have = get_option(term)
1919 name = 'ENABLE_' + term.underscorify().to_upper()
1920 conf.set10(name, have)
1923 enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
1925 foreach tuple : [['nss-mymachines', 'machined'],
1926 ['nss-resolve', 'resolve']]
1927 want = get_option(tuple[0])
1929 have = get_option(tuple[1])
1930 if want == 'true' and not have
1931 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1936 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1937 conf.set10(name, have)
1941 foreach term : ['ENABLE_NSS_MYHOSTNAME',
1942 'ENABLE_NSS_MYMACHINES',
1943 'ENABLE_NSS_RESOLVE',
1944 'ENABLE_NSS_SYSTEMD']
1945 if conf.get(term) == 1
1949 conf.set10('ENABLE_NSS', enable_nss)
1951 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1953 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1955 ############################################################
1963 ############################################################
1965 pymod = import('python')
1966 python = pymod.find_installation('python3', required : true, modules : ['jinja2'])
1967 python_39 = python.language_version().version_compare('>=3.9')
1969 #####################################################################
1974 'loongarch32' : 'loongarch32',
1975 'loongarch64' : 'loongarch64',
1976 'riscv32' : 'riscv32',
1977 'riscv64' : 'riscv64',
1980 }.get(host_machine.cpu_family(), '')
1982 if get_option('bootloader') != 'false' and efi_arch != ''
1983 conf.set_quoted('EFI_MACHINE_TYPE_NAME', efi_arch)
1984 elif get_option('bootloader') == 'true' and efi_arch == ''
1985 error('EFI not supported for this arch.')
1989 if efi_arch == 'x64' and cc.links('''
1991 int main(int argc, char *argv[]) {
1992 return __builtin_popcount(argc - CHAR_MAX);
1993 }''', args : ['-m32', '-march=i686'], name : '32bit build possible')
1994 efi_arch_alt = 'ia32'
1997 have_pyelftools = pymod.find_installation('python3', required : false, modules : ['elftools']).found()
1998 if get_option('bootloader') == 'true' and (not python_39 or not have_pyelftools)
1999 error('EFI bootloader support requires Python >= 3.9 and pyelftools.')
2003 'ENABLE_BOOTLOADER',
2004 get_option('efi') and
2005 get_option('bootloader') in ['auto', 'true'] and
2011 if get_option('ukify') == 'auto'
2012 want_ukify = python_39 and conf.get('ENABLE_BOOTLOADER') == 1
2013 elif get_option('ukify') == 'true' and (not python_39 or conf.get('ENABLE_BOOTLOADER') != 1)
2014 error('ukify requires Python >= 3.9 and -Dbootloader=true')
2016 want_ukify = get_option('ukify') == 'true'
2018 conf.set10('ENABLE_UKIFY', want_ukify)
2020 ############################################################
2022 elf2efi_lds = project_source_root / 'tools/elf2efi.lds'
2023 elf2efi_py = find_program('tools/elf2efi.py')
2024 export_dbus_interfaces_py = find_program('tools/dbus_exporter.py')
2025 generate_gperfs = find_program('tools/generate-gperfs.py')
2026 make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
2027 make_directive_index_py = find_program('tools/make-directive-index.py')
2028 make_man_index_py = find_program('tools/make-man-index.py')
2029 meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
2030 update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
2031 update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
2032 update_hwdb_sh = find_program('tools/update-hwdb.sh')
2033 update_man_rules_py = find_program('tools/update-man-rules.py')
2034 update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
2035 xml_helper_py = find_program('tools/xml_helper.py')
2037 ############################################################
2039 if get_option('b_coverage')
2040 userspace_c_args += ['-include', 'src/basic/coverage.h']
2043 ############################################################
2045 config_h = configure_file(
2046 output : 'config.h',
2047 configuration : conf)
2049 userspace_c_args += ['-include', 'config.h']
2051 jinja2_cmdline = [meson_render_jinja2, config_h, version_h]
2053 userspace = declare_dependency(
2054 compile_args : userspace_c_args,
2055 link_args : userspace_c_ld_args,
2058 ############################################################
2060 # binaries that have --help and are intended for use by humans,
2061 # usually, but not always, installed in /bin.
2062 public_programs = []
2064 # D-Bus introspection XML export
2067 basic_includes = include_directories(
2073 libsystemd_includes = [basic_includes, include_directories(
2074 'src/libsystemd/sd-bus',
2075 'src/libsystemd/sd-device',
2076 'src/libsystemd/sd-event',
2077 'src/libsystemd/sd-hwdb',
2078 'src/libsystemd/sd-id128',
2079 'src/libsystemd/sd-journal',
2080 'src/libsystemd/sd-netlink',
2081 'src/libsystemd/sd-network',
2082 'src/libsystemd/sd-resolve')]
2084 includes = [libsystemd_includes, include_directories('src/shared')]
2088 subdir('src/fundamental')
2090 subdir('src/libsystemd')
2091 subdir('src/shared')
2093 subdir('src/libudev')
2094 subdir('src/cryptsetup/cryptsetup-tokens')
2096 alias_target('devel', libsystemd_pc, libudev_pc)
2098 libsystemd = shared_library(
2100 version : libsystemd_version,
2101 include_directories : libsystemd_includes,
2102 link_args : ['-shared',
2103 '-Wl,--version-script=' + libsystemd_sym_path],
2104 link_with : [libbasic,
2107 link_whole : [libsystemd_static],
2108 dependencies : [librt,
2111 link_depends : libsystemd_sym,
2113 install_tag: 'libsystemd',
2114 install_dir : rootlibdir)
2116 alias_target('libsystemd', libsystemd)
2118 install_libsystemd_static = static_library(
2122 basic_gcrypt_sources,
2123 basic_compress_sources,
2124 fundamental_sources,
2125 include_directories : libsystemd_includes,
2126 build_by_default : static_libsystemd != 'false',
2127 install : static_libsystemd != 'false',
2128 install_tag: 'libsystemd',
2129 install_dir : rootlibdir,
2130 pic : static_libsystemd_pic,
2131 dependencies : [libblkid,
2144 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
2146 libudev = shared_library(
2148 version : libudev_version,
2149 include_directories : includes,
2150 link_args : ['-shared',
2151 '-Wl,--version-script=' + libudev_sym_path],
2152 link_with : [libsystemd_static, libshared_static],
2153 link_whole : libudev_basic,
2154 dependencies : [threads,
2156 link_depends : libudev_sym,
2158 install_tag: 'libudev',
2159 install_dir : rootlibdir)
2161 alias_target('libudev', libudev)
2163 install_libudev_static = static_library(
2166 fundamental_sources,
2170 include_directories : includes,
2171 build_by_default : static_libudev != 'false',
2172 install : static_libudev != 'false',
2173 install_tag: 'libudev',
2174 install_dir : rootlibdir,
2175 link_depends : libudev_sym,
2176 dependencies : [libmount,
2180 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
2181 pic : static_libudev_pic)
2183 if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
2184 if conf.get('HAVE_TPM2') == 1
2186 'cryptsetup-token-systemd-tpm2',
2187 cryptsetup_token_systemd_tpm2_sources,
2188 include_directories : includes,
2189 link_args : ['-shared',
2190 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2191 link_with : [lib_cryptsetup_token_common,
2193 dependencies : [libcryptsetup,
2197 link_depends : cryptsetup_token_sym,
2198 install_rpath : rootpkglibdir,
2200 install_dir : libcryptsetup_plugins_dir)
2203 if conf.get('HAVE_LIBFIDO2') == 1
2205 'cryptsetup-token-systemd-fido2',
2206 cryptsetup_token_systemd_fido2_sources,
2207 include_directories : includes,
2208 link_args : ['-shared',
2209 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2210 link_with : [lib_cryptsetup_token_common,
2212 dependencies : [libcryptsetup,
2216 link_depends : cryptsetup_token_sym,
2217 install_rpath : rootpkglibdir,
2219 install_dir : libcryptsetup_plugins_dir)
2222 if conf.get('HAVE_P11KIT') == 1
2224 'cryptsetup-token-systemd-pkcs11',
2225 cryptsetup_token_systemd_pkcs11_sources,
2226 include_directories : includes,
2227 link_args : ['-shared',
2228 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2229 link_with : [lib_cryptsetup_token_common,
2231 dependencies : [libcryptsetup,
2235 link_depends : cryptsetup_token_sym,
2236 install_rpath : rootpkglibdir,
2238 install_dir : libcryptsetup_plugins_dir)
2242 ############################################################
2244 # systemd-analyze requires 'libcore'
2246 # systemd-journal-remote requires 'libjournal_core'
2247 subdir('src/journal')
2248 # systemd-networkd requires 'libsystemd_network'
2249 subdir('src/libsystemd-network')
2251 subdir('src/analyze')
2253 subdir('src/boot/efi')
2254 subdir('src/busctl')
2255 subdir('src/coredump')
2256 subdir('src/cryptenroll')
2257 subdir('src/cryptsetup')
2259 subdir('src/hostname')
2260 subdir('src/import')
2261 subdir('src/journal-remote')
2262 subdir('src/kernel-install')
2263 subdir('src/locale')
2265 subdir('src/machine')
2266 subdir('src/network')
2267 subdir('src/nspawn')
2269 subdir('src/partition')
2270 subdir('src/portable')
2271 subdir('src/pstore')
2272 subdir('src/resolve')
2274 subdir('src/shutdown')
2275 subdir('src/sysext')
2276 subdir('src/systemctl')
2277 subdir('src/sysupdate')
2278 subdir('src/timedate')
2279 subdir('src/timesync')
2280 subdir('src/tmpfiles')
2281 subdir('src/userdb')
2282 subdir('src/xdg-autostart-generator')
2284 subdir('src/systemd')
2290 subdir('src/ukify/test') # needs to be last for test_env variable
2292 ############################################################
2294 # only static linking apart from libdl, to make sure that the
2295 # module is linked to all libraries that it uses.
2296 test_dlopen = executable(
2299 include_directories : includes,
2300 link_with : [libbasic],
2301 dependencies : [libdl,
2303 build_by_default : want_tests != 'false')
2305 foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
2306 ['systemd', 'ENABLE_NSS_SYSTEMD', ['nss-systemd.h', 'userdb-glue.c', 'userdb-glue.h']],
2307 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
2308 ['resolve', 'ENABLE_NSS_RESOLVE', [], resolve_includes]]
2310 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
2314 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
2315 version_script_arg = project_source_root / sym
2317 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
2318 if tuple.length() > 2
2319 foreach s : tuple[2]
2320 sources += ['src/nss-@0@/@1@'.format(module, s)]
2324 incs = tuple.length() > 3 ? tuple[3] : includes
2326 nss = shared_library(
2330 include_directories : incs,
2331 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
2332 link_args : ['-Wl,-z,nodelete',
2334 '-Wl,--version-script=' + version_script_arg],
2335 link_with : [libsystemd_static,
2338 dependencies : [librt,
2343 install_tag : 'nss',
2344 install_dir : rootlibdir)
2346 # We cannot use shared_module because it does not support version suffix.
2347 # Unfortunately shared_library insists on creating the symlink…
2348 meson.add_install_script('sh', '-c',
2349 'rm $DESTDIR@0@/libnss_@1@.so'
2350 .format(rootlibdir, module),
2354 if want_tests != 'false'
2355 test('dlopen-nss_' + module,
2357 # path to dlopen must include a slash
2358 args : nss.full_path(),
2364 ############################################################
2369 include_directories : includes,
2370 link_with : [libcore,
2372 dependencies : [libseccomp,
2375 install_rpath : rootpkglibdir,
2377 install_dir : rootlibexecdir)
2378 dbus_programs += exe
2379 public_programs += exe
2381 meson.add_install_script(meson_make_symlink,
2382 rootlibexecdir / 'systemd',
2383 rootsbindir / 'init')
2387 systemd_analyze_sources,
2388 include_directories : core_includes,
2389 link_with : [libcore,
2391 dependencies : [libseccomp,
2394 install_rpath : rootpkglibdir,
2395 install : conf.get('ENABLE_ANALYZE') == 1)
2396 public_programs += exe
2398 if want_tests != 'false'
2399 test('test-compare-versions',
2400 test_compare_versions_sh,
2401 args : exe.full_path())
2406 systemd_journald_sources,
2407 include_directories : includes,
2408 link_with : [libjournal_core,
2410 dependencies : [liblz4,
2417 install_rpath : rootpkglibdir,
2419 install_dir : rootlibexecdir)
2421 public_programs += executable(
2423 systemd_cat_sources,
2424 include_directories : includes,
2425 link_with : [libjournal_core,
2427 dependencies : [threads,
2430 install_rpath : rootpkglibdir,
2433 if get_option('link-journalctl-shared')
2434 journalctl_link_with = [libshared]
2436 journalctl_link_with = [libsystemd_static,
2441 public_programs += executable(
2444 include_directories : includes,
2445 link_with : [journalctl_link_with],
2446 dependencies : [libdl,
2453 install_rpath : rootpkglibdir,
2455 install_dir : rootbindir)
2458 'systemd-getty-generator',
2459 'src/getty-generator/getty-generator.c',
2460 include_directories : includes,
2461 link_with : [libshared],
2462 dependencies : userspace,
2463 install_rpath : rootpkglibdir,
2465 install_dir : systemgeneratordir)
2468 'systemd-debug-generator',
2469 'src/debug-generator/debug-generator.c',
2470 include_directories : includes,
2471 link_with : [libshared],
2472 dependencies : userspace,
2473 install_rpath : rootpkglibdir,
2475 install_dir : systemgeneratordir)
2478 'systemd-run-generator',
2479 'src/run-generator/run-generator.c',
2480 include_directories : includes,
2481 link_with : [libshared],
2482 dependencies : userspace,
2483 install_rpath : rootpkglibdir,
2485 install_dir : systemgeneratordir)
2488 'systemd-fstab-generator',
2489 'src/fstab-generator/fstab-generator.c',
2490 include_directories : includes,
2491 link_with : [libshared],
2492 dependencies : userspace,
2493 install_rpath : rootpkglibdir,
2495 install_dir : systemgeneratordir)
2497 meson.add_install_script(meson_make_symlink,
2498 systemgeneratordir / 'systemd-fstab-generator',
2499 rootlibexecdir / 'systemd-sysroot-fstab-check')
2501 if want_tests != 'false'
2502 test('test-fstab-generator',
2503 test_fstab_generator_sh,
2504 # https://github.com/mesonbuild/meson/issues/2681
2505 args : exe.full_path(),
2509 if conf.get('ENABLE_ENVIRONMENT_D') == 1
2511 '30-systemd-environment-d-generator',
2512 'src/environment-d-generator/environment-d-generator.c',
2513 include_directories : includes,
2514 link_with : [libshared],
2515 dependencies : userspace,
2516 install_rpath : rootpkglibdir,
2518 install_dir : userenvgeneratordir)
2520 meson.add_install_script(meson_make_symlink,
2521 sysconfdir / 'environment',
2522 environmentdir / '99-environment.conf')
2525 if conf.get('ENABLE_HIBERNATE') == 1
2527 'systemd-hibernate-resume-generator',
2528 'src/hibernate-resume/hibernate-resume-generator.c',
2529 include_directories : includes,
2530 link_with : [libshared],
2531 dependencies : userspace,
2532 install_rpath : rootpkglibdir,
2534 install_dir : systemgeneratordir)
2537 'systemd-hibernate-resume',
2538 'src/hibernate-resume/hibernate-resume.c',
2539 include_directories : includes,
2540 link_with : [libshared],
2541 dependencies : userspace,
2542 install_rpath : rootpkglibdir,
2544 install_dir : rootlibexecdir)
2547 if conf.get('HAVE_BLKID') == 1
2549 'systemd-gpt-auto-generator',
2550 'src/gpt-auto-generator/gpt-auto-generator.c',
2551 include_directories : includes,
2552 link_with : [libshared],
2553 dependencies : [libblkid,
2555 install_rpath : rootpkglibdir,
2557 install_dir : systemgeneratordir)
2559 public_programs += executable(
2561 'src/dissect/dissect.c',
2562 include_directories : includes,
2563 link_with : [libshared],
2564 dependencies : [userspace,
2566 install_rpath : rootpkglibdir,
2569 meson.add_install_script(meson_make_symlink,
2570 bindir / 'systemd-dissect',
2571 rootsbindir / 'mount.ddi')
2574 if conf.get('ENABLE_RESOLVE') == 1
2575 dbus_programs += executable(
2577 systemd_resolved_sources,
2578 include_directories : resolve_includes,
2579 link_with : [libshared,
2581 libsystemd_resolve_core],
2582 dependencies : [systemd_resolved_dependencies,
2584 install_rpath : rootpkglibdir,
2586 install_dir : rootlibexecdir)
2588 public_programs += executable(
2591 include_directories : includes,
2592 link_with : [libshared,
2594 libsystemd_resolve_core],
2595 dependencies : [lib_openssl_or_gcrypt,
2601 install_rpath : rootpkglibdir,
2604 meson.add_install_script(meson_make_symlink,
2605 bindir / 'resolvectl',
2606 rootsbindir / 'resolvconf')
2608 meson.add_install_script(meson_make_symlink,
2609 bindir / 'resolvectl',
2610 bindir / 'systemd-resolve')
2613 if conf.get('ENABLE_LOGIND') == 1
2614 dbus_programs += executable(
2616 systemd_logind_sources,
2617 include_directories : includes,
2618 link_with : [liblogind_core,
2620 dependencies : [libacl,
2624 install_rpath : rootpkglibdir,
2626 install_dir : rootlibexecdir)
2628 public_programs += executable(
2631 include_directories : includes,
2632 link_with : [libshared],
2633 dependencies : [liblz4,
2639 install_rpath : rootpkglibdir,
2641 install_dir : rootbindir)
2643 public_programs += executable(
2645 'src/login/inhibit.c',
2646 include_directories : includes,
2647 link_with : [libshared],
2648 dependencies : [userspace,
2650 install_rpath : rootpkglibdir,
2652 install_dir : rootbindir)
2654 if conf.get('HAVE_PAM') == 1
2655 version_script_arg = project_source_root / pam_systemd_sym
2656 pam_systemd = shared_library(
2660 include_directories : includes,
2661 link_args : ['-shared',
2662 '-Wl,--version-script=' + version_script_arg],
2663 link_with : [libsystemd_static,
2665 dependencies : [libpam_misc,
2670 link_depends : pam_systemd_sym,
2672 install_tag : 'pam',
2673 install_dir : pamlibdir)
2675 if want_tests != 'false'
2676 test('dlopen-pam_systemd',
2678 # path to dlopen must include a slash
2679 args : pam_systemd.full_path(),
2680 depends : pam_systemd)
2685 'systemd-user-runtime-dir',
2686 user_runtime_dir_sources,
2687 include_directories : includes,
2688 link_with : [libshared],
2689 dependencies : userspace,
2690 install_rpath : rootpkglibdir,
2692 install_dir : rootlibexecdir)
2695 if conf.get('HAVE_PAM') == 1
2697 'systemd-user-sessions',
2698 'src/user-sessions/user-sessions.c',
2699 include_directories : includes,
2700 link_with : [libshared],
2701 dependencies : userspace,
2702 install_rpath : rootpkglibdir,
2704 install_dir : rootlibexecdir)
2707 if conf.get('HAVE_BLKID') == 1 and conf.get('ENABLE_BOOTLOADER') == 1
2708 if get_option('link-boot-shared')
2709 boot_link_with = [libshared]
2711 boot_link_with = [libsystemd_static, libshared_static]
2717 include_directories : includes,
2718 link_with : [boot_link_with],
2719 dependencies : [libblkid,
2722 install_rpath : rootpkglibdir,
2724 public_programs += exe
2726 if want_tests != 'false'
2727 test('test-bootctl-json',
2728 test_bootctl_json_sh,
2729 args : exe.full_path(),
2733 public_programs += executable(
2734 'systemd-bless-boot',
2735 'src/boot/bless-boot.c',
2736 include_directories : includes,
2737 link_with : [boot_link_with],
2738 dependencies : [libblkid,
2741 install_rpath : rootpkglibdir,
2743 install_dir : rootlibexecdir)
2746 'systemd-bless-boot-generator',
2747 'src/boot/bless-boot-generator.c',
2748 include_directories : includes,
2749 link_with : [boot_link_with],
2750 dependencies : userspace,
2751 install_rpath : rootpkglibdir,
2753 install_dir : systemgeneratordir)
2755 if conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_TPM2') == 1
2758 'src/boot/measure.c',
2759 include_directories : includes,
2760 link_with : [libshared],
2761 dependencies : [libopenssl,
2764 install_rpath : rootpkglibdir,
2766 install_dir : rootlibexecdir)
2769 'src/boot/pcrphase.c',
2770 include_directories : includes,
2771 link_with : [libshared],
2772 dependencies : [libblkid,
2777 install_rpath : rootpkglibdir,
2779 install_dir : rootlibexecdir)
2784 'systemd-boot-check-no-failures',
2785 'src/boot/boot-check-no-failures.c',
2786 include_directories : includes,
2787 link_with : [libshared],
2788 dependencies : [libblkid,
2791 install_rpath : rootpkglibdir,
2793 install_dir : rootlibexecdir)
2795 public_programs += executable(
2796 'systemd-socket-activate',
2797 'src/activate/activate.c',
2798 include_directories : includes,
2799 link_with : [libshared],
2800 dependencies : [threads,
2803 install_rpath : rootpkglibdir,
2806 systemctl = executable(
2809 include_directories : includes,
2810 link_with : systemctl_link_with,
2811 dependencies : [libcap,
2819 install_rpath : rootpkglibdir,
2821 install_dir : rootbindir)
2822 public_programs += systemctl
2824 if conf.get('ENABLE_PORTABLED') == 1
2825 dbus_programs += executable(
2826 'systemd-portabled',
2827 systemd_portabled_sources,
2828 include_directories : includes,
2829 link_with : [libshared],
2830 dependencies : [libselinux,
2834 install_rpath : rootpkglibdir,
2836 install_dir : rootlibexecdir)
2838 public_programs += executable(
2840 'src/portable/portablectl.c',
2841 include_directories : includes,
2842 link_with : [libshared],
2843 dependencies : [threads,
2846 install_rpath : rootpkglibdir,
2848 install_dir : rootbindir)
2851 if conf.get('ENABLE_SYSEXT') == 1
2852 public_programs += executable(
2854 systemd_sysext_sources,
2855 include_directories : includes,
2856 link_with : [libshared],
2857 dependencies : [userspace,
2859 install_rpath : rootpkglibdir,
2861 install_dir : rootbindir)
2864 if conf.get('ENABLE_USERDB') == 1
2867 systemd_userwork_sources,
2868 include_directories : includes,
2869 link_with : [libshared],
2870 dependencies : [threads,
2873 install_rpath : rootpkglibdir,
2875 install_dir : rootlibexecdir)
2879 systemd_userdbd_sources,
2880 include_directories : includes,
2881 link_with : [libshared],
2882 dependencies : [threads,
2885 install_rpath : rootpkglibdir,
2887 install_dir : rootlibexecdir)
2889 public_programs += executable(
2892 include_directories : includes,
2893 link_with : [libshared],
2894 dependencies : [threads,
2897 install_rpath : rootpkglibdir,
2901 if conf.get('ENABLE_HOMED') == 1
2904 systemd_homework_sources,
2905 include_directories : includes,
2906 link_with : [libshared,
2908 dependencies : [libblkid,
2916 install_rpath : rootpkglibdir,
2918 install_dir : rootlibexecdir)
2920 dbus_programs += executable(
2922 systemd_homed_sources,
2923 include_directories : home_includes,
2924 link_with : [libshared],
2925 dependencies : [libcrypt,
2931 install_rpath : rootpkglibdir,
2933 install_dir : rootlibexecdir)
2935 public_programs += executable(
2938 include_directories : includes,
2939 link_with : [libshared],
2940 dependencies : [libcrypt,
2947 install_rpath : rootpkglibdir,
2950 if conf.get('HAVE_PAM') == 1
2951 version_script_arg = project_source_root / pam_systemd_home_sym
2952 pam_systemd_home = shared_library(
2956 include_directories : includes,
2957 link_args : ['-shared',
2958 '-Wl,--version-script=' + version_script_arg],
2959 link_with : [libsystemd_static,
2961 dependencies : [libcrypt,
2967 link_depends : pam_systemd_home_sym,
2969 install_tag : 'pam',
2970 install_dir : pamlibdir)
2972 if want_tests != 'false'
2973 test('dlopen-pam_systemd_home',
2975 # path to dlopen must include a slash
2976 args : pam_systemd_home.full_path(),
2977 depends : pam_systemd_home)
2982 foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
2983 (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
2984 meson.add_install_script(meson_make_symlink,
2985 rootbindir / 'systemctl',
2986 rootsbindir / alias)
2989 meson.add_install_script(meson_make_symlink,
2990 rootbindir / 'udevadm',
2991 rootlibexecdir / 'systemd-udevd')
2993 if conf.get('ENABLE_BACKLIGHT') == 1
2995 'systemd-backlight',
2996 'src/backlight/backlight.c',
2997 include_directories : includes,
2998 link_with : [libshared],
2999 dependencies : userspace,
3000 install_rpath : rootpkglibdir,
3002 install_dir : rootlibexecdir)
3005 if conf.get('ENABLE_RFKILL') == 1
3008 'src/rfkill/rfkill.c',
3009 include_directories : includes,
3010 link_with : [libshared],
3011 dependencies : userspace,
3012 install_rpath : rootpkglibdir,
3014 install_dir : rootlibexecdir)
3018 'systemd-system-update-generator',
3019 'src/system-update-generator/system-update-generator.c',
3020 include_directories : includes,
3021 link_with : [libshared],
3022 dependencies : userspace,
3023 install_rpath : rootpkglibdir,
3025 install_dir : systemgeneratordir)
3027 if conf.get('HAVE_LIBCRYPTSETUP') == 1
3029 'systemd-cryptsetup',
3030 systemd_cryptsetup_sources,
3031 include_directories : includes,
3032 link_with : [libshared],
3033 dependencies : [libcryptsetup,
3038 install_rpath : rootpkglibdir,
3040 install_dir : rootlibexecdir)
3043 'systemd-cryptsetup-generator',
3044 'src/cryptsetup/cryptsetup-generator.c',
3045 include_directories : includes,
3046 link_with : [libshared],
3047 dependencies : userspace,
3048 install_rpath : rootpkglibdir,
3050 install_dir : systemgeneratordir)
3053 'systemd-veritysetup',
3054 'src/veritysetup/veritysetup.c',
3055 include_directories : includes,
3056 link_with : [libshared],
3057 dependencies : [libcryptsetup,
3060 install_rpath : rootpkglibdir,
3062 install_dir : rootlibexecdir)
3065 'systemd-veritysetup-generator',
3066 'src/veritysetup/veritysetup-generator.c',
3067 include_directories : includes,
3068 link_with : [libshared],
3069 dependencies : [userspace,
3071 install_rpath : rootpkglibdir,
3073 install_dir : systemgeneratordir)
3075 public_programs += executable(
3076 'systemd-cryptenroll',
3077 systemd_cryptenroll_sources,
3078 include_directories : includes,
3079 link_with : [libshared],
3080 dependencies : [libcryptsetup,
3086 install_rpath : rootpkglibdir,
3090 'systemd-integritysetup',
3091 ['src/integritysetup/integritysetup.c', 'src/integritysetup/integrity-util.c'],
3092 include_directories : includes,
3093 link_with : [libshared],
3094 dependencies : [libcryptsetup,
3097 install_rpath : rootpkglibdir,
3099 install_dir : rootlibexecdir)
3102 'systemd-integritysetup-generator',
3103 ['src/integritysetup/integritysetup-generator.c', 'src/integritysetup/integrity-util.c'],
3104 include_directories : includes,
3105 link_with : [libshared],
3106 dependencies : userspace,
3107 install_rpath : rootpkglibdir,
3109 install_dir : systemgeneratordir)
3112 if conf.get('HAVE_SYSV_COMPAT') == 1
3114 'systemd-sysv-generator',
3115 'src/sysv-generator/sysv-generator.c',
3116 include_directories : includes,
3117 link_with : [libshared],
3118 dependencies : userspace,
3119 install_rpath : rootpkglibdir,
3121 install_dir : systemgeneratordir)
3123 sysv_generator_test_py = find_program('test/sysv-generator-test.py')
3124 if want_tests != 'false'
3125 test('sysv-generator-test',
3126 sysv_generator_test_py,
3131 'systemd-rc-local-generator',
3132 'src/rc-local-generator/rc-local-generator.c',
3133 include_directories : includes,
3134 link_with : [libshared],
3135 dependencies : userspace,
3136 install_rpath : rootpkglibdir,
3138 install_dir : systemgeneratordir)
3141 if conf.get('ENABLE_XDG_AUTOSTART') == 1
3143 'systemd-xdg-autostart-generator',
3144 systemd_xdg_autostart_generator_sources,
3145 include_directories : includes,
3146 link_with : [libshared],
3147 dependencies : userspace,
3148 install_rpath : rootpkglibdir,
3150 install_dir : usergeneratordir)
3153 'systemd-xdg-autostart-condition',
3154 'src/xdg-autostart-generator/xdg-autostart-condition.c',
3155 include_directories : includes,
3156 link_with : [libshared],
3157 dependencies : userspace,
3158 install_rpath : rootpkglibdir,
3160 install_dir : rootlibexecdir)
3163 if conf.get('ENABLE_HOSTNAMED') == 1
3164 dbus_programs += executable(
3165 'systemd-hostnamed',
3166 'src/hostname/hostnamed.c',
3167 include_directories : includes,
3168 link_with : [libshared],
3169 dependencies : userspace,
3170 install_rpath : rootpkglibdir,
3172 install_dir : rootlibexecdir)
3174 public_programs += executable(
3176 'src/hostname/hostnamectl.c',
3177 include_directories : includes,
3178 link_with : [libshared],
3179 dependencies : [userspace,
3181 install_rpath : rootpkglibdir,
3185 if conf.get('ENABLE_LOCALED') == 1
3186 dbus_programs += executable(
3188 systemd_localed_sources,
3189 include_directories : includes,
3190 link_with : [libshared],
3191 dependencies : libxkbcommon_deps +
3194 install_rpath : rootpkglibdir,
3196 install_dir : rootlibexecdir)
3198 public_programs += executable(
3201 include_directories : includes,
3202 link_with : [libshared],
3203 dependencies : [userspace,
3205 install_rpath : rootpkglibdir,
3209 if conf.get('ENABLE_TIMEDATED') == 1
3210 dbus_programs += executable(
3211 'systemd-timedated',
3212 'src/timedate/timedated.c',
3213 include_directories : includes,
3214 link_with : [libshared],
3215 dependencies : userspace,
3216 install_rpath : rootpkglibdir,
3218 install_dir : rootlibexecdir)
3221 if conf.get('ENABLE_TIMEDATECTL') == 1
3222 public_programs += executable(
3224 'src/timedate/timedatectl.c',
3225 include_directories : includes,
3226 install_rpath : rootpkglibdir,
3227 link_with : [libshared],
3228 dependencies : [libm,
3234 if conf.get('ENABLE_TIMESYNCD') == 1
3236 'systemd-timesyncd',
3237 systemd_timesyncd_sources,
3238 include_directories : includes,
3239 link_with : [libtimesyncd_core],
3240 dependencies : [libm,
3244 install_rpath : rootpkglibdir,
3246 install_dir : rootlibexecdir)
3249 'systemd-time-wait-sync',
3250 'src/timesync/wait-sync.c',
3251 include_directories : includes,
3252 link_with : [libtimesyncd_core],
3253 dependencies : userspace,
3254 install_rpath : rootpkglibdir,
3256 install_dir : rootlibexecdir)
3259 if conf.get('ENABLE_MACHINED') == 1
3260 dbus_programs += executable(
3262 systemd_machined_sources,
3263 include_directories : includes,
3264 link_with : [libmachine_core,
3266 dependencies : userspace,
3267 install_rpath : rootpkglibdir,
3269 install_dir : rootlibexecdir)
3271 public_programs += executable(
3273 'src/machine/machinectl.c',
3274 include_directories : includes,
3275 link_with : [libshared],
3276 dependencies : [liblz4,
3282 install_rpath : rootpkglibdir,
3284 install_dir : rootbindir)
3287 if conf.get('ENABLE_IMPORTD') == 1
3288 dbus_programs += executable(
3290 systemd_importd_sources,
3291 include_directories : includes,
3292 link_with : [libshared],
3293 dependencies : [threads,
3296 install_rpath : rootpkglibdir,
3298 install_dir : rootlibexecdir)
3300 systemd_pull = executable(
3302 systemd_pull_sources,
3303 include_directories : includes,
3304 link_with : [libshared,
3306 dependencies : [lib_openssl_or_gcrypt,
3313 install_rpath : rootpkglibdir,
3315 install_dir : rootlibexecdir)
3317 systemd_import = executable(
3319 systemd_import_sources,
3320 include_directories : includes,
3321 link_with : [libshared,
3323 dependencies : [libbzip2,
3329 install_rpath : rootpkglibdir,
3331 install_dir : rootlibexecdir)
3333 systemd_import_fs = executable(
3334 'systemd-import-fs',
3335 systemd_import_fs_sources,
3336 include_directories : includes,
3337 link_with : [libshared,
3339 dependencies : [userspace,
3341 install_rpath : rootpkglibdir,
3343 install_dir : rootlibexecdir)
3345 systemd_export = executable(
3347 systemd_export_sources,
3348 include_directories : includes,
3349 link_with : [libshared,
3351 dependencies : [libbzip2,
3357 install_rpath : rootpkglibdir,
3359 install_dir : rootlibexecdir)
3361 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
3364 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
3365 public_programs += executable(
3366 'systemd-journal-upload',
3367 systemd_journal_upload_sources,
3368 include_directories : includes,
3369 link_with : [libshared],
3370 dependencies : [libcurl,
3378 install_rpath : rootpkglibdir,
3380 install_dir : rootlibexecdir)
3383 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
3384 public_programs += executable(
3385 'systemd-journal-remote',
3386 systemd_journal_remote_sources,
3387 include_directories : journal_includes,
3388 link_with : [libshared,
3389 libsystemd_journal_remote],
3390 dependencies : [libgnutls,
3398 install_rpath : rootpkglibdir,
3400 install_dir : rootlibexecdir)
3402 public_programs += executable(
3403 'systemd-journal-gatewayd',
3404 systemd_journal_gatewayd_sources,
3405 include_directories : journal_includes,
3406 link_with : [libshared],
3407 dependencies : [libgnutls,
3415 install_rpath : rootpkglibdir,
3417 install_dir : rootlibexecdir)
3420 if conf.get('ENABLE_COREDUMP') == 1
3423 systemd_coredump_sources,
3424 include_directories : includes,
3425 link_with : [libshared,
3427 dependencies : [libacl,
3434 install_rpath : rootpkglibdir,
3436 install_dir : rootlibexecdir)
3438 public_programs += executable(
3440 coredumpctl_sources,
3441 include_directories : includes,
3442 link_with : [libshared,
3444 dependencies : [liblz4,
3450 install_rpath : rootpkglibdir,
3454 if conf.get('ENABLE_PSTORE') == 1
3457 systemd_pstore_sources,
3458 include_directories : includes,
3459 link_with : [libshared],
3460 dependencies : [libacl,
3467 install_rpath : rootpkglibdir,
3469 install_dir : rootlibexecdir)
3472 if conf.get('ENABLE_OOMD') == 1
3473 dbus_programs += executable('systemd-oomd',
3474 systemd_oomd_sources,
3475 include_directories : includes,
3476 link_with : [libshared],
3477 dependencies : [libatomic,
3480 install_rpath : rootpkglibdir,
3482 install_dir : rootlibexecdir)
3484 public_programs += executable(
3487 include_directories : includes,
3488 link_with : [libshared],
3489 dependencies : [userspace,
3491 install_rpath : rootpkglibdir,
3495 if conf.get('ENABLE_BINFMT') == 1
3496 public_programs += executable(
3498 'src/binfmt/binfmt.c',
3499 include_directories : includes,
3500 link_with : [libshared],
3501 dependencies : [userspace,
3503 install_rpath : rootpkglibdir,
3505 install_dir : rootlibexecdir)
3507 meson.add_install_script('sh', '-c',
3508 mkdir_p.format(binfmtdir))
3509 if install_sysconfdir
3510 meson.add_install_script('sh', '-c',
3511 mkdir_p.format(sysconfdir / 'binfmt.d'))
3515 if conf.get('ENABLE_SYSUPDATE') == 1
3517 'systemd-sysupdate',
3518 systemd_sysupdate_sources,
3519 include_directories : includes,
3520 link_with : [libshared,
3522 dependencies : [libblkid,
3528 install_rpath : rootpkglibdir,
3530 install_dir : rootlibexecdir)
3531 public_programs += exe
3534 if conf.get('ENABLE_VCONSOLE') == 1
3536 'systemd-vconsole-setup',
3537 'src/vconsole/vconsole-setup.c',
3538 include_directories : includes,
3539 link_with : [libshared],
3540 dependencies : userspace,
3541 install_rpath : rootpkglibdir,
3543 install_dir : rootlibexecdir)
3546 if conf.get('ENABLE_RANDOMSEED') == 1
3548 'systemd-random-seed',
3549 'src/random-seed/random-seed.c',
3550 include_directories : includes,
3551 link_with : [libshared],
3552 dependencies : [userspace,
3554 install_rpath : rootpkglibdir,
3556 install_dir : rootlibexecdir)
3559 if conf.get('ENABLE_FIRSTBOOT') == 1
3560 public_programs += executable(
3561 'systemd-firstboot',
3562 'src/firstboot/firstboot.c',
3563 include_directories : includes,
3564 link_with : [libshared],
3565 dependencies : [libcrypt,
3568 install_rpath : rootpkglibdir,
3570 install_dir : rootbindir)
3574 'systemd-remount-fs',
3575 'src/remount-fs/remount-fs.c',
3576 include_directories : includes,
3577 link_with : [libshared],
3578 dependencies : [userspace,
3580 install_rpath : rootpkglibdir,
3582 install_dir : rootlibexecdir)
3585 'systemd-machine-id-setup',
3586 'src/machine-id-setup/machine-id-setup-main.c',
3587 include_directories : includes,
3588 link_with : [libshared],
3589 dependencies : [userspace,
3591 install_rpath : rootpkglibdir,
3593 install_dir : rootbindir)
3598 include_directories : includes,
3599 link_with : [libshared],
3600 dependencies : [userspace,
3602 install_rpath : rootpkglibdir,
3604 install_dir : rootlibexecdir)
3608 'src/partition/growfs.c',
3609 include_directories : includes,
3610 link_with : [libshared],
3611 dependencies : [userspace,
3613 install_rpath : rootpkglibdir,
3615 install_dir : rootlibexecdir)
3619 'src/partition/makefs.c',
3620 include_directories : includes,
3621 link_with : [libshared],
3622 dependencies : [userspace,
3624 install_rpath : rootpkglibdir,
3626 install_dir : rootlibexecdir)
3630 'src/sleep/sleep.c',
3631 include_directories : includes,
3632 link_with : [libshared],
3633 dependencies : [userspace,
3635 install_rpath : rootpkglibdir,
3637 install_dir : rootlibexecdir)
3639 if install_sysconfdir_samples
3640 install_data('src/sleep/sleep.conf',
3641 install_dir : pkgsysconfdir)
3644 public_programs += executable(
3646 'src/sysctl/sysctl.c',
3647 include_directories : includes,
3648 link_with : [libshared],
3649 dependencies : [userspace,
3651 install_rpath : rootpkglibdir,
3653 install_dir : rootlibexecdir)
3655 public_programs += executable(
3657 'src/ac-power/ac-power.c',
3658 include_directories : includes,
3659 link_with : [libshared],
3660 dependencies : [userspace,
3662 install_rpath : rootpkglibdir,
3665 public_programs += executable(
3666 'systemd-detect-virt',
3667 'src/detect-virt/detect-virt.c',
3668 include_directories : includes,
3669 link_with : [libshared],
3670 dependencies : [userspace,
3672 install_rpath : rootpkglibdir,
3675 public_programs += executable(
3677 'src/delta/delta.c',
3678 include_directories : includes,
3679 link_with : [libshared],
3680 dependencies : [userspace,
3682 install_rpath : rootpkglibdir,
3685 public_programs += executable(
3687 'src/escape/escape.c',
3688 include_directories : includes,
3689 link_with : [libshared],
3690 dependencies : [userspace,
3692 install_rpath : rootpkglibdir,
3694 install_dir : rootbindir)
3696 public_programs += executable(
3698 'src/notify/notify.c',
3699 include_directories : includes,
3700 link_with : [libshared],
3701 dependencies : [userspace,
3703 install_rpath : rootpkglibdir,
3705 install_dir : rootbindir)
3707 public_programs += executable(
3709 'src/creds/creds.c',
3710 include_directories : includes,
3711 link_with : [libshared],
3712 dependencies : [threads,
3716 install_rpath : rootpkglibdir,
3718 install_dir : rootbindir)
3721 'systemd-volatile-root',
3722 'src/volatile-root/volatile-root.c',
3723 include_directories : includes,
3724 link_with : [libshared],
3725 dependencies : userspace,
3726 install_rpath : rootpkglibdir,
3727 install : conf.get('ENABLE_INITRD') == 1,
3728 install_dir : rootlibexecdir)
3731 'systemd-cgroups-agent',
3732 'src/cgroups-agent/cgroups-agent.c',
3733 include_directories : includes,
3734 link_with : [libshared],
3735 dependencies : userspace,
3736 install_rpath : rootpkglibdir,
3738 install_dir : rootlibexecdir)
3740 systemd_id128 = executable(
3742 'src/id128/id128.c',
3743 include_directories : includes,
3744 link_with : [libshared],
3745 dependencies : [userspace,
3747 install_rpath : rootpkglibdir,
3749 public_programs += systemd_id128
3751 if want_tests != 'false'
3752 test('test-systemctl-enable',
3753 test_systemctl_enable_sh,
3754 # https://github.com/mesonbuild/meson/issues/2681
3755 args : [systemctl.full_path(),
3756 systemd_id128.full_path()])
3759 public_programs += executable(
3762 include_directories : includes,
3763 link_with : [libshared],
3764 dependencies : [userspace,
3766 install_rpath : rootpkglibdir,
3769 public_programs += executable(
3770 'systemd-ask-password',
3771 'src/ask-password/ask-password.c',
3772 include_directories : includes,
3773 link_with : [libshared],
3774 dependencies : [userspace,
3776 install_rpath : rootpkglibdir,
3778 install_dir : rootbindir)
3781 'systemd-reply-password',
3782 'src/reply-password/reply-password.c',
3783 include_directories : includes,
3784 link_with : [libshared],
3785 dependencies : userspace,
3786 install_rpath : rootpkglibdir,
3788 install_dir : rootlibexecdir)
3790 public_programs += executable(
3791 'systemd-tty-ask-password-agent',
3792 'src/tty-ask-password-agent/tty-ask-password-agent.c',
3793 include_directories : includes,
3794 link_with : [libshared],
3795 dependencies : [userspace,
3797 install_rpath : rootpkglibdir,
3799 install_dir : rootbindir)
3801 public_programs += executable(
3804 include_directories : includes,
3805 link_with : [libshared],
3806 dependencies : [userspace,
3808 install_rpath : rootpkglibdir,
3811 public_programs += executable(
3813 'src/cgtop/cgtop.c',
3814 include_directories : includes,
3815 link_with : [libshared],
3816 dependencies : [userspace,
3818 install_rpath : rootpkglibdir,
3823 'src/initctl/initctl.c',
3824 include_directories : includes,
3825 link_with : [libshared],
3826 dependencies : userspace,
3827 install_rpath : rootpkglibdir,
3828 install : (conf.get('HAVE_SYSV_COMPAT') == 1),
3829 install_dir : rootlibexecdir)
3831 public_programs += executable(
3833 'src/mount/mount-tool.c',
3834 include_directories : includes,
3835 link_with : [libshared],
3836 dependencies: [libmount,
3839 install_rpath : rootpkglibdir,
3842 meson.add_install_script(meson_make_symlink,
3843 'systemd-mount', bindir / 'systemd-umount')
3845 public_programs += executable(
3848 include_directories : includes,
3849 link_with : [libshared],
3850 dependencies : [userspace,
3852 install_rpath : rootpkglibdir,
3855 public_programs += executable(
3856 'systemd-stdio-bridge',
3857 'src/stdio-bridge/stdio-bridge.c',
3858 include_directories : includes,
3859 link_with : [libshared],
3860 dependencies : [userspace,
3862 install_rpath : rootpkglibdir,
3865 public_programs += executable(
3868 include_directories : includes,
3869 link_with : [libshared],
3870 dependencies : [userspace,
3872 install_rpath : rootpkglibdir,
3878 'src/sysusers/sysusers.c',
3879 include_directories : includes,
3880 link_with : [libshared],
3881 dependencies : [userspace,
3883 install_rpath : rootpkglibdir,
3885 install_dir : rootbindir)
3886 public_programs += exe
3888 if want_tests != 'false'
3889 test('test-sysusers',
3891 # https://github.com/mesonbuild/meson/issues/2681
3892 args : exe.full_path())
3895 if have_standalone_binaries
3897 'systemd-sysusers.standalone',
3898 'src/sysusers/sysusers.c',
3899 include_directories : includes,
3900 c_args : '-DSTANDALONE',
3901 link_with : [libshared_static,
3905 dependencies : [userspace,
3908 install_dir : rootbindir)
3909 public_programs += exe
3911 if want_tests != 'false'
3912 test('test-sysusers.standalone',
3914 # https://github.com/mesonbuild/meson/issues/2681
3915 args : exe.full_path())
3920 if conf.get('ENABLE_TMPFILES') == 1
3923 systemd_tmpfiles_sources,
3924 include_directories : includes,
3925 link_with : [libshared],
3926 dependencies : [libacl,
3929 install_rpath : rootpkglibdir,
3931 install_dir : rootbindir)
3932 public_programs += exe
3934 if want_tests != 'false'
3935 test('test-systemd-tmpfiles',
3936 test_systemd_tmpfiles_py,
3937 # https://github.com/mesonbuild/meson/issues/2681
3938 args : exe.full_path())
3941 if have_standalone_binaries
3943 'systemd-tmpfiles.standalone',
3944 systemd_tmpfiles_sources,
3945 include_directories : includes,
3946 c_args : '-DSTANDALONE',
3947 link_with : [libshared_static,
3951 dependencies : [libacl,
3955 install_dir : rootbindir)
3956 public_programs += exe
3958 if want_tests != 'false'
3959 test('test-systemd-tmpfiles.standalone',
3960 test_systemd_tmpfiles_py,
3961 # https://github.com/mesonbuild/meson/issues/2681
3962 args : exe.full_path())
3967 if conf.get('ENABLE_HWDB') == 1
3968 systemd_hwdb = executable(
3971 include_directories : includes,
3972 link_with : udev_link_with,
3973 dependencies : [userspace,
3975 install_rpath : udev_rpath,
3977 install_dir : rootbindir)
3978 public_programs += systemd_hwdb
3980 if want_tests != 'false'
3983 suite : 'dist-check',
3984 args : [systemd_hwdb.full_path()],
3989 if conf.get('ENABLE_QUOTACHECK') == 1
3991 'systemd-quotacheck',
3992 'src/quotacheck/quotacheck.c',
3993 include_directories : includes,
3994 link_with : [libshared],
3995 dependencies : userspace,
3996 install_rpath : rootpkglibdir,
3998 install_dir : rootlibexecdir)
4001 public_programs += executable(
4002 'systemd-socket-proxyd',
4003 'src/socket-proxy/socket-proxyd.c',
4004 include_directories : includes,
4005 link_with : [libshared],
4006 dependencies : [threads,
4009 install_rpath : rootpkglibdir,
4011 install_dir : rootlibexecdir)
4013 udevadm = executable(
4016 include_directories : includes,
4017 link_with : [libudevd_core],
4018 dependencies : [libacl,
4025 install_rpath : udev_rpath,
4027 install_dir : rootbindir)
4028 public_programs += udevadm
4030 if want_tests != 'false'
4031 test('udev-rules-check',
4033 suite : 'dist-check',
4034 args : ['verify', '--resolve-names=never', all_rules])
4037 if conf.get('ENABLE_REPART') == 1
4040 systemd_repart_sources,
4041 include_directories : includes,
4042 link_with : [libshared,
4044 dependencies : [libblkid,
4050 install_rpath : rootpkglibdir,
4052 install_dir : rootbindir)
4053 public_programs += exe
4055 if have_standalone_binaries
4057 'systemd-repart.standalone',
4058 systemd_repart_sources,
4059 include_directories : includes,
4060 c_args : '-DSTANDALONE',
4061 link_with : [libshared_static,
4066 dependencies : [libblkid,
4072 install_rpath : rootpkglibdir,
4074 install_dir : rootbindir)
4075 public_programs += exe
4081 systemd_shutdown_sources,
4082 include_directories : includes,
4083 link_with : [libshared],
4084 dependencies : [libmount,
4087 install_rpath : rootpkglibdir,
4089 install_dir : rootlibexecdir)
4091 if have_standalone_binaries
4093 'systemd-shutdown.standalone',
4094 systemd_shutdown_sources,
4095 include_directories : includes,
4096 c_args : '-DSTANDALONE',
4097 link_with : [libshared_static,
4100 dependencies : [libmount,
4103 install_rpath : rootpkglibdir,
4105 install_dir : rootlibexecdir)
4109 'systemd-update-done',
4110 'src/update-done/update-done.c',
4111 include_directories : includes,
4112 link_with : [libshared],
4113 dependencies : [userspace,
4115 install_rpath : rootpkglibdir,
4117 install_dir : rootlibexecdir)
4120 'systemd-update-utmp',
4121 'src/update-utmp/update-utmp.c',
4122 include_directories : includes,
4123 link_with : [libshared],
4124 dependencies : [libaudit,
4127 install_rpath : rootpkglibdir,
4128 install : (conf.get('ENABLE_UTMP') == 1),
4129 install_dir : rootlibexecdir)
4131 if conf.get('HAVE_KMOD') == 1
4133 'systemd-modules-load',
4134 'src/modules-load/modules-load.c',
4135 include_directories : includes,
4136 link_with : [libshared],
4137 dependencies : [libkmod,
4140 install_rpath : rootpkglibdir,
4142 install_dir : rootlibexecdir)
4144 meson.add_install_script('sh', '-c',
4145 mkdir_p.format(modulesloaddir))
4146 if install_sysconfdir
4147 meson.add_install_script('sh', '-c',
4148 mkdir_p.format(sysconfdir / 'modules-load.d'))
4152 public_programs += executable(
4154 systemd_nspawn_sources,
4155 include_directories : includes,
4156 link_with : [libnspawn_core,
4158 dependencies : [libblkid,
4162 install_rpath : rootpkglibdir,
4165 if conf.get('ENABLE_NETWORKD') == 1
4166 dbus_programs += executable(
4168 systemd_networkd_sources,
4169 include_directories : network_includes,
4170 link_with : [libnetworkd_core,
4172 networkd_link_with],
4173 dependencies : [threads,
4176 install_rpath : rootpkglibdir,
4178 install_dir : rootlibexecdir)
4180 public_programs += executable(
4181 'systemd-networkd-wait-online',
4182 systemd_networkd_wait_online_sources,
4183 include_directories : includes,
4184 link_with : [networkd_link_with],
4185 dependencies : [userspace,
4187 install_rpath : rootpkglibdir,
4189 install_dir : rootlibexecdir)
4191 public_programs += executable(
4194 include_directories : libsystemd_network_includes,
4195 link_with : [libsystemd_network,
4196 networkd_link_with],
4197 dependencies : [userspace,
4199 install_rpath : rootpkglibdir,
4201 install_dir : rootbindir)
4205 'systemd-network-generator',
4206 network_generator_sources,
4207 include_directories : includes,
4208 link_with : [networkd_link_with],
4209 dependencies : [userspace,
4211 install_rpath : rootpkglibdir,
4213 install_dir : rootlibexecdir)
4215 if want_tests != 'false'
4216 test('test-network-generator-conversion',
4217 test_network_generator_conversion_sh,
4218 # https://github.com/mesonbuild/meson/issues/2681
4219 args : exe.full_path(),
4224 'systemd-sulogin-shell',
4225 'src/sulogin-shell/sulogin-shell.c',
4226 include_directories : includes,
4227 link_with : [libshared],
4228 dependencies : [userspace,
4230 install_rpath : rootpkglibdir,
4232 install_dir : rootlibexecdir)
4234 exe = custom_target(
4236 input : kernel_install_in,
4237 output : 'kernel-install',
4238 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
4239 install : want_kernel_install,
4240 install_mode : 'rwxr-xr-x',
4241 install_dir : bindir)
4242 public_programs += exe
4244 if want_tests != 'false' and want_kernel_install
4245 test('test-kernel-install',
4246 test_kernel_install_sh,
4248 args : [exe.full_path(), loaderentry_install])
4252 exe = custom_target(
4254 input : 'src/ukify/ukify.py',
4256 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
4258 install_mode : 'rwxr-xr-x',
4259 install_dir : rootlibexecdir)
4260 public_programs += exe
4263 ############################################################
4265 runtest_env = custom_target(
4266 'systemd-runtest.env',
4267 output : 'systemd-runtest.env',
4268 command : [sh, '-c',
4269 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
4270 project_source_root / 'test',
4271 project_build_root / 'catalog')],
4273 build_by_default : true)
4275 test_cflags = ['-DTEST_CODE=1']
4276 # We intentionally do not do inline initializations with definitions for a
4277 # bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
4278 # use the variable unexpectedly. This triggers a lot of maybe-uninitialized
4279 # false positives when the combination of -O2 and -flto is used. Suppress them.
4280 if '-O2' in c_args and '-flto=auto' in c_args
4281 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
4284 foreach test : simple_tests
4285 tests += { 'sources' : [test] }
4288 foreach test : tests
4289 sources = test.get('sources')
4290 condition = test.get('condition', '')
4291 type = test.get('type', '')
4292 base = test.get('base', {})
4294 base.get('dependencies', []),
4295 test.get('dependencies', []),
4299 # FIXME: Use fs.stem() with meson >= 0.54.0
4300 name = '@0@'.format(sources[0]).split('/')[-1]
4301 if not name.endswith('.cc')
4304 name = name.split('.')[0]
4306 suite = fs.name(fs.parent('@0@'.format(sources[0])))
4307 # FIXME: Use str.replace() with meson >= 0.58.0
4308 suite = suite.split('sd-')[-1]
4310 if condition != '' and conf.get(condition) == 0
4311 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
4318 include_directories : [base.get('includes', []), test.get('includes', includes)],
4319 link_with : [base.get('link_with', []), test.get('link_with', libshared)],
4320 dependencies : deps,
4321 c_args : [test_cflags, test.get('c_args', [])],
4322 build_by_default : want_tests != 'false',
4323 install_rpath : rootpkglibdir,
4324 install : install_tests,
4325 install_dir : unittestsdir / type,
4326 link_depends : runtest_env)
4329 message('@0@ is a manual test'.format(name))
4330 elif type == 'unsafe' and want_tests != 'unsafe'
4331 message('@0@ is an unsafe test'.format(name))
4332 elif want_tests != 'false'
4335 timeout : test.get('timeout', 30),
4337 is_parallel : test.get('parallel', true))
4342 'test-libsystemd-sym',
4343 test_libsystemd_sym_c,
4344 include_directories : includes,
4345 link_with : [libsystemd],
4346 dependencies : userspace,
4347 build_by_default : want_tests != 'false',
4348 install : install_tests,
4349 install_dir : unittestsdir)
4350 if want_tests != 'false'
4351 test('test-libsystemd-sym', exe)
4355 'test-libsystemd-static-sym',
4356 test_libsystemd_sym_c,
4357 include_directories : includes,
4358 link_with : [install_libsystemd_static],
4360 # threads is already included in dependencies on the library,
4361 # but does not seem to get propagated. Add here as a work-around.
4365 build_by_default : want_tests != 'false' and static_libsystemd_pic,
4366 install : install_tests and static_libsystemd_pic,
4367 install_dir : unittestsdir)
4368 if want_tests != 'false' and static_libsystemd_pic
4369 test('test-libsystemd-static-sym', exe)
4375 include_directories : libudev_includes,
4376 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
4377 link_with : [libudev],
4378 dependencies : userspace,
4379 build_by_default : want_tests != 'false',
4380 install : install_tests,
4381 install_dir : unittestsdir)
4382 if want_tests != 'false'
4383 test('test-libudev-sym', exe)
4387 'test-libudev-static-sym',
4389 include_directories : libudev_includes,
4390 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
4391 link_with : [install_libudev_static],
4392 dependencies : userspace,
4393 build_by_default : want_tests != 'false' and static_libudev_pic,
4394 install : install_tests and static_libudev_pic,
4395 install_dir : unittestsdir)
4396 if want_tests != 'false' and static_libudev_pic
4397 test('test-libudev-static-sym', exe)
4400 ############################################################
4402 foreach fuzzer : simple_fuzzers
4403 fuzzers += { 'sources' : [fuzzer] }
4408 foreach fuzzer : fuzzers
4409 sources = fuzzer.get('sources')
4410 base = fuzzer.get('base', {})
4411 dependencies = [base.get('dependencies', []), fuzzer.get('dependencies', [])]
4415 dependencies += fuzzing_engine
4417 if fuzzing_engine.found()
4418 dependencies += fuzzing_engine
4420 link_args += ['-fsanitize=fuzzer']
4423 sources += files('src/fuzz/fuzz-main.c')
4425 sources += fuzz_generated_directives
4427 # FIXME: Use fs.stem() with meson >= 0.54.0
4428 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
4433 include_directories : [
4434 base.get('includes', []),
4435 fuzzer.get('includes', includes),
4436 include_directories('src/fuzz'),
4438 link_with : [base.get('link_with', []), fuzzer.get('link_with', libshared)],
4444 c_args : [test_cflags, fuzzer.get('c_args', [])],
4445 link_args: link_args,
4447 build_by_default : fuzzer_build)
4450 if want_tests != 'false' and name in fuzz_regression_tests
4451 # Run the fuzz regression tests without any sanitizers enabled.
4452 # Additional invocations with sanitizers may be added below.
4453 foreach tuple : fuzz_regression_tests[name]
4456 test('@0@_@1@'.format(name, fuzz_in),
4459 args : [fuzz_dir != '' ? project_source_root / fuzz_dir / name / fuzz_in
4460 : fuzz_generated_in_dir / '@0@_@1@'.format(name, fuzz_in)])
4465 alias_target('fuzzers', fuzzer_exes)
4467 ############################################################
4469 subdir('docs/sysvinit')
4470 subdir('docs/var-log')
4473 subdir('modprobe.d')
4476 subdir('shell-completion/bash')
4477 subdir('shell-completion/zsh')
4479 subdir('sysusers.d')
4480 subdir('tmpfiles.d')
4483 install_subdir('factory/etc',
4484 install_dir : factorydir)
4485 subdir('factory/templates')
4487 if install_sysconfdir
4488 install_data('xorg/50-systemd-user.sh',
4489 install_dir : xinitrcdir)
4491 install_data('LICENSE.GPL2',
4495 'docs/CODING_STYLE.md',
4496 'docs/DISTRO_PORTING.md',
4497 'docs/ENVIRONMENT.md',
4499 'docs/TRANSIENT-SETTINGS.md',
4500 'docs/TRANSLATORS.md',
4501 'docs/UIDS-GIDS.md',
4502 install_dir : docdir)
4504 install_subdir('LICENSES',
4505 install_dir : docdir)
4507 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
4508 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
4510 ############################################################
4512 # Ensure that changes to the docs/ directory do not break the
4513 # basic Github pages build. But only run it in developer mode,
4514 # as it might be fragile due to changes in the tooling, and it is
4515 # not generally useful for users.
4516 jekyll = find_program('jekyll', required : false)
4517 if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
4518 test('github-pages',
4520 suite : 'dist-check',
4522 '--source', project_source_root / 'docs',
4523 '--destination', project_build_root / '_site'])
4526 ############################################################
4528 check_help = find_program('tools/check-help.sh')
4529 check_version = find_program('tools/check-version.sh')
4531 foreach exec : public_programs
4532 name = exec.full_path().split('/')[-1]
4533 if want_tests != 'false'
4534 test('check-help-' + name,
4536 suite : 'dist-check',
4537 args : exec.full_path(),
4540 test('check-version-' + name,
4542 suite : 'dist-check',
4543 args : [exec.full_path(),
4544 meson.project_version()],
4549 # Enable tests for all supported sanitizers
4550 foreach tuple : fuzz_sanitizers
4551 sanitizer = tuple[0]
4554 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
4555 foreach fuzzer, fuzz_ins : fuzz_regression_tests
4556 name = '@0@:@1@'.format(fuzzer, sanitizer)
4557 if want_tests == 'false'
4558 message('Not compiling @0@ because tests is set to false'.format(name))
4562 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
4565 exe = custom_target(
4568 depends : [build] + fuzz_generated_directives,
4569 command : [ln, '-fs',
4570 build.full_path() / fuzzer,
4572 build_by_default : true)
4574 foreach tuple : fuzz_ins
4578 test('@0@_@1@_@2@'.format(fuzzer, fuzz_in, sanitizer),
4581 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
4583 args : [exe.full_path(),
4584 fuzz_dir != '' ? project_source_root / fuzz_dir / fuzzer / fuzz_in
4585 : fuzz_generated_in_dir / '@0@_@1@'.format(fuzzer, fuzz_in)])
4592 ############################################################
4595 all_files = run_command(
4596 env, '-u', 'GIT_WORK_TREE',
4597 git, '--git-dir=@0@/.git'.format(project_source_root),
4598 'ls-files', ':/*.[ch]',
4600 if all_files.returncode() == 0
4601 all_files = files(all_files.stdout().split())
4606 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
4609 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
4614 git_contrib_sh = find_program('tools/git-contrib.sh')
4617 command : [git_contrib_sh])
4621 git_head = run_command(
4622 git, '--git-dir=@0@/.git'.format(project_source_root),
4623 'rev-parse', 'HEAD',
4624 check : false).stdout().strip()
4625 git_head_short = run_command(
4626 git, '--git-dir=@0@/.git'.format(project_source_root),
4627 'rev-parse', '--short=7', 'HEAD',
4628 check : false).stdout().strip()
4632 command : [git, 'archive',
4633 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
4635 '--prefix', 'systemd-@0@/'.format(git_head),
4639 ############################################################
4641 check_api_docs_sh = find_program('tools/check-api-docs.sh')
4644 depends : [man, libsystemd, libudev],
4645 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
4647 alias_target('update-dbus-docs', update_dbus_docs)
4648 alias_target('update-man-rules', update_man_rules)
4650 if not meson.is_cross_build()
4652 'export-dbus-interfaces',
4653 output : fs.name(dbus_interfaces_dir),
4654 install : dbus_interfaces_dir != 'no',
4655 install_dir : fs.parent(dbus_interfaces_dir),
4656 command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
4659 ############################################################
4661 alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
4662 check : true).stdout().strip()
4665 'split /usr' : split_usr,
4666 'split bin-sbin' : split_bin,
4667 'prefix directory' : prefixdir,
4668 'rootprefix directory' : rootprefixdir,
4669 'sysconf directory' : sysconfdir,
4670 'include directory' : includedir,
4671 'lib directory' : libdir,
4672 'rootlib directory' : rootlibdir,
4673 'SysV init scripts' : sysvinit_path,
4674 'SysV rc?.d directories' : sysvrcnd_path,
4675 'PAM modules directory' : pamlibdir,
4676 'PAM configuration directory' : pamconfdir,
4677 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
4678 'RPM macros directory' : rpmmacrosdir,
4679 'modprobe.d directory' : modprobedir,
4680 'D-Bus policy directory' : dbuspolicydir,
4681 'D-Bus session directory' : dbussessionservicedir,
4682 'D-Bus system directory' : dbussystemservicedir,
4683 'D-Bus interfaces directory' : dbus_interfaces_dir,
4684 'bash completions directory' : bashcompletiondir,
4685 'zsh completions directory' : zshcompletiondir,
4686 'private shared lib version tag' : shared_lib_tag,
4687 'extra start script' : get_option('rc-local'),
4688 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
4689 get_option('debug-tty')),
4690 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
4691 conf.get('SYSTEM_ALLOC_UID_MIN')),
4692 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
4693 conf.get('SYSTEM_ALLOC_GID_MIN')),
4694 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
4695 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
4696 'static UID/GID allocations' : ' '.join(static_ugids),
4697 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
4698 'render group access mode' : get_option('group-render-mode'),
4699 'certificate root directory' : get_option('certificate-root'),
4700 'support URL' : support_url,
4701 'nobody user name' : nobody_user,
4702 'nobody group name' : nobody_group,
4703 'fallback hostname' : get_option('fallback-hostname'),
4704 'default compression method' : compression,
4705 'default DNSSEC mode' : default_dnssec,
4706 'default DNS-over-TLS mode' : default_dns_over_tls,
4707 'default mDNS mode' : default_mdns,
4708 'default LLMNR mode' : default_llmnr,
4709 'default DNS servers' : dns_servers.split(' '),
4710 'default NTP servers' : ntp_servers.split(' '),
4711 'default cgroup hierarchy' : default_hierarchy,
4712 'default net.naming-scheme value' : default_net_naming_scheme,
4713 'default KillUserProcesses value' : kill_user_processes,
4714 'default locale' : default_locale,
4715 'default nspawn locale' : nspawn_locale,
4716 'default status unit format' : status_unit_format_default,
4717 'default user $PATH' :
4718 default_user_path != '' ? default_user_path : '(same as system services)',
4719 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
4720 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
4723 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
4724 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
4725 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
4746 ['libcryptsetup-plugins'],
4773 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
4802 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
4816 ['legacy-pkla', install_polkit_pkla],
4822 ['man pages', want_man],
4823 ['html pages', want_html],
4824 ['man page indices', want_man and have_lxml],
4826 ['compat-mutable-uid-boundaries'],
4829 ['adm group', get_option('adm-group')],
4830 ['wheel group', get_option('wheel-group')],
4833 ['debug mmap cache'],
4835 ['trace logging', conf.get('LOG_TRACE') == 1],
4836 ['slow tests', slow_tests],
4837 ['fuzz tests', fuzz_tests],
4838 ['install tests', install_tests],
4839 ['link-udev-shared', get_option('link-udev-shared')],
4840 ['link-systemctl-shared', get_option('link-systemctl-shared')],
4841 ['link-networkd-shared', get_option('link-networkd-shared')],
4842 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
4843 ['link-journalctl-shared', get_option('link-journalctl-shared')],
4844 ['link-boot-shared', get_option('link-boot-shared')],
4845 ['first-boot-full-preset'],
4847 ['standalone-binaries', get_option('standalone-binaries')],
4848 ['coverage', get_option('b_coverage')],
4851 if tuple.length() >= 2
4854 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
4855 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
4856 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
4865 if static_libsystemd == 'false'
4866 missing += 'static-libsystemd'
4868 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
4871 if static_libudev == 'false'
4872 missing += 'static-libudev'
4874 found += 'static-libudev(@0@)'.format(static_libudev)
4877 if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
4878 found += 'cryptolib(openssl)'
4879 elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
4880 found += 'cryptolib(gcrypt)'
4882 missing += 'cryptolib'
4885 if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
4886 found += 'DNS-over-TLS(gnutls)'
4887 elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
4888 found += 'DNS-over-TLS(openssl)'
4890 missing += 'DNS-over-TLS'
4894 'enabled' : ', '.join(found),
4895 'disabled' : ', '.join(missing)},
4896 section : 'Features')
4898 if rootprefixdir != rootprefix_default
4900 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
4901 'systemd used fixed names for unit file directories and other paths, so anything\n' +
4902 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))