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 # Disable -Wmaybe-uninitialized when compiling with -Os/-O1/-O3/etc. There are
394 # too many false positives with gcc >= 8. Effectively, we only test with -O0
395 # and -O2; this should be enough to catch most important cases without too much
396 # busywork. See https://github.com/systemd/systemd/pull/19226.
397 if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or
398 cc.version().version_compare('<10') or
403 possible_common_cc_flags += '-Wno-maybe-uninitialized'
406 # Disable -Wno-unused-result with gcc, see
407 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425.
408 if cc.get_id() == 'gcc'
409 possible_common_cc_flags += '-Wno-unused-result'
412 # --as-needed and --no-undefined are provided by meson by default,
413 # run 'meson configure' to see what is enabled
414 possible_link_flags = [
415 '-Wl,--fatal-warnings',
421 if get_option('b_sanitize') == 'none'
422 possible_link_flags += '-Wl,--warn-common'
425 if cc.get_id() == 'clang'
426 possible_common_cc_flags += [
427 '-Wno-typedef-redefinition',
428 '-Wno-gnu-variable-sized-type-not-at-end',
432 if get_option('mode') == 'release'
433 # We could enable 'pattern' for developer mode, but that can interfere with
434 # valgrind and sanitizer builds. Also, clang does not zero-initialize unions,
435 # breaking some of our code (https://reviews.llvm.org/D68115).
436 possible_common_cc_flags += '-ftrivial-auto-var-init=zero'
439 possible_cc_flags = possible_common_cc_flags + [
440 '-Werror=missing-declarations',
441 '-Werror=missing-prototypes',
442 '-fdiagnostics-show-option',
444 '-fno-strict-aliasing',
446 '-fstack-protector-strong',
447 '-fvisibility=hidden',
448 '--param=ssp-buffer-size=4',
451 if get_option('buildtype') != 'debug'
452 possible_cc_flags += [
453 '-ffunction-sections',
457 possible_link_flags += '-Wl,--gc-sections'
460 if get_option('mode') == 'developer'
461 possible_cc_flags += '-fno-omit-frame-pointer'
464 add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
465 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
466 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
468 have = cc.has_argument('-Wzero-length-bounds')
469 conf.set10('HAVE_ZERO_LENGTH_BOUNDS', have)
473 #include <inttypes.h>
474 typedef uint64_t usec_t;
475 usec_t now(clockid_t clock);
480 ''', args: '-Werror=shadow', name : '-Werror=shadow with local shadowing')
481 add_project_arguments('-Werror=shadow', language : 'c')
485 add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
488 cpp = ' '.join(cc.cmd_array()) + ' -E'
490 has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
492 #####################################################################
493 # compilation result tests
495 conf.set('_GNU_SOURCE', true)
496 conf.set('__SANE_USERSPACE_TYPES__', true)
497 conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)
499 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
500 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
501 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
502 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
503 conf.set('SIZEOF_TIMEX_MEMBER', cc.sizeof('typeof(((struct timex *)0)->freq)', prefix : '#include <sys/timex.h>'))
507 #include <sys/mount.h>
508 #include <sys/stat.h>
509 #include <linux/fs.h>
512 foreach decl : ['char16_t',
518 # We get -1 if the size cannot be determined
519 have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
521 if decl == 'struct statx'
523 want_linux_stat_h = false
525 have = cc.sizeof(decl,
526 prefix : decl_headers + '#include <linux/stat.h>',
527 args : '-D_GNU_SOURCE') > 0
528 want_linux_stat_h = have
532 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
535 conf.set10('WANT_LINUX_STAT_H', want_linux_stat_h)
537 foreach ident : ['secure_getenv', '__secure_getenv']
538 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
542 ['memfd_create', '''#include <sys/mman.h>'''],
543 ['gettid', '''#include <sys/types.h>
544 #include <unistd.h>'''],
545 ['pivot_root', '''#include <stdlib.h>
546 #include <unistd.h>'''], # no known header declares pivot_root
547 ['ioprio_get', '''#include <sched.h>'''], # no known header declares ioprio_get
548 ['ioprio_set', '''#include <sched.h>'''], # no known header declares ioprio_set
549 ['name_to_handle_at', '''#include <sys/types.h>
550 #include <sys/stat.h>
551 #include <fcntl.h>'''],
552 ['setns', '''#include <sched.h>'''],
553 ['renameat2', '''#include <stdio.h>
554 #include <fcntl.h>'''],
555 ['kcmp', '''#include <linux/kcmp.h>'''],
556 ['keyctl', '''#include <sys/types.h>
557 #include <keyutils.h>'''],
558 ['copy_file_range', '''#include <sys/syscall.h>
559 #include <unistd.h>'''],
560 ['bpf', '''#include <sys/syscall.h>
561 #include <unistd.h>'''],
562 ['statx', '''#include <sys/types.h>
563 #include <sys/stat.h>
564 #include <unistd.h>'''],
565 ['explicit_bzero' , '''#include <string.h>'''],
566 ['reallocarray', '''#include <stdlib.h>'''],
567 ['set_mempolicy', '''#include <stdlib.h>
568 #include <unistd.h>'''],
569 ['get_mempolicy', '''#include <stdlib.h>
570 #include <unistd.h>'''],
571 ['pidfd_send_signal', '''#include <stdlib.h>
574 #include <sys/wait.h>'''],
575 ['pidfd_open', '''#include <stdlib.h>
578 #include <sys/wait.h>'''],
579 ['rt_sigqueueinfo', '''#include <stdlib.h>
582 #include <sys/wait.h>'''],
583 ['mallinfo', '''#include <malloc.h>'''],
584 ['mallinfo2', '''#include <malloc.h>'''],
585 ['execveat', '''#include <unistd.h>'''],
586 ['close_range', '''#include <unistd.h>'''],
587 ['epoll_pwait2', '''#include <sys/epoll.h>'''],
588 ['mount_setattr', '''#include <sys/mount.h>'''],
589 ['move_mount', '''#include <sys/mount.h>'''],
590 ['open_tree', '''#include <sys/mount.h>'''],
591 ['getdents64', '''#include <dirent.h>'''],
594 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
595 conf.set10('HAVE_' + ident[0].to_upper(), have)
598 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
599 conf.set10('USE_SYS_RANDOM_H', true)
600 conf.set10('HAVE_GETRANDOM', true)
602 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
603 conf.set10('USE_SYS_RANDOM_H', false)
604 conf.set10('HAVE_GETRANDOM', have)
607 #####################################################################
609 version_tag = get_option('version-tag')
611 vcs_data = configuration_data()
612 vcs_data.set('VCS_TAG', version_tag)
613 version_h = configure_file(configuration : vcs_data,
614 input : 'src/version/version.h.in',
615 output : 'version.h')
618 project_source_root + '/tools/meson-vcs-tag.sh',
620 meson.project_version()]
623 input : 'src/version/version.h.in',
624 output : 'version.h',
628 versiondep = declare_dependency(sources: version_h)
630 shared_lib_tag = get_option('shared-lib-tag')
631 if shared_lib_tag == ''
632 shared_lib_tag = meson.project_version()
635 sh = find_program('sh')
636 echo = find_program('echo')
637 sed = find_program('sed')
638 awk = find_program('awk')
639 stat = find_program('stat')
640 ln = find_program('ln')
641 git = find_program('git', required : false)
642 env = find_program('env')
643 perl = find_program('perl', required : false)
644 rsync = find_program('rsync', required : false)
645 meson_make_symlink = project_source_root + '/tools/meson-make-symlink.sh'
647 mkdir_p = 'mkdir -p $DESTDIR/@0@'
649 # If -Dxxx-path option is found, use that. Otherwise, check in $PATH,
650 # /usr/sbin, /sbin, and fall back to the default from middle column.
651 progs = [['quotaon', '/usr/sbin/quotaon' ],
652 ['quotacheck', '/usr/sbin/quotacheck' ],
653 ['kmod', '/usr/bin/kmod' ],
654 ['kexec', '/usr/sbin/kexec' ],
655 ['sulogin', '/usr/sbin/sulogin' ],
656 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
657 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
658 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
659 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
660 ['nologin', '/usr/sbin/nologin', ],
663 path = get_option(prog[0] + '-path')
665 message('Using @1@ for @0@'.format(prog[0], path))
667 exe = find_program(prog[0],
668 '/usr/sbin/' + prog[0],
671 path = exe.found() ? exe.path() : prog[1]
673 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
674 conf.set_quoted(name, path)
677 conf.set_quoted('TELINIT', get_option('telinit-path'))
679 if run_command(ln, '--relative', '--help', check : false).returncode() != 0
680 error('ln does not support --relative (added in coreutils 8.16)')
683 ############################################################
685 python = find_program('python3')
686 if run_command(python, '-c', 'import jinja2', check : false).returncode() != 0
687 error('python3 jinja2 missing')
690 ############################################################
692 gperf = find_program('gperf')
694 gperf_test_format = '''
696 const char * in_word_set(const char *, @0@);
699 gperf_snippet = run_command(sh, '-c', 'echo foo,bar | "$1" -L ANSI-C', '_', gperf,
701 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
702 if cc.compiles(gperf_test)
703 gperf_len_type = 'size_t'
705 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
706 if cc.compiles(gperf_test)
707 gperf_len_type = 'unsigned'
709 error('unable to determine gperf len type')
712 message('gperf len type is @0@'.format(gperf_len_type))
713 conf.set('GPERF_LEN_TYPE', gperf_len_type,
714 description : 'The type of gperf "len" parameter')
716 ############################################################
718 if not cc.has_header('sys/capability.h')
719 error('POSIX caps headers not found')
721 foreach header : ['crypt.h',
723 'linux/vm_sockets.h',
725 'valgrind/memcheck.h',
726 'valgrind/valgrind.h',
727 'linux/time_types.h',
731 conf.set10('HAVE_' + header.underscorify().to_upper(),
732 cc.has_header(header))
735 ############################################################
737 fallback_hostname = get_option('fallback-hostname')
738 if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0] == '-'
739 error('Invalid fallback-hostname configuration')
740 # A more extensive test is done in test-hostname-util. Let's catch
741 # the most obvious errors here so we don't fail with an assert later.
743 conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
745 default_hierarchy = get_option('default-hierarchy')
746 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
747 description : 'default cgroup hierarchy as string')
748 if default_hierarchy == 'legacy'
749 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
750 elif default_hierarchy == 'hybrid'
751 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
753 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
756 extra_net_naming_schemes = []
757 extra_net_naming_map = []
758 foreach scheme: get_option('extra-net-naming-schemes').split(',')
760 name = scheme.split('=')[0]
761 value = scheme.split('=')[1]
762 NAME = name.underscorify().to_upper()
764 foreach field: value.split('+')
765 VALUE += 'NAMING_' + field.underscorify().to_upper()
767 extra_net_naming_schemes += 'NAMING_@0@ = @1@,'.format(NAME, '|'.join(VALUE))
768 extra_net_naming_map += '{ "@0@", NAMING_@1@ },'.format(name, NAME)
771 conf.set('EXTRA_NET_NAMING_SCHEMES', ' '.join(extra_net_naming_schemes))
772 conf.set('EXTRA_NET_NAMING_MAP', ' '.join(extra_net_naming_map))
774 default_net_naming_scheme = get_option('default-net-naming-scheme')
775 conf.set_quoted('DEFAULT_NET_NAMING_SCHEME', default_net_naming_scheme)
776 if default_net_naming_scheme != 'latest'
777 conf.set('_DEFAULT_NET_NAMING_SCHEME_TEST',
778 'NAMING_' + default_net_naming_scheme.underscorify().to_upper())
781 time_epoch = get_option('time-epoch')
783 time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check : true).stdout().strip()
784 if time_epoch == '' and git.found() and fs.exists('.git')
785 # If we're in a git repository, use the creation time of the latest git tag.
786 latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags',
788 if latest_tag.returncode() == 0
789 time_epoch = run_command(
790 git, 'log', '--no-show-signature', '-1', '--format=%at',
791 latest_tag.stdout().strip(),
792 check : false).stdout()
797 time_epoch = run_command(stat, '-c', '%Y', NEWS,
798 check : true).stdout()
800 time_epoch = time_epoch.to_int()
802 conf.set('TIME_EPOCH', time_epoch)
804 conf.set('CLOCK_VALID_RANGE_USEC_MAX', get_option('clock-valid-range-usec-max'))
806 default_user_shell = get_option('default-user-shell')
807 conf.set_quoted('DEFAULT_USER_SHELL', default_user_shell)
808 conf.set_quoted('DEFAULT_USER_SHELL_NAME', fs.name(default_user_shell))
810 foreach tuple : [['system-alloc-uid-min', 'SYS_UID_MIN', 1], # Also see login.defs(5).
811 ['system-uid-max', 'SYS_UID_MAX', 999],
812 ['system-alloc-gid-min', 'SYS_GID_MIN', 1],
813 ['system-gid-max', 'SYS_GID_MAX', 999]]
814 v = get_option(tuple[0])
818 '/^\s*@0@\s+/ { uid=$2 } END { print uid }'.format(tuple[1]),
820 check : false).stdout().strip()
827 conf.set(tuple[0].underscorify().to_upper(), v)
829 if conf.get('SYSTEM_ALLOC_UID_MIN') >= conf.get('SYSTEM_UID_MAX')
830 error('Invalid uid allocation range')
832 if conf.get('SYSTEM_ALLOC_GID_MIN') >= conf.get('SYSTEM_GID_MAX')
833 error('Invalid gid allocation range')
836 dynamic_uid_min = get_option('dynamic-uid-min')
837 dynamic_uid_max = get_option('dynamic-uid-max')
838 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
839 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
841 container_uid_base_min = get_option('container-uid-base-min')
842 container_uid_base_max = get_option('container-uid-base-max')
843 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
844 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
846 nobody_user = get_option('nobody-user')
847 nobody_group = get_option('nobody-group')
849 if not meson.is_cross_build()
850 getent_result = run_command('getent', 'passwd', '65534', check : false)
851 if getent_result.returncode() == 0
852 name = getent_result.stdout().split(':')[0]
853 if name != nobody_user
855 '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) +
856 'Your build will result in an user table setup that is incompatible with the local system.')
859 id_result = run_command('id', '-u', nobody_user, check : false)
860 if id_result.returncode() == 0
861 id = id_result.stdout().to_int()
864 '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) +
865 'Your build will result in an user table setup that is incompatible with the local system.')
869 getent_result = run_command('getent', 'group', '65534', check : false)
870 if getent_result.returncode() == 0
871 name = getent_result.stdout().split(':')[0]
872 if name != nobody_group
874 '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) +
875 'Your build will result in an group table setup that is incompatible with the local system.')
878 id_result = run_command('id', '-g', nobody_group, check : false)
879 if id_result.returncode() == 0
880 id = id_result.stdout().to_int()
883 '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) +
884 'Your build will result in an group table setup that is incompatible with the local system.')
888 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
890 'The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
891 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
894 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
895 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
898 foreach option : ['adm-gid',
915 'systemd-journal-gid',
916 'systemd-network-uid',
917 'systemd-resolve-uid',
918 'systemd-timesync-uid']
919 name = option.underscorify().to_upper()
920 val = get_option(option)
922 # Ensure provided GID argument is numeric, otherwise fall back to default assignment
923 conf.set(name, val >= 0 ? val : '-')
925 static_ugids += '@0@:@1@'.format(option, val)
929 conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
930 conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
932 dev_kvm_mode = get_option('dev-kvm-mode')
933 conf.set_quoted('DEV_KVM_MODE', dev_kvm_mode) # FIXME: convert to 0o… notation
934 conf.set10('DEV_KVM_UACCESS', dev_kvm_mode != '0666')
935 group_render_mode = get_option('group-render-mode')
936 conf.set_quoted('GROUP_RENDER_MODE', group_render_mode)
937 conf.set10('GROUP_RENDER_UACCESS', group_render_mode != '0666')
939 kill_user_processes = get_option('default-kill-user-processes')
940 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
942 dns_servers = get_option('dns-servers')
943 conf.set_quoted('DNS_SERVERS', dns_servers)
945 ntp_servers = get_option('ntp-servers')
946 conf.set_quoted('NTP_SERVERS', ntp_servers)
948 default_locale = get_option('default-locale')
949 conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale)
951 nspawn_locale = get_option('nspawn-locale')
952 conf.set_quoted('SYSTEMD_NSPAWN_LOCALE', nspawn_locale)
954 localegen_path = get_option('localegen-path')
955 if localegen_path != ''
956 conf.set_quoted('LOCALEGEN_PATH', localegen_path)
958 conf.set10('HAVE_LOCALEGEN', localegen_path != '')
960 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
962 service_watchdog = get_option('service-watchdog')
963 watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
964 conf.set_quoted('SERVICE_WATCHDOG', watchdog_value)
966 conf.set_quoted('SUSHELL', get_option('debug-shell'))
967 conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
969 enable_debug_hashmap = false
970 enable_debug_mmap_cache = false
971 enable_debug_siphash = false
972 foreach name : get_option('debug-extra')
974 enable_debug_hashmap = true
975 elif name == 'mmap-cache'
976 enable_debug_mmap_cache = true
977 elif name == 'siphash'
978 enable_debug_siphash = true
980 message('unknown debug option "@0@", ignoring'.format(name))
983 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
984 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
985 conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash)
987 conf.set10('VALGRIND', get_option('valgrind'))
988 conf.set10('LOG_TRACE', get_option('log-trace'))
990 default_user_path = get_option('user-path')
991 if default_user_path != ''
992 conf.set_quoted('DEFAULT_USER_PATH', default_user_path)
996 #####################################################################
998 threads = dependency('threads')
999 librt = cc.find_library('rt')
1000 libm = cc.find_library('m')
1001 libdl = cc.find_library('dl')
1002 libcrypt = cc.find_library('crypt')
1004 crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
1006 ['crypt_ra', crypt_header],
1007 ['crypt_preferred_method', crypt_header],
1008 ['crypt_gensalt_ra', crypt_header]]
1010 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
1011 dependencies : libcrypt)
1012 conf.set10('HAVE_' + ident[0].to_upper(), have)
1015 libcap = dependency('libcap', required : false)
1016 if not libcap.found()
1017 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
1018 libcap = cc.find_library('cap')
1021 want_bpf_framework = get_option('bpf-framework')
1022 bpf_framework_required = want_bpf_framework == 'true'
1024 libbpf = dependency('libbpf', required : bpf_framework_required, version : '>= 0.2')
1025 conf.set10('HAVE_LIBBPF', libbpf.found())
1027 if want_bpf_framework == 'false' or not libbpf.found() or skip_deps
1028 conf.set10('BPF_FRAMEWORK', false)
1030 bpf_compiler = get_option('bpf-compiler')
1032 clang_supports_bpf = false
1033 bpf_gcc_found = false
1036 if bpf_compiler == 'clang'
1037 # Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu
1038 # (like clang-10/llvm-strip-10)
1039 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')
1040 r = find_program('clang', required : bpf_framework_required, version : '>= 10.0.0')
1041 clang_found = r.found()
1045 # Assume that the required flags are supported by the found clang.
1046 clang_supports_flags = clang_found
1049 clang = cc.cmd_array()
1050 clang_supports_flags = cc.has_argument('-Wno-compare-distinct-pointer-types')
1054 # Check if 'clang -target bpf' is supported.
1055 clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0
1057 elif bpf_compiler == 'gcc'
1058 warning('GCC BPF Compiler support is experimental and not recommended.')
1059 bpf_gcc = find_program('bpf-gcc',
1061 version : '>= 12.1.0')
1062 bpf_gcc_found = bpf_gcc.found()
1065 if clang_supports_bpf or bpf_gcc_found
1066 # Debian installs this in /usr/sbin/ which is not in $PATH.
1067 # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian.
1068 # We use 'bpftool gen object' subcommand for bpftool strip, it was added by d80b2fcbe0a023619e0fc73112f2a02c2662f6ab (v5.13).
1069 bpftool = find_program('bpftool',
1070 '/usr/sbin/bpftool',
1072 version : '>= 5.13.0')
1075 bpftool_strip = true
1078 bpftool_strip = false
1079 # We require the 'bpftool gen skeleton' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6).
1080 bpftool = find_program('bpftool',
1081 '/usr/sbin/bpftool',
1082 required : bpf_framework_required,
1083 version : '>= 5.6.0')
1086 # We use `llvm-strip` as a fallback if `bpftool gen object` strip support is not available.
1087 if not bpftool_strip and bpftool.found() and clang_supports_bpf
1088 if not meson.is_cross_build()
1089 llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip',
1090 check : true).stdout().strip()
1092 llvm_strip_bin = 'llvm-strip'
1094 llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0')
1095 deps_found = llvm_strip.found()
1099 # Can build BPF program from source code in restricted C
1100 conf.set10('BPF_FRAMEWORK', deps_found)
1103 libmount = dependency('mount',
1104 version : fuzzer_build ? '>= 0' : '>= 2.30')
1106 want_libfdisk = get_option('fdisk')
1107 if want_libfdisk != 'false' and not skip_deps
1108 libfdisk = dependency('fdisk',
1109 version : '>= 2.32',
1110 required : want_libfdisk == 'true')
1111 have = libfdisk.found()
1116 conf.set10('HAVE_LIBFDISK', have)
1118 want_pwquality = get_option('pwquality')
1119 if want_pwquality != 'false' and not skip_deps
1120 libpwquality = dependency('pwquality', required : want_pwquality == 'true')
1121 have = libpwquality.found()
1126 conf.set10('HAVE_PWQUALITY', have)
1128 want_seccomp = get_option('seccomp')
1129 if want_seccomp != 'false' and not skip_deps
1130 libseccomp = dependency('libseccomp',
1131 version : '>= 2.3.1',
1132 required : want_seccomp == 'true')
1133 have = libseccomp.found()
1138 conf.set10('HAVE_SECCOMP', have)
1140 want_selinux = get_option('selinux')
1141 if want_selinux != 'false' and not skip_deps
1142 libselinux = dependency('libselinux',
1143 version : '>= 2.1.9',
1144 required : want_selinux == 'true')
1145 have = libselinux.found()
1150 conf.set10('HAVE_SELINUX', have)
1152 want_apparmor = get_option('apparmor')
1153 if want_apparmor != 'false' and not skip_deps
1154 libapparmor = dependency('libapparmor',
1155 version : '>= 2.13',
1156 required : want_apparmor == 'true')
1157 have = libapparmor.found()
1162 conf.set10('HAVE_APPARMOR', have)
1164 have = get_option('smack') and get_option('smack-run-label') != ''
1165 conf.set10('HAVE_SMACK_RUN_LABEL', have)
1167 conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
1170 have = get_option('smack') and get_option('smack-default-process-label') != ''
1172 conf.set_quoted('SMACK_DEFAULT_PROCESS_LABEL', get_option('smack-default-process-label'))
1175 want_polkit = get_option('polkit')
1176 install_polkit = false
1177 install_polkit_pkla = false
1178 if want_polkit != 'false' and not skip_deps
1179 install_polkit = true
1181 libpolkit = dependency('polkit-gobject-1',
1183 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
1184 message('Old polkit detected, will install pkla files')
1185 install_polkit_pkla = true
1188 conf.set10('ENABLE_POLKIT', install_polkit)
1190 want_acl = get_option('acl')
1191 if want_acl != 'false' and not skip_deps
1192 libacl = cc.find_library('acl', required : want_acl == 'true')
1193 have = libacl.found()
1198 conf.set10('HAVE_ACL', have)
1200 want_audit = get_option('audit')
1201 if want_audit != 'false' and not skip_deps
1202 libaudit = dependency('audit', required : want_audit == 'true')
1203 have = libaudit.found()
1208 conf.set10('HAVE_AUDIT', have)
1210 want_blkid = get_option('blkid')
1211 if want_blkid != 'false' and not skip_deps
1212 libblkid = dependency('blkid', required : want_blkid == 'true')
1213 have = libblkid.found()
1215 conf.set10('HAVE_BLKID_PROBE_SET_HINT',
1216 have and cc.has_function('blkid_probe_set_hint', dependencies : libblkid))
1221 conf.set10('HAVE_BLKID', have)
1223 want_kmod = get_option('kmod')
1224 if want_kmod != 'false' and not skip_deps
1225 libkmod = dependency('libkmod',
1227 required : want_kmod == 'true')
1228 have = libkmod.found()
1233 conf.set10('HAVE_KMOD', have)
1235 want_pam = get_option('pam')
1236 if want_pam != 'false' and not skip_deps
1237 libpam = cc.find_library('pam', required : want_pam == 'true')
1238 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1239 have = libpam.found() and libpam_misc.found()
1245 conf.set10('HAVE_PAM', have)
1247 want_microhttpd = get_option('microhttpd')
1248 if want_microhttpd != 'false' and not skip_deps
1249 libmicrohttpd = dependency('libmicrohttpd',
1250 version : '>= 0.9.33',
1251 required : want_microhttpd == 'true')
1252 have = libmicrohttpd.found()
1257 conf.set10('HAVE_MICROHTTPD', have)
1259 want_libcryptsetup = get_option('libcryptsetup')
1260 want_libcryptsetup_plugins = get_option('libcryptsetup-plugins')
1262 if want_libcryptsetup_plugins == 'true' and want_libcryptsetup == 'false'
1263 error('libcryptsetup-plugins can not be requested without libcryptsetup')
1266 if want_libcryptsetup != 'false' and not skip_deps
1267 libcryptsetup = dependency('libcryptsetup',
1268 version : want_libcryptsetup_plugins == 'true' ? '>= 2.4.0' : '>= 2.0.1',
1269 required : want_libcryptsetup == 'true' or want_libcryptsetup_plugins == 'true')
1270 have = libcryptsetup.found()
1272 foreach ident : ['crypt_set_metadata_size',
1273 'crypt_activate_by_signed_key',
1275 have_ident = have and cc.has_function(
1277 prefix : '#include <libcryptsetup.h>',
1278 dependencies : libcryptsetup)
1279 conf.set10('HAVE_' + ident.to_upper(), have_ident)
1285 conf.set10('HAVE_LIBCRYPTSETUP', have)
1287 if want_libcryptsetup_plugins != 'false' and not skip_deps
1288 have = (cc.has_function(
1289 'crypt_activate_by_token_pin',
1290 prefix : '#include <libcryptsetup.h>',
1291 dependencies : libcryptsetup) and
1293 'crypt_token_external_path',
1294 prefix : '#include <libcryptsetup.h>',
1295 dependencies : libcryptsetup))
1299 conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have)
1301 want_libcurl = get_option('libcurl')
1302 if want_libcurl != 'false' and not skip_deps
1303 libcurl = dependency('libcurl',
1304 version : '>= 7.32.0',
1305 required : want_libcurl == 'true')
1306 have = libcurl.found()
1311 conf.set10('HAVE_LIBCURL', have)
1312 conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
1314 want_libidn = get_option('libidn')
1315 want_libidn2 = get_option('libidn2')
1316 if want_libidn == 'true' and want_libidn2 == 'true'
1317 error('libidn and libidn2 cannot be requested simultaneously')
1320 if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps
1321 libidn = dependency('libidn2',
1322 required : want_libidn2 == 'true')
1323 have = libidn.found()
1328 conf.set10('HAVE_LIBIDN2', have)
1329 if not have and want_libidn != 'false' and not skip_deps
1330 # libidn is used for both libidn and libidn2 objects
1331 libidn = dependency('libidn',
1332 required : want_libidn == 'true')
1333 have = libidn.found()
1337 conf.set10('HAVE_LIBIDN', have)
1339 want_libiptc = get_option('libiptc')
1340 if want_libiptc != 'false' and not skip_deps
1341 libiptc = dependency('libiptc',
1342 required : want_libiptc == 'true')
1343 have = libiptc.found()
1348 conf.set10('HAVE_LIBIPTC', have)
1350 want_qrencode = get_option('qrencode')
1351 if want_qrencode != 'false' and not skip_deps
1352 libqrencode = dependency('libqrencode',
1354 required : want_qrencode == 'true')
1355 have = libqrencode.found()
1360 conf.set10('HAVE_QRENCODE', have)
1362 want_gcrypt = get_option('gcrypt')
1363 if want_gcrypt != 'false' and not skip_deps
1364 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1365 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1366 have = libgcrypt.found() and libgpg_error.found()
1371 # link to neither of the libs if one is not found
1375 conf.set10('HAVE_GCRYPT', have)
1377 want_gnutls = get_option('gnutls')
1378 if want_gnutls != 'false' and not skip_deps
1379 libgnutls = dependency('gnutls',
1380 version : '>= 3.1.4',
1381 required : want_gnutls == 'true')
1382 have = libgnutls.found()
1387 conf.set10('HAVE_GNUTLS', have)
1389 want_openssl = get_option('openssl')
1390 if want_openssl != 'false' and not skip_deps
1391 libopenssl = dependency('openssl',
1392 version : '>= 1.1.0',
1393 required : want_openssl == 'true')
1394 have = libopenssl.found()
1399 conf.set10('HAVE_OPENSSL', have)
1401 want_p11kit = get_option('p11kit')
1402 if want_p11kit != 'false' and not skip_deps
1403 libp11kit = dependency('p11-kit-1',
1404 version : '>= 0.23.3',
1405 required : want_p11kit == 'true')
1406 have = libp11kit.found()
1411 conf.set10('HAVE_P11KIT', have)
1413 want_libfido2 = get_option('libfido2')
1414 if want_libfido2 != 'false' and not skip_deps
1415 libfido2 = dependency('libfido2',
1416 required : want_libfido2 == 'true')
1417 have = libfido2.found()
1422 conf.set10('HAVE_LIBFIDO2', have)
1424 want_tpm2 = get_option('tpm2')
1425 if want_tpm2 != 'false' and not skip_deps
1426 tpm2 = dependency('tss2-esys tss2-rc tss2-mu',
1427 required : want_tpm2 == 'true')
1433 conf.set10('HAVE_TPM2', have)
1435 want_elfutils = get_option('elfutils')
1436 if want_elfutils != 'false' and not skip_deps
1437 libdw = dependency('libdw',
1438 required : want_elfutils == 'true')
1439 have = libdw.found()
1441 # New in elfutils 0.177
1442 conf.set10('HAVE_DWELF_ELF_E_MACHINE_STRING',
1443 have and cc.has_function('dwelf_elf_e_machine_string', dependencies : libdw))
1448 conf.set10('HAVE_ELFUTILS', have)
1450 want_zlib = get_option('zlib')
1451 if want_zlib != 'false' and not skip_deps
1452 libz = dependency('zlib',
1453 required : want_zlib == 'true')
1459 conf.set10('HAVE_ZLIB', have)
1461 want_bzip2 = get_option('bzip2')
1462 if want_bzip2 != 'false' and not skip_deps
1463 libbzip2 = cc.find_library('bz2',
1464 required : want_bzip2 == 'true')
1465 have = libbzip2.found()
1470 conf.set10('HAVE_BZIP2', have)
1472 want_xz = get_option('xz')
1473 if want_xz != 'false' and not skip_deps
1474 libxz = dependency('liblzma',
1475 required : want_xz == 'true')
1476 have_xz = libxz.found()
1481 conf.set10('HAVE_XZ', have_xz)
1483 want_lz4 = get_option('lz4')
1484 if want_lz4 != 'false' and not skip_deps
1485 liblz4 = dependency('liblz4',
1486 version : '>= 1.3.0',
1487 required : want_lz4 == 'true')
1488 have_lz4 = liblz4.found()
1493 conf.set10('HAVE_LZ4', have_lz4)
1495 want_zstd = get_option('zstd')
1496 if want_zstd != 'false' and not skip_deps
1497 libzstd = dependency('libzstd',
1498 required : want_zstd == 'true',
1499 version : '>= 1.4.0')
1500 have_zstd = libzstd.found()
1505 conf.set10('HAVE_ZSTD', have_zstd)
1507 conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
1509 compression = get_option('default-compression')
1510 if compression == 'auto'
1512 compression = 'zstd'
1518 compression = 'none'
1520 elif compression == 'zstd' and not have_zstd
1521 error('default-compression=zstd requires zstd')
1522 elif compression == 'lz4' and not have_lz4
1523 error('default-compression=lz4 requires lz4')
1524 elif compression == 'xz' and not have_xz
1525 error('default-compression=xz requires xz')
1527 conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper()))
1529 want_xkbcommon = get_option('xkbcommon')
1530 if want_xkbcommon != 'false' and not skip_deps
1531 libxkbcommon = dependency('xkbcommon',
1532 version : '>= 0.3.0',
1533 required : want_xkbcommon == 'true')
1534 have = libxkbcommon.found()
1539 conf.set10('HAVE_XKBCOMMON', have)
1541 want_pcre2 = get_option('pcre2')
1542 if want_pcre2 != 'false' and not skip_deps
1543 libpcre2 = dependency('libpcre2-8',
1544 required : want_pcre2 == 'true')
1545 have = libpcre2.found()
1550 conf.set10('HAVE_PCRE2', have)
1552 want_glib = get_option('glib')
1553 if want_glib != 'false' and not skip_deps
1554 libglib = dependency('glib-2.0',
1555 version : '>= 2.22.0',
1556 required : want_glib == 'true')
1557 libgobject = dependency('gobject-2.0',
1558 version : '>= 2.22.0',
1559 required : want_glib == 'true')
1560 libgio = dependency('gio-2.0',
1561 required : want_glib == 'true')
1562 have = libglib.found() and libgobject.found() and libgio.found()
1569 conf.set10('HAVE_GLIB', have)
1571 want_dbus = get_option('dbus')
1572 if want_dbus != 'false' and not skip_deps
1573 libdbus = dependency('dbus-1',
1574 version : '>= 1.3.2',
1575 required : want_dbus == 'true')
1576 have = libdbus.found()
1581 conf.set10('HAVE_DBUS', have)
1583 dbusdatadir = datadir / 'dbus-1'
1584 if conf.get('HAVE_DBUS') == 1
1585 dbusdatadir = libdbus.get_variable(pkgconfig: 'datadir', default_value: datadir) / 'dbus-1'
1588 dbuspolicydir = get_option('dbuspolicydir')
1589 if dbuspolicydir == ''
1590 dbuspolicydir = dbusdatadir / 'system.d'
1593 dbussessionservicedir = get_option('dbussessionservicedir')
1594 if dbussessionservicedir == ''
1595 dbussessionservicedir = dbusdatadir / 'services'
1596 if conf.get('HAVE_DBUS') == 1
1597 dbussessionservicedir = libdbus.get_variable(pkgconfig: 'session_bus_services_dir', default_value: dbussessionservicedir)
1601 dbussystemservicedir = get_option('dbussystemservicedir')
1602 if dbussystemservicedir == ''
1603 dbussystemservicedir = dbusdatadir / 'system-services'
1604 if conf.get('HAVE_DBUS') == 1
1605 dbussystemservicedir = libdbus.get_variable(pkgconfig: 'system_bus_services_dir', default_value: dbussystemservicedir)
1609 dbus_interfaces_dir = get_option('dbus-interfaces-dir')
1610 if dbus_interfaces_dir == '' or dbus_interfaces_dir == 'yes'
1611 if meson.is_cross_build() and dbus_interfaces_dir != 'yes'
1612 dbus_interfaces_dir = 'no'
1613 warning('Exporting D-Bus interface XML files is disabled during cross build. Pass path or "yes" to force enable.')
1615 dbus_interfaces_dir = dbusdatadir / 'interfaces'
1616 if conf.get('HAVE_DBUS') == 1
1617 dbus_interfaces_dir = libdbus.get_variable(pkgconfig: 'interfaces_dir', default_value: dbus_interfaces_dir)
1622 # We support one or the other. If gcrypt is available, we assume it's there to
1623 # be used, and use it in preference.
1624 opt = get_option('cryptolib')
1625 if opt == 'openssl' and conf.get('HAVE_OPENSSL') == 0
1626 error('openssl requested as the default cryptolib, but not available')
1628 conf.set10('PREFER_OPENSSL',
1629 opt == 'openssl' or (opt == 'auto' and conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_GCRYPT') == 0))
1630 conf.set10('HAVE_OPENSSL_OR_GCRYPT',
1631 conf.get('HAVE_OPENSSL') == 1 or conf.get('HAVE_GCRYPT') == 1)
1632 lib_openssl_or_gcrypt = conf.get('PREFER_OPENSSL') == 1 ? [libopenssl] : [libgcrypt, libgpg_error]
1634 dns_over_tls = get_option('dns-over-tls')
1635 if dns_over_tls != 'false'
1636 if dns_over_tls == 'gnutls' and conf.get('PREFER_OPENSSL') == 1
1637 error('Sorry, -Ddns-over-tls=gnutls is not supported when openssl is used as the cryptolib')
1640 if dns_over_tls == 'gnutls'
1641 have_openssl = false
1643 have_openssl = conf.get('HAVE_OPENSSL') == 1
1644 if dns_over_tls == 'openssl' and not have_openssl
1645 error('DNS-over-TLS support was requested with openssl, but dependencies are not available')
1648 if dns_over_tls == 'openssl' or have_openssl
1651 have_gnutls = conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0')
1652 if dns_over_tls != 'auto' and not have_gnutls
1653 str = dns_over_tls == 'gnutls' ? ' with gnutls' : ''
1654 error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
1657 have = have_gnutls or have_openssl
1661 have_openssl = false
1663 conf.set10('ENABLE_DNS_OVER_TLS', have)
1664 conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1665 conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
1667 default_dns_over_tls = get_option('default-dns-over-tls')
1669 default_dns_over_tls = 'no'
1671 if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
1672 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.')
1673 default_dns_over_tls = 'no'
1675 conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1676 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
1677 conf.set_quoted('DEFAULT_DNS_OVER_TLS_MODE_STR', default_dns_over_tls)
1679 default_mdns = get_option('default-mdns')
1680 conf.set('DEFAULT_MDNS_MODE',
1681 'RESOLVE_SUPPORT_' + default_mdns.to_upper())
1682 conf.set_quoted('DEFAULT_MDNS_MODE_STR', default_mdns)
1684 default_llmnr = get_option('default-llmnr')
1685 conf.set('DEFAULT_LLMNR_MODE',
1686 'RESOLVE_SUPPORT_' + default_llmnr.to_upper())
1687 conf.set_quoted('DEFAULT_LLMNR_MODE_STR', default_llmnr)
1689 want_repart = get_option('repart')
1690 if want_repart != 'false'
1691 have = conf.get('HAVE_LIBFDISK') == 1
1692 if want_repart == 'true' and not have
1693 error('repart support was requested, but dependencies are not available')
1698 conf.set10('ENABLE_REPART', have)
1700 default_dnssec = get_option('default-dnssec')
1702 default_dnssec = 'no'
1704 if default_dnssec != 'no' and conf.get('HAVE_OPENSSL_OR_GCRYPT') == 0
1705 message('default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.')
1706 default_dnssec = 'no'
1708 conf.set('DEFAULT_DNSSEC_MODE',
1709 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1710 conf.set_quoted('DEFAULT_DNSSEC_MODE_STR', default_dnssec)
1712 want_sysupdate = get_option('sysupdate')
1713 if want_sysupdate != 'false'
1714 have = (conf.get('HAVE_OPENSSL') == 1 and
1715 conf.get('HAVE_LIBFDISK') == 1)
1716 if want_sysupdate == 'true' and not have
1717 error('sysupdate support was requested, but dependencies are not available')
1722 conf.set10('ENABLE_SYSUPDATE', have)
1724 want_importd = get_option('importd')
1725 if want_importd != 'false'
1726 have = (conf.get('HAVE_LIBCURL') == 1 and
1727 conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and
1728 conf.get('HAVE_ZLIB') == 1 and
1729 conf.get('HAVE_XZ') == 1)
1730 if want_importd == 'true' and not have
1731 error('importd support was requested, but dependencies are not available')
1736 conf.set10('ENABLE_IMPORTD', have)
1738 want_kernel_install = get_option('kernel-install')
1739 conf.set10('ENABLE_KERNEL_INSTALL', want_kernel_install)
1741 want_homed = get_option('homed')
1742 if want_homed != 'false'
1743 have = (conf.get('HAVE_OPENSSL') == 1 and
1744 conf.get('HAVE_LIBFDISK') == 1 and
1745 conf.get('HAVE_LIBCRYPTSETUP') == 1)
1746 if want_homed == 'true' and not have
1747 error('homed support was requested, but dependencies are not available')
1752 conf.set10('ENABLE_HOMED', have)
1754 have = have and conf.get('HAVE_PAM') == 1
1755 conf.set10('ENABLE_PAM_HOME', have)
1757 have = get_option('oomd')
1758 conf.set10('ENABLE_OOMD', have)
1760 want_remote = get_option('remote')
1761 if want_remote != 'false'
1762 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1763 conf.get('HAVE_LIBCURL') == 1]
1764 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1765 # it's possible to build one without the other. Complain only if
1766 # support was explicitly requested. The auxiliary files like sysusers
1767 # config should be installed when any of the programs are built.
1768 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1769 error('remote support was requested, but dependencies are not available')
1771 have = have_deps[0] or have_deps[1]
1775 conf.set10('ENABLE_REMOTE', have)
1777 foreach term : ['analyze',
1791 'compat-mutable-uid-boundaries',
1817 have = get_option(term)
1818 name = 'ENABLE_' + term.underscorify().to_upper()
1819 conf.set10(name, have)
1822 enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
1824 foreach tuple : [['nss-mymachines', 'machined'],
1825 ['nss-resolve', 'resolve']]
1826 want = get_option(tuple[0])
1828 have = get_option(tuple[1])
1829 if want == 'true' and not have
1830 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1835 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1836 conf.set10(name, have)
1840 foreach term : ['ENABLE_NSS_MYHOSTNAME',
1841 'ENABLE_NSS_MYMACHINES',
1842 'ENABLE_NSS_RESOLVE',
1843 'ENABLE_NSS_SYSTEMD']
1844 if conf.get(term) == 1
1848 conf.set10('ENABLE_NSS', enable_nss)
1850 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1852 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1854 ############################################################
1860 ############################################################
1862 # Include these now as they provide gnu-efi detection.
1863 subdir('src/fundamental')
1864 subdir('src/boot/efi')
1866 ############################################################
1868 generate_gperfs = find_program('tools/generate-gperfs.py')
1869 make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
1870 make_directive_index_py = find_program('tools/make-directive-index.py')
1871 make_man_index_py = find_program('tools/make-man-index.py')
1872 meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
1873 update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
1874 update_man_rules_py = find_program('tools/update-man-rules.py')
1875 update_hwdb_sh = find_program('tools/update-hwdb.sh')
1876 update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
1877 update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
1878 xml_helper_py = find_program('tools/xml_helper.py')
1879 export_dbus_interfaces_py = find_program('tools/dbus_exporter.py')
1881 ############################################################
1883 if get_option('b_coverage')
1884 add_project_arguments('-include', 'src/basic/coverage.h', language : 'c')
1887 ############################################################
1889 config_h = configure_file(
1890 output : 'config.h',
1891 configuration : conf)
1893 add_project_arguments('-include', 'config.h', language : 'c')
1895 jinja2_cmdline = [meson_render_jinja2, config_h, version_h]
1897 ############################################################
1899 # binaries that have --help and are intended for use by humans,
1900 # usually, but not always, installed in /bin.
1901 public_programs = []
1903 # D-Bus introspection XML export
1906 basic_includes = include_directories(
1912 libsystemd_includes = [basic_includes, include_directories(
1913 'src/libsystemd/sd-bus',
1914 'src/libsystemd/sd-device',
1915 'src/libsystemd/sd-event',
1916 'src/libsystemd/sd-hwdb',
1917 'src/libsystemd/sd-id128',
1918 'src/libsystemd/sd-journal',
1919 'src/libsystemd/sd-netlink',
1920 'src/libsystemd/sd-network',
1921 'src/libsystemd/sd-resolve')]
1923 includes = [libsystemd_includes, include_directories('src/shared')]
1928 subdir('src/libsystemd')
1929 subdir('src/shared')
1931 subdir('src/libudev')
1932 subdir('src/cryptsetup/cryptsetup-tokens')
1934 alias_target('devel', libsystemd_pc, libudev_pc)
1936 libsystemd = shared_library(
1938 version : libsystemd_version,
1939 include_directories : libsystemd_includes,
1940 link_args : ['-shared',
1941 '-Wl,--version-script=' + libsystemd_sym_path],
1942 link_with : [libbasic,
1945 link_whole : [libsystemd_static],
1946 dependencies : [threads,
1948 link_depends : libsystemd_sym,
1950 install_tag: 'libsystemd',
1951 install_dir : rootlibdir)
1953 alias_target('libsystemd', libsystemd)
1955 install_libsystemd_static = static_library(
1959 basic_gcrypt_sources,
1960 basic_compress_sources,
1961 fundamental_sources,
1962 include_directories : libsystemd_includes,
1963 build_by_default : static_libsystemd != 'false',
1964 install : static_libsystemd != 'false',
1965 install_tag: 'libsystemd',
1966 install_dir : rootlibdir,
1967 pic : static_libsystemd_pic,
1968 dependencies : [threads,
1979 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
1981 libudev = shared_library(
1983 version : libudev_version,
1984 include_directories : includes,
1985 link_args : ['-shared',
1986 '-Wl,--version-script=' + libudev_sym_path],
1987 link_with : [libsystemd_static, libshared_static],
1988 link_whole : libudev_basic,
1989 dependencies : [threads],
1990 link_depends : libudev_sym,
1992 install_tag: 'libudev',
1993 install_dir : rootlibdir)
1995 alias_target('libudev', libudev)
1997 install_libudev_static = static_library(
2000 fundamental_sources,
2004 include_directories : includes,
2005 build_by_default : static_libudev != 'false',
2006 install : static_libudev != 'false',
2007 install_tag: 'libudev',
2008 install_dir : rootlibdir,
2009 link_depends : libudev_sym,
2010 dependencies : libshared_deps + [libmount],
2011 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
2012 pic : static_libudev_pic)
2014 if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
2015 if conf.get('HAVE_TPM2') == 1
2016 cryptsetup_token_systemd_tpm2 = shared_library(
2017 'cryptsetup-token-systemd-tpm2',
2018 cryptsetup_token_systemd_tpm2_sources,
2019 include_directories : includes,
2020 link_args : ['-shared',
2021 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2022 link_with : [lib_cryptsetup_token_common,
2024 dependencies : [libcryptsetup,
2027 link_depends : cryptsetup_token_sym,
2028 install_rpath : rootpkglibdir,
2030 install_dir : libcryptsetup_plugins_dir)
2033 if conf.get('HAVE_LIBFIDO2') == 1
2034 cryptsetup_token_systemd_fido2 = shared_library(
2035 'cryptsetup-token-systemd-fido2',
2036 cryptsetup_token_systemd_fido2_sources,
2037 include_directories : includes,
2038 link_args : ['-shared',
2039 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2040 link_with : [lib_cryptsetup_token_common,
2042 dependencies : [libcryptsetup,
2045 link_depends : cryptsetup_token_sym,
2046 install_rpath : rootpkglibdir,
2048 install_dir : libcryptsetup_plugins_dir)
2051 if conf.get('HAVE_P11KIT') == 1
2052 cryptsetup_token_systemd_pkcs11 = shared_library(
2053 'cryptsetup-token-systemd-pkcs11',
2054 cryptsetup_token_systemd_pkcs11_sources,
2055 include_directories : includes,
2056 link_args : ['-shared',
2057 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2058 link_with : [lib_cryptsetup_token_common,
2060 dependencies : [libcryptsetup,
2063 link_depends : cryptsetup_token_sym,
2064 install_rpath : rootpkglibdir,
2066 install_dir : libcryptsetup_plugins_dir)
2070 ############################################################
2072 # systemd-analyze requires 'libcore'
2074 # systemd-journal-remote requires 'libjournal_core'
2075 subdir('src/journal')
2076 # systemd-networkd requires 'libsystemd_network'
2077 subdir('src/libsystemd-network')
2079 subdir('src/analyze')
2080 subdir('src/busctl')
2081 subdir('src/coredump')
2082 subdir('src/cryptenroll')
2083 subdir('src/cryptsetup')
2085 subdir('src/hostname')
2086 subdir('src/import')
2087 subdir('src/journal-remote')
2088 subdir('src/kernel-install')
2089 subdir('src/locale')
2091 subdir('src/machine')
2092 subdir('src/network')
2093 subdir('src/nspawn')
2095 subdir('src/partition')
2096 subdir('src/portable')
2097 subdir('src/pstore')
2098 subdir('src/resolve')
2100 subdir('src/shutdown')
2101 subdir('src/sysext')
2102 subdir('src/systemctl')
2103 subdir('src/sysupdate')
2104 subdir('src/timedate')
2105 subdir('src/timesync')
2106 subdir('src/tmpfiles')
2107 subdir('src/userdb')
2108 subdir('src/xdg-autostart-generator')
2110 subdir('src/systemd')
2117 ############################################################
2119 # only static linking apart from libdl, to make sure that the
2120 # module is linked to all libraries that it uses.
2121 test_dlopen = executable(
2124 include_directories : includes,
2125 link_with : [libbasic],
2126 dependencies : [libdl],
2127 build_by_default : want_tests != 'false')
2129 foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
2130 ['systemd', 'ENABLE_NSS_SYSTEMD', ['nss-systemd.h', 'userdb-glue.c', 'userdb-glue.h']],
2131 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
2132 ['resolve', 'ENABLE_NSS_RESOLVE', [], resolve_includes]]
2134 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
2138 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
2139 version_script_arg = project_source_root / sym
2141 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
2142 if tuple.length() > 2
2143 foreach s : tuple[2]
2144 sources += ['src/nss-@0@/@1@'.format(module, s)]
2148 incs = tuple.length() > 3 ? tuple[3] : includes
2150 nss = shared_library(
2154 include_directories : incs,
2155 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
2156 link_args : ['-Wl,-z,nodelete',
2158 '-Wl,--version-script=' + version_script_arg],
2159 link_with : [libsystemd_static,
2162 dependencies : [threads,
2166 install_tag : 'nss',
2167 install_dir : rootlibdir)
2169 # We cannot use shared_module because it does not support version suffix.
2170 # Unfortunately shared_library insists on creating the symlink…
2171 meson.add_install_script('sh', '-c',
2172 'rm $DESTDIR@0@/libnss_@1@.so'
2173 .format(rootlibdir, module),
2177 if want_tests != 'false'
2178 test('dlopen-nss_' + module,
2180 # path to dlopen must include a slash
2181 args : nss.full_path(),
2187 ############################################################
2192 include_directories : includes,
2193 link_with : [libcore,
2195 dependencies : [versiondep,
2197 install_rpath : rootpkglibdir,
2199 install_dir : rootlibexecdir)
2200 dbus_programs += exe
2201 public_programs += exe
2203 meson.add_install_script(meson_make_symlink,
2204 rootlibexecdir / 'systemd',
2205 rootsbindir / 'init')
2209 systemd_analyze_sources,
2210 include_directories : core_includes,
2211 link_with : [libcore,
2213 dependencies : [versiondep,
2215 install_rpath : rootpkglibdir,
2216 install : conf.get('ENABLE_ANALYZE'))
2217 public_programs += exe
2219 if want_tests != 'false'
2220 test('test-compare-versions',
2221 test_compare_versions_sh,
2222 args : exe.full_path())
2227 systemd_journald_sources,
2228 include_directories : includes,
2229 link_with : [libjournal_core,
2231 dependencies : [threads,
2236 install_rpath : rootpkglibdir,
2238 install_dir : rootlibexecdir)
2240 public_programs += executable(
2242 systemd_cat_sources,
2243 include_directories : includes,
2244 link_with : [libjournal_core,
2246 dependencies : [threads],
2247 install_rpath : rootpkglibdir,
2250 public_programs += executable(
2253 include_directories : includes,
2254 link_with : [libshared],
2255 dependencies : [threads,
2261 install_rpath : rootpkglibdir,
2263 install_dir : rootbindir)
2266 'systemd-getty-generator',
2267 'src/getty-generator/getty-generator.c',
2268 include_directories : includes,
2269 link_with : [libshared],
2270 install_rpath : rootpkglibdir,
2272 install_dir : systemgeneratordir)
2275 'systemd-debug-generator',
2276 'src/debug-generator/debug-generator.c',
2277 include_directories : includes,
2278 link_with : [libshared],
2279 install_rpath : rootpkglibdir,
2281 install_dir : systemgeneratordir)
2284 'systemd-run-generator',
2285 'src/run-generator/run-generator.c',
2286 include_directories : includes,
2287 link_with : [libshared],
2288 install_rpath : rootpkglibdir,
2290 install_dir : systemgeneratordir)
2293 'systemd-fstab-generator',
2294 'src/fstab-generator/fstab-generator.c',
2295 include_directories : includes,
2296 link_with : [libshared],
2297 install_rpath : rootpkglibdir,
2299 install_dir : systemgeneratordir)
2301 if want_tests != 'false'
2302 test('test-fstab-generator',
2303 test_fstab_generator_sh,
2304 # https://github.com/mesonbuild/meson/issues/2681
2305 args : exe.full_path(),
2309 if conf.get('ENABLE_ENVIRONMENT_D') == 1
2311 '30-systemd-environment-d-generator',
2312 'src/environment-d-generator/environment-d-generator.c',
2313 include_directories : includes,
2314 link_with : [libshared],
2315 install_rpath : rootpkglibdir,
2317 install_dir : userenvgeneratordir)
2319 meson.add_install_script(meson_make_symlink,
2320 sysconfdir / 'environment',
2321 environmentdir / '99-environment.conf')
2324 if conf.get('ENABLE_HIBERNATE') == 1
2326 'systemd-hibernate-resume-generator',
2327 'src/hibernate-resume/hibernate-resume-generator.c',
2328 include_directories : includes,
2329 link_with : [libshared],
2330 install_rpath : rootpkglibdir,
2332 install_dir : systemgeneratordir)
2335 'systemd-hibernate-resume',
2336 'src/hibernate-resume/hibernate-resume.c',
2337 include_directories : includes,
2338 link_with : [libshared],
2339 install_rpath : rootpkglibdir,
2341 install_dir : rootlibexecdir)
2344 if conf.get('HAVE_BLKID') == 1
2346 'systemd-gpt-auto-generator',
2347 'src/gpt-auto-generator/gpt-auto-generator.c',
2348 include_directories : includes,
2349 link_with : [libshared],
2350 dependencies : libblkid,
2351 install_rpath : rootpkglibdir,
2353 install_dir : systemgeneratordir)
2355 public_programs += executable(
2357 'src/dissect/dissect.c',
2358 include_directories : includes,
2359 link_with : [libshared],
2360 install_rpath : rootpkglibdir,
2364 if conf.get('ENABLE_RESOLVE') == 1
2365 dbus_programs += executable(
2367 systemd_resolved_sources,
2368 include_directories : resolve_includes,
2369 link_with : [libshared,
2371 libsystemd_resolve_core],
2372 dependencies : systemd_resolved_dependencies,
2373 install_rpath : rootpkglibdir,
2375 install_dir : rootlibexecdir)
2377 public_programs += executable(
2380 include_directories : includes,
2381 link_with : [libshared,
2383 libsystemd_resolve_core],
2384 dependencies : [threads,
2385 lib_openssl_or_gcrypt,
2388 install_rpath : rootpkglibdir,
2391 meson.add_install_script(meson_make_symlink,
2392 bindir / 'resolvectl',
2393 rootsbindir / 'resolvconf')
2395 meson.add_install_script(meson_make_symlink,
2396 bindir / 'resolvectl',
2397 bindir / 'systemd-resolve')
2400 if conf.get('ENABLE_LOGIND') == 1
2401 dbus_programs += executable(
2403 systemd_logind_sources,
2404 include_directories : includes,
2405 link_with : [liblogind_core,
2407 dependencies : [threads,
2409 install_rpath : rootpkglibdir,
2411 install_dir : rootlibexecdir)
2413 public_programs += executable(
2416 include_directories : includes,
2417 link_with : [libshared],
2418 dependencies : [threads,
2422 install_rpath : rootpkglibdir,
2424 install_dir : rootbindir)
2426 public_programs += executable(
2428 'src/login/inhibit.c',
2429 include_directories : includes,
2430 link_with : [libshared],
2431 install_rpath : rootpkglibdir,
2433 install_dir : rootbindir)
2435 if conf.get('HAVE_PAM') == 1
2436 version_script_arg = project_source_root / pam_systemd_sym
2437 pam_systemd = shared_library(
2441 include_directories : includes,
2442 link_args : ['-shared',
2443 '-Wl,--version-script=' + version_script_arg],
2444 link_with : [libsystemd_static,
2446 dependencies : [threads,
2449 link_depends : pam_systemd_sym,
2451 install_tag : 'pam',
2452 install_dir : pamlibdir)
2454 if want_tests != 'false'
2455 test('dlopen-pam_systemd',
2457 # path to dlopen must include a slash
2458 args : pam_systemd.full_path(),
2459 depends : pam_systemd)
2464 'systemd-user-runtime-dir',
2465 user_runtime_dir_sources,
2466 include_directories : includes,
2467 link_with : [libshared],
2468 install_rpath : rootpkglibdir,
2470 install_dir : rootlibexecdir)
2473 if conf.get('HAVE_PAM') == 1
2475 'systemd-user-sessions',
2476 'src/user-sessions/user-sessions.c',
2477 include_directories : includes,
2478 link_with : [libshared],
2479 install_rpath : rootpkglibdir,
2481 install_dir : rootlibexecdir)
2484 if conf.get('HAVE_BLKID') == 1 and conf.get('HAVE_GNU_EFI') == 1
2485 if get_option('link-boot-shared')
2486 boot_link_with = [libshared]
2488 boot_link_with = [libsystemd_static, libshared_static]
2491 public_programs += executable(
2493 'src/boot/bootctl.c',
2494 include_directories : includes,
2495 link_with : [boot_link_with],
2496 dependencies : [libblkid],
2497 install_rpath : rootpkglibdir,
2500 public_programs += executable(
2501 'systemd-bless-boot',
2502 'src/boot/bless-boot.c',
2503 include_directories : includes,
2504 link_with : [boot_link_with],
2505 dependencies : [libblkid],
2506 install_rpath : rootpkglibdir,
2508 install_dir : rootlibexecdir)
2511 'systemd-bless-boot-generator',
2512 'src/boot/bless-boot-generator.c',
2513 include_directories : includes,
2514 link_with : [boot_link_with],
2515 install_rpath : rootpkglibdir,
2517 install_dir : systemgeneratordir)
2521 'systemd-boot-check-no-failures',
2522 'src/boot/boot-check-no-failures.c',
2523 include_directories : includes,
2524 link_with : [libshared],
2525 dependencies : [libblkid],
2526 install_rpath : rootpkglibdir,
2528 install_dir : rootlibexecdir)
2530 public_programs += executable(
2531 'systemd-socket-activate',
2532 'src/activate/activate.c',
2533 include_directories : includes,
2534 link_with : [libshared],
2535 dependencies : [threads],
2536 install_rpath : rootpkglibdir,
2539 systemctl = executable(
2542 include_directories : includes,
2543 link_with : systemctl_link_with,
2544 dependencies : [threads,
2550 install_rpath : rootpkglibdir,
2552 install_dir : rootbindir)
2553 public_programs += systemctl
2555 if conf.get('ENABLE_PORTABLED') == 1
2556 dbus_programs += executable(
2557 'systemd-portabled',
2558 systemd_portabled_sources,
2559 include_directories : includes,
2560 link_with : [libshared],
2561 dependencies : [threads, libselinux],
2562 install_rpath : rootpkglibdir,
2564 install_dir : rootlibexecdir)
2566 public_programs += executable(
2568 'src/portable/portablectl.c',
2569 include_directories : includes,
2570 link_with : [libshared],
2571 dependencies : [threads],
2572 install_rpath : rootpkglibdir,
2574 install_dir : rootbindir)
2577 if conf.get('ENABLE_SYSEXT') == 1
2578 public_programs += executable(
2580 systemd_sysext_sources,
2581 include_directories : includes,
2582 link_with : [libshared],
2583 install_rpath : rootpkglibdir,
2585 install_dir : rootbindir)
2588 if conf.get('ENABLE_USERDB') == 1
2591 systemd_userwork_sources,
2592 include_directories : includes,
2593 link_with : [libshared],
2594 dependencies : [threads],
2595 install_rpath : rootpkglibdir,
2597 install_dir : rootlibexecdir)
2601 systemd_userdbd_sources,
2602 include_directories : includes,
2603 link_with : [libshared],
2604 dependencies : [threads],
2605 install_rpath : rootpkglibdir,
2607 install_dir : rootlibexecdir)
2609 public_programs += executable(
2612 include_directories : includes,
2613 link_with : [libshared],
2614 dependencies : [threads],
2615 install_rpath : rootpkglibdir,
2619 if conf.get('ENABLE_HOMED') == 1
2622 systemd_homework_sources,
2623 include_directories : includes,
2624 link_with : [libshared],
2625 dependencies : [threads,
2631 install_rpath : rootpkglibdir,
2633 install_dir : rootlibexecdir)
2635 dbus_programs += executable(
2637 systemd_homed_sources,
2638 include_directories : home_includes,
2639 link_with : [libshared],
2640 dependencies : [threads,
2644 install_rpath : rootpkglibdir,
2646 install_dir : rootlibexecdir)
2648 public_programs += executable(
2651 include_directories : includes,
2652 link_with : [libshared],
2653 dependencies : [threads,
2658 install_rpath : rootpkglibdir,
2661 if conf.get('HAVE_PAM') == 1
2662 version_script_arg = project_source_root / pam_systemd_home_sym
2663 pam_systemd_home = shared_library(
2667 include_directories : includes,
2668 link_args : ['-shared',
2669 '-Wl,--version-script=' + version_script_arg],
2670 link_with : [libsystemd_static,
2672 dependencies : [threads,
2676 link_depends : pam_systemd_home_sym,
2678 install_tag : 'pam',
2679 install_dir : pamlibdir)
2681 if want_tests != 'false'
2682 test('dlopen-pam_systemd_home',
2684 # path to dlopen must include a slash
2685 args : pam_systemd_home.full_path(),
2686 depends : pam_systemd_home)
2691 foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
2692 (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
2693 meson.add_install_script(meson_make_symlink,
2694 rootbindir / 'systemctl',
2695 rootsbindir / alias)
2698 meson.add_install_script(meson_make_symlink,
2699 rootbindir / 'udevadm',
2700 rootlibexecdir / 'systemd-udevd')
2702 if conf.get('ENABLE_BACKLIGHT') == 1
2704 'systemd-backlight',
2705 'src/backlight/backlight.c',
2706 include_directories : includes,
2707 link_with : [libshared],
2708 install_rpath : rootpkglibdir,
2710 install_dir : rootlibexecdir)
2713 if conf.get('ENABLE_RFKILL') == 1
2716 'src/rfkill/rfkill.c',
2717 include_directories : includes,
2718 link_with : [libshared],
2719 install_rpath : rootpkglibdir,
2721 install_dir : rootlibexecdir)
2725 'systemd-system-update-generator',
2726 'src/system-update-generator/system-update-generator.c',
2727 include_directories : includes,
2728 link_with : [libshared],
2729 install_rpath : rootpkglibdir,
2731 install_dir : systemgeneratordir)
2733 if conf.get('HAVE_LIBCRYPTSETUP') == 1
2735 'systemd-cryptsetup',
2736 systemd_cryptsetup_sources,
2737 include_directories : includes,
2738 link_with : [libshared],
2739 dependencies : [libcryptsetup,
2741 install_rpath : rootpkglibdir,
2743 install_dir : rootlibexecdir)
2746 'systemd-cryptsetup-generator',
2747 'src/cryptsetup/cryptsetup-generator.c',
2748 include_directories : includes,
2749 link_with : [libshared],
2750 install_rpath : rootpkglibdir,
2752 install_dir : systemgeneratordir)
2755 'systemd-veritysetup',
2756 'src/veritysetup/veritysetup.c',
2757 include_directories : includes,
2758 link_with : [libshared],
2759 dependencies : [libcryptsetup],
2760 install_rpath : rootpkglibdir,
2762 install_dir : rootlibexecdir)
2765 'systemd-veritysetup-generator',
2766 'src/veritysetup/veritysetup-generator.c',
2767 include_directories : includes,
2768 link_with : [libshared],
2769 install_rpath : rootpkglibdir,
2771 install_dir : systemgeneratordir)
2773 public_programs += executable(
2774 'systemd-cryptenroll',
2775 systemd_cryptenroll_sources,
2776 include_directories : includes,
2777 link_with : [libshared],
2778 dependencies : [libcryptsetup,
2782 install_rpath : rootpkglibdir,
2786 'systemd-integritysetup',
2787 ['src/integritysetup/integritysetup.c', 'src/integritysetup/integrity-util.c'],
2788 include_directories : includes,
2789 link_with : [libshared],
2790 dependencies : [libcryptsetup],
2791 install_rpath : rootpkglibdir,
2793 install_dir : rootlibexecdir)
2796 'systemd-integritysetup-generator',
2797 ['src/integritysetup/integritysetup-generator.c', 'src/integritysetup/integrity-util.c'],
2798 include_directories : includes,
2799 link_with : [libshared],
2800 install_rpath : rootpkglibdir,
2802 install_dir : systemgeneratordir)
2805 if conf.get('HAVE_SYSV_COMPAT') == 1
2807 'systemd-sysv-generator',
2808 'src/sysv-generator/sysv-generator.c',
2809 include_directories : includes,
2810 link_with : [libshared],
2811 install_rpath : rootpkglibdir,
2813 install_dir : systemgeneratordir)
2815 sysv_generator_test_py = find_program('test/sysv-generator-test.py')
2816 if want_tests != 'false'
2817 test('sysv-generator-test',
2818 sysv_generator_test_py,
2823 'systemd-rc-local-generator',
2824 'src/rc-local-generator/rc-local-generator.c',
2825 include_directories : includes,
2826 link_with : [libshared],
2827 install_rpath : rootpkglibdir,
2829 install_dir : systemgeneratordir)
2832 if conf.get('ENABLE_XDG_AUTOSTART') == 1
2834 'systemd-xdg-autostart-generator',
2835 systemd_xdg_autostart_generator_sources,
2836 include_directories : includes,
2837 link_with : [libshared],
2838 install_rpath : rootpkglibdir,
2840 install_dir : usergeneratordir)
2843 'systemd-xdg-autostart-condition',
2844 'src/xdg-autostart-generator/xdg-autostart-condition.c',
2845 include_directories : includes,
2846 link_with : [libshared],
2847 install_rpath : rootpkglibdir,
2849 install_dir : rootlibexecdir)
2852 if conf.get('ENABLE_HOSTNAMED') == 1
2853 dbus_programs += executable(
2854 'systemd-hostnamed',
2855 'src/hostname/hostnamed.c',
2856 include_directories : includes,
2857 link_with : [libshared],
2858 install_rpath : rootpkglibdir,
2860 install_dir : rootlibexecdir)
2862 public_programs += executable(
2864 'src/hostname/hostnamectl.c',
2865 include_directories : includes,
2866 link_with : [libshared],
2867 install_rpath : rootpkglibdir,
2871 if conf.get('ENABLE_LOCALED') == 1
2872 if conf.get('HAVE_XKBCOMMON') == 1
2873 # logind will load libxkbcommon.so dynamically on its own, but we still
2874 # need to specify where the headers are
2875 deps = [libdl, libxkbcommon.partial_dependency(compile_args: true)]
2880 dbus_programs += executable(
2882 systemd_localed_sources,
2883 include_directories : includes,
2884 link_with : [libshared],
2885 dependencies : deps,
2886 install_rpath : rootpkglibdir,
2888 install_dir : rootlibexecdir)
2890 public_programs += executable(
2893 include_directories : includes,
2894 link_with : [libshared],
2895 install_rpath : rootpkglibdir,
2899 if conf.get('ENABLE_TIMEDATED') == 1
2900 dbus_programs += executable(
2901 'systemd-timedated',
2902 'src/timedate/timedated.c',
2903 include_directories : includes,
2904 link_with : [libshared],
2905 install_rpath : rootpkglibdir,
2907 install_dir : rootlibexecdir)
2910 if conf.get('ENABLE_TIMEDATECTL') == 1
2911 public_programs += executable(
2913 'src/timedate/timedatectl.c',
2914 include_directories : includes,
2915 install_rpath : rootpkglibdir,
2916 link_with : [libshared],
2917 dependencies : [libm],
2921 if conf.get('ENABLE_TIMESYNCD') == 1
2923 'systemd-timesyncd',
2924 systemd_timesyncd_sources,
2925 include_directories : includes,
2926 link_with : [libtimesyncd_core],
2927 dependencies : [threads,
2929 install_rpath : rootpkglibdir,
2931 install_dir : rootlibexecdir)
2934 'systemd-time-wait-sync',
2935 'src/timesync/wait-sync.c',
2936 include_directories : includes,
2937 link_with : [libtimesyncd_core],
2938 install_rpath : rootpkglibdir,
2940 install_dir : rootlibexecdir)
2943 if conf.get('ENABLE_MACHINED') == 1
2944 dbus_programs += executable(
2946 systemd_machined_sources,
2947 include_directories : includes,
2948 link_with : [libmachine_core,
2950 install_rpath : rootpkglibdir,
2952 install_dir : rootlibexecdir)
2954 public_programs += executable(
2956 'src/machine/machinectl.c',
2957 include_directories : includes,
2958 link_with : [libshared],
2959 dependencies : [threads,
2963 install_rpath : rootpkglibdir,
2965 install_dir : rootbindir)
2968 if conf.get('ENABLE_IMPORTD') == 1
2969 dbus_programs += executable(
2971 systemd_importd_sources,
2972 include_directories : includes,
2973 link_with : [libshared],
2974 dependencies : [threads],
2975 install_rpath : rootpkglibdir,
2977 install_dir : rootlibexecdir)
2979 systemd_pull = executable(
2981 systemd_pull_sources,
2982 include_directories : includes,
2983 link_with : [libshared,
2985 dependencies : [versiondep,
2987 lib_openssl_or_gcrypt,
2991 install_rpath : rootpkglibdir,
2993 install_dir : rootlibexecdir)
2995 systemd_import = executable(
2997 systemd_import_sources,
2998 include_directories : includes,
2999 link_with : [libshared,
3001 dependencies : [libcurl,
3005 install_rpath : rootpkglibdir,
3007 install_dir : rootlibexecdir)
3009 systemd_import_fs = executable(
3010 'systemd-import-fs',
3011 systemd_import_fs_sources,
3012 include_directories : includes,
3013 link_with : [libshared,
3015 install_rpath : rootpkglibdir,
3017 install_dir : rootlibexecdir)
3019 systemd_export = executable(
3021 systemd_export_sources,
3022 include_directories : includes,
3023 link_with : [libshared,
3025 dependencies : [libcurl,
3029 install_rpath : rootpkglibdir,
3031 install_dir : rootlibexecdir)
3033 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
3036 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
3037 public_programs += executable(
3038 'systemd-journal-upload',
3039 systemd_journal_upload_sources,
3040 include_directories : includes,
3041 link_with : [libshared],
3042 dependencies : [versiondep,
3049 install_rpath : rootpkglibdir,
3051 install_dir : rootlibexecdir)
3054 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
3055 public_programs += executable(
3056 'systemd-journal-remote',
3057 systemd_journal_remote_sources,
3058 include_directories : journal_includes,
3059 link_with : [libshared,
3060 libsystemd_journal_remote],
3061 dependencies : [threads,
3067 install_rpath : rootpkglibdir,
3069 install_dir : rootlibexecdir)
3071 public_programs += executable(
3072 'systemd-journal-gatewayd',
3073 systemd_journal_gatewayd_sources,
3074 include_directories : journal_includes,
3075 link_with : [libshared],
3076 dependencies : [threads,
3082 install_rpath : rootpkglibdir,
3084 install_dir : rootlibexecdir)
3087 if conf.get('ENABLE_COREDUMP') == 1
3090 systemd_coredump_sources,
3091 include_directories : includes,
3092 link_with : [libshared,
3094 dependencies : [threads,
3099 install_rpath : rootpkglibdir,
3101 install_dir : rootlibexecdir)
3103 public_programs += executable(
3105 coredumpctl_sources,
3106 include_directories : includes,
3107 link_with : [libshared,
3109 dependencies : [threads,
3113 install_rpath : rootpkglibdir,
3117 if conf.get('ENABLE_PSTORE') == 1
3120 systemd_pstore_sources,
3121 include_directories : includes,
3122 link_with : [libshared],
3123 dependencies : [threads,
3128 install_rpath : rootpkglibdir,
3130 install_dir : rootlibexecdir)
3133 if conf.get('ENABLE_OOMD') == 1
3134 dbus_programs += executable('systemd-oomd',
3135 systemd_oomd_sources,
3136 include_directories : includes,
3137 link_with : [libshared],
3139 install_rpath : rootpkglibdir,
3141 install_dir : rootlibexecdir)
3143 public_programs += executable(
3146 include_directories : includes,
3147 link_with : [libshared],
3149 install_rpath : rootpkglibdir,
3153 if conf.get('ENABLE_BINFMT') == 1
3154 public_programs += executable(
3156 'src/binfmt/binfmt.c',
3157 include_directories : includes,
3158 link_with : [libshared],
3159 install_rpath : rootpkglibdir,
3161 install_dir : rootlibexecdir)
3163 meson.add_install_script('sh', '-c',
3164 mkdir_p.format(binfmtdir))
3165 if install_sysconfdir
3166 meson.add_install_script('sh', '-c',
3167 mkdir_p.format(sysconfdir / 'binfmt.d'))
3171 if conf.get('ENABLE_SYSUPDATE') == 1
3173 'systemd-sysupdate',
3174 systemd_sysupdate_sources,
3175 include_directories : includes,
3176 link_with : [libshared],
3177 dependencies : [threads,
3181 install_rpath : rootpkglibdir,
3183 install_dir : rootlibexecdir)
3184 public_programs += exe
3187 if conf.get('ENABLE_VCONSOLE') == 1
3189 'systemd-vconsole-setup',
3190 'src/vconsole/vconsole-setup.c',
3191 include_directories : includes,
3192 link_with : [libshared],
3193 install_rpath : rootpkglibdir,
3195 install_dir : rootlibexecdir)
3198 if conf.get('ENABLE_RANDOMSEED') == 1
3200 'systemd-random-seed',
3201 'src/random-seed/random-seed.c',
3202 include_directories : includes,
3203 link_with : [libshared],
3204 install_rpath : rootpkglibdir,
3206 install_dir : rootlibexecdir)
3209 if conf.get('ENABLE_FIRSTBOOT') == 1
3210 public_programs += executable(
3211 'systemd-firstboot',
3212 'src/firstboot/firstboot.c',
3213 include_directories : includes,
3214 link_with : [libshared],
3215 dependencies : [libcrypt],
3216 install_rpath : rootpkglibdir,
3218 install_dir : rootbindir)
3222 'systemd-remount-fs',
3223 'src/remount-fs/remount-fs.c',
3224 include_directories : includes,
3225 link_with : [libshared],
3226 install_rpath : rootpkglibdir,
3228 install_dir : rootlibexecdir)
3231 'systemd-machine-id-setup',
3232 'src/machine-id-setup/machine-id-setup-main.c',
3233 include_directories : includes,
3234 link_with : [libshared],
3235 install_rpath : rootpkglibdir,
3237 install_dir : rootbindir)
3242 include_directories : includes,
3243 link_with : [libshared],
3244 install_rpath : rootpkglibdir,
3246 install_dir : rootlibexecdir)
3248 executable('systemd-growfs',
3249 'src/partition/growfs.c',
3250 include_directories : includes,
3251 link_with : [libshared],
3252 install_rpath : rootpkglibdir,
3254 install_dir : rootlibexecdir)
3258 'src/partition/makefs.c',
3259 include_directories : includes,
3260 link_with : [libshared],
3261 install_rpath : rootpkglibdir,
3263 install_dir : rootlibexecdir)
3267 'src/sleep/sleep.c',
3268 include_directories : includes,
3269 link_with : [libshared],
3270 install_rpath : rootpkglibdir,
3272 install_dir : rootlibexecdir)
3274 if install_sysconfdir_samples
3275 install_data('src/sleep/sleep.conf',
3276 install_dir : pkgsysconfdir)
3279 public_programs += executable(
3281 'src/sysctl/sysctl.c',
3282 include_directories : includes,
3283 link_with : [libshared],
3284 install_rpath : rootpkglibdir,
3286 install_dir : rootlibexecdir)
3290 'src/ac-power/ac-power.c',
3291 include_directories : includes,
3292 link_with : [libshared],
3293 install_rpath : rootpkglibdir,
3295 install_dir : rootlibexecdir)
3297 public_programs += executable(
3298 'systemd-detect-virt',
3299 'src/detect-virt/detect-virt.c',
3300 include_directories : includes,
3301 link_with : [libshared],
3302 install_rpath : rootpkglibdir,
3305 public_programs += executable(
3307 'src/delta/delta.c',
3308 include_directories : includes,
3309 link_with : [libshared],
3310 install_rpath : rootpkglibdir,
3313 public_programs += executable(
3315 'src/escape/escape.c',
3316 include_directories : includes,
3317 link_with : [libshared],
3318 install_rpath : rootpkglibdir,
3320 install_dir : rootbindir)
3322 public_programs += executable(
3324 'src/notify/notify.c',
3325 include_directories : includes,
3326 link_with : [libshared],
3327 install_rpath : rootpkglibdir,
3329 install_dir : rootbindir)
3331 public_programs += executable(
3333 'src/creds/creds.c',
3334 include_directories : includes,
3335 link_with : [libshared],
3336 dependencies : [threads,
3338 install_rpath : rootpkglibdir,
3340 install_dir : rootbindir)
3343 'systemd-volatile-root',
3344 'src/volatile-root/volatile-root.c',
3345 include_directories : includes,
3346 link_with : [libshared],
3347 install_rpath : rootpkglibdir,
3348 install : conf.get('ENABLE_INITRD') == 1,
3349 install_dir : rootlibexecdir)
3352 'systemd-cgroups-agent',
3353 'src/cgroups-agent/cgroups-agent.c',
3354 include_directories : includes,
3355 link_with : [libshared],
3356 install_rpath : rootpkglibdir,
3358 install_dir : rootlibexecdir)
3360 systemd_id128 = executable(
3362 'src/id128/id128.c',
3363 include_directories : includes,
3364 link_with : [libshared],
3365 install_rpath : rootpkglibdir,
3367 public_programs += systemd_id128
3369 if want_tests != 'false'
3370 test('test-systemctl-enable',
3371 test_systemctl_enable_sh,
3372 # https://github.com/mesonbuild/meson/issues/2681
3373 args : [systemctl.full_path(),
3374 systemd_id128.full_path()])
3377 public_programs += executable(
3380 include_directories : includes,
3381 link_with : [libshared],
3382 install_rpath : rootpkglibdir,
3385 public_programs += executable(
3386 'systemd-ask-password',
3387 'src/ask-password/ask-password.c',
3388 include_directories : includes,
3389 link_with : [libshared],
3390 install_rpath : rootpkglibdir,
3392 install_dir : rootbindir)
3395 'systemd-reply-password',
3396 'src/reply-password/reply-password.c',
3397 include_directories : includes,
3398 link_with : [libshared],
3399 install_rpath : rootpkglibdir,
3401 install_dir : rootlibexecdir)
3403 public_programs += executable(
3404 'systemd-tty-ask-password-agent',
3405 'src/tty-ask-password-agent/tty-ask-password-agent.c',
3406 include_directories : includes,
3407 link_with : [libshared],
3408 install_rpath : rootpkglibdir,
3410 install_dir : rootbindir)
3412 public_programs += executable(
3415 include_directories : includes,
3416 link_with : [libshared],
3417 install_rpath : rootpkglibdir,
3420 public_programs += executable(
3422 'src/cgtop/cgtop.c',
3423 include_directories : includes,
3424 link_with : [libshared],
3425 install_rpath : rootpkglibdir,
3430 'src/initctl/initctl.c',
3431 include_directories : includes,
3432 link_with : [libshared],
3433 install_rpath : rootpkglibdir,
3434 install : (conf.get('HAVE_SYSV_COMPAT') == 1),
3435 install_dir : rootlibexecdir)
3437 public_programs += executable(
3439 'src/mount/mount-tool.c',
3440 include_directories : includes,
3441 link_with : [libshared],
3442 dependencies: [libmount],
3443 install_rpath : rootpkglibdir,
3446 meson.add_install_script(meson_make_symlink,
3447 'systemd-mount', bindir / 'systemd-umount')
3449 public_programs += executable(
3452 include_directories : includes,
3453 link_with : [libshared],
3454 install_rpath : rootpkglibdir,
3457 public_programs += executable(
3458 'systemd-stdio-bridge',
3459 'src/stdio-bridge/stdio-bridge.c',
3460 include_directories : includes,
3461 link_with : [libshared],
3462 dependencies : [versiondep],
3463 install_rpath : rootpkglibdir,
3466 public_programs += executable(
3469 include_directories : includes,
3470 link_with : [libshared],
3471 dependencies : [versiondep],
3472 install_rpath : rootpkglibdir,
3478 'src/sysusers/sysusers.c',
3479 include_directories : includes,
3480 link_with : [libshared],
3481 install_rpath : rootpkglibdir,
3483 install_dir : rootbindir)
3484 public_programs += exe
3486 if want_tests != 'false'
3487 test('test-sysusers',
3489 # https://github.com/mesonbuild/meson/issues/2681
3490 args : exe.full_path())
3493 if have_standalone_binaries
3495 'systemd-sysusers.standalone',
3496 'src/sysusers/sysusers.c',
3497 include_directories : includes,
3498 c_args : '-DSTANDALONE',
3499 link_with : [libshared_static,
3504 install_dir : rootbindir)
3505 public_programs += exe
3507 if want_tests != 'false'
3508 test('test-sysusers.standalone',
3510 # https://github.com/mesonbuild/meson/issues/2681
3511 args : exe.full_path())
3516 if conf.get('ENABLE_TMPFILES') == 1
3519 systemd_tmpfiles_sources,
3520 include_directories : includes,
3521 link_with : [libshared],
3522 dependencies : [libacl],
3523 install_rpath : rootpkglibdir,
3525 install_dir : rootbindir)
3526 public_programs += exe
3528 if want_tests != 'false'
3529 test('test-systemd-tmpfiles',
3530 test_systemd_tmpfiles_py,
3531 # https://github.com/mesonbuild/meson/issues/2681
3532 args : exe.full_path())
3535 if have_standalone_binaries
3537 'systemd-tmpfiles.standalone',
3538 systemd_tmpfiles_sources,
3539 include_directories : includes,
3540 c_args : '-DSTANDALONE',
3541 link_with : [libshared_static,
3545 dependencies : [libacl],
3547 install_dir : rootbindir)
3548 public_programs += exe
3550 if want_tests != 'false'
3551 test('test-systemd-tmpfiles.standalone',
3552 test_systemd_tmpfiles_py,
3553 # https://github.com/mesonbuild/meson/issues/2681
3554 args : exe.full_path())
3559 if conf.get('ENABLE_HWDB') == 1
3560 systemd_hwdb = executable(
3563 include_directories : includes,
3564 link_with : udev_link_with,
3565 install_rpath : udev_rpath,
3567 install_dir : rootbindir)
3568 public_programs += systemd_hwdb
3570 if want_tests != 'false'
3573 suite : 'dist-check',
3574 args : [systemd_hwdb.full_path()],
3579 if conf.get('ENABLE_QUOTACHECK') == 1
3581 'systemd-quotacheck',
3582 'src/quotacheck/quotacheck.c',
3583 include_directories : includes,
3584 link_with : [libshared],
3585 install_rpath : rootpkglibdir,
3587 install_dir : rootlibexecdir)
3590 public_programs += executable(
3591 'systemd-socket-proxyd',
3592 'src/socket-proxy/socket-proxyd.c',
3593 include_directories : includes,
3594 link_with : [libshared],
3595 dependencies : [threads],
3596 install_rpath : rootpkglibdir,
3598 install_dir : rootlibexecdir)
3600 udevadm = executable(
3603 include_directories : includes,
3604 link_with : [libudevd_core],
3605 dependencies : [versiondep,
3611 install_rpath : udev_rpath,
3613 install_dir : rootbindir)
3614 public_programs += udevadm
3616 if conf.get('ENABLE_REPART') == 1
3619 systemd_repart_sources,
3620 include_directories : includes,
3621 link_with : [libshared],
3622 dependencies : [threads,
3625 install_rpath : rootpkglibdir,
3627 install_dir : rootbindir)
3628 public_programs += exe
3630 if want_tests != 'false'
3633 args : [exe.full_path(), udevadm.full_path()])
3639 systemd_shutdown_sources,
3640 include_directories : includes,
3641 link_with : [libshared],
3642 dependencies : [libmount],
3643 install_rpath : rootpkglibdir,
3645 install_dir : rootlibexecdir)
3648 'systemd-update-done',
3649 'src/update-done/update-done.c',
3650 include_directories : includes,
3651 link_with : [libshared],
3652 install_rpath : rootpkglibdir,
3654 install_dir : rootlibexecdir)
3657 'systemd-update-utmp',
3658 'src/update-utmp/update-utmp.c',
3659 include_directories : includes,
3660 link_with : [libshared],
3661 dependencies : [libaudit],
3662 install_rpath : rootpkglibdir,
3663 install : (conf.get('ENABLE_UTMP') == 1),
3664 install_dir : rootlibexecdir)
3666 if conf.get('HAVE_KMOD') == 1
3668 'systemd-modules-load',
3669 'src/modules-load/modules-load.c',
3670 include_directories : includes,
3671 link_with : [libshared],
3672 dependencies : [libkmod],
3673 install_rpath : rootpkglibdir,
3675 install_dir : rootlibexecdir)
3677 meson.add_install_script('sh', '-c',
3678 mkdir_p.format(modulesloaddir))
3679 if install_sysconfdir
3680 meson.add_install_script('sh', '-c',
3681 mkdir_p.format(sysconfdir / 'modules-load.d'))
3685 public_programs += executable(
3687 systemd_nspawn_sources,
3688 include_directories : includes,
3689 link_with : [libnspawn_core,
3691 dependencies : [libblkid,
3693 install_rpath : rootpkglibdir,
3696 if conf.get('ENABLE_NETWORKD') == 1
3697 dbus_programs += executable(
3699 systemd_networkd_sources,
3700 include_directories : network_includes,
3701 link_with : [libnetworkd_core,
3703 networkd_link_with],
3704 dependencies : [threads],
3705 install_rpath : rootpkglibdir,
3707 install_dir : rootlibexecdir)
3709 public_programs += executable(
3710 'systemd-networkd-wait-online',
3711 systemd_networkd_wait_online_sources,
3712 include_directories : includes,
3713 link_with : [networkd_link_with],
3714 install_rpath : rootpkglibdir,
3716 install_dir : rootlibexecdir)
3718 public_programs += executable(
3721 include_directories : libsystemd_network_includes,
3722 link_with : [libsystemd_network,
3723 networkd_link_with],
3724 install_rpath : rootpkglibdir,
3726 install_dir : rootbindir)
3730 'systemd-network-generator',
3731 network_generator_sources,
3732 include_directories : includes,
3733 link_with : [networkd_link_with],
3734 install_rpath : rootpkglibdir,
3736 install_dir : rootlibexecdir)
3738 if want_tests != 'false'
3739 test('test-network-generator-conversion',
3740 test_network_generator_conversion_sh,
3741 # https://github.com/mesonbuild/meson/issues/2681
3742 args : exe.full_path(),
3747 'systemd-sulogin-shell',
3748 'src/sulogin-shell/sulogin-shell.c',
3749 include_directories : includes,
3750 link_with : [libshared],
3751 install_rpath : rootpkglibdir,
3753 install_dir : rootlibexecdir)
3755 exe = custom_target(
3757 input : kernel_install_in,
3758 output : 'kernel-install',
3759 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
3760 install : want_kernel_install,
3761 install_mode : 'rwxr-xr-x',
3762 install_dir : bindir)
3763 public_programs += exe
3765 if want_tests != 'false'
3766 test('test-kernel-install',
3767 test_kernel_install_sh,
3768 args : [exe.full_path(), loaderentry_install])
3771 ############################################################
3773 runtest_env = custom_target(
3774 'systemd-runtest.env',
3775 output : 'systemd-runtest.env',
3776 command : [sh, '-c',
3777 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
3778 project_source_root / 'test',
3779 project_build_root / 'catalog')],
3781 build_by_default : true)
3783 test_cflags = ['-DTEST_CODE=1']
3784 # We intentionally do not do inline initializations with definitions for a
3785 # bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
3786 # use the variable unexpectedly. This triggers a lot of maybe-uninitialized
3787 # false positives when the combination of -O2 and -flto is used. Suppress them.
3788 if '-O2' in c_args and '-flto=auto' in c_args
3789 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
3792 foreach tuple : tests
3794 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3795 dependencies = tuple.length() > 2 ? tuple[2] : []
3796 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3797 condition = tuple.length() > 4 ? tuple[4] : ''
3798 type = tuple.length() > 5 ? tuple[5] : ''
3799 defs = tuple.length() > 6 ? tuple[6] : []
3801 parallel = tuple.length() > 7 ? tuple[7] : true
3804 # FIXME: Use fs.stem() with meson >= 0.54.0
3805 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
3806 if type.startswith('timeout=')
3807 timeout = type.split('=')[1].to_int()
3811 suite = fs.name(fs.parent('@0@'.format(sources[0])))
3812 # FIXME: Use str.replace() with meson >= 0.58.0
3813 suite = suite.split('sd-')[-1]
3815 if condition == '' or conf.get(condition) == 1
3819 include_directories : incs,
3820 link_with : link_with,
3821 dependencies : [versiondep,
3824 build_by_default : want_tests != 'false',
3825 install_rpath : rootpkglibdir,
3826 install : install_tests,
3827 install_dir : testsdir / type,
3828 link_depends : runtest_env)
3831 message('@0@ is a manual test'.format(name))
3832 elif type == 'unsafe' and want_tests != 'unsafe'
3833 message('@0@ is an unsafe test'.format(name))
3834 elif want_tests != 'false'
3841 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
3846 'test-libsystemd-sym',
3847 test_libsystemd_sym_c,
3848 include_directories : includes,
3849 link_with : [libsystemd],
3850 build_by_default : want_tests != 'false',
3851 install : install_tests,
3852 install_dir : testsdir)
3853 if want_tests != 'false'
3854 test('test-libsystemd-sym', exe)
3858 'test-libsystemd-static-sym',
3859 test_libsystemd_sym_c,
3860 include_directories : includes,
3861 link_with : [install_libsystemd_static],
3862 dependencies : [threads], # threads is already included in dependencies on the library,
3863 # but does not seem to get propagated. Add here as a work-around.
3864 build_by_default : want_tests != 'false' and static_libsystemd_pic,
3865 install : install_tests and static_libsystemd_pic,
3866 install_dir : testsdir)
3867 if want_tests != 'false' and static_libsystemd_pic
3868 test('test-libsystemd-static-sym', exe)
3874 include_directories : libudev_includes,
3875 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
3876 link_with : [libudev],
3877 build_by_default : want_tests != 'false',
3878 install : install_tests,
3879 install_dir : testsdir)
3880 if want_tests != 'false'
3881 test('test-libudev-sym', exe)
3885 'test-libudev-static-sym',
3887 include_directories : libudev_includes,
3888 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
3889 link_with : [install_libudev_static],
3890 build_by_default : want_tests != 'false' and static_libudev_pic,
3891 install : install_tests and static_libudev_pic,
3892 install_dir : testsdir)
3893 if want_tests != 'false' and static_libudev_pic
3894 test('test-libudev-static-sym', exe)
3897 ############################################################
3901 foreach tuple : fuzzers
3903 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3904 dependencies = tuple.length() > 2 ? tuple[2] : []
3905 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3906 defs = tuple.length() > 4 ? tuple[4] : []
3910 dependencies += fuzzing_engine
3912 if fuzzing_engine.found()
3913 dependencies += fuzzing_engine
3915 link_args += ['-fsanitize=fuzzer']
3918 sources += 'src/fuzz/fuzz-main.c'
3921 # FIXME: Use fs.stem() with meson >= 0.54.0
3922 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
3927 include_directories : [incs, include_directories('src/fuzz')],
3928 link_with : link_with,
3929 dependencies : dependencies,
3930 c_args : defs + test_cflags,
3931 link_args: link_args,
3933 build_by_default : fuzzer_build)
3936 if want_tests != 'false'
3937 # Run the fuzz regression tests without any sanitizers enabled.
3938 # Additional invocations with sanitizers may be added below.
3939 foreach p : fuzz_regression_tests
3940 b = p.split('/')[-2]
3941 c = p.split('/')[-1]
3944 test('@0@_@1@'.format(b, c),
3947 args : [project_source_root / p])
3953 alias_target('fuzzers', fuzzer_exes)
3955 ############################################################
3957 subdir('modprobe.d')
3959 subdir('sysusers.d')
3960 subdir('tmpfiles.d')
3966 subdir('shell-completion/bash')
3967 subdir('shell-completion/zsh')
3968 subdir('docs/sysvinit')
3969 subdir('docs/var-log')
3971 install_subdir('factory/etc',
3972 install_dir : factorydir)
3973 subdir('factory/templates')
3975 if install_sysconfdir
3976 install_data('xorg/50-systemd-user.sh',
3977 install_dir : xinitrcdir)
3979 install_data('LICENSE.GPL2',
3983 'docs/CODING_STYLE.md',
3984 'docs/DISTRO_PORTING.md',
3985 'docs/ENVIRONMENT.md',
3987 'docs/TRANSIENT-SETTINGS.md',
3988 'docs/TRANSLATORS.md',
3989 'docs/UIDS-GIDS.md',
3990 install_dir : docdir)
3992 install_subdir('LICENSES',
3993 install_dir : docdir)
3995 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
3996 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
3998 ############################################################
4000 # Ensure that changes to the docs/ directory do not break the
4001 # basic Github pages build. But only run it in developer mode,
4002 # as it might be fragile due to changes in the tooling, and it is
4003 # not generally useful for users.
4004 jekyll = find_program('jekyll', required : false)
4005 if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
4006 test('github-pages',
4008 suite : 'dist-check',
4010 '--source', project_source_root / 'docs',
4011 '--destination', project_build_root / '_site'])
4014 ############################################################
4016 check_help = find_program('tools/check-help.sh')
4017 check_version = find_program('tools/check-version.sh')
4019 foreach exec : public_programs
4020 name = exec.full_path().split('/')[-1]
4021 if want_tests != 'false'
4022 test('check-help-' + name,
4024 suite : 'dist-check',
4025 args : exec.full_path(),
4028 test('check-version-' + name,
4030 suite : 'dist-check',
4031 args : [exec.full_path(),
4032 meson.project_version()],
4037 ############################################################
4039 check_directives_sh = find_program('tools/check-directives.sh')
4041 if want_tests != 'false'
4042 test('check-directives',
4043 check_directives_sh,
4044 suite : 'dist-check',
4045 args : [project_source_root, project_build_root])
4048 ############################################################
4050 # Enable tests for all supported sanitizers
4051 foreach tuple : sanitizers
4052 sanitizer = tuple[0]
4055 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
4057 foreach p : fuzz_regression_tests
4058 b = p.split('/')[-2]
4059 c = p.split('/')[-1]
4061 name = '@0@:@1@'.format(b, sanitizer)
4064 if want_tests == 'false'
4065 message('Not compiling @0@ because tests is set to false'.format(name))
4067 exe = custom_target(
4071 command : [ln, '-fs',
4072 build.full_path() / b,
4074 build_by_default : true)
4076 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
4082 test('@0@_@1@_@2@'.format(b, c, sanitizer),
4085 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
4087 args : [exe.full_path(),
4088 project_source_root / p])
4095 ############################################################
4098 all_files = run_command(
4099 env, '-u', 'GIT_WORK_TREE',
4100 git, '--git-dir=@0@/.git'.format(project_source_root),
4101 'ls-files', ':/*.[ch]',
4103 if all_files.returncode() == 0
4104 all_files = files(all_files.stdout().split())
4109 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
4112 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
4117 git_contrib_sh = find_program('tools/git-contrib.sh')
4120 command : [git_contrib_sh])
4124 git_head = run_command(
4125 git, '--git-dir=@0@/.git'.format(project_source_root),
4126 'rev-parse', 'HEAD',
4127 check : false).stdout().strip()
4128 git_head_short = run_command(
4129 git, '--git-dir=@0@/.git'.format(project_source_root),
4130 'rev-parse', '--short=7', 'HEAD',
4131 check : false).stdout().strip()
4135 command : [git, 'archive',
4136 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
4138 '--prefix', 'systemd-@0@/'.format(git_head),
4142 ############################################################
4144 check_api_docs_sh = find_program('tools/check-api-docs.sh')
4147 depends : [man, libsystemd, libudev],
4148 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
4150 alias_target('update-dbus-docs', update_dbus_docs)
4151 alias_target('update-man-rules', update_man_rules)
4153 if not meson.is_cross_build()
4155 'export-dbus-interfaces',
4156 output : fs.name(dbus_interfaces_dir),
4157 install : dbus_interfaces_dir != 'no',
4158 install_dir : fs.parent(dbus_interfaces_dir),
4159 command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
4162 ############################################################
4164 alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
4165 check : true).stdout().strip()
4168 'split /usr' : split_usr,
4169 'split bin-sbin' : split_bin,
4170 'prefix directory' : prefixdir,
4171 'rootprefix directory' : rootprefixdir,
4172 'sysconf directory' : sysconfdir,
4173 'include directory' : includedir,
4174 'lib directory' : libdir,
4175 'rootlib directory' : rootlibdir,
4176 'SysV init scripts' : sysvinit_path,
4177 'SysV rc?.d directories' : sysvrcnd_path,
4178 'PAM modules directory' : pamlibdir,
4179 'PAM configuration directory' : pamconfdir,
4180 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
4181 'RPM macros directory' : rpmmacrosdir,
4182 'modprobe.d directory' : modprobedir,
4183 'D-Bus policy directory' : dbuspolicydir,
4184 'D-Bus session directory' : dbussessionservicedir,
4185 'D-Bus system directory' : dbussystemservicedir,
4186 'D-Bus interfaces directory' : dbus_interfaces_dir,
4187 'bash completions directory' : bashcompletiondir,
4188 'zsh completions directory' : zshcompletiondir,
4189 'private shared lib version tag' : shared_lib_tag,
4190 'extra start script' : get_option('rc-local'),
4191 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
4192 get_option('debug-tty')),
4193 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
4194 conf.get('SYSTEM_ALLOC_UID_MIN')),
4195 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
4196 conf.get('SYSTEM_ALLOC_GID_MIN')),
4197 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
4198 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
4199 'static UID/GID allocations' : ' '.join(static_ugids),
4200 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
4201 'render group access mode' : get_option('group-render-mode'),
4202 'certificate root directory' : get_option('certificate-root'),
4203 'support URL' : support_url,
4204 'nobody user name' : nobody_user,
4205 'nobody group name' : nobody_group,
4206 'fallback hostname' : get_option('fallback-hostname'),
4207 'default compression method' : compression,
4208 'default DNSSEC mode' : default_dnssec,
4209 'default DNS-over-TLS mode' : default_dns_over_tls,
4210 'default mDNS mode' : default_mdns,
4211 'default LLMNR mode' : default_llmnr,
4212 'default DNS servers' : dns_servers.split(' '),
4213 'default NTP servers' : ntp_servers.split(' '),
4214 'default cgroup hierarchy' : default_hierarchy,
4215 'default net.naming-scheme value' : default_net_naming_scheme,
4216 'default KillUserProcesses value' : kill_user_processes,
4217 'default locale' : default_locale,
4218 'default nspawn locale' : nspawn_locale,
4219 'default status unit format' : status_unit_format_default,
4220 'default user $PATH' :
4221 default_user_path != '' ? default_user_path : '(same as system services)',
4222 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
4223 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
4226 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
4227 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
4228 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
4249 ['libcryptsetup-plugins'],
4275 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
4305 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
4319 ['legacy-pkla', install_polkit_pkla],
4324 ['man pages', want_man],
4325 ['html pages', want_html],
4326 ['man page indices', want_man and have_lxml],
4328 ['compat-mutable-uid-boundaries'],
4331 ['adm group', get_option('adm-group')],
4332 ['wheel group', get_option('wheel-group')],
4335 ['debug mmap cache'],
4337 ['valgrind', conf.get('VALGRIND') == 1],
4338 ['trace logging', conf.get('LOG_TRACE') == 1],
4339 ['install tests', install_tests],
4340 ['link-udev-shared', get_option('link-udev-shared')],
4341 ['link-systemctl-shared', get_option('link-systemctl-shared')],
4342 ['link-networkd-shared', get_option('link-networkd-shared')],
4343 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
4344 ['link-boot-shared', get_option('link-boot-shared')],
4345 ['first-boot-full-preset'],
4347 ['standalone-binaries', get_option('standalone-binaries')],
4348 ['coverage', get_option('b_coverage')],
4351 if tuple.length() >= 2
4354 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
4355 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
4356 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
4365 if static_libsystemd == 'false'
4366 missing += 'static-libsystemd'
4368 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
4371 if static_libudev == 'false'
4372 missing += 'static-libudev'
4374 found += 'static-libudev(@0@)'.format(static_libudev)
4377 if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
4378 found += 'cryptolib(openssl)'
4379 elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
4380 found += 'cryptolib(gcrypt)'
4382 missing += 'cryptolib'
4385 if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
4386 found += 'DNS-over-TLS(gnutls)'
4387 elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
4388 found += 'DNS-over-TLS(openssl)'
4390 missing += 'DNS-over-TLS'
4394 'enabled' : ', '.join(found),
4395 'disabled' : ', '.join(missing)},
4396 section : 'Features')
4398 if rootprefixdir != rootprefix_default
4400 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
4401 'systemd used fixed names for unit file directories and other paths, so anything\n' +
4402 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))