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 #####################################################################
1017 if not cc.links('''#include <stdint.h>
1020 __atomic_exchange_1(&i, 1, 0);
1023 name : 'Atomic builtin requires -latomic')
1024 libatomic = cc.find_library('atomic')
1026 threads = dependency('threads')
1027 librt = cc.find_library('rt')
1028 libm = cc.find_library('m')
1029 libdl = cc.find_library('dl')
1030 libcrypt = cc.find_library('crypt')
1032 crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
1034 ['crypt_ra', crypt_header],
1035 ['crypt_preferred_method', crypt_header],
1036 ['crypt_gensalt_ra', crypt_header]]
1038 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
1039 dependencies : libcrypt)
1040 conf.set10('HAVE_' + ident[0].to_upper(), have)
1043 libcap = dependency('libcap', required : false)
1044 if not libcap.found()
1045 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
1046 libcap = cc.find_library('cap')
1049 want_bpf_framework = get_option('bpf-framework')
1050 bpf_framework_required = want_bpf_framework == 'true'
1052 libbpf = dependency('libbpf', required : bpf_framework_required, version : '>= 0.2')
1053 conf.set10('HAVE_LIBBPF', libbpf.found())
1055 if want_bpf_framework == 'false' or not libbpf.found() or skip_deps
1056 conf.set10('BPF_FRAMEWORK', false)
1058 bpf_compiler = get_option('bpf-compiler')
1060 clang_supports_bpf = false
1061 bpf_gcc_found = false
1064 if bpf_compiler == 'clang'
1065 # Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu
1066 # (like clang-10/llvm-strip-10)
1067 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')
1068 r = find_program('clang', required : bpf_framework_required, version : '>= 10.0.0')
1069 clang_found = r.found()
1073 # Assume that the required flags are supported by the found clang.
1074 clang_supports_flags = clang_found
1077 clang = cc.cmd_array()
1078 clang_supports_flags = cc.has_argument('-Wno-compare-distinct-pointer-types')
1082 # Check if 'clang -target bpf' is supported.
1083 clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0
1085 elif bpf_compiler == 'gcc'
1086 warning('GCC BPF Compiler support is experimental and not recommended.')
1087 bpf_gcc = find_program('bpf-gcc',
1089 version : '>= 12.1.0')
1090 bpf_gcc_found = bpf_gcc.found()
1093 if clang_supports_bpf or bpf_gcc_found
1094 # Debian installs this in /usr/sbin/ which is not in $PATH.
1095 # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian.
1096 # We use 'bpftool gen object' subcommand for bpftool strip, it was added by d80b2fcbe0a023619e0fc73112f2a02c2662f6ab (v5.13).
1097 bpftool = find_program('bpftool',
1098 '/usr/sbin/bpftool',
1100 version : '>= 5.13.0')
1103 bpftool_strip = true
1106 bpftool_strip = false
1107 # We require the 'bpftool gen skeleton' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6).
1108 bpftool = find_program('bpftool',
1109 '/usr/sbin/bpftool',
1110 required : bpf_framework_required,
1111 version : '>= 5.6.0')
1114 # We use `llvm-strip` as a fallback if `bpftool gen object` strip support is not available.
1115 if not bpftool_strip and bpftool.found() and clang_supports_bpf
1116 if not meson.is_cross_build()
1117 llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip',
1118 check : true).stdout().strip()
1120 llvm_strip_bin = 'llvm-strip'
1122 llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0')
1123 deps_found = llvm_strip.found()
1127 # Can build BPF program from source code in restricted C
1128 conf.set10('BPF_FRAMEWORK', deps_found)
1131 libmount = dependency('mount',
1132 version : fuzzer_build ? '>= 0' : '>= 2.30')
1134 want_libfdisk = get_option('fdisk')
1135 if want_libfdisk != 'false' and not skip_deps
1136 libfdisk = dependency('fdisk',
1137 version : '>= 2.32',
1138 required : want_libfdisk == 'true')
1139 have = libfdisk.found()
1144 conf.set10('HAVE_LIBFDISK', have)
1146 want_pwquality = get_option('pwquality')
1147 if want_pwquality != 'false' and not skip_deps
1148 libpwquality = dependency('pwquality', required : want_pwquality == 'true')
1149 have = libpwquality.found()
1154 conf.set10('HAVE_PWQUALITY', have)
1156 want_seccomp = get_option('seccomp')
1157 if want_seccomp != 'false' and not skip_deps
1158 libseccomp = dependency('libseccomp',
1159 version : '>= 2.3.1',
1160 required : want_seccomp == 'true')
1161 have = libseccomp.found()
1166 conf.set10('HAVE_SECCOMP', have)
1168 want_selinux = get_option('selinux')
1169 if want_selinux != 'false' and not skip_deps
1170 libselinux = dependency('libselinux',
1171 version : '>= 2.1.9',
1172 required : want_selinux == 'true')
1173 have = libselinux.found()
1178 conf.set10('HAVE_SELINUX', have)
1180 want_apparmor = get_option('apparmor')
1181 if want_apparmor != 'false' and not skip_deps
1182 libapparmor = dependency('libapparmor',
1183 version : '>= 2.13',
1184 required : want_apparmor == 'true')
1185 have = libapparmor.found()
1190 conf.set10('HAVE_APPARMOR', have)
1192 have = get_option('smack') and get_option('smack-run-label') != ''
1193 conf.set10('HAVE_SMACK_RUN_LABEL', have)
1195 conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
1198 have = get_option('smack') and get_option('smack-default-process-label') != ''
1200 conf.set_quoted('SMACK_DEFAULT_PROCESS_LABEL', get_option('smack-default-process-label'))
1203 want_polkit = get_option('polkit')
1204 install_polkit = false
1205 install_polkit_pkla = false
1206 if want_polkit != 'false' and not skip_deps
1207 install_polkit = true
1209 libpolkit = dependency('polkit-gobject-1',
1211 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
1212 message('Old polkit detected, will install pkla files')
1213 install_polkit_pkla = true
1216 conf.set10('ENABLE_POLKIT', install_polkit)
1218 want_acl = get_option('acl')
1219 if want_acl != 'false' and not skip_deps
1220 libacl = cc.find_library('acl', required : want_acl == 'true')
1221 have = libacl.found()
1226 conf.set10('HAVE_ACL', have)
1228 want_audit = get_option('audit')
1229 if want_audit != 'false' and not skip_deps
1230 libaudit = dependency('audit', required : want_audit == 'true')
1231 have = libaudit.found()
1236 conf.set10('HAVE_AUDIT', have)
1238 want_blkid = get_option('blkid')
1239 if want_blkid != 'false' and not skip_deps
1240 libblkid = dependency('blkid', required : want_blkid == 'true')
1241 have = libblkid.found()
1243 conf.set10('HAVE_BLKID_PROBE_SET_HINT',
1244 have and cc.has_function('blkid_probe_set_hint', dependencies : libblkid))
1249 conf.set10('HAVE_BLKID', have)
1251 want_kmod = get_option('kmod')
1252 if want_kmod != 'false' and not skip_deps
1253 libkmod = dependency('libkmod',
1255 required : want_kmod == 'true')
1256 have = libkmod.found()
1261 conf.set10('HAVE_KMOD', have)
1263 want_pam = get_option('pam')
1264 if want_pam != 'false' and not skip_deps
1265 libpam = cc.find_library('pam', required : want_pam == 'true')
1266 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1267 have = libpam.found() and libpam_misc.found()
1273 conf.set10('HAVE_PAM', have)
1275 want_microhttpd = get_option('microhttpd')
1276 if want_microhttpd != 'false' and not skip_deps
1277 libmicrohttpd = dependency('libmicrohttpd',
1278 version : '>= 0.9.33',
1279 required : want_microhttpd == 'true')
1280 have = libmicrohttpd.found()
1285 conf.set10('HAVE_MICROHTTPD', have)
1287 want_libcryptsetup = get_option('libcryptsetup')
1288 want_libcryptsetup_plugins = get_option('libcryptsetup-plugins')
1290 if want_libcryptsetup_plugins == 'true' and want_libcryptsetup == 'false'
1291 error('libcryptsetup-plugins can not be requested without libcryptsetup')
1294 if want_libcryptsetup != 'false' and not skip_deps
1295 libcryptsetup = dependency('libcryptsetup',
1296 version : want_libcryptsetup_plugins == 'true' ? '>= 2.4.0' : '>= 2.0.1',
1297 required : want_libcryptsetup == 'true' or want_libcryptsetup_plugins == 'true')
1298 have = libcryptsetup.found()
1300 foreach ident : ['crypt_set_metadata_size',
1301 'crypt_activate_by_signed_key',
1303 have_ident = have and cc.has_function(
1305 prefix : '#include <libcryptsetup.h>',
1306 dependencies : libcryptsetup)
1307 conf.set10('HAVE_' + ident.to_upper(), have_ident)
1313 conf.set10('HAVE_LIBCRYPTSETUP', have)
1315 if want_libcryptsetup_plugins != 'false' and not skip_deps
1316 have = (cc.has_function(
1317 'crypt_activate_by_token_pin',
1318 prefix : '#include <libcryptsetup.h>',
1319 dependencies : libcryptsetup) and
1321 'crypt_token_external_path',
1322 prefix : '#include <libcryptsetup.h>',
1323 dependencies : libcryptsetup))
1327 conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have)
1329 want_libcurl = get_option('libcurl')
1330 if want_libcurl != 'false' and not skip_deps
1331 libcurl = dependency('libcurl',
1332 version : '>= 7.32.0',
1333 required : want_libcurl == 'true')
1334 have = libcurl.found()
1339 conf.set10('HAVE_LIBCURL', have)
1340 conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
1342 want_libidn = get_option('libidn')
1343 want_libidn2 = get_option('libidn2')
1344 if want_libidn == 'true' and want_libidn2 == 'true'
1345 error('libidn and libidn2 cannot be requested simultaneously')
1348 if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps
1349 libidn = dependency('libidn2',
1350 required : want_libidn2 == 'true')
1351 have = libidn.found()
1356 conf.set10('HAVE_LIBIDN2', have)
1357 if not have and want_libidn != 'false' and not skip_deps
1358 # libidn is used for both libidn and libidn2 objects
1359 libidn = dependency('libidn',
1360 required : want_libidn == 'true')
1361 have = libidn.found()
1365 conf.set10('HAVE_LIBIDN', have)
1367 want_libiptc = get_option('libiptc')
1368 if want_libiptc != 'false' and not skip_deps
1369 libiptc = dependency('libiptc',
1370 required : want_libiptc == 'true')
1371 have = libiptc.found()
1376 conf.set10('HAVE_LIBIPTC', have)
1378 want_qrencode = get_option('qrencode')
1379 if want_qrencode != 'false' and not skip_deps
1380 libqrencode = dependency('libqrencode',
1382 required : want_qrencode == 'true')
1383 have = libqrencode.found()
1388 conf.set10('HAVE_QRENCODE', have)
1390 want_gcrypt = get_option('gcrypt')
1391 if want_gcrypt != 'false' and not skip_deps
1392 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1393 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1394 have = libgcrypt.found() and libgpg_error.found()
1399 # link to neither of the libs if one is not found
1403 conf.set10('HAVE_GCRYPT', have)
1405 want_gnutls = get_option('gnutls')
1406 if want_gnutls != 'false' and not skip_deps
1407 libgnutls = dependency('gnutls',
1408 version : '>= 3.1.4',
1409 required : want_gnutls == 'true')
1410 have = libgnutls.found()
1415 conf.set10('HAVE_GNUTLS', have)
1417 want_openssl = get_option('openssl')
1418 if want_openssl != 'false' and not skip_deps
1419 libopenssl = dependency('openssl',
1420 version : '>= 1.1.0',
1421 required : want_openssl == 'true')
1422 have = libopenssl.found()
1427 conf.set10('HAVE_OPENSSL', have)
1429 want_p11kit = get_option('p11kit')
1430 if want_p11kit != 'false' and not skip_deps
1431 libp11kit = dependency('p11-kit-1',
1432 version : '>= 0.23.3',
1433 required : want_p11kit == 'true')
1434 have = libp11kit.found()
1439 conf.set10('HAVE_P11KIT', have)
1441 want_libfido2 = get_option('libfido2')
1442 if want_libfido2 != 'false' and not skip_deps
1443 libfido2 = dependency('libfido2',
1444 required : want_libfido2 == 'true')
1445 have = libfido2.found()
1450 conf.set10('HAVE_LIBFIDO2', have)
1452 want_tpm2 = get_option('tpm2')
1453 if want_tpm2 != 'false' and not skip_deps
1454 tpm2 = dependency('tss2-esys tss2-rc tss2-mu',
1455 required : want_tpm2 == 'true')
1461 conf.set10('HAVE_TPM2', have)
1463 want_elfutils = get_option('elfutils')
1464 if want_elfutils != 'false' and not skip_deps
1465 libdw = dependency('libdw',
1466 required : want_elfutils == 'true')
1467 have = libdw.found()
1469 # New in elfutils 0.177
1470 conf.set10('HAVE_DWELF_ELF_E_MACHINE_STRING',
1471 have and cc.has_function('dwelf_elf_e_machine_string', dependencies : libdw))
1476 conf.set10('HAVE_ELFUTILS', have)
1478 want_zlib = get_option('zlib')
1479 if want_zlib != 'false' and not skip_deps
1480 libz = dependency('zlib',
1481 required : want_zlib == 'true')
1487 conf.set10('HAVE_ZLIB', have)
1489 want_bzip2 = get_option('bzip2')
1490 if want_bzip2 != 'false' and not skip_deps
1491 libbzip2 = cc.find_library('bz2',
1492 required : want_bzip2 == 'true')
1493 have = libbzip2.found()
1498 conf.set10('HAVE_BZIP2', have)
1500 want_xz = get_option('xz')
1501 if want_xz != 'false' and not skip_deps
1502 libxz = dependency('liblzma',
1503 required : want_xz == 'true')
1504 have_xz = libxz.found()
1509 conf.set10('HAVE_XZ', have_xz)
1511 want_lz4 = get_option('lz4')
1512 if want_lz4 != 'false' and not skip_deps
1513 liblz4 = dependency('liblz4',
1514 version : '>= 1.3.0',
1515 required : want_lz4 == 'true')
1516 have_lz4 = liblz4.found()
1521 conf.set10('HAVE_LZ4', have_lz4)
1523 want_zstd = get_option('zstd')
1524 if want_zstd != 'false' and not skip_deps
1525 libzstd = dependency('libzstd',
1526 required : want_zstd == 'true',
1527 version : '>= 1.4.0')
1528 have_zstd = libzstd.found()
1533 conf.set10('HAVE_ZSTD', have_zstd)
1535 conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
1537 compression = get_option('default-compression')
1538 if compression == 'auto'
1540 compression = 'zstd'
1546 compression = 'none'
1548 elif compression == 'zstd' and not have_zstd
1549 error('default-compression=zstd requires zstd')
1550 elif compression == 'lz4' and not have_lz4
1551 error('default-compression=lz4 requires lz4')
1552 elif compression == 'xz' and not have_xz
1553 error('default-compression=xz requires xz')
1555 conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper()))
1557 want_xkbcommon = get_option('xkbcommon')
1558 if want_xkbcommon != 'false' and not skip_deps
1559 libxkbcommon = dependency('xkbcommon',
1560 version : '>= 0.3.0',
1561 required : want_xkbcommon == 'true')
1562 have = libxkbcommon.found()
1567 conf.set10('HAVE_XKBCOMMON', have)
1569 want_pcre2 = get_option('pcre2')
1570 if want_pcre2 != 'false' and not skip_deps
1571 libpcre2 = dependency('libpcre2-8',
1572 required : want_pcre2 == 'true')
1573 have = libpcre2.found()
1578 conf.set10('HAVE_PCRE2', have)
1580 want_glib = get_option('glib')
1581 if want_glib != 'false' and not skip_deps
1582 libglib = dependency('glib-2.0',
1583 version : '>= 2.22.0',
1584 required : want_glib == 'true')
1585 libgobject = dependency('gobject-2.0',
1586 version : '>= 2.22.0',
1587 required : want_glib == 'true')
1588 libgio = dependency('gio-2.0',
1589 required : want_glib == 'true')
1590 have = libglib.found() and libgobject.found() and libgio.found()
1597 conf.set10('HAVE_GLIB', have)
1599 want_dbus = get_option('dbus')
1600 if want_dbus != 'false' and not skip_deps
1601 libdbus = dependency('dbus-1',
1602 version : '>= 1.3.2',
1603 required : want_dbus == 'true')
1604 have = libdbus.found()
1609 conf.set10('HAVE_DBUS', have)
1611 dbusdatadir = datadir / 'dbus-1'
1612 if conf.get('HAVE_DBUS') == 1
1613 dbusdatadir = libdbus.get_variable(pkgconfig: 'datadir', default_value: datadir) / 'dbus-1'
1616 dbuspolicydir = get_option('dbuspolicydir')
1617 if dbuspolicydir == ''
1618 dbuspolicydir = dbusdatadir / 'system.d'
1621 dbussessionservicedir = get_option('dbussessionservicedir')
1622 if dbussessionservicedir == ''
1623 dbussessionservicedir = dbusdatadir / 'services'
1624 if conf.get('HAVE_DBUS') == 1
1625 dbussessionservicedir = libdbus.get_variable(pkgconfig: 'session_bus_services_dir', default_value: dbussessionservicedir)
1629 dbussystemservicedir = get_option('dbussystemservicedir')
1630 if dbussystemservicedir == ''
1631 dbussystemservicedir = dbusdatadir / 'system-services'
1632 if conf.get('HAVE_DBUS') == 1
1633 dbussystemservicedir = libdbus.get_variable(pkgconfig: 'system_bus_services_dir', default_value: dbussystemservicedir)
1637 dbus_interfaces_dir = get_option('dbus-interfaces-dir')
1638 if dbus_interfaces_dir == '' or dbus_interfaces_dir == 'yes'
1639 if meson.is_cross_build() and dbus_interfaces_dir != 'yes'
1640 dbus_interfaces_dir = 'no'
1641 warning('Exporting D-Bus interface XML files is disabled during cross build. Pass path or "yes" to force enable.')
1643 dbus_interfaces_dir = dbusdatadir / 'interfaces'
1644 if conf.get('HAVE_DBUS') == 1
1645 dbus_interfaces_dir = libdbus.get_variable(pkgconfig: 'interfaces_dir', default_value: dbus_interfaces_dir)
1650 # We support one or the other. If gcrypt is available, we assume it's there to
1651 # be used, and use it in preference.
1652 opt = get_option('cryptolib')
1653 if opt == 'openssl' and conf.get('HAVE_OPENSSL') == 0
1654 error('openssl requested as the default cryptolib, but not available')
1656 conf.set10('PREFER_OPENSSL',
1657 opt == 'openssl' or (opt == 'auto' and conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_GCRYPT') == 0))
1658 conf.set10('HAVE_OPENSSL_OR_GCRYPT',
1659 conf.get('HAVE_OPENSSL') == 1 or conf.get('HAVE_GCRYPT') == 1)
1660 lib_openssl_or_gcrypt = conf.get('PREFER_OPENSSL') == 1 ? [libopenssl] : [libgcrypt, libgpg_error]
1662 dns_over_tls = get_option('dns-over-tls')
1663 if dns_over_tls != 'false'
1664 if dns_over_tls == 'gnutls' and conf.get('PREFER_OPENSSL') == 1
1665 error('Sorry, -Ddns-over-tls=gnutls is not supported when openssl is used as the cryptolib')
1668 if dns_over_tls == 'gnutls'
1669 have_openssl = false
1671 have_openssl = conf.get('HAVE_OPENSSL') == 1
1672 if dns_over_tls == 'openssl' and not have_openssl
1673 error('DNS-over-TLS support was requested with openssl, but dependencies are not available')
1676 if dns_over_tls == 'openssl' or have_openssl
1679 have_gnutls = conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0')
1680 if dns_over_tls != 'auto' and not have_gnutls
1681 str = dns_over_tls == 'gnutls' ? ' with gnutls' : ''
1682 error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
1685 have = have_gnutls or have_openssl
1689 have_openssl = false
1691 conf.set10('ENABLE_DNS_OVER_TLS', have)
1692 conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1693 conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
1695 default_dns_over_tls = get_option('default-dns-over-tls')
1697 default_dns_over_tls = 'no'
1699 if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
1700 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.')
1701 default_dns_over_tls = 'no'
1703 conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1704 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
1705 conf.set_quoted('DEFAULT_DNS_OVER_TLS_MODE_STR', default_dns_over_tls)
1707 default_mdns = get_option('default-mdns')
1708 conf.set('DEFAULT_MDNS_MODE',
1709 'RESOLVE_SUPPORT_' + default_mdns.to_upper())
1710 conf.set_quoted('DEFAULT_MDNS_MODE_STR', default_mdns)
1712 default_llmnr = get_option('default-llmnr')
1713 conf.set('DEFAULT_LLMNR_MODE',
1714 'RESOLVE_SUPPORT_' + default_llmnr.to_upper())
1715 conf.set_quoted('DEFAULT_LLMNR_MODE_STR', default_llmnr)
1717 want_repart = get_option('repart')
1718 if want_repart != 'false'
1719 have = conf.get('HAVE_LIBFDISK') == 1
1720 if want_repart == 'true' and not have
1721 error('repart support was requested, but dependencies are not available')
1726 conf.set10('ENABLE_REPART', have)
1728 default_dnssec = get_option('default-dnssec')
1730 default_dnssec = 'no'
1732 if default_dnssec != 'no' and conf.get('HAVE_OPENSSL_OR_GCRYPT') == 0
1733 message('default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.')
1734 default_dnssec = 'no'
1736 conf.set('DEFAULT_DNSSEC_MODE',
1737 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1738 conf.set_quoted('DEFAULT_DNSSEC_MODE_STR', default_dnssec)
1740 want_sysupdate = get_option('sysupdate')
1741 if want_sysupdate != 'false'
1742 have = (conf.get('HAVE_OPENSSL') == 1 and
1743 conf.get('HAVE_LIBFDISK') == 1)
1744 if want_sysupdate == 'true' and not have
1745 error('sysupdate support was requested, but dependencies are not available')
1750 conf.set10('ENABLE_SYSUPDATE', have)
1752 want_importd = get_option('importd')
1753 if want_importd != 'false'
1754 have = (conf.get('HAVE_LIBCURL') == 1 and
1755 conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and
1756 conf.get('HAVE_ZLIB') == 1 and
1757 conf.get('HAVE_XZ') == 1)
1758 if want_importd == 'true' and not have
1759 error('importd support was requested, but dependencies are not available')
1764 conf.set10('ENABLE_IMPORTD', have)
1766 want_kernel_install = get_option('kernel-install')
1767 conf.set10('ENABLE_KERNEL_INSTALL', want_kernel_install)
1769 want_homed = get_option('homed')
1770 if want_homed != 'false'
1771 have = (conf.get('HAVE_OPENSSL') == 1 and
1772 conf.get('HAVE_LIBFDISK') == 1 and
1773 conf.get('HAVE_LIBCRYPTSETUP') == 1)
1774 if want_homed == 'true' and not have
1775 error('homed support was requested, but dependencies are not available')
1780 conf.set10('ENABLE_HOMED', have)
1782 have = have and conf.get('HAVE_PAM') == 1
1783 conf.set10('ENABLE_PAM_HOME', have)
1785 have = get_option('oomd')
1786 conf.set10('ENABLE_OOMD', have)
1788 want_remote = get_option('remote')
1789 if want_remote != 'false'
1790 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1791 conf.get('HAVE_LIBCURL') == 1]
1792 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1793 # it's possible to build one without the other. Complain only if
1794 # support was explicitly requested. The auxiliary files like sysusers
1795 # config should be installed when any of the programs are built.
1796 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1797 error('remote support was requested, but dependencies are not available')
1799 have = have_deps[0] or have_deps[1]
1803 conf.set10('ENABLE_REMOTE', have)
1805 foreach term : ['analyze',
1819 'compat-mutable-uid-boundaries',
1845 have = get_option(term)
1846 name = 'ENABLE_' + term.underscorify().to_upper()
1847 conf.set10(name, have)
1850 enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
1852 foreach tuple : [['nss-mymachines', 'machined'],
1853 ['nss-resolve', 'resolve']]
1854 want = get_option(tuple[0])
1856 have = get_option(tuple[1])
1857 if want == 'true' and not have
1858 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1863 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1864 conf.set10(name, have)
1868 foreach term : ['ENABLE_NSS_MYHOSTNAME',
1869 'ENABLE_NSS_MYMACHINES',
1870 'ENABLE_NSS_RESOLVE',
1871 'ENABLE_NSS_SYSTEMD']
1872 if conf.get(term) == 1
1876 conf.set10('ENABLE_NSS', enable_nss)
1878 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1880 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1882 ############################################################
1888 ############################################################
1890 # Include these now as they provide gnu-efi detection.
1891 subdir('src/fundamental')
1892 subdir('src/boot/efi')
1894 ############################################################
1896 generate_gperfs = find_program('tools/generate-gperfs.py')
1897 make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
1898 make_directive_index_py = find_program('tools/make-directive-index.py')
1899 make_man_index_py = find_program('tools/make-man-index.py')
1900 meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
1901 update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
1902 update_man_rules_py = find_program('tools/update-man-rules.py')
1903 update_hwdb_sh = find_program('tools/update-hwdb.sh')
1904 update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
1905 update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
1906 xml_helper_py = find_program('tools/xml_helper.py')
1907 export_dbus_interfaces_py = find_program('tools/dbus_exporter.py')
1909 ############################################################
1911 if get_option('b_coverage')
1912 add_project_arguments('-include', 'src/basic/coverage.h', language : 'c')
1915 ############################################################
1917 config_h = configure_file(
1918 output : 'config.h',
1919 configuration : conf)
1921 add_project_arguments('-include', 'config.h', language : 'c')
1923 jinja2_cmdline = [meson_render_jinja2, config_h, version_h]
1925 ############################################################
1927 # binaries that have --help and are intended for use by humans,
1928 # usually, but not always, installed in /bin.
1929 public_programs = []
1931 # D-Bus introspection XML export
1934 basic_includes = include_directories(
1940 libsystemd_includes = [basic_includes, include_directories(
1941 'src/libsystemd/sd-bus',
1942 'src/libsystemd/sd-device',
1943 'src/libsystemd/sd-event',
1944 'src/libsystemd/sd-hwdb',
1945 'src/libsystemd/sd-id128',
1946 'src/libsystemd/sd-journal',
1947 'src/libsystemd/sd-netlink',
1948 'src/libsystemd/sd-network',
1949 'src/libsystemd/sd-resolve')]
1951 includes = [libsystemd_includes, include_directories('src/shared')]
1956 subdir('src/libsystemd')
1957 subdir('src/shared')
1959 subdir('src/libudev')
1960 subdir('src/cryptsetup/cryptsetup-tokens')
1962 alias_target('devel', libsystemd_pc, libudev_pc)
1964 libsystemd = shared_library(
1966 version : libsystemd_version,
1967 include_directories : libsystemd_includes,
1968 link_args : ['-shared',
1969 '-Wl,--version-script=' + libsystemd_sym_path],
1970 link_with : [libbasic,
1973 link_whole : [libsystemd_static],
1974 dependencies : [threads,
1976 link_depends : libsystemd_sym,
1978 install_tag: 'libsystemd',
1979 install_dir : rootlibdir)
1981 alias_target('libsystemd', libsystemd)
1983 install_libsystemd_static = static_library(
1987 basic_gcrypt_sources,
1988 basic_compress_sources,
1989 fundamental_sources,
1990 include_directories : libsystemd_includes,
1991 build_by_default : static_libsystemd != 'false',
1992 install : static_libsystemd != 'false',
1993 install_tag: 'libsystemd',
1994 install_dir : rootlibdir,
1995 pic : static_libsystemd_pic,
1996 dependencies : [threads,
2007 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
2009 libudev = shared_library(
2011 version : libudev_version,
2012 include_directories : includes,
2013 link_args : ['-shared',
2014 '-Wl,--version-script=' + libudev_sym_path],
2015 link_with : [libsystemd_static, libshared_static],
2016 link_whole : libudev_basic,
2017 dependencies : [threads],
2018 link_depends : libudev_sym,
2020 install_tag: 'libudev',
2021 install_dir : rootlibdir)
2023 alias_target('libudev', libudev)
2025 install_libudev_static = static_library(
2028 fundamental_sources,
2032 include_directories : includes,
2033 build_by_default : static_libudev != 'false',
2034 install : static_libudev != 'false',
2035 install_tag: 'libudev',
2036 install_dir : rootlibdir,
2037 link_depends : libudev_sym,
2038 dependencies : libshared_deps + [libmount],
2039 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
2040 pic : static_libudev_pic)
2042 if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
2043 if conf.get('HAVE_TPM2') == 1
2044 cryptsetup_token_systemd_tpm2 = shared_library(
2045 'cryptsetup-token-systemd-tpm2',
2046 cryptsetup_token_systemd_tpm2_sources,
2047 include_directories : includes,
2048 link_args : ['-shared',
2049 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2050 link_with : [lib_cryptsetup_token_common,
2052 dependencies : [libcryptsetup,
2055 link_depends : cryptsetup_token_sym,
2056 install_rpath : rootpkglibdir,
2058 install_dir : libcryptsetup_plugins_dir)
2061 if conf.get('HAVE_LIBFIDO2') == 1
2062 cryptsetup_token_systemd_fido2 = shared_library(
2063 'cryptsetup-token-systemd-fido2',
2064 cryptsetup_token_systemd_fido2_sources,
2065 include_directories : includes,
2066 link_args : ['-shared',
2067 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2068 link_with : [lib_cryptsetup_token_common,
2070 dependencies : [libcryptsetup,
2073 link_depends : cryptsetup_token_sym,
2074 install_rpath : rootpkglibdir,
2076 install_dir : libcryptsetup_plugins_dir)
2079 if conf.get('HAVE_P11KIT') == 1
2080 cryptsetup_token_systemd_pkcs11 = shared_library(
2081 'cryptsetup-token-systemd-pkcs11',
2082 cryptsetup_token_systemd_pkcs11_sources,
2083 include_directories : includes,
2084 link_args : ['-shared',
2085 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2086 link_with : [lib_cryptsetup_token_common,
2088 dependencies : [libcryptsetup,
2091 link_depends : cryptsetup_token_sym,
2092 install_rpath : rootpkglibdir,
2094 install_dir : libcryptsetup_plugins_dir)
2098 ############################################################
2100 # systemd-analyze requires 'libcore'
2102 # systemd-journal-remote requires 'libjournal_core'
2103 subdir('src/journal')
2104 # systemd-networkd requires 'libsystemd_network'
2105 subdir('src/libsystemd-network')
2107 subdir('src/analyze')
2108 subdir('src/busctl')
2109 subdir('src/coredump')
2110 subdir('src/cryptenroll')
2111 subdir('src/cryptsetup')
2113 subdir('src/hostname')
2114 subdir('src/import')
2115 subdir('src/journal-remote')
2116 subdir('src/kernel-install')
2117 subdir('src/locale')
2119 subdir('src/machine')
2120 subdir('src/network')
2121 subdir('src/nspawn')
2123 subdir('src/partition')
2124 subdir('src/portable')
2125 subdir('src/pstore')
2126 subdir('src/resolve')
2128 subdir('src/shutdown')
2129 subdir('src/sysext')
2130 subdir('src/systemctl')
2131 subdir('src/sysupdate')
2132 subdir('src/timedate')
2133 subdir('src/timesync')
2134 subdir('src/tmpfiles')
2135 subdir('src/userdb')
2136 subdir('src/xdg-autostart-generator')
2138 subdir('src/systemd')
2145 ############################################################
2147 # only static linking apart from libdl, to make sure that the
2148 # module is linked to all libraries that it uses.
2149 test_dlopen = executable(
2152 include_directories : includes,
2153 link_with : [libbasic],
2154 dependencies : [libdl],
2155 build_by_default : want_tests != 'false')
2157 foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
2158 ['systemd', 'ENABLE_NSS_SYSTEMD', ['nss-systemd.h', 'userdb-glue.c', 'userdb-glue.h']],
2159 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
2160 ['resolve', 'ENABLE_NSS_RESOLVE', [], resolve_includes]]
2162 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
2166 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
2167 version_script_arg = project_source_root / sym
2169 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
2170 if tuple.length() > 2
2171 foreach s : tuple[2]
2172 sources += ['src/nss-@0@/@1@'.format(module, s)]
2176 incs = tuple.length() > 3 ? tuple[3] : includes
2178 nss = shared_library(
2182 include_directories : incs,
2183 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
2184 link_args : ['-Wl,-z,nodelete',
2186 '-Wl,--version-script=' + version_script_arg],
2187 link_with : [libsystemd_static,
2190 dependencies : [threads,
2194 install_tag : 'nss',
2195 install_dir : rootlibdir)
2197 # We cannot use shared_module because it does not support version suffix.
2198 # Unfortunately shared_library insists on creating the symlink…
2199 meson.add_install_script('sh', '-c',
2200 'rm $DESTDIR@0@/libnss_@1@.so'
2201 .format(rootlibdir, module),
2205 if want_tests != 'false'
2206 test('dlopen-nss_' + module,
2208 # path to dlopen must include a slash
2209 args : nss.full_path(),
2215 ############################################################
2220 include_directories : includes,
2221 link_with : [libcore,
2223 dependencies : [versiondep,
2225 install_rpath : rootpkglibdir,
2227 install_dir : rootlibexecdir)
2228 dbus_programs += exe
2229 public_programs += exe
2231 meson.add_install_script(meson_make_symlink,
2232 rootlibexecdir / 'systemd',
2233 rootsbindir / 'init')
2237 systemd_analyze_sources,
2238 include_directories : core_includes,
2239 link_with : [libcore,
2241 dependencies : [versiondep,
2243 install_rpath : rootpkglibdir,
2244 install : conf.get('ENABLE_ANALYZE') == 1)
2245 public_programs += exe
2247 if want_tests != 'false'
2248 test('test-compare-versions',
2249 test_compare_versions_sh,
2250 args : exe.full_path())
2255 systemd_journald_sources,
2256 include_directories : includes,
2257 link_with : [libjournal_core,
2259 dependencies : [threads,
2264 install_rpath : rootpkglibdir,
2266 install_dir : rootlibexecdir)
2268 public_programs += executable(
2270 systemd_cat_sources,
2271 include_directories : includes,
2272 link_with : [libjournal_core,
2274 dependencies : [threads],
2275 install_rpath : rootpkglibdir,
2278 if get_option('link-journalctl-shared')
2279 journalctl_link_with = [libshared]
2281 journalctl_link_with = [libsystemd_static,
2286 public_programs += executable(
2289 include_directories : includes,
2290 link_with : [journalctl_link_with],
2291 dependencies : [threads,
2297 install_rpath : rootpkglibdir,
2299 install_dir : rootbindir)
2302 'systemd-getty-generator',
2303 'src/getty-generator/getty-generator.c',
2304 include_directories : includes,
2305 link_with : [libshared],
2306 install_rpath : rootpkglibdir,
2308 install_dir : systemgeneratordir)
2311 'systemd-debug-generator',
2312 'src/debug-generator/debug-generator.c',
2313 include_directories : includes,
2314 link_with : [libshared],
2315 install_rpath : rootpkglibdir,
2317 install_dir : systemgeneratordir)
2320 'systemd-run-generator',
2321 'src/run-generator/run-generator.c',
2322 include_directories : includes,
2323 link_with : [libshared],
2324 install_rpath : rootpkglibdir,
2326 install_dir : systemgeneratordir)
2329 'systemd-fstab-generator',
2330 'src/fstab-generator/fstab-generator.c',
2331 include_directories : includes,
2332 link_with : [libshared],
2333 install_rpath : rootpkglibdir,
2335 install_dir : systemgeneratordir)
2337 meson.add_install_script(meson_make_symlink,
2338 systemgeneratordir / 'systemd-fstab-generator',
2339 rootlibexecdir / 'systemd-sysroot-fstab-check')
2341 if want_tests != 'false'
2342 test('test-fstab-generator',
2343 test_fstab_generator_sh,
2344 # https://github.com/mesonbuild/meson/issues/2681
2345 args : exe.full_path(),
2349 if conf.get('ENABLE_ENVIRONMENT_D') == 1
2351 '30-systemd-environment-d-generator',
2352 'src/environment-d-generator/environment-d-generator.c',
2353 include_directories : includes,
2354 link_with : [libshared],
2355 install_rpath : rootpkglibdir,
2357 install_dir : userenvgeneratordir)
2359 meson.add_install_script(meson_make_symlink,
2360 sysconfdir / 'environment',
2361 environmentdir / '99-environment.conf')
2364 if conf.get('ENABLE_HIBERNATE') == 1
2366 'systemd-hibernate-resume-generator',
2367 'src/hibernate-resume/hibernate-resume-generator.c',
2368 include_directories : includes,
2369 link_with : [libshared],
2370 install_rpath : rootpkglibdir,
2372 install_dir : systemgeneratordir)
2375 'systemd-hibernate-resume',
2376 'src/hibernate-resume/hibernate-resume.c',
2377 include_directories : includes,
2378 link_with : [libshared],
2379 install_rpath : rootpkglibdir,
2381 install_dir : rootlibexecdir)
2384 if conf.get('HAVE_BLKID') == 1
2386 'systemd-gpt-auto-generator',
2387 'src/gpt-auto-generator/gpt-auto-generator.c',
2388 include_directories : includes,
2389 link_with : [libshared],
2390 dependencies : libblkid,
2391 install_rpath : rootpkglibdir,
2393 install_dir : systemgeneratordir)
2395 public_programs += executable(
2397 'src/dissect/dissect.c',
2398 include_directories : includes,
2399 link_with : [libshared],
2400 install_rpath : rootpkglibdir,
2404 if conf.get('ENABLE_RESOLVE') == 1
2405 dbus_programs += executable(
2407 systemd_resolved_sources,
2408 include_directories : resolve_includes,
2409 link_with : [libshared,
2411 libsystemd_resolve_core],
2412 dependencies : systemd_resolved_dependencies,
2413 install_rpath : rootpkglibdir,
2415 install_dir : rootlibexecdir)
2417 public_programs += executable(
2420 include_directories : includes,
2421 link_with : [libshared,
2423 libsystemd_resolve_core],
2424 dependencies : [threads,
2425 lib_openssl_or_gcrypt,
2428 install_rpath : rootpkglibdir,
2431 meson.add_install_script(meson_make_symlink,
2432 bindir / 'resolvectl',
2433 rootsbindir / 'resolvconf')
2435 meson.add_install_script(meson_make_symlink,
2436 bindir / 'resolvectl',
2437 bindir / 'systemd-resolve')
2440 if conf.get('ENABLE_LOGIND') == 1
2441 dbus_programs += executable(
2443 systemd_logind_sources,
2444 include_directories : includes,
2445 link_with : [liblogind_core,
2447 dependencies : [threads,
2449 install_rpath : rootpkglibdir,
2451 install_dir : rootlibexecdir)
2453 public_programs += executable(
2456 include_directories : includes,
2457 link_with : [libshared],
2458 dependencies : [threads,
2462 install_rpath : rootpkglibdir,
2464 install_dir : rootbindir)
2466 public_programs += executable(
2468 'src/login/inhibit.c',
2469 include_directories : includes,
2470 link_with : [libshared],
2471 install_rpath : rootpkglibdir,
2473 install_dir : rootbindir)
2475 if conf.get('HAVE_PAM') == 1
2476 version_script_arg = project_source_root / pam_systemd_sym
2477 pam_systemd = shared_library(
2481 include_directories : includes,
2482 link_args : ['-shared',
2483 '-Wl,--version-script=' + version_script_arg],
2484 link_with : [libsystemd_static,
2486 dependencies : [threads,
2489 link_depends : pam_systemd_sym,
2491 install_tag : 'pam',
2492 install_dir : pamlibdir)
2494 if want_tests != 'false'
2495 test('dlopen-pam_systemd',
2497 # path to dlopen must include a slash
2498 args : pam_systemd.full_path(),
2499 depends : pam_systemd)
2504 'systemd-user-runtime-dir',
2505 user_runtime_dir_sources,
2506 include_directories : includes,
2507 link_with : [libshared],
2508 install_rpath : rootpkglibdir,
2510 install_dir : rootlibexecdir)
2513 if conf.get('HAVE_PAM') == 1
2515 'systemd-user-sessions',
2516 'src/user-sessions/user-sessions.c',
2517 include_directories : includes,
2518 link_with : [libshared],
2519 install_rpath : rootpkglibdir,
2521 install_dir : rootlibexecdir)
2524 if conf.get('HAVE_BLKID') == 1 and conf.get('HAVE_GNU_EFI') == 1
2525 if get_option('link-boot-shared')
2526 boot_link_with = [libshared]
2528 boot_link_with = [libsystemd_static, libshared_static]
2531 public_programs += executable(
2533 'src/boot/bootctl.c',
2534 include_directories : includes,
2535 link_with : [boot_link_with],
2536 dependencies : [libblkid],
2537 install_rpath : rootpkglibdir,
2540 public_programs += executable(
2541 'systemd-bless-boot',
2542 'src/boot/bless-boot.c',
2543 include_directories : includes,
2544 link_with : [boot_link_with],
2545 dependencies : [libblkid],
2546 install_rpath : rootpkglibdir,
2548 install_dir : rootlibexecdir)
2551 'systemd-bless-boot-generator',
2552 'src/boot/bless-boot-generator.c',
2553 include_directories : includes,
2554 link_with : [boot_link_with],
2555 install_rpath : rootpkglibdir,
2557 install_dir : systemgeneratordir)
2559 if conf.get('HAVE_OPENSSL') == 1
2562 'src/boot/measure.c',
2563 include_directories : includes,
2564 link_with : [libshared],
2565 dependencies : [libopenssl],
2566 install_rpath : rootpkglibdir,
2568 install_dir : rootlibexecdir)
2573 'systemd-boot-check-no-failures',
2574 'src/boot/boot-check-no-failures.c',
2575 include_directories : includes,
2576 link_with : [libshared],
2577 dependencies : [libblkid],
2578 install_rpath : rootpkglibdir,
2580 install_dir : rootlibexecdir)
2582 public_programs += executable(
2583 'systemd-socket-activate',
2584 'src/activate/activate.c',
2585 include_directories : includes,
2586 link_with : [libshared],
2587 dependencies : [threads],
2588 install_rpath : rootpkglibdir,
2591 systemctl = executable(
2594 include_directories : includes,
2595 link_with : systemctl_link_with,
2596 dependencies : [threads,
2602 install_rpath : rootpkglibdir,
2604 install_dir : rootbindir)
2605 public_programs += systemctl
2607 if conf.get('ENABLE_PORTABLED') == 1
2608 dbus_programs += executable(
2609 'systemd-portabled',
2610 systemd_portabled_sources,
2611 include_directories : includes,
2612 link_with : [libshared],
2613 dependencies : [threads, libselinux],
2614 install_rpath : rootpkglibdir,
2616 install_dir : rootlibexecdir)
2618 public_programs += executable(
2620 'src/portable/portablectl.c',
2621 include_directories : includes,
2622 link_with : [libshared],
2623 dependencies : [threads],
2624 install_rpath : rootpkglibdir,
2626 install_dir : rootbindir)
2629 if conf.get('ENABLE_SYSEXT') == 1
2630 public_programs += executable(
2632 systemd_sysext_sources,
2633 include_directories : includes,
2634 link_with : [libshared],
2635 install_rpath : rootpkglibdir,
2637 install_dir : rootbindir)
2640 if conf.get('ENABLE_USERDB') == 1
2643 systemd_userwork_sources,
2644 include_directories : includes,
2645 link_with : [libshared],
2646 dependencies : [threads],
2647 install_rpath : rootpkglibdir,
2649 install_dir : rootlibexecdir)
2653 systemd_userdbd_sources,
2654 include_directories : includes,
2655 link_with : [libshared],
2656 dependencies : [threads],
2657 install_rpath : rootpkglibdir,
2659 install_dir : rootlibexecdir)
2661 public_programs += executable(
2664 include_directories : includes,
2665 link_with : [libshared],
2666 dependencies : [threads],
2667 install_rpath : rootpkglibdir,
2671 if conf.get('ENABLE_HOMED') == 1
2674 systemd_homework_sources,
2675 include_directories : includes,
2676 link_with : [libshared],
2677 dependencies : [threads,
2683 install_rpath : rootpkglibdir,
2685 install_dir : rootlibexecdir)
2687 dbus_programs += executable(
2689 systemd_homed_sources,
2690 include_directories : home_includes,
2691 link_with : [libshared],
2692 dependencies : [threads,
2696 install_rpath : rootpkglibdir,
2698 install_dir : rootlibexecdir)
2700 public_programs += executable(
2703 include_directories : includes,
2704 link_with : [libshared],
2705 dependencies : [threads,
2710 install_rpath : rootpkglibdir,
2713 if conf.get('HAVE_PAM') == 1
2714 version_script_arg = project_source_root / pam_systemd_home_sym
2715 pam_systemd_home = shared_library(
2719 include_directories : includes,
2720 link_args : ['-shared',
2721 '-Wl,--version-script=' + version_script_arg],
2722 link_with : [libsystemd_static,
2724 dependencies : [threads,
2728 link_depends : pam_systemd_home_sym,
2730 install_tag : 'pam',
2731 install_dir : pamlibdir)
2733 if want_tests != 'false'
2734 test('dlopen-pam_systemd_home',
2736 # path to dlopen must include a slash
2737 args : pam_systemd_home.full_path(),
2738 depends : pam_systemd_home)
2743 foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
2744 (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
2745 meson.add_install_script(meson_make_symlink,
2746 rootbindir / 'systemctl',
2747 rootsbindir / alias)
2750 meson.add_install_script(meson_make_symlink,
2751 rootbindir / 'udevadm',
2752 rootlibexecdir / 'systemd-udevd')
2754 if conf.get('ENABLE_BACKLIGHT') == 1
2756 'systemd-backlight',
2757 'src/backlight/backlight.c',
2758 include_directories : includes,
2759 link_with : [libshared],
2760 install_rpath : rootpkglibdir,
2762 install_dir : rootlibexecdir)
2765 if conf.get('ENABLE_RFKILL') == 1
2768 'src/rfkill/rfkill.c',
2769 include_directories : includes,
2770 link_with : [libshared],
2771 install_rpath : rootpkglibdir,
2773 install_dir : rootlibexecdir)
2777 'systemd-system-update-generator',
2778 'src/system-update-generator/system-update-generator.c',
2779 include_directories : includes,
2780 link_with : [libshared],
2781 install_rpath : rootpkglibdir,
2783 install_dir : systemgeneratordir)
2785 if conf.get('HAVE_LIBCRYPTSETUP') == 1
2787 'systemd-cryptsetup',
2788 systemd_cryptsetup_sources,
2789 include_directories : includes,
2790 link_with : [libshared],
2791 dependencies : [libcryptsetup,
2793 install_rpath : rootpkglibdir,
2795 install_dir : rootlibexecdir)
2798 'systemd-cryptsetup-generator',
2799 'src/cryptsetup/cryptsetup-generator.c',
2800 include_directories : includes,
2801 link_with : [libshared],
2802 install_rpath : rootpkglibdir,
2804 install_dir : systemgeneratordir)
2807 'systemd-veritysetup',
2808 'src/veritysetup/veritysetup.c',
2809 include_directories : includes,
2810 link_with : [libshared],
2811 dependencies : [libcryptsetup],
2812 install_rpath : rootpkglibdir,
2814 install_dir : rootlibexecdir)
2817 'systemd-veritysetup-generator',
2818 'src/veritysetup/veritysetup-generator.c',
2819 include_directories : includes,
2820 link_with : [libshared],
2821 install_rpath : rootpkglibdir,
2823 install_dir : systemgeneratordir)
2825 public_programs += executable(
2826 'systemd-cryptenroll',
2827 systemd_cryptenroll_sources,
2828 include_directories : includes,
2829 link_with : [libshared],
2830 dependencies : [libcryptsetup,
2834 install_rpath : rootpkglibdir,
2838 'systemd-integritysetup',
2839 ['src/integritysetup/integritysetup.c', 'src/integritysetup/integrity-util.c'],
2840 include_directories : includes,
2841 link_with : [libshared],
2842 dependencies : [libcryptsetup],
2843 install_rpath : rootpkglibdir,
2845 install_dir : rootlibexecdir)
2848 'systemd-integritysetup-generator',
2849 ['src/integritysetup/integritysetup-generator.c', 'src/integritysetup/integrity-util.c'],
2850 include_directories : includes,
2851 link_with : [libshared],
2852 install_rpath : rootpkglibdir,
2854 install_dir : systemgeneratordir)
2857 if conf.get('HAVE_SYSV_COMPAT') == 1
2859 'systemd-sysv-generator',
2860 'src/sysv-generator/sysv-generator.c',
2861 include_directories : includes,
2862 link_with : [libshared],
2863 install_rpath : rootpkglibdir,
2865 install_dir : systemgeneratordir)
2867 sysv_generator_test_py = find_program('test/sysv-generator-test.py')
2868 if want_tests != 'false'
2869 test('sysv-generator-test',
2870 sysv_generator_test_py,
2875 'systemd-rc-local-generator',
2876 'src/rc-local-generator/rc-local-generator.c',
2877 include_directories : includes,
2878 link_with : [libshared],
2879 install_rpath : rootpkglibdir,
2881 install_dir : systemgeneratordir)
2884 if conf.get('ENABLE_XDG_AUTOSTART') == 1
2886 'systemd-xdg-autostart-generator',
2887 systemd_xdg_autostart_generator_sources,
2888 include_directories : includes,
2889 link_with : [libshared],
2890 install_rpath : rootpkglibdir,
2892 install_dir : usergeneratordir)
2895 'systemd-xdg-autostart-condition',
2896 'src/xdg-autostart-generator/xdg-autostart-condition.c',
2897 include_directories : includes,
2898 link_with : [libshared],
2899 install_rpath : rootpkglibdir,
2901 install_dir : rootlibexecdir)
2904 if conf.get('ENABLE_HOSTNAMED') == 1
2905 dbus_programs += executable(
2906 'systemd-hostnamed',
2907 'src/hostname/hostnamed.c',
2908 include_directories : includes,
2909 link_with : [libshared],
2910 install_rpath : rootpkglibdir,
2912 install_dir : rootlibexecdir)
2914 public_programs += executable(
2916 'src/hostname/hostnamectl.c',
2917 include_directories : includes,
2918 link_with : [libshared],
2919 install_rpath : rootpkglibdir,
2923 if conf.get('ENABLE_LOCALED') == 1
2924 if conf.get('HAVE_XKBCOMMON') == 1
2925 # logind will load libxkbcommon.so dynamically on its own, but we still
2926 # need to specify where the headers are
2927 deps = [libdl, libxkbcommon.partial_dependency(compile_args: true)]
2932 dbus_programs += executable(
2934 systemd_localed_sources,
2935 include_directories : includes,
2936 link_with : [libshared],
2937 dependencies : deps,
2938 install_rpath : rootpkglibdir,
2940 install_dir : rootlibexecdir)
2942 public_programs += executable(
2945 include_directories : includes,
2946 link_with : [libshared],
2947 install_rpath : rootpkglibdir,
2951 if conf.get('ENABLE_TIMEDATED') == 1
2952 dbus_programs += executable(
2953 'systemd-timedated',
2954 'src/timedate/timedated.c',
2955 include_directories : includes,
2956 link_with : [libshared],
2957 install_rpath : rootpkglibdir,
2959 install_dir : rootlibexecdir)
2962 if conf.get('ENABLE_TIMEDATECTL') == 1
2963 public_programs += executable(
2965 'src/timedate/timedatectl.c',
2966 include_directories : includes,
2967 install_rpath : rootpkglibdir,
2968 link_with : [libshared],
2969 dependencies : [libm],
2973 if conf.get('ENABLE_TIMESYNCD') == 1
2975 'systemd-timesyncd',
2976 systemd_timesyncd_sources,
2977 include_directories : includes,
2978 link_with : [libtimesyncd_core],
2979 dependencies : [threads,
2981 install_rpath : rootpkglibdir,
2983 install_dir : rootlibexecdir)
2986 'systemd-time-wait-sync',
2987 'src/timesync/wait-sync.c',
2988 include_directories : includes,
2989 link_with : [libtimesyncd_core],
2990 install_rpath : rootpkglibdir,
2992 install_dir : rootlibexecdir)
2995 if conf.get('ENABLE_MACHINED') == 1
2996 dbus_programs += executable(
2998 systemd_machined_sources,
2999 include_directories : includes,
3000 link_with : [libmachine_core,
3002 install_rpath : rootpkglibdir,
3004 install_dir : rootlibexecdir)
3006 public_programs += executable(
3008 'src/machine/machinectl.c',
3009 include_directories : includes,
3010 link_with : [libshared],
3011 dependencies : [threads,
3015 install_rpath : rootpkglibdir,
3017 install_dir : rootbindir)
3020 if conf.get('ENABLE_IMPORTD') == 1
3021 dbus_programs += executable(
3023 systemd_importd_sources,
3024 include_directories : includes,
3025 link_with : [libshared],
3026 dependencies : [threads],
3027 install_rpath : rootpkglibdir,
3029 install_dir : rootlibexecdir)
3031 systemd_pull = executable(
3033 systemd_pull_sources,
3034 include_directories : includes,
3035 link_with : [libshared,
3037 dependencies : [versiondep,
3039 lib_openssl_or_gcrypt,
3043 install_rpath : rootpkglibdir,
3045 install_dir : rootlibexecdir)
3047 systemd_import = executable(
3049 systemd_import_sources,
3050 include_directories : includes,
3051 link_with : [libshared,
3053 dependencies : [libcurl,
3057 install_rpath : rootpkglibdir,
3059 install_dir : rootlibexecdir)
3061 systemd_import_fs = executable(
3062 'systemd-import-fs',
3063 systemd_import_fs_sources,
3064 include_directories : includes,
3065 link_with : [libshared,
3067 install_rpath : rootpkglibdir,
3069 install_dir : rootlibexecdir)
3071 systemd_export = executable(
3073 systemd_export_sources,
3074 include_directories : includes,
3075 link_with : [libshared,
3077 dependencies : [libcurl,
3081 install_rpath : rootpkglibdir,
3083 install_dir : rootlibexecdir)
3085 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
3088 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
3089 public_programs += executable(
3090 'systemd-journal-upload',
3091 systemd_journal_upload_sources,
3092 include_directories : includes,
3093 link_with : [libshared],
3094 dependencies : [versiondep,
3101 install_rpath : rootpkglibdir,
3103 install_dir : rootlibexecdir)
3106 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
3107 public_programs += executable(
3108 'systemd-journal-remote',
3109 systemd_journal_remote_sources,
3110 include_directories : journal_includes,
3111 link_with : [libshared,
3112 libsystemd_journal_remote],
3113 dependencies : [threads,
3119 install_rpath : rootpkglibdir,
3121 install_dir : rootlibexecdir)
3123 public_programs += executable(
3124 'systemd-journal-gatewayd',
3125 systemd_journal_gatewayd_sources,
3126 include_directories : journal_includes,
3127 link_with : [libshared],
3128 dependencies : [threads,
3134 install_rpath : rootpkglibdir,
3136 install_dir : rootlibexecdir)
3139 if conf.get('ENABLE_COREDUMP') == 1
3142 systemd_coredump_sources,
3143 include_directories : includes,
3144 link_with : [libshared,
3146 dependencies : [threads,
3151 install_rpath : rootpkglibdir,
3153 install_dir : rootlibexecdir)
3155 public_programs += executable(
3157 coredumpctl_sources,
3158 include_directories : includes,
3159 link_with : [libshared,
3161 dependencies : [threads,
3165 install_rpath : rootpkglibdir,
3169 if conf.get('ENABLE_PSTORE') == 1
3172 systemd_pstore_sources,
3173 include_directories : includes,
3174 link_with : [libshared],
3175 dependencies : [threads,
3180 install_rpath : rootpkglibdir,
3182 install_dir : rootlibexecdir)
3185 if conf.get('ENABLE_OOMD') == 1
3186 dbus_programs += executable('systemd-oomd',
3187 systemd_oomd_sources,
3188 include_directories : includes,
3189 link_with : [libshared],
3190 dependencies : [libatomic],
3191 install_rpath : rootpkglibdir,
3193 install_dir : rootlibexecdir)
3195 public_programs += executable(
3198 include_directories : includes,
3199 link_with : [libshared],
3201 install_rpath : rootpkglibdir,
3205 if conf.get('ENABLE_BINFMT') == 1
3206 public_programs += executable(
3208 'src/binfmt/binfmt.c',
3209 include_directories : includes,
3210 link_with : [libshared],
3211 install_rpath : rootpkglibdir,
3213 install_dir : rootlibexecdir)
3215 meson.add_install_script('sh', '-c',
3216 mkdir_p.format(binfmtdir))
3217 if install_sysconfdir
3218 meson.add_install_script('sh', '-c',
3219 mkdir_p.format(sysconfdir / 'binfmt.d'))
3223 if conf.get('ENABLE_SYSUPDATE') == 1
3225 'systemd-sysupdate',
3226 systemd_sysupdate_sources,
3227 include_directories : includes,
3228 link_with : [libshared],
3229 dependencies : [threads,
3233 install_rpath : rootpkglibdir,
3235 install_dir : rootlibexecdir)
3236 public_programs += exe
3239 if conf.get('ENABLE_VCONSOLE') == 1
3241 'systemd-vconsole-setup',
3242 'src/vconsole/vconsole-setup.c',
3243 include_directories : includes,
3244 link_with : [libshared],
3245 install_rpath : rootpkglibdir,
3247 install_dir : rootlibexecdir)
3250 if conf.get('ENABLE_RANDOMSEED') == 1
3252 'systemd-random-seed',
3253 'src/random-seed/random-seed.c',
3254 include_directories : includes,
3255 link_with : [libshared],
3256 install_rpath : rootpkglibdir,
3258 install_dir : rootlibexecdir)
3261 if conf.get('ENABLE_FIRSTBOOT') == 1
3262 public_programs += executable(
3263 'systemd-firstboot',
3264 'src/firstboot/firstboot.c',
3265 include_directories : includes,
3266 link_with : [libshared],
3267 dependencies : [libcrypt],
3268 install_rpath : rootpkglibdir,
3270 install_dir : rootbindir)
3274 'systemd-remount-fs',
3275 'src/remount-fs/remount-fs.c',
3276 include_directories : includes,
3277 link_with : [libshared],
3278 install_rpath : rootpkglibdir,
3280 install_dir : rootlibexecdir)
3283 'systemd-machine-id-setup',
3284 'src/machine-id-setup/machine-id-setup-main.c',
3285 include_directories : includes,
3286 link_with : [libshared],
3287 install_rpath : rootpkglibdir,
3289 install_dir : rootbindir)
3294 include_directories : includes,
3295 link_with : [libshared],
3296 install_rpath : rootpkglibdir,
3298 install_dir : rootlibexecdir)
3300 executable('systemd-growfs',
3301 'src/partition/growfs.c',
3302 include_directories : includes,
3303 link_with : [libshared],
3304 install_rpath : rootpkglibdir,
3306 install_dir : rootlibexecdir)
3310 'src/partition/makefs.c',
3311 include_directories : includes,
3312 link_with : [libshared],
3313 install_rpath : rootpkglibdir,
3315 install_dir : rootlibexecdir)
3319 'src/sleep/sleep.c',
3320 include_directories : includes,
3321 link_with : [libshared],
3322 install_rpath : rootpkglibdir,
3324 install_dir : rootlibexecdir)
3326 if install_sysconfdir_samples
3327 install_data('src/sleep/sleep.conf',
3328 install_dir : pkgsysconfdir)
3331 public_programs += executable(
3333 'src/sysctl/sysctl.c',
3334 include_directories : includes,
3335 link_with : [libshared],
3336 install_rpath : rootpkglibdir,
3338 install_dir : rootlibexecdir)
3342 'src/ac-power/ac-power.c',
3343 include_directories : includes,
3344 link_with : [libshared],
3345 install_rpath : rootpkglibdir,
3347 install_dir : rootlibexecdir)
3349 public_programs += executable(
3350 'systemd-detect-virt',
3351 'src/detect-virt/detect-virt.c',
3352 include_directories : includes,
3353 link_with : [libshared],
3354 install_rpath : rootpkglibdir,
3357 public_programs += executable(
3359 'src/delta/delta.c',
3360 include_directories : includes,
3361 link_with : [libshared],
3362 install_rpath : rootpkglibdir,
3365 public_programs += executable(
3367 'src/escape/escape.c',
3368 include_directories : includes,
3369 link_with : [libshared],
3370 install_rpath : rootpkglibdir,
3372 install_dir : rootbindir)
3374 public_programs += executable(
3376 'src/notify/notify.c',
3377 include_directories : includes,
3378 link_with : [libshared],
3379 install_rpath : rootpkglibdir,
3381 install_dir : rootbindir)
3383 public_programs += executable(
3385 'src/creds/creds.c',
3386 include_directories : includes,
3387 link_with : [libshared],
3388 dependencies : [threads,
3390 install_rpath : rootpkglibdir,
3392 install_dir : rootbindir)
3395 'systemd-volatile-root',
3396 'src/volatile-root/volatile-root.c',
3397 include_directories : includes,
3398 link_with : [libshared],
3399 install_rpath : rootpkglibdir,
3400 install : conf.get('ENABLE_INITRD') == 1,
3401 install_dir : rootlibexecdir)
3404 'systemd-cgroups-agent',
3405 'src/cgroups-agent/cgroups-agent.c',
3406 include_directories : includes,
3407 link_with : [libshared],
3408 install_rpath : rootpkglibdir,
3410 install_dir : rootlibexecdir)
3412 systemd_id128 = executable(
3414 'src/id128/id128.c',
3415 include_directories : includes,
3416 link_with : [libshared],
3417 install_rpath : rootpkglibdir,
3419 public_programs += systemd_id128
3421 if want_tests != 'false'
3422 test('test-systemctl-enable',
3423 test_systemctl_enable_sh,
3424 # https://github.com/mesonbuild/meson/issues/2681
3425 args : [systemctl.full_path(),
3426 systemd_id128.full_path()])
3429 public_programs += executable(
3432 include_directories : includes,
3433 link_with : [libshared],
3434 install_rpath : rootpkglibdir,
3437 public_programs += executable(
3438 'systemd-ask-password',
3439 'src/ask-password/ask-password.c',
3440 include_directories : includes,
3441 link_with : [libshared],
3442 install_rpath : rootpkglibdir,
3444 install_dir : rootbindir)
3447 'systemd-reply-password',
3448 'src/reply-password/reply-password.c',
3449 include_directories : includes,
3450 link_with : [libshared],
3451 install_rpath : rootpkglibdir,
3453 install_dir : rootlibexecdir)
3455 public_programs += executable(
3456 'systemd-tty-ask-password-agent',
3457 'src/tty-ask-password-agent/tty-ask-password-agent.c',
3458 include_directories : includes,
3459 link_with : [libshared],
3460 install_rpath : rootpkglibdir,
3462 install_dir : rootbindir)
3464 public_programs += executable(
3467 include_directories : includes,
3468 link_with : [libshared],
3469 install_rpath : rootpkglibdir,
3472 public_programs += executable(
3474 'src/cgtop/cgtop.c',
3475 include_directories : includes,
3476 link_with : [libshared],
3477 install_rpath : rootpkglibdir,
3482 'src/initctl/initctl.c',
3483 include_directories : includes,
3484 link_with : [libshared],
3485 install_rpath : rootpkglibdir,
3486 install : (conf.get('HAVE_SYSV_COMPAT') == 1),
3487 install_dir : rootlibexecdir)
3489 public_programs += executable(
3491 'src/mount/mount-tool.c',
3492 include_directories : includes,
3493 link_with : [libshared],
3494 dependencies: [libmount],
3495 install_rpath : rootpkglibdir,
3498 meson.add_install_script(meson_make_symlink,
3499 'systemd-mount', bindir / 'systemd-umount')
3501 public_programs += executable(
3504 include_directories : includes,
3505 link_with : [libshared],
3506 install_rpath : rootpkglibdir,
3509 public_programs += executable(
3510 'systemd-stdio-bridge',
3511 'src/stdio-bridge/stdio-bridge.c',
3512 include_directories : includes,
3513 link_with : [libshared],
3514 dependencies : [versiondep],
3515 install_rpath : rootpkglibdir,
3518 public_programs += executable(
3521 include_directories : includes,
3522 link_with : [libshared],
3523 dependencies : [versiondep],
3524 install_rpath : rootpkglibdir,
3530 'src/sysusers/sysusers.c',
3531 include_directories : includes,
3532 link_with : [libshared],
3533 install_rpath : rootpkglibdir,
3535 install_dir : rootbindir)
3536 public_programs += exe
3538 if want_tests != 'false'
3539 test('test-sysusers',
3541 # https://github.com/mesonbuild/meson/issues/2681
3542 args : exe.full_path())
3545 if have_standalone_binaries
3547 'systemd-sysusers.standalone',
3548 'src/sysusers/sysusers.c',
3549 include_directories : includes,
3550 c_args : '-DSTANDALONE',
3551 link_with : [libshared_static,
3556 install_dir : rootbindir)
3557 public_programs += exe
3559 if want_tests != 'false'
3560 test('test-sysusers.standalone',
3562 # https://github.com/mesonbuild/meson/issues/2681
3563 args : exe.full_path())
3568 if conf.get('ENABLE_TMPFILES') == 1
3571 systemd_tmpfiles_sources,
3572 include_directories : includes,
3573 link_with : [libshared],
3574 dependencies : [libacl],
3575 install_rpath : rootpkglibdir,
3577 install_dir : rootbindir)
3578 public_programs += exe
3580 if want_tests != 'false'
3581 test('test-systemd-tmpfiles',
3582 test_systemd_tmpfiles_py,
3583 # https://github.com/mesonbuild/meson/issues/2681
3584 args : exe.full_path())
3587 if have_standalone_binaries
3589 'systemd-tmpfiles.standalone',
3590 systemd_tmpfiles_sources,
3591 include_directories : includes,
3592 c_args : '-DSTANDALONE',
3593 link_with : [libshared_static,
3597 dependencies : [libacl],
3599 install_dir : rootbindir)
3600 public_programs += exe
3602 if want_tests != 'false'
3603 test('test-systemd-tmpfiles.standalone',
3604 test_systemd_tmpfiles_py,
3605 # https://github.com/mesonbuild/meson/issues/2681
3606 args : exe.full_path())
3611 if conf.get('ENABLE_HWDB') == 1
3612 systemd_hwdb = executable(
3615 include_directories : includes,
3616 link_with : udev_link_with,
3617 install_rpath : udev_rpath,
3619 install_dir : rootbindir)
3620 public_programs += systemd_hwdb
3622 if want_tests != 'false'
3625 suite : 'dist-check',
3626 args : [systemd_hwdb.full_path()],
3631 if conf.get('ENABLE_QUOTACHECK') == 1
3633 'systemd-quotacheck',
3634 'src/quotacheck/quotacheck.c',
3635 include_directories : includes,
3636 link_with : [libshared],
3637 install_rpath : rootpkglibdir,
3639 install_dir : rootlibexecdir)
3642 public_programs += executable(
3643 'systemd-socket-proxyd',
3644 'src/socket-proxy/socket-proxyd.c',
3645 include_directories : includes,
3646 link_with : [libshared],
3647 dependencies : [threads],
3648 install_rpath : rootpkglibdir,
3650 install_dir : rootlibexecdir)
3652 udevadm = executable(
3655 include_directories : includes,
3656 link_with : [libudevd_core],
3657 dependencies : [versiondep,
3663 install_rpath : udev_rpath,
3665 install_dir : rootbindir)
3666 public_programs += udevadm
3668 if conf.get('ENABLE_REPART') == 1
3671 systemd_repart_sources,
3672 include_directories : includes,
3673 link_with : [libshared],
3674 dependencies : [threads,
3677 install_rpath : rootpkglibdir,
3679 install_dir : rootbindir)
3680 public_programs += exe
3685 systemd_shutdown_sources,
3686 include_directories : includes,
3687 link_with : [libshared],
3688 dependencies : [libmount],
3689 install_rpath : rootpkglibdir,
3691 install_dir : rootlibexecdir)
3694 'systemd-update-done',
3695 'src/update-done/update-done.c',
3696 include_directories : includes,
3697 link_with : [libshared],
3698 install_rpath : rootpkglibdir,
3700 install_dir : rootlibexecdir)
3703 'systemd-update-utmp',
3704 'src/update-utmp/update-utmp.c',
3705 include_directories : includes,
3706 link_with : [libshared],
3707 dependencies : [libaudit],
3708 install_rpath : rootpkglibdir,
3709 install : (conf.get('ENABLE_UTMP') == 1),
3710 install_dir : rootlibexecdir)
3712 if conf.get('HAVE_KMOD') == 1
3714 'systemd-modules-load',
3715 'src/modules-load/modules-load.c',
3716 include_directories : includes,
3717 link_with : [libshared],
3718 dependencies : [libkmod],
3719 install_rpath : rootpkglibdir,
3721 install_dir : rootlibexecdir)
3723 meson.add_install_script('sh', '-c',
3724 mkdir_p.format(modulesloaddir))
3725 if install_sysconfdir
3726 meson.add_install_script('sh', '-c',
3727 mkdir_p.format(sysconfdir / 'modules-load.d'))
3731 public_programs += executable(
3733 systemd_nspawn_sources,
3734 include_directories : includes,
3735 link_with : [libnspawn_core,
3737 dependencies : [libblkid,
3739 install_rpath : rootpkglibdir,
3742 if conf.get('ENABLE_NETWORKD') == 1
3743 dbus_programs += executable(
3745 systemd_networkd_sources,
3746 include_directories : network_includes,
3747 link_with : [libnetworkd_core,
3749 networkd_link_with],
3750 dependencies : [threads],
3751 install_rpath : rootpkglibdir,
3753 install_dir : rootlibexecdir)
3755 public_programs += executable(
3756 'systemd-networkd-wait-online',
3757 systemd_networkd_wait_online_sources,
3758 include_directories : includes,
3759 link_with : [networkd_link_with],
3760 install_rpath : rootpkglibdir,
3762 install_dir : rootlibexecdir)
3764 public_programs += executable(
3767 include_directories : libsystemd_network_includes,
3768 link_with : [libsystemd_network,
3769 networkd_link_with],
3770 install_rpath : rootpkglibdir,
3772 install_dir : rootbindir)
3776 'systemd-network-generator',
3777 network_generator_sources,
3778 include_directories : includes,
3779 link_with : [networkd_link_with],
3780 install_rpath : rootpkglibdir,
3782 install_dir : rootlibexecdir)
3784 if want_tests != 'false'
3785 test('test-network-generator-conversion',
3786 test_network_generator_conversion_sh,
3787 # https://github.com/mesonbuild/meson/issues/2681
3788 args : exe.full_path(),
3793 'systemd-sulogin-shell',
3794 'src/sulogin-shell/sulogin-shell.c',
3795 include_directories : includes,
3796 link_with : [libshared],
3797 install_rpath : rootpkglibdir,
3799 install_dir : rootlibexecdir)
3801 exe = custom_target(
3803 input : kernel_install_in,
3804 output : 'kernel-install',
3805 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
3806 install : want_kernel_install,
3807 install_mode : 'rwxr-xr-x',
3808 install_dir : bindir)
3809 public_programs += exe
3811 if want_tests != 'false'
3812 test('test-kernel-install',
3813 test_kernel_install_sh,
3814 args : [exe.full_path(), loaderentry_install])
3817 ############################################################
3819 runtest_env = custom_target(
3820 'systemd-runtest.env',
3821 output : 'systemd-runtest.env',
3822 command : [sh, '-c',
3823 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
3824 project_source_root / 'test',
3825 project_build_root / 'catalog')],
3827 build_by_default : true)
3829 test_cflags = ['-DTEST_CODE=1']
3830 # We intentionally do not do inline initializations with definitions for a
3831 # bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
3832 # use the variable unexpectedly. This triggers a lot of maybe-uninitialized
3833 # false positives when the combination of -O2 and -flto is used. Suppress them.
3834 if '-O2' in c_args and '-flto=auto' in c_args
3835 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
3838 foreach tuple : tests
3840 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3841 dependencies = tuple.length() > 2 ? tuple[2] : []
3842 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3843 condition = tuple.length() > 4 ? tuple[4] : ''
3844 type = tuple.length() > 5 ? tuple[5] : ''
3845 defs = tuple.length() > 6 ? tuple[6] : []
3847 parallel = tuple.length() > 7 ? tuple[7] : true
3850 # FIXME: Use fs.stem() with meson >= 0.54.0
3851 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
3852 if type.startswith('timeout=')
3853 timeout = type.split('=')[1].to_int()
3857 suite = fs.name(fs.parent('@0@'.format(sources[0])))
3858 # FIXME: Use str.replace() with meson >= 0.58.0
3859 suite = suite.split('sd-')[-1]
3861 if condition == '' or conf.get(condition) == 1
3865 include_directories : incs,
3866 link_with : link_with,
3867 dependencies : [versiondep,
3870 build_by_default : want_tests != 'false',
3871 install_rpath : rootpkglibdir,
3872 install : install_tests,
3873 install_dir : testsdir / type,
3874 link_depends : runtest_env)
3877 message('@0@ is a manual test'.format(name))
3878 elif type == 'unsafe' and want_tests != 'unsafe'
3879 message('@0@ is an unsafe test'.format(name))
3880 elif want_tests != 'false'
3885 is_parallel : parallel)
3888 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
3893 'test-libsystemd-sym',
3894 test_libsystemd_sym_c,
3895 include_directories : includes,
3896 link_with : [libsystemd],
3897 build_by_default : want_tests != 'false',
3898 install : install_tests,
3899 install_dir : testsdir)
3900 if want_tests != 'false'
3901 test('test-libsystemd-sym', exe)
3905 'test-libsystemd-static-sym',
3906 test_libsystemd_sym_c,
3907 include_directories : includes,
3908 link_with : [install_libsystemd_static],
3909 dependencies : [threads], # threads is already included in dependencies on the library,
3910 # but does not seem to get propagated. Add here as a work-around.
3911 build_by_default : want_tests != 'false' and static_libsystemd_pic,
3912 install : install_tests and static_libsystemd_pic,
3913 install_dir : testsdir)
3914 if want_tests != 'false' and static_libsystemd_pic
3915 test('test-libsystemd-static-sym', exe)
3921 include_directories : libudev_includes,
3922 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
3923 link_with : [libudev],
3924 build_by_default : want_tests != 'false',
3925 install : install_tests,
3926 install_dir : testsdir)
3927 if want_tests != 'false'
3928 test('test-libudev-sym', exe)
3932 'test-libudev-static-sym',
3934 include_directories : libudev_includes,
3935 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
3936 link_with : [install_libudev_static],
3937 build_by_default : want_tests != 'false' and static_libudev_pic,
3938 install : install_tests and static_libudev_pic,
3939 install_dir : testsdir)
3940 if want_tests != 'false' and static_libudev_pic
3941 test('test-libudev-static-sym', exe)
3944 ############################################################
3948 foreach tuple : fuzzers
3950 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3951 dependencies = tuple.length() > 2 ? tuple[2] : []
3952 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3953 defs = tuple.length() > 4 ? tuple[4] : []
3957 dependencies += fuzzing_engine
3959 if fuzzing_engine.found()
3960 dependencies += fuzzing_engine
3962 link_args += ['-fsanitize=fuzzer']
3965 sources += 'src/fuzz/fuzz-main.c'
3968 # FIXME: Use fs.stem() with meson >= 0.54.0
3969 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
3974 include_directories : [incs, include_directories('src/fuzz')],
3975 link_with : link_with,
3976 dependencies : dependencies,
3977 c_args : defs + test_cflags,
3978 link_args: link_args,
3980 build_by_default : fuzzer_build)
3983 if want_tests != 'false'
3984 # Run the fuzz regression tests without any sanitizers enabled.
3985 # Additional invocations with sanitizers may be added below.
3986 foreach p : fuzz_regression_tests
3987 b = p.split('/')[-2]
3988 c = p.split('/')[-1]
3991 test('@0@_@1@'.format(b, c),
3994 args : [project_source_root / p])
4000 alias_target('fuzzers', fuzzer_exes)
4002 ############################################################
4004 subdir('modprobe.d')
4006 subdir('sysusers.d')
4007 subdir('tmpfiles.d')
4013 subdir('shell-completion/bash')
4014 subdir('shell-completion/zsh')
4015 subdir('docs/sysvinit')
4016 subdir('docs/var-log')
4018 install_subdir('factory/etc',
4019 install_dir : factorydir)
4020 subdir('factory/templates')
4022 if install_sysconfdir
4023 install_data('xorg/50-systemd-user.sh',
4024 install_dir : xinitrcdir)
4026 install_data('LICENSE.GPL2',
4030 'docs/CODING_STYLE.md',
4031 'docs/DISTRO_PORTING.md',
4032 'docs/ENVIRONMENT.md',
4034 'docs/TRANSIENT-SETTINGS.md',
4035 'docs/TRANSLATORS.md',
4036 'docs/UIDS-GIDS.md',
4037 install_dir : docdir)
4039 install_subdir('LICENSES',
4040 install_dir : docdir)
4042 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
4043 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
4045 ############################################################
4047 # Ensure that changes to the docs/ directory do not break the
4048 # basic Github pages build. But only run it in developer mode,
4049 # as it might be fragile due to changes in the tooling, and it is
4050 # not generally useful for users.
4051 jekyll = find_program('jekyll', required : false)
4052 if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
4053 test('github-pages',
4055 suite : 'dist-check',
4057 '--source', project_source_root / 'docs',
4058 '--destination', project_build_root / '_site'])
4061 ############################################################
4063 check_help = find_program('tools/check-help.sh')
4064 check_version = find_program('tools/check-version.sh')
4066 foreach exec : public_programs
4067 name = exec.full_path().split('/')[-1]
4068 if want_tests != 'false'
4069 test('check-help-' + name,
4071 suite : 'dist-check',
4072 args : exec.full_path(),
4075 test('check-version-' + name,
4077 suite : 'dist-check',
4078 args : [exec.full_path(),
4079 meson.project_version()],
4084 ############################################################
4086 check_directives_sh = find_program('tools/check-directives.sh')
4088 if want_tests != 'false'
4089 test('check-directives',
4090 check_directives_sh,
4091 suite : 'dist-check',
4092 args : [project_source_root, project_build_root])
4095 ############################################################
4097 # Enable tests for all supported sanitizers
4098 foreach tuple : sanitizers
4099 sanitizer = tuple[0]
4102 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
4104 foreach p : fuzz_regression_tests
4105 b = p.split('/')[-2]
4106 c = p.split('/')[-1]
4108 name = '@0@:@1@'.format(b, sanitizer)
4111 if want_tests == 'false'
4112 message('Not compiling @0@ because tests is set to false'.format(name))
4114 exe = custom_target(
4118 command : [ln, '-fs',
4119 build.full_path() / b,
4121 build_by_default : true)
4123 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
4129 test('@0@_@1@_@2@'.format(b, c, sanitizer),
4132 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
4134 args : [exe.full_path(),
4135 project_source_root / p])
4142 ############################################################
4145 all_files = run_command(
4146 env, '-u', 'GIT_WORK_TREE',
4147 git, '--git-dir=@0@/.git'.format(project_source_root),
4148 'ls-files', ':/*.[ch]',
4150 if all_files.returncode() == 0
4151 all_files = files(all_files.stdout().split())
4156 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
4159 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
4164 git_contrib_sh = find_program('tools/git-contrib.sh')
4167 command : [git_contrib_sh])
4171 git_head = run_command(
4172 git, '--git-dir=@0@/.git'.format(project_source_root),
4173 'rev-parse', 'HEAD',
4174 check : false).stdout().strip()
4175 git_head_short = run_command(
4176 git, '--git-dir=@0@/.git'.format(project_source_root),
4177 'rev-parse', '--short=7', 'HEAD',
4178 check : false).stdout().strip()
4182 command : [git, 'archive',
4183 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
4185 '--prefix', 'systemd-@0@/'.format(git_head),
4189 ############################################################
4191 check_api_docs_sh = find_program('tools/check-api-docs.sh')
4194 depends : [man, libsystemd, libudev],
4195 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
4197 alias_target('update-dbus-docs', update_dbus_docs)
4198 alias_target('update-man-rules', update_man_rules)
4200 if not meson.is_cross_build()
4202 'export-dbus-interfaces',
4203 output : fs.name(dbus_interfaces_dir),
4204 install : dbus_interfaces_dir != 'no',
4205 install_dir : fs.parent(dbus_interfaces_dir),
4206 command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
4209 ############################################################
4211 alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
4212 check : true).stdout().strip()
4215 'split /usr' : split_usr,
4216 'split bin-sbin' : split_bin,
4217 'prefix directory' : prefixdir,
4218 'rootprefix directory' : rootprefixdir,
4219 'sysconf directory' : sysconfdir,
4220 'include directory' : includedir,
4221 'lib directory' : libdir,
4222 'rootlib directory' : rootlibdir,
4223 'SysV init scripts' : sysvinit_path,
4224 'SysV rc?.d directories' : sysvrcnd_path,
4225 'PAM modules directory' : pamlibdir,
4226 'PAM configuration directory' : pamconfdir,
4227 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
4228 'RPM macros directory' : rpmmacrosdir,
4229 'modprobe.d directory' : modprobedir,
4230 'D-Bus policy directory' : dbuspolicydir,
4231 'D-Bus session directory' : dbussessionservicedir,
4232 'D-Bus system directory' : dbussystemservicedir,
4233 'D-Bus interfaces directory' : dbus_interfaces_dir,
4234 'bash completions directory' : bashcompletiondir,
4235 'zsh completions directory' : zshcompletiondir,
4236 'private shared lib version tag' : shared_lib_tag,
4237 'extra start script' : get_option('rc-local'),
4238 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
4239 get_option('debug-tty')),
4240 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
4241 conf.get('SYSTEM_ALLOC_UID_MIN')),
4242 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
4243 conf.get('SYSTEM_ALLOC_GID_MIN')),
4244 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
4245 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
4246 'static UID/GID allocations' : ' '.join(static_ugids),
4247 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
4248 'render group access mode' : get_option('group-render-mode'),
4249 'certificate root directory' : get_option('certificate-root'),
4250 'support URL' : support_url,
4251 'nobody user name' : nobody_user,
4252 'nobody group name' : nobody_group,
4253 'fallback hostname' : get_option('fallback-hostname'),
4254 'default compression method' : compression,
4255 'default DNSSEC mode' : default_dnssec,
4256 'default DNS-over-TLS mode' : default_dns_over_tls,
4257 'default mDNS mode' : default_mdns,
4258 'default LLMNR mode' : default_llmnr,
4259 'default DNS servers' : dns_servers.split(' '),
4260 'default NTP servers' : ntp_servers.split(' '),
4261 'default cgroup hierarchy' : default_hierarchy,
4262 'default net.naming-scheme value' : default_net_naming_scheme,
4263 'default KillUserProcesses value' : kill_user_processes,
4264 'default locale' : default_locale,
4265 'default nspawn locale' : nspawn_locale,
4266 'default status unit format' : status_unit_format_default,
4267 'default user $PATH' :
4268 default_user_path != '' ? default_user_path : '(same as system services)',
4269 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
4270 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
4273 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
4274 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
4275 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
4296 ['libcryptsetup-plugins'],
4322 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
4352 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
4366 ['legacy-pkla', install_polkit_pkla],
4371 ['man pages', want_man],
4372 ['html pages', want_html],
4373 ['man page indices', want_man and have_lxml],
4375 ['compat-mutable-uid-boundaries'],
4378 ['adm group', get_option('adm-group')],
4379 ['wheel group', get_option('wheel-group')],
4382 ['debug mmap cache'],
4384 ['valgrind', conf.get('VALGRIND') == 1],
4385 ['trace logging', conf.get('LOG_TRACE') == 1],
4386 ['install tests', install_tests],
4387 ['link-udev-shared', get_option('link-udev-shared')],
4388 ['link-systemctl-shared', get_option('link-systemctl-shared')],
4389 ['link-networkd-shared', get_option('link-networkd-shared')],
4390 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
4391 ['link-journalctl-shared', get_option('link-journalctl-shared')],
4392 ['link-boot-shared', get_option('link-boot-shared')],
4393 ['first-boot-full-preset'],
4395 ['standalone-binaries', get_option('standalone-binaries')],
4396 ['coverage', get_option('b_coverage')],
4399 if tuple.length() >= 2
4402 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
4403 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
4404 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
4413 if static_libsystemd == 'false'
4414 missing += 'static-libsystemd'
4416 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
4419 if static_libudev == 'false'
4420 missing += 'static-libudev'
4422 found += 'static-libudev(@0@)'.format(static_libudev)
4425 if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
4426 found += 'cryptolib(openssl)'
4427 elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
4428 found += 'cryptolib(gcrypt)'
4430 missing += 'cryptolib'
4433 if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
4434 found += 'DNS-over-TLS(gnutls)'
4435 elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
4436 found += 'DNS-over-TLS(openssl)'
4438 missing += 'DNS-over-TLS'
4442 'enabled' : ', '.join(found),
4443 'disabled' : ', '.join(missing)},
4444 section : 'Features')
4446 if rootprefixdir != rootprefix_default
4448 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
4449 'systemd used fixed names for unit file directories and other paths, so anything\n' +
4450 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))