1 # SPDX-License-Identifier: LGPL-2.1-or-later
3 project('systemd', 'c',
13 meson_version : '>= 0.53.2',
16 libsystemd_version = '0.35.0'
17 libudev_version = '1.7.5'
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 pkgincludedir = includedir / 'systemd'
188 systemgeneratordir = rootlibexecdir / 'system-generators'
189 usergeneratordir = prefixdir / 'lib/systemd/user-generators'
190 systemenvgeneratordir = prefixdir / 'lib/systemd/system-environment-generators'
191 userenvgeneratordir = prefixdir / 'lib/systemd/user-environment-generators'
192 systemshutdowndir = rootlibexecdir / 'system-shutdown'
193 systemsleepdir = rootlibexecdir / 'system-sleep'
194 systemunitdir = rootprefixdir / 'lib/systemd/system'
195 systempresetdir = rootprefixdir / 'lib/systemd/system-preset'
196 udevlibexecdir = rootprefixdir / 'lib/udev'
197 udevrulesdir = udevlibexecdir / 'rules.d'
198 udevhwdbdir = udevlibexecdir / 'hwdb.d'
199 catalogdir = prefixdir / 'lib/systemd/catalog'
200 kerneldir = prefixdir / 'lib/kernel'
201 kernelinstalldir = kerneldir / 'install.d'
202 factorydir = datadir / 'factory'
203 bootlibdir = prefixdir / 'lib/systemd/boot/efi'
204 testsdir = prefixdir / 'lib/systemd/tests'
205 systemdstatedir = localstatedir / 'lib/systemd'
206 catalogstatedir = systemdstatedir / 'catalog'
207 randomseeddir = localstatedir / 'lib/systemd'
208 profiledir = rootlibexecdir / 'portable' / 'profile'
209 ntpservicelistdir = rootprefixdir / 'lib/systemd/ntp-units.d'
211 docdir = get_option('docdir')
213 docdir = datadir / 'doc/systemd'
216 pamlibdir = get_option('pamlibdir')
218 pamlibdir = rootlibdir / 'security'
221 pamconfdir = get_option('pamconfdir')
223 pamconfdir = prefixdir / 'lib/pam.d'
226 libcryptsetup_plugins_dir = get_option('libcryptsetup-plugins-dir')
227 if libcryptsetup_plugins_dir == ''
228 libcryptsetup_plugins_dir = rootlibdir / 'cryptsetup'
231 memory_accounting_default = get_option('memory-accounting-default')
232 status_unit_format_default = get_option('status-unit-format-default')
233 if status_unit_format_default == 'auto'
234 status_unit_format_default = conf.get('BUILD_MODE_DEVELOPER') == 1 ? 'name' : 'description'
237 conf.set_quoted('BINFMT_DIR', binfmtdir)
238 conf.set_quoted('BOOTLIBDIR', bootlibdir)
239 conf.set_quoted('CATALOG_DATABASE', catalogstatedir / 'database')
240 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
241 conf.set_quoted('DOC_DIR', docdir)
242 conf.set_quoted('DOCUMENT_ROOT', pkgdatadir / 'gatewayd')
243 conf.set_quoted('ENVIRONMENT_DIR', environmentdir)
244 conf.set_quoted('INCLUDE_DIR', includedir)
245 conf.set_quoted('LIBDIR', libdir)
246 conf.set_quoted('MODPROBE_DIR', modprobedir)
247 conf.set_quoted('MODULESLOAD_DIR', modulesloaddir)
248 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
249 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', bindir / 'pkttyagent')
250 conf.set_quoted('PREFIX', prefixdir)
251 conf.set_quoted('RANDOM_SEED', randomseeddir / 'random-seed')
252 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
253 conf.set_quoted('RC_LOCAL_PATH', get_option('rc-local'))
254 conf.set_quoted('ROOTBINDIR', rootbindir)
255 conf.set_quoted('ROOTLIBDIR', rootlibdir)
256 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
257 conf.set_quoted('ROOTPREFIX', rootprefixdir)
258 conf.set_quoted('ROOTPREFIX_NOSLASH', rootprefixdir_noslash)
259 conf.set_quoted('SYSCONF_DIR', sysconfdir)
260 conf.set_quoted('SYSCTL_DIR', sysctldir)
261 conf.set_quoted('SYSTEMCTL_BINARY_PATH', rootbindir / 'systemctl')
262 conf.set_quoted('SYSTEMD_BINARY_PATH', rootlibexecdir / 'systemd')
263 conf.set_quoted('SYSTEMD_CATALOG_DIR', catalogdir)
264 conf.set_quoted('SYSTEMD_CGROUPS_AGENT_PATH', rootlibexecdir / 'systemd-cgroups-agent')
265 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', rootlibexecdir / 'systemd-cryptsetup')
266 conf.set_quoted('SYSTEMD_EXPORT_PATH', rootlibexecdir / 'systemd-export')
267 conf.set_quoted('SYSTEMD_FSCK_PATH', rootlibexecdir / 'systemd-fsck')
268 conf.set_quoted('SYSTEMD_GROWFS_PATH', rootlibexecdir / 'systemd-growfs')
269 conf.set_quoted('SYSTEMD_HOMEWORK_PATH', rootlibexecdir / 'systemd-homework')
270 conf.set_quoted('SYSTEMD_IMPORT_FS_PATH', rootlibexecdir / 'systemd-import-fs')
271 conf.set_quoted('SYSTEMD_IMPORT_PATH', rootlibexecdir / 'systemd-import')
272 conf.set_quoted('SYSTEMD_INTEGRITYSETUP_PATH', rootlibexecdir / 'systemd-integritysetup')
273 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', pkgdatadir / 'kbd-model-map')
274 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', pkgdatadir / 'language-fallback-map')
275 conf.set_quoted('SYSTEMD_MAKEFS_PATH', rootlibexecdir / 'systemd-makefs')
276 conf.set_quoted('SYSTEMD_PULL_PATH', rootlibexecdir / 'systemd-pull')
277 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', rootlibexecdir / 'systemd-shutdown')
278 conf.set_quoted('SYSTEMD_TEST_DATA', testsdir / 'testdata')
279 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', rootbindir / 'systemd-tty-ask-password-agent')
280 conf.set_quoted('SYSTEMD_UPDATE_HELPER_PATH', rootlibexecdir / 'systemd-update-helper')
281 conf.set_quoted('SYSTEMD_USERWORK_PATH', rootlibexecdir / 'systemd-userwork')
282 conf.set_quoted('SYSTEMD_VERITYSETUP_PATH', rootlibexecdir / 'systemd-veritysetup')
283 conf.set_quoted('SYSTEM_CONFIG_UNIT_DIR', pkgsysconfdir / 'system')
284 conf.set_quoted('SYSTEM_DATA_UNIT_DIR', systemunitdir)
285 conf.set_quoted('SYSTEM_ENV_GENERATOR_DIR', systemenvgeneratordir)
286 conf.set_quoted('SYSTEM_GENERATOR_DIR', systemgeneratordir)
287 conf.set_quoted('SYSTEM_PRESET_DIR', systempresetdir)
288 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
289 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
290 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
291 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
292 conf.set_quoted('SYSUSERS_DIR', sysusersdir)
293 conf.set_quoted('TMPFILES_DIR', tmpfilesdir)
294 conf.set_quoted('USER_TMPFILES_DIR', usertmpfilesdir)
295 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
296 conf.set_quoted('UDEV_HWDB_DIR', udevhwdbdir)
297 conf.set_quoted('UDEV_RULES_DIR', udevrulesdir)
298 conf.set_quoted('UPDATE_HELPER_USER_TIMEOUT', get_option('update-helper-user-timeout'))
299 conf.set_quoted('USER_CONFIG_UNIT_DIR', pkgsysconfdir / 'user')
300 conf.set_quoted('USER_DATA_UNIT_DIR', userunitdir)
301 conf.set_quoted('USER_ENV_GENERATOR_DIR', userenvgeneratordir)
302 conf.set_quoted('USER_GENERATOR_DIR', usergeneratordir)
303 conf.set_quoted('USER_KEYRING_PATH', pkgsysconfdir / 'import-pubring.gpg')
304 conf.set_quoted('USER_PRESET_DIR', userpresetdir)
305 conf.set_quoted('VENDOR_KEYRING_PATH', rootlibexecdir / 'import-pubring.gpg')
307 conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
308 conf.set10('ENABLE_URLIFY', get_option('urlify'))
309 conf.set10('ENABLE_FEXECVE', get_option('fexecve'))
310 conf.set10('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default)
311 conf.set('STATUS_UNIT_FORMAT_DEFAULT', 'STATUS_UNIT_FORMAT_' + status_unit_format_default.to_upper())
312 conf.set_quoted('STATUS_UNIT_FORMAT_DEFAULT_STR', status_unit_format_default)
314 conf.set10('FIRST_BOOT_FULL_PRESET', get_option('first-boot-full-preset'))
316 #####################################################################
318 cc = meson.get_compiler('c')
319 pkgconfig = import('pkgconfig')
320 meson_build_sh = find_program('tools/meson-build.sh')
322 want_tests = get_option('tests')
323 slow_tests = want_tests != 'false' and get_option('slow-tests')
324 fuzz_tests = want_tests != 'false' and get_option('fuzz-tests')
325 install_tests = get_option('install-tests')
327 if add_languages('cpp', required : fuzzer_build)
328 # Used only for tests
329 cxx = meson.get_compiler('cpp')
330 cxx_cmd = ' '.join(cxx.cmd_array())
336 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer', required : false)
337 if fuzzing_engine.found()
338 add_project_arguments('-fsanitize-coverage=trace-pc-guard,trace-cmp', language : 'c')
339 elif cc.has_argument('-fsanitize=fuzzer-no-link')
340 add_project_arguments('-fsanitize=fuzzer-no-link', language : 'c')
342 error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported')
345 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
348 # Those generate many false positives, and we do not want to change the code to
350 basic_disabled_warnings = [
351 '-Wno-missing-field-initializers',
352 '-Wno-unused-parameter',
355 possible_common_cc_flags = [
359 '-Werror=format-signedness',
360 '-Werror=implicit-function-declaration',
361 '-Werror=incompatible-pointer-types',
362 '-Werror=int-conversion',
364 '-Werror=override-init',
365 '-Werror=return-type',
366 '-Werror=shift-count-overflow',
367 '-Werror=shift-overflow=2',
370 # gperf prevents us from enabling this because it does not emit fallthrough
371 # attribute with clang.
372 #'-Wimplicit-fallthrough',
373 '-Wimplicit-fallthrough=5',
376 '-Wmissing-include-dirs',
377 '-Wmissing-noreturn',
379 '-Wold-style-definition',
383 '-Wstrict-aliasing=2',
384 '-Wstrict-prototypes',
385 '-Wsuggest-attribute=noreturn',
389 # negative arguments are correctly detected starting with meson 0.46.
390 '-Wno-error=#warnings', # clang
391 '-Wno-string-plus-int', # clang
394 c_args = get_option('c_args')
396 # Our json library does not support -ffinite-math-only, which is enabled by -Ofast or -ffast-math.
397 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)
398 error('-Ofast, -ffast-math, or -ffinite-math-only is specified in c_args.')
401 # Disable -Wmaybe-uninitialized when compiling with -Os/-O1/-O3/etc. There are
402 # too many false positives with gcc >= 8. Effectively, we only test with -O0
403 # and -O2; this should be enough to catch most important cases without too much
404 # busywork. See https://github.com/systemd/systemd/pull/19226.
405 if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or
406 cc.version().version_compare('<10') or
411 possible_common_cc_flags += '-Wno-maybe-uninitialized'
414 # Disable -Wno-unused-result with gcc, see
415 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425.
416 if cc.get_id() == 'gcc'
417 possible_common_cc_flags += '-Wno-unused-result'
420 # --as-needed and --no-undefined are provided by meson by default,
421 # run 'meson configure' to see what is enabled
422 possible_link_flags = [
423 '-Wl,--fatal-warnings',
429 if get_option('b_sanitize') == 'none'
430 possible_link_flags += '-Wl,--warn-common'
433 if cc.get_id() == 'clang'
434 possible_common_cc_flags += [
435 '-Wno-typedef-redefinition',
436 '-Wno-gnu-variable-sized-type-not-at-end',
440 if get_option('mode') == 'release'
441 # We could enable 'pattern' for developer mode, but that can interfere with
442 # valgrind and sanitizer builds. Also, clang does not zero-initialize unions,
443 # breaking some of our code (https://reviews.llvm.org/D68115).
444 possible_common_cc_flags += '-ftrivial-auto-var-init=zero'
447 possible_cc_flags = possible_common_cc_flags + [
448 '-Werror=missing-declarations',
449 '-Werror=missing-prototypes',
450 '-fdiagnostics-show-option',
452 '-fno-strict-aliasing',
454 '-fstack-protector-strong',
455 '-fstrict-flex-arrays=1',
456 '-fvisibility=hidden',
457 '--param=ssp-buffer-size=4',
460 if get_option('buildtype') != 'debug'
461 possible_cc_flags += [
462 '-ffunction-sections',
466 possible_link_flags += '-Wl,--gc-sections'
469 if get_option('mode') == 'developer'
470 possible_cc_flags += '-fno-omit-frame-pointer'
473 add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
474 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
475 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
477 have = cc.has_argument('-Wzero-length-bounds')
478 conf.set10('HAVE_ZERO_LENGTH_BOUNDS', have)
482 #include <inttypes.h>
483 typedef uint64_t usec_t;
484 usec_t now(clockid_t clock);
489 ''', args: '-Werror=shadow', name : '-Werror=shadow with local shadowing')
490 add_project_arguments('-Werror=shadow', language : 'c')
494 add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
497 cpp = ' '.join(cc.cmd_array()) + ' -E'
499 has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
501 #####################################################################
502 # compilation result tests
504 conf.set('_GNU_SOURCE', true)
505 conf.set('__SANE_USERSPACE_TYPES__', true)
506 conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)
508 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
509 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
510 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
511 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
512 conf.set('SIZEOF_TIMEX_MEMBER', cc.sizeof('typeof(((struct timex *)0)->freq)', prefix : '#include <sys/timex.h>'))
514 long_max = cc.compute_int(
516 prefix : '#include <limits.h>',
517 guess : 0x7FFFFFFFFFFFFFFF,
518 high : 0x7FFFFFFFFFFFFFFF)
519 assert(long_max > 100000)
520 conf.set_quoted('LONG_MAX_STR', '@0@'.format(long_max))
524 #include <sys/mount.h>
525 #include <sys/stat.h>
528 foreach decl : ['char16_t',
534 # We get -1 if the size cannot be determined
535 have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
537 if decl == 'struct mount_attr'
539 want_linux_fs_h = false
541 have = cc.sizeof(decl,
542 prefix : decl_headers + '#include <linux/fs.h>',
543 args : '-D_GNU_SOURCE') > 0
544 want_linux_fs_h = have
548 if decl == 'struct statx'
550 want_linux_stat_h = false
552 have = cc.sizeof(decl,
553 prefix : decl_headers + '#include <linux/stat.h>',
554 args : '-D_GNU_SOURCE') > 0
555 want_linux_stat_h = have
559 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
562 conf.set10('WANT_LINUX_STAT_H', want_linux_stat_h)
563 conf.set10('WANT_LINUX_FS_H', want_linux_fs_h)
565 foreach ident : ['secure_getenv', '__secure_getenv']
566 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
570 ['memfd_create', '''#include <sys/mman.h>'''],
571 ['gettid', '''#include <sys/types.h>
572 #include <unistd.h>'''],
573 ['pivot_root', '''#include <stdlib.h>
574 #include <unistd.h>'''], # no known header declares pivot_root
575 ['ioprio_get', '''#include <sched.h>'''], # no known header declares ioprio_get
576 ['ioprio_set', '''#include <sched.h>'''], # no known header declares ioprio_set
577 ['name_to_handle_at', '''#include <sys/types.h>
578 #include <sys/stat.h>
579 #include <fcntl.h>'''],
580 ['setns', '''#include <sched.h>'''],
581 ['renameat2', '''#include <stdio.h>
582 #include <fcntl.h>'''],
583 ['kcmp', '''#include <linux/kcmp.h>'''],
584 ['keyctl', '''#include <sys/types.h>
585 #include <keyutils.h>'''],
586 ['copy_file_range', '''#include <sys/syscall.h>
587 #include <unistd.h>'''],
588 ['bpf', '''#include <sys/syscall.h>
589 #include <unistd.h>'''],
590 ['statx', '''#include <sys/types.h>
591 #include <sys/stat.h>
592 #include <unistd.h>'''],
593 ['explicit_bzero' , '''#include <string.h>'''],
594 ['reallocarray', '''#include <stdlib.h>'''],
595 ['set_mempolicy', '''#include <stdlib.h>
596 #include <unistd.h>'''],
597 ['get_mempolicy', '''#include <stdlib.h>
598 #include <unistd.h>'''],
599 ['pidfd_send_signal', '''#include <stdlib.h>
602 #include <sys/wait.h>'''],
603 ['pidfd_open', '''#include <stdlib.h>
606 #include <sys/wait.h>'''],
607 ['rt_sigqueueinfo', '''#include <stdlib.h>
610 #include <sys/wait.h>'''],
611 ['rt_tgsigqueueinfo', '''#include <stdlib.h>
614 #include <sys/wait.h>'''],
615 ['mallinfo', '''#include <malloc.h>'''],
616 ['mallinfo2', '''#include <malloc.h>'''],
617 ['execveat', '''#include <unistd.h>'''],
618 ['close_range', '''#include <unistd.h>'''],
619 ['epoll_pwait2', '''#include <sys/epoll.h>'''],
620 ['mount_setattr', '''#include <sys/mount.h>'''],
621 ['move_mount', '''#include <sys/mount.h>'''],
622 ['open_tree', '''#include <sys/mount.h>'''],
623 ['fsopen', '''#include <sys/mount.h>'''],
624 ['fsconfig', '''#include <sys/mount.h>'''],
625 ['getdents64', '''#include <dirent.h>'''],
628 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
629 conf.set10('HAVE_' + ident[0].to_upper(), have)
632 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
633 conf.set10('USE_SYS_RANDOM_H', true)
634 conf.set10('HAVE_GETRANDOM', true)
636 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
637 conf.set10('USE_SYS_RANDOM_H', false)
638 conf.set10('HAVE_GETRANDOM', have)
641 #####################################################################
643 version_tag = get_option('version-tag')
645 vcs_data = configuration_data()
646 vcs_data.set('VCS_TAG', version_tag)
647 version_h = configure_file(configuration : vcs_data,
648 input : 'src/version/version.h.in',
649 output : 'version.h')
652 project_source_root + '/tools/meson-vcs-tag.sh',
654 meson.project_version()]
657 input : 'src/version/version.h.in',
658 output : 'version.h',
662 versiondep = declare_dependency(sources: version_h)
664 shared_lib_tag = get_option('shared-lib-tag')
665 if shared_lib_tag == ''
666 shared_lib_tag = meson.project_version()
669 sh = find_program('sh')
670 echo = find_program('echo')
671 sed = find_program('sed')
672 awk = find_program('awk')
673 stat = find_program('stat')
674 ln = find_program('ln')
675 git = find_program('git', required : false)
676 env = find_program('env')
677 perl = find_program('perl', required : false)
678 rsync = find_program('rsync', required : false)
679 meson_make_symlink = project_source_root + '/tools/meson-make-symlink.sh'
681 mkdir_p = 'mkdir -p $DESTDIR/@0@'
683 # If -Dxxx-path option is found, use that. Otherwise, check in $PATH,
684 # /usr/sbin, /sbin, and fall back to the default from middle column.
685 progs = [['quotaon', '/usr/sbin/quotaon' ],
686 ['quotacheck', '/usr/sbin/quotacheck' ],
687 ['kmod', '/usr/bin/kmod' ],
688 ['kexec', '/usr/sbin/kexec' ],
689 ['sulogin', '/usr/sbin/sulogin' ],
690 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
691 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
692 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
693 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
694 ['nologin', '/usr/sbin/nologin', ],
697 path = get_option(prog[0] + '-path')
699 message('Using @1@ for @0@'.format(prog[0], path))
701 exe = find_program(prog[0],
702 '/usr/sbin/' + prog[0],
705 path = exe.found() ? exe.path() : prog[1]
707 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
708 conf.set_quoted(name, path)
711 conf.set_quoted('TELINIT', get_option('telinit-path'))
713 if run_command(ln, '--relative', '--help', check : false).returncode() != 0
714 error('ln does not support --relative (added in coreutils 8.16)')
717 ############################################################
719 python = find_program('python3')
720 if run_command(python, '-c', 'import jinja2', check : false).returncode() != 0
721 error('python3 jinja2 missing')
724 python_310 = run_command(python, '-c',
725 'import sys; sys.exit(0 if sys.version_info >= (3,10) else 1)',
726 check : false).returncode() == 0
727 if get_option('ukify') == 'auto'
728 want_ukify = python_310
729 elif get_option('ukify') == 'true' and not python310
730 error('ukify requires Python >= 3.10')
732 want_ukify = get_option('ukify') == 'true'
735 ############################################################
737 gperf = find_program('gperf')
739 gperf_test_format = '''
741 const char * in_word_set(const char *, @0@);
744 gperf_snippet = run_command(sh, '-c', 'echo foo,bar | "$1" -L ANSI-C', '_', gperf,
746 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
747 if cc.compiles(gperf_test)
748 gperf_len_type = 'size_t'
750 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
751 if cc.compiles(gperf_test)
752 gperf_len_type = 'unsigned'
754 error('unable to determine gperf len type')
757 message('gperf len type is @0@'.format(gperf_len_type))
758 conf.set('GPERF_LEN_TYPE', gperf_len_type,
759 description : 'The type of gperf "len" parameter')
761 ############################################################
763 if not cc.has_header('sys/capability.h')
764 error('POSIX caps headers not found')
766 foreach header : ['crypt.h',
768 'linux/vm_sockets.h',
770 'valgrind/memcheck.h',
771 'valgrind/valgrind.h',
772 'linux/time_types.h',
776 conf.set10('HAVE_' + header.underscorify().to_upper(),
777 cc.has_header(header))
780 ############################################################
782 fallback_hostname = get_option('fallback-hostname')
783 if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0] == '-'
784 error('Invalid fallback-hostname configuration')
785 # A more extensive test is done in test-hostname-util. Let's catch
786 # the most obvious errors here so we don't fail with an assert later.
788 conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
790 default_hierarchy = get_option('default-hierarchy')
791 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
792 description : 'default cgroup hierarchy as string')
793 if default_hierarchy == 'legacy'
794 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
795 elif default_hierarchy == 'hybrid'
796 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
798 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
801 extra_net_naming_schemes = []
802 extra_net_naming_map = []
803 foreach scheme: get_option('extra-net-naming-schemes').split(',')
805 name = scheme.split('=')[0]
806 value = scheme.split('=')[1]
807 NAME = name.underscorify().to_upper()
809 foreach field: value.split('+')
810 VALUE += 'NAMING_' + field.underscorify().to_upper()
812 extra_net_naming_schemes += 'NAMING_@0@ = @1@,'.format(NAME, '|'.join(VALUE))
813 extra_net_naming_map += '{ "@0@", NAMING_@1@ },'.format(name, NAME)
816 conf.set('EXTRA_NET_NAMING_SCHEMES', ' '.join(extra_net_naming_schemes))
817 conf.set('EXTRA_NET_NAMING_MAP', ' '.join(extra_net_naming_map))
819 default_net_naming_scheme = get_option('default-net-naming-scheme')
820 conf.set_quoted('DEFAULT_NET_NAMING_SCHEME', default_net_naming_scheme)
821 if default_net_naming_scheme != 'latest'
822 conf.set('_DEFAULT_NET_NAMING_SCHEME_TEST',
823 'NAMING_' + default_net_naming_scheme.underscorify().to_upper())
826 time_epoch = get_option('time-epoch')
828 time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check : true).stdout().strip()
829 if time_epoch == '' and git.found() and fs.exists('.git')
830 # If we're in a git repository, use the creation time of the latest git tag.
831 latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags',
833 if latest_tag.returncode() == 0
834 time_epoch = run_command(
835 git, 'log', '--no-show-signature', '-1', '--format=%at',
836 latest_tag.stdout().strip(),
837 check : false).stdout()
842 time_epoch = run_command(stat, '-c', '%Y', NEWS,
843 check : true).stdout()
845 time_epoch = time_epoch.strip().to_int()
847 conf.set('TIME_EPOCH', time_epoch)
849 conf.set('CLOCK_VALID_RANGE_USEC_MAX', get_option('clock-valid-range-usec-max'))
851 default_user_shell = get_option('default-user-shell')
852 conf.set_quoted('DEFAULT_USER_SHELL', default_user_shell)
853 conf.set_quoted('DEFAULT_USER_SHELL_NAME', fs.name(default_user_shell))
855 foreach tuple : [['system-alloc-uid-min', 'SYS_UID_MIN', 1], # Also see login.defs(5).
856 ['system-uid-max', 'SYS_UID_MAX', 999],
857 ['system-alloc-gid-min', 'SYS_GID_MIN', 1],
858 ['system-gid-max', 'SYS_GID_MAX', 999]]
859 v = get_option(tuple[0])
863 '/^\s*@0@\s+/ { uid=$2 } END { print uid }'.format(tuple[1]),
865 check : false).stdout().strip()
872 conf.set(tuple[0].underscorify().to_upper(), v)
874 if conf.get('SYSTEM_ALLOC_UID_MIN') >= conf.get('SYSTEM_UID_MAX')
875 error('Invalid uid allocation range')
877 if conf.get('SYSTEM_ALLOC_GID_MIN') >= conf.get('SYSTEM_GID_MAX')
878 error('Invalid gid allocation range')
881 dynamic_uid_min = get_option('dynamic-uid-min')
882 dynamic_uid_max = get_option('dynamic-uid-max')
883 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
884 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
886 container_uid_base_min = get_option('container-uid-base-min')
887 container_uid_base_max = get_option('container-uid-base-max')
888 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
889 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
891 nobody_user = get_option('nobody-user')
892 nobody_group = get_option('nobody-group')
894 if not meson.is_cross_build()
895 getent_result = run_command('getent', 'passwd', '65534', check : false)
896 if getent_result.returncode() == 0
897 name = getent_result.stdout().split(':')[0]
898 if name != nobody_user
900 '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) +
901 'Your build will result in an user table setup that is incompatible with the local system.')
904 id_result = run_command('id', '-u', nobody_user, check : false)
905 if id_result.returncode() == 0
906 id = id_result.stdout().strip().to_int()
909 '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) +
910 'Your build will result in an user table setup that is incompatible with the local system.')
914 getent_result = run_command('getent', 'group', '65534', check : false)
915 if getent_result.returncode() == 0
916 name = getent_result.stdout().split(':')[0]
917 if name != nobody_group
919 '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) +
920 'Your build will result in an group table setup that is incompatible with the local system.')
923 id_result = run_command('id', '-g', nobody_group, check : false)
924 if id_result.returncode() == 0
925 id = id_result.stdout().strip().to_int()
928 '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) +
929 'Your build will result in an group table setup that is incompatible with the local system.')
933 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
935 'The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
936 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
939 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
940 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
943 foreach option : ['adm-gid',
960 'systemd-journal-gid',
961 'systemd-network-uid',
962 'systemd-resolve-uid',
963 'systemd-timesync-uid']
964 name = option.underscorify().to_upper()
965 val = get_option(option)
967 # Ensure provided GID argument is numeric, otherwise fall back to default assignment
968 conf.set(name, val > 0 ? val : '-')
970 static_ugids += '@0@:@1@'.format(option, val)
974 conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
975 conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
977 dev_kvm_mode = get_option('dev-kvm-mode')
978 conf.set_quoted('DEV_KVM_MODE', dev_kvm_mode) # FIXME: convert to 0o… notation
979 conf.set10('DEV_KVM_UACCESS', dev_kvm_mode != '0666')
980 group_render_mode = get_option('group-render-mode')
981 conf.set_quoted('GROUP_RENDER_MODE', group_render_mode)
982 conf.set10('GROUP_RENDER_UACCESS', group_render_mode != '0666')
984 kill_user_processes = get_option('default-kill-user-processes')
985 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
987 dns_servers = get_option('dns-servers')
988 conf.set_quoted('DNS_SERVERS', dns_servers)
990 ntp_servers = get_option('ntp-servers')
991 conf.set_quoted('NTP_SERVERS', ntp_servers)
993 default_locale = get_option('default-locale')
994 conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale)
996 nspawn_locale = get_option('nspawn-locale')
997 conf.set_quoted('SYSTEMD_NSPAWN_LOCALE', nspawn_locale)
999 localegen_path = get_option('localegen-path')
1000 if localegen_path != ''
1001 conf.set_quoted('LOCALEGEN_PATH', localegen_path)
1003 conf.set10('HAVE_LOCALEGEN', localegen_path != '')
1005 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
1007 service_watchdog = get_option('service-watchdog')
1008 watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
1009 conf.set_quoted('SERVICE_WATCHDOG', watchdog_value)
1011 conf.set_quoted('SUSHELL', get_option('debug-shell'))
1012 conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
1014 enable_debug_hashmap = false
1015 enable_debug_mmap_cache = false
1016 enable_debug_siphash = false
1017 foreach name : get_option('debug-extra')
1018 if name == 'hashmap'
1019 enable_debug_hashmap = true
1020 elif name == 'mmap-cache'
1021 enable_debug_mmap_cache = true
1022 elif name == 'siphash'
1023 enable_debug_siphash = true
1025 message('unknown debug option "@0@", ignoring'.format(name))
1028 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
1029 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
1030 conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash)
1032 conf.set10('VALGRIND', get_option('valgrind'))
1033 conf.set10('LOG_TRACE', get_option('log-trace'))
1035 default_user_path = get_option('user-path')
1036 if default_user_path != ''
1037 conf.set_quoted('DEFAULT_USER_PATH', default_user_path)
1041 #####################################################################
1043 threads = dependency('threads')
1044 librt = cc.find_library('rt')
1045 libm = cc.find_library('m')
1046 libdl = cc.find_library('dl')
1047 libcrypt = cc.find_library('crypt')
1049 # On some architectures, libatomic is required. But on some installations,
1050 # it is found, but actual linking fails. So let's try to use it opportunistically.
1051 # If it is installed, but not needed, it will be dropped because of --as-needed.
1052 if cc.links('''int main(int argc, char **argv) { return 0; }''',
1055 libatomic = declare_dependency(link_args : '-latomic')
1060 crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
1062 ['crypt_ra', crypt_header],
1063 ['crypt_preferred_method', crypt_header],
1064 ['crypt_gensalt_ra', crypt_header]]
1066 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
1067 dependencies : libcrypt)
1068 conf.set10('HAVE_' + ident[0].to_upper(), have)
1071 libcap = dependency('libcap', required : false)
1072 if not libcap.found()
1073 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
1074 libcap = cc.find_library('cap')
1077 want_bpf_framework = get_option('bpf-framework')
1078 bpf_compiler = get_option('bpf-compiler')
1079 bpf_framework_required = want_bpf_framework == 'true'
1081 libbpf_version_requirement = '>= 0.1.0'
1082 if bpf_compiler == 'gcc'
1083 libbpf_version_requirement = '>= 1.0.0'
1085 libbpf = dependency('libbpf', required : bpf_framework_required, version : libbpf_version_requirement)
1086 conf.set10('HAVE_LIBBPF', libbpf.found())
1088 bpftool_strip_version_requirement = '>= 5.13.0'
1089 if bpf_compiler == 'gcc'
1090 bpftool_strip_version_requirement = '>= 7.0.0'
1093 if want_bpf_framework == 'false' or not libbpf.found() or skip_deps
1094 conf.set10('BPF_FRAMEWORK', false)
1097 clang_supports_bpf = false
1098 bpf_gcc_found = false
1099 bpftool_strip = false
1102 if bpf_compiler == 'clang'
1103 # Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu
1104 # (like clang-10/llvm-strip-10)
1105 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')
1106 r = find_program('clang', required : bpf_framework_required, version : '>= 10.0.0')
1107 clang_found = r.found()
1111 # Assume that the required flags are supported by the found clang.
1112 clang_supports_flags = clang_found
1115 clang = cc.cmd_array()
1116 clang_supports_flags = cc.has_argument('-Wno-compare-distinct-pointer-types')
1120 # Check if 'clang -target bpf' is supported.
1121 clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0
1123 elif bpf_compiler == 'gcc'
1124 warning('GCC BPF Compiler support is experimental and not recommended.')
1125 bpf_gcc = find_program('bpf-gcc',
1127 version : '>= 12.1.0')
1128 bpf_gcc_found = bpf_gcc.found()
1131 if clang_supports_bpf or bpf_gcc_found
1132 # Debian installs this in /usr/sbin/ which is not in $PATH.
1133 # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian.
1134 # We use 'bpftool gen object' subcommand for bpftool strip, it was added by d80b2fcbe0a023619e0fc73112f2a02c2662f6ab (v5.13).
1135 bpftool_strip_required = bpf_framework_required and bpf_compiler == 'gcc'
1136 bpftool = find_program('bpftool',
1137 '/usr/sbin/bpftool',
1138 required : bpftool_strip_required,
1139 version : bpftool_strip_version_requirement)
1142 bpftool_strip = true
1144 elif bpf_compiler == 'clang'
1145 # We require the 'bpftool gen skeleton' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6).
1146 bpftool = find_program('bpftool',
1147 '/usr/sbin/bpftool',
1148 required : bpf_framework_required,
1149 version : '>= 5.6.0')
1152 # We use `llvm-strip` as a fallback if `bpftool gen object` strip support is not available.
1153 if not bpftool_strip and bpftool.found() and clang_supports_bpf
1154 if not meson.is_cross_build()
1155 llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip',
1156 check : true).stdout().strip()
1158 llvm_strip_bin = 'llvm-strip'
1160 llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0')
1161 deps_found = llvm_strip.found()
1165 # Can build BPF program from source code in restricted C
1166 conf.set10('BPF_FRAMEWORK', deps_found)
1169 libmount = dependency('mount',
1170 version : fuzzer_build ? '>= 0' : '>= 2.30')
1172 want_libfdisk = get_option('fdisk')
1173 if want_libfdisk != 'false' and not skip_deps
1174 libfdisk = dependency('fdisk',
1175 version : '>= 2.32',
1176 required : want_libfdisk == 'true')
1177 have = libfdisk.found()
1182 conf.set10('HAVE_LIBFDISK', have)
1184 want_pwquality = get_option('pwquality')
1185 if want_pwquality != 'false' and not skip_deps
1186 libpwquality = dependency('pwquality', required : want_pwquality == 'true')
1187 have = libpwquality.found()
1192 conf.set10('HAVE_PWQUALITY', have)
1194 want_seccomp = get_option('seccomp')
1195 if want_seccomp != 'false' and not skip_deps
1196 libseccomp = dependency('libseccomp',
1197 version : '>= 2.3.1',
1198 required : want_seccomp == 'true')
1199 have = libseccomp.found()
1204 conf.set10('HAVE_SECCOMP', have)
1206 want_selinux = get_option('selinux')
1207 if want_selinux != 'false' and not skip_deps
1208 libselinux = dependency('libselinux',
1209 version : '>= 2.1.9',
1210 required : want_selinux == 'true')
1211 have = libselinux.found()
1216 conf.set10('HAVE_SELINUX', have)
1218 want_apparmor = get_option('apparmor')
1219 if want_apparmor != 'false' and not skip_deps
1220 libapparmor = dependency('libapparmor',
1221 version : '>= 2.13',
1222 required : want_apparmor == 'true')
1223 have = libapparmor.found()
1228 conf.set10('HAVE_APPARMOR', have)
1230 have = get_option('smack') and get_option('smack-run-label') != ''
1231 conf.set10('HAVE_SMACK_RUN_LABEL', have)
1233 conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
1236 have = get_option('smack') and get_option('smack-default-process-label') != ''
1238 conf.set_quoted('SMACK_DEFAULT_PROCESS_LABEL', get_option('smack-default-process-label'))
1241 want_polkit = get_option('polkit')
1242 install_polkit = false
1243 install_polkit_pkla = false
1244 if want_polkit != 'false' and not skip_deps
1245 install_polkit = true
1247 libpolkit = dependency('polkit-gobject-1',
1249 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
1250 message('Old polkit detected, will install pkla files')
1251 install_polkit_pkla = true
1254 conf.set10('ENABLE_POLKIT', install_polkit)
1256 want_acl = get_option('acl')
1257 if want_acl != 'false' and not skip_deps
1258 libacl = cc.find_library('acl', required : want_acl == 'true')
1259 have = libacl.found()
1264 conf.set10('HAVE_ACL', have)
1266 want_audit = get_option('audit')
1267 if want_audit != 'false' and not skip_deps
1268 libaudit = dependency('audit', required : want_audit == 'true')
1269 have = libaudit.found()
1274 conf.set10('HAVE_AUDIT', have)
1276 want_blkid = get_option('blkid')
1277 if want_blkid != 'false' and not skip_deps
1278 libblkid = dependency('blkid', required : want_blkid == 'true')
1279 have = libblkid.found()
1281 conf.set10('HAVE_BLKID_PROBE_SET_HINT',
1282 have and cc.has_function('blkid_probe_set_hint', dependencies : libblkid))
1287 conf.set10('HAVE_BLKID', have)
1289 want_kmod = get_option('kmod')
1290 if want_kmod != 'false' and not skip_deps
1291 libkmod = dependency('libkmod',
1293 required : want_kmod == 'true')
1294 have = libkmod.found()
1299 conf.set10('HAVE_KMOD', have)
1301 want_xenctrl = get_option('xenctrl')
1302 if want_xenctrl != 'false' and not skip_deps
1303 libxenctrl = dependency('xencontrol',
1305 required : want_xenctrl == 'true')
1306 have = libxenctrl.found()
1311 conf.set10('HAVE_XENCTRL', have)
1313 want_pam = get_option('pam')
1314 if want_pam != 'false' and not skip_deps
1315 libpam = cc.find_library('pam', required : want_pam == 'true')
1316 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1317 have = libpam.found() and libpam_misc.found()
1323 conf.set10('HAVE_PAM', have)
1325 want_microhttpd = get_option('microhttpd')
1326 if want_microhttpd != 'false' and not skip_deps
1327 libmicrohttpd = dependency('libmicrohttpd',
1328 version : '>= 0.9.33',
1329 required : want_microhttpd == 'true')
1330 have = libmicrohttpd.found()
1335 conf.set10('HAVE_MICROHTTPD', have)
1337 want_libcryptsetup = get_option('libcryptsetup')
1338 want_libcryptsetup_plugins = get_option('libcryptsetup-plugins')
1340 if want_libcryptsetup_plugins == 'true' and want_libcryptsetup == 'false'
1341 error('libcryptsetup-plugins can not be requested without libcryptsetup')
1344 if want_libcryptsetup != 'false' and not skip_deps
1345 libcryptsetup = dependency('libcryptsetup',
1346 version : want_libcryptsetup_plugins == 'true' ? '>= 2.4.0' : '>= 2.0.1',
1347 required : want_libcryptsetup == 'true' or want_libcryptsetup_plugins == 'true')
1348 have = libcryptsetup.found()
1350 foreach ident : ['crypt_set_metadata_size',
1351 'crypt_activate_by_signed_key',
1353 'crypt_reencrypt_init_by_passphrase',
1355 'crypt_set_data_offset']
1356 have_ident = have and cc.has_function(
1358 prefix : '#include <libcryptsetup.h>',
1359 dependencies : libcryptsetup)
1360 conf.set10('HAVE_' + ident.to_upper(), have_ident)
1366 conf.set10('HAVE_LIBCRYPTSETUP', have)
1368 if want_libcryptsetup_plugins != 'false' and not skip_deps
1369 have = (cc.has_function(
1370 'crypt_activate_by_token_pin',
1371 prefix : '#include <libcryptsetup.h>',
1372 dependencies : libcryptsetup) and
1374 'crypt_token_external_path',
1375 prefix : '#include <libcryptsetup.h>',
1376 dependencies : libcryptsetup))
1380 conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have)
1382 want_libcurl = get_option('libcurl')
1383 if want_libcurl != 'false' and not skip_deps
1384 libcurl = dependency('libcurl',
1385 version : '>= 7.32.0',
1386 required : want_libcurl == 'true')
1387 have = libcurl.found()
1392 conf.set10('HAVE_LIBCURL', have)
1393 conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
1395 want_libidn = get_option('libidn')
1396 want_libidn2 = get_option('libidn2')
1397 if want_libidn == 'true' and want_libidn2 == 'true'
1398 error('libidn and libidn2 cannot be requested simultaneously')
1401 if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps
1402 libidn = dependency('libidn2',
1403 required : want_libidn2 == 'true')
1404 have = libidn.found()
1409 conf.set10('HAVE_LIBIDN2', have)
1410 if not have and want_libidn != 'false' and not skip_deps
1411 # libidn is used for both libidn and libidn2 objects
1412 libidn = dependency('libidn',
1413 required : want_libidn == 'true')
1414 have = libidn.found()
1418 conf.set10('HAVE_LIBIDN', have)
1420 want_libiptc = get_option('libiptc')
1421 if want_libiptc != 'false' and not skip_deps
1422 libiptc = dependency('libiptc',
1423 required : want_libiptc == 'true')
1424 have = libiptc.found()
1429 conf.set10('HAVE_LIBIPTC', have)
1431 want_qrencode = get_option('qrencode')
1432 if want_qrencode != 'false' and not skip_deps
1433 libqrencode = dependency('libqrencode',
1435 required : want_qrencode == 'true')
1436 have = libqrencode.found()
1441 conf.set10('HAVE_QRENCODE', have)
1443 want_gcrypt = get_option('gcrypt')
1444 if want_gcrypt != 'false' and not skip_deps
1445 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1446 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1447 have = libgcrypt.found() and libgpg_error.found()
1452 # link to neither of the libs if one is not found
1456 conf.set10('HAVE_GCRYPT', have)
1458 want_gnutls = get_option('gnutls')
1459 if want_gnutls != 'false' and not skip_deps
1460 libgnutls = dependency('gnutls',
1461 version : '>= 3.1.4',
1462 required : want_gnutls == 'true')
1463 have = libgnutls.found()
1468 conf.set10('HAVE_GNUTLS', have)
1470 want_openssl = get_option('openssl')
1471 if want_openssl != 'false' and not skip_deps
1472 libopenssl = dependency('openssl',
1473 version : '>= 1.1.0',
1474 required : want_openssl == 'true')
1475 have = libopenssl.found()
1480 conf.set10('HAVE_OPENSSL', have)
1482 want_p11kit = get_option('p11kit')
1483 if want_p11kit != 'false' and not skip_deps
1484 libp11kit = dependency('p11-kit-1',
1485 version : '>= 0.23.3',
1486 required : want_p11kit == 'true')
1487 have = libp11kit.found()
1488 libp11kit_cflags = libp11kit.partial_dependency(includes: true, compile_args: true)
1491 libp11kit_cflags = []
1494 conf.set10('HAVE_P11KIT', have)
1496 want_libfido2 = get_option('libfido2')
1497 if want_libfido2 != 'false' and not skip_deps
1498 if conf.get('HAVE_OPENSSL') == 1
1499 libfido2 = dependency('libfido2',
1500 required : want_libfido2 == 'true')
1501 have = libfido2.found()
1502 elif want_libfido2 == 'true'
1503 error('libfido2=true requires openssl')
1512 conf.set10('HAVE_LIBFIDO2', have)
1514 want_tpm2 = get_option('tpm2')
1515 if want_tpm2 != 'false' and not skip_deps
1516 tpm2 = dependency('tss2-esys tss2-rc tss2-mu',
1517 required : want_tpm2 == 'true')
1519 have_esys3 = tpm2.version().version_compare('>= 3.0.0')
1525 conf.set10('HAVE_TPM2', have)
1526 conf.set10('HAVE_TSS2_ESYS3', have_esys3)
1528 want_elfutils = get_option('elfutils')
1529 if want_elfutils != 'false' and not skip_deps
1530 libdw = dependency('libdw',
1531 required : want_elfutils == 'true')
1532 have = libdw.found()
1534 # New in elfutils 0.177
1535 conf.set10('HAVE_DWELF_ELF_E_MACHINE_STRING',
1536 have and cc.has_function('dwelf_elf_e_machine_string', dependencies : libdw))
1541 conf.set10('HAVE_ELFUTILS', have)
1543 want_zlib = get_option('zlib')
1544 if want_zlib != 'false' and not skip_deps
1545 libz = dependency('zlib',
1546 required : want_zlib == 'true')
1552 conf.set10('HAVE_ZLIB', have)
1554 want_bzip2 = get_option('bzip2')
1555 if want_bzip2 != 'false' and not skip_deps
1556 libbzip2 = cc.find_library('bz2',
1557 required : want_bzip2 == 'true')
1558 have = libbzip2.found()
1563 conf.set10('HAVE_BZIP2', have)
1565 want_xz = get_option('xz')
1566 if want_xz != 'false' and not skip_deps
1567 libxz = dependency('liblzma',
1568 required : want_xz == 'true')
1569 have_xz = libxz.found()
1574 conf.set10('HAVE_XZ', have_xz)
1576 want_lz4 = get_option('lz4')
1577 if want_lz4 != 'false' and not skip_deps
1578 liblz4 = dependency('liblz4',
1579 version : '>= 1.3.0',
1580 required : want_lz4 == 'true')
1581 have_lz4 = liblz4.found()
1586 conf.set10('HAVE_LZ4', have_lz4)
1588 want_zstd = get_option('zstd')
1589 if want_zstd != 'false' and not skip_deps
1590 libzstd = dependency('libzstd',
1591 required : want_zstd == 'true',
1592 version : '>= 1.4.0')
1593 have_zstd = libzstd.found()
1598 conf.set10('HAVE_ZSTD', have_zstd)
1600 conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
1602 compression = get_option('default-compression')
1603 if compression == 'auto'
1605 compression = 'zstd'
1611 compression = 'none'
1613 elif compression == 'zstd' and not have_zstd
1614 error('default-compression=zstd requires zstd')
1615 elif compression == 'lz4' and not have_lz4
1616 error('default-compression=lz4 requires lz4')
1617 elif compression == 'xz' and not have_xz
1618 error('default-compression=xz requires xz')
1620 conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper()))
1622 want_xkbcommon = get_option('xkbcommon')
1623 if want_xkbcommon != 'false' and not skip_deps
1624 libxkbcommon = dependency('xkbcommon',
1625 version : '>= 0.3.0',
1626 required : want_xkbcommon == 'true')
1627 have = libxkbcommon.found()
1632 conf.set10('HAVE_XKBCOMMON', have)
1634 want_pcre2 = get_option('pcre2')
1635 if want_pcre2 != 'false' and not skip_deps
1636 libpcre2 = dependency('libpcre2-8',
1637 required : want_pcre2 == 'true')
1638 have = libpcre2.found()
1643 conf.set10('HAVE_PCRE2', have)
1645 want_glib = get_option('glib')
1646 if want_glib != 'false' and not skip_deps
1647 libglib = dependency('glib-2.0',
1648 version : '>= 2.22.0',
1649 required : want_glib == 'true')
1650 libgobject = dependency('gobject-2.0',
1651 version : '>= 2.22.0',
1652 required : want_glib == 'true')
1653 libgio = dependency('gio-2.0',
1654 required : want_glib == 'true')
1655 have = libglib.found() and libgobject.found() and libgio.found()
1662 conf.set10('HAVE_GLIB', have)
1664 want_dbus = get_option('dbus')
1665 if want_dbus != 'false' and not skip_deps
1666 libdbus = dependency('dbus-1',
1667 version : '>= 1.3.2',
1668 required : want_dbus == 'true')
1669 have = libdbus.found()
1674 conf.set10('HAVE_DBUS', have)
1676 dbusdatadir = datadir / 'dbus-1'
1677 if conf.get('HAVE_DBUS') == 1
1678 dbusdatadir = libdbus.get_variable(pkgconfig: 'datadir', default_value: datadir) / 'dbus-1'
1681 dbuspolicydir = get_option('dbuspolicydir')
1682 if dbuspolicydir == ''
1683 dbuspolicydir = dbusdatadir / 'system.d'
1686 dbussessionservicedir = get_option('dbussessionservicedir')
1687 if dbussessionservicedir == ''
1688 dbussessionservicedir = dbusdatadir / 'services'
1689 if conf.get('HAVE_DBUS') == 1
1690 dbussessionservicedir = libdbus.get_variable(pkgconfig: 'session_bus_services_dir', default_value: dbussessionservicedir)
1694 dbussystemservicedir = get_option('dbussystemservicedir')
1695 if dbussystemservicedir == ''
1696 dbussystemservicedir = dbusdatadir / 'system-services'
1697 if conf.get('HAVE_DBUS') == 1
1698 dbussystemservicedir = libdbus.get_variable(pkgconfig: 'system_bus_services_dir', default_value: dbussystemservicedir)
1702 dbus_interfaces_dir = get_option('dbus-interfaces-dir')
1703 if dbus_interfaces_dir == '' or dbus_interfaces_dir == 'yes'
1704 if meson.is_cross_build() and dbus_interfaces_dir != 'yes'
1705 dbus_interfaces_dir = 'no'
1706 warning('Exporting D-Bus interface XML files is disabled during cross build. Pass path or "yes" to force enable.')
1708 dbus_interfaces_dir = dbusdatadir / 'interfaces'
1709 if conf.get('HAVE_DBUS') == 1
1710 dbus_interfaces_dir = libdbus.get_variable(pkgconfig: 'interfaces_dir', default_value: dbus_interfaces_dir)
1715 # We support one or the other. If gcrypt is available, we assume it's there to
1716 # be used, and use it in preference.
1717 opt = get_option('cryptolib')
1718 if opt == 'openssl' and conf.get('HAVE_OPENSSL') == 0
1719 error('openssl requested as the default cryptolib, but not available')
1721 conf.set10('PREFER_OPENSSL',
1722 opt == 'openssl' or (opt == 'auto' and conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_GCRYPT') == 0))
1723 conf.set10('HAVE_OPENSSL_OR_GCRYPT',
1724 conf.get('HAVE_OPENSSL') == 1 or conf.get('HAVE_GCRYPT') == 1)
1725 lib_openssl_or_gcrypt = conf.get('PREFER_OPENSSL') == 1 ? [libopenssl] : [libgcrypt, libgpg_error]
1727 dns_over_tls = get_option('dns-over-tls')
1728 if dns_over_tls != 'false'
1729 if dns_over_tls == 'gnutls' and conf.get('PREFER_OPENSSL') == 1
1730 error('Sorry, -Ddns-over-tls=gnutls is not supported when openssl is used as the cryptolib')
1733 if dns_over_tls == 'gnutls'
1734 have_openssl = false
1736 have_openssl = conf.get('HAVE_OPENSSL') == 1
1737 if dns_over_tls == 'openssl' and not have_openssl
1738 error('DNS-over-TLS support was requested with openssl, but dependencies are not available')
1741 if dns_over_tls == 'openssl' or have_openssl
1744 have_gnutls = conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0')
1745 if dns_over_tls != 'auto' and not have_gnutls
1746 str = dns_over_tls == 'gnutls' ? ' with gnutls' : ''
1747 error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
1750 have = have_gnutls or have_openssl
1754 have_openssl = false
1756 conf.set10('ENABLE_DNS_OVER_TLS', have)
1757 conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1758 conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
1760 default_dns_over_tls = get_option('default-dns-over-tls')
1762 default_dns_over_tls = 'no'
1764 if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
1765 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.')
1766 default_dns_over_tls = 'no'
1768 conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1769 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
1770 conf.set_quoted('DEFAULT_DNS_OVER_TLS_MODE_STR', default_dns_over_tls)
1772 default_mdns = get_option('default-mdns')
1773 conf.set('DEFAULT_MDNS_MODE',
1774 'RESOLVE_SUPPORT_' + default_mdns.to_upper())
1775 conf.set_quoted('DEFAULT_MDNS_MODE_STR', default_mdns)
1777 default_llmnr = get_option('default-llmnr')
1778 conf.set('DEFAULT_LLMNR_MODE',
1779 'RESOLVE_SUPPORT_' + default_llmnr.to_upper())
1780 conf.set_quoted('DEFAULT_LLMNR_MODE_STR', default_llmnr)
1782 want_repart = get_option('repart')
1783 if want_repart != 'false'
1784 have = conf.get('HAVE_LIBFDISK') == 1
1785 if want_repart == 'true' and not have
1786 error('repart support was requested, but dependencies are not available')
1791 conf.set10('ENABLE_REPART', have)
1793 default_dnssec = get_option('default-dnssec')
1795 default_dnssec = 'no'
1797 if default_dnssec != 'no' and conf.get('HAVE_OPENSSL_OR_GCRYPT') == 0
1798 message('default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.')
1799 default_dnssec = 'no'
1801 conf.set('DEFAULT_DNSSEC_MODE',
1802 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1803 conf.set_quoted('DEFAULT_DNSSEC_MODE_STR', default_dnssec)
1805 want_sysupdate = get_option('sysupdate')
1806 if want_sysupdate != 'false'
1807 have = (conf.get('HAVE_OPENSSL') == 1 and
1808 conf.get('HAVE_LIBFDISK') == 1)
1809 if want_sysupdate == 'true' and not have
1810 error('sysupdate support was requested, but dependencies are not available')
1815 conf.set10('ENABLE_SYSUPDATE', have)
1817 want_importd = get_option('importd')
1818 if want_importd != 'false'
1819 have = (conf.get('HAVE_LIBCURL') == 1 and
1820 conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and
1821 conf.get('HAVE_ZLIB') == 1 and
1822 conf.get('HAVE_XZ') == 1)
1823 if want_importd == 'true' and not have
1824 error('importd support was requested, but dependencies are not available')
1829 conf.set10('ENABLE_IMPORTD', have)
1831 want_kernel_install = get_option('kernel-install')
1832 conf.set10('ENABLE_KERNEL_INSTALL', want_kernel_install)
1834 want_homed = get_option('homed')
1835 if want_homed != 'false'
1836 have = (conf.get('HAVE_OPENSSL') == 1 and
1837 conf.get('HAVE_LIBFDISK') == 1 and
1838 conf.get('HAVE_LIBCRYPTSETUP') == 1)
1839 if want_homed == 'true' and not have
1840 error('homed support was requested, but dependencies are not available')
1845 conf.set10('ENABLE_HOMED', have)
1847 have = have and conf.get('HAVE_PAM') == 1
1848 conf.set10('ENABLE_PAM_HOME', have)
1850 have = get_option('oomd')
1851 conf.set10('ENABLE_OOMD', have)
1853 want_remote = get_option('remote')
1854 if want_remote != 'false'
1855 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1856 conf.get('HAVE_LIBCURL') == 1]
1857 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1858 # it's possible to build one without the other. Complain only if
1859 # support was explicitly requested. The auxiliary files like sysusers
1860 # config should be installed when any of the programs are built.
1861 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1862 error('remote support was requested, but dependencies are not available')
1864 have = have_deps[0] or have_deps[1]
1868 conf.set10('ENABLE_REMOTE', have)
1870 foreach term : ['analyze',
1884 'compat-mutable-uid-boundaries',
1910 have = get_option(term)
1911 name = 'ENABLE_' + term.underscorify().to_upper()
1912 conf.set10(name, have)
1915 enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
1917 foreach tuple : [['nss-mymachines', 'machined'],
1918 ['nss-resolve', 'resolve']]
1919 want = get_option(tuple[0])
1921 have = get_option(tuple[1])
1922 if want == 'true' and not have
1923 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1928 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1929 conf.set10(name, have)
1933 foreach term : ['ENABLE_NSS_MYHOSTNAME',
1934 'ENABLE_NSS_MYMACHINES',
1935 'ENABLE_NSS_RESOLVE',
1936 'ENABLE_NSS_SYSTEMD']
1937 if conf.get(term) == 1
1941 conf.set10('ENABLE_NSS', enable_nss)
1943 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1945 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1947 ############################################################
1953 ############################################################
1955 # Include these now as they provide gnu-efi detection.
1956 subdir('src/fundamental')
1957 subdir('src/boot/efi')
1959 ############################################################
1961 generate_gperfs = find_program('tools/generate-gperfs.py')
1962 make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
1963 make_directive_index_py = find_program('tools/make-directive-index.py')
1964 make_man_index_py = find_program('tools/make-man-index.py')
1965 meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
1966 update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
1967 update_man_rules_py = find_program('tools/update-man-rules.py')
1968 update_hwdb_sh = find_program('tools/update-hwdb.sh')
1969 update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
1970 update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
1971 xml_helper_py = find_program('tools/xml_helper.py')
1972 export_dbus_interfaces_py = find_program('tools/dbus_exporter.py')
1974 ############################################################
1976 if get_option('b_coverage')
1977 add_project_arguments('-include', 'src/basic/coverage.h', language : 'c')
1980 ############################################################
1982 config_h = configure_file(
1983 output : 'config.h',
1984 configuration : conf)
1986 add_project_arguments('-include', 'config.h', language : 'c')
1988 jinja2_cmdline = [meson_render_jinja2, config_h, version_h]
1990 ############################################################
1992 # binaries that have --help and are intended for use by humans,
1993 # usually, but not always, installed in /bin.
1994 public_programs = []
1996 # D-Bus introspection XML export
1999 basic_includes = include_directories(
2005 libsystemd_includes = [basic_includes, include_directories(
2006 'src/libsystemd/sd-bus',
2007 'src/libsystemd/sd-device',
2008 'src/libsystemd/sd-event',
2009 'src/libsystemd/sd-hwdb',
2010 'src/libsystemd/sd-id128',
2011 'src/libsystemd/sd-journal',
2012 'src/libsystemd/sd-netlink',
2013 'src/libsystemd/sd-network',
2014 'src/libsystemd/sd-resolve')]
2016 includes = [libsystemd_includes, include_directories('src/shared')]
2021 subdir('src/libsystemd')
2022 subdir('src/shared')
2024 subdir('src/libudev')
2025 subdir('src/cryptsetup/cryptsetup-tokens')
2027 alias_target('devel', libsystemd_pc, libudev_pc)
2029 libsystemd = shared_library(
2031 version : libsystemd_version,
2032 include_directories : libsystemd_includes,
2033 link_args : ['-shared',
2034 '-Wl,--version-script=' + libsystemd_sym_path],
2035 link_with : [libbasic,
2038 link_whole : [libsystemd_static],
2039 dependencies : [threads,
2041 link_depends : libsystemd_sym,
2043 install_tag: 'libsystemd',
2044 install_dir : rootlibdir)
2046 alias_target('libsystemd', libsystemd)
2048 install_libsystemd_static = static_library(
2052 basic_gcrypt_sources,
2053 basic_compress_sources,
2054 fundamental_sources,
2055 include_directories : libsystemd_includes,
2056 build_by_default : static_libsystemd != 'false',
2057 install : static_libsystemd != 'false',
2058 install_tag: 'libsystemd',
2059 install_dir : rootlibdir,
2060 pic : static_libsystemd_pic,
2061 dependencies : [threads,
2073 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
2075 libudev = shared_library(
2077 version : libudev_version,
2078 include_directories : includes,
2079 link_args : ['-shared',
2080 '-Wl,--version-script=' + libudev_sym_path],
2081 link_with : [libsystemd_static, libshared_static],
2082 link_whole : libudev_basic,
2083 dependencies : [threads],
2084 link_depends : libudev_sym,
2086 install_tag: 'libudev',
2087 install_dir : rootlibdir)
2089 alias_target('libudev', libudev)
2091 install_libudev_static = static_library(
2094 fundamental_sources,
2098 include_directories : includes,
2099 build_by_default : static_libudev != 'false',
2100 install : static_libudev != 'false',
2101 install_tag: 'libudev',
2102 install_dir : rootlibdir,
2103 link_depends : libudev_sym,
2104 dependencies : [libshared_deps,
2107 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
2108 pic : static_libudev_pic)
2110 if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
2111 if conf.get('HAVE_TPM2') == 1
2112 cryptsetup_token_systemd_tpm2 = shared_library(
2113 'cryptsetup-token-systemd-tpm2',
2114 cryptsetup_token_systemd_tpm2_sources,
2115 include_directories : includes,
2116 link_args : ['-shared',
2117 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2118 link_with : [lib_cryptsetup_token_common,
2120 dependencies : [libcryptsetup,
2123 link_depends : cryptsetup_token_sym,
2124 install_rpath : rootpkglibdir,
2126 install_dir : libcryptsetup_plugins_dir)
2129 if conf.get('HAVE_LIBFIDO2') == 1
2130 cryptsetup_token_systemd_fido2 = shared_library(
2131 'cryptsetup-token-systemd-fido2',
2132 cryptsetup_token_systemd_fido2_sources,
2133 include_directories : includes,
2134 link_args : ['-shared',
2135 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2136 link_with : [lib_cryptsetup_token_common,
2138 dependencies : [libcryptsetup,
2141 link_depends : cryptsetup_token_sym,
2142 install_rpath : rootpkglibdir,
2144 install_dir : libcryptsetup_plugins_dir)
2147 if conf.get('HAVE_P11KIT') == 1
2148 cryptsetup_token_systemd_pkcs11 = shared_library(
2149 'cryptsetup-token-systemd-pkcs11',
2150 cryptsetup_token_systemd_pkcs11_sources,
2151 include_directories : includes,
2152 link_args : ['-shared',
2153 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2154 link_with : [lib_cryptsetup_token_common,
2156 dependencies : [libcryptsetup,
2159 link_depends : cryptsetup_token_sym,
2160 install_rpath : rootpkglibdir,
2162 install_dir : libcryptsetup_plugins_dir)
2166 ############################################################
2168 # systemd-analyze requires 'libcore'
2170 # systemd-journal-remote requires 'libjournal_core'
2171 subdir('src/journal')
2172 # systemd-networkd requires 'libsystemd_network'
2173 subdir('src/libsystemd-network')
2175 subdir('src/analyze')
2176 subdir('src/busctl')
2177 subdir('src/coredump')
2178 subdir('src/cryptenroll')
2179 subdir('src/cryptsetup')
2181 subdir('src/hostname')
2182 subdir('src/import')
2183 subdir('src/journal-remote')
2184 subdir('src/kernel-install')
2185 subdir('src/locale')
2187 subdir('src/machine')
2188 subdir('src/network')
2189 subdir('src/nspawn')
2191 subdir('src/partition')
2192 subdir('src/portable')
2193 subdir('src/pstore')
2194 subdir('src/resolve')
2196 subdir('src/shutdown')
2197 subdir('src/sysext')
2198 subdir('src/systemctl')
2199 subdir('src/sysupdate')
2200 subdir('src/timedate')
2201 subdir('src/timesync')
2202 subdir('src/tmpfiles')
2203 subdir('src/userdb')
2204 subdir('src/xdg-autostart-generator')
2206 subdir('src/systemd')
2212 subdir('src/ukify/test') # needs to be last for test_env variable
2214 ############################################################
2216 # only static linking apart from libdl, to make sure that the
2217 # module is linked to all libraries that it uses.
2218 test_dlopen = executable(
2221 include_directories : includes,
2222 link_with : [libbasic],
2223 dependencies : [libdl],
2224 build_by_default : want_tests != 'false')
2226 foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
2227 ['systemd', 'ENABLE_NSS_SYSTEMD', ['nss-systemd.h', 'userdb-glue.c', 'userdb-glue.h']],
2228 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
2229 ['resolve', 'ENABLE_NSS_RESOLVE', [], resolve_includes]]
2231 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
2235 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
2236 version_script_arg = project_source_root / sym
2238 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
2239 if tuple.length() > 2
2240 foreach s : tuple[2]
2241 sources += ['src/nss-@0@/@1@'.format(module, s)]
2245 incs = tuple.length() > 3 ? tuple[3] : includes
2247 nss = shared_library(
2251 include_directories : incs,
2252 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
2253 link_args : ['-Wl,-z,nodelete',
2255 '-Wl,--version-script=' + version_script_arg],
2256 link_with : [libsystemd_static,
2259 dependencies : [threads,
2263 install_tag : 'nss',
2264 install_dir : rootlibdir)
2266 # We cannot use shared_module because it does not support version suffix.
2267 # Unfortunately shared_library insists on creating the symlink…
2268 meson.add_install_script('sh', '-c',
2269 'rm $DESTDIR@0@/libnss_@1@.so'
2270 .format(rootlibdir, module),
2274 if want_tests != 'false'
2275 test('dlopen-nss_' + module,
2277 # path to dlopen must include a slash
2278 args : nss.full_path(),
2284 ############################################################
2289 include_directories : includes,
2290 link_with : [libcore,
2292 dependencies : [libseccomp,
2294 install_rpath : rootpkglibdir,
2296 install_dir : rootlibexecdir)
2297 dbus_programs += exe
2298 public_programs += exe
2300 meson.add_install_script(meson_make_symlink,
2301 rootlibexecdir / 'systemd',
2302 rootsbindir / 'init')
2306 systemd_analyze_sources,
2307 include_directories : core_includes,
2308 link_with : [libcore,
2310 dependencies : [libseccomp,
2312 install_rpath : rootpkglibdir,
2313 install : conf.get('ENABLE_ANALYZE') == 1)
2314 public_programs += exe
2316 if want_tests != 'false'
2317 test('test-compare-versions',
2318 test_compare_versions_sh,
2319 args : exe.full_path())
2324 systemd_journald_sources,
2325 include_directories : includes,
2326 link_with : [libjournal_core,
2328 dependencies : [threads,
2334 install_rpath : rootpkglibdir,
2336 install_dir : rootlibexecdir)
2338 public_programs += executable(
2340 systemd_cat_sources,
2341 include_directories : includes,
2342 link_with : [libjournal_core,
2344 dependencies : [threads,
2346 install_rpath : rootpkglibdir,
2349 if get_option('link-journalctl-shared')
2350 journalctl_link_with = [libshared]
2352 journalctl_link_with = [libsystemd_static,
2357 public_programs += executable(
2360 include_directories : includes,
2361 link_with : [journalctl_link_with],
2362 dependencies : [threads,
2369 install_rpath : rootpkglibdir,
2371 install_dir : rootbindir)
2374 'systemd-getty-generator',
2375 'src/getty-generator/getty-generator.c',
2376 include_directories : includes,
2377 link_with : [libshared],
2378 install_rpath : rootpkglibdir,
2380 install_dir : systemgeneratordir)
2383 'systemd-debug-generator',
2384 'src/debug-generator/debug-generator.c',
2385 include_directories : includes,
2386 link_with : [libshared],
2387 install_rpath : rootpkglibdir,
2389 install_dir : systemgeneratordir)
2392 'systemd-run-generator',
2393 'src/run-generator/run-generator.c',
2394 include_directories : includes,
2395 link_with : [libshared],
2396 install_rpath : rootpkglibdir,
2398 install_dir : systemgeneratordir)
2401 'systemd-fstab-generator',
2402 'src/fstab-generator/fstab-generator.c',
2403 include_directories : includes,
2404 link_with : [libshared],
2405 install_rpath : rootpkglibdir,
2407 install_dir : systemgeneratordir)
2409 meson.add_install_script(meson_make_symlink,
2410 systemgeneratordir / 'systemd-fstab-generator',
2411 rootlibexecdir / 'systemd-sysroot-fstab-check')
2413 if want_tests != 'false'
2414 test('test-fstab-generator',
2415 test_fstab_generator_sh,
2416 # https://github.com/mesonbuild/meson/issues/2681
2417 args : exe.full_path(),
2421 if conf.get('ENABLE_ENVIRONMENT_D') == 1
2423 '30-systemd-environment-d-generator',
2424 'src/environment-d-generator/environment-d-generator.c',
2425 include_directories : includes,
2426 link_with : [libshared],
2427 install_rpath : rootpkglibdir,
2429 install_dir : userenvgeneratordir)
2431 meson.add_install_script(meson_make_symlink,
2432 sysconfdir / 'environment',
2433 environmentdir / '99-environment.conf')
2436 if conf.get('ENABLE_HIBERNATE') == 1
2438 'systemd-hibernate-resume-generator',
2439 'src/hibernate-resume/hibernate-resume-generator.c',
2440 include_directories : includes,
2441 link_with : [libshared],
2442 install_rpath : rootpkglibdir,
2444 install_dir : systemgeneratordir)
2447 'systemd-hibernate-resume',
2448 'src/hibernate-resume/hibernate-resume.c',
2449 include_directories : includes,
2450 link_with : [libshared],
2451 install_rpath : rootpkglibdir,
2453 install_dir : rootlibexecdir)
2456 if conf.get('HAVE_BLKID') == 1
2458 'systemd-gpt-auto-generator',
2459 'src/gpt-auto-generator/gpt-auto-generator.c',
2460 include_directories : includes,
2461 link_with : [libshared],
2462 dependencies : libblkid,
2463 install_rpath : rootpkglibdir,
2465 install_dir : systemgeneratordir)
2467 public_programs += executable(
2469 'src/dissect/dissect.c',
2470 include_directories : includes,
2471 link_with : [libshared],
2472 dependencies : [versiondep],
2473 install_rpath : rootpkglibdir,
2477 if conf.get('ENABLE_RESOLVE') == 1
2478 dbus_programs += executable(
2480 systemd_resolved_sources,
2481 include_directories : resolve_includes,
2482 link_with : [libshared,
2484 libsystemd_resolve_core],
2485 dependencies : systemd_resolved_dependencies,
2486 install_rpath : rootpkglibdir,
2488 install_dir : rootlibexecdir)
2490 public_programs += executable(
2493 include_directories : includes,
2494 link_with : [libshared,
2496 libsystemd_resolve_core],
2497 dependencies : [threads,
2498 lib_openssl_or_gcrypt,
2502 install_rpath : rootpkglibdir,
2505 meson.add_install_script(meson_make_symlink,
2506 bindir / 'resolvectl',
2507 rootsbindir / 'resolvconf')
2509 meson.add_install_script(meson_make_symlink,
2510 bindir / 'resolvectl',
2511 bindir / 'systemd-resolve')
2514 if conf.get('ENABLE_LOGIND') == 1
2515 dbus_programs += executable(
2517 systemd_logind_sources,
2518 include_directories : includes,
2519 link_with : [liblogind_core,
2521 dependencies : [threads,
2524 install_rpath : rootpkglibdir,
2526 install_dir : rootlibexecdir)
2528 public_programs += executable(
2531 include_directories : includes,
2532 link_with : [libshared],
2533 dependencies : [threads,
2538 install_rpath : rootpkglibdir,
2540 install_dir : rootbindir)
2542 public_programs += executable(
2544 'src/login/inhibit.c',
2545 include_directories : includes,
2546 link_with : [libshared],
2547 dependencies : [versiondep],
2548 install_rpath : rootpkglibdir,
2550 install_dir : rootbindir)
2552 if conf.get('HAVE_PAM') == 1
2553 version_script_arg = project_source_root / pam_systemd_sym
2554 pam_systemd = shared_library(
2558 include_directories : includes,
2559 link_args : ['-shared',
2560 '-Wl,--version-script=' + version_script_arg],
2561 link_with : [libsystemd_static,
2563 dependencies : [threads,
2567 link_depends : pam_systemd_sym,
2569 install_tag : 'pam',
2570 install_dir : pamlibdir)
2572 if want_tests != 'false'
2573 test('dlopen-pam_systemd',
2575 # path to dlopen must include a slash
2576 args : pam_systemd.full_path(),
2577 depends : pam_systemd)
2582 'systemd-user-runtime-dir',
2583 user_runtime_dir_sources,
2584 include_directories : includes,
2585 link_with : [libshared],
2586 install_rpath : rootpkglibdir,
2588 install_dir : rootlibexecdir)
2591 if conf.get('HAVE_PAM') == 1
2593 'systemd-user-sessions',
2594 'src/user-sessions/user-sessions.c',
2595 include_directories : includes,
2596 link_with : [libshared],
2597 install_rpath : rootpkglibdir,
2599 install_dir : rootlibexecdir)
2602 if conf.get('HAVE_BLKID') == 1 and conf.get('HAVE_GNU_EFI') == 1
2603 if get_option('link-boot-shared')
2604 boot_link_with = [libshared]
2606 boot_link_with = [libsystemd_static, libshared_static]
2611 ['src/boot/bootctl.c',
2612 'src/boot/bootctl.h',
2613 'src/boot/bootctl-install.c',
2614 'src/boot/bootctl-install.h',
2615 'src/boot/bootctl-random-seed.c',
2616 'src/boot/bootctl-random-seed.h',
2617 'src/boot/bootctl-reboot-to-firmware.c',
2618 'src/boot/bootctl-reboot-to-firmware.h',
2619 'src/boot/bootctl-set-efivar.c',
2620 'src/boot/bootctl-set-efivar.h',
2621 'src/boot/bootctl-status.c',
2622 'src/boot/bootctl-status.h',
2623 'src/boot/bootctl-systemd-efi-options.c',
2624 'src/boot/bootctl-systemd-efi-options.h',
2625 'src/boot/bootctl-uki.c',
2626 'src/boot/bootctl-uki.h',
2627 'src/boot/bootctl-util.c',
2628 'src/boot/bootctl-util.h'],
2629 include_directories : includes,
2630 link_with : [boot_link_with],
2631 dependencies : [libblkid,
2633 install_rpath : rootpkglibdir,
2635 public_programs += exe
2637 if want_tests != 'false'
2638 test('test-bootctl-json',
2639 test_bootctl_json_sh,
2640 args : exe.full_path(),
2644 public_programs += executable(
2645 'systemd-bless-boot',
2646 'src/boot/bless-boot.c',
2647 include_directories : includes,
2648 link_with : [boot_link_with],
2649 dependencies : [libblkid,
2651 install_rpath : rootpkglibdir,
2653 install_dir : rootlibexecdir)
2656 'systemd-bless-boot-generator',
2657 'src/boot/bless-boot-generator.c',
2658 include_directories : includes,
2659 link_with : [boot_link_with],
2660 install_rpath : rootpkglibdir,
2662 install_dir : systemgeneratordir)
2664 if conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_TPM2') == 1
2667 'src/boot/measure.c',
2668 include_directories : includes,
2669 link_with : [libshared],
2670 dependencies : [libopenssl,
2672 install_rpath : rootpkglibdir,
2674 install_dir : rootlibexecdir)
2677 'src/boot/pcrphase.c',
2678 include_directories : includes,
2679 link_with : [libshared],
2680 dependencies : [libopenssl,
2684 install_rpath : rootpkglibdir,
2686 install_dir : rootlibexecdir)
2691 'systemd-boot-check-no-failures',
2692 'src/boot/boot-check-no-failures.c',
2693 include_directories : includes,
2694 link_with : [libshared],
2695 dependencies : [libblkid,
2697 install_rpath : rootpkglibdir,
2699 install_dir : rootlibexecdir)
2701 public_programs += executable(
2702 'systemd-socket-activate',
2703 'src/activate/activate.c',
2704 include_directories : includes,
2705 link_with : [libshared],
2706 dependencies : [threads,
2708 install_rpath : rootpkglibdir,
2711 systemctl = executable(
2714 include_directories : includes,
2715 link_with : systemctl_link_with,
2716 dependencies : [threads,
2723 install_rpath : rootpkglibdir,
2725 install_dir : rootbindir)
2726 public_programs += systemctl
2728 if conf.get('ENABLE_PORTABLED') == 1
2729 dbus_programs += executable(
2730 'systemd-portabled',
2731 systemd_portabled_sources,
2732 include_directories : includes,
2733 link_with : [libshared],
2734 dependencies : [threads,
2737 install_rpath : rootpkglibdir,
2739 install_dir : rootlibexecdir)
2741 public_programs += executable(
2743 'src/portable/portablectl.c',
2744 include_directories : includes,
2745 link_with : [libshared],
2746 dependencies : [threads,
2748 install_rpath : rootpkglibdir,
2750 install_dir : rootbindir)
2753 if conf.get('ENABLE_SYSEXT') == 1
2754 public_programs += executable(
2756 systemd_sysext_sources,
2757 include_directories : includes,
2758 link_with : [libshared],
2759 dependencies : [versiondep],
2760 install_rpath : rootpkglibdir,
2762 install_dir : rootbindir)
2765 if conf.get('ENABLE_USERDB') == 1
2768 systemd_userwork_sources,
2769 include_directories : includes,
2770 link_with : [libshared],
2771 dependencies : [threads,
2773 install_rpath : rootpkglibdir,
2775 install_dir : rootlibexecdir)
2779 systemd_userdbd_sources,
2780 include_directories : includes,
2781 link_with : [libshared],
2782 dependencies : [threads,
2784 install_rpath : rootpkglibdir,
2786 install_dir : rootlibexecdir)
2788 public_programs += executable(
2791 include_directories : includes,
2792 link_with : [libshared],
2793 dependencies : [threads,
2795 install_rpath : rootpkglibdir,
2799 if conf.get('ENABLE_HOMED') == 1
2802 systemd_homework_sources,
2803 include_directories : includes,
2804 link_with : [libshared,
2806 dependencies : [threads,
2813 install_rpath : rootpkglibdir,
2815 install_dir : rootlibexecdir)
2817 dbus_programs += executable(
2819 systemd_homed_sources,
2820 include_directories : home_includes,
2821 link_with : [libshared],
2822 dependencies : [threads,
2827 install_rpath : rootpkglibdir,
2829 install_dir : rootlibexecdir)
2831 public_programs += executable(
2834 include_directories : includes,
2835 link_with : [libshared],
2836 dependencies : [threads,
2842 install_rpath : rootpkglibdir,
2845 if conf.get('HAVE_PAM') == 1
2846 version_script_arg = project_source_root / pam_systemd_home_sym
2847 pam_systemd_home = shared_library(
2851 include_directories : includes,
2852 link_args : ['-shared',
2853 '-Wl,--version-script=' + version_script_arg],
2854 link_with : [libsystemd_static,
2856 dependencies : [threads,
2861 link_depends : pam_systemd_home_sym,
2863 install_tag : 'pam',
2864 install_dir : pamlibdir)
2866 if want_tests != 'false'
2867 test('dlopen-pam_systemd_home',
2869 # path to dlopen must include a slash
2870 args : pam_systemd_home.full_path(),
2871 depends : pam_systemd_home)
2876 foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
2877 (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
2878 meson.add_install_script(meson_make_symlink,
2879 rootbindir / 'systemctl',
2880 rootsbindir / alias)
2883 meson.add_install_script(meson_make_symlink,
2884 rootbindir / 'udevadm',
2885 rootlibexecdir / 'systemd-udevd')
2887 if conf.get('ENABLE_BACKLIGHT') == 1
2889 'systemd-backlight',
2890 'src/backlight/backlight.c',
2891 include_directories : includes,
2892 link_with : [libshared],
2893 install_rpath : rootpkglibdir,
2895 install_dir : rootlibexecdir)
2898 if conf.get('ENABLE_RFKILL') == 1
2901 'src/rfkill/rfkill.c',
2902 include_directories : includes,
2903 link_with : [libshared],
2904 install_rpath : rootpkglibdir,
2906 install_dir : rootlibexecdir)
2910 'systemd-system-update-generator',
2911 'src/system-update-generator/system-update-generator.c',
2912 include_directories : includes,
2913 link_with : [libshared],
2914 install_rpath : rootpkglibdir,
2916 install_dir : systemgeneratordir)
2918 if conf.get('HAVE_LIBCRYPTSETUP') == 1
2920 'systemd-cryptsetup',
2921 systemd_cryptsetup_sources,
2922 include_directories : includes,
2923 link_with : [libshared],
2924 dependencies : [libcryptsetup,
2928 install_rpath : rootpkglibdir,
2930 install_dir : rootlibexecdir)
2933 'systemd-cryptsetup-generator',
2934 'src/cryptsetup/cryptsetup-generator.c',
2935 include_directories : includes,
2936 link_with : [libshared],
2937 install_rpath : rootpkglibdir,
2939 install_dir : systemgeneratordir)
2942 'systemd-veritysetup',
2943 'src/veritysetup/veritysetup.c',
2944 include_directories : includes,
2945 link_with : [libshared],
2946 dependencies : [libcryptsetup,
2948 install_rpath : rootpkglibdir,
2950 install_dir : rootlibexecdir)
2953 'systemd-veritysetup-generator',
2954 'src/veritysetup/veritysetup-generator.c',
2955 include_directories : includes,
2956 link_with : [libshared],
2957 dependencies : [versiondep],
2958 install_rpath : rootpkglibdir,
2960 install_dir : systemgeneratordir)
2962 public_programs += executable(
2963 'systemd-cryptenroll',
2964 systemd_cryptenroll_sources,
2965 include_directories : includes,
2966 link_with : [libshared],
2967 dependencies : [libcryptsetup,
2972 install_rpath : rootpkglibdir,
2976 'systemd-integritysetup',
2977 ['src/integritysetup/integritysetup.c', 'src/integritysetup/integrity-util.c'],
2978 include_directories : includes,
2979 link_with : [libshared],
2980 dependencies : [libcryptsetup,
2982 install_rpath : rootpkglibdir,
2984 install_dir : rootlibexecdir)
2987 'systemd-integritysetup-generator',
2988 ['src/integritysetup/integritysetup-generator.c', 'src/integritysetup/integrity-util.c'],
2989 include_directories : includes,
2990 link_with : [libshared],
2991 install_rpath : rootpkglibdir,
2993 install_dir : systemgeneratordir)
2996 if conf.get('HAVE_SYSV_COMPAT') == 1
2998 'systemd-sysv-generator',
2999 'src/sysv-generator/sysv-generator.c',
3000 include_directories : includes,
3001 link_with : [libshared],
3002 install_rpath : rootpkglibdir,
3004 install_dir : systemgeneratordir)
3006 sysv_generator_test_py = find_program('test/sysv-generator-test.py')
3007 if want_tests != 'false'
3008 test('sysv-generator-test',
3009 sysv_generator_test_py,
3014 'systemd-rc-local-generator',
3015 'src/rc-local-generator/rc-local-generator.c',
3016 include_directories : includes,
3017 link_with : [libshared],
3018 install_rpath : rootpkglibdir,
3020 install_dir : systemgeneratordir)
3023 if conf.get('ENABLE_XDG_AUTOSTART') == 1
3025 'systemd-xdg-autostart-generator',
3026 systemd_xdg_autostart_generator_sources,
3027 include_directories : includes,
3028 link_with : [libshared],
3029 install_rpath : rootpkglibdir,
3031 install_dir : usergeneratordir)
3034 'systemd-xdg-autostart-condition',
3035 'src/xdg-autostart-generator/xdg-autostart-condition.c',
3036 include_directories : includes,
3037 link_with : [libshared],
3038 install_rpath : rootpkglibdir,
3040 install_dir : rootlibexecdir)
3043 if conf.get('ENABLE_HOSTNAMED') == 1
3044 dbus_programs += executable(
3045 'systemd-hostnamed',
3046 'src/hostname/hostnamed.c',
3047 include_directories : includes,
3048 link_with : [libshared],
3049 install_rpath : rootpkglibdir,
3051 install_dir : rootlibexecdir)
3053 public_programs += executable(
3055 'src/hostname/hostnamectl.c',
3056 include_directories : includes,
3057 link_with : [libshared],
3058 dependencies : [versiondep],
3059 install_rpath : rootpkglibdir,
3063 if conf.get('ENABLE_LOCALED') == 1
3064 if conf.get('HAVE_XKBCOMMON') == 1
3065 # logind will load libxkbcommon.so dynamically on its own, but we still
3066 # need to specify where the headers are
3068 libxkbcommon.partial_dependency(compile_args: true),
3074 dbus_programs += executable(
3076 systemd_localed_sources,
3077 include_directories : includes,
3078 link_with : [libshared],
3079 dependencies : deps,
3080 install_rpath : rootpkglibdir,
3082 install_dir : rootlibexecdir)
3084 public_programs += executable(
3087 include_directories : includes,
3088 link_with : [libshared],
3089 dependencies : [versiondep],
3090 install_rpath : rootpkglibdir,
3094 if conf.get('ENABLE_TIMEDATED') == 1
3095 dbus_programs += executable(
3096 'systemd-timedated',
3097 'src/timedate/timedated.c',
3098 include_directories : includes,
3099 link_with : [libshared],
3100 install_rpath : rootpkglibdir,
3102 install_dir : rootlibexecdir)
3105 if conf.get('ENABLE_TIMEDATECTL') == 1
3106 public_programs += executable(
3108 'src/timedate/timedatectl.c',
3109 include_directories : includes,
3110 install_rpath : rootpkglibdir,
3111 link_with : [libshared],
3112 dependencies : [libm,
3117 if conf.get('ENABLE_TIMESYNCD') == 1
3119 'systemd-timesyncd',
3120 systemd_timesyncd_sources,
3121 include_directories : includes,
3122 link_with : [libtimesyncd_core],
3123 dependencies : [threads,
3126 install_rpath : rootpkglibdir,
3128 install_dir : rootlibexecdir)
3131 'systemd-time-wait-sync',
3132 'src/timesync/wait-sync.c',
3133 include_directories : includes,
3134 link_with : [libtimesyncd_core],
3135 install_rpath : rootpkglibdir,
3137 install_dir : rootlibexecdir)
3140 if conf.get('ENABLE_MACHINED') == 1
3141 dbus_programs += executable(
3143 systemd_machined_sources,
3144 include_directories : includes,
3145 link_with : [libmachine_core,
3147 install_rpath : rootpkglibdir,
3149 install_dir : rootlibexecdir)
3151 public_programs += executable(
3153 'src/machine/machinectl.c',
3154 include_directories : includes,
3155 link_with : [libshared],
3156 dependencies : [threads,
3161 install_rpath : rootpkglibdir,
3163 install_dir : rootbindir)
3166 if conf.get('ENABLE_IMPORTD') == 1
3167 dbus_programs += executable(
3169 systemd_importd_sources,
3170 include_directories : includes,
3171 link_with : [libshared],
3172 dependencies : [threads,
3174 install_rpath : rootpkglibdir,
3176 install_dir : rootlibexecdir)
3178 systemd_pull = executable(
3180 systemd_pull_sources,
3181 include_directories : includes,
3182 link_with : [libshared,
3184 dependencies : [libcurl,
3185 lib_openssl_or_gcrypt,
3190 install_rpath : rootpkglibdir,
3192 install_dir : rootlibexecdir)
3194 systemd_import = executable(
3196 systemd_import_sources,
3197 include_directories : includes,
3198 link_with : [libshared,
3200 dependencies : [libcurl,
3205 install_rpath : rootpkglibdir,
3207 install_dir : rootlibexecdir)
3209 systemd_import_fs = executable(
3210 'systemd-import-fs',
3211 systemd_import_fs_sources,
3212 include_directories : includes,
3213 link_with : [libshared,
3215 dependencies : [versiondep],
3216 install_rpath : rootpkglibdir,
3218 install_dir : rootlibexecdir)
3220 systemd_export = executable(
3222 systemd_export_sources,
3223 include_directories : includes,
3224 link_with : [libshared,
3226 dependencies : [libcurl,
3231 install_rpath : rootpkglibdir,
3233 install_dir : rootlibexecdir)
3235 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
3238 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
3239 public_programs += executable(
3240 'systemd-journal-upload',
3241 systemd_journal_upload_sources,
3242 include_directories : includes,
3243 link_with : [libshared],
3244 dependencies : [threads,
3251 install_rpath : rootpkglibdir,
3253 install_dir : rootlibexecdir)
3256 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
3257 public_programs += executable(
3258 'systemd-journal-remote',
3259 systemd_journal_remote_sources,
3260 include_directories : journal_includes,
3261 link_with : [libshared,
3262 libsystemd_journal_remote],
3263 dependencies : [threads,
3270 install_rpath : rootpkglibdir,
3272 install_dir : rootlibexecdir)
3274 public_programs += executable(
3275 'systemd-journal-gatewayd',
3276 systemd_journal_gatewayd_sources,
3277 include_directories : journal_includes,
3278 link_with : [libshared],
3279 dependencies : [threads,
3286 install_rpath : rootpkglibdir,
3288 install_dir : rootlibexecdir)
3291 if conf.get('ENABLE_COREDUMP') == 1
3294 systemd_coredump_sources,
3295 include_directories : includes,
3296 link_with : [libshared,
3298 dependencies : [threads,
3304 install_rpath : rootpkglibdir,
3306 install_dir : rootlibexecdir)
3308 public_programs += executable(
3310 coredumpctl_sources,
3311 include_directories : includes,
3312 link_with : [libshared,
3314 dependencies : [threads,
3319 install_rpath : rootpkglibdir,
3323 if conf.get('ENABLE_PSTORE') == 1
3326 systemd_pstore_sources,
3327 include_directories : includes,
3328 link_with : [libshared],
3329 dependencies : [threads,
3335 install_rpath : rootpkglibdir,
3337 install_dir : rootlibexecdir)
3340 if conf.get('ENABLE_OOMD') == 1
3341 dbus_programs += executable('systemd-oomd',
3342 systemd_oomd_sources,
3343 include_directories : includes,
3344 link_with : [libshared],
3345 dependencies : [libatomic,
3347 install_rpath : rootpkglibdir,
3349 install_dir : rootlibexecdir)
3351 public_programs += executable(
3354 include_directories : includes,
3355 link_with : [libshared],
3356 dependencies : [versiondep],
3357 install_rpath : rootpkglibdir,
3361 if conf.get('ENABLE_BINFMT') == 1
3362 public_programs += executable(
3364 'src/binfmt/binfmt.c',
3365 include_directories : includes,
3366 link_with : [libshared],
3367 dependencies : [versiondep],
3368 install_rpath : rootpkglibdir,
3370 install_dir : rootlibexecdir)
3372 meson.add_install_script('sh', '-c',
3373 mkdir_p.format(binfmtdir))
3374 if install_sysconfdir
3375 meson.add_install_script('sh', '-c',
3376 mkdir_p.format(sysconfdir / 'binfmt.d'))
3380 if conf.get('ENABLE_SYSUPDATE') == 1
3382 'systemd-sysupdate',
3383 systemd_sysupdate_sources,
3384 include_directories : includes,
3385 link_with : [libshared,
3387 dependencies : [threads,
3392 install_rpath : rootpkglibdir,
3394 install_dir : rootlibexecdir)
3395 public_programs += exe
3398 if conf.get('ENABLE_VCONSOLE') == 1
3400 'systemd-vconsole-setup',
3401 'src/vconsole/vconsole-setup.c',
3402 include_directories : includes,
3403 link_with : [libshared],
3404 install_rpath : rootpkglibdir,
3406 install_dir : rootlibexecdir)
3409 if conf.get('ENABLE_RANDOMSEED') == 1
3411 'systemd-random-seed',
3412 'src/random-seed/random-seed.c',
3413 include_directories : includes,
3414 link_with : [libshared],
3415 dependencies : [versiondep],
3416 install_rpath : rootpkglibdir,
3418 install_dir : rootlibexecdir)
3421 if conf.get('ENABLE_FIRSTBOOT') == 1
3422 public_programs += executable(
3423 'systemd-firstboot',
3424 'src/firstboot/firstboot.c',
3425 include_directories : includes,
3426 link_with : [libshared],
3427 dependencies : [libcrypt,
3429 install_rpath : rootpkglibdir,
3431 install_dir : rootbindir)
3435 'systemd-remount-fs',
3436 'src/remount-fs/remount-fs.c',
3437 include_directories : includes,
3438 link_with : [libshared],
3439 dependencies : [versiondep],
3440 install_rpath : rootpkglibdir,
3442 install_dir : rootlibexecdir)
3445 'systemd-machine-id-setup',
3446 'src/machine-id-setup/machine-id-setup-main.c',
3447 include_directories : includes,
3448 link_with : [libshared],
3449 dependencies : [versiondep],
3450 install_rpath : rootpkglibdir,
3452 install_dir : rootbindir)
3457 include_directories : includes,
3458 link_with : [libshared],
3459 dependencies : [versiondep],
3460 install_rpath : rootpkglibdir,
3462 install_dir : rootlibexecdir)
3466 'src/partition/growfs.c',
3467 include_directories : includes,
3468 link_with : [libshared],
3469 dependencies : [versiondep],
3470 install_rpath : rootpkglibdir,
3472 install_dir : rootlibexecdir)
3476 'src/partition/makefs.c',
3477 include_directories : includes,
3478 link_with : [libshared],
3479 dependencies : [versiondep],
3480 install_rpath : rootpkglibdir,
3482 install_dir : rootlibexecdir)
3486 'src/sleep/sleep.c',
3487 include_directories : includes,
3488 link_with : [libshared],
3489 dependencies : [versiondep],
3490 install_rpath : rootpkglibdir,
3492 install_dir : rootlibexecdir)
3494 if install_sysconfdir_samples
3495 install_data('src/sleep/sleep.conf',
3496 install_dir : pkgsysconfdir)
3499 public_programs += executable(
3501 'src/sysctl/sysctl.c',
3502 include_directories : includes,
3503 link_with : [libshared],
3504 dependencies : [versiondep],
3505 install_rpath : rootpkglibdir,
3507 install_dir : rootlibexecdir)
3509 public_programs += executable(
3511 'src/ac-power/ac-power.c',
3512 include_directories : includes,
3513 link_with : [libshared],
3514 dependencies : [versiondep],
3515 install_rpath : rootpkglibdir,
3518 public_programs += executable(
3519 'systemd-detect-virt',
3520 'src/detect-virt/detect-virt.c',
3521 include_directories : includes,
3522 link_with : [libshared],
3523 dependencies : [versiondep],
3524 install_rpath : rootpkglibdir,
3527 public_programs += executable(
3529 'src/delta/delta.c',
3530 include_directories : includes,
3531 link_with : [libshared],
3532 dependencies : [versiondep],
3533 install_rpath : rootpkglibdir,
3536 public_programs += executable(
3538 'src/escape/escape.c',
3539 include_directories : includes,
3540 link_with : [libshared],
3541 dependencies : [versiondep],
3542 install_rpath : rootpkglibdir,
3544 install_dir : rootbindir)
3546 public_programs += executable(
3548 'src/notify/notify.c',
3549 include_directories : includes,
3550 link_with : [libshared],
3551 dependencies : [versiondep],
3552 install_rpath : rootpkglibdir,
3554 install_dir : rootbindir)
3556 public_programs += executable(
3558 'src/creds/creds.c',
3559 include_directories : includes,
3560 link_with : [libshared],
3561 dependencies : [threads,
3564 install_rpath : rootpkglibdir,
3566 install_dir : rootbindir)
3569 'systemd-volatile-root',
3570 'src/volatile-root/volatile-root.c',
3571 include_directories : includes,
3572 link_with : [libshared],
3573 install_rpath : rootpkglibdir,
3574 install : conf.get('ENABLE_INITRD') == 1,
3575 install_dir : rootlibexecdir)
3578 'systemd-cgroups-agent',
3579 'src/cgroups-agent/cgroups-agent.c',
3580 include_directories : includes,
3581 link_with : [libshared],
3582 install_rpath : rootpkglibdir,
3584 install_dir : rootlibexecdir)
3586 systemd_id128 = executable(
3588 'src/id128/id128.c',
3589 include_directories : includes,
3590 link_with : [libshared],
3591 dependencies : [versiondep],
3592 install_rpath : rootpkglibdir,
3594 public_programs += systemd_id128
3596 if want_tests != 'false'
3597 test('test-systemctl-enable',
3598 test_systemctl_enable_sh,
3599 # https://github.com/mesonbuild/meson/issues/2681
3600 args : [systemctl.full_path(),
3601 systemd_id128.full_path()])
3604 public_programs += executable(
3607 include_directories : includes,
3608 link_with : [libshared],
3609 dependencies : [versiondep],
3610 install_rpath : rootpkglibdir,
3613 public_programs += executable(
3614 'systemd-ask-password',
3615 'src/ask-password/ask-password.c',
3616 include_directories : includes,
3617 link_with : [libshared],
3618 dependencies : [versiondep],
3619 install_rpath : rootpkglibdir,
3621 install_dir : rootbindir)
3624 'systemd-reply-password',
3625 'src/reply-password/reply-password.c',
3626 include_directories : includes,
3627 link_with : [libshared],
3628 install_rpath : rootpkglibdir,
3630 install_dir : rootlibexecdir)
3632 public_programs += executable(
3633 'systemd-tty-ask-password-agent',
3634 'src/tty-ask-password-agent/tty-ask-password-agent.c',
3635 include_directories : includes,
3636 link_with : [libshared],
3637 dependencies : [versiondep],
3638 install_rpath : rootpkglibdir,
3640 install_dir : rootbindir)
3642 public_programs += executable(
3645 include_directories : includes,
3646 link_with : [libshared],
3647 dependencies : [versiondep],
3648 install_rpath : rootpkglibdir,
3651 public_programs += executable(
3653 'src/cgtop/cgtop.c',
3654 include_directories : includes,
3655 link_with : [libshared],
3656 dependencies : [versiondep],
3657 install_rpath : rootpkglibdir,
3662 'src/initctl/initctl.c',
3663 include_directories : includes,
3664 link_with : [libshared],
3665 install_rpath : rootpkglibdir,
3666 install : (conf.get('HAVE_SYSV_COMPAT') == 1),
3667 install_dir : rootlibexecdir)
3669 public_programs += executable(
3671 'src/mount/mount-tool.c',
3672 include_directories : includes,
3673 link_with : [libshared],
3674 dependencies: [libmount,
3676 install_rpath : rootpkglibdir,
3679 meson.add_install_script(meson_make_symlink,
3680 'systemd-mount', bindir / 'systemd-umount')
3682 public_programs += executable(
3685 include_directories : includes,
3686 link_with : [libshared],
3687 dependencies : [versiondep],
3688 install_rpath : rootpkglibdir,
3691 public_programs += executable(
3692 'systemd-stdio-bridge',
3693 'src/stdio-bridge/stdio-bridge.c',
3694 include_directories : includes,
3695 link_with : [libshared],
3696 dependencies : [versiondep,
3698 install_rpath : rootpkglibdir,
3701 public_programs += executable(
3704 include_directories : includes,
3705 link_with : [libshared],
3706 dependencies : [versiondep],
3707 install_rpath : rootpkglibdir,
3713 'src/sysusers/sysusers.c',
3714 include_directories : includes,
3715 link_with : [libshared],
3716 dependencies : [versiondep],
3717 install_rpath : rootpkglibdir,
3719 install_dir : rootbindir)
3720 public_programs += exe
3722 if want_tests != 'false'
3723 test('test-sysusers',
3725 # https://github.com/mesonbuild/meson/issues/2681
3726 args : exe.full_path())
3729 if have_standalone_binaries
3731 'systemd-sysusers.standalone',
3732 'src/sysusers/sysusers.c',
3733 include_directories : includes,
3734 c_args : '-DSTANDALONE',
3735 link_with : [libshared_static,
3739 dependencies : [versiondep],
3741 install_dir : rootbindir)
3742 public_programs += exe
3744 if want_tests != 'false'
3745 test('test-sysusers.standalone',
3747 # https://github.com/mesonbuild/meson/issues/2681
3748 args : exe.full_path())
3753 if conf.get('ENABLE_TMPFILES') == 1
3756 systemd_tmpfiles_sources,
3757 include_directories : includes,
3758 link_with : [libshared],
3759 dependencies : [libacl,
3761 install_rpath : rootpkglibdir,
3763 install_dir : rootbindir)
3764 public_programs += exe
3766 if want_tests != 'false'
3767 test('test-systemd-tmpfiles',
3768 test_systemd_tmpfiles_py,
3769 # https://github.com/mesonbuild/meson/issues/2681
3770 args : exe.full_path())
3773 if have_standalone_binaries
3775 'systemd-tmpfiles.standalone',
3776 systemd_tmpfiles_sources,
3777 include_directories : includes,
3778 c_args : '-DSTANDALONE',
3779 link_with : [libshared_static,
3783 dependencies : [libacl,
3786 install_dir : rootbindir)
3787 public_programs += exe
3789 if want_tests != 'false'
3790 test('test-systemd-tmpfiles.standalone',
3791 test_systemd_tmpfiles_py,
3792 # https://github.com/mesonbuild/meson/issues/2681
3793 args : exe.full_path())
3798 if conf.get('ENABLE_HWDB') == 1
3799 systemd_hwdb = executable(
3802 include_directories : includes,
3803 link_with : udev_link_with,
3804 dependencies : [versiondep],
3805 install_rpath : udev_rpath,
3807 install_dir : rootbindir)
3808 public_programs += systemd_hwdb
3810 if want_tests != 'false'
3813 suite : 'dist-check',
3814 args : [systemd_hwdb.full_path()],
3819 if conf.get('ENABLE_QUOTACHECK') == 1
3821 'systemd-quotacheck',
3822 'src/quotacheck/quotacheck.c',
3823 include_directories : includes,
3824 link_with : [libshared],
3825 install_rpath : rootpkglibdir,
3827 install_dir : rootlibexecdir)
3830 public_programs += executable(
3831 'systemd-socket-proxyd',
3832 'src/socket-proxy/socket-proxyd.c',
3833 include_directories : includes,
3834 link_with : [libshared],
3835 dependencies : [threads,
3837 install_rpath : rootpkglibdir,
3839 install_dir : rootlibexecdir)
3841 udevadm = executable(
3844 include_directories : includes,
3845 link_with : [libudevd_core],
3846 dependencies : [threads,
3852 install_rpath : udev_rpath,
3854 install_dir : rootbindir)
3855 public_programs += udevadm
3857 if conf.get('ENABLE_REPART') == 1
3860 systemd_repart_sources,
3861 include_directories : includes,
3862 link_with : [libshared,
3864 dependencies : [threads,
3869 install_rpath : rootpkglibdir,
3871 install_dir : rootbindir)
3872 public_programs += exe
3874 if have_standalone_binaries
3876 'systemd-repart.standalone',
3877 systemd_repart_sources,
3878 include_directories : includes,
3879 c_args : '-DSTANDALONE',
3880 link_with : [libshared_static,
3885 dependencies : [threads,
3890 install_rpath : rootpkglibdir,
3892 install_dir : rootbindir)
3893 public_programs += exe
3899 systemd_shutdown_sources,
3900 include_directories : includes,
3901 link_with : [libshared],
3902 dependencies : [libmount,
3904 install_rpath : rootpkglibdir,
3906 install_dir : rootlibexecdir)
3908 if have_standalone_binaries
3910 'systemd-shutdown.standalone',
3911 systemd_shutdown_sources,
3912 include_directories : includes,
3913 c_args : '-DSTANDALONE',
3914 link_with : [libshared_static,
3917 dependencies : [libmount,
3919 install_rpath : rootpkglibdir,
3921 install_dir : rootlibexecdir)
3925 'systemd-update-done',
3926 'src/update-done/update-done.c',
3927 include_directories : includes,
3928 link_with : [libshared],
3929 dependencies : [versiondep],
3930 install_rpath : rootpkglibdir,
3932 install_dir : rootlibexecdir)
3935 'systemd-update-utmp',
3936 'src/update-utmp/update-utmp.c',
3937 include_directories : includes,
3938 link_with : [libshared],
3939 dependencies : [libaudit,
3941 install_rpath : rootpkglibdir,
3942 install : (conf.get('ENABLE_UTMP') == 1),
3943 install_dir : rootlibexecdir)
3945 if conf.get('HAVE_KMOD') == 1
3947 'systemd-modules-load',
3948 'src/modules-load/modules-load.c',
3949 include_directories : includes,
3950 link_with : [libshared],
3951 dependencies : [libkmod,
3953 install_rpath : rootpkglibdir,
3955 install_dir : rootlibexecdir)
3957 meson.add_install_script('sh', '-c',
3958 mkdir_p.format(modulesloaddir))
3959 if install_sysconfdir
3960 meson.add_install_script('sh', '-c',
3961 mkdir_p.format(sysconfdir / 'modules-load.d'))
3965 public_programs += executable(
3967 systemd_nspawn_sources,
3968 include_directories : includes,
3969 link_with : [libnspawn_core,
3971 dependencies : [libblkid,
3974 install_rpath : rootpkglibdir,
3977 if conf.get('ENABLE_NETWORKD') == 1
3978 dbus_programs += executable(
3980 systemd_networkd_sources,
3981 include_directories : network_includes,
3982 link_with : [libnetworkd_core,
3984 networkd_link_with],
3985 dependencies : [threads,
3987 install_rpath : rootpkglibdir,
3989 install_dir : rootlibexecdir)
3991 public_programs += executable(
3992 'systemd-networkd-wait-online',
3993 systemd_networkd_wait_online_sources,
3994 include_directories : includes,
3995 link_with : [networkd_link_with],
3996 dependencies : [versiondep],
3997 install_rpath : rootpkglibdir,
3999 install_dir : rootlibexecdir)
4001 public_programs += executable(
4004 include_directories : libsystemd_network_includes,
4005 link_with : [libsystemd_network,
4006 networkd_link_with],
4007 dependencies : [versiondep],
4008 install_rpath : rootpkglibdir,
4010 install_dir : rootbindir)
4014 'systemd-network-generator',
4015 network_generator_sources,
4016 include_directories : includes,
4017 link_with : [networkd_link_with],
4018 dependencies : [versiondep],
4019 install_rpath : rootpkglibdir,
4021 install_dir : rootlibexecdir)
4023 if want_tests != 'false'
4024 test('test-network-generator-conversion',
4025 test_network_generator_conversion_sh,
4026 # https://github.com/mesonbuild/meson/issues/2681
4027 args : exe.full_path(),
4032 'systemd-sulogin-shell',
4033 'src/sulogin-shell/sulogin-shell.c',
4034 include_directories : includes,
4035 link_with : [libshared],
4036 dependencies : [versiondep],
4037 install_rpath : rootpkglibdir,
4039 install_dir : rootlibexecdir)
4041 exe = custom_target(
4043 input : kernel_install_in,
4044 output : 'kernel-install',
4045 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
4046 install : want_kernel_install,
4047 install_mode : 'rwxr-xr-x',
4048 install_dir : bindir)
4049 public_programs += exe
4051 if want_tests != 'false' and want_kernel_install
4052 test('test-kernel-install',
4053 test_kernel_install_sh,
4054 args : [exe.full_path(), loaderentry_install])
4058 exe = custom_target(
4060 input : 'src/ukify/ukify.py',
4062 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
4064 install_mode : 'rwxr-xr-x',
4065 install_dir : rootlibexecdir)
4066 public_programs += exe
4069 ############################################################
4071 runtest_env = custom_target(
4072 'systemd-runtest.env',
4073 output : 'systemd-runtest.env',
4074 command : [sh, '-c',
4075 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
4076 project_source_root / 'test',
4077 project_build_root / 'catalog')],
4079 build_by_default : true)
4081 test_cflags = ['-DTEST_CODE=1']
4082 # We intentionally do not do inline initializations with definitions for a
4083 # bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
4084 # use the variable unexpectedly. This triggers a lot of maybe-uninitialized
4085 # false positives when the combination of -O2 and -flto is used. Suppress them.
4086 if '-O2' in c_args and '-flto=auto' in c_args
4087 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
4090 foreach tuple : tests
4092 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
4093 dependencies = tuple.length() > 2 ? tuple[2] : []
4094 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
4095 condition = tuple.length() > 4 ? tuple[4] : ''
4096 type = tuple.length() > 5 ? tuple[5] : ''
4097 defs = tuple.length() > 6 ? tuple[6] : []
4099 parallel = tuple.length() > 7 ? tuple[7] : true
4102 # FIXME: Use fs.stem() with meson >= 0.54.0
4103 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
4104 if type.startswith('timeout=')
4105 timeout = type.split('=')[1].to_int()
4109 suite = fs.name(fs.parent('@0@'.format(sources[0])))
4110 # FIXME: Use str.replace() with meson >= 0.58.0
4111 suite = suite.split('sd-')[-1]
4113 if condition == '' or conf.get(condition) == 1
4117 include_directories : incs,
4118 link_with : link_with,
4119 dependencies : [versiondep,
4122 build_by_default : want_tests != 'false',
4123 install_rpath : rootpkglibdir,
4124 install : install_tests,
4125 install_dir : testsdir / type,
4126 link_depends : runtest_env)
4129 message('@0@ is a manual test'.format(name))
4130 elif type == 'unsafe' and want_tests != 'unsafe'
4131 message('@0@ is an unsafe test'.format(name))
4132 elif want_tests != 'false'
4137 is_parallel : parallel)
4140 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
4145 'test-libsystemd-sym',
4146 test_libsystemd_sym_c,
4147 include_directories : includes,
4148 link_with : [libsystemd],
4149 build_by_default : want_tests != 'false',
4150 install : install_tests,
4151 install_dir : testsdir)
4152 if want_tests != 'false'
4153 test('test-libsystemd-sym', exe)
4157 'test-libsystemd-static-sym',
4158 test_libsystemd_sym_c,
4159 include_directories : includes,
4160 link_with : [install_libsystemd_static],
4161 dependencies : [threads], # threads is already included in dependencies on the library,
4162 # but does not seem to get propagated. Add here as a work-around.
4163 build_by_default : want_tests != 'false' and static_libsystemd_pic,
4164 install : install_tests and static_libsystemd_pic,
4165 install_dir : testsdir)
4166 if want_tests != 'false' and static_libsystemd_pic
4167 test('test-libsystemd-static-sym', exe)
4173 include_directories : libudev_includes,
4174 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
4175 link_with : [libudev],
4176 build_by_default : want_tests != 'false',
4177 install : install_tests,
4178 install_dir : testsdir)
4179 if want_tests != 'false'
4180 test('test-libudev-sym', exe)
4184 'test-libudev-static-sym',
4186 include_directories : libudev_includes,
4187 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
4188 link_with : [install_libudev_static],
4189 build_by_default : want_tests != 'false' and static_libudev_pic,
4190 install : install_tests and static_libudev_pic,
4191 install_dir : testsdir)
4192 if want_tests != 'false' and static_libudev_pic
4193 test('test-libudev-static-sym', exe)
4196 ############################################################
4200 foreach tuple : fuzzers
4202 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
4203 dependencies = tuple.length() > 2 ? tuple[2] : []
4204 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
4205 defs = tuple.length() > 4 ? tuple[4] : []
4209 dependencies += fuzzing_engine
4211 if fuzzing_engine.found()
4212 dependencies += fuzzing_engine
4214 link_args += ['-fsanitize=fuzzer']
4217 sources += 'src/fuzz/fuzz-main.c'
4219 sources += fuzz_generated_directives
4221 # FIXME: Use fs.stem() with meson >= 0.54.0
4222 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
4227 include_directories : [incs, include_directories('src/fuzz')],
4228 link_with : link_with,
4229 dependencies : [dependencies,
4231 c_args : defs + test_cflags,
4232 link_args: link_args,
4234 build_by_default : fuzzer_build)
4237 if want_tests != 'false' and name in fuzz_regression_tests
4238 # Run the fuzz regression tests without any sanitizers enabled.
4239 # Additional invocations with sanitizers may be added below.
4240 foreach tuple : fuzz_regression_tests[name]
4243 test('@0@_@1@'.format(name, fuzz_in),
4246 args : [fuzz_dir != '' ? project_source_root / fuzz_dir / name / fuzz_in
4247 : fuzz_generated_in_dir / '@0@_@1@'.format(name, fuzz_in)])
4252 alias_target('fuzzers', fuzzer_exes)
4254 ############################################################
4256 subdir('docs/sysvinit')
4257 subdir('docs/var-log')
4260 subdir('modprobe.d')
4263 subdir('shell-completion/bash')
4264 subdir('shell-completion/zsh')
4266 subdir('sysusers.d')
4267 subdir('tmpfiles.d')
4270 install_subdir('factory/etc',
4271 install_dir : factorydir)
4272 subdir('factory/templates')
4274 if install_sysconfdir
4275 install_data('xorg/50-systemd-user.sh',
4276 install_dir : xinitrcdir)
4278 install_data('LICENSE.GPL2',
4282 'docs/CODING_STYLE.md',
4283 'docs/DISTRO_PORTING.md',
4284 'docs/ENVIRONMENT.md',
4286 'docs/TRANSIENT-SETTINGS.md',
4287 'docs/TRANSLATORS.md',
4288 'docs/UIDS-GIDS.md',
4289 install_dir : docdir)
4291 install_subdir('LICENSES',
4292 install_dir : docdir)
4294 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
4295 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
4297 ############################################################
4299 # Ensure that changes to the docs/ directory do not break the
4300 # basic Github pages build. But only run it in developer mode,
4301 # as it might be fragile due to changes in the tooling, and it is
4302 # not generally useful for users.
4303 jekyll = find_program('jekyll', required : false)
4304 if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
4305 test('github-pages',
4307 suite : 'dist-check',
4309 '--source', project_source_root / 'docs',
4310 '--destination', project_build_root / '_site'])
4313 ############################################################
4315 check_help = find_program('tools/check-help.sh')
4316 check_version = find_program('tools/check-version.sh')
4318 foreach exec : public_programs
4319 name = exec.full_path().split('/')[-1]
4320 if want_tests != 'false'
4321 test('check-help-' + name,
4323 suite : 'dist-check',
4324 args : exec.full_path(),
4327 test('check-version-' + name,
4329 suite : 'dist-check',
4330 args : [exec.full_path(),
4331 meson.project_version()],
4336 # Enable tests for all supported sanitizers
4337 foreach tuple : fuzz_sanitizers
4338 sanitizer = tuple[0]
4341 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
4342 foreach fuzzer, fuzz_ins : fuzz_regression_tests
4343 name = '@0@:@1@'.format(fuzzer, sanitizer)
4344 if want_tests == 'false'
4345 message('Not compiling @0@ because tests is set to false'.format(name))
4349 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
4352 exe = custom_target(
4355 depends : [build] + fuzz_generated_directives,
4356 command : [ln, '-fs',
4357 build.full_path() / fuzzer,
4359 build_by_default : true)
4361 foreach tuple : fuzz_ins
4365 test('@0@_@1@_@2@'.format(fuzzer, fuzz_in, sanitizer),
4368 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
4370 args : [exe.full_path(),
4371 fuzz_dir != '' ? project_source_root / fuzz_dir / fuzzer / fuzz_in
4372 : fuzz_generated_in_dir / '@0@_@1@'.format(fuzzer, fuzz_in)])
4379 ############################################################
4382 all_files = run_command(
4383 env, '-u', 'GIT_WORK_TREE',
4384 git, '--git-dir=@0@/.git'.format(project_source_root),
4385 'ls-files', ':/*.[ch]',
4387 if all_files.returncode() == 0
4388 all_files = files(all_files.stdout().split())
4393 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
4396 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
4401 git_contrib_sh = find_program('tools/git-contrib.sh')
4404 command : [git_contrib_sh])
4408 git_head = run_command(
4409 git, '--git-dir=@0@/.git'.format(project_source_root),
4410 'rev-parse', 'HEAD',
4411 check : false).stdout().strip()
4412 git_head_short = run_command(
4413 git, '--git-dir=@0@/.git'.format(project_source_root),
4414 'rev-parse', '--short=7', 'HEAD',
4415 check : false).stdout().strip()
4419 command : [git, 'archive',
4420 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
4422 '--prefix', 'systemd-@0@/'.format(git_head),
4426 ############################################################
4428 check_api_docs_sh = find_program('tools/check-api-docs.sh')
4431 depends : [man, libsystemd, libudev],
4432 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
4434 alias_target('update-dbus-docs', update_dbus_docs)
4435 alias_target('update-man-rules', update_man_rules)
4437 if not meson.is_cross_build()
4439 'export-dbus-interfaces',
4440 output : fs.name(dbus_interfaces_dir),
4441 install : dbus_interfaces_dir != 'no',
4442 install_dir : fs.parent(dbus_interfaces_dir),
4443 command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
4446 ############################################################
4448 alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
4449 check : true).stdout().strip()
4452 'split /usr' : split_usr,
4453 'split bin-sbin' : split_bin,
4454 'prefix directory' : prefixdir,
4455 'rootprefix directory' : rootprefixdir,
4456 'sysconf directory' : sysconfdir,
4457 'include directory' : includedir,
4458 'lib directory' : libdir,
4459 'rootlib directory' : rootlibdir,
4460 'SysV init scripts' : sysvinit_path,
4461 'SysV rc?.d directories' : sysvrcnd_path,
4462 'PAM modules directory' : pamlibdir,
4463 'PAM configuration directory' : pamconfdir,
4464 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
4465 'RPM macros directory' : rpmmacrosdir,
4466 'modprobe.d directory' : modprobedir,
4467 'D-Bus policy directory' : dbuspolicydir,
4468 'D-Bus session directory' : dbussessionservicedir,
4469 'D-Bus system directory' : dbussystemservicedir,
4470 'D-Bus interfaces directory' : dbus_interfaces_dir,
4471 'bash completions directory' : bashcompletiondir,
4472 'zsh completions directory' : zshcompletiondir,
4473 'private shared lib version tag' : shared_lib_tag,
4474 'extra start script' : get_option('rc-local'),
4475 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
4476 get_option('debug-tty')),
4477 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
4478 conf.get('SYSTEM_ALLOC_UID_MIN')),
4479 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
4480 conf.get('SYSTEM_ALLOC_GID_MIN')),
4481 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
4482 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
4483 'static UID/GID allocations' : ' '.join(static_ugids),
4484 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
4485 'render group access mode' : get_option('group-render-mode'),
4486 'certificate root directory' : get_option('certificate-root'),
4487 'support URL' : support_url,
4488 'nobody user name' : nobody_user,
4489 'nobody group name' : nobody_group,
4490 'fallback hostname' : get_option('fallback-hostname'),
4491 'default compression method' : compression,
4492 'default DNSSEC mode' : default_dnssec,
4493 'default DNS-over-TLS mode' : default_dns_over_tls,
4494 'default mDNS mode' : default_mdns,
4495 'default LLMNR mode' : default_llmnr,
4496 'default DNS servers' : dns_servers.split(' '),
4497 'default NTP servers' : ntp_servers.split(' '),
4498 'default cgroup hierarchy' : default_hierarchy,
4499 'default net.naming-scheme value' : default_net_naming_scheme,
4500 'default KillUserProcesses value' : kill_user_processes,
4501 'default locale' : default_locale,
4502 'default nspawn locale' : nspawn_locale,
4503 'default status unit format' : status_unit_format_default,
4504 'default user $PATH' :
4505 default_user_path != '' ? default_user_path : '(same as system services)',
4506 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
4507 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
4510 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
4511 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
4512 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
4533 ['libcryptsetup-plugins'],
4559 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
4589 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
4603 ['legacy-pkla', install_polkit_pkla],
4609 ['man pages', want_man],
4610 ['html pages', want_html],
4611 ['man page indices', want_man and have_lxml],
4613 ['compat-mutable-uid-boundaries'],
4616 ['adm group', get_option('adm-group')],
4617 ['wheel group', get_option('wheel-group')],
4620 ['debug mmap cache'],
4622 ['valgrind', conf.get('VALGRIND') == 1],
4623 ['trace logging', conf.get('LOG_TRACE') == 1],
4624 ['install tests', install_tests],
4625 ['link-udev-shared', get_option('link-udev-shared')],
4626 ['link-systemctl-shared', get_option('link-systemctl-shared')],
4627 ['link-networkd-shared', get_option('link-networkd-shared')],
4628 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
4629 ['link-journalctl-shared', get_option('link-journalctl-shared')],
4630 ['link-boot-shared', get_option('link-boot-shared')],
4631 ['first-boot-full-preset'],
4633 ['standalone-binaries', get_option('standalone-binaries')],
4634 ['coverage', get_option('b_coverage')],
4637 if tuple.length() >= 2
4640 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
4641 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
4642 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
4651 if static_libsystemd == 'false'
4652 missing += 'static-libsystemd'
4654 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
4657 if static_libudev == 'false'
4658 missing += 'static-libudev'
4660 found += 'static-libudev(@0@)'.format(static_libudev)
4663 if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
4664 found += 'cryptolib(openssl)'
4665 elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
4666 found += 'cryptolib(gcrypt)'
4668 missing += 'cryptolib'
4671 if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
4672 found += 'DNS-over-TLS(gnutls)'
4673 elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
4674 found += 'DNS-over-TLS(openssl)'
4676 missing += 'DNS-over-TLS'
4680 'enabled' : ', '.join(found),
4681 'disabled' : ', '.join(missing)},
4682 section : 'Features')
4684 if rootprefixdir != rootprefix_default
4686 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
4687 'systemd used fixed names for unit file directories and other paths, so anything\n' +
4688 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))