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 default_keymap = get_option('default-keymap')
989 conf.set_quoted('SYSTEMD_DEFAULT_KEYMAP', default_keymap)
991 localegen_path = get_option('localegen-path')
992 if localegen_path != ''
993 conf.set_quoted('LOCALEGEN_PATH', localegen_path)
995 conf.set10('HAVE_LOCALEGEN', localegen_path != '')
997 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
999 service_watchdog = get_option('service-watchdog')
1000 watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
1001 conf.set_quoted('SERVICE_WATCHDOG', watchdog_value)
1003 conf.set_quoted('SUSHELL', get_option('debug-shell'))
1004 conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
1006 enable_debug_hashmap = false
1007 enable_debug_mmap_cache = false
1008 enable_debug_siphash = false
1009 foreach name : get_option('debug-extra')
1010 if name == 'hashmap'
1011 enable_debug_hashmap = true
1012 elif name == 'mmap-cache'
1013 enable_debug_mmap_cache = true
1014 elif name == 'siphash'
1015 enable_debug_siphash = true
1017 message('unknown debug option "@0@", ignoring'.format(name))
1020 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
1021 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
1022 conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash)
1024 conf.set10('VALGRIND', get_option('valgrind'))
1025 conf.set10('LOG_TRACE', get_option('log-trace'))
1027 default_user_path = get_option('user-path')
1028 if default_user_path != ''
1029 conf.set_quoted('DEFAULT_USER_PATH', default_user_path)
1033 #####################################################################
1035 threads = dependency('threads')
1036 librt = cc.find_library('rt')
1037 libm = cc.find_library('m')
1038 libdl = cc.find_library('dl')
1039 libcrypt = cc.find_library('crypt')
1041 # On some architectures, libatomic is required. But on some installations,
1042 # it is found, but actual linking fails. So let's try to use it opportunistically.
1043 # If it is installed, but not needed, it will be dropped because of --as-needed.
1044 if cc.links('''int main(int argc, char **argv) { return 0; }''',
1047 libatomic = declare_dependency(link_args : '-latomic')
1052 crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
1054 ['crypt_ra', crypt_header],
1055 ['crypt_preferred_method', crypt_header],
1056 ['crypt_gensalt_ra', crypt_header]]
1058 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
1059 dependencies : libcrypt)
1060 conf.set10('HAVE_' + ident[0].to_upper(), have)
1063 libcap = dependency('libcap', required : false)
1064 if not libcap.found()
1065 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
1066 libcap = cc.find_library('cap')
1069 want_bpf_framework = get_option('bpf-framework')
1070 bpf_compiler = get_option('bpf-compiler')
1071 bpf_framework_required = want_bpf_framework == 'true'
1073 libbpf_version_requirement = '>= 0.1.0'
1074 if bpf_compiler == 'gcc'
1075 libbpf_version_requirement = '>= 1.0.0'
1077 libbpf = dependency('libbpf', required : bpf_framework_required, version : libbpf_version_requirement)
1078 conf.set10('HAVE_LIBBPF', libbpf.found())
1080 bpftool_strip_version_requirement = '>= 5.13.0'
1081 if bpf_compiler == 'gcc'
1082 bpftool_strip_version_requirement = '>= 7.0.0'
1085 if want_bpf_framework == 'false' or not libbpf.found() or skip_deps
1086 conf.set10('BPF_FRAMEWORK', false)
1089 clang_supports_bpf = false
1090 bpf_gcc_found = false
1091 bpftool_strip = false
1094 if bpf_compiler == 'clang'
1095 # Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu
1096 # (like clang-10/llvm-strip-10)
1097 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')
1098 r = find_program('clang', required : bpf_framework_required, version : '>= 10.0.0')
1099 clang_found = r.found()
1105 clang = cc.cmd_array()
1109 # Check if 'clang -target bpf' is supported.
1110 clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0
1112 elif bpf_compiler == 'gcc'
1113 warning('GCC BPF Compiler support is experimental and not recommended.')
1114 bpf_gcc = find_program('bpf-gcc',
1116 version : '>= 12.1.0')
1117 bpf_gcc_found = bpf_gcc.found()
1120 if clang_supports_bpf or bpf_gcc_found
1121 # Debian installs this in /usr/sbin/ which is not in $PATH.
1122 # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian.
1123 # We use 'bpftool gen object' subcommand for bpftool strip, it was added by d80b2fcbe0a023619e0fc73112f2a02c2662f6ab (v5.13).
1124 bpftool_strip_required = bpf_framework_required and bpf_compiler == 'gcc'
1125 bpftool = find_program('bpftool',
1126 '/usr/sbin/bpftool',
1127 required : bpftool_strip_required,
1128 version : bpftool_strip_version_requirement)
1131 bpftool_strip = true
1133 elif bpf_compiler == 'clang'
1134 # We require the 'bpftool gen skeleton' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6).
1135 bpftool = find_program('bpftool',
1136 '/usr/sbin/bpftool',
1137 required : bpf_framework_required,
1138 version : '>= 5.6.0')
1141 # We use `llvm-strip` as a fallback if `bpftool gen object` strip support is not available.
1142 if not bpftool_strip and bpftool.found() and clang_supports_bpf
1143 if not meson.is_cross_build()
1144 llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip',
1145 check : true).stdout().strip()
1147 llvm_strip_bin = 'llvm-strip'
1149 llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0')
1150 deps_found = llvm_strip.found()
1154 # Can build BPF program from source code in restricted C
1155 conf.set10('BPF_FRAMEWORK', deps_found)
1158 libmount = dependency('mount',
1159 version : fuzzer_build ? '>= 0' : '>= 2.30')
1161 want_libfdisk = get_option('fdisk')
1162 if want_libfdisk != 'false' and not skip_deps
1163 libfdisk = dependency('fdisk',
1164 version : '>= 2.32',
1165 required : want_libfdisk == 'true')
1166 have = libfdisk.found()
1171 conf.set10('HAVE_LIBFDISK', have)
1173 want_pwquality = get_option('pwquality')
1174 if want_pwquality != 'false' and not skip_deps
1175 libpwquality = dependency('pwquality', required : want_pwquality == 'true')
1176 have = libpwquality.found()
1181 conf.set10('HAVE_PWQUALITY', have)
1183 want_seccomp = get_option('seccomp')
1184 if want_seccomp != 'false' and not skip_deps
1185 libseccomp = dependency('libseccomp',
1186 version : '>= 2.3.1',
1187 required : want_seccomp == 'true')
1188 have = libseccomp.found()
1193 conf.set10('HAVE_SECCOMP', have)
1195 want_selinux = get_option('selinux')
1196 if want_selinux != 'false' and not skip_deps
1197 libselinux = dependency('libselinux',
1198 version : '>= 2.1.9',
1199 required : want_selinux == 'true')
1200 have = libselinux.found()
1205 conf.set10('HAVE_SELINUX', have)
1207 want_apparmor = get_option('apparmor')
1208 if want_apparmor != 'false' and not skip_deps
1209 libapparmor = dependency('libapparmor',
1210 version : '>= 2.13',
1211 required : want_apparmor == 'true')
1212 have = libapparmor.found()
1217 conf.set10('HAVE_APPARMOR', have)
1219 have = get_option('smack') and get_option('smack-run-label') != ''
1220 conf.set10('HAVE_SMACK_RUN_LABEL', have)
1222 conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
1225 have = get_option('smack') and get_option('smack-default-process-label') != ''
1227 conf.set_quoted('SMACK_DEFAULT_PROCESS_LABEL', get_option('smack-default-process-label'))
1230 want_polkit = get_option('polkit')
1231 install_polkit = false
1232 install_polkit_pkla = false
1233 if want_polkit != 'false' and not skip_deps
1234 install_polkit = true
1236 libpolkit = dependency('polkit-gobject-1',
1238 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
1239 message('Old polkit detected, will install pkla files')
1240 install_polkit_pkla = true
1243 conf.set10('ENABLE_POLKIT', install_polkit)
1245 want_acl = get_option('acl')
1246 if want_acl != 'false' and not skip_deps
1247 libacl = cc.find_library('acl', required : want_acl == 'true')
1248 have = libacl.found()
1253 conf.set10('HAVE_ACL', have)
1255 want_audit = get_option('audit')
1256 if want_audit != 'false' and not skip_deps
1257 libaudit = dependency('audit', required : want_audit == 'true')
1258 have = libaudit.found()
1263 conf.set10('HAVE_AUDIT', have)
1265 want_blkid = get_option('blkid')
1266 if want_blkid != 'false' and not skip_deps
1267 libblkid = dependency('blkid', required : want_blkid == 'true')
1268 have = libblkid.found()
1270 conf.set10('HAVE_BLKID_PROBE_SET_HINT',
1271 have and cc.has_function('blkid_probe_set_hint', dependencies : libblkid))
1276 conf.set10('HAVE_BLKID', have)
1278 want_kmod = get_option('kmod')
1279 if want_kmod != 'false' and not skip_deps
1280 libkmod = dependency('libkmod',
1282 required : want_kmod == 'true')
1283 have = libkmod.found()
1288 conf.set10('HAVE_KMOD', have)
1290 want_xenctrl = get_option('xenctrl')
1291 if want_xenctrl != 'false' and not skip_deps
1292 libxenctrl = dependency('xencontrol',
1294 required : want_xenctrl == 'true')
1295 have = libxenctrl.found()
1300 conf.set10('HAVE_XENCTRL', have)
1302 want_pam = get_option('pam')
1303 if want_pam != 'false' and not skip_deps
1304 libpam = cc.find_library('pam', required : want_pam == 'true')
1305 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1306 have = libpam.found() and libpam_misc.found()
1312 conf.set10('HAVE_PAM', have)
1314 want_microhttpd = get_option('microhttpd')
1315 if want_microhttpd != 'false' and not skip_deps
1316 libmicrohttpd = dependency('libmicrohttpd',
1317 version : '>= 0.9.33',
1318 required : want_microhttpd == 'true')
1319 have = libmicrohttpd.found()
1324 conf.set10('HAVE_MICROHTTPD', have)
1326 want_libcryptsetup = get_option('libcryptsetup')
1327 want_libcryptsetup_plugins = get_option('libcryptsetup-plugins')
1329 if want_libcryptsetup_plugins == 'true' and want_libcryptsetup == 'false'
1330 error('libcryptsetup-plugins can not be requested without libcryptsetup')
1333 if want_libcryptsetup != 'false' and not skip_deps
1334 libcryptsetup = dependency('libcryptsetup',
1335 version : want_libcryptsetup_plugins == 'true' ? '>= 2.4.0' : '>= 2.0.1',
1336 required : want_libcryptsetup == 'true' or want_libcryptsetup_plugins == 'true')
1337 have = libcryptsetup.found()
1339 foreach ident : ['crypt_set_metadata_size',
1340 'crypt_activate_by_signed_key',
1342 'crypt_reencrypt_init_by_passphrase',
1344 'crypt_set_data_offset']
1345 have_ident = have and cc.has_function(
1347 prefix : '#include <libcryptsetup.h>',
1348 dependencies : libcryptsetup)
1349 conf.set10('HAVE_' + ident.to_upper(), have_ident)
1355 conf.set10('HAVE_LIBCRYPTSETUP', have)
1357 if want_libcryptsetup_plugins != 'false' and not skip_deps
1358 have = (cc.has_function(
1359 'crypt_activate_by_token_pin',
1360 prefix : '#include <libcryptsetup.h>',
1361 dependencies : libcryptsetup) and
1363 'crypt_token_external_path',
1364 prefix : '#include <libcryptsetup.h>',
1365 dependencies : libcryptsetup))
1369 conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have)
1371 want_libcurl = get_option('libcurl')
1372 if want_libcurl != 'false' and not skip_deps
1373 libcurl = dependency('libcurl',
1374 version : '>= 7.32.0',
1375 required : want_libcurl == 'true')
1376 have = libcurl.found()
1381 conf.set10('HAVE_LIBCURL', have)
1382 conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
1384 want_libidn = get_option('libidn')
1385 want_libidn2 = get_option('libidn2')
1386 if want_libidn == 'true' and want_libidn2 == 'true'
1387 error('libidn and libidn2 cannot be requested simultaneously')
1390 if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps
1391 libidn = dependency('libidn2',
1392 required : want_libidn2 == 'true')
1393 have = libidn.found()
1398 conf.set10('HAVE_LIBIDN2', have)
1399 if not have and want_libidn != 'false' and not skip_deps
1400 # libidn is used for both libidn and libidn2 objects
1401 libidn = dependency('libidn',
1402 required : want_libidn == 'true')
1403 have = libidn.found()
1407 conf.set10('HAVE_LIBIDN', have)
1409 want_libiptc = get_option('libiptc')
1410 if want_libiptc != 'false' and not skip_deps
1411 libiptc = dependency('libiptc',
1412 required : want_libiptc == 'true')
1413 have = libiptc.found()
1418 conf.set10('HAVE_LIBIPTC', have)
1420 want_qrencode = get_option('qrencode')
1421 if want_qrencode != 'false' and not skip_deps
1422 libqrencode = dependency('libqrencode',
1424 required : want_qrencode == 'true')
1425 have = libqrencode.found()
1430 conf.set10('HAVE_QRENCODE', have)
1432 want_gcrypt = get_option('gcrypt')
1433 if want_gcrypt != 'false' and not skip_deps
1434 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1435 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1436 have = libgcrypt.found() and libgpg_error.found()
1441 # link to neither of the libs if one is not found
1445 conf.set10('HAVE_GCRYPT', have)
1447 want_gnutls = get_option('gnutls')
1448 if want_gnutls != 'false' and not skip_deps
1449 libgnutls = dependency('gnutls',
1450 version : '>= 3.1.4',
1451 required : want_gnutls == 'true')
1452 have = libgnutls.found()
1457 conf.set10('HAVE_GNUTLS', have)
1459 want_openssl = get_option('openssl')
1460 if want_openssl != 'false' and not skip_deps
1461 libopenssl = dependency('openssl',
1462 version : '>= 1.1.0',
1463 required : want_openssl == 'true')
1464 have = libopenssl.found()
1469 conf.set10('HAVE_OPENSSL', have)
1471 want_p11kit = get_option('p11kit')
1472 if want_p11kit != 'false' and not skip_deps
1473 libp11kit = dependency('p11-kit-1',
1474 version : '>= 0.23.3',
1475 required : want_p11kit == 'true')
1476 have = libp11kit.found()
1477 libp11kit_cflags = libp11kit.partial_dependency(includes: true, compile_args: true)
1480 libp11kit_cflags = []
1483 conf.set10('HAVE_P11KIT', have)
1485 want_libfido2 = get_option('libfido2')
1486 if want_libfido2 != 'false' and not skip_deps
1487 if conf.get('HAVE_OPENSSL') == 1
1488 libfido2 = dependency('libfido2',
1489 required : want_libfido2 == 'true')
1490 have = libfido2.found()
1491 elif want_libfido2 == 'true'
1492 error('libfido2=true requires openssl')
1501 conf.set10('HAVE_LIBFIDO2', have)
1503 want_tpm2 = get_option('tpm2')
1504 if want_tpm2 != 'false' and not skip_deps
1505 tpm2 = dependency('tss2-esys tss2-rc tss2-mu',
1506 required : want_tpm2 == 'true')
1508 have_esys3 = tpm2.version().version_compare('>= 3.0.0')
1514 conf.set10('HAVE_TPM2', have)
1515 conf.set10('HAVE_TSS2_ESYS3', have_esys3)
1517 want_elfutils = get_option('elfutils')
1518 if want_elfutils != 'false' and not skip_deps
1519 libdw = dependency('libdw',
1520 required : want_elfutils == 'true')
1521 have = libdw.found()
1523 # New in elfutils 0.177
1524 conf.set10('HAVE_DWELF_ELF_E_MACHINE_STRING',
1525 have and cc.has_function('dwelf_elf_e_machine_string', dependencies : libdw))
1530 conf.set10('HAVE_ELFUTILS', have)
1532 want_zlib = get_option('zlib')
1533 if want_zlib != 'false' and not skip_deps
1534 libz = dependency('zlib',
1535 required : want_zlib == 'true')
1541 conf.set10('HAVE_ZLIB', have)
1543 want_bzip2 = get_option('bzip2')
1544 if want_bzip2 != 'false' and not skip_deps
1545 libbzip2 = cc.find_library('bz2',
1546 required : want_bzip2 == 'true')
1547 have = libbzip2.found()
1552 conf.set10('HAVE_BZIP2', have)
1554 want_xz = get_option('xz')
1555 if want_xz != 'false' and not skip_deps
1556 libxz = dependency('liblzma',
1557 required : want_xz == 'true')
1558 have_xz = libxz.found()
1563 conf.set10('HAVE_XZ', have_xz)
1565 want_lz4 = get_option('lz4')
1566 if want_lz4 != 'false' and not skip_deps
1567 liblz4 = dependency('liblz4',
1568 version : '>= 1.3.0',
1569 required : want_lz4 == 'true')
1570 have_lz4 = liblz4.found()
1575 conf.set10('HAVE_LZ4', have_lz4)
1577 want_zstd = get_option('zstd')
1578 if want_zstd != 'false' and not skip_deps
1579 libzstd = dependency('libzstd',
1580 required : want_zstd == 'true',
1581 version : '>= 1.4.0')
1582 have_zstd = libzstd.found()
1587 conf.set10('HAVE_ZSTD', have_zstd)
1589 conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
1591 compression = get_option('default-compression')
1592 if compression == 'auto'
1594 compression = 'zstd'
1600 compression = 'none'
1602 elif compression == 'zstd' and not have_zstd
1603 error('default-compression=zstd requires zstd')
1604 elif compression == 'lz4' and not have_lz4
1605 error('default-compression=lz4 requires lz4')
1606 elif compression == 'xz' and not have_xz
1607 error('default-compression=xz requires xz')
1609 conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper()))
1611 want_xkbcommon = get_option('xkbcommon')
1612 if want_xkbcommon != 'false' and not skip_deps
1613 libxkbcommon = dependency('xkbcommon',
1614 version : '>= 0.3.0',
1615 required : want_xkbcommon == 'true')
1616 have = libxkbcommon.found()
1621 conf.set10('HAVE_XKBCOMMON', have)
1623 want_pcre2 = get_option('pcre2')
1624 if want_pcre2 != 'false' and not skip_deps
1625 libpcre2 = dependency('libpcre2-8',
1626 required : want_pcre2 == 'true')
1627 have = libpcre2.found()
1632 conf.set10('HAVE_PCRE2', have)
1634 want_glib = get_option('glib')
1635 if want_glib != 'false' and not skip_deps
1636 libglib = dependency('glib-2.0',
1637 version : '>= 2.22.0',
1638 required : want_glib == 'true')
1639 libgobject = dependency('gobject-2.0',
1640 version : '>= 2.22.0',
1641 required : want_glib == 'true')
1642 libgio = dependency('gio-2.0',
1643 required : want_glib == 'true')
1644 have = libglib.found() and libgobject.found() and libgio.found()
1651 conf.set10('HAVE_GLIB', have)
1653 want_dbus = get_option('dbus')
1654 if want_dbus != 'false' and not skip_deps
1655 libdbus = dependency('dbus-1',
1656 version : '>= 1.3.2',
1657 required : want_dbus == 'true')
1658 have = libdbus.found()
1663 conf.set10('HAVE_DBUS', have)
1665 dbusdatadir = datadir / 'dbus-1'
1666 if conf.get('HAVE_DBUS') == 1
1667 dbusdatadir = libdbus.get_variable(pkgconfig: 'datadir', default_value: datadir) / 'dbus-1'
1670 dbuspolicydir = get_option('dbuspolicydir')
1671 if dbuspolicydir == ''
1672 dbuspolicydir = dbusdatadir / 'system.d'
1675 dbussessionservicedir = get_option('dbussessionservicedir')
1676 if dbussessionservicedir == ''
1677 dbussessionservicedir = dbusdatadir / 'services'
1678 if conf.get('HAVE_DBUS') == 1
1679 dbussessionservicedir = libdbus.get_variable(pkgconfig: 'session_bus_services_dir', default_value: dbussessionservicedir)
1683 dbussystemservicedir = get_option('dbussystemservicedir')
1684 if dbussystemservicedir == ''
1685 dbussystemservicedir = dbusdatadir / 'system-services'
1686 if conf.get('HAVE_DBUS') == 1
1687 dbussystemservicedir = libdbus.get_variable(pkgconfig: 'system_bus_services_dir', default_value: dbussystemservicedir)
1691 dbus_interfaces_dir = get_option('dbus-interfaces-dir')
1692 if dbus_interfaces_dir == '' or dbus_interfaces_dir == 'yes'
1693 if meson.is_cross_build() and dbus_interfaces_dir != 'yes'
1694 dbus_interfaces_dir = 'no'
1695 warning('Exporting D-Bus interface XML files is disabled during cross build. Pass path or "yes" to force enable.')
1697 dbus_interfaces_dir = dbusdatadir / 'interfaces'
1698 if conf.get('HAVE_DBUS') == 1
1699 dbus_interfaces_dir = libdbus.get_variable(pkgconfig: 'interfaces_dir', default_value: dbus_interfaces_dir)
1704 # We support one or the other. If gcrypt is available, we assume it's there to
1705 # be used, and use it in preference.
1706 opt = get_option('cryptolib')
1707 if opt == 'openssl' and conf.get('HAVE_OPENSSL') == 0
1708 error('openssl requested as the default cryptolib, but not available')
1710 conf.set10('PREFER_OPENSSL',
1711 opt == 'openssl' or (opt == 'auto' and conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_GCRYPT') == 0))
1712 conf.set10('HAVE_OPENSSL_OR_GCRYPT',
1713 conf.get('HAVE_OPENSSL') == 1 or conf.get('HAVE_GCRYPT') == 1)
1714 lib_openssl_or_gcrypt = conf.get('PREFER_OPENSSL') == 1 ? [libopenssl] : [libgcrypt, libgpg_error]
1716 dns_over_tls = get_option('dns-over-tls')
1717 if dns_over_tls != 'false'
1718 if dns_over_tls == 'gnutls' and conf.get('PREFER_OPENSSL') == 1
1719 error('Sorry, -Ddns-over-tls=gnutls is not supported when openssl is used as the cryptolib')
1722 if dns_over_tls == 'gnutls'
1723 have_openssl = false
1725 have_openssl = conf.get('HAVE_OPENSSL') == 1
1726 if dns_over_tls == 'openssl' and not have_openssl
1727 error('DNS-over-TLS support was requested with openssl, but dependencies are not available')
1730 if dns_over_tls == 'openssl' or have_openssl
1733 have_gnutls = conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0')
1734 if dns_over_tls != 'auto' and not have_gnutls
1735 str = dns_over_tls == 'gnutls' ? ' with gnutls' : ''
1736 error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
1739 have = have_gnutls or have_openssl
1743 have_openssl = false
1745 conf.set10('ENABLE_DNS_OVER_TLS', have)
1746 conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1747 conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
1749 default_dns_over_tls = get_option('default-dns-over-tls')
1751 default_dns_over_tls = 'no'
1753 if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
1754 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.')
1755 default_dns_over_tls = 'no'
1757 conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1758 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
1759 conf.set_quoted('DEFAULT_DNS_OVER_TLS_MODE_STR', default_dns_over_tls)
1761 default_mdns = get_option('default-mdns')
1762 conf.set('DEFAULT_MDNS_MODE',
1763 'RESOLVE_SUPPORT_' + default_mdns.to_upper())
1764 conf.set_quoted('DEFAULT_MDNS_MODE_STR', default_mdns)
1766 default_llmnr = get_option('default-llmnr')
1767 conf.set('DEFAULT_LLMNR_MODE',
1768 'RESOLVE_SUPPORT_' + default_llmnr.to_upper())
1769 conf.set_quoted('DEFAULT_LLMNR_MODE_STR', default_llmnr)
1771 want_repart = get_option('repart')
1772 if want_repart != 'false'
1773 have = conf.get('HAVE_LIBFDISK') == 1
1774 if want_repart == 'true' and not have
1775 error('repart support was requested, but dependencies are not available')
1780 conf.set10('ENABLE_REPART', have)
1782 default_dnssec = get_option('default-dnssec')
1784 default_dnssec = 'no'
1786 if default_dnssec != 'no' and conf.get('HAVE_OPENSSL_OR_GCRYPT') == 0
1787 message('default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.')
1788 default_dnssec = 'no'
1790 conf.set('DEFAULT_DNSSEC_MODE',
1791 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1792 conf.set_quoted('DEFAULT_DNSSEC_MODE_STR', default_dnssec)
1794 want_sysupdate = get_option('sysupdate')
1795 if want_sysupdate != 'false'
1796 have = (conf.get('HAVE_OPENSSL') == 1 and
1797 conf.get('HAVE_LIBFDISK') == 1)
1798 if want_sysupdate == 'true' and not have
1799 error('sysupdate support was requested, but dependencies are not available')
1804 conf.set10('ENABLE_SYSUPDATE', have)
1806 want_importd = get_option('importd')
1807 if want_importd != 'false'
1808 have = (conf.get('HAVE_LIBCURL') == 1 and
1809 conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and
1810 conf.get('HAVE_ZLIB') == 1 and
1811 conf.get('HAVE_XZ') == 1)
1812 if want_importd == 'true' and not have
1813 error('importd support was requested, but dependencies are not available')
1818 conf.set10('ENABLE_IMPORTD', have)
1820 want_kernel_install = get_option('kernel-install')
1821 conf.set10('ENABLE_KERNEL_INSTALL', want_kernel_install)
1823 want_homed = get_option('homed')
1824 if want_homed != 'false'
1825 have = (conf.get('HAVE_OPENSSL') == 1 and
1826 conf.get('HAVE_LIBFDISK') == 1 and
1827 conf.get('HAVE_LIBCRYPTSETUP') == 1)
1828 if want_homed == 'true' and not have
1829 error('homed support was requested, but dependencies are not available')
1834 conf.set10('ENABLE_HOMED', have)
1836 have = have and conf.get('HAVE_PAM') == 1
1837 conf.set10('ENABLE_PAM_HOME', have)
1839 have = get_option('oomd')
1840 conf.set10('ENABLE_OOMD', have)
1842 want_remote = get_option('remote')
1843 if want_remote != 'false'
1844 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1845 conf.get('HAVE_LIBCURL') == 1]
1846 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1847 # it's possible to build one without the other. Complain only if
1848 # support was explicitly requested. The auxiliary files like sysusers
1849 # config should be installed when any of the programs are built.
1850 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1851 error('remote support was requested, but dependencies are not available')
1853 have = have_deps[0] or have_deps[1]
1857 conf.set10('ENABLE_REMOTE', have)
1859 foreach term : ['analyze',
1873 'compat-mutable-uid-boundaries',
1899 have = get_option(term)
1900 name = 'ENABLE_' + term.underscorify().to_upper()
1901 conf.set10(name, have)
1904 enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
1906 foreach tuple : [['nss-mymachines', 'machined'],
1907 ['nss-resolve', 'resolve']]
1908 want = get_option(tuple[0])
1910 have = get_option(tuple[1])
1911 if want == 'true' and not have
1912 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1917 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1918 conf.set10(name, have)
1922 foreach term : ['ENABLE_NSS_MYHOSTNAME',
1923 'ENABLE_NSS_MYMACHINES',
1924 'ENABLE_NSS_RESOLVE',
1925 'ENABLE_NSS_SYSTEMD']
1926 if conf.get(term) == 1
1930 conf.set10('ENABLE_NSS', enable_nss)
1932 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1934 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1936 ############################################################
1942 ############################################################
1944 # Include these now as they provide gnu-efi detection.
1945 subdir('src/fundamental')
1946 subdir('src/boot/efi')
1948 ############################################################
1950 pymod = import('python')
1951 python = pymod.find_installation('python3', required : true, modules : ['jinja2'])
1952 python_39 = python.language_version().version_compare('>=3.9')
1954 if get_option('ukify') == 'auto'
1955 want_ukify = python_39 and conf.get('HAVE_GNU_EFI') == 1
1956 elif get_option('ukify') == 'true' and (not python_39 or conf.get('HAVE_GNU_EFI') != 1)
1957 error('ukify requires Python >= 3.9 and GNU EFI')
1959 want_ukify = get_option('ukify') == 'true'
1961 conf.set10('ENABLE_UKIFY', want_ukify)
1963 ############################################################
1965 generate_gperfs = find_program('tools/generate-gperfs.py')
1966 make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
1967 make_directive_index_py = find_program('tools/make-directive-index.py')
1968 make_man_index_py = find_program('tools/make-man-index.py')
1969 meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
1970 update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
1971 update_man_rules_py = find_program('tools/update-man-rules.py')
1972 update_hwdb_sh = find_program('tools/update-hwdb.sh')
1973 update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
1974 update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
1975 xml_helper_py = find_program('tools/xml_helper.py')
1976 export_dbus_interfaces_py = find_program('tools/dbus_exporter.py')
1978 ############################################################
1980 if get_option('b_coverage')
1981 add_project_arguments('-include', 'src/basic/coverage.h', language : 'c')
1984 ############################################################
1986 config_h = configure_file(
1987 output : 'config.h',
1988 configuration : conf)
1990 add_project_arguments('-include', 'config.h', language : 'c')
1992 jinja2_cmdline = [meson_render_jinja2, config_h, version_h]
1994 ############################################################
1996 # binaries that have --help and are intended for use by humans,
1997 # usually, but not always, installed in /bin.
1998 public_programs = []
2000 # D-Bus introspection XML export
2003 basic_includes = include_directories(
2009 libsystemd_includes = [basic_includes, include_directories(
2010 'src/libsystemd/sd-bus',
2011 'src/libsystemd/sd-device',
2012 'src/libsystemd/sd-event',
2013 'src/libsystemd/sd-hwdb',
2014 'src/libsystemd/sd-id128',
2015 'src/libsystemd/sd-journal',
2016 'src/libsystemd/sd-netlink',
2017 'src/libsystemd/sd-network',
2018 'src/libsystemd/sd-resolve')]
2020 includes = [libsystemd_includes, include_directories('src/shared')]
2025 subdir('src/libsystemd')
2026 subdir('src/shared')
2028 subdir('src/libudev')
2029 subdir('src/cryptsetup/cryptsetup-tokens')
2031 alias_target('devel', libsystemd_pc, libudev_pc)
2033 libsystemd = shared_library(
2035 version : libsystemd_version,
2036 include_directories : libsystemd_includes,
2037 link_args : ['-shared',
2038 '-Wl,--version-script=' + libsystemd_sym_path],
2039 link_with : [libbasic,
2042 link_whole : [libsystemd_static],
2043 dependencies : [threads,
2045 link_depends : libsystemd_sym,
2047 install_tag: 'libsystemd',
2048 install_dir : rootlibdir)
2050 alias_target('libsystemd', libsystemd)
2052 install_libsystemd_static = static_library(
2056 basic_gcrypt_sources,
2057 basic_compress_sources,
2058 fundamental_sources,
2059 include_directories : libsystemd_includes,
2060 build_by_default : static_libsystemd != 'false',
2061 install : static_libsystemd != 'false',
2062 install_tag: 'libsystemd',
2063 install_dir : rootlibdir,
2064 pic : static_libsystemd_pic,
2065 dependencies : [threads,
2077 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
2079 libudev = shared_library(
2081 version : libudev_version,
2082 include_directories : includes,
2083 link_args : ['-shared',
2084 '-Wl,--version-script=' + libudev_sym_path],
2085 link_with : [libsystemd_static, libshared_static],
2086 link_whole : libudev_basic,
2087 dependencies : [threads],
2088 link_depends : libudev_sym,
2090 install_tag: 'libudev',
2091 install_dir : rootlibdir)
2093 alias_target('libudev', libudev)
2095 install_libudev_static = static_library(
2098 fundamental_sources,
2102 include_directories : includes,
2103 build_by_default : static_libudev != 'false',
2104 install : static_libudev != 'false',
2105 install_tag: 'libudev',
2106 install_dir : rootlibdir,
2107 link_depends : libudev_sym,
2108 dependencies : [libshared_deps,
2111 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
2112 pic : static_libudev_pic)
2114 if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
2115 if conf.get('HAVE_TPM2') == 1
2117 'cryptsetup-token-systemd-tpm2',
2118 cryptsetup_token_systemd_tpm2_sources,
2119 include_directories : includes,
2120 link_args : ['-shared',
2121 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2122 link_with : [lib_cryptsetup_token_common,
2124 dependencies : [libcryptsetup,
2127 link_depends : cryptsetup_token_sym,
2128 install_rpath : rootpkglibdir,
2130 install_dir : libcryptsetup_plugins_dir)
2133 if conf.get('HAVE_LIBFIDO2') == 1
2135 'cryptsetup-token-systemd-fido2',
2136 cryptsetup_token_systemd_fido2_sources,
2137 include_directories : includes,
2138 link_args : ['-shared',
2139 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2140 link_with : [lib_cryptsetup_token_common,
2142 dependencies : [libcryptsetup,
2145 link_depends : cryptsetup_token_sym,
2146 install_rpath : rootpkglibdir,
2148 install_dir : libcryptsetup_plugins_dir)
2151 if conf.get('HAVE_P11KIT') == 1
2153 'cryptsetup-token-systemd-pkcs11',
2154 cryptsetup_token_systemd_pkcs11_sources,
2155 include_directories : includes,
2156 link_args : ['-shared',
2157 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2158 link_with : [lib_cryptsetup_token_common,
2160 dependencies : [libcryptsetup,
2163 link_depends : cryptsetup_token_sym,
2164 install_rpath : rootpkglibdir,
2166 install_dir : libcryptsetup_plugins_dir)
2170 ############################################################
2172 # systemd-analyze requires 'libcore'
2174 # systemd-journal-remote requires 'libjournal_core'
2175 subdir('src/journal')
2176 # systemd-networkd requires 'libsystemd_network'
2177 subdir('src/libsystemd-network')
2179 subdir('src/analyze')
2181 subdir('src/busctl')
2182 subdir('src/coredump')
2183 subdir('src/cryptenroll')
2184 subdir('src/cryptsetup')
2186 subdir('src/hostname')
2187 subdir('src/import')
2188 subdir('src/journal-remote')
2189 subdir('src/kernel-install')
2190 subdir('src/locale')
2192 subdir('src/machine')
2193 subdir('src/network')
2194 subdir('src/nspawn')
2196 subdir('src/partition')
2197 subdir('src/portable')
2198 subdir('src/pstore')
2199 subdir('src/resolve')
2201 subdir('src/shutdown')
2202 subdir('src/sysext')
2203 subdir('src/systemctl')
2204 subdir('src/sysupdate')
2205 subdir('src/timedate')
2206 subdir('src/timesync')
2207 subdir('src/tmpfiles')
2208 subdir('src/userdb')
2209 subdir('src/xdg-autostart-generator')
2211 subdir('src/systemd')
2217 subdir('src/ukify/test') # needs to be last for test_env variable
2219 ############################################################
2221 # only static linking apart from libdl, to make sure that the
2222 # module is linked to all libraries that it uses.
2223 test_dlopen = executable(
2226 include_directories : includes,
2227 link_with : [libbasic],
2228 dependencies : [libdl],
2229 build_by_default : want_tests != 'false')
2231 foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
2232 ['systemd', 'ENABLE_NSS_SYSTEMD', ['nss-systemd.h', 'userdb-glue.c', 'userdb-glue.h']],
2233 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
2234 ['resolve', 'ENABLE_NSS_RESOLVE', [], resolve_includes]]
2236 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
2240 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
2241 version_script_arg = project_source_root / sym
2243 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
2244 if tuple.length() > 2
2245 foreach s : tuple[2]
2246 sources += ['src/nss-@0@/@1@'.format(module, s)]
2250 incs = tuple.length() > 3 ? tuple[3] : includes
2252 nss = shared_library(
2256 include_directories : incs,
2257 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
2258 link_args : ['-Wl,-z,nodelete',
2260 '-Wl,--version-script=' + version_script_arg],
2261 link_with : [libsystemd_static,
2264 dependencies : [threads,
2268 install_tag : 'nss',
2269 install_dir : rootlibdir)
2271 # We cannot use shared_module because it does not support version suffix.
2272 # Unfortunately shared_library insists on creating the symlink…
2273 meson.add_install_script('sh', '-c',
2274 'rm $DESTDIR@0@/libnss_@1@.so'
2275 .format(rootlibdir, module),
2279 if want_tests != 'false'
2280 test('dlopen-nss_' + module,
2282 # path to dlopen must include a slash
2283 args : nss.full_path(),
2289 ############################################################
2294 include_directories : includes,
2295 link_with : [libcore,
2297 dependencies : [libseccomp,
2299 install_rpath : rootpkglibdir,
2301 install_dir : rootlibexecdir)
2302 dbus_programs += exe
2303 public_programs += exe
2305 meson.add_install_script(meson_make_symlink,
2306 rootlibexecdir / 'systemd',
2307 rootsbindir / 'init')
2311 systemd_analyze_sources,
2312 include_directories : core_includes,
2313 link_with : [libcore,
2315 dependencies : [libseccomp,
2317 install_rpath : rootpkglibdir,
2318 install : conf.get('ENABLE_ANALYZE') == 1)
2319 public_programs += exe
2321 if want_tests != 'false'
2322 test('test-compare-versions',
2323 test_compare_versions_sh,
2324 args : exe.full_path())
2329 systemd_journald_sources,
2330 include_directories : includes,
2331 link_with : [libjournal_core,
2333 dependencies : [threads,
2339 install_rpath : rootpkglibdir,
2341 install_dir : rootlibexecdir)
2343 public_programs += executable(
2345 systemd_cat_sources,
2346 include_directories : includes,
2347 link_with : [libjournal_core,
2349 dependencies : [threads,
2351 install_rpath : rootpkglibdir,
2354 if get_option('link-journalctl-shared')
2355 journalctl_link_with = [libshared]
2357 journalctl_link_with = [libsystemd_static,
2362 public_programs += executable(
2365 include_directories : includes,
2366 link_with : [journalctl_link_with],
2367 dependencies : [threads,
2374 install_rpath : rootpkglibdir,
2376 install_dir : rootbindir)
2379 'systemd-getty-generator',
2380 'src/getty-generator/getty-generator.c',
2381 include_directories : includes,
2382 link_with : [libshared],
2383 install_rpath : rootpkglibdir,
2385 install_dir : systemgeneratordir)
2388 'systemd-debug-generator',
2389 'src/debug-generator/debug-generator.c',
2390 include_directories : includes,
2391 link_with : [libshared],
2392 install_rpath : rootpkglibdir,
2394 install_dir : systemgeneratordir)
2397 'systemd-run-generator',
2398 'src/run-generator/run-generator.c',
2399 include_directories : includes,
2400 link_with : [libshared],
2401 install_rpath : rootpkglibdir,
2403 install_dir : systemgeneratordir)
2406 'systemd-fstab-generator',
2407 'src/fstab-generator/fstab-generator.c',
2408 include_directories : includes,
2409 link_with : [libshared],
2410 install_rpath : rootpkglibdir,
2412 install_dir : systemgeneratordir)
2414 meson.add_install_script(meson_make_symlink,
2415 systemgeneratordir / 'systemd-fstab-generator',
2416 rootlibexecdir / 'systemd-sysroot-fstab-check')
2418 if want_tests != 'false'
2419 test('test-fstab-generator',
2420 test_fstab_generator_sh,
2421 # https://github.com/mesonbuild/meson/issues/2681
2422 args : exe.full_path(),
2426 if conf.get('ENABLE_ENVIRONMENT_D') == 1
2428 '30-systemd-environment-d-generator',
2429 'src/environment-d-generator/environment-d-generator.c',
2430 include_directories : includes,
2431 link_with : [libshared],
2432 install_rpath : rootpkglibdir,
2434 install_dir : userenvgeneratordir)
2436 meson.add_install_script(meson_make_symlink,
2437 sysconfdir / 'environment',
2438 environmentdir / '99-environment.conf')
2441 if conf.get('ENABLE_HIBERNATE') == 1
2443 'systemd-hibernate-resume-generator',
2444 'src/hibernate-resume/hibernate-resume-generator.c',
2445 include_directories : includes,
2446 link_with : [libshared],
2447 install_rpath : rootpkglibdir,
2449 install_dir : systemgeneratordir)
2452 'systemd-hibernate-resume',
2453 'src/hibernate-resume/hibernate-resume.c',
2454 include_directories : includes,
2455 link_with : [libshared],
2456 install_rpath : rootpkglibdir,
2458 install_dir : rootlibexecdir)
2461 if conf.get('HAVE_BLKID') == 1
2463 'systemd-gpt-auto-generator',
2464 'src/gpt-auto-generator/gpt-auto-generator.c',
2465 include_directories : includes,
2466 link_with : [libshared],
2467 dependencies : libblkid,
2468 install_rpath : rootpkglibdir,
2470 install_dir : systemgeneratordir)
2472 public_programs += executable(
2474 'src/dissect/dissect.c',
2475 include_directories : includes,
2476 link_with : [libshared],
2477 dependencies : [versiondep],
2478 install_rpath : rootpkglibdir,
2482 if conf.get('ENABLE_RESOLVE') == 1
2483 dbus_programs += executable(
2485 systemd_resolved_sources,
2486 include_directories : resolve_includes,
2487 link_with : [libshared,
2489 libsystemd_resolve_core],
2490 dependencies : systemd_resolved_dependencies,
2491 install_rpath : rootpkglibdir,
2493 install_dir : rootlibexecdir)
2495 public_programs += executable(
2498 include_directories : includes,
2499 link_with : [libshared,
2501 libsystemd_resolve_core],
2502 dependencies : [threads,
2503 lib_openssl_or_gcrypt,
2507 install_rpath : rootpkglibdir,
2510 meson.add_install_script(meson_make_symlink,
2511 bindir / 'resolvectl',
2512 rootsbindir / 'resolvconf')
2514 meson.add_install_script(meson_make_symlink,
2515 bindir / 'resolvectl',
2516 bindir / 'systemd-resolve')
2519 if conf.get('ENABLE_LOGIND') == 1
2520 dbus_programs += executable(
2522 systemd_logind_sources,
2523 include_directories : includes,
2524 link_with : [liblogind_core,
2526 dependencies : [threads,
2529 install_rpath : rootpkglibdir,
2531 install_dir : rootlibexecdir)
2533 public_programs += executable(
2536 include_directories : includes,
2537 link_with : [libshared],
2538 dependencies : [threads,
2543 install_rpath : rootpkglibdir,
2545 install_dir : rootbindir)
2547 public_programs += executable(
2549 'src/login/inhibit.c',
2550 include_directories : includes,
2551 link_with : [libshared],
2552 dependencies : [versiondep],
2553 install_rpath : rootpkglibdir,
2555 install_dir : rootbindir)
2557 if conf.get('HAVE_PAM') == 1
2558 version_script_arg = project_source_root / pam_systemd_sym
2559 pam_systemd = shared_library(
2563 include_directories : includes,
2564 link_args : ['-shared',
2565 '-Wl,--version-script=' + version_script_arg],
2566 link_with : [libsystemd_static,
2568 dependencies : [threads,
2572 link_depends : pam_systemd_sym,
2574 install_tag : 'pam',
2575 install_dir : pamlibdir)
2577 if want_tests != 'false'
2578 test('dlopen-pam_systemd',
2580 # path to dlopen must include a slash
2581 args : pam_systemd.full_path(),
2582 depends : pam_systemd)
2587 'systemd-user-runtime-dir',
2588 user_runtime_dir_sources,
2589 include_directories : includes,
2590 link_with : [libshared],
2591 install_rpath : rootpkglibdir,
2593 install_dir : rootlibexecdir)
2596 if conf.get('HAVE_PAM') == 1
2598 'systemd-user-sessions',
2599 'src/user-sessions/user-sessions.c',
2600 include_directories : includes,
2601 link_with : [libshared],
2602 install_rpath : rootpkglibdir,
2604 install_dir : rootlibexecdir)
2607 if conf.get('HAVE_BLKID') == 1 and conf.get('HAVE_GNU_EFI') == 1
2608 if get_option('link-boot-shared')
2609 boot_link_with = [libshared]
2611 boot_link_with = [libsystemd_static, libshared_static]
2617 include_directories : includes,
2618 link_with : [boot_link_with],
2619 dependencies : [libblkid,
2621 install_rpath : rootpkglibdir,
2623 public_programs += exe
2625 if want_tests != 'false'
2626 test('test-bootctl-json',
2627 test_bootctl_json_sh,
2628 args : exe.full_path(),
2632 public_programs += executable(
2633 'systemd-bless-boot',
2634 'src/boot/bless-boot.c',
2635 include_directories : includes,
2636 link_with : [boot_link_with],
2637 dependencies : [libblkid,
2639 install_rpath : rootpkglibdir,
2641 install_dir : rootlibexecdir)
2644 'systemd-bless-boot-generator',
2645 'src/boot/bless-boot-generator.c',
2646 include_directories : includes,
2647 link_with : [boot_link_with],
2648 install_rpath : rootpkglibdir,
2650 install_dir : systemgeneratordir)
2652 if conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_TPM2') == 1
2655 'src/boot/measure.c',
2656 include_directories : includes,
2657 link_with : [libshared],
2658 dependencies : [libopenssl,
2660 install_rpath : rootpkglibdir,
2662 install_dir : rootlibexecdir)
2665 'src/boot/pcrphase.c',
2666 include_directories : includes,
2667 link_with : [libshared],
2668 dependencies : [libopenssl,
2672 install_rpath : rootpkglibdir,
2674 install_dir : rootlibexecdir)
2679 'systemd-boot-check-no-failures',
2680 'src/boot/boot-check-no-failures.c',
2681 include_directories : includes,
2682 link_with : [libshared],
2683 dependencies : [libblkid,
2685 install_rpath : rootpkglibdir,
2687 install_dir : rootlibexecdir)
2689 public_programs += executable(
2690 'systemd-socket-activate',
2691 'src/activate/activate.c',
2692 include_directories : includes,
2693 link_with : [libshared],
2694 dependencies : [threads,
2696 install_rpath : rootpkglibdir,
2699 systemctl = executable(
2702 include_directories : includes,
2703 link_with : systemctl_link_with,
2704 dependencies : [threads,
2711 install_rpath : rootpkglibdir,
2713 install_dir : rootbindir)
2714 public_programs += systemctl
2716 if conf.get('ENABLE_PORTABLED') == 1
2717 dbus_programs += executable(
2718 'systemd-portabled',
2719 systemd_portabled_sources,
2720 include_directories : includes,
2721 link_with : [libshared],
2722 dependencies : [threads,
2725 install_rpath : rootpkglibdir,
2727 install_dir : rootlibexecdir)
2729 public_programs += executable(
2731 'src/portable/portablectl.c',
2732 include_directories : includes,
2733 link_with : [libshared],
2734 dependencies : [threads,
2736 install_rpath : rootpkglibdir,
2738 install_dir : rootbindir)
2741 if conf.get('ENABLE_SYSEXT') == 1
2742 public_programs += executable(
2744 systemd_sysext_sources,
2745 include_directories : includes,
2746 link_with : [libshared],
2747 dependencies : [versiondep],
2748 install_rpath : rootpkglibdir,
2750 install_dir : rootbindir)
2753 if conf.get('ENABLE_USERDB') == 1
2756 systemd_userwork_sources,
2757 include_directories : includes,
2758 link_with : [libshared],
2759 dependencies : [threads,
2761 install_rpath : rootpkglibdir,
2763 install_dir : rootlibexecdir)
2767 systemd_userdbd_sources,
2768 include_directories : includes,
2769 link_with : [libshared],
2770 dependencies : [threads,
2772 install_rpath : rootpkglibdir,
2774 install_dir : rootlibexecdir)
2776 public_programs += executable(
2779 include_directories : includes,
2780 link_with : [libshared],
2781 dependencies : [threads,
2783 install_rpath : rootpkglibdir,
2787 if conf.get('ENABLE_HOMED') == 1
2790 systemd_homework_sources,
2791 include_directories : includes,
2792 link_with : [libshared,
2794 dependencies : [threads,
2801 install_rpath : rootpkglibdir,
2803 install_dir : rootlibexecdir)
2805 dbus_programs += executable(
2807 systemd_homed_sources,
2808 include_directories : home_includes,
2809 link_with : [libshared],
2810 dependencies : [threads,
2815 install_rpath : rootpkglibdir,
2817 install_dir : rootlibexecdir)
2819 public_programs += executable(
2822 include_directories : includes,
2823 link_with : [libshared],
2824 dependencies : [threads,
2830 install_rpath : rootpkglibdir,
2833 if conf.get('HAVE_PAM') == 1
2834 version_script_arg = project_source_root / pam_systemd_home_sym
2835 pam_systemd_home = shared_library(
2839 include_directories : includes,
2840 link_args : ['-shared',
2841 '-Wl,--version-script=' + version_script_arg],
2842 link_with : [libsystemd_static,
2844 dependencies : [threads,
2849 link_depends : pam_systemd_home_sym,
2851 install_tag : 'pam',
2852 install_dir : pamlibdir)
2854 if want_tests != 'false'
2855 test('dlopen-pam_systemd_home',
2857 # path to dlopen must include a slash
2858 args : pam_systemd_home.full_path(),
2859 depends : pam_systemd_home)
2864 foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
2865 (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
2866 meson.add_install_script(meson_make_symlink,
2867 rootbindir / 'systemctl',
2868 rootsbindir / alias)
2871 meson.add_install_script(meson_make_symlink,
2872 rootbindir / 'udevadm',
2873 rootlibexecdir / 'systemd-udevd')
2875 if conf.get('ENABLE_BACKLIGHT') == 1
2877 'systemd-backlight',
2878 'src/backlight/backlight.c',
2879 include_directories : includes,
2880 link_with : [libshared],
2881 install_rpath : rootpkglibdir,
2883 install_dir : rootlibexecdir)
2886 if conf.get('ENABLE_RFKILL') == 1
2889 'src/rfkill/rfkill.c',
2890 include_directories : includes,
2891 link_with : [libshared],
2892 install_rpath : rootpkglibdir,
2894 install_dir : rootlibexecdir)
2898 'systemd-system-update-generator',
2899 'src/system-update-generator/system-update-generator.c',
2900 include_directories : includes,
2901 link_with : [libshared],
2902 install_rpath : rootpkglibdir,
2904 install_dir : systemgeneratordir)
2906 if conf.get('HAVE_LIBCRYPTSETUP') == 1
2908 'systemd-cryptsetup',
2909 systemd_cryptsetup_sources,
2910 include_directories : includes,
2911 link_with : [libshared],
2912 dependencies : [libcryptsetup,
2916 install_rpath : rootpkglibdir,
2918 install_dir : rootlibexecdir)
2921 'systemd-cryptsetup-generator',
2922 'src/cryptsetup/cryptsetup-generator.c',
2923 include_directories : includes,
2924 link_with : [libshared],
2925 install_rpath : rootpkglibdir,
2927 install_dir : systemgeneratordir)
2930 'systemd-veritysetup',
2931 'src/veritysetup/veritysetup.c',
2932 include_directories : includes,
2933 link_with : [libshared],
2934 dependencies : [libcryptsetup,
2936 install_rpath : rootpkglibdir,
2938 install_dir : rootlibexecdir)
2941 'systemd-veritysetup-generator',
2942 'src/veritysetup/veritysetup-generator.c',
2943 include_directories : includes,
2944 link_with : [libshared],
2945 dependencies : [versiondep],
2946 install_rpath : rootpkglibdir,
2948 install_dir : systemgeneratordir)
2950 public_programs += executable(
2951 'systemd-cryptenroll',
2952 systemd_cryptenroll_sources,
2953 include_directories : includes,
2954 link_with : [libshared],
2955 dependencies : [libcryptsetup,
2960 install_rpath : rootpkglibdir,
2964 'systemd-integritysetup',
2965 ['src/integritysetup/integritysetup.c', 'src/integritysetup/integrity-util.c'],
2966 include_directories : includes,
2967 link_with : [libshared],
2968 dependencies : [libcryptsetup,
2970 install_rpath : rootpkglibdir,
2972 install_dir : rootlibexecdir)
2975 'systemd-integritysetup-generator',
2976 ['src/integritysetup/integritysetup-generator.c', 'src/integritysetup/integrity-util.c'],
2977 include_directories : includes,
2978 link_with : [libshared],
2979 install_rpath : rootpkglibdir,
2981 install_dir : systemgeneratordir)
2984 if conf.get('HAVE_SYSV_COMPAT') == 1
2986 'systemd-sysv-generator',
2987 'src/sysv-generator/sysv-generator.c',
2988 include_directories : includes,
2989 link_with : [libshared],
2990 install_rpath : rootpkglibdir,
2992 install_dir : systemgeneratordir)
2994 sysv_generator_test_py = find_program('test/sysv-generator-test.py')
2995 if want_tests != 'false'
2996 test('sysv-generator-test',
2997 sysv_generator_test_py,
3002 'systemd-rc-local-generator',
3003 'src/rc-local-generator/rc-local-generator.c',
3004 include_directories : includes,
3005 link_with : [libshared],
3006 install_rpath : rootpkglibdir,
3008 install_dir : systemgeneratordir)
3011 if conf.get('ENABLE_XDG_AUTOSTART') == 1
3013 'systemd-xdg-autostart-generator',
3014 systemd_xdg_autostart_generator_sources,
3015 include_directories : includes,
3016 link_with : [libshared],
3017 install_rpath : rootpkglibdir,
3019 install_dir : usergeneratordir)
3022 'systemd-xdg-autostart-condition',
3023 'src/xdg-autostart-generator/xdg-autostart-condition.c',
3024 include_directories : includes,
3025 link_with : [libshared],
3026 install_rpath : rootpkglibdir,
3028 install_dir : rootlibexecdir)
3031 if conf.get('ENABLE_HOSTNAMED') == 1
3032 dbus_programs += executable(
3033 'systemd-hostnamed',
3034 'src/hostname/hostnamed.c',
3035 include_directories : includes,
3036 link_with : [libshared],
3037 install_rpath : rootpkglibdir,
3039 install_dir : rootlibexecdir)
3041 public_programs += executable(
3043 'src/hostname/hostnamectl.c',
3044 include_directories : includes,
3045 link_with : [libshared],
3046 dependencies : [versiondep],
3047 install_rpath : rootpkglibdir,
3051 if conf.get('ENABLE_LOCALED') == 1
3052 if conf.get('HAVE_XKBCOMMON') == 1
3053 # logind will load libxkbcommon.so dynamically on its own, but we still
3054 # need to specify where the headers are
3056 libxkbcommon.partial_dependency(compile_args: true),
3062 dbus_programs += executable(
3064 systemd_localed_sources,
3065 include_directories : includes,
3066 link_with : [libshared],
3067 dependencies : deps,
3068 install_rpath : rootpkglibdir,
3070 install_dir : rootlibexecdir)
3072 public_programs += executable(
3075 include_directories : includes,
3076 link_with : [libshared],
3077 dependencies : [versiondep],
3078 install_rpath : rootpkglibdir,
3082 if conf.get('ENABLE_TIMEDATED') == 1
3083 dbus_programs += executable(
3084 'systemd-timedated',
3085 'src/timedate/timedated.c',
3086 include_directories : includes,
3087 link_with : [libshared],
3088 install_rpath : rootpkglibdir,
3090 install_dir : rootlibexecdir)
3093 if conf.get('ENABLE_TIMEDATECTL') == 1
3094 public_programs += executable(
3096 'src/timedate/timedatectl.c',
3097 include_directories : includes,
3098 install_rpath : rootpkglibdir,
3099 link_with : [libshared],
3100 dependencies : [libm,
3105 if conf.get('ENABLE_TIMESYNCD') == 1
3107 'systemd-timesyncd',
3108 systemd_timesyncd_sources,
3109 include_directories : includes,
3110 link_with : [libtimesyncd_core],
3111 dependencies : [threads,
3114 install_rpath : rootpkglibdir,
3116 install_dir : rootlibexecdir)
3119 'systemd-time-wait-sync',
3120 'src/timesync/wait-sync.c',
3121 include_directories : includes,
3122 link_with : [libtimesyncd_core],
3123 install_rpath : rootpkglibdir,
3125 install_dir : rootlibexecdir)
3128 if conf.get('ENABLE_MACHINED') == 1
3129 dbus_programs += executable(
3131 systemd_machined_sources,
3132 include_directories : includes,
3133 link_with : [libmachine_core,
3135 install_rpath : rootpkglibdir,
3137 install_dir : rootlibexecdir)
3139 public_programs += executable(
3141 'src/machine/machinectl.c',
3142 include_directories : includes,
3143 link_with : [libshared],
3144 dependencies : [threads,
3149 install_rpath : rootpkglibdir,
3151 install_dir : rootbindir)
3154 if conf.get('ENABLE_IMPORTD') == 1
3155 dbus_programs += executable(
3157 systemd_importd_sources,
3158 include_directories : includes,
3159 link_with : [libshared],
3160 dependencies : [threads,
3162 install_rpath : rootpkglibdir,
3164 install_dir : rootlibexecdir)
3166 systemd_pull = executable(
3168 systemd_pull_sources,
3169 include_directories : includes,
3170 link_with : [libshared,
3172 dependencies : [libcurl,
3173 lib_openssl_or_gcrypt,
3178 install_rpath : rootpkglibdir,
3180 install_dir : rootlibexecdir)
3182 systemd_import = executable(
3184 systemd_import_sources,
3185 include_directories : includes,
3186 link_with : [libshared,
3188 dependencies : [libcurl,
3193 install_rpath : rootpkglibdir,
3195 install_dir : rootlibexecdir)
3197 systemd_import_fs = executable(
3198 'systemd-import-fs',
3199 systemd_import_fs_sources,
3200 include_directories : includes,
3201 link_with : [libshared,
3203 dependencies : [versiondep],
3204 install_rpath : rootpkglibdir,
3206 install_dir : rootlibexecdir)
3208 systemd_export = executable(
3210 systemd_export_sources,
3211 include_directories : includes,
3212 link_with : [libshared,
3214 dependencies : [libcurl,
3219 install_rpath : rootpkglibdir,
3221 install_dir : rootlibexecdir)
3223 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
3226 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
3227 public_programs += executable(
3228 'systemd-journal-upload',
3229 systemd_journal_upload_sources,
3230 include_directories : includes,
3231 link_with : [libshared],
3232 dependencies : [threads,
3239 install_rpath : rootpkglibdir,
3241 install_dir : rootlibexecdir)
3244 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
3245 public_programs += executable(
3246 'systemd-journal-remote',
3247 systemd_journal_remote_sources,
3248 include_directories : journal_includes,
3249 link_with : [libshared,
3250 libsystemd_journal_remote],
3251 dependencies : [threads,
3258 install_rpath : rootpkglibdir,
3260 install_dir : rootlibexecdir)
3262 public_programs += executable(
3263 'systemd-journal-gatewayd',
3264 systemd_journal_gatewayd_sources,
3265 include_directories : journal_includes,
3266 link_with : [libshared],
3267 dependencies : [threads,
3274 install_rpath : rootpkglibdir,
3276 install_dir : rootlibexecdir)
3279 if conf.get('ENABLE_COREDUMP') == 1
3282 systemd_coredump_sources,
3283 include_directories : includes,
3284 link_with : [libshared,
3286 dependencies : [threads,
3292 install_rpath : rootpkglibdir,
3294 install_dir : rootlibexecdir)
3296 public_programs += executable(
3298 coredumpctl_sources,
3299 include_directories : includes,
3300 link_with : [libshared,
3302 dependencies : [threads,
3307 install_rpath : rootpkglibdir,
3311 if conf.get('ENABLE_PSTORE') == 1
3314 systemd_pstore_sources,
3315 include_directories : includes,
3316 link_with : [libshared],
3317 dependencies : [threads,
3323 install_rpath : rootpkglibdir,
3325 install_dir : rootlibexecdir)
3328 if conf.get('ENABLE_OOMD') == 1
3329 dbus_programs += executable('systemd-oomd',
3330 systemd_oomd_sources,
3331 include_directories : includes,
3332 link_with : [libshared],
3333 dependencies : [libatomic,
3335 install_rpath : rootpkglibdir,
3337 install_dir : rootlibexecdir)
3339 public_programs += executable(
3342 include_directories : includes,
3343 link_with : [libshared],
3344 dependencies : [versiondep],
3345 install_rpath : rootpkglibdir,
3349 if conf.get('ENABLE_BINFMT') == 1
3350 public_programs += executable(
3352 'src/binfmt/binfmt.c',
3353 include_directories : includes,
3354 link_with : [libshared],
3355 dependencies : [versiondep],
3356 install_rpath : rootpkglibdir,
3358 install_dir : rootlibexecdir)
3360 meson.add_install_script('sh', '-c',
3361 mkdir_p.format(binfmtdir))
3362 if install_sysconfdir
3363 meson.add_install_script('sh', '-c',
3364 mkdir_p.format(sysconfdir / 'binfmt.d'))
3368 if conf.get('ENABLE_SYSUPDATE') == 1
3370 'systemd-sysupdate',
3371 systemd_sysupdate_sources,
3372 include_directories : includes,
3373 link_with : [libshared,
3375 dependencies : [threads,
3380 install_rpath : rootpkglibdir,
3382 install_dir : rootlibexecdir)
3383 public_programs += exe
3386 if conf.get('ENABLE_VCONSOLE') == 1
3388 'systemd-vconsole-setup',
3389 'src/vconsole/vconsole-setup.c',
3390 include_directories : includes,
3391 link_with : [libshared],
3392 install_rpath : rootpkglibdir,
3394 install_dir : rootlibexecdir)
3397 if conf.get('ENABLE_RANDOMSEED') == 1
3399 'systemd-random-seed',
3400 'src/random-seed/random-seed.c',
3401 include_directories : includes,
3402 link_with : [libshared],
3403 dependencies : [versiondep],
3404 install_rpath : rootpkglibdir,
3406 install_dir : rootlibexecdir)
3409 if conf.get('ENABLE_FIRSTBOOT') == 1
3410 public_programs += executable(
3411 'systemd-firstboot',
3412 'src/firstboot/firstboot.c',
3413 include_directories : includes,
3414 link_with : [libshared],
3415 dependencies : [libcrypt,
3417 install_rpath : rootpkglibdir,
3419 install_dir : rootbindir)
3423 'systemd-remount-fs',
3424 'src/remount-fs/remount-fs.c',
3425 include_directories : includes,
3426 link_with : [libshared],
3427 dependencies : [versiondep],
3428 install_rpath : rootpkglibdir,
3430 install_dir : rootlibexecdir)
3433 'systemd-machine-id-setup',
3434 'src/machine-id-setup/machine-id-setup-main.c',
3435 include_directories : includes,
3436 link_with : [libshared],
3437 dependencies : [versiondep],
3438 install_rpath : rootpkglibdir,
3440 install_dir : rootbindir)
3445 include_directories : includes,
3446 link_with : [libshared],
3447 dependencies : [versiondep],
3448 install_rpath : rootpkglibdir,
3450 install_dir : rootlibexecdir)
3454 'src/partition/growfs.c',
3455 include_directories : includes,
3456 link_with : [libshared],
3457 dependencies : [versiondep],
3458 install_rpath : rootpkglibdir,
3460 install_dir : rootlibexecdir)
3464 'src/partition/makefs.c',
3465 include_directories : includes,
3466 link_with : [libshared],
3467 dependencies : [versiondep],
3468 install_rpath : rootpkglibdir,
3470 install_dir : rootlibexecdir)
3474 'src/sleep/sleep.c',
3475 include_directories : includes,
3476 link_with : [libshared],
3477 dependencies : [versiondep],
3478 install_rpath : rootpkglibdir,
3480 install_dir : rootlibexecdir)
3482 if install_sysconfdir_samples
3483 install_data('src/sleep/sleep.conf',
3484 install_dir : pkgsysconfdir)
3487 public_programs += executable(
3489 'src/sysctl/sysctl.c',
3490 include_directories : includes,
3491 link_with : [libshared],
3492 dependencies : [versiondep],
3493 install_rpath : rootpkglibdir,
3495 install_dir : rootlibexecdir)
3497 public_programs += executable(
3499 'src/ac-power/ac-power.c',
3500 include_directories : includes,
3501 link_with : [libshared],
3502 dependencies : [versiondep],
3503 install_rpath : rootpkglibdir,
3506 public_programs += executable(
3507 'systemd-detect-virt',
3508 'src/detect-virt/detect-virt.c',
3509 include_directories : includes,
3510 link_with : [libshared],
3511 dependencies : [versiondep],
3512 install_rpath : rootpkglibdir,
3515 public_programs += executable(
3517 'src/delta/delta.c',
3518 include_directories : includes,
3519 link_with : [libshared],
3520 dependencies : [versiondep],
3521 install_rpath : rootpkglibdir,
3524 public_programs += executable(
3526 'src/escape/escape.c',
3527 include_directories : includes,
3528 link_with : [libshared],
3529 dependencies : [versiondep],
3530 install_rpath : rootpkglibdir,
3532 install_dir : rootbindir)
3534 public_programs += executable(
3536 'src/notify/notify.c',
3537 include_directories : includes,
3538 link_with : [libshared],
3539 dependencies : [versiondep],
3540 install_rpath : rootpkglibdir,
3542 install_dir : rootbindir)
3544 public_programs += executable(
3546 'src/creds/creds.c',
3547 include_directories : includes,
3548 link_with : [libshared],
3549 dependencies : [threads,
3552 install_rpath : rootpkglibdir,
3554 install_dir : rootbindir)
3557 'systemd-volatile-root',
3558 'src/volatile-root/volatile-root.c',
3559 include_directories : includes,
3560 link_with : [libshared],
3561 install_rpath : rootpkglibdir,
3562 install : conf.get('ENABLE_INITRD') == 1,
3563 install_dir : rootlibexecdir)
3566 'systemd-cgroups-agent',
3567 'src/cgroups-agent/cgroups-agent.c',
3568 include_directories : includes,
3569 link_with : [libshared],
3570 install_rpath : rootpkglibdir,
3572 install_dir : rootlibexecdir)
3574 systemd_id128 = executable(
3576 'src/id128/id128.c',
3577 include_directories : includes,
3578 link_with : [libshared],
3579 dependencies : [versiondep],
3580 install_rpath : rootpkglibdir,
3582 public_programs += systemd_id128
3584 if want_tests != 'false'
3585 test('test-systemctl-enable',
3586 test_systemctl_enable_sh,
3587 # https://github.com/mesonbuild/meson/issues/2681
3588 args : [systemctl.full_path(),
3589 systemd_id128.full_path()])
3592 public_programs += executable(
3595 include_directories : includes,
3596 link_with : [libshared],
3597 dependencies : [versiondep],
3598 install_rpath : rootpkglibdir,
3601 public_programs += executable(
3602 'systemd-ask-password',
3603 'src/ask-password/ask-password.c',
3604 include_directories : includes,
3605 link_with : [libshared],
3606 dependencies : [versiondep],
3607 install_rpath : rootpkglibdir,
3609 install_dir : rootbindir)
3612 'systemd-reply-password',
3613 'src/reply-password/reply-password.c',
3614 include_directories : includes,
3615 link_with : [libshared],
3616 install_rpath : rootpkglibdir,
3618 install_dir : rootlibexecdir)
3620 public_programs += executable(
3621 'systemd-tty-ask-password-agent',
3622 'src/tty-ask-password-agent/tty-ask-password-agent.c',
3623 include_directories : includes,
3624 link_with : [libshared],
3625 dependencies : [versiondep],
3626 install_rpath : rootpkglibdir,
3628 install_dir : rootbindir)
3630 public_programs += executable(
3633 include_directories : includes,
3634 link_with : [libshared],
3635 dependencies : [versiondep],
3636 install_rpath : rootpkglibdir,
3639 public_programs += executable(
3641 'src/cgtop/cgtop.c',
3642 include_directories : includes,
3643 link_with : [libshared],
3644 dependencies : [versiondep],
3645 install_rpath : rootpkglibdir,
3650 'src/initctl/initctl.c',
3651 include_directories : includes,
3652 link_with : [libshared],
3653 install_rpath : rootpkglibdir,
3654 install : (conf.get('HAVE_SYSV_COMPAT') == 1),
3655 install_dir : rootlibexecdir)
3657 public_programs += executable(
3659 'src/mount/mount-tool.c',
3660 include_directories : includes,
3661 link_with : [libshared],
3662 dependencies: [libmount,
3664 install_rpath : rootpkglibdir,
3667 meson.add_install_script(meson_make_symlink,
3668 'systemd-mount', bindir / 'systemd-umount')
3670 public_programs += executable(
3673 include_directories : includes,
3674 link_with : [libshared],
3675 dependencies : [versiondep],
3676 install_rpath : rootpkglibdir,
3679 public_programs += executable(
3680 'systemd-stdio-bridge',
3681 'src/stdio-bridge/stdio-bridge.c',
3682 include_directories : includes,
3683 link_with : [libshared],
3684 dependencies : [versiondep,
3686 install_rpath : rootpkglibdir,
3689 public_programs += executable(
3692 include_directories : includes,
3693 link_with : [libshared],
3694 dependencies : [versiondep],
3695 install_rpath : rootpkglibdir,
3701 'src/sysusers/sysusers.c',
3702 include_directories : includes,
3703 link_with : [libshared],
3704 dependencies : [versiondep],
3705 install_rpath : rootpkglibdir,
3707 install_dir : rootbindir)
3708 public_programs += exe
3710 if want_tests != 'false'
3711 test('test-sysusers',
3713 # https://github.com/mesonbuild/meson/issues/2681
3714 args : exe.full_path())
3717 if have_standalone_binaries
3719 'systemd-sysusers.standalone',
3720 'src/sysusers/sysusers.c',
3721 include_directories : includes,
3722 c_args : '-DSTANDALONE',
3723 link_with : [libshared_static,
3727 dependencies : [versiondep],
3729 install_dir : rootbindir)
3730 public_programs += exe
3732 if want_tests != 'false'
3733 test('test-sysusers.standalone',
3735 # https://github.com/mesonbuild/meson/issues/2681
3736 args : exe.full_path())
3741 if conf.get('ENABLE_TMPFILES') == 1
3744 systemd_tmpfiles_sources,
3745 include_directories : includes,
3746 link_with : [libshared],
3747 dependencies : [libacl,
3749 install_rpath : rootpkglibdir,
3751 install_dir : rootbindir)
3752 public_programs += exe
3754 if want_tests != 'false'
3755 test('test-systemd-tmpfiles',
3756 test_systemd_tmpfiles_py,
3757 # https://github.com/mesonbuild/meson/issues/2681
3758 args : exe.full_path())
3761 if have_standalone_binaries
3763 'systemd-tmpfiles.standalone',
3764 systemd_tmpfiles_sources,
3765 include_directories : includes,
3766 c_args : '-DSTANDALONE',
3767 link_with : [libshared_static,
3771 dependencies : [libacl,
3774 install_dir : rootbindir)
3775 public_programs += exe
3777 if want_tests != 'false'
3778 test('test-systemd-tmpfiles.standalone',
3779 test_systemd_tmpfiles_py,
3780 # https://github.com/mesonbuild/meson/issues/2681
3781 args : exe.full_path())
3786 if conf.get('ENABLE_HWDB') == 1
3787 systemd_hwdb = executable(
3790 include_directories : includes,
3791 link_with : udev_link_with,
3792 dependencies : [versiondep],
3793 install_rpath : udev_rpath,
3795 install_dir : rootbindir)
3796 public_programs += systemd_hwdb
3798 if want_tests != 'false'
3801 suite : 'dist-check',
3802 args : [systemd_hwdb.full_path()],
3807 if conf.get('ENABLE_QUOTACHECK') == 1
3809 'systemd-quotacheck',
3810 'src/quotacheck/quotacheck.c',
3811 include_directories : includes,
3812 link_with : [libshared],
3813 install_rpath : rootpkglibdir,
3815 install_dir : rootlibexecdir)
3818 public_programs += executable(
3819 'systemd-socket-proxyd',
3820 'src/socket-proxy/socket-proxyd.c',
3821 include_directories : includes,
3822 link_with : [libshared],
3823 dependencies : [threads,
3825 install_rpath : rootpkglibdir,
3827 install_dir : rootlibexecdir)
3829 udevadm = executable(
3832 include_directories : includes,
3833 link_with : [libudevd_core],
3834 dependencies : [threads,
3840 install_rpath : udev_rpath,
3842 install_dir : rootbindir)
3843 public_programs += udevadm
3845 if conf.get('ENABLE_REPART') == 1
3848 systemd_repart_sources,
3849 include_directories : includes,
3850 link_with : [libshared,
3852 dependencies : [threads,
3857 install_rpath : rootpkglibdir,
3859 install_dir : rootbindir)
3860 public_programs += exe
3862 if have_standalone_binaries
3864 'systemd-repart.standalone',
3865 systemd_repart_sources,
3866 include_directories : includes,
3867 c_args : '-DSTANDALONE',
3868 link_with : [libshared_static,
3873 dependencies : [threads,
3878 install_rpath : rootpkglibdir,
3880 install_dir : rootbindir)
3881 public_programs += exe
3887 systemd_shutdown_sources,
3888 include_directories : includes,
3889 link_with : [libshared],
3890 dependencies : [libmount,
3892 install_rpath : rootpkglibdir,
3894 install_dir : rootlibexecdir)
3896 if have_standalone_binaries
3898 'systemd-shutdown.standalone',
3899 systemd_shutdown_sources,
3900 include_directories : includes,
3901 c_args : '-DSTANDALONE',
3902 link_with : [libshared_static,
3905 dependencies : [libmount,
3907 install_rpath : rootpkglibdir,
3909 install_dir : rootlibexecdir)
3913 'systemd-update-done',
3914 'src/update-done/update-done.c',
3915 include_directories : includes,
3916 link_with : [libshared],
3917 dependencies : [versiondep],
3918 install_rpath : rootpkglibdir,
3920 install_dir : rootlibexecdir)
3923 'systemd-update-utmp',
3924 'src/update-utmp/update-utmp.c',
3925 include_directories : includes,
3926 link_with : [libshared],
3927 dependencies : [libaudit,
3929 install_rpath : rootpkglibdir,
3930 install : (conf.get('ENABLE_UTMP') == 1),
3931 install_dir : rootlibexecdir)
3933 if conf.get('HAVE_KMOD') == 1
3935 'systemd-modules-load',
3936 'src/modules-load/modules-load.c',
3937 include_directories : includes,
3938 link_with : [libshared],
3939 dependencies : [libkmod,
3941 install_rpath : rootpkglibdir,
3943 install_dir : rootlibexecdir)
3945 meson.add_install_script('sh', '-c',
3946 mkdir_p.format(modulesloaddir))
3947 if install_sysconfdir
3948 meson.add_install_script('sh', '-c',
3949 mkdir_p.format(sysconfdir / 'modules-load.d'))
3953 public_programs += executable(
3955 systemd_nspawn_sources,
3956 include_directories : includes,
3957 link_with : [libnspawn_core,
3959 dependencies : [libblkid,
3962 install_rpath : rootpkglibdir,
3965 if conf.get('ENABLE_NETWORKD') == 1
3966 dbus_programs += executable(
3968 systemd_networkd_sources,
3969 include_directories : network_includes,
3970 link_with : [libnetworkd_core,
3972 networkd_link_with],
3973 dependencies : [threads,
3975 install_rpath : rootpkglibdir,
3977 install_dir : rootlibexecdir)
3979 public_programs += executable(
3980 'systemd-networkd-wait-online',
3981 systemd_networkd_wait_online_sources,
3982 include_directories : includes,
3983 link_with : [networkd_link_with],
3984 dependencies : [versiondep],
3985 install_rpath : rootpkglibdir,
3987 install_dir : rootlibexecdir)
3989 public_programs += executable(
3992 include_directories : libsystemd_network_includes,
3993 link_with : [libsystemd_network,
3994 networkd_link_with],
3995 dependencies : [versiondep],
3996 install_rpath : rootpkglibdir,
3998 install_dir : rootbindir)
4002 'systemd-network-generator',
4003 network_generator_sources,
4004 include_directories : includes,
4005 link_with : [networkd_link_with],
4006 dependencies : [versiondep],
4007 install_rpath : rootpkglibdir,
4009 install_dir : rootlibexecdir)
4011 if want_tests != 'false'
4012 test('test-network-generator-conversion',
4013 test_network_generator_conversion_sh,
4014 # https://github.com/mesonbuild/meson/issues/2681
4015 args : exe.full_path(),
4020 'systemd-sulogin-shell',
4021 'src/sulogin-shell/sulogin-shell.c',
4022 include_directories : includes,
4023 link_with : [libshared],
4024 dependencies : [versiondep],
4025 install_rpath : rootpkglibdir,
4027 install_dir : rootlibexecdir)
4029 exe = custom_target(
4031 input : kernel_install_in,
4032 output : 'kernel-install',
4033 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
4034 install : want_kernel_install,
4035 install_mode : 'rwxr-xr-x',
4036 install_dir : bindir)
4037 public_programs += exe
4039 if want_tests != 'false' and want_kernel_install
4040 test('test-kernel-install',
4041 test_kernel_install_sh,
4043 args : [exe.full_path(), loaderentry_install])
4047 exe = custom_target(
4049 input : 'src/ukify/ukify.py',
4051 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
4053 install_mode : 'rwxr-xr-x',
4054 install_dir : rootlibexecdir)
4055 public_programs += exe
4058 ############################################################
4060 runtest_env = custom_target(
4061 'systemd-runtest.env',
4062 output : 'systemd-runtest.env',
4063 command : [sh, '-c',
4064 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
4065 project_source_root / 'test',
4066 project_build_root / 'catalog')],
4068 build_by_default : true)
4070 test_cflags = ['-DTEST_CODE=1']
4071 # We intentionally do not do inline initializations with definitions for a
4072 # bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
4073 # use the variable unexpectedly. This triggers a lot of maybe-uninitialized
4074 # false positives when the combination of -O2 and -flto is used. Suppress them.
4075 if '-O2' in c_args and '-flto=auto' in c_args
4076 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
4079 foreach tuple : tests
4081 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
4082 dependencies = tuple.length() > 2 ? tuple[2] : []
4083 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
4084 condition = tuple.length() > 4 ? tuple[4] : ''
4085 type = tuple.length() > 5 ? tuple[5] : ''
4086 defs = tuple.length() > 6 ? tuple[6] : []
4088 parallel = tuple.length() > 7 ? tuple[7] : true
4091 # FIXME: Use fs.stem() with meson >= 0.54.0
4092 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
4093 if type.startswith('timeout=')
4094 timeout = type.split('=')[1].to_int()
4098 suite = fs.name(fs.parent('@0@'.format(sources[0])))
4099 # FIXME: Use str.replace() with meson >= 0.58.0
4100 suite = suite.split('sd-')[-1]
4102 if condition == '' or conf.get(condition) == 1
4106 include_directories : incs,
4107 link_with : link_with,
4108 dependencies : [versiondep,
4111 build_by_default : want_tests != 'false',
4112 install_rpath : rootpkglibdir,
4113 install : install_tests,
4114 install_dir : testsdir / type,
4115 link_depends : runtest_env)
4118 message('@0@ is a manual test'.format(name))
4119 elif type == 'unsafe' and want_tests != 'unsafe'
4120 message('@0@ is an unsafe test'.format(name))
4121 elif want_tests != 'false'
4126 is_parallel : parallel)
4129 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
4134 'test-libsystemd-sym',
4135 test_libsystemd_sym_c,
4136 include_directories : includes,
4137 link_with : [libsystemd],
4138 build_by_default : want_tests != 'false',
4139 install : install_tests,
4140 install_dir : testsdir)
4141 if want_tests != 'false'
4142 test('test-libsystemd-sym', exe)
4146 'test-libsystemd-static-sym',
4147 test_libsystemd_sym_c,
4148 include_directories : includes,
4149 link_with : [install_libsystemd_static],
4150 dependencies : [threads], # threads is already included in dependencies on the library,
4151 # but does not seem to get propagated. Add here as a work-around.
4152 build_by_default : want_tests != 'false' and static_libsystemd_pic,
4153 install : install_tests and static_libsystemd_pic,
4154 install_dir : testsdir)
4155 if want_tests != 'false' and static_libsystemd_pic
4156 test('test-libsystemd-static-sym', exe)
4162 include_directories : libudev_includes,
4163 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
4164 link_with : [libudev],
4165 build_by_default : want_tests != 'false',
4166 install : install_tests,
4167 install_dir : testsdir)
4168 if want_tests != 'false'
4169 test('test-libudev-sym', exe)
4173 'test-libudev-static-sym',
4175 include_directories : libudev_includes,
4176 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
4177 link_with : [install_libudev_static],
4178 build_by_default : want_tests != 'false' and static_libudev_pic,
4179 install : install_tests and static_libudev_pic,
4180 install_dir : testsdir)
4181 if want_tests != 'false' and static_libudev_pic
4182 test('test-libudev-static-sym', exe)
4185 ############################################################
4189 foreach tuple : fuzzers
4191 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
4192 dependencies = tuple.length() > 2 ? tuple[2] : []
4193 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
4194 defs = tuple.length() > 4 ? tuple[4] : []
4198 dependencies += fuzzing_engine
4200 if fuzzing_engine.found()
4201 dependencies += fuzzing_engine
4203 link_args += ['-fsanitize=fuzzer']
4206 sources += 'src/fuzz/fuzz-main.c'
4208 sources += fuzz_generated_directives
4210 # FIXME: Use fs.stem() with meson >= 0.54.0
4211 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
4216 include_directories : [incs, include_directories('src/fuzz')],
4217 link_with : link_with,
4218 dependencies : [dependencies,
4220 c_args : defs + test_cflags,
4221 link_args: link_args,
4223 build_by_default : fuzzer_build)
4226 if want_tests != 'false' and name in fuzz_regression_tests
4227 # Run the fuzz regression tests without any sanitizers enabled.
4228 # Additional invocations with sanitizers may be added below.
4229 foreach tuple : fuzz_regression_tests[name]
4232 test('@0@_@1@'.format(name, fuzz_in),
4235 args : [fuzz_dir != '' ? project_source_root / fuzz_dir / name / fuzz_in
4236 : fuzz_generated_in_dir / '@0@_@1@'.format(name, fuzz_in)])
4241 alias_target('fuzzers', fuzzer_exes)
4243 ############################################################
4245 subdir('docs/sysvinit')
4246 subdir('docs/var-log')
4249 subdir('modprobe.d')
4252 subdir('shell-completion/bash')
4253 subdir('shell-completion/zsh')
4255 subdir('sysusers.d')
4256 subdir('tmpfiles.d')
4259 install_subdir('factory/etc',
4260 install_dir : factorydir)
4261 subdir('factory/templates')
4263 if install_sysconfdir
4264 install_data('xorg/50-systemd-user.sh',
4265 install_dir : xinitrcdir)
4267 install_data('LICENSE.GPL2',
4271 'docs/CODING_STYLE.md',
4272 'docs/DISTRO_PORTING.md',
4273 'docs/ENVIRONMENT.md',
4275 'docs/TRANSIENT-SETTINGS.md',
4276 'docs/TRANSLATORS.md',
4277 'docs/UIDS-GIDS.md',
4278 install_dir : docdir)
4280 install_subdir('LICENSES',
4281 install_dir : docdir)
4283 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
4284 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
4286 ############################################################
4288 # Ensure that changes to the docs/ directory do not break the
4289 # basic Github pages build. But only run it in developer mode,
4290 # as it might be fragile due to changes in the tooling, and it is
4291 # not generally useful for users.
4292 jekyll = find_program('jekyll', required : false)
4293 if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
4294 test('github-pages',
4296 suite : 'dist-check',
4298 '--source', project_source_root / 'docs',
4299 '--destination', project_build_root / '_site'])
4302 ############################################################
4304 check_help = find_program('tools/check-help.sh')
4305 check_version = find_program('tools/check-version.sh')
4307 foreach exec : public_programs
4308 name = exec.full_path().split('/')[-1]
4309 if want_tests != 'false'
4310 test('check-help-' + name,
4312 suite : 'dist-check',
4313 args : exec.full_path(),
4316 test('check-version-' + name,
4318 suite : 'dist-check',
4319 args : [exec.full_path(),
4320 meson.project_version()],
4325 # Enable tests for all supported sanitizers
4326 foreach tuple : fuzz_sanitizers
4327 sanitizer = tuple[0]
4330 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
4331 foreach fuzzer, fuzz_ins : fuzz_regression_tests
4332 name = '@0@:@1@'.format(fuzzer, sanitizer)
4333 if want_tests == 'false'
4334 message('Not compiling @0@ because tests is set to false'.format(name))
4338 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
4341 exe = custom_target(
4344 depends : [build] + fuzz_generated_directives,
4345 command : [ln, '-fs',
4346 build.full_path() / fuzzer,
4348 build_by_default : true)
4350 foreach tuple : fuzz_ins
4354 test('@0@_@1@_@2@'.format(fuzzer, fuzz_in, sanitizer),
4357 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
4359 args : [exe.full_path(),
4360 fuzz_dir != '' ? project_source_root / fuzz_dir / fuzzer / fuzz_in
4361 : fuzz_generated_in_dir / '@0@_@1@'.format(fuzzer, fuzz_in)])
4368 ############################################################
4371 all_files = run_command(
4372 env, '-u', 'GIT_WORK_TREE',
4373 git, '--git-dir=@0@/.git'.format(project_source_root),
4374 'ls-files', ':/*.[ch]',
4376 if all_files.returncode() == 0
4377 all_files = files(all_files.stdout().split())
4382 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
4385 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
4390 git_contrib_sh = find_program('tools/git-contrib.sh')
4393 command : [git_contrib_sh])
4397 git_head = run_command(
4398 git, '--git-dir=@0@/.git'.format(project_source_root),
4399 'rev-parse', 'HEAD',
4400 check : false).stdout().strip()
4401 git_head_short = run_command(
4402 git, '--git-dir=@0@/.git'.format(project_source_root),
4403 'rev-parse', '--short=7', 'HEAD',
4404 check : false).stdout().strip()
4408 command : [git, 'archive',
4409 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
4411 '--prefix', 'systemd-@0@/'.format(git_head),
4415 ############################################################
4417 check_api_docs_sh = find_program('tools/check-api-docs.sh')
4420 depends : [man, libsystemd, libudev],
4421 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
4423 alias_target('update-dbus-docs', update_dbus_docs)
4424 alias_target('update-man-rules', update_man_rules)
4426 if not meson.is_cross_build()
4428 'export-dbus-interfaces',
4429 output : fs.name(dbus_interfaces_dir),
4430 install : dbus_interfaces_dir != 'no',
4431 install_dir : fs.parent(dbus_interfaces_dir),
4432 command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
4435 ############################################################
4437 alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
4438 check : true).stdout().strip()
4441 'split /usr' : split_usr,
4442 'split bin-sbin' : split_bin,
4443 'prefix directory' : prefixdir,
4444 'rootprefix directory' : rootprefixdir,
4445 'sysconf directory' : sysconfdir,
4446 'include directory' : includedir,
4447 'lib directory' : libdir,
4448 'rootlib directory' : rootlibdir,
4449 'SysV init scripts' : sysvinit_path,
4450 'SysV rc?.d directories' : sysvrcnd_path,
4451 'PAM modules directory' : pamlibdir,
4452 'PAM configuration directory' : pamconfdir,
4453 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
4454 'RPM macros directory' : rpmmacrosdir,
4455 'modprobe.d directory' : modprobedir,
4456 'D-Bus policy directory' : dbuspolicydir,
4457 'D-Bus session directory' : dbussessionservicedir,
4458 'D-Bus system directory' : dbussystemservicedir,
4459 'D-Bus interfaces directory' : dbus_interfaces_dir,
4460 'bash completions directory' : bashcompletiondir,
4461 'zsh completions directory' : zshcompletiondir,
4462 'private shared lib version tag' : shared_lib_tag,
4463 'extra start script' : get_option('rc-local'),
4464 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
4465 get_option('debug-tty')),
4466 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
4467 conf.get('SYSTEM_ALLOC_UID_MIN')),
4468 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
4469 conf.get('SYSTEM_ALLOC_GID_MIN')),
4470 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
4471 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
4472 'static UID/GID allocations' : ' '.join(static_ugids),
4473 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
4474 'render group access mode' : get_option('group-render-mode'),
4475 'certificate root directory' : get_option('certificate-root'),
4476 'support URL' : support_url,
4477 'nobody user name' : nobody_user,
4478 'nobody group name' : nobody_group,
4479 'fallback hostname' : get_option('fallback-hostname'),
4480 'default compression method' : compression,
4481 'default DNSSEC mode' : default_dnssec,
4482 'default DNS-over-TLS mode' : default_dns_over_tls,
4483 'default mDNS mode' : default_mdns,
4484 'default LLMNR mode' : default_llmnr,
4485 'default DNS servers' : dns_servers.split(' '),
4486 'default NTP servers' : ntp_servers.split(' '),
4487 'default cgroup hierarchy' : default_hierarchy,
4488 'default net.naming-scheme value' : default_net_naming_scheme,
4489 'default KillUserProcesses value' : kill_user_processes,
4490 'default locale' : default_locale,
4491 'default nspawn locale' : nspawn_locale,
4492 'default status unit format' : status_unit_format_default,
4493 'default user $PATH' :
4494 default_user_path != '' ? default_user_path : '(same as system services)',
4495 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
4496 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
4499 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
4500 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
4501 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
4522 ['libcryptsetup-plugins'],
4548 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
4578 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
4592 ['legacy-pkla', install_polkit_pkla],
4598 ['man pages', want_man],
4599 ['html pages', want_html],
4600 ['man page indices', want_man and have_lxml],
4602 ['compat-mutable-uid-boundaries'],
4605 ['adm group', get_option('adm-group')],
4606 ['wheel group', get_option('wheel-group')],
4609 ['debug mmap cache'],
4611 ['valgrind', conf.get('VALGRIND') == 1],
4612 ['trace logging', conf.get('LOG_TRACE') == 1],
4613 ['install tests', install_tests],
4614 ['link-udev-shared', get_option('link-udev-shared')],
4615 ['link-systemctl-shared', get_option('link-systemctl-shared')],
4616 ['link-networkd-shared', get_option('link-networkd-shared')],
4617 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
4618 ['link-journalctl-shared', get_option('link-journalctl-shared')],
4619 ['link-boot-shared', get_option('link-boot-shared')],
4620 ['first-boot-full-preset'],
4622 ['standalone-binaries', get_option('standalone-binaries')],
4623 ['coverage', get_option('b_coverage')],
4626 if tuple.length() >= 2
4629 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
4630 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
4631 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
4640 if static_libsystemd == 'false'
4641 missing += 'static-libsystemd'
4643 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
4646 if static_libudev == 'false'
4647 missing += 'static-libudev'
4649 found += 'static-libudev(@0@)'.format(static_libudev)
4652 if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
4653 found += 'cryptolib(openssl)'
4654 elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
4655 found += 'cryptolib(gcrypt)'
4657 missing += 'cryptolib'
4660 if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
4661 found += 'DNS-over-TLS(gnutls)'
4662 elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
4663 found += 'DNS-over-TLS(openssl)'
4665 missing += 'DNS-over-TLS'
4669 'enabled' : ', '.join(found),
4670 'disabled' : ', '.join(missing)},
4671 section : 'Features')
4673 if rootprefixdir != rootprefix_default
4675 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
4676 'systemd used fixed names for unit file directories and other paths, so anything\n' +
4677 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))