1 # SPDX-License-Identifier: LGPL-2.1-or-later
3 project('systemd', 'c',
13 meson_version : '>= 0.53.2',
16 libsystemd_version = '0.34.0'
17 libudev_version = '1.7.4'
19 conf = configuration_data()
20 conf.set_quoted('PROJECT_URL', 'https://systemd.io/')
21 conf.set('PROJECT_VERSION', meson.project_version(),
22 description : 'Numerical project version (used where a simple number is expected)')
24 # This is to be used instead of meson.source_root(), as the latter will return
25 # the wrong result when systemd is being built as a meson subproject
26 project_source_root = meson.current_source_dir()
27 project_build_root = meson.current_build_dir()
28 relative_source_path = run_command('realpath',
29 '--relative-to=@0@'.format(project_build_root),
31 check : true).stdout().strip()
32 conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)
34 conf.set10('BUILD_MODE_DEVELOPER', get_option('mode') == 'developer',
35 description : 'tailor build to development or release builds')
36 verification = get_option('log-message-verification')
37 if verification == 'auto'
38 verification = conf.get('BUILD_MODE_DEVELOPER') == 1
40 verification = verification == 'true'
42 conf.set10('LOG_MESSAGE_VERIFICATION', verification)
44 want_ossfuzz = get_option('oss-fuzz')
45 want_libfuzzer = get_option('llvm-fuzz')
46 if want_ossfuzz and want_libfuzzer
47 error('only one of oss-fuzz or llvm-fuzz can be specified')
50 skip_deps = want_ossfuzz or get_option('skip-deps')
51 fuzzer_build = want_ossfuzz or want_libfuzzer
53 # If we're building *not* for actual fuzzing, allow input samples of any size
54 # (for testing and for reproduction of issues discovered with previously-higher
56 conf.set10('FUZZ_USE_SIZE_LIMIT', fuzzer_build)
58 # Create a title-less summary section early, so it ends up first in the output.
59 # More items are added later after they have been detected.
60 summary({'build mode' : get_option('mode')})
62 #####################################################################
64 # Try to install the git pre-commit hook
65 add_git_hook_sh = find_program('tools/add-git-hook.sh', required : false)
66 if add_git_hook_sh.found()
67 git_hook = run_command(add_git_hook_sh, check : false)
68 if git_hook.returncode() == 0
69 message(git_hook.stdout().strip())
73 #####################################################################
76 if get_option('split-usr') == 'auto'
77 split_usr = not fs.is_symlink('/bin')
79 split_usr = get_option('split-usr') == 'true'
82 warning('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n\n'
83 + ' split-usr mode is going to be removed\n' +
84 '\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
86 conf.set10('HAVE_SPLIT_USR', split_usr,
87 description : '/usr/bin and /bin directories are separate')
89 if get_option('split-bin') == 'auto'
90 split_bin = not fs.is_symlink('/usr/sbin')
92 split_bin = get_option('split-bin') == 'true'
94 conf.set10('HAVE_SPLIT_BIN', split_bin,
95 description : 'bin and sbin directories are separate')
97 rootprefixdir = get_option('rootprefix')
98 # Unusual rootprefixdir values are used by some distros
99 # (see https://github.com/systemd/systemd/pull/7461).
100 rootprefix_default = split_usr ? '/' : '/usr'
101 if rootprefixdir == ''
102 rootprefixdir = rootprefix_default
104 rootprefixdir_noslash = rootprefixdir == '/' ? '' : rootprefixdir
106 have_standalone_binaries = get_option('standalone-binaries')
108 sysvinit_path = get_option('sysvinit-path')
109 sysvrcnd_path = get_option('sysvrcnd-path')
110 conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '',
111 description : 'SysV init scripts and rcN.d links are supported')
112 conf.set10('CREATE_LOG_DIRS', get_option('create-log-dirs'))
114 if get_option('hibernate') and not get_option('initrd')
115 error('hibernate depends on initrd')
118 conf.set10('BUMP_PROC_SYS_FS_FILE_MAX', get_option('bump-proc-sys-fs-file-max'))
119 conf.set10('BUMP_PROC_SYS_FS_NR_OPEN', get_option('bump-proc-sys-fs-nr-open'))
120 conf.set('HIGH_RLIMIT_NOFILE', 512*1024)
122 # Meson ignores the preceding arguments when joining paths if an absolute
123 # component is encountered, so this should canonicalize various paths when they
124 # are absolute or relative.
125 prefixdir = get_option('prefix')
126 if not prefixdir.startswith('/')
127 error('Prefix is not absolute: "@0@"'.format(prefixdir))
129 if prefixdir != rootprefixdir and rootprefixdir != '/' and not prefixdir.strip('/').startswith(rootprefixdir.strip('/') + '/')
130 error('Prefix is not below root prefix (now rootprefix=@0@ prefix=@1@)'.format(
131 rootprefixdir, prefixdir))
134 bindir = prefixdir / get_option('bindir')
135 libdir = prefixdir / get_option('libdir')
136 sysconfdir = prefixdir / get_option('sysconfdir')
137 includedir = prefixdir / get_option('includedir')
138 datadir = prefixdir / get_option('datadir')
139 localstatedir = '/' / get_option('localstatedir')
141 rootbindir = rootprefixdir / 'bin'
142 rootsbindir = rootprefixdir / (split_bin ? 'sbin' : 'bin')
143 rootlibexecdir = rootprefixdir / 'lib/systemd'
145 rootlibdir = get_option('rootlibdir')
147 # This will be a relative path if libdir is in prefix.
148 rootlibdir = get_option('libdir')
150 if not rootlibdir.startswith('/')
151 # If we have a relative path, add rootprefixdir to the front.
152 rootlibdir = rootprefixdir / rootlibdir
154 rootpkglibdir = rootlibdir / 'systemd'
156 install_sysconfdir = get_option('install-sysconfdir') != 'false'
157 install_sysconfdir_samples = get_option('install-sysconfdir') == 'true'
158 # Dirs of external packages
159 pkgconfigdatadir = get_option('pkgconfigdatadir') != '' ? get_option('pkgconfigdatadir') : datadir / 'pkgconfig'
160 pkgconfiglibdir = get_option('pkgconfiglibdir') != '' ? get_option('pkgconfiglibdir') : libdir / 'pkgconfig'
161 polkitpolicydir = datadir / 'polkit-1/actions'
162 polkitrulesdir = datadir / 'polkit-1/rules.d'
163 polkitpkladir = localstatedir / 'lib/polkit-1/localauthority/10-vendor.d'
164 xinitrcdir = get_option('xinitrcdir') != '' ? get_option('xinitrcdir') : sysconfdir / 'X11/xinit/xinitrc.d'
165 rpmmacrosdir = get_option('rpmmacrosdir')
166 if rpmmacrosdir != 'no'
167 rpmmacrosdir = prefixdir / rpmmacrosdir
169 modprobedir = rootprefixdir / 'lib/modprobe.d'
172 pkgdatadir = datadir / 'systemd'
173 environmentdir = prefixdir / 'lib/environment.d'
174 pkgsysconfdir = sysconfdir / 'systemd'
175 userunitdir = prefixdir / 'lib/systemd/user'
176 userpresetdir = prefixdir / 'lib/systemd/user-preset'
177 tmpfilesdir = prefixdir / 'lib/tmpfiles.d'
178 usertmpfilesdir = prefixdir / 'share/user-tmpfiles.d'
179 sysusersdir = prefixdir / 'lib/sysusers.d'
180 sysctldir = prefixdir / 'lib/sysctl.d'
181 binfmtdir = prefixdir / 'lib/binfmt.d'
182 modulesloaddir = prefixdir / 'lib/modules-load.d'
183 networkdir = rootprefixdir / 'lib/systemd/network'
184 pkgincludedir = includedir / 'systemd'
185 systemgeneratordir = rootlibexecdir / 'system-generators'
186 usergeneratordir = prefixdir / 'lib/systemd/user-generators'
187 systemenvgeneratordir = prefixdir / 'lib/systemd/system-environment-generators'
188 userenvgeneratordir = prefixdir / 'lib/systemd/user-environment-generators'
189 systemshutdowndir = rootlibexecdir / 'system-shutdown'
190 systemsleepdir = rootlibexecdir / 'system-sleep'
191 systemunitdir = rootprefixdir / 'lib/systemd/system'
192 systempresetdir = rootprefixdir / 'lib/systemd/system-preset'
193 udevlibexecdir = rootprefixdir / 'lib/udev'
194 udevrulesdir = udevlibexecdir / 'rules.d'
195 udevhwdbdir = udevlibexecdir / 'hwdb.d'
196 catalogdir = prefixdir / 'lib/systemd/catalog'
197 kerneldir = prefixdir / 'lib/kernel'
198 kernelinstalldir = kerneldir / 'install.d'
199 factorydir = datadir / 'factory'
200 bootlibdir = prefixdir / 'lib/systemd/boot/efi'
201 testsdir = prefixdir / 'lib/systemd/tests'
202 systemdstatedir = localstatedir / 'lib/systemd'
203 catalogstatedir = systemdstatedir / 'catalog'
204 randomseeddir = localstatedir / 'lib/systemd'
205 profiledir = rootlibexecdir / 'portable' / 'profile'
206 ntpservicelistdir = rootprefixdir / 'lib/systemd/ntp-units.d'
208 docdir = get_option('docdir')
210 docdir = datadir / 'doc/systemd'
213 pamlibdir = get_option('pamlibdir')
215 pamlibdir = rootlibdir / 'security'
218 pamconfdir = get_option('pamconfdir')
220 pamconfdir = prefixdir / 'lib/pam.d'
223 libcryptsetup_plugins_dir = get_option('libcryptsetup-plugins-dir')
224 if libcryptsetup_plugins_dir == ''
225 libcryptsetup_plugins_dir = rootlibdir / 'cryptsetup'
228 memory_accounting_default = get_option('memory-accounting-default')
229 status_unit_format_default = get_option('status-unit-format-default')
230 if status_unit_format_default == 'auto'
231 status_unit_format_default = conf.get('BUILD_MODE_DEVELOPER') == 1 ? 'name' : 'description'
234 conf.set_quoted('BINFMT_DIR', binfmtdir)
235 conf.set_quoted('BOOTLIBDIR', bootlibdir)
236 conf.set_quoted('CATALOG_DATABASE', catalogstatedir / 'database')
237 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
238 conf.set_quoted('DOC_DIR', docdir)
239 conf.set_quoted('DOCUMENT_ROOT', pkgdatadir / 'gatewayd')
240 conf.set_quoted('ENVIRONMENT_DIR', environmentdir)
241 conf.set_quoted('INCLUDE_DIR', includedir)
242 conf.set_quoted('LIBDIR', libdir)
243 conf.set_quoted('MODPROBE_DIR', modprobedir)
244 conf.set_quoted('MODULESLOAD_DIR', modulesloaddir)
245 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
246 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', bindir / 'pkttyagent')
247 conf.set_quoted('PREFIX', prefixdir)
248 conf.set_quoted('RANDOM_SEED', randomseeddir / 'random-seed')
249 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
250 conf.set_quoted('RC_LOCAL_PATH', get_option('rc-local'))
251 conf.set_quoted('ROOTBINDIR', rootbindir)
252 conf.set_quoted('ROOTLIBDIR', rootlibdir)
253 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
254 conf.set_quoted('ROOTPREFIX', rootprefixdir)
255 conf.set_quoted('ROOTPREFIX_NOSLASH', rootprefixdir_noslash)
256 conf.set_quoted('SYSCONF_DIR', sysconfdir)
257 conf.set_quoted('SYSCTL_DIR', sysctldir)
258 conf.set_quoted('SYSTEMCTL_BINARY_PATH', rootbindir / 'systemctl')
259 conf.set_quoted('SYSTEMD_BINARY_PATH', rootlibexecdir / 'systemd')
260 conf.set_quoted('SYSTEMD_CATALOG_DIR', catalogdir)
261 conf.set_quoted('SYSTEMD_CGROUPS_AGENT_PATH', rootlibexecdir / 'systemd-cgroups-agent')
262 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', rootlibexecdir / 'systemd-cryptsetup')
263 conf.set_quoted('SYSTEMD_EXPORT_PATH', rootlibexecdir / 'systemd-export')
264 conf.set_quoted('SYSTEMD_FSCK_PATH', rootlibexecdir / 'systemd-fsck')
265 conf.set_quoted('SYSTEMD_GROWFS_PATH', rootlibexecdir / 'systemd-growfs')
266 conf.set_quoted('SYSTEMD_HOMEWORK_PATH', rootlibexecdir / 'systemd-homework')
267 conf.set_quoted('SYSTEMD_IMPORT_FS_PATH', rootlibexecdir / 'systemd-import-fs')
268 conf.set_quoted('SYSTEMD_IMPORT_PATH', rootlibexecdir / 'systemd-import')
269 conf.set_quoted('SYSTEMD_INTEGRITYSETUP_PATH', rootlibexecdir / 'systemd-integritysetup')
270 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', pkgdatadir / 'kbd-model-map')
271 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', pkgdatadir / 'language-fallback-map')
272 conf.set_quoted('SYSTEMD_MAKEFS_PATH', rootlibexecdir / 'systemd-makefs')
273 conf.set_quoted('SYSTEMD_PULL_PATH', rootlibexecdir / 'systemd-pull')
274 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', rootlibexecdir / 'systemd-shutdown')
275 conf.set_quoted('SYSTEMD_TEST_DATA', testsdir / 'testdata')
276 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', rootbindir / 'systemd-tty-ask-password-agent')
277 conf.set_quoted('SYSTEMD_UPDATE_HELPER_PATH', rootlibexecdir / 'systemd-update-helper')
278 conf.set_quoted('SYSTEMD_USERWORK_PATH', rootlibexecdir / 'systemd-userwork')
279 conf.set_quoted('SYSTEMD_VERITYSETUP_PATH', rootlibexecdir / 'systemd-veritysetup')
280 conf.set_quoted('SYSTEM_CONFIG_UNIT_DIR', pkgsysconfdir / 'system')
281 conf.set_quoted('SYSTEM_DATA_UNIT_DIR', systemunitdir)
282 conf.set_quoted('SYSTEM_ENV_GENERATOR_DIR', systemenvgeneratordir)
283 conf.set_quoted('SYSTEM_GENERATOR_DIR', systemgeneratordir)
284 conf.set_quoted('SYSTEM_PRESET_DIR', systempresetdir)
285 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
286 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
287 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
288 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
289 conf.set_quoted('SYSUSERS_DIR', sysusersdir)
290 conf.set_quoted('TMPFILES_DIR', tmpfilesdir)
291 conf.set_quoted('USER_TMPFILES_DIR', usertmpfilesdir)
292 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
293 conf.set_quoted('UDEV_HWDB_DIR', udevhwdbdir)
294 conf.set_quoted('UDEV_RULES_DIR', udevrulesdir)
295 conf.set_quoted('UPDATE_HELPER_USER_TIMEOUT', get_option('update-helper-user-timeout'))
296 conf.set_quoted('USER_CONFIG_UNIT_DIR', pkgsysconfdir / 'user')
297 conf.set_quoted('USER_DATA_UNIT_DIR', userunitdir)
298 conf.set_quoted('USER_ENV_GENERATOR_DIR', userenvgeneratordir)
299 conf.set_quoted('USER_GENERATOR_DIR', usergeneratordir)
300 conf.set_quoted('USER_KEYRING_PATH', pkgsysconfdir / 'import-pubring.gpg')
301 conf.set_quoted('USER_PRESET_DIR', userpresetdir)
302 conf.set_quoted('VENDOR_KEYRING_PATH', rootlibexecdir / 'import-pubring.gpg')
304 conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
305 conf.set10('ENABLE_URLIFY', get_option('urlify'))
306 conf.set10('ENABLE_FEXECVE', get_option('fexecve'))
307 conf.set10('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default)
308 conf.set('STATUS_UNIT_FORMAT_DEFAULT', 'STATUS_UNIT_FORMAT_' + status_unit_format_default.to_upper())
309 conf.set_quoted('STATUS_UNIT_FORMAT_DEFAULT_STR', status_unit_format_default)
311 conf.set10('FIRST_BOOT_FULL_PRESET', get_option('first-boot-full-preset'))
313 #####################################################################
315 cc = meson.get_compiler('c')
316 pkgconfig = import('pkgconfig')
317 meson_build_sh = find_program('tools/meson-build.sh')
319 want_tests = get_option('tests')
320 slow_tests = want_tests != 'false' and get_option('slow-tests')
321 fuzz_tests = want_tests != 'false' and get_option('fuzz-tests')
322 install_tests = get_option('install-tests')
324 if add_languages('cpp', required : fuzzer_build)
325 # Used only for tests
326 cxx = meson.get_compiler('cpp')
327 cxx_cmd = ' '.join(cxx.cmd_array())
333 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer', required : false)
334 if fuzzing_engine.found()
335 add_project_arguments('-fsanitize-coverage=trace-pc-guard,trace-cmp', language : 'c')
336 elif cc.has_argument('-fsanitize=fuzzer-no-link')
337 add_project_arguments('-fsanitize=fuzzer-no-link', language : 'c')
339 error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported')
342 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
345 # Those generate many false positives, and we do not want to change the code to
347 basic_disabled_warnings = [
348 '-Wno-format-signedness',
349 '-Wno-missing-field-initializers',
350 '-Wno-unused-parameter',
353 possible_common_cc_flags = [
357 '-Werror=implicit-function-declaration',
358 '-Werror=incompatible-pointer-types',
359 '-Werror=int-conversion',
361 '-Werror=override-init',
362 '-Werror=return-type',
363 '-Werror=shift-count-overflow',
364 '-Werror=shift-overflow=2',
367 # gperf prevents us from enabling this because it does not emit fallthrough
368 # attribute with clang.
369 #'-Wimplicit-fallthrough',
370 '-Wimplicit-fallthrough=5',
373 '-Wmissing-include-dirs',
374 '-Wmissing-noreturn',
376 '-Wold-style-definition',
380 '-Wstrict-aliasing=2',
381 '-Wstrict-prototypes',
382 '-Wsuggest-attribute=noreturn',
386 # negative arguments are correctly detected starting with meson 0.46.
387 '-Wno-error=#warnings', # clang
388 '-Wno-string-plus-int', # clang
391 c_args = get_option('c_args')
393 # Our json library does not support -ffinite-math-only, which is enabled by -Ofast or -ffast-math.
394 if (('-Ofast' in c_args or '-ffast-math' in c_args or '-ffinite-math-only' in c_args) and not ('-fno-finite-math-only' in c_args))
395 error('-Ofast, -ffast-math, or -ffinite-math-only is specified in c_args.')
398 # Disable -Wmaybe-uninitialized when compiling with -Os/-O1/-O3/etc. There are
399 # too many false positives with gcc >= 8. Effectively, we only test with -O0
400 # and -O2; this should be enough to catch most important cases without too much
401 # busywork. See https://github.com/systemd/systemd/pull/19226.
402 if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or
403 cc.version().version_compare('<10') or
408 possible_common_cc_flags += '-Wno-maybe-uninitialized'
411 # Disable -Wno-unused-result with gcc, see
412 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425.
413 if cc.get_id() == 'gcc'
414 possible_common_cc_flags += '-Wno-unused-result'
417 # --as-needed and --no-undefined are provided by meson by default,
418 # run 'meson configure' to see what is enabled
419 possible_link_flags = [
420 '-Wl,--fatal-warnings',
426 if get_option('b_sanitize') == 'none'
427 possible_link_flags += '-Wl,--warn-common'
430 if cc.get_id() == 'clang'
431 possible_common_cc_flags += [
432 '-Wno-typedef-redefinition',
433 '-Wno-gnu-variable-sized-type-not-at-end',
437 if get_option('mode') == 'release'
438 # We could enable 'pattern' for developer mode, but that can interfere with
439 # valgrind and sanitizer builds. Also, clang does not zero-initialize unions,
440 # breaking some of our code (https://reviews.llvm.org/D68115).
441 possible_common_cc_flags += '-ftrivial-auto-var-init=zero'
444 possible_cc_flags = possible_common_cc_flags + [
445 '-Werror=missing-declarations',
446 '-Werror=missing-prototypes',
447 '-fdiagnostics-show-option',
449 '-fno-strict-aliasing',
451 '-fstack-protector-strong',
452 '-fvisibility=hidden',
453 '--param=ssp-buffer-size=4',
456 if get_option('buildtype') != 'debug'
457 possible_cc_flags += [
458 '-ffunction-sections',
462 possible_link_flags += '-Wl,--gc-sections'
465 if get_option('mode') == 'developer'
466 possible_cc_flags += '-fno-omit-frame-pointer'
469 add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
470 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
471 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
473 have = cc.has_argument('-Wzero-length-bounds')
474 conf.set10('HAVE_ZERO_LENGTH_BOUNDS', have)
478 #include <inttypes.h>
479 typedef uint64_t usec_t;
480 usec_t now(clockid_t clock);
485 ''', args: '-Werror=shadow', name : '-Werror=shadow with local shadowing')
486 add_project_arguments('-Werror=shadow', language : 'c')
490 add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
493 cpp = ' '.join(cc.cmd_array()) + ' -E'
495 has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
497 #####################################################################
498 # compilation result tests
500 conf.set('_GNU_SOURCE', true)
501 conf.set('__SANE_USERSPACE_TYPES__', true)
502 conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)
504 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
505 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
506 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
507 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
508 conf.set('SIZEOF_TIMEX_MEMBER', cc.sizeof('typeof(((struct timex *)0)->freq)', prefix : '#include <sys/timex.h>'))
512 #include <sys/mount.h>
513 #include <sys/stat.h>
516 foreach decl : ['char16_t',
522 # We get -1 if the size cannot be determined
523 have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
525 if decl == 'struct mount_attr'
527 want_linux_fs_h = false
529 have = cc.sizeof(decl,
530 prefix : decl_headers + '#include <linux/fs.h>',
531 args : '-D_GNU_SOURCE') > 0
532 want_linux_fs_h = have
536 if decl == 'struct statx'
538 want_linux_stat_h = false
540 have = cc.sizeof(decl,
541 prefix : decl_headers + '#include <linux/stat.h>',
542 args : '-D_GNU_SOURCE') > 0
543 want_linux_stat_h = have
547 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
550 conf.set10('WANT_LINUX_STAT_H', want_linux_stat_h)
551 conf.set10('WANT_LINUX_FS_H', want_linux_fs_h)
553 foreach ident : ['secure_getenv', '__secure_getenv']
554 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
558 ['memfd_create', '''#include <sys/mman.h>'''],
559 ['gettid', '''#include <sys/types.h>
560 #include <unistd.h>'''],
561 ['pivot_root', '''#include <stdlib.h>
562 #include <unistd.h>'''], # no known header declares pivot_root
563 ['ioprio_get', '''#include <sched.h>'''], # no known header declares ioprio_get
564 ['ioprio_set', '''#include <sched.h>'''], # no known header declares ioprio_set
565 ['name_to_handle_at', '''#include <sys/types.h>
566 #include <sys/stat.h>
567 #include <fcntl.h>'''],
568 ['setns', '''#include <sched.h>'''],
569 ['renameat2', '''#include <stdio.h>
570 #include <fcntl.h>'''],
571 ['kcmp', '''#include <linux/kcmp.h>'''],
572 ['keyctl', '''#include <sys/types.h>
573 #include <keyutils.h>'''],
574 ['copy_file_range', '''#include <sys/syscall.h>
575 #include <unistd.h>'''],
576 ['bpf', '''#include <sys/syscall.h>
577 #include <unistd.h>'''],
578 ['statx', '''#include <sys/types.h>
579 #include <sys/stat.h>
580 #include <unistd.h>'''],
581 ['explicit_bzero' , '''#include <string.h>'''],
582 ['reallocarray', '''#include <stdlib.h>'''],
583 ['set_mempolicy', '''#include <stdlib.h>
584 #include <unistd.h>'''],
585 ['get_mempolicy', '''#include <stdlib.h>
586 #include <unistd.h>'''],
587 ['pidfd_send_signal', '''#include <stdlib.h>
590 #include <sys/wait.h>'''],
591 ['pidfd_open', '''#include <stdlib.h>
594 #include <sys/wait.h>'''],
595 ['rt_sigqueueinfo', '''#include <stdlib.h>
598 #include <sys/wait.h>'''],
599 ['mallinfo', '''#include <malloc.h>'''],
600 ['mallinfo2', '''#include <malloc.h>'''],
601 ['execveat', '''#include <unistd.h>'''],
602 ['close_range', '''#include <unistd.h>'''],
603 ['epoll_pwait2', '''#include <sys/epoll.h>'''],
604 ['mount_setattr', '''#include <sys/mount.h>'''],
605 ['move_mount', '''#include <sys/mount.h>'''],
606 ['open_tree', '''#include <sys/mount.h>'''],
607 ['getdents64', '''#include <dirent.h>'''],
610 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
611 conf.set10('HAVE_' + ident[0].to_upper(), have)
614 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
615 conf.set10('USE_SYS_RANDOM_H', true)
616 conf.set10('HAVE_GETRANDOM', true)
618 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
619 conf.set10('USE_SYS_RANDOM_H', false)
620 conf.set10('HAVE_GETRANDOM', have)
623 #####################################################################
625 version_tag = get_option('version-tag')
627 vcs_data = configuration_data()
628 vcs_data.set('VCS_TAG', version_tag)
629 version_h = configure_file(configuration : vcs_data,
630 input : 'src/version/version.h.in',
631 output : 'version.h')
634 project_source_root + '/tools/meson-vcs-tag.sh',
636 meson.project_version()]
639 input : 'src/version/version.h.in',
640 output : 'version.h',
644 versiondep = declare_dependency(sources: version_h)
646 shared_lib_tag = get_option('shared-lib-tag')
647 if shared_lib_tag == ''
648 shared_lib_tag = meson.project_version()
651 sh = find_program('sh')
652 echo = find_program('echo')
653 sed = find_program('sed')
654 awk = find_program('awk')
655 stat = find_program('stat')
656 ln = find_program('ln')
657 git = find_program('git', required : false)
658 env = find_program('env')
659 perl = find_program('perl', required : false)
660 rsync = find_program('rsync', required : false)
661 meson_make_symlink = project_source_root + '/tools/meson-make-symlink.sh'
663 mkdir_p = 'mkdir -p $DESTDIR/@0@'
665 # If -Dxxx-path option is found, use that. Otherwise, check in $PATH,
666 # /usr/sbin, /sbin, and fall back to the default from middle column.
667 progs = [['quotaon', '/usr/sbin/quotaon' ],
668 ['quotacheck', '/usr/sbin/quotacheck' ],
669 ['kmod', '/usr/bin/kmod' ],
670 ['kexec', '/usr/sbin/kexec' ],
671 ['sulogin', '/usr/sbin/sulogin' ],
672 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
673 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
674 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
675 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
676 ['nologin', '/usr/sbin/nologin', ],
679 path = get_option(prog[0] + '-path')
681 message('Using @1@ for @0@'.format(prog[0], path))
683 exe = find_program(prog[0],
684 '/usr/sbin/' + prog[0],
687 path = exe.found() ? exe.path() : prog[1]
689 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
690 conf.set_quoted(name, path)
693 conf.set_quoted('TELINIT', get_option('telinit-path'))
695 if run_command(ln, '--relative', '--help', check : false).returncode() != 0
696 error('ln does not support --relative (added in coreutils 8.16)')
699 ############################################################
701 python = find_program('python3')
702 if run_command(python, '-c', 'import jinja2', check : false).returncode() != 0
703 error('python3 jinja2 missing')
706 ############################################################
708 gperf = find_program('gperf')
710 gperf_test_format = '''
712 const char * in_word_set(const char *, @0@);
715 gperf_snippet = run_command(sh, '-c', 'echo foo,bar | "$1" -L ANSI-C', '_', gperf,
717 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
718 if cc.compiles(gperf_test)
719 gperf_len_type = 'size_t'
721 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
722 if cc.compiles(gperf_test)
723 gperf_len_type = 'unsigned'
725 error('unable to determine gperf len type')
728 message('gperf len type is @0@'.format(gperf_len_type))
729 conf.set('GPERF_LEN_TYPE', gperf_len_type,
730 description : 'The type of gperf "len" parameter')
732 ############################################################
734 if not cc.has_header('sys/capability.h')
735 error('POSIX caps headers not found')
737 foreach header : ['crypt.h',
739 'linux/vm_sockets.h',
741 'valgrind/memcheck.h',
742 'valgrind/valgrind.h',
743 'linux/time_types.h',
747 conf.set10('HAVE_' + header.underscorify().to_upper(),
748 cc.has_header(header))
751 ############################################################
753 fallback_hostname = get_option('fallback-hostname')
754 if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0] == '-'
755 error('Invalid fallback-hostname configuration')
756 # A more extensive test is done in test-hostname-util. Let's catch
757 # the most obvious errors here so we don't fail with an assert later.
759 conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
761 default_hierarchy = get_option('default-hierarchy')
762 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
763 description : 'default cgroup hierarchy as string')
764 if default_hierarchy == 'legacy'
765 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
766 elif default_hierarchy == 'hybrid'
767 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
769 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
772 extra_net_naming_schemes = []
773 extra_net_naming_map = []
774 foreach scheme: get_option('extra-net-naming-schemes').split(',')
776 name = scheme.split('=')[0]
777 value = scheme.split('=')[1]
778 NAME = name.underscorify().to_upper()
780 foreach field: value.split('+')
781 VALUE += 'NAMING_' + field.underscorify().to_upper()
783 extra_net_naming_schemes += 'NAMING_@0@ = @1@,'.format(NAME, '|'.join(VALUE))
784 extra_net_naming_map += '{ "@0@", NAMING_@1@ },'.format(name, NAME)
787 conf.set('EXTRA_NET_NAMING_SCHEMES', ' '.join(extra_net_naming_schemes))
788 conf.set('EXTRA_NET_NAMING_MAP', ' '.join(extra_net_naming_map))
790 default_net_naming_scheme = get_option('default-net-naming-scheme')
791 conf.set_quoted('DEFAULT_NET_NAMING_SCHEME', default_net_naming_scheme)
792 if default_net_naming_scheme != 'latest'
793 conf.set('_DEFAULT_NET_NAMING_SCHEME_TEST',
794 'NAMING_' + default_net_naming_scheme.underscorify().to_upper())
797 time_epoch = get_option('time-epoch')
799 time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check : true).stdout().strip()
800 if time_epoch == '' and git.found() and fs.exists('.git')
801 # If we're in a git repository, use the creation time of the latest git tag.
802 latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags',
804 if latest_tag.returncode() == 0
805 time_epoch = run_command(
806 git, 'log', '--no-show-signature', '-1', '--format=%at',
807 latest_tag.stdout().strip(),
808 check : false).stdout()
813 time_epoch = run_command(stat, '-c', '%Y', NEWS,
814 check : true).stdout()
816 time_epoch = time_epoch.strip().to_int()
818 conf.set('TIME_EPOCH', time_epoch)
820 conf.set('CLOCK_VALID_RANGE_USEC_MAX', get_option('clock-valid-range-usec-max'))
822 default_user_shell = get_option('default-user-shell')
823 conf.set_quoted('DEFAULT_USER_SHELL', default_user_shell)
824 conf.set_quoted('DEFAULT_USER_SHELL_NAME', fs.name(default_user_shell))
826 foreach tuple : [['system-alloc-uid-min', 'SYS_UID_MIN', 1], # Also see login.defs(5).
827 ['system-uid-max', 'SYS_UID_MAX', 999],
828 ['system-alloc-gid-min', 'SYS_GID_MIN', 1],
829 ['system-gid-max', 'SYS_GID_MAX', 999]]
830 v = get_option(tuple[0])
834 '/^\s*@0@\s+/ { uid=$2 } END { print uid }'.format(tuple[1]),
836 check : false).stdout().strip()
843 conf.set(tuple[0].underscorify().to_upper(), v)
845 if conf.get('SYSTEM_ALLOC_UID_MIN') >= conf.get('SYSTEM_UID_MAX')
846 error('Invalid uid allocation range')
848 if conf.get('SYSTEM_ALLOC_GID_MIN') >= conf.get('SYSTEM_GID_MAX')
849 error('Invalid gid allocation range')
852 dynamic_uid_min = get_option('dynamic-uid-min')
853 dynamic_uid_max = get_option('dynamic-uid-max')
854 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
855 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
857 container_uid_base_min = get_option('container-uid-base-min')
858 container_uid_base_max = get_option('container-uid-base-max')
859 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
860 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
862 nobody_user = get_option('nobody-user')
863 nobody_group = get_option('nobody-group')
865 if not meson.is_cross_build()
866 getent_result = run_command('getent', 'passwd', '65534', check : false)
867 if getent_result.returncode() == 0
868 name = getent_result.stdout().split(':')[0]
869 if name != nobody_user
871 '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) +
872 'Your build will result in an user table setup that is incompatible with the local system.')
875 id_result = run_command('id', '-u', nobody_user, check : false)
876 if id_result.returncode() == 0
877 id = id_result.stdout().strip().to_int()
880 '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) +
881 'Your build will result in an user table setup that is incompatible with the local system.')
885 getent_result = run_command('getent', 'group', '65534', check : false)
886 if getent_result.returncode() == 0
887 name = getent_result.stdout().split(':')[0]
888 if name != nobody_group
890 '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) +
891 'Your build will result in an group table setup that is incompatible with the local system.')
894 id_result = run_command('id', '-g', nobody_group, check : false)
895 if id_result.returncode() == 0
896 id = id_result.stdout().strip().to_int()
899 '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) +
900 'Your build will result in an group table setup that is incompatible with the local system.')
904 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
906 'The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
907 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
910 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
911 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
914 foreach option : ['adm-gid',
931 'systemd-journal-gid',
932 'systemd-network-uid',
933 'systemd-resolve-uid',
934 'systemd-timesync-uid']
935 name = option.underscorify().to_upper()
936 val = get_option(option)
938 # Ensure provided GID argument is numeric, otherwise fall back to default assignment
939 conf.set(name, val > 0 ? val : '-')
941 static_ugids += '@0@:@1@'.format(option, val)
945 conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
946 conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
948 dev_kvm_mode = get_option('dev-kvm-mode')
949 conf.set_quoted('DEV_KVM_MODE', dev_kvm_mode) # FIXME: convert to 0o… notation
950 conf.set10('DEV_KVM_UACCESS', dev_kvm_mode != '0666')
951 group_render_mode = get_option('group-render-mode')
952 conf.set_quoted('GROUP_RENDER_MODE', group_render_mode)
953 conf.set10('GROUP_RENDER_UACCESS', group_render_mode != '0666')
955 kill_user_processes = get_option('default-kill-user-processes')
956 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
958 dns_servers = get_option('dns-servers')
959 conf.set_quoted('DNS_SERVERS', dns_servers)
961 ntp_servers = get_option('ntp-servers')
962 conf.set_quoted('NTP_SERVERS', ntp_servers)
964 default_locale = get_option('default-locale')
965 conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale)
967 nspawn_locale = get_option('nspawn-locale')
968 conf.set_quoted('SYSTEMD_NSPAWN_LOCALE', nspawn_locale)
970 localegen_path = get_option('localegen-path')
971 if localegen_path != ''
972 conf.set_quoted('LOCALEGEN_PATH', localegen_path)
974 conf.set10('HAVE_LOCALEGEN', localegen_path != '')
976 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
978 service_watchdog = get_option('service-watchdog')
979 watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
980 conf.set_quoted('SERVICE_WATCHDOG', watchdog_value)
982 conf.set_quoted('SUSHELL', get_option('debug-shell'))
983 conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
985 enable_debug_hashmap = false
986 enable_debug_mmap_cache = false
987 enable_debug_siphash = false
988 foreach name : get_option('debug-extra')
990 enable_debug_hashmap = true
991 elif name == 'mmap-cache'
992 enable_debug_mmap_cache = true
993 elif name == 'siphash'
994 enable_debug_siphash = true
996 message('unknown debug option "@0@", ignoring'.format(name))
999 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
1000 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
1001 conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash)
1003 conf.set10('VALGRIND', get_option('valgrind'))
1004 conf.set10('LOG_TRACE', get_option('log-trace'))
1006 default_user_path = get_option('user-path')
1007 if default_user_path != ''
1008 conf.set_quoted('DEFAULT_USER_PATH', default_user_path)
1012 #####################################################################
1014 threads = dependency('threads')
1015 librt = cc.find_library('rt')
1016 libm = cc.find_library('m')
1017 libdl = cc.find_library('dl')
1018 libcrypt = cc.find_library('crypt')
1020 crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
1022 ['crypt_ra', crypt_header],
1023 ['crypt_preferred_method', crypt_header],
1024 ['crypt_gensalt_ra', crypt_header]]
1026 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
1027 dependencies : libcrypt)
1028 conf.set10('HAVE_' + ident[0].to_upper(), have)
1031 libcap = dependency('libcap', required : false)
1032 if not libcap.found()
1033 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
1034 libcap = cc.find_library('cap')
1037 want_bpf_framework = get_option('bpf-framework')
1038 bpf_framework_required = want_bpf_framework == 'true'
1040 libbpf = dependency('libbpf', required : bpf_framework_required, version : '>= 0.2')
1041 conf.set10('HAVE_LIBBPF', libbpf.found())
1043 if want_bpf_framework == 'false' or not libbpf.found() or skip_deps
1044 conf.set10('BPF_FRAMEWORK', false)
1046 bpf_compiler = get_option('bpf-compiler')
1048 clang_supports_bpf = false
1049 bpf_gcc_found = false
1052 if bpf_compiler == 'clang'
1053 # Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu
1054 # (like clang-10/llvm-strip-10)
1055 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')
1056 r = find_program('clang', required : bpf_framework_required, version : '>= 10.0.0')
1057 clang_found = r.found()
1061 # Assume that the required flags are supported by the found clang.
1062 clang_supports_flags = clang_found
1065 clang = cc.cmd_array()
1066 clang_supports_flags = cc.has_argument('-Wno-compare-distinct-pointer-types')
1070 # Check if 'clang -target bpf' is supported.
1071 clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0
1073 elif bpf_compiler == 'gcc'
1074 warning('GCC BPF Compiler support is experimental and not recommended.')
1075 bpf_gcc = find_program('bpf-gcc',
1077 version : '>= 12.1.0')
1078 bpf_gcc_found = bpf_gcc.found()
1081 if clang_supports_bpf or bpf_gcc_found
1082 # Debian installs this in /usr/sbin/ which is not in $PATH.
1083 # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian.
1084 # We use 'bpftool gen object' subcommand for bpftool strip, it was added by d80b2fcbe0a023619e0fc73112f2a02c2662f6ab (v5.13).
1085 bpftool = find_program('bpftool',
1086 '/usr/sbin/bpftool',
1088 version : '>= 5.13.0')
1091 bpftool_strip = true
1094 bpftool_strip = false
1095 # We require the 'bpftool gen skeleton' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6).
1096 bpftool = find_program('bpftool',
1097 '/usr/sbin/bpftool',
1098 required : bpf_framework_required,
1099 version : '>= 5.6.0')
1102 # We use `llvm-strip` as a fallback if `bpftool gen object` strip support is not available.
1103 if not bpftool_strip and bpftool.found() and clang_supports_bpf
1104 if not meson.is_cross_build()
1105 llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip',
1106 check : true).stdout().strip()
1108 llvm_strip_bin = 'llvm-strip'
1110 llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0')
1111 deps_found = llvm_strip.found()
1115 # Can build BPF program from source code in restricted C
1116 conf.set10('BPF_FRAMEWORK', deps_found)
1119 libmount = dependency('mount',
1120 version : fuzzer_build ? '>= 0' : '>= 2.30')
1122 want_libfdisk = get_option('fdisk')
1123 if want_libfdisk != 'false' and not skip_deps
1124 libfdisk = dependency('fdisk',
1125 version : '>= 2.32',
1126 required : want_libfdisk == 'true')
1127 have = libfdisk.found()
1132 conf.set10('HAVE_LIBFDISK', have)
1134 want_pwquality = get_option('pwquality')
1135 if want_pwquality != 'false' and not skip_deps
1136 libpwquality = dependency('pwquality', required : want_pwquality == 'true')
1137 have = libpwquality.found()
1142 conf.set10('HAVE_PWQUALITY', have)
1144 want_seccomp = get_option('seccomp')
1145 if want_seccomp != 'false' and not skip_deps
1146 libseccomp = dependency('libseccomp',
1147 version : '>= 2.3.1',
1148 required : want_seccomp == 'true')
1149 have = libseccomp.found()
1154 conf.set10('HAVE_SECCOMP', have)
1156 want_selinux = get_option('selinux')
1157 if want_selinux != 'false' and not skip_deps
1158 libselinux = dependency('libselinux',
1159 version : '>= 2.1.9',
1160 required : want_selinux == 'true')
1161 have = libselinux.found()
1166 conf.set10('HAVE_SELINUX', have)
1168 want_apparmor = get_option('apparmor')
1169 if want_apparmor != 'false' and not skip_deps
1170 libapparmor = dependency('libapparmor',
1171 version : '>= 2.13',
1172 required : want_apparmor == 'true')
1173 have = libapparmor.found()
1178 conf.set10('HAVE_APPARMOR', have)
1180 have = get_option('smack') and get_option('smack-run-label') != ''
1181 conf.set10('HAVE_SMACK_RUN_LABEL', have)
1183 conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
1186 have = get_option('smack') and get_option('smack-default-process-label') != ''
1188 conf.set_quoted('SMACK_DEFAULT_PROCESS_LABEL', get_option('smack-default-process-label'))
1191 want_polkit = get_option('polkit')
1192 install_polkit = false
1193 install_polkit_pkla = false
1194 if want_polkit != 'false' and not skip_deps
1195 install_polkit = true
1197 libpolkit = dependency('polkit-gobject-1',
1199 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
1200 message('Old polkit detected, will install pkla files')
1201 install_polkit_pkla = true
1204 conf.set10('ENABLE_POLKIT', install_polkit)
1206 want_acl = get_option('acl')
1207 if want_acl != 'false' and not skip_deps
1208 libacl = cc.find_library('acl', required : want_acl == 'true')
1209 have = libacl.found()
1214 conf.set10('HAVE_ACL', have)
1216 want_audit = get_option('audit')
1217 if want_audit != 'false' and not skip_deps
1218 libaudit = dependency('audit', required : want_audit == 'true')
1219 have = libaudit.found()
1224 conf.set10('HAVE_AUDIT', have)
1226 want_blkid = get_option('blkid')
1227 if want_blkid != 'false' and not skip_deps
1228 libblkid = dependency('blkid', required : want_blkid == 'true')
1229 have = libblkid.found()
1231 conf.set10('HAVE_BLKID_PROBE_SET_HINT',
1232 have and cc.has_function('blkid_probe_set_hint', dependencies : libblkid))
1237 conf.set10('HAVE_BLKID', have)
1239 want_kmod = get_option('kmod')
1240 if want_kmod != 'false' and not skip_deps
1241 libkmod = dependency('libkmod',
1243 required : want_kmod == 'true')
1244 have = libkmod.found()
1249 conf.set10('HAVE_KMOD', have)
1251 want_pam = get_option('pam')
1252 if want_pam != 'false' and not skip_deps
1253 libpam = cc.find_library('pam', required : want_pam == 'true')
1254 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1255 have = libpam.found() and libpam_misc.found()
1261 conf.set10('HAVE_PAM', have)
1263 want_microhttpd = get_option('microhttpd')
1264 if want_microhttpd != 'false' and not skip_deps
1265 libmicrohttpd = dependency('libmicrohttpd',
1266 version : '>= 0.9.33',
1267 required : want_microhttpd == 'true')
1268 have = libmicrohttpd.found()
1273 conf.set10('HAVE_MICROHTTPD', have)
1275 want_libcryptsetup = get_option('libcryptsetup')
1276 want_libcryptsetup_plugins = get_option('libcryptsetup-plugins')
1278 if want_libcryptsetup_plugins == 'true' and want_libcryptsetup == 'false'
1279 error('libcryptsetup-plugins can not be requested without libcryptsetup')
1282 if want_libcryptsetup != 'false' and not skip_deps
1283 libcryptsetup = dependency('libcryptsetup',
1284 version : want_libcryptsetup_plugins == 'true' ? '>= 2.4.0' : '>= 2.0.1',
1285 required : want_libcryptsetup == 'true' or want_libcryptsetup_plugins == 'true')
1286 have = libcryptsetup.found()
1288 foreach ident : ['crypt_set_metadata_size',
1289 'crypt_activate_by_signed_key',
1291 have_ident = have and cc.has_function(
1293 prefix : '#include <libcryptsetup.h>',
1294 dependencies : libcryptsetup)
1295 conf.set10('HAVE_' + ident.to_upper(), have_ident)
1301 conf.set10('HAVE_LIBCRYPTSETUP', have)
1303 if want_libcryptsetup_plugins != 'false' and not skip_deps
1304 have = (cc.has_function(
1305 'crypt_activate_by_token_pin',
1306 prefix : '#include <libcryptsetup.h>',
1307 dependencies : libcryptsetup) and
1309 'crypt_token_external_path',
1310 prefix : '#include <libcryptsetup.h>',
1311 dependencies : libcryptsetup))
1315 conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have)
1317 want_libcurl = get_option('libcurl')
1318 if want_libcurl != 'false' and not skip_deps
1319 libcurl = dependency('libcurl',
1320 version : '>= 7.32.0',
1321 required : want_libcurl == 'true')
1322 have = libcurl.found()
1327 conf.set10('HAVE_LIBCURL', have)
1328 conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
1330 want_libidn = get_option('libidn')
1331 want_libidn2 = get_option('libidn2')
1332 if want_libidn == 'true' and want_libidn2 == 'true'
1333 error('libidn and libidn2 cannot be requested simultaneously')
1336 if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps
1337 libidn = dependency('libidn2',
1338 required : want_libidn2 == 'true')
1339 have = libidn.found()
1344 conf.set10('HAVE_LIBIDN2', have)
1345 if not have and want_libidn != 'false' and not skip_deps
1346 # libidn is used for both libidn and libidn2 objects
1347 libidn = dependency('libidn',
1348 required : want_libidn == 'true')
1349 have = libidn.found()
1353 conf.set10('HAVE_LIBIDN', have)
1355 want_libiptc = get_option('libiptc')
1356 if want_libiptc != 'false' and not skip_deps
1357 libiptc = dependency('libiptc',
1358 required : want_libiptc == 'true')
1359 have = libiptc.found()
1364 conf.set10('HAVE_LIBIPTC', have)
1366 want_qrencode = get_option('qrencode')
1367 if want_qrencode != 'false' and not skip_deps
1368 libqrencode = dependency('libqrencode',
1370 required : want_qrencode == 'true')
1371 have = libqrencode.found()
1376 conf.set10('HAVE_QRENCODE', have)
1378 want_gcrypt = get_option('gcrypt')
1379 if want_gcrypt != 'false' and not skip_deps
1380 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1381 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1382 have = libgcrypt.found() and libgpg_error.found()
1387 # link to neither of the libs if one is not found
1391 conf.set10('HAVE_GCRYPT', have)
1393 want_gnutls = get_option('gnutls')
1394 if want_gnutls != 'false' and not skip_deps
1395 libgnutls = dependency('gnutls',
1396 version : '>= 3.1.4',
1397 required : want_gnutls == 'true')
1398 have = libgnutls.found()
1403 conf.set10('HAVE_GNUTLS', have)
1405 want_openssl = get_option('openssl')
1406 if want_openssl != 'false' and not skip_deps
1407 libopenssl = dependency('openssl',
1408 version : '>= 1.1.0',
1409 required : want_openssl == 'true')
1410 have = libopenssl.found()
1415 conf.set10('HAVE_OPENSSL', have)
1417 want_p11kit = get_option('p11kit')
1418 if want_p11kit != 'false' and not skip_deps
1419 libp11kit = dependency('p11-kit-1',
1420 version : '>= 0.23.3',
1421 required : want_p11kit == 'true')
1422 have = libp11kit.found()
1427 conf.set10('HAVE_P11KIT', have)
1429 want_libfido2 = get_option('libfido2')
1430 if want_libfido2 != 'false' and not skip_deps
1431 libfido2 = dependency('libfido2',
1432 required : want_libfido2 == 'true')
1433 have = libfido2.found()
1438 conf.set10('HAVE_LIBFIDO2', have)
1440 want_tpm2 = get_option('tpm2')
1441 if want_tpm2 != 'false' and not skip_deps
1442 tpm2 = dependency('tss2-esys tss2-rc tss2-mu',
1443 required : want_tpm2 == 'true')
1449 conf.set10('HAVE_TPM2', have)
1451 want_elfutils = get_option('elfutils')
1452 if want_elfutils != 'false' and not skip_deps
1453 libdw = dependency('libdw',
1454 required : want_elfutils == 'true')
1455 have = libdw.found()
1457 # New in elfutils 0.177
1458 conf.set10('HAVE_DWELF_ELF_E_MACHINE_STRING',
1459 have and cc.has_function('dwelf_elf_e_machine_string', dependencies : libdw))
1464 conf.set10('HAVE_ELFUTILS', have)
1466 want_zlib = get_option('zlib')
1467 if want_zlib != 'false' and not skip_deps
1468 libz = dependency('zlib',
1469 required : want_zlib == 'true')
1475 conf.set10('HAVE_ZLIB', have)
1477 want_bzip2 = get_option('bzip2')
1478 if want_bzip2 != 'false' and not skip_deps
1479 libbzip2 = cc.find_library('bz2',
1480 required : want_bzip2 == 'true')
1481 have = libbzip2.found()
1486 conf.set10('HAVE_BZIP2', have)
1488 want_xz = get_option('xz')
1489 if want_xz != 'false' and not skip_deps
1490 libxz = dependency('liblzma',
1491 required : want_xz == 'true')
1492 have_xz = libxz.found()
1497 conf.set10('HAVE_XZ', have_xz)
1499 want_lz4 = get_option('lz4')
1500 if want_lz4 != 'false' and not skip_deps
1501 liblz4 = dependency('liblz4',
1502 version : '>= 1.3.0',
1503 required : want_lz4 == 'true')
1504 have_lz4 = liblz4.found()
1509 conf.set10('HAVE_LZ4', have_lz4)
1511 want_zstd = get_option('zstd')
1512 if want_zstd != 'false' and not skip_deps
1513 libzstd = dependency('libzstd',
1514 required : want_zstd == 'true',
1515 version : '>= 1.4.0')
1516 have_zstd = libzstd.found()
1521 conf.set10('HAVE_ZSTD', have_zstd)
1523 conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
1525 compression = get_option('default-compression')
1526 if compression == 'auto'
1528 compression = 'zstd'
1534 compression = 'none'
1536 elif compression == 'zstd' and not have_zstd
1537 error('default-compression=zstd requires zstd')
1538 elif compression == 'lz4' and not have_lz4
1539 error('default-compression=lz4 requires lz4')
1540 elif compression == 'xz' and not have_xz
1541 error('default-compression=xz requires xz')
1543 conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper()))
1545 want_xkbcommon = get_option('xkbcommon')
1546 if want_xkbcommon != 'false' and not skip_deps
1547 libxkbcommon = dependency('xkbcommon',
1548 version : '>= 0.3.0',
1549 required : want_xkbcommon == 'true')
1550 have = libxkbcommon.found()
1555 conf.set10('HAVE_XKBCOMMON', have)
1557 want_pcre2 = get_option('pcre2')
1558 if want_pcre2 != 'false' and not skip_deps
1559 libpcre2 = dependency('libpcre2-8',
1560 required : want_pcre2 == 'true')
1561 have = libpcre2.found()
1566 conf.set10('HAVE_PCRE2', have)
1568 want_glib = get_option('glib')
1569 if want_glib != 'false' and not skip_deps
1570 libglib = dependency('glib-2.0',
1571 version : '>= 2.22.0',
1572 required : want_glib == 'true')
1573 libgobject = dependency('gobject-2.0',
1574 version : '>= 2.22.0',
1575 required : want_glib == 'true')
1576 libgio = dependency('gio-2.0',
1577 required : want_glib == 'true')
1578 have = libglib.found() and libgobject.found() and libgio.found()
1585 conf.set10('HAVE_GLIB', have)
1587 want_dbus = get_option('dbus')
1588 if want_dbus != 'false' and not skip_deps
1589 libdbus = dependency('dbus-1',
1590 version : '>= 1.3.2',
1591 required : want_dbus == 'true')
1592 have = libdbus.found()
1597 conf.set10('HAVE_DBUS', have)
1599 dbusdatadir = datadir / 'dbus-1'
1600 if conf.get('HAVE_DBUS') == 1
1601 dbusdatadir = libdbus.get_variable(pkgconfig: 'datadir', default_value: datadir) / 'dbus-1'
1604 dbuspolicydir = get_option('dbuspolicydir')
1605 if dbuspolicydir == ''
1606 dbuspolicydir = dbusdatadir / 'system.d'
1609 dbussessionservicedir = get_option('dbussessionservicedir')
1610 if dbussessionservicedir == ''
1611 dbussessionservicedir = dbusdatadir / 'services'
1612 if conf.get('HAVE_DBUS') == 1
1613 dbussessionservicedir = libdbus.get_variable(pkgconfig: 'session_bus_services_dir', default_value: dbussessionservicedir)
1617 dbussystemservicedir = get_option('dbussystemservicedir')
1618 if dbussystemservicedir == ''
1619 dbussystemservicedir = dbusdatadir / 'system-services'
1620 if conf.get('HAVE_DBUS') == 1
1621 dbussystemservicedir = libdbus.get_variable(pkgconfig: 'system_bus_services_dir', default_value: dbussystemservicedir)
1625 dbus_interfaces_dir = get_option('dbus-interfaces-dir')
1626 if dbus_interfaces_dir == '' or dbus_interfaces_dir == 'yes'
1627 if meson.is_cross_build() and dbus_interfaces_dir != 'yes'
1628 dbus_interfaces_dir = 'no'
1629 warning('Exporting D-Bus interface XML files is disabled during cross build. Pass path or "yes" to force enable.')
1631 dbus_interfaces_dir = dbusdatadir / 'interfaces'
1632 if conf.get('HAVE_DBUS') == 1
1633 dbus_interfaces_dir = libdbus.get_variable(pkgconfig: 'interfaces_dir', default_value: dbus_interfaces_dir)
1638 # We support one or the other. If gcrypt is available, we assume it's there to
1639 # be used, and use it in preference.
1640 opt = get_option('cryptolib')
1641 if opt == 'openssl' and conf.get('HAVE_OPENSSL') == 0
1642 error('openssl requested as the default cryptolib, but not available')
1644 conf.set10('PREFER_OPENSSL',
1645 opt == 'openssl' or (opt == 'auto' and conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_GCRYPT') == 0))
1646 conf.set10('HAVE_OPENSSL_OR_GCRYPT',
1647 conf.get('HAVE_OPENSSL') == 1 or conf.get('HAVE_GCRYPT') == 1)
1648 lib_openssl_or_gcrypt = conf.get('PREFER_OPENSSL') == 1 ? [libopenssl] : [libgcrypt, libgpg_error]
1650 dns_over_tls = get_option('dns-over-tls')
1651 if dns_over_tls != 'false'
1652 if dns_over_tls == 'gnutls' and conf.get('PREFER_OPENSSL') == 1
1653 error('Sorry, -Ddns-over-tls=gnutls is not supported when openssl is used as the cryptolib')
1656 if dns_over_tls == 'gnutls'
1657 have_openssl = false
1659 have_openssl = conf.get('HAVE_OPENSSL') == 1
1660 if dns_over_tls == 'openssl' and not have_openssl
1661 error('DNS-over-TLS support was requested with openssl, but dependencies are not available')
1664 if dns_over_tls == 'openssl' or have_openssl
1667 have_gnutls = conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0')
1668 if dns_over_tls != 'auto' and not have_gnutls
1669 str = dns_over_tls == 'gnutls' ? ' with gnutls' : ''
1670 error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
1673 have = have_gnutls or have_openssl
1677 have_openssl = false
1679 conf.set10('ENABLE_DNS_OVER_TLS', have)
1680 conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1681 conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
1683 default_dns_over_tls = get_option('default-dns-over-tls')
1685 default_dns_over_tls = 'no'
1687 if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
1688 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.')
1689 default_dns_over_tls = 'no'
1691 conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1692 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
1693 conf.set_quoted('DEFAULT_DNS_OVER_TLS_MODE_STR', default_dns_over_tls)
1695 default_mdns = get_option('default-mdns')
1696 conf.set('DEFAULT_MDNS_MODE',
1697 'RESOLVE_SUPPORT_' + default_mdns.to_upper())
1698 conf.set_quoted('DEFAULT_MDNS_MODE_STR', default_mdns)
1700 default_llmnr = get_option('default-llmnr')
1701 conf.set('DEFAULT_LLMNR_MODE',
1702 'RESOLVE_SUPPORT_' + default_llmnr.to_upper())
1703 conf.set_quoted('DEFAULT_LLMNR_MODE_STR', default_llmnr)
1705 want_repart = get_option('repart')
1706 if want_repart != 'false'
1707 have = conf.get('HAVE_LIBFDISK') == 1
1708 if want_repart == 'true' and not have
1709 error('repart support was requested, but dependencies are not available')
1714 conf.set10('ENABLE_REPART', have)
1716 default_dnssec = get_option('default-dnssec')
1718 default_dnssec = 'no'
1720 if default_dnssec != 'no' and conf.get('HAVE_OPENSSL_OR_GCRYPT') == 0
1721 message('default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.')
1722 default_dnssec = 'no'
1724 conf.set('DEFAULT_DNSSEC_MODE',
1725 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1726 conf.set_quoted('DEFAULT_DNSSEC_MODE_STR', default_dnssec)
1728 want_sysupdate = get_option('sysupdate')
1729 if want_sysupdate != 'false'
1730 have = (conf.get('HAVE_OPENSSL') == 1 and
1731 conf.get('HAVE_LIBFDISK') == 1)
1732 if want_sysupdate == 'true' and not have
1733 error('sysupdate support was requested, but dependencies are not available')
1738 conf.set10('ENABLE_SYSUPDATE', have)
1740 want_importd = get_option('importd')
1741 if want_importd != 'false'
1742 have = (conf.get('HAVE_LIBCURL') == 1 and
1743 conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and
1744 conf.get('HAVE_ZLIB') == 1 and
1745 conf.get('HAVE_XZ') == 1)
1746 if want_importd == 'true' and not have
1747 error('importd support was requested, but dependencies are not available')
1752 conf.set10('ENABLE_IMPORTD', have)
1754 want_kernel_install = get_option('kernel-install')
1755 conf.set10('ENABLE_KERNEL_INSTALL', want_kernel_install)
1757 want_homed = get_option('homed')
1758 if want_homed != 'false'
1759 have = (conf.get('HAVE_OPENSSL') == 1 and
1760 conf.get('HAVE_LIBFDISK') == 1 and
1761 conf.get('HAVE_LIBCRYPTSETUP') == 1)
1762 if want_homed == 'true' and not have
1763 error('homed support was requested, but dependencies are not available')
1768 conf.set10('ENABLE_HOMED', have)
1770 have = have and conf.get('HAVE_PAM') == 1
1771 conf.set10('ENABLE_PAM_HOME', have)
1773 have = get_option('oomd')
1774 conf.set10('ENABLE_OOMD', have)
1776 want_remote = get_option('remote')
1777 if want_remote != 'false'
1778 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1779 conf.get('HAVE_LIBCURL') == 1]
1780 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1781 # it's possible to build one without the other. Complain only if
1782 # support was explicitly requested. The auxiliary files like sysusers
1783 # config should be installed when any of the programs are built.
1784 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1785 error('remote support was requested, but dependencies are not available')
1787 have = have_deps[0] or have_deps[1]
1791 conf.set10('ENABLE_REMOTE', have)
1793 foreach term : ['analyze',
1807 'compat-mutable-uid-boundaries',
1833 have = get_option(term)
1834 name = 'ENABLE_' + term.underscorify().to_upper()
1835 conf.set10(name, have)
1838 enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
1840 foreach tuple : [['nss-mymachines', 'machined'],
1841 ['nss-resolve', 'resolve']]
1842 want = get_option(tuple[0])
1844 have = get_option(tuple[1])
1845 if want == 'true' and not have
1846 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1851 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1852 conf.set10(name, have)
1856 foreach term : ['ENABLE_NSS_MYHOSTNAME',
1857 'ENABLE_NSS_MYMACHINES',
1858 'ENABLE_NSS_RESOLVE',
1859 'ENABLE_NSS_SYSTEMD']
1860 if conf.get(term) == 1
1864 conf.set10('ENABLE_NSS', enable_nss)
1866 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1868 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1870 ############################################################
1876 ############################################################
1878 # Include these now as they provide gnu-efi detection.
1879 subdir('src/fundamental')
1880 subdir('src/boot/efi')
1882 ############################################################
1884 generate_gperfs = find_program('tools/generate-gperfs.py')
1885 make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
1886 make_directive_index_py = find_program('tools/make-directive-index.py')
1887 make_man_index_py = find_program('tools/make-man-index.py')
1888 meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
1889 update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
1890 update_man_rules_py = find_program('tools/update-man-rules.py')
1891 update_hwdb_sh = find_program('tools/update-hwdb.sh')
1892 update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
1893 update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
1894 xml_helper_py = find_program('tools/xml_helper.py')
1895 export_dbus_interfaces_py = find_program('tools/dbus_exporter.py')
1897 ############################################################
1899 if get_option('b_coverage')
1900 add_project_arguments('-include', 'src/basic/coverage.h', language : 'c')
1903 ############################################################
1905 config_h = configure_file(
1906 output : 'config.h',
1907 configuration : conf)
1909 add_project_arguments('-include', 'config.h', language : 'c')
1911 jinja2_cmdline = [meson_render_jinja2, config_h, version_h]
1913 ############################################################
1915 # binaries that have --help and are intended for use by humans,
1916 # usually, but not always, installed in /bin.
1917 public_programs = []
1919 # D-Bus introspection XML export
1922 basic_includes = include_directories(
1928 libsystemd_includes = [basic_includes, include_directories(
1929 'src/libsystemd/sd-bus',
1930 'src/libsystemd/sd-device',
1931 'src/libsystemd/sd-event',
1932 'src/libsystemd/sd-hwdb',
1933 'src/libsystemd/sd-id128',
1934 'src/libsystemd/sd-journal',
1935 'src/libsystemd/sd-netlink',
1936 'src/libsystemd/sd-network',
1937 'src/libsystemd/sd-resolve')]
1939 includes = [libsystemd_includes, include_directories('src/shared')]
1944 subdir('src/libsystemd')
1945 subdir('src/shared')
1947 subdir('src/libudev')
1948 subdir('src/cryptsetup/cryptsetup-tokens')
1950 alias_target('devel', libsystemd_pc, libudev_pc)
1952 libsystemd = shared_library(
1954 version : libsystemd_version,
1955 include_directories : libsystemd_includes,
1956 link_args : ['-shared',
1957 '-Wl,--version-script=' + libsystemd_sym_path],
1958 link_with : [libbasic,
1961 link_whole : [libsystemd_static],
1962 dependencies : [threads,
1964 link_depends : libsystemd_sym,
1966 install_tag: 'libsystemd',
1967 install_dir : rootlibdir)
1969 alias_target('libsystemd', libsystemd)
1971 install_libsystemd_static = static_library(
1975 basic_gcrypt_sources,
1976 basic_compress_sources,
1977 fundamental_sources,
1978 include_directories : libsystemd_includes,
1979 build_by_default : static_libsystemd != 'false',
1980 install : static_libsystemd != 'false',
1981 install_tag: 'libsystemd',
1982 install_dir : rootlibdir,
1983 pic : static_libsystemd_pic,
1984 dependencies : [threads,
1995 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
1997 libudev = shared_library(
1999 version : libudev_version,
2000 include_directories : includes,
2001 link_args : ['-shared',
2002 '-Wl,--version-script=' + libudev_sym_path],
2003 link_with : [libsystemd_static, libshared_static],
2004 link_whole : libudev_basic,
2005 dependencies : [threads],
2006 link_depends : libudev_sym,
2008 install_tag: 'libudev',
2009 install_dir : rootlibdir)
2011 alias_target('libudev', libudev)
2013 install_libudev_static = static_library(
2016 fundamental_sources,
2020 include_directories : includes,
2021 build_by_default : static_libudev != 'false',
2022 install : static_libudev != 'false',
2023 install_tag: 'libudev',
2024 install_dir : rootlibdir,
2025 link_depends : libudev_sym,
2026 dependencies : libshared_deps + [libmount],
2027 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
2028 pic : static_libudev_pic)
2030 if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
2031 if conf.get('HAVE_TPM2') == 1
2032 cryptsetup_token_systemd_tpm2 = shared_library(
2033 'cryptsetup-token-systemd-tpm2',
2034 cryptsetup_token_systemd_tpm2_sources,
2035 include_directories : includes,
2036 link_args : ['-shared',
2037 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2038 link_with : [lib_cryptsetup_token_common,
2040 dependencies : [libcryptsetup,
2043 link_depends : cryptsetup_token_sym,
2044 install_rpath : rootpkglibdir,
2046 install_dir : libcryptsetup_plugins_dir)
2049 if conf.get('HAVE_LIBFIDO2') == 1
2050 cryptsetup_token_systemd_fido2 = shared_library(
2051 'cryptsetup-token-systemd-fido2',
2052 cryptsetup_token_systemd_fido2_sources,
2053 include_directories : includes,
2054 link_args : ['-shared',
2055 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2056 link_with : [lib_cryptsetup_token_common,
2058 dependencies : [libcryptsetup,
2061 link_depends : cryptsetup_token_sym,
2062 install_rpath : rootpkglibdir,
2064 install_dir : libcryptsetup_plugins_dir)
2067 if conf.get('HAVE_P11KIT') == 1
2068 cryptsetup_token_systemd_pkcs11 = shared_library(
2069 'cryptsetup-token-systemd-pkcs11',
2070 cryptsetup_token_systemd_pkcs11_sources,
2071 include_directories : includes,
2072 link_args : ['-shared',
2073 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2074 link_with : [lib_cryptsetup_token_common,
2076 dependencies : [libcryptsetup,
2079 link_depends : cryptsetup_token_sym,
2080 install_rpath : rootpkglibdir,
2082 install_dir : libcryptsetup_plugins_dir)
2086 ############################################################
2088 # systemd-analyze requires 'libcore'
2090 # systemd-journal-remote requires 'libjournal_core'
2091 subdir('src/journal')
2092 # systemd-networkd requires 'libsystemd_network'
2093 subdir('src/libsystemd-network')
2095 subdir('src/analyze')
2096 subdir('src/busctl')
2097 subdir('src/coredump')
2098 subdir('src/cryptenroll')
2099 subdir('src/cryptsetup')
2101 subdir('src/hostname')
2102 subdir('src/import')
2103 subdir('src/journal-remote')
2104 subdir('src/kernel-install')
2105 subdir('src/locale')
2107 subdir('src/machine')
2108 subdir('src/network')
2109 subdir('src/nspawn')
2111 subdir('src/partition')
2112 subdir('src/portable')
2113 subdir('src/pstore')
2114 subdir('src/resolve')
2116 subdir('src/shutdown')
2117 subdir('src/sysext')
2118 subdir('src/systemctl')
2119 subdir('src/sysupdate')
2120 subdir('src/timedate')
2121 subdir('src/timesync')
2122 subdir('src/tmpfiles')
2123 subdir('src/userdb')
2124 subdir('src/xdg-autostart-generator')
2126 subdir('src/systemd')
2133 ############################################################
2135 # only static linking apart from libdl, to make sure that the
2136 # module is linked to all libraries that it uses.
2137 test_dlopen = executable(
2140 include_directories : includes,
2141 link_with : [libbasic],
2142 dependencies : [libdl],
2143 build_by_default : want_tests != 'false')
2145 foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
2146 ['systemd', 'ENABLE_NSS_SYSTEMD', ['nss-systemd.h', 'userdb-glue.c', 'userdb-glue.h']],
2147 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
2148 ['resolve', 'ENABLE_NSS_RESOLVE', [], resolve_includes]]
2150 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
2154 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
2155 version_script_arg = project_source_root / sym
2157 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
2158 if tuple.length() > 2
2159 foreach s : tuple[2]
2160 sources += ['src/nss-@0@/@1@'.format(module, s)]
2164 incs = tuple.length() > 3 ? tuple[3] : includes
2166 nss = shared_library(
2170 include_directories : incs,
2171 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
2172 link_args : ['-Wl,-z,nodelete',
2174 '-Wl,--version-script=' + version_script_arg],
2175 link_with : [libsystemd_static,
2178 dependencies : [threads,
2182 install_tag : 'nss',
2183 install_dir : rootlibdir)
2185 # We cannot use shared_module because it does not support version suffix.
2186 # Unfortunately shared_library insists on creating the symlink…
2187 meson.add_install_script('sh', '-c',
2188 'rm $DESTDIR@0@/libnss_@1@.so'
2189 .format(rootlibdir, module),
2193 if want_tests != 'false'
2194 test('dlopen-nss_' + module,
2196 # path to dlopen must include a slash
2197 args : nss.full_path(),
2203 ############################################################
2208 include_directories : includes,
2209 link_with : [libcore,
2211 dependencies : [versiondep,
2213 install_rpath : rootpkglibdir,
2215 install_dir : rootlibexecdir)
2216 dbus_programs += exe
2217 public_programs += exe
2219 meson.add_install_script(meson_make_symlink,
2220 rootlibexecdir / 'systemd',
2221 rootsbindir / 'init')
2225 systemd_analyze_sources,
2226 include_directories : core_includes,
2227 link_with : [libcore,
2229 dependencies : [versiondep,
2231 install_rpath : rootpkglibdir,
2232 install : conf.get('ENABLE_ANALYZE') == 1)
2233 public_programs += exe
2235 if want_tests != 'false'
2236 test('test-compare-versions',
2237 test_compare_versions_sh,
2238 args : exe.full_path())
2243 systemd_journald_sources,
2244 include_directories : includes,
2245 link_with : [libjournal_core,
2247 dependencies : [threads,
2252 install_rpath : rootpkglibdir,
2254 install_dir : rootlibexecdir)
2256 public_programs += executable(
2258 systemd_cat_sources,
2259 include_directories : includes,
2260 link_with : [libjournal_core,
2262 dependencies : [threads],
2263 install_rpath : rootpkglibdir,
2266 if get_option('link-journalctl-shared')
2267 journalctl_link_with = [libshared]
2269 journalctl_link_with = [libsystemd_static,
2274 public_programs += executable(
2277 include_directories : includes,
2278 link_with : [journalctl_link_with],
2279 dependencies : [threads,
2285 install_rpath : rootpkglibdir,
2287 install_dir : rootbindir)
2290 'systemd-getty-generator',
2291 'src/getty-generator/getty-generator.c',
2292 include_directories : includes,
2293 link_with : [libshared],
2294 install_rpath : rootpkglibdir,
2296 install_dir : systemgeneratordir)
2299 'systemd-debug-generator',
2300 'src/debug-generator/debug-generator.c',
2301 include_directories : includes,
2302 link_with : [libshared],
2303 install_rpath : rootpkglibdir,
2305 install_dir : systemgeneratordir)
2308 'systemd-run-generator',
2309 'src/run-generator/run-generator.c',
2310 include_directories : includes,
2311 link_with : [libshared],
2312 install_rpath : rootpkglibdir,
2314 install_dir : systemgeneratordir)
2317 'systemd-fstab-generator',
2318 'src/fstab-generator/fstab-generator.c',
2319 include_directories : includes,
2320 link_with : [libshared],
2321 install_rpath : rootpkglibdir,
2323 install_dir : systemgeneratordir)
2325 if want_tests != 'false'
2326 test('test-fstab-generator',
2327 test_fstab_generator_sh,
2328 # https://github.com/mesonbuild/meson/issues/2681
2329 args : exe.full_path(),
2333 if conf.get('ENABLE_ENVIRONMENT_D') == 1
2335 '30-systemd-environment-d-generator',
2336 'src/environment-d-generator/environment-d-generator.c',
2337 include_directories : includes,
2338 link_with : [libshared],
2339 install_rpath : rootpkglibdir,
2341 install_dir : userenvgeneratordir)
2343 meson.add_install_script(meson_make_symlink,
2344 sysconfdir / 'environment',
2345 environmentdir / '99-environment.conf')
2348 if conf.get('ENABLE_HIBERNATE') == 1
2350 'systemd-hibernate-resume-generator',
2351 'src/hibernate-resume/hibernate-resume-generator.c',
2352 include_directories : includes,
2353 link_with : [libshared],
2354 install_rpath : rootpkglibdir,
2356 install_dir : systemgeneratordir)
2359 'systemd-hibernate-resume',
2360 'src/hibernate-resume/hibernate-resume.c',
2361 include_directories : includes,
2362 link_with : [libshared],
2363 install_rpath : rootpkglibdir,
2365 install_dir : rootlibexecdir)
2368 if conf.get('HAVE_BLKID') == 1
2370 'systemd-gpt-auto-generator',
2371 'src/gpt-auto-generator/gpt-auto-generator.c',
2372 include_directories : includes,
2373 link_with : [libshared],
2374 dependencies : libblkid,
2375 install_rpath : rootpkglibdir,
2377 install_dir : systemgeneratordir)
2379 public_programs += executable(
2381 'src/dissect/dissect.c',
2382 include_directories : includes,
2383 link_with : [libshared],
2384 install_rpath : rootpkglibdir,
2388 if conf.get('ENABLE_RESOLVE') == 1
2389 dbus_programs += executable(
2391 systemd_resolved_sources,
2392 include_directories : resolve_includes,
2393 link_with : [libshared,
2395 libsystemd_resolve_core],
2396 dependencies : systemd_resolved_dependencies,
2397 install_rpath : rootpkglibdir,
2399 install_dir : rootlibexecdir)
2401 public_programs += executable(
2404 include_directories : includes,
2405 link_with : [libshared,
2407 libsystemd_resolve_core],
2408 dependencies : [threads,
2409 lib_openssl_or_gcrypt,
2412 install_rpath : rootpkglibdir,
2415 meson.add_install_script(meson_make_symlink,
2416 bindir / 'resolvectl',
2417 rootsbindir / 'resolvconf')
2419 meson.add_install_script(meson_make_symlink,
2420 bindir / 'resolvectl',
2421 bindir / 'systemd-resolve')
2424 if conf.get('ENABLE_LOGIND') == 1
2425 dbus_programs += executable(
2427 systemd_logind_sources,
2428 include_directories : includes,
2429 link_with : [liblogind_core,
2431 dependencies : [threads,
2433 install_rpath : rootpkglibdir,
2435 install_dir : rootlibexecdir)
2437 public_programs += executable(
2440 include_directories : includes,
2441 link_with : [libshared],
2442 dependencies : [threads,
2446 install_rpath : rootpkglibdir,
2448 install_dir : rootbindir)
2450 public_programs += executable(
2452 'src/login/inhibit.c',
2453 include_directories : includes,
2454 link_with : [libshared],
2455 install_rpath : rootpkglibdir,
2457 install_dir : rootbindir)
2459 if conf.get('HAVE_PAM') == 1
2460 version_script_arg = project_source_root / pam_systemd_sym
2461 pam_systemd = shared_library(
2465 include_directories : includes,
2466 link_args : ['-shared',
2467 '-Wl,--version-script=' + version_script_arg],
2468 link_with : [libsystemd_static,
2470 dependencies : [threads,
2473 link_depends : pam_systemd_sym,
2475 install_tag : 'pam',
2476 install_dir : pamlibdir)
2478 if want_tests != 'false'
2479 test('dlopen-pam_systemd',
2481 # path to dlopen must include a slash
2482 args : pam_systemd.full_path(),
2483 depends : pam_systemd)
2488 'systemd-user-runtime-dir',
2489 user_runtime_dir_sources,
2490 include_directories : includes,
2491 link_with : [libshared],
2492 install_rpath : rootpkglibdir,
2494 install_dir : rootlibexecdir)
2497 if conf.get('HAVE_PAM') == 1
2499 'systemd-user-sessions',
2500 'src/user-sessions/user-sessions.c',
2501 include_directories : includes,
2502 link_with : [libshared],
2503 install_rpath : rootpkglibdir,
2505 install_dir : rootlibexecdir)
2508 if conf.get('HAVE_BLKID') == 1 and conf.get('HAVE_GNU_EFI') == 1
2509 if get_option('link-boot-shared')
2510 boot_link_with = [libshared]
2512 boot_link_with = [libsystemd_static, libshared_static]
2515 public_programs += executable(
2517 'src/boot/bootctl.c',
2518 include_directories : includes,
2519 link_with : [boot_link_with],
2520 dependencies : [libblkid],
2521 install_rpath : rootpkglibdir,
2524 public_programs += executable(
2525 'systemd-bless-boot',
2526 'src/boot/bless-boot.c',
2527 include_directories : includes,
2528 link_with : [boot_link_with],
2529 dependencies : [libblkid],
2530 install_rpath : rootpkglibdir,
2532 install_dir : rootlibexecdir)
2535 'systemd-bless-boot-generator',
2536 'src/boot/bless-boot-generator.c',
2537 include_directories : includes,
2538 link_with : [boot_link_with],
2539 install_rpath : rootpkglibdir,
2541 install_dir : systemgeneratordir)
2545 'systemd-boot-check-no-failures',
2546 'src/boot/boot-check-no-failures.c',
2547 include_directories : includes,
2548 link_with : [libshared],
2549 dependencies : [libblkid],
2550 install_rpath : rootpkglibdir,
2552 install_dir : rootlibexecdir)
2554 public_programs += executable(
2555 'systemd-socket-activate',
2556 'src/activate/activate.c',
2557 include_directories : includes,
2558 link_with : [libshared],
2559 dependencies : [threads],
2560 install_rpath : rootpkglibdir,
2563 systemctl = executable(
2566 include_directories : includes,
2567 link_with : systemctl_link_with,
2568 dependencies : [threads,
2574 install_rpath : rootpkglibdir,
2576 install_dir : rootbindir)
2577 public_programs += systemctl
2579 if conf.get('ENABLE_PORTABLED') == 1
2580 dbus_programs += executable(
2581 'systemd-portabled',
2582 systemd_portabled_sources,
2583 include_directories : includes,
2584 link_with : [libshared],
2585 dependencies : [threads, libselinux],
2586 install_rpath : rootpkglibdir,
2588 install_dir : rootlibexecdir)
2590 public_programs += executable(
2592 'src/portable/portablectl.c',
2593 include_directories : includes,
2594 link_with : [libshared],
2595 dependencies : [threads],
2596 install_rpath : rootpkglibdir,
2598 install_dir : rootbindir)
2601 if conf.get('ENABLE_SYSEXT') == 1
2602 public_programs += executable(
2604 systemd_sysext_sources,
2605 include_directories : includes,
2606 link_with : [libshared],
2607 install_rpath : rootpkglibdir,
2609 install_dir : rootbindir)
2612 if conf.get('ENABLE_USERDB') == 1
2615 systemd_userwork_sources,
2616 include_directories : includes,
2617 link_with : [libshared],
2618 dependencies : [threads],
2619 install_rpath : rootpkglibdir,
2621 install_dir : rootlibexecdir)
2625 systemd_userdbd_sources,
2626 include_directories : includes,
2627 link_with : [libshared],
2628 dependencies : [threads],
2629 install_rpath : rootpkglibdir,
2631 install_dir : rootlibexecdir)
2633 public_programs += executable(
2636 include_directories : includes,
2637 link_with : [libshared],
2638 dependencies : [threads],
2639 install_rpath : rootpkglibdir,
2643 if conf.get('ENABLE_HOMED') == 1
2646 systemd_homework_sources,
2647 include_directories : includes,
2648 link_with : [libshared],
2649 dependencies : [threads,
2655 install_rpath : rootpkglibdir,
2657 install_dir : rootlibexecdir)
2659 dbus_programs += executable(
2661 systemd_homed_sources,
2662 include_directories : home_includes,
2663 link_with : [libshared],
2664 dependencies : [threads,
2668 install_rpath : rootpkglibdir,
2670 install_dir : rootlibexecdir)
2672 public_programs += executable(
2675 include_directories : includes,
2676 link_with : [libshared],
2677 dependencies : [threads,
2682 install_rpath : rootpkglibdir,
2685 if conf.get('HAVE_PAM') == 1
2686 version_script_arg = project_source_root / pam_systemd_home_sym
2687 pam_systemd_home = shared_library(
2691 include_directories : includes,
2692 link_args : ['-shared',
2693 '-Wl,--version-script=' + version_script_arg],
2694 link_with : [libsystemd_static,
2696 dependencies : [threads,
2700 link_depends : pam_systemd_home_sym,
2702 install_tag : 'pam',
2703 install_dir : pamlibdir)
2705 if want_tests != 'false'
2706 test('dlopen-pam_systemd_home',
2708 # path to dlopen must include a slash
2709 args : pam_systemd_home.full_path(),
2710 depends : pam_systemd_home)
2715 foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
2716 (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
2717 meson.add_install_script(meson_make_symlink,
2718 rootbindir / 'systemctl',
2719 rootsbindir / alias)
2722 meson.add_install_script(meson_make_symlink,
2723 rootbindir / 'udevadm',
2724 rootlibexecdir / 'systemd-udevd')
2726 if conf.get('ENABLE_BACKLIGHT') == 1
2728 'systemd-backlight',
2729 'src/backlight/backlight.c',
2730 include_directories : includes,
2731 link_with : [libshared],
2732 install_rpath : rootpkglibdir,
2734 install_dir : rootlibexecdir)
2737 if conf.get('ENABLE_RFKILL') == 1
2740 'src/rfkill/rfkill.c',
2741 include_directories : includes,
2742 link_with : [libshared],
2743 install_rpath : rootpkglibdir,
2745 install_dir : rootlibexecdir)
2749 'systemd-system-update-generator',
2750 'src/system-update-generator/system-update-generator.c',
2751 include_directories : includes,
2752 link_with : [libshared],
2753 install_rpath : rootpkglibdir,
2755 install_dir : systemgeneratordir)
2757 if conf.get('HAVE_LIBCRYPTSETUP') == 1
2759 'systemd-cryptsetup',
2760 systemd_cryptsetup_sources,
2761 include_directories : includes,
2762 link_with : [libshared],
2763 dependencies : [libcryptsetup,
2765 install_rpath : rootpkglibdir,
2767 install_dir : rootlibexecdir)
2770 'systemd-cryptsetup-generator',
2771 'src/cryptsetup/cryptsetup-generator.c',
2772 include_directories : includes,
2773 link_with : [libshared],
2774 install_rpath : rootpkglibdir,
2776 install_dir : systemgeneratordir)
2779 'systemd-veritysetup',
2780 'src/veritysetup/veritysetup.c',
2781 include_directories : includes,
2782 link_with : [libshared],
2783 dependencies : [libcryptsetup],
2784 install_rpath : rootpkglibdir,
2786 install_dir : rootlibexecdir)
2789 'systemd-veritysetup-generator',
2790 'src/veritysetup/veritysetup-generator.c',
2791 include_directories : includes,
2792 link_with : [libshared],
2793 install_rpath : rootpkglibdir,
2795 install_dir : systemgeneratordir)
2797 public_programs += executable(
2798 'systemd-cryptenroll',
2799 systemd_cryptenroll_sources,
2800 include_directories : includes,
2801 link_with : [libshared],
2802 dependencies : [libcryptsetup,
2806 install_rpath : rootpkglibdir,
2810 'systemd-integritysetup',
2811 ['src/integritysetup/integritysetup.c', 'src/integritysetup/integrity-util.c'],
2812 include_directories : includes,
2813 link_with : [libshared],
2814 dependencies : [libcryptsetup],
2815 install_rpath : rootpkglibdir,
2817 install_dir : rootlibexecdir)
2820 'systemd-integritysetup-generator',
2821 ['src/integritysetup/integritysetup-generator.c', 'src/integritysetup/integrity-util.c'],
2822 include_directories : includes,
2823 link_with : [libshared],
2824 install_rpath : rootpkglibdir,
2826 install_dir : systemgeneratordir)
2829 if conf.get('HAVE_SYSV_COMPAT') == 1
2831 'systemd-sysv-generator',
2832 'src/sysv-generator/sysv-generator.c',
2833 include_directories : includes,
2834 link_with : [libshared],
2835 install_rpath : rootpkglibdir,
2837 install_dir : systemgeneratordir)
2839 sysv_generator_test_py = find_program('test/sysv-generator-test.py')
2840 if want_tests != 'false'
2841 test('sysv-generator-test',
2842 sysv_generator_test_py,
2847 'systemd-rc-local-generator',
2848 'src/rc-local-generator/rc-local-generator.c',
2849 include_directories : includes,
2850 link_with : [libshared],
2851 install_rpath : rootpkglibdir,
2853 install_dir : systemgeneratordir)
2856 if conf.get('ENABLE_XDG_AUTOSTART') == 1
2858 'systemd-xdg-autostart-generator',
2859 systemd_xdg_autostart_generator_sources,
2860 include_directories : includes,
2861 link_with : [libshared],
2862 install_rpath : rootpkglibdir,
2864 install_dir : usergeneratordir)
2867 'systemd-xdg-autostart-condition',
2868 'src/xdg-autostart-generator/xdg-autostart-condition.c',
2869 include_directories : includes,
2870 link_with : [libshared],
2871 install_rpath : rootpkglibdir,
2873 install_dir : rootlibexecdir)
2876 if conf.get('ENABLE_HOSTNAMED') == 1
2877 dbus_programs += executable(
2878 'systemd-hostnamed',
2879 'src/hostname/hostnamed.c',
2880 include_directories : includes,
2881 link_with : [libshared],
2882 install_rpath : rootpkglibdir,
2884 install_dir : rootlibexecdir)
2886 public_programs += executable(
2888 'src/hostname/hostnamectl.c',
2889 include_directories : includes,
2890 link_with : [libshared],
2891 install_rpath : rootpkglibdir,
2895 if conf.get('ENABLE_LOCALED') == 1
2896 if conf.get('HAVE_XKBCOMMON') == 1
2897 # logind will load libxkbcommon.so dynamically on its own, but we still
2898 # need to specify where the headers are
2899 deps = [libdl, libxkbcommon.partial_dependency(compile_args: true)]
2904 dbus_programs += executable(
2906 systemd_localed_sources,
2907 include_directories : includes,
2908 link_with : [libshared],
2909 dependencies : deps,
2910 install_rpath : rootpkglibdir,
2912 install_dir : rootlibexecdir)
2914 public_programs += executable(
2917 include_directories : includes,
2918 link_with : [libshared],
2919 install_rpath : rootpkglibdir,
2923 if conf.get('ENABLE_TIMEDATED') == 1
2924 dbus_programs += executable(
2925 'systemd-timedated',
2926 'src/timedate/timedated.c',
2927 include_directories : includes,
2928 link_with : [libshared],
2929 install_rpath : rootpkglibdir,
2931 install_dir : rootlibexecdir)
2934 if conf.get('ENABLE_TIMEDATECTL') == 1
2935 public_programs += executable(
2937 'src/timedate/timedatectl.c',
2938 include_directories : includes,
2939 install_rpath : rootpkglibdir,
2940 link_with : [libshared],
2941 dependencies : [libm],
2945 if conf.get('ENABLE_TIMESYNCD') == 1
2947 'systemd-timesyncd',
2948 systemd_timesyncd_sources,
2949 include_directories : includes,
2950 link_with : [libtimesyncd_core],
2951 dependencies : [threads,
2953 install_rpath : rootpkglibdir,
2955 install_dir : rootlibexecdir)
2958 'systemd-time-wait-sync',
2959 'src/timesync/wait-sync.c',
2960 include_directories : includes,
2961 link_with : [libtimesyncd_core],
2962 install_rpath : rootpkglibdir,
2964 install_dir : rootlibexecdir)
2967 if conf.get('ENABLE_MACHINED') == 1
2968 dbus_programs += executable(
2970 systemd_machined_sources,
2971 include_directories : includes,
2972 link_with : [libmachine_core,
2974 install_rpath : rootpkglibdir,
2976 install_dir : rootlibexecdir)
2978 public_programs += executable(
2980 'src/machine/machinectl.c',
2981 include_directories : includes,
2982 link_with : [libshared],
2983 dependencies : [threads,
2987 install_rpath : rootpkglibdir,
2989 install_dir : rootbindir)
2992 if conf.get('ENABLE_IMPORTD') == 1
2993 dbus_programs += executable(
2995 systemd_importd_sources,
2996 include_directories : includes,
2997 link_with : [libshared],
2998 dependencies : [threads],
2999 install_rpath : rootpkglibdir,
3001 install_dir : rootlibexecdir)
3003 systemd_pull = executable(
3005 systemd_pull_sources,
3006 include_directories : includes,
3007 link_with : [libshared,
3009 dependencies : [versiondep,
3011 lib_openssl_or_gcrypt,
3015 install_rpath : rootpkglibdir,
3017 install_dir : rootlibexecdir)
3019 systemd_import = executable(
3021 systemd_import_sources,
3022 include_directories : includes,
3023 link_with : [libshared,
3025 dependencies : [libcurl,
3029 install_rpath : rootpkglibdir,
3031 install_dir : rootlibexecdir)
3033 systemd_import_fs = executable(
3034 'systemd-import-fs',
3035 systemd_import_fs_sources,
3036 include_directories : includes,
3037 link_with : [libshared,
3039 install_rpath : rootpkglibdir,
3041 install_dir : rootlibexecdir)
3043 systemd_export = executable(
3045 systemd_export_sources,
3046 include_directories : includes,
3047 link_with : [libshared,
3049 dependencies : [libcurl,
3053 install_rpath : rootpkglibdir,
3055 install_dir : rootlibexecdir)
3057 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
3060 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
3061 public_programs += executable(
3062 'systemd-journal-upload',
3063 systemd_journal_upload_sources,
3064 include_directories : includes,
3065 link_with : [libshared],
3066 dependencies : [versiondep,
3073 install_rpath : rootpkglibdir,
3075 install_dir : rootlibexecdir)
3078 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
3079 public_programs += executable(
3080 'systemd-journal-remote',
3081 systemd_journal_remote_sources,
3082 include_directories : journal_includes,
3083 link_with : [libshared,
3084 libsystemd_journal_remote],
3085 dependencies : [threads,
3091 install_rpath : rootpkglibdir,
3093 install_dir : rootlibexecdir)
3095 public_programs += executable(
3096 'systemd-journal-gatewayd',
3097 systemd_journal_gatewayd_sources,
3098 include_directories : journal_includes,
3099 link_with : [libshared],
3100 dependencies : [threads,
3106 install_rpath : rootpkglibdir,
3108 install_dir : rootlibexecdir)
3111 if conf.get('ENABLE_COREDUMP') == 1
3114 systemd_coredump_sources,
3115 include_directories : includes,
3116 link_with : [libshared,
3118 dependencies : [threads,
3123 install_rpath : rootpkglibdir,
3125 install_dir : rootlibexecdir)
3127 public_programs += executable(
3129 coredumpctl_sources,
3130 include_directories : includes,
3131 link_with : [libshared,
3133 dependencies : [threads,
3137 install_rpath : rootpkglibdir,
3141 if conf.get('ENABLE_PSTORE') == 1
3144 systemd_pstore_sources,
3145 include_directories : includes,
3146 link_with : [libshared],
3147 dependencies : [threads,
3152 install_rpath : rootpkglibdir,
3154 install_dir : rootlibexecdir)
3157 if conf.get('ENABLE_OOMD') == 1
3158 dbus_programs += executable('systemd-oomd',
3159 systemd_oomd_sources,
3160 include_directories : includes,
3161 link_with : [libshared],
3163 install_rpath : rootpkglibdir,
3165 install_dir : rootlibexecdir)
3167 public_programs += executable(
3170 include_directories : includes,
3171 link_with : [libshared],
3173 install_rpath : rootpkglibdir,
3177 if conf.get('ENABLE_BINFMT') == 1
3178 public_programs += executable(
3180 'src/binfmt/binfmt.c',
3181 include_directories : includes,
3182 link_with : [libshared],
3183 install_rpath : rootpkglibdir,
3185 install_dir : rootlibexecdir)
3187 meson.add_install_script('sh', '-c',
3188 mkdir_p.format(binfmtdir))
3189 if install_sysconfdir
3190 meson.add_install_script('sh', '-c',
3191 mkdir_p.format(sysconfdir / 'binfmt.d'))
3195 if conf.get('ENABLE_SYSUPDATE') == 1
3197 'systemd-sysupdate',
3198 systemd_sysupdate_sources,
3199 include_directories : includes,
3200 link_with : [libshared],
3201 dependencies : [threads,
3205 install_rpath : rootpkglibdir,
3207 install_dir : rootlibexecdir)
3208 public_programs += exe
3211 if conf.get('ENABLE_VCONSOLE') == 1
3213 'systemd-vconsole-setup',
3214 'src/vconsole/vconsole-setup.c',
3215 include_directories : includes,
3216 link_with : [libshared],
3217 install_rpath : rootpkglibdir,
3219 install_dir : rootlibexecdir)
3222 if conf.get('ENABLE_RANDOMSEED') == 1
3224 'systemd-random-seed',
3225 'src/random-seed/random-seed.c',
3226 include_directories : includes,
3227 link_with : [libshared],
3228 install_rpath : rootpkglibdir,
3230 install_dir : rootlibexecdir)
3233 if conf.get('ENABLE_FIRSTBOOT') == 1
3234 public_programs += executable(
3235 'systemd-firstboot',
3236 'src/firstboot/firstboot.c',
3237 include_directories : includes,
3238 link_with : [libshared],
3239 dependencies : [libcrypt],
3240 install_rpath : rootpkglibdir,
3242 install_dir : rootbindir)
3246 'systemd-remount-fs',
3247 'src/remount-fs/remount-fs.c',
3248 include_directories : includes,
3249 link_with : [libshared],
3250 install_rpath : rootpkglibdir,
3252 install_dir : rootlibexecdir)
3255 'systemd-machine-id-setup',
3256 'src/machine-id-setup/machine-id-setup-main.c',
3257 include_directories : includes,
3258 link_with : [libshared],
3259 install_rpath : rootpkglibdir,
3261 install_dir : rootbindir)
3266 include_directories : includes,
3267 link_with : [libshared],
3268 install_rpath : rootpkglibdir,
3270 install_dir : rootlibexecdir)
3272 executable('systemd-growfs',
3273 'src/partition/growfs.c',
3274 include_directories : includes,
3275 link_with : [libshared],
3276 install_rpath : rootpkglibdir,
3278 install_dir : rootlibexecdir)
3282 'src/partition/makefs.c',
3283 include_directories : includes,
3284 link_with : [libshared],
3285 install_rpath : rootpkglibdir,
3287 install_dir : rootlibexecdir)
3291 'src/sleep/sleep.c',
3292 include_directories : includes,
3293 link_with : [libshared],
3294 install_rpath : rootpkglibdir,
3296 install_dir : rootlibexecdir)
3298 if install_sysconfdir_samples
3299 install_data('src/sleep/sleep.conf',
3300 install_dir : pkgsysconfdir)
3303 public_programs += executable(
3305 'src/sysctl/sysctl.c',
3306 include_directories : includes,
3307 link_with : [libshared],
3308 install_rpath : rootpkglibdir,
3310 install_dir : rootlibexecdir)
3314 'src/ac-power/ac-power.c',
3315 include_directories : includes,
3316 link_with : [libshared],
3317 install_rpath : rootpkglibdir,
3319 install_dir : rootlibexecdir)
3321 public_programs += executable(
3322 'systemd-detect-virt',
3323 'src/detect-virt/detect-virt.c',
3324 include_directories : includes,
3325 link_with : [libshared],
3326 install_rpath : rootpkglibdir,
3329 public_programs += executable(
3331 'src/delta/delta.c',
3332 include_directories : includes,
3333 link_with : [libshared],
3334 install_rpath : rootpkglibdir,
3337 public_programs += executable(
3339 'src/escape/escape.c',
3340 include_directories : includes,
3341 link_with : [libshared],
3342 install_rpath : rootpkglibdir,
3344 install_dir : rootbindir)
3346 public_programs += executable(
3348 'src/notify/notify.c',
3349 include_directories : includes,
3350 link_with : [libshared],
3351 install_rpath : rootpkglibdir,
3353 install_dir : rootbindir)
3355 public_programs += executable(
3357 'src/creds/creds.c',
3358 include_directories : includes,
3359 link_with : [libshared],
3360 dependencies : [threads,
3362 install_rpath : rootpkglibdir,
3364 install_dir : rootbindir)
3367 'systemd-volatile-root',
3368 'src/volatile-root/volatile-root.c',
3369 include_directories : includes,
3370 link_with : [libshared],
3371 install_rpath : rootpkglibdir,
3372 install : conf.get('ENABLE_INITRD') == 1,
3373 install_dir : rootlibexecdir)
3376 'systemd-cgroups-agent',
3377 'src/cgroups-agent/cgroups-agent.c',
3378 include_directories : includes,
3379 link_with : [libshared],
3380 install_rpath : rootpkglibdir,
3382 install_dir : rootlibexecdir)
3384 systemd_id128 = executable(
3386 'src/id128/id128.c',
3387 include_directories : includes,
3388 link_with : [libshared],
3389 install_rpath : rootpkglibdir,
3391 public_programs += systemd_id128
3393 if want_tests != 'false'
3394 test('test-systemctl-enable',
3395 test_systemctl_enable_sh,
3396 # https://github.com/mesonbuild/meson/issues/2681
3397 args : [systemctl.full_path(),
3398 systemd_id128.full_path()])
3401 public_programs += executable(
3404 include_directories : includes,
3405 link_with : [libshared],
3406 install_rpath : rootpkglibdir,
3409 public_programs += executable(
3410 'systemd-ask-password',
3411 'src/ask-password/ask-password.c',
3412 include_directories : includes,
3413 link_with : [libshared],
3414 install_rpath : rootpkglibdir,
3416 install_dir : rootbindir)
3419 'systemd-reply-password',
3420 'src/reply-password/reply-password.c',
3421 include_directories : includes,
3422 link_with : [libshared],
3423 install_rpath : rootpkglibdir,
3425 install_dir : rootlibexecdir)
3427 public_programs += executable(
3428 'systemd-tty-ask-password-agent',
3429 'src/tty-ask-password-agent/tty-ask-password-agent.c',
3430 include_directories : includes,
3431 link_with : [libshared],
3432 install_rpath : rootpkglibdir,
3434 install_dir : rootbindir)
3436 public_programs += executable(
3439 include_directories : includes,
3440 link_with : [libshared],
3441 install_rpath : rootpkglibdir,
3444 public_programs += executable(
3446 'src/cgtop/cgtop.c',
3447 include_directories : includes,
3448 link_with : [libshared],
3449 install_rpath : rootpkglibdir,
3454 'src/initctl/initctl.c',
3455 include_directories : includes,
3456 link_with : [libshared],
3457 install_rpath : rootpkglibdir,
3458 install : (conf.get('HAVE_SYSV_COMPAT') == 1),
3459 install_dir : rootlibexecdir)
3461 public_programs += executable(
3463 'src/mount/mount-tool.c',
3464 include_directories : includes,
3465 link_with : [libshared],
3466 dependencies: [libmount],
3467 install_rpath : rootpkglibdir,
3470 meson.add_install_script(meson_make_symlink,
3471 'systemd-mount', bindir / 'systemd-umount')
3473 public_programs += executable(
3476 include_directories : includes,
3477 link_with : [libshared],
3478 install_rpath : rootpkglibdir,
3481 public_programs += executable(
3482 'systemd-stdio-bridge',
3483 'src/stdio-bridge/stdio-bridge.c',
3484 include_directories : includes,
3485 link_with : [libshared],
3486 dependencies : [versiondep],
3487 install_rpath : rootpkglibdir,
3490 public_programs += executable(
3493 include_directories : includes,
3494 link_with : [libshared],
3495 dependencies : [versiondep],
3496 install_rpath : rootpkglibdir,
3502 'src/sysusers/sysusers.c',
3503 include_directories : includes,
3504 link_with : [libshared],
3505 install_rpath : rootpkglibdir,
3507 install_dir : rootbindir)
3508 public_programs += exe
3510 if want_tests != 'false'
3511 test('test-sysusers',
3513 # https://github.com/mesonbuild/meson/issues/2681
3514 args : exe.full_path())
3517 if have_standalone_binaries
3519 'systemd-sysusers.standalone',
3520 'src/sysusers/sysusers.c',
3521 include_directories : includes,
3522 c_args : '-DSTANDALONE',
3523 link_with : [libshared_static,
3528 install_dir : rootbindir)
3529 public_programs += exe
3531 if want_tests != 'false'
3532 test('test-sysusers.standalone',
3534 # https://github.com/mesonbuild/meson/issues/2681
3535 args : exe.full_path())
3540 if conf.get('ENABLE_TMPFILES') == 1
3543 systemd_tmpfiles_sources,
3544 include_directories : includes,
3545 link_with : [libshared],
3546 dependencies : [libacl],
3547 install_rpath : rootpkglibdir,
3549 install_dir : rootbindir)
3550 public_programs += exe
3552 if want_tests != 'false'
3553 test('test-systemd-tmpfiles',
3554 test_systemd_tmpfiles_py,
3555 # https://github.com/mesonbuild/meson/issues/2681
3556 args : exe.full_path())
3559 if have_standalone_binaries
3561 'systemd-tmpfiles.standalone',
3562 systemd_tmpfiles_sources,
3563 include_directories : includes,
3564 c_args : '-DSTANDALONE',
3565 link_with : [libshared_static,
3569 dependencies : [libacl],
3571 install_dir : rootbindir)
3572 public_programs += exe
3574 if want_tests != 'false'
3575 test('test-systemd-tmpfiles.standalone',
3576 test_systemd_tmpfiles_py,
3577 # https://github.com/mesonbuild/meson/issues/2681
3578 args : exe.full_path())
3583 if conf.get('ENABLE_HWDB') == 1
3584 systemd_hwdb = executable(
3587 include_directories : includes,
3588 link_with : udev_link_with,
3589 install_rpath : udev_rpath,
3591 install_dir : rootbindir)
3592 public_programs += systemd_hwdb
3594 if want_tests != 'false'
3597 suite : 'dist-check',
3598 args : [systemd_hwdb.full_path()],
3603 if conf.get('ENABLE_QUOTACHECK') == 1
3605 'systemd-quotacheck',
3606 'src/quotacheck/quotacheck.c',
3607 include_directories : includes,
3608 link_with : [libshared],
3609 install_rpath : rootpkglibdir,
3611 install_dir : rootlibexecdir)
3614 public_programs += executable(
3615 'systemd-socket-proxyd',
3616 'src/socket-proxy/socket-proxyd.c',
3617 include_directories : includes,
3618 link_with : [libshared],
3619 dependencies : [threads],
3620 install_rpath : rootpkglibdir,
3622 install_dir : rootlibexecdir)
3624 udevadm = executable(
3627 include_directories : includes,
3628 link_with : [libudevd_core],
3629 dependencies : [versiondep,
3635 install_rpath : udev_rpath,
3637 install_dir : rootbindir)
3638 public_programs += udevadm
3640 if conf.get('ENABLE_REPART') == 1
3643 systemd_repart_sources,
3644 include_directories : includes,
3645 link_with : [libshared],
3646 dependencies : [threads,
3649 install_rpath : rootpkglibdir,
3651 install_dir : rootbindir)
3652 public_programs += exe
3654 if want_tests != 'false'
3657 args : [exe.full_path(), udevadm.full_path()])
3663 systemd_shutdown_sources,
3664 include_directories : includes,
3665 link_with : [libshared],
3666 dependencies : [libmount],
3667 install_rpath : rootpkglibdir,
3669 install_dir : rootlibexecdir)
3672 'systemd-update-done',
3673 'src/update-done/update-done.c',
3674 include_directories : includes,
3675 link_with : [libshared],
3676 install_rpath : rootpkglibdir,
3678 install_dir : rootlibexecdir)
3681 'systemd-update-utmp',
3682 'src/update-utmp/update-utmp.c',
3683 include_directories : includes,
3684 link_with : [libshared],
3685 dependencies : [libaudit],
3686 install_rpath : rootpkglibdir,
3687 install : (conf.get('ENABLE_UTMP') == 1),
3688 install_dir : rootlibexecdir)
3690 if conf.get('HAVE_KMOD') == 1
3692 'systemd-modules-load',
3693 'src/modules-load/modules-load.c',
3694 include_directories : includes,
3695 link_with : [libshared],
3696 dependencies : [libkmod],
3697 install_rpath : rootpkglibdir,
3699 install_dir : rootlibexecdir)
3701 meson.add_install_script('sh', '-c',
3702 mkdir_p.format(modulesloaddir))
3703 if install_sysconfdir
3704 meson.add_install_script('sh', '-c',
3705 mkdir_p.format(sysconfdir / 'modules-load.d'))
3709 public_programs += executable(
3711 systemd_nspawn_sources,
3712 include_directories : includes,
3713 link_with : [libnspawn_core,
3715 dependencies : [libblkid,
3717 install_rpath : rootpkglibdir,
3720 if conf.get('ENABLE_NETWORKD') == 1
3721 dbus_programs += executable(
3723 systemd_networkd_sources,
3724 include_directories : network_includes,
3725 link_with : [libnetworkd_core,
3727 networkd_link_with],
3728 dependencies : [threads],
3729 install_rpath : rootpkglibdir,
3731 install_dir : rootlibexecdir)
3733 public_programs += executable(
3734 'systemd-networkd-wait-online',
3735 systemd_networkd_wait_online_sources,
3736 include_directories : includes,
3737 link_with : [networkd_link_with],
3738 install_rpath : rootpkglibdir,
3740 install_dir : rootlibexecdir)
3742 public_programs += executable(
3745 include_directories : libsystemd_network_includes,
3746 link_with : [libsystemd_network,
3747 networkd_link_with],
3748 install_rpath : rootpkglibdir,
3750 install_dir : rootbindir)
3754 'systemd-network-generator',
3755 network_generator_sources,
3756 include_directories : includes,
3757 link_with : [networkd_link_with],
3758 install_rpath : rootpkglibdir,
3760 install_dir : rootlibexecdir)
3762 if want_tests != 'false'
3763 test('test-network-generator-conversion',
3764 test_network_generator_conversion_sh,
3765 # https://github.com/mesonbuild/meson/issues/2681
3766 args : exe.full_path(),
3771 'systemd-sulogin-shell',
3772 'src/sulogin-shell/sulogin-shell.c',
3773 include_directories : includes,
3774 link_with : [libshared],
3775 install_rpath : rootpkglibdir,
3777 install_dir : rootlibexecdir)
3779 exe = custom_target(
3781 input : kernel_install_in,
3782 output : 'kernel-install',
3783 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
3784 install : want_kernel_install,
3785 install_mode : 'rwxr-xr-x',
3786 install_dir : bindir)
3787 public_programs += exe
3789 if want_tests != 'false'
3790 test('test-kernel-install',
3791 test_kernel_install_sh,
3792 args : [exe.full_path(), loaderentry_install])
3795 ############################################################
3797 runtest_env = custom_target(
3798 'systemd-runtest.env',
3799 output : 'systemd-runtest.env',
3800 command : [sh, '-c',
3801 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
3802 project_source_root / 'test',
3803 project_build_root / 'catalog')],
3805 build_by_default : true)
3807 test_cflags = ['-DTEST_CODE=1']
3808 # We intentionally do not do inline initializations with definitions for a
3809 # bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
3810 # use the variable unexpectedly. This triggers a lot of maybe-uninitialized
3811 # false positives when the combination of -O2 and -flto is used. Suppress them.
3812 if '-O2' in c_args and '-flto=auto' in c_args
3813 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
3816 foreach tuple : tests
3818 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3819 dependencies = tuple.length() > 2 ? tuple[2] : []
3820 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3821 condition = tuple.length() > 4 ? tuple[4] : ''
3822 type = tuple.length() > 5 ? tuple[5] : ''
3823 defs = tuple.length() > 6 ? tuple[6] : []
3825 parallel = tuple.length() > 7 ? tuple[7] : true
3828 # FIXME: Use fs.stem() with meson >= 0.54.0
3829 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
3830 if type.startswith('timeout=')
3831 timeout = type.split('=')[1].to_int()
3835 suite = fs.name(fs.parent('@0@'.format(sources[0])))
3836 # FIXME: Use str.replace() with meson >= 0.58.0
3837 suite = suite.split('sd-')[-1]
3839 if condition == '' or conf.get(condition) == 1
3843 include_directories : incs,
3844 link_with : link_with,
3845 dependencies : [versiondep,
3848 build_by_default : want_tests != 'false',
3849 install_rpath : rootpkglibdir,
3850 install : install_tests,
3851 install_dir : testsdir / type,
3852 link_depends : runtest_env)
3855 message('@0@ is a manual test'.format(name))
3856 elif type == 'unsafe' and want_tests != 'unsafe'
3857 message('@0@ is an unsafe test'.format(name))
3858 elif want_tests != 'false'
3865 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
3870 'test-libsystemd-sym',
3871 test_libsystemd_sym_c,
3872 include_directories : includes,
3873 link_with : [libsystemd],
3874 build_by_default : want_tests != 'false',
3875 install : install_tests,
3876 install_dir : testsdir)
3877 if want_tests != 'false'
3878 test('test-libsystemd-sym', exe)
3882 'test-libsystemd-static-sym',
3883 test_libsystemd_sym_c,
3884 include_directories : includes,
3885 link_with : [install_libsystemd_static],
3886 dependencies : [threads], # threads is already included in dependencies on the library,
3887 # but does not seem to get propagated. Add here as a work-around.
3888 build_by_default : want_tests != 'false' and static_libsystemd_pic,
3889 install : install_tests and static_libsystemd_pic,
3890 install_dir : testsdir)
3891 if want_tests != 'false' and static_libsystemd_pic
3892 test('test-libsystemd-static-sym', exe)
3898 include_directories : libudev_includes,
3899 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
3900 link_with : [libudev],
3901 build_by_default : want_tests != 'false',
3902 install : install_tests,
3903 install_dir : testsdir)
3904 if want_tests != 'false'
3905 test('test-libudev-sym', exe)
3909 'test-libudev-static-sym',
3911 include_directories : libudev_includes,
3912 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
3913 link_with : [install_libudev_static],
3914 build_by_default : want_tests != 'false' and static_libudev_pic,
3915 install : install_tests and static_libudev_pic,
3916 install_dir : testsdir)
3917 if want_tests != 'false' and static_libudev_pic
3918 test('test-libudev-static-sym', exe)
3921 ############################################################
3925 foreach tuple : fuzzers
3927 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3928 dependencies = tuple.length() > 2 ? tuple[2] : []
3929 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3930 defs = tuple.length() > 4 ? tuple[4] : []
3934 dependencies += fuzzing_engine
3936 if fuzzing_engine.found()
3937 dependencies += fuzzing_engine
3939 link_args += ['-fsanitize=fuzzer']
3942 sources += 'src/fuzz/fuzz-main.c'
3945 # FIXME: Use fs.stem() with meson >= 0.54.0
3946 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
3951 include_directories : [incs, include_directories('src/fuzz')],
3952 link_with : link_with,
3953 dependencies : dependencies,
3954 c_args : defs + test_cflags,
3955 link_args: link_args,
3957 build_by_default : fuzzer_build)
3960 if want_tests != 'false'
3961 # Run the fuzz regression tests without any sanitizers enabled.
3962 # Additional invocations with sanitizers may be added below.
3963 foreach p : fuzz_regression_tests
3964 b = p.split('/')[-2]
3965 c = p.split('/')[-1]
3968 test('@0@_@1@'.format(b, c),
3971 args : [project_source_root / p])
3977 alias_target('fuzzers', fuzzer_exes)
3979 ############################################################
3981 subdir('modprobe.d')
3983 subdir('sysusers.d')
3984 subdir('tmpfiles.d')
3990 subdir('shell-completion/bash')
3991 subdir('shell-completion/zsh')
3992 subdir('docs/sysvinit')
3993 subdir('docs/var-log')
3995 install_subdir('factory/etc',
3996 install_dir : factorydir)
3997 subdir('factory/templates')
3999 if install_sysconfdir
4000 install_data('xorg/50-systemd-user.sh',
4001 install_dir : xinitrcdir)
4003 install_data('LICENSE.GPL2',
4007 'docs/CODING_STYLE.md',
4008 'docs/DISTRO_PORTING.md',
4009 'docs/ENVIRONMENT.md',
4011 'docs/TRANSIENT-SETTINGS.md',
4012 'docs/TRANSLATORS.md',
4013 'docs/UIDS-GIDS.md',
4014 install_dir : docdir)
4016 install_subdir('LICENSES',
4017 install_dir : docdir)
4019 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
4020 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
4022 ############################################################
4024 # Ensure that changes to the docs/ directory do not break the
4025 # basic Github pages build. But only run it in developer mode,
4026 # as it might be fragile due to changes in the tooling, and it is
4027 # not generally useful for users.
4028 jekyll = find_program('jekyll', required : false)
4029 if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
4030 test('github-pages',
4032 suite : 'dist-check',
4034 '--source', project_source_root / 'docs',
4035 '--destination', project_build_root / '_site'])
4038 ############################################################
4040 check_help = find_program('tools/check-help.sh')
4041 check_version = find_program('tools/check-version.sh')
4043 foreach exec : public_programs
4044 name = exec.full_path().split('/')[-1]
4045 if want_tests != 'false'
4046 test('check-help-' + name,
4048 suite : 'dist-check',
4049 args : exec.full_path(),
4052 test('check-version-' + name,
4054 suite : 'dist-check',
4055 args : [exec.full_path(),
4056 meson.project_version()],
4061 ############################################################
4063 check_directives_sh = find_program('tools/check-directives.sh')
4065 if want_tests != 'false'
4066 test('check-directives',
4067 check_directives_sh,
4068 suite : 'dist-check',
4069 args : [project_source_root, project_build_root])
4072 ############################################################
4074 # Enable tests for all supported sanitizers
4075 foreach tuple : sanitizers
4076 sanitizer = tuple[0]
4079 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
4081 foreach p : fuzz_regression_tests
4082 b = p.split('/')[-2]
4083 c = p.split('/')[-1]
4085 name = '@0@:@1@'.format(b, sanitizer)
4088 if want_tests == 'false'
4089 message('Not compiling @0@ because tests is set to false'.format(name))
4091 exe = custom_target(
4095 command : [ln, '-fs',
4096 build.full_path() / b,
4098 build_by_default : true)
4100 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
4106 test('@0@_@1@_@2@'.format(b, c, sanitizer),
4109 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
4111 args : [exe.full_path(),
4112 project_source_root / p])
4119 ############################################################
4122 all_files = run_command(
4123 env, '-u', 'GIT_WORK_TREE',
4124 git, '--git-dir=@0@/.git'.format(project_source_root),
4125 'ls-files', ':/*.[ch]',
4127 if all_files.returncode() == 0
4128 all_files = files(all_files.stdout().split())
4133 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
4136 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
4141 git_contrib_sh = find_program('tools/git-contrib.sh')
4144 command : [git_contrib_sh])
4148 git_head = run_command(
4149 git, '--git-dir=@0@/.git'.format(project_source_root),
4150 'rev-parse', 'HEAD',
4151 check : false).stdout().strip()
4152 git_head_short = run_command(
4153 git, '--git-dir=@0@/.git'.format(project_source_root),
4154 'rev-parse', '--short=7', 'HEAD',
4155 check : false).stdout().strip()
4159 command : [git, 'archive',
4160 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
4162 '--prefix', 'systemd-@0@/'.format(git_head),
4166 ############################################################
4168 check_api_docs_sh = find_program('tools/check-api-docs.sh')
4171 depends : [man, libsystemd, libudev],
4172 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
4174 alias_target('update-dbus-docs', update_dbus_docs)
4175 alias_target('update-man-rules', update_man_rules)
4177 if not meson.is_cross_build()
4179 'export-dbus-interfaces',
4180 output : fs.name(dbus_interfaces_dir),
4181 install : dbus_interfaces_dir != 'no',
4182 install_dir : fs.parent(dbus_interfaces_dir),
4183 command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
4186 ############################################################
4188 alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
4189 check : true).stdout().strip()
4192 'split /usr' : split_usr,
4193 'split bin-sbin' : split_bin,
4194 'prefix directory' : prefixdir,
4195 'rootprefix directory' : rootprefixdir,
4196 'sysconf directory' : sysconfdir,
4197 'include directory' : includedir,
4198 'lib directory' : libdir,
4199 'rootlib directory' : rootlibdir,
4200 'SysV init scripts' : sysvinit_path,
4201 'SysV rc?.d directories' : sysvrcnd_path,
4202 'PAM modules directory' : pamlibdir,
4203 'PAM configuration directory' : pamconfdir,
4204 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
4205 'RPM macros directory' : rpmmacrosdir,
4206 'modprobe.d directory' : modprobedir,
4207 'D-Bus policy directory' : dbuspolicydir,
4208 'D-Bus session directory' : dbussessionservicedir,
4209 'D-Bus system directory' : dbussystemservicedir,
4210 'D-Bus interfaces directory' : dbus_interfaces_dir,
4211 'bash completions directory' : bashcompletiondir,
4212 'zsh completions directory' : zshcompletiondir,
4213 'private shared lib version tag' : shared_lib_tag,
4214 'extra start script' : get_option('rc-local'),
4215 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
4216 get_option('debug-tty')),
4217 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
4218 conf.get('SYSTEM_ALLOC_UID_MIN')),
4219 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
4220 conf.get('SYSTEM_ALLOC_GID_MIN')),
4221 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
4222 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
4223 'static UID/GID allocations' : ' '.join(static_ugids),
4224 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
4225 'render group access mode' : get_option('group-render-mode'),
4226 'certificate root directory' : get_option('certificate-root'),
4227 'support URL' : support_url,
4228 'nobody user name' : nobody_user,
4229 'nobody group name' : nobody_group,
4230 'fallback hostname' : get_option('fallback-hostname'),
4231 'default compression method' : compression,
4232 'default DNSSEC mode' : default_dnssec,
4233 'default DNS-over-TLS mode' : default_dns_over_tls,
4234 'default mDNS mode' : default_mdns,
4235 'default LLMNR mode' : default_llmnr,
4236 'default DNS servers' : dns_servers.split(' '),
4237 'default NTP servers' : ntp_servers.split(' '),
4238 'default cgroup hierarchy' : default_hierarchy,
4239 'default net.naming-scheme value' : default_net_naming_scheme,
4240 'default KillUserProcesses value' : kill_user_processes,
4241 'default locale' : default_locale,
4242 'default nspawn locale' : nspawn_locale,
4243 'default status unit format' : status_unit_format_default,
4244 'default user $PATH' :
4245 default_user_path != '' ? default_user_path : '(same as system services)',
4246 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
4247 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
4250 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
4251 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
4252 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
4273 ['libcryptsetup-plugins'],
4299 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
4329 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
4343 ['legacy-pkla', install_polkit_pkla],
4348 ['man pages', want_man],
4349 ['html pages', want_html],
4350 ['man page indices', want_man and have_lxml],
4352 ['compat-mutable-uid-boundaries'],
4355 ['adm group', get_option('adm-group')],
4356 ['wheel group', get_option('wheel-group')],
4359 ['debug mmap cache'],
4361 ['valgrind', conf.get('VALGRIND') == 1],
4362 ['trace logging', conf.get('LOG_TRACE') == 1],
4363 ['install tests', install_tests],
4364 ['link-udev-shared', get_option('link-udev-shared')],
4365 ['link-systemctl-shared', get_option('link-systemctl-shared')],
4366 ['link-networkd-shared', get_option('link-networkd-shared')],
4367 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
4368 ['link-journalctl-shared', get_option('link-journalctl-shared')],
4369 ['link-boot-shared', get_option('link-boot-shared')],
4370 ['first-boot-full-preset'],
4372 ['standalone-binaries', get_option('standalone-binaries')],
4373 ['coverage', get_option('b_coverage')],
4376 if tuple.length() >= 2
4379 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
4380 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
4381 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
4390 if static_libsystemd == 'false'
4391 missing += 'static-libsystemd'
4393 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
4396 if static_libudev == 'false'
4397 missing += 'static-libudev'
4399 found += 'static-libudev(@0@)'.format(static_libudev)
4402 if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
4403 found += 'cryptolib(openssl)'
4404 elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
4405 found += 'cryptolib(gcrypt)'
4407 missing += 'cryptolib'
4410 if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
4411 found += 'DNS-over-TLS(gnutls)'
4412 elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
4413 found += 'DNS-over-TLS(openssl)'
4415 missing += 'DNS-over-TLS'
4419 'enabled' : ', '.join(found),
4420 'disabled' : ', '.join(missing)},
4421 section : 'Features')
4423 if rootprefixdir != rootprefix_default
4425 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
4426 'systemd used fixed names for unit file directories and other paths, so anything\n' +
4427 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))