1 # SPDX-License-Identifier: LGPL-2.1-or-later
3 project('systemd', 'c',
13 meson_version : '>= 0.53.2',
16 libsystemd_version = '0.36.0'
17 libudev_version = '1.7.6'
19 conf = configuration_data()
20 conf.set_quoted('PROJECT_URL', 'https://systemd.io/')
21 conf.set('PROJECT_VERSION', meson.project_version(),
22 description : 'Numerical project version (used where a simple number is expected)')
24 # This is to be used instead of meson.source_root(), as the latter will return
25 # the wrong result when systemd is being built as a meson subproject
26 project_source_root = meson.current_source_dir()
27 project_build_root = meson.current_build_dir()
28 relative_source_path = run_command('realpath',
29 '--relative-to=@0@'.format(project_build_root),
31 check : true).stdout().strip()
32 conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)
34 conf.set10('BUILD_MODE_DEVELOPER', get_option('mode') == 'developer',
35 description : 'tailor build to development or release builds')
36 verification = get_option('log-message-verification')
37 if verification == 'auto'
38 verification = conf.get('BUILD_MODE_DEVELOPER') == 1
40 verification = verification == 'true'
42 conf.set10('LOG_MESSAGE_VERIFICATION', verification)
44 want_ossfuzz = get_option('oss-fuzz')
45 want_libfuzzer = get_option('llvm-fuzz')
46 if want_ossfuzz and want_libfuzzer
47 error('only one of oss-fuzz or llvm-fuzz can be specified')
50 skip_deps = want_ossfuzz or get_option('skip-deps')
51 fuzzer_build = want_ossfuzz or want_libfuzzer
53 # If we're building *not* for actual fuzzing, allow input samples of any size
54 # (for testing and for reproduction of issues discovered with previously-higher
56 conf.set10('FUZZ_USE_SIZE_LIMIT', fuzzer_build)
58 # We'll set this to '1' for EFI builds in a different place.
59 conf.set10('SD_BOOT', false)
61 # Create a title-less summary section early, so it ends up first in the output.
62 # More items are added later after they have been detected.
63 summary({'build mode' : get_option('mode')})
65 #####################################################################
67 # Try to install the git pre-commit hook
68 add_git_hook_sh = find_program('tools/add-git-hook.sh', required : false)
69 if add_git_hook_sh.found()
70 git_hook = run_command(add_git_hook_sh, check : false)
71 if git_hook.returncode() == 0
72 message(git_hook.stdout().strip())
76 #####################################################################
79 if get_option('split-usr') == 'auto'
80 split_usr = not fs.is_symlink('/bin')
82 split_usr = get_option('split-usr') == 'true'
85 warning('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n\n'
86 + ' split-usr mode is going to be removed\n' +
87 '\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
89 conf.set10('HAVE_SPLIT_USR', split_usr,
90 description : '/usr/bin and /bin directories are separate')
92 if get_option('split-bin') == 'auto'
93 split_bin = not fs.is_symlink('/usr/sbin')
95 split_bin = get_option('split-bin') == 'true'
97 conf.set10('HAVE_SPLIT_BIN', split_bin,
98 description : 'bin and sbin directories are separate')
100 rootprefixdir = get_option('rootprefix')
101 # Unusual rootprefixdir values are used by some distros
102 # (see https://github.com/systemd/systemd/pull/7461).
103 rootprefix_default = split_usr ? '/' : '/usr'
104 if rootprefixdir == ''
105 rootprefixdir = rootprefix_default
107 rootprefixdir_noslash = rootprefixdir == '/' ? '' : rootprefixdir
109 have_standalone_binaries = get_option('standalone-binaries')
111 sysvinit_path = get_option('sysvinit-path')
112 sysvrcnd_path = get_option('sysvrcnd-path')
113 conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '',
114 description : 'SysV init scripts and rcN.d links are supported')
115 conf.set10('CREATE_LOG_DIRS', get_option('create-log-dirs'))
117 if get_option('hibernate') and not get_option('initrd')
118 error('hibernate depends on initrd')
121 conf.set10('BUMP_PROC_SYS_FS_FILE_MAX', get_option('bump-proc-sys-fs-file-max'))
122 conf.set10('BUMP_PROC_SYS_FS_NR_OPEN', get_option('bump-proc-sys-fs-nr-open'))
123 conf.set('HIGH_RLIMIT_NOFILE', 512*1024)
125 # Meson ignores the preceding arguments when joining paths if an absolute
126 # component is encountered, so this should canonicalize various paths when they
127 # are absolute or relative.
128 prefixdir = get_option('prefix')
129 if not prefixdir.startswith('/')
130 error('Prefix is not absolute: "@0@"'.format(prefixdir))
132 if prefixdir != rootprefixdir and rootprefixdir != '/' and not prefixdir.strip('/').startswith(rootprefixdir.strip('/') + '/')
133 error('Prefix is not below root prefix (now rootprefix=@0@ prefix=@1@)'.format(
134 rootprefixdir, prefixdir))
137 bindir = prefixdir / get_option('bindir')
138 libdir = prefixdir / get_option('libdir')
139 sysconfdir = prefixdir / get_option('sysconfdir')
140 includedir = prefixdir / get_option('includedir')
141 datadir = prefixdir / get_option('datadir')
142 localstatedir = '/' / get_option('localstatedir')
144 rootbindir = rootprefixdir / 'bin'
145 rootsbindir = rootprefixdir / (split_bin ? 'sbin' : 'bin')
146 rootlibexecdir = rootprefixdir / 'lib/systemd'
148 rootlibdir = get_option('rootlibdir')
150 # This will be a relative path if libdir is in prefix.
151 rootlibdir = get_option('libdir')
153 if not rootlibdir.startswith('/')
154 # If we have a relative path, add rootprefixdir to the front.
155 rootlibdir = rootprefixdir / rootlibdir
157 rootpkglibdir = rootlibdir / 'systemd'
159 install_sysconfdir = get_option('install-sysconfdir') != 'false'
160 install_sysconfdir_samples = get_option('install-sysconfdir') == 'true'
161 # Dirs of external packages
162 pkgconfigdatadir = get_option('pkgconfigdatadir') != '' ? get_option('pkgconfigdatadir') : datadir / 'pkgconfig'
163 pkgconfiglibdir = get_option('pkgconfiglibdir') != '' ? get_option('pkgconfiglibdir') : libdir / 'pkgconfig'
164 polkitpolicydir = datadir / 'polkit-1/actions'
165 polkitrulesdir = datadir / 'polkit-1/rules.d'
166 polkitpkladir = localstatedir / 'lib/polkit-1/localauthority/10-vendor.d'
167 xinitrcdir = get_option('xinitrcdir') != '' ? get_option('xinitrcdir') : sysconfdir / 'X11/xinit/xinitrc.d'
168 rpmmacrosdir = get_option('rpmmacrosdir')
169 if rpmmacrosdir != 'no'
170 rpmmacrosdir = prefixdir / rpmmacrosdir
172 modprobedir = rootprefixdir / 'lib/modprobe.d'
175 pkgdatadir = datadir / 'systemd'
176 environmentdir = prefixdir / 'lib/environment.d'
177 pkgsysconfdir = sysconfdir / 'systemd'
178 userunitdir = prefixdir / 'lib/systemd/user'
179 userpresetdir = prefixdir / 'lib/systemd/user-preset'
180 tmpfilesdir = prefixdir / 'lib/tmpfiles.d'
181 usertmpfilesdir = prefixdir / 'share/user-tmpfiles.d'
182 sysusersdir = prefixdir / 'lib/sysusers.d'
183 sysctldir = prefixdir / 'lib/sysctl.d'
184 binfmtdir = prefixdir / 'lib/binfmt.d'
185 modulesloaddir = prefixdir / 'lib/modules-load.d'
186 networkdir = rootprefixdir / 'lib/systemd/network'
187 systemgeneratordir = rootlibexecdir / 'system-generators'
188 usergeneratordir = prefixdir / 'lib/systemd/user-generators'
189 systemenvgeneratordir = prefixdir / 'lib/systemd/system-environment-generators'
190 userenvgeneratordir = prefixdir / 'lib/systemd/user-environment-generators'
191 systemshutdowndir = rootlibexecdir / 'system-shutdown'
192 systemsleepdir = rootlibexecdir / 'system-sleep'
193 systemunitdir = rootprefixdir / 'lib/systemd/system'
194 systempresetdir = rootprefixdir / 'lib/systemd/system-preset'
195 udevlibexecdir = rootprefixdir / 'lib/udev'
196 udevrulesdir = udevlibexecdir / 'rules.d'
197 udevhwdbdir = udevlibexecdir / 'hwdb.d'
198 catalogdir = prefixdir / 'lib/systemd/catalog'
199 kerneldir = prefixdir / 'lib/kernel'
200 kernelinstalldir = kerneldir / 'install.d'
201 factorydir = datadir / 'factory'
202 bootlibdir = prefixdir / 'lib/systemd/boot/efi'
203 testsdir = prefixdir / 'lib/systemd/tests'
204 systemdstatedir = localstatedir / 'lib/systemd'
205 catalogstatedir = systemdstatedir / 'catalog'
206 randomseeddir = localstatedir / 'lib/systemd'
207 profiledir = rootlibexecdir / 'portable' / 'profile'
208 ntpservicelistdir = rootprefixdir / 'lib/systemd/ntp-units.d'
210 docdir = get_option('docdir')
212 docdir = datadir / 'doc/systemd'
215 pamlibdir = get_option('pamlibdir')
217 pamlibdir = rootlibdir / 'security'
220 pamconfdir = get_option('pamconfdir')
222 pamconfdir = prefixdir / 'lib/pam.d'
225 libcryptsetup_plugins_dir = get_option('libcryptsetup-plugins-dir')
226 if libcryptsetup_plugins_dir == ''
227 libcryptsetup_plugins_dir = rootlibdir / 'cryptsetup'
230 memory_accounting_default = get_option('memory-accounting-default')
231 status_unit_format_default = get_option('status-unit-format-default')
232 if status_unit_format_default == 'auto'
233 status_unit_format_default = conf.get('BUILD_MODE_DEVELOPER') == 1 ? 'name' : 'description'
236 conf.set_quoted('BINFMT_DIR', binfmtdir)
237 conf.set_quoted('BOOTLIBDIR', bootlibdir)
238 conf.set_quoted('CATALOG_DATABASE', catalogstatedir / 'database')
239 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
240 conf.set_quoted('DOC_DIR', docdir)
241 conf.set_quoted('DOCUMENT_ROOT', pkgdatadir / 'gatewayd')
242 conf.set_quoted('ENVIRONMENT_DIR', environmentdir)
243 conf.set_quoted('INCLUDE_DIR', includedir)
244 conf.set_quoted('LIBDIR', libdir)
245 conf.set_quoted('MODPROBE_DIR', modprobedir)
246 conf.set_quoted('MODULESLOAD_DIR', modulesloaddir)
247 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
248 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', bindir / 'pkttyagent')
249 conf.set_quoted('PREFIX', prefixdir)
250 conf.set_quoted('RANDOM_SEED', randomseeddir / 'random-seed')
251 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
252 conf.set_quoted('RC_LOCAL_PATH', get_option('rc-local'))
253 conf.set_quoted('ROOTBINDIR', rootbindir)
254 conf.set_quoted('ROOTLIBDIR', rootlibdir)
255 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
256 conf.set_quoted('ROOTPREFIX', rootprefixdir)
257 conf.set_quoted('ROOTPREFIX_NOSLASH', rootprefixdir_noslash)
258 conf.set_quoted('SYSCONF_DIR', sysconfdir)
259 conf.set_quoted('SYSCTL_DIR', sysctldir)
260 conf.set_quoted('SYSTEMCTL_BINARY_PATH', rootbindir / 'systemctl')
261 conf.set_quoted('SYSTEMD_BINARY_PATH', rootlibexecdir / 'systemd')
262 conf.set_quoted('SYSTEMD_CATALOG_DIR', catalogdir)
263 conf.set_quoted('SYSTEMD_CGROUPS_AGENT_PATH', rootlibexecdir / 'systemd-cgroups-agent')
264 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', rootlibexecdir / 'systemd-cryptsetup')
265 conf.set_quoted('SYSTEMD_EXPORT_PATH', rootlibexecdir / 'systemd-export')
266 conf.set_quoted('SYSTEMD_FSCK_PATH', rootlibexecdir / 'systemd-fsck')
267 conf.set_quoted('SYSTEMD_GROWFS_PATH', rootlibexecdir / 'systemd-growfs')
268 conf.set_quoted('SYSTEMD_HOMEWORK_PATH', rootlibexecdir / 'systemd-homework')
269 conf.set_quoted('SYSTEMD_IMPORT_FS_PATH', rootlibexecdir / 'systemd-import-fs')
270 conf.set_quoted('SYSTEMD_IMPORT_PATH', rootlibexecdir / 'systemd-import')
271 conf.set_quoted('SYSTEMD_INTEGRITYSETUP_PATH', rootlibexecdir / 'systemd-integritysetup')
272 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', pkgdatadir / 'kbd-model-map')
273 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', pkgdatadir / 'language-fallback-map')
274 conf.set_quoted('SYSTEMD_MAKEFS_PATH', rootlibexecdir / 'systemd-makefs')
275 conf.set_quoted('SYSTEMD_PULL_PATH', rootlibexecdir / 'systemd-pull')
276 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', rootlibexecdir / 'systemd-shutdown')
277 conf.set_quoted('SYSTEMD_TEST_DATA', testsdir / 'testdata')
278 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', rootbindir / 'systemd-tty-ask-password-agent')
279 conf.set_quoted('SYSTEMD_UPDATE_HELPER_PATH', rootlibexecdir / 'systemd-update-helper')
280 conf.set_quoted('SYSTEMD_USERWORK_PATH', rootlibexecdir / 'systemd-userwork')
281 conf.set_quoted('SYSTEMD_VERITYSETUP_PATH', rootlibexecdir / 'systemd-veritysetup')
282 conf.set_quoted('SYSTEM_CONFIG_UNIT_DIR', pkgsysconfdir / 'system')
283 conf.set_quoted('SYSTEM_DATA_UNIT_DIR', systemunitdir)
284 conf.set_quoted('SYSTEM_ENV_GENERATOR_DIR', systemenvgeneratordir)
285 conf.set_quoted('SYSTEM_GENERATOR_DIR', systemgeneratordir)
286 conf.set_quoted('SYSTEM_PRESET_DIR', systempresetdir)
287 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
288 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
289 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
290 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
291 conf.set_quoted('SYSUSERS_DIR', sysusersdir)
292 conf.set_quoted('TMPFILES_DIR', tmpfilesdir)
293 conf.set_quoted('USER_TMPFILES_DIR', usertmpfilesdir)
294 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
295 conf.set_quoted('UDEV_HWDB_DIR', udevhwdbdir)
296 conf.set_quoted('UDEV_RULES_DIR', udevrulesdir)
297 conf.set_quoted('USER_CONFIG_UNIT_DIR', pkgsysconfdir / 'user')
298 conf.set_quoted('USER_DATA_UNIT_DIR', userunitdir)
299 conf.set_quoted('USER_ENV_GENERATOR_DIR', userenvgeneratordir)
300 conf.set_quoted('USER_GENERATOR_DIR', usergeneratordir)
301 conf.set_quoted('USER_KEYRING_PATH', pkgsysconfdir / 'import-pubring.gpg')
302 conf.set_quoted('USER_PRESET_DIR', userpresetdir)
303 conf.set_quoted('VENDOR_KEYRING_PATH', rootlibexecdir / 'import-pubring.gpg')
305 conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
306 conf.set10('ENABLE_URLIFY', get_option('urlify'))
307 conf.set10('ENABLE_FEXECVE', get_option('fexecve'))
308 conf.set10('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default)
309 conf.set('STATUS_UNIT_FORMAT_DEFAULT', 'STATUS_UNIT_FORMAT_' + status_unit_format_default.to_upper())
310 conf.set_quoted('STATUS_UNIT_FORMAT_DEFAULT_STR', status_unit_format_default)
312 conf.set('DEFAULT_TIMEOUT_SEC', get_option('default-timeout-sec'))
313 conf.set('DEFAULT_USER_TIMEOUT_SEC', get_option('default-user-timeout-sec'))
314 conf.set('UPDATE_HELPER_USER_TIMEOUT_SEC', get_option('update-helper-user-timeout-sec'))
316 conf.set10('FIRST_BOOT_FULL_PRESET', get_option('first-boot-full-preset'))
318 #####################################################################
320 cc = meson.get_compiler('c')
321 meson_build_sh = find_program('tools/meson-build.sh')
323 want_tests = get_option('tests')
324 slow_tests = want_tests != 'false' and get_option('slow-tests')
325 fuzz_tests = want_tests != 'false' and get_option('fuzz-tests')
326 install_tests = get_option('install-tests')
328 if add_languages('cpp', required : fuzzer_build)
329 # Used only for tests
330 cxx = meson.get_compiler('cpp')
331 cxx_cmd = ' '.join(cxx.cmd_array())
337 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer', required : false)
338 if fuzzing_engine.found()
339 add_project_arguments('-fsanitize-coverage=trace-pc-guard,trace-cmp', language : 'c')
340 elif cc.has_argument('-fsanitize=fuzzer-no-link')
341 add_project_arguments('-fsanitize=fuzzer-no-link', language : 'c')
343 error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported')
346 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
349 # Those generate many false positives, and we do not want to change the code to
351 basic_disabled_warnings = [
352 '-Wno-missing-field-initializers',
353 '-Wno-unused-parameter',
356 possible_common_cc_flags = [
357 '-Warray-bounds', # clang
362 '-Werror=format-signedness',
363 '-Werror=implicit-function-declaration',
364 '-Werror=implicit-int',
365 '-Werror=incompatible-pointer-types',
366 '-Werror=int-conversion',
368 '-Werror=override-init',
369 '-Werror=return-type',
370 '-Werror=shift-count-overflow',
371 '-Werror=shift-overflow=2',
374 # gperf prevents us from enabling this because it does not emit fallthrough
375 # attribute with clang.
376 #'-Wimplicit-fallthrough',
377 '-Wimplicit-fallthrough=5',
380 '-Wmissing-include-dirs',
381 '-Wmissing-noreturn',
383 '-Wold-style-definition',
387 '-Wstrict-aliasing=2',
388 '-Wstrict-prototypes',
389 '-Wsuggest-attribute=noreturn',
392 '-Wzero-length-bounds',
394 # negative arguments are correctly detected starting with meson 0.46.
395 '-Wno-error=#warnings', # clang
396 '-Wno-string-plus-int', # clang
398 '-fstrict-flex-arrays',
401 c_args = get_option('c_args')
403 # Our json library does not support -ffinite-math-only, which is enabled by -Ofast or -ffast-math.
404 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)
405 error('-Ofast, -ffast-math, or -ffinite-math-only is specified in c_args.')
408 # Disable -Wmaybe-uninitialized when compiling with -Os/-O1/-O3/etc. There are
409 # too many false positives with gcc >= 8. Effectively, we only test with -O0
410 # and -O2; this should be enough to catch most important cases without too much
411 # busywork. See https://github.com/systemd/systemd/pull/19226.
412 if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or
413 cc.version().version_compare('<10') or
418 possible_common_cc_flags += '-Wno-maybe-uninitialized'
421 # Disable -Wno-unused-result with gcc, see
422 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425.
423 if cc.get_id() == 'gcc'
424 possible_common_cc_flags += '-Wno-unused-result'
427 # --as-needed and --no-undefined are provided by meson by default,
428 # run 'meson configure' to see what is enabled
429 possible_link_flags = [
430 '-Wl,--fatal-warnings',
436 if get_option('b_sanitize') == 'none'
437 possible_link_flags += '-Wl,--warn-common'
440 if cc.get_id() == 'clang'
441 possible_common_cc_flags += [
442 '-Wno-typedef-redefinition',
443 '-Wno-gnu-variable-sized-type-not-at-end',
447 if get_option('mode') == 'release'
448 # We could enable 'pattern' for developer mode, but that can interfere with
449 # valgrind and sanitizer builds. Also, clang does not zero-initialize unions,
450 # breaking some of our code (https://reviews.llvm.org/D68115).
451 possible_common_cc_flags += '-ftrivial-auto-var-init=zero'
454 possible_cc_flags = possible_common_cc_flags + [
455 '-Werror=missing-declarations',
456 '-Werror=missing-prototypes',
457 '-fdiagnostics-show-option',
459 '-fno-strict-aliasing',
461 '-fstack-protector-strong',
462 '-fstrict-flex-arrays=1',
463 '-fvisibility=hidden',
464 '--param=ssp-buffer-size=4',
467 if get_option('buildtype') != 'debug'
468 possible_cc_flags += [
469 '-ffunction-sections',
473 possible_link_flags += '-Wl,--gc-sections'
476 if get_option('mode') == 'developer'
477 possible_cc_flags += '-fno-omit-frame-pointer'
480 add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
481 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
482 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
484 have = cc.has_argument('-Wzero-length-bounds')
485 conf.set10('HAVE_ZERO_LENGTH_BOUNDS', have)
489 #include <inttypes.h>
490 typedef uint64_t usec_t;
491 usec_t now(clockid_t clock);
496 ''', args: '-Werror=shadow', name : '-Werror=shadow with local shadowing')
497 add_project_arguments('-Werror=shadow', language : 'c')
501 add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
504 cpp = ' '.join(cc.cmd_array()) + ' -E'
506 has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
508 #####################################################################
509 # compilation result tests
511 conf.set('_GNU_SOURCE', true)
512 conf.set('__SANE_USERSPACE_TYPES__', true)
513 conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)
515 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
516 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
517 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
518 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
519 conf.set('SIZEOF_TIMEX_MEMBER', cc.sizeof('typeof(((struct timex *)0)->freq)', prefix : '#include <sys/timex.h>'))
521 long_max = cc.compute_int(
523 prefix : '#include <limits.h>',
524 guess : 0x7FFFFFFFFFFFFFFF,
525 high : 0x7FFFFFFFFFFFFFFF)
526 assert(long_max > 100000)
527 conf.set_quoted('LONG_MAX_STR', '@0@'.format(long_max))
531 #include <sys/mount.h>
532 #include <sys/stat.h>
535 foreach decl : ['char16_t',
541 # We get -1 if the size cannot be determined
542 have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
544 if decl == 'struct mount_attr'
546 want_linux_fs_h = false
548 have = cc.sizeof(decl,
549 prefix : decl_headers + '#include <linux/fs.h>',
550 args : '-D_GNU_SOURCE') > 0
551 want_linux_fs_h = have
555 if decl == 'struct statx'
557 want_linux_stat_h = false
559 have = cc.sizeof(decl,
560 prefix : decl_headers + '#include <linux/stat.h>',
561 args : '-D_GNU_SOURCE') > 0
562 want_linux_stat_h = have
566 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
569 conf.set10('WANT_LINUX_STAT_H', want_linux_stat_h)
570 conf.set10('WANT_LINUX_FS_H', want_linux_fs_h)
572 foreach ident : ['secure_getenv', '__secure_getenv']
573 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
577 ['memfd_create', '''#include <sys/mman.h>'''],
578 ['gettid', '''#include <sys/types.h>
579 #include <unistd.h>'''],
580 ['pivot_root', '''#include <stdlib.h>
581 #include <unistd.h>'''], # no known header declares pivot_root
582 ['ioprio_get', '''#include <sched.h>'''], # no known header declares ioprio_get
583 ['ioprio_set', '''#include <sched.h>'''], # no known header declares ioprio_set
584 ['name_to_handle_at', '''#include <sys/types.h>
585 #include <sys/stat.h>
586 #include <fcntl.h>'''],
587 ['setns', '''#include <sched.h>'''],
588 ['renameat2', '''#include <stdio.h>
589 #include <fcntl.h>'''],
590 ['kcmp', '''#include <linux/kcmp.h>'''],
591 ['keyctl', '''#include <sys/types.h>
592 #include <keyutils.h>'''],
593 ['copy_file_range', '''#include <sys/syscall.h>
594 #include <unistd.h>'''],
595 ['bpf', '''#include <sys/syscall.h>
596 #include <unistd.h>'''],
597 ['statx', '''#include <sys/types.h>
598 #include <sys/stat.h>
599 #include <unistd.h>'''],
600 ['explicit_bzero' , '''#include <string.h>'''],
601 ['reallocarray', '''#include <stdlib.h>'''],
602 ['set_mempolicy', '''#include <stdlib.h>
603 #include <unistd.h>'''],
604 ['get_mempolicy', '''#include <stdlib.h>
605 #include <unistd.h>'''],
606 ['pidfd_send_signal', '''#include <stdlib.h>
609 #include <sys/wait.h>'''],
610 ['pidfd_open', '''#include <stdlib.h>
613 #include <sys/wait.h>'''],
614 ['rt_sigqueueinfo', '''#include <stdlib.h>
617 #include <sys/wait.h>'''],
618 ['rt_tgsigqueueinfo', '''#include <stdlib.h>
621 #include <sys/wait.h>'''],
622 ['mallinfo', '''#include <malloc.h>'''],
623 ['mallinfo2', '''#include <malloc.h>'''],
624 ['execveat', '''#include <unistd.h>'''],
625 ['close_range', '''#include <unistd.h>'''],
626 ['epoll_pwait2', '''#include <sys/epoll.h>'''],
627 ['mount_setattr', '''#include <sys/mount.h>'''],
628 ['move_mount', '''#include <sys/mount.h>'''],
629 ['open_tree', '''#include <sys/mount.h>'''],
630 ['fsopen', '''#include <sys/mount.h>'''],
631 ['fsconfig', '''#include <sys/mount.h>'''],
632 ['getdents64', '''#include <dirent.h>'''],
635 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
636 conf.set10('HAVE_' + ident[0].to_upper(), have)
639 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
640 conf.set10('USE_SYS_RANDOM_H', true)
641 conf.set10('HAVE_GETRANDOM', true)
643 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
644 conf.set10('USE_SYS_RANDOM_H', false)
645 conf.set10('HAVE_GETRANDOM', have)
648 #####################################################################
650 version_tag = get_option('version-tag')
652 vcs_data = configuration_data()
653 vcs_data.set('VCS_TAG', version_tag)
654 version_h = configure_file(configuration : vcs_data,
655 input : 'src/version/version.h.in',
656 output : 'version.h')
659 project_source_root + '/tools/meson-vcs-tag.sh',
661 meson.project_version()]
664 input : 'src/version/version.h.in',
665 output : 'version.h',
669 versiondep = declare_dependency(sources: version_h)
671 shared_lib_tag = get_option('shared-lib-tag')
672 if shared_lib_tag == ''
673 shared_lib_tag = meson.project_version()
676 sh = find_program('sh')
677 echo = find_program('echo')
678 sed = find_program('sed')
679 awk = find_program('awk')
680 stat = find_program('stat')
681 ln = find_program('ln')
682 git = find_program('git', required : false)
683 env = find_program('env')
684 perl = find_program('perl', required : false)
685 rsync = find_program('rsync', required : false)
686 meson_make_symlink = project_source_root + '/tools/meson-make-symlink.sh'
688 mkdir_p = 'mkdir -p $DESTDIR/@0@'
690 # If -Dxxx-path option is found, use that. Otherwise, check in $PATH,
691 # /usr/sbin, /sbin, and fall back to the default from middle column.
692 progs = [['quotaon', '/usr/sbin/quotaon' ],
693 ['quotacheck', '/usr/sbin/quotacheck' ],
694 ['kmod', '/usr/bin/kmod' ],
695 ['kexec', '/usr/sbin/kexec' ],
696 ['sulogin', '/usr/sbin/sulogin' ],
697 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
698 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
699 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
700 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
701 ['nologin', '/usr/sbin/nologin', ],
704 path = get_option(prog[0] + '-path')
706 message('Using @1@ for @0@'.format(prog[0], path))
708 exe = find_program(prog[0],
709 '/usr/sbin/' + prog[0],
712 path = exe.found() ? exe.path() : prog[1]
714 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
715 conf.set_quoted(name, path)
718 conf.set_quoted('TELINIT', get_option('telinit-path'))
720 if run_command(ln, '--relative', '--help', check : false).returncode() != 0
721 error('ln does not support --relative (added in coreutils 8.16)')
724 ############################################################
726 gperf = find_program('gperf')
728 gperf_test_format = '''
730 const char * in_word_set(const char *, @0@);
733 gperf_snippet = run_command(sh, '-c', 'echo foo,bar | "$1" -L ANSI-C', '_', gperf,
735 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
736 if cc.compiles(gperf_test)
737 gperf_len_type = 'size_t'
739 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
740 if cc.compiles(gperf_test)
741 gperf_len_type = 'unsigned'
743 error('unable to determine gperf len type')
746 message('gperf len type is @0@'.format(gperf_len_type))
747 conf.set('GPERF_LEN_TYPE', gperf_len_type,
748 description : 'The type of gperf "len" parameter')
750 ############################################################
752 if not cc.has_header('sys/capability.h')
753 error('POSIX caps headers not found')
755 foreach header : ['crypt.h',
757 'linux/vm_sockets.h',
759 'valgrind/memcheck.h',
760 'valgrind/valgrind.h',
761 'linux/time_types.h',
765 conf.set10('HAVE_' + header.underscorify().to_upper(),
766 cc.has_header(header))
769 ############################################################
771 fallback_hostname = get_option('fallback-hostname')
772 if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0] == '-'
773 error('Invalid fallback-hostname configuration')
774 # A more extensive test is done in test-hostname-util. Let's catch
775 # the most obvious errors here so we don't fail with an assert later.
777 conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
779 default_hierarchy = get_option('default-hierarchy')
780 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
781 description : 'default cgroup hierarchy as string')
782 if default_hierarchy == 'legacy'
783 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
784 elif default_hierarchy == 'hybrid'
785 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
787 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
790 extra_net_naming_schemes = []
791 extra_net_naming_map = []
792 foreach scheme: get_option('extra-net-naming-schemes').split(',')
794 name = scheme.split('=')[0]
795 value = scheme.split('=')[1]
796 NAME = name.underscorify().to_upper()
798 foreach field: value.split('+')
799 VALUE += 'NAMING_' + field.underscorify().to_upper()
801 extra_net_naming_schemes += 'NAMING_@0@ = @1@,'.format(NAME, '|'.join(VALUE))
802 extra_net_naming_map += '{ "@0@", NAMING_@1@ },'.format(name, NAME)
805 conf.set('EXTRA_NET_NAMING_SCHEMES', ' '.join(extra_net_naming_schemes))
806 conf.set('EXTRA_NET_NAMING_MAP', ' '.join(extra_net_naming_map))
808 default_net_naming_scheme = get_option('default-net-naming-scheme')
809 conf.set_quoted('DEFAULT_NET_NAMING_SCHEME', default_net_naming_scheme)
810 if default_net_naming_scheme != 'latest'
811 conf.set('_DEFAULT_NET_NAMING_SCHEME_TEST',
812 'NAMING_' + default_net_naming_scheme.underscorify().to_upper())
815 time_epoch = get_option('time-epoch')
817 time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check : true).stdout().strip()
818 if time_epoch == '' and git.found() and fs.exists('.git')
819 # If we're in a git repository, use the creation time of the latest git tag.
820 latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags',
822 if latest_tag.returncode() == 0
823 time_epoch = run_command(
824 git, 'log', '--no-show-signature', '-1', '--format=%at',
825 latest_tag.stdout().strip(),
826 check : false).stdout()
831 time_epoch = run_command(stat, '-c', '%Y', NEWS,
832 check : true).stdout()
834 time_epoch = time_epoch.strip().to_int()
836 conf.set('TIME_EPOCH', time_epoch)
838 conf.set('CLOCK_VALID_RANGE_USEC_MAX', get_option('clock-valid-range-usec-max'))
840 default_user_shell = get_option('default-user-shell')
841 conf.set_quoted('DEFAULT_USER_SHELL', default_user_shell)
842 conf.set_quoted('DEFAULT_USER_SHELL_NAME', fs.name(default_user_shell))
844 foreach tuple : [['system-alloc-uid-min', 'SYS_UID_MIN', 1], # Also see login.defs(5).
845 ['system-uid-max', 'SYS_UID_MAX', 999],
846 ['system-alloc-gid-min', 'SYS_GID_MIN', 1],
847 ['system-gid-max', 'SYS_GID_MAX', 999]]
848 v = get_option(tuple[0])
852 '/^\s*@0@\s+/ { uid=$2 } END { print uid }'.format(tuple[1]),
854 check : false).stdout().strip()
861 conf.set(tuple[0].underscorify().to_upper(), v)
863 if conf.get('SYSTEM_ALLOC_UID_MIN') >= conf.get('SYSTEM_UID_MAX')
864 error('Invalid uid allocation range')
866 if conf.get('SYSTEM_ALLOC_GID_MIN') >= conf.get('SYSTEM_GID_MAX')
867 error('Invalid gid allocation range')
870 dynamic_uid_min = get_option('dynamic-uid-min')
871 dynamic_uid_max = get_option('dynamic-uid-max')
872 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
873 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
875 container_uid_base_min = get_option('container-uid-base-min')
876 container_uid_base_max = get_option('container-uid-base-max')
877 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
878 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
880 nobody_user = get_option('nobody-user')
881 nobody_group = get_option('nobody-group')
883 if not meson.is_cross_build()
884 getent_result = run_command('getent', 'passwd', '65534', check : false)
885 if getent_result.returncode() == 0
886 name = getent_result.stdout().split(':')[0]
887 if name != nobody_user
889 '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) +
890 'Your build will result in an user table setup that is incompatible with the local system.')
893 id_result = run_command('id', '-u', nobody_user, check : false)
894 if id_result.returncode() == 0
895 id = id_result.stdout().strip().to_int()
898 '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) +
899 'Your build will result in an user table setup that is incompatible with the local system.')
903 getent_result = run_command('getent', 'group', '65534', check : false)
904 if getent_result.returncode() == 0
905 name = getent_result.stdout().split(':')[0]
906 if name != nobody_group
908 '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) +
909 'Your build will result in an group table setup that is incompatible with the local system.')
912 id_result = run_command('id', '-g', nobody_group, check : false)
913 if id_result.returncode() == 0
914 id = id_result.stdout().strip().to_int()
917 '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) +
918 'Your build will result in an group table setup that is incompatible with the local system.')
922 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
924 'The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
925 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
928 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
929 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
932 foreach option : ['adm-gid',
949 'systemd-journal-gid',
950 'systemd-network-uid',
951 'systemd-resolve-uid',
952 'systemd-timesync-uid']
953 name = option.underscorify().to_upper()
954 val = get_option(option)
956 # Ensure provided GID argument is numeric, otherwise fall back to default assignment
957 conf.set(name, val > 0 ? val : '-')
959 static_ugids += '@0@:@1@'.format(option, val)
963 conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
964 conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
966 dev_kvm_mode = get_option('dev-kvm-mode')
967 conf.set_quoted('DEV_KVM_MODE', dev_kvm_mode) # FIXME: convert to 0o… notation
968 conf.set10('DEV_KVM_UACCESS', dev_kvm_mode != '0666')
969 group_render_mode = get_option('group-render-mode')
970 conf.set_quoted('GROUP_RENDER_MODE', group_render_mode)
971 conf.set10('GROUP_RENDER_UACCESS', group_render_mode != '0666')
973 kill_user_processes = get_option('default-kill-user-processes')
974 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
976 dns_servers = get_option('dns-servers')
977 conf.set_quoted('DNS_SERVERS', dns_servers)
979 ntp_servers = get_option('ntp-servers')
980 conf.set_quoted('NTP_SERVERS', ntp_servers)
982 default_locale = get_option('default-locale')
983 conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale)
985 nspawn_locale = get_option('nspawn-locale')
986 conf.set_quoted('SYSTEMD_NSPAWN_LOCALE', nspawn_locale)
988 localegen_path = get_option('localegen-path')
989 if localegen_path != ''
990 conf.set_quoted('LOCALEGEN_PATH', localegen_path)
992 conf.set10('HAVE_LOCALEGEN', localegen_path != '')
994 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
996 service_watchdog = get_option('service-watchdog')
997 watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
998 conf.set_quoted('SERVICE_WATCHDOG', watchdog_value)
1000 conf.set_quoted('SUSHELL', get_option('debug-shell'))
1001 conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
1003 enable_debug_hashmap = false
1004 enable_debug_mmap_cache = false
1005 enable_debug_siphash = false
1006 foreach name : get_option('debug-extra')
1007 if name == 'hashmap'
1008 enable_debug_hashmap = true
1009 elif name == 'mmap-cache'
1010 enable_debug_mmap_cache = true
1011 elif name == 'siphash'
1012 enable_debug_siphash = true
1014 message('unknown debug option "@0@", ignoring'.format(name))
1017 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
1018 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
1019 conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash)
1021 conf.set10('VALGRIND', get_option('valgrind'))
1022 conf.set10('LOG_TRACE', get_option('log-trace'))
1024 default_user_path = get_option('user-path')
1025 if default_user_path != ''
1026 conf.set_quoted('DEFAULT_USER_PATH', default_user_path)
1030 #####################################################################
1032 threads = dependency('threads')
1033 librt = cc.find_library('rt')
1034 libm = cc.find_library('m')
1035 libdl = cc.find_library('dl')
1036 libcrypt = cc.find_library('crypt')
1038 # On some architectures, libatomic is required. But on some installations,
1039 # it is found, but actual linking fails. So let's try to use it opportunistically.
1040 # If it is installed, but not needed, it will be dropped because of --as-needed.
1041 if cc.links('''int main(int argc, char **argv) { return 0; }''',
1044 libatomic = declare_dependency(link_args : '-latomic')
1049 crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
1051 ['crypt_ra', crypt_header],
1052 ['crypt_preferred_method', crypt_header],
1053 ['crypt_gensalt_ra', crypt_header]]
1055 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
1056 dependencies : libcrypt)
1057 conf.set10('HAVE_' + ident[0].to_upper(), have)
1060 libcap = dependency('libcap', required : false)
1061 if not libcap.found()
1062 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
1063 libcap = cc.find_library('cap')
1066 want_bpf_framework = get_option('bpf-framework')
1067 bpf_compiler = get_option('bpf-compiler')
1068 bpf_framework_required = want_bpf_framework == 'true'
1070 libbpf_version_requirement = '>= 0.1.0'
1071 if bpf_compiler == 'gcc'
1072 libbpf_version_requirement = '>= 1.0.0'
1074 libbpf = dependency('libbpf', required : bpf_framework_required, version : libbpf_version_requirement)
1075 conf.set10('HAVE_LIBBPF', libbpf.found())
1077 bpftool_strip_version_requirement = '>= 5.13.0'
1078 if bpf_compiler == 'gcc'
1079 bpftool_strip_version_requirement = '>= 7.0.0'
1082 if want_bpf_framework == 'false' or not libbpf.found() or skip_deps
1083 conf.set10('BPF_FRAMEWORK', false)
1086 clang_supports_bpf = false
1087 bpf_gcc_found = false
1088 bpftool_strip = false
1091 if bpf_compiler == 'clang'
1092 # Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu
1093 # (like clang-10/llvm-strip-10)
1094 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')
1095 r = find_program('clang', required : bpf_framework_required, version : '>= 10.0.0')
1096 clang_found = r.found()
1102 clang = cc.cmd_array()
1106 # Check if 'clang -target bpf' is supported.
1107 clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0
1109 elif bpf_compiler == 'gcc'
1110 warning('GCC BPF Compiler support is experimental and not recommended.')
1111 bpf_gcc = find_program('bpf-gcc',
1113 version : '>= 12.1.0')
1114 bpf_gcc_found = bpf_gcc.found()
1117 if clang_supports_bpf or bpf_gcc_found
1118 # Debian installs this in /usr/sbin/ which is not in $PATH.
1119 # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian.
1120 # We use 'bpftool gen object' subcommand for bpftool strip, it was added by d80b2fcbe0a023619e0fc73112f2a02c2662f6ab (v5.13).
1121 bpftool_strip_required = bpf_framework_required and bpf_compiler == 'gcc'
1122 bpftool = find_program('bpftool',
1123 '/usr/sbin/bpftool',
1124 required : bpftool_strip_required,
1125 version : bpftool_strip_version_requirement)
1128 bpftool_strip = true
1130 elif bpf_compiler == 'clang'
1131 # We require the 'bpftool gen skeleton' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6).
1132 bpftool = find_program('bpftool',
1133 '/usr/sbin/bpftool',
1134 required : bpf_framework_required,
1135 version : '>= 5.6.0')
1138 # We use `llvm-strip` as a fallback if `bpftool gen object` strip support is not available.
1139 if not bpftool_strip and bpftool.found() and clang_supports_bpf
1140 if not meson.is_cross_build()
1141 llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip',
1142 check : true).stdout().strip()
1144 llvm_strip_bin = 'llvm-strip'
1146 llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0')
1147 deps_found = llvm_strip.found()
1151 # Can build BPF program from source code in restricted C
1152 conf.set10('BPF_FRAMEWORK', deps_found)
1155 libmount = dependency('mount',
1156 version : fuzzer_build ? '>= 0' : '>= 2.30')
1158 want_libfdisk = get_option('fdisk')
1159 if want_libfdisk != 'false' and not skip_deps
1160 libfdisk = dependency('fdisk',
1161 version : '>= 2.32',
1162 required : want_libfdisk == 'true')
1163 have = libfdisk.found()
1168 conf.set10('HAVE_LIBFDISK', have)
1170 want_pwquality = get_option('pwquality')
1171 if want_pwquality != 'false' and not skip_deps
1172 libpwquality = dependency('pwquality', required : want_pwquality == 'true')
1173 have = libpwquality.found()
1178 conf.set10('HAVE_PWQUALITY', have)
1180 want_seccomp = get_option('seccomp')
1181 if want_seccomp != 'false' and not skip_deps
1182 libseccomp = dependency('libseccomp',
1183 version : '>= 2.3.1',
1184 required : want_seccomp == 'true')
1185 have = libseccomp.found()
1190 conf.set10('HAVE_SECCOMP', have)
1192 want_selinux = get_option('selinux')
1193 if want_selinux != 'false' and not skip_deps
1194 libselinux = dependency('libselinux',
1195 version : '>= 2.1.9',
1196 required : want_selinux == 'true')
1197 have = libselinux.found()
1202 conf.set10('HAVE_SELINUX', have)
1204 want_apparmor = get_option('apparmor')
1205 if want_apparmor != 'false' and not skip_deps
1206 libapparmor = dependency('libapparmor',
1207 version : '>= 2.13',
1208 required : want_apparmor == 'true')
1209 have = libapparmor.found()
1214 conf.set10('HAVE_APPARMOR', have)
1216 have = get_option('smack') and get_option('smack-run-label') != ''
1217 conf.set10('HAVE_SMACK_RUN_LABEL', have)
1219 conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
1222 have = get_option('smack') and get_option('smack-default-process-label') != ''
1224 conf.set_quoted('SMACK_DEFAULT_PROCESS_LABEL', get_option('smack-default-process-label'))
1227 want_polkit = get_option('polkit')
1228 install_polkit = false
1229 install_polkit_pkla = false
1230 if want_polkit != 'false' and not skip_deps
1231 install_polkit = true
1233 libpolkit = dependency('polkit-gobject-1',
1235 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
1236 message('Old polkit detected, will install pkla files')
1237 install_polkit_pkla = true
1240 conf.set10('ENABLE_POLKIT', install_polkit)
1242 want_acl = get_option('acl')
1243 if want_acl != 'false' and not skip_deps
1244 libacl = cc.find_library('acl', required : want_acl == 'true')
1245 have = libacl.found()
1250 conf.set10('HAVE_ACL', have)
1252 want_audit = get_option('audit')
1253 if want_audit != 'false' and not skip_deps
1254 libaudit = dependency('audit', required : want_audit == 'true')
1255 have = libaudit.found()
1260 conf.set10('HAVE_AUDIT', have)
1262 want_blkid = get_option('blkid')
1263 if want_blkid != 'false' and not skip_deps
1264 libblkid = dependency('blkid', required : want_blkid == 'true')
1265 have = libblkid.found()
1267 conf.set10('HAVE_BLKID_PROBE_SET_HINT',
1268 have and cc.has_function('blkid_probe_set_hint', dependencies : libblkid))
1273 conf.set10('HAVE_BLKID', have)
1275 want_kmod = get_option('kmod')
1276 if want_kmod != 'false' and not skip_deps
1277 libkmod = dependency('libkmod',
1279 required : want_kmod == 'true')
1280 have = libkmod.found()
1285 conf.set10('HAVE_KMOD', have)
1287 want_xenctrl = get_option('xenctrl')
1288 if want_xenctrl != 'false' and not skip_deps
1289 libxenctrl = dependency('xencontrol',
1291 required : want_xenctrl == 'true')
1292 have = libxenctrl.found()
1297 conf.set10('HAVE_XENCTRL', have)
1299 want_pam = get_option('pam')
1300 if want_pam != 'false' and not skip_deps
1301 libpam = cc.find_library('pam', required : want_pam == 'true')
1302 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1303 have = libpam.found() and libpam_misc.found()
1309 conf.set10('HAVE_PAM', have)
1311 want_microhttpd = get_option('microhttpd')
1312 if want_microhttpd != 'false' and not skip_deps
1313 libmicrohttpd = dependency('libmicrohttpd',
1314 version : '>= 0.9.33',
1315 required : want_microhttpd == 'true')
1316 have = libmicrohttpd.found()
1321 conf.set10('HAVE_MICROHTTPD', have)
1323 want_libcryptsetup = get_option('libcryptsetup')
1324 want_libcryptsetup_plugins = get_option('libcryptsetup-plugins')
1326 if want_libcryptsetup_plugins == 'true' and want_libcryptsetup == 'false'
1327 error('libcryptsetup-plugins can not be requested without libcryptsetup')
1330 if want_libcryptsetup != 'false' and not skip_deps
1331 libcryptsetup = dependency('libcryptsetup',
1332 version : want_libcryptsetup_plugins == 'true' ? '>= 2.4.0' : '>= 2.0.1',
1333 required : want_libcryptsetup == 'true' or want_libcryptsetup_plugins == 'true')
1334 have = libcryptsetup.found()
1336 foreach ident : ['crypt_set_metadata_size',
1337 'crypt_activate_by_signed_key',
1339 'crypt_reencrypt_init_by_passphrase',
1341 'crypt_set_data_offset']
1342 have_ident = have and cc.has_function(
1344 prefix : '#include <libcryptsetup.h>',
1345 dependencies : libcryptsetup)
1346 conf.set10('HAVE_' + ident.to_upper(), have_ident)
1352 conf.set10('HAVE_LIBCRYPTSETUP', have)
1354 if want_libcryptsetup_plugins != 'false' and not skip_deps
1355 have = (cc.has_function(
1356 'crypt_activate_by_token_pin',
1357 prefix : '#include <libcryptsetup.h>',
1358 dependencies : libcryptsetup) and
1360 'crypt_token_external_path',
1361 prefix : '#include <libcryptsetup.h>',
1362 dependencies : libcryptsetup))
1366 conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have)
1368 want_libcurl = get_option('libcurl')
1369 if want_libcurl != 'false' and not skip_deps
1370 libcurl = dependency('libcurl',
1371 version : '>= 7.32.0',
1372 required : want_libcurl == 'true')
1373 have = libcurl.found()
1378 conf.set10('HAVE_LIBCURL', have)
1379 conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
1381 want_libidn = get_option('libidn')
1382 want_libidn2 = get_option('libidn2')
1383 if want_libidn == 'true' and want_libidn2 == 'true'
1384 error('libidn and libidn2 cannot be requested simultaneously')
1387 if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps
1388 libidn = dependency('libidn2',
1389 required : want_libidn2 == 'true')
1390 have = libidn.found()
1395 conf.set10('HAVE_LIBIDN2', have)
1396 if not have and want_libidn != 'false' and not skip_deps
1397 # libidn is used for both libidn and libidn2 objects
1398 libidn = dependency('libidn',
1399 required : want_libidn == 'true')
1400 have = libidn.found()
1404 conf.set10('HAVE_LIBIDN', have)
1406 want_libiptc = get_option('libiptc')
1407 if want_libiptc != 'false' and not skip_deps
1408 libiptc = dependency('libiptc',
1409 required : want_libiptc == 'true')
1410 have = libiptc.found()
1415 conf.set10('HAVE_LIBIPTC', have)
1417 want_qrencode = get_option('qrencode')
1418 if want_qrencode != 'false' and not skip_deps
1419 libqrencode = dependency('libqrencode',
1421 required : want_qrencode == 'true')
1422 have = libqrencode.found()
1427 conf.set10('HAVE_QRENCODE', have)
1429 want_gcrypt = get_option('gcrypt')
1430 if want_gcrypt != 'false' and not skip_deps
1431 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1432 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1433 have = libgcrypt.found() and libgpg_error.found()
1438 # link to neither of the libs if one is not found
1442 conf.set10('HAVE_GCRYPT', have)
1444 want_gnutls = get_option('gnutls')
1445 if want_gnutls != 'false' and not skip_deps
1446 libgnutls = dependency('gnutls',
1447 version : '>= 3.1.4',
1448 required : want_gnutls == 'true')
1449 have = libgnutls.found()
1454 conf.set10('HAVE_GNUTLS', have)
1456 want_openssl = get_option('openssl')
1457 if want_openssl != 'false' and not skip_deps
1458 libopenssl = dependency('openssl',
1459 version : '>= 1.1.0',
1460 required : want_openssl == 'true')
1461 have = libopenssl.found()
1466 conf.set10('HAVE_OPENSSL', have)
1468 want_p11kit = get_option('p11kit')
1469 if want_p11kit != 'false' and not skip_deps
1470 libp11kit = dependency('p11-kit-1',
1471 version : '>= 0.23.3',
1472 required : want_p11kit == 'true')
1473 have = libp11kit.found()
1474 libp11kit_cflags = libp11kit.partial_dependency(includes: true, compile_args: true)
1477 libp11kit_cflags = []
1480 conf.set10('HAVE_P11KIT', have)
1482 want_libfido2 = get_option('libfido2')
1483 if want_libfido2 != 'false' and not skip_deps
1484 if conf.get('HAVE_OPENSSL') == 1
1485 libfido2 = dependency('libfido2',
1486 required : want_libfido2 == 'true')
1487 have = libfido2.found()
1488 elif want_libfido2 == 'true'
1489 error('libfido2=true requires openssl')
1498 conf.set10('HAVE_LIBFIDO2', have)
1500 want_tpm2 = get_option('tpm2')
1501 if want_tpm2 != 'false' and not skip_deps
1502 tpm2 = dependency('tss2-esys tss2-rc tss2-mu',
1503 required : want_tpm2 == 'true')
1505 have_esys3 = tpm2.version().version_compare('>= 3.0.0')
1511 conf.set10('HAVE_TPM2', have)
1512 conf.set10('HAVE_TSS2_ESYS3', have_esys3)
1514 want_elfutils = get_option('elfutils')
1515 if want_elfutils != 'false' and not skip_deps
1516 libdw = dependency('libdw',
1517 required : want_elfutils == 'true')
1518 have = libdw.found()
1520 # New in elfutils 0.177
1521 conf.set10('HAVE_DWELF_ELF_E_MACHINE_STRING',
1522 have and cc.has_function('dwelf_elf_e_machine_string', dependencies : libdw))
1527 conf.set10('HAVE_ELFUTILS', have)
1529 want_zlib = get_option('zlib')
1530 if want_zlib != 'false' and not skip_deps
1531 libz = dependency('zlib',
1532 required : want_zlib == 'true')
1538 conf.set10('HAVE_ZLIB', have)
1540 want_bzip2 = get_option('bzip2')
1541 if want_bzip2 != 'false' and not skip_deps
1542 libbzip2 = cc.find_library('bz2',
1543 required : want_bzip2 == 'true')
1544 have = libbzip2.found()
1549 conf.set10('HAVE_BZIP2', have)
1551 want_xz = get_option('xz')
1552 if want_xz != 'false' and not skip_deps
1553 libxz = dependency('liblzma',
1554 required : want_xz == 'true')
1555 have_xz = libxz.found()
1560 conf.set10('HAVE_XZ', have_xz)
1562 want_lz4 = get_option('lz4')
1563 if want_lz4 != 'false' and not skip_deps
1564 liblz4 = dependency('liblz4',
1565 version : '>= 1.3.0',
1566 required : want_lz4 == 'true')
1567 have_lz4 = liblz4.found()
1572 conf.set10('HAVE_LZ4', have_lz4)
1574 want_zstd = get_option('zstd')
1575 if want_zstd != 'false' and not skip_deps
1576 libzstd = dependency('libzstd',
1577 required : want_zstd == 'true',
1578 version : '>= 1.4.0')
1579 have_zstd = libzstd.found()
1584 conf.set10('HAVE_ZSTD', have_zstd)
1586 conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
1588 compression = get_option('default-compression')
1589 if compression == 'auto'
1591 compression = 'zstd'
1597 compression = 'none'
1599 elif compression == 'zstd' and not have_zstd
1600 error('default-compression=zstd requires zstd')
1601 elif compression == 'lz4' and not have_lz4
1602 error('default-compression=lz4 requires lz4')
1603 elif compression == 'xz' and not have_xz
1604 error('default-compression=xz requires xz')
1606 conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper()))
1608 want_xkbcommon = get_option('xkbcommon')
1609 if want_xkbcommon != 'false' and not skip_deps
1610 libxkbcommon = dependency('xkbcommon',
1611 version : '>= 0.3.0',
1612 required : want_xkbcommon == 'true')
1613 have = libxkbcommon.found()
1618 conf.set10('HAVE_XKBCOMMON', have)
1620 want_pcre2 = get_option('pcre2')
1621 if want_pcre2 != 'false' and not skip_deps
1622 libpcre2 = dependency('libpcre2-8',
1623 required : want_pcre2 == 'true')
1624 have = libpcre2.found()
1629 conf.set10('HAVE_PCRE2', have)
1631 want_glib = get_option('glib')
1632 if want_glib != 'false' and not skip_deps
1633 libglib = dependency('glib-2.0',
1634 version : '>= 2.22.0',
1635 required : want_glib == 'true')
1636 libgobject = dependency('gobject-2.0',
1637 version : '>= 2.22.0',
1638 required : want_glib == 'true')
1639 libgio = dependency('gio-2.0',
1640 required : want_glib == 'true')
1641 have = libglib.found() and libgobject.found() and libgio.found()
1648 conf.set10('HAVE_GLIB', have)
1650 want_dbus = get_option('dbus')
1651 if want_dbus != 'false' and not skip_deps
1652 libdbus = dependency('dbus-1',
1653 version : '>= 1.3.2',
1654 required : want_dbus == 'true')
1655 have = libdbus.found()
1660 conf.set10('HAVE_DBUS', have)
1662 dbusdatadir = datadir / 'dbus-1'
1663 if conf.get('HAVE_DBUS') == 1
1664 dbusdatadir = libdbus.get_variable(pkgconfig: 'datadir', default_value: datadir) / 'dbus-1'
1667 dbuspolicydir = get_option('dbuspolicydir')
1668 if dbuspolicydir == ''
1669 dbuspolicydir = dbusdatadir / 'system.d'
1672 dbussessionservicedir = get_option('dbussessionservicedir')
1673 if dbussessionservicedir == ''
1674 dbussessionservicedir = dbusdatadir / 'services'
1675 if conf.get('HAVE_DBUS') == 1
1676 dbussessionservicedir = libdbus.get_variable(pkgconfig: 'session_bus_services_dir', default_value: dbussessionservicedir)
1680 dbussystemservicedir = get_option('dbussystemservicedir')
1681 if dbussystemservicedir == ''
1682 dbussystemservicedir = dbusdatadir / 'system-services'
1683 if conf.get('HAVE_DBUS') == 1
1684 dbussystemservicedir = libdbus.get_variable(pkgconfig: 'system_bus_services_dir', default_value: dbussystemservicedir)
1688 dbus_interfaces_dir = get_option('dbus-interfaces-dir')
1689 if dbus_interfaces_dir == '' or dbus_interfaces_dir == 'yes'
1690 if meson.is_cross_build() and dbus_interfaces_dir != 'yes'
1691 dbus_interfaces_dir = 'no'
1692 warning('Exporting D-Bus interface XML files is disabled during cross build. Pass path or "yes" to force enable.')
1694 dbus_interfaces_dir = dbusdatadir / 'interfaces'
1695 if conf.get('HAVE_DBUS') == 1
1696 dbus_interfaces_dir = libdbus.get_variable(pkgconfig: 'interfaces_dir', default_value: dbus_interfaces_dir)
1701 # We support one or the other. If gcrypt is available, we assume it's there to
1702 # be used, and use it in preference.
1703 opt = get_option('cryptolib')
1704 if opt == 'openssl' and conf.get('HAVE_OPENSSL') == 0
1705 error('openssl requested as the default cryptolib, but not available')
1707 conf.set10('PREFER_OPENSSL',
1708 opt == 'openssl' or (opt == 'auto' and conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_GCRYPT') == 0))
1709 conf.set10('HAVE_OPENSSL_OR_GCRYPT',
1710 conf.get('HAVE_OPENSSL') == 1 or conf.get('HAVE_GCRYPT') == 1)
1711 lib_openssl_or_gcrypt = conf.get('PREFER_OPENSSL') == 1 ? [libopenssl] : [libgcrypt, libgpg_error]
1713 dns_over_tls = get_option('dns-over-tls')
1714 if dns_over_tls != 'false'
1715 if dns_over_tls == 'gnutls' and conf.get('PREFER_OPENSSL') == 1
1716 error('Sorry, -Ddns-over-tls=gnutls is not supported when openssl is used as the cryptolib')
1719 if dns_over_tls == 'gnutls'
1720 have_openssl = false
1722 have_openssl = conf.get('HAVE_OPENSSL') == 1
1723 if dns_over_tls == 'openssl' and not have_openssl
1724 error('DNS-over-TLS support was requested with openssl, but dependencies are not available')
1727 if dns_over_tls == 'openssl' or have_openssl
1730 have_gnutls = conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0')
1731 if dns_over_tls != 'auto' and not have_gnutls
1732 str = dns_over_tls == 'gnutls' ? ' with gnutls' : ''
1733 error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
1736 have = have_gnutls or have_openssl
1740 have_openssl = false
1742 conf.set10('ENABLE_DNS_OVER_TLS', have)
1743 conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1744 conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
1746 default_dns_over_tls = get_option('default-dns-over-tls')
1748 default_dns_over_tls = 'no'
1750 if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
1751 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.')
1752 default_dns_over_tls = 'no'
1754 conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1755 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
1756 conf.set_quoted('DEFAULT_DNS_OVER_TLS_MODE_STR', default_dns_over_tls)
1758 default_mdns = get_option('default-mdns')
1759 conf.set('DEFAULT_MDNS_MODE',
1760 'RESOLVE_SUPPORT_' + default_mdns.to_upper())
1761 conf.set_quoted('DEFAULT_MDNS_MODE_STR', default_mdns)
1763 default_llmnr = get_option('default-llmnr')
1764 conf.set('DEFAULT_LLMNR_MODE',
1765 'RESOLVE_SUPPORT_' + default_llmnr.to_upper())
1766 conf.set_quoted('DEFAULT_LLMNR_MODE_STR', default_llmnr)
1768 want_repart = get_option('repart')
1769 if want_repart != 'false'
1770 have = conf.get('HAVE_LIBFDISK') == 1
1771 if want_repart == 'true' and not have
1772 error('repart support was requested, but dependencies are not available')
1777 conf.set10('ENABLE_REPART', have)
1779 default_dnssec = get_option('default-dnssec')
1781 default_dnssec = 'no'
1783 if default_dnssec != 'no' and conf.get('HAVE_OPENSSL_OR_GCRYPT') == 0
1784 message('default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.')
1785 default_dnssec = 'no'
1787 conf.set('DEFAULT_DNSSEC_MODE',
1788 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1789 conf.set_quoted('DEFAULT_DNSSEC_MODE_STR', default_dnssec)
1791 want_sysupdate = get_option('sysupdate')
1792 if want_sysupdate != 'false'
1793 have = (conf.get('HAVE_OPENSSL') == 1 and
1794 conf.get('HAVE_LIBFDISK') == 1)
1795 if want_sysupdate == 'true' and not have
1796 error('sysupdate support was requested, but dependencies are not available')
1801 conf.set10('ENABLE_SYSUPDATE', have)
1803 want_importd = get_option('importd')
1804 if want_importd != 'false'
1805 have = (conf.get('HAVE_LIBCURL') == 1 and
1806 conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and
1807 conf.get('HAVE_ZLIB') == 1 and
1808 conf.get('HAVE_XZ') == 1)
1809 if want_importd == 'true' and not have
1810 error('importd support was requested, but dependencies are not available')
1815 conf.set10('ENABLE_IMPORTD', have)
1817 want_kernel_install = get_option('kernel-install')
1818 conf.set10('ENABLE_KERNEL_INSTALL', want_kernel_install)
1820 want_homed = get_option('homed')
1821 if want_homed != 'false'
1822 have = (conf.get('HAVE_OPENSSL') == 1 and
1823 conf.get('HAVE_LIBFDISK') == 1 and
1824 conf.get('HAVE_LIBCRYPTSETUP') == 1)
1825 if want_homed == 'true' and not have
1826 error('homed support was requested, but dependencies are not available')
1831 conf.set10('ENABLE_HOMED', have)
1833 have = have and conf.get('HAVE_PAM') == 1
1834 conf.set10('ENABLE_PAM_HOME', have)
1836 have = get_option('oomd')
1837 conf.set10('ENABLE_OOMD', have)
1839 want_remote = get_option('remote')
1840 if want_remote != 'false'
1841 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1842 conf.get('HAVE_LIBCURL') == 1]
1843 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1844 # it's possible to build one without the other. Complain only if
1845 # support was explicitly requested. The auxiliary files like sysusers
1846 # config should be installed when any of the programs are built.
1847 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1848 error('remote support was requested, but dependencies are not available')
1850 have = have_deps[0] or have_deps[1]
1854 conf.set10('ENABLE_REMOTE', have)
1856 foreach term : ['analyze',
1870 'compat-mutable-uid-boundaries',
1896 have = get_option(term)
1897 name = 'ENABLE_' + term.underscorify().to_upper()
1898 conf.set10(name, have)
1901 enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
1903 foreach tuple : [['nss-mymachines', 'machined'],
1904 ['nss-resolve', 'resolve']]
1905 want = get_option(tuple[0])
1907 have = get_option(tuple[1])
1908 if want == 'true' and not have
1909 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1914 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1915 conf.set10(name, have)
1919 foreach term : ['ENABLE_NSS_MYHOSTNAME',
1920 'ENABLE_NSS_MYMACHINES',
1921 'ENABLE_NSS_RESOLVE',
1922 'ENABLE_NSS_SYSTEMD']
1923 if conf.get(term) == 1
1927 conf.set10('ENABLE_NSS', enable_nss)
1929 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1931 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1933 ############################################################
1939 ############################################################
1941 # Include these now as they provide gnu-efi detection.
1942 subdir('src/fundamental')
1943 subdir('src/boot/efi')
1945 ############################################################
1947 pymod = import('python')
1948 python = pymod.find_installation('python3', required : true, modules : ['jinja2'])
1949 python_39 = python.language_version().version_compare('>=3.9')
1951 if get_option('ukify') == 'auto'
1952 want_ukify = python_39 and conf.get('HAVE_GNU_EFI') == 1
1953 elif get_option('ukify') == 'true' and (not python_39 or conf.get('HAVE_GNU_EFI') != 1)
1954 error('ukify requires Python >= 3.9 and GNU EFI')
1956 want_ukify = get_option('ukify') == 'true'
1958 conf.set10('ENABLE_UKIFY', want_ukify)
1960 ############################################################
1962 generate_gperfs = find_program('tools/generate-gperfs.py')
1963 make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
1964 make_directive_index_py = find_program('tools/make-directive-index.py')
1965 make_man_index_py = find_program('tools/make-man-index.py')
1966 meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
1967 update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
1968 update_man_rules_py = find_program('tools/update-man-rules.py')
1969 update_hwdb_sh = find_program('tools/update-hwdb.sh')
1970 update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
1971 update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
1972 xml_helper_py = find_program('tools/xml_helper.py')
1973 export_dbus_interfaces_py = find_program('tools/dbus_exporter.py')
1975 ############################################################
1977 if get_option('b_coverage')
1978 add_project_arguments('-include', 'src/basic/coverage.h', language : 'c')
1981 ############################################################
1983 config_h = configure_file(
1984 output : 'config.h',
1985 configuration : conf)
1987 add_project_arguments('-include', 'config.h', language : 'c')
1989 jinja2_cmdline = [meson_render_jinja2, config_h, version_h]
1991 ############################################################
1993 # binaries that have --help and are intended for use by humans,
1994 # usually, but not always, installed in /bin.
1995 public_programs = []
1997 # D-Bus introspection XML export
2000 basic_includes = include_directories(
2006 libsystemd_includes = [basic_includes, include_directories(
2007 'src/libsystemd/sd-bus',
2008 'src/libsystemd/sd-device',
2009 'src/libsystemd/sd-event',
2010 'src/libsystemd/sd-hwdb',
2011 'src/libsystemd/sd-id128',
2012 'src/libsystemd/sd-journal',
2013 'src/libsystemd/sd-netlink',
2014 'src/libsystemd/sd-network',
2015 'src/libsystemd/sd-resolve')]
2017 includes = [libsystemd_includes, include_directories('src/shared')]
2022 subdir('src/libsystemd')
2023 subdir('src/shared')
2025 subdir('src/libudev')
2026 subdir('src/cryptsetup/cryptsetup-tokens')
2028 alias_target('devel', libsystemd_pc, libudev_pc)
2030 libsystemd = shared_library(
2032 version : libsystemd_version,
2033 include_directories : libsystemd_includes,
2034 link_args : ['-shared',
2035 '-Wl,--version-script=' + libsystemd_sym_path],
2036 link_with : [libbasic,
2039 link_whole : [libsystemd_static],
2040 dependencies : [threads,
2042 link_depends : libsystemd_sym,
2044 install_tag: 'libsystemd',
2045 install_dir : rootlibdir)
2047 alias_target('libsystemd', libsystemd)
2049 install_libsystemd_static = static_library(
2053 basic_gcrypt_sources,
2054 basic_compress_sources,
2055 fundamental_sources,
2056 include_directories : libsystemd_includes,
2057 build_by_default : static_libsystemd != 'false',
2058 install : static_libsystemd != 'false',
2059 install_tag: 'libsystemd',
2060 install_dir : rootlibdir,
2061 pic : static_libsystemd_pic,
2062 dependencies : [threads,
2074 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
2076 libudev = shared_library(
2078 version : libudev_version,
2079 include_directories : includes,
2080 link_args : ['-shared',
2081 '-Wl,--version-script=' + libudev_sym_path],
2082 link_with : [libsystemd_static, libshared_static],
2083 link_whole : libudev_basic,
2084 dependencies : [threads],
2085 link_depends : libudev_sym,
2087 install_tag: 'libudev',
2088 install_dir : rootlibdir)
2090 alias_target('libudev', libudev)
2092 install_libudev_static = static_library(
2095 fundamental_sources,
2099 include_directories : includes,
2100 build_by_default : static_libudev != 'false',
2101 install : static_libudev != 'false',
2102 install_tag: 'libudev',
2103 install_dir : rootlibdir,
2104 link_depends : libudev_sym,
2105 dependencies : [libshared_deps,
2108 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
2109 pic : static_libudev_pic)
2111 if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
2112 if conf.get('HAVE_TPM2') == 1
2114 'cryptsetup-token-systemd-tpm2',
2115 cryptsetup_token_systemd_tpm2_sources,
2116 include_directories : includes,
2117 link_args : ['-shared',
2118 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2119 link_with : [lib_cryptsetup_token_common,
2121 dependencies : [libcryptsetup,
2124 link_depends : cryptsetup_token_sym,
2125 install_rpath : rootpkglibdir,
2127 install_dir : libcryptsetup_plugins_dir)
2130 if conf.get('HAVE_LIBFIDO2') == 1
2132 'cryptsetup-token-systemd-fido2',
2133 cryptsetup_token_systemd_fido2_sources,
2134 include_directories : includes,
2135 link_args : ['-shared',
2136 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2137 link_with : [lib_cryptsetup_token_common,
2139 dependencies : [libcryptsetup,
2142 link_depends : cryptsetup_token_sym,
2143 install_rpath : rootpkglibdir,
2145 install_dir : libcryptsetup_plugins_dir)
2148 if conf.get('HAVE_P11KIT') == 1
2150 'cryptsetup-token-systemd-pkcs11',
2151 cryptsetup_token_systemd_pkcs11_sources,
2152 include_directories : includes,
2153 link_args : ['-shared',
2154 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2155 link_with : [lib_cryptsetup_token_common,
2157 dependencies : [libcryptsetup,
2160 link_depends : cryptsetup_token_sym,
2161 install_rpath : rootpkglibdir,
2163 install_dir : libcryptsetup_plugins_dir)
2167 ############################################################
2169 # systemd-analyze requires 'libcore'
2171 # systemd-journal-remote requires 'libjournal_core'
2172 subdir('src/journal')
2173 # systemd-networkd requires 'libsystemd_network'
2174 subdir('src/libsystemd-network')
2176 subdir('src/analyze')
2178 subdir('src/busctl')
2179 subdir('src/coredump')
2180 subdir('src/cryptenroll')
2181 subdir('src/cryptsetup')
2183 subdir('src/hostname')
2184 subdir('src/import')
2185 subdir('src/journal-remote')
2186 subdir('src/kernel-install')
2187 subdir('src/locale')
2189 subdir('src/machine')
2190 subdir('src/network')
2191 subdir('src/nspawn')
2193 subdir('src/partition')
2194 subdir('src/portable')
2195 subdir('src/pstore')
2196 subdir('src/resolve')
2198 subdir('src/shutdown')
2199 subdir('src/sysext')
2200 subdir('src/systemctl')
2201 subdir('src/sysupdate')
2202 subdir('src/timedate')
2203 subdir('src/timesync')
2204 subdir('src/tmpfiles')
2205 subdir('src/userdb')
2206 subdir('src/xdg-autostart-generator')
2208 subdir('src/systemd')
2214 subdir('src/ukify/test') # needs to be last for test_env variable
2216 ############################################################
2218 # only static linking apart from libdl, to make sure that the
2219 # module is linked to all libraries that it uses.
2220 test_dlopen = executable(
2223 include_directories : includes,
2224 link_with : [libbasic],
2225 dependencies : [libdl],
2226 build_by_default : want_tests != 'false')
2228 foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
2229 ['systemd', 'ENABLE_NSS_SYSTEMD', ['nss-systemd.h', 'userdb-glue.c', 'userdb-glue.h']],
2230 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
2231 ['resolve', 'ENABLE_NSS_RESOLVE', [], resolve_includes]]
2233 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
2237 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
2238 version_script_arg = project_source_root / sym
2240 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
2241 if tuple.length() > 2
2242 foreach s : tuple[2]
2243 sources += ['src/nss-@0@/@1@'.format(module, s)]
2247 incs = tuple.length() > 3 ? tuple[3] : includes
2249 nss = shared_library(
2253 include_directories : incs,
2254 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
2255 link_args : ['-Wl,-z,nodelete',
2257 '-Wl,--version-script=' + version_script_arg],
2258 link_with : [libsystemd_static,
2261 dependencies : [threads,
2265 install_tag : 'nss',
2266 install_dir : rootlibdir)
2268 # We cannot use shared_module because it does not support version suffix.
2269 # Unfortunately shared_library insists on creating the symlink…
2270 meson.add_install_script('sh', '-c',
2271 'rm $DESTDIR@0@/libnss_@1@.so'
2272 .format(rootlibdir, module),
2276 if want_tests != 'false'
2277 test('dlopen-nss_' + module,
2279 # path to dlopen must include a slash
2280 args : nss.full_path(),
2286 ############################################################
2291 include_directories : includes,
2292 link_with : [libcore,
2294 dependencies : [libseccomp,
2296 install_rpath : rootpkglibdir,
2298 install_dir : rootlibexecdir)
2299 dbus_programs += exe
2300 public_programs += exe
2302 meson.add_install_script(meson_make_symlink,
2303 rootlibexecdir / 'systemd',
2304 rootsbindir / 'init')
2308 systemd_analyze_sources,
2309 include_directories : core_includes,
2310 link_with : [libcore,
2312 dependencies : [libseccomp,
2314 install_rpath : rootpkglibdir,
2315 install : conf.get('ENABLE_ANALYZE') == 1)
2316 public_programs += exe
2318 if want_tests != 'false'
2319 test('test-compare-versions',
2320 test_compare_versions_sh,
2321 args : exe.full_path())
2326 systemd_journald_sources,
2327 include_directories : includes,
2328 link_with : [libjournal_core,
2330 dependencies : [threads,
2336 install_rpath : rootpkglibdir,
2338 install_dir : rootlibexecdir)
2340 public_programs += executable(
2342 systemd_cat_sources,
2343 include_directories : includes,
2344 link_with : [libjournal_core,
2346 dependencies : [threads,
2348 install_rpath : rootpkglibdir,
2351 if get_option('link-journalctl-shared')
2352 journalctl_link_with = [libshared]
2354 journalctl_link_with = [libsystemd_static,
2359 public_programs += executable(
2362 include_directories : includes,
2363 link_with : [journalctl_link_with],
2364 dependencies : [threads,
2371 install_rpath : rootpkglibdir,
2373 install_dir : rootbindir)
2376 'systemd-getty-generator',
2377 'src/getty-generator/getty-generator.c',
2378 include_directories : includes,
2379 link_with : [libshared],
2380 install_rpath : rootpkglibdir,
2382 install_dir : systemgeneratordir)
2385 'systemd-debug-generator',
2386 'src/debug-generator/debug-generator.c',
2387 include_directories : includes,
2388 link_with : [libshared],
2389 install_rpath : rootpkglibdir,
2391 install_dir : systemgeneratordir)
2394 'systemd-run-generator',
2395 'src/run-generator/run-generator.c',
2396 include_directories : includes,
2397 link_with : [libshared],
2398 install_rpath : rootpkglibdir,
2400 install_dir : systemgeneratordir)
2403 'systemd-fstab-generator',
2404 'src/fstab-generator/fstab-generator.c',
2405 include_directories : includes,
2406 link_with : [libshared],
2407 install_rpath : rootpkglibdir,
2409 install_dir : systemgeneratordir)
2411 meson.add_install_script(meson_make_symlink,
2412 systemgeneratordir / 'systemd-fstab-generator',
2413 rootlibexecdir / 'systemd-sysroot-fstab-check')
2415 if want_tests != 'false'
2416 test('test-fstab-generator',
2417 test_fstab_generator_sh,
2418 # https://github.com/mesonbuild/meson/issues/2681
2419 args : exe.full_path(),
2423 if conf.get('ENABLE_ENVIRONMENT_D') == 1
2425 '30-systemd-environment-d-generator',
2426 'src/environment-d-generator/environment-d-generator.c',
2427 include_directories : includes,
2428 link_with : [libshared],
2429 install_rpath : rootpkglibdir,
2431 install_dir : userenvgeneratordir)
2433 meson.add_install_script(meson_make_symlink,
2434 sysconfdir / 'environment',
2435 environmentdir / '99-environment.conf')
2438 if conf.get('ENABLE_HIBERNATE') == 1
2440 'systemd-hibernate-resume-generator',
2441 'src/hibernate-resume/hibernate-resume-generator.c',
2442 include_directories : includes,
2443 link_with : [libshared],
2444 install_rpath : rootpkglibdir,
2446 install_dir : systemgeneratordir)
2449 'systemd-hibernate-resume',
2450 'src/hibernate-resume/hibernate-resume.c',
2451 include_directories : includes,
2452 link_with : [libshared],
2453 install_rpath : rootpkglibdir,
2455 install_dir : rootlibexecdir)
2458 if conf.get('HAVE_BLKID') == 1
2460 'systemd-gpt-auto-generator',
2461 'src/gpt-auto-generator/gpt-auto-generator.c',
2462 include_directories : includes,
2463 link_with : [libshared],
2464 dependencies : libblkid,
2465 install_rpath : rootpkglibdir,
2467 install_dir : systemgeneratordir)
2469 public_programs += executable(
2471 'src/dissect/dissect.c',
2472 include_directories : includes,
2473 link_with : [libshared],
2474 dependencies : [versiondep],
2475 install_rpath : rootpkglibdir,
2479 if conf.get('ENABLE_RESOLVE') == 1
2480 dbus_programs += executable(
2482 systemd_resolved_sources,
2483 include_directories : resolve_includes,
2484 link_with : [libshared,
2486 libsystemd_resolve_core],
2487 dependencies : systemd_resolved_dependencies,
2488 install_rpath : rootpkglibdir,
2490 install_dir : rootlibexecdir)
2492 public_programs += executable(
2495 include_directories : includes,
2496 link_with : [libshared,
2498 libsystemd_resolve_core],
2499 dependencies : [threads,
2500 lib_openssl_or_gcrypt,
2504 install_rpath : rootpkglibdir,
2507 meson.add_install_script(meson_make_symlink,
2508 bindir / 'resolvectl',
2509 rootsbindir / 'resolvconf')
2511 meson.add_install_script(meson_make_symlink,
2512 bindir / 'resolvectl',
2513 bindir / 'systemd-resolve')
2516 if conf.get('ENABLE_LOGIND') == 1
2517 dbus_programs += executable(
2519 systemd_logind_sources,
2520 include_directories : includes,
2521 link_with : [liblogind_core,
2523 dependencies : [threads,
2526 install_rpath : rootpkglibdir,
2528 install_dir : rootlibexecdir)
2530 public_programs += executable(
2533 include_directories : includes,
2534 link_with : [libshared],
2535 dependencies : [threads,
2540 install_rpath : rootpkglibdir,
2542 install_dir : rootbindir)
2544 public_programs += executable(
2546 'src/login/inhibit.c',
2547 include_directories : includes,
2548 link_with : [libshared],
2549 dependencies : [versiondep],
2550 install_rpath : rootpkglibdir,
2552 install_dir : rootbindir)
2554 if conf.get('HAVE_PAM') == 1
2555 version_script_arg = project_source_root / pam_systemd_sym
2556 pam_systemd = shared_library(
2560 include_directories : includes,
2561 link_args : ['-shared',
2562 '-Wl,--version-script=' + version_script_arg],
2563 link_with : [libsystemd_static,
2565 dependencies : [threads,
2569 link_depends : pam_systemd_sym,
2571 install_tag : 'pam',
2572 install_dir : pamlibdir)
2574 if want_tests != 'false'
2575 test('dlopen-pam_systemd',
2577 # path to dlopen must include a slash
2578 args : pam_systemd.full_path(),
2579 depends : pam_systemd)
2584 'systemd-user-runtime-dir',
2585 user_runtime_dir_sources,
2586 include_directories : includes,
2587 link_with : [libshared],
2588 install_rpath : rootpkglibdir,
2590 install_dir : rootlibexecdir)
2593 if conf.get('HAVE_PAM') == 1
2595 'systemd-user-sessions',
2596 'src/user-sessions/user-sessions.c',
2597 include_directories : includes,
2598 link_with : [libshared],
2599 install_rpath : rootpkglibdir,
2601 install_dir : rootlibexecdir)
2604 if conf.get('HAVE_BLKID') == 1 and conf.get('HAVE_GNU_EFI') == 1
2605 if get_option('link-boot-shared')
2606 boot_link_with = [libshared]
2608 boot_link_with = [libsystemd_static, libshared_static]
2614 include_directories : includes,
2615 link_with : [boot_link_with],
2616 dependencies : [libblkid,
2618 install_rpath : rootpkglibdir,
2620 public_programs += exe
2622 if want_tests != 'false'
2623 test('test-bootctl-json',
2624 test_bootctl_json_sh,
2625 args : exe.full_path(),
2629 public_programs += executable(
2630 'systemd-bless-boot',
2631 'src/boot/bless-boot.c',
2632 include_directories : includes,
2633 link_with : [boot_link_with],
2634 dependencies : [libblkid,
2636 install_rpath : rootpkglibdir,
2638 install_dir : rootlibexecdir)
2641 'systemd-bless-boot-generator',
2642 'src/boot/bless-boot-generator.c',
2643 include_directories : includes,
2644 link_with : [boot_link_with],
2645 install_rpath : rootpkglibdir,
2647 install_dir : systemgeneratordir)
2649 if conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_TPM2') == 1
2652 'src/boot/measure.c',
2653 include_directories : includes,
2654 link_with : [libshared],
2655 dependencies : [libopenssl,
2657 install_rpath : rootpkglibdir,
2659 install_dir : rootlibexecdir)
2662 'src/boot/pcrphase.c',
2663 include_directories : includes,
2664 link_with : [libshared],
2665 dependencies : [libopenssl,
2669 install_rpath : rootpkglibdir,
2671 install_dir : rootlibexecdir)
2676 'systemd-boot-check-no-failures',
2677 'src/boot/boot-check-no-failures.c',
2678 include_directories : includes,
2679 link_with : [libshared],
2680 dependencies : [libblkid,
2682 install_rpath : rootpkglibdir,
2684 install_dir : rootlibexecdir)
2686 public_programs += executable(
2687 'systemd-socket-activate',
2688 'src/activate/activate.c',
2689 include_directories : includes,
2690 link_with : [libshared],
2691 dependencies : [threads,
2693 install_rpath : rootpkglibdir,
2696 systemctl = executable(
2699 include_directories : includes,
2700 link_with : systemctl_link_with,
2701 dependencies : [threads,
2708 install_rpath : rootpkglibdir,
2710 install_dir : rootbindir)
2711 public_programs += systemctl
2713 if conf.get('ENABLE_PORTABLED') == 1
2714 dbus_programs += executable(
2715 'systemd-portabled',
2716 systemd_portabled_sources,
2717 include_directories : includes,
2718 link_with : [libshared],
2719 dependencies : [threads,
2722 install_rpath : rootpkglibdir,
2724 install_dir : rootlibexecdir)
2726 public_programs += executable(
2728 'src/portable/portablectl.c',
2729 include_directories : includes,
2730 link_with : [libshared],
2731 dependencies : [threads,
2733 install_rpath : rootpkglibdir,
2735 install_dir : rootbindir)
2738 if conf.get('ENABLE_SYSEXT') == 1
2739 public_programs += executable(
2741 systemd_sysext_sources,
2742 include_directories : includes,
2743 link_with : [libshared],
2744 dependencies : [versiondep],
2745 install_rpath : rootpkglibdir,
2747 install_dir : rootbindir)
2750 if conf.get('ENABLE_USERDB') == 1
2753 systemd_userwork_sources,
2754 include_directories : includes,
2755 link_with : [libshared],
2756 dependencies : [threads,
2758 install_rpath : rootpkglibdir,
2760 install_dir : rootlibexecdir)
2764 systemd_userdbd_sources,
2765 include_directories : includes,
2766 link_with : [libshared],
2767 dependencies : [threads,
2769 install_rpath : rootpkglibdir,
2771 install_dir : rootlibexecdir)
2773 public_programs += executable(
2776 include_directories : includes,
2777 link_with : [libshared],
2778 dependencies : [threads,
2780 install_rpath : rootpkglibdir,
2784 if conf.get('ENABLE_HOMED') == 1
2787 systemd_homework_sources,
2788 include_directories : includes,
2789 link_with : [libshared,
2791 dependencies : [threads,
2798 install_rpath : rootpkglibdir,
2800 install_dir : rootlibexecdir)
2802 dbus_programs += executable(
2804 systemd_homed_sources,
2805 include_directories : home_includes,
2806 link_with : [libshared],
2807 dependencies : [threads,
2812 install_rpath : rootpkglibdir,
2814 install_dir : rootlibexecdir)
2816 public_programs += executable(
2819 include_directories : includes,
2820 link_with : [libshared],
2821 dependencies : [threads,
2827 install_rpath : rootpkglibdir,
2830 if conf.get('HAVE_PAM') == 1
2831 version_script_arg = project_source_root / pam_systemd_home_sym
2832 pam_systemd_home = shared_library(
2836 include_directories : includes,
2837 link_args : ['-shared',
2838 '-Wl,--version-script=' + version_script_arg],
2839 link_with : [libsystemd_static,
2841 dependencies : [threads,
2846 link_depends : pam_systemd_home_sym,
2848 install_tag : 'pam',
2849 install_dir : pamlibdir)
2851 if want_tests != 'false'
2852 test('dlopen-pam_systemd_home',
2854 # path to dlopen must include a slash
2855 args : pam_systemd_home.full_path(),
2856 depends : pam_systemd_home)
2861 foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
2862 (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
2863 meson.add_install_script(meson_make_symlink,
2864 rootbindir / 'systemctl',
2865 rootsbindir / alias)
2868 meson.add_install_script(meson_make_symlink,
2869 rootbindir / 'udevadm',
2870 rootlibexecdir / 'systemd-udevd')
2872 if conf.get('ENABLE_BACKLIGHT') == 1
2874 'systemd-backlight',
2875 'src/backlight/backlight.c',
2876 include_directories : includes,
2877 link_with : [libshared],
2878 install_rpath : rootpkglibdir,
2880 install_dir : rootlibexecdir)
2883 if conf.get('ENABLE_RFKILL') == 1
2886 'src/rfkill/rfkill.c',
2887 include_directories : includes,
2888 link_with : [libshared],
2889 install_rpath : rootpkglibdir,
2891 install_dir : rootlibexecdir)
2895 'systemd-system-update-generator',
2896 'src/system-update-generator/system-update-generator.c',
2897 include_directories : includes,
2898 link_with : [libshared],
2899 install_rpath : rootpkglibdir,
2901 install_dir : systemgeneratordir)
2903 if conf.get('HAVE_LIBCRYPTSETUP') == 1
2905 'systemd-cryptsetup',
2906 systemd_cryptsetup_sources,
2907 include_directories : includes,
2908 link_with : [libshared],
2909 dependencies : [libcryptsetup,
2913 install_rpath : rootpkglibdir,
2915 install_dir : rootlibexecdir)
2918 'systemd-cryptsetup-generator',
2919 'src/cryptsetup/cryptsetup-generator.c',
2920 include_directories : includes,
2921 link_with : [libshared],
2922 install_rpath : rootpkglibdir,
2924 install_dir : systemgeneratordir)
2927 'systemd-veritysetup',
2928 'src/veritysetup/veritysetup.c',
2929 include_directories : includes,
2930 link_with : [libshared],
2931 dependencies : [libcryptsetup,
2933 install_rpath : rootpkglibdir,
2935 install_dir : rootlibexecdir)
2938 'systemd-veritysetup-generator',
2939 'src/veritysetup/veritysetup-generator.c',
2940 include_directories : includes,
2941 link_with : [libshared],
2942 dependencies : [versiondep],
2943 install_rpath : rootpkglibdir,
2945 install_dir : systemgeneratordir)
2947 public_programs += executable(
2948 'systemd-cryptenroll',
2949 systemd_cryptenroll_sources,
2950 include_directories : includes,
2951 link_with : [libshared],
2952 dependencies : [libcryptsetup,
2957 install_rpath : rootpkglibdir,
2961 'systemd-integritysetup',
2962 ['src/integritysetup/integritysetup.c', 'src/integritysetup/integrity-util.c'],
2963 include_directories : includes,
2964 link_with : [libshared],
2965 dependencies : [libcryptsetup,
2967 install_rpath : rootpkglibdir,
2969 install_dir : rootlibexecdir)
2972 'systemd-integritysetup-generator',
2973 ['src/integritysetup/integritysetup-generator.c', 'src/integritysetup/integrity-util.c'],
2974 include_directories : includes,
2975 link_with : [libshared],
2976 install_rpath : rootpkglibdir,
2978 install_dir : systemgeneratordir)
2981 if conf.get('HAVE_SYSV_COMPAT') == 1
2983 'systemd-sysv-generator',
2984 'src/sysv-generator/sysv-generator.c',
2985 include_directories : includes,
2986 link_with : [libshared],
2987 install_rpath : rootpkglibdir,
2989 install_dir : systemgeneratordir)
2991 sysv_generator_test_py = find_program('test/sysv-generator-test.py')
2992 if want_tests != 'false'
2993 test('sysv-generator-test',
2994 sysv_generator_test_py,
2999 'systemd-rc-local-generator',
3000 'src/rc-local-generator/rc-local-generator.c',
3001 include_directories : includes,
3002 link_with : [libshared],
3003 install_rpath : rootpkglibdir,
3005 install_dir : systemgeneratordir)
3008 if conf.get('ENABLE_XDG_AUTOSTART') == 1
3010 'systemd-xdg-autostart-generator',
3011 systemd_xdg_autostart_generator_sources,
3012 include_directories : includes,
3013 link_with : [libshared],
3014 install_rpath : rootpkglibdir,
3016 install_dir : usergeneratordir)
3019 'systemd-xdg-autostart-condition',
3020 'src/xdg-autostart-generator/xdg-autostart-condition.c',
3021 include_directories : includes,
3022 link_with : [libshared],
3023 install_rpath : rootpkglibdir,
3025 install_dir : rootlibexecdir)
3028 if conf.get('ENABLE_HOSTNAMED') == 1
3029 dbus_programs += executable(
3030 'systemd-hostnamed',
3031 'src/hostname/hostnamed.c',
3032 include_directories : includes,
3033 link_with : [libshared],
3034 install_rpath : rootpkglibdir,
3036 install_dir : rootlibexecdir)
3038 public_programs += executable(
3040 'src/hostname/hostnamectl.c',
3041 include_directories : includes,
3042 link_with : [libshared],
3043 dependencies : [versiondep],
3044 install_rpath : rootpkglibdir,
3048 if conf.get('ENABLE_LOCALED') == 1
3049 if conf.get('HAVE_XKBCOMMON') == 1
3050 # logind will load libxkbcommon.so dynamically on its own, but we still
3051 # need to specify where the headers are
3053 libxkbcommon.partial_dependency(compile_args: true),
3059 dbus_programs += executable(
3061 systemd_localed_sources,
3062 include_directories : includes,
3063 link_with : [libshared],
3064 dependencies : deps,
3065 install_rpath : rootpkglibdir,
3067 install_dir : rootlibexecdir)
3069 public_programs += executable(
3072 include_directories : includes,
3073 link_with : [libshared],
3074 dependencies : [versiondep],
3075 install_rpath : rootpkglibdir,
3079 if conf.get('ENABLE_TIMEDATED') == 1
3080 dbus_programs += executable(
3081 'systemd-timedated',
3082 'src/timedate/timedated.c',
3083 include_directories : includes,
3084 link_with : [libshared],
3085 install_rpath : rootpkglibdir,
3087 install_dir : rootlibexecdir)
3090 if conf.get('ENABLE_TIMEDATECTL') == 1
3091 public_programs += executable(
3093 'src/timedate/timedatectl.c',
3094 include_directories : includes,
3095 install_rpath : rootpkglibdir,
3096 link_with : [libshared],
3097 dependencies : [libm,
3102 if conf.get('ENABLE_TIMESYNCD') == 1
3104 'systemd-timesyncd',
3105 systemd_timesyncd_sources,
3106 include_directories : includes,
3107 link_with : [libtimesyncd_core],
3108 dependencies : [threads,
3111 install_rpath : rootpkglibdir,
3113 install_dir : rootlibexecdir)
3116 'systemd-time-wait-sync',
3117 'src/timesync/wait-sync.c',
3118 include_directories : includes,
3119 link_with : [libtimesyncd_core],
3120 install_rpath : rootpkglibdir,
3122 install_dir : rootlibexecdir)
3125 if conf.get('ENABLE_MACHINED') == 1
3126 dbus_programs += executable(
3128 systemd_machined_sources,
3129 include_directories : includes,
3130 link_with : [libmachine_core,
3132 install_rpath : rootpkglibdir,
3134 install_dir : rootlibexecdir)
3136 public_programs += executable(
3138 'src/machine/machinectl.c',
3139 include_directories : includes,
3140 link_with : [libshared],
3141 dependencies : [threads,
3146 install_rpath : rootpkglibdir,
3148 install_dir : rootbindir)
3151 if conf.get('ENABLE_IMPORTD') == 1
3152 dbus_programs += executable(
3154 systemd_importd_sources,
3155 include_directories : includes,
3156 link_with : [libshared],
3157 dependencies : [threads,
3159 install_rpath : rootpkglibdir,
3161 install_dir : rootlibexecdir)
3163 systemd_pull = executable(
3165 systemd_pull_sources,
3166 include_directories : includes,
3167 link_with : [libshared,
3169 dependencies : [libcurl,
3170 lib_openssl_or_gcrypt,
3175 install_rpath : rootpkglibdir,
3177 install_dir : rootlibexecdir)
3179 systemd_import = executable(
3181 systemd_import_sources,
3182 include_directories : includes,
3183 link_with : [libshared,
3185 dependencies : [libcurl,
3190 install_rpath : rootpkglibdir,
3192 install_dir : rootlibexecdir)
3194 systemd_import_fs = executable(
3195 'systemd-import-fs',
3196 systemd_import_fs_sources,
3197 include_directories : includes,
3198 link_with : [libshared,
3200 dependencies : [versiondep],
3201 install_rpath : rootpkglibdir,
3203 install_dir : rootlibexecdir)
3205 systemd_export = executable(
3207 systemd_export_sources,
3208 include_directories : includes,
3209 link_with : [libshared,
3211 dependencies : [libcurl,
3216 install_rpath : rootpkglibdir,
3218 install_dir : rootlibexecdir)
3220 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
3223 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
3224 public_programs += executable(
3225 'systemd-journal-upload',
3226 systemd_journal_upload_sources,
3227 include_directories : includes,
3228 link_with : [libshared],
3229 dependencies : [threads,
3236 install_rpath : rootpkglibdir,
3238 install_dir : rootlibexecdir)
3241 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
3242 public_programs += executable(
3243 'systemd-journal-remote',
3244 systemd_journal_remote_sources,
3245 include_directories : journal_includes,
3246 link_with : [libshared,
3247 libsystemd_journal_remote],
3248 dependencies : [threads,
3255 install_rpath : rootpkglibdir,
3257 install_dir : rootlibexecdir)
3259 public_programs += executable(
3260 'systemd-journal-gatewayd',
3261 systemd_journal_gatewayd_sources,
3262 include_directories : journal_includes,
3263 link_with : [libshared],
3264 dependencies : [threads,
3271 install_rpath : rootpkglibdir,
3273 install_dir : rootlibexecdir)
3276 if conf.get('ENABLE_COREDUMP') == 1
3279 systemd_coredump_sources,
3280 include_directories : includes,
3281 link_with : [libshared,
3283 dependencies : [threads,
3289 install_rpath : rootpkglibdir,
3291 install_dir : rootlibexecdir)
3293 public_programs += executable(
3295 coredumpctl_sources,
3296 include_directories : includes,
3297 link_with : [libshared,
3299 dependencies : [threads,
3304 install_rpath : rootpkglibdir,
3308 if conf.get('ENABLE_PSTORE') == 1
3311 systemd_pstore_sources,
3312 include_directories : includes,
3313 link_with : [libshared],
3314 dependencies : [threads,
3320 install_rpath : rootpkglibdir,
3322 install_dir : rootlibexecdir)
3325 if conf.get('ENABLE_OOMD') == 1
3326 dbus_programs += executable('systemd-oomd',
3327 systemd_oomd_sources,
3328 include_directories : includes,
3329 link_with : [libshared],
3330 dependencies : [libatomic,
3332 install_rpath : rootpkglibdir,
3334 install_dir : rootlibexecdir)
3336 public_programs += executable(
3339 include_directories : includes,
3340 link_with : [libshared],
3341 dependencies : [versiondep],
3342 install_rpath : rootpkglibdir,
3346 if conf.get('ENABLE_BINFMT') == 1
3347 public_programs += executable(
3349 'src/binfmt/binfmt.c',
3350 include_directories : includes,
3351 link_with : [libshared],
3352 dependencies : [versiondep],
3353 install_rpath : rootpkglibdir,
3355 install_dir : rootlibexecdir)
3357 meson.add_install_script('sh', '-c',
3358 mkdir_p.format(binfmtdir))
3359 if install_sysconfdir
3360 meson.add_install_script('sh', '-c',
3361 mkdir_p.format(sysconfdir / 'binfmt.d'))
3365 if conf.get('ENABLE_SYSUPDATE') == 1
3367 'systemd-sysupdate',
3368 systemd_sysupdate_sources,
3369 include_directories : includes,
3370 link_with : [libshared,
3372 dependencies : [threads,
3377 install_rpath : rootpkglibdir,
3379 install_dir : rootlibexecdir)
3380 public_programs += exe
3383 if conf.get('ENABLE_VCONSOLE') == 1
3385 'systemd-vconsole-setup',
3386 'src/vconsole/vconsole-setup.c',
3387 include_directories : includes,
3388 link_with : [libshared],
3389 install_rpath : rootpkglibdir,
3391 install_dir : rootlibexecdir)
3394 if conf.get('ENABLE_RANDOMSEED') == 1
3396 'systemd-random-seed',
3397 'src/random-seed/random-seed.c',
3398 include_directories : includes,
3399 link_with : [libshared],
3400 dependencies : [versiondep],
3401 install_rpath : rootpkglibdir,
3403 install_dir : rootlibexecdir)
3406 if conf.get('ENABLE_FIRSTBOOT') == 1
3407 public_programs += executable(
3408 'systemd-firstboot',
3409 'src/firstboot/firstboot.c',
3410 include_directories : includes,
3411 link_with : [libshared],
3412 dependencies : [libcrypt,
3414 install_rpath : rootpkglibdir,
3416 install_dir : rootbindir)
3420 'systemd-remount-fs',
3421 'src/remount-fs/remount-fs.c',
3422 include_directories : includes,
3423 link_with : [libshared],
3424 dependencies : [versiondep],
3425 install_rpath : rootpkglibdir,
3427 install_dir : rootlibexecdir)
3430 'systemd-machine-id-setup',
3431 'src/machine-id-setup/machine-id-setup-main.c',
3432 include_directories : includes,
3433 link_with : [libshared],
3434 dependencies : [versiondep],
3435 install_rpath : rootpkglibdir,
3437 install_dir : rootbindir)
3442 include_directories : includes,
3443 link_with : [libshared],
3444 dependencies : [versiondep],
3445 install_rpath : rootpkglibdir,
3447 install_dir : rootlibexecdir)
3451 'src/partition/growfs.c',
3452 include_directories : includes,
3453 link_with : [libshared],
3454 dependencies : [versiondep],
3455 install_rpath : rootpkglibdir,
3457 install_dir : rootlibexecdir)
3461 'src/partition/makefs.c',
3462 include_directories : includes,
3463 link_with : [libshared],
3464 dependencies : [versiondep],
3465 install_rpath : rootpkglibdir,
3467 install_dir : rootlibexecdir)
3471 'src/sleep/sleep.c',
3472 include_directories : includes,
3473 link_with : [libshared],
3474 dependencies : [versiondep],
3475 install_rpath : rootpkglibdir,
3477 install_dir : rootlibexecdir)
3479 if install_sysconfdir_samples
3480 install_data('src/sleep/sleep.conf',
3481 install_dir : pkgsysconfdir)
3484 public_programs += executable(
3486 'src/sysctl/sysctl.c',
3487 include_directories : includes,
3488 link_with : [libshared],
3489 dependencies : [versiondep],
3490 install_rpath : rootpkglibdir,
3492 install_dir : rootlibexecdir)
3494 public_programs += executable(
3496 'src/ac-power/ac-power.c',
3497 include_directories : includes,
3498 link_with : [libshared],
3499 dependencies : [versiondep],
3500 install_rpath : rootpkglibdir,
3503 public_programs += executable(
3504 'systemd-detect-virt',
3505 'src/detect-virt/detect-virt.c',
3506 include_directories : includes,
3507 link_with : [libshared],
3508 dependencies : [versiondep],
3509 install_rpath : rootpkglibdir,
3512 public_programs += executable(
3514 'src/delta/delta.c',
3515 include_directories : includes,
3516 link_with : [libshared],
3517 dependencies : [versiondep],
3518 install_rpath : rootpkglibdir,
3521 public_programs += executable(
3523 'src/escape/escape.c',
3524 include_directories : includes,
3525 link_with : [libshared],
3526 dependencies : [versiondep],
3527 install_rpath : rootpkglibdir,
3529 install_dir : rootbindir)
3531 public_programs += executable(
3533 'src/notify/notify.c',
3534 include_directories : includes,
3535 link_with : [libshared],
3536 dependencies : [versiondep],
3537 install_rpath : rootpkglibdir,
3539 install_dir : rootbindir)
3541 public_programs += executable(
3543 'src/creds/creds.c',
3544 include_directories : includes,
3545 link_with : [libshared],
3546 dependencies : [threads,
3549 install_rpath : rootpkglibdir,
3551 install_dir : rootbindir)
3554 'systemd-volatile-root',
3555 'src/volatile-root/volatile-root.c',
3556 include_directories : includes,
3557 link_with : [libshared],
3558 install_rpath : rootpkglibdir,
3559 install : conf.get('ENABLE_INITRD') == 1,
3560 install_dir : rootlibexecdir)
3563 'systemd-cgroups-agent',
3564 'src/cgroups-agent/cgroups-agent.c',
3565 include_directories : includes,
3566 link_with : [libshared],
3567 install_rpath : rootpkglibdir,
3569 install_dir : rootlibexecdir)
3571 systemd_id128 = executable(
3573 'src/id128/id128.c',
3574 include_directories : includes,
3575 link_with : [libshared],
3576 dependencies : [versiondep],
3577 install_rpath : rootpkglibdir,
3579 public_programs += systemd_id128
3581 if want_tests != 'false'
3582 test('test-systemctl-enable',
3583 test_systemctl_enable_sh,
3584 # https://github.com/mesonbuild/meson/issues/2681
3585 args : [systemctl.full_path(),
3586 systemd_id128.full_path()])
3589 public_programs += executable(
3592 include_directories : includes,
3593 link_with : [libshared],
3594 dependencies : [versiondep],
3595 install_rpath : rootpkglibdir,
3598 public_programs += executable(
3599 'systemd-ask-password',
3600 'src/ask-password/ask-password.c',
3601 include_directories : includes,
3602 link_with : [libshared],
3603 dependencies : [versiondep],
3604 install_rpath : rootpkglibdir,
3606 install_dir : rootbindir)
3609 'systemd-reply-password',
3610 'src/reply-password/reply-password.c',
3611 include_directories : includes,
3612 link_with : [libshared],
3613 install_rpath : rootpkglibdir,
3615 install_dir : rootlibexecdir)
3617 public_programs += executable(
3618 'systemd-tty-ask-password-agent',
3619 'src/tty-ask-password-agent/tty-ask-password-agent.c',
3620 include_directories : includes,
3621 link_with : [libshared],
3622 dependencies : [versiondep],
3623 install_rpath : rootpkglibdir,
3625 install_dir : rootbindir)
3627 public_programs += executable(
3630 include_directories : includes,
3631 link_with : [libshared],
3632 dependencies : [versiondep],
3633 install_rpath : rootpkglibdir,
3636 public_programs += executable(
3638 'src/cgtop/cgtop.c',
3639 include_directories : includes,
3640 link_with : [libshared],
3641 dependencies : [versiondep],
3642 install_rpath : rootpkglibdir,
3647 'src/initctl/initctl.c',
3648 include_directories : includes,
3649 link_with : [libshared],
3650 install_rpath : rootpkglibdir,
3651 install : (conf.get('HAVE_SYSV_COMPAT') == 1),
3652 install_dir : rootlibexecdir)
3654 public_programs += executable(
3656 'src/mount/mount-tool.c',
3657 include_directories : includes,
3658 link_with : [libshared],
3659 dependencies: [libmount,
3661 install_rpath : rootpkglibdir,
3664 meson.add_install_script(meson_make_symlink,
3665 'systemd-mount', bindir / 'systemd-umount')
3667 public_programs += executable(
3670 include_directories : includes,
3671 link_with : [libshared],
3672 dependencies : [versiondep],
3673 install_rpath : rootpkglibdir,
3676 public_programs += executable(
3677 'systemd-stdio-bridge',
3678 'src/stdio-bridge/stdio-bridge.c',
3679 include_directories : includes,
3680 link_with : [libshared],
3681 dependencies : [versiondep,
3683 install_rpath : rootpkglibdir,
3686 public_programs += executable(
3689 include_directories : includes,
3690 link_with : [libshared],
3691 dependencies : [versiondep],
3692 install_rpath : rootpkglibdir,
3698 'src/sysusers/sysusers.c',
3699 include_directories : includes,
3700 link_with : [libshared],
3701 dependencies : [versiondep],
3702 install_rpath : rootpkglibdir,
3704 install_dir : rootbindir)
3705 public_programs += exe
3707 if want_tests != 'false'
3708 test('test-sysusers',
3710 # https://github.com/mesonbuild/meson/issues/2681
3711 args : exe.full_path())
3714 if have_standalone_binaries
3716 'systemd-sysusers.standalone',
3717 'src/sysusers/sysusers.c',
3718 include_directories : includes,
3719 c_args : '-DSTANDALONE',
3720 link_with : [libshared_static,
3724 dependencies : [versiondep],
3726 install_dir : rootbindir)
3727 public_programs += exe
3729 if want_tests != 'false'
3730 test('test-sysusers.standalone',
3732 # https://github.com/mesonbuild/meson/issues/2681
3733 args : exe.full_path())
3738 if conf.get('ENABLE_TMPFILES') == 1
3741 systemd_tmpfiles_sources,
3742 include_directories : includes,
3743 link_with : [libshared],
3744 dependencies : [libacl,
3746 install_rpath : rootpkglibdir,
3748 install_dir : rootbindir)
3749 public_programs += exe
3751 if want_tests != 'false'
3752 test('test-systemd-tmpfiles',
3753 test_systemd_tmpfiles_py,
3754 # https://github.com/mesonbuild/meson/issues/2681
3755 args : exe.full_path())
3758 if have_standalone_binaries
3760 'systemd-tmpfiles.standalone',
3761 systemd_tmpfiles_sources,
3762 include_directories : includes,
3763 c_args : '-DSTANDALONE',
3764 link_with : [libshared_static,
3768 dependencies : [libacl,
3771 install_dir : rootbindir)
3772 public_programs += exe
3774 if want_tests != 'false'
3775 test('test-systemd-tmpfiles.standalone',
3776 test_systemd_tmpfiles_py,
3777 # https://github.com/mesonbuild/meson/issues/2681
3778 args : exe.full_path())
3783 if conf.get('ENABLE_HWDB') == 1
3784 systemd_hwdb = executable(
3787 include_directories : includes,
3788 link_with : udev_link_with,
3789 dependencies : [versiondep],
3790 install_rpath : udev_rpath,
3792 install_dir : rootbindir)
3793 public_programs += systemd_hwdb
3795 if want_tests != 'false'
3798 suite : 'dist-check',
3799 args : [systemd_hwdb.full_path()],
3804 if conf.get('ENABLE_QUOTACHECK') == 1
3806 'systemd-quotacheck',
3807 'src/quotacheck/quotacheck.c',
3808 include_directories : includes,
3809 link_with : [libshared],
3810 install_rpath : rootpkglibdir,
3812 install_dir : rootlibexecdir)
3815 public_programs += executable(
3816 'systemd-socket-proxyd',
3817 'src/socket-proxy/socket-proxyd.c',
3818 include_directories : includes,
3819 link_with : [libshared],
3820 dependencies : [threads,
3822 install_rpath : rootpkglibdir,
3824 install_dir : rootlibexecdir)
3826 udevadm = executable(
3829 include_directories : includes,
3830 link_with : [libudevd_core],
3831 dependencies : [threads,
3837 install_rpath : udev_rpath,
3839 install_dir : rootbindir)
3840 public_programs += udevadm
3842 if conf.get('ENABLE_REPART') == 1
3845 systemd_repart_sources,
3846 include_directories : includes,
3847 link_with : [libshared,
3849 dependencies : [threads,
3854 install_rpath : rootpkglibdir,
3856 install_dir : rootbindir)
3857 public_programs += exe
3859 if have_standalone_binaries
3861 'systemd-repart.standalone',
3862 systemd_repart_sources,
3863 include_directories : includes,
3864 c_args : '-DSTANDALONE',
3865 link_with : [libshared_static,
3870 dependencies : [threads,
3875 install_rpath : rootpkglibdir,
3877 install_dir : rootbindir)
3878 public_programs += exe
3884 systemd_shutdown_sources,
3885 include_directories : includes,
3886 link_with : [libshared],
3887 dependencies : [libmount,
3889 install_rpath : rootpkglibdir,
3891 install_dir : rootlibexecdir)
3893 if have_standalone_binaries
3895 'systemd-shutdown.standalone',
3896 systemd_shutdown_sources,
3897 include_directories : includes,
3898 c_args : '-DSTANDALONE',
3899 link_with : [libshared_static,
3902 dependencies : [libmount,
3904 install_rpath : rootpkglibdir,
3906 install_dir : rootlibexecdir)
3910 'systemd-update-done',
3911 'src/update-done/update-done.c',
3912 include_directories : includes,
3913 link_with : [libshared],
3914 dependencies : [versiondep],
3915 install_rpath : rootpkglibdir,
3917 install_dir : rootlibexecdir)
3920 'systemd-update-utmp',
3921 'src/update-utmp/update-utmp.c',
3922 include_directories : includes,
3923 link_with : [libshared],
3924 dependencies : [libaudit,
3926 install_rpath : rootpkglibdir,
3927 install : (conf.get('ENABLE_UTMP') == 1),
3928 install_dir : rootlibexecdir)
3930 if conf.get('HAVE_KMOD') == 1
3932 'systemd-modules-load',
3933 'src/modules-load/modules-load.c',
3934 include_directories : includes,
3935 link_with : [libshared],
3936 dependencies : [libkmod,
3938 install_rpath : rootpkglibdir,
3940 install_dir : rootlibexecdir)
3942 meson.add_install_script('sh', '-c',
3943 mkdir_p.format(modulesloaddir))
3944 if install_sysconfdir
3945 meson.add_install_script('sh', '-c',
3946 mkdir_p.format(sysconfdir / 'modules-load.d'))
3950 public_programs += executable(
3952 systemd_nspawn_sources,
3953 include_directories : includes,
3954 link_with : [libnspawn_core,
3956 dependencies : [libblkid,
3959 install_rpath : rootpkglibdir,
3962 if conf.get('ENABLE_NETWORKD') == 1
3963 dbus_programs += executable(
3965 systemd_networkd_sources,
3966 include_directories : network_includes,
3967 link_with : [libnetworkd_core,
3969 networkd_link_with],
3970 dependencies : [threads,
3972 install_rpath : rootpkglibdir,
3974 install_dir : rootlibexecdir)
3976 public_programs += executable(
3977 'systemd-networkd-wait-online',
3978 systemd_networkd_wait_online_sources,
3979 include_directories : includes,
3980 link_with : [networkd_link_with],
3981 dependencies : [versiondep],
3982 install_rpath : rootpkglibdir,
3984 install_dir : rootlibexecdir)
3986 public_programs += executable(
3989 include_directories : libsystemd_network_includes,
3990 link_with : [libsystemd_network,
3991 networkd_link_with],
3992 dependencies : [versiondep],
3993 install_rpath : rootpkglibdir,
3995 install_dir : rootbindir)
3999 'systemd-network-generator',
4000 network_generator_sources,
4001 include_directories : includes,
4002 link_with : [networkd_link_with],
4003 dependencies : [versiondep],
4004 install_rpath : rootpkglibdir,
4006 install_dir : rootlibexecdir)
4008 if want_tests != 'false'
4009 test('test-network-generator-conversion',
4010 test_network_generator_conversion_sh,
4011 # https://github.com/mesonbuild/meson/issues/2681
4012 args : exe.full_path(),
4017 'systemd-sulogin-shell',
4018 'src/sulogin-shell/sulogin-shell.c',
4019 include_directories : includes,
4020 link_with : [libshared],
4021 dependencies : [versiondep],
4022 install_rpath : rootpkglibdir,
4024 install_dir : rootlibexecdir)
4026 exe = custom_target(
4028 input : kernel_install_in,
4029 output : 'kernel-install',
4030 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
4031 install : want_kernel_install,
4032 install_mode : 'rwxr-xr-x',
4033 install_dir : bindir)
4034 public_programs += exe
4036 if want_tests != 'false' and want_kernel_install
4037 test('test-kernel-install',
4038 test_kernel_install_sh,
4040 args : [exe.full_path(), loaderentry_install])
4044 exe = custom_target(
4046 input : 'src/ukify/ukify.py',
4048 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
4050 install_mode : 'rwxr-xr-x',
4051 install_dir : rootlibexecdir)
4052 public_programs += exe
4055 ############################################################
4057 runtest_env = custom_target(
4058 'systemd-runtest.env',
4059 output : 'systemd-runtest.env',
4060 command : [sh, '-c',
4061 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
4062 project_source_root / 'test',
4063 project_build_root / 'catalog')],
4065 build_by_default : true)
4067 test_cflags = ['-DTEST_CODE=1']
4068 # We intentionally do not do inline initializations with definitions for a
4069 # bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
4070 # use the variable unexpectedly. This triggers a lot of maybe-uninitialized
4071 # false positives when the combination of -O2 and -flto is used. Suppress them.
4072 if '-O2' in c_args and '-flto=auto' in c_args
4073 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
4076 foreach tuple : tests
4078 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
4079 dependencies = tuple.length() > 2 ? tuple[2] : []
4080 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
4081 condition = tuple.length() > 4 ? tuple[4] : ''
4082 type = tuple.length() > 5 ? tuple[5] : ''
4083 defs = tuple.length() > 6 ? tuple[6] : []
4085 parallel = tuple.length() > 7 ? tuple[7] : true
4088 # FIXME: Use fs.stem() with meson >= 0.54.0
4089 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
4090 if type.startswith('timeout=')
4091 timeout = type.split('=')[1].to_int()
4095 suite = fs.name(fs.parent('@0@'.format(sources[0])))
4096 # FIXME: Use str.replace() with meson >= 0.58.0
4097 suite = suite.split('sd-')[-1]
4099 if condition == '' or conf.get(condition) == 1
4103 include_directories : incs,
4104 link_with : link_with,
4105 dependencies : [versiondep,
4108 build_by_default : want_tests != 'false',
4109 install_rpath : rootpkglibdir,
4110 install : install_tests,
4111 install_dir : testsdir / type,
4112 link_depends : runtest_env)
4115 message('@0@ is a manual test'.format(name))
4116 elif type == 'unsafe' and want_tests != 'unsafe'
4117 message('@0@ is an unsafe test'.format(name))
4118 elif want_tests != 'false'
4123 is_parallel : parallel)
4126 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
4131 'test-libsystemd-sym',
4132 test_libsystemd_sym_c,
4133 include_directories : includes,
4134 link_with : [libsystemd],
4135 build_by_default : want_tests != 'false',
4136 install : install_tests,
4137 install_dir : testsdir)
4138 if want_tests != 'false'
4139 test('test-libsystemd-sym', exe)
4143 'test-libsystemd-static-sym',
4144 test_libsystemd_sym_c,
4145 include_directories : includes,
4146 link_with : [install_libsystemd_static],
4147 dependencies : [threads], # threads is already included in dependencies on the library,
4148 # but does not seem to get propagated. Add here as a work-around.
4149 build_by_default : want_tests != 'false' and static_libsystemd_pic,
4150 install : install_tests and static_libsystemd_pic,
4151 install_dir : testsdir)
4152 if want_tests != 'false' and static_libsystemd_pic
4153 test('test-libsystemd-static-sym', exe)
4159 include_directories : libudev_includes,
4160 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
4161 link_with : [libudev],
4162 build_by_default : want_tests != 'false',
4163 install : install_tests,
4164 install_dir : testsdir)
4165 if want_tests != 'false'
4166 test('test-libudev-sym', exe)
4170 'test-libudev-static-sym',
4172 include_directories : libudev_includes,
4173 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
4174 link_with : [install_libudev_static],
4175 build_by_default : want_tests != 'false' and static_libudev_pic,
4176 install : install_tests and static_libudev_pic,
4177 install_dir : testsdir)
4178 if want_tests != 'false' and static_libudev_pic
4179 test('test-libudev-static-sym', exe)
4182 ############################################################
4186 foreach tuple : fuzzers
4188 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
4189 dependencies = tuple.length() > 2 ? tuple[2] : []
4190 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
4191 defs = tuple.length() > 4 ? tuple[4] : []
4195 dependencies += fuzzing_engine
4197 if fuzzing_engine.found()
4198 dependencies += fuzzing_engine
4200 link_args += ['-fsanitize=fuzzer']
4203 sources += 'src/fuzz/fuzz-main.c'
4205 sources += fuzz_generated_directives
4207 # FIXME: Use fs.stem() with meson >= 0.54.0
4208 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
4213 include_directories : [incs, include_directories('src/fuzz')],
4214 link_with : link_with,
4215 dependencies : [dependencies,
4217 c_args : defs + test_cflags,
4218 link_args: link_args,
4220 build_by_default : fuzzer_build)
4223 if want_tests != 'false' and name in fuzz_regression_tests
4224 # Run the fuzz regression tests without any sanitizers enabled.
4225 # Additional invocations with sanitizers may be added below.
4226 foreach tuple : fuzz_regression_tests[name]
4229 test('@0@_@1@'.format(name, fuzz_in),
4232 args : [fuzz_dir != '' ? project_source_root / fuzz_dir / name / fuzz_in
4233 : fuzz_generated_in_dir / '@0@_@1@'.format(name, fuzz_in)])
4238 alias_target('fuzzers', fuzzer_exes)
4240 ############################################################
4242 subdir('docs/sysvinit')
4243 subdir('docs/var-log')
4246 subdir('modprobe.d')
4249 subdir('shell-completion/bash')
4250 subdir('shell-completion/zsh')
4252 subdir('sysusers.d')
4253 subdir('tmpfiles.d')
4256 install_subdir('factory/etc',
4257 install_dir : factorydir)
4258 subdir('factory/templates')
4260 if install_sysconfdir
4261 install_data('xorg/50-systemd-user.sh',
4262 install_dir : xinitrcdir)
4264 install_data('LICENSE.GPL2',
4268 'docs/CODING_STYLE.md',
4269 'docs/DISTRO_PORTING.md',
4270 'docs/ENVIRONMENT.md',
4272 'docs/TRANSIENT-SETTINGS.md',
4273 'docs/TRANSLATORS.md',
4274 'docs/UIDS-GIDS.md',
4275 install_dir : docdir)
4277 install_subdir('LICENSES',
4278 install_dir : docdir)
4280 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
4281 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
4283 ############################################################
4285 # Ensure that changes to the docs/ directory do not break the
4286 # basic Github pages build. But only run it in developer mode,
4287 # as it might be fragile due to changes in the tooling, and it is
4288 # not generally useful for users.
4289 jekyll = find_program('jekyll', required : false)
4290 if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
4291 test('github-pages',
4293 suite : 'dist-check',
4295 '--source', project_source_root / 'docs',
4296 '--destination', project_build_root / '_site'])
4299 ############################################################
4301 check_help = find_program('tools/check-help.sh')
4302 check_version = find_program('tools/check-version.sh')
4304 foreach exec : public_programs
4305 name = exec.full_path().split('/')[-1]
4306 if want_tests != 'false'
4307 test('check-help-' + name,
4309 suite : 'dist-check',
4310 args : exec.full_path(),
4313 test('check-version-' + name,
4315 suite : 'dist-check',
4316 args : [exec.full_path(),
4317 meson.project_version()],
4322 # Enable tests for all supported sanitizers
4323 foreach tuple : fuzz_sanitizers
4324 sanitizer = tuple[0]
4327 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
4328 foreach fuzzer, fuzz_ins : fuzz_regression_tests
4329 name = '@0@:@1@'.format(fuzzer, sanitizer)
4330 if want_tests == 'false'
4331 message('Not compiling @0@ because tests is set to false'.format(name))
4335 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
4338 exe = custom_target(
4341 depends : [build] + fuzz_generated_directives,
4342 command : [ln, '-fs',
4343 build.full_path() / fuzzer,
4345 build_by_default : true)
4347 foreach tuple : fuzz_ins
4351 test('@0@_@1@_@2@'.format(fuzzer, fuzz_in, sanitizer),
4354 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
4356 args : [exe.full_path(),
4357 fuzz_dir != '' ? project_source_root / fuzz_dir / fuzzer / fuzz_in
4358 : fuzz_generated_in_dir / '@0@_@1@'.format(fuzzer, fuzz_in)])
4365 ############################################################
4368 all_files = run_command(
4369 env, '-u', 'GIT_WORK_TREE',
4370 git, '--git-dir=@0@/.git'.format(project_source_root),
4371 'ls-files', ':/*.[ch]',
4373 if all_files.returncode() == 0
4374 all_files = files(all_files.stdout().split())
4379 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
4382 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
4387 git_contrib_sh = find_program('tools/git-contrib.sh')
4390 command : [git_contrib_sh])
4394 git_head = run_command(
4395 git, '--git-dir=@0@/.git'.format(project_source_root),
4396 'rev-parse', 'HEAD',
4397 check : false).stdout().strip()
4398 git_head_short = run_command(
4399 git, '--git-dir=@0@/.git'.format(project_source_root),
4400 'rev-parse', '--short=7', 'HEAD',
4401 check : false).stdout().strip()
4405 command : [git, 'archive',
4406 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
4408 '--prefix', 'systemd-@0@/'.format(git_head),
4412 ############################################################
4414 check_api_docs_sh = find_program('tools/check-api-docs.sh')
4417 depends : [man, libsystemd, libudev],
4418 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
4420 alias_target('update-dbus-docs', update_dbus_docs)
4421 alias_target('update-man-rules', update_man_rules)
4423 if not meson.is_cross_build()
4425 'export-dbus-interfaces',
4426 output : fs.name(dbus_interfaces_dir),
4427 install : dbus_interfaces_dir != 'no',
4428 install_dir : fs.parent(dbus_interfaces_dir),
4429 command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
4432 ############################################################
4434 alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
4435 check : true).stdout().strip()
4438 'split /usr' : split_usr,
4439 'split bin-sbin' : split_bin,
4440 'prefix directory' : prefixdir,
4441 'rootprefix directory' : rootprefixdir,
4442 'sysconf directory' : sysconfdir,
4443 'include directory' : includedir,
4444 'lib directory' : libdir,
4445 'rootlib directory' : rootlibdir,
4446 'SysV init scripts' : sysvinit_path,
4447 'SysV rc?.d directories' : sysvrcnd_path,
4448 'PAM modules directory' : pamlibdir,
4449 'PAM configuration directory' : pamconfdir,
4450 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
4451 'RPM macros directory' : rpmmacrosdir,
4452 'modprobe.d directory' : modprobedir,
4453 'D-Bus policy directory' : dbuspolicydir,
4454 'D-Bus session directory' : dbussessionservicedir,
4455 'D-Bus system directory' : dbussystemservicedir,
4456 'D-Bus interfaces directory' : dbus_interfaces_dir,
4457 'bash completions directory' : bashcompletiondir,
4458 'zsh completions directory' : zshcompletiondir,
4459 'private shared lib version tag' : shared_lib_tag,
4460 'extra start script' : get_option('rc-local'),
4461 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
4462 get_option('debug-tty')),
4463 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
4464 conf.get('SYSTEM_ALLOC_UID_MIN')),
4465 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
4466 conf.get('SYSTEM_ALLOC_GID_MIN')),
4467 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
4468 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
4469 'static UID/GID allocations' : ' '.join(static_ugids),
4470 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
4471 'render group access mode' : get_option('group-render-mode'),
4472 'certificate root directory' : get_option('certificate-root'),
4473 'support URL' : support_url,
4474 'nobody user name' : nobody_user,
4475 'nobody group name' : nobody_group,
4476 'fallback hostname' : get_option('fallback-hostname'),
4477 'default compression method' : compression,
4478 'default DNSSEC mode' : default_dnssec,
4479 'default DNS-over-TLS mode' : default_dns_over_tls,
4480 'default mDNS mode' : default_mdns,
4481 'default LLMNR mode' : default_llmnr,
4482 'default DNS servers' : dns_servers.split(' '),
4483 'default NTP servers' : ntp_servers.split(' '),
4484 'default cgroup hierarchy' : default_hierarchy,
4485 'default net.naming-scheme value' : default_net_naming_scheme,
4486 'default KillUserProcesses value' : kill_user_processes,
4487 'default locale' : default_locale,
4488 'default nspawn locale' : nspawn_locale,
4489 'default status unit format' : status_unit_format_default,
4490 'default user $PATH' :
4491 default_user_path != '' ? default_user_path : '(same as system services)',
4492 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
4493 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
4496 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
4497 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
4498 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
4519 ['libcryptsetup-plugins'],
4545 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
4575 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
4589 ['legacy-pkla', install_polkit_pkla],
4595 ['man pages', want_man],
4596 ['html pages', want_html],
4597 ['man page indices', want_man and have_lxml],
4599 ['compat-mutable-uid-boundaries'],
4602 ['adm group', get_option('adm-group')],
4603 ['wheel group', get_option('wheel-group')],
4606 ['debug mmap cache'],
4608 ['valgrind', conf.get('VALGRIND') == 1],
4609 ['trace logging', conf.get('LOG_TRACE') == 1],
4610 ['install tests', install_tests],
4611 ['link-udev-shared', get_option('link-udev-shared')],
4612 ['link-systemctl-shared', get_option('link-systemctl-shared')],
4613 ['link-networkd-shared', get_option('link-networkd-shared')],
4614 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
4615 ['link-journalctl-shared', get_option('link-journalctl-shared')],
4616 ['link-boot-shared', get_option('link-boot-shared')],
4617 ['first-boot-full-preset'],
4619 ['standalone-binaries', get_option('standalone-binaries')],
4620 ['coverage', get_option('b_coverage')],
4623 if tuple.length() >= 2
4626 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
4627 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
4628 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
4637 if static_libsystemd == 'false'
4638 missing += 'static-libsystemd'
4640 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
4643 if static_libudev == 'false'
4644 missing += 'static-libudev'
4646 found += 'static-libudev(@0@)'.format(static_libudev)
4649 if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
4650 found += 'cryptolib(openssl)'
4651 elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
4652 found += 'cryptolib(gcrypt)'
4654 missing += 'cryptolib'
4657 if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
4658 found += 'DNS-over-TLS(gnutls)'
4659 elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
4660 found += 'DNS-over-TLS(openssl)'
4662 missing += 'DNS-over-TLS'
4666 'enabled' : ', '.join(found),
4667 'disabled' : ', '.join(missing)},
4668 section : 'Features')
4670 if rootprefixdir != rootprefix_default
4672 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
4673 'systemd used fixed names for unit file directories and other paths, so anything\n' +
4674 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))