1 # SPDX-License-Identifier: LGPL-2.1-or-later
3 project('systemd', 'c',
13 meson_version : '>= 0.53.2',
16 libsystemd_version = '0.34.0'
17 libudev_version = '1.7.4'
19 conf = configuration_data()
20 conf.set_quoted('PROJECT_URL', 'https://systemd.io/')
21 conf.set('PROJECT_VERSION', meson.project_version(),
22 description : 'Numerical project version (used where a simple number is expected)')
24 # This is to be used instead of meson.source_root(), as the latter will return
25 # the wrong result when systemd is being built as a meson subproject
26 project_source_root = meson.current_source_dir()
27 project_build_root = meson.current_build_dir()
28 relative_source_path = run_command('realpath',
29 '--relative-to=@0@'.format(project_build_root),
31 check : true).stdout().strip()
32 conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)
34 conf.set10('BUILD_MODE_DEVELOPER', get_option('mode') == 'developer',
35 description : 'tailor build to development or release builds')
36 verification = get_option('log-message-verification')
37 if verification == 'auto'
38 verification = conf.get('BUILD_MODE_DEVELOPER') == 1
40 verification = verification == 'true'
42 conf.set10('LOG_MESSAGE_VERIFICATION', verification)
44 want_ossfuzz = get_option('oss-fuzz')
45 want_libfuzzer = get_option('llvm-fuzz')
46 if want_ossfuzz and want_libfuzzer
47 error('only one of oss-fuzz or llvm-fuzz can be specified')
50 skip_deps = want_ossfuzz or get_option('skip-deps')
51 fuzzer_build = want_ossfuzz or want_libfuzzer
53 # If we're building *not* for actual fuzzing, allow input samples of any size
54 # (for testing and for reproduction of issues discovered with previously-higher
56 conf.set10('FUZZ_USE_SIZE_LIMIT', fuzzer_build)
58 # Create a title-less summary section early, so it ends up first in the output.
59 # More items are added later after they have been detected.
60 summary({'build mode' : get_option('mode')})
62 #####################################################################
64 # Try to install the git pre-commit hook
65 add_git_hook_sh = find_program('tools/add-git-hook.sh', required : false)
66 if add_git_hook_sh.found()
67 git_hook = run_command(add_git_hook_sh, check : false)
68 if git_hook.returncode() == 0
69 message(git_hook.stdout().strip())
73 #####################################################################
76 if get_option('split-usr') == 'auto'
77 split_usr = not fs.is_symlink('/bin')
79 split_usr = get_option('split-usr') == 'true'
82 warning('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n\n'
83 + ' split-usr mode is going to be removed\n' +
84 '\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
86 conf.set10('HAVE_SPLIT_USR', split_usr,
87 description : '/usr/bin and /bin directories are separate')
89 if get_option('split-bin') == 'auto'
90 split_bin = not fs.is_symlink('/usr/sbin')
92 split_bin = get_option('split-bin') == 'true'
94 conf.set10('HAVE_SPLIT_BIN', split_bin,
95 description : 'bin and sbin directories are separate')
97 rootprefixdir = get_option('rootprefix')
98 # Unusual rootprefixdir values are used by some distros
99 # (see https://github.com/systemd/systemd/pull/7461).
100 rootprefix_default = split_usr ? '/' : '/usr'
101 if rootprefixdir == ''
102 rootprefixdir = rootprefix_default
104 rootprefixdir_noslash = rootprefixdir == '/' ? '' : rootprefixdir
106 have_standalone_binaries = get_option('standalone-binaries')
108 sysvinit_path = get_option('sysvinit-path')
109 sysvrcnd_path = get_option('sysvrcnd-path')
110 conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '',
111 description : 'SysV init scripts and rcN.d links are supported')
112 conf.set10('CREATE_LOG_DIRS', get_option('create-log-dirs'))
114 if get_option('hibernate') and not get_option('initrd')
115 error('hibernate depends on initrd')
118 conf.set10('BUMP_PROC_SYS_FS_FILE_MAX', get_option('bump-proc-sys-fs-file-max'))
119 conf.set10('BUMP_PROC_SYS_FS_NR_OPEN', get_option('bump-proc-sys-fs-nr-open'))
120 conf.set('HIGH_RLIMIT_NOFILE', 512*1024)
122 # Meson ignores the preceding arguments when joining paths if an absolute
123 # component is encountered, so this should canonicalize various paths when they
124 # are absolute or relative.
125 prefixdir = get_option('prefix')
126 if not prefixdir.startswith('/')
127 error('Prefix is not absolute: "@0@"'.format(prefixdir))
129 if prefixdir != rootprefixdir and rootprefixdir != '/' and not prefixdir.strip('/').startswith(rootprefixdir.strip('/') + '/')
130 error('Prefix is not below root prefix (now rootprefix=@0@ prefix=@1@)'.format(
131 rootprefixdir, prefixdir))
134 bindir = prefixdir / get_option('bindir')
135 libdir = prefixdir / get_option('libdir')
136 sysconfdir = prefixdir / get_option('sysconfdir')
137 includedir = prefixdir / get_option('includedir')
138 datadir = prefixdir / get_option('datadir')
139 localstatedir = '/' / get_option('localstatedir')
141 rootbindir = rootprefixdir / 'bin'
142 rootsbindir = rootprefixdir / (split_bin ? 'sbin' : 'bin')
143 rootlibexecdir = rootprefixdir / 'lib/systemd'
145 rootlibdir = get_option('rootlibdir')
147 rootlibdir = rootprefixdir / libdir.split('/')[-1]
150 install_sysconfdir = get_option('install-sysconfdir') != 'false'
151 install_sysconfdir_samples = get_option('install-sysconfdir') == 'true'
152 # Dirs of external packages
153 pkgconfigdatadir = get_option('pkgconfigdatadir') != '' ? get_option('pkgconfigdatadir') : datadir / 'pkgconfig'
154 pkgconfiglibdir = get_option('pkgconfiglibdir') != '' ? get_option('pkgconfiglibdir') : libdir / 'pkgconfig'
155 polkitpolicydir = datadir / 'polkit-1/actions'
156 polkitrulesdir = datadir / 'polkit-1/rules.d'
157 polkitpkladir = localstatedir / 'lib/polkit-1/localauthority/10-vendor.d'
158 xinitrcdir = get_option('xinitrcdir') != '' ? get_option('xinitrcdir') : sysconfdir / 'X11/xinit/xinitrc.d'
159 rpmmacrosdir = get_option('rpmmacrosdir')
160 if rpmmacrosdir != 'no'
161 rpmmacrosdir = prefixdir / rpmmacrosdir
163 modprobedir = rootprefixdir / 'lib/modprobe.d'
166 pkgdatadir = datadir / 'systemd'
167 environmentdir = prefixdir / 'lib/environment.d'
168 pkgsysconfdir = sysconfdir / 'systemd'
169 userunitdir = prefixdir / 'lib/systemd/user'
170 userpresetdir = prefixdir / 'lib/systemd/user-preset'
171 tmpfilesdir = prefixdir / 'lib/tmpfiles.d'
172 sysusersdir = prefixdir / 'lib/sysusers.d'
173 sysctldir = prefixdir / 'lib/sysctl.d'
174 binfmtdir = prefixdir / 'lib/binfmt.d'
175 modulesloaddir = prefixdir / 'lib/modules-load.d'
176 networkdir = rootprefixdir / 'lib/systemd/network'
177 pkgincludedir = includedir / 'systemd'
178 systemgeneratordir = rootlibexecdir / 'system-generators'
179 usergeneratordir = prefixdir / 'lib/systemd/user-generators'
180 systemenvgeneratordir = prefixdir / 'lib/systemd/system-environment-generators'
181 userenvgeneratordir = prefixdir / 'lib/systemd/user-environment-generators'
182 systemshutdowndir = rootlibexecdir / 'system-shutdown'
183 systemsleepdir = rootlibexecdir / 'system-sleep'
184 systemunitdir = rootprefixdir / 'lib/systemd/system'
185 systempresetdir = rootprefixdir / 'lib/systemd/system-preset'
186 udevlibexecdir = rootprefixdir / 'lib/udev'
187 udevrulesdir = udevlibexecdir / 'rules.d'
188 udevhwdbdir = udevlibexecdir / 'hwdb.d'
189 catalogdir = prefixdir / 'lib/systemd/catalog'
190 kerneldir = prefixdir / 'lib/kernel'
191 kernelinstalldir = kerneldir / 'install.d'
192 factorydir = datadir / 'factory'
193 bootlibdir = prefixdir / 'lib/systemd/boot/efi'
194 testsdir = prefixdir / 'lib/systemd/tests'
195 systemdstatedir = localstatedir / 'lib/systemd'
196 catalogstatedir = systemdstatedir / 'catalog'
197 randomseeddir = localstatedir / 'lib/systemd'
198 profiledir = rootlibexecdir / 'portable' / 'profile'
199 ntpservicelistdir = rootprefixdir / 'lib/systemd/ntp-units.d'
201 docdir = get_option('docdir')
203 docdir = datadir / 'doc/systemd'
206 pamlibdir = get_option('pamlibdir')
208 pamlibdir = rootlibdir / 'security'
211 pamconfdir = get_option('pamconfdir')
213 pamconfdir = prefixdir / 'lib/pam.d'
216 libcryptsetup_plugins_dir = get_option('libcryptsetup-plugins-dir')
217 if libcryptsetup_plugins_dir == ''
218 libcryptsetup_plugins_dir = rootlibdir / 'cryptsetup'
221 memory_accounting_default = get_option('memory-accounting-default')
222 status_unit_format_default = get_option('status-unit-format-default')
224 conf.set_quoted('BINFMT_DIR', binfmtdir)
225 conf.set_quoted('BOOTLIBDIR', bootlibdir)
226 conf.set_quoted('CATALOG_DATABASE', catalogstatedir / 'database')
227 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
228 conf.set_quoted('DOC_DIR', docdir)
229 conf.set_quoted('DOCUMENT_ROOT', pkgdatadir / 'gatewayd')
230 conf.set_quoted('ENVIRONMENT_DIR', environmentdir)
231 conf.set_quoted('INCLUDE_DIR', includedir)
232 conf.set_quoted('LIBDIR', libdir)
233 conf.set_quoted('MODPROBE_DIR', modprobedir)
234 conf.set_quoted('MODULESLOAD_DIR', modulesloaddir)
235 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
236 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', bindir / 'pkttyagent')
237 conf.set_quoted('PREFIX', prefixdir)
238 conf.set_quoted('RANDOM_SEED', randomseeddir / 'random-seed')
239 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
240 conf.set_quoted('RC_LOCAL_PATH', get_option('rc-local'))
241 conf.set_quoted('ROOTBINDIR', rootbindir)
242 conf.set_quoted('ROOTLIBDIR', rootlibdir)
243 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
244 conf.set_quoted('ROOTPREFIX', rootprefixdir)
245 conf.set_quoted('ROOTPREFIX_NOSLASH', rootprefixdir_noslash)
246 conf.set_quoted('SYSCONF_DIR', sysconfdir)
247 conf.set_quoted('SYSCTL_DIR', sysctldir)
248 conf.set_quoted('SYSTEMCTL_BINARY_PATH', rootbindir / 'systemctl')
249 conf.set_quoted('SYSTEMD_BINARY_PATH', rootlibexecdir / 'systemd')
250 conf.set_quoted('SYSTEMD_CATALOG_DIR', catalogdir)
251 conf.set_quoted('SYSTEMD_CGROUPS_AGENT_PATH', rootlibexecdir / 'systemd-cgroups-agent')
252 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', rootlibexecdir / 'systemd-cryptsetup')
253 conf.set_quoted('SYSTEMD_EXPORT_PATH', rootlibexecdir / 'systemd-export')
254 conf.set_quoted('SYSTEMD_FSCK_PATH', rootlibexecdir / 'systemd-fsck')
255 conf.set_quoted('SYSTEMD_GROWFS_PATH', rootlibexecdir / 'systemd-growfs')
256 conf.set_quoted('SYSTEMD_HOMEWORK_PATH', rootlibexecdir / 'systemd-homework')
257 conf.set_quoted('SYSTEMD_IMPORT_FS_PATH', rootlibexecdir / 'systemd-import-fs')
258 conf.set_quoted('SYSTEMD_IMPORT_PATH', rootlibexecdir / 'systemd-import')
259 conf.set_quoted('SYSTEMD_INTEGRITYSETUP_PATH', rootlibexecdir / 'systemd-integritysetup')
260 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', pkgdatadir / 'kbd-model-map')
261 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', pkgdatadir / 'language-fallback-map')
262 conf.set_quoted('SYSTEMD_MAKEFS_PATH', rootlibexecdir / 'systemd-makefs')
263 conf.set_quoted('SYSTEMD_PULL_PATH', rootlibexecdir / 'systemd-pull')
264 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', rootlibexecdir / 'systemd-shutdown')
265 conf.set_quoted('SYSTEMD_TEST_DATA', testsdir / 'testdata')
266 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', rootbindir / 'systemd-tty-ask-password-agent')
267 conf.set_quoted('SYSTEMD_UPDATE_HELPER_PATH', rootlibexecdir / 'systemd-update-helper')
268 conf.set_quoted('SYSTEMD_USERWORK_PATH', rootlibexecdir / 'systemd-userwork')
269 conf.set_quoted('SYSTEMD_VERITYSETUP_PATH', rootlibexecdir / 'systemd-veritysetup')
270 conf.set_quoted('SYSTEM_CONFIG_UNIT_DIR', pkgsysconfdir / 'system')
271 conf.set_quoted('SYSTEM_DATA_UNIT_DIR', systemunitdir)
272 conf.set_quoted('SYSTEM_ENV_GENERATOR_DIR', systemenvgeneratordir)
273 conf.set_quoted('SYSTEM_GENERATOR_DIR', systemgeneratordir)
274 conf.set_quoted('SYSTEM_PRESET_DIR', systempresetdir)
275 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
276 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
277 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
278 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
279 conf.set_quoted('SYSUSERS_DIR', sysusersdir)
280 conf.set_quoted('TMPFILES_DIR', tmpfilesdir)
281 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
282 conf.set_quoted('UDEV_HWDB_DIR', udevhwdbdir)
283 conf.set_quoted('UDEV_RULES_DIR', udevrulesdir)
284 conf.set_quoted('UPDATE_HELPER_USER_TIMEOUT', get_option('update-helper-user-timeout'))
285 conf.set_quoted('USER_CONFIG_UNIT_DIR', pkgsysconfdir / 'user')
286 conf.set_quoted('USER_DATA_UNIT_DIR', userunitdir)
287 conf.set_quoted('USER_ENV_GENERATOR_DIR', userenvgeneratordir)
288 conf.set_quoted('USER_GENERATOR_DIR', usergeneratordir)
289 conf.set_quoted('USER_KEYRING_PATH', pkgsysconfdir / 'import-pubring.gpg')
290 conf.set_quoted('USER_PRESET_DIR', userpresetdir)
291 conf.set_quoted('VENDOR_KEYRING_PATH', rootlibexecdir / 'import-pubring.gpg')
293 conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
294 conf.set10('ENABLE_URLIFY', get_option('urlify'))
295 conf.set10('ENABLE_FEXECVE', get_option('fexecve'))
296 conf.set10('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default)
297 conf.set('STATUS_UNIT_FORMAT_DEFAULT', 'STATUS_UNIT_FORMAT_' + status_unit_format_default.to_upper())
298 conf.set_quoted('STATUS_UNIT_FORMAT_DEFAULT_STR', status_unit_format_default)
300 #####################################################################
302 cc = meson.get_compiler('c')
303 pkgconfig = import('pkgconfig')
304 meson_build_sh = find_program('tools/meson-build.sh')
306 want_tests = get_option('tests')
307 slow_tests = want_tests != 'false' and get_option('slow-tests')
308 fuzz_tests = want_tests != 'false' and get_option('fuzz-tests')
309 install_tests = get_option('install-tests')
311 if add_languages('cpp', required : fuzzer_build)
312 # Used only for tests
313 cxx = meson.get_compiler('cpp')
314 cxx_cmd = ' '.join(cxx.cmd_array())
320 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer', required : false)
321 if fuzzing_engine.found()
322 add_project_arguments('-fsanitize-coverage=trace-pc-guard,trace-cmp', language : 'c')
323 elif cc.has_argument('-fsanitize=fuzzer-no-link')
324 add_project_arguments('-fsanitize=fuzzer-no-link', language : 'c')
326 error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported')
329 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
332 # Those generate many false positives, and we do not want to change the code to
334 basic_disabled_warnings = [
335 '-Wno-format-signedness',
336 '-Wno-missing-field-initializers',
337 '-Wno-unused-parameter',
340 possible_common_cc_flags = [
344 '-Werror=implicit-function-declaration',
345 '-Werror=incompatible-pointer-types',
346 '-Werror=int-conversion',
348 '-Werror=override-init',
349 '-Werror=return-type',
350 '-Werror=shift-count-overflow',
351 '-Werror=shift-overflow=2',
354 '-Wimplicit-fallthrough=5',
357 '-Wmissing-include-dirs',
358 '-Wmissing-noreturn',
360 '-Wold-style-definition',
364 '-Wstrict-aliasing=2',
365 '-Wstrict-prototypes',
366 '-Wsuggest-attribute=noreturn',
370 # negative arguments are correctly detected starting with meson 0.46.
371 '-Wno-error=#warnings', # clang
372 '-Wno-string-plus-int', # clang
375 c_args = get_option('c_args')
377 # Disable -Wmaybe-uninitialized when compiling with -Os/-O1/-O3/etc. There are
378 # too many false positives with gcc >= 8. Effectively, we only test with -O0
379 # and -O2; this should be enough to catch most important cases without too much
380 # busywork. See https://github.com/systemd/systemd/pull/19226.
381 if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or
382 cc.version().version_compare('<10') or
387 possible_common_cc_flags += '-Wno-maybe-uninitialized'
390 # Disable -Wno-unused-result with gcc, see
391 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425.
392 if cc.get_id() == 'gcc'
393 possible_common_cc_flags += '-Wno-unused-result'
396 # --as-needed and --no-undefined are provided by meson by default,
397 # run 'meson configure' to see what is enabled
398 possible_link_flags = [
399 '-Wl,--fatal-warnings',
405 if get_option('b_sanitize') == 'none'
406 possible_link_flags += '-Wl,--warn-common'
409 if cc.get_id() == 'clang'
410 possible_common_cc_flags += [
411 '-Wno-typedef-redefinition',
412 '-Wno-gnu-variable-sized-type-not-at-end',
416 possible_cc_flags = possible_common_cc_flags + [
417 '-Werror=missing-declarations',
418 '-Werror=missing-prototypes',
419 '-fdiagnostics-show-option',
421 '-fno-strict-aliasing',
423 '-fstack-protector-strong',
424 '-fvisibility=hidden',
425 '--param=ssp-buffer-size=4',
428 if get_option('buildtype') != 'debug'
429 possible_cc_flags += [
430 '-ffunction-sections',
434 possible_link_flags += '-Wl,--gc-sections'
437 add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
438 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
439 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
441 have = cc.has_argument('-Wzero-length-bounds')
442 conf.set10('HAVE_ZERO_LENGTH_BOUNDS', have)
446 #include <inttypes.h>
447 typedef uint64_t usec_t;
448 usec_t now(clockid_t clock);
453 ''', args: '-Werror=shadow', name : '-Werror=shadow with local shadowing')
454 add_project_arguments('-Werror=shadow', language : 'c')
458 add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
461 cpp = ' '.join(cc.cmd_array()) + ' -E'
463 has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
465 #####################################################################
466 # compilation result tests
468 conf.set('_GNU_SOURCE', true)
469 conf.set('__SANE_USERSPACE_TYPES__', true)
470 conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)
472 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
473 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
474 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
475 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
476 conf.set('SIZEOF_TIMEX_MEMBER', cc.sizeof('typeof(((struct timex *)0)->freq)', prefix : '#include <sys/timex.h>'))
480 #include <sys/mount.h>
481 #include <sys/stat.h>
482 #include <linux/fs.h>
485 foreach decl : ['char16_t',
491 # We get -1 if the size cannot be determined
492 have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
494 if decl == 'struct statx'
496 want_linux_stat_h = false
498 have = cc.sizeof(decl,
499 prefix : decl_headers + '#include <linux/stat.h>',
500 args : '-D_GNU_SOURCE') > 0
501 want_linux_stat_h = have
505 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
508 conf.set10('WANT_LINUX_STAT_H', want_linux_stat_h)
510 foreach ident : ['secure_getenv', '__secure_getenv']
511 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
515 ['memfd_create', '''#include <sys/mman.h>'''],
516 ['gettid', '''#include <sys/types.h>
517 #include <unistd.h>'''],
518 ['pivot_root', '''#include <stdlib.h>
519 #include <unistd.h>'''], # no known header declares pivot_root
520 ['ioprio_get', '''#include <sched.h>'''], # no known header declares ioprio_get
521 ['ioprio_set', '''#include <sched.h>'''], # no known header declares ioprio_set
522 ['name_to_handle_at', '''#include <sys/types.h>
523 #include <sys/stat.h>
524 #include <fcntl.h>'''],
525 ['setns', '''#include <sched.h>'''],
526 ['renameat2', '''#include <stdio.h>
527 #include <fcntl.h>'''],
528 ['kcmp', '''#include <linux/kcmp.h>'''],
529 ['keyctl', '''#include <sys/types.h>
530 #include <keyutils.h>'''],
531 ['copy_file_range', '''#include <sys/syscall.h>
532 #include <unistd.h>'''],
533 ['bpf', '''#include <sys/syscall.h>
534 #include <unistd.h>'''],
535 ['statx', '''#include <sys/types.h>
536 #include <sys/stat.h>
537 #include <unistd.h>'''],
538 ['explicit_bzero' , '''#include <string.h>'''],
539 ['reallocarray', '''#include <stdlib.h>'''],
540 ['set_mempolicy', '''#include <stdlib.h>
541 #include <unistd.h>'''],
542 ['get_mempolicy', '''#include <stdlib.h>
543 #include <unistd.h>'''],
544 ['pidfd_send_signal', '''#include <stdlib.h>
547 #include <sys/wait.h>'''],
548 ['pidfd_open', '''#include <stdlib.h>
551 #include <sys/wait.h>'''],
552 ['rt_sigqueueinfo', '''#include <stdlib.h>
555 #include <sys/wait.h>'''],
556 ['mallinfo', '''#include <malloc.h>'''],
557 ['mallinfo2', '''#include <malloc.h>'''],
558 ['execveat', '''#include <unistd.h>'''],
559 ['close_range', '''#include <unistd.h>'''],
560 ['epoll_pwait2', '''#include <sys/epoll.h>'''],
561 ['mount_setattr', '''#include <sys/mount.h>'''],
562 ['move_mount', '''#include <sys/mount.h>'''],
563 ['open_tree', '''#include <sys/mount.h>'''],
564 ['getdents64', '''#include <dirent.h>'''],
567 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
568 conf.set10('HAVE_' + ident[0].to_upper(), have)
571 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
572 conf.set10('USE_SYS_RANDOM_H', true)
573 conf.set10('HAVE_GETRANDOM', true)
575 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
576 conf.set10('USE_SYS_RANDOM_H', false)
577 conf.set10('HAVE_GETRANDOM', have)
580 #####################################################################
582 version_tag = get_option('version-tag')
584 vcs_data = configuration_data()
585 vcs_data.set('VCS_TAG', version_tag)
586 version_h = configure_file(configuration : vcs_data,
587 input : 'src/version/version.h.in',
588 output : 'version.h')
591 project_source_root + '/tools/meson-vcs-tag.sh',
593 meson.project_version()]
596 input : 'src/version/version.h.in',
597 output : 'version.h',
601 versiondep = declare_dependency(sources: version_h)
603 shared_lib_tag = get_option('shared-lib-tag')
604 if shared_lib_tag == ''
605 shared_lib_tag = meson.project_version()
608 sh = find_program('sh')
609 echo = find_program('echo')
610 sed = find_program('sed')
611 awk = find_program('awk')
612 stat = find_program('stat')
613 ln = find_program('ln')
614 git = find_program('git', required : false)
615 env = find_program('env')
616 perl = find_program('perl', required : false)
617 rsync = find_program('rsync', required : false)
618 meson_make_symlink = project_source_root + '/tools/meson-make-symlink.sh'
620 mkdir_p = 'mkdir -p $DESTDIR/@0@'
622 # If -Dxxx-path option is found, use that. Otherwise, check in $PATH,
623 # /usr/sbin, /sbin, and fall back to the default from middle column.
624 progs = [['quotaon', '/usr/sbin/quotaon' ],
625 ['quotacheck', '/usr/sbin/quotacheck' ],
626 ['kmod', '/usr/bin/kmod' ],
627 ['kexec', '/usr/sbin/kexec' ],
628 ['sulogin', '/usr/sbin/sulogin' ],
629 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
630 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
631 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
632 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
633 ['nologin', '/usr/sbin/nologin', ],
636 path = get_option(prog[0] + '-path')
638 message('Using @1@ for @0@'.format(prog[0], path))
640 exe = find_program(prog[0],
641 '/usr/sbin/' + prog[0],
644 path = exe.found() ? exe.path() : prog[1]
646 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
647 conf.set_quoted(name, path)
650 conf.set_quoted('TELINIT', get_option('telinit-path'))
652 if run_command(ln, '--relative', '--help', check : false).returncode() != 0
653 error('ln does not support --relative (added in coreutils 8.16)')
656 ############################################################
658 python = find_program('python3')
659 if run_command(python, '-c', 'import jinja2', check : false).returncode() != 0
660 error('python3 jinja2 missing')
663 ############################################################
665 gperf = find_program('gperf')
667 gperf_test_format = '''
669 const char * in_word_set(const char *, @0@);
672 gperf_snippet = run_command(sh, '-c', 'echo foo,bar | "$1" -L ANSI-C', '_', gperf,
674 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
675 if cc.compiles(gperf_test)
676 gperf_len_type = 'size_t'
678 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
679 if cc.compiles(gperf_test)
680 gperf_len_type = 'unsigned'
682 error('unable to determine gperf len type')
685 message('gperf len type is @0@'.format(gperf_len_type))
686 conf.set('GPERF_LEN_TYPE', gperf_len_type,
687 description : 'The type of gperf "len" parameter')
689 ############################################################
691 if not cc.has_header('sys/capability.h')
692 error('POSIX caps headers not found')
694 foreach header : ['crypt.h',
696 'linux/vm_sockets.h',
698 'valgrind/memcheck.h',
699 'valgrind/valgrind.h',
700 'linux/time_types.h',
704 conf.set10('HAVE_' + header.underscorify().to_upper(),
705 cc.has_header(header))
708 ############################################################
710 fallback_hostname = get_option('fallback-hostname')
711 if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0] == '-'
712 error('Invalid fallback-hostname configuration')
713 # A more extensive test is done in test-hostname-util. Let's catch
714 # the most obvious errors here so we don't fail with an assert later.
716 conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
718 default_hierarchy = get_option('default-hierarchy')
719 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
720 description : 'default cgroup hierarchy as string')
721 if default_hierarchy == 'legacy'
722 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
723 elif default_hierarchy == 'hybrid'
724 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
726 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
729 extra_net_naming_schemes = []
730 extra_net_naming_map = []
731 foreach scheme: get_option('extra-net-naming-schemes').split(',')
733 name = scheme.split('=')[0]
734 value = scheme.split('=')[1]
735 NAME = name.underscorify().to_upper()
737 foreach field: value.split('+')
738 VALUE += 'NAMING_' + field.underscorify().to_upper()
740 extra_net_naming_schemes += 'NAMING_@0@ = @1@,'.format(NAME, '|'.join(VALUE))
741 extra_net_naming_map += '{ "@0@", NAMING_@1@ },'.format(name, NAME)
744 conf.set('EXTRA_NET_NAMING_SCHEMES', ' '.join(extra_net_naming_schemes))
745 conf.set('EXTRA_NET_NAMING_MAP', ' '.join(extra_net_naming_map))
747 default_net_naming_scheme = get_option('default-net-naming-scheme')
748 conf.set_quoted('DEFAULT_NET_NAMING_SCHEME', default_net_naming_scheme)
749 if default_net_naming_scheme != 'latest'
750 conf.set('_DEFAULT_NET_NAMING_SCHEME_TEST',
751 'NAMING_' + default_net_naming_scheme.underscorify().to_upper())
754 time_epoch = get_option('time-epoch')
756 time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check : true).stdout().strip()
757 if time_epoch == '' and git.found() and fs.exists('.git')
758 # If we're in a git repository, use the creation time of the latest git tag.
759 latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags',
761 if latest_tag.returncode() == 0
762 time_epoch = run_command(
763 git, 'log', '--no-show-signature', '-1', '--format=%at',
764 latest_tag.stdout().strip(),
765 check : false).stdout()
770 time_epoch = run_command(stat, '-c', '%Y', NEWS,
771 check : true).stdout()
773 time_epoch = time_epoch.to_int()
775 conf.set('TIME_EPOCH', time_epoch)
777 conf.set('CLOCK_VALID_RANGE_USEC_MAX', get_option('clock-valid-range-usec-max'))
779 default_user_shell = get_option('default-user-shell')
780 conf.set_quoted('DEFAULT_USER_SHELL', default_user_shell)
781 conf.set_quoted('DEFAULT_USER_SHELL_NAME', fs.name(default_user_shell))
783 foreach tuple : [['system-alloc-uid-min', 'SYS_UID_MIN', 1], # Also see login.defs(5).
784 ['system-uid-max', 'SYS_UID_MAX', 999],
785 ['system-alloc-gid-min', 'SYS_GID_MIN', 1],
786 ['system-gid-max', 'SYS_GID_MAX', 999]]
787 v = get_option(tuple[0])
791 '/^\s*@0@\s+/ { uid=$2 } END { print uid }'.format(tuple[1]),
793 check : false).stdout().strip()
800 conf.set(tuple[0].underscorify().to_upper(), v)
802 if conf.get('SYSTEM_ALLOC_UID_MIN') >= conf.get('SYSTEM_UID_MAX')
803 error('Invalid uid allocation range')
805 if conf.get('SYSTEM_ALLOC_GID_MIN') >= conf.get('SYSTEM_GID_MAX')
806 error('Invalid gid allocation range')
809 dynamic_uid_min = get_option('dynamic-uid-min')
810 dynamic_uid_max = get_option('dynamic-uid-max')
811 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
812 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
814 container_uid_base_min = get_option('container-uid-base-min')
815 container_uid_base_max = get_option('container-uid-base-max')
816 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
817 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
819 nobody_user = get_option('nobody-user')
820 nobody_group = get_option('nobody-group')
822 if not meson.is_cross_build()
823 getent_result = run_command('getent', 'passwd', '65534', check : false)
824 if getent_result.returncode() == 0
825 name = getent_result.stdout().split(':')[0]
826 if name != nobody_user
828 '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) +
829 'Your build will result in an user table setup that is incompatible with the local system.')
832 id_result = run_command('id', '-u', nobody_user, check : false)
833 if id_result.returncode() == 0
834 id = id_result.stdout().to_int()
837 '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) +
838 'Your build will result in an user table setup that is incompatible with the local system.')
842 getent_result = run_command('getent', 'group', '65534', check : false)
843 if getent_result.returncode() == 0
844 name = getent_result.stdout().split(':')[0]
845 if name != nobody_group
847 '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) +
848 'Your build will result in an group table setup that is incompatible with the local system.')
851 id_result = run_command('id', '-g', nobody_group, check : false)
852 if id_result.returncode() == 0
853 id = id_result.stdout().to_int()
856 '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) +
857 'Your build will result in an group table setup that is incompatible with the local system.')
861 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
863 'The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
864 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
867 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
868 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
871 foreach option : ['adm-gid',
888 'systemd-journal-gid',
889 'systemd-network-uid',
890 'systemd-resolve-uid',
891 'systemd-timesync-uid']
892 name = option.underscorify().to_upper()
893 val = get_option(option)
895 # Ensure provided GID argument is numeric, otherwise fall back to default assignment
896 conf.set(name, val >= 0 ? val : '-')
898 static_ugids += '@0@:@1@'.format(option, val)
902 conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
903 conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
905 dev_kvm_mode = get_option('dev-kvm-mode')
906 conf.set_quoted('DEV_KVM_MODE', dev_kvm_mode) # FIXME: convert to 0o… notation
907 conf.set10('DEV_KVM_UACCESS', dev_kvm_mode != '0666')
908 group_render_mode = get_option('group-render-mode')
909 conf.set_quoted('GROUP_RENDER_MODE', group_render_mode)
910 conf.set10('GROUP_RENDER_UACCESS', group_render_mode != '0666')
912 kill_user_processes = get_option('default-kill-user-processes')
913 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
915 dns_servers = get_option('dns-servers')
916 conf.set_quoted('DNS_SERVERS', dns_servers)
918 ntp_servers = get_option('ntp-servers')
919 conf.set_quoted('NTP_SERVERS', ntp_servers)
921 default_locale = get_option('default-locale')
922 if default_locale == ''
923 if not meson.is_cross_build()
924 choose_default_locale_sh = find_program('tools/choose-default-locale.sh')
925 default_locale = run_command(choose_default_locale_sh,
926 check : true).stdout().strip()
928 default_locale = 'C.UTF-8'
931 conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale)
933 localegen_path = get_option('localegen-path')
934 if localegen_path != ''
935 conf.set_quoted('LOCALEGEN_PATH', localegen_path)
937 conf.set10('HAVE_LOCALEGEN', localegen_path != '')
939 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
941 service_watchdog = get_option('service-watchdog')
942 watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
943 conf.set_quoted('SERVICE_WATCHDOG', watchdog_value)
945 conf.set_quoted('SUSHELL', get_option('debug-shell'))
946 conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
948 enable_debug_hashmap = false
949 enable_debug_mmap_cache = false
950 enable_debug_siphash = false
951 foreach name : get_option('debug-extra')
953 enable_debug_hashmap = true
954 elif name == 'mmap-cache'
955 enable_debug_mmap_cache = true
956 elif name == 'siphash'
957 enable_debug_siphash = true
959 message('unknown debug option "@0@", ignoring'.format(name))
962 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
963 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
964 conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash)
966 conf.set10('VALGRIND', get_option('valgrind'))
967 conf.set10('LOG_TRACE', get_option('log-trace'))
969 default_user_path = get_option('user-path')
970 if default_user_path != ''
971 conf.set_quoted('DEFAULT_USER_PATH', default_user_path)
975 #####################################################################
977 threads = dependency('threads')
978 librt = cc.find_library('rt')
979 libm = cc.find_library('m')
980 libdl = cc.find_library('dl')
981 libcrypt = cc.find_library('crypt')
983 crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
985 ['crypt_ra', crypt_header],
986 ['crypt_preferred_method', crypt_header],
987 ['crypt_gensalt_ra', crypt_header]]
989 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
990 dependencies : libcrypt)
991 conf.set10('HAVE_' + ident[0].to_upper(), have)
994 libcap = dependency('libcap', required : false)
995 if not libcap.found()
996 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
997 libcap = cc.find_library('cap')
1000 want_bpf_framework = get_option('bpf-framework')
1001 bpf_framework_required = want_bpf_framework == 'true'
1003 libbpf = dependency('libbpf', required : bpf_framework_required, version : '>= 0.2')
1004 conf.set10('HAVE_LIBBPF', libbpf.found())
1006 if want_bpf_framework == 'false' or not libbpf.found() or skip_deps
1007 conf.set10('BPF_FRAMEWORK', false)
1009 # Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu
1010 # (like clang-10/llvm-strip-10)
1011 if meson.is_cross_build() or cc.get_id() != 'clang' or cc.cmd_array()[0].contains('afl-clang') or cc.cmd_array()[0].contains('hfuzz-clang')
1012 r = find_program('clang', required : bpf_framework_required, version : '>= 10.0.0')
1013 clang_found = r.found()
1017 # Assume that the required flags are supported by the found clang.
1018 clang_supports_flags = clang_found
1021 clang = cc.cmd_array()
1022 clang_supports_flags = cc.has_argument('-Wno-compare-distinct-pointer-types')
1026 # Check if 'clang -target bpf' is supported.
1027 clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0
1029 clang_supports_bpf = false
1032 # Debian installs this in /usr/sbin/ which is not in $PATH.
1033 # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian.
1034 # We use 'bpftool gen' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6).
1035 bpftool = find_program('bpftool',
1036 '/usr/sbin/bpftool',
1038 version : '>= 5.13.0')
1041 bpftool_strip = true
1043 bpftool_strip = false
1044 bpftool = find_program('bpftool',
1045 '/usr/sbin/bpftool',
1046 required : bpf_framework_required,
1047 version : '>= 5.6.0')
1050 if not bpftool_strip
1051 if not meson.is_cross_build() and clang_found
1052 llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip',
1053 check : true).stdout().strip()
1055 llvm_strip_bin = 'llvm-strip'
1057 llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0')
1060 deps_found = clang_found and clang_supports_bpf and clang_supports_flags and (bpftool_strip or llvm_strip.found()) and bpftool.found()
1062 # Can build BPF program from source code in restricted C
1063 conf.set10('BPF_FRAMEWORK', deps_found)
1066 libmount = dependency('mount',
1067 version : fuzzer_build ? '>= 0' : '>= 2.30')
1069 want_libfdisk = get_option('fdisk')
1070 if want_libfdisk != 'false' and not skip_deps
1071 libfdisk = dependency('fdisk',
1072 version : '>= 2.32',
1073 required : want_libfdisk == 'true')
1074 have = libfdisk.found()
1079 conf.set10('HAVE_LIBFDISK', have)
1081 want_pwquality = get_option('pwquality')
1082 if want_pwquality != 'false' and not skip_deps
1083 libpwquality = dependency('pwquality', required : want_pwquality == 'true')
1084 have = libpwquality.found()
1089 conf.set10('HAVE_PWQUALITY', have)
1091 want_seccomp = get_option('seccomp')
1092 if want_seccomp != 'false' and not skip_deps
1093 libseccomp = dependency('libseccomp',
1094 version : '>= 2.3.1',
1095 required : want_seccomp == 'true')
1096 have = libseccomp.found()
1101 conf.set10('HAVE_SECCOMP', have)
1103 want_selinux = get_option('selinux')
1104 if want_selinux != 'false' and not skip_deps
1105 libselinux = dependency('libselinux',
1106 version : '>= 2.1.9',
1107 required : want_selinux == 'true')
1108 have = libselinux.found()
1113 conf.set10('HAVE_SELINUX', have)
1115 want_apparmor = get_option('apparmor')
1116 if want_apparmor != 'false' and not skip_deps
1117 libapparmor = dependency('libapparmor',
1118 version : '>= 2.13',
1119 required : want_apparmor == 'true')
1120 have = libapparmor.found()
1125 conf.set10('HAVE_APPARMOR', have)
1127 have = get_option('smack') and get_option('smack-run-label') != ''
1128 conf.set10('HAVE_SMACK_RUN_LABEL', have)
1130 conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
1133 want_polkit = get_option('polkit')
1134 install_polkit = false
1135 install_polkit_pkla = false
1136 if want_polkit != 'false' and not skip_deps
1137 install_polkit = true
1139 libpolkit = dependency('polkit-gobject-1',
1141 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
1142 message('Old polkit detected, will install pkla files')
1143 install_polkit_pkla = true
1146 conf.set10('ENABLE_POLKIT', install_polkit)
1148 want_acl = get_option('acl')
1149 if want_acl != 'false' and not skip_deps
1150 libacl = cc.find_library('acl', required : want_acl == 'true')
1151 have = libacl.found()
1156 conf.set10('HAVE_ACL', have)
1158 want_audit = get_option('audit')
1159 if want_audit != 'false' and not skip_deps
1160 libaudit = dependency('audit', required : want_audit == 'true')
1161 have = libaudit.found()
1166 conf.set10('HAVE_AUDIT', have)
1168 want_blkid = get_option('blkid')
1169 if want_blkid != 'false' and not skip_deps
1170 libblkid = dependency('blkid', required : want_blkid == 'true')
1171 have = libblkid.found()
1173 conf.set10('HAVE_BLKID_PROBE_SET_HINT',
1174 have and cc.has_function('blkid_probe_set_hint', dependencies : libblkid))
1179 conf.set10('HAVE_BLKID', have)
1181 want_kmod = get_option('kmod')
1182 if want_kmod != 'false' and not skip_deps
1183 libkmod = dependency('libkmod',
1185 required : want_kmod == 'true')
1186 have = libkmod.found()
1191 conf.set10('HAVE_KMOD', have)
1193 want_pam = get_option('pam')
1194 if want_pam != 'false' and not skip_deps
1195 libpam = cc.find_library('pam', required : want_pam == 'true')
1196 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1197 have = libpam.found() and libpam_misc.found()
1203 conf.set10('HAVE_PAM', have)
1205 want_microhttpd = get_option('microhttpd')
1206 if want_microhttpd != 'false' and not skip_deps
1207 libmicrohttpd = dependency('libmicrohttpd',
1208 version : '>= 0.9.33',
1209 required : want_microhttpd == 'true')
1210 have = libmicrohttpd.found()
1215 conf.set10('HAVE_MICROHTTPD', have)
1217 want_libcryptsetup = get_option('libcryptsetup')
1218 want_libcryptsetup_plugins = get_option('libcryptsetup-plugins')
1220 if want_libcryptsetup_plugins == 'true' and want_libcryptsetup == 'false'
1221 error('libcryptsetup-plugins can not be requested without libcryptsetup')
1224 if want_libcryptsetup != 'false' and not skip_deps
1225 libcryptsetup = dependency('libcryptsetup',
1226 version : want_libcryptsetup_plugins == 'true' ? '>= 2.4.0' : '>= 2.0.1',
1227 required : want_libcryptsetup == 'true' or want_libcryptsetup_plugins == 'true')
1228 have = libcryptsetup.found()
1230 foreach ident : ['crypt_set_metadata_size',
1231 'crypt_activate_by_signed_key',
1233 have_ident = have and cc.has_function(
1235 prefix : '#include <libcryptsetup.h>',
1236 dependencies : libcryptsetup)
1237 conf.set10('HAVE_' + ident.to_upper(), have_ident)
1243 conf.set10('HAVE_LIBCRYPTSETUP', have)
1245 if want_libcryptsetup_plugins != 'false' and not skip_deps
1246 have = (cc.has_function(
1247 'crypt_activate_by_token_pin',
1248 prefix : '#include <libcryptsetup.h>',
1249 dependencies : libcryptsetup) and
1251 'crypt_token_external_path',
1252 prefix : '#include <libcryptsetup.h>',
1253 dependencies : libcryptsetup))
1257 conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have)
1259 want_libcurl = get_option('libcurl')
1260 if want_libcurl != 'false' and not skip_deps
1261 libcurl = dependency('libcurl',
1262 version : '>= 7.32.0',
1263 required : want_libcurl == 'true')
1264 have = libcurl.found()
1269 conf.set10('HAVE_LIBCURL', have)
1270 conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
1272 want_libidn = get_option('libidn')
1273 want_libidn2 = get_option('libidn2')
1274 if want_libidn == 'true' and want_libidn2 == 'true'
1275 error('libidn and libidn2 cannot be requested simultaneously')
1278 if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps
1279 libidn = dependency('libidn2',
1280 required : want_libidn2 == 'true')
1281 have = libidn.found()
1286 conf.set10('HAVE_LIBIDN2', have)
1287 if not have and want_libidn != 'false' and not skip_deps
1288 # libidn is used for both libidn and libidn2 objects
1289 libidn = dependency('libidn',
1290 required : want_libidn == 'true')
1291 have = libidn.found()
1295 conf.set10('HAVE_LIBIDN', have)
1297 want_libiptc = get_option('libiptc')
1298 if want_libiptc != 'false' and not skip_deps
1299 libiptc = dependency('libiptc',
1300 required : want_libiptc == 'true')
1301 have = libiptc.found()
1306 conf.set10('HAVE_LIBIPTC', have)
1308 want_qrencode = get_option('qrencode')
1309 if want_qrencode != 'false' and not skip_deps
1310 libqrencode = dependency('libqrencode',
1312 required : want_qrencode == 'true')
1313 have = libqrencode.found()
1318 conf.set10('HAVE_QRENCODE', have)
1320 want_gcrypt = get_option('gcrypt')
1321 if want_gcrypt != 'false' and not skip_deps
1322 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1323 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1324 have = libgcrypt.found() and libgpg_error.found()
1329 # link to neither of the libs if one is not found
1333 conf.set10('HAVE_GCRYPT', have)
1335 want_gnutls = get_option('gnutls')
1336 if want_gnutls != 'false' and not skip_deps
1337 libgnutls = dependency('gnutls',
1338 version : '>= 3.1.4',
1339 required : want_gnutls == 'true')
1340 have = libgnutls.found()
1345 conf.set10('HAVE_GNUTLS', have)
1347 want_openssl = get_option('openssl')
1348 if want_openssl != 'false' and not skip_deps
1349 libopenssl = dependency('openssl',
1350 version : '>= 1.1.0',
1351 required : want_openssl == 'true')
1352 have = libopenssl.found()
1357 conf.set10('HAVE_OPENSSL', have)
1359 want_p11kit = get_option('p11kit')
1360 if want_p11kit != 'false' and not skip_deps
1361 libp11kit = dependency('p11-kit-1',
1362 version : '>= 0.23.3',
1363 required : want_p11kit == 'true')
1364 have = libp11kit.found()
1369 conf.set10('HAVE_P11KIT', have)
1371 want_libfido2 = get_option('libfido2')
1372 if want_libfido2 != 'false' and not skip_deps
1373 libfido2 = dependency('libfido2',
1374 required : want_libfido2 == 'true')
1375 have = libfido2.found()
1380 conf.set10('HAVE_LIBFIDO2', have)
1382 want_tpm2 = get_option('tpm2')
1383 if want_tpm2 != 'false' and not skip_deps
1384 tpm2 = dependency('tss2-esys tss2-rc tss2-mu',
1385 required : want_tpm2 == 'true')
1391 conf.set10('HAVE_TPM2', have)
1393 want_elfutils = get_option('elfutils')
1394 if want_elfutils != 'false' and not skip_deps
1395 libdw = dependency('libdw',
1396 required : want_elfutils == 'true')
1397 have = libdw.found()
1399 # New in elfutils 0.177
1400 conf.set10('HAVE_DWELF_ELF_E_MACHINE_STRING',
1401 have and cc.has_function('dwelf_elf_e_machine_string', dependencies : libdw))
1406 conf.set10('HAVE_ELFUTILS', have)
1408 want_zlib = get_option('zlib')
1409 if want_zlib != 'false' and not skip_deps
1410 libz = dependency('zlib',
1411 required : want_zlib == 'true')
1417 conf.set10('HAVE_ZLIB', have)
1419 want_bzip2 = get_option('bzip2')
1420 if want_bzip2 != 'false' and not skip_deps
1421 libbzip2 = cc.find_library('bz2',
1422 required : want_bzip2 == 'true')
1423 have = libbzip2.found()
1428 conf.set10('HAVE_BZIP2', have)
1430 want_xz = get_option('xz')
1431 if want_xz != 'false' and not skip_deps
1432 libxz = dependency('liblzma',
1433 required : want_xz == 'true')
1434 have_xz = libxz.found()
1439 conf.set10('HAVE_XZ', have_xz)
1441 want_lz4 = get_option('lz4')
1442 if want_lz4 != 'false' and not skip_deps
1443 liblz4 = dependency('liblz4',
1444 version : '>= 1.3.0',
1445 required : want_lz4 == 'true')
1446 have_lz4 = liblz4.found()
1451 conf.set10('HAVE_LZ4', have_lz4)
1453 want_zstd = get_option('zstd')
1454 if want_zstd != 'false' and not skip_deps
1455 libzstd = dependency('libzstd',
1456 required : want_zstd == 'true',
1457 version : '>= 1.4.0')
1458 have_zstd = libzstd.found()
1463 conf.set10('HAVE_ZSTD', have_zstd)
1465 conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
1467 compression = get_option('default-compression')
1468 if compression == 'auto'
1470 compression = 'zstd'
1476 compression = 'none'
1478 elif compression == 'zstd' and not have_zstd
1479 error('default-compression=zstd requires zstd')
1480 elif compression == 'lz4' and not have_lz4
1481 error('default-compression=lz4 requires lz4')
1482 elif compression == 'xz' and not have_xz
1483 error('default-compression=xz requires xz')
1485 conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper()))
1487 want_xkbcommon = get_option('xkbcommon')
1488 if want_xkbcommon != 'false' and not skip_deps
1489 libxkbcommon = dependency('xkbcommon',
1490 version : '>= 0.3.0',
1491 required : want_xkbcommon == 'true')
1492 have = libxkbcommon.found()
1497 conf.set10('HAVE_XKBCOMMON', have)
1499 want_pcre2 = get_option('pcre2')
1500 if want_pcre2 != 'false'
1501 libpcre2 = dependency('libpcre2-8',
1502 required : want_pcre2 == 'true')
1503 have = libpcre2.found()
1508 conf.set10('HAVE_PCRE2', have)
1510 want_glib = get_option('glib')
1511 if want_glib != 'false' and not skip_deps
1512 libglib = dependency('glib-2.0',
1513 version : '>= 2.22.0',
1514 required : want_glib == 'true')
1515 libgobject = dependency('gobject-2.0',
1516 version : '>= 2.22.0',
1517 required : want_glib == 'true')
1518 libgio = dependency('gio-2.0',
1519 required : want_glib == 'true')
1520 have = libglib.found() and libgobject.found() and libgio.found()
1527 conf.set10('HAVE_GLIB', have)
1529 want_dbus = get_option('dbus')
1530 if want_dbus != 'false' and not skip_deps
1531 libdbus = dependency('dbus-1',
1532 version : '>= 1.3.2',
1533 required : want_dbus == 'true')
1534 have = libdbus.found()
1539 conf.set10('HAVE_DBUS', have)
1541 dbusdatadir = datadir / 'dbus-1'
1542 if conf.get('HAVE_DBUS') == 1
1543 dbusdatadir = libdbus.get_variable(pkgconfig: 'datadir', default_value: datadir) / 'dbus-1'
1546 dbuspolicydir = get_option('dbuspolicydir')
1547 if dbuspolicydir == ''
1548 dbuspolicydir = dbusdatadir / 'system.d'
1551 dbussessionservicedir = get_option('dbussessionservicedir')
1552 if dbussessionservicedir == ''
1553 dbussessionservicedir = dbusdatadir / 'services'
1554 if conf.get('HAVE_DBUS') == 1
1555 dbussessionservicedir = libdbus.get_variable(pkgconfig: 'session_bus_services_dir', default_value: dbussessionservicedir)
1559 dbussystemservicedir = get_option('dbussystemservicedir')
1560 if dbussystemservicedir == ''
1561 dbussystemservicedir = dbusdatadir / 'system-services'
1562 if conf.get('HAVE_DBUS') == 1
1563 dbussystemservicedir = libdbus.get_variable(pkgconfig: 'system_bus_services_dir', default_value: dbussystemservicedir)
1567 dbus_interfaces_dir = get_option('dbus-interfaces-dir')
1568 if dbus_interfaces_dir == '' or dbus_interfaces_dir == 'yes'
1569 if meson.is_cross_build() and dbus_interfaces_dir != 'yes'
1570 dbus_interfaces_dir = 'no'
1571 warning('Exporting D-Bus interface XML files is disabled during cross build. Pass path or "yes" to force enable.')
1573 dbus_interfaces_dir = dbusdatadir / 'interfaces'
1574 if conf.get('HAVE_DBUS') == 1
1575 dbus_interfaces_dir = libdbus.get_variable(pkgconfig: 'interfaces_dir', default_value: dbus_interfaces_dir)
1580 # We support one or the other. If gcrypt is available, we assume it's there to
1581 # be used, and use it in preference.
1582 opt = get_option('cryptolib')
1583 if opt == 'openssl' and conf.get('HAVE_OPENSSL') == 0
1584 error('openssl requested as the default cryptolib, but not available')
1586 conf.set10('PREFER_OPENSSL',
1587 opt == 'openssl' or (opt == 'auto' and conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_GCRYPT') == 0))
1588 conf.set10('HAVE_OPENSSL_OR_GCRYPT',
1589 conf.get('HAVE_OPENSSL') == 1 or conf.get('HAVE_GCRYPT') == 1)
1590 lib_openssl_or_gcrypt = conf.get('PREFER_OPENSSL') == 1 ? [libopenssl] : [libgcrypt, libgpg_error]
1592 dns_over_tls = get_option('dns-over-tls')
1593 if dns_over_tls != 'false'
1594 if dns_over_tls == 'gnutls' and conf.get('PREFER_OPENSSL') == 1
1595 error('Sorry, -Ddns-over-tls=gnutls is not supported when openssl is used as the cryptolib')
1598 if dns_over_tls == 'gnutls'
1599 have_openssl = false
1601 have_openssl = conf.get('HAVE_OPENSSL') == 1
1602 if dns_over_tls == 'openssl' and not have_openssl
1603 error('DNS-over-TLS support was requested with openssl, but dependencies are not available')
1606 if dns_over_tls == 'openssl' or have_openssl
1609 have_gnutls = conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0')
1610 if dns_over_tls != 'auto' and not have_gnutls
1611 str = dns_over_tls == 'gnutls' ? ' with gnutls' : ''
1612 error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
1615 have = have_gnutls or have_openssl
1619 have_openssl = false
1621 conf.set10('ENABLE_DNS_OVER_TLS', have)
1622 conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1623 conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
1625 default_dns_over_tls = get_option('default-dns-over-tls')
1627 default_dns_over_tls = 'no'
1629 if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
1630 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.')
1631 default_dns_over_tls = 'no'
1633 conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1634 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
1635 conf.set_quoted('DEFAULT_DNS_OVER_TLS_MODE_STR', default_dns_over_tls)
1637 default_mdns = get_option('default-mdns')
1638 conf.set('DEFAULT_MDNS_MODE',
1639 'RESOLVE_SUPPORT_' + default_mdns.to_upper())
1640 conf.set_quoted('DEFAULT_MDNS_MODE_STR', default_mdns)
1642 default_llmnr = get_option('default-llmnr')
1643 conf.set('DEFAULT_LLMNR_MODE',
1644 'RESOLVE_SUPPORT_' + default_llmnr.to_upper())
1645 conf.set_quoted('DEFAULT_LLMNR_MODE_STR', default_llmnr)
1647 want_repart = get_option('repart')
1648 if want_repart != 'false'
1649 have = conf.get('HAVE_LIBFDISK') == 1
1650 if want_repart == 'true' and not have
1651 error('repart support was requested, but dependencies are not available')
1656 conf.set10('ENABLE_REPART', have)
1658 default_dnssec = get_option('default-dnssec')
1660 default_dnssec = 'no'
1662 if default_dnssec != 'no' and conf.get('HAVE_OPENSSL_OR_GCRYPT') == 0
1663 message('default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.')
1664 default_dnssec = 'no'
1666 conf.set('DEFAULT_DNSSEC_MODE',
1667 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1668 conf.set_quoted('DEFAULT_DNSSEC_MODE_STR', default_dnssec)
1670 want_sysupdate = get_option('sysupdate')
1671 if want_sysupdate != 'false'
1672 have = (conf.get('HAVE_OPENSSL') == 1 and
1673 conf.get('HAVE_LIBFDISK') == 1)
1674 if want_sysupdate == 'true' and not have
1675 error('sysupdate support was requested, but dependencies are not available')
1680 conf.set10('ENABLE_SYSUPDATE', have)
1682 want_importd = get_option('importd')
1683 if want_importd != 'false'
1684 have = (conf.get('HAVE_LIBCURL') == 1 and
1685 conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and
1686 conf.get('HAVE_ZLIB') == 1 and
1687 conf.get('HAVE_XZ') == 1)
1688 if want_importd == 'true' and not have
1689 error('importd support was requested, but dependencies are not available')
1694 conf.set10('ENABLE_IMPORTD', have)
1696 want_kernel_install = get_option('kernel-install')
1697 conf.set10('ENABLE_KERNEL_INSTALL', want_kernel_install)
1699 want_homed = get_option('homed')
1700 if want_homed != 'false'
1701 have = (conf.get('HAVE_OPENSSL') == 1 and
1702 conf.get('HAVE_LIBFDISK') == 1 and
1703 conf.get('HAVE_LIBCRYPTSETUP') == 1)
1704 if want_homed == 'true' and not have
1705 error('homed support was requested, but dependencies are not available')
1710 conf.set10('ENABLE_HOMED', have)
1712 have = have and conf.get('HAVE_PAM') == 1
1713 conf.set10('ENABLE_PAM_HOME', have)
1715 have = get_option('oomd')
1716 conf.set10('ENABLE_OOMD', have)
1718 want_remote = get_option('remote')
1719 if want_remote != 'false'
1720 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1721 conf.get('HAVE_LIBCURL') == 1]
1722 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1723 # it's possible to build one without the other. Complain only if
1724 # support was explicitly requested. The auxiliary files like sysusers
1725 # config should be installed when any of the programs are built.
1726 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1727 error('remote support was requested, but dependencies are not available')
1729 have = have_deps[0] or have_deps[1]
1733 conf.set10('ENABLE_REMOTE', have)
1735 foreach term : ['analyze',
1749 'compat-mutable-uid-boundaries',
1775 have = get_option(term)
1776 name = 'ENABLE_' + term.underscorify().to_upper()
1777 conf.set10(name, have)
1780 enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
1782 foreach tuple : [['nss-mymachines', 'machined'],
1783 ['nss-resolve', 'resolve']]
1784 want = get_option(tuple[0])
1786 have = get_option(tuple[1])
1787 if want == 'true' and not have
1788 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1793 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1794 conf.set10(name, have)
1798 foreach term : ['ENABLE_NSS_MYHOSTNAME',
1799 'ENABLE_NSS_MYMACHINES',
1800 'ENABLE_NSS_RESOLVE',
1801 'ENABLE_NSS_SYSTEMD']
1802 if conf.get(term) == 1
1806 conf.set10('ENABLE_NSS', enable_nss)
1808 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1810 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1812 ############################################################
1818 ############################################################
1820 # Include these now as they provide gnu-efi detection.
1821 subdir('src/fundamental')
1822 subdir('src/boot/efi')
1824 ############################################################
1826 generate_gperfs = find_program('tools/generate-gperfs.py')
1827 make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
1828 make_directive_index_py = find_program('tools/make-directive-index.py')
1829 make_man_index_py = find_program('tools/make-man-index.py')
1830 meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
1831 update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
1832 update_man_rules_py = find_program('tools/update-man-rules.py')
1833 update_hwdb_sh = find_program('tools/update-hwdb.sh')
1834 update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
1835 update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
1836 xml_helper_py = find_program('tools/xml_helper.py')
1837 export_dbus_interfaces_py = find_program('tools/dbus_exporter.py')
1839 ############################################################
1841 if get_option('b_coverage')
1842 add_project_arguments('-include', 'src/basic/coverage.h', language : 'c')
1845 ############################################################
1847 config_h = configure_file(
1848 output : 'config.h',
1849 configuration : conf)
1851 add_project_arguments('-include', 'config.h', language : 'c')
1853 jinja2_cmdline = [meson_render_jinja2, config_h, version_h]
1855 ############################################################
1857 # binaries that have --help and are intended for use by humans,
1858 # usually, but not always, installed in /bin.
1859 public_programs = []
1861 # D-Bus introspection XML export
1864 basic_includes = include_directories(
1870 libsystemd_includes = [basic_includes, include_directories(
1871 'src/libsystemd/sd-bus',
1872 'src/libsystemd/sd-device',
1873 'src/libsystemd/sd-event',
1874 'src/libsystemd/sd-hwdb',
1875 'src/libsystemd/sd-id128',
1876 'src/libsystemd/sd-journal',
1877 'src/libsystemd/sd-netlink',
1878 'src/libsystemd/sd-network',
1879 'src/libsystemd/sd-resolve')]
1881 includes = [libsystemd_includes, include_directories('src/shared')]
1886 subdir('src/libsystemd')
1887 subdir('src/shared')
1889 subdir('src/libudev')
1890 subdir('src/cryptsetup/cryptsetup-tokens')
1892 libsystemd = shared_library(
1895 version : libsystemd_version,
1896 include_directories : libsystemd_includes,
1897 link_args : ['-shared',
1898 '-Wl,--version-script=' + libsystemd_sym_path],
1899 link_with : [libbasic,
1902 link_whole : [libsystemd_static],
1903 dependencies : [threads,
1905 link_depends : libsystemd_sym,
1907 install_tag: 'libsystemd',
1908 install_dir : rootlibdir)
1910 install_libsystemd_static = static_library(
1914 basic_gcrypt_sources,
1915 basic_compress_sources,
1916 fundamental_sources,
1918 include_directories : libsystemd_includes,
1919 build_by_default : static_libsystemd != 'false',
1920 install : static_libsystemd != 'false',
1921 install_tag: 'libsystemd',
1922 install_dir : rootlibdir,
1923 pic : static_libsystemd_pic,
1924 dependencies : [threads,
1935 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
1937 libudev = shared_library(
1940 version : libudev_version,
1941 include_directories : includes,
1942 link_args : ['-shared',
1943 '-Wl,--version-script=' + libudev_sym_path],
1944 link_with : [libsystemd_static, libshared_static],
1945 link_whole : libudev_basic,
1946 dependencies : [threads],
1947 link_depends : libudev_sym,
1949 install_tag: 'libudev',
1950 install_dir : rootlibdir)
1952 install_libudev_static = static_library(
1955 fundamental_sources,
1960 include_directories : includes,
1961 build_by_default : static_libudev != 'false',
1962 install : static_libudev != 'false',
1963 install_tag: 'libudev',
1964 install_dir : rootlibdir,
1965 link_depends : libudev_sym,
1966 dependencies : libshared_deps + [libmount],
1967 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
1968 pic : static_libudev_pic)
1970 if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
1971 if conf.get('HAVE_TPM2') == 1
1972 cryptsetup_token_systemd_tpm2 = shared_library(
1973 'cryptsetup-token-systemd-tpm2',
1974 cryptsetup_token_systemd_tpm2_sources,
1975 include_directories : includes,
1976 link_args : ['-shared',
1977 '-Wl,--version-script=' + cryptsetup_token_sym_path],
1978 link_with : [lib_cryptsetup_token_common,
1980 dependencies : [libcryptsetup,
1983 link_depends : cryptsetup_token_sym,
1984 install_rpath : rootlibexecdir,
1986 install_dir : libcryptsetup_plugins_dir)
1989 if conf.get('HAVE_LIBFIDO2') == 1
1990 cryptsetup_token_systemd_fido2 = shared_library(
1991 'cryptsetup-token-systemd-fido2',
1992 cryptsetup_token_systemd_fido2_sources,
1993 include_directories : includes,
1994 link_args : ['-shared',
1995 '-Wl,--version-script=' + cryptsetup_token_sym_path],
1996 link_with : [lib_cryptsetup_token_common,
1998 dependencies : [libcryptsetup,
2001 link_depends : cryptsetup_token_sym,
2002 install_rpath : rootlibexecdir,
2004 install_dir : libcryptsetup_plugins_dir)
2007 if conf.get('HAVE_P11KIT') == 1
2008 cryptsetup_token_systemd_pkcs11 = shared_library(
2009 'cryptsetup-token-systemd-pkcs11',
2010 cryptsetup_token_systemd_pkcs11_sources,
2011 include_directories : includes,
2012 link_args : ['-shared',
2013 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2014 link_with : [lib_cryptsetup_token_common,
2016 dependencies : [libcryptsetup,
2019 link_depends : cryptsetup_token_sym,
2020 install_rpath : rootlibexecdir,
2022 install_dir : libcryptsetup_plugins_dir)
2026 ############################################################
2028 # systemd-analyze requires 'libcore'
2030 # systemd-journal-remote requires 'libjournal_core'
2031 subdir('src/journal')
2032 # systemd-networkd requires 'libsystemd_network'
2033 subdir('src/libsystemd-network')
2035 subdir('src/analyze')
2036 subdir('src/busctl')
2037 subdir('src/coredump')
2038 subdir('src/cryptenroll')
2039 subdir('src/cryptsetup')
2041 subdir('src/hostname')
2042 subdir('src/import')
2043 subdir('src/journal-remote')
2044 subdir('src/kernel-install')
2045 subdir('src/locale')
2047 subdir('src/machine')
2048 subdir('src/network')
2049 subdir('src/nspawn')
2051 subdir('src/partition')
2052 subdir('src/portable')
2053 subdir('src/pstore')
2054 subdir('src/resolve')
2056 subdir('src/shutdown')
2057 subdir('src/sysext')
2058 subdir('src/systemctl')
2059 subdir('src/sysupdate')
2060 subdir('src/timedate')
2061 subdir('src/timesync')
2062 subdir('src/tmpfiles')
2063 subdir('src/userdb')
2064 subdir('src/xdg-autostart-generator')
2066 subdir('src/systemd')
2073 ############################################################
2075 # only static linking apart from libdl, to make sure that the
2076 # module is linked to all libraries that it uses.
2077 test_dlopen = executable(
2081 include_directories : includes,
2082 link_with : [libbasic],
2083 dependencies : [libdl],
2084 build_by_default : want_tests != 'false')
2086 foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
2087 ['systemd', 'ENABLE_NSS_SYSTEMD', ['nss-systemd.h', 'userdb-glue.c', 'userdb-glue.h']],
2088 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
2089 ['resolve', 'ENABLE_NSS_RESOLVE', [], resolve_includes]]
2091 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
2095 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
2096 version_script_arg = project_source_root / sym
2098 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
2099 if tuple.length() > 2
2100 foreach s : tuple[2]
2101 sources += ['src/nss-@0@/@1@'.format(module, s)]
2105 incs = tuple.length() > 3 ? tuple[3] : includes
2107 nss = shared_library(
2112 include_directories : incs,
2113 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
2114 link_args : ['-Wl,-z,nodelete',
2116 '-Wl,--version-script=' + version_script_arg],
2117 link_with : [libsystemd_static,
2120 dependencies : [threads,
2124 install_tag : 'nss',
2125 install_dir : rootlibdir)
2127 # We cannot use shared_module because it does not support version suffix.
2128 # Unfortunately shared_library insists on creating the symlink…
2129 meson.add_install_script('sh', '-c',
2130 'rm $DESTDIR@0@/libnss_@1@.so'
2131 .format(rootlibdir, module),
2135 if want_tests != 'false'
2136 test('dlopen-nss_' + module,
2138 # path to dlopen must include a slash
2139 args : nss.full_path(),
2145 ############################################################
2150 include_directories : includes,
2151 link_with : [libcore,
2153 dependencies : [versiondep,
2155 install_rpath : rootlibexecdir,
2157 install_dir : rootlibexecdir)
2158 dbus_programs += exe
2159 public_programs += exe
2161 meson.add_install_script(meson_make_symlink,
2162 rootlibexecdir / 'systemd',
2163 rootsbindir / 'init')
2167 systemd_analyze_sources,
2168 include_directories : core_includes,
2169 link_with : [libcore,
2171 dependencies : [versiondep,
2173 install_rpath : rootlibexecdir,
2174 install : conf.get('ENABLE_ANALYZE'))
2175 public_programs += exe
2177 if want_tests != 'false'
2178 test('test-compare-versions',
2179 test_compare_versions_sh,
2180 args : exe.full_path())
2185 systemd_journald_sources,
2186 include_directories : includes,
2187 link_with : [libjournal_core,
2189 dependencies : [threads,
2194 install_rpath : rootlibexecdir,
2196 install_dir : rootlibexecdir)
2198 public_programs += executable(
2200 systemd_cat_sources,
2201 include_directories : includes,
2202 link_with : [libjournal_core,
2204 dependencies : [threads],
2205 install_rpath : rootlibexecdir,
2208 public_programs += executable(
2211 include_directories : includes,
2212 link_with : [libshared],
2213 dependencies : [threads,
2219 install_rpath : rootlibexecdir,
2221 install_dir : rootbindir)
2224 'systemd-getty-generator',
2225 'src/getty-generator/getty-generator.c',
2226 include_directories : includes,
2227 link_with : [libshared],
2228 install_rpath : rootlibexecdir,
2230 install_dir : systemgeneratordir)
2233 'systemd-debug-generator',
2234 'src/debug-generator/debug-generator.c',
2235 include_directories : includes,
2236 link_with : [libshared],
2237 install_rpath : rootlibexecdir,
2239 install_dir : systemgeneratordir)
2242 'systemd-run-generator',
2243 'src/run-generator/run-generator.c',
2244 include_directories : includes,
2245 link_with : [libshared],
2246 install_rpath : rootlibexecdir,
2248 install_dir : systemgeneratordir)
2251 'systemd-fstab-generator',
2252 'src/fstab-generator/fstab-generator.c',
2253 include_directories : includes,
2254 link_with : [libshared],
2255 install_rpath : rootlibexecdir,
2257 install_dir : systemgeneratordir)
2259 if want_tests != 'false'
2260 test('test-fstab-generator',
2261 test_fstab_generator_sh,
2262 # https://github.com/mesonbuild/meson/issues/2681
2263 args : exe.full_path(),
2267 if conf.get('ENABLE_ENVIRONMENT_D') == 1
2269 '30-systemd-environment-d-generator',
2270 'src/environment-d-generator/environment-d-generator.c',
2271 include_directories : includes,
2272 link_with : [libshared],
2273 install_rpath : rootlibexecdir,
2275 install_dir : userenvgeneratordir)
2277 meson.add_install_script(meson_make_symlink,
2278 sysconfdir / 'environment',
2279 environmentdir / '99-environment.conf')
2282 if conf.get('ENABLE_HIBERNATE') == 1
2284 'systemd-hibernate-resume-generator',
2285 'src/hibernate-resume/hibernate-resume-generator.c',
2286 include_directories : includes,
2287 link_with : [libshared],
2288 install_rpath : rootlibexecdir,
2290 install_dir : systemgeneratordir)
2293 'systemd-hibernate-resume',
2294 'src/hibernate-resume/hibernate-resume.c',
2295 include_directories : includes,
2296 link_with : [libshared],
2297 install_rpath : rootlibexecdir,
2299 install_dir : rootlibexecdir)
2302 if conf.get('HAVE_BLKID') == 1
2304 'systemd-gpt-auto-generator',
2305 'src/gpt-auto-generator/gpt-auto-generator.c',
2306 include_directories : includes,
2307 link_with : [libshared],
2308 dependencies : libblkid,
2309 install_rpath : rootlibexecdir,
2311 install_dir : systemgeneratordir)
2313 public_programs += executable(
2315 'src/dissect/dissect.c',
2316 include_directories : includes,
2317 link_with : [libshared],
2318 install_rpath : rootlibexecdir,
2322 if conf.get('ENABLE_RESOLVE') == 1
2323 dbus_programs += executable(
2325 systemd_resolved_sources,
2326 include_directories : resolve_includes,
2327 link_with : [libshared,
2329 libsystemd_resolve_core],
2330 dependencies : systemd_resolved_dependencies,
2331 install_rpath : rootlibexecdir,
2333 install_dir : rootlibexecdir)
2335 public_programs += executable(
2338 include_directories : includes,
2339 link_with : [libshared,
2341 libsystemd_resolve_core],
2342 dependencies : [threads,
2343 lib_openssl_or_gcrypt,
2346 install_rpath : rootlibexecdir,
2349 meson.add_install_script(meson_make_symlink,
2350 bindir / 'resolvectl',
2351 rootsbindir / 'resolvconf')
2353 meson.add_install_script(meson_make_symlink,
2354 bindir / 'resolvectl',
2355 bindir / 'systemd-resolve')
2358 if conf.get('ENABLE_LOGIND') == 1
2359 dbus_programs += executable(
2361 systemd_logind_sources,
2362 include_directories : includes,
2363 link_with : [liblogind_core,
2365 dependencies : [threads,
2367 install_rpath : rootlibexecdir,
2369 install_dir : rootlibexecdir)
2371 public_programs += executable(
2374 include_directories : includes,
2375 link_with : [libshared],
2376 dependencies : [threads,
2380 install_rpath : rootlibexecdir,
2382 install_dir : rootbindir)
2384 public_programs += executable(
2386 'src/login/inhibit.c',
2387 include_directories : includes,
2388 link_with : [libshared],
2389 install_rpath : rootlibexecdir,
2391 install_dir : rootbindir)
2393 if conf.get('HAVE_PAM') == 1
2394 version_script_arg = project_source_root / pam_systemd_sym
2395 pam_systemd = shared_library(
2399 include_directories : includes,
2400 link_args : ['-shared',
2401 '-Wl,--version-script=' + version_script_arg],
2402 link_with : [libsystemd_static,
2404 dependencies : [threads,
2407 link_depends : pam_systemd_sym,
2409 install_tag : 'pam',
2410 install_dir : pamlibdir)
2412 if want_tests != 'false'
2413 test('dlopen-pam_systemd',
2415 # path to dlopen must include a slash
2416 args : pam_systemd.full_path(),
2417 depends : pam_systemd)
2422 'systemd-user-runtime-dir',
2423 user_runtime_dir_sources,
2424 include_directories : includes,
2425 link_with : [libshared],
2426 install_rpath : rootlibexecdir,
2428 install_dir : rootlibexecdir)
2431 if conf.get('HAVE_PAM') == 1
2433 'systemd-user-sessions',
2434 'src/user-sessions/user-sessions.c',
2435 include_directories : includes,
2436 link_with : [libshared],
2437 install_rpath : rootlibexecdir,
2439 install_dir : rootlibexecdir)
2442 if conf.get('HAVE_BLKID') == 1 and conf.get('HAVE_GNU_EFI') == 1
2443 if get_option('link-boot-shared')
2444 boot_link_with = [libshared]
2446 boot_link_with = [libsystemd_static, libshared_static]
2449 public_programs += executable(
2451 'src/boot/bootctl.c',
2452 include_directories : includes,
2453 link_with : [boot_link_with],
2454 dependencies : [libblkid],
2455 install_rpath : rootlibexecdir,
2458 public_programs += executable(
2459 'systemd-bless-boot',
2460 'src/boot/bless-boot.c',
2461 include_directories : includes,
2462 link_with : [boot_link_with],
2463 dependencies : [libblkid],
2464 install_rpath : rootlibexecdir,
2466 install_dir : rootlibexecdir)
2469 'systemd-bless-boot-generator',
2470 'src/boot/bless-boot-generator.c',
2471 include_directories : includes,
2472 link_with : [boot_link_with],
2473 install_rpath : rootlibexecdir,
2475 install_dir : systemgeneratordir)
2479 'systemd-boot-check-no-failures',
2480 'src/boot/boot-check-no-failures.c',
2481 include_directories : includes,
2482 link_with : [libshared],
2483 dependencies : [libblkid],
2484 install_rpath : rootlibexecdir,
2486 install_dir : rootlibexecdir)
2488 public_programs += executable(
2489 'systemd-socket-activate',
2490 'src/activate/activate.c',
2491 include_directories : includes,
2492 link_with : [libshared],
2493 dependencies : [threads],
2494 install_rpath : rootlibexecdir,
2497 systemctl = executable(
2500 include_directories : includes,
2501 link_with : systemctl_link_with,
2502 dependencies : [threads,
2508 install_rpath : rootlibexecdir,
2510 install_dir : rootbindir)
2511 public_programs += systemctl
2513 if conf.get('ENABLE_PORTABLED') == 1
2514 dbus_programs += executable(
2515 'systemd-portabled',
2516 systemd_portabled_sources,
2517 include_directories : includes,
2518 link_with : [libshared],
2519 dependencies : [threads, libselinux],
2520 install_rpath : rootlibexecdir,
2522 install_dir : rootlibexecdir)
2524 public_programs += executable(
2526 'src/portable/portablectl.c',
2527 include_directories : includes,
2528 link_with : [libshared],
2529 dependencies : [threads],
2530 install_rpath : rootlibexecdir,
2532 install_dir : rootbindir)
2535 if conf.get('ENABLE_SYSEXT') == 1
2536 public_programs += executable(
2538 systemd_sysext_sources,
2539 include_directories : includes,
2540 link_with : [libshared],
2541 install_rpath : rootlibexecdir,
2543 install_dir : rootbindir)
2546 if conf.get('ENABLE_USERDB') == 1
2549 systemd_userwork_sources,
2550 include_directories : includes,
2551 link_with : [libshared],
2552 dependencies : [threads],
2553 install_rpath : rootlibexecdir,
2555 install_dir : rootlibexecdir)
2559 systemd_userdbd_sources,
2560 include_directories : includes,
2561 link_with : [libshared],
2562 dependencies : [threads],
2563 install_rpath : rootlibexecdir,
2565 install_dir : rootlibexecdir)
2567 public_programs += executable(
2570 include_directories : includes,
2571 link_with : [libshared],
2572 dependencies : [threads],
2573 install_rpath : rootlibexecdir,
2575 install_dir : rootbindir)
2578 if conf.get('ENABLE_HOMED') == 1
2581 systemd_homework_sources,
2582 include_directories : includes,
2583 link_with : [libshared],
2584 dependencies : [threads,
2590 install_rpath : rootlibexecdir,
2592 install_dir : rootlibexecdir)
2594 dbus_programs += executable(
2596 systemd_homed_sources,
2597 include_directories : home_includes,
2598 link_with : [libshared],
2599 dependencies : [threads,
2603 install_rpath : rootlibexecdir,
2605 install_dir : rootlibexecdir)
2607 public_programs += executable(
2610 include_directories : includes,
2611 link_with : [libshared],
2612 dependencies : [threads,
2617 install_rpath : rootlibexecdir,
2619 install_dir : rootbindir)
2621 if conf.get('HAVE_PAM') == 1
2622 version_script_arg = project_source_root / pam_systemd_home_sym
2623 pam_systemd = shared_library(
2627 include_directories : includes,
2628 link_args : ['-shared',
2629 '-Wl,--version-script=' + version_script_arg],
2630 link_with : [libsystemd_static,
2632 dependencies : [threads,
2636 link_depends : pam_systemd_home_sym,
2638 install_tag : 'pam',
2639 install_dir : pamlibdir)
2643 foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
2644 (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
2645 meson.add_install_script(meson_make_symlink,
2646 rootbindir / 'systemctl',
2647 rootsbindir / alias)
2650 meson.add_install_script(meson_make_symlink,
2651 rootbindir / 'udevadm',
2652 rootlibexecdir / 'systemd-udevd')
2654 if conf.get('ENABLE_BACKLIGHT') == 1
2656 'systemd-backlight',
2657 'src/backlight/backlight.c',
2658 include_directories : includes,
2659 link_with : [libshared],
2660 install_rpath : rootlibexecdir,
2662 install_dir : rootlibexecdir)
2665 if conf.get('ENABLE_RFKILL') == 1
2668 'src/rfkill/rfkill.c',
2669 include_directories : includes,
2670 link_with : [libshared],
2671 install_rpath : rootlibexecdir,
2673 install_dir : rootlibexecdir)
2677 'systemd-system-update-generator',
2678 'src/system-update-generator/system-update-generator.c',
2679 include_directories : includes,
2680 link_with : [libshared],
2681 install_rpath : rootlibexecdir,
2683 install_dir : systemgeneratordir)
2685 if conf.get('HAVE_LIBCRYPTSETUP') == 1
2687 'systemd-cryptsetup',
2688 systemd_cryptsetup_sources,
2689 include_directories : includes,
2690 link_with : [libshared],
2691 dependencies : [libcryptsetup,
2693 install_rpath : rootlibexecdir,
2695 install_dir : rootlibexecdir)
2698 'systemd-cryptsetup-generator',
2699 'src/cryptsetup/cryptsetup-generator.c',
2700 include_directories : includes,
2701 link_with : [libshared],
2702 install_rpath : rootlibexecdir,
2704 install_dir : systemgeneratordir)
2707 'systemd-veritysetup',
2708 'src/veritysetup/veritysetup.c',
2709 include_directories : includes,
2710 link_with : [libshared],
2711 dependencies : [libcryptsetup],
2712 install_rpath : rootlibexecdir,
2714 install_dir : rootlibexecdir)
2717 'systemd-veritysetup-generator',
2718 'src/veritysetup/veritysetup-generator.c',
2719 include_directories : includes,
2720 link_with : [libshared],
2721 install_rpath : rootlibexecdir,
2723 install_dir : systemgeneratordir)
2725 public_programs += executable(
2726 'systemd-cryptenroll',
2727 systemd_cryptenroll_sources,
2728 include_directories : includes,
2729 link_with : [libshared],
2730 dependencies : [libcryptsetup,
2734 install_rpath : rootlibexecdir,
2738 'systemd-integritysetup',
2739 ['src/integritysetup/integritysetup.c', 'src/integritysetup/integrity-util.c'],
2740 include_directories : includes,
2741 link_with : [libshared],
2742 dependencies : [libcryptsetup],
2743 install_rpath : rootlibexecdir,
2745 install_dir : rootlibexecdir)
2748 'systemd-integritysetup-generator',
2749 ['src/integritysetup/integritysetup-generator.c', 'src/integritysetup/integrity-util.c'],
2750 include_directories : includes,
2751 link_with : [libshared],
2752 install_rpath : rootlibexecdir,
2754 install_dir : systemgeneratordir)
2757 if conf.get('HAVE_SYSV_COMPAT') == 1
2759 'systemd-sysv-generator',
2760 'src/sysv-generator/sysv-generator.c',
2761 include_directories : includes,
2762 link_with : [libshared],
2763 install_rpath : rootlibexecdir,
2765 install_dir : systemgeneratordir)
2767 sysv_generator_test_py = find_program('test/sysv-generator-test.py')
2768 if want_tests != 'false'
2769 test('sysv-generator-test',
2770 sysv_generator_test_py,
2775 'systemd-rc-local-generator',
2776 'src/rc-local-generator/rc-local-generator.c',
2777 include_directories : includes,
2778 link_with : [libshared],
2779 install_rpath : rootlibexecdir,
2781 install_dir : systemgeneratordir)
2784 if conf.get('ENABLE_XDG_AUTOSTART') == 1
2786 'systemd-xdg-autostart-generator',
2787 systemd_xdg_autostart_generator_sources,
2788 include_directories : includes,
2789 link_with : [libshared],
2790 install_rpath : rootlibexecdir,
2792 install_dir : usergeneratordir)
2795 'systemd-xdg-autostart-condition',
2796 'src/xdg-autostart-generator/xdg-autostart-condition.c',
2797 include_directories : includes,
2798 link_with : [libshared],
2799 install_rpath : rootlibexecdir,
2801 install_dir : rootlibexecdir)
2804 if conf.get('ENABLE_HOSTNAMED') == 1
2805 dbus_programs += executable(
2806 'systemd-hostnamed',
2807 'src/hostname/hostnamed.c',
2808 include_directories : includes,
2809 link_with : [libshared],
2810 install_rpath : rootlibexecdir,
2812 install_dir : rootlibexecdir)
2814 public_programs += executable(
2816 'src/hostname/hostnamectl.c',
2817 include_directories : includes,
2818 link_with : [libshared],
2819 install_rpath : rootlibexecdir,
2823 if conf.get('ENABLE_LOCALED') == 1
2824 if conf.get('HAVE_XKBCOMMON') == 1
2825 # logind will load libxkbcommon.so dynamically on its own, but we still
2826 # need to specify where the headers are
2827 deps = [libdl, libxkbcommon.partial_dependency(compile_args: true)]
2832 dbus_programs += executable(
2834 systemd_localed_sources,
2835 include_directories : includes,
2836 link_with : [libshared],
2837 dependencies : deps,
2838 install_rpath : rootlibexecdir,
2840 install_dir : rootlibexecdir)
2842 public_programs += executable(
2845 include_directories : includes,
2846 link_with : [libshared],
2847 install_rpath : rootlibexecdir,
2851 if conf.get('ENABLE_TIMEDATED') == 1
2852 dbus_programs += executable(
2853 'systemd-timedated',
2854 'src/timedate/timedated.c',
2855 include_directories : includes,
2856 link_with : [libshared],
2857 install_rpath : rootlibexecdir,
2859 install_dir : rootlibexecdir)
2862 if conf.get('ENABLE_TIMEDATECTL') == 1
2863 public_programs += executable(
2865 'src/timedate/timedatectl.c',
2866 include_directories : includes,
2867 install_rpath : rootlibexecdir,
2868 link_with : [libshared],
2869 dependencies : [libm],
2873 if conf.get('ENABLE_TIMESYNCD') == 1
2875 'systemd-timesyncd',
2876 systemd_timesyncd_sources,
2877 include_directories : includes,
2878 link_with : [libtimesyncd_core],
2879 dependencies : [threads,
2881 install_rpath : rootlibexecdir,
2883 install_dir : rootlibexecdir)
2886 'systemd-time-wait-sync',
2887 'src/timesync/wait-sync.c',
2888 include_directories : includes,
2889 link_with : [libtimesyncd_core],
2890 install_rpath : rootlibexecdir,
2892 install_dir : rootlibexecdir)
2895 if conf.get('ENABLE_MACHINED') == 1
2896 dbus_programs += executable(
2898 systemd_machined_sources,
2899 include_directories : includes,
2900 link_with : [libmachine_core,
2902 install_rpath : rootlibexecdir,
2904 install_dir : rootlibexecdir)
2906 public_programs += executable(
2908 'src/machine/machinectl.c',
2909 include_directories : includes,
2910 link_with : [libshared],
2911 dependencies : [threads,
2915 install_rpath : rootlibexecdir,
2917 install_dir : rootbindir)
2920 if conf.get('ENABLE_IMPORTD') == 1
2921 dbus_programs += executable(
2923 systemd_importd_sources,
2924 include_directories : includes,
2925 link_with : [libshared],
2926 dependencies : [threads],
2927 install_rpath : rootlibexecdir,
2929 install_dir : rootlibexecdir)
2931 systemd_pull = executable(
2933 systemd_pull_sources,
2934 include_directories : includes,
2935 link_with : [libshared,
2937 dependencies : [versiondep,
2939 lib_openssl_or_gcrypt,
2943 install_rpath : rootlibexecdir,
2945 install_dir : rootlibexecdir)
2947 systemd_import = executable(
2949 systemd_import_sources,
2950 include_directories : includes,
2951 link_with : [libshared,
2953 dependencies : [libcurl,
2957 install_rpath : rootlibexecdir,
2959 install_dir : rootlibexecdir)
2961 systemd_import_fs = executable(
2962 'systemd-import-fs',
2963 systemd_import_fs_sources,
2964 include_directories : includes,
2965 link_with : [libshared,
2967 install_rpath : rootlibexecdir,
2969 install_dir : rootlibexecdir)
2971 systemd_export = executable(
2973 systemd_export_sources,
2974 include_directories : includes,
2975 link_with : [libshared,
2977 dependencies : [libcurl,
2981 install_rpath : rootlibexecdir,
2983 install_dir : rootlibexecdir)
2985 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
2988 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
2989 public_programs += executable(
2990 'systemd-journal-upload',
2991 systemd_journal_upload_sources,
2992 include_directories : includes,
2993 link_with : [libshared],
2994 dependencies : [versiondep,
3001 install_rpath : rootlibexecdir,
3003 install_dir : rootlibexecdir)
3006 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
3007 public_programs += executable(
3008 'systemd-journal-remote',
3009 systemd_journal_remote_sources,
3010 include_directories : journal_includes,
3011 link_with : [libshared,
3012 libsystemd_journal_remote],
3013 dependencies : [threads,
3019 install_rpath : rootlibexecdir,
3021 install_dir : rootlibexecdir)
3023 public_programs += executable(
3024 'systemd-journal-gatewayd',
3025 systemd_journal_gatewayd_sources,
3026 include_directories : journal_includes,
3027 link_with : [libshared],
3028 dependencies : [threads,
3034 install_rpath : rootlibexecdir,
3036 install_dir : rootlibexecdir)
3039 if conf.get('ENABLE_COREDUMP') == 1
3042 systemd_coredump_sources,
3043 include_directories : includes,
3044 link_with : [libshared,
3046 dependencies : [threads,
3051 install_rpath : rootlibexecdir,
3053 install_dir : rootlibexecdir)
3055 public_programs += executable(
3057 coredumpctl_sources,
3058 include_directories : includes,
3059 link_with : [libshared,
3061 dependencies : [threads,
3065 install_rpath : rootlibexecdir,
3069 if conf.get('ENABLE_PSTORE') == 1
3072 systemd_pstore_sources,
3073 include_directories : includes,
3074 link_with : [libshared],
3075 dependencies : [threads,
3080 install_rpath : rootlibexecdir,
3082 install_dir : rootlibexecdir)
3085 if conf.get('ENABLE_OOMD') == 1
3086 dbus_programs += executable('systemd-oomd',
3087 systemd_oomd_sources,
3088 include_directories : includes,
3089 link_with : [libshared],
3091 install_rpath : rootlibexecdir,
3093 install_dir : rootlibexecdir)
3095 public_programs += executable(
3098 include_directories : includes,
3099 link_with : [libshared],
3101 install_rpath : rootlibexecdir,
3105 if conf.get('ENABLE_BINFMT') == 1
3106 public_programs += executable(
3108 'src/binfmt/binfmt.c',
3109 include_directories : includes,
3110 link_with : [libshared],
3111 install_rpath : rootlibexecdir,
3113 install_dir : rootlibexecdir)
3115 meson.add_install_script('sh', '-c',
3116 mkdir_p.format(binfmtdir))
3117 if install_sysconfdir
3118 meson.add_install_script('sh', '-c',
3119 mkdir_p.format(sysconfdir / 'binfmt.d'))
3123 if conf.get('ENABLE_SYSUPDATE') == 1
3125 'systemd-sysupdate',
3126 systemd_sysupdate_sources,
3127 include_directories : includes,
3128 link_with : [libshared],
3129 dependencies : [threads,
3133 install_rpath : rootlibexecdir,
3135 install_dir : rootlibexecdir)
3136 public_programs += exe
3139 if conf.get('ENABLE_VCONSOLE') == 1
3141 'systemd-vconsole-setup',
3142 'src/vconsole/vconsole-setup.c',
3143 include_directories : includes,
3144 link_with : [libshared],
3145 install_rpath : rootlibexecdir,
3147 install_dir : rootlibexecdir)
3150 if conf.get('ENABLE_RANDOMSEED') == 1
3152 'systemd-random-seed',
3153 'src/random-seed/random-seed.c',
3154 include_directories : includes,
3155 link_with : [libshared],
3156 install_rpath : rootlibexecdir,
3158 install_dir : rootlibexecdir)
3161 if conf.get('ENABLE_FIRSTBOOT') == 1
3162 public_programs += executable(
3163 'systemd-firstboot',
3164 'src/firstboot/firstboot.c',
3165 include_directories : includes,
3166 link_with : [libshared],
3167 dependencies : [libcrypt],
3168 install_rpath : rootlibexecdir,
3170 install_dir : rootbindir)
3174 'systemd-remount-fs',
3175 'src/remount-fs/remount-fs.c',
3176 include_directories : includes,
3177 link_with : [libshared],
3178 install_rpath : rootlibexecdir,
3180 install_dir : rootlibexecdir)
3183 'systemd-machine-id-setup',
3184 'src/machine-id-setup/machine-id-setup-main.c',
3185 include_directories : includes,
3186 link_with : [libshared],
3187 install_rpath : rootlibexecdir,
3189 install_dir : rootbindir)
3194 include_directories : includes,
3195 link_with : [libshared],
3196 install_rpath : rootlibexecdir,
3198 install_dir : rootlibexecdir)
3200 executable('systemd-growfs',
3201 'src/partition/growfs.c',
3202 include_directories : includes,
3203 link_with : [libshared],
3204 install_rpath : rootlibexecdir,
3206 install_dir : rootlibexecdir)
3210 'src/partition/makefs.c',
3211 include_directories : includes,
3212 link_with : [libshared],
3213 install_rpath : rootlibexecdir,
3215 install_dir : rootlibexecdir)
3219 'src/sleep/sleep.c',
3220 include_directories : includes,
3221 link_with : [libshared],
3222 install_rpath : rootlibexecdir,
3224 install_dir : rootlibexecdir)
3226 if install_sysconfdir_samples
3227 install_data('src/sleep/sleep.conf',
3228 install_dir : pkgsysconfdir)
3231 public_programs += executable(
3233 'src/sysctl/sysctl.c',
3234 include_directories : includes,
3235 link_with : [libshared],
3236 install_rpath : rootlibexecdir,
3238 install_dir : rootlibexecdir)
3242 'src/ac-power/ac-power.c',
3243 include_directories : includes,
3244 link_with : [libshared],
3245 install_rpath : rootlibexecdir,
3247 install_dir : rootlibexecdir)
3249 public_programs += executable(
3250 'systemd-detect-virt',
3251 'src/detect-virt/detect-virt.c',
3252 include_directories : includes,
3253 link_with : [libshared],
3254 install_rpath : rootlibexecdir,
3257 public_programs += executable(
3259 'src/delta/delta.c',
3260 include_directories : includes,
3261 link_with : [libshared],
3262 install_rpath : rootlibexecdir,
3265 public_programs += executable(
3267 'src/escape/escape.c',
3268 include_directories : includes,
3269 link_with : [libshared],
3270 install_rpath : rootlibexecdir,
3272 install_dir : rootbindir)
3274 public_programs += executable(
3276 'src/notify/notify.c',
3277 include_directories : includes,
3278 link_with : [libshared],
3279 install_rpath : rootlibexecdir,
3281 install_dir : rootbindir)
3283 public_programs += executable(
3285 'src/creds/creds.c',
3286 include_directories : includes,
3287 link_with : [libshared],
3288 dependencies : [threads,
3290 install_rpath : rootlibexecdir,
3292 install_dir : rootbindir)
3295 'systemd-volatile-root',
3296 'src/volatile-root/volatile-root.c',
3297 include_directories : includes,
3298 link_with : [libshared],
3299 install_rpath : rootlibexecdir,
3300 install : conf.get('ENABLE_INITRD') == 1,
3301 install_dir : rootlibexecdir)
3304 'systemd-cgroups-agent',
3305 'src/cgroups-agent/cgroups-agent.c',
3306 include_directories : includes,
3307 link_with : [libshared],
3308 install_rpath : rootlibexecdir,
3310 install_dir : rootlibexecdir)
3312 systemd_id128 = executable(
3314 'src/id128/id128.c',
3315 include_directories : includes,
3316 link_with : [libshared],
3317 install_rpath : rootlibexecdir,
3319 public_programs += systemd_id128
3321 if want_tests != 'false'
3322 test('test-systemctl-enable',
3323 test_systemctl_enable_sh,
3324 # https://github.com/mesonbuild/meson/issues/2681
3325 args : [systemctl.full_path(),
3326 systemd_id128.full_path()])
3329 public_programs += executable(
3332 include_directories : includes,
3333 link_with : [libshared],
3334 install_rpath : rootlibexecdir,
3337 public_programs += executable(
3338 'systemd-ask-password',
3339 'src/ask-password/ask-password.c',
3340 include_directories : includes,
3341 link_with : [libshared],
3342 install_rpath : rootlibexecdir,
3344 install_dir : rootbindir)
3347 'systemd-reply-password',
3348 'src/reply-password/reply-password.c',
3349 include_directories : includes,
3350 link_with : [libshared],
3351 install_rpath : rootlibexecdir,
3353 install_dir : rootlibexecdir)
3355 public_programs += executable(
3356 'systemd-tty-ask-password-agent',
3357 'src/tty-ask-password-agent/tty-ask-password-agent.c',
3358 include_directories : includes,
3359 link_with : [libshared],
3360 install_rpath : rootlibexecdir,
3362 install_dir : rootbindir)
3364 public_programs += executable(
3367 include_directories : includes,
3368 link_with : [libshared],
3369 install_rpath : rootlibexecdir,
3372 public_programs += executable(
3374 'src/cgtop/cgtop.c',
3375 include_directories : includes,
3376 link_with : [libshared],
3377 install_rpath : rootlibexecdir,
3382 'src/initctl/initctl.c',
3383 include_directories : includes,
3384 link_with : [libshared],
3385 install_rpath : rootlibexecdir,
3386 install : (conf.get('HAVE_SYSV_COMPAT') == 1),
3387 install_dir : rootlibexecdir)
3389 public_programs += executable(
3391 'src/mount/mount-tool.c',
3392 include_directories : includes,
3393 link_with : [libshared],
3394 dependencies: [libmount],
3395 install_rpath : rootlibexecdir,
3398 meson.add_install_script(meson_make_symlink,
3399 'systemd-mount', bindir / 'systemd-umount')
3401 public_programs += executable(
3404 include_directories : includes,
3405 link_with : [libshared],
3406 install_rpath : rootlibexecdir,
3409 public_programs += executable(
3410 'systemd-stdio-bridge',
3411 'src/stdio-bridge/stdio-bridge.c',
3412 include_directories : includes,
3413 link_with : [libshared],
3414 dependencies : [versiondep],
3415 install_rpath : rootlibexecdir,
3418 public_programs += executable(
3421 include_directories : includes,
3422 link_with : [libshared],
3423 dependencies : [versiondep],
3424 install_rpath : rootlibexecdir,
3430 'src/sysusers/sysusers.c',
3431 include_directories : includes,
3432 link_with : [libshared],
3433 install_rpath : rootlibexecdir,
3435 install_dir : rootbindir)
3436 public_programs += exe
3438 if want_tests != 'false'
3439 test('test-sysusers',
3441 # https://github.com/mesonbuild/meson/issues/2681
3442 args : exe.full_path())
3445 if have_standalone_binaries
3447 'systemd-sysusers.standalone',
3448 'src/sysusers/sysusers.c',
3449 include_directories : includes,
3450 c_args : '-DSTANDALONE',
3451 link_with : [libshared_static,
3456 install_dir : rootbindir)
3457 public_programs += exe
3459 if want_tests != 'false'
3460 test('test-sysusers.standalone',
3462 # https://github.com/mesonbuild/meson/issues/2681
3463 args : exe.full_path())
3468 if conf.get('ENABLE_TMPFILES') == 1
3471 systemd_tmpfiles_sources,
3472 include_directories : includes,
3473 link_with : [libshared],
3474 dependencies : [libacl],
3475 install_rpath : rootlibexecdir,
3477 install_dir : rootbindir)
3478 public_programs += exe
3480 if want_tests != 'false'
3481 test('test-systemd-tmpfiles',
3482 test_systemd_tmpfiles_py,
3483 # https://github.com/mesonbuild/meson/issues/2681
3484 args : exe.full_path())
3487 if have_standalone_binaries
3489 'systemd-tmpfiles.standalone',
3490 systemd_tmpfiles_sources,
3491 include_directories : includes,
3492 c_args : '-DSTANDALONE',
3493 link_with : [libshared_static,
3497 dependencies : [libacl],
3499 install_dir : rootbindir)
3500 public_programs += exe
3502 if want_tests != 'false'
3503 test('test-systemd-tmpfiles.standalone',
3504 test_systemd_tmpfiles_py,
3505 # https://github.com/mesonbuild/meson/issues/2681
3506 args : exe.full_path())
3511 if conf.get('ENABLE_HWDB') == 1
3512 systemd_hwdb = executable(
3515 include_directories : includes,
3516 link_with : udev_link_with,
3517 install_rpath : udev_rpath,
3519 install_dir : rootbindir)
3520 public_programs += systemd_hwdb
3522 if want_tests != 'false'
3525 suite : 'dist-check',
3526 args : [systemd_hwdb.full_path()],
3531 if conf.get('ENABLE_QUOTACHECK') == 1
3533 'systemd-quotacheck',
3534 'src/quotacheck/quotacheck.c',
3535 include_directories : includes,
3536 link_with : [libshared],
3537 install_rpath : rootlibexecdir,
3539 install_dir : rootlibexecdir)
3542 public_programs += executable(
3543 'systemd-socket-proxyd',
3544 'src/socket-proxy/socket-proxyd.c',
3545 include_directories : includes,
3546 link_with : [libshared],
3547 dependencies : [threads],
3548 install_rpath : rootlibexecdir,
3550 install_dir : rootlibexecdir)
3552 udevadm = executable(
3555 include_directories : includes,
3556 link_with : [libudevd_core],
3557 dependencies : [versiondep,
3563 install_rpath : udev_rpath,
3565 install_dir : rootbindir)
3566 public_programs += udevadm
3568 if conf.get('ENABLE_REPART') == 1
3571 systemd_repart_sources,
3572 include_directories : includes,
3573 link_with : [libshared],
3574 dependencies : [threads,
3577 install_rpath : rootlibexecdir,
3579 install_dir : rootbindir)
3580 public_programs += exe
3582 if want_tests != 'false'
3585 args : [exe.full_path(), udevadm.full_path()])
3591 systemd_shutdown_sources,
3592 include_directories : includes,
3593 link_with : [libshared],
3594 dependencies : [libmount],
3595 install_rpath : rootlibexecdir,
3597 install_dir : rootlibexecdir)
3600 'systemd-update-done',
3601 'src/update-done/update-done.c',
3602 include_directories : includes,
3603 link_with : [libshared],
3604 install_rpath : rootlibexecdir,
3606 install_dir : rootlibexecdir)
3609 'systemd-update-utmp',
3610 'src/update-utmp/update-utmp.c',
3611 include_directories : includes,
3612 link_with : [libshared],
3613 dependencies : [libaudit],
3614 install_rpath : rootlibexecdir,
3615 install : (conf.get('ENABLE_UTMP') == 1),
3616 install_dir : rootlibexecdir)
3618 if conf.get('HAVE_KMOD') == 1
3620 'systemd-modules-load',
3621 'src/modules-load/modules-load.c',
3622 include_directories : includes,
3623 link_with : [libshared],
3624 dependencies : [libkmod],
3625 install_rpath : rootlibexecdir,
3627 install_dir : rootlibexecdir)
3629 meson.add_install_script('sh', '-c',
3630 mkdir_p.format(modulesloaddir))
3631 if install_sysconfdir
3632 meson.add_install_script('sh', '-c',
3633 mkdir_p.format(sysconfdir / 'modules-load.d'))
3637 public_programs += executable(
3639 systemd_nspawn_sources,
3640 include_directories : includes,
3641 link_with : [libnspawn_core,
3643 dependencies : [libblkid,
3645 install_rpath : rootlibexecdir,
3648 if conf.get('ENABLE_NETWORKD') == 1
3649 dbus_programs += executable(
3651 systemd_networkd_sources,
3652 include_directories : network_includes,
3653 link_with : [libnetworkd_core,
3655 networkd_link_with],
3656 dependencies : [threads],
3657 install_rpath : rootlibexecdir,
3659 install_dir : rootlibexecdir)
3661 public_programs += executable(
3662 'systemd-networkd-wait-online',
3663 systemd_networkd_wait_online_sources,
3664 include_directories : includes,
3665 link_with : [networkd_link_with],
3666 install_rpath : rootlibexecdir,
3668 install_dir : rootlibexecdir)
3670 public_programs += executable(
3673 include_directories : libsystemd_network_includes,
3674 link_with : [libsystemd_network,
3675 networkd_link_with],
3676 install_rpath : rootlibexecdir,
3678 install_dir : rootbindir)
3682 'systemd-network-generator',
3683 network_generator_sources,
3684 include_directories : includes,
3685 link_with : [networkd_link_with],
3686 install_rpath : rootlibexecdir,
3688 install_dir : rootlibexecdir)
3690 if want_tests != 'false'
3691 test('test-network-generator-conversion',
3692 test_network_generator_conversion_sh,
3693 # https://github.com/mesonbuild/meson/issues/2681
3694 args : exe.full_path(),
3699 'systemd-sulogin-shell',
3700 'src/sulogin-shell/sulogin-shell.c',
3701 include_directories : includes,
3702 link_with : [libshared],
3703 install_rpath : rootlibexecdir,
3705 install_dir : rootlibexecdir)
3707 public_programs += custom_target(
3709 input : kernel_install_in,
3710 output : 'kernel-install',
3711 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
3712 install : want_kernel_install,
3713 install_mode : 'rwxr-xr-x',
3714 install_dir : bindir)
3716 ############################################################
3718 runtest_env = custom_target(
3719 'systemd-runtest.env',
3720 output : 'systemd-runtest.env',
3721 command : [sh, '-c',
3722 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
3723 project_source_root / 'test',
3724 project_build_root / 'catalog')],
3726 build_by_default : true)
3728 test_cflags = ['-DTEST_CODE=1']
3729 # We intentionally do not do inline initializations with definitions for a
3730 # bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
3731 # use the variable unexpectedly. This triggers a lot of maybe-uninitialized
3732 # false positives when the combination of -O2 and -flto is used. Suppress them.
3733 if '-O2' in c_args and '-flto=auto' in c_args
3734 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
3737 foreach tuple : tests
3739 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3740 dependencies = tuple.length() > 2 ? tuple[2] : []
3741 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3742 condition = tuple.length() > 4 ? tuple[4] : ''
3743 type = tuple.length() > 5 ? tuple[5] : ''
3744 defs = tuple.length() > 6 ? tuple[6] : []
3746 parallel = tuple.length() > 7 ? tuple[7] : true
3749 # FIXME: Use fs.stem() with meson >= 0.54.0
3750 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
3751 if type.startswith('timeout=')
3752 timeout = type.split('=')[1].to_int()
3756 if condition == '' or conf.get(condition) == 1
3760 include_directories : incs,
3761 link_with : link_with,
3762 dependencies : [versiondep,
3765 build_by_default : want_tests != 'false',
3766 install_rpath : rootlibexecdir,
3767 install : install_tests,
3768 install_dir : testsdir / type,
3769 link_depends : runtest_env)
3772 message('@0@ is a manual test'.format(name))
3773 elif type == 'unsafe' and want_tests != 'unsafe'
3774 message('@0@ is an unsafe test'.format(name))
3775 elif want_tests != 'false'
3781 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
3786 'test-libsystemd-sym',
3787 test_libsystemd_sym_c,
3788 include_directories : includes,
3789 link_with : [libsystemd],
3790 build_by_default : want_tests != 'false',
3791 install : install_tests,
3792 install_dir : testsdir)
3793 if want_tests != 'false'
3794 test('test-libsystemd-sym', exe)
3798 'test-libsystemd-static-sym',
3799 test_libsystemd_sym_c,
3800 include_directories : includes,
3801 link_with : [install_libsystemd_static],
3802 dependencies : [threads], # threads is already included in dependencies on the library,
3803 # but does not seem to get propagated. Add here as a work-around.
3804 build_by_default : want_tests != 'false' and static_libsystemd_pic,
3805 install : install_tests and static_libsystemd_pic,
3806 install_dir : testsdir)
3807 if want_tests != 'false' and static_libsystemd_pic
3808 test('test-libsystemd-static-sym', exe)
3814 include_directories : libudev_includes,
3815 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
3816 link_with : [libudev],
3817 build_by_default : want_tests != 'false',
3818 install : install_tests,
3819 install_dir : testsdir)
3820 if want_tests != 'false'
3821 test('test-libudev-sym', exe)
3825 'test-libudev-static-sym',
3827 include_directories : libudev_includes,
3828 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
3829 link_with : [install_libudev_static],
3830 build_by_default : want_tests != 'false' and static_libudev_pic,
3831 install : install_tests and static_libudev_pic,
3832 install_dir : testsdir)
3833 if want_tests != 'false' and static_libudev_pic
3834 test('test-libudev-static-sym', exe)
3837 ############################################################
3841 foreach tuple : fuzzers
3843 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3844 dependencies = tuple.length() > 2 ? tuple[2] : []
3845 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3846 defs = tuple.length() > 4 ? tuple[4] : []
3850 dependencies += fuzzing_engine
3852 if fuzzing_engine.found()
3853 dependencies += fuzzing_engine
3855 link_args += ['-fsanitize=fuzzer']
3858 sources += 'src/fuzz/fuzz-main.c'
3861 # FIXME: Use fs.stem() with meson >= 0.54.0
3862 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
3867 include_directories : [incs, include_directories('src/fuzz')],
3868 link_with : link_with,
3869 dependencies : dependencies,
3870 c_args : defs + test_cflags,
3871 link_args: link_args,
3873 build_by_default : fuzzer_build)
3876 if want_tests != 'false'
3877 # Run the fuzz regression tests without any sanitizers enabled.
3878 # Additional invocations with sanitizers may be added below.
3879 foreach p : fuzz_regression_tests
3880 b = p.split('/')[-2]
3881 c = p.split('/')[-1]
3884 test('@0@_@1@'.format(b, c),
3887 args : [project_source_root / p])
3893 alias_target('fuzzers', fuzzer_exes)
3895 ############################################################
3897 subdir('modprobe.d')
3899 subdir('sysusers.d')
3900 subdir('tmpfiles.d')
3906 subdir('shell-completion/bash')
3907 subdir('shell-completion/zsh')
3908 subdir('docs/sysvinit')
3909 subdir('docs/var-log')
3911 install_subdir('factory/etc',
3912 install_dir : factorydir)
3913 subdir('factory/templates')
3915 if install_sysconfdir
3916 install_data('xorg/50-systemd-user.sh',
3917 install_dir : xinitrcdir)
3919 install_data('LICENSE.GPL2',
3923 'docs/CODING_STYLE.md',
3924 'docs/DISTRO_PORTING.md',
3925 'docs/ENVIRONMENT.md',
3927 'docs/TRANSIENT-SETTINGS.md',
3928 'docs/TRANSLATORS.md',
3929 'docs/UIDS-GIDS.md',
3930 'docs/GVARIANT-SERIALIZATION.md',
3931 install_dir : docdir)
3933 install_subdir('LICENSES',
3934 install_dir : docdir)
3936 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
3937 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
3939 ############################################################
3941 # Ensure that changes to the docs/ directory do not break the
3942 # basic Github pages build. But only run it in developer mode,
3943 # as it might be fragile due to changes in the tooling, and it is
3944 # not generally useful for users.
3945 jekyll = find_program('jekyll', required : false)
3946 if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
3947 test('github-pages',
3949 suite : 'dist-check',
3951 '--source', project_source_root / 'docs',
3952 '--destination', project_build_root / '_site'])
3955 ############################################################
3957 check_help = find_program('tools/check-help.sh')
3958 check_version = find_program('tools/check-version.sh')
3960 foreach exec : public_programs
3961 name = exec.full_path().split('/')[-1]
3962 if want_tests != 'false'
3963 test('check-help-' + name,
3965 suite : 'dist-check',
3966 args : exec.full_path(),
3969 test('check-version-' + name,
3971 suite : 'dist-check',
3972 args : [exec.full_path(),
3973 meson.project_version()],
3978 ############################################################
3980 check_directives_sh = find_program('tools/check-directives.sh')
3982 if want_tests != 'false'
3983 test('check-directives',
3984 check_directives_sh,
3985 suite : 'dist-check',
3986 args : [project_source_root, project_build_root])
3989 ############################################################
3991 # Enable tests for all supported sanitizers
3992 foreach tuple : sanitizers
3993 sanitizer = tuple[0]
3996 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
3998 foreach p : fuzz_regression_tests
3999 b = p.split('/')[-2]
4000 c = p.split('/')[-1]
4002 name = '@0@:@1@'.format(b, sanitizer)
4005 if want_tests == 'false'
4006 message('Not compiling @0@ because tests is set to false'.format(name))
4008 exe = custom_target(
4012 command : [ln, '-fs',
4013 build.full_path() / b,
4015 build_by_default : true)
4017 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
4023 test('@0@_@1@_@2@'.format(b, c, sanitizer),
4026 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
4028 args : [exe.full_path(),
4029 project_source_root / p])
4036 ############################################################
4039 all_files = run_command(
4040 env, '-u', 'GIT_WORK_TREE',
4041 git, '--git-dir=@0@/.git'.format(project_source_root),
4042 'ls-files', ':/*.[ch]',
4044 if all_files.returncode() == 0
4045 all_files = files(all_files.stdout().split())
4050 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
4053 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
4058 git_contrib_sh = find_program('tools/git-contrib.sh')
4061 command : [git_contrib_sh])
4065 git_head = run_command(
4066 git, '--git-dir=@0@/.git'.format(project_source_root),
4067 'rev-parse', 'HEAD',
4068 check : false).stdout().strip()
4069 git_head_short = run_command(
4070 git, '--git-dir=@0@/.git'.format(project_source_root),
4071 'rev-parse', '--short=7', 'HEAD',
4072 check : false).stdout().strip()
4076 command : [git, 'archive',
4077 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
4079 '--prefix', 'systemd-@0@/'.format(git_head),
4083 ############################################################
4085 check_api_docs_sh = find_program('tools/check-api-docs.sh')
4088 depends : [man, libsystemd, libudev],
4089 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
4091 alias_target('update-dbus-docs', update_dbus_docs)
4092 alias_target('update-man-rules', update_man_rules)
4094 if not meson.is_cross_build()
4096 'export-dbus-interfaces',
4097 output : fs.name(dbus_interfaces_dir),
4098 install : dbus_interfaces_dir != 'no',
4099 install_dir : fs.parent(dbus_interfaces_dir),
4100 command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
4103 ############################################################
4105 alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
4106 check : true).stdout().strip()
4109 'split /usr' : split_usr,
4110 'split bin-sbin' : split_bin,
4111 'prefix directory' : prefixdir,
4112 'rootprefix directory' : rootprefixdir,
4113 'sysconf directory' : sysconfdir,
4114 'include directory' : includedir,
4115 'lib directory' : libdir,
4116 'rootlib directory' : rootlibdir,
4117 'SysV init scripts' : sysvinit_path,
4118 'SysV rc?.d directories' : sysvrcnd_path,
4119 'PAM modules directory' : pamlibdir,
4120 'PAM configuration directory' : pamconfdir,
4121 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
4122 'RPM macros directory' : rpmmacrosdir,
4123 'modprobe.d directory' : modprobedir,
4124 'D-Bus policy directory' : dbuspolicydir,
4125 'D-Bus session directory' : dbussessionservicedir,
4126 'D-Bus system directory' : dbussystemservicedir,
4127 'D-Bus interfaces directory' : dbus_interfaces_dir,
4128 'bash completions directory' : bashcompletiondir,
4129 'zsh completions directory' : zshcompletiondir,
4130 'private shared lib version tag' : shared_lib_tag,
4131 'extra start script' : get_option('rc-local'),
4132 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
4133 get_option('debug-tty')),
4134 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
4135 conf.get('SYSTEM_ALLOC_UID_MIN')),
4136 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
4137 conf.get('SYSTEM_ALLOC_GID_MIN')),
4138 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
4139 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
4140 'static UID/GID allocations' : ' '.join(static_ugids),
4141 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
4142 'render group access mode' : get_option('group-render-mode'),
4143 'certificate root directory' : get_option('certificate-root'),
4144 'support URL' : support_url,
4145 'nobody user name' : nobody_user,
4146 'nobody group name' : nobody_group,
4147 'fallback hostname' : get_option('fallback-hostname'),
4148 'default compression method' : compression,
4149 'default DNSSEC mode' : default_dnssec,
4150 'default DNS-over-TLS mode' : default_dns_over_tls,
4151 'default mDNS mode' : default_mdns,
4152 'default LLMNR mode' : default_llmnr,
4153 'default DNS servers' : dns_servers.split(' '),
4154 'default NTP servers' : ntp_servers.split(' '),
4155 'default cgroup hierarchy' : default_hierarchy,
4156 'default net.naming-scheme value' : default_net_naming_scheme,
4157 'default KillUserProcesses value' : kill_user_processes,
4158 'default locale' : default_locale,
4159 'default user $PATH' :
4160 default_user_path != '' ? default_user_path : '(same as system services)',
4161 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
4162 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
4165 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
4166 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
4167 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
4188 ['libcryptsetup-plugins'],
4214 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
4244 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
4258 ['legacy-pkla', install_polkit_pkla],
4263 ['man pages', want_man],
4264 ['html pages', want_html],
4265 ['man page indices', want_man and have_lxml],
4267 ['compat-mutable-uid-boundaries'],
4270 ['adm group', get_option('adm-group')],
4271 ['wheel group', get_option('wheel-group')],
4274 ['debug mmap cache'],
4276 ['valgrind', conf.get('VALGRIND') == 1],
4277 ['trace logging', conf.get('LOG_TRACE') == 1],
4278 ['install tests', install_tests],
4279 ['link-udev-shared', get_option('link-udev-shared')],
4280 ['link-systemctl-shared', get_option('link-systemctl-shared')],
4281 ['link-networkd-shared', get_option('link-networkd-shared')],
4282 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
4283 ['link-boot-shared', get_option('link-boot-shared')],
4285 ['standalone-binaries', get_option('standalone-binaries')],
4286 ['coverage', get_option('b_coverage')],
4289 if tuple.length() >= 2
4292 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
4293 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
4294 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
4303 if static_libsystemd == 'false'
4304 missing += 'static-libsystemd'
4306 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
4309 if static_libudev == 'false'
4310 missing += 'static-libudev'
4312 found += 'static-libudev(@0@)'.format(static_libudev)
4315 if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
4316 found += 'cryptolib(openssl)'
4317 elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
4318 found += 'cryptolib(gcrypt)'
4320 missing += 'cryptolib'
4323 if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
4324 found += 'DNS-over-TLS(gnutls)'
4325 elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
4326 found += 'DNS-over-TLS(openssl)'
4328 missing += 'DNS-over-TLS'
4332 'enabled' : ', '.join(found),
4333 'disabled' : ', '.join(missing)},
4334 section : 'Features')
4336 if rootprefixdir != rootprefix_default
4338 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
4339 'systemd used fixed names for unit file directories and other paths, so anything\n' +
4340 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))