1 # SPDX-License-Identifier: LGPL-2.1-or-later
3 project('systemd', 'c',
13 meson_version : '>= 0.53.2',
16 libsystemd_version = '0.34.0'
17 libudev_version = '1.7.4'
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 # Create a title-less summary section early, so it ends up first in the output.
59 # More items are added later after they have been detected.
60 summary({'build mode' : get_option('mode')})
62 #####################################################################
64 # Try to install the git pre-commit hook
65 add_git_hook_sh = find_program('tools/add-git-hook.sh', required : false)
66 if add_git_hook_sh.found()
67 git_hook = run_command(add_git_hook_sh, check : false)
68 if git_hook.returncode() == 0
69 message(git_hook.stdout().strip())
73 #####################################################################
76 if get_option('split-usr') == 'auto'
77 split_usr = not fs.is_symlink('/bin')
79 split_usr = get_option('split-usr') == 'true'
82 warning('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n\n'
83 + ' split-usr mode is going to be removed\n' +
84 '\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
86 conf.set10('HAVE_SPLIT_USR', split_usr,
87 description : '/usr/bin and /bin directories are separate')
89 if get_option('split-bin') == 'auto'
90 split_bin = not fs.is_symlink('/usr/sbin')
92 split_bin = get_option('split-bin') == 'true'
94 conf.set10('HAVE_SPLIT_BIN', split_bin,
95 description : 'bin and sbin directories are separate')
97 rootprefixdir = get_option('rootprefix')
98 # Unusual rootprefixdir values are used by some distros
99 # (see https://github.com/systemd/systemd/pull/7461).
100 rootprefix_default = split_usr ? '/' : '/usr'
101 if rootprefixdir == ''
102 rootprefixdir = rootprefix_default
104 rootprefixdir_noslash = rootprefixdir == '/' ? '' : rootprefixdir
106 have_standalone_binaries = get_option('standalone-binaries')
108 sysvinit_path = get_option('sysvinit-path')
109 sysvrcnd_path = get_option('sysvrcnd-path')
110 conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '',
111 description : 'SysV init scripts and rcN.d links are supported')
112 conf.set10('CREATE_LOG_DIRS', get_option('create-log-dirs'))
114 if get_option('hibernate') and not get_option('initrd')
115 error('hibernate depends on initrd')
118 conf.set10('BUMP_PROC_SYS_FS_FILE_MAX', get_option('bump-proc-sys-fs-file-max'))
119 conf.set10('BUMP_PROC_SYS_FS_NR_OPEN', get_option('bump-proc-sys-fs-nr-open'))
120 conf.set('HIGH_RLIMIT_NOFILE', 512*1024)
122 # Meson ignores the preceding arguments when joining paths if an absolute
123 # component is encountered, so this should canonicalize various paths when they
124 # are absolute or relative.
125 prefixdir = get_option('prefix')
126 if not prefixdir.startswith('/')
127 error('Prefix is not absolute: "@0@"'.format(prefixdir))
129 if prefixdir != rootprefixdir and rootprefixdir != '/' and not prefixdir.strip('/').startswith(rootprefixdir.strip('/') + '/')
130 error('Prefix is not below root prefix (now rootprefix=@0@ prefix=@1@)'.format(
131 rootprefixdir, prefixdir))
134 bindir = prefixdir / get_option('bindir')
135 libdir = prefixdir / get_option('libdir')
136 sysconfdir = prefixdir / get_option('sysconfdir')
137 includedir = prefixdir / get_option('includedir')
138 datadir = prefixdir / get_option('datadir')
139 localstatedir = '/' / get_option('localstatedir')
141 rootbindir = rootprefixdir / 'bin'
142 rootsbindir = rootprefixdir / (split_bin ? 'sbin' : 'bin')
143 rootlibexecdir = rootprefixdir / 'lib/systemd'
145 rootlibdir = get_option('rootlibdir')
147 # This will be a relative path if libdir is in prefix.
148 rootlibdir = get_option('libdir')
150 if not rootlibdir.startswith('/')
151 # If we have a relative path, add rootprefixdir to the front.
152 rootlibdir = rootprefixdir / rootlibdir
154 rootpkglibdir = rootlibdir / 'systemd'
156 install_sysconfdir = get_option('install-sysconfdir') != 'false'
157 install_sysconfdir_samples = get_option('install-sysconfdir') == 'true'
158 # Dirs of external packages
159 pkgconfigdatadir = get_option('pkgconfigdatadir') != '' ? get_option('pkgconfigdatadir') : datadir / 'pkgconfig'
160 pkgconfiglibdir = get_option('pkgconfiglibdir') != '' ? get_option('pkgconfiglibdir') : libdir / 'pkgconfig'
161 polkitpolicydir = datadir / 'polkit-1/actions'
162 polkitrulesdir = datadir / 'polkit-1/rules.d'
163 polkitpkladir = localstatedir / 'lib/polkit-1/localauthority/10-vendor.d'
164 xinitrcdir = get_option('xinitrcdir') != '' ? get_option('xinitrcdir') : sysconfdir / 'X11/xinit/xinitrc.d'
165 rpmmacrosdir = get_option('rpmmacrosdir')
166 if rpmmacrosdir != 'no'
167 rpmmacrosdir = prefixdir / rpmmacrosdir
169 modprobedir = rootprefixdir / 'lib/modprobe.d'
172 pkgdatadir = datadir / 'systemd'
173 environmentdir = prefixdir / 'lib/environment.d'
174 pkgsysconfdir = sysconfdir / 'systemd'
175 userunitdir = prefixdir / 'lib/systemd/user'
176 userpresetdir = prefixdir / 'lib/systemd/user-preset'
177 tmpfilesdir = prefixdir / 'lib/tmpfiles.d'
178 usertmpfilesdir = prefixdir / 'share/user-tmpfiles.d'
179 sysusersdir = prefixdir / 'lib/sysusers.d'
180 sysctldir = prefixdir / 'lib/sysctl.d'
181 binfmtdir = prefixdir / 'lib/binfmt.d'
182 modulesloaddir = prefixdir / 'lib/modules-load.d'
183 networkdir = rootprefixdir / 'lib/systemd/network'
184 pkgincludedir = includedir / 'systemd'
185 systemgeneratordir = rootlibexecdir / 'system-generators'
186 usergeneratordir = prefixdir / 'lib/systemd/user-generators'
187 systemenvgeneratordir = prefixdir / 'lib/systemd/system-environment-generators'
188 userenvgeneratordir = prefixdir / 'lib/systemd/user-environment-generators'
189 systemshutdowndir = rootlibexecdir / 'system-shutdown'
190 systemsleepdir = rootlibexecdir / 'system-sleep'
191 systemunitdir = rootprefixdir / 'lib/systemd/system'
192 systempresetdir = rootprefixdir / 'lib/systemd/system-preset'
193 udevlibexecdir = rootprefixdir / 'lib/udev'
194 udevrulesdir = udevlibexecdir / 'rules.d'
195 udevhwdbdir = udevlibexecdir / 'hwdb.d'
196 catalogdir = prefixdir / 'lib/systemd/catalog'
197 kerneldir = prefixdir / 'lib/kernel'
198 kernelinstalldir = kerneldir / 'install.d'
199 factorydir = datadir / 'factory'
200 bootlibdir = prefixdir / 'lib/systemd/boot/efi'
201 testsdir = prefixdir / 'lib/systemd/tests'
202 systemdstatedir = localstatedir / 'lib/systemd'
203 catalogstatedir = systemdstatedir / 'catalog'
204 randomseeddir = localstatedir / 'lib/systemd'
205 profiledir = rootlibexecdir / 'portable' / 'profile'
206 ntpservicelistdir = rootprefixdir / 'lib/systemd/ntp-units.d'
208 docdir = get_option('docdir')
210 docdir = datadir / 'doc/systemd'
213 pamlibdir = get_option('pamlibdir')
215 pamlibdir = rootlibdir / 'security'
218 pamconfdir = get_option('pamconfdir')
220 pamconfdir = prefixdir / 'lib/pam.d'
223 libcryptsetup_plugins_dir = get_option('libcryptsetup-plugins-dir')
224 if libcryptsetup_plugins_dir == ''
225 libcryptsetup_plugins_dir = rootlibdir / 'cryptsetup'
228 memory_accounting_default = get_option('memory-accounting-default')
229 status_unit_format_default = get_option('status-unit-format-default')
230 if status_unit_format_default == 'auto'
231 status_unit_format_default = conf.get('BUILD_MODE_DEVELOPER') == 1 ? 'name' : 'description'
234 conf.set_quoted('BINFMT_DIR', binfmtdir)
235 conf.set_quoted('BOOTLIBDIR', bootlibdir)
236 conf.set_quoted('CATALOG_DATABASE', catalogstatedir / 'database')
237 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
238 conf.set_quoted('DOC_DIR', docdir)
239 conf.set_quoted('DOCUMENT_ROOT', pkgdatadir / 'gatewayd')
240 conf.set_quoted('ENVIRONMENT_DIR', environmentdir)
241 conf.set_quoted('INCLUDE_DIR', includedir)
242 conf.set_quoted('LIBDIR', libdir)
243 conf.set_quoted('MODPROBE_DIR', modprobedir)
244 conf.set_quoted('MODULESLOAD_DIR', modulesloaddir)
245 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
246 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', bindir / 'pkttyagent')
247 conf.set_quoted('PREFIX', prefixdir)
248 conf.set_quoted('RANDOM_SEED', randomseeddir / 'random-seed')
249 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
250 conf.set_quoted('RC_LOCAL_PATH', get_option('rc-local'))
251 conf.set_quoted('ROOTBINDIR', rootbindir)
252 conf.set_quoted('ROOTLIBDIR', rootlibdir)
253 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
254 conf.set_quoted('ROOTPREFIX', rootprefixdir)
255 conf.set_quoted('ROOTPREFIX_NOSLASH', rootprefixdir_noslash)
256 conf.set_quoted('SYSCONF_DIR', sysconfdir)
257 conf.set_quoted('SYSCTL_DIR', sysctldir)
258 conf.set_quoted('SYSTEMCTL_BINARY_PATH', rootbindir / 'systemctl')
259 conf.set_quoted('SYSTEMD_BINARY_PATH', rootlibexecdir / 'systemd')
260 conf.set_quoted('SYSTEMD_CATALOG_DIR', catalogdir)
261 conf.set_quoted('SYSTEMD_CGROUPS_AGENT_PATH', rootlibexecdir / 'systemd-cgroups-agent')
262 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', rootlibexecdir / 'systemd-cryptsetup')
263 conf.set_quoted('SYSTEMD_EXPORT_PATH', rootlibexecdir / 'systemd-export')
264 conf.set_quoted('SYSTEMD_FSCK_PATH', rootlibexecdir / 'systemd-fsck')
265 conf.set_quoted('SYSTEMD_GROWFS_PATH', rootlibexecdir / 'systemd-growfs')
266 conf.set_quoted('SYSTEMD_HOMEWORK_PATH', rootlibexecdir / 'systemd-homework')
267 conf.set_quoted('SYSTEMD_IMPORT_FS_PATH', rootlibexecdir / 'systemd-import-fs')
268 conf.set_quoted('SYSTEMD_IMPORT_PATH', rootlibexecdir / 'systemd-import')
269 conf.set_quoted('SYSTEMD_INTEGRITYSETUP_PATH', rootlibexecdir / 'systemd-integritysetup')
270 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', pkgdatadir / 'kbd-model-map')
271 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', pkgdatadir / 'language-fallback-map')
272 conf.set_quoted('SYSTEMD_MAKEFS_PATH', rootlibexecdir / 'systemd-makefs')
273 conf.set_quoted('SYSTEMD_PULL_PATH', rootlibexecdir / 'systemd-pull')
274 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', rootlibexecdir / 'systemd-shutdown')
275 conf.set_quoted('SYSTEMD_TEST_DATA', testsdir / 'testdata')
276 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', rootbindir / 'systemd-tty-ask-password-agent')
277 conf.set_quoted('SYSTEMD_UPDATE_HELPER_PATH', rootlibexecdir / 'systemd-update-helper')
278 conf.set_quoted('SYSTEMD_USERWORK_PATH', rootlibexecdir / 'systemd-userwork')
279 conf.set_quoted('SYSTEMD_VERITYSETUP_PATH', rootlibexecdir / 'systemd-veritysetup')
280 conf.set_quoted('SYSTEM_CONFIG_UNIT_DIR', pkgsysconfdir / 'system')
281 conf.set_quoted('SYSTEM_DATA_UNIT_DIR', systemunitdir)
282 conf.set_quoted('SYSTEM_ENV_GENERATOR_DIR', systemenvgeneratordir)
283 conf.set_quoted('SYSTEM_GENERATOR_DIR', systemgeneratordir)
284 conf.set_quoted('SYSTEM_PRESET_DIR', systempresetdir)
285 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
286 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
287 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
288 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
289 conf.set_quoted('SYSUSERS_DIR', sysusersdir)
290 conf.set_quoted('TMPFILES_DIR', tmpfilesdir)
291 conf.set_quoted('USER_TMPFILES_DIR', usertmpfilesdir)
292 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
293 conf.set_quoted('UDEV_HWDB_DIR', udevhwdbdir)
294 conf.set_quoted('UDEV_RULES_DIR', udevrulesdir)
295 conf.set_quoted('UPDATE_HELPER_USER_TIMEOUT', get_option('update-helper-user-timeout'))
296 conf.set_quoted('USER_CONFIG_UNIT_DIR', pkgsysconfdir / 'user')
297 conf.set_quoted('USER_DATA_UNIT_DIR', userunitdir)
298 conf.set_quoted('USER_ENV_GENERATOR_DIR', userenvgeneratordir)
299 conf.set_quoted('USER_GENERATOR_DIR', usergeneratordir)
300 conf.set_quoted('USER_KEYRING_PATH', pkgsysconfdir / 'import-pubring.gpg')
301 conf.set_quoted('USER_PRESET_DIR', userpresetdir)
302 conf.set_quoted('VENDOR_KEYRING_PATH', rootlibexecdir / 'import-pubring.gpg')
304 conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
305 conf.set10('ENABLE_URLIFY', get_option('urlify'))
306 conf.set10('ENABLE_FEXECVE', get_option('fexecve'))
307 conf.set10('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default)
308 conf.set('STATUS_UNIT_FORMAT_DEFAULT', 'STATUS_UNIT_FORMAT_' + status_unit_format_default.to_upper())
309 conf.set_quoted('STATUS_UNIT_FORMAT_DEFAULT_STR', status_unit_format_default)
311 conf.set10('FIRST_BOOT_FULL_PRESET', get_option('first-boot-full-preset'))
313 conf.set10('EFI_TPM_PCR_COMPAT', get_option('efi-tpm-pcr-compat'))
315 #####################################################################
317 cc = meson.get_compiler('c')
318 pkgconfig = import('pkgconfig')
319 meson_build_sh = find_program('tools/meson-build.sh')
321 want_tests = get_option('tests')
322 slow_tests = want_tests != 'false' and get_option('slow-tests')
323 fuzz_tests = want_tests != 'false' and get_option('fuzz-tests')
324 install_tests = get_option('install-tests')
326 if add_languages('cpp', required : fuzzer_build)
327 # Used only for tests
328 cxx = meson.get_compiler('cpp')
329 cxx_cmd = ' '.join(cxx.cmd_array())
335 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer', required : false)
336 if fuzzing_engine.found()
337 add_project_arguments('-fsanitize-coverage=trace-pc-guard,trace-cmp', language : 'c')
338 elif cc.has_argument('-fsanitize=fuzzer-no-link')
339 add_project_arguments('-fsanitize=fuzzer-no-link', language : 'c')
341 error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported')
344 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
347 # Those generate many false positives, and we do not want to change the code to
349 basic_disabled_warnings = [
350 '-Wno-missing-field-initializers',
351 '-Wno-unused-parameter',
354 possible_common_cc_flags = [
358 '-Werror=format-signedness',
359 '-Werror=implicit-function-declaration',
360 '-Werror=incompatible-pointer-types',
361 '-Werror=int-conversion',
363 '-Werror=override-init',
364 '-Werror=return-type',
365 '-Werror=shift-count-overflow',
366 '-Werror=shift-overflow=2',
369 # gperf prevents us from enabling this because it does not emit fallthrough
370 # attribute with clang.
371 #'-Wimplicit-fallthrough',
372 '-Wimplicit-fallthrough=5',
375 '-Wmissing-include-dirs',
376 '-Wmissing-noreturn',
378 '-Wold-style-definition',
382 '-Wstrict-aliasing=2',
383 '-Wstrict-prototypes',
384 '-Wsuggest-attribute=noreturn',
388 # negative arguments are correctly detected starting with meson 0.46.
389 '-Wno-error=#warnings', # clang
390 '-Wno-string-plus-int', # clang
393 c_args = get_option('c_args')
395 # Our json library does not support -ffinite-math-only, which is enabled by -Ofast or -ffast-math.
396 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)
397 error('-Ofast, -ffast-math, or -ffinite-math-only is specified in c_args.')
400 # Disable -Wmaybe-uninitialized when compiling with -Os/-O1/-O3/etc. There are
401 # too many false positives with gcc >= 8. Effectively, we only test with -O0
402 # and -O2; this should be enough to catch most important cases without too much
403 # busywork. See https://github.com/systemd/systemd/pull/19226.
404 if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or
405 cc.version().version_compare('<10') or
410 possible_common_cc_flags += '-Wno-maybe-uninitialized'
413 # Disable -Wno-unused-result with gcc, see
414 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425.
415 if cc.get_id() == 'gcc'
416 possible_common_cc_flags += '-Wno-unused-result'
419 # --as-needed and --no-undefined are provided by meson by default,
420 # run 'meson configure' to see what is enabled
421 possible_link_flags = [
422 '-Wl,--fatal-warnings',
428 if get_option('b_sanitize') == 'none'
429 possible_link_flags += '-Wl,--warn-common'
432 if cc.get_id() == 'clang'
433 possible_common_cc_flags += [
434 '-Wno-typedef-redefinition',
435 '-Wno-gnu-variable-sized-type-not-at-end',
439 if get_option('mode') == 'release'
440 # We could enable 'pattern' for developer mode, but that can interfere with
441 # valgrind and sanitizer builds. Also, clang does not zero-initialize unions,
442 # breaking some of our code (https://reviews.llvm.org/D68115).
443 possible_common_cc_flags += '-ftrivial-auto-var-init=zero'
446 possible_cc_flags = possible_common_cc_flags + [
447 '-Werror=missing-declarations',
448 '-Werror=missing-prototypes',
449 '-fdiagnostics-show-option',
451 '-fno-strict-aliasing',
453 '-fstack-protector-strong',
454 '-fvisibility=hidden',
455 '--param=ssp-buffer-size=4',
458 if get_option('buildtype') != 'debug'
459 possible_cc_flags += [
460 '-ffunction-sections',
464 possible_link_flags += '-Wl,--gc-sections'
467 if get_option('mode') == 'developer'
468 possible_cc_flags += '-fno-omit-frame-pointer'
471 add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
472 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
473 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
475 have = cc.has_argument('-Wzero-length-bounds')
476 conf.set10('HAVE_ZERO_LENGTH_BOUNDS', have)
480 #include <inttypes.h>
481 typedef uint64_t usec_t;
482 usec_t now(clockid_t clock);
487 ''', args: '-Werror=shadow', name : '-Werror=shadow with local shadowing')
488 add_project_arguments('-Werror=shadow', language : 'c')
492 add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
495 cpp = ' '.join(cc.cmd_array()) + ' -E'
497 has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
499 #####################################################################
500 # compilation result tests
502 conf.set('_GNU_SOURCE', true)
503 conf.set('__SANE_USERSPACE_TYPES__', true)
504 conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)
506 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
507 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
508 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
509 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
510 conf.set('SIZEOF_TIMEX_MEMBER', cc.sizeof('typeof(((struct timex *)0)->freq)', prefix : '#include <sys/timex.h>'))
514 #include <sys/mount.h>
515 #include <sys/stat.h>
518 foreach decl : ['char16_t',
524 # We get -1 if the size cannot be determined
525 have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
527 if decl == 'struct mount_attr'
529 want_linux_fs_h = false
531 have = cc.sizeof(decl,
532 prefix : decl_headers + '#include <linux/fs.h>',
533 args : '-D_GNU_SOURCE') > 0
534 want_linux_fs_h = have
538 if decl == 'struct statx'
540 want_linux_stat_h = false
542 have = cc.sizeof(decl,
543 prefix : decl_headers + '#include <linux/stat.h>',
544 args : '-D_GNU_SOURCE') > 0
545 want_linux_stat_h = have
549 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
552 conf.set10('WANT_LINUX_STAT_H', want_linux_stat_h)
553 conf.set10('WANT_LINUX_FS_H', want_linux_fs_h)
555 foreach ident : ['secure_getenv', '__secure_getenv']
556 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
560 ['memfd_create', '''#include <sys/mman.h>'''],
561 ['gettid', '''#include <sys/types.h>
562 #include <unistd.h>'''],
563 ['pivot_root', '''#include <stdlib.h>
564 #include <unistd.h>'''], # no known header declares pivot_root
565 ['ioprio_get', '''#include <sched.h>'''], # no known header declares ioprio_get
566 ['ioprio_set', '''#include <sched.h>'''], # no known header declares ioprio_set
567 ['name_to_handle_at', '''#include <sys/types.h>
568 #include <sys/stat.h>
569 #include <fcntl.h>'''],
570 ['setns', '''#include <sched.h>'''],
571 ['renameat2', '''#include <stdio.h>
572 #include <fcntl.h>'''],
573 ['kcmp', '''#include <linux/kcmp.h>'''],
574 ['keyctl', '''#include <sys/types.h>
575 #include <keyutils.h>'''],
576 ['copy_file_range', '''#include <sys/syscall.h>
577 #include <unistd.h>'''],
578 ['bpf', '''#include <sys/syscall.h>
579 #include <unistd.h>'''],
580 ['statx', '''#include <sys/types.h>
581 #include <sys/stat.h>
582 #include <unistd.h>'''],
583 ['explicit_bzero' , '''#include <string.h>'''],
584 ['reallocarray', '''#include <stdlib.h>'''],
585 ['set_mempolicy', '''#include <stdlib.h>
586 #include <unistd.h>'''],
587 ['get_mempolicy', '''#include <stdlib.h>
588 #include <unistd.h>'''],
589 ['pidfd_send_signal', '''#include <stdlib.h>
592 #include <sys/wait.h>'''],
593 ['pidfd_open', '''#include <stdlib.h>
596 #include <sys/wait.h>'''],
597 ['rt_sigqueueinfo', '''#include <stdlib.h>
600 #include <sys/wait.h>'''],
601 ['mallinfo', '''#include <malloc.h>'''],
602 ['mallinfo2', '''#include <malloc.h>'''],
603 ['execveat', '''#include <unistd.h>'''],
604 ['close_range', '''#include <unistd.h>'''],
605 ['epoll_pwait2', '''#include <sys/epoll.h>'''],
606 ['mount_setattr', '''#include <sys/mount.h>'''],
607 ['move_mount', '''#include <sys/mount.h>'''],
608 ['open_tree', '''#include <sys/mount.h>'''],
609 ['getdents64', '''#include <dirent.h>'''],
612 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
613 conf.set10('HAVE_' + ident[0].to_upper(), have)
616 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
617 conf.set10('USE_SYS_RANDOM_H', true)
618 conf.set10('HAVE_GETRANDOM', true)
620 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
621 conf.set10('USE_SYS_RANDOM_H', false)
622 conf.set10('HAVE_GETRANDOM', have)
625 #####################################################################
627 version_tag = get_option('version-tag')
629 vcs_data = configuration_data()
630 vcs_data.set('VCS_TAG', version_tag)
631 version_h = configure_file(configuration : vcs_data,
632 input : 'src/version/version.h.in',
633 output : 'version.h')
636 project_source_root + '/tools/meson-vcs-tag.sh',
638 meson.project_version()]
641 input : 'src/version/version.h.in',
642 output : 'version.h',
646 versiondep = declare_dependency(sources: version_h)
648 shared_lib_tag = get_option('shared-lib-tag')
649 if shared_lib_tag == ''
650 shared_lib_tag = meson.project_version()
653 sh = find_program('sh')
654 echo = find_program('echo')
655 sed = find_program('sed')
656 awk = find_program('awk')
657 stat = find_program('stat')
658 ln = find_program('ln')
659 git = find_program('git', required : false)
660 env = find_program('env')
661 perl = find_program('perl', required : false)
662 rsync = find_program('rsync', required : false)
663 meson_make_symlink = project_source_root + '/tools/meson-make-symlink.sh'
665 mkdir_p = 'mkdir -p $DESTDIR/@0@'
667 # If -Dxxx-path option is found, use that. Otherwise, check in $PATH,
668 # /usr/sbin, /sbin, and fall back to the default from middle column.
669 progs = [['quotaon', '/usr/sbin/quotaon' ],
670 ['quotacheck', '/usr/sbin/quotacheck' ],
671 ['kmod', '/usr/bin/kmod' ],
672 ['kexec', '/usr/sbin/kexec' ],
673 ['sulogin', '/usr/sbin/sulogin' ],
674 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
675 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
676 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
677 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
678 ['nologin', '/usr/sbin/nologin', ],
681 path = get_option(prog[0] + '-path')
683 message('Using @1@ for @0@'.format(prog[0], path))
685 exe = find_program(prog[0],
686 '/usr/sbin/' + prog[0],
689 path = exe.found() ? exe.path() : prog[1]
691 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
692 conf.set_quoted(name, path)
695 conf.set_quoted('TELINIT', get_option('telinit-path'))
697 if run_command(ln, '--relative', '--help', check : false).returncode() != 0
698 error('ln does not support --relative (added in coreutils 8.16)')
701 ############################################################
703 python = find_program('python3')
704 if run_command(python, '-c', 'import jinja2', check : false).returncode() != 0
705 error('python3 jinja2 missing')
708 ############################################################
710 gperf = find_program('gperf')
712 gperf_test_format = '''
714 const char * in_word_set(const char *, @0@);
717 gperf_snippet = run_command(sh, '-c', 'echo foo,bar | "$1" -L ANSI-C', '_', gperf,
719 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
720 if cc.compiles(gperf_test)
721 gperf_len_type = 'size_t'
723 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
724 if cc.compiles(gperf_test)
725 gperf_len_type = 'unsigned'
727 error('unable to determine gperf len type')
730 message('gperf len type is @0@'.format(gperf_len_type))
731 conf.set('GPERF_LEN_TYPE', gperf_len_type,
732 description : 'The type of gperf "len" parameter')
734 ############################################################
736 if not cc.has_header('sys/capability.h')
737 error('POSIX caps headers not found')
739 foreach header : ['crypt.h',
741 'linux/vm_sockets.h',
743 'valgrind/memcheck.h',
744 'valgrind/valgrind.h',
745 'linux/time_types.h',
749 conf.set10('HAVE_' + header.underscorify().to_upper(),
750 cc.has_header(header))
753 ############################################################
755 fallback_hostname = get_option('fallback-hostname')
756 if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0] == '-'
757 error('Invalid fallback-hostname configuration')
758 # A more extensive test is done in test-hostname-util. Let's catch
759 # the most obvious errors here so we don't fail with an assert later.
761 conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
763 default_hierarchy = get_option('default-hierarchy')
764 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
765 description : 'default cgroup hierarchy as string')
766 if default_hierarchy == 'legacy'
767 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
768 elif default_hierarchy == 'hybrid'
769 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
771 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
774 extra_net_naming_schemes = []
775 extra_net_naming_map = []
776 foreach scheme: get_option('extra-net-naming-schemes').split(',')
778 name = scheme.split('=')[0]
779 value = scheme.split('=')[1]
780 NAME = name.underscorify().to_upper()
782 foreach field: value.split('+')
783 VALUE += 'NAMING_' + field.underscorify().to_upper()
785 extra_net_naming_schemes += 'NAMING_@0@ = @1@,'.format(NAME, '|'.join(VALUE))
786 extra_net_naming_map += '{ "@0@", NAMING_@1@ },'.format(name, NAME)
789 conf.set('EXTRA_NET_NAMING_SCHEMES', ' '.join(extra_net_naming_schemes))
790 conf.set('EXTRA_NET_NAMING_MAP', ' '.join(extra_net_naming_map))
792 default_net_naming_scheme = get_option('default-net-naming-scheme')
793 conf.set_quoted('DEFAULT_NET_NAMING_SCHEME', default_net_naming_scheme)
794 if default_net_naming_scheme != 'latest'
795 conf.set('_DEFAULT_NET_NAMING_SCHEME_TEST',
796 'NAMING_' + default_net_naming_scheme.underscorify().to_upper())
799 time_epoch = get_option('time-epoch')
801 time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check : true).stdout().strip()
802 if time_epoch == '' and git.found() and fs.exists('.git')
803 # If we're in a git repository, use the creation time of the latest git tag.
804 latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags',
806 if latest_tag.returncode() == 0
807 time_epoch = run_command(
808 git, 'log', '--no-show-signature', '-1', '--format=%at',
809 latest_tag.stdout().strip(),
810 check : false).stdout()
815 time_epoch = run_command(stat, '-c', '%Y', NEWS,
816 check : true).stdout()
818 time_epoch = time_epoch.strip().to_int()
820 conf.set('TIME_EPOCH', time_epoch)
822 conf.set('CLOCK_VALID_RANGE_USEC_MAX', get_option('clock-valid-range-usec-max'))
824 default_user_shell = get_option('default-user-shell')
825 conf.set_quoted('DEFAULT_USER_SHELL', default_user_shell)
826 conf.set_quoted('DEFAULT_USER_SHELL_NAME', fs.name(default_user_shell))
828 foreach tuple : [['system-alloc-uid-min', 'SYS_UID_MIN', 1], # Also see login.defs(5).
829 ['system-uid-max', 'SYS_UID_MAX', 999],
830 ['system-alloc-gid-min', 'SYS_GID_MIN', 1],
831 ['system-gid-max', 'SYS_GID_MAX', 999]]
832 v = get_option(tuple[0])
836 '/^\s*@0@\s+/ { uid=$2 } END { print uid }'.format(tuple[1]),
838 check : false).stdout().strip()
845 conf.set(tuple[0].underscorify().to_upper(), v)
847 if conf.get('SYSTEM_ALLOC_UID_MIN') >= conf.get('SYSTEM_UID_MAX')
848 error('Invalid uid allocation range')
850 if conf.get('SYSTEM_ALLOC_GID_MIN') >= conf.get('SYSTEM_GID_MAX')
851 error('Invalid gid allocation range')
854 dynamic_uid_min = get_option('dynamic-uid-min')
855 dynamic_uid_max = get_option('dynamic-uid-max')
856 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
857 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
859 container_uid_base_min = get_option('container-uid-base-min')
860 container_uid_base_max = get_option('container-uid-base-max')
861 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
862 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
864 nobody_user = get_option('nobody-user')
865 nobody_group = get_option('nobody-group')
867 if not meson.is_cross_build()
868 getent_result = run_command('getent', 'passwd', '65534', check : false)
869 if getent_result.returncode() == 0
870 name = getent_result.stdout().split(':')[0]
871 if name != nobody_user
873 '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) +
874 'Your build will result in an user table setup that is incompatible with the local system.')
877 id_result = run_command('id', '-u', nobody_user, check : false)
878 if id_result.returncode() == 0
879 id = id_result.stdout().strip().to_int()
882 '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) +
883 'Your build will result in an user table setup that is incompatible with the local system.')
887 getent_result = run_command('getent', 'group', '65534', check : false)
888 if getent_result.returncode() == 0
889 name = getent_result.stdout().split(':')[0]
890 if name != nobody_group
892 '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) +
893 'Your build will result in an group table setup that is incompatible with the local system.')
896 id_result = run_command('id', '-g', nobody_group, check : false)
897 if id_result.returncode() == 0
898 id = id_result.stdout().strip().to_int()
901 '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) +
902 'Your build will result in an group table setup that is incompatible with the local system.')
906 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
908 'The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
909 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
912 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
913 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
916 foreach option : ['adm-gid',
933 'systemd-journal-gid',
934 'systemd-network-uid',
935 'systemd-resolve-uid',
936 'systemd-timesync-uid']
937 name = option.underscorify().to_upper()
938 val = get_option(option)
940 # Ensure provided GID argument is numeric, otherwise fall back to default assignment
941 conf.set(name, val > 0 ? val : '-')
943 static_ugids += '@0@:@1@'.format(option, val)
947 conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
948 conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
950 dev_kvm_mode = get_option('dev-kvm-mode')
951 conf.set_quoted('DEV_KVM_MODE', dev_kvm_mode) # FIXME: convert to 0o… notation
952 conf.set10('DEV_KVM_UACCESS', dev_kvm_mode != '0666')
953 group_render_mode = get_option('group-render-mode')
954 conf.set_quoted('GROUP_RENDER_MODE', group_render_mode)
955 conf.set10('GROUP_RENDER_UACCESS', group_render_mode != '0666')
957 kill_user_processes = get_option('default-kill-user-processes')
958 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
960 dns_servers = get_option('dns-servers')
961 conf.set_quoted('DNS_SERVERS', dns_servers)
963 ntp_servers = get_option('ntp-servers')
964 conf.set_quoted('NTP_SERVERS', ntp_servers)
966 default_locale = get_option('default-locale')
967 conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale)
969 nspawn_locale = get_option('nspawn-locale')
970 conf.set_quoted('SYSTEMD_NSPAWN_LOCALE', nspawn_locale)
972 localegen_path = get_option('localegen-path')
973 if localegen_path != ''
974 conf.set_quoted('LOCALEGEN_PATH', localegen_path)
976 conf.set10('HAVE_LOCALEGEN', localegen_path != '')
978 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
980 service_watchdog = get_option('service-watchdog')
981 watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
982 conf.set_quoted('SERVICE_WATCHDOG', watchdog_value)
984 conf.set_quoted('SUSHELL', get_option('debug-shell'))
985 conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
987 enable_debug_hashmap = false
988 enable_debug_mmap_cache = false
989 enable_debug_siphash = false
990 foreach name : get_option('debug-extra')
992 enable_debug_hashmap = true
993 elif name == 'mmap-cache'
994 enable_debug_mmap_cache = true
995 elif name == 'siphash'
996 enable_debug_siphash = true
998 message('unknown debug option "@0@", ignoring'.format(name))
1001 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
1002 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
1003 conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash)
1005 conf.set10('VALGRIND', get_option('valgrind'))
1006 conf.set10('LOG_TRACE', get_option('log-trace'))
1008 default_user_path = get_option('user-path')
1009 if default_user_path != ''
1010 conf.set_quoted('DEFAULT_USER_PATH', default_user_path)
1014 #####################################################################
1016 threads = dependency('threads')
1017 librt = cc.find_library('rt')
1018 libm = cc.find_library('m')
1019 libdl = cc.find_library('dl')
1020 libcrypt = cc.find_library('crypt')
1022 crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
1024 ['crypt_ra', crypt_header],
1025 ['crypt_preferred_method', crypt_header],
1026 ['crypt_gensalt_ra', crypt_header]]
1028 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
1029 dependencies : libcrypt)
1030 conf.set10('HAVE_' + ident[0].to_upper(), have)
1033 libcap = dependency('libcap', required : false)
1034 if not libcap.found()
1035 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
1036 libcap = cc.find_library('cap')
1039 want_bpf_framework = get_option('bpf-framework')
1040 bpf_framework_required = want_bpf_framework == 'true'
1042 libbpf = dependency('libbpf', required : bpf_framework_required, version : '>= 0.2')
1043 conf.set10('HAVE_LIBBPF', libbpf.found())
1045 if want_bpf_framework == 'false' or not libbpf.found() or skip_deps
1046 conf.set10('BPF_FRAMEWORK', false)
1048 bpf_compiler = get_option('bpf-compiler')
1050 clang_supports_bpf = false
1051 bpf_gcc_found = false
1054 if bpf_compiler == 'clang'
1055 # Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu
1056 # (like clang-10/llvm-strip-10)
1057 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')
1058 r = find_program('clang', required : bpf_framework_required, version : '>= 10.0.0')
1059 clang_found = r.found()
1063 # Assume that the required flags are supported by the found clang.
1064 clang_supports_flags = clang_found
1067 clang = cc.cmd_array()
1068 clang_supports_flags = cc.has_argument('-Wno-compare-distinct-pointer-types')
1072 # Check if 'clang -target bpf' is supported.
1073 clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0
1075 elif bpf_compiler == 'gcc'
1076 warning('GCC BPF Compiler support is experimental and not recommended.')
1077 bpf_gcc = find_program('bpf-gcc',
1079 version : '>= 12.1.0')
1080 bpf_gcc_found = bpf_gcc.found()
1083 if clang_supports_bpf or bpf_gcc_found
1084 # Debian installs this in /usr/sbin/ which is not in $PATH.
1085 # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian.
1086 # We use 'bpftool gen object' subcommand for bpftool strip, it was added by d80b2fcbe0a023619e0fc73112f2a02c2662f6ab (v5.13).
1087 bpftool = find_program('bpftool',
1088 '/usr/sbin/bpftool',
1090 version : '>= 5.13.0')
1093 bpftool_strip = true
1096 bpftool_strip = false
1097 # We require the 'bpftool gen skeleton' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6).
1098 bpftool = find_program('bpftool',
1099 '/usr/sbin/bpftool',
1100 required : bpf_framework_required,
1101 version : '>= 5.6.0')
1104 # We use `llvm-strip` as a fallback if `bpftool gen object` strip support is not available.
1105 if not bpftool_strip and bpftool.found() and clang_supports_bpf
1106 if not meson.is_cross_build()
1107 llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip',
1108 check : true).stdout().strip()
1110 llvm_strip_bin = 'llvm-strip'
1112 llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0')
1113 deps_found = llvm_strip.found()
1117 # Can build BPF program from source code in restricted C
1118 conf.set10('BPF_FRAMEWORK', deps_found)
1121 libmount = dependency('mount',
1122 version : fuzzer_build ? '>= 0' : '>= 2.30')
1124 want_libfdisk = get_option('fdisk')
1125 if want_libfdisk != 'false' and not skip_deps
1126 libfdisk = dependency('fdisk',
1127 version : '>= 2.32',
1128 required : want_libfdisk == 'true')
1129 have = libfdisk.found()
1134 conf.set10('HAVE_LIBFDISK', have)
1136 want_pwquality = get_option('pwquality')
1137 if want_pwquality != 'false' and not skip_deps
1138 libpwquality = dependency('pwquality', required : want_pwquality == 'true')
1139 have = libpwquality.found()
1144 conf.set10('HAVE_PWQUALITY', have)
1146 want_seccomp = get_option('seccomp')
1147 if want_seccomp != 'false' and not skip_deps
1148 libseccomp = dependency('libseccomp',
1149 version : '>= 2.3.1',
1150 required : want_seccomp == 'true')
1151 have = libseccomp.found()
1156 conf.set10('HAVE_SECCOMP', have)
1158 want_selinux = get_option('selinux')
1159 if want_selinux != 'false' and not skip_deps
1160 libselinux = dependency('libselinux',
1161 version : '>= 2.1.9',
1162 required : want_selinux == 'true')
1163 have = libselinux.found()
1168 conf.set10('HAVE_SELINUX', have)
1170 want_apparmor = get_option('apparmor')
1171 if want_apparmor != 'false' and not skip_deps
1172 libapparmor = dependency('libapparmor',
1173 version : '>= 2.13',
1174 required : want_apparmor == 'true')
1175 have = libapparmor.found()
1180 conf.set10('HAVE_APPARMOR', have)
1182 have = get_option('smack') and get_option('smack-run-label') != ''
1183 conf.set10('HAVE_SMACK_RUN_LABEL', have)
1185 conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
1188 have = get_option('smack') and get_option('smack-default-process-label') != ''
1190 conf.set_quoted('SMACK_DEFAULT_PROCESS_LABEL', get_option('smack-default-process-label'))
1193 want_polkit = get_option('polkit')
1194 install_polkit = false
1195 install_polkit_pkla = false
1196 if want_polkit != 'false' and not skip_deps
1197 install_polkit = true
1199 libpolkit = dependency('polkit-gobject-1',
1201 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
1202 message('Old polkit detected, will install pkla files')
1203 install_polkit_pkla = true
1206 conf.set10('ENABLE_POLKIT', install_polkit)
1208 want_acl = get_option('acl')
1209 if want_acl != 'false' and not skip_deps
1210 libacl = cc.find_library('acl', required : want_acl == 'true')
1211 have = libacl.found()
1216 conf.set10('HAVE_ACL', have)
1218 want_audit = get_option('audit')
1219 if want_audit != 'false' and not skip_deps
1220 libaudit = dependency('audit', required : want_audit == 'true')
1221 have = libaudit.found()
1226 conf.set10('HAVE_AUDIT', have)
1228 want_blkid = get_option('blkid')
1229 if want_blkid != 'false' and not skip_deps
1230 libblkid = dependency('blkid', required : want_blkid == 'true')
1231 have = libblkid.found()
1233 conf.set10('HAVE_BLKID_PROBE_SET_HINT',
1234 have and cc.has_function('blkid_probe_set_hint', dependencies : libblkid))
1239 conf.set10('HAVE_BLKID', have)
1241 want_kmod = get_option('kmod')
1242 if want_kmod != 'false' and not skip_deps
1243 libkmod = dependency('libkmod',
1245 required : want_kmod == 'true')
1246 have = libkmod.found()
1251 conf.set10('HAVE_KMOD', have)
1253 want_pam = get_option('pam')
1254 if want_pam != 'false' and not skip_deps
1255 libpam = cc.find_library('pam', required : want_pam == 'true')
1256 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1257 have = libpam.found() and libpam_misc.found()
1263 conf.set10('HAVE_PAM', have)
1265 want_microhttpd = get_option('microhttpd')
1266 if want_microhttpd != 'false' and not skip_deps
1267 libmicrohttpd = dependency('libmicrohttpd',
1268 version : '>= 0.9.33',
1269 required : want_microhttpd == 'true')
1270 have = libmicrohttpd.found()
1275 conf.set10('HAVE_MICROHTTPD', have)
1277 want_libcryptsetup = get_option('libcryptsetup')
1278 want_libcryptsetup_plugins = get_option('libcryptsetup-plugins')
1280 if want_libcryptsetup_plugins == 'true' and want_libcryptsetup == 'false'
1281 error('libcryptsetup-plugins can not be requested without libcryptsetup')
1284 if want_libcryptsetup != 'false' and not skip_deps
1285 libcryptsetup = dependency('libcryptsetup',
1286 version : want_libcryptsetup_plugins == 'true' ? '>= 2.4.0' : '>= 2.0.1',
1287 required : want_libcryptsetup == 'true' or want_libcryptsetup_plugins == 'true')
1288 have = libcryptsetup.found()
1290 foreach ident : ['crypt_set_metadata_size',
1291 'crypt_activate_by_signed_key',
1293 have_ident = have and cc.has_function(
1295 prefix : '#include <libcryptsetup.h>',
1296 dependencies : libcryptsetup)
1297 conf.set10('HAVE_' + ident.to_upper(), have_ident)
1303 conf.set10('HAVE_LIBCRYPTSETUP', have)
1305 if want_libcryptsetup_plugins != 'false' and not skip_deps
1306 have = (cc.has_function(
1307 'crypt_activate_by_token_pin',
1308 prefix : '#include <libcryptsetup.h>',
1309 dependencies : libcryptsetup) and
1311 'crypt_token_external_path',
1312 prefix : '#include <libcryptsetup.h>',
1313 dependencies : libcryptsetup))
1317 conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have)
1319 want_libcurl = get_option('libcurl')
1320 if want_libcurl != 'false' and not skip_deps
1321 libcurl = dependency('libcurl',
1322 version : '>= 7.32.0',
1323 required : want_libcurl == 'true')
1324 have = libcurl.found()
1329 conf.set10('HAVE_LIBCURL', have)
1330 conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
1332 want_libidn = get_option('libidn')
1333 want_libidn2 = get_option('libidn2')
1334 if want_libidn == 'true' and want_libidn2 == 'true'
1335 error('libidn and libidn2 cannot be requested simultaneously')
1338 if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps
1339 libidn = dependency('libidn2',
1340 required : want_libidn2 == 'true')
1341 have = libidn.found()
1346 conf.set10('HAVE_LIBIDN2', have)
1347 if not have and want_libidn != 'false' and not skip_deps
1348 # libidn is used for both libidn and libidn2 objects
1349 libidn = dependency('libidn',
1350 required : want_libidn == 'true')
1351 have = libidn.found()
1355 conf.set10('HAVE_LIBIDN', have)
1357 want_libiptc = get_option('libiptc')
1358 if want_libiptc != 'false' and not skip_deps
1359 libiptc = dependency('libiptc',
1360 required : want_libiptc == 'true')
1361 have = libiptc.found()
1366 conf.set10('HAVE_LIBIPTC', have)
1368 want_qrencode = get_option('qrencode')
1369 if want_qrencode != 'false' and not skip_deps
1370 libqrencode = dependency('libqrencode',
1372 required : want_qrencode == 'true')
1373 have = libqrencode.found()
1378 conf.set10('HAVE_QRENCODE', have)
1380 want_gcrypt = get_option('gcrypt')
1381 if want_gcrypt != 'false' and not skip_deps
1382 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1383 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1384 have = libgcrypt.found() and libgpg_error.found()
1389 # link to neither of the libs if one is not found
1393 conf.set10('HAVE_GCRYPT', have)
1395 want_gnutls = get_option('gnutls')
1396 if want_gnutls != 'false' and not skip_deps
1397 libgnutls = dependency('gnutls',
1398 version : '>= 3.1.4',
1399 required : want_gnutls == 'true')
1400 have = libgnutls.found()
1405 conf.set10('HAVE_GNUTLS', have)
1407 want_openssl = get_option('openssl')
1408 if want_openssl != 'false' and not skip_deps
1409 libopenssl = dependency('openssl',
1410 version : '>= 1.1.0',
1411 required : want_openssl == 'true')
1412 have = libopenssl.found()
1417 conf.set10('HAVE_OPENSSL', have)
1419 want_p11kit = get_option('p11kit')
1420 if want_p11kit != 'false' and not skip_deps
1421 libp11kit = dependency('p11-kit-1',
1422 version : '>= 0.23.3',
1423 required : want_p11kit == 'true')
1424 have = libp11kit.found()
1429 conf.set10('HAVE_P11KIT', have)
1431 want_libfido2 = get_option('libfido2')
1432 if want_libfido2 != 'false' and not skip_deps
1433 libfido2 = dependency('libfido2',
1434 required : want_libfido2 == 'true')
1435 have = libfido2.found()
1440 conf.set10('HAVE_LIBFIDO2', have)
1442 want_tpm2 = get_option('tpm2')
1443 if want_tpm2 != 'false' and not skip_deps
1444 tpm2 = dependency('tss2-esys tss2-rc tss2-mu',
1445 required : want_tpm2 == 'true')
1451 conf.set10('HAVE_TPM2', have)
1453 want_elfutils = get_option('elfutils')
1454 if want_elfutils != 'false' and not skip_deps
1455 libdw = dependency('libdw',
1456 required : want_elfutils == 'true')
1457 have = libdw.found()
1459 # New in elfutils 0.177
1460 conf.set10('HAVE_DWELF_ELF_E_MACHINE_STRING',
1461 have and cc.has_function('dwelf_elf_e_machine_string', dependencies : libdw))
1466 conf.set10('HAVE_ELFUTILS', have)
1468 want_zlib = get_option('zlib')
1469 if want_zlib != 'false' and not skip_deps
1470 libz = dependency('zlib',
1471 required : want_zlib == 'true')
1477 conf.set10('HAVE_ZLIB', have)
1479 want_bzip2 = get_option('bzip2')
1480 if want_bzip2 != 'false' and not skip_deps
1481 libbzip2 = cc.find_library('bz2',
1482 required : want_bzip2 == 'true')
1483 have = libbzip2.found()
1488 conf.set10('HAVE_BZIP2', have)
1490 want_xz = get_option('xz')
1491 if want_xz != 'false' and not skip_deps
1492 libxz = dependency('liblzma',
1493 required : want_xz == 'true')
1494 have_xz = libxz.found()
1499 conf.set10('HAVE_XZ', have_xz)
1501 want_lz4 = get_option('lz4')
1502 if want_lz4 != 'false' and not skip_deps
1503 liblz4 = dependency('liblz4',
1504 version : '>= 1.3.0',
1505 required : want_lz4 == 'true')
1506 have_lz4 = liblz4.found()
1511 conf.set10('HAVE_LZ4', have_lz4)
1513 want_zstd = get_option('zstd')
1514 if want_zstd != 'false' and not skip_deps
1515 libzstd = dependency('libzstd',
1516 required : want_zstd == 'true',
1517 version : '>= 1.4.0')
1518 have_zstd = libzstd.found()
1523 conf.set10('HAVE_ZSTD', have_zstd)
1525 conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
1527 compression = get_option('default-compression')
1528 if compression == 'auto'
1530 compression = 'zstd'
1536 compression = 'none'
1538 elif compression == 'zstd' and not have_zstd
1539 error('default-compression=zstd requires zstd')
1540 elif compression == 'lz4' and not have_lz4
1541 error('default-compression=lz4 requires lz4')
1542 elif compression == 'xz' and not have_xz
1543 error('default-compression=xz requires xz')
1545 conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper()))
1547 want_xkbcommon = get_option('xkbcommon')
1548 if want_xkbcommon != 'false' and not skip_deps
1549 libxkbcommon = dependency('xkbcommon',
1550 version : '>= 0.3.0',
1551 required : want_xkbcommon == 'true')
1552 have = libxkbcommon.found()
1557 conf.set10('HAVE_XKBCOMMON', have)
1559 want_pcre2 = get_option('pcre2')
1560 if want_pcre2 != 'false' and not skip_deps
1561 libpcre2 = dependency('libpcre2-8',
1562 required : want_pcre2 == 'true')
1563 have = libpcre2.found()
1568 conf.set10('HAVE_PCRE2', have)
1570 want_glib = get_option('glib')
1571 if want_glib != 'false' and not skip_deps
1572 libglib = dependency('glib-2.0',
1573 version : '>= 2.22.0',
1574 required : want_glib == 'true')
1575 libgobject = dependency('gobject-2.0',
1576 version : '>= 2.22.0',
1577 required : want_glib == 'true')
1578 libgio = dependency('gio-2.0',
1579 required : want_glib == 'true')
1580 have = libglib.found() and libgobject.found() and libgio.found()
1587 conf.set10('HAVE_GLIB', have)
1589 want_dbus = get_option('dbus')
1590 if want_dbus != 'false' and not skip_deps
1591 libdbus = dependency('dbus-1',
1592 version : '>= 1.3.2',
1593 required : want_dbus == 'true')
1594 have = libdbus.found()
1599 conf.set10('HAVE_DBUS', have)
1601 dbusdatadir = datadir / 'dbus-1'
1602 if conf.get('HAVE_DBUS') == 1
1603 dbusdatadir = libdbus.get_variable(pkgconfig: 'datadir', default_value: datadir) / 'dbus-1'
1606 dbuspolicydir = get_option('dbuspolicydir')
1607 if dbuspolicydir == ''
1608 dbuspolicydir = dbusdatadir / 'system.d'
1611 dbussessionservicedir = get_option('dbussessionservicedir')
1612 if dbussessionservicedir == ''
1613 dbussessionservicedir = dbusdatadir / 'services'
1614 if conf.get('HAVE_DBUS') == 1
1615 dbussessionservicedir = libdbus.get_variable(pkgconfig: 'session_bus_services_dir', default_value: dbussessionservicedir)
1619 dbussystemservicedir = get_option('dbussystemservicedir')
1620 if dbussystemservicedir == ''
1621 dbussystemservicedir = dbusdatadir / 'system-services'
1622 if conf.get('HAVE_DBUS') == 1
1623 dbussystemservicedir = libdbus.get_variable(pkgconfig: 'system_bus_services_dir', default_value: dbussystemservicedir)
1627 dbus_interfaces_dir = get_option('dbus-interfaces-dir')
1628 if dbus_interfaces_dir == '' or dbus_interfaces_dir == 'yes'
1629 if meson.is_cross_build() and dbus_interfaces_dir != 'yes'
1630 dbus_interfaces_dir = 'no'
1631 warning('Exporting D-Bus interface XML files is disabled during cross build. Pass path or "yes" to force enable.')
1633 dbus_interfaces_dir = dbusdatadir / 'interfaces'
1634 if conf.get('HAVE_DBUS') == 1
1635 dbus_interfaces_dir = libdbus.get_variable(pkgconfig: 'interfaces_dir', default_value: dbus_interfaces_dir)
1640 # We support one or the other. If gcrypt is available, we assume it's there to
1641 # be used, and use it in preference.
1642 opt = get_option('cryptolib')
1643 if opt == 'openssl' and conf.get('HAVE_OPENSSL') == 0
1644 error('openssl requested as the default cryptolib, but not available')
1646 conf.set10('PREFER_OPENSSL',
1647 opt == 'openssl' or (opt == 'auto' and conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_GCRYPT') == 0))
1648 conf.set10('HAVE_OPENSSL_OR_GCRYPT',
1649 conf.get('HAVE_OPENSSL') == 1 or conf.get('HAVE_GCRYPT') == 1)
1650 lib_openssl_or_gcrypt = conf.get('PREFER_OPENSSL') == 1 ? [libopenssl] : [libgcrypt, libgpg_error]
1652 dns_over_tls = get_option('dns-over-tls')
1653 if dns_over_tls != 'false'
1654 if dns_over_tls == 'gnutls' and conf.get('PREFER_OPENSSL') == 1
1655 error('Sorry, -Ddns-over-tls=gnutls is not supported when openssl is used as the cryptolib')
1658 if dns_over_tls == 'gnutls'
1659 have_openssl = false
1661 have_openssl = conf.get('HAVE_OPENSSL') == 1
1662 if dns_over_tls == 'openssl' and not have_openssl
1663 error('DNS-over-TLS support was requested with openssl, but dependencies are not available')
1666 if dns_over_tls == 'openssl' or have_openssl
1669 have_gnutls = conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0')
1670 if dns_over_tls != 'auto' and not have_gnutls
1671 str = dns_over_tls == 'gnutls' ? ' with gnutls' : ''
1672 error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
1675 have = have_gnutls or have_openssl
1679 have_openssl = false
1681 conf.set10('ENABLE_DNS_OVER_TLS', have)
1682 conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1683 conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
1685 default_dns_over_tls = get_option('default-dns-over-tls')
1687 default_dns_over_tls = 'no'
1689 if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
1690 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.')
1691 default_dns_over_tls = 'no'
1693 conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1694 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
1695 conf.set_quoted('DEFAULT_DNS_OVER_TLS_MODE_STR', default_dns_over_tls)
1697 default_mdns = get_option('default-mdns')
1698 conf.set('DEFAULT_MDNS_MODE',
1699 'RESOLVE_SUPPORT_' + default_mdns.to_upper())
1700 conf.set_quoted('DEFAULT_MDNS_MODE_STR', default_mdns)
1702 default_llmnr = get_option('default-llmnr')
1703 conf.set('DEFAULT_LLMNR_MODE',
1704 'RESOLVE_SUPPORT_' + default_llmnr.to_upper())
1705 conf.set_quoted('DEFAULT_LLMNR_MODE_STR', default_llmnr)
1707 want_repart = get_option('repart')
1708 if want_repart != 'false'
1709 have = conf.get('HAVE_LIBFDISK') == 1
1710 if want_repart == 'true' and not have
1711 error('repart support was requested, but dependencies are not available')
1716 conf.set10('ENABLE_REPART', have)
1718 default_dnssec = get_option('default-dnssec')
1720 default_dnssec = 'no'
1722 if default_dnssec != 'no' and conf.get('HAVE_OPENSSL_OR_GCRYPT') == 0
1723 message('default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.')
1724 default_dnssec = 'no'
1726 conf.set('DEFAULT_DNSSEC_MODE',
1727 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1728 conf.set_quoted('DEFAULT_DNSSEC_MODE_STR', default_dnssec)
1730 want_sysupdate = get_option('sysupdate')
1731 if want_sysupdate != 'false'
1732 have = (conf.get('HAVE_OPENSSL') == 1 and
1733 conf.get('HAVE_LIBFDISK') == 1)
1734 if want_sysupdate == 'true' and not have
1735 error('sysupdate support was requested, but dependencies are not available')
1740 conf.set10('ENABLE_SYSUPDATE', have)
1742 want_importd = get_option('importd')
1743 if want_importd != 'false'
1744 have = (conf.get('HAVE_LIBCURL') == 1 and
1745 conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and
1746 conf.get('HAVE_ZLIB') == 1 and
1747 conf.get('HAVE_XZ') == 1)
1748 if want_importd == 'true' and not have
1749 error('importd support was requested, but dependencies are not available')
1754 conf.set10('ENABLE_IMPORTD', have)
1756 want_kernel_install = get_option('kernel-install')
1757 conf.set10('ENABLE_KERNEL_INSTALL', want_kernel_install)
1759 want_homed = get_option('homed')
1760 if want_homed != 'false'
1761 have = (conf.get('HAVE_OPENSSL') == 1 and
1762 conf.get('HAVE_LIBFDISK') == 1 and
1763 conf.get('HAVE_LIBCRYPTSETUP') == 1)
1764 if want_homed == 'true' and not have
1765 error('homed support was requested, but dependencies are not available')
1770 conf.set10('ENABLE_HOMED', have)
1772 have = have and conf.get('HAVE_PAM') == 1
1773 conf.set10('ENABLE_PAM_HOME', have)
1775 have = get_option('oomd')
1776 conf.set10('ENABLE_OOMD', have)
1778 want_remote = get_option('remote')
1779 if want_remote != 'false'
1780 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1781 conf.get('HAVE_LIBCURL') == 1]
1782 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1783 # it's possible to build one without the other. Complain only if
1784 # support was explicitly requested. The auxiliary files like sysusers
1785 # config should be installed when any of the programs are built.
1786 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1787 error('remote support was requested, but dependencies are not available')
1789 have = have_deps[0] or have_deps[1]
1793 conf.set10('ENABLE_REMOTE', have)
1795 foreach term : ['analyze',
1809 'compat-mutable-uid-boundaries',
1835 have = get_option(term)
1836 name = 'ENABLE_' + term.underscorify().to_upper()
1837 conf.set10(name, have)
1840 enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
1842 foreach tuple : [['nss-mymachines', 'machined'],
1843 ['nss-resolve', 'resolve']]
1844 want = get_option(tuple[0])
1846 have = get_option(tuple[1])
1847 if want == 'true' and not have
1848 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1853 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1854 conf.set10(name, have)
1858 foreach term : ['ENABLE_NSS_MYHOSTNAME',
1859 'ENABLE_NSS_MYMACHINES',
1860 'ENABLE_NSS_RESOLVE',
1861 'ENABLE_NSS_SYSTEMD']
1862 if conf.get(term) == 1
1866 conf.set10('ENABLE_NSS', enable_nss)
1868 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1870 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1872 ############################################################
1878 ############################################################
1880 # Include these now as they provide gnu-efi detection.
1881 subdir('src/fundamental')
1882 subdir('src/boot/efi')
1884 ############################################################
1886 generate_gperfs = find_program('tools/generate-gperfs.py')
1887 make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
1888 make_directive_index_py = find_program('tools/make-directive-index.py')
1889 make_man_index_py = find_program('tools/make-man-index.py')
1890 meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
1891 update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
1892 update_man_rules_py = find_program('tools/update-man-rules.py')
1893 update_hwdb_sh = find_program('tools/update-hwdb.sh')
1894 update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
1895 update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
1896 xml_helper_py = find_program('tools/xml_helper.py')
1897 export_dbus_interfaces_py = find_program('tools/dbus_exporter.py')
1899 ############################################################
1901 if get_option('b_coverage')
1902 add_project_arguments('-include', 'src/basic/coverage.h', language : 'c')
1905 ############################################################
1907 config_h = configure_file(
1908 output : 'config.h',
1909 configuration : conf)
1911 add_project_arguments('-include', 'config.h', language : 'c')
1913 jinja2_cmdline = [meson_render_jinja2, config_h, version_h]
1915 ############################################################
1917 # binaries that have --help and are intended for use by humans,
1918 # usually, but not always, installed in /bin.
1919 public_programs = []
1921 # D-Bus introspection XML export
1924 basic_includes = include_directories(
1930 libsystemd_includes = [basic_includes, include_directories(
1931 'src/libsystemd/sd-bus',
1932 'src/libsystemd/sd-device',
1933 'src/libsystemd/sd-event',
1934 'src/libsystemd/sd-hwdb',
1935 'src/libsystemd/sd-id128',
1936 'src/libsystemd/sd-journal',
1937 'src/libsystemd/sd-netlink',
1938 'src/libsystemd/sd-network',
1939 'src/libsystemd/sd-resolve')]
1941 includes = [libsystemd_includes, include_directories('src/shared')]
1946 subdir('src/libsystemd')
1947 subdir('src/shared')
1949 subdir('src/libudev')
1950 subdir('src/cryptsetup/cryptsetup-tokens')
1952 alias_target('devel', libsystemd_pc, libudev_pc)
1954 libsystemd = shared_library(
1956 version : libsystemd_version,
1957 include_directories : libsystemd_includes,
1958 link_args : ['-shared',
1959 '-Wl,--version-script=' + libsystemd_sym_path],
1960 link_with : [libbasic,
1963 link_whole : [libsystemd_static],
1964 dependencies : [threads,
1966 link_depends : libsystemd_sym,
1968 install_tag: 'libsystemd',
1969 install_dir : rootlibdir)
1971 alias_target('libsystemd', libsystemd)
1973 install_libsystemd_static = static_library(
1977 basic_gcrypt_sources,
1978 basic_compress_sources,
1979 fundamental_sources,
1980 include_directories : libsystemd_includes,
1981 build_by_default : static_libsystemd != 'false',
1982 install : static_libsystemd != 'false',
1983 install_tag: 'libsystemd',
1984 install_dir : rootlibdir,
1985 pic : static_libsystemd_pic,
1986 dependencies : [threads,
1997 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
1999 libudev = shared_library(
2001 version : libudev_version,
2002 include_directories : includes,
2003 link_args : ['-shared',
2004 '-Wl,--version-script=' + libudev_sym_path],
2005 link_with : [libsystemd_static, libshared_static],
2006 link_whole : libudev_basic,
2007 dependencies : [threads],
2008 link_depends : libudev_sym,
2010 install_tag: 'libudev',
2011 install_dir : rootlibdir)
2013 alias_target('libudev', libudev)
2015 install_libudev_static = static_library(
2018 fundamental_sources,
2022 include_directories : includes,
2023 build_by_default : static_libudev != 'false',
2024 install : static_libudev != 'false',
2025 install_tag: 'libudev',
2026 install_dir : rootlibdir,
2027 link_depends : libudev_sym,
2028 dependencies : libshared_deps + [libmount],
2029 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
2030 pic : static_libudev_pic)
2032 if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
2033 if conf.get('HAVE_TPM2') == 1
2034 cryptsetup_token_systemd_tpm2 = shared_library(
2035 'cryptsetup-token-systemd-tpm2',
2036 cryptsetup_token_systemd_tpm2_sources,
2037 include_directories : includes,
2038 link_args : ['-shared',
2039 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2040 link_with : [lib_cryptsetup_token_common,
2042 dependencies : [libcryptsetup,
2045 link_depends : cryptsetup_token_sym,
2046 install_rpath : rootpkglibdir,
2048 install_dir : libcryptsetup_plugins_dir)
2051 if conf.get('HAVE_LIBFIDO2') == 1
2052 cryptsetup_token_systemd_fido2 = shared_library(
2053 'cryptsetup-token-systemd-fido2',
2054 cryptsetup_token_systemd_fido2_sources,
2055 include_directories : includes,
2056 link_args : ['-shared',
2057 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2058 link_with : [lib_cryptsetup_token_common,
2060 dependencies : [libcryptsetup,
2063 link_depends : cryptsetup_token_sym,
2064 install_rpath : rootpkglibdir,
2066 install_dir : libcryptsetup_plugins_dir)
2069 if conf.get('HAVE_P11KIT') == 1
2070 cryptsetup_token_systemd_pkcs11 = shared_library(
2071 'cryptsetup-token-systemd-pkcs11',
2072 cryptsetup_token_systemd_pkcs11_sources,
2073 include_directories : includes,
2074 link_args : ['-shared',
2075 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2076 link_with : [lib_cryptsetup_token_common,
2078 dependencies : [libcryptsetup,
2081 link_depends : cryptsetup_token_sym,
2082 install_rpath : rootpkglibdir,
2084 install_dir : libcryptsetup_plugins_dir)
2088 ############################################################
2090 # systemd-analyze requires 'libcore'
2092 # systemd-journal-remote requires 'libjournal_core'
2093 subdir('src/journal')
2094 # systemd-networkd requires 'libsystemd_network'
2095 subdir('src/libsystemd-network')
2097 subdir('src/analyze')
2098 subdir('src/busctl')
2099 subdir('src/coredump')
2100 subdir('src/cryptenroll')
2101 subdir('src/cryptsetup')
2103 subdir('src/hostname')
2104 subdir('src/import')
2105 subdir('src/journal-remote')
2106 subdir('src/kernel-install')
2107 subdir('src/locale')
2109 subdir('src/machine')
2110 subdir('src/network')
2111 subdir('src/nspawn')
2113 subdir('src/partition')
2114 subdir('src/portable')
2115 subdir('src/pstore')
2116 subdir('src/resolve')
2118 subdir('src/shutdown')
2119 subdir('src/sysext')
2120 subdir('src/systemctl')
2121 subdir('src/sysupdate')
2122 subdir('src/timedate')
2123 subdir('src/timesync')
2124 subdir('src/tmpfiles')
2125 subdir('src/userdb')
2126 subdir('src/xdg-autostart-generator')
2128 subdir('src/systemd')
2135 ############################################################
2137 # only static linking apart from libdl, to make sure that the
2138 # module is linked to all libraries that it uses.
2139 test_dlopen = executable(
2142 include_directories : includes,
2143 link_with : [libbasic],
2144 dependencies : [libdl],
2145 build_by_default : want_tests != 'false')
2147 foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
2148 ['systemd', 'ENABLE_NSS_SYSTEMD', ['nss-systemd.h', 'userdb-glue.c', 'userdb-glue.h']],
2149 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
2150 ['resolve', 'ENABLE_NSS_RESOLVE', [], resolve_includes]]
2152 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
2156 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
2157 version_script_arg = project_source_root / sym
2159 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
2160 if tuple.length() > 2
2161 foreach s : tuple[2]
2162 sources += ['src/nss-@0@/@1@'.format(module, s)]
2166 incs = tuple.length() > 3 ? tuple[3] : includes
2168 nss = shared_library(
2172 include_directories : incs,
2173 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
2174 link_args : ['-Wl,-z,nodelete',
2176 '-Wl,--version-script=' + version_script_arg],
2177 link_with : [libsystemd_static,
2180 dependencies : [threads,
2184 install_tag : 'nss',
2185 install_dir : rootlibdir)
2187 # We cannot use shared_module because it does not support version suffix.
2188 # Unfortunately shared_library insists on creating the symlink…
2189 meson.add_install_script('sh', '-c',
2190 'rm $DESTDIR@0@/libnss_@1@.so'
2191 .format(rootlibdir, module),
2195 if want_tests != 'false'
2196 test('dlopen-nss_' + module,
2198 # path to dlopen must include a slash
2199 args : nss.full_path(),
2205 ############################################################
2210 include_directories : includes,
2211 link_with : [libcore,
2213 dependencies : [versiondep,
2215 install_rpath : rootpkglibdir,
2217 install_dir : rootlibexecdir)
2218 dbus_programs += exe
2219 public_programs += exe
2221 meson.add_install_script(meson_make_symlink,
2222 rootlibexecdir / 'systemd',
2223 rootsbindir / 'init')
2227 systemd_analyze_sources,
2228 include_directories : core_includes,
2229 link_with : [libcore,
2231 dependencies : [versiondep,
2233 install_rpath : rootpkglibdir,
2234 install : conf.get('ENABLE_ANALYZE') == 1)
2235 public_programs += exe
2237 if want_tests != 'false'
2238 test('test-compare-versions',
2239 test_compare_versions_sh,
2240 args : exe.full_path())
2245 systemd_journald_sources,
2246 include_directories : includes,
2247 link_with : [libjournal_core,
2249 dependencies : [threads,
2254 install_rpath : rootpkglibdir,
2256 install_dir : rootlibexecdir)
2258 public_programs += executable(
2260 systemd_cat_sources,
2261 include_directories : includes,
2262 link_with : [libjournal_core,
2264 dependencies : [threads],
2265 install_rpath : rootpkglibdir,
2268 if get_option('link-journalctl-shared')
2269 journalctl_link_with = [libshared]
2271 journalctl_link_with = [libsystemd_static,
2276 public_programs += executable(
2279 include_directories : includes,
2280 link_with : [journalctl_link_with],
2281 dependencies : [threads,
2287 install_rpath : rootpkglibdir,
2289 install_dir : rootbindir)
2292 'systemd-getty-generator',
2293 'src/getty-generator/getty-generator.c',
2294 include_directories : includes,
2295 link_with : [libshared],
2296 install_rpath : rootpkglibdir,
2298 install_dir : systemgeneratordir)
2301 'systemd-debug-generator',
2302 'src/debug-generator/debug-generator.c',
2303 include_directories : includes,
2304 link_with : [libshared],
2305 install_rpath : rootpkglibdir,
2307 install_dir : systemgeneratordir)
2310 'systemd-run-generator',
2311 'src/run-generator/run-generator.c',
2312 include_directories : includes,
2313 link_with : [libshared],
2314 install_rpath : rootpkglibdir,
2316 install_dir : systemgeneratordir)
2319 'systemd-fstab-generator',
2320 'src/fstab-generator/fstab-generator.c',
2321 include_directories : includes,
2322 link_with : [libshared],
2323 install_rpath : rootpkglibdir,
2325 install_dir : systemgeneratordir)
2327 meson.add_install_script(meson_make_symlink,
2328 systemgeneratordir / 'systemd-fstab-generator',
2329 rootlibexecdir / 'systemd-sysroot-fstab-check')
2331 if want_tests != 'false'
2332 test('test-fstab-generator',
2333 test_fstab_generator_sh,
2334 # https://github.com/mesonbuild/meson/issues/2681
2335 args : exe.full_path(),
2339 if conf.get('ENABLE_ENVIRONMENT_D') == 1
2341 '30-systemd-environment-d-generator',
2342 'src/environment-d-generator/environment-d-generator.c',
2343 include_directories : includes,
2344 link_with : [libshared],
2345 install_rpath : rootpkglibdir,
2347 install_dir : userenvgeneratordir)
2349 meson.add_install_script(meson_make_symlink,
2350 sysconfdir / 'environment',
2351 environmentdir / '99-environment.conf')
2354 if conf.get('ENABLE_HIBERNATE') == 1
2356 'systemd-hibernate-resume-generator',
2357 'src/hibernate-resume/hibernate-resume-generator.c',
2358 include_directories : includes,
2359 link_with : [libshared],
2360 install_rpath : rootpkglibdir,
2362 install_dir : systemgeneratordir)
2365 'systemd-hibernate-resume',
2366 'src/hibernate-resume/hibernate-resume.c',
2367 include_directories : includes,
2368 link_with : [libshared],
2369 install_rpath : rootpkglibdir,
2371 install_dir : rootlibexecdir)
2374 if conf.get('HAVE_BLKID') == 1
2376 'systemd-gpt-auto-generator',
2377 'src/gpt-auto-generator/gpt-auto-generator.c',
2378 include_directories : includes,
2379 link_with : [libshared],
2380 dependencies : libblkid,
2381 install_rpath : rootpkglibdir,
2383 install_dir : systemgeneratordir)
2385 public_programs += executable(
2387 'src/dissect/dissect.c',
2388 include_directories : includes,
2389 link_with : [libshared],
2390 install_rpath : rootpkglibdir,
2394 if conf.get('ENABLE_RESOLVE') == 1
2395 dbus_programs += executable(
2397 systemd_resolved_sources,
2398 include_directories : resolve_includes,
2399 link_with : [libshared,
2401 libsystemd_resolve_core],
2402 dependencies : systemd_resolved_dependencies,
2403 install_rpath : rootpkglibdir,
2405 install_dir : rootlibexecdir)
2407 public_programs += executable(
2410 include_directories : includes,
2411 link_with : [libshared,
2413 libsystemd_resolve_core],
2414 dependencies : [threads,
2415 lib_openssl_or_gcrypt,
2418 install_rpath : rootpkglibdir,
2421 meson.add_install_script(meson_make_symlink,
2422 bindir / 'resolvectl',
2423 rootsbindir / 'resolvconf')
2425 meson.add_install_script(meson_make_symlink,
2426 bindir / 'resolvectl',
2427 bindir / 'systemd-resolve')
2430 if conf.get('ENABLE_LOGIND') == 1
2431 dbus_programs += executable(
2433 systemd_logind_sources,
2434 include_directories : includes,
2435 link_with : [liblogind_core,
2437 dependencies : [threads,
2439 install_rpath : rootpkglibdir,
2441 install_dir : rootlibexecdir)
2443 public_programs += executable(
2446 include_directories : includes,
2447 link_with : [libshared],
2448 dependencies : [threads,
2452 install_rpath : rootpkglibdir,
2454 install_dir : rootbindir)
2456 public_programs += executable(
2458 'src/login/inhibit.c',
2459 include_directories : includes,
2460 link_with : [libshared],
2461 install_rpath : rootpkglibdir,
2463 install_dir : rootbindir)
2465 if conf.get('HAVE_PAM') == 1
2466 version_script_arg = project_source_root / pam_systemd_sym
2467 pam_systemd = shared_library(
2471 include_directories : includes,
2472 link_args : ['-shared',
2473 '-Wl,--version-script=' + version_script_arg],
2474 link_with : [libsystemd_static,
2476 dependencies : [threads,
2479 link_depends : pam_systemd_sym,
2481 install_tag : 'pam',
2482 install_dir : pamlibdir)
2484 if want_tests != 'false'
2485 test('dlopen-pam_systemd',
2487 # path to dlopen must include a slash
2488 args : pam_systemd.full_path(),
2489 depends : pam_systemd)
2494 'systemd-user-runtime-dir',
2495 user_runtime_dir_sources,
2496 include_directories : includes,
2497 link_with : [libshared],
2498 install_rpath : rootpkglibdir,
2500 install_dir : rootlibexecdir)
2503 if conf.get('HAVE_PAM') == 1
2505 'systemd-user-sessions',
2506 'src/user-sessions/user-sessions.c',
2507 include_directories : includes,
2508 link_with : [libshared],
2509 install_rpath : rootpkglibdir,
2511 install_dir : rootlibexecdir)
2514 if conf.get('HAVE_BLKID') == 1 and conf.get('HAVE_GNU_EFI') == 1
2515 if get_option('link-boot-shared')
2516 boot_link_with = [libshared]
2518 boot_link_with = [libsystemd_static, libshared_static]
2521 public_programs += executable(
2523 'src/boot/bootctl.c',
2524 include_directories : includes,
2525 link_with : [boot_link_with],
2526 dependencies : [libblkid],
2527 install_rpath : rootpkglibdir,
2530 public_programs += executable(
2531 'systemd-bless-boot',
2532 'src/boot/bless-boot.c',
2533 include_directories : includes,
2534 link_with : [boot_link_with],
2535 dependencies : [libblkid],
2536 install_rpath : rootpkglibdir,
2538 install_dir : rootlibexecdir)
2541 'systemd-bless-boot-generator',
2542 'src/boot/bless-boot-generator.c',
2543 include_directories : includes,
2544 link_with : [boot_link_with],
2545 install_rpath : rootpkglibdir,
2547 install_dir : systemgeneratordir)
2549 if conf.get('HAVE_OPENSSL') == 1
2552 'src/boot/measure.c',
2553 include_directories : includes,
2554 link_with : [libshared],
2555 dependencies : [libopenssl],
2556 install_rpath : rootpkglibdir,
2558 install_dir : rootlibexecdir)
2563 'systemd-boot-check-no-failures',
2564 'src/boot/boot-check-no-failures.c',
2565 include_directories : includes,
2566 link_with : [libshared],
2567 dependencies : [libblkid],
2568 install_rpath : rootpkglibdir,
2570 install_dir : rootlibexecdir)
2572 public_programs += executable(
2573 'systemd-socket-activate',
2574 'src/activate/activate.c',
2575 include_directories : includes,
2576 link_with : [libshared],
2577 dependencies : [threads],
2578 install_rpath : rootpkglibdir,
2581 systemctl = executable(
2584 include_directories : includes,
2585 link_with : systemctl_link_with,
2586 dependencies : [threads,
2592 install_rpath : rootpkglibdir,
2594 install_dir : rootbindir)
2595 public_programs += systemctl
2597 if conf.get('ENABLE_PORTABLED') == 1
2598 dbus_programs += executable(
2599 'systemd-portabled',
2600 systemd_portabled_sources,
2601 include_directories : includes,
2602 link_with : [libshared],
2603 dependencies : [threads, libselinux],
2604 install_rpath : rootpkglibdir,
2606 install_dir : rootlibexecdir)
2608 public_programs += executable(
2610 'src/portable/portablectl.c',
2611 include_directories : includes,
2612 link_with : [libshared],
2613 dependencies : [threads],
2614 install_rpath : rootpkglibdir,
2616 install_dir : rootbindir)
2619 if conf.get('ENABLE_SYSEXT') == 1
2620 public_programs += executable(
2622 systemd_sysext_sources,
2623 include_directories : includes,
2624 link_with : [libshared],
2625 install_rpath : rootpkglibdir,
2627 install_dir : rootbindir)
2630 if conf.get('ENABLE_USERDB') == 1
2633 systemd_userwork_sources,
2634 include_directories : includes,
2635 link_with : [libshared],
2636 dependencies : [threads],
2637 install_rpath : rootpkglibdir,
2639 install_dir : rootlibexecdir)
2643 systemd_userdbd_sources,
2644 include_directories : includes,
2645 link_with : [libshared],
2646 dependencies : [threads],
2647 install_rpath : rootpkglibdir,
2649 install_dir : rootlibexecdir)
2651 public_programs += executable(
2654 include_directories : includes,
2655 link_with : [libshared],
2656 dependencies : [threads],
2657 install_rpath : rootpkglibdir,
2661 if conf.get('ENABLE_HOMED') == 1
2664 systemd_homework_sources,
2665 include_directories : includes,
2666 link_with : [libshared],
2667 dependencies : [threads,
2673 install_rpath : rootpkglibdir,
2675 install_dir : rootlibexecdir)
2677 dbus_programs += executable(
2679 systemd_homed_sources,
2680 include_directories : home_includes,
2681 link_with : [libshared],
2682 dependencies : [threads,
2686 install_rpath : rootpkglibdir,
2688 install_dir : rootlibexecdir)
2690 public_programs += executable(
2693 include_directories : includes,
2694 link_with : [libshared],
2695 dependencies : [threads,
2700 install_rpath : rootpkglibdir,
2703 if conf.get('HAVE_PAM') == 1
2704 version_script_arg = project_source_root / pam_systemd_home_sym
2705 pam_systemd_home = shared_library(
2709 include_directories : includes,
2710 link_args : ['-shared',
2711 '-Wl,--version-script=' + version_script_arg],
2712 link_with : [libsystemd_static,
2714 dependencies : [threads,
2718 link_depends : pam_systemd_home_sym,
2720 install_tag : 'pam',
2721 install_dir : pamlibdir)
2723 if want_tests != 'false'
2724 test('dlopen-pam_systemd_home',
2726 # path to dlopen must include a slash
2727 args : pam_systemd_home.full_path(),
2728 depends : pam_systemd_home)
2733 foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
2734 (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
2735 meson.add_install_script(meson_make_symlink,
2736 rootbindir / 'systemctl',
2737 rootsbindir / alias)
2740 meson.add_install_script(meson_make_symlink,
2741 rootbindir / 'udevadm',
2742 rootlibexecdir / 'systemd-udevd')
2744 if conf.get('ENABLE_BACKLIGHT') == 1
2746 'systemd-backlight',
2747 'src/backlight/backlight.c',
2748 include_directories : includes,
2749 link_with : [libshared],
2750 install_rpath : rootpkglibdir,
2752 install_dir : rootlibexecdir)
2755 if conf.get('ENABLE_RFKILL') == 1
2758 'src/rfkill/rfkill.c',
2759 include_directories : includes,
2760 link_with : [libshared],
2761 install_rpath : rootpkglibdir,
2763 install_dir : rootlibexecdir)
2767 'systemd-system-update-generator',
2768 'src/system-update-generator/system-update-generator.c',
2769 include_directories : includes,
2770 link_with : [libshared],
2771 install_rpath : rootpkglibdir,
2773 install_dir : systemgeneratordir)
2775 if conf.get('HAVE_LIBCRYPTSETUP') == 1
2777 'systemd-cryptsetup',
2778 systemd_cryptsetup_sources,
2779 include_directories : includes,
2780 link_with : [libshared],
2781 dependencies : [libcryptsetup,
2783 install_rpath : rootpkglibdir,
2785 install_dir : rootlibexecdir)
2788 'systemd-cryptsetup-generator',
2789 'src/cryptsetup/cryptsetup-generator.c',
2790 include_directories : includes,
2791 link_with : [libshared],
2792 install_rpath : rootpkglibdir,
2794 install_dir : systemgeneratordir)
2797 'systemd-veritysetup',
2798 'src/veritysetup/veritysetup.c',
2799 include_directories : includes,
2800 link_with : [libshared],
2801 dependencies : [libcryptsetup],
2802 install_rpath : rootpkglibdir,
2804 install_dir : rootlibexecdir)
2807 'systemd-veritysetup-generator',
2808 'src/veritysetup/veritysetup-generator.c',
2809 include_directories : includes,
2810 link_with : [libshared],
2811 install_rpath : rootpkglibdir,
2813 install_dir : systemgeneratordir)
2815 public_programs += executable(
2816 'systemd-cryptenroll',
2817 systemd_cryptenroll_sources,
2818 include_directories : includes,
2819 link_with : [libshared],
2820 dependencies : [libcryptsetup,
2824 install_rpath : rootpkglibdir,
2828 'systemd-integritysetup',
2829 ['src/integritysetup/integritysetup.c', 'src/integritysetup/integrity-util.c'],
2830 include_directories : includes,
2831 link_with : [libshared],
2832 dependencies : [libcryptsetup],
2833 install_rpath : rootpkglibdir,
2835 install_dir : rootlibexecdir)
2838 'systemd-integritysetup-generator',
2839 ['src/integritysetup/integritysetup-generator.c', 'src/integritysetup/integrity-util.c'],
2840 include_directories : includes,
2841 link_with : [libshared],
2842 install_rpath : rootpkglibdir,
2844 install_dir : systemgeneratordir)
2847 if conf.get('HAVE_SYSV_COMPAT') == 1
2849 'systemd-sysv-generator',
2850 'src/sysv-generator/sysv-generator.c',
2851 include_directories : includes,
2852 link_with : [libshared],
2853 install_rpath : rootpkglibdir,
2855 install_dir : systemgeneratordir)
2857 sysv_generator_test_py = find_program('test/sysv-generator-test.py')
2858 if want_tests != 'false'
2859 test('sysv-generator-test',
2860 sysv_generator_test_py,
2865 'systemd-rc-local-generator',
2866 'src/rc-local-generator/rc-local-generator.c',
2867 include_directories : includes,
2868 link_with : [libshared],
2869 install_rpath : rootpkglibdir,
2871 install_dir : systemgeneratordir)
2874 if conf.get('ENABLE_XDG_AUTOSTART') == 1
2876 'systemd-xdg-autostart-generator',
2877 systemd_xdg_autostart_generator_sources,
2878 include_directories : includes,
2879 link_with : [libshared],
2880 install_rpath : rootpkglibdir,
2882 install_dir : usergeneratordir)
2885 'systemd-xdg-autostart-condition',
2886 'src/xdg-autostart-generator/xdg-autostart-condition.c',
2887 include_directories : includes,
2888 link_with : [libshared],
2889 install_rpath : rootpkglibdir,
2891 install_dir : rootlibexecdir)
2894 if conf.get('ENABLE_HOSTNAMED') == 1
2895 dbus_programs += executable(
2896 'systemd-hostnamed',
2897 'src/hostname/hostnamed.c',
2898 include_directories : includes,
2899 link_with : [libshared],
2900 install_rpath : rootpkglibdir,
2902 install_dir : rootlibexecdir)
2904 public_programs += executable(
2906 'src/hostname/hostnamectl.c',
2907 include_directories : includes,
2908 link_with : [libshared],
2909 install_rpath : rootpkglibdir,
2913 if conf.get('ENABLE_LOCALED') == 1
2914 if conf.get('HAVE_XKBCOMMON') == 1
2915 # logind will load libxkbcommon.so dynamically on its own, but we still
2916 # need to specify where the headers are
2917 deps = [libdl, libxkbcommon.partial_dependency(compile_args: true)]
2922 dbus_programs += executable(
2924 systemd_localed_sources,
2925 include_directories : includes,
2926 link_with : [libshared],
2927 dependencies : deps,
2928 install_rpath : rootpkglibdir,
2930 install_dir : rootlibexecdir)
2932 public_programs += executable(
2935 include_directories : includes,
2936 link_with : [libshared],
2937 install_rpath : rootpkglibdir,
2941 if conf.get('ENABLE_TIMEDATED') == 1
2942 dbus_programs += executable(
2943 'systemd-timedated',
2944 'src/timedate/timedated.c',
2945 include_directories : includes,
2946 link_with : [libshared],
2947 install_rpath : rootpkglibdir,
2949 install_dir : rootlibexecdir)
2952 if conf.get('ENABLE_TIMEDATECTL') == 1
2953 public_programs += executable(
2955 'src/timedate/timedatectl.c',
2956 include_directories : includes,
2957 install_rpath : rootpkglibdir,
2958 link_with : [libshared],
2959 dependencies : [libm],
2963 if conf.get('ENABLE_TIMESYNCD') == 1
2965 'systemd-timesyncd',
2966 systemd_timesyncd_sources,
2967 include_directories : includes,
2968 link_with : [libtimesyncd_core],
2969 dependencies : [threads,
2971 install_rpath : rootpkglibdir,
2973 install_dir : rootlibexecdir)
2976 'systemd-time-wait-sync',
2977 'src/timesync/wait-sync.c',
2978 include_directories : includes,
2979 link_with : [libtimesyncd_core],
2980 install_rpath : rootpkglibdir,
2982 install_dir : rootlibexecdir)
2985 if conf.get('ENABLE_MACHINED') == 1
2986 dbus_programs += executable(
2988 systemd_machined_sources,
2989 include_directories : includes,
2990 link_with : [libmachine_core,
2992 install_rpath : rootpkglibdir,
2994 install_dir : rootlibexecdir)
2996 public_programs += executable(
2998 'src/machine/machinectl.c',
2999 include_directories : includes,
3000 link_with : [libshared],
3001 dependencies : [threads,
3005 install_rpath : rootpkglibdir,
3007 install_dir : rootbindir)
3010 if conf.get('ENABLE_IMPORTD') == 1
3011 dbus_programs += executable(
3013 systemd_importd_sources,
3014 include_directories : includes,
3015 link_with : [libshared],
3016 dependencies : [threads],
3017 install_rpath : rootpkglibdir,
3019 install_dir : rootlibexecdir)
3021 systemd_pull = executable(
3023 systemd_pull_sources,
3024 include_directories : includes,
3025 link_with : [libshared,
3027 dependencies : [versiondep,
3029 lib_openssl_or_gcrypt,
3033 install_rpath : rootpkglibdir,
3035 install_dir : rootlibexecdir)
3037 systemd_import = executable(
3039 systemd_import_sources,
3040 include_directories : includes,
3041 link_with : [libshared,
3043 dependencies : [libcurl,
3047 install_rpath : rootpkglibdir,
3049 install_dir : rootlibexecdir)
3051 systemd_import_fs = executable(
3052 'systemd-import-fs',
3053 systemd_import_fs_sources,
3054 include_directories : includes,
3055 link_with : [libshared,
3057 install_rpath : rootpkglibdir,
3059 install_dir : rootlibexecdir)
3061 systemd_export = executable(
3063 systemd_export_sources,
3064 include_directories : includes,
3065 link_with : [libshared,
3067 dependencies : [libcurl,
3071 install_rpath : rootpkglibdir,
3073 install_dir : rootlibexecdir)
3075 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
3078 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
3079 public_programs += executable(
3080 'systemd-journal-upload',
3081 systemd_journal_upload_sources,
3082 include_directories : includes,
3083 link_with : [libshared],
3084 dependencies : [versiondep,
3091 install_rpath : rootpkglibdir,
3093 install_dir : rootlibexecdir)
3096 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
3097 public_programs += executable(
3098 'systemd-journal-remote',
3099 systemd_journal_remote_sources,
3100 include_directories : journal_includes,
3101 link_with : [libshared,
3102 libsystemd_journal_remote],
3103 dependencies : [threads,
3109 install_rpath : rootpkglibdir,
3111 install_dir : rootlibexecdir)
3113 public_programs += executable(
3114 'systemd-journal-gatewayd',
3115 systemd_journal_gatewayd_sources,
3116 include_directories : journal_includes,
3117 link_with : [libshared],
3118 dependencies : [threads,
3124 install_rpath : rootpkglibdir,
3126 install_dir : rootlibexecdir)
3129 if conf.get('ENABLE_COREDUMP') == 1
3132 systemd_coredump_sources,
3133 include_directories : includes,
3134 link_with : [libshared,
3136 dependencies : [threads,
3141 install_rpath : rootpkglibdir,
3143 install_dir : rootlibexecdir)
3145 public_programs += executable(
3147 coredumpctl_sources,
3148 include_directories : includes,
3149 link_with : [libshared,
3151 dependencies : [threads,
3155 install_rpath : rootpkglibdir,
3159 if conf.get('ENABLE_PSTORE') == 1
3162 systemd_pstore_sources,
3163 include_directories : includes,
3164 link_with : [libshared],
3165 dependencies : [threads,
3170 install_rpath : rootpkglibdir,
3172 install_dir : rootlibexecdir)
3175 if conf.get('ENABLE_OOMD') == 1
3176 dbus_programs += executable('systemd-oomd',
3177 systemd_oomd_sources,
3178 include_directories : includes,
3179 link_with : [libshared],
3181 install_rpath : rootpkglibdir,
3183 install_dir : rootlibexecdir)
3185 public_programs += executable(
3188 include_directories : includes,
3189 link_with : [libshared],
3191 install_rpath : rootpkglibdir,
3195 if conf.get('ENABLE_BINFMT') == 1
3196 public_programs += executable(
3198 'src/binfmt/binfmt.c',
3199 include_directories : includes,
3200 link_with : [libshared],
3201 install_rpath : rootpkglibdir,
3203 install_dir : rootlibexecdir)
3205 meson.add_install_script('sh', '-c',
3206 mkdir_p.format(binfmtdir))
3207 if install_sysconfdir
3208 meson.add_install_script('sh', '-c',
3209 mkdir_p.format(sysconfdir / 'binfmt.d'))
3213 if conf.get('ENABLE_SYSUPDATE') == 1
3215 'systemd-sysupdate',
3216 systemd_sysupdate_sources,
3217 include_directories : includes,
3218 link_with : [libshared],
3219 dependencies : [threads,
3223 install_rpath : rootpkglibdir,
3225 install_dir : rootlibexecdir)
3226 public_programs += exe
3229 if conf.get('ENABLE_VCONSOLE') == 1
3231 'systemd-vconsole-setup',
3232 'src/vconsole/vconsole-setup.c',
3233 include_directories : includes,
3234 link_with : [libshared],
3235 install_rpath : rootpkglibdir,
3237 install_dir : rootlibexecdir)
3240 if conf.get('ENABLE_RANDOMSEED') == 1
3242 'systemd-random-seed',
3243 'src/random-seed/random-seed.c',
3244 include_directories : includes,
3245 link_with : [libshared],
3246 install_rpath : rootpkglibdir,
3248 install_dir : rootlibexecdir)
3251 if conf.get('ENABLE_FIRSTBOOT') == 1
3252 public_programs += executable(
3253 'systemd-firstboot',
3254 'src/firstboot/firstboot.c',
3255 include_directories : includes,
3256 link_with : [libshared],
3257 dependencies : [libcrypt],
3258 install_rpath : rootpkglibdir,
3260 install_dir : rootbindir)
3264 'systemd-remount-fs',
3265 'src/remount-fs/remount-fs.c',
3266 include_directories : includes,
3267 link_with : [libshared],
3268 install_rpath : rootpkglibdir,
3270 install_dir : rootlibexecdir)
3273 'systemd-machine-id-setup',
3274 'src/machine-id-setup/machine-id-setup-main.c',
3275 include_directories : includes,
3276 link_with : [libshared],
3277 install_rpath : rootpkglibdir,
3279 install_dir : rootbindir)
3284 include_directories : includes,
3285 link_with : [libshared],
3286 install_rpath : rootpkglibdir,
3288 install_dir : rootlibexecdir)
3290 executable('systemd-growfs',
3291 'src/partition/growfs.c',
3292 include_directories : includes,
3293 link_with : [libshared],
3294 install_rpath : rootpkglibdir,
3296 install_dir : rootlibexecdir)
3300 'src/partition/makefs.c',
3301 include_directories : includes,
3302 link_with : [libshared],
3303 install_rpath : rootpkglibdir,
3305 install_dir : rootlibexecdir)
3309 'src/sleep/sleep.c',
3310 include_directories : includes,
3311 link_with : [libshared],
3312 install_rpath : rootpkglibdir,
3314 install_dir : rootlibexecdir)
3316 if install_sysconfdir_samples
3317 install_data('src/sleep/sleep.conf',
3318 install_dir : pkgsysconfdir)
3321 public_programs += executable(
3323 'src/sysctl/sysctl.c',
3324 include_directories : includes,
3325 link_with : [libshared],
3326 install_rpath : rootpkglibdir,
3328 install_dir : rootlibexecdir)
3332 'src/ac-power/ac-power.c',
3333 include_directories : includes,
3334 link_with : [libshared],
3335 install_rpath : rootpkglibdir,
3337 install_dir : rootlibexecdir)
3339 public_programs += executable(
3340 'systemd-detect-virt',
3341 'src/detect-virt/detect-virt.c',
3342 include_directories : includes,
3343 link_with : [libshared],
3344 install_rpath : rootpkglibdir,
3347 public_programs += executable(
3349 'src/delta/delta.c',
3350 include_directories : includes,
3351 link_with : [libshared],
3352 install_rpath : rootpkglibdir,
3355 public_programs += executable(
3357 'src/escape/escape.c',
3358 include_directories : includes,
3359 link_with : [libshared],
3360 install_rpath : rootpkglibdir,
3362 install_dir : rootbindir)
3364 public_programs += executable(
3366 'src/notify/notify.c',
3367 include_directories : includes,
3368 link_with : [libshared],
3369 install_rpath : rootpkglibdir,
3371 install_dir : rootbindir)
3373 public_programs += executable(
3375 'src/creds/creds.c',
3376 include_directories : includes,
3377 link_with : [libshared],
3378 dependencies : [threads,
3380 install_rpath : rootpkglibdir,
3382 install_dir : rootbindir)
3385 'systemd-volatile-root',
3386 'src/volatile-root/volatile-root.c',
3387 include_directories : includes,
3388 link_with : [libshared],
3389 install_rpath : rootpkglibdir,
3390 install : conf.get('ENABLE_INITRD') == 1,
3391 install_dir : rootlibexecdir)
3394 'systemd-cgroups-agent',
3395 'src/cgroups-agent/cgroups-agent.c',
3396 include_directories : includes,
3397 link_with : [libshared],
3398 install_rpath : rootpkglibdir,
3400 install_dir : rootlibexecdir)
3402 systemd_id128 = executable(
3404 'src/id128/id128.c',
3405 include_directories : includes,
3406 link_with : [libshared],
3407 install_rpath : rootpkglibdir,
3409 public_programs += systemd_id128
3411 if want_tests != 'false'
3412 test('test-systemctl-enable',
3413 test_systemctl_enable_sh,
3414 # https://github.com/mesonbuild/meson/issues/2681
3415 args : [systemctl.full_path(),
3416 systemd_id128.full_path()])
3419 public_programs += executable(
3422 include_directories : includes,
3423 link_with : [libshared],
3424 install_rpath : rootpkglibdir,
3427 public_programs += executable(
3428 'systemd-ask-password',
3429 'src/ask-password/ask-password.c',
3430 include_directories : includes,
3431 link_with : [libshared],
3432 install_rpath : rootpkglibdir,
3434 install_dir : rootbindir)
3437 'systemd-reply-password',
3438 'src/reply-password/reply-password.c',
3439 include_directories : includes,
3440 link_with : [libshared],
3441 install_rpath : rootpkglibdir,
3443 install_dir : rootlibexecdir)
3445 public_programs += executable(
3446 'systemd-tty-ask-password-agent',
3447 'src/tty-ask-password-agent/tty-ask-password-agent.c',
3448 include_directories : includes,
3449 link_with : [libshared],
3450 install_rpath : rootpkglibdir,
3452 install_dir : rootbindir)
3454 public_programs += executable(
3457 include_directories : includes,
3458 link_with : [libshared],
3459 install_rpath : rootpkglibdir,
3462 public_programs += executable(
3464 'src/cgtop/cgtop.c',
3465 include_directories : includes,
3466 link_with : [libshared],
3467 install_rpath : rootpkglibdir,
3472 'src/initctl/initctl.c',
3473 include_directories : includes,
3474 link_with : [libshared],
3475 install_rpath : rootpkglibdir,
3476 install : (conf.get('HAVE_SYSV_COMPAT') == 1),
3477 install_dir : rootlibexecdir)
3479 public_programs += executable(
3481 'src/mount/mount-tool.c',
3482 include_directories : includes,
3483 link_with : [libshared],
3484 dependencies: [libmount],
3485 install_rpath : rootpkglibdir,
3488 meson.add_install_script(meson_make_symlink,
3489 'systemd-mount', bindir / 'systemd-umount')
3491 public_programs += executable(
3494 include_directories : includes,
3495 link_with : [libshared],
3496 install_rpath : rootpkglibdir,
3499 public_programs += executable(
3500 'systemd-stdio-bridge',
3501 'src/stdio-bridge/stdio-bridge.c',
3502 include_directories : includes,
3503 link_with : [libshared],
3504 dependencies : [versiondep],
3505 install_rpath : rootpkglibdir,
3508 public_programs += executable(
3511 include_directories : includes,
3512 link_with : [libshared],
3513 dependencies : [versiondep],
3514 install_rpath : rootpkglibdir,
3520 'src/sysusers/sysusers.c',
3521 include_directories : includes,
3522 link_with : [libshared],
3523 install_rpath : rootpkglibdir,
3525 install_dir : rootbindir)
3526 public_programs += exe
3528 if want_tests != 'false'
3529 test('test-sysusers',
3531 # https://github.com/mesonbuild/meson/issues/2681
3532 args : exe.full_path())
3535 if have_standalone_binaries
3537 'systemd-sysusers.standalone',
3538 'src/sysusers/sysusers.c',
3539 include_directories : includes,
3540 c_args : '-DSTANDALONE',
3541 link_with : [libshared_static,
3546 install_dir : rootbindir)
3547 public_programs += exe
3549 if want_tests != 'false'
3550 test('test-sysusers.standalone',
3552 # https://github.com/mesonbuild/meson/issues/2681
3553 args : exe.full_path())
3558 if conf.get('ENABLE_TMPFILES') == 1
3561 systemd_tmpfiles_sources,
3562 include_directories : includes,
3563 link_with : [libshared],
3564 dependencies : [libacl],
3565 install_rpath : rootpkglibdir,
3567 install_dir : rootbindir)
3568 public_programs += exe
3570 if want_tests != 'false'
3571 test('test-systemd-tmpfiles',
3572 test_systemd_tmpfiles_py,
3573 # https://github.com/mesonbuild/meson/issues/2681
3574 args : exe.full_path())
3577 if have_standalone_binaries
3579 'systemd-tmpfiles.standalone',
3580 systemd_tmpfiles_sources,
3581 include_directories : includes,
3582 c_args : '-DSTANDALONE',
3583 link_with : [libshared_static,
3587 dependencies : [libacl],
3589 install_dir : rootbindir)
3590 public_programs += exe
3592 if want_tests != 'false'
3593 test('test-systemd-tmpfiles.standalone',
3594 test_systemd_tmpfiles_py,
3595 # https://github.com/mesonbuild/meson/issues/2681
3596 args : exe.full_path())
3601 if conf.get('ENABLE_HWDB') == 1
3602 systemd_hwdb = executable(
3605 include_directories : includes,
3606 link_with : udev_link_with,
3607 install_rpath : udev_rpath,
3609 install_dir : rootbindir)
3610 public_programs += systemd_hwdb
3612 if want_tests != 'false'
3615 suite : 'dist-check',
3616 args : [systemd_hwdb.full_path()],
3621 if conf.get('ENABLE_QUOTACHECK') == 1
3623 'systemd-quotacheck',
3624 'src/quotacheck/quotacheck.c',
3625 include_directories : includes,
3626 link_with : [libshared],
3627 install_rpath : rootpkglibdir,
3629 install_dir : rootlibexecdir)
3632 public_programs += executable(
3633 'systemd-socket-proxyd',
3634 'src/socket-proxy/socket-proxyd.c',
3635 include_directories : includes,
3636 link_with : [libshared],
3637 dependencies : [threads],
3638 install_rpath : rootpkglibdir,
3640 install_dir : rootlibexecdir)
3642 udevadm = executable(
3645 include_directories : includes,
3646 link_with : [libudevd_core],
3647 dependencies : [versiondep,
3653 install_rpath : udev_rpath,
3655 install_dir : rootbindir)
3656 public_programs += udevadm
3658 if conf.get('ENABLE_REPART') == 1
3661 systemd_repart_sources,
3662 include_directories : includes,
3663 link_with : [libshared],
3664 dependencies : [threads,
3667 install_rpath : rootpkglibdir,
3669 install_dir : rootbindir)
3670 public_programs += exe
3675 systemd_shutdown_sources,
3676 include_directories : includes,
3677 link_with : [libshared],
3678 dependencies : [libmount],
3679 install_rpath : rootpkglibdir,
3681 install_dir : rootlibexecdir)
3684 'systemd-update-done',
3685 'src/update-done/update-done.c',
3686 include_directories : includes,
3687 link_with : [libshared],
3688 install_rpath : rootpkglibdir,
3690 install_dir : rootlibexecdir)
3693 'systemd-update-utmp',
3694 'src/update-utmp/update-utmp.c',
3695 include_directories : includes,
3696 link_with : [libshared],
3697 dependencies : [libaudit],
3698 install_rpath : rootpkglibdir,
3699 install : (conf.get('ENABLE_UTMP') == 1),
3700 install_dir : rootlibexecdir)
3702 if conf.get('HAVE_KMOD') == 1
3704 'systemd-modules-load',
3705 'src/modules-load/modules-load.c',
3706 include_directories : includes,
3707 link_with : [libshared],
3708 dependencies : [libkmod],
3709 install_rpath : rootpkglibdir,
3711 install_dir : rootlibexecdir)
3713 meson.add_install_script('sh', '-c',
3714 mkdir_p.format(modulesloaddir))
3715 if install_sysconfdir
3716 meson.add_install_script('sh', '-c',
3717 mkdir_p.format(sysconfdir / 'modules-load.d'))
3721 public_programs += executable(
3723 systemd_nspawn_sources,
3724 include_directories : includes,
3725 link_with : [libnspawn_core,
3727 dependencies : [libblkid,
3729 install_rpath : rootpkglibdir,
3732 if conf.get('ENABLE_NETWORKD') == 1
3733 dbus_programs += executable(
3735 systemd_networkd_sources,
3736 include_directories : network_includes,
3737 link_with : [libnetworkd_core,
3739 networkd_link_with],
3740 dependencies : [threads],
3741 install_rpath : rootpkglibdir,
3743 install_dir : rootlibexecdir)
3745 public_programs += executable(
3746 'systemd-networkd-wait-online',
3747 systemd_networkd_wait_online_sources,
3748 include_directories : includes,
3749 link_with : [networkd_link_with],
3750 install_rpath : rootpkglibdir,
3752 install_dir : rootlibexecdir)
3754 public_programs += executable(
3757 include_directories : libsystemd_network_includes,
3758 link_with : [libsystemd_network,
3759 networkd_link_with],
3760 install_rpath : rootpkglibdir,
3762 install_dir : rootbindir)
3766 'systemd-network-generator',
3767 network_generator_sources,
3768 include_directories : includes,
3769 link_with : [networkd_link_with],
3770 install_rpath : rootpkglibdir,
3772 install_dir : rootlibexecdir)
3774 if want_tests != 'false'
3775 test('test-network-generator-conversion',
3776 test_network_generator_conversion_sh,
3777 # https://github.com/mesonbuild/meson/issues/2681
3778 args : exe.full_path(),
3783 'systemd-sulogin-shell',
3784 'src/sulogin-shell/sulogin-shell.c',
3785 include_directories : includes,
3786 link_with : [libshared],
3787 install_rpath : rootpkglibdir,
3789 install_dir : rootlibexecdir)
3791 exe = custom_target(
3793 input : kernel_install_in,
3794 output : 'kernel-install',
3795 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
3796 install : want_kernel_install,
3797 install_mode : 'rwxr-xr-x',
3798 install_dir : bindir)
3799 public_programs += exe
3801 if want_tests != 'false'
3802 test('test-kernel-install',
3803 test_kernel_install_sh,
3804 args : [exe.full_path(), loaderentry_install])
3807 ############################################################
3809 runtest_env = custom_target(
3810 'systemd-runtest.env',
3811 output : 'systemd-runtest.env',
3812 command : [sh, '-c',
3813 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
3814 project_source_root / 'test',
3815 project_build_root / 'catalog')],
3817 build_by_default : true)
3819 test_cflags = ['-DTEST_CODE=1']
3820 # We intentionally do not do inline initializations with definitions for a
3821 # bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
3822 # use the variable unexpectedly. This triggers a lot of maybe-uninitialized
3823 # false positives when the combination of -O2 and -flto is used. Suppress them.
3824 if '-O2' in c_args and '-flto=auto' in c_args
3825 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
3828 foreach tuple : tests
3830 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3831 dependencies = tuple.length() > 2 ? tuple[2] : []
3832 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3833 condition = tuple.length() > 4 ? tuple[4] : ''
3834 type = tuple.length() > 5 ? tuple[5] : ''
3835 defs = tuple.length() > 6 ? tuple[6] : []
3837 parallel = tuple.length() > 7 ? tuple[7] : true
3840 # FIXME: Use fs.stem() with meson >= 0.54.0
3841 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
3842 if type.startswith('timeout=')
3843 timeout = type.split('=')[1].to_int()
3847 suite = fs.name(fs.parent('@0@'.format(sources[0])))
3848 # FIXME: Use str.replace() with meson >= 0.58.0
3849 suite = suite.split('sd-')[-1]
3851 if condition == '' or conf.get(condition) == 1
3855 include_directories : incs,
3856 link_with : link_with,
3857 dependencies : [versiondep,
3860 build_by_default : want_tests != 'false',
3861 install_rpath : rootpkglibdir,
3862 install : install_tests,
3863 install_dir : testsdir / type,
3864 link_depends : runtest_env)
3867 message('@0@ is a manual test'.format(name))
3868 elif type == 'unsafe' and want_tests != 'unsafe'
3869 message('@0@ is an unsafe test'.format(name))
3870 elif want_tests != 'false'
3877 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
3882 'test-libsystemd-sym',
3883 test_libsystemd_sym_c,
3884 include_directories : includes,
3885 link_with : [libsystemd],
3886 build_by_default : want_tests != 'false',
3887 install : install_tests,
3888 install_dir : testsdir)
3889 if want_tests != 'false'
3890 test('test-libsystemd-sym', exe)
3894 'test-libsystemd-static-sym',
3895 test_libsystemd_sym_c,
3896 include_directories : includes,
3897 link_with : [install_libsystemd_static],
3898 dependencies : [threads], # threads is already included in dependencies on the library,
3899 # but does not seem to get propagated. Add here as a work-around.
3900 build_by_default : want_tests != 'false' and static_libsystemd_pic,
3901 install : install_tests and static_libsystemd_pic,
3902 install_dir : testsdir)
3903 if want_tests != 'false' and static_libsystemd_pic
3904 test('test-libsystemd-static-sym', exe)
3910 include_directories : libudev_includes,
3911 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
3912 link_with : [libudev],
3913 build_by_default : want_tests != 'false',
3914 install : install_tests,
3915 install_dir : testsdir)
3916 if want_tests != 'false'
3917 test('test-libudev-sym', exe)
3921 'test-libudev-static-sym',
3923 include_directories : libudev_includes,
3924 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
3925 link_with : [install_libudev_static],
3926 build_by_default : want_tests != 'false' and static_libudev_pic,
3927 install : install_tests and static_libudev_pic,
3928 install_dir : testsdir)
3929 if want_tests != 'false' and static_libudev_pic
3930 test('test-libudev-static-sym', exe)
3933 ############################################################
3937 foreach tuple : fuzzers
3939 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3940 dependencies = tuple.length() > 2 ? tuple[2] : []
3941 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3942 defs = tuple.length() > 4 ? tuple[4] : []
3946 dependencies += fuzzing_engine
3948 if fuzzing_engine.found()
3949 dependencies += fuzzing_engine
3951 link_args += ['-fsanitize=fuzzer']
3954 sources += 'src/fuzz/fuzz-main.c'
3957 # FIXME: Use fs.stem() with meson >= 0.54.0
3958 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
3963 include_directories : [incs, include_directories('src/fuzz')],
3964 link_with : link_with,
3965 dependencies : dependencies,
3966 c_args : defs + test_cflags,
3967 link_args: link_args,
3969 build_by_default : fuzzer_build)
3972 if want_tests != 'false'
3973 # Run the fuzz regression tests without any sanitizers enabled.
3974 # Additional invocations with sanitizers may be added below.
3975 foreach p : fuzz_regression_tests
3976 b = p.split('/')[-2]
3977 c = p.split('/')[-1]
3980 test('@0@_@1@'.format(b, c),
3983 args : [project_source_root / p])
3989 alias_target('fuzzers', fuzzer_exes)
3991 ############################################################
3993 subdir('modprobe.d')
3995 subdir('sysusers.d')
3996 subdir('tmpfiles.d')
4002 subdir('shell-completion/bash')
4003 subdir('shell-completion/zsh')
4004 subdir('docs/sysvinit')
4005 subdir('docs/var-log')
4007 install_subdir('factory/etc',
4008 install_dir : factorydir)
4009 subdir('factory/templates')
4011 if install_sysconfdir
4012 install_data('xorg/50-systemd-user.sh',
4013 install_dir : xinitrcdir)
4015 install_data('LICENSE.GPL2',
4019 'docs/CODING_STYLE.md',
4020 'docs/DISTRO_PORTING.md',
4021 'docs/ENVIRONMENT.md',
4023 'docs/TRANSIENT-SETTINGS.md',
4024 'docs/TRANSLATORS.md',
4025 'docs/UIDS-GIDS.md',
4026 install_dir : docdir)
4028 install_subdir('LICENSES',
4029 install_dir : docdir)
4031 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
4032 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
4034 ############################################################
4036 # Ensure that changes to the docs/ directory do not break the
4037 # basic Github pages build. But only run it in developer mode,
4038 # as it might be fragile due to changes in the tooling, and it is
4039 # not generally useful for users.
4040 jekyll = find_program('jekyll', required : false)
4041 if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
4042 test('github-pages',
4044 suite : 'dist-check',
4046 '--source', project_source_root / 'docs',
4047 '--destination', project_build_root / '_site'])
4050 ############################################################
4052 check_help = find_program('tools/check-help.sh')
4053 check_version = find_program('tools/check-version.sh')
4055 foreach exec : public_programs
4056 name = exec.full_path().split('/')[-1]
4057 if want_tests != 'false'
4058 test('check-help-' + name,
4060 suite : 'dist-check',
4061 args : exec.full_path(),
4064 test('check-version-' + name,
4066 suite : 'dist-check',
4067 args : [exec.full_path(),
4068 meson.project_version()],
4073 ############################################################
4075 check_directives_sh = find_program('tools/check-directives.sh')
4077 if want_tests != 'false'
4078 test('check-directives',
4079 check_directives_sh,
4080 suite : 'dist-check',
4081 args : [project_source_root, project_build_root])
4084 ############################################################
4086 # Enable tests for all supported sanitizers
4087 foreach tuple : sanitizers
4088 sanitizer = tuple[0]
4091 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
4093 foreach p : fuzz_regression_tests
4094 b = p.split('/')[-2]
4095 c = p.split('/')[-1]
4097 name = '@0@:@1@'.format(b, sanitizer)
4100 if want_tests == 'false'
4101 message('Not compiling @0@ because tests is set to false'.format(name))
4103 exe = custom_target(
4107 command : [ln, '-fs',
4108 build.full_path() / b,
4110 build_by_default : true)
4112 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
4118 test('@0@_@1@_@2@'.format(b, c, sanitizer),
4121 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
4123 args : [exe.full_path(),
4124 project_source_root / p])
4131 ############################################################
4134 all_files = run_command(
4135 env, '-u', 'GIT_WORK_TREE',
4136 git, '--git-dir=@0@/.git'.format(project_source_root),
4137 'ls-files', ':/*.[ch]',
4139 if all_files.returncode() == 0
4140 all_files = files(all_files.stdout().split())
4145 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
4148 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
4153 git_contrib_sh = find_program('tools/git-contrib.sh')
4156 command : [git_contrib_sh])
4160 git_head = run_command(
4161 git, '--git-dir=@0@/.git'.format(project_source_root),
4162 'rev-parse', 'HEAD',
4163 check : false).stdout().strip()
4164 git_head_short = run_command(
4165 git, '--git-dir=@0@/.git'.format(project_source_root),
4166 'rev-parse', '--short=7', 'HEAD',
4167 check : false).stdout().strip()
4171 command : [git, 'archive',
4172 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
4174 '--prefix', 'systemd-@0@/'.format(git_head),
4178 ############################################################
4180 check_api_docs_sh = find_program('tools/check-api-docs.sh')
4183 depends : [man, libsystemd, libudev],
4184 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
4186 alias_target('update-dbus-docs', update_dbus_docs)
4187 alias_target('update-man-rules', update_man_rules)
4189 if not meson.is_cross_build()
4191 'export-dbus-interfaces',
4192 output : fs.name(dbus_interfaces_dir),
4193 install : dbus_interfaces_dir != 'no',
4194 install_dir : fs.parent(dbus_interfaces_dir),
4195 command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
4198 ############################################################
4200 alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
4201 check : true).stdout().strip()
4204 'split /usr' : split_usr,
4205 'split bin-sbin' : split_bin,
4206 'prefix directory' : prefixdir,
4207 'rootprefix directory' : rootprefixdir,
4208 'sysconf directory' : sysconfdir,
4209 'include directory' : includedir,
4210 'lib directory' : libdir,
4211 'rootlib directory' : rootlibdir,
4212 'SysV init scripts' : sysvinit_path,
4213 'SysV rc?.d directories' : sysvrcnd_path,
4214 'PAM modules directory' : pamlibdir,
4215 'PAM configuration directory' : pamconfdir,
4216 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
4217 'RPM macros directory' : rpmmacrosdir,
4218 'modprobe.d directory' : modprobedir,
4219 'D-Bus policy directory' : dbuspolicydir,
4220 'D-Bus session directory' : dbussessionservicedir,
4221 'D-Bus system directory' : dbussystemservicedir,
4222 'D-Bus interfaces directory' : dbus_interfaces_dir,
4223 'bash completions directory' : bashcompletiondir,
4224 'zsh completions directory' : zshcompletiondir,
4225 'private shared lib version tag' : shared_lib_tag,
4226 'extra start script' : get_option('rc-local'),
4227 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
4228 get_option('debug-tty')),
4229 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
4230 conf.get('SYSTEM_ALLOC_UID_MIN')),
4231 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
4232 conf.get('SYSTEM_ALLOC_GID_MIN')),
4233 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
4234 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
4235 'static UID/GID allocations' : ' '.join(static_ugids),
4236 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
4237 'render group access mode' : get_option('group-render-mode'),
4238 'certificate root directory' : get_option('certificate-root'),
4239 'support URL' : support_url,
4240 'nobody user name' : nobody_user,
4241 'nobody group name' : nobody_group,
4242 'fallback hostname' : get_option('fallback-hostname'),
4243 'default compression method' : compression,
4244 'default DNSSEC mode' : default_dnssec,
4245 'default DNS-over-TLS mode' : default_dns_over_tls,
4246 'default mDNS mode' : default_mdns,
4247 'default LLMNR mode' : default_llmnr,
4248 'default DNS servers' : dns_servers.split(' '),
4249 'default NTP servers' : ntp_servers.split(' '),
4250 'default cgroup hierarchy' : default_hierarchy,
4251 'default net.naming-scheme value' : default_net_naming_scheme,
4252 'default KillUserProcesses value' : kill_user_processes,
4253 'default locale' : default_locale,
4254 'default nspawn locale' : nspawn_locale,
4255 'default status unit format' : status_unit_format_default,
4256 'default user $PATH' :
4257 default_user_path != '' ? default_user_path : '(same as system services)',
4258 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
4259 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
4262 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
4263 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
4264 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
4285 ['libcryptsetup-plugins'],
4311 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
4341 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
4355 ['legacy-pkla', install_polkit_pkla],
4360 ['man pages', want_man],
4361 ['html pages', want_html],
4362 ['man page indices', want_man and have_lxml],
4364 ['compat-mutable-uid-boundaries'],
4367 ['adm group', get_option('adm-group')],
4368 ['wheel group', get_option('wheel-group')],
4371 ['debug mmap cache'],
4373 ['valgrind', conf.get('VALGRIND') == 1],
4374 ['trace logging', conf.get('LOG_TRACE') == 1],
4375 ['install tests', install_tests],
4376 ['link-udev-shared', get_option('link-udev-shared')],
4377 ['link-systemctl-shared', get_option('link-systemctl-shared')],
4378 ['link-networkd-shared', get_option('link-networkd-shared')],
4379 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
4380 ['link-journalctl-shared', get_option('link-journalctl-shared')],
4381 ['link-boot-shared', get_option('link-boot-shared')],
4382 ['first-boot-full-preset'],
4384 ['standalone-binaries', get_option('standalone-binaries')],
4385 ['coverage', get_option('b_coverage')],
4388 if tuple.length() >= 2
4391 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
4392 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
4393 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
4402 if static_libsystemd == 'false'
4403 missing += 'static-libsystemd'
4405 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
4408 if static_libudev == 'false'
4409 missing += 'static-libudev'
4411 found += 'static-libudev(@0@)'.format(static_libudev)
4414 if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
4415 found += 'cryptolib(openssl)'
4416 elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
4417 found += 'cryptolib(gcrypt)'
4419 missing += 'cryptolib'
4422 if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
4423 found += 'DNS-over-TLS(gnutls)'
4424 elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
4425 found += 'DNS-over-TLS(openssl)'
4427 missing += 'DNS-over-TLS'
4431 'enabled' : ', '.join(found),
4432 'disabled' : ', '.join(missing)},
4433 section : 'Features')
4435 if rootprefixdir != rootprefix_default
4437 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
4438 'systemd used fixed names for unit file directories and other paths, so anything\n' +
4439 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))