1 # SPDX-License-Identifier: LGPL-2.1-or-later
3 project('systemd', 'c',
13 meson_version : '>= 0.53.2',
16 libsystemd_version = '0.32.0'
17 libudev_version = '1.7.2'
19 conf = configuration_data()
20 conf.set_quoted('PROJECT_URL', 'https://www.freedesktop.org/wiki/Software/systemd')
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),
30 project_source_root).stdout().strip()
31 conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)
33 conf.set10('BUILD_MODE_DEVELOPER', get_option('mode') == 'developer',
34 description : 'tailor build to development or release builds')
36 want_ossfuzz = get_option('oss-fuzz')
37 want_libfuzzer = get_option('llvm-fuzz')
38 if want_ossfuzz + want_libfuzzer > 1
39 error('only one of oss-fuzz or llvm-fuzz can be specified')
42 skip_deps = want_ossfuzz or want_libfuzzer
43 fuzzer_build = want_ossfuzz or want_libfuzzer
45 #####################################################################
47 # Try to install the git pre-commit hook
48 add_git_hook_sh = find_program('tools/add-git-hook.sh', required : false)
49 if add_git_hook_sh.found()
50 git_hook = run_command(add_git_hook_sh)
51 if git_hook.returncode() == 0
52 message(git_hook.stdout().strip())
56 #####################################################################
58 if get_option('split-usr') == 'auto'
59 split_usr = run_command('test', '-L', '/bin').returncode() != 0
61 split_usr = get_option('split-usr') == 'true'
64 warning('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n\n'
65 + ' split-usr mode is going to be removed\n' +
66 '\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
68 conf.set10('HAVE_SPLIT_USR', split_usr,
69 description : '/usr/bin and /bin directories are separate')
71 if get_option('split-bin') == 'auto'
72 split_bin = run_command('test', '-L', '/usr/sbin').returncode() != 0
74 split_bin = get_option('split-bin') == 'true'
76 conf.set10('HAVE_SPLIT_BIN', split_bin,
77 description : 'bin and sbin directories are separate')
79 rootprefixdir = get_option('rootprefix')
80 # Unusual rootprefixdir values are used by some distros
81 # (see https://github.com/systemd/systemd/pull/7461).
82 rootprefix_default = split_usr ? '/' : '/usr'
83 if rootprefixdir == ''
84 rootprefixdir = rootprefix_default
86 rootprefixdir_noslash = rootprefixdir == '/' ? '' : rootprefixdir
88 have_standalone_binaries = get_option('standalone-binaries')
90 sysvinit_path = get_option('sysvinit-path')
91 sysvrcnd_path = get_option('sysvrcnd-path')
92 conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '',
93 description : 'SysV init scripts and rcN.d links are supported')
94 conf.set10('CREATE_LOG_DIRS', get_option('create-log-dirs'))
96 if get_option('hibernate') and not get_option('initrd')
97 error('hibernate depends on initrd')
100 conf.set10('BUMP_PROC_SYS_FS_FILE_MAX', get_option('bump-proc-sys-fs-file-max'))
101 conf.set10('BUMP_PROC_SYS_FS_NR_OPEN', get_option('bump-proc-sys-fs-nr-open'))
102 conf.set('HIGH_RLIMIT_NOFILE', 512*1024)
104 # Meson ignores the preceding arguments when joining paths if an absolute
105 # component is encountered, so this should canonicalize various paths when they
106 # are absolute or relative.
107 prefixdir = get_option('prefix')
108 if not prefixdir.startswith('/')
109 error('Prefix is not absolute: "@0@"'.format(prefixdir))
111 if prefixdir != rootprefixdir and rootprefixdir != '/' and not prefixdir.strip('/').startswith(rootprefixdir.strip('/') + '/')
112 error('Prefix is not below root prefix (now rootprefix=@0@ prefix=@1@)'.format(
113 rootprefixdir, prefixdir))
116 bindir = prefixdir / get_option('bindir')
117 libdir = prefixdir / get_option('libdir')
118 sysconfdir = prefixdir / get_option('sysconfdir')
119 includedir = prefixdir / get_option('includedir')
120 datadir = prefixdir / get_option('datadir')
121 localstatedir = '/' / get_option('localstatedir')
123 rootbindir = rootprefixdir / 'bin'
124 rootsbindir = rootprefixdir / (split_bin ? 'sbin' : 'bin')
125 rootlibexecdir = rootprefixdir / 'lib/systemd'
127 rootlibdir = get_option('rootlibdir')
129 rootlibdir = rootprefixdir / libdir.split('/')[-1]
132 install_sysconfdir = get_option('install-sysconfdir') != 'false'
133 install_sysconfdir_samples = get_option('install-sysconfdir') == 'true'
134 # Dirs of external packages
135 pkgconfigdatadir = get_option('pkgconfigdatadir') != '' ? get_option('pkgconfigdatadir') : datadir / 'pkgconfig'
136 pkgconfiglibdir = get_option('pkgconfiglibdir') != '' ? get_option('pkgconfiglibdir') : libdir / 'pkgconfig'
137 polkitpolicydir = datadir / 'polkit-1/actions'
138 polkitrulesdir = datadir / 'polkit-1/rules.d'
139 polkitpkladir = localstatedir / 'lib/polkit-1/localauthority/10-vendor.d'
140 xinitrcdir = get_option('xinitrcdir') != '' ? get_option('xinitrcdir') : sysconfdir / 'X11/xinit/xinitrc.d'
141 rpmmacrosdir = get_option('rpmmacrosdir')
142 if rpmmacrosdir != 'no'
143 rpmmacrosdir = prefixdir / rpmmacrosdir
145 modprobedir = rootprefixdir / 'lib/modprobe.d'
148 pkgdatadir = datadir / 'systemd'
149 environmentdir = prefixdir / 'lib/environment.d'
150 pkgsysconfdir = sysconfdir / 'systemd'
151 userunitdir = prefixdir / 'lib/systemd/user'
152 userpresetdir = prefixdir / 'lib/systemd/user-preset'
153 tmpfilesdir = prefixdir / 'lib/tmpfiles.d'
154 sysusersdir = prefixdir / 'lib/sysusers.d'
155 sysctldir = prefixdir / 'lib/sysctl.d'
156 binfmtdir = prefixdir / 'lib/binfmt.d'
157 modulesloaddir = prefixdir / 'lib/modules-load.d'
158 networkdir = rootprefixdir / 'lib/systemd/network'
159 pkgincludedir = includedir / 'systemd'
160 systemgeneratordir = rootlibexecdir / 'system-generators'
161 usergeneratordir = prefixdir / 'lib/systemd/user-generators'
162 systemenvgeneratordir = prefixdir / 'lib/systemd/system-environment-generators'
163 userenvgeneratordir = prefixdir / 'lib/systemd/user-environment-generators'
164 systemshutdowndir = rootlibexecdir / 'system-shutdown'
165 systemsleepdir = rootlibexecdir / 'system-sleep'
166 systemunitdir = rootprefixdir / 'lib/systemd/system'
167 systempresetdir = rootprefixdir / 'lib/systemd/system-preset'
168 udevlibexecdir = rootprefixdir / 'lib/udev'
169 udevrulesdir = udevlibexecdir / 'rules.d'
170 udevhwdbdir = udevlibexecdir / 'hwdb.d'
171 catalogdir = prefixdir / 'lib/systemd/catalog'
172 kernelinstalldir = prefixdir / 'lib/kernel/install.d'
173 factorydir = datadir / 'factory'
174 bootlibdir = prefixdir / 'lib/systemd/boot/efi'
175 testsdir = prefixdir / 'lib/systemd/tests'
176 systemdstatedir = localstatedir / 'lib/systemd'
177 catalogstatedir = systemdstatedir / 'catalog'
178 randomseeddir = localstatedir / 'lib/systemd'
179 profiledir = rootlibexecdir / 'portable' / 'profile'
180 ntpservicelistdir = rootprefixdir / 'lib/systemd/ntp-units.d'
182 docdir = get_option('docdir')
184 docdir = datadir / 'doc/systemd'
187 dbuspolicydir = get_option('dbuspolicydir')
188 if dbuspolicydir == ''
189 dbuspolicydir = datadir / 'dbus-1/system.d'
192 dbussessionservicedir = get_option('dbussessionservicedir')
193 if dbussessionservicedir == ''
194 dbussessionservicedir = datadir / 'dbus-1/services'
197 dbussystemservicedir = get_option('dbussystemservicedir')
198 if dbussystemservicedir == ''
199 dbussystemservicedir = datadir / 'dbus-1/system-services'
202 pamlibdir = get_option('pamlibdir')
204 pamlibdir = rootlibdir / 'security'
207 pamconfdir = get_option('pamconfdir')
209 pamconfdir = prefixdir / 'lib/pam.d'
212 libcryptsetup_plugins_dir = get_option('libcryptsetup-plugins-dir')
213 if libcryptsetup_plugins_dir == ''
214 libcryptsetup_plugins_dir = rootlibdir / 'cryptsetup'
217 memory_accounting_default = get_option('memory-accounting-default')
218 status_unit_format_default = get_option('status-unit-format-default')
220 conf.set_quoted('BINFMT_DIR', binfmtdir)
221 conf.set_quoted('BOOTLIBDIR', bootlibdir)
222 conf.set_quoted('CATALOG_DATABASE', catalogstatedir / 'database')
223 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
224 conf.set_quoted('DOC_DIR', docdir)
225 conf.set_quoted('DOCUMENT_ROOT', pkgdatadir / 'gatewayd')
226 conf.set_quoted('ENVIRONMENT_DIR', environmentdir)
227 conf.set_quoted('INCLUDE_DIR', includedir)
228 conf.set_quoted('LIBDIR', libdir)
229 conf.set_quoted('MODPROBE_DIR', modprobedir)
230 conf.set_quoted('MODULESLOAD_DIR', modulesloaddir)
231 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
232 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', bindir / 'pkttyagent')
233 conf.set_quoted('PREFIX', prefixdir)
234 conf.set_quoted('RANDOM_SEED', randomseeddir / 'random-seed')
235 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
236 conf.set_quoted('RC_LOCAL_PATH', get_option('rc-local'))
237 conf.set_quoted('ROOTBINDIR', rootbindir)
238 conf.set_quoted('ROOTLIBDIR', rootlibdir)
239 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
240 conf.set_quoted('ROOTPREFIX', rootprefixdir)
241 conf.set_quoted('ROOTPREFIX_NOSLASH', rootprefixdir_noslash)
242 conf.set_quoted('SYSCONF_DIR', sysconfdir)
243 conf.set_quoted('SYSCTL_DIR', sysctldir)
244 conf.set_quoted('SYSTEMCTL_BINARY_PATH', rootbindir / 'systemctl')
245 conf.set_quoted('SYSTEMD_BINARY_PATH', rootlibexecdir / 'systemd')
246 conf.set_quoted('SYSTEMD_CATALOG_DIR', catalogdir)
247 conf.set_quoted('SYSTEMD_CGROUPS_AGENT_PATH', rootlibexecdir / 'systemd-cgroups-agent')
248 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', rootlibexecdir / 'systemd-cryptsetup')
249 conf.set_quoted('SYSTEMD_EXPORT_PATH', rootlibexecdir / 'systemd-export')
250 conf.set_quoted('SYSTEMD_FSCK_PATH', rootlibexecdir / 'systemd-fsck')
251 conf.set_quoted('SYSTEMD_GROWFS_PATH', rootlibexecdir / 'systemd-growfs')
252 conf.set_quoted('SYSTEMD_HOMEWORK_PATH', rootlibexecdir / 'systemd-homework')
253 conf.set_quoted('SYSTEMD_IMPORT_FS_PATH', rootlibexecdir / 'systemd-import-fs')
254 conf.set_quoted('SYSTEMD_IMPORT_PATH', rootlibexecdir / 'systemd-import')
255 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', pkgdatadir / 'kbd-model-map')
256 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', pkgdatadir / 'language-fallback-map')
257 conf.set_quoted('SYSTEMD_MAKEFS_PATH', rootlibexecdir / 'systemd-makefs')
258 conf.set_quoted('SYSTEMD_PULL_PATH', rootlibexecdir / 'systemd-pull')
259 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', rootlibexecdir / 'systemd-shutdown')
260 conf.set_quoted('SYSTEMD_STDIO_BRIDGE_BINARY_PATH', bindir / 'systemd-stdio-bridge')
261 conf.set_quoted('SYSTEMD_TEST_DATA', testsdir / 'testdata')
262 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', rootbindir / 'systemd-tty-ask-password-agent')
263 conf.set_quoted('SYSTEMD_UPDATE_HELPER_PATH', rootlibexecdir / 'systemd-update-helper')
264 conf.set_quoted('SYSTEMD_USERWORK_PATH', rootlibexecdir / 'systemd-userwork')
265 conf.set_quoted('SYSTEMD_VERITYSETUP_PATH', rootlibexecdir / 'systemd-veritysetup')
266 conf.set_quoted('SYSTEM_CONFIG_UNIT_DIR', pkgsysconfdir / 'system')
267 conf.set_quoted('SYSTEM_DATA_UNIT_DIR', systemunitdir)
268 conf.set_quoted('SYSTEM_ENV_GENERATOR_DIR', systemenvgeneratordir)
269 conf.set_quoted('SYSTEM_GENERATOR_DIR', systemgeneratordir)
270 conf.set_quoted('SYSTEM_PRESET_DIR', systempresetdir)
271 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
272 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
273 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
274 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
275 conf.set_quoted('SYSUSERS_DIR', sysusersdir)
276 conf.set_quoted('TMPFILES_DIR', tmpfilesdir)
277 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
278 conf.set_quoted('UDEV_HWDB_DIR', udevhwdbdir)
279 conf.set_quoted('UDEV_RULES_DIR', udevrulesdir)
280 conf.set_quoted('UPDATE_HELPER_USER_TIMEOUT', get_option('update-helper-user-timeout'))
281 conf.set_quoted('USER_CONFIG_UNIT_DIR', pkgsysconfdir / 'user')
282 conf.set_quoted('USER_DATA_UNIT_DIR', userunitdir)
283 conf.set_quoted('USER_ENV_GENERATOR_DIR', userenvgeneratordir)
284 conf.set_quoted('USER_GENERATOR_DIR', usergeneratordir)
285 conf.set_quoted('USER_KEYRING_PATH', pkgsysconfdir / 'import-pubring.gpg')
286 conf.set_quoted('USER_PRESET_DIR', userpresetdir)
287 conf.set_quoted('VENDOR_KEYRING_PATH', rootlibexecdir / 'import-pubring.gpg')
289 conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
290 conf.set10('ENABLE_URLIFY', get_option('urlify'))
291 conf.set10('ENABLE_FEXECVE', get_option('fexecve'))
292 conf.set10('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default)
293 conf.set('STATUS_UNIT_FORMAT_DEFAULT', 'STATUS_UNIT_FORMAT_' + status_unit_format_default.to_upper())
294 conf.set_quoted('STATUS_UNIT_FORMAT_DEFAULT_STR', status_unit_format_default)
296 #####################################################################
298 cc = meson.get_compiler('c')
299 pkgconfig = import('pkgconfig')
300 check_compilation_sh = find_program('tools/check-compilation.sh')
301 meson_build_sh = find_program('tools/meson-build.sh')
303 want_tests = get_option('tests')
304 slow_tests = want_tests != 'false' and get_option('slow-tests')
305 fuzz_tests = want_tests != 'false' and get_option('fuzz-tests')
306 install_tests = get_option('install-tests')
308 if add_languages('cpp', required : fuzzer_build)
309 # Used only for tests
310 cxx = meson.get_compiler('cpp')
311 cxx_cmd = ' '.join(cxx.cmd_array())
317 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer', required : false)
318 if fuzzing_engine.found()
319 add_project_arguments('-fsanitize-coverage=trace-pc-guard,trace-cmp', language : 'c')
320 elif cc.has_argument('-fsanitize=fuzzer-no-link')
321 add_project_arguments('-fsanitize=fuzzer-no-link', language : 'c')
323 error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported')
326 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
329 # Those generate many false positives, and we do not want to change the code to
331 basic_disabled_warnings = [
332 '-Wno-format-signedness',
333 '-Wno-missing-field-initializers',
334 '-Wno-unused-parameter',
337 possible_common_cc_flags = [
341 '-Werror=implicit-function-declaration',
342 '-Werror=incompatible-pointer-types',
344 '-Werror=return-type',
345 '-Werror=shift-count-overflow',
346 '-Werror=shift-overflow=2',
349 '-Wimplicit-fallthrough=5',
352 '-Wmissing-include-dirs',
353 '-Wmissing-noreturn',
355 '-Wold-style-definition',
359 '-Wstrict-aliasing=2',
360 '-Wstrict-prototypes',
361 '-Wsuggest-attribute=noreturn',
364 # negative arguments are correctly detected starting with meson 0.46.
365 '-Wno-error=#warnings', # clang
366 '-Wno-string-plus-int', # clang
369 # Disable -Wmaybe-unitialized when compiling with -Os/-O1/-O3/etc. There are
370 # too many false positives with gcc >= 8. Effectively, we only test with -O0
371 # and -O2; this should be enough to catch most important cases without too much
372 # busywork. See https://github.com/systemd/systemd/pull/19226.
373 if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or
374 cc.version().version_compare('<10'))
375 possible_common_cc_flags += '-Wno-maybe-uninitialized'
378 # Disable -Wno-unused-result with gcc, see
379 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425.
380 if cc.get_id() == 'gcc'
381 possible_common_cc_flags += '-Wno-unused-result'
384 # --as-needed and --no-undefined are provided by meson by default,
385 # run 'meson configure' to see what is enabled
386 possible_link_flags = [
392 if cc.get_id() == 'clang'
393 possible_common_cc_flags += [
394 '-Wno-typedef-redefinition',
395 '-Wno-gnu-variable-sized-type-not-at-end',
399 possible_cc_flags = possible_common_cc_flags + [
400 '-Werror=missing-declarations',
401 '-Werror=missing-prototypes',
402 '-fdiagnostics-show-option',
405 '-fno-strict-aliasing',
407 '-fstack-protector-strong',
408 '-fvisibility=hidden',
409 '--param=ssp-buffer-size=4',
412 if get_option('buildtype') != 'debug'
413 possible_cc_flags += [
414 '-ffunction-sections',
418 possible_link_flags += '-Wl,--gc-sections'
421 add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
422 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
423 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
425 have = cc.has_argument('-Wzero-length-bounds')
426 conf.set10('HAVE_ZERO_LENGTH_BOUNDS', have)
430 #include <inttypes.h>
431 typedef uint64_t usec_t;
432 usec_t now(clockid_t clock);
437 ''', args: '-Werror=shadow', name : '-Werror=shadow with local shadowing')
438 add_project_arguments('-Werror=shadow', language : 'c')
442 add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
445 cpp = ' '.join(cc.cmd_array()) + ' -E'
447 has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
449 #####################################################################
450 # compilation result tests
452 conf.set('_GNU_SOURCE', true)
453 conf.set('__SANE_USERSPACE_TYPES__', true)
454 conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)
456 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
457 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
458 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
459 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
463 #include <sys/mount.h>
464 #include <sys/stat.h>
465 #include <linux/fs.h>
468 foreach decl : ['char16_t',
474 # We get -1 if the size cannot be determined
475 have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
477 if decl == 'struct statx'
479 want_linux_stat_h = false
481 have = cc.sizeof(decl,
482 prefix : decl_headers + '#include <linux/stat.h>',
483 args : '-D_GNU_SOURCE') > 0
484 want_linux_stat_h = have
488 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
491 conf.set10('WANT_LINUX_STAT_H', want_linux_stat_h)
493 foreach ident : ['secure_getenv', '__secure_getenv']
494 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
498 ['memfd_create', '''#include <sys/mman.h>'''],
499 ['gettid', '''#include <sys/types.h>
500 #include <unistd.h>'''],
501 ['pivot_root', '''#include <stdlib.h>
502 #include <unistd.h>'''], # no known header declares pivot_root
503 ['name_to_handle_at', '''#include <sys/types.h>
504 #include <sys/stat.h>
505 #include <fcntl.h>'''],
506 ['setns', '''#include <sched.h>'''],
507 ['renameat2', '''#include <stdio.h>
508 #include <fcntl.h>'''],
509 ['kcmp', '''#include <linux/kcmp.h>'''],
510 ['keyctl', '''#include <sys/types.h>
511 #include <keyutils.h>'''],
512 ['copy_file_range', '''#include <sys/syscall.h>
513 #include <unistd.h>'''],
514 ['bpf', '''#include <sys/syscall.h>
515 #include <unistd.h>'''],
516 ['statx', '''#include <sys/types.h>
517 #include <sys/stat.h>
518 #include <unistd.h>'''],
519 ['explicit_bzero' , '''#include <string.h>'''],
520 ['reallocarray', '''#include <stdlib.h>'''],
521 ['set_mempolicy', '''#include <stdlib.h>
522 #include <unistd.h>'''],
523 ['get_mempolicy', '''#include <stdlib.h>
524 #include <unistd.h>'''],
525 ['pidfd_send_signal', '''#include <stdlib.h>
528 #include <sys/wait.h>'''],
529 ['pidfd_open', '''#include <stdlib.h>
532 #include <sys/wait.h>'''],
533 ['rt_sigqueueinfo', '''#include <stdlib.h>
536 #include <sys/wait.h>'''],
537 ['mallinfo', '''#include <malloc.h>'''],
538 ['mallinfo2', '''#include <malloc.h>'''],
539 ['execveat', '''#include <unistd.h>'''],
540 ['close_range', '''#include <unistd.h>'''],
541 ['epoll_pwait2', '''#include <sys/epoll.h>'''],
542 ['mount_setattr', '''#include <sys/mount.h>'''],
543 ['move_mount', '''#include <sys/mount.h>'''],
544 ['open_tree', '''#include <sys/mount.h>'''],
547 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
548 conf.set10('HAVE_' + ident[0].to_upper(), have)
551 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
552 conf.set10('USE_SYS_RANDOM_H', true)
553 conf.set10('HAVE_GETRANDOM', true)
555 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
556 conf.set10('USE_SYS_RANDOM_H', false)
557 conf.set10('HAVE_GETRANDOM', have)
560 #####################################################################
562 version_tag = get_option('version-tag')
564 vcs_data = configuration_data()
565 vcs_data.set('VCS_TAG', version_tag)
566 version_h = configure_file(configuration : vcs_data,
567 input : 'src/version/version.h.in',
568 output : 'version.h')
571 project_source_root + '/tools/meson-vcs-tag.sh',
573 meson.project_version()]
576 input : 'src/version/version.h.in',
577 output : 'version.h',
581 versiondep = declare_dependency(sources: version_h)
583 sh = find_program('sh')
584 echo = find_program('echo')
585 test = find_program('test')
586 sed = find_program('sed')
587 awk = find_program('awk')
588 stat = find_program('stat')
589 ln = find_program('ln')
590 git = find_program('git', required : false)
591 env = find_program('env')
592 perl = find_program('perl', required : false)
593 rsync = find_program('rsync', required : false)
594 meson_make_symlink = project_source_root + '/tools/meson-make-symlink.sh'
595 test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
597 mkdir_p = 'mkdir -p $DESTDIR/@0@'
598 splash_bmp = files('test/splash.bmp')
600 # If -Dxxx-path option is found, use that. Otherwise, check in $PATH,
601 # /usr/sbin, /sbin, and fall back to the default from middle column.
602 progs = [['quotaon', '/usr/sbin/quotaon' ],
603 ['quotacheck', '/usr/sbin/quotacheck' ],
604 ['kmod', '/usr/bin/kmod' ],
605 ['kexec', '/usr/sbin/kexec' ],
606 ['sulogin', '/usr/sbin/sulogin' ],
607 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
608 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
609 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
610 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
611 ['nologin', '/usr/sbin/nologin', ],
614 path = get_option(prog[0] + '-path')
616 message('Using @1@ for @0@'.format(prog[0], path))
618 exe = find_program(prog[0],
619 '/usr/sbin/' + prog[0],
622 path = exe.found() ? exe.path() : prog[1]
624 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
625 conf.set_quoted(name, path)
628 conf.set_quoted('TELINIT', get_option('telinit-path'))
630 if run_command(ln, '--relative', '--help').returncode() != 0
631 error('ln does not support --relative (added in coreutils 8.16)')
634 ############################################################
636 if run_command('python3', '-c', 'import jinja2').returncode() != 0
637 error('python3 jinja2 missing')
640 ############################################################
642 gperf = find_program('gperf')
644 gperf_test_format = '''
646 const char * in_word_set(const char *, @0@);
649 gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
650 gperf_snippet = run_command(sh, '-c', gperf_snippet_format.format(gperf.path()))
651 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
652 if cc.compiles(gperf_test)
653 gperf_len_type = 'size_t'
655 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
656 if cc.compiles(gperf_test)
657 gperf_len_type = 'unsigned'
659 error('unable to determine gperf len type')
662 message('gperf len type is @0@'.format(gperf_len_type))
663 conf.set('GPERF_LEN_TYPE', gperf_len_type,
664 description : 'The type of gperf "len" parameter')
666 ############################################################
668 if not cc.has_header('sys/capability.h')
669 error('POSIX caps headers not found')
671 foreach header : ['crypt.h',
673 'linux/vm_sockets.h',
675 'valgrind/memcheck.h',
676 'valgrind/valgrind.h',
677 'linux/time_types.h',
681 conf.set10('HAVE_' + header.underscorify().to_upper(),
682 cc.has_header(header))
685 ############################################################
687 fallback_hostname = get_option('fallback-hostname')
688 if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0] == '-'
689 error('Invalid fallback-hostname configuration')
690 # A more extensive test is done in test-hostname-util. Let's catch
691 # the most obvious errors here so we don't fail with an assert later.
693 conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
695 default_hierarchy = get_option('default-hierarchy')
696 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
697 description : 'default cgroup hierarchy as string')
698 if default_hierarchy == 'legacy'
699 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
700 elif default_hierarchy == 'hybrid'
701 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
703 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
706 default_net_naming_scheme = get_option('default-net-naming-scheme')
707 conf.set_quoted('DEFAULT_NET_NAMING_SCHEME', default_net_naming_scheme)
709 time_epoch = get_option('time-epoch')
711 time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"').stdout().strip()
712 if time_epoch == '' and git.found() and run_command('test', '-e', '.git').returncode() == 0
713 # If we're in a git repository, use the creation time of the latest git tag.
714 latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags').stdout().strip()
715 time_epoch = run_command(git, 'log', '--no-show-signature', '-1', '--format=%at', latest_tag).stdout()
719 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
721 time_epoch = time_epoch.to_int()
723 conf.set('TIME_EPOCH', time_epoch)
725 conf.set('CLOCK_VALID_RANGE_USEC_MAX', get_option('clock-valid-range-usec-max'))
727 foreach tuple : [['system-alloc-uid-min', 'SYS_UID_MIN', 1], # Also see login.defs(5).
728 ['system-uid-max', 'SYS_UID_MAX', 999],
729 ['system-alloc-gid-min', 'SYS_GID_MIN', 1],
730 ['system-gid-max', 'SYS_GID_MAX', 999]]
731 v = get_option(tuple[0])
735 '/^\s*@0@\s+/ { uid=$2 } END { print uid }'.format(tuple[1]),
736 '/etc/login.defs').stdout().strip()
743 conf.set(tuple[0].underscorify().to_upper(), v)
745 if conf.get('SYSTEM_ALLOC_UID_MIN') >= conf.get('SYSTEM_UID_MAX')
746 error('Invalid uid allocation range')
748 if conf.get('SYSTEM_ALLOC_GID_MIN') >= conf.get('SYSTEM_GID_MAX')
749 error('Invalid gid allocation range')
752 dynamic_uid_min = get_option('dynamic-uid-min')
753 dynamic_uid_max = get_option('dynamic-uid-max')
754 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
755 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
757 container_uid_base_min = get_option('container-uid-base-min')
758 container_uid_base_max = get_option('container-uid-base-max')
759 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
760 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
762 nobody_user = get_option('nobody-user')
763 nobody_group = get_option('nobody-group')
765 if not meson.is_cross_build()
766 getent_result = run_command('getent', 'passwd', '65534')
767 if getent_result.returncode() == 0
768 name = getent_result.stdout().split(':')[0]
769 if name != nobody_user
771 '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) +
772 'Your build will result in an user table setup that is incompatible with the local system.')
775 id_result = run_command('id', '-u', nobody_user)
776 if id_result.returncode() == 0
777 id = id_result.stdout().to_int()
780 '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) +
781 'Your build will result in an user table setup that is incompatible with the local system.')
785 getent_result = run_command('getent', 'group', '65534')
786 if getent_result.returncode() == 0
787 name = getent_result.stdout().split(':')[0]
788 if name != nobody_group
790 '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) +
791 'Your build will result in an group table setup that is incompatible with the local system.')
794 id_result = run_command('id', '-g', nobody_group)
795 if id_result.returncode() == 0
796 id = id_result.stdout().to_int()
799 '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) +
800 'Your build will result in an group table setup that is incompatible with the local system.')
804 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
806 'The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
807 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
810 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
811 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
814 foreach option : ['adm-gid',
831 'systemd-journal-gid',
832 'systemd-network-uid',
833 'systemd-resolve-uid',
834 'systemd-timesync-uid']
835 name = option.underscorify().to_upper()
836 val = get_option(option)
838 # Ensure provided GID argument is numeric, otherwise fall back to default assignment
839 conf.set(name, val >= 0 ? val : '-')
841 static_ugids += '@0@:@1@'.format(option, val)
845 conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
846 conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
848 dev_kvm_mode = get_option('dev-kvm-mode')
849 conf.set_quoted('DEV_KVM_MODE', dev_kvm_mode) # FIXME: convert to 0o… notation
850 conf.set10('DEV_KVM_UACCESS', dev_kvm_mode != '0666')
851 group_render_mode = get_option('group-render-mode')
852 conf.set_quoted('GROUP_RENDER_MODE', group_render_mode)
853 conf.set10('GROUP_RENDER_UACCESS', group_render_mode != '0666')
855 kill_user_processes = get_option('default-kill-user-processes')
856 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
858 dns_servers = get_option('dns-servers')
859 conf.set_quoted('DNS_SERVERS', dns_servers)
861 ntp_servers = get_option('ntp-servers')
862 conf.set_quoted('NTP_SERVERS', ntp_servers)
864 default_locale = get_option('default-locale')
865 if default_locale == ''
866 if not meson.is_cross_build()
867 choose_default_locale_sh = find_program('tools/choose-default-locale.sh')
868 default_locale = run_command(choose_default_locale_sh).stdout().strip()
870 default_locale = 'C.UTF-8'
873 conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale)
875 localegen_path = get_option('localegen-path')
876 if localegen_path != ''
877 conf.set_quoted('LOCALEGEN_PATH', localegen_path)
879 conf.set10('HAVE_LOCALEGEN', localegen_path != '')
881 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
883 service_watchdog = get_option('service-watchdog')
884 watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
885 conf.set_quoted('SERVICE_WATCHDOG', watchdog_value)
887 conf.set_quoted('SUSHELL', get_option('debug-shell'))
888 conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
890 enable_debug_hashmap = false
891 enable_debug_mmap_cache = false
892 enable_debug_siphash = false
893 foreach name : get_option('debug-extra')
895 enable_debug_hashmap = true
896 elif name == 'mmap-cache'
897 enable_debug_mmap_cache = true
898 elif name == 'siphash'
899 enable_debug_siphash = true
901 message('unknown debug option "@0@", ignoring'.format(name))
904 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
905 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
906 conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash)
908 conf.set10('VALGRIND', get_option('valgrind'))
909 conf.set10('LOG_TRACE', get_option('log-trace'))
911 default_user_path = get_option('user-path')
912 if default_user_path != ''
913 conf.set_quoted('DEFAULT_USER_PATH', default_user_path)
917 #####################################################################
919 threads = dependency('threads')
920 librt = cc.find_library('rt')
921 libm = cc.find_library('m')
922 libdl = cc.find_library('dl')
923 libcrypt = cc.find_library('crypt')
925 crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
927 ['crypt_ra', crypt_header],
928 ['crypt_preferred_method', crypt_header],
929 ['crypt_gensalt_ra', crypt_header]]
931 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
932 dependencies : libcrypt)
933 conf.set10('HAVE_' + ident[0].to_upper(), have)
936 libcap = dependency('libcap', required : false)
937 if not libcap.found()
938 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
939 libcap = cc.find_library('cap')
942 want_bpf_framework = get_option('bpf-framework')
943 bpf_framework_required = want_bpf_framework == 'true'
945 libbpf = dependency('libbpf', required : bpf_framework_required, version : '>= 0.2')
946 conf.set10('HAVE_LIBBPF', libbpf.found())
948 if want_bpf_framework == 'false'
949 conf.set10('BPF_FRAMEWORK', 0)
951 clang = find_program('clang', required : bpf_framework_required)
952 llvm_strip = find_program('llvm-strip', required : bpf_framework_required)
954 # Debian installs this in /usr/sbin/ which is not in $PATH.
955 # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian.
956 bpftool = find_program('bpftool', '/usr/sbin/bpftool', required : bpf_framework_required)
958 bpf_arches = ['x86_64']
959 deps_found = libbpf.found() and clang.found() and llvm_strip.found() and bpftool.found()
960 # Can build BPF program from source code in restricted C
961 conf.set10('BPF_FRAMEWORK',
962 bpf_arches.contains(host_machine.cpu_family()) and deps_found)
965 libmount = dependency('mount',
966 version : fuzzer_build ? '>= 0' : '>= 2.30')
968 want_libfdisk = get_option('fdisk')
969 if want_libfdisk != 'false' and not skip_deps
970 libfdisk = dependency('fdisk',
972 required : want_libfdisk == 'true')
973 have = libfdisk.found()
978 conf.set10('HAVE_LIBFDISK', have)
980 want_pwquality = get_option('pwquality')
981 if want_pwquality != 'false' and not skip_deps
982 libpwquality = dependency('pwquality', required : want_pwquality == 'true')
983 have = libpwquality.found()
988 conf.set10('HAVE_PWQUALITY', have)
990 want_seccomp = get_option('seccomp')
991 if want_seccomp != 'false' and not skip_deps
992 libseccomp = dependency('libseccomp',
993 version : '>= 2.3.1',
994 required : want_seccomp == 'true')
995 have = libseccomp.found()
1000 conf.set10('HAVE_SECCOMP', have)
1002 want_selinux = get_option('selinux')
1003 if want_selinux != 'false' and not skip_deps
1004 libselinux = dependency('libselinux',
1005 version : '>= 2.1.9',
1006 required : want_selinux == 'true')
1007 have = libselinux.found()
1012 conf.set10('HAVE_SELINUX', have)
1014 want_apparmor = get_option('apparmor')
1015 if want_apparmor != 'false' and not skip_deps
1016 libapparmor = dependency('libapparmor',
1017 version : '>= 2.13',
1018 required : want_apparmor == 'true')
1019 have = libapparmor.found()
1024 conf.set10('HAVE_APPARMOR', have)
1026 conf.set10('HAVE_SMACK_RUN_LABEL', get_option('smack-run-label') != '')
1027 conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
1029 want_polkit = get_option('polkit')
1030 install_polkit = false
1031 install_polkit_pkla = false
1032 if want_polkit != 'false' and not skip_deps
1033 install_polkit = true
1035 libpolkit = dependency('polkit-gobject-1',
1037 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
1038 message('Old polkit detected, will install pkla files')
1039 install_polkit_pkla = true
1042 conf.set10('ENABLE_POLKIT', install_polkit)
1044 want_acl = get_option('acl')
1045 if want_acl != 'false' and not skip_deps
1046 libacl = cc.find_library('acl', required : want_acl == 'true')
1047 have = libacl.found()
1052 conf.set10('HAVE_ACL', have)
1054 want_audit = get_option('audit')
1055 if want_audit != 'false' and not skip_deps
1056 libaudit = dependency('audit', required : want_audit == 'true')
1057 have = libaudit.found()
1062 conf.set10('HAVE_AUDIT', have)
1064 want_blkid = get_option('blkid')
1065 if want_blkid != 'false' and not skip_deps
1066 libblkid = dependency('blkid', required : want_blkid == 'true')
1067 have = libblkid.found()
1069 conf.set10('HAVE_BLKID_PROBE_SET_HINT',
1070 have and cc.has_function('blkid_probe_set_hint', dependencies : libblkid))
1075 conf.set10('HAVE_BLKID', have)
1077 want_kmod = get_option('kmod')
1078 if want_kmod != 'false' and not skip_deps
1079 libkmod = dependency('libkmod',
1081 required : want_kmod == 'true')
1082 have = libkmod.found()
1087 conf.set10('HAVE_KMOD', have)
1089 want_pam = get_option('pam')
1090 if want_pam != 'false' and not skip_deps
1091 libpam = cc.find_library('pam', required : want_pam == 'true')
1092 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1093 have = libpam.found() and libpam_misc.found()
1099 conf.set10('HAVE_PAM', have)
1101 want_microhttpd = get_option('microhttpd')
1102 if want_microhttpd != 'false' and not skip_deps
1103 libmicrohttpd = dependency('libmicrohttpd',
1104 version : '>= 0.9.33',
1105 required : want_microhttpd == 'true')
1106 have = libmicrohttpd.found()
1111 conf.set10('HAVE_MICROHTTPD', have)
1113 want_libcryptsetup = get_option('libcryptsetup')
1114 want_libcryptsetup_plugins = get_option('libcryptsetup-plugins')
1116 if want_libcryptsetup_plugins == 'true' and want_libcryptsetup == 'false'
1117 error('libcryptsetup-plugins can not be requested without libcryptsetup')
1120 if want_libcryptsetup != 'false' and not skip_deps
1121 libcryptsetup = dependency('libcryptsetup',
1122 version : want_libcryptsetup_plugins == 'true' ? '>= 2.4.0' : '>= 2.0.1',
1123 required : want_libcryptsetup == 'true' or want_libcryptsetup_plugins == 'true')
1124 have = libcryptsetup.found()
1126 conf.set10('HAVE_CRYPT_SET_METADATA_SIZE',
1127 have and cc.has_function('crypt_set_metadata_size', dependencies : libcryptsetup))
1128 conf.set10('HAVE_CRYPT_ACTIVATE_BY_SIGNED_KEY',
1129 have and cc.has_function('crypt_activate_by_signed_key', dependencies : libcryptsetup))
1130 conf.set10('HAVE_CRYPT_TOKEN_MAX',
1131 have and cc.has_function('crypt_token_max', dependencies : libcryptsetup))
1136 conf.set10('HAVE_LIBCRYPTSETUP', have)
1138 if want_libcryptsetup_plugins != 'false' and not skip_deps
1139 have = (cc.has_function('crypt_activate_by_token_pin', dependencies : libcryptsetup) and
1140 cc.has_function('crypt_token_external_path', dependencies : libcryptsetup))
1144 conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have)
1146 want_libcurl = get_option('libcurl')
1147 if want_libcurl != 'false' and not skip_deps
1148 libcurl = dependency('libcurl',
1149 version : '>= 7.32.0',
1150 required : want_libcurl == 'true')
1151 have = libcurl.found()
1156 conf.set10('HAVE_LIBCURL', have)
1157 conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
1159 want_libidn = get_option('libidn')
1160 want_libidn2 = get_option('libidn2')
1161 if want_libidn == 'true' and want_libidn2 == 'true'
1162 error('libidn and libidn2 cannot be requested simultaneously')
1165 if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps
1166 libidn = dependency('libidn2',
1167 required : want_libidn2 == 'true')
1168 have = libidn.found()
1173 conf.set10('HAVE_LIBIDN2', have)
1174 if not have and want_libidn != 'false' and not skip_deps
1175 # libidn is used for both libidn and libidn2 objects
1176 libidn = dependency('libidn',
1177 required : want_libidn == 'true')
1178 have = libidn.found()
1182 conf.set10('HAVE_LIBIDN', have)
1184 want_libiptc = get_option('libiptc')
1185 if want_libiptc != 'false' and not skip_deps
1186 libiptc = dependency('libiptc',
1187 required : want_libiptc == 'true')
1188 have = libiptc.found()
1193 conf.set10('HAVE_LIBIPTC', have)
1195 want_qrencode = get_option('qrencode')
1196 if want_qrencode != 'false' and not skip_deps
1197 libqrencode = dependency('libqrencode',
1199 required : want_qrencode == 'true')
1200 have = libqrencode.found()
1205 conf.set10('HAVE_QRENCODE', have)
1207 want_gcrypt = get_option('gcrypt')
1208 if want_gcrypt != 'false' and not skip_deps
1209 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1210 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1211 have = libgcrypt.found() and libgpg_error.found()
1216 # link to neither of the libs if one is not found
1220 conf.set10('HAVE_GCRYPT', have)
1222 want_gnutls = get_option('gnutls')
1223 if want_gnutls != 'false' and not skip_deps
1224 libgnutls = dependency('gnutls',
1225 version : '>= 3.1.4',
1226 required : want_gnutls == 'true')
1227 have = libgnutls.found()
1232 conf.set10('HAVE_GNUTLS', have)
1234 want_openssl = get_option('openssl')
1235 if want_openssl != 'false' and not skip_deps
1236 libopenssl = dependency('openssl',
1237 version : '>= 1.1.0',
1238 required : want_openssl == 'true')
1239 have = libopenssl.found()
1244 conf.set10('HAVE_OPENSSL', have)
1246 want_p11kit = get_option('p11kit')
1247 if want_p11kit != 'false' and not skip_deps
1248 libp11kit = dependency('p11-kit-1',
1249 version : '>= 0.23.3',
1250 required : want_p11kit == 'true')
1251 have = libp11kit.found()
1256 conf.set10('HAVE_P11KIT', have)
1258 want_libfido2 = get_option('libfido2')
1259 if want_libfido2 != 'false' and not skip_deps
1260 libfido2 = dependency('libfido2',
1261 required : want_libfido2 == 'true')
1262 have = libfido2.found()
1267 conf.set10('HAVE_LIBFIDO2', have)
1269 want_tpm2 = get_option('tpm2')
1270 if want_tpm2 != 'false' and not skip_deps
1271 tpm2 = dependency('tss2-esys tss2-rc tss2-mu',
1272 required : want_tpm2 == 'true')
1278 conf.set10('HAVE_TPM2', have)
1280 want_elfutils = get_option('elfutils')
1281 if want_elfutils != 'false' and not skip_deps
1282 libdw = dependency('libdw',
1283 required : want_elfutils == 'true')
1284 have = libdw.found()
1289 conf.set10('HAVE_ELFUTILS', have)
1291 want_zlib = get_option('zlib')
1292 if want_zlib != 'false' and not skip_deps
1293 libz = dependency('zlib',
1294 required : want_zlib == 'true')
1300 conf.set10('HAVE_ZLIB', have)
1302 want_bzip2 = get_option('bzip2')
1303 if want_bzip2 != 'false' and not skip_deps
1304 libbzip2 = cc.find_library('bz2',
1305 required : want_bzip2 == 'true')
1306 have = libbzip2.found()
1311 conf.set10('HAVE_BZIP2', have)
1313 want_xz = get_option('xz')
1314 if want_xz != 'false' and not skip_deps
1315 libxz = dependency('liblzma',
1316 required : want_xz == 'true')
1317 have_xz = libxz.found()
1322 conf.set10('HAVE_XZ', have_xz)
1324 want_lz4 = get_option('lz4')
1325 if want_lz4 != 'false' and not skip_deps
1326 liblz4 = dependency('liblz4',
1327 version : '>= 1.3.0',
1328 required : want_lz4 == 'true')
1329 have_lz4 = liblz4.found()
1334 conf.set10('HAVE_LZ4', have_lz4)
1336 want_zstd = get_option('zstd')
1337 if want_zstd != 'false' and not skip_deps
1338 libzstd = dependency('libzstd',
1339 required : want_zstd == 'true',
1340 version : '>= 1.4.0')
1341 have_zstd = libzstd.found()
1346 conf.set10('HAVE_ZSTD', have_zstd)
1348 conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
1350 want_xkbcommon = get_option('xkbcommon')
1351 if want_xkbcommon != 'false' and not skip_deps
1352 libxkbcommon = dependency('xkbcommon',
1353 version : '>= 0.3.0',
1354 required : want_xkbcommon == 'true')
1355 have = libxkbcommon.found()
1360 conf.set10('HAVE_XKBCOMMON', have)
1362 want_pcre2 = get_option('pcre2')
1363 if want_pcre2 != 'false'
1364 libpcre2 = dependency('libpcre2-8',
1365 required : want_pcre2 == 'true')
1366 have = libpcre2.found()
1371 conf.set10('HAVE_PCRE2', have)
1373 want_glib = get_option('glib')
1374 if want_glib != 'false' and not skip_deps
1375 libglib = dependency('glib-2.0',
1376 version : '>= 2.22.0',
1377 required : want_glib == 'true')
1378 libgobject = dependency('gobject-2.0',
1379 version : '>= 2.22.0',
1380 required : want_glib == 'true')
1381 libgio = dependency('gio-2.0',
1382 required : want_glib == 'true')
1383 have = libglib.found() and libgobject.found() and libgio.found()
1390 conf.set10('HAVE_GLIB', have)
1392 want_dbus = get_option('dbus')
1393 if want_dbus != 'false' and not skip_deps
1394 libdbus = dependency('dbus-1',
1395 version : '>= 1.3.2',
1396 required : want_dbus == 'true')
1397 have = libdbus.found()
1402 conf.set10('HAVE_DBUS', have)
1404 default_dnssec = get_option('default-dnssec')
1406 default_dnssec = 'no'
1408 if default_dnssec != 'no' and conf.get('HAVE_GCRYPT') == 0
1409 message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.')
1410 default_dnssec = 'no'
1412 conf.set('DEFAULT_DNSSEC_MODE',
1413 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1414 conf.set_quoted('DEFAULT_DNSSEC_MODE_STR', default_dnssec)
1416 dns_over_tls = get_option('dns-over-tls')
1417 if dns_over_tls != 'false'
1418 if dns_over_tls == 'openssl'
1421 have_gnutls = (conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0'))
1422 if dns_over_tls == 'gnutls' and not have_gnutls
1423 error('DNS-over-TLS support was requested with gnutls, but dependencies are not available')
1426 if dns_over_tls == 'gnutls' or have_gnutls
1427 have_openssl = false
1429 have_openssl = conf.get('HAVE_OPENSSL') == 1
1430 if dns_over_tls != 'auto' and not have_openssl
1431 str = dns_over_tls == 'openssl' ? ' with openssl' : ''
1432 error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
1435 have = have_gnutls or have_openssl
1439 have_openssl = false
1441 conf.set10('ENABLE_DNS_OVER_TLS', have)
1442 conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1443 conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
1445 default_dns_over_tls = get_option('default-dns-over-tls')
1447 default_dns_over_tls = 'no'
1449 if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
1450 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.')
1451 default_dns_over_tls = 'no'
1453 conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1454 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
1455 conf.set_quoted('DEFAULT_DNS_OVER_TLS_MODE_STR', default_dns_over_tls)
1457 default_mdns = get_option('default-mdns')
1458 conf.set('DEFAULT_MDNS_MODE',
1459 'RESOLVE_SUPPORT_' + default_mdns.to_upper())
1460 conf.set_quoted('DEFAULT_MDNS_MODE_STR', default_mdns)
1462 default_llmnr = get_option('default-llmnr')
1463 conf.set('DEFAULT_LLMNR_MODE',
1464 'RESOLVE_SUPPORT_' + default_llmnr.to_upper())
1465 conf.set_quoted('DEFAULT_LLMNR_MODE_STR', default_llmnr)
1467 want_repart = get_option('repart')
1468 if want_repart != 'false'
1469 have = (conf.get('HAVE_OPENSSL') == 1 and
1470 conf.get('HAVE_LIBFDISK') == 1)
1471 if want_repart == 'true' and not have
1472 error('repart support was requested, but dependencies are not available')
1477 conf.set10('ENABLE_REPART', have)
1479 want_importd = get_option('importd')
1480 if want_importd != 'false'
1481 have = (conf.get('HAVE_LIBCURL') == 1 and
1482 conf.get('HAVE_ZLIB') == 1 and
1483 conf.get('HAVE_XZ') == 1 and
1484 conf.get('HAVE_GCRYPT') == 1)
1485 if want_importd == 'true' and not have
1486 error('importd support was requested, but dependencies are not available')
1491 conf.set10('ENABLE_IMPORTD', have)
1493 want_homed = get_option('homed')
1494 if want_homed != 'false'
1495 have = (conf.get('HAVE_OPENSSL') == 1 and
1496 conf.get('HAVE_LIBFDISK') == 1 and
1497 conf.get('HAVE_LIBCRYPTSETUP') == 1)
1498 if want_homed == 'true' and not have
1499 error('homed support was requested, but dependencies are not available')
1504 conf.set10('ENABLE_HOMED', have)
1506 have = have and conf.get('HAVE_PAM') == 1
1507 conf.set10('ENABLE_PAM_HOME', have)
1509 have = get_option('oomd')
1510 conf.set10('ENABLE_OOMD', have)
1512 want_remote = get_option('remote')
1513 if want_remote != 'false'
1514 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1515 conf.get('HAVE_LIBCURL') == 1]
1516 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1517 # it's possible to build one without the other. Complain only if
1518 # support was explicitly requested. The auxiliary files like sysusers
1519 # config should be installed when any of the programs are built.
1520 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1521 error('remote support was requested, but dependencies are not available')
1523 have = have_deps[0] or have_deps[1]
1527 conf.set10('ENABLE_REMOTE', have)
1529 foreach term : ['analyze',
1543 'compat-mutable-uid-boundaries',
1569 have = get_option(term)
1570 name = 'ENABLE_' + term.underscorify().to_upper()
1571 conf.set10(name, have)
1574 enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
1576 foreach tuple : [['nss-mymachines', 'machined'],
1577 ['nss-resolve', 'resolve']]
1578 want = get_option(tuple[0])
1580 have = get_option(tuple[1])
1581 if want == 'true' and not have
1582 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1587 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1588 conf.set10(name, have)
1592 foreach term : ['ENABLE_NSS_MYHOSTNAME',
1593 'ENABLE_NSS_MYMACHINES',
1594 'ENABLE_NSS_RESOLVE',
1595 'ENABLE_NSS_SYSTEMD']
1596 if conf.get(term) == 1
1600 conf.set10('ENABLE_NSS', enable_nss)
1602 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1604 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1606 #####################################################################
1608 if get_option('efi')
1609 efi_arch = host_machine.cpu_family()
1611 if efi_arch == 'x86'
1612 EFI_MACHINE_TYPE_NAME = 'ia32'
1613 gnu_efi_arch = 'ia32'
1614 elif efi_arch == 'x86_64'
1615 EFI_MACHINE_TYPE_NAME = 'x64'
1616 gnu_efi_arch = 'x86_64'
1617 elif efi_arch == 'arm'
1618 EFI_MACHINE_TYPE_NAME = 'arm'
1619 gnu_efi_arch = 'arm'
1620 elif efi_arch == 'aarch64'
1621 EFI_MACHINE_TYPE_NAME = 'aa64'
1622 gnu_efi_arch = 'aarch64'
1623 elif efi_arch == 'riscv64'
1624 EFI_MACHINE_TYPE_NAME = 'riscv64'
1625 gnu_efi_arch = 'riscv64'
1627 EFI_MACHINE_TYPE_NAME = ''
1632 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
1634 conf.set('SD_TPM_PCR', get_option('tpm-pcrindex'))
1638 conf.set10('ENABLE_EFI', have)
1640 ############################################################
1642 build_bpf_skel_py = find_program('tools/build-bpf-skel.py')
1643 generate_gperfs = find_program('tools/generate-gperfs.py')
1644 make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
1645 make_directive_index_py = find_program('tools/make-directive-index.py')
1646 make_man_index_py = find_program('tools/make-man-index.py')
1647 meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
1648 update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
1649 update_hwdb_sh = find_program('tools/update-hwdb.sh')
1650 update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
1651 update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
1652 xml_helper_py = find_program('tools/xml_helper.py')
1654 #####################################################################
1656 config_h = configure_file(
1657 output : 'config.h',
1658 configuration : conf)
1660 add_project_arguments('-include', 'config.h', language : 'c')
1662 ############################################################
1664 # binaries that have --help and are intended for use by humans,
1665 # usually, but not always, installed in /bin.
1666 public_programs = []
1671 basic_includes = include_directories(
1677 libsystemd_includes = [basic_includes, include_directories(
1678 'src/libsystemd/sd-bus',
1679 'src/libsystemd/sd-device',
1680 'src/libsystemd/sd-event',
1681 'src/libsystemd/sd-hwdb',
1682 'src/libsystemd/sd-id128',
1683 'src/libsystemd/sd-journal',
1684 'src/libsystemd/sd-netlink',
1685 'src/libsystemd/sd-network',
1686 'src/libsystemd/sd-resolve')]
1688 includes = [libsystemd_includes, include_directories('src/shared')]
1692 subdir('src/fundamental')
1694 subdir('src/libsystemd')
1695 subdir('src/shared')
1697 subdir('src/libudev')
1698 subdir('src/cryptsetup/cryptsetup-tokens')
1700 libsystemd = shared_library(
1703 version : libsystemd_version,
1704 include_directories : libsystemd_includes,
1705 link_args : ['-shared',
1706 '-Wl,--version-script=' + libsystemd_sym_path],
1707 link_with : [libbasic,
1709 link_whole : [libsystemd_static],
1710 dependencies : [threads,
1715 link_depends : libsystemd_sym,
1717 install_dir : rootlibdir)
1719 install_libsystemd_static = static_library(
1723 basic_gcrypt_sources,
1724 fundamental_sources,
1726 include_directories : libsystemd_includes,
1727 build_by_default : static_libsystemd != 'false',
1728 install : static_libsystemd != 'false',
1729 install_dir : rootlibdir,
1730 pic : static_libsystemd_pic,
1731 dependencies : [threads,
1742 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
1744 libudev = shared_library(
1747 version : libudev_version,
1748 include_directories : includes,
1749 link_args : ['-shared',
1750 '-Wl,--version-script=' + libudev_sym_path],
1751 link_with : [libsystemd_static, libshared_static],
1752 link_whole : libudev_basic,
1753 dependencies : [threads],
1754 link_depends : libudev_sym,
1756 install_dir : rootlibdir)
1758 install_libudev_static = static_library(
1761 fundamental_sources,
1766 include_directories : includes,
1767 build_by_default : static_libudev != 'false',
1768 install : static_libudev != 'false',
1769 install_dir : rootlibdir,
1770 link_depends : libudev_sym,
1771 dependencies : libshared_deps + [libmount],
1772 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
1773 pic : static_libudev_pic)
1775 if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
1776 if conf.get('HAVE_TPM2') == 1
1777 cryptsetup_token_systemd_tpm2 = shared_library(
1778 'cryptsetup-token-systemd-tpm2',
1779 link_args : ['-shared',
1780 '-Wl,--version-script=' + cryptsetup_token_sym_path],
1781 dependencies : libshared_deps + [libcryptsetup, versiondep],
1782 link_with : [libshared],
1783 link_whole : [cryptsetup_token_systemd_tpm2_static],
1784 link_depends : cryptsetup_token_sym,
1785 install_rpath : rootlibexecdir,
1787 install_dir : libcryptsetup_plugins_dir)
1791 ############################################################
1793 # systemd-analyze requires 'libcore'
1795 # systemd-journal-remote requires 'libjournal_core'
1796 subdir('src/journal')
1797 # systemd-networkd requires 'libsystemd_network'
1798 subdir('src/libsystemd-network')
1800 subdir('src/analyze')
1801 subdir('src/boot/efi')
1802 subdir('src/busctl')
1803 subdir('src/coredump')
1804 subdir('src/cryptenroll')
1805 subdir('src/cryptsetup')
1807 subdir('src/hostname')
1808 subdir('src/import')
1809 subdir('src/journal-remote')
1810 subdir('src/kernel-install')
1811 subdir('src/locale')
1813 subdir('src/machine')
1814 subdir('src/network')
1815 subdir('src/nspawn')
1817 subdir('src/partition')
1818 subdir('src/portable')
1819 subdir('src/pstore')
1820 subdir('src/resolve')
1822 subdir('src/shutdown')
1823 subdir('src/sysext')
1824 subdir('src/systemctl')
1825 subdir('src/timedate')
1826 subdir('src/timesync')
1827 subdir('src/tmpfiles')
1828 subdir('src/userdb')
1829 subdir('src/vconsole')
1830 subdir('src/xdg-autostart-generator')
1832 subdir('src/systemd')
1839 ############################################################
1841 # only static linking apart from libdl, to make sure that the
1842 # module is linked to all libraries that it uses.
1843 test_dlopen = executable(
1847 include_directories : includes,
1848 link_with : [libbasic],
1849 dependencies : [libdl],
1850 build_by_default : want_tests != 'false')
1852 foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
1853 ['systemd', 'ENABLE_NSS_SYSTEMD', ['nss-systemd.h', 'userdb-glue.c', 'userdb-glue.h']],
1854 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
1855 ['resolve', 'ENABLE_NSS_RESOLVE', [], resolve_includes]]
1857 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
1861 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1862 version_script_arg = project_source_root / sym
1864 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
1865 if tuple.length() > 2
1866 foreach s : tuple[2]
1867 sources += ['src/nss-@0@/@1@'.format(module, s)]
1871 incs = tuple.length() > 3 ? tuple[3] : includes
1873 nss = shared_library(
1878 include_directories : incs,
1879 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
1880 link_args : ['-Wl,-z,nodelete',
1882 '-Wl,--version-script=' + version_script_arg],
1883 link_with : [libsystemd_static,
1886 dependencies : [threads,
1890 install_dir : rootlibdir)
1892 # We cannot use shared_module because it does not support version suffix.
1893 # Unfortunately shared_library insists on creating the symlink…
1894 meson.add_install_script('sh', '-c',
1895 'rm $DESTDIR@0@/libnss_@1@.so'
1896 .format(rootlibdir, module))
1898 if want_tests != 'false'
1899 test('dlopen-nss_' + module,
1901 # path to dlopen must include a slash
1902 args : nss.full_path())
1907 ############################################################
1912 include_directories : includes,
1913 link_with : [libcore,
1915 dependencies : [versiondep,
1922 install_rpath : rootlibexecdir,
1924 install_dir : rootlibexecdir)
1926 meson.add_install_script(meson_make_symlink,
1927 rootlibexecdir / 'systemd',
1928 rootsbindir / 'init')
1930 public_programs += executable(
1932 systemd_analyze_sources,
1933 include_directories : core_includes,
1934 link_with : [libcore,
1936 dependencies : [versiondep,
1943 install_rpath : rootlibexecdir,
1944 install : conf.get('ENABLE_ANALYZE'))
1948 systemd_journald_sources,
1949 include_directories : includes,
1950 link_with : [libjournal_core,
1952 dependencies : [threads,
1957 install_rpath : rootlibexecdir,
1959 install_dir : rootlibexecdir)
1961 public_programs += executable(
1963 systemd_cat_sources,
1964 include_directories : includes,
1965 link_with : [libjournal_core,
1967 dependencies : [threads],
1968 install_rpath : rootlibexecdir,
1971 public_programs += executable(
1974 include_directories : includes,
1975 link_with : [libshared],
1976 dependencies : [threads,
1982 install_rpath : rootlibexecdir,
1984 install_dir : rootbindir)
1987 'systemd-getty-generator',
1988 'src/getty-generator/getty-generator.c',
1989 include_directories : includes,
1990 link_with : [libshared],
1991 install_rpath : rootlibexecdir,
1993 install_dir : systemgeneratordir)
1996 'systemd-debug-generator',
1997 'src/debug-generator/debug-generator.c',
1998 include_directories : includes,
1999 link_with : [libshared],
2000 install_rpath : rootlibexecdir,
2002 install_dir : systemgeneratordir)
2005 'systemd-run-generator',
2006 'src/run-generator/run-generator.c',
2007 include_directories : includes,
2008 link_with : [libshared],
2009 install_rpath : rootlibexecdir,
2011 install_dir : systemgeneratordir)
2014 'systemd-fstab-generator',
2015 'src/fstab-generator/fstab-generator.c',
2016 include_directories : includes,
2017 link_with : [libshared],
2018 install_rpath : rootlibexecdir,
2020 install_dir : systemgeneratordir)
2022 if conf.get('ENABLE_ENVIRONMENT_D') == 1
2024 '30-systemd-environment-d-generator',
2025 'src/environment-d-generator/environment-d-generator.c',
2026 include_directories : includes,
2027 link_with : [libshared],
2028 install_rpath : rootlibexecdir,
2030 install_dir : userenvgeneratordir)
2032 meson.add_install_script(meson_make_symlink,
2033 sysconfdir / 'environment',
2034 environmentdir / '99-environment.conf')
2037 if conf.get('ENABLE_HIBERNATE') == 1
2039 'systemd-hibernate-resume-generator',
2040 'src/hibernate-resume/hibernate-resume-generator.c',
2041 include_directories : includes,
2042 link_with : [libshared],
2043 install_rpath : rootlibexecdir,
2045 install_dir : systemgeneratordir)
2048 'systemd-hibernate-resume',
2049 'src/hibernate-resume/hibernate-resume.c',
2050 include_directories : includes,
2051 link_with : [libshared],
2052 install_rpath : rootlibexecdir,
2054 install_dir : rootlibexecdir)
2057 if conf.get('HAVE_BLKID') == 1
2059 'systemd-gpt-auto-generator',
2060 'src/gpt-auto-generator/gpt-auto-generator.c',
2061 include_directories : includes,
2062 link_with : [libshared],
2063 dependencies : libblkid,
2064 install_rpath : rootlibexecdir,
2066 install_dir : systemgeneratordir)
2068 public_programs += executable(
2070 'src/dissect/dissect.c',
2071 include_directories : includes,
2072 link_with : [libshared],
2073 install_rpath : rootlibexecdir,
2077 if conf.get('ENABLE_RESOLVE') == 1
2080 systemd_resolved_sources,
2081 include_directories : resolve_includes,
2082 link_with : [libshared,
2084 libsystemd_resolve_core],
2085 dependencies : systemd_resolved_dependencies,
2086 install_rpath : rootlibexecdir,
2088 install_dir : rootlibexecdir)
2090 public_programs += executable(
2093 include_directories : includes,
2094 link_with : [libshared,
2096 libsystemd_resolve_core],
2097 dependencies : [threads,
2101 install_rpath : rootlibexecdir,
2104 meson.add_install_script(meson_make_symlink,
2105 bindir / 'resolvectl',
2106 rootsbindir / 'resolvconf')
2108 meson.add_install_script(meson_make_symlink,
2109 bindir / 'resolvectl',
2110 bindir / 'systemd-resolve')
2113 if conf.get('ENABLE_LOGIND') == 1
2116 systemd_logind_sources,
2117 include_directories : includes,
2118 link_with : [liblogind_core,
2120 dependencies : [threads,
2122 install_rpath : rootlibexecdir,
2124 install_dir : rootlibexecdir)
2126 public_programs += executable(
2129 include_directories : includes,
2130 link_with : [libshared],
2131 dependencies : [threads,
2135 install_rpath : rootlibexecdir,
2137 install_dir : rootbindir)
2139 public_programs += executable(
2141 'src/login/inhibit.c',
2142 include_directories : includes,
2143 link_with : [libshared],
2144 install_rpath : rootlibexecdir,
2146 install_dir : rootbindir)
2148 if conf.get('HAVE_PAM') == 1
2149 version_script_arg = project_source_root / pam_systemd_sym
2150 pam_systemd = shared_library(
2154 include_directories : includes,
2155 link_args : ['-shared',
2156 '-Wl,--version-script=' + version_script_arg],
2157 link_with : [libsystemd_static,
2159 dependencies : [threads,
2162 link_depends : pam_systemd_sym,
2164 install_dir : pamlibdir)
2166 if want_tests != 'false'
2167 test('dlopen-pam_systemd',
2169 # path to dlopen must include a slash
2170 args : pam_systemd.full_path())
2175 'systemd-user-runtime-dir',
2176 user_runtime_dir_sources,
2177 include_directories : includes,
2178 link_with : [libshared],
2179 install_rpath : rootlibexecdir,
2181 install_dir : rootlibexecdir)
2184 if conf.get('HAVE_PAM') == 1
2186 'systemd-user-sessions',
2187 'src/user-sessions/user-sessions.c',
2188 include_directories : includes,
2189 link_with : [libshared],
2190 install_rpath : rootlibexecdir,
2192 install_dir : rootlibexecdir)
2195 if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
2196 public_programs += executable(
2198 'src/boot/bootctl.c',
2199 include_directories : includes,
2200 link_with : [libshared],
2201 dependencies : [libblkid],
2202 install_rpath : rootlibexecdir,
2205 public_programs += executable(
2206 'systemd-bless-boot',
2207 'src/boot/bless-boot.c',
2208 include_directories : includes,
2209 link_with : [libshared],
2210 dependencies : [libblkid],
2211 install_rpath : rootlibexecdir,
2213 install_dir : rootlibexecdir)
2216 'systemd-bless-boot-generator',
2217 'src/boot/bless-boot-generator.c',
2218 include_directories : includes,
2219 link_with : [libshared],
2220 install_rpath : rootlibexecdir,
2222 install_dir : systemgeneratordir)
2226 'systemd-boot-check-no-failures',
2227 'src/boot/boot-check-no-failures.c',
2228 include_directories : includes,
2229 link_with : [libshared],
2230 dependencies : [libblkid],
2231 install_rpath : rootlibexecdir,
2233 install_dir : rootlibexecdir)
2235 public_programs += executable(
2236 'systemd-socket-activate',
2237 'src/activate/activate.c',
2238 include_directories : includes,
2239 link_with : [libshared],
2240 dependencies : [threads],
2241 install_rpath : rootlibexecdir,
2244 public_programs += executable(
2247 include_directories : includes,
2248 link_with : systemctl_link_with,
2249 dependencies : [threads,
2255 install_rpath : rootlibexecdir,
2257 install_dir : rootbindir)
2259 if conf.get('ENABLE_PORTABLED') == 1
2261 'systemd-portabled',
2262 systemd_portabled_sources,
2263 include_directories : includes,
2264 link_with : [libshared],
2265 dependencies : [threads],
2266 install_rpath : rootlibexecdir,
2268 install_dir : rootlibexecdir)
2270 public_programs += executable(
2272 'src/portable/portablectl.c',
2273 include_directories : includes,
2274 link_with : [libshared],
2275 dependencies : [threads],
2276 install_rpath : rootlibexecdir,
2278 install_dir : rootbindir)
2281 if conf.get('ENABLE_SYSEXT') == 1
2282 public_programs += executable(
2284 systemd_sysext_sources,
2285 include_directories : includes,
2286 link_with : [libshared],
2287 install_rpath : rootlibexecdir,
2289 install_dir : rootbindir)
2292 if conf.get('ENABLE_USERDB') == 1
2295 systemd_userwork_sources,
2296 include_directories : includes,
2297 link_with : [libshared],
2298 dependencies : [threads],
2299 install_rpath : rootlibexecdir,
2301 install_dir : rootlibexecdir)
2305 systemd_userdbd_sources,
2306 include_directories : includes,
2307 link_with : [libshared],
2308 dependencies : [threads],
2309 install_rpath : rootlibexecdir,
2311 install_dir : rootlibexecdir)
2313 public_programs += executable(
2316 include_directories : includes,
2317 link_with : [libshared],
2318 dependencies : [threads],
2319 install_rpath : rootlibexecdir,
2321 install_dir : rootbindir)
2324 if conf.get('ENABLE_HOMED') == 1
2327 systemd_homework_sources,
2328 include_directories : includes,
2329 link_with : [libshared],
2330 dependencies : [threads,
2336 install_rpath : rootlibexecdir,
2338 install_dir : rootlibexecdir)
2342 systemd_homed_sources,
2343 include_directories : home_includes,
2344 link_with : [libshared],
2345 dependencies : [threads,
2348 install_rpath : rootlibexecdir,
2350 install_dir : rootlibexecdir)
2352 public_programs += executable(
2355 include_directories : includes,
2356 link_with : [libshared],
2357 dependencies : [threads,
2362 install_rpath : rootlibexecdir,
2364 install_dir : rootbindir)
2366 if conf.get('HAVE_PAM') == 1
2367 version_script_arg = project_source_root / pam_systemd_home_sym
2368 pam_systemd = shared_library(
2372 include_directories : includes,
2373 link_args : ['-shared',
2374 '-Wl,--version-script=' + version_script_arg],
2375 link_with : [libsystemd_static,
2377 dependencies : [threads,
2381 link_depends : pam_systemd_home_sym,
2383 install_dir : pamlibdir)
2387 foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
2388 (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
2389 meson.add_install_script(meson_make_symlink,
2390 rootbindir / 'systemctl',
2391 rootsbindir / alias)
2394 meson.add_install_script(meson_make_symlink,
2395 rootbindir / 'udevadm',
2396 rootlibexecdir / 'systemd-udevd')
2398 if conf.get('ENABLE_BACKLIGHT') == 1
2400 'systemd-backlight',
2401 'src/backlight/backlight.c',
2402 include_directories : includes,
2403 link_with : [libshared],
2404 install_rpath : rootlibexecdir,
2406 install_dir : rootlibexecdir)
2409 if conf.get('ENABLE_RFKILL') == 1
2412 'src/rfkill/rfkill.c',
2413 include_directories : includes,
2414 link_with : [libshared],
2415 install_rpath : rootlibexecdir,
2417 install_dir : rootlibexecdir)
2421 'systemd-system-update-generator',
2422 'src/system-update-generator/system-update-generator.c',
2423 include_directories : includes,
2424 link_with : [libshared],
2425 install_rpath : rootlibexecdir,
2427 install_dir : systemgeneratordir)
2429 if conf.get('HAVE_LIBCRYPTSETUP') == 1
2431 'systemd-cryptsetup',
2432 systemd_cryptsetup_sources,
2433 include_directories : includes,
2434 link_with : [libshared],
2435 dependencies : [libcryptsetup,
2437 install_rpath : rootlibexecdir,
2439 install_dir : rootlibexecdir)
2442 'systemd-cryptsetup-generator',
2443 'src/cryptsetup/cryptsetup-generator.c',
2444 include_directories : includes,
2445 link_with : [libshared],
2446 install_rpath : rootlibexecdir,
2448 install_dir : systemgeneratordir)
2451 'systemd-veritysetup',
2452 'src/veritysetup/veritysetup.c',
2453 include_directories : includes,
2454 link_with : [libshared],
2455 dependencies : [libcryptsetup],
2456 install_rpath : rootlibexecdir,
2458 install_dir : rootlibexecdir)
2461 'systemd-veritysetup-generator',
2462 'src/veritysetup/veritysetup-generator.c',
2463 include_directories : includes,
2464 link_with : [libshared],
2465 install_rpath : rootlibexecdir,
2467 install_dir : systemgeneratordir)
2470 'systemd-cryptenroll',
2471 systemd_cryptenroll_sources,
2472 include_directories : includes,
2473 link_with : [libshared],
2474 dependencies : [libcryptsetup,
2478 install_rpath : rootlibexecdir,
2482 if conf.get('HAVE_SYSV_COMPAT') == 1
2484 'systemd-sysv-generator',
2485 'src/sysv-generator/sysv-generator.c',
2486 include_directories : includes,
2487 link_with : [libshared],
2488 install_rpath : rootlibexecdir,
2490 install_dir : systemgeneratordir)
2493 'systemd-rc-local-generator',
2494 'src/rc-local-generator/rc-local-generator.c',
2495 include_directories : includes,
2496 link_with : [libshared],
2497 install_rpath : rootlibexecdir,
2499 install_dir : systemgeneratordir)
2502 if conf.get('ENABLE_XDG_AUTOSTART') == 1
2504 'systemd-xdg-autostart-generator',
2505 systemd_xdg_autostart_generator_sources,
2506 include_directories : includes,
2507 link_with : [libshared],
2508 install_rpath : rootlibexecdir,
2510 install_dir : usergeneratordir)
2513 'systemd-xdg-autostart-condition',
2514 'src/xdg-autostart-generator/xdg-autostart-condition.c',
2515 include_directories : includes,
2516 link_with : [libshared],
2517 install_rpath : rootlibexecdir,
2519 install_dir : rootlibexecdir)
2522 if conf.get('ENABLE_HOSTNAMED') == 1
2524 'systemd-hostnamed',
2525 'src/hostname/hostnamed.c',
2526 include_directories : includes,
2527 link_with : [libshared],
2528 install_rpath : rootlibexecdir,
2530 install_dir : rootlibexecdir)
2532 public_programs += executable(
2534 'src/hostname/hostnamectl.c',
2535 include_directories : includes,
2536 link_with : [libshared],
2537 install_rpath : rootlibexecdir,
2541 if conf.get('ENABLE_LOCALED') == 1
2542 if conf.get('HAVE_XKBCOMMON') == 1
2543 # logind will load libxkbcommon.so dynamically on its own
2551 systemd_localed_sources,
2552 include_directories : includes,
2553 link_with : [libshared],
2554 dependencies : deps,
2555 install_rpath : rootlibexecdir,
2557 install_dir : rootlibexecdir)
2559 public_programs += executable(
2562 include_directories : includes,
2563 link_with : [libshared],
2564 install_rpath : rootlibexecdir,
2568 if conf.get('ENABLE_TIMEDATED') == 1
2570 'systemd-timedated',
2571 'src/timedate/timedated.c',
2572 include_directories : includes,
2573 link_with : [libshared],
2574 install_rpath : rootlibexecdir,
2576 install_dir : rootlibexecdir)
2579 if conf.get('ENABLE_TIMEDATECTL') == 1
2580 public_programs += executable(
2582 'src/timedate/timedatectl.c',
2583 include_directories : includes,
2584 install_rpath : rootlibexecdir,
2585 link_with : [libshared],
2586 dependencies : [libm],
2590 if conf.get('ENABLE_TIMESYNCD') == 1
2592 'systemd-timesyncd',
2593 systemd_timesyncd_sources,
2594 include_directories : includes,
2595 link_with : [libtimesyncd_core],
2596 dependencies : [threads,
2598 install_rpath : rootlibexecdir,
2600 install_dir : rootlibexecdir)
2603 'systemd-time-wait-sync',
2604 'src/timesync/wait-sync.c',
2605 include_directories : includes,
2606 link_with : [libtimesyncd_core],
2607 install_rpath : rootlibexecdir,
2609 install_dir : rootlibexecdir)
2612 if conf.get('ENABLE_MACHINED') == 1
2615 systemd_machined_sources,
2616 include_directories : includes,
2617 link_with : [libmachine_core,
2619 install_rpath : rootlibexecdir,
2621 install_dir : rootlibexecdir)
2623 public_programs += executable(
2625 'src/machine/machinectl.c',
2626 include_directories : includes,
2627 link_with : [libshared],
2628 dependencies : [threads,
2632 install_rpath : rootlibexecdir,
2634 install_dir : rootbindir)
2637 if conf.get('ENABLE_IMPORTD') == 1
2640 systemd_importd_sources,
2641 include_directories : includes,
2642 link_with : [libshared],
2643 dependencies : [threads],
2644 install_rpath : rootlibexecdir,
2646 install_dir : rootlibexecdir)
2648 systemd_pull = executable(
2650 systemd_pull_sources,
2651 include_directories : includes,
2652 link_with : [libshared],
2653 dependencies : [versiondep,
2659 install_rpath : rootlibexecdir,
2661 install_dir : rootlibexecdir)
2663 systemd_import = executable(
2665 systemd_import_sources,
2666 include_directories : includes,
2667 link_with : [libshared],
2668 dependencies : [libcurl,
2672 install_rpath : rootlibexecdir,
2674 install_dir : rootlibexecdir)
2676 systemd_import_fs = executable(
2677 'systemd-import-fs',
2678 systemd_import_fs_sources,
2679 include_directories : includes,
2680 link_with : [libshared],
2681 install_rpath : rootlibexecdir,
2683 install_dir : rootlibexecdir)
2685 systemd_export = executable(
2687 systemd_export_sources,
2688 include_directories : includes,
2689 link_with : [libshared],
2690 dependencies : [libcurl,
2694 install_rpath : rootlibexecdir,
2696 install_dir : rootlibexecdir)
2698 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
2701 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
2702 public_programs += executable(
2703 'systemd-journal-upload',
2704 systemd_journal_upload_sources,
2705 include_directories : includes,
2706 link_with : [libshared],
2707 dependencies : [versiondep,
2714 install_rpath : rootlibexecdir,
2716 install_dir : rootlibexecdir)
2719 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
2720 public_programs += executable(
2721 'systemd-journal-remote',
2722 systemd_journal_remote_sources,
2723 include_directories : includes,
2724 link_with : [libshared,
2725 libsystemd_journal_remote],
2726 dependencies : [threads,
2732 install_rpath : rootlibexecdir,
2734 install_dir : rootlibexecdir)
2736 public_programs += executable(
2737 'systemd-journal-gatewayd',
2738 systemd_journal_gatewayd_sources,
2739 include_directories : includes,
2740 link_with : [libshared],
2741 dependencies : [threads,
2747 install_rpath : rootlibexecdir,
2749 install_dir : rootlibexecdir)
2752 if conf.get('ENABLE_COREDUMP') == 1
2755 systemd_coredump_sources,
2756 include_directories : includes,
2757 link_with : [libshared],
2758 dependencies : [threads,
2764 install_rpath : rootlibexecdir,
2766 install_dir : rootlibexecdir)
2768 public_programs += executable(
2770 coredumpctl_sources,
2771 include_directories : includes,
2772 link_with : [libshared],
2773 dependencies : [threads,
2777 install_rpath : rootlibexecdir,
2781 if conf.get('ENABLE_PSTORE') == 1
2784 systemd_pstore_sources,
2785 include_directories : includes,
2786 link_with : [libshared],
2787 dependencies : [threads,
2793 install_rpath : rootlibexecdir,
2795 install_dir : rootlibexecdir)
2798 if conf.get('ENABLE_OOMD') == 1
2799 executable('systemd-oomd',
2800 systemd_oomd_sources,
2801 include_directories : includes,
2802 link_with : [libshared],
2804 install_rpath : rootlibexecdir,
2806 install_dir : rootlibexecdir)
2808 public_programs += executable(
2811 include_directories : includes,
2812 link_with : [libshared],
2814 install_rpath : rootlibexecdir,
2816 install_dir : rootbindir)
2819 if conf.get('ENABLE_BINFMT') == 1
2820 public_programs += executable(
2822 'src/binfmt/binfmt.c',
2823 include_directories : includes,
2824 link_with : [libshared],
2825 install_rpath : rootlibexecdir,
2827 install_dir : rootlibexecdir)
2829 meson.add_install_script('sh', '-c',
2830 mkdir_p.format(binfmtdir))
2831 if install_sysconfdir
2832 meson.add_install_script('sh', '-c',
2833 mkdir_p.format(sysconfdir / 'binfmt.d'))
2837 if conf.get('ENABLE_REPART') == 1
2840 systemd_repart_sources,
2841 include_directories : includes,
2842 link_with : [libshared],
2843 dependencies : [threads,
2847 install_rpath : rootlibexecdir,
2849 install_dir : rootbindir)
2850 public_programs += exe
2852 if want_tests != 'false'
2855 args : exe.full_path())
2859 if conf.get('ENABLE_VCONSOLE') == 1
2861 'systemd-vconsole-setup',
2862 'src/vconsole/vconsole-setup.c',
2863 include_directories : includes,
2864 link_with : [libshared],
2865 install_rpath : rootlibexecdir,
2867 install_dir : rootlibexecdir)
2870 if conf.get('ENABLE_RANDOMSEED') == 1
2872 'systemd-random-seed',
2873 'src/random-seed/random-seed.c',
2874 include_directories : includes,
2875 link_with : [libshared],
2876 install_rpath : rootlibexecdir,
2878 install_dir : rootlibexecdir)
2881 if conf.get('ENABLE_FIRSTBOOT') == 1
2883 'systemd-firstboot',
2884 'src/firstboot/firstboot.c',
2885 include_directories : includes,
2886 link_with : [libshared],
2887 dependencies : [libcrypt],
2888 install_rpath : rootlibexecdir,
2890 install_dir : rootbindir)
2894 'systemd-remount-fs',
2895 'src/remount-fs/remount-fs.c',
2896 include_directories : includes,
2897 link_with : [libshared],
2898 install_rpath : rootlibexecdir,
2900 install_dir : rootlibexecdir)
2903 'systemd-machine-id-setup',
2904 'src/machine-id-setup/machine-id-setup-main.c',
2905 include_directories : includes,
2906 link_with : [libshared],
2907 install_rpath : rootlibexecdir,
2909 install_dir : rootbindir)
2914 include_directories : includes,
2915 link_with : [libshared],
2916 install_rpath : rootlibexecdir,
2918 install_dir : rootlibexecdir)
2920 executable('systemd-growfs',
2921 'src/partition/growfs.c',
2922 include_directories : includes,
2923 link_with : [libshared],
2924 install_rpath : rootlibexecdir,
2926 install_dir : rootlibexecdir)
2930 'src/partition/makefs.c',
2931 include_directories : includes,
2932 link_with : [libshared],
2933 install_rpath : rootlibexecdir,
2935 install_dir : rootlibexecdir)
2939 'src/sleep/sleep.c',
2940 include_directories : includes,
2941 link_with : [libshared],
2942 install_rpath : rootlibexecdir,
2944 install_dir : rootlibexecdir)
2946 if install_sysconfdir_samples
2947 install_data('src/sleep/sleep.conf',
2948 install_dir : pkgsysconfdir)
2951 public_programs += executable(
2953 'src/sysctl/sysctl.c',
2954 include_directories : includes,
2955 link_with : [libshared],
2956 install_rpath : rootlibexecdir,
2958 install_dir : rootlibexecdir)
2962 'src/ac-power/ac-power.c',
2963 include_directories : includes,
2964 link_with : [libshared],
2965 install_rpath : rootlibexecdir,
2967 install_dir : rootlibexecdir)
2969 public_programs += executable(
2970 'systemd-detect-virt',
2971 'src/detect-virt/detect-virt.c',
2972 include_directories : includes,
2973 link_with : [libshared],
2974 install_rpath : rootlibexecdir,
2977 public_programs += executable(
2979 'src/delta/delta.c',
2980 include_directories : includes,
2981 link_with : [libshared],
2982 install_rpath : rootlibexecdir,
2985 public_programs += executable(
2987 'src/escape/escape.c',
2988 include_directories : includes,
2989 link_with : [libshared],
2990 install_rpath : rootlibexecdir,
2992 install_dir : rootbindir)
2994 public_programs += executable(
2996 'src/notify/notify.c',
2997 include_directories : includes,
2998 link_with : [libshared],
2999 install_rpath : rootlibexecdir,
3001 install_dir : rootbindir)
3003 public_programs += executable(
3005 'src/creds/creds.c',
3006 include_directories : includes,
3007 link_with : [libshared],
3008 dependencies : [threads,
3010 install_rpath : rootlibexecdir,
3012 install_dir : rootbindir)
3015 'systemd-volatile-root',
3016 'src/volatile-root/volatile-root.c',
3017 include_directories : includes,
3018 link_with : [libshared],
3019 install_rpath : rootlibexecdir,
3020 install : conf.get('ENABLE_INITRD') == 1,
3021 install_dir : rootlibexecdir)
3024 'systemd-cgroups-agent',
3025 'src/cgroups-agent/cgroups-agent.c',
3026 include_directories : includes,
3027 link_with : [libshared],
3028 install_rpath : rootlibexecdir,
3030 install_dir : rootlibexecdir)
3032 public_programs += executable(
3034 'src/id128/id128.c',
3035 include_directories : includes,
3036 link_with : [libshared],
3037 install_rpath : rootlibexecdir,
3040 public_programs += executable(
3043 include_directories : includes,
3044 link_with : [libshared],
3045 install_rpath : rootlibexecdir,
3048 public_programs += executable(
3049 'systemd-ask-password',
3050 'src/ask-password/ask-password.c',
3051 include_directories : includes,
3052 link_with : [libshared],
3053 install_rpath : rootlibexecdir,
3055 install_dir : rootbindir)
3058 'systemd-reply-password',
3059 'src/reply-password/reply-password.c',
3060 include_directories : includes,
3061 link_with : [libshared],
3062 install_rpath : rootlibexecdir,
3064 install_dir : rootlibexecdir)
3066 public_programs += executable(
3067 'systemd-tty-ask-password-agent',
3068 'src/tty-ask-password-agent/tty-ask-password-agent.c',
3069 include_directories : includes,
3070 link_with : [libshared],
3071 install_rpath : rootlibexecdir,
3073 install_dir : rootbindir)
3075 public_programs += executable(
3078 include_directories : includes,
3079 link_with : [libshared],
3080 install_rpath : rootlibexecdir,
3083 public_programs += executable(
3085 'src/cgtop/cgtop.c',
3086 include_directories : includes,
3087 link_with : [libshared],
3088 install_rpath : rootlibexecdir,
3093 'src/initctl/initctl.c',
3094 include_directories : includes,
3095 link_with : [libshared],
3096 install_rpath : rootlibexecdir,
3097 install : (conf.get('HAVE_SYSV_COMPAT') == 1),
3098 install_dir : rootlibexecdir)
3100 public_programs += executable(
3102 'src/mount/mount-tool.c',
3103 include_directories : includes,
3104 link_with : [libshared],
3105 dependencies: [libmount],
3106 install_rpath : rootlibexecdir,
3109 meson.add_install_script(meson_make_symlink,
3110 'systemd-mount', bindir / 'systemd-umount')
3112 public_programs += executable(
3115 include_directories : includes,
3116 link_with : [libshared],
3117 install_rpath : rootlibexecdir,
3120 public_programs += executable(
3121 'systemd-stdio-bridge',
3122 'src/stdio-bridge/stdio-bridge.c',
3123 include_directories : includes,
3124 link_with : [libshared],
3125 dependencies : [versiondep],
3126 install_rpath : rootlibexecdir,
3129 public_programs += executable(
3132 include_directories : includes,
3133 link_with : [libshared],
3134 install_rpath : rootlibexecdir,
3140 'src/sysusers/sysusers.c',
3141 include_directories : includes,
3142 link_with : [libshared],
3143 install_rpath : rootlibexecdir,
3145 install_dir : rootbindir)
3146 public_programs += exe
3148 if want_tests != 'false'
3149 test('test-sysusers',
3151 # https://github.com/mesonbuild/meson/issues/2681
3152 args : exe.full_path())
3155 if have_standalone_binaries
3157 'systemd-sysusers.standalone',
3158 'src/sysusers/sysusers.c',
3159 include_directories : includes,
3160 c_args : '-DSTANDALONE',
3161 link_with : [libshared_static,
3166 install_dir : rootbindir)
3167 public_programs += exe
3169 if want_tests != 'false'
3170 test('test-sysusers.standalone',
3172 # https://github.com/mesonbuild/meson/issues/2681
3173 args : exe.full_path())
3178 if conf.get('ENABLE_TMPFILES') == 1
3181 systemd_tmpfiles_sources,
3182 include_directories : includes,
3183 link_with : [libshared],
3184 dependencies : [libacl],
3185 install_rpath : rootlibexecdir,
3187 install_dir : rootbindir)
3188 public_programs += exe
3190 if want_tests != 'false'
3191 test('test-systemd-tmpfiles',
3192 test_systemd_tmpfiles_py,
3193 # https://github.com/mesonbuild/meson/issues/2681
3194 args : exe.full_path())
3197 if have_standalone_binaries
3198 public_programs += executable(
3199 'systemd-tmpfiles.standalone',
3200 systemd_tmpfiles_sources,
3201 include_directories : includes,
3202 c_args : '-DSTANDALONE',
3203 link_with : [libshared_static,
3207 dependencies : [libacl],
3209 install_dir : rootbindir)
3213 if conf.get('ENABLE_HWDB') == 1
3214 systemd_hwdb = executable(
3217 include_directories : includes,
3218 link_with : udev_link_with,
3219 install_rpath : udev_rpath,
3221 install_dir : rootbindir)
3222 public_programs += systemd_hwdb
3224 if want_tests != 'false'
3227 args : [systemd_hwdb.full_path()],
3232 if conf.get('ENABLE_QUOTACHECK') == 1
3234 'systemd-quotacheck',
3235 'src/quotacheck/quotacheck.c',
3236 include_directories : includes,
3237 link_with : [libshared],
3238 install_rpath : rootlibexecdir,
3240 install_dir : rootlibexecdir)
3243 public_programs += executable(
3244 'systemd-socket-proxyd',
3245 'src/socket-proxy/socket-proxyd.c',
3246 include_directories : includes,
3247 link_with : [libshared],
3248 dependencies : [threads],
3249 install_rpath : rootlibexecdir,
3251 install_dir : rootlibexecdir)
3253 public_programs += executable(
3256 include_directories : includes,
3257 link_with : [libudevd_core],
3258 dependencies : [versiondep,
3264 install_rpath : udev_rpath,
3266 install_dir : rootbindir)
3270 systemd_shutdown_sources,
3271 include_directories : includes,
3272 link_with : [libshared],
3273 dependencies : [libmount],
3274 install_rpath : rootlibexecdir,
3276 install_dir : rootlibexecdir)
3279 'systemd-update-done',
3280 'src/update-done/update-done.c',
3281 include_directories : includes,
3282 link_with : [libshared],
3283 install_rpath : rootlibexecdir,
3285 install_dir : rootlibexecdir)
3288 'systemd-update-utmp',
3289 'src/update-utmp/update-utmp.c',
3290 include_directories : includes,
3291 link_with : [libshared],
3292 dependencies : [libaudit],
3293 install_rpath : rootlibexecdir,
3294 install : (conf.get('ENABLE_UTMP') == 1),
3295 install_dir : rootlibexecdir)
3297 if conf.get('HAVE_KMOD') == 1
3299 'systemd-modules-load',
3300 'src/modules-load/modules-load.c',
3301 include_directories : includes,
3302 link_with : [libshared],
3303 dependencies : [libkmod],
3304 install_rpath : rootlibexecdir,
3306 install_dir : rootlibexecdir)
3308 meson.add_install_script('sh', '-c',
3309 mkdir_p.format(modulesloaddir))
3310 if install_sysconfdir
3311 meson.add_install_script('sh', '-c',
3312 mkdir_p.format(sysconfdir / 'modules-load.d'))
3316 public_programs += executable(
3318 systemd_nspawn_sources,
3319 include_directories : includes,
3320 link_with : [libnspawn_core,
3322 dependencies : [libblkid,
3324 install_rpath : rootlibexecdir,
3327 if conf.get('ENABLE_NETWORKD') == 1
3330 systemd_networkd_sources,
3331 include_directories : network_includes,
3332 link_with : [libnetworkd_core,
3334 networkd_link_with],
3335 dependencies : [threads],
3336 install_rpath : rootlibexecdir,
3338 install_dir : rootlibexecdir)
3341 'systemd-networkd-wait-online',
3342 systemd_networkd_wait_online_sources,
3343 include_directories : includes,
3344 link_with : [networkd_link_with],
3345 install_rpath : rootlibexecdir,
3347 install_dir : rootlibexecdir)
3349 public_programs += executable(
3352 include_directories : libsystemd_network_includes,
3353 link_with : [libsystemd_network,
3354 networkd_link_with],
3355 install_rpath : rootlibexecdir,
3357 install_dir : rootbindir)
3360 'systemd-network-generator',
3361 network_generator_sources,
3362 include_directories : includes,
3363 link_with : [networkd_link_with],
3364 install_rpath : rootlibexecdir,
3366 install_dir : rootlibexecdir)
3368 if want_tests != 'false'
3369 test('test-network-generator-conversion',
3370 test_network_generator_conversion_sh,
3371 # https://github.com/mesonbuild/meson/issues/2681
3372 args : exe.full_path())
3377 'systemd-sulogin-shell',
3378 'src/sulogin-shell/sulogin-shell.c',
3379 include_directories : includes,
3380 link_with : [libshared],
3381 install_rpath : rootlibexecdir,
3383 install_dir : rootlibexecdir)
3385 ############################################################
3388 'systemd-runtest.env',
3389 output : 'systemd-runtest.env',
3390 command : [sh, '-c',
3391 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
3392 project_source_root / 'test',
3393 project_build_root / 'catalog')],
3394 build_by_default : true)
3396 test_cflags = ['-DTEST_CODE=1']
3397 # We intentionally do not do inline initializations with definitions for a
3398 # bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
3399 # use the variable unexpectedly. This triggers a lot of maybe-uninitialized
3400 # false positives when the combination of -O2 and -flto is used. Suppress them.
3401 if '-O2' in get_option('c_args') and '-flto=auto' in get_option('c_args')
3402 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
3405 foreach tuple : tests
3407 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3408 dependencies = tuple.length() > 2 ? tuple[2] : []
3409 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3410 condition = tuple.length() > 4 ? tuple[4] : ''
3411 type = tuple.length() > 5 ? tuple[5] : ''
3412 defs = tuple.length() > 6 ? tuple[6] : []
3414 parallel = tuple.length() > 7 ? tuple[7] : true
3417 name = sources[0].split('/')[-1].split('.')[0]
3418 if type.startswith('timeout=')
3419 timeout = type.split('=')[1].to_int()
3423 if condition == '' or conf.get(condition) == 1
3427 include_directories : incs,
3428 link_with : link_with,
3429 dependencies : [versiondep,
3432 build_by_default : want_tests != 'false',
3433 install_rpath : rootlibexecdir,
3434 install : install_tests,
3435 install_dir : testsdir / type)
3438 message('@0@ is a manual test'.format(name))
3439 elif type == 'unsafe' and want_tests != 'unsafe'
3440 message('@0@ is an unsafe test'.format(name))
3441 elif want_tests != 'false'
3447 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
3452 'test-libsystemd-sym',
3453 test_libsystemd_sym_c,
3454 include_directories : includes,
3455 link_with : [libsystemd],
3456 build_by_default : want_tests != 'false',
3457 install : install_tests,
3458 install_dir : testsdir)
3459 if want_tests != 'false'
3460 test('test-libsystemd-sym', exe)
3464 'test-libsystemd-static-sym',
3465 test_libsystemd_sym_c,
3466 include_directories : includes,
3467 link_with : [install_libsystemd_static],
3468 dependencies : [threads], # threads is already included in dependencies on the library,
3469 # but does not seem to get propagated. Add here as a work-around.
3470 build_by_default : want_tests != 'false' and static_libsystemd_pic,
3471 install : install_tests and static_libsystemd_pic,
3472 install_dir : testsdir)
3473 if want_tests != 'false' and static_libsystemd_pic
3474 test('test-libsystemd-static-sym', exe)
3480 include_directories : libudev_includes,
3481 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
3482 link_with : [libudev],
3483 build_by_default : want_tests != 'false',
3484 install : install_tests,
3485 install_dir : testsdir)
3486 if want_tests != 'false'
3487 test('test-libudev-sym', exe)
3491 'test-libudev-static-sym',
3493 include_directories : libudev_includes,
3494 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
3495 link_with : [install_libudev_static],
3496 build_by_default : want_tests != 'false' and static_libudev_pic,
3497 install : install_tests and static_libudev_pic,
3498 install_dir : testsdir)
3499 if want_tests != 'false' and static_libudev_pic
3500 test('test-libudev-static-sym', exe)
3503 ############################################################
3507 foreach tuple : fuzzers
3509 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3510 dependencies = tuple.length() > 2 ? tuple[2] : []
3511 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3512 defs = tuple.length() > 4 ? tuple[4] : []
3516 dependencies += fuzzing_engine
3518 if fuzzing_engine.found()
3519 dependencies += fuzzing_engine
3521 link_args += ['-fsanitize=fuzzer']
3524 sources += 'src/fuzz/fuzz-main.c'
3527 name = sources[0].split('/')[-1].split('.')[0]
3532 include_directories : [incs, include_directories('src/fuzz')],
3533 link_with : link_with,
3534 dependencies : dependencies,
3535 c_args : defs + test_cflags,
3536 link_args: link_args,
3538 build_by_default : fuzzer_build)
3541 if want_tests != 'false'
3542 # Run the fuzz regression tests without any sanitizers enabled.
3543 # Additional invocations with sanitizers may be added below.
3544 foreach p : fuzz_regression_tests
3545 b = p.split('/')[-2]
3546 c = p.split('/')[-1]
3549 test('@0@_@1@'.format(b, c),
3551 args : [project_source_root / p])
3557 alias_target('fuzzers', fuzzer_exes)
3559 ############################################################
3561 subdir('modprobe.d')
3563 subdir('sysusers.d')
3564 subdir('tmpfiles.d')
3570 subdir('shell-completion/bash')
3571 subdir('shell-completion/zsh')
3572 subdir('docs/sysvinit')
3573 subdir('docs/var-log')
3575 install_subdir('factory/etc',
3576 install_dir : factorydir)
3578 if install_sysconfdir
3579 install_data('xorg/50-systemd-user.sh',
3580 install_dir : xinitrcdir)
3582 install_data('LICENSE.GPL2',
3586 'docs/CODING_STYLE.md',
3587 'docs/DISTRO_PORTING.md',
3588 'docs/ENVIRONMENT.md',
3590 'docs/TRANSIENT-SETTINGS.md',
3591 'docs/TRANSLATORS.md',
3592 'docs/UIDS-GIDS.md',
3593 'docs/GVARIANT-SERIALIZATION.md',
3594 install_dir : docdir)
3596 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
3597 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
3599 ############################################################
3601 # Ensure that changes to the docs/ directory do not break the
3602 # basic Github pages build. But only run it in developer mode,
3603 # as it might be fragile due to changes in the tooling, and it is
3604 # not generally useful for users.
3605 jekyll = find_program('jekyll', required : false)
3606 if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
3607 test('github-pages',
3610 '--source', project_source_root / 'docs',
3611 '--destination', project_build_root / '_site'])
3614 ############################################################
3616 check_help = find_program('tools/check-help.sh')
3618 foreach exec : public_programs
3619 name = exec.full_path().split('/')[-1]
3620 if want_tests != 'false'
3621 test('check-help-' + name,
3623 args : exec.full_path())
3627 ############################################################
3629 check_directives_sh = find_program('tools/check-directives.sh')
3631 if want_tests != 'false'
3632 test('check-directives',
3633 check_directives_sh,
3634 args : [project_source_root, project_build_root])
3637 ############################################################
3639 # Enable tests for all supported sanitizers
3640 foreach tuple : sanitizers
3641 sanitizer = tuple[0]
3644 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
3646 foreach p : fuzz_regression_tests
3647 b = p.split('/')[-2]
3648 c = p.split('/')[-1]
3650 name = '@0@:@1@'.format(b, sanitizer)
3653 if want_tests == 'false'
3654 message('Not compiling @0@ because tests is set to false'.format(name))
3656 exe = custom_target(
3660 command : [ln, '-fs',
3661 build.full_path() / b,
3663 build_by_default : true)
3665 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
3671 test('@0@_@1@_@2@'.format(b, c, sanitizer),
3673 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
3675 args : [exe.full_path(),
3676 project_source_root / p])
3683 ############################################################
3686 all_files = run_command(
3687 env, '-u', 'GIT_WORK_TREE',
3688 git, '--git-dir=@0@/.git'.format(project_source_root),
3689 'ls-files', ':/*.[ch]')
3691 all_files = files(all_files.stdout().split())
3696 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
3699 command : [env, 'ctags', '-o', '@0@/tags'.format(project_source_root)] + all_files)
3703 git_contrib_sh = find_program('tools/git-contrib.sh')
3706 command : [git_contrib_sh])
3710 git_head = run_command(
3712 '--git-dir=@0@/.git'.format(project_source_root),
3713 'rev-parse', 'HEAD').stdout().strip()
3714 git_head_short = run_command(
3716 '--git-dir=@0@/.git'.format(project_source_root),
3717 'rev-parse', '--short=7', 'HEAD').stdout().strip()
3721 command : [git, 'archive',
3722 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
3724 '--prefix', 'systemd-@0@/'.format(git_head),
3728 ############################################################
3730 check_api_docs_sh = find_program('tools/check-api-docs.sh')
3733 depends : [man, libsystemd, libudev],
3734 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
3736 alias_target('update-dbus-docs', update_dbus_docs)
3737 alias_target('update-man-rules', update_man_rules)
3739 ############################################################
3741 alt_time_epoch = run_command('date', '-Is', '-u', '-d',
3742 '@@0@'.format(time_epoch)).stdout().strip()
3745 'build mode' : get_option('mode'),
3746 'split /usr' : split_usr,
3747 'split bin-sbin' : split_bin,
3748 'prefix directory' : prefixdir,
3749 'rootprefix directory' : rootprefixdir,
3750 'sysconf directory' : sysconfdir,
3751 'include directory' : includedir,
3752 'lib directory' : libdir,
3753 'rootlib directory' : rootlibdir,
3754 'SysV init scripts' : sysvinit_path,
3755 'SysV rc?.d directories' : sysvrcnd_path,
3756 'PAM modules directory' : pamlibdir,
3757 'PAM configuration directory' : pamconfdir,
3758 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
3759 'RPM macros directory' : rpmmacrosdir,
3760 'modprobe.d directory' : modprobedir,
3761 'D-Bus policy directory' : dbuspolicydir,
3762 'D-Bus session directory' : dbussessionservicedir,
3763 'D-Bus system directory' : dbussystemservicedir,
3764 'bash completions directory' : bashcompletiondir,
3765 'zsh completions directory' : zshcompletiondir,
3766 'extra start script' : get_option('rc-local'),
3767 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
3768 get_option('debug-tty')),
3769 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
3770 conf.get('SYSTEM_ALLOC_UID_MIN')),
3771 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
3772 conf.get('SYSTEM_ALLOC_GID_MIN')),
3773 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
3774 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
3775 'static UID/GID allocations' : ' '.join(static_ugids),
3776 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
3777 'render group access mode' : get_option('group-render-mode'),
3778 'certificate root directory' : get_option('certificate-root'),
3779 'support URL' : support_url,
3780 'nobody user name' : nobody_user,
3781 'nobody group name' : nobody_group,
3782 'fallback hostname' : get_option('fallback-hostname'),
3783 'default DNSSEC mode' : default_dnssec,
3784 'default DNS-over-TLS mode' : default_dns_over_tls,
3785 'default mDNS mode' : default_mdns,
3786 'default LLMNR mode' : default_llmnr,
3787 'default DNS servers' : dns_servers.split(' '),
3788 'default NTP servers' : ntp_servers.split(' '),
3789 'default cgroup hierarchy' : default_hierarchy,
3790 'default net.naming-scheme value' : default_net_naming_scheme,
3791 'default KillUserProcesses value' : kill_user_processes,
3792 'default locale' : default_locale,
3793 'default user $PATH' :
3794 default_user_path != '' ? default_user_path : '(same as system services)',
3795 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
3796 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
3799 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
3800 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
3801 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
3803 if conf.get('ENABLE_EFI') == 1
3804 summary({'efi arch' : efi_arch},
3805 section : 'Extensible Firmware Interface')
3809 'EFI machine type' : EFI_MACHINE_TYPE_NAME,
3810 'EFI CC' : '@0@'.format(' '.join(efi_cc)),
3811 'EFI lds' : efi_lds,
3812 'EFI crt0' : efi_crt0,
3813 'EFI include directory' : efi_incdir},
3814 section : 'Extensible Firmware Interface')
3837 ['libcryptsetup-plugins'],
3863 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
3867 ['gnu-efi', have_gnu_efi],
3875 ['kernel-install', get_option('kernel-install')],
3893 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
3906 ['legacy-pkla', install_polkit_pkla],
3911 ['man pages', want_man],
3912 ['html pages', want_html],
3913 ['man page indices', want_man and have_lxml],
3915 ['compat-mutable-uid-boundaries'],
3918 ['adm group', get_option('adm-group')],
3919 ['wheel group', get_option('wheel-group')],
3922 ['debug mmap cache'],
3924 ['valgrind', conf.get('VALGRIND') == 1],
3925 ['trace logging', conf.get('LOG_TRACE') == 1],
3926 ['install tests', install_tests],
3927 ['link-udev-shared', get_option('link-udev-shared')],
3928 ['link-systemctl-shared', get_option('link-systemctl-shared')],
3929 ['link-networkd-shared', get_option('link-networkd-shared')],
3930 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
3932 ['standalone-binaries', get_option('standalone-binaries')],
3935 if tuple.length() >= 2
3938 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
3939 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
3940 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
3949 if static_libsystemd == 'false'
3950 missing += 'static-libsystemd'
3952 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
3955 if static_libudev == 'false'
3956 missing += 'static-libudev'
3958 found += 'static-libudev(@0@)'.format(static_libudev)
3961 if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
3962 found += 'DNS-over-TLS(gnutls)'
3963 elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
3964 found += 'DNS-over-TLS(openssl)'
3966 missing += 'DNS-over-TLS'
3970 'enabled' : ', '.join(found),
3971 'disabled' : ', '.join(missing)},
3972 section : 'Features')
3974 if rootprefixdir != rootprefix_default
3976 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
3977 'systemd used fixed names for unit file directories and other paths, so anything\n' +
3978 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))