1 # SPDX-License-Identifier: LGPL-2.1-or-later
3 project('systemd', 'c',
13 meson_version : '>= 0.53.2',
16 libsystemd_version = '0.35.0'
17 libudev_version = '1.7.5'
19 conf = configuration_data()
20 conf.set_quoted('PROJECT_URL', 'https://systemd.io/')
21 conf.set('PROJECT_VERSION', meson.project_version(),
22 description : 'Numerical project version (used where a simple number is expected)')
24 # This is to be used instead of meson.source_root(), as the latter will return
25 # the wrong result when systemd is being built as a meson subproject
26 project_source_root = meson.current_source_dir()
27 project_build_root = meson.current_build_dir()
28 relative_source_path = run_command('realpath',
29 '--relative-to=@0@'.format(project_build_root),
31 check : true).stdout().strip()
32 conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)
34 conf.set10('BUILD_MODE_DEVELOPER', get_option('mode') == 'developer',
35 description : 'tailor build to development or release builds')
36 verification = get_option('log-message-verification')
37 if verification == 'auto'
38 verification = conf.get('BUILD_MODE_DEVELOPER') == 1
40 verification = verification == 'true'
42 conf.set10('LOG_MESSAGE_VERIFICATION', verification)
44 want_ossfuzz = get_option('oss-fuzz')
45 want_libfuzzer = get_option('llvm-fuzz')
46 if want_ossfuzz and want_libfuzzer
47 error('only one of oss-fuzz or llvm-fuzz can be specified')
50 skip_deps = want_ossfuzz or get_option('skip-deps')
51 fuzzer_build = want_ossfuzz or want_libfuzzer
53 # If we're building *not* for actual fuzzing, allow input samples of any size
54 # (for testing and for reproduction of issues discovered with previously-higher
56 conf.set10('FUZZ_USE_SIZE_LIMIT', fuzzer_build)
58 # 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 '-fstrict-flex-arrays=1',
455 '-fvisibility=hidden',
456 '--param=ssp-buffer-size=4',
459 if get_option('buildtype') != 'debug'
460 possible_cc_flags += [
461 '-ffunction-sections',
465 possible_link_flags += '-Wl,--gc-sections'
468 if get_option('mode') == 'developer'
469 possible_cc_flags += '-fno-omit-frame-pointer'
472 add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
473 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
474 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
476 have = cc.has_argument('-Wzero-length-bounds')
477 conf.set10('HAVE_ZERO_LENGTH_BOUNDS', have)
481 #include <inttypes.h>
482 typedef uint64_t usec_t;
483 usec_t now(clockid_t clock);
488 ''', args: '-Werror=shadow', name : '-Werror=shadow with local shadowing')
489 add_project_arguments('-Werror=shadow', language : 'c')
493 add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
496 cpp = ' '.join(cc.cmd_array()) + ' -E'
498 has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
500 #####################################################################
501 # compilation result tests
503 conf.set('_GNU_SOURCE', true)
504 conf.set('__SANE_USERSPACE_TYPES__', true)
505 conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)
507 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
508 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
509 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
510 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
511 conf.set('SIZEOF_TIMEX_MEMBER', cc.sizeof('typeof(((struct timex *)0)->freq)', prefix : '#include <sys/timex.h>'))
513 long_max = cc.compute_int('LONG_MAX', prefix : '#include <limits.h>')
514 assert(long_max > 100000)
515 conf.set_quoted('LONG_MAX_STR', '@0@'.format(long_max))
519 #include <sys/mount.h>
520 #include <sys/stat.h>
523 foreach decl : ['char16_t',
529 # We get -1 if the size cannot be determined
530 have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
532 if decl == 'struct mount_attr'
534 want_linux_fs_h = false
536 have = cc.sizeof(decl,
537 prefix : decl_headers + '#include <linux/fs.h>',
538 args : '-D_GNU_SOURCE') > 0
539 want_linux_fs_h = have
543 if decl == 'struct statx'
545 want_linux_stat_h = false
547 have = cc.sizeof(decl,
548 prefix : decl_headers + '#include <linux/stat.h>',
549 args : '-D_GNU_SOURCE') > 0
550 want_linux_stat_h = have
554 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
557 conf.set10('WANT_LINUX_STAT_H', want_linux_stat_h)
558 conf.set10('WANT_LINUX_FS_H', want_linux_fs_h)
560 foreach ident : ['secure_getenv', '__secure_getenv']
561 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
565 ['memfd_create', '''#include <sys/mman.h>'''],
566 ['gettid', '''#include <sys/types.h>
567 #include <unistd.h>'''],
568 ['pivot_root', '''#include <stdlib.h>
569 #include <unistd.h>'''], # no known header declares pivot_root
570 ['ioprio_get', '''#include <sched.h>'''], # no known header declares ioprio_get
571 ['ioprio_set', '''#include <sched.h>'''], # no known header declares ioprio_set
572 ['name_to_handle_at', '''#include <sys/types.h>
573 #include <sys/stat.h>
574 #include <fcntl.h>'''],
575 ['setns', '''#include <sched.h>'''],
576 ['renameat2', '''#include <stdio.h>
577 #include <fcntl.h>'''],
578 ['kcmp', '''#include <linux/kcmp.h>'''],
579 ['keyctl', '''#include <sys/types.h>
580 #include <keyutils.h>'''],
581 ['copy_file_range', '''#include <sys/syscall.h>
582 #include <unistd.h>'''],
583 ['bpf', '''#include <sys/syscall.h>
584 #include <unistd.h>'''],
585 ['statx', '''#include <sys/types.h>
586 #include <sys/stat.h>
587 #include <unistd.h>'''],
588 ['explicit_bzero' , '''#include <string.h>'''],
589 ['reallocarray', '''#include <stdlib.h>'''],
590 ['set_mempolicy', '''#include <stdlib.h>
591 #include <unistd.h>'''],
592 ['get_mempolicy', '''#include <stdlib.h>
593 #include <unistd.h>'''],
594 ['pidfd_send_signal', '''#include <stdlib.h>
597 #include <sys/wait.h>'''],
598 ['pidfd_open', '''#include <stdlib.h>
601 #include <sys/wait.h>'''],
602 ['rt_sigqueueinfo', '''#include <stdlib.h>
605 #include <sys/wait.h>'''],
606 ['rt_tgsigqueueinfo', '''#include <stdlib.h>
609 #include <sys/wait.h>'''],
610 ['mallinfo', '''#include <malloc.h>'''],
611 ['mallinfo2', '''#include <malloc.h>'''],
612 ['execveat', '''#include <unistd.h>'''],
613 ['close_range', '''#include <unistd.h>'''],
614 ['epoll_pwait2', '''#include <sys/epoll.h>'''],
615 ['mount_setattr', '''#include <sys/mount.h>'''],
616 ['move_mount', '''#include <sys/mount.h>'''],
617 ['open_tree', '''#include <sys/mount.h>'''],
618 ['fsopen', '''#include <sys/mount.h>'''],
619 ['fsconfig', '''#include <sys/mount.h>'''],
620 ['getdents64', '''#include <dirent.h>'''],
623 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
624 conf.set10('HAVE_' + ident[0].to_upper(), have)
627 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
628 conf.set10('USE_SYS_RANDOM_H', true)
629 conf.set10('HAVE_GETRANDOM', true)
631 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
632 conf.set10('USE_SYS_RANDOM_H', false)
633 conf.set10('HAVE_GETRANDOM', have)
636 #####################################################################
638 version_tag = get_option('version-tag')
640 vcs_data = configuration_data()
641 vcs_data.set('VCS_TAG', version_tag)
642 version_h = configure_file(configuration : vcs_data,
643 input : 'src/version/version.h.in',
644 output : 'version.h')
647 project_source_root + '/tools/meson-vcs-tag.sh',
649 meson.project_version()]
652 input : 'src/version/version.h.in',
653 output : 'version.h',
657 versiondep = declare_dependency(sources: version_h)
659 shared_lib_tag = get_option('shared-lib-tag')
660 if shared_lib_tag == ''
661 shared_lib_tag = meson.project_version()
664 sh = find_program('sh')
665 echo = find_program('echo')
666 sed = find_program('sed')
667 awk = find_program('awk')
668 stat = find_program('stat')
669 ln = find_program('ln')
670 git = find_program('git', required : false)
671 env = find_program('env')
672 perl = find_program('perl', required : false)
673 rsync = find_program('rsync', required : false)
674 meson_make_symlink = project_source_root + '/tools/meson-make-symlink.sh'
676 mkdir_p = 'mkdir -p $DESTDIR/@0@'
678 # If -Dxxx-path option is found, use that. Otherwise, check in $PATH,
679 # /usr/sbin, /sbin, and fall back to the default from middle column.
680 progs = [['quotaon', '/usr/sbin/quotaon' ],
681 ['quotacheck', '/usr/sbin/quotacheck' ],
682 ['kmod', '/usr/bin/kmod' ],
683 ['kexec', '/usr/sbin/kexec' ],
684 ['sulogin', '/usr/sbin/sulogin' ],
685 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
686 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
687 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
688 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
689 ['nologin', '/usr/sbin/nologin', ],
692 path = get_option(prog[0] + '-path')
694 message('Using @1@ for @0@'.format(prog[0], path))
696 exe = find_program(prog[0],
697 '/usr/sbin/' + prog[0],
700 path = exe.found() ? exe.path() : prog[1]
702 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
703 conf.set_quoted(name, path)
706 conf.set_quoted('TELINIT', get_option('telinit-path'))
708 if run_command(ln, '--relative', '--help', check : false).returncode() != 0
709 error('ln does not support --relative (added in coreutils 8.16)')
712 ############################################################
714 python = find_program('python3')
715 if run_command(python, '-c', 'import jinja2', check : false).returncode() != 0
716 error('python3 jinja2 missing')
719 ############################################################
721 gperf = find_program('gperf')
723 gperf_test_format = '''
725 const char * in_word_set(const char *, @0@);
728 gperf_snippet = run_command(sh, '-c', 'echo foo,bar | "$1" -L ANSI-C', '_', gperf,
730 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
731 if cc.compiles(gperf_test)
732 gperf_len_type = 'size_t'
734 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
735 if cc.compiles(gperf_test)
736 gperf_len_type = 'unsigned'
738 error('unable to determine gperf len type')
741 message('gperf len type is @0@'.format(gperf_len_type))
742 conf.set('GPERF_LEN_TYPE', gperf_len_type,
743 description : 'The type of gperf "len" parameter')
745 ############################################################
747 if not cc.has_header('sys/capability.h')
748 error('POSIX caps headers not found')
750 foreach header : ['crypt.h',
752 'linux/vm_sockets.h',
754 'valgrind/memcheck.h',
755 'valgrind/valgrind.h',
756 'linux/time_types.h',
760 conf.set10('HAVE_' + header.underscorify().to_upper(),
761 cc.has_header(header))
764 ############################################################
766 fallback_hostname = get_option('fallback-hostname')
767 if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0] == '-'
768 error('Invalid fallback-hostname configuration')
769 # A more extensive test is done in test-hostname-util. Let's catch
770 # the most obvious errors here so we don't fail with an assert later.
772 conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
774 default_hierarchy = get_option('default-hierarchy')
775 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
776 description : 'default cgroup hierarchy as string')
777 if default_hierarchy == 'legacy'
778 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
779 elif default_hierarchy == 'hybrid'
780 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
782 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
785 extra_net_naming_schemes = []
786 extra_net_naming_map = []
787 foreach scheme: get_option('extra-net-naming-schemes').split(',')
789 name = scheme.split('=')[0]
790 value = scheme.split('=')[1]
791 NAME = name.underscorify().to_upper()
793 foreach field: value.split('+')
794 VALUE += 'NAMING_' + field.underscorify().to_upper()
796 extra_net_naming_schemes += 'NAMING_@0@ = @1@,'.format(NAME, '|'.join(VALUE))
797 extra_net_naming_map += '{ "@0@", NAMING_@1@ },'.format(name, NAME)
800 conf.set('EXTRA_NET_NAMING_SCHEMES', ' '.join(extra_net_naming_schemes))
801 conf.set('EXTRA_NET_NAMING_MAP', ' '.join(extra_net_naming_map))
803 default_net_naming_scheme = get_option('default-net-naming-scheme')
804 conf.set_quoted('DEFAULT_NET_NAMING_SCHEME', default_net_naming_scheme)
805 if default_net_naming_scheme != 'latest'
806 conf.set('_DEFAULT_NET_NAMING_SCHEME_TEST',
807 'NAMING_' + default_net_naming_scheme.underscorify().to_upper())
810 time_epoch = get_option('time-epoch')
812 time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check : true).stdout().strip()
813 if time_epoch == '' and git.found() and fs.exists('.git')
814 # If we're in a git repository, use the creation time of the latest git tag.
815 latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags',
817 if latest_tag.returncode() == 0
818 time_epoch = run_command(
819 git, 'log', '--no-show-signature', '-1', '--format=%at',
820 latest_tag.stdout().strip(),
821 check : false).stdout()
826 time_epoch = run_command(stat, '-c', '%Y', NEWS,
827 check : true).stdout()
829 time_epoch = time_epoch.strip().to_int()
831 conf.set('TIME_EPOCH', time_epoch)
833 conf.set('CLOCK_VALID_RANGE_USEC_MAX', get_option('clock-valid-range-usec-max'))
835 default_user_shell = get_option('default-user-shell')
836 conf.set_quoted('DEFAULT_USER_SHELL', default_user_shell)
837 conf.set_quoted('DEFAULT_USER_SHELL_NAME', fs.name(default_user_shell))
839 foreach tuple : [['system-alloc-uid-min', 'SYS_UID_MIN', 1], # Also see login.defs(5).
840 ['system-uid-max', 'SYS_UID_MAX', 999],
841 ['system-alloc-gid-min', 'SYS_GID_MIN', 1],
842 ['system-gid-max', 'SYS_GID_MAX', 999]]
843 v = get_option(tuple[0])
847 '/^\s*@0@\s+/ { uid=$2 } END { print uid }'.format(tuple[1]),
849 check : false).stdout().strip()
856 conf.set(tuple[0].underscorify().to_upper(), v)
858 if conf.get('SYSTEM_ALLOC_UID_MIN') >= conf.get('SYSTEM_UID_MAX')
859 error('Invalid uid allocation range')
861 if conf.get('SYSTEM_ALLOC_GID_MIN') >= conf.get('SYSTEM_GID_MAX')
862 error('Invalid gid allocation range')
865 dynamic_uid_min = get_option('dynamic-uid-min')
866 dynamic_uid_max = get_option('dynamic-uid-max')
867 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
868 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
870 container_uid_base_min = get_option('container-uid-base-min')
871 container_uid_base_max = get_option('container-uid-base-max')
872 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
873 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
875 nobody_user = get_option('nobody-user')
876 nobody_group = get_option('nobody-group')
878 if not meson.is_cross_build()
879 getent_result = run_command('getent', 'passwd', '65534', check : false)
880 if getent_result.returncode() == 0
881 name = getent_result.stdout().split(':')[0]
882 if name != nobody_user
884 '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) +
885 'Your build will result in an user table setup that is incompatible with the local system.')
888 id_result = run_command('id', '-u', nobody_user, check : false)
889 if id_result.returncode() == 0
890 id = id_result.stdout().strip().to_int()
893 '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) +
894 'Your build will result in an user table setup that is incompatible with the local system.')
898 getent_result = run_command('getent', 'group', '65534', check : false)
899 if getent_result.returncode() == 0
900 name = getent_result.stdout().split(':')[0]
901 if name != nobody_group
903 '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) +
904 'Your build will result in an group table setup that is incompatible with the local system.')
907 id_result = run_command('id', '-g', nobody_group, check : false)
908 if id_result.returncode() == 0
909 id = id_result.stdout().strip().to_int()
912 '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) +
913 'Your build will result in an group table setup that is incompatible with the local system.')
917 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
919 'The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
920 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
923 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
924 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
927 foreach option : ['adm-gid',
944 'systemd-journal-gid',
945 'systemd-network-uid',
946 'systemd-resolve-uid',
947 'systemd-timesync-uid']
948 name = option.underscorify().to_upper()
949 val = get_option(option)
951 # Ensure provided GID argument is numeric, otherwise fall back to default assignment
952 conf.set(name, val > 0 ? val : '-')
954 static_ugids += '@0@:@1@'.format(option, val)
958 conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
959 conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
961 dev_kvm_mode = get_option('dev-kvm-mode')
962 conf.set_quoted('DEV_KVM_MODE', dev_kvm_mode) # FIXME: convert to 0o… notation
963 conf.set10('DEV_KVM_UACCESS', dev_kvm_mode != '0666')
964 group_render_mode = get_option('group-render-mode')
965 conf.set_quoted('GROUP_RENDER_MODE', group_render_mode)
966 conf.set10('GROUP_RENDER_UACCESS', group_render_mode != '0666')
968 kill_user_processes = get_option('default-kill-user-processes')
969 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
971 dns_servers = get_option('dns-servers')
972 conf.set_quoted('DNS_SERVERS', dns_servers)
974 ntp_servers = get_option('ntp-servers')
975 conf.set_quoted('NTP_SERVERS', ntp_servers)
977 default_locale = get_option('default-locale')
978 conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale)
980 nspawn_locale = get_option('nspawn-locale')
981 conf.set_quoted('SYSTEMD_NSPAWN_LOCALE', nspawn_locale)
983 localegen_path = get_option('localegen-path')
984 if localegen_path != ''
985 conf.set_quoted('LOCALEGEN_PATH', localegen_path)
987 conf.set10('HAVE_LOCALEGEN', localegen_path != '')
989 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
991 service_watchdog = get_option('service-watchdog')
992 watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
993 conf.set_quoted('SERVICE_WATCHDOG', watchdog_value)
995 conf.set_quoted('SUSHELL', get_option('debug-shell'))
996 conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
998 enable_debug_hashmap = false
999 enable_debug_mmap_cache = false
1000 enable_debug_siphash = false
1001 foreach name : get_option('debug-extra')
1002 if name == 'hashmap'
1003 enable_debug_hashmap = true
1004 elif name == 'mmap-cache'
1005 enable_debug_mmap_cache = true
1006 elif name == 'siphash'
1007 enable_debug_siphash = true
1009 message('unknown debug option "@0@", ignoring'.format(name))
1012 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
1013 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
1014 conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash)
1016 conf.set10('VALGRIND', get_option('valgrind'))
1017 conf.set10('LOG_TRACE', get_option('log-trace'))
1019 default_user_path = get_option('user-path')
1020 if default_user_path != ''
1021 conf.set_quoted('DEFAULT_USER_PATH', default_user_path)
1025 #####################################################################
1027 threads = dependency('threads')
1028 librt = cc.find_library('rt')
1029 libm = cc.find_library('m')
1030 libdl = cc.find_library('dl')
1031 libcrypt = cc.find_library('crypt')
1033 # On some architectures, libatomic is required. But on some installations,
1034 # it is found, but actual linking fails. So let's try to use it opportunistically.
1035 # If it is installed, but not needed, it will be dropped because of --as-needed.
1036 if cc.links('''int main(int argc, char **argv) { return 0; }''',
1039 libatomic = declare_dependency(link_args : '-latomic')
1044 crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
1046 ['crypt_ra', crypt_header],
1047 ['crypt_preferred_method', crypt_header],
1048 ['crypt_gensalt_ra', crypt_header]]
1050 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
1051 dependencies : libcrypt)
1052 conf.set10('HAVE_' + ident[0].to_upper(), have)
1055 libcap = dependency('libcap', required : false)
1056 if not libcap.found()
1057 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
1058 libcap = cc.find_library('cap')
1061 want_bpf_framework = get_option('bpf-framework')
1062 bpf_compiler = get_option('bpf-compiler')
1063 bpf_framework_required = want_bpf_framework == 'true'
1065 libbpf_version_requirement = '>= 0.1.0'
1066 if bpf_compiler == 'gcc'
1067 libbpf_version_requirement = '>= 1.0.0'
1069 libbpf = dependency('libbpf', required : bpf_framework_required, version : libbpf_version_requirement)
1070 conf.set10('HAVE_LIBBPF', libbpf.found())
1072 bpftool_strip_version_requirement = '>= 5.13.0'
1073 if bpf_compiler == 'gcc'
1074 bpftool_strip_version_requirement = '>= 7.0.0'
1077 if want_bpf_framework == 'false' or not libbpf.found() or skip_deps
1078 conf.set10('BPF_FRAMEWORK', false)
1081 clang_supports_bpf = false
1082 bpf_gcc_found = false
1083 bpftool_strip = false
1086 if bpf_compiler == 'clang'
1087 # Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu
1088 # (like clang-10/llvm-strip-10)
1089 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')
1090 r = find_program('clang', required : bpf_framework_required, version : '>= 10.0.0')
1091 clang_found = r.found()
1095 # Assume that the required flags are supported by the found clang.
1096 clang_supports_flags = clang_found
1099 clang = cc.cmd_array()
1100 clang_supports_flags = cc.has_argument('-Wno-compare-distinct-pointer-types')
1104 # Check if 'clang -target bpf' is supported.
1105 clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0
1107 elif bpf_compiler == 'gcc'
1108 warning('GCC BPF Compiler support is experimental and not recommended.')
1109 bpf_gcc = find_program('bpf-gcc',
1111 version : '>= 12.1.0')
1112 bpf_gcc_found = bpf_gcc.found()
1115 if clang_supports_bpf or bpf_gcc_found
1116 # Debian installs this in /usr/sbin/ which is not in $PATH.
1117 # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian.
1118 # We use 'bpftool gen object' subcommand for bpftool strip, it was added by d80b2fcbe0a023619e0fc73112f2a02c2662f6ab (v5.13).
1119 bpftool_strip_required = bpf_framework_required and bpf_compiler == 'gcc'
1120 bpftool = find_program('bpftool',
1121 '/usr/sbin/bpftool',
1122 required : bpftool_strip_required,
1123 version : bpftool_strip_version_requirement)
1126 bpftool_strip = true
1128 elif bpf_compiler == 'clang'
1129 # We require the 'bpftool gen skeleton' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6).
1130 bpftool = find_program('bpftool',
1131 '/usr/sbin/bpftool',
1132 required : bpf_framework_required,
1133 version : '>= 5.6.0')
1136 # We use `llvm-strip` as a fallback if `bpftool gen object` strip support is not available.
1137 if not bpftool_strip and bpftool.found() and clang_supports_bpf
1138 if not meson.is_cross_build()
1139 llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip',
1140 check : true).stdout().strip()
1142 llvm_strip_bin = 'llvm-strip'
1144 llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0')
1145 deps_found = llvm_strip.found()
1149 # Can build BPF program from source code in restricted C
1150 conf.set10('BPF_FRAMEWORK', deps_found)
1153 libmount = dependency('mount',
1154 version : fuzzer_build ? '>= 0' : '>= 2.30')
1156 want_libfdisk = get_option('fdisk')
1157 if want_libfdisk != 'false' and not skip_deps
1158 libfdisk = dependency('fdisk',
1159 version : '>= 2.32',
1160 required : want_libfdisk == 'true')
1161 have = libfdisk.found()
1166 conf.set10('HAVE_LIBFDISK', have)
1168 want_pwquality = get_option('pwquality')
1169 if want_pwquality != 'false' and not skip_deps
1170 libpwquality = dependency('pwquality', required : want_pwquality == 'true')
1171 have = libpwquality.found()
1176 conf.set10('HAVE_PWQUALITY', have)
1178 want_seccomp = get_option('seccomp')
1179 if want_seccomp != 'false' and not skip_deps
1180 libseccomp = dependency('libseccomp',
1181 version : '>= 2.3.1',
1182 required : want_seccomp == 'true')
1183 have = libseccomp.found()
1188 conf.set10('HAVE_SECCOMP', have)
1190 want_selinux = get_option('selinux')
1191 if want_selinux != 'false' and not skip_deps
1192 libselinux = dependency('libselinux',
1193 version : '>= 2.1.9',
1194 required : want_selinux == 'true')
1195 have = libselinux.found()
1200 conf.set10('HAVE_SELINUX', have)
1202 want_apparmor = get_option('apparmor')
1203 if want_apparmor != 'false' and not skip_deps
1204 libapparmor = dependency('libapparmor',
1205 version : '>= 2.13',
1206 required : want_apparmor == 'true')
1207 have = libapparmor.found()
1212 conf.set10('HAVE_APPARMOR', have)
1214 have = get_option('smack') and get_option('smack-run-label') != ''
1215 conf.set10('HAVE_SMACK_RUN_LABEL', have)
1217 conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
1220 have = get_option('smack') and get_option('smack-default-process-label') != ''
1222 conf.set_quoted('SMACK_DEFAULT_PROCESS_LABEL', get_option('smack-default-process-label'))
1225 want_polkit = get_option('polkit')
1226 install_polkit = false
1227 install_polkit_pkla = false
1228 if want_polkit != 'false' and not skip_deps
1229 install_polkit = true
1231 libpolkit = dependency('polkit-gobject-1',
1233 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
1234 message('Old polkit detected, will install pkla files')
1235 install_polkit_pkla = true
1238 conf.set10('ENABLE_POLKIT', install_polkit)
1240 want_acl = get_option('acl')
1241 if want_acl != 'false' and not skip_deps
1242 libacl = cc.find_library('acl', required : want_acl == 'true')
1243 have = libacl.found()
1248 conf.set10('HAVE_ACL', have)
1250 want_audit = get_option('audit')
1251 if want_audit != 'false' and not skip_deps
1252 libaudit = dependency('audit', required : want_audit == 'true')
1253 have = libaudit.found()
1258 conf.set10('HAVE_AUDIT', have)
1260 want_blkid = get_option('blkid')
1261 if want_blkid != 'false' and not skip_deps
1262 libblkid = dependency('blkid', required : want_blkid == 'true')
1263 have = libblkid.found()
1265 conf.set10('HAVE_BLKID_PROBE_SET_HINT',
1266 have and cc.has_function('blkid_probe_set_hint', dependencies : libblkid))
1271 conf.set10('HAVE_BLKID', have)
1273 want_kmod = get_option('kmod')
1274 if want_kmod != 'false' and not skip_deps
1275 libkmod = dependency('libkmod',
1277 required : want_kmod == 'true')
1278 have = libkmod.found()
1283 conf.set10('HAVE_KMOD', have)
1285 want_xenctrl = get_option('xenctrl')
1286 if want_xenctrl != 'false' and not skip_deps
1287 libxenctrl = dependency('xencontrol',
1289 required : want_xenctrl == 'true')
1290 have = libxenctrl.found()
1295 conf.set10('HAVE_XENCTRL', have)
1297 want_pam = get_option('pam')
1298 if want_pam != 'false' and not skip_deps
1299 libpam = cc.find_library('pam', required : want_pam == 'true')
1300 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1301 have = libpam.found() and libpam_misc.found()
1307 conf.set10('HAVE_PAM', have)
1309 want_microhttpd = get_option('microhttpd')
1310 if want_microhttpd != 'false' and not skip_deps
1311 libmicrohttpd = dependency('libmicrohttpd',
1312 version : '>= 0.9.33',
1313 required : want_microhttpd == 'true')
1314 have = libmicrohttpd.found()
1319 conf.set10('HAVE_MICROHTTPD', have)
1321 want_libcryptsetup = get_option('libcryptsetup')
1322 want_libcryptsetup_plugins = get_option('libcryptsetup-plugins')
1324 if want_libcryptsetup_plugins == 'true' and want_libcryptsetup == 'false'
1325 error('libcryptsetup-plugins can not be requested without libcryptsetup')
1328 if want_libcryptsetup != 'false' and not skip_deps
1329 libcryptsetup = dependency('libcryptsetup',
1330 version : want_libcryptsetup_plugins == 'true' ? '>= 2.4.0' : '>= 2.0.1',
1331 required : want_libcryptsetup == 'true' or want_libcryptsetup_plugins == 'true')
1332 have = libcryptsetup.found()
1334 foreach ident : ['crypt_set_metadata_size',
1335 'crypt_activate_by_signed_key',
1337 'crypt_reencrypt_init_by_passphrase',
1339 'crypt_set_data_offset']
1340 have_ident = have and cc.has_function(
1342 prefix : '#include <libcryptsetup.h>',
1343 dependencies : libcryptsetup)
1344 conf.set10('HAVE_' + ident.to_upper(), have_ident)
1350 conf.set10('HAVE_LIBCRYPTSETUP', have)
1352 if want_libcryptsetup_plugins != 'false' and not skip_deps
1353 have = (cc.has_function(
1354 'crypt_activate_by_token_pin',
1355 prefix : '#include <libcryptsetup.h>',
1356 dependencies : libcryptsetup) and
1358 'crypt_token_external_path',
1359 prefix : '#include <libcryptsetup.h>',
1360 dependencies : libcryptsetup))
1364 conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have)
1366 want_libcurl = get_option('libcurl')
1367 if want_libcurl != 'false' and not skip_deps
1368 libcurl = dependency('libcurl',
1369 version : '>= 7.32.0',
1370 required : want_libcurl == 'true')
1371 have = libcurl.found()
1376 conf.set10('HAVE_LIBCURL', have)
1377 conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
1379 want_libidn = get_option('libidn')
1380 want_libidn2 = get_option('libidn2')
1381 if want_libidn == 'true' and want_libidn2 == 'true'
1382 error('libidn and libidn2 cannot be requested simultaneously')
1385 if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps
1386 libidn = dependency('libidn2',
1387 required : want_libidn2 == 'true')
1388 have = libidn.found()
1393 conf.set10('HAVE_LIBIDN2', have)
1394 if not have and want_libidn != 'false' and not skip_deps
1395 # libidn is used for both libidn and libidn2 objects
1396 libidn = dependency('libidn',
1397 required : want_libidn == 'true')
1398 have = libidn.found()
1402 conf.set10('HAVE_LIBIDN', have)
1404 want_libiptc = get_option('libiptc')
1405 if want_libiptc != 'false' and not skip_deps
1406 libiptc = dependency('libiptc',
1407 required : want_libiptc == 'true')
1408 have = libiptc.found()
1413 conf.set10('HAVE_LIBIPTC', have)
1415 want_qrencode = get_option('qrencode')
1416 if want_qrencode != 'false' and not skip_deps
1417 libqrencode = dependency('libqrencode',
1419 required : want_qrencode == 'true')
1420 have = libqrencode.found()
1425 conf.set10('HAVE_QRENCODE', have)
1427 want_gcrypt = get_option('gcrypt')
1428 if want_gcrypt != 'false' and not skip_deps
1429 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1430 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1431 have = libgcrypt.found() and libgpg_error.found()
1436 # link to neither of the libs if one is not found
1440 conf.set10('HAVE_GCRYPT', have)
1442 want_gnutls = get_option('gnutls')
1443 if want_gnutls != 'false' and not skip_deps
1444 libgnutls = dependency('gnutls',
1445 version : '>= 3.1.4',
1446 required : want_gnutls == 'true')
1447 have = libgnutls.found()
1452 conf.set10('HAVE_GNUTLS', have)
1454 want_openssl = get_option('openssl')
1455 if want_openssl != 'false' and not skip_deps
1456 libopenssl = dependency('openssl',
1457 version : '>= 1.1.0',
1458 required : want_openssl == 'true')
1459 have = libopenssl.found()
1464 conf.set10('HAVE_OPENSSL', have)
1466 want_p11kit = get_option('p11kit')
1467 if want_p11kit != 'false' and not skip_deps
1468 libp11kit = dependency('p11-kit-1',
1469 version : '>= 0.23.3',
1470 required : want_p11kit == 'true')
1471 have = libp11kit.found()
1476 conf.set10('HAVE_P11KIT', have)
1478 want_libfido2 = get_option('libfido2')
1479 if want_libfido2 != 'false' and not skip_deps
1480 if conf.get('HAVE_OPENSSL') == 1
1481 libfido2 = dependency('libfido2',
1482 required : want_libfido2 == 'true')
1483 have = libfido2.found()
1484 elif want_libfido2 == 'true'
1485 error('libfido2=true requires openssl')
1494 conf.set10('HAVE_LIBFIDO2', have)
1496 want_tpm2 = get_option('tpm2')
1497 if want_tpm2 != 'false' and not skip_deps
1498 tpm2 = dependency('tss2-esys tss2-rc tss2-mu',
1499 required : want_tpm2 == 'true')
1501 have_esys3 = tpm2.version().version_compare('>= 3.0.0')
1507 conf.set10('HAVE_TPM2', have)
1508 conf.set10('HAVE_TSS2_ESYS3', have_esys3)
1510 want_elfutils = get_option('elfutils')
1511 if want_elfutils != 'false' and not skip_deps
1512 libdw = dependency('libdw',
1513 required : want_elfutils == 'true')
1514 have = libdw.found()
1516 # New in elfutils 0.177
1517 conf.set10('HAVE_DWELF_ELF_E_MACHINE_STRING',
1518 have and cc.has_function('dwelf_elf_e_machine_string', dependencies : libdw))
1523 conf.set10('HAVE_ELFUTILS', have)
1525 want_zlib = get_option('zlib')
1526 if want_zlib != 'false' and not skip_deps
1527 libz = dependency('zlib',
1528 required : want_zlib == 'true')
1534 conf.set10('HAVE_ZLIB', have)
1536 want_bzip2 = get_option('bzip2')
1537 if want_bzip2 != 'false' and not skip_deps
1538 libbzip2 = cc.find_library('bz2',
1539 required : want_bzip2 == 'true')
1540 have = libbzip2.found()
1545 conf.set10('HAVE_BZIP2', have)
1547 want_xz = get_option('xz')
1548 if want_xz != 'false' and not skip_deps
1549 libxz = dependency('liblzma',
1550 required : want_xz == 'true')
1551 have_xz = libxz.found()
1556 conf.set10('HAVE_XZ', have_xz)
1558 want_lz4 = get_option('lz4')
1559 if want_lz4 != 'false' and not skip_deps
1560 liblz4 = dependency('liblz4',
1561 version : '>= 1.3.0',
1562 required : want_lz4 == 'true')
1563 have_lz4 = liblz4.found()
1568 conf.set10('HAVE_LZ4', have_lz4)
1570 want_zstd = get_option('zstd')
1571 if want_zstd != 'false' and not skip_deps
1572 libzstd = dependency('libzstd',
1573 required : want_zstd == 'true',
1574 version : '>= 1.4.0')
1575 have_zstd = libzstd.found()
1580 conf.set10('HAVE_ZSTD', have_zstd)
1582 conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
1584 compression = get_option('default-compression')
1585 if compression == 'auto'
1587 compression = 'zstd'
1593 compression = 'none'
1595 elif compression == 'zstd' and not have_zstd
1596 error('default-compression=zstd requires zstd')
1597 elif compression == 'lz4' and not have_lz4
1598 error('default-compression=lz4 requires lz4')
1599 elif compression == 'xz' and not have_xz
1600 error('default-compression=xz requires xz')
1602 conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper()))
1604 want_xkbcommon = get_option('xkbcommon')
1605 if want_xkbcommon != 'false' and not skip_deps
1606 libxkbcommon = dependency('xkbcommon',
1607 version : '>= 0.3.0',
1608 required : want_xkbcommon == 'true')
1609 have = libxkbcommon.found()
1614 conf.set10('HAVE_XKBCOMMON', have)
1616 want_pcre2 = get_option('pcre2')
1617 if want_pcre2 != 'false' and not skip_deps
1618 libpcre2 = dependency('libpcre2-8',
1619 required : want_pcre2 == 'true')
1620 have = libpcre2.found()
1625 conf.set10('HAVE_PCRE2', have)
1627 want_glib = get_option('glib')
1628 if want_glib != 'false' and not skip_deps
1629 libglib = dependency('glib-2.0',
1630 version : '>= 2.22.0',
1631 required : want_glib == 'true')
1632 libgobject = dependency('gobject-2.0',
1633 version : '>= 2.22.0',
1634 required : want_glib == 'true')
1635 libgio = dependency('gio-2.0',
1636 required : want_glib == 'true')
1637 have = libglib.found() and libgobject.found() and libgio.found()
1644 conf.set10('HAVE_GLIB', have)
1646 want_dbus = get_option('dbus')
1647 if want_dbus != 'false' and not skip_deps
1648 libdbus = dependency('dbus-1',
1649 version : '>= 1.3.2',
1650 required : want_dbus == 'true')
1651 have = libdbus.found()
1656 conf.set10('HAVE_DBUS', have)
1658 dbusdatadir = datadir / 'dbus-1'
1659 if conf.get('HAVE_DBUS') == 1
1660 dbusdatadir = libdbus.get_variable(pkgconfig: 'datadir', default_value: datadir) / 'dbus-1'
1663 dbuspolicydir = get_option('dbuspolicydir')
1664 if dbuspolicydir == ''
1665 dbuspolicydir = dbusdatadir / 'system.d'
1668 dbussessionservicedir = get_option('dbussessionservicedir')
1669 if dbussessionservicedir == ''
1670 dbussessionservicedir = dbusdatadir / 'services'
1671 if conf.get('HAVE_DBUS') == 1
1672 dbussessionservicedir = libdbus.get_variable(pkgconfig: 'session_bus_services_dir', default_value: dbussessionservicedir)
1676 dbussystemservicedir = get_option('dbussystemservicedir')
1677 if dbussystemservicedir == ''
1678 dbussystemservicedir = dbusdatadir / 'system-services'
1679 if conf.get('HAVE_DBUS') == 1
1680 dbussystemservicedir = libdbus.get_variable(pkgconfig: 'system_bus_services_dir', default_value: dbussystemservicedir)
1684 dbus_interfaces_dir = get_option('dbus-interfaces-dir')
1685 if dbus_interfaces_dir == '' or dbus_interfaces_dir == 'yes'
1686 if meson.is_cross_build() and dbus_interfaces_dir != 'yes'
1687 dbus_interfaces_dir = 'no'
1688 warning('Exporting D-Bus interface XML files is disabled during cross build. Pass path or "yes" to force enable.')
1690 dbus_interfaces_dir = dbusdatadir / 'interfaces'
1691 if conf.get('HAVE_DBUS') == 1
1692 dbus_interfaces_dir = libdbus.get_variable(pkgconfig: 'interfaces_dir', default_value: dbus_interfaces_dir)
1697 # We support one or the other. If gcrypt is available, we assume it's there to
1698 # be used, and use it in preference.
1699 opt = get_option('cryptolib')
1700 if opt == 'openssl' and conf.get('HAVE_OPENSSL') == 0
1701 error('openssl requested as the default cryptolib, but not available')
1703 conf.set10('PREFER_OPENSSL',
1704 opt == 'openssl' or (opt == 'auto' and conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_GCRYPT') == 0))
1705 conf.set10('HAVE_OPENSSL_OR_GCRYPT',
1706 conf.get('HAVE_OPENSSL') == 1 or conf.get('HAVE_GCRYPT') == 1)
1707 lib_openssl_or_gcrypt = conf.get('PREFER_OPENSSL') == 1 ? [libopenssl] : [libgcrypt, libgpg_error]
1709 dns_over_tls = get_option('dns-over-tls')
1710 if dns_over_tls != 'false'
1711 if dns_over_tls == 'gnutls' and conf.get('PREFER_OPENSSL') == 1
1712 error('Sorry, -Ddns-over-tls=gnutls is not supported when openssl is used as the cryptolib')
1715 if dns_over_tls == 'gnutls'
1716 have_openssl = false
1718 have_openssl = conf.get('HAVE_OPENSSL') == 1
1719 if dns_over_tls == 'openssl' and not have_openssl
1720 error('DNS-over-TLS support was requested with openssl, but dependencies are not available')
1723 if dns_over_tls == 'openssl' or have_openssl
1726 have_gnutls = conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0')
1727 if dns_over_tls != 'auto' and not have_gnutls
1728 str = dns_over_tls == 'gnutls' ? ' with gnutls' : ''
1729 error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
1732 have = have_gnutls or have_openssl
1736 have_openssl = false
1738 conf.set10('ENABLE_DNS_OVER_TLS', have)
1739 conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1740 conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
1742 default_dns_over_tls = get_option('default-dns-over-tls')
1744 default_dns_over_tls = 'no'
1746 if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
1747 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.')
1748 default_dns_over_tls = 'no'
1750 conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1751 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
1752 conf.set_quoted('DEFAULT_DNS_OVER_TLS_MODE_STR', default_dns_over_tls)
1754 default_mdns = get_option('default-mdns')
1755 conf.set('DEFAULT_MDNS_MODE',
1756 'RESOLVE_SUPPORT_' + default_mdns.to_upper())
1757 conf.set_quoted('DEFAULT_MDNS_MODE_STR', default_mdns)
1759 default_llmnr = get_option('default-llmnr')
1760 conf.set('DEFAULT_LLMNR_MODE',
1761 'RESOLVE_SUPPORT_' + default_llmnr.to_upper())
1762 conf.set_quoted('DEFAULT_LLMNR_MODE_STR', default_llmnr)
1764 want_repart = get_option('repart')
1765 if want_repart != 'false'
1766 have = conf.get('HAVE_LIBFDISK') == 1
1767 if want_repart == 'true' and not have
1768 error('repart support was requested, but dependencies are not available')
1773 conf.set10('ENABLE_REPART', have)
1775 default_dnssec = get_option('default-dnssec')
1777 default_dnssec = 'no'
1779 if default_dnssec != 'no' and conf.get('HAVE_OPENSSL_OR_GCRYPT') == 0
1780 message('default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.')
1781 default_dnssec = 'no'
1783 conf.set('DEFAULT_DNSSEC_MODE',
1784 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1785 conf.set_quoted('DEFAULT_DNSSEC_MODE_STR', default_dnssec)
1787 want_sysupdate = get_option('sysupdate')
1788 if want_sysupdate != 'false'
1789 have = (conf.get('HAVE_OPENSSL') == 1 and
1790 conf.get('HAVE_LIBFDISK') == 1)
1791 if want_sysupdate == 'true' and not have
1792 error('sysupdate support was requested, but dependencies are not available')
1797 conf.set10('ENABLE_SYSUPDATE', have)
1799 want_importd = get_option('importd')
1800 if want_importd != 'false'
1801 have = (conf.get('HAVE_LIBCURL') == 1 and
1802 conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and
1803 conf.get('HAVE_ZLIB') == 1 and
1804 conf.get('HAVE_XZ') == 1)
1805 if want_importd == 'true' and not have
1806 error('importd support was requested, but dependencies are not available')
1811 conf.set10('ENABLE_IMPORTD', have)
1813 want_kernel_install = get_option('kernel-install')
1814 conf.set10('ENABLE_KERNEL_INSTALL', want_kernel_install)
1816 want_homed = get_option('homed')
1817 if want_homed != 'false'
1818 have = (conf.get('HAVE_OPENSSL') == 1 and
1819 conf.get('HAVE_LIBFDISK') == 1 and
1820 conf.get('HAVE_LIBCRYPTSETUP') == 1)
1821 if want_homed == 'true' and not have
1822 error('homed support was requested, but dependencies are not available')
1827 conf.set10('ENABLE_HOMED', have)
1829 have = have and conf.get('HAVE_PAM') == 1
1830 conf.set10('ENABLE_PAM_HOME', have)
1832 have = get_option('oomd')
1833 conf.set10('ENABLE_OOMD', have)
1835 want_remote = get_option('remote')
1836 if want_remote != 'false'
1837 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1838 conf.get('HAVE_LIBCURL') == 1]
1839 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1840 # it's possible to build one without the other. Complain only if
1841 # support was explicitly requested. The auxiliary files like sysusers
1842 # config should be installed when any of the programs are built.
1843 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1844 error('remote support was requested, but dependencies are not available')
1846 have = have_deps[0] or have_deps[1]
1850 conf.set10('ENABLE_REMOTE', have)
1852 foreach term : ['analyze',
1866 'compat-mutable-uid-boundaries',
1892 have = get_option(term)
1893 name = 'ENABLE_' + term.underscorify().to_upper()
1894 conf.set10(name, have)
1897 enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
1899 foreach tuple : [['nss-mymachines', 'machined'],
1900 ['nss-resolve', 'resolve']]
1901 want = get_option(tuple[0])
1903 have = get_option(tuple[1])
1904 if want == 'true' and not have
1905 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1910 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1911 conf.set10(name, have)
1915 foreach term : ['ENABLE_NSS_MYHOSTNAME',
1916 'ENABLE_NSS_MYMACHINES',
1917 'ENABLE_NSS_RESOLVE',
1918 'ENABLE_NSS_SYSTEMD']
1919 if conf.get(term) == 1
1923 conf.set10('ENABLE_NSS', enable_nss)
1925 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1927 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1929 ############################################################
1935 ############################################################
1937 # Include these now as they provide gnu-efi detection.
1938 subdir('src/fundamental')
1939 subdir('src/boot/efi')
1941 ############################################################
1943 generate_gperfs = find_program('tools/generate-gperfs.py')
1944 make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
1945 make_directive_index_py = find_program('tools/make-directive-index.py')
1946 make_man_index_py = find_program('tools/make-man-index.py')
1947 meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
1948 update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
1949 update_man_rules_py = find_program('tools/update-man-rules.py')
1950 update_hwdb_sh = find_program('tools/update-hwdb.sh')
1951 update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
1952 update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
1953 xml_helper_py = find_program('tools/xml_helper.py')
1954 export_dbus_interfaces_py = find_program('tools/dbus_exporter.py')
1956 ############################################################
1958 if get_option('b_coverage')
1959 add_project_arguments('-include', 'src/basic/coverage.h', language : 'c')
1962 ############################################################
1964 config_h = configure_file(
1965 output : 'config.h',
1966 configuration : conf)
1968 add_project_arguments('-include', 'config.h', language : 'c')
1970 jinja2_cmdline = [meson_render_jinja2, config_h, version_h]
1972 ############################################################
1974 # binaries that have --help and are intended for use by humans,
1975 # usually, but not always, installed in /bin.
1976 public_programs = []
1978 # D-Bus introspection XML export
1981 basic_includes = include_directories(
1987 libsystemd_includes = [basic_includes, include_directories(
1988 'src/libsystemd/sd-bus',
1989 'src/libsystemd/sd-device',
1990 'src/libsystemd/sd-event',
1991 'src/libsystemd/sd-hwdb',
1992 'src/libsystemd/sd-id128',
1993 'src/libsystemd/sd-journal',
1994 'src/libsystemd/sd-netlink',
1995 'src/libsystemd/sd-network',
1996 'src/libsystemd/sd-resolve')]
1998 includes = [libsystemd_includes, include_directories('src/shared')]
2003 subdir('src/libsystemd')
2004 subdir('src/shared')
2006 subdir('src/libudev')
2007 subdir('src/cryptsetup/cryptsetup-tokens')
2009 alias_target('devel', libsystemd_pc, libudev_pc)
2011 libsystemd = shared_library(
2013 version : libsystemd_version,
2014 include_directories : libsystemd_includes,
2015 link_args : ['-shared',
2016 '-Wl,--version-script=' + libsystemd_sym_path],
2017 link_with : [libbasic,
2020 link_whole : [libsystemd_static],
2021 dependencies : [threads,
2023 link_depends : libsystemd_sym,
2025 install_tag: 'libsystemd',
2026 install_dir : rootlibdir)
2028 alias_target('libsystemd', libsystemd)
2030 install_libsystemd_static = static_library(
2034 basic_gcrypt_sources,
2035 basic_compress_sources,
2036 fundamental_sources,
2037 include_directories : libsystemd_includes,
2038 build_by_default : static_libsystemd != 'false',
2039 install : static_libsystemd != 'false',
2040 install_tag: 'libsystemd',
2041 install_dir : rootlibdir,
2042 pic : static_libsystemd_pic,
2043 dependencies : [threads,
2055 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
2057 libudev = shared_library(
2059 version : libudev_version,
2060 include_directories : includes,
2061 link_args : ['-shared',
2062 '-Wl,--version-script=' + libudev_sym_path],
2063 link_with : [libsystemd_static, libshared_static],
2064 link_whole : libudev_basic,
2065 dependencies : [threads],
2066 link_depends : libudev_sym,
2068 install_tag: 'libudev',
2069 install_dir : rootlibdir)
2071 alias_target('libudev', libudev)
2073 install_libudev_static = static_library(
2076 fundamental_sources,
2080 include_directories : includes,
2081 build_by_default : static_libudev != 'false',
2082 install : static_libudev != 'false',
2083 install_tag: 'libudev',
2084 install_dir : rootlibdir,
2085 link_depends : libudev_sym,
2086 dependencies : [libshared_deps,
2089 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
2090 pic : static_libudev_pic)
2092 if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
2093 if conf.get('HAVE_TPM2') == 1
2094 cryptsetup_token_systemd_tpm2 = shared_library(
2095 'cryptsetup-token-systemd-tpm2',
2096 cryptsetup_token_systemd_tpm2_sources,
2097 include_directories : includes,
2098 link_args : ['-shared',
2099 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2100 link_with : [lib_cryptsetup_token_common,
2102 dependencies : [libcryptsetup,
2105 link_depends : cryptsetup_token_sym,
2106 install_rpath : rootpkglibdir,
2108 install_dir : libcryptsetup_plugins_dir)
2111 if conf.get('HAVE_LIBFIDO2') == 1
2112 cryptsetup_token_systemd_fido2 = shared_library(
2113 'cryptsetup-token-systemd-fido2',
2114 cryptsetup_token_systemd_fido2_sources,
2115 include_directories : includes,
2116 link_args : ['-shared',
2117 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2118 link_with : [lib_cryptsetup_token_common,
2120 dependencies : [libcryptsetup,
2123 link_depends : cryptsetup_token_sym,
2124 install_rpath : rootpkglibdir,
2126 install_dir : libcryptsetup_plugins_dir)
2129 if conf.get('HAVE_P11KIT') == 1
2130 cryptsetup_token_systemd_pkcs11 = shared_library(
2131 'cryptsetup-token-systemd-pkcs11',
2132 cryptsetup_token_systemd_pkcs11_sources,
2133 include_directories : includes,
2134 link_args : ['-shared',
2135 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2136 link_with : [lib_cryptsetup_token_common,
2138 dependencies : [libcryptsetup,
2141 link_depends : cryptsetup_token_sym,
2142 install_rpath : rootpkglibdir,
2144 install_dir : libcryptsetup_plugins_dir)
2148 ############################################################
2150 # systemd-analyze requires 'libcore'
2152 # systemd-journal-remote requires 'libjournal_core'
2153 subdir('src/journal')
2154 # systemd-networkd requires 'libsystemd_network'
2155 subdir('src/libsystemd-network')
2157 subdir('src/analyze')
2158 subdir('src/busctl')
2159 subdir('src/coredump')
2160 subdir('src/cryptenroll')
2161 subdir('src/cryptsetup')
2163 subdir('src/hostname')
2164 subdir('src/import')
2165 subdir('src/journal-remote')
2166 subdir('src/kernel-install')
2167 subdir('src/locale')
2169 subdir('src/machine')
2170 subdir('src/network')
2171 subdir('src/nspawn')
2173 subdir('src/partition')
2174 subdir('src/portable')
2175 subdir('src/pstore')
2176 subdir('src/resolve')
2178 subdir('src/shutdown')
2179 subdir('src/sysext')
2180 subdir('src/systemctl')
2181 subdir('src/sysupdate')
2182 subdir('src/timedate')
2183 subdir('src/timesync')
2184 subdir('src/tmpfiles')
2185 subdir('src/userdb')
2186 subdir('src/xdg-autostart-generator')
2188 subdir('src/systemd')
2195 ############################################################
2197 # only static linking apart from libdl, to make sure that the
2198 # module is linked to all libraries that it uses.
2199 test_dlopen = executable(
2202 include_directories : includes,
2203 link_with : [libbasic],
2204 dependencies : [libdl],
2205 build_by_default : want_tests != 'false')
2207 foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
2208 ['systemd', 'ENABLE_NSS_SYSTEMD', ['nss-systemd.h', 'userdb-glue.c', 'userdb-glue.h']],
2209 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
2210 ['resolve', 'ENABLE_NSS_RESOLVE', [], resolve_includes]]
2212 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
2216 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
2217 version_script_arg = project_source_root / sym
2219 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
2220 if tuple.length() > 2
2221 foreach s : tuple[2]
2222 sources += ['src/nss-@0@/@1@'.format(module, s)]
2226 incs = tuple.length() > 3 ? tuple[3] : includes
2228 nss = shared_library(
2232 include_directories : incs,
2233 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
2234 link_args : ['-Wl,-z,nodelete',
2236 '-Wl,--version-script=' + version_script_arg],
2237 link_with : [libsystemd_static,
2240 dependencies : [threads,
2244 install_tag : 'nss',
2245 install_dir : rootlibdir)
2247 # We cannot use shared_module because it does not support version suffix.
2248 # Unfortunately shared_library insists on creating the symlink…
2249 meson.add_install_script('sh', '-c',
2250 'rm $DESTDIR@0@/libnss_@1@.so'
2251 .format(rootlibdir, module),
2255 if want_tests != 'false'
2256 test('dlopen-nss_' + module,
2258 # path to dlopen must include a slash
2259 args : nss.full_path(),
2265 ############################################################
2270 include_directories : includes,
2271 link_with : [libcore,
2273 dependencies : [libseccomp,
2275 install_rpath : rootpkglibdir,
2277 install_dir : rootlibexecdir)
2278 dbus_programs += exe
2279 public_programs += exe
2281 meson.add_install_script(meson_make_symlink,
2282 rootlibexecdir / 'systemd',
2283 rootsbindir / 'init')
2287 systemd_analyze_sources,
2288 include_directories : core_includes,
2289 link_with : [libcore,
2291 dependencies : [libseccomp,
2293 install_rpath : rootpkglibdir,
2294 install : conf.get('ENABLE_ANALYZE') == 1)
2295 public_programs += exe
2297 if want_tests != 'false'
2298 test('test-compare-versions',
2299 test_compare_versions_sh,
2300 args : exe.full_path())
2305 systemd_journald_sources,
2306 include_directories : includes,
2307 link_with : [libjournal_core,
2309 dependencies : [threads,
2315 install_rpath : rootpkglibdir,
2317 install_dir : rootlibexecdir)
2319 public_programs += executable(
2321 systemd_cat_sources,
2322 include_directories : includes,
2323 link_with : [libjournal_core,
2325 dependencies : [threads,
2327 install_rpath : rootpkglibdir,
2330 if get_option('link-journalctl-shared')
2331 journalctl_link_with = [libshared]
2333 journalctl_link_with = [libsystemd_static,
2338 public_programs += executable(
2341 include_directories : includes,
2342 link_with : [journalctl_link_with],
2343 dependencies : [threads,
2350 install_rpath : rootpkglibdir,
2352 install_dir : rootbindir)
2355 'systemd-getty-generator',
2356 'src/getty-generator/getty-generator.c',
2357 include_directories : includes,
2358 link_with : [libshared],
2359 install_rpath : rootpkglibdir,
2361 install_dir : systemgeneratordir)
2364 'systemd-debug-generator',
2365 'src/debug-generator/debug-generator.c',
2366 include_directories : includes,
2367 link_with : [libshared],
2368 install_rpath : rootpkglibdir,
2370 install_dir : systemgeneratordir)
2373 'systemd-run-generator',
2374 'src/run-generator/run-generator.c',
2375 include_directories : includes,
2376 link_with : [libshared],
2377 install_rpath : rootpkglibdir,
2379 install_dir : systemgeneratordir)
2382 'systemd-fstab-generator',
2383 'src/fstab-generator/fstab-generator.c',
2384 include_directories : includes,
2385 link_with : [libshared],
2386 install_rpath : rootpkglibdir,
2388 install_dir : systemgeneratordir)
2390 meson.add_install_script(meson_make_symlink,
2391 systemgeneratordir / 'systemd-fstab-generator',
2392 rootlibexecdir / 'systemd-sysroot-fstab-check')
2394 if want_tests != 'false'
2395 test('test-fstab-generator',
2396 test_fstab_generator_sh,
2397 # https://github.com/mesonbuild/meson/issues/2681
2398 args : exe.full_path(),
2402 if conf.get('ENABLE_ENVIRONMENT_D') == 1
2404 '30-systemd-environment-d-generator',
2405 'src/environment-d-generator/environment-d-generator.c',
2406 include_directories : includes,
2407 link_with : [libshared],
2408 install_rpath : rootpkglibdir,
2410 install_dir : userenvgeneratordir)
2412 meson.add_install_script(meson_make_symlink,
2413 sysconfdir / 'environment',
2414 environmentdir / '99-environment.conf')
2417 if conf.get('ENABLE_HIBERNATE') == 1
2419 'systemd-hibernate-resume-generator',
2420 'src/hibernate-resume/hibernate-resume-generator.c',
2421 include_directories : includes,
2422 link_with : [libshared],
2423 install_rpath : rootpkglibdir,
2425 install_dir : systemgeneratordir)
2428 'systemd-hibernate-resume',
2429 'src/hibernate-resume/hibernate-resume.c',
2430 include_directories : includes,
2431 link_with : [libshared],
2432 install_rpath : rootpkglibdir,
2434 install_dir : rootlibexecdir)
2437 if conf.get('HAVE_BLKID') == 1
2439 'systemd-gpt-auto-generator',
2440 'src/gpt-auto-generator/gpt-auto-generator.c',
2441 include_directories : includes,
2442 link_with : [libshared],
2443 dependencies : libblkid,
2444 install_rpath : rootpkglibdir,
2446 install_dir : systemgeneratordir)
2448 public_programs += executable(
2450 'src/dissect/dissect.c',
2451 include_directories : includes,
2452 link_with : [libshared],
2453 dependencies : [versiondep],
2454 install_rpath : rootpkglibdir,
2458 if conf.get('ENABLE_RESOLVE') == 1
2459 dbus_programs += executable(
2461 systemd_resolved_sources,
2462 include_directories : resolve_includes,
2463 link_with : [libshared,
2465 libsystemd_resolve_core],
2466 dependencies : systemd_resolved_dependencies,
2467 install_rpath : rootpkglibdir,
2469 install_dir : rootlibexecdir)
2471 public_programs += executable(
2474 include_directories : includes,
2475 link_with : [libshared,
2477 libsystemd_resolve_core],
2478 dependencies : [threads,
2479 lib_openssl_or_gcrypt,
2483 install_rpath : rootpkglibdir,
2486 meson.add_install_script(meson_make_symlink,
2487 bindir / 'resolvectl',
2488 rootsbindir / 'resolvconf')
2490 meson.add_install_script(meson_make_symlink,
2491 bindir / 'resolvectl',
2492 bindir / 'systemd-resolve')
2495 if conf.get('ENABLE_LOGIND') == 1
2496 dbus_programs += executable(
2498 systemd_logind_sources,
2499 include_directories : includes,
2500 link_with : [liblogind_core,
2502 dependencies : [threads,
2505 install_rpath : rootpkglibdir,
2507 install_dir : rootlibexecdir)
2509 public_programs += executable(
2512 include_directories : includes,
2513 link_with : [libshared],
2514 dependencies : [threads,
2519 install_rpath : rootpkglibdir,
2521 install_dir : rootbindir)
2523 public_programs += executable(
2525 'src/login/inhibit.c',
2526 include_directories : includes,
2527 link_with : [libshared],
2528 dependencies : [versiondep],
2529 install_rpath : rootpkglibdir,
2531 install_dir : rootbindir)
2533 if conf.get('HAVE_PAM') == 1
2534 version_script_arg = project_source_root / pam_systemd_sym
2535 pam_systemd = shared_library(
2539 include_directories : includes,
2540 link_args : ['-shared',
2541 '-Wl,--version-script=' + version_script_arg],
2542 link_with : [libsystemd_static,
2544 dependencies : [threads,
2548 link_depends : pam_systemd_sym,
2550 install_tag : 'pam',
2551 install_dir : pamlibdir)
2553 if want_tests != 'false'
2554 test('dlopen-pam_systemd',
2556 # path to dlopen must include a slash
2557 args : pam_systemd.full_path(),
2558 depends : pam_systemd)
2563 'systemd-user-runtime-dir',
2564 user_runtime_dir_sources,
2565 include_directories : includes,
2566 link_with : [libshared],
2567 install_rpath : rootpkglibdir,
2569 install_dir : rootlibexecdir)
2572 if conf.get('HAVE_PAM') == 1
2574 'systemd-user-sessions',
2575 'src/user-sessions/user-sessions.c',
2576 include_directories : includes,
2577 link_with : [libshared],
2578 install_rpath : rootpkglibdir,
2580 install_dir : rootlibexecdir)
2583 if conf.get('HAVE_BLKID') == 1 and conf.get('HAVE_GNU_EFI') == 1
2584 if get_option('link-boot-shared')
2585 boot_link_with = [libshared]
2587 boot_link_with = [libsystemd_static, libshared_static]
2590 public_programs += executable(
2592 'src/boot/bootctl.c',
2593 include_directories : includes,
2594 link_with : [boot_link_with],
2595 dependencies : [libblkid,
2597 install_rpath : rootpkglibdir,
2600 public_programs += executable(
2601 'systemd-bless-boot',
2602 'src/boot/bless-boot.c',
2603 include_directories : includes,
2604 link_with : [boot_link_with],
2605 dependencies : [libblkid,
2607 install_rpath : rootpkglibdir,
2609 install_dir : rootlibexecdir)
2612 'systemd-bless-boot-generator',
2613 'src/boot/bless-boot-generator.c',
2614 include_directories : includes,
2615 link_with : [boot_link_with],
2616 install_rpath : rootpkglibdir,
2618 install_dir : systemgeneratordir)
2620 if conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_TPM2') == 1
2623 'src/boot/measure.c',
2624 include_directories : includes,
2625 link_with : [libshared],
2626 dependencies : [libopenssl,
2628 install_rpath : rootpkglibdir,
2630 install_dir : rootlibexecdir)
2633 'src/boot/pcrphase.c',
2634 include_directories : includes,
2635 link_with : [libshared],
2636 dependencies : [libopenssl,
2639 install_rpath : rootpkglibdir,
2641 install_dir : rootlibexecdir)
2646 'systemd-boot-check-no-failures',
2647 'src/boot/boot-check-no-failures.c',
2648 include_directories : includes,
2649 link_with : [libshared],
2650 dependencies : [libblkid,
2652 install_rpath : rootpkglibdir,
2654 install_dir : rootlibexecdir)
2656 public_programs += executable(
2657 'systemd-socket-activate',
2658 'src/activate/activate.c',
2659 include_directories : includes,
2660 link_with : [libshared],
2661 dependencies : [threads,
2663 install_rpath : rootpkglibdir,
2666 systemctl = executable(
2669 include_directories : includes,
2670 link_with : systemctl_link_with,
2671 dependencies : [threads,
2678 install_rpath : rootpkglibdir,
2680 install_dir : rootbindir)
2681 public_programs += systemctl
2683 if conf.get('ENABLE_PORTABLED') == 1
2684 dbus_programs += executable(
2685 'systemd-portabled',
2686 systemd_portabled_sources,
2687 include_directories : includes,
2688 link_with : [libshared],
2689 dependencies : [threads,
2692 install_rpath : rootpkglibdir,
2694 install_dir : rootlibexecdir)
2696 public_programs += executable(
2698 'src/portable/portablectl.c',
2699 include_directories : includes,
2700 link_with : [libshared],
2701 dependencies : [threads,
2703 install_rpath : rootpkglibdir,
2705 install_dir : rootbindir)
2708 if conf.get('ENABLE_SYSEXT') == 1
2709 public_programs += executable(
2711 systemd_sysext_sources,
2712 include_directories : includes,
2713 link_with : [libshared],
2714 dependencies : [versiondep],
2715 install_rpath : rootpkglibdir,
2717 install_dir : rootbindir)
2720 if conf.get('ENABLE_USERDB') == 1
2723 systemd_userwork_sources,
2724 include_directories : includes,
2725 link_with : [libshared],
2726 dependencies : [threads,
2728 install_rpath : rootpkglibdir,
2730 install_dir : rootlibexecdir)
2734 systemd_userdbd_sources,
2735 include_directories : includes,
2736 link_with : [libshared],
2737 dependencies : [threads,
2739 install_rpath : rootpkglibdir,
2741 install_dir : rootlibexecdir)
2743 public_programs += executable(
2746 include_directories : includes,
2747 link_with : [libshared],
2748 dependencies : [threads,
2750 install_rpath : rootpkglibdir,
2754 if conf.get('ENABLE_HOMED') == 1
2757 systemd_homework_sources,
2758 include_directories : includes,
2759 link_with : [libshared,
2761 dependencies : [threads,
2768 install_rpath : rootpkglibdir,
2770 install_dir : rootlibexecdir)
2772 dbus_programs += executable(
2774 systemd_homed_sources,
2775 include_directories : home_includes,
2776 link_with : [libshared],
2777 dependencies : [threads,
2782 install_rpath : rootpkglibdir,
2784 install_dir : rootlibexecdir)
2786 public_programs += executable(
2789 include_directories : includes,
2790 link_with : [libshared],
2791 dependencies : [threads,
2797 install_rpath : rootpkglibdir,
2800 if conf.get('HAVE_PAM') == 1
2801 version_script_arg = project_source_root / pam_systemd_home_sym
2802 pam_systemd_home = shared_library(
2806 include_directories : includes,
2807 link_args : ['-shared',
2808 '-Wl,--version-script=' + version_script_arg],
2809 link_with : [libsystemd_static,
2811 dependencies : [threads,
2816 link_depends : pam_systemd_home_sym,
2818 install_tag : 'pam',
2819 install_dir : pamlibdir)
2821 if want_tests != 'false'
2822 test('dlopen-pam_systemd_home',
2824 # path to dlopen must include a slash
2825 args : pam_systemd_home.full_path(),
2826 depends : pam_systemd_home)
2831 foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
2832 (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
2833 meson.add_install_script(meson_make_symlink,
2834 rootbindir / 'systemctl',
2835 rootsbindir / alias)
2838 meson.add_install_script(meson_make_symlink,
2839 rootbindir / 'udevadm',
2840 rootlibexecdir / 'systemd-udevd')
2842 if conf.get('ENABLE_BACKLIGHT') == 1
2844 'systemd-backlight',
2845 'src/backlight/backlight.c',
2846 include_directories : includes,
2847 link_with : [libshared],
2848 install_rpath : rootpkglibdir,
2850 install_dir : rootlibexecdir)
2853 if conf.get('ENABLE_RFKILL') == 1
2856 'src/rfkill/rfkill.c',
2857 include_directories : includes,
2858 link_with : [libshared],
2859 install_rpath : rootpkglibdir,
2861 install_dir : rootlibexecdir)
2865 'systemd-system-update-generator',
2866 'src/system-update-generator/system-update-generator.c',
2867 include_directories : includes,
2868 link_with : [libshared],
2869 install_rpath : rootpkglibdir,
2871 install_dir : systemgeneratordir)
2873 if conf.get('HAVE_LIBCRYPTSETUP') == 1
2875 'systemd-cryptsetup',
2876 systemd_cryptsetup_sources,
2877 include_directories : includes,
2878 link_with : [libshared],
2879 dependencies : [libcryptsetup,
2882 install_rpath : rootpkglibdir,
2884 install_dir : rootlibexecdir)
2887 'systemd-cryptsetup-generator',
2888 'src/cryptsetup/cryptsetup-generator.c',
2889 include_directories : includes,
2890 link_with : [libshared],
2891 install_rpath : rootpkglibdir,
2893 install_dir : systemgeneratordir)
2896 'systemd-veritysetup',
2897 'src/veritysetup/veritysetup.c',
2898 include_directories : includes,
2899 link_with : [libshared],
2900 dependencies : [libcryptsetup,
2902 install_rpath : rootpkglibdir,
2904 install_dir : rootlibexecdir)
2907 'systemd-veritysetup-generator',
2908 'src/veritysetup/veritysetup-generator.c',
2909 include_directories : includes,
2910 link_with : [libshared],
2911 dependencies : [versiondep],
2912 install_rpath : rootpkglibdir,
2914 install_dir : systemgeneratordir)
2916 public_programs += executable(
2917 'systemd-cryptenroll',
2918 systemd_cryptenroll_sources,
2919 include_directories : includes,
2920 link_with : [libshared],
2921 dependencies : [libcryptsetup,
2926 install_rpath : rootpkglibdir,
2930 'systemd-integritysetup',
2931 ['src/integritysetup/integritysetup.c', 'src/integritysetup/integrity-util.c'],
2932 include_directories : includes,
2933 link_with : [libshared],
2934 dependencies : [libcryptsetup,
2936 install_rpath : rootpkglibdir,
2938 install_dir : rootlibexecdir)
2941 'systemd-integritysetup-generator',
2942 ['src/integritysetup/integritysetup-generator.c', 'src/integritysetup/integrity-util.c'],
2943 include_directories : includes,
2944 link_with : [libshared],
2945 install_rpath : rootpkglibdir,
2947 install_dir : systemgeneratordir)
2950 if conf.get('HAVE_SYSV_COMPAT') == 1
2952 'systemd-sysv-generator',
2953 'src/sysv-generator/sysv-generator.c',
2954 include_directories : includes,
2955 link_with : [libshared],
2956 install_rpath : rootpkglibdir,
2958 install_dir : systemgeneratordir)
2960 sysv_generator_test_py = find_program('test/sysv-generator-test.py')
2961 if want_tests != 'false'
2962 test('sysv-generator-test',
2963 sysv_generator_test_py,
2968 'systemd-rc-local-generator',
2969 'src/rc-local-generator/rc-local-generator.c',
2970 include_directories : includes,
2971 link_with : [libshared],
2972 install_rpath : rootpkglibdir,
2974 install_dir : systemgeneratordir)
2977 if conf.get('ENABLE_XDG_AUTOSTART') == 1
2979 'systemd-xdg-autostart-generator',
2980 systemd_xdg_autostart_generator_sources,
2981 include_directories : includes,
2982 link_with : [libshared],
2983 install_rpath : rootpkglibdir,
2985 install_dir : usergeneratordir)
2988 'systemd-xdg-autostart-condition',
2989 'src/xdg-autostart-generator/xdg-autostart-condition.c',
2990 include_directories : includes,
2991 link_with : [libshared],
2992 install_rpath : rootpkglibdir,
2994 install_dir : rootlibexecdir)
2997 if conf.get('ENABLE_HOSTNAMED') == 1
2998 dbus_programs += executable(
2999 'systemd-hostnamed',
3000 'src/hostname/hostnamed.c',
3001 include_directories : includes,
3002 link_with : [libshared],
3003 install_rpath : rootpkglibdir,
3005 install_dir : rootlibexecdir)
3007 public_programs += executable(
3009 'src/hostname/hostnamectl.c',
3010 include_directories : includes,
3011 link_with : [libshared],
3012 dependencies : [versiondep],
3013 install_rpath : rootpkglibdir,
3017 if conf.get('ENABLE_LOCALED') == 1
3018 if conf.get('HAVE_XKBCOMMON') == 1
3019 # logind will load libxkbcommon.so dynamically on its own, but we still
3020 # need to specify where the headers are
3022 libxkbcommon.partial_dependency(compile_args: true),
3028 dbus_programs += executable(
3030 systemd_localed_sources,
3031 include_directories : includes,
3032 link_with : [libshared],
3033 dependencies : deps,
3034 install_rpath : rootpkglibdir,
3036 install_dir : rootlibexecdir)
3038 public_programs += executable(
3041 include_directories : includes,
3042 link_with : [libshared],
3043 dependencies : [versiondep],
3044 install_rpath : rootpkglibdir,
3048 if conf.get('ENABLE_TIMEDATED') == 1
3049 dbus_programs += executable(
3050 'systemd-timedated',
3051 'src/timedate/timedated.c',
3052 include_directories : includes,
3053 link_with : [libshared],
3054 install_rpath : rootpkglibdir,
3056 install_dir : rootlibexecdir)
3059 if conf.get('ENABLE_TIMEDATECTL') == 1
3060 public_programs += executable(
3062 'src/timedate/timedatectl.c',
3063 include_directories : includes,
3064 install_rpath : rootpkglibdir,
3065 link_with : [libshared],
3066 dependencies : [libm,
3071 if conf.get('ENABLE_TIMESYNCD') == 1
3073 'systemd-timesyncd',
3074 systemd_timesyncd_sources,
3075 include_directories : includes,
3076 link_with : [libtimesyncd_core],
3077 dependencies : [threads,
3080 install_rpath : rootpkglibdir,
3082 install_dir : rootlibexecdir)
3085 'systemd-time-wait-sync',
3086 'src/timesync/wait-sync.c',
3087 include_directories : includes,
3088 link_with : [libtimesyncd_core],
3089 install_rpath : rootpkglibdir,
3091 install_dir : rootlibexecdir)
3094 if conf.get('ENABLE_MACHINED') == 1
3095 dbus_programs += executable(
3097 systemd_machined_sources,
3098 include_directories : includes,
3099 link_with : [libmachine_core,
3101 install_rpath : rootpkglibdir,
3103 install_dir : rootlibexecdir)
3105 public_programs += executable(
3107 'src/machine/machinectl.c',
3108 include_directories : includes,
3109 link_with : [libshared],
3110 dependencies : [threads,
3115 install_rpath : rootpkglibdir,
3117 install_dir : rootbindir)
3120 if conf.get('ENABLE_IMPORTD') == 1
3121 dbus_programs += executable(
3123 systemd_importd_sources,
3124 include_directories : includes,
3125 link_with : [libshared],
3126 dependencies : [threads,
3128 install_rpath : rootpkglibdir,
3130 install_dir : rootlibexecdir)
3132 systemd_pull = executable(
3134 systemd_pull_sources,
3135 include_directories : includes,
3136 link_with : [libshared,
3138 dependencies : [libcurl,
3139 lib_openssl_or_gcrypt,
3144 install_rpath : rootpkglibdir,
3146 install_dir : rootlibexecdir)
3148 systemd_import = executable(
3150 systemd_import_sources,
3151 include_directories : includes,
3152 link_with : [libshared,
3154 dependencies : [libcurl,
3159 install_rpath : rootpkglibdir,
3161 install_dir : rootlibexecdir)
3163 systemd_import_fs = executable(
3164 'systemd-import-fs',
3165 systemd_import_fs_sources,
3166 include_directories : includes,
3167 link_with : [libshared,
3169 dependencies : [versiondep],
3170 install_rpath : rootpkglibdir,
3172 install_dir : rootlibexecdir)
3174 systemd_export = executable(
3176 systemd_export_sources,
3177 include_directories : includes,
3178 link_with : [libshared,
3180 dependencies : [libcurl,
3185 install_rpath : rootpkglibdir,
3187 install_dir : rootlibexecdir)
3189 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
3192 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
3193 public_programs += executable(
3194 'systemd-journal-upload',
3195 systemd_journal_upload_sources,
3196 include_directories : includes,
3197 link_with : [libshared],
3198 dependencies : [threads,
3205 install_rpath : rootpkglibdir,
3207 install_dir : rootlibexecdir)
3210 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
3211 public_programs += executable(
3212 'systemd-journal-remote',
3213 systemd_journal_remote_sources,
3214 include_directories : journal_includes,
3215 link_with : [libshared,
3216 libsystemd_journal_remote],
3217 dependencies : [threads,
3224 install_rpath : rootpkglibdir,
3226 install_dir : rootlibexecdir)
3228 public_programs += executable(
3229 'systemd-journal-gatewayd',
3230 systemd_journal_gatewayd_sources,
3231 include_directories : journal_includes,
3232 link_with : [libshared],
3233 dependencies : [threads,
3240 install_rpath : rootpkglibdir,
3242 install_dir : rootlibexecdir)
3245 if conf.get('ENABLE_COREDUMP') == 1
3248 systemd_coredump_sources,
3249 include_directories : includes,
3250 link_with : [libshared,
3252 dependencies : [threads,
3258 install_rpath : rootpkglibdir,
3260 install_dir : rootlibexecdir)
3262 public_programs += executable(
3264 coredumpctl_sources,
3265 include_directories : includes,
3266 link_with : [libshared,
3268 dependencies : [threads,
3273 install_rpath : rootpkglibdir,
3277 if conf.get('ENABLE_PSTORE') == 1
3280 systemd_pstore_sources,
3281 include_directories : includes,
3282 link_with : [libshared],
3283 dependencies : [threads,
3289 install_rpath : rootpkglibdir,
3291 install_dir : rootlibexecdir)
3294 if conf.get('ENABLE_OOMD') == 1
3295 dbus_programs += executable('systemd-oomd',
3296 systemd_oomd_sources,
3297 include_directories : includes,
3298 link_with : [libshared],
3299 dependencies : [libatomic,
3301 install_rpath : rootpkglibdir,
3303 install_dir : rootlibexecdir)
3305 public_programs += executable(
3308 include_directories : includes,
3309 link_with : [libshared],
3310 dependencies : [versiondep],
3311 install_rpath : rootpkglibdir,
3315 if conf.get('ENABLE_BINFMT') == 1
3316 public_programs += executable(
3318 'src/binfmt/binfmt.c',
3319 include_directories : includes,
3320 link_with : [libshared],
3321 dependencies : [versiondep],
3322 install_rpath : rootpkglibdir,
3324 install_dir : rootlibexecdir)
3326 meson.add_install_script('sh', '-c',
3327 mkdir_p.format(binfmtdir))
3328 if install_sysconfdir
3329 meson.add_install_script('sh', '-c',
3330 mkdir_p.format(sysconfdir / 'binfmt.d'))
3334 if conf.get('ENABLE_SYSUPDATE') == 1
3336 'systemd-sysupdate',
3337 systemd_sysupdate_sources,
3338 include_directories : includes,
3339 link_with : [libshared,
3341 dependencies : [threads,
3346 install_rpath : rootpkglibdir,
3348 install_dir : rootlibexecdir)
3349 public_programs += exe
3352 if conf.get('ENABLE_VCONSOLE') == 1
3354 'systemd-vconsole-setup',
3355 'src/vconsole/vconsole-setup.c',
3356 include_directories : includes,
3357 link_with : [libshared],
3358 install_rpath : rootpkglibdir,
3360 install_dir : rootlibexecdir)
3363 if conf.get('ENABLE_RANDOMSEED') == 1
3365 'systemd-random-seed',
3366 'src/random-seed/random-seed.c',
3367 include_directories : includes,
3368 link_with : [libshared],
3369 dependencies : [versiondep],
3370 install_rpath : rootpkglibdir,
3372 install_dir : rootlibexecdir)
3375 if conf.get('ENABLE_FIRSTBOOT') == 1
3376 public_programs += executable(
3377 'systemd-firstboot',
3378 'src/firstboot/firstboot.c',
3379 include_directories : includes,
3380 link_with : [libshared],
3381 dependencies : [libcrypt,
3383 install_rpath : rootpkglibdir,
3385 install_dir : rootbindir)
3389 'systemd-remount-fs',
3390 'src/remount-fs/remount-fs.c',
3391 include_directories : includes,
3392 link_with : [libshared],
3393 dependencies : [versiondep],
3394 install_rpath : rootpkglibdir,
3396 install_dir : rootlibexecdir)
3399 'systemd-machine-id-setup',
3400 'src/machine-id-setup/machine-id-setup-main.c',
3401 include_directories : includes,
3402 link_with : [libshared],
3403 dependencies : [versiondep],
3404 install_rpath : rootpkglibdir,
3406 install_dir : rootbindir)
3411 include_directories : includes,
3412 link_with : [libshared],
3413 dependencies : [versiondep],
3414 install_rpath : rootpkglibdir,
3416 install_dir : rootlibexecdir)
3420 'src/partition/growfs.c',
3421 include_directories : includes,
3422 link_with : [libshared],
3423 dependencies : [versiondep],
3424 install_rpath : rootpkglibdir,
3426 install_dir : rootlibexecdir)
3430 'src/partition/makefs.c',
3431 include_directories : includes,
3432 link_with : [libshared],
3433 dependencies : [versiondep],
3434 install_rpath : rootpkglibdir,
3436 install_dir : rootlibexecdir)
3440 'src/sleep/sleep.c',
3441 include_directories : includes,
3442 link_with : [libshared],
3443 dependencies : [versiondep],
3444 install_rpath : rootpkglibdir,
3446 install_dir : rootlibexecdir)
3448 if install_sysconfdir_samples
3449 install_data('src/sleep/sleep.conf',
3450 install_dir : pkgsysconfdir)
3453 public_programs += executable(
3455 'src/sysctl/sysctl.c',
3456 include_directories : includes,
3457 link_with : [libshared],
3458 dependencies : [versiondep],
3459 install_rpath : rootpkglibdir,
3461 install_dir : rootlibexecdir)
3463 public_programs += executable(
3465 'src/ac-power/ac-power.c',
3466 include_directories : includes,
3467 link_with : [libshared],
3468 dependencies : [versiondep],
3469 install_rpath : rootpkglibdir,
3472 public_programs += executable(
3473 'systemd-detect-virt',
3474 'src/detect-virt/detect-virt.c',
3475 include_directories : includes,
3476 link_with : [libshared],
3477 dependencies : [versiondep],
3478 install_rpath : rootpkglibdir,
3481 public_programs += executable(
3483 'src/delta/delta.c',
3484 include_directories : includes,
3485 link_with : [libshared],
3486 dependencies : [versiondep],
3487 install_rpath : rootpkglibdir,
3490 public_programs += executable(
3492 'src/escape/escape.c',
3493 include_directories : includes,
3494 link_with : [libshared],
3495 dependencies : [versiondep],
3496 install_rpath : rootpkglibdir,
3498 install_dir : rootbindir)
3500 public_programs += executable(
3502 'src/notify/notify.c',
3503 include_directories : includes,
3504 link_with : [libshared],
3505 dependencies : [versiondep],
3506 install_rpath : rootpkglibdir,
3508 install_dir : rootbindir)
3510 public_programs += executable(
3512 'src/creds/creds.c',
3513 include_directories : includes,
3514 link_with : [libshared],
3515 dependencies : [threads,
3518 install_rpath : rootpkglibdir,
3520 install_dir : rootbindir)
3523 'systemd-volatile-root',
3524 'src/volatile-root/volatile-root.c',
3525 include_directories : includes,
3526 link_with : [libshared],
3527 install_rpath : rootpkglibdir,
3528 install : conf.get('ENABLE_INITRD') == 1,
3529 install_dir : rootlibexecdir)
3532 'systemd-cgroups-agent',
3533 'src/cgroups-agent/cgroups-agent.c',
3534 include_directories : includes,
3535 link_with : [libshared],
3536 install_rpath : rootpkglibdir,
3538 install_dir : rootlibexecdir)
3540 systemd_id128 = executable(
3542 'src/id128/id128.c',
3543 include_directories : includes,
3544 link_with : [libshared],
3545 dependencies : [versiondep],
3546 install_rpath : rootpkglibdir,
3548 public_programs += systemd_id128
3550 if want_tests != 'false'
3551 test('test-systemctl-enable',
3552 test_systemctl_enable_sh,
3553 # https://github.com/mesonbuild/meson/issues/2681
3554 args : [systemctl.full_path(),
3555 systemd_id128.full_path()])
3558 public_programs += executable(
3561 include_directories : includes,
3562 link_with : [libshared],
3563 dependencies : [versiondep],
3564 install_rpath : rootpkglibdir,
3567 public_programs += executable(
3568 'systemd-ask-password',
3569 'src/ask-password/ask-password.c',
3570 include_directories : includes,
3571 link_with : [libshared],
3572 dependencies : [versiondep],
3573 install_rpath : rootpkglibdir,
3575 install_dir : rootbindir)
3578 'systemd-reply-password',
3579 'src/reply-password/reply-password.c',
3580 include_directories : includes,
3581 link_with : [libshared],
3582 install_rpath : rootpkglibdir,
3584 install_dir : rootlibexecdir)
3586 public_programs += executable(
3587 'systemd-tty-ask-password-agent',
3588 'src/tty-ask-password-agent/tty-ask-password-agent.c',
3589 include_directories : includes,
3590 link_with : [libshared],
3591 dependencies : [versiondep],
3592 install_rpath : rootpkglibdir,
3594 install_dir : rootbindir)
3596 public_programs += executable(
3599 include_directories : includes,
3600 link_with : [libshared],
3601 dependencies : [versiondep],
3602 install_rpath : rootpkglibdir,
3605 public_programs += executable(
3607 'src/cgtop/cgtop.c',
3608 include_directories : includes,
3609 link_with : [libshared],
3610 dependencies : [versiondep],
3611 install_rpath : rootpkglibdir,
3616 'src/initctl/initctl.c',
3617 include_directories : includes,
3618 link_with : [libshared],
3619 install_rpath : rootpkglibdir,
3620 install : (conf.get('HAVE_SYSV_COMPAT') == 1),
3621 install_dir : rootlibexecdir)
3623 public_programs += executable(
3625 'src/mount/mount-tool.c',
3626 include_directories : includes,
3627 link_with : [libshared],
3628 dependencies: [libmount,
3630 install_rpath : rootpkglibdir,
3633 meson.add_install_script(meson_make_symlink,
3634 'systemd-mount', bindir / 'systemd-umount')
3636 public_programs += executable(
3639 include_directories : includes,
3640 link_with : [libshared],
3641 dependencies : [versiondep],
3642 install_rpath : rootpkglibdir,
3645 public_programs += executable(
3646 'systemd-stdio-bridge',
3647 'src/stdio-bridge/stdio-bridge.c',
3648 include_directories : includes,
3649 link_with : [libshared],
3650 dependencies : [versiondep,
3652 install_rpath : rootpkglibdir,
3655 public_programs += executable(
3658 include_directories : includes,
3659 link_with : [libshared],
3660 dependencies : [versiondep],
3661 install_rpath : rootpkglibdir,
3667 'src/sysusers/sysusers.c',
3668 include_directories : includes,
3669 link_with : [libshared],
3670 dependencies : [versiondep],
3671 install_rpath : rootpkglibdir,
3673 install_dir : rootbindir)
3674 public_programs += exe
3676 if want_tests != 'false'
3677 test('test-sysusers',
3679 # https://github.com/mesonbuild/meson/issues/2681
3680 args : exe.full_path())
3683 if have_standalone_binaries
3685 'systemd-sysusers.standalone',
3686 'src/sysusers/sysusers.c',
3687 include_directories : includes,
3688 c_args : '-DSTANDALONE',
3689 link_with : [libshared_static,
3693 dependencies : [versiondep],
3695 install_dir : rootbindir)
3696 public_programs += exe
3698 if want_tests != 'false'
3699 test('test-sysusers.standalone',
3701 # https://github.com/mesonbuild/meson/issues/2681
3702 args : exe.full_path())
3707 if conf.get('ENABLE_TMPFILES') == 1
3710 systemd_tmpfiles_sources,
3711 include_directories : includes,
3712 link_with : [libshared],
3713 dependencies : [libacl,
3715 install_rpath : rootpkglibdir,
3717 install_dir : rootbindir)
3718 public_programs += exe
3720 if want_tests != 'false'
3721 test('test-systemd-tmpfiles',
3722 test_systemd_tmpfiles_py,
3723 # https://github.com/mesonbuild/meson/issues/2681
3724 args : exe.full_path())
3727 if have_standalone_binaries
3729 'systemd-tmpfiles.standalone',
3730 systemd_tmpfiles_sources,
3731 include_directories : includes,
3732 c_args : '-DSTANDALONE',
3733 link_with : [libshared_static,
3737 dependencies : [libacl,
3740 install_dir : rootbindir)
3741 public_programs += exe
3743 if want_tests != 'false'
3744 test('test-systemd-tmpfiles.standalone',
3745 test_systemd_tmpfiles_py,
3746 # https://github.com/mesonbuild/meson/issues/2681
3747 args : exe.full_path())
3752 if conf.get('ENABLE_HWDB') == 1
3753 systemd_hwdb = executable(
3756 include_directories : includes,
3757 link_with : udev_link_with,
3758 dependencies : [versiondep],
3759 install_rpath : udev_rpath,
3761 install_dir : rootbindir)
3762 public_programs += systemd_hwdb
3764 if want_tests != 'false'
3767 suite : 'dist-check',
3768 args : [systemd_hwdb.full_path()],
3773 if conf.get('ENABLE_QUOTACHECK') == 1
3775 'systemd-quotacheck',
3776 'src/quotacheck/quotacheck.c',
3777 include_directories : includes,
3778 link_with : [libshared],
3779 install_rpath : rootpkglibdir,
3781 install_dir : rootlibexecdir)
3784 public_programs += executable(
3785 'systemd-socket-proxyd',
3786 'src/socket-proxy/socket-proxyd.c',
3787 include_directories : includes,
3788 link_with : [libshared],
3789 dependencies : [threads,
3791 install_rpath : rootpkglibdir,
3793 install_dir : rootlibexecdir)
3795 udevadm = executable(
3798 include_directories : includes,
3799 link_with : [libudevd_core],
3800 dependencies : [threads,
3806 install_rpath : udev_rpath,
3808 install_dir : rootbindir)
3809 public_programs += udevadm
3811 if conf.get('ENABLE_REPART') == 1
3814 systemd_repart_sources,
3815 include_directories : includes,
3816 link_with : [libshared,
3818 dependencies : [threads,
3823 install_rpath : rootpkglibdir,
3825 install_dir : rootbindir)
3826 public_programs += exe
3828 if have_standalone_binaries
3830 'systemd-repart.standalone',
3831 systemd_repart_sources,
3832 include_directories : includes,
3833 c_args : '-DSTANDALONE',
3834 link_with : [libshared_static,
3839 dependencies : [threads,
3844 install_rpath : rootpkglibdir,
3846 install_dir : rootbindir)
3847 public_programs += exe
3853 systemd_shutdown_sources,
3854 include_directories : includes,
3855 link_with : [libshared],
3856 dependencies : [libmount,
3858 install_rpath : rootpkglibdir,
3860 install_dir : rootlibexecdir)
3862 if have_standalone_binaries
3864 'systemd-shutdown.standalone',
3865 systemd_shutdown_sources,
3866 include_directories : includes,
3867 c_args : '-DSTANDALONE',
3868 link_with : [libshared_static,
3871 dependencies : [libmount,
3873 install_rpath : rootpkglibdir,
3875 install_dir : rootlibexecdir)
3879 'systemd-update-done',
3880 'src/update-done/update-done.c',
3881 include_directories : includes,
3882 link_with : [libshared],
3883 dependencies : [versiondep],
3884 install_rpath : rootpkglibdir,
3886 install_dir : rootlibexecdir)
3889 'systemd-update-utmp',
3890 'src/update-utmp/update-utmp.c',
3891 include_directories : includes,
3892 link_with : [libshared],
3893 dependencies : [libaudit,
3895 install_rpath : rootpkglibdir,
3896 install : (conf.get('ENABLE_UTMP') == 1),
3897 install_dir : rootlibexecdir)
3899 if conf.get('HAVE_KMOD') == 1
3901 'systemd-modules-load',
3902 'src/modules-load/modules-load.c',
3903 include_directories : includes,
3904 link_with : [libshared],
3905 dependencies : [libkmod,
3907 install_rpath : rootpkglibdir,
3909 install_dir : rootlibexecdir)
3911 meson.add_install_script('sh', '-c',
3912 mkdir_p.format(modulesloaddir))
3913 if install_sysconfdir
3914 meson.add_install_script('sh', '-c',
3915 mkdir_p.format(sysconfdir / 'modules-load.d'))
3919 public_programs += executable(
3921 systemd_nspawn_sources,
3922 include_directories : includes,
3923 link_with : [libnspawn_core,
3925 dependencies : [libblkid,
3928 install_rpath : rootpkglibdir,
3931 if conf.get('ENABLE_NETWORKD') == 1
3932 dbus_programs += executable(
3934 systemd_networkd_sources,
3935 include_directories : network_includes,
3936 link_with : [libnetworkd_core,
3938 networkd_link_with],
3939 dependencies : [threads,
3941 install_rpath : rootpkglibdir,
3943 install_dir : rootlibexecdir)
3945 public_programs += executable(
3946 'systemd-networkd-wait-online',
3947 systemd_networkd_wait_online_sources,
3948 include_directories : includes,
3949 link_with : [networkd_link_with],
3950 dependencies : [versiondep],
3951 install_rpath : rootpkglibdir,
3953 install_dir : rootlibexecdir)
3955 public_programs += executable(
3958 include_directories : libsystemd_network_includes,
3959 link_with : [libsystemd_network,
3960 networkd_link_with],
3961 dependencies : [versiondep],
3962 install_rpath : rootpkglibdir,
3964 install_dir : rootbindir)
3968 'systemd-network-generator',
3969 network_generator_sources,
3970 include_directories : includes,
3971 link_with : [networkd_link_with],
3972 dependencies : [versiondep],
3973 install_rpath : rootpkglibdir,
3975 install_dir : rootlibexecdir)
3977 if want_tests != 'false'
3978 test('test-network-generator-conversion',
3979 test_network_generator_conversion_sh,
3980 # https://github.com/mesonbuild/meson/issues/2681
3981 args : exe.full_path(),
3986 'systemd-sulogin-shell',
3987 'src/sulogin-shell/sulogin-shell.c',
3988 include_directories : includes,
3989 link_with : [libshared],
3990 dependencies : [versiondep],
3991 install_rpath : rootpkglibdir,
3993 install_dir : rootlibexecdir)
3995 exe = custom_target(
3997 input : kernel_install_in,
3998 output : 'kernel-install',
3999 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
4000 install : want_kernel_install,
4001 install_mode : 'rwxr-xr-x',
4002 install_dir : bindir)
4003 public_programs += exe
4005 if want_tests != 'false' and want_kernel_install
4006 test('test-kernel-install',
4007 test_kernel_install_sh,
4008 args : [exe.full_path(), loaderentry_install])
4011 ############################################################
4013 runtest_env = custom_target(
4014 'systemd-runtest.env',
4015 output : 'systemd-runtest.env',
4016 command : [sh, '-c',
4017 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
4018 project_source_root / 'test',
4019 project_build_root / 'catalog')],
4021 build_by_default : true)
4023 test_cflags = ['-DTEST_CODE=1']
4024 # We intentionally do not do inline initializations with definitions for a
4025 # bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
4026 # use the variable unexpectedly. This triggers a lot of maybe-uninitialized
4027 # false positives when the combination of -O2 and -flto is used. Suppress them.
4028 if '-O2' in c_args and '-flto=auto' in c_args
4029 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
4032 foreach tuple : tests
4034 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
4035 dependencies = tuple.length() > 2 ? tuple[2] : []
4036 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
4037 condition = tuple.length() > 4 ? tuple[4] : ''
4038 type = tuple.length() > 5 ? tuple[5] : ''
4039 defs = tuple.length() > 6 ? tuple[6] : []
4041 parallel = tuple.length() > 7 ? tuple[7] : true
4044 # FIXME: Use fs.stem() with meson >= 0.54.0
4045 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
4046 if type.startswith('timeout=')
4047 timeout = type.split('=')[1].to_int()
4051 suite = fs.name(fs.parent('@0@'.format(sources[0])))
4052 # FIXME: Use str.replace() with meson >= 0.58.0
4053 suite = suite.split('sd-')[-1]
4055 if condition == '' or conf.get(condition) == 1
4059 include_directories : incs,
4060 link_with : link_with,
4061 dependencies : [versiondep,
4064 build_by_default : want_tests != 'false',
4065 install_rpath : rootpkglibdir,
4066 install : install_tests,
4067 install_dir : testsdir / type,
4068 link_depends : runtest_env)
4071 message('@0@ is a manual test'.format(name))
4072 elif type == 'unsafe' and want_tests != 'unsafe'
4073 message('@0@ is an unsafe test'.format(name))
4074 elif want_tests != 'false'
4079 is_parallel : parallel)
4082 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
4087 'test-libsystemd-sym',
4088 test_libsystemd_sym_c,
4089 include_directories : includes,
4090 link_with : [libsystemd],
4091 build_by_default : want_tests != 'false',
4092 install : install_tests,
4093 install_dir : testsdir)
4094 if want_tests != 'false'
4095 test('test-libsystemd-sym', exe)
4099 'test-libsystemd-static-sym',
4100 test_libsystemd_sym_c,
4101 include_directories : includes,
4102 link_with : [install_libsystemd_static],
4103 dependencies : [threads], # threads is already included in dependencies on the library,
4104 # but does not seem to get propagated. Add here as a work-around.
4105 build_by_default : want_tests != 'false' and static_libsystemd_pic,
4106 install : install_tests and static_libsystemd_pic,
4107 install_dir : testsdir)
4108 if want_tests != 'false' and static_libsystemd_pic
4109 test('test-libsystemd-static-sym', exe)
4115 include_directories : libudev_includes,
4116 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
4117 link_with : [libudev],
4118 build_by_default : want_tests != 'false',
4119 install : install_tests,
4120 install_dir : testsdir)
4121 if want_tests != 'false'
4122 test('test-libudev-sym', exe)
4126 'test-libudev-static-sym',
4128 include_directories : libudev_includes,
4129 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
4130 link_with : [install_libudev_static],
4131 build_by_default : want_tests != 'false' and static_libudev_pic,
4132 install : install_tests and static_libudev_pic,
4133 install_dir : testsdir)
4134 if want_tests != 'false' and static_libudev_pic
4135 test('test-libudev-static-sym', exe)
4138 ############################################################
4142 foreach tuple : fuzzers
4144 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
4145 dependencies = tuple.length() > 2 ? tuple[2] : []
4146 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
4147 defs = tuple.length() > 4 ? tuple[4] : []
4151 dependencies += fuzzing_engine
4153 if fuzzing_engine.found()
4154 dependencies += fuzzing_engine
4156 link_args += ['-fsanitize=fuzzer']
4159 sources += 'src/fuzz/fuzz-main.c'
4161 sources += fuzz_generated_directives
4163 # FIXME: Use fs.stem() with meson >= 0.54.0
4164 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
4169 include_directories : [incs, include_directories('src/fuzz')],
4170 link_with : link_with,
4171 dependencies : [dependencies,
4173 c_args : defs + test_cflags,
4174 link_args: link_args,
4176 build_by_default : fuzzer_build)
4179 if want_tests != 'false' and name in fuzz_regression_tests
4180 # Run the fuzz regression tests without any sanitizers enabled.
4181 # Additional invocations with sanitizers may be added below.
4182 foreach tuple : fuzz_regression_tests[name]
4185 test('@0@_@1@'.format(name, fuzz_in),
4188 args : [fuzz_dir != '' ? project_source_root / fuzz_dir / name / fuzz_in
4189 : fuzz_generated_in_dir / '@0@_@1@'.format(name, fuzz_in)])
4194 alias_target('fuzzers', fuzzer_exes)
4196 ############################################################
4198 subdir('docs/sysvinit')
4199 subdir('docs/var-log')
4202 subdir('modprobe.d')
4205 subdir('shell-completion/bash')
4206 subdir('shell-completion/zsh')
4208 subdir('sysusers.d')
4209 subdir('tmpfiles.d')
4212 install_subdir('factory/etc',
4213 install_dir : factorydir)
4214 subdir('factory/templates')
4216 if install_sysconfdir
4217 install_data('xorg/50-systemd-user.sh',
4218 install_dir : xinitrcdir)
4220 install_data('LICENSE.GPL2',
4224 'docs/CODING_STYLE.md',
4225 'docs/DISTRO_PORTING.md',
4226 'docs/ENVIRONMENT.md',
4228 'docs/TRANSIENT-SETTINGS.md',
4229 'docs/TRANSLATORS.md',
4230 'docs/UIDS-GIDS.md',
4231 install_dir : docdir)
4233 install_subdir('LICENSES',
4234 install_dir : docdir)
4236 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
4237 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
4239 ############################################################
4241 # Ensure that changes to the docs/ directory do not break the
4242 # basic Github pages build. But only run it in developer mode,
4243 # as it might be fragile due to changes in the tooling, and it is
4244 # not generally useful for users.
4245 jekyll = find_program('jekyll', required : false)
4246 if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
4247 test('github-pages',
4249 suite : 'dist-check',
4251 '--source', project_source_root / 'docs',
4252 '--destination', project_build_root / '_site'])
4255 ############################################################
4257 check_help = find_program('tools/check-help.sh')
4258 check_version = find_program('tools/check-version.sh')
4260 foreach exec : public_programs
4261 name = exec.full_path().split('/')[-1]
4262 if want_tests != 'false'
4263 test('check-help-' + name,
4265 suite : 'dist-check',
4266 args : exec.full_path(),
4269 test('check-version-' + name,
4271 suite : 'dist-check',
4272 args : [exec.full_path(),
4273 meson.project_version()],
4278 # Enable tests for all supported sanitizers
4279 foreach tuple : fuzz_sanitizers
4280 sanitizer = tuple[0]
4283 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
4284 foreach fuzzer, fuzz_ins : fuzz_regression_tests
4285 name = '@0@:@1@'.format(fuzzer, sanitizer)
4286 if want_tests == 'false'
4287 message('Not compiling @0@ because tests is set to false'.format(name))
4291 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
4294 exe = custom_target(
4297 depends : [build] + fuzz_generated_directives,
4298 command : [ln, '-fs',
4299 build.full_path() / fuzzer,
4301 build_by_default : true)
4303 foreach tuple : fuzz_ins
4307 test('@0@_@1@_@2@'.format(fuzzer, fuzz_in, sanitizer),
4310 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
4312 args : [exe.full_path(),
4313 fuzz_dir != '' ? project_source_root / fuzz_dir / fuzzer / fuzz_in
4314 : fuzz_generated_in_dir / '@0@_@1@'.format(fuzzer, fuzz_in)])
4321 ############################################################
4324 all_files = run_command(
4325 env, '-u', 'GIT_WORK_TREE',
4326 git, '--git-dir=@0@/.git'.format(project_source_root),
4327 'ls-files', ':/*.[ch]',
4329 if all_files.returncode() == 0
4330 all_files = files(all_files.stdout().split())
4335 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
4338 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
4343 git_contrib_sh = find_program('tools/git-contrib.sh')
4346 command : [git_contrib_sh])
4350 git_head = run_command(
4351 git, '--git-dir=@0@/.git'.format(project_source_root),
4352 'rev-parse', 'HEAD',
4353 check : false).stdout().strip()
4354 git_head_short = run_command(
4355 git, '--git-dir=@0@/.git'.format(project_source_root),
4356 'rev-parse', '--short=7', 'HEAD',
4357 check : false).stdout().strip()
4361 command : [git, 'archive',
4362 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
4364 '--prefix', 'systemd-@0@/'.format(git_head),
4368 ############################################################
4370 check_api_docs_sh = find_program('tools/check-api-docs.sh')
4373 depends : [man, libsystemd, libudev],
4374 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
4376 alias_target('update-dbus-docs', update_dbus_docs)
4377 alias_target('update-man-rules', update_man_rules)
4379 if not meson.is_cross_build()
4381 'export-dbus-interfaces',
4382 output : fs.name(dbus_interfaces_dir),
4383 install : dbus_interfaces_dir != 'no',
4384 install_dir : fs.parent(dbus_interfaces_dir),
4385 command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
4388 ############################################################
4390 alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
4391 check : true).stdout().strip()
4394 'split /usr' : split_usr,
4395 'split bin-sbin' : split_bin,
4396 'prefix directory' : prefixdir,
4397 'rootprefix directory' : rootprefixdir,
4398 'sysconf directory' : sysconfdir,
4399 'include directory' : includedir,
4400 'lib directory' : libdir,
4401 'rootlib directory' : rootlibdir,
4402 'SysV init scripts' : sysvinit_path,
4403 'SysV rc?.d directories' : sysvrcnd_path,
4404 'PAM modules directory' : pamlibdir,
4405 'PAM configuration directory' : pamconfdir,
4406 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
4407 'RPM macros directory' : rpmmacrosdir,
4408 'modprobe.d directory' : modprobedir,
4409 'D-Bus policy directory' : dbuspolicydir,
4410 'D-Bus session directory' : dbussessionservicedir,
4411 'D-Bus system directory' : dbussystemservicedir,
4412 'D-Bus interfaces directory' : dbus_interfaces_dir,
4413 'bash completions directory' : bashcompletiondir,
4414 'zsh completions directory' : zshcompletiondir,
4415 'private shared lib version tag' : shared_lib_tag,
4416 'extra start script' : get_option('rc-local'),
4417 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
4418 get_option('debug-tty')),
4419 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
4420 conf.get('SYSTEM_ALLOC_UID_MIN')),
4421 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
4422 conf.get('SYSTEM_ALLOC_GID_MIN')),
4423 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
4424 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
4425 'static UID/GID allocations' : ' '.join(static_ugids),
4426 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
4427 'render group access mode' : get_option('group-render-mode'),
4428 'certificate root directory' : get_option('certificate-root'),
4429 'support URL' : support_url,
4430 'nobody user name' : nobody_user,
4431 'nobody group name' : nobody_group,
4432 'fallback hostname' : get_option('fallback-hostname'),
4433 'default compression method' : compression,
4434 'default DNSSEC mode' : default_dnssec,
4435 'default DNS-over-TLS mode' : default_dns_over_tls,
4436 'default mDNS mode' : default_mdns,
4437 'default LLMNR mode' : default_llmnr,
4438 'default DNS servers' : dns_servers.split(' '),
4439 'default NTP servers' : ntp_servers.split(' '),
4440 'default cgroup hierarchy' : default_hierarchy,
4441 'default net.naming-scheme value' : default_net_naming_scheme,
4442 'default KillUserProcesses value' : kill_user_processes,
4443 'default locale' : default_locale,
4444 'default nspawn locale' : nspawn_locale,
4445 'default status unit format' : status_unit_format_default,
4446 'default user $PATH' :
4447 default_user_path != '' ? default_user_path : '(same as system services)',
4448 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
4449 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
4452 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
4453 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
4454 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
4475 ['libcryptsetup-plugins'],
4501 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
4531 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
4545 ['legacy-pkla', install_polkit_pkla],
4551 ['man pages', want_man],
4552 ['html pages', want_html],
4553 ['man page indices', want_man and have_lxml],
4555 ['compat-mutable-uid-boundaries'],
4558 ['adm group', get_option('adm-group')],
4559 ['wheel group', get_option('wheel-group')],
4562 ['debug mmap cache'],
4564 ['valgrind', conf.get('VALGRIND') == 1],
4565 ['trace logging', conf.get('LOG_TRACE') == 1],
4566 ['install tests', install_tests],
4567 ['link-udev-shared', get_option('link-udev-shared')],
4568 ['link-systemctl-shared', get_option('link-systemctl-shared')],
4569 ['link-networkd-shared', get_option('link-networkd-shared')],
4570 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
4571 ['link-journalctl-shared', get_option('link-journalctl-shared')],
4572 ['link-boot-shared', get_option('link-boot-shared')],
4573 ['first-boot-full-preset'],
4575 ['standalone-binaries', get_option('standalone-binaries')],
4576 ['coverage', get_option('b_coverage')],
4579 if tuple.length() >= 2
4582 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
4583 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
4584 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
4593 if static_libsystemd == 'false'
4594 missing += 'static-libsystemd'
4596 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
4599 if static_libudev == 'false'
4600 missing += 'static-libudev'
4602 found += 'static-libudev(@0@)'.format(static_libudev)
4605 if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
4606 found += 'cryptolib(openssl)'
4607 elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
4608 found += 'cryptolib(gcrypt)'
4610 missing += 'cryptolib'
4613 if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
4614 found += 'DNS-over-TLS(gnutls)'
4615 elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
4616 found += 'DNS-over-TLS(openssl)'
4618 missing += 'DNS-over-TLS'
4622 'enabled' : ', '.join(found),
4623 'disabled' : ', '.join(missing)},
4624 section : 'Features')
4626 if rootprefixdir != rootprefix_default
4628 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
4629 'systemd used fixed names for unit file directories and other paths, so anything\n' +
4630 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))