1 # SPDX-License-Identifier: LGPL-2.1-or-later
3 project('systemd', 'c',
13 meson_version : '>= 0.60.0',
16 libsystemd_version = '0.37.0'
17 libudev_version = '1.7.7'
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-bin') == 'auto'
80 split_bin = not fs.is_symlink('/usr/sbin')
82 split_bin = get_option('split-bin') == 'true'
84 conf.set10('HAVE_SPLIT_BIN', split_bin,
85 description : 'bin and sbin directories are separate')
87 have_standalone_binaries = get_option('standalone-binaries')
89 sysvinit_path = get_option('sysvinit-path')
90 sysvrcnd_path = get_option('sysvrcnd-path')
91 conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '',
92 description : 'SysV init scripts and rcN.d links are supported')
93 conf.set10('CREATE_LOG_DIRS', get_option('create-log-dirs'))
95 if get_option('hibernate') and not get_option('initrd')
96 error('hibernate depends on initrd')
99 conf.set10('BUMP_PROC_SYS_FS_FILE_MAX', get_option('bump-proc-sys-fs-file-max'))
100 conf.set10('BUMP_PROC_SYS_FS_NR_OPEN', get_option('bump-proc-sys-fs-nr-open'))
101 conf.set('HIGH_RLIMIT_NOFILE', 512*1024)
103 # Meson ignores the preceding arguments when joining paths if an absolute
104 # component is encountered, so this should canonicalize various paths when they
105 # are absolute or relative.
106 prefixdir = get_option('prefix')
107 if not prefixdir.startswith('/')
108 error('Prefix is not absolute: "@0@"'.format(prefixdir))
111 prefixdir_noslash = '/' + prefixdir.strip('/')
112 bindir = prefixdir / get_option('bindir')
113 sbindir = prefixdir / (split_bin ? 'sbin' : 'bin')
114 libdir = prefixdir / get_option('libdir')
115 sysconfdir = prefixdir / get_option('sysconfdir')
116 includedir = prefixdir / get_option('includedir')
117 datadir = prefixdir / get_option('datadir')
118 localstatedir = '/' / get_option('localstatedir')
120 libexecdir = prefixdir / 'lib/systemd'
121 pkglibdir = libdir / 'systemd'
123 install_sysconfdir = get_option('install-sysconfdir') != 'false'
124 install_sysconfdir_samples = get_option('install-sysconfdir') == 'true'
125 # Dirs of external packages
126 pkgconfigdatadir = get_option('pkgconfigdatadir') != '' ? get_option('pkgconfigdatadir') : datadir / 'pkgconfig'
127 pkgconfiglibdir = get_option('pkgconfiglibdir') != '' ? get_option('pkgconfiglibdir') : libdir / 'pkgconfig'
128 polkitpolicydir = datadir / 'polkit-1/actions'
129 polkitrulesdir = datadir / 'polkit-1/rules.d'
130 polkitpkladir = localstatedir / 'lib/polkit-1/localauthority/10-vendor.d'
131 xinitrcdir = get_option('xinitrcdir') != '' ? get_option('xinitrcdir') : sysconfdir / 'X11/xinit/xinitrc.d'
132 rpmmacrosdir = get_option('rpmmacrosdir')
133 if rpmmacrosdir != 'no'
134 rpmmacrosdir = prefixdir / rpmmacrosdir
136 modprobedir = prefixdir / 'lib/modprobe.d'
139 pkgdatadir = datadir / 'systemd'
140 environmentdir = prefixdir / 'lib/environment.d'
141 pkgsysconfdir = sysconfdir / 'systemd'
142 userunitdir = prefixdir / 'lib/systemd/user'
143 userpresetdir = prefixdir / 'lib/systemd/user-preset'
144 tmpfilesdir = prefixdir / 'lib/tmpfiles.d'
145 usertmpfilesdir = prefixdir / 'share/user-tmpfiles.d'
146 sysusersdir = prefixdir / 'lib/sysusers.d'
147 sysctldir = prefixdir / 'lib/sysctl.d'
148 binfmtdir = prefixdir / 'lib/binfmt.d'
149 modulesloaddir = prefixdir / 'lib/modules-load.d'
150 networkdir = prefixdir / 'lib/systemd/network'
151 systemgeneratordir = libexecdir / 'system-generators'
152 usergeneratordir = prefixdir / 'lib/systemd/user-generators'
153 systemenvgeneratordir = prefixdir / 'lib/systemd/system-environment-generators'
154 userenvgeneratordir = prefixdir / 'lib/systemd/user-environment-generators'
155 systemshutdowndir = libexecdir / 'system-shutdown'
156 systemsleepdir = libexecdir / 'system-sleep'
157 systemunitdir = prefixdir / 'lib/systemd/system'
158 systempresetdir = prefixdir / 'lib/systemd/system-preset'
159 udevlibexecdir = prefixdir / 'lib/udev'
160 udevrulesdir = udevlibexecdir / 'rules.d'
161 udevhwdbdir = udevlibexecdir / 'hwdb.d'
162 catalogdir = prefixdir / 'lib/systemd/catalog'
163 kerneldir = prefixdir / 'lib/kernel'
164 kernelinstalldir = kerneldir / 'install.d'
165 factorydir = datadir / 'factory'
166 bootlibdir = prefixdir / 'lib/systemd/boot/efi'
167 testsdir = prefixdir / 'lib/systemd/tests'
168 unittestsdir = testsdir / 'unit-tests'
169 testdata_dir = testsdir / 'testdata'
170 systemdstatedir = localstatedir / 'lib/systemd'
171 catalogstatedir = systemdstatedir / 'catalog'
172 randomseeddir = localstatedir / 'lib/systemd'
173 profiledir = libexecdir / 'portable' / 'profile'
174 ntpservicelistdir = prefixdir / 'lib/systemd/ntp-units.d'
175 credstoredir = prefixdir / 'lib/credstore'
177 docdir = get_option('docdir')
179 docdir = datadir / 'doc/systemd'
182 pamlibdir = get_option('pamlibdir')
184 pamlibdir = libdir / 'security'
187 pamconfdir = get_option('pamconfdir')
189 pamconfdir = prefixdir / 'lib/pam.d'
192 libcryptsetup_plugins_dir = get_option('libcryptsetup-plugins-dir')
193 if libcryptsetup_plugins_dir == ''
194 libcryptsetup_plugins_dir = libdir / 'cryptsetup'
197 memory_accounting_default = get_option('memory-accounting-default')
198 status_unit_format_default = get_option('status-unit-format-default')
199 if status_unit_format_default == 'auto'
200 status_unit_format_default = conf.get('BUILD_MODE_DEVELOPER') == 1 ? 'name' : 'description'
203 conf.set_quoted('BINDIR', bindir)
204 conf.set_quoted('BINFMT_DIR', binfmtdir)
205 conf.set_quoted('BOOTLIBDIR', bootlibdir)
206 conf.set_quoted('CATALOG_DATABASE', catalogstatedir / 'database')
207 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
208 conf.set_quoted('DOC_DIR', docdir)
209 conf.set_quoted('DOCUMENT_ROOT', pkgdatadir / 'gatewayd')
210 conf.set_quoted('ENVIRONMENT_DIR', environmentdir)
211 conf.set_quoted('INCLUDE_DIR', includedir)
212 conf.set_quoted('LIBDIR', libdir)
213 conf.set_quoted('LIBEXECDIR', libexecdir)
214 conf.set_quoted('MODPROBE_DIR', modprobedir)
215 conf.set_quoted('MODULESLOAD_DIR', modulesloaddir)
216 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
217 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', bindir / 'pkttyagent')
218 conf.set_quoted('PREFIX', prefixdir)
219 conf.set_quoted('PREFIX_NOSLASH', prefixdir_noslash)
220 conf.set_quoted('RANDOM_SEED', randomseeddir / 'random-seed')
221 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
222 conf.set_quoted('RC_LOCAL_PATH', get_option('rc-local'))
223 conf.set_quoted('SYSCONF_DIR', sysconfdir)
224 conf.set_quoted('SYSCTL_DIR', sysctldir)
225 conf.set_quoted('SYSTEMCTL_BINARY_PATH', bindir / 'systemctl')
226 conf.set_quoted('SYSTEMD_BINARY_PATH', libexecdir / 'systemd')
227 conf.set_quoted('SYSTEMD_CATALOG_DIR', catalogdir)
228 conf.set_quoted('SYSTEMD_CGROUPS_AGENT_PATH', libexecdir / 'systemd-cgroups-agent')
229 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', libexecdir / 'systemd-cryptsetup')
230 conf.set_quoted('SYSTEMD_EXPORT_PATH', libexecdir / 'systemd-export')
231 conf.set_quoted('SYSTEMD_FSCK_PATH', libexecdir / 'systemd-fsck')
232 conf.set_quoted('SYSTEMD_GROWFS_PATH', libexecdir / 'systemd-growfs')
233 conf.set_quoted('SYSTEMD_HOMEWORK_PATH', libexecdir / 'systemd-homework')
234 conf.set_quoted('SYSTEMD_IMPORT_FS_PATH', libexecdir / 'systemd-import-fs')
235 conf.set_quoted('SYSTEMD_IMPORT_PATH', libexecdir / 'systemd-import')
236 conf.set_quoted('SYSTEMD_INTEGRITYSETUP_PATH', libexecdir / 'systemd-integritysetup')
237 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', pkgdatadir / 'kbd-model-map')
238 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', pkgdatadir / 'language-fallback-map')
239 conf.set_quoted('SYSTEMD_MAKEFS_PATH', libexecdir / 'systemd-makefs')
240 conf.set_quoted('SYSTEMD_PULL_PATH', libexecdir / 'systemd-pull')
241 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', libexecdir / 'systemd-shutdown')
242 conf.set_quoted('SYSTEMD_TEST_DATA', testdata_dir)
243 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', bindir / 'systemd-tty-ask-password-agent')
244 conf.set_quoted('SYSTEMD_UPDATE_HELPER_PATH', libexecdir / 'systemd-update-helper')
245 conf.set_quoted('SYSTEMD_USERWORK_PATH', libexecdir / 'systemd-userwork')
246 conf.set_quoted('SYSTEMD_VERITYSETUP_PATH', libexecdir / 'systemd-veritysetup')
247 conf.set_quoted('SYSTEM_CONFIG_UNIT_DIR', pkgsysconfdir / 'system')
248 conf.set_quoted('SYSTEM_DATA_UNIT_DIR', systemunitdir)
249 conf.set_quoted('SYSTEM_ENV_GENERATOR_DIR', systemenvgeneratordir)
250 conf.set_quoted('SYSTEM_GENERATOR_DIR', systemgeneratordir)
251 conf.set_quoted('SYSTEM_PRESET_DIR', systempresetdir)
252 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
253 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
254 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
255 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
256 conf.set_quoted('SYSUSERS_DIR', sysusersdir)
257 conf.set_quoted('TMPFILES_DIR', tmpfilesdir)
258 conf.set_quoted('USER_TMPFILES_DIR', usertmpfilesdir)
259 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
260 conf.set_quoted('UDEV_HWDB_DIR', udevhwdbdir)
261 conf.set_quoted('UDEV_RULES_DIR', udevrulesdir)
262 conf.set_quoted('USER_CONFIG_UNIT_DIR', pkgsysconfdir / 'user')
263 conf.set_quoted('USER_DATA_UNIT_DIR', userunitdir)
264 conf.set_quoted('USER_ENV_GENERATOR_DIR', userenvgeneratordir)
265 conf.set_quoted('USER_GENERATOR_DIR', usergeneratordir)
266 conf.set_quoted('USER_KEYRING_PATH', pkgsysconfdir / 'import-pubring.gpg')
267 conf.set_quoted('USER_PRESET_DIR', userpresetdir)
268 conf.set_quoted('VENDOR_KEYRING_PATH', libexecdir / 'import-pubring.gpg')
270 conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
271 conf.set10('ENABLE_URLIFY', get_option('urlify'))
272 conf.set10('ENABLE_FEXECVE', get_option('fexecve'))
273 conf.set10('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default)
274 conf.set('STATUS_UNIT_FORMAT_DEFAULT', 'STATUS_UNIT_FORMAT_' + status_unit_format_default.to_upper())
275 conf.set_quoted('STATUS_UNIT_FORMAT_DEFAULT_STR', status_unit_format_default)
277 conf.set('DEFAULT_TIMEOUT_SEC', get_option('default-timeout-sec'))
278 conf.set('DEFAULT_USER_TIMEOUT_SEC', get_option('default-user-timeout-sec'))
279 conf.set('UPDATE_HELPER_USER_TIMEOUT_SEC', get_option('update-helper-user-timeout-sec'))
281 conf.set10('FIRST_BOOT_FULL_PRESET', get_option('first-boot-full-preset'))
283 #####################################################################
285 cc = meson.get_compiler('c')
286 userspace_c_args = []
287 userspace_c_ld_args = []
288 meson_build_sh = find_program('tools/meson-build.sh')
290 want_tests = get_option('tests')
291 slow_tests = want_tests != 'false' and get_option('slow-tests')
292 fuzz_tests = want_tests != 'false' and get_option('fuzz-tests')
293 install_tests = get_option('install-tests')
295 if add_languages('cpp', native : false, required : fuzzer_build)
296 # Used only for tests
297 cxx = meson.get_compiler('cpp')
298 cxx_cmd = ' '.join(cxx.cmd_array())
304 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer', required : false)
305 if fuzzing_engine.found()
306 userspace_c_args += '-fsanitize-coverage=trace-pc-guard,trace-cmp'
307 elif cc.has_argument('-fsanitize=fuzzer-no-link')
308 userspace_c_args += '-fsanitize=fuzzer-no-link'
310 error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported')
313 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
316 # Those generate many false positives, and we do not want to change the code to
318 basic_disabled_warnings = [
319 '-Wno-missing-field-initializers',
320 '-Wno-unused-parameter',
323 possible_common_cc_flags = [
324 '-Warray-bounds', # clang
329 '-Werror=format-signedness',
330 '-Werror=implicit-function-declaration',
331 '-Werror=implicit-int',
332 '-Werror=incompatible-pointer-types',
333 '-Werror=int-conversion',
334 '-Werror=missing-declarations',
335 '-Werror=missing-prototypes',
337 '-Werror=override-init',
338 '-Werror=return-type',
339 '-Werror=shift-count-overflow',
340 '-Werror=shift-overflow=2',
341 '-Werror=strict-flex-arrays',
344 # gperf prevents us from enabling this because it does not emit fallthrough
345 # attribute with clang.
346 #'-Wimplicit-fallthrough',
347 '-Wimplicit-fallthrough=5',
350 '-Wmissing-include-dirs',
351 '-Wmissing-noreturn',
353 '-Wold-style-definition',
357 '-Wstrict-aliasing=2',
358 '-Wstrict-prototypes',
359 '-Wsuggest-attribute=noreturn',
362 '-Wzero-length-bounds',
364 # negative arguments are correctly detected starting with meson 0.46.
365 '-Wno-error=#warnings', # clang
366 '-Wno-string-plus-int', # clang
368 '-fdiagnostics-show-option',
371 '-fstack-protector-strong',
372 '-fstrict-flex-arrays',
373 '--param=ssp-buffer-size=4',
376 possible_common_link_flags = [
380 c_args = get_option('c_args')
382 # Our json library does not support -ffinite-math-only, which is enabled by -Ofast or -ffast-math.
383 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)
384 error('-Ofast, -ffast-math, or -ffinite-math-only is specified in c_args.')
387 # Disable -Wmaybe-uninitialized when compiling with -Os/-O1/-O3/etc. There are
388 # too many false positives with gcc >= 8. Effectively, we only test with -O0
389 # and -O2; this should be enough to catch most important cases without too much
390 # busywork. See https://github.com/systemd/systemd/pull/19226.
391 if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or
392 cc.version().version_compare('<10') or
397 possible_common_cc_flags += '-Wno-maybe-uninitialized'
400 # Disable -Wno-unused-result with gcc, see
401 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425.
402 if cc.get_id() == 'gcc'
403 possible_common_cc_flags += '-Wno-unused-result'
406 # --as-needed and --no-undefined are provided by meson by default,
407 # run 'meson configure' to see what is enabled
408 possible_link_flags = [
409 '-Wl,--fatal-warnings',
414 if get_option('b_sanitize') == 'none'
415 possible_link_flags += '-Wl,--warn-common'
418 if cc.get_id() == 'clang'
419 possible_common_cc_flags += [
420 '-Wno-typedef-redefinition',
421 '-Wno-gnu-variable-sized-type-not-at-end',
425 if get_option('mode') == 'release'
426 # We could enable 'pattern' for developer mode, but that can interfere with
427 # valgrind and sanitizer builds. Also, clang does not zero-initialize unions,
428 # breaking some of our code (https://reviews.llvm.org/D68115).
429 possible_common_cc_flags += '-ftrivial-auto-var-init=zero'
432 possible_cc_flags = [
433 '-fno-strict-aliasing',
434 '-fstrict-flex-arrays=1',
435 '-fvisibility=hidden',
438 if get_option('buildtype') != 'debug'
439 possible_cc_flags += [
440 '-ffunction-sections',
444 possible_link_flags += '-Wl,--gc-sections'
447 if get_option('mode') == 'developer'
448 possible_cc_flags += '-fno-omit-frame-pointer'
451 add_project_arguments(
452 cc.get_supported_arguments(
453 basic_disabled_warnings,
454 possible_common_cc_flags
458 add_project_link_arguments(
459 cc.get_supported_link_arguments(possible_common_link_flags),
462 userspace_c_args += cc.get_supported_arguments(possible_cc_flags)
463 userspace_c_ld_args += cc.get_supported_link_arguments(possible_link_flags)
465 have = cc.has_argument('-Wzero-length-bounds')
466 conf.set10('HAVE_ZERO_LENGTH_BOUNDS', have)
470 #include <inttypes.h>
471 typedef uint64_t usec_t;
472 usec_t now(clockid_t clock);
477 ''', args: '-Werror=shadow', name : '-Werror=shadow with local shadowing')
478 add_project_arguments('-Werror=shadow', language : 'c')
482 add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
485 cpp = ' '.join(cc.cmd_array()) + ' -E'
487 has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
489 #####################################################################
490 # compilation result tests
492 conf.set('_GNU_SOURCE', 1)
493 conf.set('__SANE_USERSPACE_TYPES__', true)
494 conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)
496 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
497 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
498 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
499 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
500 conf.set('SIZEOF_TIMEX_MEMBER', cc.sizeof('typeof(((struct timex *)0)->freq)', prefix : '#include <sys/timex.h>'))
502 long_max = cc.compute_int(
504 prefix : '#include <limits.h>',
505 guess : 0x7FFFFFFFFFFFFFFF,
506 high : 0x7FFFFFFFFFFFFFFF)
507 assert(long_max > 100000)
508 conf.set_quoted('LONG_MAX_STR', '@0@'.format(long_max))
513 #include <sys/mount.h>
514 #include <sys/stat.h>
517 foreach decl : ['char16_t',
524 # We get -1 if the size cannot be determined
525 have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
527 if decl == 'struct mount_attr'
529 want_linux_fs_h = false
531 have = cc.sizeof(decl,
532 prefix : decl_headers + '#include <linux/fs.h>',
533 args : '-D_GNU_SOURCE') > 0
534 want_linux_fs_h = have
538 if decl == 'struct statx'
540 want_linux_stat_h = false
542 have = cc.sizeof(decl,
543 prefix : decl_headers + '#include <linux/stat.h>',
544 args : '-D_GNU_SOURCE') > 0
545 want_linux_stat_h = have
549 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
552 conf.set10('WANT_LINUX_STAT_H', want_linux_stat_h)
553 conf.set10('WANT_LINUX_FS_H', want_linux_fs_h)
555 foreach ident : ['secure_getenv', '__secure_getenv']
556 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
560 ['memfd_create', '''#include <sys/mman.h>'''],
561 ['gettid', '''#include <sys/types.h>
562 #include <unistd.h>'''],
563 ['pivot_root', '''#include <stdlib.h>
564 #include <unistd.h>'''], # no known header declares pivot_root
565 ['ioprio_get', '''#include <sched.h>'''], # no known header declares ioprio_get
566 ['ioprio_set', '''#include <sched.h>'''], # no known header declares ioprio_set
567 ['name_to_handle_at', '''#include <sys/types.h>
568 #include <sys/stat.h>
569 #include <fcntl.h>'''],
570 ['setns', '''#include <sched.h>'''],
571 ['renameat2', '''#include <stdio.h>
572 #include <fcntl.h>'''],
573 ['kcmp', '''#include <linux/kcmp.h>'''],
574 ['keyctl', '''#include <sys/types.h>
575 #include <keyutils.h>'''],
576 ['copy_file_range', '''#include <sys/syscall.h>
577 #include <unistd.h>'''],
578 ['bpf', '''#include <sys/syscall.h>
579 #include <unistd.h>'''],
580 ['statx', '''#include <sys/types.h>
581 #include <sys/stat.h>
582 #include <unistd.h>'''],
583 ['explicit_bzero' , '''#include <string.h>'''],
584 ['reallocarray', '''#include <stdlib.h>'''],
585 ['set_mempolicy', '''#include <stdlib.h>
586 #include <unistd.h>'''],
587 ['get_mempolicy', '''#include <stdlib.h>
588 #include <unistd.h>'''],
589 ['pidfd_send_signal', '''#include <stdlib.h>
592 #include <sys/wait.h>'''],
593 ['pidfd_open', '''#include <stdlib.h>
596 #include <sys/wait.h>'''],
597 ['rt_sigqueueinfo', '''#include <stdlib.h>
600 #include <sys/wait.h>'''],
601 ['rt_tgsigqueueinfo', '''#include <stdlib.h>
604 #include <sys/wait.h>'''],
605 ['mallinfo', '''#include <malloc.h>'''],
606 ['mallinfo2', '''#include <malloc.h>'''],
607 ['execveat', '''#include <unistd.h>'''],
608 ['close_range', '''#include <unistd.h>'''],
609 ['epoll_pwait2', '''#include <sys/epoll.h>'''],
610 ['mount_setattr', '''#include <sys/mount.h>'''],
611 ['move_mount', '''#include <sys/mount.h>'''],
612 ['open_tree', '''#include <sys/mount.h>'''],
613 ['fsopen', '''#include <sys/mount.h>'''],
614 ['fsconfig', '''#include <sys/mount.h>'''],
615 ['fsmount', '''#include <sys/mount.h>'''],
616 ['getdents64', '''#include <dirent.h>'''],
619 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
620 conf.set10('HAVE_' + ident[0].to_upper(), have)
623 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
624 conf.set10('USE_SYS_RANDOM_H', true)
625 conf.set10('HAVE_GETRANDOM', true)
627 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
628 conf.set10('USE_SYS_RANDOM_H', false)
629 conf.set10('HAVE_GETRANDOM', have)
632 #####################################################################
634 sh = find_program('sh')
635 echo = find_program('echo')
636 sed = find_program('sed')
637 awk = find_program('awk')
638 stat = find_program('stat')
639 ln = find_program('ln')
640 git = find_program('git', required : false)
641 env = find_program('env')
642 rsync = find_program('rsync', required : false)
643 diff = find_program('diff')
644 find = find_program('find')
645 meson_make_symlink = project_source_root + '/tools/meson-make-symlink.sh'
647 mkdir_p = 'mkdir -p $DESTDIR/@0@'
648 mkdir_p_mode = 'mkdir -p $DESTDIR/@0@ -m @1@'
650 # If -Dxxx-path option is found, use that. Otherwise, check in $PATH,
651 # /usr/sbin, /sbin, and fall back to the default from middle column.
652 progs = [['quotaon', '/usr/sbin/quotaon' ],
653 ['quotacheck', '/usr/sbin/quotacheck' ],
654 ['kmod', '/usr/bin/kmod' ],
655 ['kexec', '/usr/sbin/kexec' ],
656 ['sulogin', '/usr/sbin/sulogin' ],
657 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
658 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
659 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
660 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
661 ['nologin', '/usr/sbin/nologin', ],
664 path = get_option(prog[0] + '-path')
666 message('Using @1@ for @0@'.format(prog[0], path))
668 exe = find_program(prog[0],
669 '/usr/sbin/' + prog[0],
672 path = exe.found() ? exe.full_path() : prog[1]
674 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
675 conf.set_quoted(name, path)
678 conf.set_quoted('TELINIT', get_option('telinit-path'))
680 if run_command(ln, '--relative', '--help', check : false).returncode() != 0
681 error('ln does not support --relative (added in coreutils 8.16)')
684 ############################################################
686 gperf = find_program('gperf')
688 gperf_test_format = '''
690 const char * in_word_set(const char *, @0@);
693 gperf_snippet = run_command(sh, '-c', 'echo foo,bar | "$1" -L ANSI-C', '_', gperf,
695 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
696 if cc.compiles(gperf_test)
697 gperf_len_type = 'size_t'
699 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
700 if cc.compiles(gperf_test)
701 gperf_len_type = 'unsigned'
703 error('unable to determine gperf len type')
706 message('gperf len type is @0@'.format(gperf_len_type))
707 conf.set('GPERF_LEN_TYPE', gperf_len_type,
708 description : 'The type of gperf "len" parameter')
710 ############################################################
712 if not cc.has_header('sys/capability.h')
713 error('POSIX caps headers not found')
715 foreach header : ['crypt.h',
717 'linux/vm_sockets.h',
720 'valgrind/memcheck.h',
721 'valgrind/valgrind.h',
722 'linux/time_types.h',
726 conf.set10('HAVE_' + header.underscorify().to_upper(),
727 cc.has_header(header))
730 ############################################################
732 fallback_hostname = get_option('fallback-hostname')
733 if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0] == '-'
734 error('Invalid fallback-hostname configuration')
735 # A more extensive test is done in test-hostname-util. Let's catch
736 # the most obvious errors here so we don't fail with an assert later.
738 conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
740 default_hierarchy = get_option('default-hierarchy')
741 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
742 description : 'default cgroup hierarchy as string')
743 if default_hierarchy == 'legacy'
744 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
745 elif default_hierarchy == 'hybrid'
746 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
748 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
751 extra_net_naming_schemes = []
752 extra_net_naming_map = []
753 foreach scheme: get_option('extra-net-naming-schemes').split(',')
755 name = scheme.split('=')[0]
756 value = scheme.split('=')[1]
757 NAME = name.underscorify().to_upper()
759 foreach field: value.split('+')
760 VALUE += 'NAMING_' + field.underscorify().to_upper()
762 extra_net_naming_schemes += 'NAMING_@0@ = @1@,'.format(NAME, '|'.join(VALUE))
763 extra_net_naming_map += '{ "@0@", NAMING_@1@ },'.format(name, NAME)
766 conf.set('EXTRA_NET_NAMING_SCHEMES', ' '.join(extra_net_naming_schemes))
767 conf.set('EXTRA_NET_NAMING_MAP', ' '.join(extra_net_naming_map))
769 default_net_naming_scheme = get_option('default-net-naming-scheme')
770 conf.set_quoted('DEFAULT_NET_NAMING_SCHEME', default_net_naming_scheme)
771 if default_net_naming_scheme != 'latest'
772 conf.set('_DEFAULT_NET_NAMING_SCHEME_TEST',
773 'NAMING_' + default_net_naming_scheme.underscorify().to_upper())
776 time_epoch = get_option('time-epoch')
778 time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check : true).stdout().strip()
779 if time_epoch == '' and git.found() and fs.is_dir('.git')
780 # If we're in a git repository, use the creation time of the latest git tag.
781 latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags',
783 if latest_tag.returncode() == 0
784 time_epoch = run_command(
785 git, 'log', '--no-show-signature', '-1', '--format=%at',
786 latest_tag.stdout().strip(),
787 check : false).stdout()
792 time_epoch = run_command(stat, '-c', '%Y', NEWS,
793 check : true).stdout()
795 time_epoch = time_epoch.strip().to_int()
797 conf.set('TIME_EPOCH', time_epoch)
799 conf.set('CLOCK_VALID_RANGE_USEC_MAX', get_option('clock-valid-range-usec-max'))
801 default_user_shell = get_option('default-user-shell')
802 conf.set_quoted('DEFAULT_USER_SHELL', default_user_shell)
803 conf.set_quoted('DEFAULT_USER_SHELL_NAME', fs.name(default_user_shell))
805 foreach tuple : [['system-alloc-uid-min', 'SYS_UID_MIN', 1], # Also see login.defs(5).
806 ['system-uid-max', 'SYS_UID_MAX', 999],
807 ['system-alloc-gid-min', 'SYS_GID_MIN', 1],
808 ['system-gid-max', 'SYS_GID_MAX', 999]]
809 v = get_option(tuple[0])
813 '/^\s*@0@\s+/ { uid=$2 } END { print uid }'.format(tuple[1]),
815 check : false).stdout().strip()
822 conf.set(tuple[0].underscorify().to_upper(), v)
824 if conf.get('SYSTEM_ALLOC_UID_MIN') >= conf.get('SYSTEM_UID_MAX')
825 error('Invalid uid allocation range')
827 if conf.get('SYSTEM_ALLOC_GID_MIN') >= conf.get('SYSTEM_GID_MAX')
828 error('Invalid gid allocation range')
831 dynamic_uid_min = get_option('dynamic-uid-min')
832 dynamic_uid_max = get_option('dynamic-uid-max')
833 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
834 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
836 container_uid_base_min = get_option('container-uid-base-min')
837 container_uid_base_max = get_option('container-uid-base-max')
838 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
839 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
841 nobody_user = get_option('nobody-user')
842 nobody_group = get_option('nobody-group')
844 if not meson.is_cross_build()
845 getent_result = run_command('getent', 'passwd', '65534', check : false)
846 if getent_result.returncode() == 0
847 name = getent_result.stdout().split(':')[0]
848 if name != nobody_user
850 '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) +
851 'Your build will result in an user table setup that is incompatible with the local system.')
854 id_result = run_command('id', '-u', nobody_user, check : false)
855 if id_result.returncode() == 0
856 id = id_result.stdout().strip().to_int()
859 '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) +
860 'Your build will result in an user table setup that is incompatible with the local system.')
864 getent_result = run_command('getent', 'group', '65534', check : false)
865 if getent_result.returncode() == 0
866 name = getent_result.stdout().split(':')[0]
867 if name != nobody_group
869 '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) +
870 'Your build will result in an group table setup that is incompatible with the local system.')
873 id_result = run_command('id', '-g', nobody_group, check : false)
874 if id_result.returncode() == 0
875 id = id_result.stdout().strip().to_int()
878 '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) +
879 'Your build will result in an group table setup that is incompatible with the local system.')
883 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
885 'The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
886 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
889 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
890 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
893 foreach option : ['adm-gid',
910 'systemd-journal-gid',
911 'systemd-network-uid',
912 'systemd-resolve-uid',
913 'systemd-timesync-uid']
914 name = option.underscorify().to_upper()
915 val = get_option(option)
917 # Ensure provided GID argument is numeric, otherwise fall back to default assignment
918 conf.set(name, val > 0 ? val : '-')
920 static_ugids += '@0@:@1@'.format(option, val)
924 conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
925 conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
927 dev_kvm_mode = get_option('dev-kvm-mode')
928 conf.set_quoted('DEV_KVM_MODE', dev_kvm_mode) # FIXME: convert to 0o… notation
929 conf.set10('DEV_KVM_UACCESS', dev_kvm_mode != '0666')
930 group_render_mode = get_option('group-render-mode')
931 conf.set_quoted('GROUP_RENDER_MODE', group_render_mode)
932 conf.set10('GROUP_RENDER_UACCESS', group_render_mode != '0666')
934 kill_user_processes = get_option('default-kill-user-processes')
935 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
937 dns_servers = get_option('dns-servers')
938 conf.set_quoted('DNS_SERVERS', dns_servers)
940 ntp_servers = get_option('ntp-servers')
941 conf.set_quoted('NTP_SERVERS', ntp_servers)
943 default_locale = get_option('default-locale')
944 conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale)
946 nspawn_locale = get_option('nspawn-locale')
947 conf.set_quoted('SYSTEMD_NSPAWN_LOCALE', nspawn_locale)
949 default_keymap = get_option('default-keymap')
950 conf.set_quoted('SYSTEMD_DEFAULT_KEYMAP', default_keymap)
952 localegen_path = get_option('localegen-path')
953 if localegen_path != ''
954 conf.set_quoted('LOCALEGEN_PATH', localegen_path)
956 conf.set10('HAVE_LOCALEGEN', localegen_path != '')
958 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
960 service_watchdog = get_option('service-watchdog')
961 watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
962 conf.set_quoted('SERVICE_WATCHDOG', watchdog_value)
964 conf.set_quoted('SUSHELL', get_option('debug-shell'))
965 conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
967 enable_debug_hashmap = false
968 enable_debug_mmap_cache = false
969 enable_debug_siphash = false
970 foreach name : get_option('debug-extra')
972 enable_debug_hashmap = true
973 elif name == 'mmap-cache'
974 enable_debug_mmap_cache = true
975 elif name == 'siphash'
976 enable_debug_siphash = true
978 message('unknown debug option "@0@", ignoring'.format(name))
981 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
982 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
983 conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash)
984 conf.set10('LOG_TRACE', get_option('log-trace'))
986 default_user_path = get_option('user-path')
987 if default_user_path != ''
988 conf.set_quoted('DEFAULT_USER_PATH', default_user_path)
991 #####################################################################
993 threads = dependency('threads')
994 librt = cc.find_library('rt')
995 libm = cc.find_library('m')
996 libdl = cc.find_library('dl')
997 libcrypt = dependency('libcrypt', 'libxcrypt', required : false)
998 if not libcrypt.found()
999 # fallback to use find_library() if libcrypt is provided by glibc, e.g. for LibreELEC.
1000 libcrypt = cc.find_library('crypt')
1002 libcap = dependency('libcap')
1004 # On some architectures, libatomic is required. But on some installations,
1005 # it is found, but actual linking fails. So let's try to use it opportunistically.
1006 # If it is installed, but not needed, it will be dropped because of --as-needed.
1007 if cc.links('''int main(int argc, char **argv) { return 0; }''',
1010 libatomic = declare_dependency(link_args : '-latomic')
1015 crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
1017 ['crypt_ra', crypt_header],
1018 ['crypt_preferred_method', crypt_header],
1019 ['crypt_gensalt_ra', crypt_header]]
1021 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
1022 dependencies : libcrypt)
1023 conf.set10('HAVE_' + ident[0].to_upper(), have)
1026 want_bpf_framework = get_option('bpf-framework')
1027 bpf_compiler = get_option('bpf-compiler')
1028 bpf_framework_required = want_bpf_framework == 'true'
1030 libbpf_version_requirement = '>= 0.1.0'
1031 if bpf_compiler == 'gcc'
1032 libbpf_version_requirement = '>= 1.0.0'
1034 libbpf = dependency('libbpf', required : bpf_framework_required, version : libbpf_version_requirement)
1035 conf.set10('HAVE_LIBBPF', libbpf.found())
1037 bpftool_strip_version_requirement = '>= 5.13.0'
1038 if bpf_compiler == 'gcc'
1039 bpftool_strip_version_requirement = '>= 7.0.0'
1042 if want_bpf_framework == 'false' or not libbpf.found() or skip_deps
1043 conf.set10('BPF_FRAMEWORK', false)
1046 clang_supports_bpf = false
1047 bpf_gcc_found = false
1048 bpftool_strip = false
1051 if bpf_compiler == 'clang'
1052 # Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu
1053 # (like clang-10/llvm-strip-10)
1054 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')
1055 r = find_program('clang', required : bpf_framework_required, version : '>= 10.0.0')
1056 clang_found = r.found()
1058 clang = r.full_path()
1062 clang = cc.cmd_array()
1066 # Check if 'clang -target bpf' is supported.
1067 clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0
1069 elif bpf_compiler == 'gcc'
1070 bpf_gcc = find_program('bpf-gcc',
1073 version : '>= 13.1.0')
1074 bpf_gcc_found = bpf_gcc.found()
1077 if clang_supports_bpf or bpf_gcc_found
1078 # Debian installs this in /usr/sbin/ which is not in $PATH.
1079 # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian.
1080 # We use 'bpftool gen object' subcommand for bpftool strip, it was added by d80b2fcbe0a023619e0fc73112f2a02c2662f6ab (v5.13).
1081 bpftool_strip_required = bpf_framework_required and bpf_compiler == 'gcc'
1082 bpftool = find_program('bpftool',
1083 '/usr/sbin/bpftool',
1084 required : bpftool_strip_required,
1085 version : bpftool_strip_version_requirement)
1088 bpftool_strip = true
1090 elif bpf_compiler == 'clang'
1091 # We require the 'bpftool gen skeleton' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6).
1092 bpftool = find_program('bpftool',
1093 '/usr/sbin/bpftool',
1094 required : bpf_framework_required,
1095 version : '>= 5.6.0')
1098 # We use `llvm-strip` as a fallback if `bpftool gen object` strip support is not available.
1099 if not bpftool_strip and bpftool.found() and clang_supports_bpf
1100 if not meson.is_cross_build()
1101 llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip',
1102 check : true).stdout().strip()
1104 llvm_strip_bin = 'llvm-strip'
1106 llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0')
1107 deps_found = llvm_strip.found()
1111 # Can build BPF program from source code in restricted C
1112 conf.set10('BPF_FRAMEWORK', deps_found)
1115 libmount = dependency('mount',
1116 version : fuzzer_build ? '>= 0' : '>= 2.30')
1118 want_libfdisk = get_option('fdisk')
1119 if want_libfdisk != 'false' and not skip_deps
1120 libfdisk = dependency('fdisk',
1121 version : '>= 2.32',
1122 required : want_libfdisk == 'true')
1123 have = libfdisk.found()
1128 conf.set10('HAVE_LIBFDISK', have)
1130 want_passwdqc = get_option('passwdqc')
1131 want_pwquality = get_option('pwquality')
1132 if want_passwdqc == 'true' and want_pwquality == 'true'
1133 error('passwdqc and pwquality cannot be requested simultaneously')
1136 if want_pwquality != 'false' and want_passwdqc != 'true' and not skip_deps
1137 libpwquality = dependency('pwquality',
1138 version : '>= 1.4.1',
1139 required : want_pwquality == 'true')
1140 have = libpwquality.found()
1145 conf.set10('HAVE_PWQUALITY', have)
1147 if not have and want_passwdqc != 'false' and not skip_deps
1148 libpasswdqc = dependency('passwdqc',
1149 required : want_passwdqc == 'true')
1150 have = libpasswdqc.found()
1155 conf.set10('HAVE_PASSWDQC', have)
1157 want_seccomp = get_option('seccomp')
1158 if want_seccomp != 'false' and not skip_deps
1159 libseccomp = dependency('libseccomp',
1160 version : '>= 2.3.1',
1161 required : want_seccomp == 'true')
1162 have = libseccomp.found()
1167 conf.set10('HAVE_SECCOMP', have)
1169 want_selinux = get_option('selinux')
1170 if want_selinux != 'false' and not skip_deps
1171 libselinux = dependency('libselinux',
1172 version : '>= 2.1.9',
1173 required : want_selinux == 'true')
1174 have = libselinux.found()
1179 conf.set10('HAVE_SELINUX', have)
1181 want_apparmor = get_option('apparmor')
1182 if want_apparmor != 'false' and not skip_deps
1183 libapparmor = dependency('libapparmor',
1184 version : '>= 2.13',
1185 required : want_apparmor == 'true')
1186 have = libapparmor.found()
1191 conf.set10('HAVE_APPARMOR', have)
1193 have = get_option('smack') and get_option('smack-run-label') != ''
1194 conf.set10('HAVE_SMACK_RUN_LABEL', have)
1196 conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
1199 have = get_option('smack') and get_option('smack-default-process-label') != ''
1201 conf.set_quoted('SMACK_DEFAULT_PROCESS_LABEL', get_option('smack-default-process-label'))
1204 want_polkit = get_option('polkit')
1205 install_polkit = false
1206 install_polkit_pkla = false
1207 if want_polkit != 'false' and not skip_deps
1208 install_polkit = true
1210 libpolkit = dependency('polkit-gobject-1',
1212 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
1213 message('Old polkit detected, will install pkla files')
1214 install_polkit_pkla = true
1217 conf.set10('ENABLE_POLKIT', install_polkit)
1219 want_acl = get_option('acl')
1220 if want_acl != 'false' and not skip_deps
1221 libacl = dependency('libacl', required : want_acl == 'true')
1222 have = libacl.found()
1227 conf.set10('HAVE_ACL', have)
1229 want_audit = get_option('audit')
1230 if want_audit != 'false' and not skip_deps
1231 libaudit = dependency('audit', required : want_audit == 'true')
1232 have = libaudit.found()
1237 conf.set10('HAVE_AUDIT', have)
1239 want_blkid = get_option('blkid')
1240 if want_blkid != 'false' and not skip_deps
1241 libblkid = dependency('blkid', required : want_blkid == 'true')
1242 have = libblkid.found()
1244 conf.set10('HAVE_BLKID_PROBE_SET_HINT',
1245 have and cc.has_function('blkid_probe_set_hint', dependencies : libblkid))
1250 conf.set10('HAVE_BLKID', have)
1252 want_kmod = get_option('kmod')
1253 if want_kmod != 'false' and not skip_deps
1254 libkmod = dependency('libkmod',
1256 required : want_kmod == 'true')
1257 have = libkmod.found()
1262 conf.set10('HAVE_KMOD', have)
1264 want_xenctrl = get_option('xenctrl')
1265 if want_xenctrl != 'false' and not skip_deps
1266 libxenctrl = dependency('xencontrol',
1268 required : want_xenctrl == 'true')
1269 have = libxenctrl.found()
1274 conf.set10('HAVE_XENCTRL', have)
1276 want_pam = get_option('pam')
1277 if want_pam != 'false' and not skip_deps
1278 libpam = dependency('pam', required : false)
1279 if not libpam.found()
1280 # Debian older than bookworm and Ubuntu older than 22.10 do not provide the .pc file.
1281 libpam = cc.find_library('pam', required : want_pam == 'true')
1283 libpam_misc = dependency('pam_misc', required : false)
1284 if not libpam_misc.found()
1285 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1287 have = libpam.found() and libpam_misc.found()
1293 conf.set10('HAVE_PAM', have)
1295 want_microhttpd = get_option('microhttpd')
1296 if want_microhttpd != 'false' and not skip_deps
1297 libmicrohttpd = dependency('libmicrohttpd',
1298 version : '>= 0.9.33',
1299 required : want_microhttpd == 'true')
1300 have = libmicrohttpd.found()
1305 conf.set10('HAVE_MICROHTTPD', have)
1307 want_libcryptsetup = get_option('libcryptsetup')
1308 want_libcryptsetup_plugins = get_option('libcryptsetup-plugins')
1310 if want_libcryptsetup_plugins == 'true' and want_libcryptsetup == 'false'
1311 error('libcryptsetup-plugins can not be requested without libcryptsetup')
1314 if want_libcryptsetup != 'false' and not skip_deps
1315 libcryptsetup = dependency('libcryptsetup',
1316 version : want_libcryptsetup_plugins == 'true' ? '>= 2.4.0' : '>= 2.0.1',
1317 required : want_libcryptsetup == 'true' or want_libcryptsetup_plugins == 'true')
1318 have = libcryptsetup.found()
1320 foreach ident : ['crypt_set_metadata_size',
1321 'crypt_activate_by_signed_key',
1323 'crypt_reencrypt_init_by_passphrase',
1325 'crypt_set_data_offset']
1326 have_ident = have and cc.has_function(
1328 prefix : '#include <libcryptsetup.h>',
1329 dependencies : libcryptsetup)
1330 conf.set10('HAVE_' + ident.to_upper(), have_ident)
1336 conf.set10('HAVE_LIBCRYPTSETUP', have)
1338 if want_libcryptsetup_plugins != 'false' and not skip_deps
1339 have = (cc.has_function(
1340 'crypt_activate_by_token_pin',
1341 prefix : '#include <libcryptsetup.h>',
1342 dependencies : libcryptsetup) and
1344 'crypt_token_external_path',
1345 prefix : '#include <libcryptsetup.h>',
1346 dependencies : libcryptsetup))
1350 conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have)
1352 want_libcurl = get_option('libcurl')
1353 if want_libcurl != 'false' and not skip_deps
1354 libcurl = dependency('libcurl',
1355 version : '>= 7.32.0',
1356 required : want_libcurl == 'true')
1357 have = libcurl.found()
1362 conf.set10('HAVE_LIBCURL', have)
1363 conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
1365 want_libidn = get_option('libidn')
1366 want_libidn2 = get_option('libidn2')
1367 if want_libidn == 'true' and want_libidn2 == 'true'
1368 error('libidn and libidn2 cannot be requested simultaneously')
1371 if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps
1372 libidn = dependency('libidn2',
1373 required : want_libidn2 == 'true')
1374 have = libidn.found()
1379 conf.set10('HAVE_LIBIDN2', have)
1380 if not have and want_libidn != 'false' and not skip_deps
1381 # libidn is used for both libidn and libidn2 objects
1382 libidn = dependency('libidn',
1383 required : want_libidn == 'true')
1384 have = libidn.found()
1388 conf.set10('HAVE_LIBIDN', have)
1390 want_libiptc = get_option('libiptc')
1391 if want_libiptc != 'false' and not skip_deps
1392 libiptc = dependency('libiptc',
1393 required : want_libiptc == 'true')
1394 have = libiptc.found()
1399 conf.set10('HAVE_LIBIPTC', have)
1401 want_qrencode = get_option('qrencode')
1402 if want_qrencode != 'false' and not skip_deps
1403 libqrencode = dependency('libqrencode',
1405 required : want_qrencode == 'true')
1406 have = libqrencode.found()
1411 conf.set10('HAVE_QRENCODE', have)
1413 want_gcrypt = get_option('gcrypt')
1414 if want_gcrypt != 'false' and not skip_deps
1415 libgcrypt = dependency('libgcrypt', required : want_gcrypt == 'true')
1416 libgpg_error = dependency('gpg-error', required : false)
1417 if not libgpg_error.found()
1418 # CentOS 8 does not provide the .pc file.
1419 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1421 have = libgcrypt.found() and libgpg_error.found()
1426 # link to neither of the libs if one is not found
1430 conf.set10('HAVE_GCRYPT', have)
1432 want_gnutls = get_option('gnutls')
1433 if want_gnutls != 'false' and not skip_deps
1434 libgnutls = dependency('gnutls',
1435 version : '>= 3.1.4',
1436 required : want_gnutls == 'true')
1437 have = libgnutls.found()
1442 conf.set10('HAVE_GNUTLS', have)
1444 want_openssl = get_option('openssl')
1445 if want_openssl != 'false' and not skip_deps
1446 libopenssl = dependency('openssl',
1447 version : '>= 1.1.0',
1448 required : want_openssl == 'true')
1449 have = libopenssl.found()
1454 conf.set10('HAVE_OPENSSL', have)
1456 want_p11kit = get_option('p11kit')
1457 if want_p11kit != 'false' and not skip_deps
1458 libp11kit = dependency('p11-kit-1',
1459 version : '>= 0.23.3',
1460 required : want_p11kit == 'true')
1461 have = libp11kit.found()
1462 libp11kit_cflags = libp11kit.partial_dependency(includes: true, compile_args: true)
1465 libp11kit_cflags = []
1468 conf.set10('HAVE_P11KIT', have)
1470 want_libfido2 = get_option('libfido2')
1471 if want_libfido2 != 'false' and not skip_deps
1472 if conf.get('HAVE_OPENSSL') == 1
1473 libfido2 = dependency('libfido2',
1474 required : want_libfido2 == 'true')
1475 have = libfido2.found()
1476 elif want_libfido2 == 'true'
1477 error('libfido2=true requires openssl')
1486 conf.set10('HAVE_LIBFIDO2', have)
1488 want_tpm2 = get_option('tpm2')
1489 if want_tpm2 != 'false' and not skip_deps
1490 tpm2 = dependency('tss2-esys tss2-rc tss2-mu tss2-tcti-device',
1491 required : want_tpm2 == 'true')
1493 have_esys3 = tpm2.version().version_compare('>= 3.0.0')
1499 conf.set10('HAVE_TPM2', have)
1500 conf.set10('HAVE_TSS2_ESYS3', have_esys3)
1502 want_elfutils = get_option('elfutils')
1503 if want_elfutils != 'false' and not skip_deps
1504 libdw = dependency('libdw',
1505 required : want_elfutils == 'true')
1506 have = libdw.found()
1508 # New in elfutils 0.177
1509 conf.set10('HAVE_DWELF_ELF_E_MACHINE_STRING',
1510 have and cc.has_function('dwelf_elf_e_machine_string', dependencies : libdw))
1515 conf.set10('HAVE_ELFUTILS', have)
1517 want_zlib = get_option('zlib')
1518 if want_zlib != 'false' and not skip_deps
1519 libz = dependency('zlib',
1520 required : want_zlib == 'true')
1526 conf.set10('HAVE_ZLIB', have)
1528 want_bzip2 = get_option('bzip2')
1529 if want_bzip2 != 'false' and not skip_deps
1530 libbzip2 = dependency('bzip2', required : false)
1531 if not libbzip2.found()
1532 # Debian and Ubuntu do not provide the .pc file.
1533 libbzip2 = cc.find_library('bz2', required : want_bzip2 == 'true')
1535 have = libbzip2.found()
1540 conf.set10('HAVE_BZIP2', have)
1542 want_xz = get_option('xz')
1543 if want_xz != 'false' and not skip_deps
1544 libxz = dependency('liblzma',
1545 required : want_xz == 'true')
1546 have_xz = libxz.found()
1551 conf.set10('HAVE_XZ', have_xz)
1553 want_lz4 = get_option('lz4')
1554 if want_lz4 != 'false' and not skip_deps
1555 liblz4 = dependency('liblz4',
1556 version : '>= 1.3.0',
1557 required : want_lz4 == 'true')
1558 have_lz4 = liblz4.found()
1563 conf.set10('HAVE_LZ4', have_lz4)
1565 want_zstd = get_option('zstd')
1566 if want_zstd != 'false' and not skip_deps
1567 libzstd = dependency('libzstd',
1568 required : want_zstd == 'true',
1569 version : '>= 1.4.0')
1570 have_zstd = libzstd.found()
1575 conf.set10('HAVE_ZSTD', have_zstd)
1577 conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
1579 compression = get_option('default-compression')
1580 if compression == 'auto'
1582 compression = 'zstd'
1588 compression = 'none'
1590 elif compression == 'zstd' and not have_zstd
1591 error('default-compression=zstd requires zstd')
1592 elif compression == 'lz4' and not have_lz4
1593 error('default-compression=lz4 requires lz4')
1594 elif compression == 'xz' and not have_xz
1595 error('default-compression=xz requires xz')
1597 conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper()))
1599 want_xkbcommon = get_option('xkbcommon')
1600 if want_xkbcommon != 'false' and not skip_deps
1601 libxkbcommon = dependency('xkbcommon',
1602 version : '>= 0.3.0',
1603 required : want_xkbcommon == 'true')
1604 have = libxkbcommon.found()
1609 conf.set10('HAVE_XKBCOMMON', have)
1611 want_pcre2 = get_option('pcre2')
1612 if want_pcre2 != 'false' and not skip_deps
1613 libpcre2 = dependency('libpcre2-8',
1614 required : want_pcre2 == 'true')
1615 have = libpcre2.found()
1620 conf.set10('HAVE_PCRE2', have)
1622 want_glib = get_option('glib')
1623 if want_glib != 'false' and not skip_deps
1624 libglib = dependency('glib-2.0',
1625 version : '>= 2.22.0',
1626 required : want_glib == 'true')
1627 libgobject = dependency('gobject-2.0',
1628 version : '>= 2.22.0',
1629 required : want_glib == 'true')
1630 libgio = dependency('gio-2.0',
1631 required : want_glib == 'true')
1632 have = libglib.found() and libgobject.found() and libgio.found()
1639 conf.set10('HAVE_GLIB', have)
1641 want_dbus = get_option('dbus')
1642 if want_dbus != 'false' and not skip_deps
1643 libdbus = dependency('dbus-1',
1644 version : '>= 1.3.2',
1645 required : want_dbus == 'true')
1646 have = libdbus.found()
1651 conf.set10('HAVE_DBUS', have)
1653 dbusdatadir = datadir / 'dbus-1'
1654 if conf.get('HAVE_DBUS') == 1
1655 dbusdatadir = libdbus.get_variable(pkgconfig: 'datadir', default_value: datadir) / 'dbus-1'
1658 dbuspolicydir = get_option('dbuspolicydir')
1659 if dbuspolicydir == ''
1660 dbuspolicydir = dbusdatadir / 'system.d'
1663 dbussessionservicedir = get_option('dbussessionservicedir')
1664 if dbussessionservicedir == ''
1665 dbussessionservicedir = dbusdatadir / 'services'
1666 if conf.get('HAVE_DBUS') == 1
1667 dbussessionservicedir = libdbus.get_variable(pkgconfig: 'session_bus_services_dir', default_value: dbussessionservicedir)
1671 dbussystemservicedir = get_option('dbussystemservicedir')
1672 if dbussystemservicedir == ''
1673 dbussystemservicedir = dbusdatadir / 'system-services'
1674 if conf.get('HAVE_DBUS') == 1
1675 dbussystemservicedir = libdbus.get_variable(pkgconfig: 'system_bus_services_dir', default_value: dbussystemservicedir)
1679 dbus_interfaces_dir = get_option('dbus-interfaces-dir')
1680 if dbus_interfaces_dir == '' or dbus_interfaces_dir == 'yes'
1681 if meson.is_cross_build() and dbus_interfaces_dir != 'yes'
1682 dbus_interfaces_dir = 'no'
1683 warning('Exporting D-Bus interface XML files is disabled during cross build. Pass path or "yes" to force enable.')
1685 dbus_interfaces_dir = dbusdatadir / 'interfaces'
1686 if conf.get('HAVE_DBUS') == 1
1687 dbus_interfaces_dir = libdbus.get_variable(pkgconfig: 'interfaces_dir', default_value: dbus_interfaces_dir)
1692 # We support one or the other. If gcrypt is available, we assume it's there to
1693 # be used, and use it in preference.
1694 opt = get_option('cryptolib')
1695 if opt == 'openssl' and conf.get('HAVE_OPENSSL') == 0
1696 error('openssl requested as the default cryptolib, but not available')
1698 conf.set10('PREFER_OPENSSL',
1699 opt == 'openssl' or (opt == 'auto' and conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_GCRYPT') == 0))
1700 conf.set10('HAVE_OPENSSL_OR_GCRYPT',
1701 conf.get('HAVE_OPENSSL') == 1 or conf.get('HAVE_GCRYPT') == 1)
1702 lib_openssl_or_gcrypt = conf.get('PREFER_OPENSSL') == 1 ? [libopenssl] : [libgcrypt, libgpg_error]
1704 dns_over_tls = get_option('dns-over-tls')
1705 if dns_over_tls != 'false'
1706 if dns_over_tls == 'gnutls' and conf.get('PREFER_OPENSSL') == 1
1707 error('Sorry, -Ddns-over-tls=gnutls is not supported when openssl is used as the cryptolib')
1710 if dns_over_tls == 'gnutls'
1711 have_openssl = false
1713 have_openssl = conf.get('HAVE_OPENSSL') == 1
1714 if dns_over_tls == 'openssl' and not have_openssl
1715 error('DNS-over-TLS support was requested with openssl, but dependencies are not available')
1718 if dns_over_tls == 'openssl' or have_openssl
1721 have_gnutls = conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0')
1722 if dns_over_tls != 'auto' and not have_gnutls
1723 str = dns_over_tls == 'gnutls' ? ' with gnutls' : ''
1724 error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
1727 have = have_gnutls or have_openssl
1731 have_openssl = false
1733 conf.set10('ENABLE_DNS_OVER_TLS', have)
1734 conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1735 conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
1737 default_dns_over_tls = get_option('default-dns-over-tls')
1739 default_dns_over_tls = 'no'
1741 if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
1742 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.')
1743 default_dns_over_tls = 'no'
1745 conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1746 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
1747 conf.set_quoted('DEFAULT_DNS_OVER_TLS_MODE_STR', default_dns_over_tls)
1749 default_mdns = get_option('default-mdns')
1750 conf.set('DEFAULT_MDNS_MODE',
1751 'RESOLVE_SUPPORT_' + default_mdns.to_upper())
1752 conf.set_quoted('DEFAULT_MDNS_MODE_STR', default_mdns)
1754 default_llmnr = get_option('default-llmnr')
1755 conf.set('DEFAULT_LLMNR_MODE',
1756 'RESOLVE_SUPPORT_' + default_llmnr.to_upper())
1757 conf.set_quoted('DEFAULT_LLMNR_MODE_STR', default_llmnr)
1759 want_repart = get_option('repart')
1760 if want_repart != 'false'
1761 have = conf.get('HAVE_LIBFDISK') == 1
1762 if want_repart == 'true' and not have
1763 error('repart support was requested, but dependencies are not available')
1768 conf.set10('ENABLE_REPART', have)
1770 default_dnssec = get_option('default-dnssec')
1772 default_dnssec = 'no'
1774 if default_dnssec != 'no' and conf.get('HAVE_OPENSSL_OR_GCRYPT') == 0
1775 message('default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.')
1776 default_dnssec = 'no'
1778 conf.set('DEFAULT_DNSSEC_MODE',
1779 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1780 conf.set_quoted('DEFAULT_DNSSEC_MODE_STR', default_dnssec)
1782 want_sysupdate = get_option('sysupdate')
1783 if want_sysupdate != 'false'
1784 have = (conf.get('HAVE_OPENSSL') == 1 and
1785 conf.get('HAVE_LIBFDISK') == 1)
1786 if want_sysupdate == 'true' and not have
1787 error('sysupdate support was requested, but dependencies are not available')
1792 conf.set10('ENABLE_SYSUPDATE', have)
1794 want_importd = get_option('importd')
1795 if want_importd != 'false'
1796 have = (conf.get('HAVE_LIBCURL') == 1 and
1797 conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and
1798 conf.get('HAVE_ZLIB') == 1 and
1799 conf.get('HAVE_XZ') == 1)
1800 if want_importd == 'true' and not have
1801 error('importd support was requested, but dependencies are not available')
1806 conf.set10('ENABLE_IMPORTD', have)
1808 want_homed = get_option('homed')
1809 if want_homed != 'false'
1810 have = (conf.get('HAVE_OPENSSL') == 1 and
1811 conf.get('HAVE_LIBFDISK') == 1 and
1812 conf.get('HAVE_LIBCRYPTSETUP') == 1)
1813 if want_homed == 'true' and not have
1814 error('homed support was requested, but dependencies are not available')
1819 conf.set10('ENABLE_HOMED', have)
1821 have = have and conf.get('HAVE_PAM') == 1
1822 conf.set10('ENABLE_PAM_HOME', have)
1824 want_remote = get_option('remote')
1825 if want_remote != 'false'
1826 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1827 conf.get('HAVE_LIBCURL') == 1]
1828 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1829 # it's possible to build one without the other. Complain only if
1830 # support was explicitly requested. The auxiliary files like sysusers
1831 # config should be installed when any of the programs are built.
1832 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1833 error('remote support was requested, but dependencies are not available')
1835 have = have_deps[0] or have_deps[1]
1839 conf.set10('ENABLE_REMOTE', have)
1841 foreach term : ['analyze',
1844 'compat-mutable-uid-boundaries',
1883 have = get_option(term)
1884 name = 'ENABLE_' + term.underscorify().to_upper()
1885 conf.set10(name, have)
1888 enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
1890 foreach tuple : [['nss-mymachines', 'machined'],
1891 ['nss-resolve', 'resolve']]
1892 want = get_option(tuple[0])
1894 have = get_option(tuple[1])
1895 if want == 'true' and not have
1896 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1901 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1902 conf.set10(name, have)
1906 foreach term : ['ENABLE_NSS_MYHOSTNAME',
1907 'ENABLE_NSS_MYMACHINES',
1908 'ENABLE_NSS_RESOLVE',
1909 'ENABLE_NSS_SYSTEMD']
1910 if conf.get(term) == 1
1914 conf.set10('ENABLE_NSS', enable_nss)
1916 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1918 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1920 ############################################################
1922 pymod = import('python')
1923 python = pymod.find_installation('python3', required : true, modules : ['jinja2'])
1924 python_39 = python.language_version().version_compare('>=3.9')
1926 ############################################################
1928 if conf.get('BPF_FRAMEWORK') == 1
1931 '-Wno-compare-distinct-pointer-types',
1932 '-fno-stack-protector',
1942 '-fno-stack-protector',
1951 # Generate defines that are appropriate to tell the compiler what architecture
1952 # we're compiling for. By default we just map meson's cpu_family to __<cpu_family>__.
1953 # This dictionary contains the exceptions where this doesn't work.
1955 # C.f. https://mesonbuild.com/Reference-tables.html#cpu-families
1956 # and src/basic/missing_syscall_def.h.
1957 cpu_arch_defines = {
1958 'ppc' : ['-D__powerpc__'],
1959 'ppc64' : ['-D__powerpc64__', '-D_CALL_ELF=2'],
1960 'riscv32' : ['-D__riscv', '-D__riscv_xlen=32'],
1961 'riscv64' : ['-D__riscv', '-D__riscv_xlen=64'],
1962 'x86' : ['-D__i386__'],
1964 # For arm, assume hardware fp is available.
1965 'arm' : ['-D__arm__', '-D__ARM_PCS_VFP'],
1968 bpf_arch_flags = cpu_arch_defines.get(host_machine.cpu_family(),
1969 ['-D__@0@__'.format(host_machine.cpu_family())])
1970 if bpf_compiler == 'gcc'
1971 bpf_arch_flags += ['-m' + host_machine.endian() + '-endian']
1974 libbpf_include_dir = libbpf.get_variable(pkgconfig : 'includedir')
1976 bpf_o_unstripped_cmd = []
1977 if bpf_compiler == 'clang'
1978 bpf_o_unstripped_cmd += [
1983 elif bpf_compiler == 'gcc'
1984 bpf_o_unstripped_cmd += [
1991 bpf_o_unstripped_cmd += ['-I.']
1993 if not meson.is_cross_build() and bpf_compiler == 'clang'
1994 target_triplet_cmd = run_command('gcc', '-dumpmachine', check: false)
1995 if target_triplet_cmd.returncode() == 0
1996 target_triplet = target_triplet_cmd.stdout().strip()
1997 bpf_o_unstripped_cmd += [
1999 '/usr/include/@0@'.format(target_triplet)
2004 bpf_o_unstripped_cmd += [
2020 elif bpf_compiler == 'clang'
2038 #####################################################################
2043 'loongarch32' : 'loongarch32',
2044 'loongarch64' : 'loongarch64',
2045 'riscv32' : 'riscv32',
2046 'riscv64' : 'riscv64',
2049 }.get(host_machine.cpu_family(), '')
2051 if get_option('bootloader') != 'false' and efi_arch != ''
2052 conf.set_quoted('EFI_MACHINE_TYPE_NAME', efi_arch)
2053 elif get_option('bootloader') == 'false' and efi_arch != ''
2054 # Ensure that if the option is explicitly set to false, then no EFI code is built, including tests
2056 elif get_option('bootloader') == 'true' and efi_arch == ''
2057 error('EFI not supported for this arch.')
2061 efi_cpu_family_alt = ''
2062 if efi_arch == 'x64' and cc.links('''
2064 int main(int argc, char *argv[]) {
2065 return __builtin_popcount(argc - CHAR_MAX);
2066 }''', args : ['-m32', '-march=i686'], name : '32bit build possible')
2067 efi_arch_alt = 'ia32'
2068 efi_cpu_family_alt = 'x86'
2071 have_pyelftools = pymod.find_installation('python3', required : false, modules : ['elftools']).found()
2072 if get_option('bootloader') == 'true' and not have_pyelftools
2073 error('EFI bootloader support requires pyelftools.')
2077 'ENABLE_BOOTLOADER',
2078 get_option('efi') and
2079 get_option('bootloader') in ['auto', 'true'] and
2084 if get_option('ukify') == 'auto'
2085 want_ukify = python_39 and conf.get('ENABLE_BOOTLOADER') == 1
2086 elif get_option('ukify') == 'true' and (not python_39 or conf.get('ENABLE_BOOTLOADER') != 1)
2087 error('ukify requires Python >= 3.9 and -Dbootloader=true')
2089 want_ukify = get_option('ukify') == 'true'
2091 conf.set10('ENABLE_UKIFY', want_ukify)
2093 ############################################################
2095 elf2efi_lds = project_source_root / 'tools/elf2efi.lds'
2096 elf2efi_py = find_program('tools/elf2efi.py')
2097 export_dbus_interfaces_py = find_program('tools/dbus_exporter.py')
2098 generate_gperfs = find_program('tools/generate-gperfs.py')
2099 make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
2100 make_directive_index_py = find_program('tools/make-directive-index.py')
2101 make_man_index_py = find_program('tools/make-man-index.py')
2102 meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
2103 update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
2104 update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
2105 update_hwdb_sh = find_program('tools/update-hwdb.sh')
2106 update_man_rules_py = find_program('tools/update-man-rules.py')
2107 update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
2108 xml_helper_py = find_program('tools/xml_helper.py')
2110 ############################################################
2112 version_tag = get_option('version-tag')
2113 if version_tag == ''
2114 # Check that we have either .git/ (a normal clone) or a .git file (a work-tree) and that we don't
2115 # get confused if a tarball is extracted in a higher-level git repository.
2116 if git.found() and fs.exists(project_source_root / '.git')
2117 # Apparently git describe has a bug where it always considers the work-tree dirty when
2118 # invoked with --git-dir (even though 'git status' is happy). Work around this issue by
2119 # cd-ing to the source directory.
2120 version_tag = run_command(
2122 'cd "$MESON_SOURCE_ROOT"; git describe --abbrev=7 --dirty=^ 2>/dev/null | sed "s/^v//; s/-rc/~rc/"',
2126 version_tag = meson.project_version()
2130 vcs_data = configuration_data()
2131 vcs_data.set('VCS_TAG', version_tag)
2132 version_h = configure_file(configuration : vcs_data,
2133 input : 'src/version/version.h.in',
2134 output : 'version.h')
2136 versiondep = declare_dependency(
2137 sources : version_h,
2138 include_directories : include_directories('.'),
2141 shared_lib_tag = get_option('shared-lib-tag')
2142 if shared_lib_tag == ''
2143 shared_lib_tag = meson.project_version()
2146 ############################################################
2148 if get_option('b_coverage')
2149 userspace_c_args += ['-include', 'src/basic/coverage.h']
2152 ############################################################
2154 config_h = configure_file(
2155 output : 'config.h',
2156 configuration : conf)
2158 userspace_c_args += ['-include', 'config.h']
2160 jinja2_cmdline = [meson_render_jinja2, config_h, version_h]
2162 userspace = declare_dependency(
2163 compile_args : userspace_c_args,
2164 link_args : userspace_c_ld_args,
2165 dependencies : versiondep,
2168 man_page_depends = []
2170 ############################################################
2178 # binaries that have --help and are intended for use by humans,
2179 # usually, but not always, installed in /bin.
2180 public_programs = []
2182 # D-Bus introspection XML export
2185 # A list of boot stubs. Required for testing of ukify.
2188 basic_includes = include_directories(
2194 libsystemd_includes = [basic_includes, include_directories(
2195 'src/libsystemd/sd-bus',
2196 'src/libsystemd/sd-device',
2197 'src/libsystemd/sd-event',
2198 'src/libsystemd/sd-hwdb',
2199 'src/libsystemd/sd-id128',
2200 'src/libsystemd/sd-journal',
2201 'src/libsystemd/sd-netlink',
2202 'src/libsystemd/sd-network',
2203 'src/libsystemd/sd-resolve')]
2205 includes = [libsystemd_includes, include_directories('src/shared')]
2209 subdir('src/fundamental')
2211 subdir('src/libsystemd')
2212 subdir('src/shared')
2214 subdir('src/libudev')
2215 subdir('src/cryptsetup/cryptsetup-tokens')
2217 libsystemd = shared_library(
2219 version : libsystemd_version,
2220 include_directories : libsystemd_includes,
2221 link_args : ['-shared',
2222 '-Wl,--version-script=' + libsystemd_sym_path],
2223 link_with : [libbasic,
2226 link_whole : [libsystemd_static],
2227 dependencies : [librt,
2230 link_depends : libsystemd_sym,
2232 install_tag: 'libsystemd',
2233 install_dir : libdir)
2235 alias_target('libsystemd', libsystemd)
2237 install_libsystemd_static = static_library(
2241 basic_gcrypt_sources,
2242 basic_compress_sources,
2243 fundamental_sources,
2244 include_directories : libsystemd_includes,
2245 build_by_default : static_libsystemd != 'false',
2246 install : static_libsystemd != 'false',
2247 install_tag: 'libsystemd',
2248 install_dir : libdir,
2249 pic : static_libsystemd_pic,
2250 dependencies : [libblkid,
2262 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
2264 libudev = shared_library(
2266 version : libudev_version,
2267 include_directories : includes,
2268 link_args : ['-shared',
2269 '-Wl,--version-script=' + libudev_sym_path],
2270 link_with : [libsystemd_static, libshared_static],
2271 link_whole : libudev_basic,
2272 dependencies : [threads,
2274 link_depends : libudev_sym,
2276 install_tag: 'libudev',
2277 install_dir : libdir)
2279 alias_target('libudev', libudev)
2281 install_libudev_static = static_library(
2284 fundamental_sources,
2288 include_directories : includes,
2289 build_by_default : static_libudev != 'false',
2290 install : static_libudev != 'false',
2291 install_tag: 'libudev',
2292 install_dir : libdir,
2293 link_depends : libudev_sym,
2294 dependencies : [libmount,
2297 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
2298 pic : static_libudev_pic)
2300 if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
2301 if conf.get('HAVE_TPM2') == 1
2303 'cryptsetup-token-systemd-tpm2',
2304 cryptsetup_token_systemd_tpm2_sources,
2305 include_directories : includes,
2306 link_args : ['-shared',
2307 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2308 link_with : [lib_cryptsetup_token_common,
2310 dependencies : [libcryptsetup,
2313 link_depends : cryptsetup_token_sym,
2314 install_rpath : pkglibdir,
2316 install_dir : libcryptsetup_plugins_dir)
2319 if conf.get('HAVE_LIBFIDO2') == 1
2321 'cryptsetup-token-systemd-fido2',
2322 cryptsetup_token_systemd_fido2_sources,
2323 include_directories : includes,
2324 link_args : ['-shared',
2325 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2326 link_with : [lib_cryptsetup_token_common,
2328 dependencies : [libcryptsetup,
2331 link_depends : cryptsetup_token_sym,
2332 install_rpath : pkglibdir,
2334 install_dir : libcryptsetup_plugins_dir)
2337 if conf.get('HAVE_P11KIT') == 1
2339 'cryptsetup-token-systemd-pkcs11',
2340 cryptsetup_token_systemd_pkcs11_sources,
2341 include_directories : includes,
2342 link_args : ['-shared',
2343 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2344 link_with : [lib_cryptsetup_token_common,
2346 dependencies : [libcryptsetup,
2349 link_depends : cryptsetup_token_sym,
2350 install_rpath : pkglibdir,
2352 install_dir : libcryptsetup_plugins_dir)
2356 ############################################################
2358 # systemd-analyze requires 'libcore'
2360 # systemd-journal-remote requires 'libjournal_core'
2361 subdir('src/journal')
2362 # systemd-networkd requires 'libsystemd_network'
2363 subdir('src/libsystemd-network')
2365 subdir('src/analyze')
2367 subdir('src/boot/efi')
2368 subdir('src/busctl')
2369 subdir('src/coredump')
2370 subdir('src/cryptenroll')
2371 subdir('src/cryptsetup')
2373 subdir('src/hostname')
2374 subdir('src/import')
2375 subdir('src/journal-remote')
2376 subdir('src/kernel-install')
2377 subdir('src/locale')
2379 subdir('src/machine')
2380 subdir('src/network')
2381 subdir('src/nspawn')
2383 subdir('src/partition')
2384 subdir('src/portable')
2385 subdir('src/pstore')
2386 subdir('src/resolve')
2388 subdir('src/shutdown')
2389 subdir('src/sysext')
2390 subdir('src/systemctl')
2391 subdir('src/sysupdate')
2392 subdir('src/timedate')
2393 subdir('src/timesync')
2394 subdir('src/tmpfiles')
2395 subdir('src/userdb')
2396 subdir('src/xdg-autostart-generator')
2398 subdir('src/systemd')
2404 subdir('src/ukify/test') # needs to be last for test_env variable
2406 alias_target('devel', libsystemd_pc, libudev_pc, systemd_pc, udev_pc)
2408 ############################################################
2410 # only static linking apart from libdl, to make sure that the
2411 # module is linked to all libraries that it uses.
2412 test_dlopen = executable(
2415 include_directories : includes,
2416 link_with : [libbasic],
2417 dependencies : [libdl,
2419 build_by_default : want_tests != 'false')
2421 foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
2422 ['systemd', 'ENABLE_NSS_SYSTEMD', ['nss-systemd.h', 'userdb-glue.c', 'userdb-glue.h']],
2423 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
2424 ['resolve', 'ENABLE_NSS_RESOLVE', [], resolve_includes]]
2426 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
2430 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
2431 version_script_arg = project_source_root / sym
2433 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
2434 if tuple.length() > 2
2435 foreach s : tuple[2]
2436 sources += ['src/nss-@0@/@1@'.format(module, s)]
2440 incs = tuple.length() > 3 ? tuple[3] : includes
2442 nss = shared_library(
2446 include_directories : incs,
2447 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
2448 link_args : ['-Wl,-z,nodelete',
2450 '-Wl,--version-script=' + version_script_arg],
2451 link_with : [libsystemd_static,
2454 dependencies : [librt,
2459 install_tag : 'nss',
2460 install_dir : libdir)
2462 # We cannot use shared_module because it does not support version suffix.
2463 # Unfortunately shared_library insists on creating the symlink…
2464 meson.add_install_script('sh', '-c',
2465 'rm $DESTDIR@0@/libnss_@1@.so'
2466 .format(libdir, module),
2470 if want_tests != 'false'
2471 test('dlopen-nss_' + module,
2473 # path to dlopen must include a slash
2474 args : nss.full_path(),
2480 ############################################################
2485 include_directories : includes,
2486 link_with : [libcore,
2488 dependencies : [libseccomp,
2490 install_rpath : pkglibdir,
2492 install_dir : libexecdir)
2493 dbus_programs += exe
2494 public_programs += exe
2496 meson.add_install_script(meson_make_symlink,
2497 libexecdir / 'systemd',
2502 systemd_analyze_sources,
2503 include_directories : core_includes,
2504 link_with : [libcore,
2506 dependencies : [libseccomp,
2508 install_rpath : pkglibdir,
2509 install : conf.get('ENABLE_ANALYZE') == 1)
2510 if conf.get('ENABLE_ANALYZE') == 1
2511 public_programs += exe
2514 if want_tests != 'false'
2515 test('test-compare-versions',
2516 test_compare_versions_sh,
2517 args : exe.full_path())
2522 systemd_journald_sources,
2523 include_directories : includes,
2524 link_with : [libjournal_core,
2526 dependencies : [liblz4,
2532 install_rpath : pkglibdir,
2534 install_dir : libexecdir)
2536 public_programs += executable(
2538 systemd_cat_sources,
2539 include_directories : includes,
2540 link_with : [libjournal_core,
2542 dependencies : [threads,
2544 install_rpath : pkglibdir,
2547 if get_option('link-journalctl-shared')
2548 journalctl_link_with = [libshared]
2550 journalctl_link_with = [libsystemd_static,
2555 public_programs += executable(
2558 include_directories : includes,
2559 link_with : [journalctl_link_with],
2560 dependencies : [libdl,
2566 install_rpath : pkglibdir,
2570 'systemd-getty-generator',
2571 'src/getty-generator/getty-generator.c',
2572 include_directories : includes,
2573 link_with : [libshared],
2574 dependencies : userspace,
2575 install_rpath : pkglibdir,
2577 install_dir : systemgeneratordir)
2580 'systemd-debug-generator',
2581 'src/debug-generator/debug-generator.c',
2582 include_directories : includes,
2583 link_with : [libshared],
2584 dependencies : userspace,
2585 install_rpath : pkglibdir,
2587 install_dir : systemgeneratordir)
2590 'systemd-run-generator',
2591 'src/run-generator/run-generator.c',
2592 include_directories : includes,
2593 link_with : [libshared],
2594 dependencies : userspace,
2595 install_rpath : pkglibdir,
2597 install_dir : systemgeneratordir)
2600 'systemd-fstab-generator',
2601 'src/fstab-generator/fstab-generator.c',
2602 include_directories : includes,
2603 link_with : [libshared],
2604 dependencies : userspace,
2605 install_rpath : pkglibdir,
2607 install_dir : systemgeneratordir)
2609 meson.add_install_script(meson_make_symlink,
2610 systemgeneratordir / 'systemd-fstab-generator',
2611 libexecdir / 'systemd-sysroot-fstab-check')
2613 if want_tests != 'false'
2614 test('test-fstab-generator',
2615 test_fstab_generator_sh,
2616 # https://github.com/mesonbuild/meson/issues/2681
2617 args : exe.full_path(),
2622 if conf.get('ENABLE_ENVIRONMENT_D') == 1
2624 '30-systemd-environment-d-generator',
2625 'src/environment-d-generator/environment-d-generator.c',
2626 include_directories : includes,
2627 link_with : [libshared],
2628 dependencies : userspace,
2629 install_rpath : pkglibdir,
2631 install_dir : userenvgeneratordir)
2633 meson.add_install_script(meson_make_symlink,
2634 sysconfdir / 'environment',
2635 environmentdir / '99-environment.conf')
2638 if conf.get('ENABLE_HIBERNATE') == 1
2640 'systemd-hibernate-resume-generator',
2641 'src/hibernate-resume/hibernate-resume-generator.c',
2642 include_directories : includes,
2643 link_with : [libshared],
2644 dependencies : userspace,
2645 install_rpath : pkglibdir,
2647 install_dir : systemgeneratordir)
2650 'systemd-hibernate-resume',
2651 'src/hibernate-resume/hibernate-resume.c',
2652 include_directories : includes,
2653 link_with : [libshared],
2654 dependencies : userspace,
2655 install_rpath : pkglibdir,
2657 install_dir : libexecdir)
2660 if conf.get('HAVE_BLKID') == 1
2662 'systemd-gpt-auto-generator',
2663 'src/gpt-auto-generator/gpt-auto-generator.c',
2664 include_directories : includes,
2665 link_with : [libshared],
2666 dependencies : [libblkid,
2668 install_rpath : pkglibdir,
2670 install_dir : systemgeneratordir)
2672 public_programs += executable(
2674 'src/dissect/dissect.c',
2675 include_directories : includes,
2676 link_with : [libshared],
2677 dependencies : [userspace],
2678 install_rpath : pkglibdir,
2681 meson.add_install_script(meson_make_symlink,
2682 bindir / 'systemd-dissect',
2683 sbindir / 'mount.ddi')
2686 if conf.get('ENABLE_RESOLVE') == 1
2687 dbus_programs += executable(
2689 systemd_resolved_sources,
2690 include_directories : resolve_includes,
2691 link_with : [libshared,
2693 libsystemd_resolve_core],
2694 dependencies : [systemd_resolved_dependencies,
2696 install_rpath : pkglibdir,
2698 install_dir : libexecdir)
2700 public_programs += executable(
2703 include_directories : includes,
2704 link_with : [libshared,
2706 libsystemd_resolve_core],
2707 dependencies : [lib_openssl_or_gcrypt,
2712 install_rpath : pkglibdir,
2715 meson.add_install_script(meson_make_symlink,
2716 bindir / 'resolvectl',
2717 sbindir / 'resolvconf')
2719 meson.add_install_script(meson_make_symlink,
2720 bindir / 'resolvectl',
2721 bindir / 'systemd-resolve')
2724 if conf.get('ENABLE_LOGIND') == 1
2725 dbus_programs += executable(
2727 systemd_logind_sources,
2728 include_directories : includes,
2729 link_with : [liblogind_core,
2731 dependencies : [libacl,
2734 install_rpath : pkglibdir,
2736 install_dir : libexecdir)
2738 public_programs += executable(
2741 include_directories : includes,
2742 link_with : [libshared],
2743 dependencies : [liblz4,
2748 install_rpath : pkglibdir,
2751 public_programs += executable(
2753 'src/login/inhibit.c',
2754 include_directories : includes,
2755 link_with : [libshared],
2756 dependencies : [userspace],
2757 install_rpath : pkglibdir,
2760 if conf.get('HAVE_PAM') == 1
2761 version_script_arg = project_source_root / pam_systemd_sym
2762 pam_systemd = shared_library(
2766 include_directories : includes,
2767 link_args : ['-shared',
2768 '-Wl,--version-script=' + version_script_arg],
2769 link_with : [libsystemd_static,
2771 dependencies : [libpam_misc,
2775 link_depends : pam_systemd_sym,
2777 install_tag : 'pam',
2778 install_dir : pamlibdir)
2780 if want_tests != 'false'
2781 test('dlopen-pam_systemd',
2783 # path to dlopen must include a slash
2784 args : pam_systemd.full_path(),
2785 depends : pam_systemd)
2790 'systemd-user-runtime-dir',
2791 user_runtime_dir_sources,
2792 include_directories : includes,
2793 link_with : [libshared],
2794 dependencies : userspace,
2795 install_rpath : pkglibdir,
2797 install_dir : libexecdir)
2800 if conf.get('HAVE_PAM') == 1
2802 'systemd-user-sessions',
2803 'src/user-sessions/user-sessions.c',
2804 include_directories : includes,
2805 link_with : [libshared],
2806 dependencies : userspace,
2807 install_rpath : pkglibdir,
2809 install_dir : libexecdir)
2812 if conf.get('HAVE_BLKID') == 1 and conf.get('ENABLE_BOOTLOADER') == 1
2813 if get_option('link-boot-shared')
2814 boot_link_with = [libshared]
2816 boot_link_with = [libsystemd_static, libshared_static]
2822 include_directories : includes,
2823 link_with : [boot_link_with],
2824 dependencies : [libblkid,
2826 install_rpath : pkglibdir,
2828 public_programs += exe
2830 if want_tests != 'false'
2831 test('test-bootctl-json',
2832 test_bootctl_json_sh,
2833 args : exe.full_path(),
2837 public_programs += executable(
2838 'systemd-bless-boot',
2839 'src/boot/bless-boot.c',
2840 include_directories : includes,
2841 link_with : [boot_link_with],
2842 dependencies : [libblkid,
2844 install_rpath : pkglibdir,
2846 install_dir : libexecdir)
2849 'systemd-bless-boot-generator',
2850 'src/boot/bless-boot-generator.c',
2851 include_directories : includes,
2852 link_with : [boot_link_with],
2853 dependencies : userspace,
2854 install_rpath : pkglibdir,
2856 install_dir : systemgeneratordir)
2858 if conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_TPM2') == 1
2861 'src/boot/measure.c',
2862 include_directories : includes,
2863 link_with : [libshared],
2864 dependencies : [libopenssl,
2866 install_rpath : pkglibdir,
2868 install_dir : libexecdir)
2871 'src/boot/pcrphase.c',
2872 include_directories : includes,
2873 link_with : [libshared],
2874 dependencies : [libblkid,
2878 install_rpath : pkglibdir,
2880 install_dir : libexecdir)
2885 'systemd-boot-check-no-failures',
2886 'src/boot/boot-check-no-failures.c',
2887 include_directories : includes,
2888 link_with : [libshared],
2889 dependencies : [libblkid,
2891 install_rpath : pkglibdir,
2893 install_dir : libexecdir)
2895 public_programs += executable(
2896 'systemd-socket-activate',
2897 'src/socket-activate/socket-activate.c',
2898 include_directories : includes,
2899 link_with : [libshared],
2900 dependencies : [threads,
2902 install_rpath : pkglibdir,
2905 systemctl = executable(
2908 include_directories : includes,
2909 link_with : systemctl_link_with,
2910 dependencies : [libcap,
2917 install_rpath : pkglibdir,
2919 public_programs += systemctl
2921 if conf.get('ENABLE_PORTABLED') == 1
2922 if get_option('link-portabled-shared')
2923 portabled_link_with = [libshared]
2925 portabled_link_with = [libsystemd_static,
2929 dbus_programs += executable(
2930 'systemd-portabled',
2931 systemd_portabled_sources,
2932 include_directories : includes,
2933 link_with : [portabled_link_with],
2934 dependencies : [libselinux,
2937 install_rpath : pkglibdir,
2939 install_dir : libexecdir)
2941 public_programs += executable(
2943 'src/portable/portablectl.c',
2944 include_directories : includes,
2945 link_with : [portabled_link_with],
2946 dependencies : [threads,
2948 install_rpath : pkglibdir,
2952 if conf.get('ENABLE_SYSEXT') == 1
2953 public_programs += executable(
2955 systemd_sysext_sources,
2956 include_directories : includes,
2957 link_with : [libshared],
2958 dependencies : [userspace],
2959 install_rpath : pkglibdir,
2963 if conf.get('ENABLE_USERDB') == 1
2966 systemd_userwork_sources,
2967 include_directories : includes,
2968 link_with : [libshared],
2969 dependencies : [threads,
2971 install_rpath : pkglibdir,
2973 install_dir : libexecdir)
2977 systemd_userdbd_sources,
2978 include_directories : includes,
2979 link_with : [libshared],
2980 dependencies : [threads,
2982 install_rpath : pkglibdir,
2984 install_dir : libexecdir)
2986 public_programs += executable(
2989 include_directories : includes,
2990 link_with : [libshared],
2991 dependencies : [threads,
2993 install_rpath : pkglibdir,
2997 if conf.get('ENABLE_HOMED') == 1
3000 systemd_homework_sources,
3001 include_directories : includes,
3002 link_with : [libshared,
3004 dependencies : [libblkid,
3011 install_rpath : pkglibdir,
3013 install_dir : libexecdir)
3015 dbus_programs += executable(
3017 systemd_homed_sources,
3018 include_directories : home_includes,
3019 link_with : [libshared],
3020 dependencies : [libcrypt,
3025 install_rpath : pkglibdir,
3027 install_dir : libexecdir)
3029 public_programs += executable(
3032 include_directories : includes,
3033 link_with : [libshared],
3034 dependencies : [libcrypt,
3040 install_rpath : pkglibdir,
3043 if conf.get('HAVE_PAM') == 1
3044 version_script_arg = project_source_root / pam_systemd_home_sym
3045 pam_systemd_home = shared_library(
3049 include_directories : includes,
3050 link_args : ['-shared',
3051 '-Wl,--version-script=' + version_script_arg],
3052 link_with : [libsystemd_static,
3054 dependencies : [libcrypt,
3059 link_depends : pam_systemd_home_sym,
3061 install_tag : 'pam',
3062 install_dir : pamlibdir)
3064 if want_tests != 'false'
3065 test('dlopen-pam_systemd_home',
3067 # path to dlopen must include a slash
3068 args : pam_systemd_home.full_path(),
3069 depends : pam_systemd_home)
3074 foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
3075 (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
3076 meson.add_install_script(meson_make_symlink,
3077 bindir / 'systemctl',
3081 meson.add_install_script(meson_make_symlink,
3083 libexecdir / 'systemd-udevd')
3085 if conf.get('ENABLE_BACKLIGHT') == 1
3087 'systemd-backlight',
3088 'src/backlight/backlight.c',
3089 include_directories : includes,
3090 link_with : [libshared],
3091 dependencies : userspace,
3092 install_rpath : pkglibdir,
3094 install_dir : libexecdir)
3097 if conf.get('ENABLE_RFKILL') == 1
3100 'src/rfkill/rfkill.c',
3101 include_directories : includes,
3102 link_with : [libshared],
3103 dependencies : userspace,
3104 install_rpath : pkglibdir,
3106 install_dir : libexecdir)
3110 'systemd-system-update-generator',
3111 'src/system-update-generator/system-update-generator.c',
3112 include_directories : includes,
3113 link_with : [libshared],
3114 dependencies : userspace,
3115 install_rpath : pkglibdir,
3117 install_dir : systemgeneratordir)
3119 if conf.get('HAVE_LIBCRYPTSETUP') == 1
3121 'systemd-cryptsetup',
3122 systemd_cryptsetup_sources,
3123 include_directories : includes,
3124 link_with : [libshared],
3125 dependencies : [libcryptsetup,
3129 install_rpath : pkglibdir,
3131 install_dir : libexecdir)
3134 'systemd-cryptsetup-generator',
3135 'src/cryptsetup/cryptsetup-generator.c',
3136 include_directories : includes,
3137 link_with : [libshared],
3138 dependencies : userspace,
3139 install_rpath : pkglibdir,
3141 install_dir : systemgeneratordir)
3144 'systemd-veritysetup',
3145 'src/veritysetup/veritysetup.c',
3146 include_directories : includes,
3147 link_with : [libshared],
3148 dependencies : [libcryptsetup,
3150 install_rpath : pkglibdir,
3152 install_dir : libexecdir)
3155 'systemd-veritysetup-generator',
3156 'src/veritysetup/veritysetup-generator.c',
3157 include_directories : includes,
3158 link_with : [libshared],
3159 dependencies : [userspace],
3160 install_rpath : pkglibdir,
3162 install_dir : systemgeneratordir)
3164 public_programs += executable(
3165 'systemd-cryptenroll',
3166 systemd_cryptenroll_sources,
3167 include_directories : includes,
3168 link_with : [libshared],
3169 dependencies : [libcryptsetup,
3174 install_rpath : pkglibdir,
3178 'systemd-integritysetup',
3179 ['src/integritysetup/integritysetup.c', 'src/integritysetup/integrity-util.c'],
3180 include_directories : includes,
3181 link_with : [libshared],
3182 dependencies : [libcryptsetup,
3184 install_rpath : pkglibdir,
3186 install_dir : libexecdir)
3189 'systemd-integritysetup-generator',
3190 ['src/integritysetup/integritysetup-generator.c', 'src/integritysetup/integrity-util.c'],
3191 include_directories : includes,
3192 link_with : [libshared],
3193 dependencies : userspace,
3194 install_rpath : pkglibdir,
3196 install_dir : systemgeneratordir)
3199 if conf.get('HAVE_SYSV_COMPAT') == 1
3201 'systemd-sysv-generator',
3202 'src/sysv-generator/sysv-generator.c',
3203 include_directories : includes,
3204 link_with : [libshared],
3205 dependencies : userspace,
3206 install_rpath : pkglibdir,
3208 install_dir : systemgeneratordir)
3210 sysv_generator_test_py = find_program('test/sysv-generator-test.py')
3211 if want_tests != 'false'
3212 test('sysv-generator-test',
3213 sysv_generator_test_py,
3218 'systemd-rc-local-generator',
3219 'src/rc-local-generator/rc-local-generator.c',
3220 include_directories : includes,
3221 link_with : [libshared],
3222 dependencies : userspace,
3223 install_rpath : pkglibdir,
3225 install_dir : systemgeneratordir)
3228 if conf.get('ENABLE_XDG_AUTOSTART') == 1
3230 'systemd-xdg-autostart-generator',
3231 systemd_xdg_autostart_generator_sources,
3232 include_directories : includes,
3233 link_with : [libshared],
3234 dependencies : userspace,
3235 install_rpath : pkglibdir,
3237 install_dir : usergeneratordir)
3240 'systemd-xdg-autostart-condition',
3241 'src/xdg-autostart-generator/xdg-autostart-condition.c',
3242 include_directories : includes,
3243 link_with : [libshared],
3244 dependencies : userspace,
3245 install_rpath : pkglibdir,
3247 install_dir : libexecdir)
3250 if conf.get('ENABLE_HOSTNAMED') == 1
3251 dbus_programs += executable(
3252 'systemd-hostnamed',
3253 'src/hostname/hostnamed.c',
3254 include_directories : includes,
3255 link_with : [libshared],
3256 dependencies : userspace,
3257 install_rpath : pkglibdir,
3259 install_dir : libexecdir)
3261 public_programs += executable(
3263 'src/hostname/hostnamectl.c',
3264 include_directories : includes,
3265 link_with : [libshared],
3266 dependencies : [userspace],
3267 install_rpath : pkglibdir,
3271 if conf.get('ENABLE_LOCALED') == 1
3272 dbus_programs += executable(
3274 systemd_localed_sources,
3275 include_directories : includes,
3276 link_with : [libshared],
3277 dependencies : libxkbcommon_deps +
3279 install_rpath : pkglibdir,
3281 install_dir : libexecdir)
3283 public_programs += executable(
3286 include_directories : includes,
3287 link_with : [libshared],
3288 dependencies : [userspace],
3289 install_rpath : pkglibdir,
3293 if conf.get('ENABLE_TIMEDATED') == 1
3294 dbus_programs += executable(
3295 'systemd-timedated',
3296 'src/timedate/timedated.c',
3297 include_directories : includes,
3298 link_with : [libshared],
3299 dependencies : userspace,
3300 install_rpath : pkglibdir,
3302 install_dir : libexecdir)
3305 if conf.get('ENABLE_TIMEDATECTL') == 1
3306 public_programs += executable(
3308 'src/timedate/timedatectl.c',
3309 include_directories : includes,
3310 install_rpath : pkglibdir,
3311 link_with : [libshared],
3312 dependencies : [libm,
3317 if conf.get('ENABLE_TIMESYNCD') == 1
3319 'systemd-timesyncd',
3320 systemd_timesyncd_sources,
3321 include_directories : includes,
3322 link_with : [libtimesyncd_core],
3323 dependencies : [libm,
3326 install_rpath : pkglibdir,
3328 install_dir : libexecdir)
3331 'systemd-time-wait-sync',
3332 'src/timesync/wait-sync.c',
3333 include_directories : includes,
3334 link_with : [libtimesyncd_core],
3335 dependencies : userspace,
3336 install_rpath : pkglibdir,
3338 install_dir : libexecdir)
3341 if conf.get('ENABLE_MACHINED') == 1
3342 dbus_programs += executable(
3344 systemd_machined_sources,
3345 include_directories : includes,
3346 link_with : [libmachine_core,
3348 dependencies : userspace,
3349 install_rpath : pkglibdir,
3351 install_dir : libexecdir)
3353 public_programs += executable(
3355 'src/machine/machinectl.c',
3356 include_directories : includes,
3357 link_with : [libshared],
3358 dependencies : [liblz4,
3363 install_rpath : pkglibdir,
3367 if conf.get('ENABLE_IMPORTD') == 1
3368 dbus_programs += executable(
3370 systemd_importd_sources,
3371 include_directories : includes,
3372 link_with : [libshared],
3373 dependencies : [threads,
3375 install_rpath : pkglibdir,
3377 install_dir : libexecdir)
3379 systemd_pull = executable(
3381 systemd_pull_sources,
3382 include_directories : includes,
3383 link_with : [libshared,
3385 dependencies : [lib_openssl_or_gcrypt,
3391 install_rpath : pkglibdir,
3393 install_dir : libexecdir)
3395 systemd_import = executable(
3397 systemd_import_sources,
3398 include_directories : includes,
3399 link_with : [libshared,
3401 dependencies : [libbzip2,
3406 install_rpath : pkglibdir,
3408 install_dir : libexecdir)
3410 systemd_import_fs = executable(
3411 'systemd-import-fs',
3412 systemd_import_fs_sources,
3413 include_directories : includes,
3414 link_with : [libshared,
3416 dependencies : [userspace],
3417 install_rpath : pkglibdir,
3419 install_dir : libexecdir)
3421 systemd_export = executable(
3423 systemd_export_sources,
3424 include_directories : includes,
3425 link_with : [libshared,
3427 dependencies : [libbzip2,
3432 install_rpath : pkglibdir,
3434 install_dir : libexecdir)
3436 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
3439 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
3440 public_programs += executable(
3441 'systemd-journal-upload',
3442 systemd_journal_upload_sources,
3443 include_directories : includes,
3444 link_with : [libshared],
3445 dependencies : [libcurl,
3452 install_rpath : pkglibdir,
3454 install_dir : libexecdir)
3457 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
3458 public_programs += executable(
3459 'systemd-journal-remote',
3460 systemd_journal_remote_sources,
3461 include_directories : journal_includes,
3462 link_with : [libshared,
3463 libsystemd_journal_remote],
3464 dependencies : [libgnutls,
3471 install_rpath : pkglibdir,
3473 install_dir : libexecdir)
3475 public_programs += executable(
3476 'systemd-journal-gatewayd',
3477 systemd_journal_gatewayd_sources,
3478 include_directories : journal_includes,
3479 link_with : [libshared],
3480 dependencies : [libgnutls,
3487 install_rpath : pkglibdir,
3489 install_dir : libexecdir)
3492 if conf.get('ENABLE_COREDUMP') == 1
3495 systemd_coredump_sources,
3496 include_directories : includes,
3497 link_with : [libshared,
3499 dependencies : [libacl,
3505 install_rpath : pkglibdir,
3507 install_dir : libexecdir)
3509 public_programs += executable(
3511 coredumpctl_sources,
3512 include_directories : includes,
3513 link_with : [libshared,
3515 dependencies : [liblz4,
3520 install_rpath : pkglibdir,
3524 if conf.get('ENABLE_PSTORE') == 1
3527 systemd_pstore_sources,
3528 include_directories : includes,
3529 link_with : [libshared],
3530 dependencies : [libacl,
3536 install_rpath : pkglibdir,
3538 install_dir : libexecdir)
3541 if conf.get('ENABLE_OOMD') == 1
3542 dbus_programs += executable('systemd-oomd',
3543 systemd_oomd_sources,
3544 include_directories : includes,
3545 link_with : [libshared],
3546 dependencies : [libatomic,
3548 install_rpath : pkglibdir,
3550 install_dir : libexecdir)
3552 public_programs += executable(
3555 include_directories : includes,
3556 link_with : [libshared],
3557 dependencies : [userspace],
3558 install_rpath : pkglibdir,
3562 if conf.get('ENABLE_BINFMT') == 1
3563 public_programs += executable(
3565 'src/binfmt/binfmt.c',
3566 include_directories : includes,
3567 link_with : [libshared],
3568 dependencies : [userspace],
3569 install_rpath : pkglibdir,
3571 install_dir : libexecdir)
3573 meson.add_install_script('sh', '-c',
3574 mkdir_p.format(binfmtdir))
3575 if install_sysconfdir
3576 meson.add_install_script('sh', '-c',
3577 mkdir_p.format(sysconfdir / 'binfmt.d'))
3581 if conf.get('ENABLE_SYSUPDATE') == 1
3583 'systemd-sysupdate',
3584 systemd_sysupdate_sources,
3585 include_directories : includes,
3586 link_with : [libshared,
3588 dependencies : [libblkid,
3593 install_rpath : pkglibdir,
3595 install_dir : libexecdir)
3596 public_programs += exe
3599 if conf.get('ENABLE_VCONSOLE') == 1
3601 'systemd-vconsole-setup',
3602 'src/vconsole/vconsole-setup.c',
3603 include_directories : includes,
3604 link_with : [libshared],
3605 dependencies : userspace,
3606 install_rpath : pkglibdir,
3608 install_dir : libexecdir)
3611 if conf.get('ENABLE_RANDOMSEED') == 1
3613 'systemd-random-seed',
3614 'src/random-seed/random-seed.c',
3615 include_directories : includes,
3616 link_with : [libshared],
3617 dependencies : [userspace],
3618 install_rpath : pkglibdir,
3620 install_dir : libexecdir)
3623 if conf.get('ENABLE_FIRSTBOOT') == 1
3624 public_programs += executable(
3625 'systemd-firstboot',
3626 'src/firstboot/firstboot.c',
3627 include_directories : includes,
3628 link_with : [libshared],
3629 dependencies : [libcrypt,
3631 install_rpath : pkglibdir,
3636 'systemd-remount-fs',
3637 'src/remount-fs/remount-fs.c',
3638 include_directories : includes,
3639 link_with : [libshared],
3640 dependencies : [userspace],
3641 install_rpath : pkglibdir,
3643 install_dir : libexecdir)
3646 'systemd-machine-id-setup',
3647 'src/machine-id-setup/machine-id-setup-main.c',
3648 include_directories : includes,
3649 link_with : [libshared],
3650 dependencies : [userspace],
3651 install_rpath : pkglibdir,
3657 include_directories : includes,
3658 link_with : [libshared],
3659 dependencies : [userspace],
3660 install_rpath : pkglibdir,
3662 install_dir : libexecdir)
3666 'src/partition/growfs.c',
3667 include_directories : includes,
3668 link_with : [libshared],
3669 dependencies : [userspace],
3670 install_rpath : pkglibdir,
3672 install_dir : libexecdir)
3676 'src/partition/makefs.c',
3677 include_directories : includes,
3678 link_with : [libshared],
3679 dependencies : [userspace],
3680 install_rpath : pkglibdir,
3682 install_dir : libexecdir)
3686 'src/sleep/sleep.c',
3687 include_directories : includes,
3688 link_with : [libshared],
3689 dependencies : [userspace],
3690 install_rpath : pkglibdir,
3692 install_dir : libexecdir)
3694 if install_sysconfdir_samples
3695 install_data('src/sleep/sleep.conf',
3696 install_dir : pkgsysconfdir)
3699 public_programs += executable(
3701 'src/sysctl/sysctl.c',
3702 include_directories : includes,
3703 link_with : [libshared],
3704 dependencies : [userspace],
3705 install_rpath : pkglibdir,
3707 install_dir : libexecdir)
3709 public_programs += executable(
3711 'src/ac-power/ac-power.c',
3712 include_directories : includes,
3713 link_with : [libshared],
3714 dependencies : [userspace],
3715 install_rpath : pkglibdir,
3718 public_programs += executable(
3719 'systemd-detect-virt',
3720 'src/detect-virt/detect-virt.c',
3721 include_directories : includes,
3722 link_with : [libshared],
3723 dependencies : [userspace],
3724 install_rpath : pkglibdir,
3727 public_programs += executable(
3729 'src/delta/delta.c',
3730 include_directories : includes,
3731 link_with : [libshared],
3732 dependencies : [userspace],
3733 install_rpath : pkglibdir,
3736 public_programs += executable(
3738 'src/escape/escape.c',
3739 include_directories : includes,
3740 link_with : [libshared],
3741 dependencies : [userspace],
3742 install_rpath : pkglibdir,
3745 public_programs += executable(
3747 'src/notify/notify.c',
3748 include_directories : includes,
3749 link_with : [libshared],
3750 dependencies : [userspace],
3751 install_rpath : pkglibdir,
3754 public_programs += executable(
3756 'src/creds/creds.c',
3757 include_directories : includes,
3758 link_with : [libshared],
3759 dependencies : [threads,
3762 install_rpath : pkglibdir,
3765 public_programs += executable(
3766 'systemd-battery-check',
3767 'src/battery-check/battery-check.c',
3768 include_directories : includes,
3769 link_with : [libshared],
3770 dependencies : [userspace],
3771 install_rpath : pkglibdir,
3772 install_dir : libexecdir,
3775 # Protecting files from the distro in /usr doesn't make sense since they can be trivially accessed otherwise,
3776 # so don't restrict the access mode in /usr. That doesn't apply to /etc, so we do restrict the access mode
3778 meson.add_install_script('sh', '-c', mkdir_p.format(credstoredir))
3779 if install_sysconfdir
3780 # Keep in sync with tmpfiles.d/credstore.conf
3781 meson.add_install_script('sh', '-c', mkdir_p_mode.format(sysconfdir / 'credstore', '0700'))
3782 meson.add_install_script('sh', '-c', mkdir_p_mode.format(sysconfdir / 'credstore.encrypted', '0700'))
3786 'systemd-volatile-root',
3787 'src/volatile-root/volatile-root.c',
3788 include_directories : includes,
3789 link_with : [libshared],
3790 dependencies : userspace,
3791 install_rpath : pkglibdir,
3792 install : conf.get('ENABLE_INITRD') == 1,
3793 install_dir : libexecdir)
3796 'systemd-cgroups-agent',
3797 'src/cgroups-agent/cgroups-agent.c',
3798 include_directories : includes,
3799 link_with : [libshared],
3800 dependencies : userspace,
3801 install_rpath : pkglibdir,
3803 install_dir : libexecdir)
3805 systemd_id128 = executable(
3807 'src/id128/id128.c',
3808 include_directories : includes,
3809 link_with : [libshared],
3810 dependencies : [userspace],
3811 install_rpath : pkglibdir,
3813 public_programs += systemd_id128
3815 if want_tests != 'false'
3816 test('test-systemctl-enable',
3817 test_systemctl_enable_sh,
3818 # https://github.com/mesonbuild/meson/issues/2681
3819 args : [systemctl.full_path(),
3820 systemd_id128.full_path()])
3823 public_programs += executable(
3826 include_directories : includes,
3827 link_with : [libshared],
3828 dependencies : [userspace],
3829 install_rpath : pkglibdir,
3832 public_programs += executable(
3833 'systemd-ask-password',
3834 'src/ask-password/ask-password.c',
3835 include_directories : includes,
3836 link_with : [libshared],
3837 dependencies : [userspace],
3838 install_rpath : pkglibdir,
3842 'systemd-reply-password',
3843 'src/reply-password/reply-password.c',
3844 include_directories : includes,
3845 link_with : [libshared],
3846 dependencies : userspace,
3847 install_rpath : pkglibdir,
3849 install_dir : libexecdir)
3851 public_programs += executable(
3852 'systemd-tty-ask-password-agent',
3853 'src/tty-ask-password-agent/tty-ask-password-agent.c',
3854 include_directories : includes,
3855 link_with : [libshared],
3856 dependencies : [userspace],
3857 install_rpath : pkglibdir,
3860 public_programs += executable(
3863 include_directories : includes,
3864 link_with : [libshared],
3865 dependencies : [userspace],
3866 install_rpath : pkglibdir,
3869 public_programs += executable(
3871 'src/cgtop/cgtop.c',
3872 include_directories : includes,
3873 link_with : [libshared],
3874 dependencies : [userspace],
3875 install_rpath : pkglibdir,
3880 'src/initctl/initctl.c',
3881 include_directories : includes,
3882 link_with : [libshared],
3883 dependencies : userspace,
3884 install_rpath : pkglibdir,
3885 install : (conf.get('HAVE_SYSV_COMPAT') == 1),
3886 install_dir : libexecdir)
3888 public_programs += executable(
3890 'src/mount/mount-tool.c',
3891 include_directories : includes,
3892 link_with : [libshared],
3893 dependencies: [libmount,
3895 install_rpath : pkglibdir,
3898 meson.add_install_script(meson_make_symlink,
3899 'systemd-mount', bindir / 'systemd-umount')
3901 public_programs += executable(
3904 include_directories : includes,
3905 link_with : [libshared],
3906 dependencies : [userspace],
3907 install_rpath : pkglibdir,
3910 public_programs += executable(
3911 'systemd-stdio-bridge',
3912 'src/stdio-bridge/stdio-bridge.c',
3913 include_directories : includes,
3914 link_with : [libshared],
3915 dependencies : [userspace],
3916 install_rpath : pkglibdir,
3919 public_programs += executable(
3922 include_directories : includes,
3923 link_with : [libshared],
3924 dependencies : [userspace],
3925 install_rpath : pkglibdir,
3931 'src/sysusers/sysusers.c',
3932 include_directories : includes,
3933 link_with : [libshared],
3934 dependencies : [userspace],
3935 install_rpath : pkglibdir,
3937 public_programs += exe
3939 if want_tests != 'false'
3940 test('test-sysusers',
3942 # https://github.com/mesonbuild/meson/issues/2681
3943 args : exe.full_path())
3947 'systemd-sysusers.standalone',
3948 'src/sysusers/sysusers.c',
3949 include_directories : includes,
3950 c_args : '-DSTANDALONE',
3951 link_with : [libshared_static,
3955 dependencies : [userspace],
3956 build_by_default: have_standalone_binaries,
3957 install : have_standalone_binaries)
3958 if have_standalone_binaries
3959 public_programs += exe
3961 if want_tests != 'false'
3962 test('test-sysusers.standalone',
3964 # https://github.com/mesonbuild/meson/issues/2681
3965 args : exe.full_path())
3970 if conf.get('ENABLE_TMPFILES') == 1
3973 systemd_tmpfiles_sources,
3974 include_directories : includes,
3975 link_with : [libshared],
3976 dependencies : [libacl,
3978 install_rpath : pkglibdir,
3980 public_programs += exe
3982 if want_tests != 'false'
3983 test('test-systemd-tmpfiles',
3984 test_systemd_tmpfiles_py,
3985 # https://github.com/mesonbuild/meson/issues/2681
3986 args : exe.full_path())
3990 'systemd-tmpfiles.standalone',
3991 systemd_tmpfiles_sources,
3992 include_directories : includes,
3993 c_args : '-DSTANDALONE',
3994 link_with : [libshared_static,
3998 dependencies : [libacl,
4000 build_by_default: have_standalone_binaries,
4001 install : have_standalone_binaries)
4002 if have_standalone_binaries
4003 public_programs += exe
4005 if want_tests != 'false'
4006 test('test-systemd-tmpfiles.standalone',
4007 test_systemd_tmpfiles_py,
4008 # https://github.com/mesonbuild/meson/issues/2681
4009 args : exe.full_path())
4014 if conf.get('ENABLE_HWDB') == 1
4015 systemd_hwdb = executable(
4018 include_directories : includes,
4019 link_with : udev_link_with,
4020 dependencies : [userspace],
4021 install_rpath : udev_rpath,
4023 public_programs += systemd_hwdb
4025 if want_tests != 'false'
4029 args : [systemd_hwdb.full_path()],
4034 if conf.get('ENABLE_QUOTACHECK') == 1
4036 'systemd-quotacheck',
4037 'src/quotacheck/quotacheck.c',
4038 include_directories : includes,
4039 link_with : [libshared],
4040 dependencies : userspace,
4041 install_rpath : pkglibdir,
4043 install_dir : libexecdir)
4046 public_programs += executable(
4047 'systemd-socket-proxyd',
4048 'src/socket-proxy/socket-proxyd.c',
4049 include_directories : includes,
4050 link_with : [libshared],
4051 dependencies : [threads,
4053 install_rpath : pkglibdir,
4055 install_dir : libexecdir)
4057 udevadm = executable(
4060 include_directories : includes,
4061 link_with : [libudevd_core],
4062 dependencies : [libacl,
4068 install_rpath : udev_rpath,
4070 public_programs += udevadm
4072 if want_tests != 'false'
4073 test('udev-rules-check',
4076 args : ['verify', '--resolve-names=never', all_rules])
4079 if conf.get('ENABLE_REPART') == 1
4082 systemd_repart_sources,
4083 include_directories : includes,
4084 link_with : [libshared,
4086 dependencies : [libblkid,
4091 install_rpath : pkglibdir,
4093 public_programs += exe
4096 'systemd-repart.standalone',
4097 systemd_repart_sources,
4098 include_directories : includes,
4099 c_args : '-DSTANDALONE',
4100 link_with : [libshared_static,
4105 dependencies : [libblkid,
4110 build_by_default: have_standalone_binaries,
4111 install_rpath : pkglibdir,
4112 install : have_standalone_binaries)
4113 if have_standalone_binaries
4114 public_programs += exe
4120 systemd_shutdown_sources,
4121 include_directories : includes,
4122 link_with : [libshared],
4123 dependencies : [libmount,
4125 install_rpath : pkglibdir,
4127 install_dir : libexecdir)
4130 'systemd-shutdown.standalone',
4131 systemd_shutdown_sources,
4132 include_directories : includes,
4133 c_args : '-DSTANDALONE',
4134 link_with : [libshared_static,
4137 dependencies : [libmount,
4139 build_by_default: have_standalone_binaries,
4140 install_rpath : pkglibdir,
4141 install : have_standalone_binaries,
4142 install_dir : libexecdir)
4145 'systemd-update-done',
4146 'src/update-done/update-done.c',
4147 include_directories : includes,
4148 link_with : [libshared],
4149 dependencies : [userspace],
4150 install_rpath : pkglibdir,
4152 install_dir : libexecdir)
4155 'systemd-update-utmp',
4156 'src/update-utmp/update-utmp.c',
4157 include_directories : includes,
4158 link_with : [libshared],
4159 dependencies : [libaudit,
4161 install_rpath : pkglibdir,
4162 install : (conf.get('ENABLE_UTMP') == 1),
4163 install_dir : libexecdir)
4165 if conf.get('HAVE_KMOD') == 1
4167 'systemd-modules-load',
4168 'src/modules-load/modules-load.c',
4169 include_directories : includes,
4170 link_with : [libshared],
4171 dependencies : [libkmod,
4173 install_rpath : pkglibdir,
4175 install_dir : libexecdir)
4177 meson.add_install_script('sh', '-c',
4178 mkdir_p.format(modulesloaddir))
4179 if install_sysconfdir
4180 meson.add_install_script('sh', '-c',
4181 mkdir_p.format(sysconfdir / 'modules-load.d'))
4185 public_programs += executable(
4187 systemd_nspawn_sources,
4188 include_directories : includes,
4189 link_with : [libnspawn_core,
4191 dependencies : [libblkid,
4194 install_rpath : pkglibdir,
4197 if conf.get('ENABLE_NETWORKD') == 1
4198 dbus_programs += executable(
4200 systemd_networkd_sources,
4201 include_directories : network_includes,
4202 link_with : [libnetworkd_core,
4204 networkd_link_with],
4205 dependencies : [threads,
4207 install_rpath : pkglibdir,
4209 install_dir : libexecdir)
4211 public_programs += executable(
4212 'systemd-networkd-wait-online',
4213 systemd_networkd_wait_online_sources,
4214 include_directories : includes,
4215 link_with : [networkd_link_with],
4216 dependencies : [userspace],
4217 install_rpath : pkglibdir,
4219 install_dir : libexecdir)
4221 public_programs += executable(
4224 include_directories : libsystemd_network_includes,
4225 link_with : [libsystemd_network,
4226 networkd_link_with],
4227 dependencies : [userspace],
4228 install_rpath : pkglibdir,
4233 'systemd-network-generator',
4234 network_generator_sources,
4235 include_directories : includes,
4236 link_with : [networkd_link_with],
4237 dependencies : [userspace],
4238 install_rpath : pkglibdir,
4240 install_dir : libexecdir)
4242 if want_tests != 'false'
4243 test('test-network-generator-conversion',
4244 test_network_generator_conversion_sh,
4245 # https://github.com/mesonbuild/meson/issues/2681
4246 args : exe.full_path(),
4251 'systemd-sulogin-shell',
4252 'src/sulogin-shell/sulogin-shell.c',
4253 include_directories : includes,
4254 link_with : [libshared],
4255 dependencies : [userspace],
4256 install_rpath : pkglibdir,
4258 install_dir : libexecdir)
4260 kernel_install = executable(
4262 'src/kernel-install/kernel-install.c',
4263 include_directories : includes,
4264 link_with : [libshared],
4265 dependencies : [userspace],
4266 install_rpath : pkglibdir,
4267 install : want_kernel_install)
4268 public_programs += kernel_install
4270 ukify = custom_target(
4272 input : 'src/ukify/ukify.py',
4274 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
4275 install : want_ukify,
4276 install_mode : 'rwxr-xr-x',
4277 install_dir : libexecdir)
4279 public_programs += ukify
4282 if want_tests != 'false' and want_kernel_install
4283 args = [kernel_install.full_path(), loaderentry_install.full_path(), uki_copy_install]
4284 deps = [kernel_install, loaderentry_install]
4285 if want_ukify and boot_stubs.length() > 0
4286 args += [ukify.full_path(), ukify_install.full_path(), boot_stubs[0]]
4287 deps += [ukify, ukify_install, boot_stubs[0]]
4290 test('test-kernel-install',
4291 test_kernel_install_sh,
4297 ############################################################
4299 runtest_env = custom_target(
4300 'systemd-runtest.env',
4301 output : 'systemd-runtest.env',
4302 command : [sh, '-c',
4303 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
4304 project_source_root / 'test',
4305 project_build_root / 'catalog')],
4307 build_by_default : true)
4309 test_cflags = ['-DTEST_CODE=1']
4310 # We intentionally do not do inline initializations with definitions for a
4311 # bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
4312 # use the variable unexpectedly. This triggers a lot of maybe-uninitialized
4313 # false positives when the combination of -O2 and -flto is used. Suppress them.
4314 if '-O2' in c_args and '-flto=auto' in c_args
4315 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
4318 foreach test : simple_tests
4319 tests += { 'sources' : [test] }
4323 foreach test : tests
4324 sources = test.get('sources')
4325 condition = test.get('condition', '')
4326 type = test.get('type', '')
4327 base = test.get('base', {})
4329 base.get('dependencies', []),
4330 test.get('dependencies', []),
4333 name = fs.name(sources[0])
4334 if name.endswith('.cc')
4335 deps += [versiondep]
4339 name = fs.stem(name)
4341 suite = fs.name(fs.parent(sources[0])).replace('sd-', '')
4343 if condition != '' and conf.get(condition) == 0
4344 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
4351 include_directories : [base.get('includes', []), test.get('includes', includes)],
4352 link_with : [base.get('link_with', []), test.get('link_with', libshared)],
4353 dependencies : deps,
4354 c_args : [test_cflags, test.get('c_args', [])],
4355 build_by_default : want_tests != 'false',
4356 install_rpath : pkglibdir,
4357 install : install_tests,
4358 install_dir : unittestsdir / type,
4359 link_depends : runtest_env)
4362 message('@0@ is a manual test'.format(name))
4363 elif type == 'unsafe' and want_tests != 'unsafe'
4364 message('@0@ is an unsafe test'.format(name))
4365 elif want_tests != 'false'
4368 timeout : test.get('timeout', 30),
4370 is_parallel : test.get('parallel', true))
4373 TESTS += { name : exe }
4377 'test-libsystemd-sym',
4378 test_libsystemd_sym_c,
4379 include_directories : includes,
4380 link_with : [libsystemd],
4381 dependencies : userspace,
4382 build_by_default : want_tests != 'false',
4383 install : install_tests,
4384 install_dir : unittestsdir)
4385 if want_tests != 'false'
4386 test('test-libsystemd-sym', exe)
4390 'test-libsystemd-static-sym',
4391 test_libsystemd_sym_c,
4392 include_directories : includes,
4393 link_with : [install_libsystemd_static],
4395 # threads is already included in dependencies on the library,
4396 # but does not seem to get propagated. Add here as a work-around.
4400 build_by_default : want_tests != 'false' and static_libsystemd != 'false',
4401 install : install_tests and static_libsystemd != 'false',
4402 install_dir : unittestsdir)
4403 if want_tests != 'false' and static_libsystemd != 'false'
4404 test('test-libsystemd-static-sym', exe)
4410 include_directories : libudev_includes,
4411 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
4412 link_with : [libudev],
4413 dependencies : userspace,
4414 build_by_default : want_tests != 'false',
4415 install : install_tests,
4416 install_dir : unittestsdir)
4417 if want_tests != 'false'
4418 test('test-libudev-sym', exe)
4422 'test-libudev-static-sym',
4424 include_directories : libudev_includes,
4425 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
4426 link_with : [install_libudev_static],
4427 dependencies : userspace,
4428 build_by_default : want_tests != 'false' and static_libudev != 'false',
4429 install : install_tests and static_libudev != 'false',
4430 install_dir : unittestsdir)
4431 if want_tests != 'false' and static_libudev != 'false'
4432 test('test-libudev-static-sym', exe)
4435 if want_tests != 'false'
4436 exe = TESTS.get('udev-rule-runner')
4440 env : ['UDEV_RULE_RUNNER=' + exe.full_path()],
4445 ############################################################
4447 foreach fuzzer : simple_fuzzers
4448 fuzzers += { 'sources' : [fuzzer] }
4453 foreach fuzzer : fuzzers
4454 sources = fuzzer.get('sources')
4455 base = fuzzer.get('base', {})
4456 dependencies = [base.get('dependencies', []), fuzzer.get('dependencies', [])]
4460 dependencies += fuzzing_engine
4462 if fuzzing_engine.found()
4463 dependencies += fuzzing_engine
4465 link_args += ['-fsanitize=fuzzer']
4468 sources += files('src/fuzz/fuzz-main.c')
4470 sources += fuzz_generated_directives
4472 name = fs.stem(sources[0])
4477 include_directories : [
4478 base.get('includes', []),
4479 fuzzer.get('includes', includes),
4480 include_directories('src/fuzz'),
4482 link_with : [base.get('link_with', []), fuzzer.get('link_with', libshared)],
4487 c_args : [test_cflags, fuzzer.get('c_args', [])],
4488 link_args: link_args,
4490 build_by_default : fuzzer_build)
4493 if want_tests != 'false' and name in fuzz_regression_tests
4494 # Run the fuzz regression tests without any sanitizers enabled.
4495 # Additional invocations with sanitizers may be added below.
4496 foreach tuple : fuzz_regression_tests[name]
4499 test('@0@_@1@'.format(name, fuzz_in),
4502 args : [fuzz_dir != '' ? project_source_root / fuzz_dir / name / fuzz_in
4503 : fuzz_generated_in_dir / '@0@_@1@'.format(name, fuzz_in)])
4508 alias_target('fuzzers', fuzzer_exes)
4510 ############################################################
4512 subdir('docs/sysvinit')
4513 subdir('docs/var-log')
4516 subdir('modprobe.d')
4519 subdir('shell-completion/bash')
4520 subdir('shell-completion/zsh')
4522 subdir('sysusers.d')
4523 subdir('tmpfiles.d')
4526 install_subdir('factory/etc',
4527 install_dir : factorydir)
4528 subdir('factory/templates')
4530 if install_sysconfdir
4531 install_data('xorg/50-systemd-user.sh',
4532 install_dir : xinitrcdir)
4534 install_data('LICENSE.GPL2',
4538 'docs/CODING_STYLE.md',
4539 'docs/DISTRO_PORTING.md',
4540 'docs/ENVIRONMENT.md',
4542 'docs/TRANSIENT-SETTINGS.md',
4543 'docs/TRANSLATORS.md',
4544 'docs/UIDS-GIDS.md',
4545 install_dir : docdir)
4547 install_subdir('LICENSES',
4548 install_dir : docdir)
4550 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
4551 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
4553 ############################################################
4555 # Ensure that changes to the docs/ directory do not break the
4556 # basic Github pages build. But only run it in developer mode,
4557 # as it might be fragile due to changes in the tooling, and it is
4558 # not generally useful for users.
4559 jekyll = find_program('jekyll', required : false)
4560 if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
4561 test('github-pages',
4565 '--source', project_source_root / 'docs',
4566 '--destination', project_build_root / '_site'])
4569 ############################################################
4571 check_help = find_program('tools/check-help.sh')
4572 check_version = find_program('tools/check-version.sh')
4574 foreach exec : public_programs
4575 name = fs.name(exec.full_path())
4576 if want_tests != 'false'
4577 test('check-help-' + name,
4580 args : exec.full_path(),
4583 test('check-version-' + name,
4586 args : [exec.full_path(),
4587 meson.project_version()],
4592 # Enable tests for all supported sanitizers
4593 foreach tuple : fuzz_sanitizers
4594 sanitizer = tuple[0]
4597 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
4598 foreach fuzzer, fuzz_ins : fuzz_regression_tests
4599 name = '@0@:@1@'.format(fuzzer, sanitizer)
4600 if want_tests == 'false'
4601 message('Not compiling @0@ because tests is set to false'.format(name))
4605 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
4608 exe = custom_target(
4611 depends : [build] + fuzz_generated_directives,
4612 command : [ln, '-fs',
4613 build.full_path() / fuzzer,
4615 build_by_default : true)
4617 foreach tuple : fuzz_ins
4621 test('@0@_@1@_@2@'.format(fuzzer, fuzz_in, sanitizer),
4624 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
4626 args : [exe.full_path(),
4627 fuzz_dir != '' ? project_source_root / fuzz_dir / fuzzer / fuzz_in
4628 : fuzz_generated_in_dir / '@0@_@1@'.format(fuzzer, fuzz_in)])
4634 ############################################################
4637 all_files = run_command(
4638 env, '-u', 'GIT_WORK_TREE',
4639 git, '--git-dir=@0@/.git'.format(project_source_root),
4640 'ls-files', ':/*.[ch]', ':/*.cc',
4642 if all_files.returncode() == 0
4643 all_files = files(all_files.stdout().split())
4648 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
4651 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
4653 ############################################
4655 if want_tests != 'false' and conf.get('BUILD_MODE_DEVELOPER') == 1
4656 test('check-includes',
4657 files('tools/check-includes.py'),
4659 env : ['PROJECT_SOURCE_ROOT=@0@'.format(project_source_root)])
4663 ####################################################
4665 git_contrib_sh = find_program('tools/git-contrib.sh')
4668 command : [git_contrib_sh])
4670 ####################################################
4672 git_head = run_command(
4673 git, '--git-dir=@0@/.git'.format(project_source_root),
4674 'rev-parse', 'HEAD',
4675 check : false).stdout().strip()
4676 git_head_short = run_command(
4677 git, '--git-dir=@0@/.git'.format(project_source_root),
4678 'rev-parse', '--short=7', 'HEAD',
4679 check : false).stdout().strip()
4683 command : [git, 'archive',
4684 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
4686 '--prefix', 'systemd-@0@/'.format(git_head),
4690 ############################################################
4692 check_api_docs_sh = find_program('tools/check-api-docs.sh')
4695 depends : [man, libsystemd, libudev],
4696 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
4698 alias_target('update-dbus-docs', update_dbus_docs)
4699 alias_target('update-man-rules', update_man_rules)
4701 if not meson.is_cross_build()
4703 'export-dbus-interfaces',
4704 output : fs.name(dbus_interfaces_dir),
4705 install : dbus_interfaces_dir != 'no',
4706 install_dir : fs.parent(dbus_interfaces_dir),
4707 command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
4710 ############################################################
4712 alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
4713 check : true).stdout().strip()
4716 'split bin-sbin' : split_bin,
4717 'prefix directory' : prefixdir,
4718 'sysconf directory' : sysconfdir,
4719 'include directory' : includedir,
4720 'lib directory' : libdir,
4721 'SysV init scripts' : sysvinit_path,
4722 'SysV rc?.d directories' : sysvrcnd_path,
4723 'PAM modules directory' : pamlibdir,
4724 'PAM configuration directory' : pamconfdir,
4725 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
4726 'RPM macros directory' : rpmmacrosdir,
4727 'modprobe.d directory' : modprobedir,
4728 'D-Bus policy directory' : dbuspolicydir,
4729 'D-Bus session directory' : dbussessionservicedir,
4730 'D-Bus system directory' : dbussystemservicedir,
4731 'D-Bus interfaces directory' : dbus_interfaces_dir,
4732 'bash completions directory' : bashcompletiondir,
4733 'zsh completions directory' : zshcompletiondir,
4734 'private shared lib version tag' : shared_lib_tag,
4735 'extra start script' : get_option('rc-local'),
4736 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
4737 get_option('debug-tty')),
4738 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
4739 conf.get('SYSTEM_ALLOC_UID_MIN')),
4740 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
4741 conf.get('SYSTEM_ALLOC_GID_MIN')),
4742 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
4743 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
4744 'static UID/GID allocations' : ' '.join(static_ugids),
4745 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
4746 'render group access mode' : get_option('group-render-mode'),
4747 'certificate root directory' : get_option('certificate-root'),
4748 'support URL' : support_url,
4749 'nobody user name' : nobody_user,
4750 'nobody group name' : nobody_group,
4751 'fallback hostname' : get_option('fallback-hostname'),
4752 'default compression method' : compression,
4753 'default DNSSEC mode' : default_dnssec,
4754 'default DNS-over-TLS mode' : default_dns_over_tls,
4755 'default mDNS mode' : default_mdns,
4756 'default LLMNR mode' : default_llmnr,
4757 'default DNS servers' : dns_servers.split(' '),
4758 'default NTP servers' : ntp_servers.split(' '),
4759 'default cgroup hierarchy' : default_hierarchy,
4760 'default net.naming-scheme value' : default_net_naming_scheme,
4761 'default KillUserProcesses value' : kill_user_processes,
4762 'default locale' : default_locale,
4763 'default nspawn locale' : nspawn_locale,
4764 'default status unit format' : status_unit_format_default,
4765 'default user $PATH' :
4766 default_user_path != '' ? default_user_path : '(same as system services)',
4767 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
4768 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
4771 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
4772 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
4773 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
4794 ['libcryptsetup-plugins'],
4822 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
4851 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
4865 ['legacy-pkla', install_polkit_pkla],
4871 ['man pages', want_man],
4872 ['html pages', want_html],
4873 ['man page indices', want_man and have_lxml],
4875 ['compat-mutable-uid-boundaries'],
4878 ['adm group', get_option('adm-group')],
4879 ['wheel group', get_option('wheel-group')],
4882 ['debug mmap cache'],
4884 ['trace logging', conf.get('LOG_TRACE') == 1],
4885 ['slow tests', slow_tests],
4886 ['fuzz tests', fuzz_tests],
4887 ['install tests', install_tests],
4888 ['link-udev-shared', get_option('link-udev-shared')],
4889 ['link-systemctl-shared', get_option('link-systemctl-shared')],
4890 ['link-networkd-shared', get_option('link-networkd-shared')],
4891 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
4892 ['link-journalctl-shared', get_option('link-journalctl-shared')],
4893 ['link-boot-shared', get_option('link-boot-shared')],
4894 ['link-portabled-shared', get_option('link-portabled-shared')],
4895 ['first-boot-full-preset'],
4897 ['standalone-binaries', get_option('standalone-binaries')],
4898 ['coverage', get_option('b_coverage')],
4901 if tuple.length() >= 2
4904 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
4905 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
4906 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
4915 if static_libsystemd == 'false'
4916 missing += 'static-libsystemd'
4918 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
4921 if static_libudev == 'false'
4922 missing += 'static-libudev'
4924 found += 'static-libudev(@0@)'.format(static_libudev)
4927 if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
4928 found += 'cryptolib(openssl)'
4929 elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
4930 found += 'cryptolib(gcrypt)'
4932 missing += 'cryptolib'
4935 if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
4936 found += 'DNS-over-TLS(gnutls)'
4937 elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
4938 found += 'DNS-over-TLS(openssl)'
4940 missing += 'DNS-over-TLS'
4944 'enabled' : ', '.join(found),
4945 'disabled' : ', '.join(missing)},
4946 section : 'Features')