1 # SPDX-License-Identifier: LGPL-2.1-or-later
3 project('systemd', 'c',
13 meson_version : '>= 0.53.2',
16 libsystemd_version = '0.35.0'
17 libudev_version = '1.7.5'
19 conf = configuration_data()
20 conf.set_quoted('PROJECT_URL', 'https://systemd.io/')
21 conf.set('PROJECT_VERSION', meson.project_version(),
22 description : 'Numerical project version (used where a simple number is expected)')
24 # This is to be used instead of meson.source_root(), as the latter will return
25 # the wrong result when systemd is being built as a meson subproject
26 project_source_root = meson.current_source_dir()
27 project_build_root = meson.current_build_dir()
28 relative_source_path = run_command('realpath',
29 '--relative-to=@0@'.format(project_build_root),
31 check : true).stdout().strip()
32 conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)
34 conf.set10('BUILD_MODE_DEVELOPER', get_option('mode') == 'developer',
35 description : 'tailor build to development or release builds')
36 verification = get_option('log-message-verification')
37 if verification == 'auto'
38 verification = conf.get('BUILD_MODE_DEVELOPER') == 1
40 verification = verification == 'true'
42 conf.set10('LOG_MESSAGE_VERIFICATION', verification)
44 want_ossfuzz = get_option('oss-fuzz')
45 want_libfuzzer = get_option('llvm-fuzz')
46 if want_ossfuzz and want_libfuzzer
47 error('only one of oss-fuzz or llvm-fuzz can be specified')
50 skip_deps = want_ossfuzz or get_option('skip-deps')
51 fuzzer_build = want_ossfuzz or want_libfuzzer
53 # If we're building *not* for actual fuzzing, allow input samples of any size
54 # (for testing and for reproduction of issues discovered with previously-higher
56 conf.set10('FUZZ_USE_SIZE_LIMIT', fuzzer_build)
58 # We'll set this to '1' for EFI builds in a different place.
59 conf.set10('SD_BOOT', false)
61 # Create a title-less summary section early, so it ends up first in the output.
62 # More items are added later after they have been detected.
63 summary({'build mode' : get_option('mode')})
65 #####################################################################
67 # Try to install the git pre-commit hook
68 add_git_hook_sh = find_program('tools/add-git-hook.sh', required : false)
69 if add_git_hook_sh.found()
70 git_hook = run_command(add_git_hook_sh, check : false)
71 if git_hook.returncode() == 0
72 message(git_hook.stdout().strip())
76 #####################################################################
79 if get_option('split-usr') == 'auto'
80 split_usr = not fs.is_symlink('/bin')
82 split_usr = get_option('split-usr') == 'true'
85 warning('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n\n'
86 + ' split-usr mode is going to be removed\n' +
87 '\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
89 conf.set10('HAVE_SPLIT_USR', split_usr,
90 description : '/usr/bin and /bin directories are separate')
92 if get_option('split-bin') == 'auto'
93 split_bin = not fs.is_symlink('/usr/sbin')
95 split_bin = get_option('split-bin') == 'true'
97 conf.set10('HAVE_SPLIT_BIN', split_bin,
98 description : 'bin and sbin directories are separate')
100 rootprefixdir = get_option('rootprefix')
101 # Unusual rootprefixdir values are used by some distros
102 # (see https://github.com/systemd/systemd/pull/7461).
103 rootprefix_default = split_usr ? '/' : '/usr'
104 if rootprefixdir == ''
105 rootprefixdir = rootprefix_default
107 rootprefixdir_noslash = rootprefixdir == '/' ? '' : rootprefixdir
109 have_standalone_binaries = get_option('standalone-binaries')
111 sysvinit_path = get_option('sysvinit-path')
112 sysvrcnd_path = get_option('sysvrcnd-path')
113 conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '',
114 description : 'SysV init scripts and rcN.d links are supported')
115 conf.set10('CREATE_LOG_DIRS', get_option('create-log-dirs'))
117 if get_option('hibernate') and not get_option('initrd')
118 error('hibernate depends on initrd')
121 conf.set10('BUMP_PROC_SYS_FS_FILE_MAX', get_option('bump-proc-sys-fs-file-max'))
122 conf.set10('BUMP_PROC_SYS_FS_NR_OPEN', get_option('bump-proc-sys-fs-nr-open'))
123 conf.set('HIGH_RLIMIT_NOFILE', 512*1024)
125 # Meson ignores the preceding arguments when joining paths if an absolute
126 # component is encountered, so this should canonicalize various paths when they
127 # are absolute or relative.
128 prefixdir = get_option('prefix')
129 if not prefixdir.startswith('/')
130 error('Prefix is not absolute: "@0@"'.format(prefixdir))
132 if prefixdir != rootprefixdir and rootprefixdir != '/' and not prefixdir.strip('/').startswith(rootprefixdir.strip('/') + '/')
133 error('Prefix is not below root prefix (now rootprefix=@0@ prefix=@1@)'.format(
134 rootprefixdir, prefixdir))
137 bindir = prefixdir / get_option('bindir')
138 libdir = prefixdir / get_option('libdir')
139 sysconfdir = prefixdir / get_option('sysconfdir')
140 includedir = prefixdir / get_option('includedir')
141 datadir = prefixdir / get_option('datadir')
142 localstatedir = '/' / get_option('localstatedir')
144 rootbindir = rootprefixdir / 'bin'
145 rootsbindir = rootprefixdir / (split_bin ? 'sbin' : 'bin')
146 rootlibexecdir = rootprefixdir / 'lib/systemd'
148 rootlibdir = get_option('rootlibdir')
150 # This will be a relative path if libdir is in prefix.
151 rootlibdir = get_option('libdir')
153 if not rootlibdir.startswith('/')
154 # If we have a relative path, add rootprefixdir to the front.
155 rootlibdir = rootprefixdir / rootlibdir
157 rootpkglibdir = rootlibdir / 'systemd'
159 install_sysconfdir = get_option('install-sysconfdir') != 'false'
160 install_sysconfdir_samples = get_option('install-sysconfdir') == 'true'
161 # Dirs of external packages
162 pkgconfigdatadir = get_option('pkgconfigdatadir') != '' ? get_option('pkgconfigdatadir') : datadir / 'pkgconfig'
163 pkgconfiglibdir = get_option('pkgconfiglibdir') != '' ? get_option('pkgconfiglibdir') : libdir / 'pkgconfig'
164 polkitpolicydir = datadir / 'polkit-1/actions'
165 polkitrulesdir = datadir / 'polkit-1/rules.d'
166 polkitpkladir = localstatedir / 'lib/polkit-1/localauthority/10-vendor.d'
167 xinitrcdir = get_option('xinitrcdir') != '' ? get_option('xinitrcdir') : sysconfdir / 'X11/xinit/xinitrc.d'
168 rpmmacrosdir = get_option('rpmmacrosdir')
169 if rpmmacrosdir != 'no'
170 rpmmacrosdir = prefixdir / rpmmacrosdir
172 modprobedir = rootprefixdir / 'lib/modprobe.d'
175 pkgdatadir = datadir / 'systemd'
176 environmentdir = prefixdir / 'lib/environment.d'
177 pkgsysconfdir = sysconfdir / 'systemd'
178 userunitdir = prefixdir / 'lib/systemd/user'
179 userpresetdir = prefixdir / 'lib/systemd/user-preset'
180 tmpfilesdir = prefixdir / 'lib/tmpfiles.d'
181 usertmpfilesdir = prefixdir / 'share/user-tmpfiles.d'
182 sysusersdir = prefixdir / 'lib/sysusers.d'
183 sysctldir = prefixdir / 'lib/sysctl.d'
184 binfmtdir = prefixdir / 'lib/binfmt.d'
185 modulesloaddir = prefixdir / 'lib/modules-load.d'
186 networkdir = rootprefixdir / 'lib/systemd/network'
187 pkgincludedir = includedir / 'systemd'
188 systemgeneratordir = rootlibexecdir / 'system-generators'
189 usergeneratordir = prefixdir / 'lib/systemd/user-generators'
190 systemenvgeneratordir = prefixdir / 'lib/systemd/system-environment-generators'
191 userenvgeneratordir = prefixdir / 'lib/systemd/user-environment-generators'
192 systemshutdowndir = rootlibexecdir / 'system-shutdown'
193 systemsleepdir = rootlibexecdir / 'system-sleep'
194 systemunitdir = rootprefixdir / 'lib/systemd/system'
195 systempresetdir = rootprefixdir / 'lib/systemd/system-preset'
196 udevlibexecdir = rootprefixdir / 'lib/udev'
197 udevrulesdir = udevlibexecdir / 'rules.d'
198 udevhwdbdir = udevlibexecdir / 'hwdb.d'
199 catalogdir = prefixdir / 'lib/systemd/catalog'
200 kerneldir = prefixdir / 'lib/kernel'
201 kernelinstalldir = kerneldir / 'install.d'
202 factorydir = datadir / 'factory'
203 bootlibdir = prefixdir / 'lib/systemd/boot/efi'
204 testsdir = prefixdir / 'lib/systemd/tests'
205 systemdstatedir = localstatedir / 'lib/systemd'
206 catalogstatedir = systemdstatedir / 'catalog'
207 randomseeddir = localstatedir / 'lib/systemd'
208 profiledir = rootlibexecdir / 'portable' / 'profile'
209 ntpservicelistdir = rootprefixdir / 'lib/systemd/ntp-units.d'
211 docdir = get_option('docdir')
213 docdir = datadir / 'doc/systemd'
216 pamlibdir = get_option('pamlibdir')
218 pamlibdir = rootlibdir / 'security'
221 pamconfdir = get_option('pamconfdir')
223 pamconfdir = prefixdir / 'lib/pam.d'
226 libcryptsetup_plugins_dir = get_option('libcryptsetup-plugins-dir')
227 if libcryptsetup_plugins_dir == ''
228 libcryptsetup_plugins_dir = rootlibdir / 'cryptsetup'
231 memory_accounting_default = get_option('memory-accounting-default')
232 status_unit_format_default = get_option('status-unit-format-default')
233 if status_unit_format_default == 'auto'
234 status_unit_format_default = conf.get('BUILD_MODE_DEVELOPER') == 1 ? 'name' : 'description'
237 conf.set_quoted('BINFMT_DIR', binfmtdir)
238 conf.set_quoted('BOOTLIBDIR', bootlibdir)
239 conf.set_quoted('CATALOG_DATABASE', catalogstatedir / 'database')
240 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
241 conf.set_quoted('DOC_DIR', docdir)
242 conf.set_quoted('DOCUMENT_ROOT', pkgdatadir / 'gatewayd')
243 conf.set_quoted('ENVIRONMENT_DIR', environmentdir)
244 conf.set_quoted('INCLUDE_DIR', includedir)
245 conf.set_quoted('LIBDIR', libdir)
246 conf.set_quoted('MODPROBE_DIR', modprobedir)
247 conf.set_quoted('MODULESLOAD_DIR', modulesloaddir)
248 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
249 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', bindir / 'pkttyagent')
250 conf.set_quoted('PREFIX', prefixdir)
251 conf.set_quoted('RANDOM_SEED', randomseeddir / 'random-seed')
252 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
253 conf.set_quoted('RC_LOCAL_PATH', get_option('rc-local'))
254 conf.set_quoted('ROOTBINDIR', rootbindir)
255 conf.set_quoted('ROOTLIBDIR', rootlibdir)
256 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
257 conf.set_quoted('ROOTPREFIX', rootprefixdir)
258 conf.set_quoted('ROOTPREFIX_NOSLASH', rootprefixdir_noslash)
259 conf.set_quoted('SYSCONF_DIR', sysconfdir)
260 conf.set_quoted('SYSCTL_DIR', sysctldir)
261 conf.set_quoted('SYSTEMCTL_BINARY_PATH', rootbindir / 'systemctl')
262 conf.set_quoted('SYSTEMD_BINARY_PATH', rootlibexecdir / 'systemd')
263 conf.set_quoted('SYSTEMD_CATALOG_DIR', catalogdir)
264 conf.set_quoted('SYSTEMD_CGROUPS_AGENT_PATH', rootlibexecdir / 'systemd-cgroups-agent')
265 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', rootlibexecdir / 'systemd-cryptsetup')
266 conf.set_quoted('SYSTEMD_EXPORT_PATH', rootlibexecdir / 'systemd-export')
267 conf.set_quoted('SYSTEMD_FSCK_PATH', rootlibexecdir / 'systemd-fsck')
268 conf.set_quoted('SYSTEMD_GROWFS_PATH', rootlibexecdir / 'systemd-growfs')
269 conf.set_quoted('SYSTEMD_HOMEWORK_PATH', rootlibexecdir / 'systemd-homework')
270 conf.set_quoted('SYSTEMD_IMPORT_FS_PATH', rootlibexecdir / 'systemd-import-fs')
271 conf.set_quoted('SYSTEMD_IMPORT_PATH', rootlibexecdir / 'systemd-import')
272 conf.set_quoted('SYSTEMD_INTEGRITYSETUP_PATH', rootlibexecdir / 'systemd-integritysetup')
273 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', pkgdatadir / 'kbd-model-map')
274 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', pkgdatadir / 'language-fallback-map')
275 conf.set_quoted('SYSTEMD_MAKEFS_PATH', rootlibexecdir / 'systemd-makefs')
276 conf.set_quoted('SYSTEMD_PULL_PATH', rootlibexecdir / 'systemd-pull')
277 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', rootlibexecdir / 'systemd-shutdown')
278 conf.set_quoted('SYSTEMD_TEST_DATA', testsdir / 'testdata')
279 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', rootbindir / 'systemd-tty-ask-password-agent')
280 conf.set_quoted('SYSTEMD_UPDATE_HELPER_PATH', rootlibexecdir / 'systemd-update-helper')
281 conf.set_quoted('SYSTEMD_USERWORK_PATH', rootlibexecdir / 'systemd-userwork')
282 conf.set_quoted('SYSTEMD_VERITYSETUP_PATH', rootlibexecdir / 'systemd-veritysetup')
283 conf.set_quoted('SYSTEM_CONFIG_UNIT_DIR', pkgsysconfdir / 'system')
284 conf.set_quoted('SYSTEM_DATA_UNIT_DIR', systemunitdir)
285 conf.set_quoted('SYSTEM_ENV_GENERATOR_DIR', systemenvgeneratordir)
286 conf.set_quoted('SYSTEM_GENERATOR_DIR', systemgeneratordir)
287 conf.set_quoted('SYSTEM_PRESET_DIR', systempresetdir)
288 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
289 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
290 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
291 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
292 conf.set_quoted('SYSUSERS_DIR', sysusersdir)
293 conf.set_quoted('TMPFILES_DIR', tmpfilesdir)
294 conf.set_quoted('USER_TMPFILES_DIR', usertmpfilesdir)
295 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
296 conf.set_quoted('UDEV_HWDB_DIR', udevhwdbdir)
297 conf.set_quoted('UDEV_RULES_DIR', udevrulesdir)
298 conf.set_quoted('UPDATE_HELPER_USER_TIMEOUT', get_option('update-helper-user-timeout'))
299 conf.set_quoted('USER_CONFIG_UNIT_DIR', pkgsysconfdir / 'user')
300 conf.set_quoted('USER_DATA_UNIT_DIR', userunitdir)
301 conf.set_quoted('USER_ENV_GENERATOR_DIR', userenvgeneratordir)
302 conf.set_quoted('USER_GENERATOR_DIR', usergeneratordir)
303 conf.set_quoted('USER_KEYRING_PATH', pkgsysconfdir / 'import-pubring.gpg')
304 conf.set_quoted('USER_PRESET_DIR', userpresetdir)
305 conf.set_quoted('VENDOR_KEYRING_PATH', rootlibexecdir / 'import-pubring.gpg')
307 conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
308 conf.set10('ENABLE_URLIFY', get_option('urlify'))
309 conf.set10('ENABLE_FEXECVE', get_option('fexecve'))
310 conf.set10('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default)
311 conf.set('STATUS_UNIT_FORMAT_DEFAULT', 'STATUS_UNIT_FORMAT_' + status_unit_format_default.to_upper())
312 conf.set_quoted('STATUS_UNIT_FORMAT_DEFAULT_STR', status_unit_format_default)
314 conf.set10('FIRST_BOOT_FULL_PRESET', get_option('first-boot-full-preset'))
316 #####################################################################
318 cc = meson.get_compiler('c')
319 pkgconfig = import('pkgconfig')
320 meson_build_sh = find_program('tools/meson-build.sh')
322 want_tests = get_option('tests')
323 slow_tests = want_tests != 'false' and get_option('slow-tests')
324 fuzz_tests = want_tests != 'false' and get_option('fuzz-tests')
325 install_tests = get_option('install-tests')
327 if add_languages('cpp', required : fuzzer_build)
328 # Used only for tests
329 cxx = meson.get_compiler('cpp')
330 cxx_cmd = ' '.join(cxx.cmd_array())
336 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer', required : false)
337 if fuzzing_engine.found()
338 add_project_arguments('-fsanitize-coverage=trace-pc-guard,trace-cmp', language : 'c')
339 elif cc.has_argument('-fsanitize=fuzzer-no-link')
340 add_project_arguments('-fsanitize=fuzzer-no-link', language : 'c')
342 error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported')
345 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
348 # Those generate many false positives, and we do not want to change the code to
350 basic_disabled_warnings = [
351 '-Wno-missing-field-initializers',
352 '-Wno-unused-parameter',
355 possible_common_cc_flags = [
359 '-Werror=format-signedness',
360 '-Werror=implicit-function-declaration',
361 '-Werror=incompatible-pointer-types',
362 '-Werror=int-conversion',
364 '-Werror=override-init',
365 '-Werror=return-type',
366 '-Werror=shift-count-overflow',
367 '-Werror=shift-overflow=2',
370 # gperf prevents us from enabling this because it does not emit fallthrough
371 # attribute with clang.
372 #'-Wimplicit-fallthrough',
373 '-Wimplicit-fallthrough=5',
376 '-Wmissing-include-dirs',
377 '-Wmissing-noreturn',
379 '-Wold-style-definition',
383 '-Wstrict-aliasing=2',
384 '-Wstrict-prototypes',
385 '-Wsuggest-attribute=noreturn',
389 # negative arguments are correctly detected starting with meson 0.46.
390 '-Wno-error=#warnings', # clang
391 '-Wno-string-plus-int', # clang
394 c_args = get_option('c_args')
396 # Our json library does not support -ffinite-math-only, which is enabled by -Ofast or -ffast-math.
397 if (('-Ofast' in c_args or '-ffast-math' in c_args or '-ffinite-math-only' in c_args) and '-fno-finite-math-only' not in c_args)
398 error('-Ofast, -ffast-math, or -ffinite-math-only is specified in c_args.')
401 # Disable -Wmaybe-uninitialized when compiling with -Os/-O1/-O3/etc. There are
402 # too many false positives with gcc >= 8. Effectively, we only test with -O0
403 # and -O2; this should be enough to catch most important cases without too much
404 # busywork. See https://github.com/systemd/systemd/pull/19226.
405 if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or
406 cc.version().version_compare('<10') or
411 possible_common_cc_flags += '-Wno-maybe-uninitialized'
414 # Disable -Wno-unused-result with gcc, see
415 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425.
416 if cc.get_id() == 'gcc'
417 possible_common_cc_flags += '-Wno-unused-result'
420 # --as-needed and --no-undefined are provided by meson by default,
421 # run 'meson configure' to see what is enabled
422 possible_link_flags = [
423 '-Wl,--fatal-warnings',
429 if get_option('b_sanitize') == 'none'
430 possible_link_flags += '-Wl,--warn-common'
433 if cc.get_id() == 'clang'
434 possible_common_cc_flags += [
435 '-Wno-typedef-redefinition',
436 '-Wno-gnu-variable-sized-type-not-at-end',
440 if get_option('mode') == 'release'
441 # We could enable 'pattern' for developer mode, but that can interfere with
442 # valgrind and sanitizer builds. Also, clang does not zero-initialize unions,
443 # breaking some of our code (https://reviews.llvm.org/D68115).
444 possible_common_cc_flags += '-ftrivial-auto-var-init=zero'
447 possible_cc_flags = possible_common_cc_flags + [
448 '-Werror=missing-declarations',
449 '-Werror=missing-prototypes',
450 '-fdiagnostics-show-option',
452 '-fno-strict-aliasing',
454 '-fstack-protector-strong',
455 '-fstrict-flex-arrays=1',
456 '-fvisibility=hidden',
457 '--param=ssp-buffer-size=4',
460 if get_option('buildtype') != 'debug'
461 possible_cc_flags += [
462 '-ffunction-sections',
466 possible_link_flags += '-Wl,--gc-sections'
469 if get_option('mode') == 'developer'
470 possible_cc_flags += '-fno-omit-frame-pointer'
473 add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
474 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
475 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
477 have = cc.has_argument('-Wzero-length-bounds')
478 conf.set10('HAVE_ZERO_LENGTH_BOUNDS', have)
482 #include <inttypes.h>
483 typedef uint64_t usec_t;
484 usec_t now(clockid_t clock);
489 ''', args: '-Werror=shadow', name : '-Werror=shadow with local shadowing')
490 add_project_arguments('-Werror=shadow', language : 'c')
494 add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
497 cpp = ' '.join(cc.cmd_array()) + ' -E'
499 has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
501 #####################################################################
502 # compilation result tests
504 conf.set('_GNU_SOURCE', true)
505 conf.set('__SANE_USERSPACE_TYPES__', true)
506 conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)
508 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
509 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
510 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
511 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
512 conf.set('SIZEOF_TIMEX_MEMBER', cc.sizeof('typeof(((struct timex *)0)->freq)', prefix : '#include <sys/timex.h>'))
514 long_max = cc.compute_int(
516 prefix : '#include <limits.h>',
517 guess : 0x7FFFFFFFFFFFFFFF,
518 high : 0x7FFFFFFFFFFFFFFF)
519 assert(long_max > 100000)
520 conf.set_quoted('LONG_MAX_STR', '@0@'.format(long_max))
524 #include <sys/mount.h>
525 #include <sys/stat.h>
528 foreach decl : ['char16_t',
534 # We get -1 if the size cannot be determined
535 have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
537 if decl == 'struct mount_attr'
539 want_linux_fs_h = false
541 have = cc.sizeof(decl,
542 prefix : decl_headers + '#include <linux/fs.h>',
543 args : '-D_GNU_SOURCE') > 0
544 want_linux_fs_h = have
548 if decl == 'struct statx'
550 want_linux_stat_h = false
552 have = cc.sizeof(decl,
553 prefix : decl_headers + '#include <linux/stat.h>',
554 args : '-D_GNU_SOURCE') > 0
555 want_linux_stat_h = have
559 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
562 conf.set10('WANT_LINUX_STAT_H', want_linux_stat_h)
563 conf.set10('WANT_LINUX_FS_H', want_linux_fs_h)
565 foreach ident : ['secure_getenv', '__secure_getenv']
566 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
570 ['memfd_create', '''#include <sys/mman.h>'''],
571 ['gettid', '''#include <sys/types.h>
572 #include <unistd.h>'''],
573 ['pivot_root', '''#include <stdlib.h>
574 #include <unistd.h>'''], # no known header declares pivot_root
575 ['ioprio_get', '''#include <sched.h>'''], # no known header declares ioprio_get
576 ['ioprio_set', '''#include <sched.h>'''], # no known header declares ioprio_set
577 ['name_to_handle_at', '''#include <sys/types.h>
578 #include <sys/stat.h>
579 #include <fcntl.h>'''],
580 ['setns', '''#include <sched.h>'''],
581 ['renameat2', '''#include <stdio.h>
582 #include <fcntl.h>'''],
583 ['kcmp', '''#include <linux/kcmp.h>'''],
584 ['keyctl', '''#include <sys/types.h>
585 #include <keyutils.h>'''],
586 ['copy_file_range', '''#include <sys/syscall.h>
587 #include <unistd.h>'''],
588 ['bpf', '''#include <sys/syscall.h>
589 #include <unistd.h>'''],
590 ['statx', '''#include <sys/types.h>
591 #include <sys/stat.h>
592 #include <unistd.h>'''],
593 ['explicit_bzero' , '''#include <string.h>'''],
594 ['reallocarray', '''#include <stdlib.h>'''],
595 ['set_mempolicy', '''#include <stdlib.h>
596 #include <unistd.h>'''],
597 ['get_mempolicy', '''#include <stdlib.h>
598 #include <unistd.h>'''],
599 ['pidfd_send_signal', '''#include <stdlib.h>
602 #include <sys/wait.h>'''],
603 ['pidfd_open', '''#include <stdlib.h>
606 #include <sys/wait.h>'''],
607 ['rt_sigqueueinfo', '''#include <stdlib.h>
610 #include <sys/wait.h>'''],
611 ['rt_tgsigqueueinfo', '''#include <stdlib.h>
614 #include <sys/wait.h>'''],
615 ['mallinfo', '''#include <malloc.h>'''],
616 ['mallinfo2', '''#include <malloc.h>'''],
617 ['execveat', '''#include <unistd.h>'''],
618 ['close_range', '''#include <unistd.h>'''],
619 ['epoll_pwait2', '''#include <sys/epoll.h>'''],
620 ['mount_setattr', '''#include <sys/mount.h>'''],
621 ['move_mount', '''#include <sys/mount.h>'''],
622 ['open_tree', '''#include <sys/mount.h>'''],
623 ['fsopen', '''#include <sys/mount.h>'''],
624 ['fsconfig', '''#include <sys/mount.h>'''],
625 ['getdents64', '''#include <dirent.h>'''],
628 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
629 conf.set10('HAVE_' + ident[0].to_upper(), have)
632 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
633 conf.set10('USE_SYS_RANDOM_H', true)
634 conf.set10('HAVE_GETRANDOM', true)
636 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
637 conf.set10('USE_SYS_RANDOM_H', false)
638 conf.set10('HAVE_GETRANDOM', have)
641 #####################################################################
643 version_tag = get_option('version-tag')
645 vcs_data = configuration_data()
646 vcs_data.set('VCS_TAG', version_tag)
647 version_h = configure_file(configuration : vcs_data,
648 input : 'src/version/version.h.in',
649 output : 'version.h')
652 project_source_root + '/tools/meson-vcs-tag.sh',
654 meson.project_version()]
657 input : 'src/version/version.h.in',
658 output : 'version.h',
662 versiondep = declare_dependency(sources: version_h)
664 shared_lib_tag = get_option('shared-lib-tag')
665 if shared_lib_tag == ''
666 shared_lib_tag = meson.project_version()
669 sh = find_program('sh')
670 echo = find_program('echo')
671 sed = find_program('sed')
672 awk = find_program('awk')
673 stat = find_program('stat')
674 ln = find_program('ln')
675 git = find_program('git', required : false)
676 env = find_program('env')
677 perl = find_program('perl', required : false)
678 rsync = find_program('rsync', required : false)
679 meson_make_symlink = project_source_root + '/tools/meson-make-symlink.sh'
681 mkdir_p = 'mkdir -p $DESTDIR/@0@'
683 # If -Dxxx-path option is found, use that. Otherwise, check in $PATH,
684 # /usr/sbin, /sbin, and fall back to the default from middle column.
685 progs = [['quotaon', '/usr/sbin/quotaon' ],
686 ['quotacheck', '/usr/sbin/quotacheck' ],
687 ['kmod', '/usr/bin/kmod' ],
688 ['kexec', '/usr/sbin/kexec' ],
689 ['sulogin', '/usr/sbin/sulogin' ],
690 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
691 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
692 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
693 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
694 ['nologin', '/usr/sbin/nologin', ],
697 path = get_option(prog[0] + '-path')
699 message('Using @1@ for @0@'.format(prog[0], path))
701 exe = find_program(prog[0],
702 '/usr/sbin/' + prog[0],
705 path = exe.found() ? exe.path() : prog[1]
707 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
708 conf.set_quoted(name, path)
711 conf.set_quoted('TELINIT', get_option('telinit-path'))
713 if run_command(ln, '--relative', '--help', check : false).returncode() != 0
714 error('ln does not support --relative (added in coreutils 8.16)')
717 ############################################################
719 gperf = find_program('gperf')
721 gperf_test_format = '''
723 const char * in_word_set(const char *, @0@);
726 gperf_snippet = run_command(sh, '-c', 'echo foo,bar | "$1" -L ANSI-C', '_', gperf,
728 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
729 if cc.compiles(gperf_test)
730 gperf_len_type = 'size_t'
732 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
733 if cc.compiles(gperf_test)
734 gperf_len_type = 'unsigned'
736 error('unable to determine gperf len type')
739 message('gperf len type is @0@'.format(gperf_len_type))
740 conf.set('GPERF_LEN_TYPE', gperf_len_type,
741 description : 'The type of gperf "len" parameter')
743 ############################################################
745 if not cc.has_header('sys/capability.h')
746 error('POSIX caps headers not found')
748 foreach header : ['crypt.h',
750 'linux/vm_sockets.h',
752 'valgrind/memcheck.h',
753 'valgrind/valgrind.h',
754 'linux/time_types.h',
758 conf.set10('HAVE_' + header.underscorify().to_upper(),
759 cc.has_header(header))
762 ############################################################
764 fallback_hostname = get_option('fallback-hostname')
765 if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0] == '-'
766 error('Invalid fallback-hostname configuration')
767 # A more extensive test is done in test-hostname-util. Let's catch
768 # the most obvious errors here so we don't fail with an assert later.
770 conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
772 default_hierarchy = get_option('default-hierarchy')
773 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
774 description : 'default cgroup hierarchy as string')
775 if default_hierarchy == 'legacy'
776 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
777 elif default_hierarchy == 'hybrid'
778 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
780 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
783 extra_net_naming_schemes = []
784 extra_net_naming_map = []
785 foreach scheme: get_option('extra-net-naming-schemes').split(',')
787 name = scheme.split('=')[0]
788 value = scheme.split('=')[1]
789 NAME = name.underscorify().to_upper()
791 foreach field: value.split('+')
792 VALUE += 'NAMING_' + field.underscorify().to_upper()
794 extra_net_naming_schemes += 'NAMING_@0@ = @1@,'.format(NAME, '|'.join(VALUE))
795 extra_net_naming_map += '{ "@0@", NAMING_@1@ },'.format(name, NAME)
798 conf.set('EXTRA_NET_NAMING_SCHEMES', ' '.join(extra_net_naming_schemes))
799 conf.set('EXTRA_NET_NAMING_MAP', ' '.join(extra_net_naming_map))
801 default_net_naming_scheme = get_option('default-net-naming-scheme')
802 conf.set_quoted('DEFAULT_NET_NAMING_SCHEME', default_net_naming_scheme)
803 if default_net_naming_scheme != 'latest'
804 conf.set('_DEFAULT_NET_NAMING_SCHEME_TEST',
805 'NAMING_' + default_net_naming_scheme.underscorify().to_upper())
808 time_epoch = get_option('time-epoch')
810 time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check : true).stdout().strip()
811 if time_epoch == '' and git.found() and fs.exists('.git')
812 # If we're in a git repository, use the creation time of the latest git tag.
813 latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags',
815 if latest_tag.returncode() == 0
816 time_epoch = run_command(
817 git, 'log', '--no-show-signature', '-1', '--format=%at',
818 latest_tag.stdout().strip(),
819 check : false).stdout()
824 time_epoch = run_command(stat, '-c', '%Y', NEWS,
825 check : true).stdout()
827 time_epoch = time_epoch.strip().to_int()
829 conf.set('TIME_EPOCH', time_epoch)
831 conf.set('CLOCK_VALID_RANGE_USEC_MAX', get_option('clock-valid-range-usec-max'))
833 default_user_shell = get_option('default-user-shell')
834 conf.set_quoted('DEFAULT_USER_SHELL', default_user_shell)
835 conf.set_quoted('DEFAULT_USER_SHELL_NAME', fs.name(default_user_shell))
837 foreach tuple : [['system-alloc-uid-min', 'SYS_UID_MIN', 1], # Also see login.defs(5).
838 ['system-uid-max', 'SYS_UID_MAX', 999],
839 ['system-alloc-gid-min', 'SYS_GID_MIN', 1],
840 ['system-gid-max', 'SYS_GID_MAX', 999]]
841 v = get_option(tuple[0])
845 '/^\s*@0@\s+/ { uid=$2 } END { print uid }'.format(tuple[1]),
847 check : false).stdout().strip()
854 conf.set(tuple[0].underscorify().to_upper(), v)
856 if conf.get('SYSTEM_ALLOC_UID_MIN') >= conf.get('SYSTEM_UID_MAX')
857 error('Invalid uid allocation range')
859 if conf.get('SYSTEM_ALLOC_GID_MIN') >= conf.get('SYSTEM_GID_MAX')
860 error('Invalid gid allocation range')
863 dynamic_uid_min = get_option('dynamic-uid-min')
864 dynamic_uid_max = get_option('dynamic-uid-max')
865 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
866 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
868 container_uid_base_min = get_option('container-uid-base-min')
869 container_uid_base_max = get_option('container-uid-base-max')
870 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
871 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
873 nobody_user = get_option('nobody-user')
874 nobody_group = get_option('nobody-group')
876 if not meson.is_cross_build()
877 getent_result = run_command('getent', 'passwd', '65534', check : false)
878 if getent_result.returncode() == 0
879 name = getent_result.stdout().split(':')[0]
880 if name != nobody_user
882 '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) +
883 'Your build will result in an user table setup that is incompatible with the local system.')
886 id_result = run_command('id', '-u', nobody_user, check : false)
887 if id_result.returncode() == 0
888 id = id_result.stdout().strip().to_int()
891 '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) +
892 'Your build will result in an user table setup that is incompatible with the local system.')
896 getent_result = run_command('getent', 'group', '65534', check : false)
897 if getent_result.returncode() == 0
898 name = getent_result.stdout().split(':')[0]
899 if name != nobody_group
901 '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) +
902 'Your build will result in an group table setup that is incompatible with the local system.')
905 id_result = run_command('id', '-g', nobody_group, check : false)
906 if id_result.returncode() == 0
907 id = id_result.stdout().strip().to_int()
910 '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) +
911 'Your build will result in an group table setup that is incompatible with the local system.')
915 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
917 'The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
918 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
921 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
922 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
925 foreach option : ['adm-gid',
942 'systemd-journal-gid',
943 'systemd-network-uid',
944 'systemd-resolve-uid',
945 'systemd-timesync-uid']
946 name = option.underscorify().to_upper()
947 val = get_option(option)
949 # Ensure provided GID argument is numeric, otherwise fall back to default assignment
950 conf.set(name, val > 0 ? val : '-')
952 static_ugids += '@0@:@1@'.format(option, val)
956 conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
957 conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
959 dev_kvm_mode = get_option('dev-kvm-mode')
960 conf.set_quoted('DEV_KVM_MODE', dev_kvm_mode) # FIXME: convert to 0o… notation
961 conf.set10('DEV_KVM_UACCESS', dev_kvm_mode != '0666')
962 group_render_mode = get_option('group-render-mode')
963 conf.set_quoted('GROUP_RENDER_MODE', group_render_mode)
964 conf.set10('GROUP_RENDER_UACCESS', group_render_mode != '0666')
966 kill_user_processes = get_option('default-kill-user-processes')
967 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
969 dns_servers = get_option('dns-servers')
970 conf.set_quoted('DNS_SERVERS', dns_servers)
972 ntp_servers = get_option('ntp-servers')
973 conf.set_quoted('NTP_SERVERS', ntp_servers)
975 default_locale = get_option('default-locale')
976 conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale)
978 nspawn_locale = get_option('nspawn-locale')
979 conf.set_quoted('SYSTEMD_NSPAWN_LOCALE', nspawn_locale)
981 localegen_path = get_option('localegen-path')
982 if localegen_path != ''
983 conf.set_quoted('LOCALEGEN_PATH', localegen_path)
985 conf.set10('HAVE_LOCALEGEN', localegen_path != '')
987 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
989 service_watchdog = get_option('service-watchdog')
990 watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
991 conf.set_quoted('SERVICE_WATCHDOG', watchdog_value)
993 conf.set_quoted('SUSHELL', get_option('debug-shell'))
994 conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
996 enable_debug_hashmap = false
997 enable_debug_mmap_cache = false
998 enable_debug_siphash = false
999 foreach name : get_option('debug-extra')
1000 if name == 'hashmap'
1001 enable_debug_hashmap = true
1002 elif name == 'mmap-cache'
1003 enable_debug_mmap_cache = true
1004 elif name == 'siphash'
1005 enable_debug_siphash = true
1007 message('unknown debug option "@0@", ignoring'.format(name))
1010 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
1011 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
1012 conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash)
1014 conf.set10('VALGRIND', get_option('valgrind'))
1015 conf.set10('LOG_TRACE', get_option('log-trace'))
1017 default_user_path = get_option('user-path')
1018 if default_user_path != ''
1019 conf.set_quoted('DEFAULT_USER_PATH', default_user_path)
1023 #####################################################################
1025 threads = dependency('threads')
1026 librt = cc.find_library('rt')
1027 libm = cc.find_library('m')
1028 libdl = cc.find_library('dl')
1029 libcrypt = cc.find_library('crypt')
1031 # On some architectures, libatomic is required. But on some installations,
1032 # it is found, but actual linking fails. So let's try to use it opportunistically.
1033 # If it is installed, but not needed, it will be dropped because of --as-needed.
1034 if cc.links('''int main(int argc, char **argv) { return 0; }''',
1037 libatomic = declare_dependency(link_args : '-latomic')
1042 crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
1044 ['crypt_ra', crypt_header],
1045 ['crypt_preferred_method', crypt_header],
1046 ['crypt_gensalt_ra', crypt_header]]
1048 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
1049 dependencies : libcrypt)
1050 conf.set10('HAVE_' + ident[0].to_upper(), have)
1053 libcap = dependency('libcap', required : false)
1054 if not libcap.found()
1055 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
1056 libcap = cc.find_library('cap')
1059 want_bpf_framework = get_option('bpf-framework')
1060 bpf_compiler = get_option('bpf-compiler')
1061 bpf_framework_required = want_bpf_framework == 'true'
1063 libbpf_version_requirement = '>= 0.1.0'
1064 if bpf_compiler == 'gcc'
1065 libbpf_version_requirement = '>= 1.0.0'
1067 libbpf = dependency('libbpf', required : bpf_framework_required, version : libbpf_version_requirement)
1068 conf.set10('HAVE_LIBBPF', libbpf.found())
1070 bpftool_strip_version_requirement = '>= 5.13.0'
1071 if bpf_compiler == 'gcc'
1072 bpftool_strip_version_requirement = '>= 7.0.0'
1075 if want_bpf_framework == 'false' or not libbpf.found() or skip_deps
1076 conf.set10('BPF_FRAMEWORK', false)
1079 clang_supports_bpf = false
1080 bpf_gcc_found = false
1081 bpftool_strip = false
1084 if bpf_compiler == 'clang'
1085 # Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu
1086 # (like clang-10/llvm-strip-10)
1087 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')
1088 r = find_program('clang', required : bpf_framework_required, version : '>= 10.0.0')
1089 clang_found = r.found()
1093 # Assume that the required flags are supported by the found clang.
1094 clang_supports_flags = clang_found
1097 clang = cc.cmd_array()
1098 clang_supports_flags = cc.has_argument('-Wno-compare-distinct-pointer-types')
1102 # Check if 'clang -target bpf' is supported.
1103 clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0
1105 elif bpf_compiler == 'gcc'
1106 warning('GCC BPF Compiler support is experimental and not recommended.')
1107 bpf_gcc = find_program('bpf-gcc',
1109 version : '>= 12.1.0')
1110 bpf_gcc_found = bpf_gcc.found()
1113 if clang_supports_bpf or bpf_gcc_found
1114 # Debian installs this in /usr/sbin/ which is not in $PATH.
1115 # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian.
1116 # We use 'bpftool gen object' subcommand for bpftool strip, it was added by d80b2fcbe0a023619e0fc73112f2a02c2662f6ab (v5.13).
1117 bpftool_strip_required = bpf_framework_required and bpf_compiler == 'gcc'
1118 bpftool = find_program('bpftool',
1119 '/usr/sbin/bpftool',
1120 required : bpftool_strip_required,
1121 version : bpftool_strip_version_requirement)
1124 bpftool_strip = true
1126 elif bpf_compiler == 'clang'
1127 # We require the 'bpftool gen skeleton' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6).
1128 bpftool = find_program('bpftool',
1129 '/usr/sbin/bpftool',
1130 required : bpf_framework_required,
1131 version : '>= 5.6.0')
1134 # We use `llvm-strip` as a fallback if `bpftool gen object` strip support is not available.
1135 if not bpftool_strip and bpftool.found() and clang_supports_bpf
1136 if not meson.is_cross_build()
1137 llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip',
1138 check : true).stdout().strip()
1140 llvm_strip_bin = 'llvm-strip'
1142 llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0')
1143 deps_found = llvm_strip.found()
1147 # Can build BPF program from source code in restricted C
1148 conf.set10('BPF_FRAMEWORK', deps_found)
1151 libmount = dependency('mount',
1152 version : fuzzer_build ? '>= 0' : '>= 2.30')
1154 want_libfdisk = get_option('fdisk')
1155 if want_libfdisk != 'false' and not skip_deps
1156 libfdisk = dependency('fdisk',
1157 version : '>= 2.32',
1158 required : want_libfdisk == 'true')
1159 have = libfdisk.found()
1164 conf.set10('HAVE_LIBFDISK', have)
1166 want_pwquality = get_option('pwquality')
1167 if want_pwquality != 'false' and not skip_deps
1168 libpwquality = dependency('pwquality', required : want_pwquality == 'true')
1169 have = libpwquality.found()
1174 conf.set10('HAVE_PWQUALITY', have)
1176 want_seccomp = get_option('seccomp')
1177 if want_seccomp != 'false' and not skip_deps
1178 libseccomp = dependency('libseccomp',
1179 version : '>= 2.3.1',
1180 required : want_seccomp == 'true')
1181 have = libseccomp.found()
1186 conf.set10('HAVE_SECCOMP', have)
1188 want_selinux = get_option('selinux')
1189 if want_selinux != 'false' and not skip_deps
1190 libselinux = dependency('libselinux',
1191 version : '>= 2.1.9',
1192 required : want_selinux == 'true')
1193 have = libselinux.found()
1198 conf.set10('HAVE_SELINUX', have)
1200 want_apparmor = get_option('apparmor')
1201 if want_apparmor != 'false' and not skip_deps
1202 libapparmor = dependency('libapparmor',
1203 version : '>= 2.13',
1204 required : want_apparmor == 'true')
1205 have = libapparmor.found()
1210 conf.set10('HAVE_APPARMOR', have)
1212 have = get_option('smack') and get_option('smack-run-label') != ''
1213 conf.set10('HAVE_SMACK_RUN_LABEL', have)
1215 conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
1218 have = get_option('smack') and get_option('smack-default-process-label') != ''
1220 conf.set_quoted('SMACK_DEFAULT_PROCESS_LABEL', get_option('smack-default-process-label'))
1223 want_polkit = get_option('polkit')
1224 install_polkit = false
1225 install_polkit_pkla = false
1226 if want_polkit != 'false' and not skip_deps
1227 install_polkit = true
1229 libpolkit = dependency('polkit-gobject-1',
1231 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
1232 message('Old polkit detected, will install pkla files')
1233 install_polkit_pkla = true
1236 conf.set10('ENABLE_POLKIT', install_polkit)
1238 want_acl = get_option('acl')
1239 if want_acl != 'false' and not skip_deps
1240 libacl = cc.find_library('acl', required : want_acl == 'true')
1241 have = libacl.found()
1246 conf.set10('HAVE_ACL', have)
1248 want_audit = get_option('audit')
1249 if want_audit != 'false' and not skip_deps
1250 libaudit = dependency('audit', required : want_audit == 'true')
1251 have = libaudit.found()
1256 conf.set10('HAVE_AUDIT', have)
1258 want_blkid = get_option('blkid')
1259 if want_blkid != 'false' and not skip_deps
1260 libblkid = dependency('blkid', required : want_blkid == 'true')
1261 have = libblkid.found()
1263 conf.set10('HAVE_BLKID_PROBE_SET_HINT',
1264 have and cc.has_function('blkid_probe_set_hint', dependencies : libblkid))
1269 conf.set10('HAVE_BLKID', have)
1271 want_kmod = get_option('kmod')
1272 if want_kmod != 'false' and not skip_deps
1273 libkmod = dependency('libkmod',
1275 required : want_kmod == 'true')
1276 have = libkmod.found()
1281 conf.set10('HAVE_KMOD', have)
1283 want_xenctrl = get_option('xenctrl')
1284 if want_xenctrl != 'false' and not skip_deps
1285 libxenctrl = dependency('xencontrol',
1287 required : want_xenctrl == 'true')
1288 have = libxenctrl.found()
1293 conf.set10('HAVE_XENCTRL', have)
1295 want_pam = get_option('pam')
1296 if want_pam != 'false' and not skip_deps
1297 libpam = cc.find_library('pam', required : want_pam == 'true')
1298 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1299 have = libpam.found() and libpam_misc.found()
1305 conf.set10('HAVE_PAM', have)
1307 want_microhttpd = get_option('microhttpd')
1308 if want_microhttpd != 'false' and not skip_deps
1309 libmicrohttpd = dependency('libmicrohttpd',
1310 version : '>= 0.9.33',
1311 required : want_microhttpd == 'true')
1312 have = libmicrohttpd.found()
1317 conf.set10('HAVE_MICROHTTPD', have)
1319 want_libcryptsetup = get_option('libcryptsetup')
1320 want_libcryptsetup_plugins = get_option('libcryptsetup-plugins')
1322 if want_libcryptsetup_plugins == 'true' and want_libcryptsetup == 'false'
1323 error('libcryptsetup-plugins can not be requested without libcryptsetup')
1326 if want_libcryptsetup != 'false' and not skip_deps
1327 libcryptsetup = dependency('libcryptsetup',
1328 version : want_libcryptsetup_plugins == 'true' ? '>= 2.4.0' : '>= 2.0.1',
1329 required : want_libcryptsetup == 'true' or want_libcryptsetup_plugins == 'true')
1330 have = libcryptsetup.found()
1332 foreach ident : ['crypt_set_metadata_size',
1333 'crypt_activate_by_signed_key',
1335 'crypt_reencrypt_init_by_passphrase',
1337 'crypt_set_data_offset']
1338 have_ident = have and cc.has_function(
1340 prefix : '#include <libcryptsetup.h>',
1341 dependencies : libcryptsetup)
1342 conf.set10('HAVE_' + ident.to_upper(), have_ident)
1348 conf.set10('HAVE_LIBCRYPTSETUP', have)
1350 if want_libcryptsetup_plugins != 'false' and not skip_deps
1351 have = (cc.has_function(
1352 'crypt_activate_by_token_pin',
1353 prefix : '#include <libcryptsetup.h>',
1354 dependencies : libcryptsetup) and
1356 'crypt_token_external_path',
1357 prefix : '#include <libcryptsetup.h>',
1358 dependencies : libcryptsetup))
1362 conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have)
1364 want_libcurl = get_option('libcurl')
1365 if want_libcurl != 'false' and not skip_deps
1366 libcurl = dependency('libcurl',
1367 version : '>= 7.32.0',
1368 required : want_libcurl == 'true')
1369 have = libcurl.found()
1374 conf.set10('HAVE_LIBCURL', have)
1375 conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
1377 want_libidn = get_option('libidn')
1378 want_libidn2 = get_option('libidn2')
1379 if want_libidn == 'true' and want_libidn2 == 'true'
1380 error('libidn and libidn2 cannot be requested simultaneously')
1383 if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps
1384 libidn = dependency('libidn2',
1385 required : want_libidn2 == 'true')
1386 have = libidn.found()
1391 conf.set10('HAVE_LIBIDN2', have)
1392 if not have and want_libidn != 'false' and not skip_deps
1393 # libidn is used for both libidn and libidn2 objects
1394 libidn = dependency('libidn',
1395 required : want_libidn == 'true')
1396 have = libidn.found()
1400 conf.set10('HAVE_LIBIDN', have)
1402 want_libiptc = get_option('libiptc')
1403 if want_libiptc != 'false' and not skip_deps
1404 libiptc = dependency('libiptc',
1405 required : want_libiptc == 'true')
1406 have = libiptc.found()
1411 conf.set10('HAVE_LIBIPTC', have)
1413 want_qrencode = get_option('qrencode')
1414 if want_qrencode != 'false' and not skip_deps
1415 libqrencode = dependency('libqrencode',
1417 required : want_qrencode == 'true')
1418 have = libqrencode.found()
1423 conf.set10('HAVE_QRENCODE', have)
1425 want_gcrypt = get_option('gcrypt')
1426 if want_gcrypt != 'false' and not skip_deps
1427 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1428 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1429 have = libgcrypt.found() and libgpg_error.found()
1434 # link to neither of the libs if one is not found
1438 conf.set10('HAVE_GCRYPT', have)
1440 want_gnutls = get_option('gnutls')
1441 if want_gnutls != 'false' and not skip_deps
1442 libgnutls = dependency('gnutls',
1443 version : '>= 3.1.4',
1444 required : want_gnutls == 'true')
1445 have = libgnutls.found()
1450 conf.set10('HAVE_GNUTLS', have)
1452 want_openssl = get_option('openssl')
1453 if want_openssl != 'false' and not skip_deps
1454 libopenssl = dependency('openssl',
1455 version : '>= 1.1.0',
1456 required : want_openssl == 'true')
1457 have = libopenssl.found()
1462 conf.set10('HAVE_OPENSSL', have)
1464 want_p11kit = get_option('p11kit')
1465 if want_p11kit != 'false' and not skip_deps
1466 libp11kit = dependency('p11-kit-1',
1467 version : '>= 0.23.3',
1468 required : want_p11kit == 'true')
1469 have = libp11kit.found()
1470 libp11kit_cflags = libp11kit.partial_dependency(includes: true, compile_args: true)
1473 libp11kit_cflags = []
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 pymod = import('python')
1975 python = pymod.find_installation('python3', required : true, modules : ['jinja2'])
1976 python_39 = python.language_version().version_compare('>=3.9')
1978 if get_option('ukify') == 'auto'
1979 want_ukify = python_39 and conf.get('HAVE_GNU_EFI') == 1
1980 elif get_option('ukify') == 'true' and (not python_39 or conf.get('HAVE_GNU_EFI') != 1)
1981 error('ukify requires Python >= 3.9 and GNU EFI')
1983 want_ukify = get_option('ukify') == 'true'
1986 ############################################################
1988 # binaries that have --help and are intended for use by humans,
1989 # usually, but not always, installed in /bin.
1990 public_programs = []
1992 # D-Bus introspection XML export
1995 basic_includes = include_directories(
2001 libsystemd_includes = [basic_includes, include_directories(
2002 'src/libsystemd/sd-bus',
2003 'src/libsystemd/sd-device',
2004 'src/libsystemd/sd-event',
2005 'src/libsystemd/sd-hwdb',
2006 'src/libsystemd/sd-id128',
2007 'src/libsystemd/sd-journal',
2008 'src/libsystemd/sd-netlink',
2009 'src/libsystemd/sd-network',
2010 'src/libsystemd/sd-resolve')]
2012 includes = [libsystemd_includes, include_directories('src/shared')]
2017 subdir('src/libsystemd')
2018 subdir('src/shared')
2020 subdir('src/libudev')
2021 subdir('src/cryptsetup/cryptsetup-tokens')
2023 alias_target('devel', libsystemd_pc, libudev_pc)
2025 libsystemd = shared_library(
2027 version : libsystemd_version,
2028 include_directories : libsystemd_includes,
2029 link_args : ['-shared',
2030 '-Wl,--version-script=' + libsystemd_sym_path],
2031 link_with : [libbasic,
2034 link_whole : [libsystemd_static],
2035 dependencies : [threads,
2037 link_depends : libsystemd_sym,
2039 install_tag: 'libsystemd',
2040 install_dir : rootlibdir)
2042 alias_target('libsystemd', libsystemd)
2044 install_libsystemd_static = static_library(
2048 basic_gcrypt_sources,
2049 basic_compress_sources,
2050 fundamental_sources,
2051 include_directories : libsystemd_includes,
2052 build_by_default : static_libsystemd != 'false',
2053 install : static_libsystemd != 'false',
2054 install_tag: 'libsystemd',
2055 install_dir : rootlibdir,
2056 pic : static_libsystemd_pic,
2057 dependencies : [threads,
2069 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
2071 libudev = shared_library(
2073 version : libudev_version,
2074 include_directories : includes,
2075 link_args : ['-shared',
2076 '-Wl,--version-script=' + libudev_sym_path],
2077 link_with : [libsystemd_static, libshared_static],
2078 link_whole : libudev_basic,
2079 dependencies : [threads],
2080 link_depends : libudev_sym,
2082 install_tag: 'libudev',
2083 install_dir : rootlibdir)
2085 alias_target('libudev', libudev)
2087 install_libudev_static = static_library(
2090 fundamental_sources,
2094 include_directories : includes,
2095 build_by_default : static_libudev != 'false',
2096 install : static_libudev != 'false',
2097 install_tag: 'libudev',
2098 install_dir : rootlibdir,
2099 link_depends : libudev_sym,
2100 dependencies : [libshared_deps,
2103 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
2104 pic : static_libudev_pic)
2106 if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
2107 if conf.get('HAVE_TPM2') == 1
2108 cryptsetup_token_systemd_tpm2 = shared_library(
2109 'cryptsetup-token-systemd-tpm2',
2110 cryptsetup_token_systemd_tpm2_sources,
2111 include_directories : includes,
2112 link_args : ['-shared',
2113 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2114 link_with : [lib_cryptsetup_token_common,
2116 dependencies : [libcryptsetup,
2119 link_depends : cryptsetup_token_sym,
2120 install_rpath : rootpkglibdir,
2122 install_dir : libcryptsetup_plugins_dir)
2125 if conf.get('HAVE_LIBFIDO2') == 1
2126 cryptsetup_token_systemd_fido2 = shared_library(
2127 'cryptsetup-token-systemd-fido2',
2128 cryptsetup_token_systemd_fido2_sources,
2129 include_directories : includes,
2130 link_args : ['-shared',
2131 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2132 link_with : [lib_cryptsetup_token_common,
2134 dependencies : [libcryptsetup,
2137 link_depends : cryptsetup_token_sym,
2138 install_rpath : rootpkglibdir,
2140 install_dir : libcryptsetup_plugins_dir)
2143 if conf.get('HAVE_P11KIT') == 1
2144 cryptsetup_token_systemd_pkcs11 = shared_library(
2145 'cryptsetup-token-systemd-pkcs11',
2146 cryptsetup_token_systemd_pkcs11_sources,
2147 include_directories : includes,
2148 link_args : ['-shared',
2149 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2150 link_with : [lib_cryptsetup_token_common,
2152 dependencies : [libcryptsetup,
2155 link_depends : cryptsetup_token_sym,
2156 install_rpath : rootpkglibdir,
2158 install_dir : libcryptsetup_plugins_dir)
2162 ############################################################
2164 # systemd-analyze requires 'libcore'
2166 # systemd-journal-remote requires 'libjournal_core'
2167 subdir('src/journal')
2168 # systemd-networkd requires 'libsystemd_network'
2169 subdir('src/libsystemd-network')
2171 subdir('src/analyze')
2173 subdir('src/busctl')
2174 subdir('src/coredump')
2175 subdir('src/cryptenroll')
2176 subdir('src/cryptsetup')
2178 subdir('src/hostname')
2179 subdir('src/import')
2180 subdir('src/journal-remote')
2181 subdir('src/kernel-install')
2182 subdir('src/locale')
2184 subdir('src/machine')
2185 subdir('src/network')
2186 subdir('src/nspawn')
2188 subdir('src/partition')
2189 subdir('src/portable')
2190 subdir('src/pstore')
2191 subdir('src/resolve')
2193 subdir('src/shutdown')
2194 subdir('src/sysext')
2195 subdir('src/systemctl')
2196 subdir('src/sysupdate')
2197 subdir('src/timedate')
2198 subdir('src/timesync')
2199 subdir('src/tmpfiles')
2200 subdir('src/userdb')
2201 subdir('src/xdg-autostart-generator')
2203 subdir('src/systemd')
2209 subdir('src/ukify/test') # needs to be last for test_env variable
2211 ############################################################
2213 # only static linking apart from libdl, to make sure that the
2214 # module is linked to all libraries that it uses.
2215 test_dlopen = executable(
2218 include_directories : includes,
2219 link_with : [libbasic],
2220 dependencies : [libdl],
2221 build_by_default : want_tests != 'false')
2223 foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
2224 ['systemd', 'ENABLE_NSS_SYSTEMD', ['nss-systemd.h', 'userdb-glue.c', 'userdb-glue.h']],
2225 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
2226 ['resolve', 'ENABLE_NSS_RESOLVE', [], resolve_includes]]
2228 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
2232 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
2233 version_script_arg = project_source_root / sym
2235 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
2236 if tuple.length() > 2
2237 foreach s : tuple[2]
2238 sources += ['src/nss-@0@/@1@'.format(module, s)]
2242 incs = tuple.length() > 3 ? tuple[3] : includes
2244 nss = shared_library(
2248 include_directories : incs,
2249 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
2250 link_args : ['-Wl,-z,nodelete',
2252 '-Wl,--version-script=' + version_script_arg],
2253 link_with : [libsystemd_static,
2256 dependencies : [threads,
2260 install_tag : 'nss',
2261 install_dir : rootlibdir)
2263 # We cannot use shared_module because it does not support version suffix.
2264 # Unfortunately shared_library insists on creating the symlink…
2265 meson.add_install_script('sh', '-c',
2266 'rm $DESTDIR@0@/libnss_@1@.so'
2267 .format(rootlibdir, module),
2271 if want_tests != 'false'
2272 test('dlopen-nss_' + module,
2274 # path to dlopen must include a slash
2275 args : nss.full_path(),
2281 ############################################################
2286 include_directories : includes,
2287 link_with : [libcore,
2289 dependencies : [libseccomp,
2291 install_rpath : rootpkglibdir,
2293 install_dir : rootlibexecdir)
2294 dbus_programs += exe
2295 public_programs += exe
2297 meson.add_install_script(meson_make_symlink,
2298 rootlibexecdir / 'systemd',
2299 rootsbindir / 'init')
2303 systemd_analyze_sources,
2304 include_directories : core_includes,
2305 link_with : [libcore,
2307 dependencies : [libseccomp,
2309 install_rpath : rootpkglibdir,
2310 install : conf.get('ENABLE_ANALYZE') == 1)
2311 public_programs += exe
2313 if want_tests != 'false'
2314 test('test-compare-versions',
2315 test_compare_versions_sh,
2316 args : exe.full_path())
2321 systemd_journald_sources,
2322 include_directories : includes,
2323 link_with : [libjournal_core,
2325 dependencies : [threads,
2331 install_rpath : rootpkglibdir,
2333 install_dir : rootlibexecdir)
2335 public_programs += executable(
2337 systemd_cat_sources,
2338 include_directories : includes,
2339 link_with : [libjournal_core,
2341 dependencies : [threads,
2343 install_rpath : rootpkglibdir,
2346 if get_option('link-journalctl-shared')
2347 journalctl_link_with = [libshared]
2349 journalctl_link_with = [libsystemd_static,
2354 public_programs += executable(
2357 include_directories : includes,
2358 link_with : [journalctl_link_with],
2359 dependencies : [threads,
2366 install_rpath : rootpkglibdir,
2368 install_dir : rootbindir)
2371 'systemd-getty-generator',
2372 'src/getty-generator/getty-generator.c',
2373 include_directories : includes,
2374 link_with : [libshared],
2375 install_rpath : rootpkglibdir,
2377 install_dir : systemgeneratordir)
2380 'systemd-debug-generator',
2381 'src/debug-generator/debug-generator.c',
2382 include_directories : includes,
2383 link_with : [libshared],
2384 install_rpath : rootpkglibdir,
2386 install_dir : systemgeneratordir)
2389 'systemd-run-generator',
2390 'src/run-generator/run-generator.c',
2391 include_directories : includes,
2392 link_with : [libshared],
2393 install_rpath : rootpkglibdir,
2395 install_dir : systemgeneratordir)
2398 'systemd-fstab-generator',
2399 'src/fstab-generator/fstab-generator.c',
2400 include_directories : includes,
2401 link_with : [libshared],
2402 install_rpath : rootpkglibdir,
2404 install_dir : systemgeneratordir)
2406 meson.add_install_script(meson_make_symlink,
2407 systemgeneratordir / 'systemd-fstab-generator',
2408 rootlibexecdir / 'systemd-sysroot-fstab-check')
2410 if want_tests != 'false'
2411 test('test-fstab-generator',
2412 test_fstab_generator_sh,
2413 # https://github.com/mesonbuild/meson/issues/2681
2414 args : exe.full_path(),
2418 if conf.get('ENABLE_ENVIRONMENT_D') == 1
2420 '30-systemd-environment-d-generator',
2421 'src/environment-d-generator/environment-d-generator.c',
2422 include_directories : includes,
2423 link_with : [libshared],
2424 install_rpath : rootpkglibdir,
2426 install_dir : userenvgeneratordir)
2428 meson.add_install_script(meson_make_symlink,
2429 sysconfdir / 'environment',
2430 environmentdir / '99-environment.conf')
2433 if conf.get('ENABLE_HIBERNATE') == 1
2435 'systemd-hibernate-resume-generator',
2436 'src/hibernate-resume/hibernate-resume-generator.c',
2437 include_directories : includes,
2438 link_with : [libshared],
2439 install_rpath : rootpkglibdir,
2441 install_dir : systemgeneratordir)
2444 'systemd-hibernate-resume',
2445 'src/hibernate-resume/hibernate-resume.c',
2446 include_directories : includes,
2447 link_with : [libshared],
2448 install_rpath : rootpkglibdir,
2450 install_dir : rootlibexecdir)
2453 if conf.get('HAVE_BLKID') == 1
2455 'systemd-gpt-auto-generator',
2456 'src/gpt-auto-generator/gpt-auto-generator.c',
2457 include_directories : includes,
2458 link_with : [libshared],
2459 dependencies : libblkid,
2460 install_rpath : rootpkglibdir,
2462 install_dir : systemgeneratordir)
2464 public_programs += executable(
2466 'src/dissect/dissect.c',
2467 include_directories : includes,
2468 link_with : [libshared],
2469 dependencies : [versiondep],
2470 install_rpath : rootpkglibdir,
2474 if conf.get('ENABLE_RESOLVE') == 1
2475 dbus_programs += executable(
2477 systemd_resolved_sources,
2478 include_directories : resolve_includes,
2479 link_with : [libshared,
2481 libsystemd_resolve_core],
2482 dependencies : systemd_resolved_dependencies,
2483 install_rpath : rootpkglibdir,
2485 install_dir : rootlibexecdir)
2487 public_programs += executable(
2490 include_directories : includes,
2491 link_with : [libshared,
2493 libsystemd_resolve_core],
2494 dependencies : [threads,
2495 lib_openssl_or_gcrypt,
2499 install_rpath : rootpkglibdir,
2502 meson.add_install_script(meson_make_symlink,
2503 bindir / 'resolvectl',
2504 rootsbindir / 'resolvconf')
2506 meson.add_install_script(meson_make_symlink,
2507 bindir / 'resolvectl',
2508 bindir / 'systemd-resolve')
2511 if conf.get('ENABLE_LOGIND') == 1
2512 dbus_programs += executable(
2514 systemd_logind_sources,
2515 include_directories : includes,
2516 link_with : [liblogind_core,
2518 dependencies : [threads,
2521 install_rpath : rootpkglibdir,
2523 install_dir : rootlibexecdir)
2525 public_programs += executable(
2528 include_directories : includes,
2529 link_with : [libshared],
2530 dependencies : [threads,
2535 install_rpath : rootpkglibdir,
2537 install_dir : rootbindir)
2539 public_programs += executable(
2541 'src/login/inhibit.c',
2542 include_directories : includes,
2543 link_with : [libshared],
2544 dependencies : [versiondep],
2545 install_rpath : rootpkglibdir,
2547 install_dir : rootbindir)
2549 if conf.get('HAVE_PAM') == 1
2550 version_script_arg = project_source_root / pam_systemd_sym
2551 pam_systemd = shared_library(
2555 include_directories : includes,
2556 link_args : ['-shared',
2557 '-Wl,--version-script=' + version_script_arg],
2558 link_with : [libsystemd_static,
2560 dependencies : [threads,
2564 link_depends : pam_systemd_sym,
2566 install_tag : 'pam',
2567 install_dir : pamlibdir)
2569 if want_tests != 'false'
2570 test('dlopen-pam_systemd',
2572 # path to dlopen must include a slash
2573 args : pam_systemd.full_path(),
2574 depends : pam_systemd)
2579 'systemd-user-runtime-dir',
2580 user_runtime_dir_sources,
2581 include_directories : includes,
2582 link_with : [libshared],
2583 install_rpath : rootpkglibdir,
2585 install_dir : rootlibexecdir)
2588 if conf.get('HAVE_PAM') == 1
2590 'systemd-user-sessions',
2591 'src/user-sessions/user-sessions.c',
2592 include_directories : includes,
2593 link_with : [libshared],
2594 install_rpath : rootpkglibdir,
2596 install_dir : rootlibexecdir)
2599 if conf.get('HAVE_BLKID') == 1 and conf.get('HAVE_GNU_EFI') == 1
2600 if get_option('link-boot-shared')
2601 boot_link_with = [libshared]
2603 boot_link_with = [libsystemd_static, libshared_static]
2609 include_directories : includes,
2610 link_with : [boot_link_with],
2611 dependencies : [libblkid,
2613 install_rpath : rootpkglibdir,
2615 public_programs += exe
2617 if want_tests != 'false'
2618 test('test-bootctl-json',
2619 test_bootctl_json_sh,
2620 args : exe.full_path(),
2624 public_programs += executable(
2625 'systemd-bless-boot',
2626 'src/boot/bless-boot.c',
2627 include_directories : includes,
2628 link_with : [boot_link_with],
2629 dependencies : [libblkid,
2631 install_rpath : rootpkglibdir,
2633 install_dir : rootlibexecdir)
2636 'systemd-bless-boot-generator',
2637 'src/boot/bless-boot-generator.c',
2638 include_directories : includes,
2639 link_with : [boot_link_with],
2640 install_rpath : rootpkglibdir,
2642 install_dir : systemgeneratordir)
2644 if conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_TPM2') == 1
2647 'src/boot/measure.c',
2648 include_directories : includes,
2649 link_with : [libshared],
2650 dependencies : [libopenssl,
2652 install_rpath : rootpkglibdir,
2654 install_dir : rootlibexecdir)
2657 'src/boot/pcrphase.c',
2658 include_directories : includes,
2659 link_with : [libshared],
2660 dependencies : [libopenssl,
2664 install_rpath : rootpkglibdir,
2666 install_dir : rootlibexecdir)
2671 'systemd-boot-check-no-failures',
2672 'src/boot/boot-check-no-failures.c',
2673 include_directories : includes,
2674 link_with : [libshared],
2675 dependencies : [libblkid,
2677 install_rpath : rootpkglibdir,
2679 install_dir : rootlibexecdir)
2681 public_programs += executable(
2682 'systemd-socket-activate',
2683 'src/activate/activate.c',
2684 include_directories : includes,
2685 link_with : [libshared],
2686 dependencies : [threads,
2688 install_rpath : rootpkglibdir,
2691 systemctl = executable(
2694 include_directories : includes,
2695 link_with : systemctl_link_with,
2696 dependencies : [threads,
2703 install_rpath : rootpkglibdir,
2705 install_dir : rootbindir)
2706 public_programs += systemctl
2708 if conf.get('ENABLE_PORTABLED') == 1
2709 dbus_programs += executable(
2710 'systemd-portabled',
2711 systemd_portabled_sources,
2712 include_directories : includes,
2713 link_with : [libshared],
2714 dependencies : [threads,
2717 install_rpath : rootpkglibdir,
2719 install_dir : rootlibexecdir)
2721 public_programs += executable(
2723 'src/portable/portablectl.c',
2724 include_directories : includes,
2725 link_with : [libshared],
2726 dependencies : [threads,
2728 install_rpath : rootpkglibdir,
2730 install_dir : rootbindir)
2733 if conf.get('ENABLE_SYSEXT') == 1
2734 public_programs += executable(
2736 systemd_sysext_sources,
2737 include_directories : includes,
2738 link_with : [libshared],
2739 dependencies : [versiondep],
2740 install_rpath : rootpkglibdir,
2742 install_dir : rootbindir)
2745 if conf.get('ENABLE_USERDB') == 1
2748 systemd_userwork_sources,
2749 include_directories : includes,
2750 link_with : [libshared],
2751 dependencies : [threads,
2753 install_rpath : rootpkglibdir,
2755 install_dir : rootlibexecdir)
2759 systemd_userdbd_sources,
2760 include_directories : includes,
2761 link_with : [libshared],
2762 dependencies : [threads,
2764 install_rpath : rootpkglibdir,
2766 install_dir : rootlibexecdir)
2768 public_programs += executable(
2771 include_directories : includes,
2772 link_with : [libshared],
2773 dependencies : [threads,
2775 install_rpath : rootpkglibdir,
2779 if conf.get('ENABLE_HOMED') == 1
2782 systemd_homework_sources,
2783 include_directories : includes,
2784 link_with : [libshared,
2786 dependencies : [threads,
2793 install_rpath : rootpkglibdir,
2795 install_dir : rootlibexecdir)
2797 dbus_programs += executable(
2799 systemd_homed_sources,
2800 include_directories : home_includes,
2801 link_with : [libshared],
2802 dependencies : [threads,
2807 install_rpath : rootpkglibdir,
2809 install_dir : rootlibexecdir)
2811 public_programs += executable(
2814 include_directories : includes,
2815 link_with : [libshared],
2816 dependencies : [threads,
2822 install_rpath : rootpkglibdir,
2825 if conf.get('HAVE_PAM') == 1
2826 version_script_arg = project_source_root / pam_systemd_home_sym
2827 pam_systemd_home = shared_library(
2831 include_directories : includes,
2832 link_args : ['-shared',
2833 '-Wl,--version-script=' + version_script_arg],
2834 link_with : [libsystemd_static,
2836 dependencies : [threads,
2841 link_depends : pam_systemd_home_sym,
2843 install_tag : 'pam',
2844 install_dir : pamlibdir)
2846 if want_tests != 'false'
2847 test('dlopen-pam_systemd_home',
2849 # path to dlopen must include a slash
2850 args : pam_systemd_home.full_path(),
2851 depends : pam_systemd_home)
2856 foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
2857 (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
2858 meson.add_install_script(meson_make_symlink,
2859 rootbindir / 'systemctl',
2860 rootsbindir / alias)
2863 meson.add_install_script(meson_make_symlink,
2864 rootbindir / 'udevadm',
2865 rootlibexecdir / 'systemd-udevd')
2867 if conf.get('ENABLE_BACKLIGHT') == 1
2869 'systemd-backlight',
2870 'src/backlight/backlight.c',
2871 include_directories : includes,
2872 link_with : [libshared],
2873 install_rpath : rootpkglibdir,
2875 install_dir : rootlibexecdir)
2878 if conf.get('ENABLE_RFKILL') == 1
2881 'src/rfkill/rfkill.c',
2882 include_directories : includes,
2883 link_with : [libshared],
2884 install_rpath : rootpkglibdir,
2886 install_dir : rootlibexecdir)
2890 'systemd-system-update-generator',
2891 'src/system-update-generator/system-update-generator.c',
2892 include_directories : includes,
2893 link_with : [libshared],
2894 install_rpath : rootpkglibdir,
2896 install_dir : systemgeneratordir)
2898 if conf.get('HAVE_LIBCRYPTSETUP') == 1
2900 'systemd-cryptsetup',
2901 systemd_cryptsetup_sources,
2902 include_directories : includes,
2903 link_with : [libshared],
2904 dependencies : [libcryptsetup,
2908 install_rpath : rootpkglibdir,
2910 install_dir : rootlibexecdir)
2913 'systemd-cryptsetup-generator',
2914 'src/cryptsetup/cryptsetup-generator.c',
2915 include_directories : includes,
2916 link_with : [libshared],
2917 install_rpath : rootpkglibdir,
2919 install_dir : systemgeneratordir)
2922 'systemd-veritysetup',
2923 'src/veritysetup/veritysetup.c',
2924 include_directories : includes,
2925 link_with : [libshared],
2926 dependencies : [libcryptsetup,
2928 install_rpath : rootpkglibdir,
2930 install_dir : rootlibexecdir)
2933 'systemd-veritysetup-generator',
2934 'src/veritysetup/veritysetup-generator.c',
2935 include_directories : includes,
2936 link_with : [libshared],
2937 dependencies : [versiondep],
2938 install_rpath : rootpkglibdir,
2940 install_dir : systemgeneratordir)
2942 public_programs += executable(
2943 'systemd-cryptenroll',
2944 systemd_cryptenroll_sources,
2945 include_directories : includes,
2946 link_with : [libshared],
2947 dependencies : [libcryptsetup,
2952 install_rpath : rootpkglibdir,
2956 'systemd-integritysetup',
2957 ['src/integritysetup/integritysetup.c', 'src/integritysetup/integrity-util.c'],
2958 include_directories : includes,
2959 link_with : [libshared],
2960 dependencies : [libcryptsetup,
2962 install_rpath : rootpkglibdir,
2964 install_dir : rootlibexecdir)
2967 'systemd-integritysetup-generator',
2968 ['src/integritysetup/integritysetup-generator.c', 'src/integritysetup/integrity-util.c'],
2969 include_directories : includes,
2970 link_with : [libshared],
2971 install_rpath : rootpkglibdir,
2973 install_dir : systemgeneratordir)
2976 if conf.get('HAVE_SYSV_COMPAT') == 1
2978 'systemd-sysv-generator',
2979 'src/sysv-generator/sysv-generator.c',
2980 include_directories : includes,
2981 link_with : [libshared],
2982 install_rpath : rootpkglibdir,
2984 install_dir : systemgeneratordir)
2986 sysv_generator_test_py = find_program('test/sysv-generator-test.py')
2987 if want_tests != 'false'
2988 test('sysv-generator-test',
2989 sysv_generator_test_py,
2994 'systemd-rc-local-generator',
2995 'src/rc-local-generator/rc-local-generator.c',
2996 include_directories : includes,
2997 link_with : [libshared],
2998 install_rpath : rootpkglibdir,
3000 install_dir : systemgeneratordir)
3003 if conf.get('ENABLE_XDG_AUTOSTART') == 1
3005 'systemd-xdg-autostart-generator',
3006 systemd_xdg_autostart_generator_sources,
3007 include_directories : includes,
3008 link_with : [libshared],
3009 install_rpath : rootpkglibdir,
3011 install_dir : usergeneratordir)
3014 'systemd-xdg-autostart-condition',
3015 'src/xdg-autostart-generator/xdg-autostart-condition.c',
3016 include_directories : includes,
3017 link_with : [libshared],
3018 install_rpath : rootpkglibdir,
3020 install_dir : rootlibexecdir)
3023 if conf.get('ENABLE_HOSTNAMED') == 1
3024 dbus_programs += executable(
3025 'systemd-hostnamed',
3026 'src/hostname/hostnamed.c',
3027 include_directories : includes,
3028 link_with : [libshared],
3029 install_rpath : rootpkglibdir,
3031 install_dir : rootlibexecdir)
3033 public_programs += executable(
3035 'src/hostname/hostnamectl.c',
3036 include_directories : includes,
3037 link_with : [libshared],
3038 dependencies : [versiondep],
3039 install_rpath : rootpkglibdir,
3043 if conf.get('ENABLE_LOCALED') == 1
3044 if conf.get('HAVE_XKBCOMMON') == 1
3045 # logind will load libxkbcommon.so dynamically on its own, but we still
3046 # need to specify where the headers are
3048 libxkbcommon.partial_dependency(compile_args: true),
3054 dbus_programs += executable(
3056 systemd_localed_sources,
3057 include_directories : includes,
3058 link_with : [libshared],
3059 dependencies : deps,
3060 install_rpath : rootpkglibdir,
3062 install_dir : rootlibexecdir)
3064 public_programs += executable(
3067 include_directories : includes,
3068 link_with : [libshared],
3069 dependencies : [versiondep],
3070 install_rpath : rootpkglibdir,
3074 if conf.get('ENABLE_TIMEDATED') == 1
3075 dbus_programs += executable(
3076 'systemd-timedated',
3077 'src/timedate/timedated.c',
3078 include_directories : includes,
3079 link_with : [libshared],
3080 install_rpath : rootpkglibdir,
3082 install_dir : rootlibexecdir)
3085 if conf.get('ENABLE_TIMEDATECTL') == 1
3086 public_programs += executable(
3088 'src/timedate/timedatectl.c',
3089 include_directories : includes,
3090 install_rpath : rootpkglibdir,
3091 link_with : [libshared],
3092 dependencies : [libm,
3097 if conf.get('ENABLE_TIMESYNCD') == 1
3099 'systemd-timesyncd',
3100 systemd_timesyncd_sources,
3101 include_directories : includes,
3102 link_with : [libtimesyncd_core],
3103 dependencies : [threads,
3106 install_rpath : rootpkglibdir,
3108 install_dir : rootlibexecdir)
3111 'systemd-time-wait-sync',
3112 'src/timesync/wait-sync.c',
3113 include_directories : includes,
3114 link_with : [libtimesyncd_core],
3115 install_rpath : rootpkglibdir,
3117 install_dir : rootlibexecdir)
3120 if conf.get('ENABLE_MACHINED') == 1
3121 dbus_programs += executable(
3123 systemd_machined_sources,
3124 include_directories : includes,
3125 link_with : [libmachine_core,
3127 install_rpath : rootpkglibdir,
3129 install_dir : rootlibexecdir)
3131 public_programs += executable(
3133 'src/machine/machinectl.c',
3134 include_directories : includes,
3135 link_with : [libshared],
3136 dependencies : [threads,
3141 install_rpath : rootpkglibdir,
3143 install_dir : rootbindir)
3146 if conf.get('ENABLE_IMPORTD') == 1
3147 dbus_programs += executable(
3149 systemd_importd_sources,
3150 include_directories : includes,
3151 link_with : [libshared],
3152 dependencies : [threads,
3154 install_rpath : rootpkglibdir,
3156 install_dir : rootlibexecdir)
3158 systemd_pull = executable(
3160 systemd_pull_sources,
3161 include_directories : includes,
3162 link_with : [libshared,
3164 dependencies : [libcurl,
3165 lib_openssl_or_gcrypt,
3170 install_rpath : rootpkglibdir,
3172 install_dir : rootlibexecdir)
3174 systemd_import = executable(
3176 systemd_import_sources,
3177 include_directories : includes,
3178 link_with : [libshared,
3180 dependencies : [libcurl,
3185 install_rpath : rootpkglibdir,
3187 install_dir : rootlibexecdir)
3189 systemd_import_fs = executable(
3190 'systemd-import-fs',
3191 systemd_import_fs_sources,
3192 include_directories : includes,
3193 link_with : [libshared,
3195 dependencies : [versiondep],
3196 install_rpath : rootpkglibdir,
3198 install_dir : rootlibexecdir)
3200 systemd_export = executable(
3202 systemd_export_sources,
3203 include_directories : includes,
3204 link_with : [libshared,
3206 dependencies : [libcurl,
3211 install_rpath : rootpkglibdir,
3213 install_dir : rootlibexecdir)
3215 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
3218 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
3219 public_programs += executable(
3220 'systemd-journal-upload',
3221 systemd_journal_upload_sources,
3222 include_directories : includes,
3223 link_with : [libshared],
3224 dependencies : [threads,
3231 install_rpath : rootpkglibdir,
3233 install_dir : rootlibexecdir)
3236 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
3237 public_programs += executable(
3238 'systemd-journal-remote',
3239 systemd_journal_remote_sources,
3240 include_directories : journal_includes,
3241 link_with : [libshared,
3242 libsystemd_journal_remote],
3243 dependencies : [threads,
3250 install_rpath : rootpkglibdir,
3252 install_dir : rootlibexecdir)
3254 public_programs += executable(
3255 'systemd-journal-gatewayd',
3256 systemd_journal_gatewayd_sources,
3257 include_directories : journal_includes,
3258 link_with : [libshared],
3259 dependencies : [threads,
3266 install_rpath : rootpkglibdir,
3268 install_dir : rootlibexecdir)
3271 if conf.get('ENABLE_COREDUMP') == 1
3274 systemd_coredump_sources,
3275 include_directories : includes,
3276 link_with : [libshared,
3278 dependencies : [threads,
3284 install_rpath : rootpkglibdir,
3286 install_dir : rootlibexecdir)
3288 public_programs += executable(
3290 coredumpctl_sources,
3291 include_directories : includes,
3292 link_with : [libshared,
3294 dependencies : [threads,
3299 install_rpath : rootpkglibdir,
3303 if conf.get('ENABLE_PSTORE') == 1
3306 systemd_pstore_sources,
3307 include_directories : includes,
3308 link_with : [libshared],
3309 dependencies : [threads,
3315 install_rpath : rootpkglibdir,
3317 install_dir : rootlibexecdir)
3320 if conf.get('ENABLE_OOMD') == 1
3321 dbus_programs += executable('systemd-oomd',
3322 systemd_oomd_sources,
3323 include_directories : includes,
3324 link_with : [libshared],
3325 dependencies : [libatomic,
3327 install_rpath : rootpkglibdir,
3329 install_dir : rootlibexecdir)
3331 public_programs += executable(
3334 include_directories : includes,
3335 link_with : [libshared],
3336 dependencies : [versiondep],
3337 install_rpath : rootpkglibdir,
3341 if conf.get('ENABLE_BINFMT') == 1
3342 public_programs += executable(
3344 'src/binfmt/binfmt.c',
3345 include_directories : includes,
3346 link_with : [libshared],
3347 dependencies : [versiondep],
3348 install_rpath : rootpkglibdir,
3350 install_dir : rootlibexecdir)
3352 meson.add_install_script('sh', '-c',
3353 mkdir_p.format(binfmtdir))
3354 if install_sysconfdir
3355 meson.add_install_script('sh', '-c',
3356 mkdir_p.format(sysconfdir / 'binfmt.d'))
3360 if conf.get('ENABLE_SYSUPDATE') == 1
3362 'systemd-sysupdate',
3363 systemd_sysupdate_sources,
3364 include_directories : includes,
3365 link_with : [libshared,
3367 dependencies : [threads,
3372 install_rpath : rootpkglibdir,
3374 install_dir : rootlibexecdir)
3375 public_programs += exe
3378 if conf.get('ENABLE_VCONSOLE') == 1
3380 'systemd-vconsole-setup',
3381 'src/vconsole/vconsole-setup.c',
3382 include_directories : includes,
3383 link_with : [libshared],
3384 install_rpath : rootpkglibdir,
3386 install_dir : rootlibexecdir)
3389 if conf.get('ENABLE_RANDOMSEED') == 1
3391 'systemd-random-seed',
3392 'src/random-seed/random-seed.c',
3393 include_directories : includes,
3394 link_with : [libshared],
3395 dependencies : [versiondep],
3396 install_rpath : rootpkglibdir,
3398 install_dir : rootlibexecdir)
3401 if conf.get('ENABLE_FIRSTBOOT') == 1
3402 public_programs += executable(
3403 'systemd-firstboot',
3404 'src/firstboot/firstboot.c',
3405 include_directories : includes,
3406 link_with : [libshared],
3407 dependencies : [libcrypt,
3409 install_rpath : rootpkglibdir,
3411 install_dir : rootbindir)
3415 'systemd-remount-fs',
3416 'src/remount-fs/remount-fs.c',
3417 include_directories : includes,
3418 link_with : [libshared],
3419 dependencies : [versiondep],
3420 install_rpath : rootpkglibdir,
3422 install_dir : rootlibexecdir)
3425 'systemd-machine-id-setup',
3426 'src/machine-id-setup/machine-id-setup-main.c',
3427 include_directories : includes,
3428 link_with : [libshared],
3429 dependencies : [versiondep],
3430 install_rpath : rootpkglibdir,
3432 install_dir : rootbindir)
3437 include_directories : includes,
3438 link_with : [libshared],
3439 dependencies : [versiondep],
3440 install_rpath : rootpkglibdir,
3442 install_dir : rootlibexecdir)
3446 'src/partition/growfs.c',
3447 include_directories : includes,
3448 link_with : [libshared],
3449 dependencies : [versiondep],
3450 install_rpath : rootpkglibdir,
3452 install_dir : rootlibexecdir)
3456 'src/partition/makefs.c',
3457 include_directories : includes,
3458 link_with : [libshared],
3459 dependencies : [versiondep],
3460 install_rpath : rootpkglibdir,
3462 install_dir : rootlibexecdir)
3466 'src/sleep/sleep.c',
3467 include_directories : includes,
3468 link_with : [libshared],
3469 dependencies : [versiondep],
3470 install_rpath : rootpkglibdir,
3472 install_dir : rootlibexecdir)
3474 if install_sysconfdir_samples
3475 install_data('src/sleep/sleep.conf',
3476 install_dir : pkgsysconfdir)
3479 public_programs += executable(
3481 'src/sysctl/sysctl.c',
3482 include_directories : includes,
3483 link_with : [libshared],
3484 dependencies : [versiondep],
3485 install_rpath : rootpkglibdir,
3487 install_dir : rootlibexecdir)
3489 public_programs += executable(
3491 'src/ac-power/ac-power.c',
3492 include_directories : includes,
3493 link_with : [libshared],
3494 dependencies : [versiondep],
3495 install_rpath : rootpkglibdir,
3498 public_programs += executable(
3499 'systemd-detect-virt',
3500 'src/detect-virt/detect-virt.c',
3501 include_directories : includes,
3502 link_with : [libshared],
3503 dependencies : [versiondep],
3504 install_rpath : rootpkglibdir,
3507 public_programs += executable(
3509 'src/delta/delta.c',
3510 include_directories : includes,
3511 link_with : [libshared],
3512 dependencies : [versiondep],
3513 install_rpath : rootpkglibdir,
3516 public_programs += executable(
3518 'src/escape/escape.c',
3519 include_directories : includes,
3520 link_with : [libshared],
3521 dependencies : [versiondep],
3522 install_rpath : rootpkglibdir,
3524 install_dir : rootbindir)
3526 public_programs += executable(
3528 'src/notify/notify.c',
3529 include_directories : includes,
3530 link_with : [libshared],
3531 dependencies : [versiondep],
3532 install_rpath : rootpkglibdir,
3534 install_dir : rootbindir)
3536 public_programs += executable(
3538 'src/creds/creds.c',
3539 include_directories : includes,
3540 link_with : [libshared],
3541 dependencies : [threads,
3544 install_rpath : rootpkglibdir,
3546 install_dir : rootbindir)
3549 'systemd-volatile-root',
3550 'src/volatile-root/volatile-root.c',
3551 include_directories : includes,
3552 link_with : [libshared],
3553 install_rpath : rootpkglibdir,
3554 install : conf.get('ENABLE_INITRD') == 1,
3555 install_dir : rootlibexecdir)
3558 'systemd-cgroups-agent',
3559 'src/cgroups-agent/cgroups-agent.c',
3560 include_directories : includes,
3561 link_with : [libshared],
3562 install_rpath : rootpkglibdir,
3564 install_dir : rootlibexecdir)
3566 systemd_id128 = executable(
3568 'src/id128/id128.c',
3569 include_directories : includes,
3570 link_with : [libshared],
3571 dependencies : [versiondep],
3572 install_rpath : rootpkglibdir,
3574 public_programs += systemd_id128
3576 if want_tests != 'false'
3577 test('test-systemctl-enable',
3578 test_systemctl_enable_sh,
3579 # https://github.com/mesonbuild/meson/issues/2681
3580 args : [systemctl.full_path(),
3581 systemd_id128.full_path()])
3584 public_programs += executable(
3587 include_directories : includes,
3588 link_with : [libshared],
3589 dependencies : [versiondep],
3590 install_rpath : rootpkglibdir,
3593 public_programs += executable(
3594 'systemd-ask-password',
3595 'src/ask-password/ask-password.c',
3596 include_directories : includes,
3597 link_with : [libshared],
3598 dependencies : [versiondep],
3599 install_rpath : rootpkglibdir,
3601 install_dir : rootbindir)
3604 'systemd-reply-password',
3605 'src/reply-password/reply-password.c',
3606 include_directories : includes,
3607 link_with : [libshared],
3608 install_rpath : rootpkglibdir,
3610 install_dir : rootlibexecdir)
3612 public_programs += executable(
3613 'systemd-tty-ask-password-agent',
3614 'src/tty-ask-password-agent/tty-ask-password-agent.c',
3615 include_directories : includes,
3616 link_with : [libshared],
3617 dependencies : [versiondep],
3618 install_rpath : rootpkglibdir,
3620 install_dir : rootbindir)
3622 public_programs += executable(
3625 include_directories : includes,
3626 link_with : [libshared],
3627 dependencies : [versiondep],
3628 install_rpath : rootpkglibdir,
3631 public_programs += executable(
3633 'src/cgtop/cgtop.c',
3634 include_directories : includes,
3635 link_with : [libshared],
3636 dependencies : [versiondep],
3637 install_rpath : rootpkglibdir,
3642 'src/initctl/initctl.c',
3643 include_directories : includes,
3644 link_with : [libshared],
3645 install_rpath : rootpkglibdir,
3646 install : (conf.get('HAVE_SYSV_COMPAT') == 1),
3647 install_dir : rootlibexecdir)
3649 public_programs += executable(
3651 'src/mount/mount-tool.c',
3652 include_directories : includes,
3653 link_with : [libshared],
3654 dependencies: [libmount,
3656 install_rpath : rootpkglibdir,
3659 meson.add_install_script(meson_make_symlink,
3660 'systemd-mount', bindir / 'systemd-umount')
3662 public_programs += executable(
3665 include_directories : includes,
3666 link_with : [libshared],
3667 dependencies : [versiondep],
3668 install_rpath : rootpkglibdir,
3671 public_programs += executable(
3672 'systemd-stdio-bridge',
3673 'src/stdio-bridge/stdio-bridge.c',
3674 include_directories : includes,
3675 link_with : [libshared],
3676 dependencies : [versiondep,
3678 install_rpath : rootpkglibdir,
3681 public_programs += executable(
3684 include_directories : includes,
3685 link_with : [libshared],
3686 dependencies : [versiondep],
3687 install_rpath : rootpkglibdir,
3693 'src/sysusers/sysusers.c',
3694 include_directories : includes,
3695 link_with : [libshared],
3696 dependencies : [versiondep],
3697 install_rpath : rootpkglibdir,
3699 install_dir : rootbindir)
3700 public_programs += exe
3702 if want_tests != 'false'
3703 test('test-sysusers',
3705 # https://github.com/mesonbuild/meson/issues/2681
3706 args : exe.full_path())
3709 if have_standalone_binaries
3711 'systemd-sysusers.standalone',
3712 'src/sysusers/sysusers.c',
3713 include_directories : includes,
3714 c_args : '-DSTANDALONE',
3715 link_with : [libshared_static,
3719 dependencies : [versiondep],
3721 install_dir : rootbindir)
3722 public_programs += exe
3724 if want_tests != 'false'
3725 test('test-sysusers.standalone',
3727 # https://github.com/mesonbuild/meson/issues/2681
3728 args : exe.full_path())
3733 if conf.get('ENABLE_TMPFILES') == 1
3736 systemd_tmpfiles_sources,
3737 include_directories : includes,
3738 link_with : [libshared],
3739 dependencies : [libacl,
3741 install_rpath : rootpkglibdir,
3743 install_dir : rootbindir)
3744 public_programs += exe
3746 if want_tests != 'false'
3747 test('test-systemd-tmpfiles',
3748 test_systemd_tmpfiles_py,
3749 # https://github.com/mesonbuild/meson/issues/2681
3750 args : exe.full_path())
3753 if have_standalone_binaries
3755 'systemd-tmpfiles.standalone',
3756 systemd_tmpfiles_sources,
3757 include_directories : includes,
3758 c_args : '-DSTANDALONE',
3759 link_with : [libshared_static,
3763 dependencies : [libacl,
3766 install_dir : rootbindir)
3767 public_programs += exe
3769 if want_tests != 'false'
3770 test('test-systemd-tmpfiles.standalone',
3771 test_systemd_tmpfiles_py,
3772 # https://github.com/mesonbuild/meson/issues/2681
3773 args : exe.full_path())
3778 if conf.get('ENABLE_HWDB') == 1
3779 systemd_hwdb = executable(
3782 include_directories : includes,
3783 link_with : udev_link_with,
3784 dependencies : [versiondep],
3785 install_rpath : udev_rpath,
3787 install_dir : rootbindir)
3788 public_programs += systemd_hwdb
3790 if want_tests != 'false'
3793 suite : 'dist-check',
3794 args : [systemd_hwdb.full_path()],
3799 if conf.get('ENABLE_QUOTACHECK') == 1
3801 'systemd-quotacheck',
3802 'src/quotacheck/quotacheck.c',
3803 include_directories : includes,
3804 link_with : [libshared],
3805 install_rpath : rootpkglibdir,
3807 install_dir : rootlibexecdir)
3810 public_programs += executable(
3811 'systemd-socket-proxyd',
3812 'src/socket-proxy/socket-proxyd.c',
3813 include_directories : includes,
3814 link_with : [libshared],
3815 dependencies : [threads,
3817 install_rpath : rootpkglibdir,
3819 install_dir : rootlibexecdir)
3821 udevadm = executable(
3824 include_directories : includes,
3825 link_with : [libudevd_core],
3826 dependencies : [threads,
3832 install_rpath : udev_rpath,
3834 install_dir : rootbindir)
3835 public_programs += udevadm
3837 if conf.get('ENABLE_REPART') == 1
3840 systemd_repart_sources,
3841 include_directories : includes,
3842 link_with : [libshared,
3844 dependencies : [threads,
3849 install_rpath : rootpkglibdir,
3851 install_dir : rootbindir)
3852 public_programs += exe
3854 if have_standalone_binaries
3856 'systemd-repart.standalone',
3857 systemd_repart_sources,
3858 include_directories : includes,
3859 c_args : '-DSTANDALONE',
3860 link_with : [libshared_static,
3865 dependencies : [threads,
3870 install_rpath : rootpkglibdir,
3872 install_dir : rootbindir)
3873 public_programs += exe
3879 systemd_shutdown_sources,
3880 include_directories : includes,
3881 link_with : [libshared],
3882 dependencies : [libmount,
3884 install_rpath : rootpkglibdir,
3886 install_dir : rootlibexecdir)
3888 if have_standalone_binaries
3890 'systemd-shutdown.standalone',
3891 systemd_shutdown_sources,
3892 include_directories : includes,
3893 c_args : '-DSTANDALONE',
3894 link_with : [libshared_static,
3897 dependencies : [libmount,
3899 install_rpath : rootpkglibdir,
3901 install_dir : rootlibexecdir)
3905 'systemd-update-done',
3906 'src/update-done/update-done.c',
3907 include_directories : includes,
3908 link_with : [libshared],
3909 dependencies : [versiondep],
3910 install_rpath : rootpkglibdir,
3912 install_dir : rootlibexecdir)
3915 'systemd-update-utmp',
3916 'src/update-utmp/update-utmp.c',
3917 include_directories : includes,
3918 link_with : [libshared],
3919 dependencies : [libaudit,
3921 install_rpath : rootpkglibdir,
3922 install : (conf.get('ENABLE_UTMP') == 1),
3923 install_dir : rootlibexecdir)
3925 if conf.get('HAVE_KMOD') == 1
3927 'systemd-modules-load',
3928 'src/modules-load/modules-load.c',
3929 include_directories : includes,
3930 link_with : [libshared],
3931 dependencies : [libkmod,
3933 install_rpath : rootpkglibdir,
3935 install_dir : rootlibexecdir)
3937 meson.add_install_script('sh', '-c',
3938 mkdir_p.format(modulesloaddir))
3939 if install_sysconfdir
3940 meson.add_install_script('sh', '-c',
3941 mkdir_p.format(sysconfdir / 'modules-load.d'))
3945 public_programs += executable(
3947 systemd_nspawn_sources,
3948 include_directories : includes,
3949 link_with : [libnspawn_core,
3951 dependencies : [libblkid,
3954 install_rpath : rootpkglibdir,
3957 if conf.get('ENABLE_NETWORKD') == 1
3958 dbus_programs += executable(
3960 systemd_networkd_sources,
3961 include_directories : network_includes,
3962 link_with : [libnetworkd_core,
3964 networkd_link_with],
3965 dependencies : [threads,
3967 install_rpath : rootpkglibdir,
3969 install_dir : rootlibexecdir)
3971 public_programs += executable(
3972 'systemd-networkd-wait-online',
3973 systemd_networkd_wait_online_sources,
3974 include_directories : includes,
3975 link_with : [networkd_link_with],
3976 dependencies : [versiondep],
3977 install_rpath : rootpkglibdir,
3979 install_dir : rootlibexecdir)
3981 public_programs += executable(
3984 include_directories : libsystemd_network_includes,
3985 link_with : [libsystemd_network,
3986 networkd_link_with],
3987 dependencies : [versiondep],
3988 install_rpath : rootpkglibdir,
3990 install_dir : rootbindir)
3994 'systemd-network-generator',
3995 network_generator_sources,
3996 include_directories : includes,
3997 link_with : [networkd_link_with],
3998 dependencies : [versiondep],
3999 install_rpath : rootpkglibdir,
4001 install_dir : rootlibexecdir)
4003 if want_tests != 'false'
4004 test('test-network-generator-conversion',
4005 test_network_generator_conversion_sh,
4006 # https://github.com/mesonbuild/meson/issues/2681
4007 args : exe.full_path(),
4012 'systemd-sulogin-shell',
4013 'src/sulogin-shell/sulogin-shell.c',
4014 include_directories : includes,
4015 link_with : [libshared],
4016 dependencies : [versiondep],
4017 install_rpath : rootpkglibdir,
4019 install_dir : rootlibexecdir)
4021 exe = custom_target(
4023 input : kernel_install_in,
4024 output : 'kernel-install',
4025 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
4026 install : want_kernel_install,
4027 install_mode : 'rwxr-xr-x',
4028 install_dir : bindir)
4029 public_programs += exe
4031 if want_tests != 'false' and want_kernel_install
4032 test('test-kernel-install',
4033 test_kernel_install_sh,
4035 args : [exe.full_path(), loaderentry_install])
4039 exe = custom_target(
4041 input : 'src/ukify/ukify.py',
4043 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
4045 install_mode : 'rwxr-xr-x',
4046 install_dir : rootlibexecdir)
4047 public_programs += exe
4050 ############################################################
4052 runtest_env = custom_target(
4053 'systemd-runtest.env',
4054 output : 'systemd-runtest.env',
4055 command : [sh, '-c',
4056 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
4057 project_source_root / 'test',
4058 project_build_root / 'catalog')],
4060 build_by_default : true)
4062 test_cflags = ['-DTEST_CODE=1']
4063 # We intentionally do not do inline initializations with definitions for a
4064 # bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
4065 # use the variable unexpectedly. This triggers a lot of maybe-uninitialized
4066 # false positives when the combination of -O2 and -flto is used. Suppress them.
4067 if '-O2' in c_args and '-flto=auto' in c_args
4068 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
4071 foreach tuple : tests
4073 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
4074 dependencies = tuple.length() > 2 ? tuple[2] : []
4075 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
4076 condition = tuple.length() > 4 ? tuple[4] : ''
4077 type = tuple.length() > 5 ? tuple[5] : ''
4078 defs = tuple.length() > 6 ? tuple[6] : []
4080 parallel = tuple.length() > 7 ? tuple[7] : true
4083 # FIXME: Use fs.stem() with meson >= 0.54.0
4084 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
4085 if type.startswith('timeout=')
4086 timeout = type.split('=')[1].to_int()
4090 suite = fs.name(fs.parent('@0@'.format(sources[0])))
4091 # FIXME: Use str.replace() with meson >= 0.58.0
4092 suite = suite.split('sd-')[-1]
4094 if condition == '' or conf.get(condition) == 1
4098 include_directories : incs,
4099 link_with : link_with,
4100 dependencies : [versiondep,
4103 build_by_default : want_tests != 'false',
4104 install_rpath : rootpkglibdir,
4105 install : install_tests,
4106 install_dir : testsdir / type,
4107 link_depends : runtest_env)
4110 message('@0@ is a manual test'.format(name))
4111 elif type == 'unsafe' and want_tests != 'unsafe'
4112 message('@0@ is an unsafe test'.format(name))
4113 elif want_tests != 'false'
4118 is_parallel : parallel)
4121 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
4126 'test-libsystemd-sym',
4127 test_libsystemd_sym_c,
4128 include_directories : includes,
4129 link_with : [libsystemd],
4130 build_by_default : want_tests != 'false',
4131 install : install_tests,
4132 install_dir : testsdir)
4133 if want_tests != 'false'
4134 test('test-libsystemd-sym', exe)
4138 'test-libsystemd-static-sym',
4139 test_libsystemd_sym_c,
4140 include_directories : includes,
4141 link_with : [install_libsystemd_static],
4142 dependencies : [threads], # threads is already included in dependencies on the library,
4143 # but does not seem to get propagated. Add here as a work-around.
4144 build_by_default : want_tests != 'false' and static_libsystemd_pic,
4145 install : install_tests and static_libsystemd_pic,
4146 install_dir : testsdir)
4147 if want_tests != 'false' and static_libsystemd_pic
4148 test('test-libsystemd-static-sym', exe)
4154 include_directories : libudev_includes,
4155 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
4156 link_with : [libudev],
4157 build_by_default : want_tests != 'false',
4158 install : install_tests,
4159 install_dir : testsdir)
4160 if want_tests != 'false'
4161 test('test-libudev-sym', exe)
4165 'test-libudev-static-sym',
4167 include_directories : libudev_includes,
4168 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
4169 link_with : [install_libudev_static],
4170 build_by_default : want_tests != 'false' and static_libudev_pic,
4171 install : install_tests and static_libudev_pic,
4172 install_dir : testsdir)
4173 if want_tests != 'false' and static_libudev_pic
4174 test('test-libudev-static-sym', exe)
4177 ############################################################
4181 foreach tuple : fuzzers
4183 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
4184 dependencies = tuple.length() > 2 ? tuple[2] : []
4185 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
4186 defs = tuple.length() > 4 ? tuple[4] : []
4190 dependencies += fuzzing_engine
4192 if fuzzing_engine.found()
4193 dependencies += fuzzing_engine
4195 link_args += ['-fsanitize=fuzzer']
4198 sources += 'src/fuzz/fuzz-main.c'
4200 sources += fuzz_generated_directives
4202 # FIXME: Use fs.stem() with meson >= 0.54.0
4203 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
4208 include_directories : [incs, include_directories('src/fuzz')],
4209 link_with : link_with,
4210 dependencies : [dependencies,
4212 c_args : defs + test_cflags,
4213 link_args: link_args,
4215 build_by_default : fuzzer_build)
4218 if want_tests != 'false' and name in fuzz_regression_tests
4219 # Run the fuzz regression tests without any sanitizers enabled.
4220 # Additional invocations with sanitizers may be added below.
4221 foreach tuple : fuzz_regression_tests[name]
4224 test('@0@_@1@'.format(name, fuzz_in),
4227 args : [fuzz_dir != '' ? project_source_root / fuzz_dir / name / fuzz_in
4228 : fuzz_generated_in_dir / '@0@_@1@'.format(name, fuzz_in)])
4233 alias_target('fuzzers', fuzzer_exes)
4235 ############################################################
4237 subdir('docs/sysvinit')
4238 subdir('docs/var-log')
4241 subdir('modprobe.d')
4244 subdir('shell-completion/bash')
4245 subdir('shell-completion/zsh')
4247 subdir('sysusers.d')
4248 subdir('tmpfiles.d')
4251 install_subdir('factory/etc',
4252 install_dir : factorydir)
4253 subdir('factory/templates')
4255 if install_sysconfdir
4256 install_data('xorg/50-systemd-user.sh',
4257 install_dir : xinitrcdir)
4259 install_data('LICENSE.GPL2',
4263 'docs/CODING_STYLE.md',
4264 'docs/DISTRO_PORTING.md',
4265 'docs/ENVIRONMENT.md',
4267 'docs/TRANSIENT-SETTINGS.md',
4268 'docs/TRANSLATORS.md',
4269 'docs/UIDS-GIDS.md',
4270 install_dir : docdir)
4272 install_subdir('LICENSES',
4273 install_dir : docdir)
4275 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
4276 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
4278 ############################################################
4280 # Ensure that changes to the docs/ directory do not break the
4281 # basic Github pages build. But only run it in developer mode,
4282 # as it might be fragile due to changes in the tooling, and it is
4283 # not generally useful for users.
4284 jekyll = find_program('jekyll', required : false)
4285 if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
4286 test('github-pages',
4288 suite : 'dist-check',
4290 '--source', project_source_root / 'docs',
4291 '--destination', project_build_root / '_site'])
4294 ############################################################
4296 check_help = find_program('tools/check-help.sh')
4297 check_version = find_program('tools/check-version.sh')
4299 foreach exec : public_programs
4300 name = exec.full_path().split('/')[-1]
4301 if want_tests != 'false'
4302 test('check-help-' + name,
4304 suite : 'dist-check',
4305 args : exec.full_path(),
4308 test('check-version-' + name,
4310 suite : 'dist-check',
4311 args : [exec.full_path(),
4312 meson.project_version()],
4317 # Enable tests for all supported sanitizers
4318 foreach tuple : fuzz_sanitizers
4319 sanitizer = tuple[0]
4322 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
4323 foreach fuzzer, fuzz_ins : fuzz_regression_tests
4324 name = '@0@:@1@'.format(fuzzer, sanitizer)
4325 if want_tests == 'false'
4326 message('Not compiling @0@ because tests is set to false'.format(name))
4330 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
4333 exe = custom_target(
4336 depends : [build] + fuzz_generated_directives,
4337 command : [ln, '-fs',
4338 build.full_path() / fuzzer,
4340 build_by_default : true)
4342 foreach tuple : fuzz_ins
4346 test('@0@_@1@_@2@'.format(fuzzer, fuzz_in, sanitizer),
4349 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
4351 args : [exe.full_path(),
4352 fuzz_dir != '' ? project_source_root / fuzz_dir / fuzzer / fuzz_in
4353 : fuzz_generated_in_dir / '@0@_@1@'.format(fuzzer, fuzz_in)])
4360 ############################################################
4363 all_files = run_command(
4364 env, '-u', 'GIT_WORK_TREE',
4365 git, '--git-dir=@0@/.git'.format(project_source_root),
4366 'ls-files', ':/*.[ch]',
4368 if all_files.returncode() == 0
4369 all_files = files(all_files.stdout().split())
4374 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
4377 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
4382 git_contrib_sh = find_program('tools/git-contrib.sh')
4385 command : [git_contrib_sh])
4389 git_head = run_command(
4390 git, '--git-dir=@0@/.git'.format(project_source_root),
4391 'rev-parse', 'HEAD',
4392 check : false).stdout().strip()
4393 git_head_short = run_command(
4394 git, '--git-dir=@0@/.git'.format(project_source_root),
4395 'rev-parse', '--short=7', 'HEAD',
4396 check : false).stdout().strip()
4400 command : [git, 'archive',
4401 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
4403 '--prefix', 'systemd-@0@/'.format(git_head),
4407 ############################################################
4409 check_api_docs_sh = find_program('tools/check-api-docs.sh')
4412 depends : [man, libsystemd, libudev],
4413 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
4415 alias_target('update-dbus-docs', update_dbus_docs)
4416 alias_target('update-man-rules', update_man_rules)
4418 if not meson.is_cross_build()
4420 'export-dbus-interfaces',
4421 output : fs.name(dbus_interfaces_dir),
4422 install : dbus_interfaces_dir != 'no',
4423 install_dir : fs.parent(dbus_interfaces_dir),
4424 command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
4427 ############################################################
4429 alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
4430 check : true).stdout().strip()
4433 'split /usr' : split_usr,
4434 'split bin-sbin' : split_bin,
4435 'prefix directory' : prefixdir,
4436 'rootprefix directory' : rootprefixdir,
4437 'sysconf directory' : sysconfdir,
4438 'include directory' : includedir,
4439 'lib directory' : libdir,
4440 'rootlib directory' : rootlibdir,
4441 'SysV init scripts' : sysvinit_path,
4442 'SysV rc?.d directories' : sysvrcnd_path,
4443 'PAM modules directory' : pamlibdir,
4444 'PAM configuration directory' : pamconfdir,
4445 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
4446 'RPM macros directory' : rpmmacrosdir,
4447 'modprobe.d directory' : modprobedir,
4448 'D-Bus policy directory' : dbuspolicydir,
4449 'D-Bus session directory' : dbussessionservicedir,
4450 'D-Bus system directory' : dbussystemservicedir,
4451 'D-Bus interfaces directory' : dbus_interfaces_dir,
4452 'bash completions directory' : bashcompletiondir,
4453 'zsh completions directory' : zshcompletiondir,
4454 'private shared lib version tag' : shared_lib_tag,
4455 'extra start script' : get_option('rc-local'),
4456 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
4457 get_option('debug-tty')),
4458 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
4459 conf.get('SYSTEM_ALLOC_UID_MIN')),
4460 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
4461 conf.get('SYSTEM_ALLOC_GID_MIN')),
4462 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
4463 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
4464 'static UID/GID allocations' : ' '.join(static_ugids),
4465 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
4466 'render group access mode' : get_option('group-render-mode'),
4467 'certificate root directory' : get_option('certificate-root'),
4468 'support URL' : support_url,
4469 'nobody user name' : nobody_user,
4470 'nobody group name' : nobody_group,
4471 'fallback hostname' : get_option('fallback-hostname'),
4472 'default compression method' : compression,
4473 'default DNSSEC mode' : default_dnssec,
4474 'default DNS-over-TLS mode' : default_dns_over_tls,
4475 'default mDNS mode' : default_mdns,
4476 'default LLMNR mode' : default_llmnr,
4477 'default DNS servers' : dns_servers.split(' '),
4478 'default NTP servers' : ntp_servers.split(' '),
4479 'default cgroup hierarchy' : default_hierarchy,
4480 'default net.naming-scheme value' : default_net_naming_scheme,
4481 'default KillUserProcesses value' : kill_user_processes,
4482 'default locale' : default_locale,
4483 'default nspawn locale' : nspawn_locale,
4484 'default status unit format' : status_unit_format_default,
4485 'default user $PATH' :
4486 default_user_path != '' ? default_user_path : '(same as system services)',
4487 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
4488 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
4491 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
4492 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
4493 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
4514 ['libcryptsetup-plugins'],
4540 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
4570 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
4584 ['legacy-pkla', install_polkit_pkla],
4590 ['man pages', want_man],
4591 ['html pages', want_html],
4592 ['man page indices', want_man and have_lxml],
4594 ['compat-mutable-uid-boundaries'],
4597 ['adm group', get_option('adm-group')],
4598 ['wheel group', get_option('wheel-group')],
4601 ['debug mmap cache'],
4603 ['valgrind', conf.get('VALGRIND') == 1],
4604 ['trace logging', conf.get('LOG_TRACE') == 1],
4605 ['install tests', install_tests],
4606 ['link-udev-shared', get_option('link-udev-shared')],
4607 ['link-systemctl-shared', get_option('link-systemctl-shared')],
4608 ['link-networkd-shared', get_option('link-networkd-shared')],
4609 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
4610 ['link-journalctl-shared', get_option('link-journalctl-shared')],
4611 ['link-boot-shared', get_option('link-boot-shared')],
4612 ['first-boot-full-preset'],
4614 ['standalone-binaries', get_option('standalone-binaries')],
4615 ['coverage', get_option('b_coverage')],
4618 if tuple.length() >= 2
4621 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
4622 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
4623 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
4632 if static_libsystemd == 'false'
4633 missing += 'static-libsystemd'
4635 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
4638 if static_libudev == 'false'
4639 missing += 'static-libudev'
4641 found += 'static-libudev(@0@)'.format(static_libudev)
4644 if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
4645 found += 'cryptolib(openssl)'
4646 elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
4647 found += 'cryptolib(gcrypt)'
4649 missing += 'cryptolib'
4652 if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
4653 found += 'DNS-over-TLS(gnutls)'
4654 elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
4655 found += 'DNS-over-TLS(openssl)'
4657 missing += 'DNS-over-TLS'
4661 'enabled' : ', '.join(found),
4662 'disabled' : ', '.join(missing)},
4663 section : 'Features')
4665 if rootprefixdir != rootprefix_default
4667 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
4668 'systemd used fixed names for unit file directories and other paths, so anything\n' +
4669 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))