]> git.ipfire.org Git - thirdparty/systemd.git/blob - meson.build
unit: check for mount rate limiting before checking active state
[thirdparty/systemd.git] / meson.build
1 # SPDX-License-Identifier: LGPL-2.1-or-later
2
3 project('systemd', 'c',
4 version : '251',
5 license : 'LGPLv2+',
6 default_options: [
7 'c_std=gnu11',
8 'prefix=/usr',
9 'sysconfdir=/etc',
10 'localstatedir=/var',
11 'warning_level=2',
12 ],
13 meson_version : '>= 0.53.2',
14 )
15
16 libsystemd_version = '0.34.0'
17 libudev_version = '1.7.4'
18
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)')
23
24 # This is to be used instead of meson.source_root(), as the latter will return
25 # the wrong result when systemd is being built as a meson subproject
26 project_source_root = meson.current_source_dir()
27 project_build_root = meson.current_build_dir()
28 relative_source_path = run_command('realpath',
29 '--relative-to=@0@'.format(project_build_root),
30 project_source_root,
31 check : true).stdout().strip()
32 conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)
33
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
39 else
40 verification = verification == 'true'
41 endif
42 conf.set10('LOG_MESSAGE_VERIFICATION', verification)
43
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')
48 endif
49
50 skip_deps = want_ossfuzz or get_option('skip-deps')
51 fuzzer_build = want_ossfuzz or want_libfuzzer
52
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
55 # limits).
56 conf.set10('FUZZ_USE_SIZE_LIMIT', fuzzer_build)
57
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')})
61
62 #####################################################################
63
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())
70 endif
71 endif
72
73 #####################################################################
74
75 fs = import('fs')
76 if get_option('split-usr') == 'auto'
77 split_usr = not fs.is_symlink('/bin')
78 else
79 split_usr = get_option('split-usr') == 'true'
80 endif
81 if split_usr
82 warning('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n\n'
83 + ' split-usr mode is going to be removed\n' +
84 '\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
85 endif
86 conf.set10('HAVE_SPLIT_USR', split_usr,
87 description : '/usr/bin and /bin directories are separate')
88
89 if get_option('split-bin') == 'auto'
90 split_bin = not fs.is_symlink('/usr/sbin')
91 else
92 split_bin = get_option('split-bin') == 'true'
93 endif
94 conf.set10('HAVE_SPLIT_BIN', split_bin,
95 description : 'bin and sbin directories are separate')
96
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
103 endif
104 rootprefixdir_noslash = rootprefixdir == '/' ? '' : rootprefixdir
105
106 have_standalone_binaries = get_option('standalone-binaries')
107
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'))
113
114 if get_option('hibernate') and not get_option('initrd')
115 error('hibernate depends on initrd')
116 endif
117
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)
121
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))
128 endif
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))
132 endif
133
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')
140
141 rootbindir = rootprefixdir / 'bin'
142 rootsbindir = rootprefixdir / (split_bin ? 'sbin' : 'bin')
143 rootlibexecdir = rootprefixdir / 'lib/systemd'
144
145 rootlibdir = get_option('rootlibdir')
146 if rootlibdir == ''
147 rootlibdir = rootprefixdir / libdir.split('/')[-1]
148 endif
149
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
162 endif
163 modprobedir = rootprefixdir / 'lib/modprobe.d'
164
165 # Our own paths
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'
200
201 docdir = get_option('docdir')
202 if docdir == ''
203 docdir = datadir / 'doc/systemd'
204 endif
205
206 pamlibdir = get_option('pamlibdir')
207 if pamlibdir == ''
208 pamlibdir = rootlibdir / 'security'
209 endif
210
211 pamconfdir = get_option('pamconfdir')
212 if pamconfdir == ''
213 pamconfdir = prefixdir / 'lib/pam.d'
214 endif
215
216 libcryptsetup_plugins_dir = get_option('libcryptsetup-plugins-dir')
217 if libcryptsetup_plugins_dir == ''
218 libcryptsetup_plugins_dir = rootlibdir / 'cryptsetup'
219 endif
220
221 memory_accounting_default = get_option('memory-accounting-default')
222 status_unit_format_default = get_option('status-unit-format-default')
223
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')
292
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)
299
300 #####################################################################
301
302 cc = meson.get_compiler('c')
303 pkgconfig = import('pkgconfig')
304 meson_build_sh = find_program('tools/meson-build.sh')
305
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')
310
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())
315 else
316 cxx_cmd = ''
317 endif
318
319 if want_libfuzzer
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')
325 else
326 error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported')
327 endif
328 elif want_ossfuzz
329 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
330 endif
331
332 # Those generate many false positives, and we do not want to change the code to
333 # avoid them.
334 basic_disabled_warnings = [
335 '-Wno-format-signedness',
336 '-Wno-missing-field-initializers',
337 '-Wno-unused-parameter',
338 ]
339
340 possible_common_cc_flags = [
341 '-Wdate-time',
342 '-Wendif-labels',
343 '-Werror=format=2',
344 '-Werror=implicit-function-declaration',
345 '-Werror=incompatible-pointer-types',
346 '-Werror=int-conversion',
347 '-Werror=overflow',
348 '-Werror=override-init',
349 '-Werror=return-type',
350 '-Werror=shift-count-overflow',
351 '-Werror=shift-overflow=2',
352 '-Werror=undef',
353 '-Wfloat-equal',
354 '-Wimplicit-fallthrough=5',
355 '-Winit-self',
356 '-Wlogical-op',
357 '-Wmissing-include-dirs',
358 '-Wmissing-noreturn',
359 '-Wnested-externs',
360 '-Wold-style-definition',
361 '-Wpointer-arith',
362 '-Wredundant-decls',
363 '-Wshadow',
364 '-Wstrict-aliasing=2',
365 '-Wstrict-prototypes',
366 '-Wsuggest-attribute=noreturn',
367 '-Wunused-function',
368 '-Wwrite-strings',
369
370 # negative arguments are correctly detected starting with meson 0.46.
371 '-Wno-error=#warnings', # clang
372 '-Wno-string-plus-int', # clang
373 ]
374
375 c_args = get_option('c_args')
376
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
383 '-Os' in c_args or
384 '-O1' in c_args or
385 '-O3' in c_args or
386 '-Og' in c_args)
387 possible_common_cc_flags += '-Wno-maybe-uninitialized'
388 endif
389
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'
394 endif
395
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',
400 '-Wl,-z,now',
401 '-Wl,-z,relro',
402 '-fstack-protector',
403 ]
404
405 if get_option('b_sanitize') == 'none'
406 possible_link_flags += '-Wl,--warn-common'
407 endif
408
409 if cc.get_id() == 'clang'
410 possible_common_cc_flags += [
411 '-Wno-typedef-redefinition',
412 '-Wno-gnu-variable-sized-type-not-at-end',
413 ]
414 endif
415
416 possible_cc_flags = possible_common_cc_flags + [
417 '-Werror=missing-declarations',
418 '-Werror=missing-prototypes',
419 '-fdiagnostics-show-option',
420 '-fno-common',
421 '-fno-strict-aliasing',
422 '-fstack-protector',
423 '-fstack-protector-strong',
424 '-fvisibility=hidden',
425 '--param=ssp-buffer-size=4',
426 ]
427
428 if get_option('buildtype') != 'debug'
429 possible_cc_flags += [
430 '-ffunction-sections',
431 '-fdata-sections',
432 ]
433
434 possible_link_flags += '-Wl,--gc-sections'
435 endif
436
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')
440
441 have = cc.has_argument('-Wzero-length-bounds')
442 conf.set10('HAVE_ZERO_LENGTH_BOUNDS', have)
443
444 if cc.compiles('''
445 #include <time.h>
446 #include <inttypes.h>
447 typedef uint64_t usec_t;
448 usec_t now(clockid_t clock);
449 int main(void) {
450 struct timespec now;
451 return 0;
452 }
453 ''', args: '-Werror=shadow', name : '-Werror=shadow with local shadowing')
454 add_project_arguments('-Werror=shadow', language : 'c')
455 endif
456
457 if cxx_cmd != ''
458 add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
459 endif
460
461 cpp = ' '.join(cc.cmd_array()) + ' -E'
462
463 has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
464
465 #####################################################################
466 # compilation result tests
467
468 conf.set('_GNU_SOURCE', true)
469 conf.set('__SANE_USERSPACE_TYPES__', true)
470 conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)
471
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>'))
477
478 decl_headers = '''
479 #include <uchar.h>
480 #include <sys/mount.h>
481 #include <sys/stat.h>
482 #include <linux/fs.h>
483 '''
484
485 foreach decl : ['char16_t',
486 'char32_t',
487 'struct mount_attr',
488 'struct statx',
489 ]
490
491 # We get -1 if the size cannot be determined
492 have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
493
494 if decl == 'struct statx'
495 if have
496 want_linux_stat_h = false
497 else
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
502 endif
503 endif
504
505 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
506 endforeach
507
508 conf.set10('WANT_LINUX_STAT_H', want_linux_stat_h)
509
510 foreach ident : ['secure_getenv', '__secure_getenv']
511 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
512 endforeach
513
514 foreach 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>
545 #include <unistd.h>
546 #include <signal.h>
547 #include <sys/wait.h>'''],
548 ['pidfd_open', '''#include <stdlib.h>
549 #include <unistd.h>
550 #include <signal.h>
551 #include <sys/wait.h>'''],
552 ['rt_sigqueueinfo', '''#include <stdlib.h>
553 #include <unistd.h>
554 #include <signal.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>'''],
565 ]
566
567 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
568 conf.set10('HAVE_' + ident[0].to_upper(), have)
569 endforeach
570
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)
574 else
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)
578 endif
579
580 #####################################################################
581
582 version_tag = get_option('version-tag')
583 if 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')
589 else
590 vcs_tagger = [
591 project_source_root + '/tools/meson-vcs-tag.sh',
592 project_source_root,
593 meson.project_version()]
594
595 version_h = vcs_tag(
596 input : 'src/version/version.h.in',
597 output : 'version.h',
598 command: vcs_tagger)
599 endif
600
601 versiondep = declare_dependency(sources: version_h)
602
603 shared_lib_tag = get_option('shared-lib-tag')
604 if shared_lib_tag == ''
605 shared_lib_tag = meson.project_version()
606 endif
607
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'
619
620 mkdir_p = 'mkdir -p $DESTDIR/@0@'
621
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', ],
634 ]
635 foreach prog : progs
636 path = get_option(prog[0] + '-path')
637 if path != ''
638 message('Using @1@ for @0@'.format(prog[0], path))
639 else
640 exe = find_program(prog[0],
641 '/usr/sbin/' + prog[0],
642 '/sbin/' + prog[0],
643 required: false)
644 path = exe.found() ? exe.path() : prog[1]
645 endif
646 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
647 conf.set_quoted(name, path)
648 endforeach
649
650 conf.set_quoted('TELINIT', get_option('telinit-path'))
651
652 if run_command(ln, '--relative', '--help', check : false).returncode() != 0
653 error('ln does not support --relative (added in coreutils 8.16)')
654 endif
655
656 ############################################################
657
658 python = find_program('python3')
659 if run_command(python, '-c', 'import jinja2', check : false).returncode() != 0
660 error('python3 jinja2 missing')
661 endif
662
663 ############################################################
664
665 gperf = find_program('gperf')
666
667 gperf_test_format = '''
668 #include <string.h>
669 const char * in_word_set(const char *, @0@);
670 @1@
671 '''
672 gperf_snippet = run_command(sh, '-c', 'echo foo,bar | "$1" -L ANSI-C', '_', gperf,
673 check : true)
674 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
675 if cc.compiles(gperf_test)
676 gperf_len_type = 'size_t'
677 else
678 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
679 if cc.compiles(gperf_test)
680 gperf_len_type = 'unsigned'
681 else
682 error('unable to determine gperf len type')
683 endif
684 endif
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')
688
689 ############################################################
690
691 if not cc.has_header('sys/capability.h')
692 error('POSIX caps headers not found')
693 endif
694 foreach header : ['crypt.h',
695 'linux/memfd.h',
696 'linux/vm_sockets.h',
697 'sys/auxv.h',
698 'valgrind/memcheck.h',
699 'valgrind/valgrind.h',
700 'linux/time_types.h',
701 'sys/sdt.h',
702 ]
703
704 conf.set10('HAVE_' + header.underscorify().to_upper(),
705 cc.has_header(header))
706 endforeach
707
708 ############################################################
709
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.
715 endif
716 conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
717
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')
725 else
726 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
727 endif
728
729 extra_net_naming_schemes = []
730 extra_net_naming_map = []
731 foreach scheme: get_option('extra-net-naming-schemes').split(',')
732 if scheme != ''
733 name = scheme.split('=')[0]
734 value = scheme.split('=')[1]
735 NAME = name.underscorify().to_upper()
736 VALUE = []
737 foreach field: value.split('+')
738 VALUE += 'NAMING_' + field.underscorify().to_upper()
739 endforeach
740 extra_net_naming_schemes += 'NAMING_@0@ = @1@,'.format(NAME, '|'.join(VALUE))
741 extra_net_naming_map += '{ "@0@", NAMING_@1@ },'.format(name, NAME)
742 endif
743 endforeach
744 conf.set('EXTRA_NET_NAMING_SCHEMES', ' '.join(extra_net_naming_schemes))
745 conf.set('EXTRA_NET_NAMING_MAP', ' '.join(extra_net_naming_map))
746
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())
752 endif
753
754 time_epoch = get_option('time-epoch')
755 if time_epoch == -1
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',
760 check : false)
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()
766 endif
767 endif
768 if time_epoch == ''
769 NEWS = files('NEWS')
770 time_epoch = run_command(stat, '-c', '%Y', NEWS,
771 check : true).stdout()
772 endif
773 time_epoch = time_epoch.to_int()
774 endif
775 conf.set('TIME_EPOCH', time_epoch)
776
777 conf.set('CLOCK_VALID_RANGE_USEC_MAX', get_option('clock-valid-range-usec-max'))
778
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))
782
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])
788 if v == -1
789 v = run_command(
790 awk,
791 '/^\s*@0@\s+/ { uid=$2 } END { print uid }'.format(tuple[1]),
792 '/etc/login.defs',
793 check : false).stdout().strip()
794 if v == ''
795 v = tuple[2]
796 else
797 v = v.to_int()
798 endif
799 endif
800 conf.set(tuple[0].underscorify().to_upper(), v)
801 endforeach
802 if conf.get('SYSTEM_ALLOC_UID_MIN') >= conf.get('SYSTEM_UID_MAX')
803 error('Invalid uid allocation range')
804 endif
805 if conf.get('SYSTEM_ALLOC_GID_MIN') >= conf.get('SYSTEM_GID_MAX')
806 error('Invalid gid allocation range')
807 endif
808
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)
813
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)
818
819 nobody_user = get_option('nobody-user')
820 nobody_group = get_option('nobody-group')
821
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
827 warning('\n' +
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.')
830 endif
831 endif
832 id_result = run_command('id', '-u', nobody_user, check : false)
833 if id_result.returncode() == 0
834 id = id_result.stdout().to_int()
835 if id != 65534
836 warning('\n' +
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.')
839 endif
840 endif
841
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
846 warning('\n' +
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.')
849 endif
850 endif
851 id_result = run_command('id', '-g', nobody_group, check : false)
852 if id_result.returncode() == 0
853 id = id_result.stdout().to_int()
854 if id != 65534
855 warning('\n' +
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.')
858 endif
859 endif
860 endif
861 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
862 warning('\n' +
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.')
865 endif
866
867 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
868 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
869
870 static_ugids = []
871 foreach option : ['adm-gid',
872 'audio-gid',
873 'cdrom-gid',
874 'dialout-gid',
875 'disk-gid',
876 'input-gid',
877 'kmem-gid',
878 'kvm-gid',
879 'lp-gid',
880 'render-gid',
881 'sgx-gid',
882 'tape-gid',
883 'tty-gid',
884 'users-gid',
885 'utmp-gid',
886 'video-gid',
887 'wheel-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)
894
895 # Ensure provided GID argument is numeric, otherwise fall back to default assignment
896 conf.set(name, val >= 0 ? val : '-')
897 if val >= 0
898 static_ugids += '@0@:@1@'.format(option, val)
899 endif
900 endforeach
901
902 conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
903 conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
904
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')
911
912 kill_user_processes = get_option('default-kill-user-processes')
913 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
914
915 dns_servers = get_option('dns-servers')
916 conf.set_quoted('DNS_SERVERS', dns_servers)
917
918 ntp_servers = get_option('ntp-servers')
919 conf.set_quoted('NTP_SERVERS', ntp_servers)
920
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()
927 else
928 default_locale = 'C.UTF-8'
929 endif
930 endif
931 conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale)
932
933 localegen_path = get_option('localegen-path')
934 if localegen_path != ''
935 conf.set_quoted('LOCALEGEN_PATH', localegen_path)
936 endif
937 conf.set10('HAVE_LOCALEGEN', localegen_path != '')
938
939 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
940
941 service_watchdog = get_option('service-watchdog')
942 watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
943 conf.set_quoted('SERVICE_WATCHDOG', watchdog_value)
944
945 conf.set_quoted('SUSHELL', get_option('debug-shell'))
946 conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
947
948 enable_debug_hashmap = false
949 enable_debug_mmap_cache = false
950 enable_debug_siphash = false
951 foreach name : get_option('debug-extra')
952 if name == 'hashmap'
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
958 else
959 message('unknown debug option "@0@", ignoring'.format(name))
960 endif
961 endforeach
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)
965
966 conf.set10('VALGRIND', get_option('valgrind'))
967 conf.set10('LOG_TRACE', get_option('log-trace'))
968
969 default_user_path = get_option('user-path')
970 if default_user_path != ''
971 conf.set_quoted('DEFAULT_USER_PATH', default_user_path)
972 endif
973
974
975 #####################################################################
976
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')
982
983 crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
984 foreach ident : [
985 ['crypt_ra', crypt_header],
986 ['crypt_preferred_method', crypt_header],
987 ['crypt_gensalt_ra', crypt_header]]
988
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)
992 endforeach
993
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')
998 endif
999
1000 want_bpf_framework = get_option('bpf-framework')
1001 bpf_framework_required = want_bpf_framework == 'true'
1002
1003 libbpf = dependency('libbpf', required : bpf_framework_required, version : '>= 0.2')
1004 conf.set10('HAVE_LIBBPF', libbpf.found())
1005
1006 if want_bpf_framework == 'false' or not libbpf.found() or skip_deps
1007 conf.set10('BPF_FRAMEWORK', false)
1008 else
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()
1014 if clang_found
1015 clang = r.path()
1016 endif
1017 # Assume that the required flags are supported by the found clang.
1018 clang_supports_flags = clang_found
1019 else
1020 clang_found = true
1021 clang = cc.cmd_array()
1022 clang_supports_flags = cc.has_argument('-Wno-compare-distinct-pointer-types')
1023 endif
1024
1025 if clang_found
1026 # Check if 'clang -target bpf' is supported.
1027 clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0
1028 else
1029 clang_supports_bpf = false
1030 endif
1031
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',
1037 required : false,
1038 version : '>= 5.13.0')
1039
1040 if bpftool.found()
1041 bpftool_strip = true
1042 else
1043 bpftool_strip = false
1044 bpftool = find_program('bpftool',
1045 '/usr/sbin/bpftool',
1046 required : bpf_framework_required,
1047 version : '>= 5.6.0')
1048 endif
1049
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()
1054 else
1055 llvm_strip_bin = 'llvm-strip'
1056 endif
1057 llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0')
1058 endif
1059
1060 deps_found = clang_found and clang_supports_bpf and clang_supports_flags and (bpftool_strip or llvm_strip.found()) and bpftool.found()
1061
1062 # Can build BPF program from source code in restricted C
1063 conf.set10('BPF_FRAMEWORK', deps_found)
1064 endif
1065
1066 libmount = dependency('mount',
1067 version : fuzzer_build ? '>= 0' : '>= 2.30')
1068
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()
1075 else
1076 have = false
1077 libfdisk = []
1078 endif
1079 conf.set10('HAVE_LIBFDISK', have)
1080
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()
1085 else
1086 have = false
1087 libpwquality = []
1088 endif
1089 conf.set10('HAVE_PWQUALITY', have)
1090
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()
1097 else
1098 have = false
1099 libseccomp = []
1100 endif
1101 conf.set10('HAVE_SECCOMP', have)
1102
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()
1109 else
1110 have = false
1111 libselinux = []
1112 endif
1113 conf.set10('HAVE_SELINUX', have)
1114
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()
1121 else
1122 have = false
1123 libapparmor = []
1124 endif
1125 conf.set10('HAVE_APPARMOR', have)
1126
1127 have = get_option('smack') and get_option('smack-run-label') != ''
1128 conf.set10('HAVE_SMACK_RUN_LABEL', have)
1129 if have
1130 conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
1131 endif
1132
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
1138
1139 libpolkit = dependency('polkit-gobject-1',
1140 required : false)
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
1144 endif
1145 endif
1146 conf.set10('ENABLE_POLKIT', install_polkit)
1147
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()
1152 else
1153 have = false
1154 libacl = []
1155 endif
1156 conf.set10('HAVE_ACL', have)
1157
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()
1162 else
1163 have = false
1164 libaudit = []
1165 endif
1166 conf.set10('HAVE_AUDIT', have)
1167
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()
1172
1173 conf.set10('HAVE_BLKID_PROBE_SET_HINT',
1174 have and cc.has_function('blkid_probe_set_hint', dependencies : libblkid))
1175 else
1176 have = false
1177 libblkid = []
1178 endif
1179 conf.set10('HAVE_BLKID', have)
1180
1181 want_kmod = get_option('kmod')
1182 if want_kmod != 'false' and not skip_deps
1183 libkmod = dependency('libkmod',
1184 version : '>= 15',
1185 required : want_kmod == 'true')
1186 have = libkmod.found()
1187 else
1188 have = false
1189 libkmod = []
1190 endif
1191 conf.set10('HAVE_KMOD', have)
1192
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()
1198 else
1199 have = false
1200 libpam = []
1201 libpam_misc = []
1202 endif
1203 conf.set10('HAVE_PAM', have)
1204
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()
1211 else
1212 have = false
1213 libmicrohttpd = []
1214 endif
1215 conf.set10('HAVE_MICROHTTPD', have)
1216
1217 want_libcryptsetup = get_option('libcryptsetup')
1218 want_libcryptsetup_plugins = get_option('libcryptsetup-plugins')
1219
1220 if want_libcryptsetup_plugins == 'true' and want_libcryptsetup == 'false'
1221 error('libcryptsetup-plugins can not be requested without libcryptsetup')
1222 endif
1223
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()
1229
1230 foreach ident : ['crypt_set_metadata_size',
1231 'crypt_activate_by_signed_key',
1232 'crypt_token_max']
1233 have_ident = have and cc.has_function(
1234 ident,
1235 prefix : '#include <libcryptsetup.h>',
1236 dependencies : libcryptsetup)
1237 conf.set10('HAVE_' + ident.to_upper(), have_ident)
1238 endforeach
1239 else
1240 have = false
1241 libcryptsetup = []
1242 endif
1243 conf.set10('HAVE_LIBCRYPTSETUP', have)
1244
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
1250 cc.has_function(
1251 'crypt_token_external_path',
1252 prefix : '#include <libcryptsetup.h>',
1253 dependencies : libcryptsetup))
1254 else
1255 have = false
1256 endif
1257 conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have)
1258
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()
1265 else
1266 have = false
1267 libcurl = []
1268 endif
1269 conf.set10('HAVE_LIBCURL', have)
1270 conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
1271
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')
1276 endif
1277
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()
1282 else
1283 have = false
1284 libidn = []
1285 endif
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()
1292 else
1293 have = false
1294 endif
1295 conf.set10('HAVE_LIBIDN', have)
1296
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()
1302 else
1303 have = false
1304 libiptc = []
1305 endif
1306 conf.set10('HAVE_LIBIPTC', have)
1307
1308 want_qrencode = get_option('qrencode')
1309 if want_qrencode != 'false' and not skip_deps
1310 libqrencode = dependency('libqrencode',
1311 version : '>= 4',
1312 required : want_qrencode == 'true')
1313 have = libqrencode.found()
1314 else
1315 have = false
1316 libqrencode = []
1317 endif
1318 conf.set10('HAVE_QRENCODE', have)
1319
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()
1325 else
1326 have = false
1327 endif
1328 if not have
1329 # link to neither of the libs if one is not found
1330 libgcrypt = []
1331 libgpg_error = []
1332 endif
1333 conf.set10('HAVE_GCRYPT', have)
1334
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()
1341 else
1342 have = false
1343 libgnutls = []
1344 endif
1345 conf.set10('HAVE_GNUTLS', have)
1346
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()
1353 else
1354 have = false
1355 libopenssl = []
1356 endif
1357 conf.set10('HAVE_OPENSSL', have)
1358
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()
1365 else
1366 have = false
1367 libp11kit = []
1368 endif
1369 conf.set10('HAVE_P11KIT', have)
1370
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()
1376 else
1377 have = false
1378 libfido2 = []
1379 endif
1380 conf.set10('HAVE_LIBFIDO2', have)
1381
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')
1386 have = tpm2.found()
1387 else
1388 have = false
1389 tpm2 = []
1390 endif
1391 conf.set10('HAVE_TPM2', have)
1392
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()
1398
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))
1402 else
1403 have = false
1404 libdw = []
1405 endif
1406 conf.set10('HAVE_ELFUTILS', have)
1407
1408 want_zlib = get_option('zlib')
1409 if want_zlib != 'false' and not skip_deps
1410 libz = dependency('zlib',
1411 required : want_zlib == 'true')
1412 have = libz.found()
1413 else
1414 have = false
1415 libz = []
1416 endif
1417 conf.set10('HAVE_ZLIB', have)
1418
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()
1424 else
1425 have = false
1426 libbzip2 = []
1427 endif
1428 conf.set10('HAVE_BZIP2', have)
1429
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()
1435 else
1436 have_xz = false
1437 libxz = []
1438 endif
1439 conf.set10('HAVE_XZ', have_xz)
1440
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()
1447 else
1448 have_lz4 = false
1449 liblz4 = []
1450 endif
1451 conf.set10('HAVE_LZ4', have_lz4)
1452
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()
1459 else
1460 have_zstd = false
1461 libzstd = []
1462 endif
1463 conf.set10('HAVE_ZSTD', have_zstd)
1464
1465 conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
1466
1467 compression = get_option('default-compression')
1468 if compression == 'auto'
1469 if have_zstd
1470 compression = 'zstd'
1471 elif have_lz4
1472 compression = 'lz4'
1473 elif have_xz
1474 compression = 'xz'
1475 else
1476 compression = 'none'
1477 endif
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')
1484 endif
1485 conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper()))
1486
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()
1493 else
1494 have = false
1495 libxkbcommon = []
1496 endif
1497 conf.set10('HAVE_XKBCOMMON', have)
1498
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()
1504 else
1505 have = false
1506 libpcre2 = []
1507 endif
1508 conf.set10('HAVE_PCRE2', have)
1509
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()
1521 else
1522 have = false
1523 libglib = []
1524 libgobject = []
1525 libgio = []
1526 endif
1527 conf.set10('HAVE_GLIB', have)
1528
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()
1535 else
1536 have = false
1537 libdbus = []
1538 endif
1539 conf.set10('HAVE_DBUS', have)
1540
1541 dbusdatadir = datadir / 'dbus-1'
1542 if conf.get('HAVE_DBUS') == 1
1543 dbusdatadir = libdbus.get_variable(pkgconfig: 'datadir', default_value: datadir) / 'dbus-1'
1544 endif
1545
1546 dbuspolicydir = get_option('dbuspolicydir')
1547 if dbuspolicydir == ''
1548 dbuspolicydir = dbusdatadir / 'system.d'
1549 endif
1550
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)
1556 endif
1557 endif
1558
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)
1564 endif
1565 endif
1566
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.')
1572 else
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)
1576 endif
1577 endif
1578 endif
1579
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')
1585 endif
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]
1591
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')
1596 endif
1597
1598 if dns_over_tls == 'gnutls'
1599 have_openssl = false
1600 else
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')
1604 endif
1605 endif
1606 if dns_over_tls == 'openssl' or have_openssl
1607 have_gnutls = false
1608 else
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))
1613 endif
1614 endif
1615 have = have_gnutls or have_openssl
1616 else
1617 have = false
1618 have_gnutls = false
1619 have_openssl = false
1620 endif
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)
1624
1625 default_dns_over_tls = get_option('default-dns-over-tls')
1626 if skip_deps
1627 default_dns_over_tls = 'no'
1628 endif
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'
1632 endif
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)
1636
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)
1641
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)
1646
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')
1652 endif
1653 else
1654 have = false
1655 endif
1656 conf.set10('ENABLE_REPART', have)
1657
1658 default_dnssec = get_option('default-dnssec')
1659 if skip_deps
1660 default_dnssec = 'no'
1661 endif
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'
1665 endif
1666 conf.set('DEFAULT_DNSSEC_MODE',
1667 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1668 conf.set_quoted('DEFAULT_DNSSEC_MODE_STR', default_dnssec)
1669
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')
1676 endif
1677 else
1678 have = false
1679 endif
1680 conf.set10('ENABLE_SYSUPDATE', have)
1681
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')
1690 endif
1691 else
1692 have = false
1693 endif
1694 conf.set10('ENABLE_IMPORTD', have)
1695
1696 want_kernel_install = get_option('kernel-install')
1697 conf.set10('ENABLE_KERNEL_INSTALL', want_kernel_install)
1698
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')
1706 endif
1707 else
1708 have = false
1709 endif
1710 conf.set10('ENABLE_HOMED', have)
1711
1712 have = have and conf.get('HAVE_PAM') == 1
1713 conf.set10('ENABLE_PAM_HOME', have)
1714
1715 have = get_option('oomd')
1716 conf.set10('ENABLE_OOMD', have)
1717
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')
1728 endif
1729 have = have_deps[0] or have_deps[1]
1730 else
1731 have = false
1732 endif
1733 conf.set10('ENABLE_REMOTE', have)
1734
1735 foreach term : ['analyze',
1736 'backlight',
1737 'binfmt',
1738 'coredump',
1739 'efi',
1740 'environment-d',
1741 'firstboot',
1742 'gshadow',
1743 'hibernate',
1744 'hostnamed',
1745 'hwdb',
1746 'idn',
1747 'ima',
1748 'initrd',
1749 'compat-mutable-uid-boundaries',
1750 'nscd',
1751 'ldconfig',
1752 'localed',
1753 'logind',
1754 'machined',
1755 'networkd',
1756 'nss-myhostname',
1757 'nss-systemd',
1758 'portabled',
1759 'sysext',
1760 'pstore',
1761 'quotacheck',
1762 'randomseed',
1763 'resolve',
1764 'rfkill',
1765 'smack',
1766 'sysusers',
1767 'timedated',
1768 'timesyncd',
1769 'tmpfiles',
1770 'tpm',
1771 'userdb',
1772 'utmp',
1773 'vconsole',
1774 'xdg-autostart']
1775 have = get_option(term)
1776 name = 'ENABLE_' + term.underscorify().to_upper()
1777 conf.set10(name, have)
1778 endforeach
1779
1780 enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
1781
1782 foreach tuple : [['nss-mymachines', 'machined'],
1783 ['nss-resolve', 'resolve']]
1784 want = get_option(tuple[0])
1785 if want != 'false'
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]))
1789 endif
1790 else
1791 have = false
1792 endif
1793 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1794 conf.set10(name, have)
1795 endforeach
1796
1797 enable_nss = false
1798 foreach term : ['ENABLE_NSS_MYHOSTNAME',
1799 'ENABLE_NSS_MYMACHINES',
1800 'ENABLE_NSS_RESOLVE',
1801 'ENABLE_NSS_SYSTEMD']
1802 if conf.get(term) == 1
1803 enable_nss = true
1804 endif
1805 endforeach
1806 conf.set10('ENABLE_NSS', enable_nss)
1807
1808 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1809
1810 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1811
1812 ############################################################
1813
1814 tests = []
1815 fuzzers = []
1816 catalogs = []
1817
1818 ############################################################
1819
1820 # Include these now as they provide gnu-efi detection.
1821 subdir('src/fundamental')
1822 subdir('src/boot/efi')
1823
1824 ############################################################
1825
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')
1838
1839 ############################################################
1840
1841 if get_option('b_coverage')
1842 add_project_arguments('-include', 'src/basic/coverage.h', language : 'c')
1843 endif
1844
1845 ############################################################
1846
1847 config_h = configure_file(
1848 output : 'config.h',
1849 configuration : conf)
1850
1851 add_project_arguments('-include', 'config.h', language : 'c')
1852
1853 jinja2_cmdline = [meson_render_jinja2, config_h, version_h]
1854
1855 ############################################################
1856
1857 # binaries that have --help and are intended for use by humans,
1858 # usually, but not always, installed in /bin.
1859 public_programs = []
1860
1861 # D-Bus introspection XML export
1862 dbus_programs = []
1863
1864 basic_includes = include_directories(
1865 'src/basic',
1866 'src/fundamental',
1867 'src/systemd',
1868 '.')
1869
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')]
1880
1881 includes = [libsystemd_includes, include_directories('src/shared')]
1882
1883 subdir('po')
1884 subdir('catalog')
1885 subdir('src/basic')
1886 subdir('src/libsystemd')
1887 subdir('src/shared')
1888 subdir('src/udev')
1889 subdir('src/libudev')
1890 subdir('src/cryptsetup/cryptsetup-tokens')
1891
1892 libsystemd = shared_library(
1893 'systemd',
1894 disable_mempool_c,
1895 version : libsystemd_version,
1896 include_directories : libsystemd_includes,
1897 link_args : ['-shared',
1898 '-Wl,--version-script=' + libsystemd_sym_path],
1899 link_with : [libbasic,
1900 libbasic_gcrypt,
1901 libbasic_compress],
1902 link_whole : [libsystemd_static],
1903 dependencies : [threads,
1904 librt],
1905 link_depends : libsystemd_sym,
1906 install : true,
1907 install_tag: 'libsystemd',
1908 install_dir : rootlibdir)
1909
1910 install_libsystemd_static = static_library(
1911 'systemd',
1912 libsystemd_sources,
1913 basic_sources,
1914 basic_gcrypt_sources,
1915 basic_compress_sources,
1916 fundamental_sources,
1917 disable_mempool_c,
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,
1925 librt,
1926 libxz,
1927 libzstd,
1928 liblz4,
1929 libdl,
1930 libcap,
1931 libblkid,
1932 libmount,
1933 libgcrypt,
1934 libopenssl],
1935 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
1936
1937 libudev = shared_library(
1938 'udev',
1939 disable_mempool_c,
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,
1948 install : true,
1949 install_tag: 'libudev',
1950 install_dir : rootlibdir)
1951
1952 install_libudev_static = static_library(
1953 'udev',
1954 basic_sources,
1955 fundamental_sources,
1956 shared_sources,
1957 libsystemd_sources,
1958 libudev_sources,
1959 disable_mempool_c,
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)
1969
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,
1979 libshared],
1980 dependencies : [libcryptsetup,
1981 tpm2,
1982 versiondep],
1983 link_depends : cryptsetup_token_sym,
1984 install_rpath : rootlibexecdir,
1985 install : true,
1986 install_dir : libcryptsetup_plugins_dir)
1987 endif
1988
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,
1997 libshared],
1998 dependencies : [libcryptsetup,
1999 libfido2,
2000 versiondep],
2001 link_depends : cryptsetup_token_sym,
2002 install_rpath : rootlibexecdir,
2003 install : true,
2004 install_dir : libcryptsetup_plugins_dir)
2005 endif
2006
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,
2015 libshared],
2016 dependencies : [libcryptsetup,
2017 libp11kit,
2018 versiondep],
2019 link_depends : cryptsetup_token_sym,
2020 install_rpath : rootlibexecdir,
2021 install : true,
2022 install_dir : libcryptsetup_plugins_dir)
2023 endif
2024 endif
2025
2026 ############################################################
2027
2028 # systemd-analyze requires 'libcore'
2029 subdir('src/core')
2030 # systemd-journal-remote requires 'libjournal_core'
2031 subdir('src/journal')
2032 # systemd-networkd requires 'libsystemd_network'
2033 subdir('src/libsystemd-network')
2034
2035 subdir('src/analyze')
2036 subdir('src/busctl')
2037 subdir('src/coredump')
2038 subdir('src/cryptenroll')
2039 subdir('src/cryptsetup')
2040 subdir('src/home')
2041 subdir('src/hostname')
2042 subdir('src/import')
2043 subdir('src/journal-remote')
2044 subdir('src/kernel-install')
2045 subdir('src/locale')
2046 subdir('src/login')
2047 subdir('src/machine')
2048 subdir('src/network')
2049 subdir('src/nspawn')
2050 subdir('src/oom')
2051 subdir('src/partition')
2052 subdir('src/portable')
2053 subdir('src/pstore')
2054 subdir('src/resolve')
2055 subdir('src/rpm')
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')
2065
2066 subdir('src/systemd')
2067
2068 subdir('src/test')
2069 subdir('src/fuzz')
2070 subdir('rules.d')
2071 subdir('test')
2072
2073 ############################################################
2074
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(
2078 'test-dlopen',
2079 test_dlopen_c,
2080 disable_mempool_c,
2081 include_directories : includes,
2082 link_with : [libbasic],
2083 dependencies : [libdl],
2084 build_by_default : want_tests != 'false')
2085
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]]
2090
2091 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
2092 if condition
2093 module = tuple[0]
2094
2095 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
2096 version_script_arg = project_source_root / sym
2097
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)]
2102 endforeach
2103 endif
2104
2105 incs = tuple.length() > 3 ? tuple[3] : includes
2106
2107 nss = shared_library(
2108 'nss_' + module,
2109 sources,
2110 disable_mempool_c,
2111 version : '2',
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',
2115 '-shared',
2116 '-Wl,--version-script=' + version_script_arg],
2117 link_with : [libsystemd_static,
2118 libshared_static,
2119 libbasic],
2120 dependencies : [threads,
2121 librt],
2122 link_depends : sym,
2123 install : true,
2124 install_tag : 'nss',
2125 install_dir : rootlibdir)
2126
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),
2132 install_tag : 'nss'
2133 )
2134
2135 if want_tests != 'false'
2136 test('dlopen-nss_' + module,
2137 test_dlopen,
2138 # path to dlopen must include a slash
2139 args : nss.full_path(),
2140 depends : nss)
2141 endif
2142 endif
2143 endforeach
2144
2145 ############################################################
2146
2147 exe = executable(
2148 'systemd',
2149 systemd_sources,
2150 include_directories : includes,
2151 link_with : [libcore,
2152 libshared],
2153 dependencies : [versiondep,
2154 libseccomp],
2155 install_rpath : rootlibexecdir,
2156 install : true,
2157 install_dir : rootlibexecdir)
2158 dbus_programs += exe
2159 public_programs += exe
2160
2161 meson.add_install_script(meson_make_symlink,
2162 rootlibexecdir / 'systemd',
2163 rootsbindir / 'init')
2164
2165 exe = executable(
2166 'systemd-analyze',
2167 systemd_analyze_sources,
2168 include_directories : core_includes,
2169 link_with : [libcore,
2170 libshared],
2171 dependencies : [versiondep,
2172 libseccomp],
2173 install_rpath : rootlibexecdir,
2174 install : conf.get('ENABLE_ANALYZE'))
2175 public_programs += exe
2176
2177 if want_tests != 'false'
2178 test('test-compare-versions',
2179 test_compare_versions_sh,
2180 args : exe.full_path())
2181 endif
2182
2183 executable(
2184 'systemd-journald',
2185 systemd_journald_sources,
2186 include_directories : includes,
2187 link_with : [libjournal_core,
2188 libshared],
2189 dependencies : [threads,
2190 libxz,
2191 liblz4,
2192 libselinux,
2193 libzstd],
2194 install_rpath : rootlibexecdir,
2195 install : true,
2196 install_dir : rootlibexecdir)
2197
2198 public_programs += executable(
2199 'systemd-cat',
2200 systemd_cat_sources,
2201 include_directories : includes,
2202 link_with : [libjournal_core,
2203 libshared],
2204 dependencies : [threads],
2205 install_rpath : rootlibexecdir,
2206 install : true)
2207
2208 public_programs += executable(
2209 'journalctl',
2210 journalctl_sources,
2211 include_directories : includes,
2212 link_with : [libshared],
2213 dependencies : [threads,
2214 libdl,
2215 libxz,
2216 liblz4,
2217 libzstd,
2218 libdl],
2219 install_rpath : rootlibexecdir,
2220 install : true,
2221 install_dir : rootbindir)
2222
2223 executable(
2224 'systemd-getty-generator',
2225 'src/getty-generator/getty-generator.c',
2226 include_directories : includes,
2227 link_with : [libshared],
2228 install_rpath : rootlibexecdir,
2229 install : true,
2230 install_dir : systemgeneratordir)
2231
2232 executable(
2233 'systemd-debug-generator',
2234 'src/debug-generator/debug-generator.c',
2235 include_directories : includes,
2236 link_with : [libshared],
2237 install_rpath : rootlibexecdir,
2238 install : true,
2239 install_dir : systemgeneratordir)
2240
2241 executable(
2242 'systemd-run-generator',
2243 'src/run-generator/run-generator.c',
2244 include_directories : includes,
2245 link_with : [libshared],
2246 install_rpath : rootlibexecdir,
2247 install : true,
2248 install_dir : systemgeneratordir)
2249
2250 exe = executable(
2251 'systemd-fstab-generator',
2252 'src/fstab-generator/fstab-generator.c',
2253 include_directories : includes,
2254 link_with : [libshared],
2255 install_rpath : rootlibexecdir,
2256 install : true,
2257 install_dir : systemgeneratordir)
2258
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(),
2264 depends : exe)
2265 endif
2266
2267 if conf.get('ENABLE_ENVIRONMENT_D') == 1
2268 executable(
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,
2274 install : true,
2275 install_dir : userenvgeneratordir)
2276
2277 meson.add_install_script(meson_make_symlink,
2278 sysconfdir / 'environment',
2279 environmentdir / '99-environment.conf')
2280 endif
2281
2282 if conf.get('ENABLE_HIBERNATE') == 1
2283 executable(
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,
2289 install : true,
2290 install_dir : systemgeneratordir)
2291
2292 executable(
2293 'systemd-hibernate-resume',
2294 'src/hibernate-resume/hibernate-resume.c',
2295 include_directories : includes,
2296 link_with : [libshared],
2297 install_rpath : rootlibexecdir,
2298 install : true,
2299 install_dir : rootlibexecdir)
2300 endif
2301
2302 if conf.get('HAVE_BLKID') == 1
2303 executable(
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,
2310 install : true,
2311 install_dir : systemgeneratordir)
2312
2313 public_programs += executable(
2314 'systemd-dissect',
2315 'src/dissect/dissect.c',
2316 include_directories : includes,
2317 link_with : [libshared],
2318 install_rpath : rootlibexecdir,
2319 install : true)
2320 endif
2321
2322 if conf.get('ENABLE_RESOLVE') == 1
2323 dbus_programs += executable(
2324 'systemd-resolved',
2325 systemd_resolved_sources,
2326 include_directories : resolve_includes,
2327 link_with : [libshared,
2328 libbasic_gcrypt,
2329 libsystemd_resolve_core],
2330 dependencies : systemd_resolved_dependencies,
2331 install_rpath : rootlibexecdir,
2332 install : true,
2333 install_dir : rootlibexecdir)
2334
2335 public_programs += executable(
2336 'resolvectl',
2337 resolvectl_sources,
2338 include_directories : includes,
2339 link_with : [libshared,
2340 libbasic_gcrypt,
2341 libsystemd_resolve_core],
2342 dependencies : [threads,
2343 lib_openssl_or_gcrypt,
2344 libm,
2345 libidn],
2346 install_rpath : rootlibexecdir,
2347 install : true)
2348
2349 meson.add_install_script(meson_make_symlink,
2350 bindir / 'resolvectl',
2351 rootsbindir / 'resolvconf')
2352
2353 meson.add_install_script(meson_make_symlink,
2354 bindir / 'resolvectl',
2355 bindir / 'systemd-resolve')
2356 endif
2357
2358 if conf.get('ENABLE_LOGIND') == 1
2359 dbus_programs += executable(
2360 'systemd-logind',
2361 systemd_logind_sources,
2362 include_directories : includes,
2363 link_with : [liblogind_core,
2364 libshared],
2365 dependencies : [threads,
2366 libacl],
2367 install_rpath : rootlibexecdir,
2368 install : true,
2369 install_dir : rootlibexecdir)
2370
2371 public_programs += executable(
2372 'loginctl',
2373 loginctl_sources,
2374 include_directories : includes,
2375 link_with : [libshared],
2376 dependencies : [threads,
2377 liblz4,
2378 libxz,
2379 libzstd],
2380 install_rpath : rootlibexecdir,
2381 install : true,
2382 install_dir : rootbindir)
2383
2384 public_programs += executable(
2385 'systemd-inhibit',
2386 'src/login/inhibit.c',
2387 include_directories : includes,
2388 link_with : [libshared],
2389 install_rpath : rootlibexecdir,
2390 install : true,
2391 install_dir : rootbindir)
2392
2393 if conf.get('HAVE_PAM') == 1
2394 version_script_arg = project_source_root / pam_systemd_sym
2395 pam_systemd = shared_library(
2396 'pam_systemd',
2397 pam_systemd_c,
2398 name_prefix : '',
2399 include_directories : includes,
2400 link_args : ['-shared',
2401 '-Wl,--version-script=' + version_script_arg],
2402 link_with : [libsystemd_static,
2403 libshared_static],
2404 dependencies : [threads,
2405 libpam,
2406 libpam_misc],
2407 link_depends : pam_systemd_sym,
2408 install : true,
2409 install_tag : 'pam',
2410 install_dir : pamlibdir)
2411
2412 if want_tests != 'false'
2413 test('dlopen-pam_systemd',
2414 test_dlopen,
2415 # path to dlopen must include a slash
2416 args : pam_systemd.full_path(),
2417 depends : pam_systemd)
2418 endif
2419 endif
2420
2421 executable(
2422 'systemd-user-runtime-dir',
2423 user_runtime_dir_sources,
2424 include_directories : includes,
2425 link_with : [libshared],
2426 install_rpath : rootlibexecdir,
2427 install : true,
2428 install_dir : rootlibexecdir)
2429 endif
2430
2431 if conf.get('HAVE_PAM') == 1
2432 executable(
2433 'systemd-user-sessions',
2434 'src/user-sessions/user-sessions.c',
2435 include_directories : includes,
2436 link_with : [libshared],
2437 install_rpath : rootlibexecdir,
2438 install : true,
2439 install_dir : rootlibexecdir)
2440 endif
2441
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]
2445 else
2446 boot_link_with = [libsystemd_static, libshared_static]
2447 endif
2448
2449 public_programs += executable(
2450 'bootctl',
2451 'src/boot/bootctl.c',
2452 include_directories : includes,
2453 link_with : [boot_link_with],
2454 dependencies : [libblkid],
2455 install_rpath : rootlibexecdir,
2456 install : true)
2457
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,
2465 install : true,
2466 install_dir : rootlibexecdir)
2467
2468 executable(
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,
2474 install : true,
2475 install_dir : systemgeneratordir)
2476 endif
2477
2478 executable(
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,
2485 install : true,
2486 install_dir : rootlibexecdir)
2487
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,
2495 install : true)
2496
2497 systemctl = executable(
2498 'systemctl',
2499 systemctl_sources,
2500 include_directories : includes,
2501 link_with : systemctl_link_with,
2502 dependencies : [threads,
2503 libcap,
2504 libselinux,
2505 libxz,
2506 liblz4,
2507 libzstd],
2508 install_rpath : rootlibexecdir,
2509 install : true,
2510 install_dir : rootbindir)
2511 public_programs += systemctl
2512
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,
2521 install : true,
2522 install_dir : rootlibexecdir)
2523
2524 public_programs += executable(
2525 'portablectl',
2526 'src/portable/portablectl.c',
2527 include_directories : includes,
2528 link_with : [libshared],
2529 dependencies : [threads],
2530 install_rpath : rootlibexecdir,
2531 install : true,
2532 install_dir : rootbindir)
2533 endif
2534
2535 if conf.get('ENABLE_SYSEXT') == 1
2536 public_programs += executable(
2537 'systemd-sysext',
2538 systemd_sysext_sources,
2539 include_directories : includes,
2540 link_with : [libshared],
2541 install_rpath : rootlibexecdir,
2542 install : true,
2543 install_dir : rootbindir)
2544 endif
2545
2546 if conf.get('ENABLE_USERDB') == 1
2547 executable(
2548 'systemd-userwork',
2549 systemd_userwork_sources,
2550 include_directories : includes,
2551 link_with : [libshared],
2552 dependencies : [threads],
2553 install_rpath : rootlibexecdir,
2554 install : true,
2555 install_dir : rootlibexecdir)
2556
2557 executable(
2558 'systemd-userdbd',
2559 systemd_userdbd_sources,
2560 include_directories : includes,
2561 link_with : [libshared],
2562 dependencies : [threads],
2563 install_rpath : rootlibexecdir,
2564 install : true,
2565 install_dir : rootlibexecdir)
2566
2567 public_programs += executable(
2568 'userdbctl',
2569 userdbctl_sources,
2570 include_directories : includes,
2571 link_with : [libshared],
2572 dependencies : [threads],
2573 install_rpath : rootlibexecdir,
2574 install : true,
2575 install_dir : rootbindir)
2576 endif
2577
2578 if conf.get('ENABLE_HOMED') == 1
2579 executable(
2580 'systemd-homework',
2581 systemd_homework_sources,
2582 include_directories : includes,
2583 link_with : [libshared],
2584 dependencies : [threads,
2585 libblkid,
2586 libcrypt,
2587 libopenssl,
2588 libfdisk,
2589 libp11kit],
2590 install_rpath : rootlibexecdir,
2591 install : true,
2592 install_dir : rootlibexecdir)
2593
2594 dbus_programs += executable(
2595 'systemd-homed',
2596 systemd_homed_sources,
2597 include_directories : home_includes,
2598 link_with : [libshared],
2599 dependencies : [threads,
2600 libcrypt,
2601 libopenssl,
2602 libm],
2603 install_rpath : rootlibexecdir,
2604 install : true,
2605 install_dir : rootlibexecdir)
2606
2607 public_programs += executable(
2608 'homectl',
2609 homectl_sources,
2610 include_directories : includes,
2611 link_with : [libshared],
2612 dependencies : [threads,
2613 libcrypt,
2614 libopenssl,
2615 libp11kit,
2616 libdl],
2617 install_rpath : rootlibexecdir,
2618 install : true,
2619 install_dir : rootbindir)
2620
2621 if conf.get('HAVE_PAM') == 1
2622 version_script_arg = project_source_root / pam_systemd_home_sym
2623 pam_systemd = shared_library(
2624 'pam_systemd_home',
2625 pam_systemd_home_c,
2626 name_prefix : '',
2627 include_directories : includes,
2628 link_args : ['-shared',
2629 '-Wl,--version-script=' + version_script_arg],
2630 link_with : [libsystemd_static,
2631 libshared_static],
2632 dependencies : [threads,
2633 libpam,
2634 libpam_misc,
2635 libcrypt],
2636 link_depends : pam_systemd_home_sym,
2637 install : true,
2638 install_tag : 'pam',
2639 install_dir : pamlibdir)
2640 endif
2641 endif
2642
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)
2648 endforeach
2649
2650 meson.add_install_script(meson_make_symlink,
2651 rootbindir / 'udevadm',
2652 rootlibexecdir / 'systemd-udevd')
2653
2654 if conf.get('ENABLE_BACKLIGHT') == 1
2655 executable(
2656 'systemd-backlight',
2657 'src/backlight/backlight.c',
2658 include_directories : includes,
2659 link_with : [libshared],
2660 install_rpath : rootlibexecdir,
2661 install : true,
2662 install_dir : rootlibexecdir)
2663 endif
2664
2665 if conf.get('ENABLE_RFKILL') == 1
2666 executable(
2667 'systemd-rfkill',
2668 'src/rfkill/rfkill.c',
2669 include_directories : includes,
2670 link_with : [libshared],
2671 install_rpath : rootlibexecdir,
2672 install : true,
2673 install_dir : rootlibexecdir)
2674 endif
2675
2676 executable(
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,
2682 install : true,
2683 install_dir : systemgeneratordir)
2684
2685 if conf.get('HAVE_LIBCRYPTSETUP') == 1
2686 executable(
2687 'systemd-cryptsetup',
2688 systemd_cryptsetup_sources,
2689 include_directories : includes,
2690 link_with : [libshared],
2691 dependencies : [libcryptsetup,
2692 libp11kit],
2693 install_rpath : rootlibexecdir,
2694 install : true,
2695 install_dir : rootlibexecdir)
2696
2697 executable(
2698 'systemd-cryptsetup-generator',
2699 'src/cryptsetup/cryptsetup-generator.c',
2700 include_directories : includes,
2701 link_with : [libshared],
2702 install_rpath : rootlibexecdir,
2703 install : true,
2704 install_dir : systemgeneratordir)
2705
2706 executable(
2707 'systemd-veritysetup',
2708 'src/veritysetup/veritysetup.c',
2709 include_directories : includes,
2710 link_with : [libshared],
2711 dependencies : [libcryptsetup],
2712 install_rpath : rootlibexecdir,
2713 install : true,
2714 install_dir : rootlibexecdir)
2715
2716 executable(
2717 'systemd-veritysetup-generator',
2718 'src/veritysetup/veritysetup-generator.c',
2719 include_directories : includes,
2720 link_with : [libshared],
2721 install_rpath : rootlibexecdir,
2722 install : true,
2723 install_dir : systemgeneratordir)
2724
2725 public_programs += executable(
2726 'systemd-cryptenroll',
2727 systemd_cryptenroll_sources,
2728 include_directories : includes,
2729 link_with : [libshared],
2730 dependencies : [libcryptsetup,
2731 libdl,
2732 libopenssl,
2733 libp11kit],
2734 install_rpath : rootlibexecdir,
2735 install : true)
2736
2737 executable(
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,
2744 install : true,
2745 install_dir : rootlibexecdir)
2746
2747 executable(
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,
2753 install : true,
2754 install_dir : systemgeneratordir)
2755 endif
2756
2757 if conf.get('HAVE_SYSV_COMPAT') == 1
2758 exe = executable(
2759 'systemd-sysv-generator',
2760 'src/sysv-generator/sysv-generator.c',
2761 include_directories : includes,
2762 link_with : [libshared],
2763 install_rpath : rootlibexecdir,
2764 install : true,
2765 install_dir : systemgeneratordir)
2766
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,
2771 depends : exe)
2772 endif
2773
2774 executable(
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,
2780 install : true,
2781 install_dir : systemgeneratordir)
2782 endif
2783
2784 if conf.get('ENABLE_XDG_AUTOSTART') == 1
2785 executable(
2786 'systemd-xdg-autostart-generator',
2787 systemd_xdg_autostart_generator_sources,
2788 include_directories : includes,
2789 link_with : [libshared],
2790 install_rpath : rootlibexecdir,
2791 install : true,
2792 install_dir : usergeneratordir)
2793
2794 executable(
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,
2800 install : true,
2801 install_dir : rootlibexecdir)
2802 endif
2803
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,
2811 install : true,
2812 install_dir : rootlibexecdir)
2813
2814 public_programs += executable(
2815 'hostnamectl',
2816 'src/hostname/hostnamectl.c',
2817 include_directories : includes,
2818 link_with : [libshared],
2819 install_rpath : rootlibexecdir,
2820 install : true)
2821 endif
2822
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)]
2828 else
2829 deps = []
2830 endif
2831
2832 dbus_programs += executable(
2833 'systemd-localed',
2834 systemd_localed_sources,
2835 include_directories : includes,
2836 link_with : [libshared],
2837 dependencies : deps,
2838 install_rpath : rootlibexecdir,
2839 install : true,
2840 install_dir : rootlibexecdir)
2841
2842 public_programs += executable(
2843 'localectl',
2844 localectl_sources,
2845 include_directories : includes,
2846 link_with : [libshared],
2847 install_rpath : rootlibexecdir,
2848 install : true)
2849 endif
2850
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,
2858 install : true,
2859 install_dir : rootlibexecdir)
2860 endif
2861
2862 if conf.get('ENABLE_TIMEDATECTL') == 1
2863 public_programs += executable(
2864 'timedatectl',
2865 'src/timedate/timedatectl.c',
2866 include_directories : includes,
2867 install_rpath : rootlibexecdir,
2868 link_with : [libshared],
2869 dependencies : [libm],
2870 install : true)
2871 endif
2872
2873 if conf.get('ENABLE_TIMESYNCD') == 1
2874 executable(
2875 'systemd-timesyncd',
2876 systemd_timesyncd_sources,
2877 include_directories : includes,
2878 link_with : [libtimesyncd_core],
2879 dependencies : [threads,
2880 libm],
2881 install_rpath : rootlibexecdir,
2882 install : true,
2883 install_dir : rootlibexecdir)
2884
2885 executable(
2886 'systemd-time-wait-sync',
2887 'src/timesync/wait-sync.c',
2888 include_directories : includes,
2889 link_with : [libtimesyncd_core],
2890 install_rpath : rootlibexecdir,
2891 install : true,
2892 install_dir : rootlibexecdir)
2893 endif
2894
2895 if conf.get('ENABLE_MACHINED') == 1
2896 dbus_programs += executable(
2897 'systemd-machined',
2898 systemd_machined_sources,
2899 include_directories : includes,
2900 link_with : [libmachine_core,
2901 libshared],
2902 install_rpath : rootlibexecdir,
2903 install : true,
2904 install_dir : rootlibexecdir)
2905
2906 public_programs += executable(
2907 'machinectl',
2908 'src/machine/machinectl.c',
2909 include_directories : includes,
2910 link_with : [libshared],
2911 dependencies : [threads,
2912 libxz,
2913 liblz4,
2914 libzstd],
2915 install_rpath : rootlibexecdir,
2916 install : true,
2917 install_dir : rootbindir)
2918 endif
2919
2920 if conf.get('ENABLE_IMPORTD') == 1
2921 dbus_programs += executable(
2922 'systemd-importd',
2923 systemd_importd_sources,
2924 include_directories : includes,
2925 link_with : [libshared],
2926 dependencies : [threads],
2927 install_rpath : rootlibexecdir,
2928 install : true,
2929 install_dir : rootlibexecdir)
2930
2931 systemd_pull = executable(
2932 'systemd-pull',
2933 systemd_pull_sources,
2934 include_directories : includes,
2935 link_with : [libshared,
2936 lib_import_common],
2937 dependencies : [versiondep,
2938 libcurl,
2939 lib_openssl_or_gcrypt,
2940 libz,
2941 libbzip2,
2942 libxz],
2943 install_rpath : rootlibexecdir,
2944 install : true,
2945 install_dir : rootlibexecdir)
2946
2947 systemd_import = executable(
2948 'systemd-import',
2949 systemd_import_sources,
2950 include_directories : includes,
2951 link_with : [libshared,
2952 lib_import_common],
2953 dependencies : [libcurl,
2954 libz,
2955 libbzip2,
2956 libxz],
2957 install_rpath : rootlibexecdir,
2958 install : true,
2959 install_dir : rootlibexecdir)
2960
2961 systemd_import_fs = executable(
2962 'systemd-import-fs',
2963 systemd_import_fs_sources,
2964 include_directories : includes,
2965 link_with : [libshared,
2966 lib_import_common],
2967 install_rpath : rootlibexecdir,
2968 install : true,
2969 install_dir : rootlibexecdir)
2970
2971 systemd_export = executable(
2972 'systemd-export',
2973 systemd_export_sources,
2974 include_directories : includes,
2975 link_with : [libshared,
2976 lib_import_common],
2977 dependencies : [libcurl,
2978 libz,
2979 libbzip2,
2980 libxz],
2981 install_rpath : rootlibexecdir,
2982 install : true,
2983 install_dir : rootlibexecdir)
2984
2985 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
2986 endif
2987
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,
2995 threads,
2996 libcurl,
2997 libgnutls,
2998 libxz,
2999 liblz4,
3000 libzstd],
3001 install_rpath : rootlibexecdir,
3002 install : true,
3003 install_dir : rootlibexecdir)
3004 endif
3005
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,
3014 libmicrohttpd,
3015 libgnutls,
3016 libxz,
3017 liblz4,
3018 libzstd],
3019 install_rpath : rootlibexecdir,
3020 install : true,
3021 install_dir : rootlibexecdir)
3022
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,
3029 libmicrohttpd,
3030 libgnutls,
3031 libxz,
3032 liblz4,
3033 libzstd],
3034 install_rpath : rootlibexecdir,
3035 install : true,
3036 install_dir : rootlibexecdir)
3037 endif
3038
3039 if conf.get('ENABLE_COREDUMP') == 1
3040 executable(
3041 'systemd-coredump',
3042 systemd_coredump_sources,
3043 include_directories : includes,
3044 link_with : [libshared,
3045 libbasic_compress],
3046 dependencies : [threads,
3047 libacl,
3048 libxz,
3049 liblz4,
3050 libzstd],
3051 install_rpath : rootlibexecdir,
3052 install : true,
3053 install_dir : rootlibexecdir)
3054
3055 public_programs += executable(
3056 'coredumpctl',
3057 coredumpctl_sources,
3058 include_directories : includes,
3059 link_with : [libshared,
3060 libbasic_compress],
3061 dependencies : [threads,
3062 libxz,
3063 liblz4,
3064 libzstd],
3065 install_rpath : rootlibexecdir,
3066 install : true)
3067 endif
3068
3069 if conf.get('ENABLE_PSTORE') == 1
3070 executable(
3071 'systemd-pstore',
3072 systemd_pstore_sources,
3073 include_directories : includes,
3074 link_with : [libshared],
3075 dependencies : [threads,
3076 libacl,
3077 libxz,
3078 liblz4,
3079 libzstd],
3080 install_rpath : rootlibexecdir,
3081 install : true,
3082 install_dir : rootlibexecdir)
3083 endif
3084
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],
3090 dependencies : [],
3091 install_rpath : rootlibexecdir,
3092 install : true,
3093 install_dir : rootlibexecdir)
3094
3095 public_programs += executable(
3096 'oomctl',
3097 oomctl_sources,
3098 include_directories : includes,
3099 link_with : [libshared],
3100 dependencies : [],
3101 install_rpath : rootlibexecdir,
3102 install : true)
3103 endif
3104
3105 if conf.get('ENABLE_BINFMT') == 1
3106 public_programs += executable(
3107 'systemd-binfmt',
3108 'src/binfmt/binfmt.c',
3109 include_directories : includes,
3110 link_with : [libshared],
3111 install_rpath : rootlibexecdir,
3112 install : true,
3113 install_dir : rootlibexecdir)
3114
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'))
3120 endif
3121 endif
3122
3123 if conf.get('ENABLE_SYSUPDATE') == 1
3124 exe = executable(
3125 'systemd-sysupdate',
3126 systemd_sysupdate_sources,
3127 include_directories : includes,
3128 link_with : [libshared],
3129 dependencies : [threads,
3130 libblkid,
3131 libfdisk,
3132 libopenssl],
3133 install_rpath : rootlibexecdir,
3134 install : true,
3135 install_dir : rootlibexecdir)
3136 public_programs += exe
3137 endif
3138
3139 if conf.get('ENABLE_VCONSOLE') == 1
3140 executable(
3141 'systemd-vconsole-setup',
3142 'src/vconsole/vconsole-setup.c',
3143 include_directories : includes,
3144 link_with : [libshared],
3145 install_rpath : rootlibexecdir,
3146 install : true,
3147 install_dir : rootlibexecdir)
3148 endif
3149
3150 if conf.get('ENABLE_RANDOMSEED') == 1
3151 executable(
3152 'systemd-random-seed',
3153 'src/random-seed/random-seed.c',
3154 include_directories : includes,
3155 link_with : [libshared],
3156 install_rpath : rootlibexecdir,
3157 install : true,
3158 install_dir : rootlibexecdir)
3159 endif
3160
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,
3169 install : true,
3170 install_dir : rootbindir)
3171 endif
3172
3173 executable(
3174 'systemd-remount-fs',
3175 'src/remount-fs/remount-fs.c',
3176 include_directories : includes,
3177 link_with : [libshared],
3178 install_rpath : rootlibexecdir,
3179 install : true,
3180 install_dir : rootlibexecdir)
3181
3182 executable(
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,
3188 install : true,
3189 install_dir : rootbindir)
3190
3191 executable(
3192 'systemd-fsck',
3193 'src/fsck/fsck.c',
3194 include_directories : includes,
3195 link_with : [libshared],
3196 install_rpath : rootlibexecdir,
3197 install : true,
3198 install_dir : rootlibexecdir)
3199
3200 executable('systemd-growfs',
3201 'src/partition/growfs.c',
3202 include_directories : includes,
3203 link_with : [libshared],
3204 install_rpath : rootlibexecdir,
3205 install : true,
3206 install_dir : rootlibexecdir)
3207
3208 executable(
3209 'systemd-makefs',
3210 'src/partition/makefs.c',
3211 include_directories : includes,
3212 link_with : [libshared],
3213 install_rpath : rootlibexecdir,
3214 install : true,
3215 install_dir : rootlibexecdir)
3216
3217 executable(
3218 'systemd-sleep',
3219 'src/sleep/sleep.c',
3220 include_directories : includes,
3221 link_with : [libshared],
3222 install_rpath : rootlibexecdir,
3223 install : true,
3224 install_dir : rootlibexecdir)
3225
3226 if install_sysconfdir_samples
3227 install_data('src/sleep/sleep.conf',
3228 install_dir : pkgsysconfdir)
3229 endif
3230
3231 public_programs += executable(
3232 'systemd-sysctl',
3233 'src/sysctl/sysctl.c',
3234 include_directories : includes,
3235 link_with : [libshared],
3236 install_rpath : rootlibexecdir,
3237 install : true,
3238 install_dir : rootlibexecdir)
3239
3240 executable(
3241 'systemd-ac-power',
3242 'src/ac-power/ac-power.c',
3243 include_directories : includes,
3244 link_with : [libshared],
3245 install_rpath : rootlibexecdir,
3246 install : true,
3247 install_dir : rootlibexecdir)
3248
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,
3255 install : true)
3256
3257 public_programs += executable(
3258 'systemd-delta',
3259 'src/delta/delta.c',
3260 include_directories : includes,
3261 link_with : [libshared],
3262 install_rpath : rootlibexecdir,
3263 install : true)
3264
3265 public_programs += executable(
3266 'systemd-escape',
3267 'src/escape/escape.c',
3268 include_directories : includes,
3269 link_with : [libshared],
3270 install_rpath : rootlibexecdir,
3271 install : true,
3272 install_dir : rootbindir)
3273
3274 public_programs += executable(
3275 'systemd-notify',
3276 'src/notify/notify.c',
3277 include_directories : includes,
3278 link_with : [libshared],
3279 install_rpath : rootlibexecdir,
3280 install : true,
3281 install_dir : rootbindir)
3282
3283 public_programs += executable(
3284 'systemd-creds',
3285 'src/creds/creds.c',
3286 include_directories : includes,
3287 link_with : [libshared],
3288 dependencies : [threads,
3289 libopenssl],
3290 install_rpath : rootlibexecdir,
3291 install : true,
3292 install_dir : rootbindir)
3293
3294 executable(
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)
3302
3303 executable(
3304 'systemd-cgroups-agent',
3305 'src/cgroups-agent/cgroups-agent.c',
3306 include_directories : includes,
3307 link_with : [libshared],
3308 install_rpath : rootlibexecdir,
3309 install : true,
3310 install_dir : rootlibexecdir)
3311
3312 systemd_id128 = executable(
3313 'systemd-id128',
3314 'src/id128/id128.c',
3315 include_directories : includes,
3316 link_with : [libshared],
3317 install_rpath : rootlibexecdir,
3318 install : true)
3319 public_programs += systemd_id128
3320
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()])
3327 endif
3328
3329 public_programs += executable(
3330 'systemd-path',
3331 'src/path/path.c',
3332 include_directories : includes,
3333 link_with : [libshared],
3334 install_rpath : rootlibexecdir,
3335 install : true)
3336
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,
3343 install : true,
3344 install_dir : rootbindir)
3345
3346 executable(
3347 'systemd-reply-password',
3348 'src/reply-password/reply-password.c',
3349 include_directories : includes,
3350 link_with : [libshared],
3351 install_rpath : rootlibexecdir,
3352 install : true,
3353 install_dir : rootlibexecdir)
3354
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,
3361 install : true,
3362 install_dir : rootbindir)
3363
3364 public_programs += executable(
3365 'systemd-cgls',
3366 'src/cgls/cgls.c',
3367 include_directories : includes,
3368 link_with : [libshared],
3369 install_rpath : rootlibexecdir,
3370 install : true)
3371
3372 public_programs += executable(
3373 'systemd-cgtop',
3374 'src/cgtop/cgtop.c',
3375 include_directories : includes,
3376 link_with : [libshared],
3377 install_rpath : rootlibexecdir,
3378 install : true)
3379
3380 executable(
3381 'systemd-initctl',
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)
3388
3389 public_programs += executable(
3390 'systemd-mount',
3391 'src/mount/mount-tool.c',
3392 include_directories : includes,
3393 link_with : [libshared],
3394 dependencies: [libmount],
3395 install_rpath : rootlibexecdir,
3396 install : true)
3397
3398 meson.add_install_script(meson_make_symlink,
3399 'systemd-mount', bindir / 'systemd-umount')
3400
3401 public_programs += executable(
3402 'systemd-run',
3403 'src/run/run.c',
3404 include_directories : includes,
3405 link_with : [libshared],
3406 install_rpath : rootlibexecdir,
3407 install : true)
3408
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,
3416 install : true)
3417
3418 public_programs += executable(
3419 'busctl',
3420 busctl_sources,
3421 include_directories : includes,
3422 link_with : [libshared],
3423 dependencies : [versiondep],
3424 install_rpath : rootlibexecdir,
3425 install : true)
3426
3427 if enable_sysusers
3428 exe = executable(
3429 'systemd-sysusers',
3430 'src/sysusers/sysusers.c',
3431 include_directories : includes,
3432 link_with : [libshared],
3433 install_rpath : rootlibexecdir,
3434 install : true,
3435 install_dir : rootbindir)
3436 public_programs += exe
3437
3438 if want_tests != 'false'
3439 test('test-sysusers',
3440 test_sysusers_sh,
3441 # https://github.com/mesonbuild/meson/issues/2681
3442 args : exe.full_path())
3443 endif
3444
3445 if have_standalone_binaries
3446 exe = executable(
3447 'systemd-sysusers.standalone',
3448 'src/sysusers/sysusers.c',
3449 include_directories : includes,
3450 c_args : '-DSTANDALONE',
3451 link_with : [libshared_static,
3452 libbasic,
3453 libbasic_gcrypt,
3454 libsystemd_static],
3455 install : true,
3456 install_dir : rootbindir)
3457 public_programs += exe
3458
3459 if want_tests != 'false'
3460 test('test-sysusers.standalone',
3461 test_sysusers_sh,
3462 # https://github.com/mesonbuild/meson/issues/2681
3463 args : exe.full_path())
3464 endif
3465 endif
3466 endif
3467
3468 if conf.get('ENABLE_TMPFILES') == 1
3469 exe = executable(
3470 'systemd-tmpfiles',
3471 systemd_tmpfiles_sources,
3472 include_directories : includes,
3473 link_with : [libshared],
3474 dependencies : [libacl],
3475 install_rpath : rootlibexecdir,
3476 install : true,
3477 install_dir : rootbindir)
3478 public_programs += exe
3479
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())
3485 endif
3486
3487 if have_standalone_binaries
3488 exe = executable(
3489 'systemd-tmpfiles.standalone',
3490 systemd_tmpfiles_sources,
3491 include_directories : includes,
3492 c_args : '-DSTANDALONE',
3493 link_with : [libshared_static,
3494 libbasic,
3495 libbasic_gcrypt,
3496 libsystemd_static],
3497 dependencies : [libacl],
3498 install : true,
3499 install_dir : rootbindir)
3500 public_programs += exe
3501
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())
3507 endif
3508 endif
3509 endif
3510
3511 if conf.get('ENABLE_HWDB') == 1
3512 systemd_hwdb = executable(
3513 'systemd-hwdb',
3514 'src/hwdb/hwdb.c',
3515 include_directories : includes,
3516 link_with : udev_link_with,
3517 install_rpath : udev_rpath,
3518 install : true,
3519 install_dir : rootbindir)
3520 public_programs += systemd_hwdb
3521
3522 if want_tests != 'false'
3523 test('hwdb-test',
3524 hwdb_test_sh,
3525 suite : 'dist-check',
3526 args : [systemd_hwdb.full_path()],
3527 timeout : 90)
3528 endif
3529 endif
3530
3531 if conf.get('ENABLE_QUOTACHECK') == 1
3532 executable(
3533 'systemd-quotacheck',
3534 'src/quotacheck/quotacheck.c',
3535 include_directories : includes,
3536 link_with : [libshared],
3537 install_rpath : rootlibexecdir,
3538 install : true,
3539 install_dir : rootlibexecdir)
3540 endif
3541
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,
3549 install : true,
3550 install_dir : rootlibexecdir)
3551
3552 udevadm = executable(
3553 'udevadm',
3554 udevadm_sources,
3555 include_directories : includes,
3556 link_with : [libudevd_core],
3557 dependencies : [versiondep,
3558 threads,
3559 libkmod,
3560 libidn,
3561 libacl,
3562 libblkid],
3563 install_rpath : udev_rpath,
3564 install : true,
3565 install_dir : rootbindir)
3566 public_programs += udevadm
3567
3568 if conf.get('ENABLE_REPART') == 1
3569 exe = executable(
3570 'systemd-repart',
3571 systemd_repart_sources,
3572 include_directories : includes,
3573 link_with : [libshared],
3574 dependencies : [threads,
3575 libblkid,
3576 libfdisk],
3577 install_rpath : rootlibexecdir,
3578 install : true,
3579 install_dir : rootbindir)
3580 public_programs += exe
3581
3582 if want_tests != 'false'
3583 test('test-repart',
3584 test_repart_sh,
3585 args : [exe.full_path(), udevadm.full_path()])
3586 endif
3587 endif
3588
3589 executable(
3590 'systemd-shutdown',
3591 systemd_shutdown_sources,
3592 include_directories : includes,
3593 link_with : [libshared],
3594 dependencies : [libmount],
3595 install_rpath : rootlibexecdir,
3596 install : true,
3597 install_dir : rootlibexecdir)
3598
3599 executable(
3600 'systemd-update-done',
3601 'src/update-done/update-done.c',
3602 include_directories : includes,
3603 link_with : [libshared],
3604 install_rpath : rootlibexecdir,
3605 install : true,
3606 install_dir : rootlibexecdir)
3607
3608 executable(
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)
3617
3618 if conf.get('HAVE_KMOD') == 1
3619 executable(
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,
3626 install : true,
3627 install_dir : rootlibexecdir)
3628
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'))
3634 endif
3635 endif
3636
3637 public_programs += executable(
3638 'systemd-nspawn',
3639 systemd_nspawn_sources,
3640 include_directories : includes,
3641 link_with : [libnspawn_core,
3642 libshared],
3643 dependencies : [libblkid,
3644 libseccomp],
3645 install_rpath : rootlibexecdir,
3646 install : true)
3647
3648 if conf.get('ENABLE_NETWORKD') == 1
3649 dbus_programs += executable(
3650 'systemd-networkd',
3651 systemd_networkd_sources,
3652 include_directories : network_includes,
3653 link_with : [libnetworkd_core,
3654 libsystemd_network,
3655 networkd_link_with],
3656 dependencies : [threads],
3657 install_rpath : rootlibexecdir,
3658 install : true,
3659 install_dir : rootlibexecdir)
3660
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,
3667 install : true,
3668 install_dir : rootlibexecdir)
3669
3670 public_programs += executable(
3671 'networkctl',
3672 networkctl_sources,
3673 include_directories : libsystemd_network_includes,
3674 link_with : [libsystemd_network,
3675 networkd_link_with],
3676 install_rpath : rootlibexecdir,
3677 install : true,
3678 install_dir : rootbindir)
3679 endif
3680
3681 exe = executable(
3682 'systemd-network-generator',
3683 network_generator_sources,
3684 include_directories : includes,
3685 link_with : [networkd_link_with],
3686 install_rpath : rootlibexecdir,
3687 install : true,
3688 install_dir : rootlibexecdir)
3689
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(),
3695 depends : exe)
3696 endif
3697
3698 executable(
3699 'systemd-sulogin-shell',
3700 'src/sulogin-shell/sulogin-shell.c',
3701 include_directories : includes,
3702 link_with : [libshared],
3703 install_rpath : rootlibexecdir,
3704 install : true,
3705 install_dir : rootlibexecdir)
3706
3707 public_programs += custom_target(
3708 'kernel-install',
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)
3715
3716 ############################################################
3717
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')],
3725 depends : catalogs,
3726 build_by_default : true)
3727
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')
3735 endif
3736
3737 foreach tuple : tests
3738 sources = tuple[0]
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] : []
3745 defs += test_cflags
3746 parallel = tuple.length() > 7 ? tuple[7] : true
3747 timeout = 30
3748
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()
3753 type = ''
3754 endif
3755
3756 if condition == '' or conf.get(condition) == 1
3757 exe = executable(
3758 name,
3759 sources,
3760 include_directories : incs,
3761 link_with : link_with,
3762 dependencies : [versiondep,
3763 dependencies],
3764 c_args : defs,
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)
3770
3771 if type == 'manual'
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'
3776 test(name, exe,
3777 env : test_env,
3778 timeout : timeout)
3779 endif
3780 else
3781 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
3782 endif
3783 endforeach
3784
3785 exe = executable(
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)
3795 endif
3796
3797 exe = executable(
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)
3809 endif
3810
3811 exe = executable(
3812 'test-libudev-sym',
3813 test_libudev_sym_c,
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)
3822 endif
3823
3824 exe = executable(
3825 'test-libudev-static-sym',
3826 test_libudev_sym_c,
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)
3835 endif
3836
3837 ############################################################
3838
3839 fuzzer_exes = []
3840
3841 foreach tuple : fuzzers
3842 sources = tuple[0]
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] : []
3847 link_args = []
3848
3849 if want_ossfuzz
3850 dependencies += fuzzing_engine
3851 elif want_libfuzzer
3852 if fuzzing_engine.found()
3853 dependencies += fuzzing_engine
3854 else
3855 link_args += ['-fsanitize=fuzzer']
3856 endif
3857 else
3858 sources += 'src/fuzz/fuzz-main.c'
3859 endif
3860
3861 # FIXME: Use fs.stem() with meson >= 0.54.0
3862 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
3863
3864 exe = executable(
3865 name,
3866 sources,
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,
3872 install : false,
3873 build_by_default : fuzzer_build)
3874 fuzzer_exes += exe
3875
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]
3882
3883 if b == name
3884 test('@0@_@1@'.format(b, c),
3885 exe,
3886 suite : 'fuzzers',
3887 args : [project_source_root / p])
3888 endif
3889 endforeach
3890 endif
3891 endforeach
3892
3893 alias_target('fuzzers', fuzzer_exes)
3894
3895 ############################################################
3896
3897 subdir('modprobe.d')
3898 subdir('sysctl.d')
3899 subdir('sysusers.d')
3900 subdir('tmpfiles.d')
3901 subdir('hwdb.d')
3902 subdir('units')
3903 subdir('presets')
3904 subdir('network')
3905 subdir('man')
3906 subdir('shell-completion/bash')
3907 subdir('shell-completion/zsh')
3908 subdir('docs/sysvinit')
3909 subdir('docs/var-log')
3910
3911 install_subdir('factory/etc',
3912 install_dir : factorydir)
3913 subdir('factory/templates')
3914
3915 if install_sysconfdir
3916 install_data('xorg/50-systemd-user.sh',
3917 install_dir : xinitrcdir)
3918 endif
3919 install_data('LICENSE.GPL2',
3920 'LICENSE.LGPL2.1',
3921 'NEWS',
3922 'README',
3923 'docs/CODING_STYLE.md',
3924 'docs/DISTRO_PORTING.md',
3925 'docs/ENVIRONMENT.md',
3926 'docs/HACKING.md',
3927 'docs/TRANSIENT-SETTINGS.md',
3928 'docs/TRANSLATORS.md',
3929 'docs/UIDS-GIDS.md',
3930 'docs/GVARIANT-SERIALIZATION.md',
3931 install_dir : docdir)
3932
3933 install_subdir('LICENSES',
3934 install_dir : docdir)
3935
3936 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
3937 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
3938
3939 ############################################################
3940
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',
3948 jekyll,
3949 suite : 'dist-check',
3950 args : ['build',
3951 '--source', project_source_root / 'docs',
3952 '--destination', project_build_root / '_site'])
3953 endif
3954
3955 ############################################################
3956
3957 check_help = find_program('tools/check-help.sh')
3958 check_version = find_program('tools/check-version.sh')
3959
3960 foreach exec : public_programs
3961 name = exec.full_path().split('/')[-1]
3962 if want_tests != 'false'
3963 test('check-help-' + name,
3964 check_help,
3965 suite : 'dist-check',
3966 args : exec.full_path(),
3967 depends: exec)
3968
3969 test('check-version-' + name,
3970 check_version,
3971 suite : 'dist-check',
3972 args : [exec.full_path(),
3973 meson.project_version()],
3974 depends: exec)
3975 endif
3976 endforeach
3977
3978 ############################################################
3979
3980 check_directives_sh = find_program('tools/check-directives.sh')
3981
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])
3987 endif
3988
3989 ############################################################
3990
3991 # Enable tests for all supported sanitizers
3992 foreach tuple : sanitizers
3993 sanitizer = tuple[0]
3994 build = tuple[1]
3995
3996 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
3997 prev = ''
3998 foreach p : fuzz_regression_tests
3999 b = p.split('/')[-2]
4000 c = p.split('/')[-1]
4001
4002 name = '@0@:@1@'.format(b, sanitizer)
4003
4004 if name != prev
4005 if want_tests == 'false'
4006 message('Not compiling @0@ because tests is set to false'.format(name))
4007 elif fuzz_tests
4008 exe = custom_target(
4009 name,
4010 output : name,
4011 depends : build,
4012 command : [ln, '-fs',
4013 build.full_path() / b,
4014 '@OUTPUT@'],
4015 build_by_default : true)
4016 else
4017 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
4018 endif
4019 endif
4020 prev = name
4021
4022 if fuzz_tests
4023 test('@0@_@1@_@2@'.format(b, c, sanitizer),
4024 env,
4025 suite : 'fuzz+san',
4026 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
4027 timeout : 60,
4028 args : [exe.full_path(),
4029 project_source_root / p])
4030 endif
4031 endforeach
4032 endif
4033 endforeach
4034
4035
4036 ############################################################
4037
4038 if git.found()
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]',
4043 check : false)
4044 if all_files.returncode() == 0
4045 all_files = files(all_files.stdout().split())
4046
4047 custom_target(
4048 'tags',
4049 output : 'tags',
4050 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
4051 run_target(
4052 'ctags',
4053 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
4054 endif
4055 endif
4056
4057 if git.found()
4058 git_contrib_sh = find_program('tools/git-contrib.sh')
4059 run_target(
4060 'git-contrib',
4061 command : [git_contrib_sh])
4062 endif
4063
4064 if git.found()
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()
4073
4074 run_target(
4075 'git-snapshot',
4076 command : [git, 'archive',
4077 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
4078 git_head_short),
4079 '--prefix', 'systemd-@0@/'.format(git_head),
4080 'HEAD'])
4081 endif
4082
4083 ############################################################
4084
4085 check_api_docs_sh = find_program('tools/check-api-docs.sh')
4086 run_target(
4087 'check-api-docs',
4088 depends : [man, libsystemd, libudev],
4089 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
4090
4091 alias_target('update-dbus-docs', update_dbus_docs)
4092 alias_target('update-man-rules', update_man_rules)
4093
4094 if not meson.is_cross_build()
4095 custom_target(
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])
4101 endif
4102
4103 ############################################################
4104
4105 alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
4106 check : true).stdout().strip()
4107
4108 summary({
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)})
4163
4164 # TODO:
4165 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
4166 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
4167 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
4168
4169 found = []
4170 missing = []
4171
4172 foreach tuple : [
4173 # dependencies
4174 ['ACL'],
4175 ['AUDIT'],
4176 ['AppArmor'],
4177 ['IMA'],
4178 ['PAM'],
4179 ['SECCOMP'],
4180 ['SELinux'],
4181 ['SMACK'],
4182 ['blkid'],
4183 ['elfutils'],
4184 ['gcrypt'],
4185 ['gnutls'],
4186 ['libbpf'],
4187 ['libcryptsetup'],
4188 ['libcryptsetup-plugins'],
4189 ['libcurl'],
4190 ['libfdisk'],
4191 ['libfido2'],
4192 ['libidn'],
4193 ['libidn2'],
4194 ['libiptc'],
4195 ['microhttpd'],
4196 ['openssl'],
4197 ['p11kit'],
4198 ['pcre2'],
4199 ['pwquality'],
4200 ['qrencode'],
4201 ['tpm2'],
4202 ['xkbcommon'],
4203
4204 # compression libs
4205 ['zstd'],
4206 ['lz4'],
4207 ['xz'],
4208 ['zlib'],
4209 ['bzip2'],
4210
4211 # components
4212 ['backlight'],
4213 ['binfmt'],
4214 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
4215 ['coredump'],
4216 ['environment.d'],
4217 ['efi'],
4218 ['gnu-efi'],
4219 ['firstboot'],
4220 ['hibernate'],
4221 ['homed'],
4222 ['hostnamed'],
4223 ['hwdb'],
4224 ['importd'],
4225 ['initrd'],
4226 ['kernel-install'],
4227 ['localed'],
4228 ['logind'],
4229 ['machined'],
4230 ['networkd'],
4231 ['nss-myhostname'],
4232 ['nss-mymachines'],
4233 ['nss-resolve'],
4234 ['nss-systemd'],
4235 ['oomd'],
4236 ['portabled'],
4237 ['pstore'],
4238 ['quotacheck'],
4239 ['randomseed'],
4240 ['repart'],
4241 ['resolve'],
4242 ['rfkill'],
4243 ['sysext'],
4244 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
4245 ['sysupdate'],
4246 ['sysusers'],
4247 ['timedated'],
4248 ['timesyncd'],
4249 ['tmpfiles'],
4250 ['userdb'],
4251 ['vconsole'],
4252 ['xdg-autostart'],
4253
4254 # optional features
4255 ['idn'],
4256 ['polkit'],
4257 ['nscd'],
4258 ['legacy-pkla', install_polkit_pkla],
4259 ['kmod'],
4260 ['dbus'],
4261 ['glib'],
4262 ['tpm'],
4263 ['man pages', want_man],
4264 ['html pages', want_html],
4265 ['man page indices', want_man and have_lxml],
4266 ['SysV compat'],
4267 ['compat-mutable-uid-boundaries'],
4268 ['utmp'],
4269 ['ldconfig'],
4270 ['adm group', get_option('adm-group')],
4271 ['wheel group', get_option('wheel-group')],
4272 ['gshadow'],
4273 ['debug hashmap'],
4274 ['debug mmap cache'],
4275 ['debug siphash'],
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')],
4284 ['fexecve'],
4285 ['standalone-binaries', get_option('standalone-binaries')],
4286 ['coverage', get_option('b_coverage')],
4287 ]
4288
4289 if tuple.length() >= 2
4290 cond = tuple[1]
4291 else
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
4295 endif
4296 if cond
4297 found += tuple[0]
4298 else
4299 missing += tuple[0]
4300 endif
4301 endforeach
4302
4303 if static_libsystemd == 'false'
4304 missing += 'static-libsystemd'
4305 else
4306 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
4307 endif
4308
4309 if static_libudev == 'false'
4310 missing += 'static-libudev'
4311 else
4312 found += 'static-libudev(@0@)'.format(static_libudev)
4313 endif
4314
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)'
4319 else
4320 missing += 'cryptolib'
4321 endif
4322
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)'
4327 else
4328 missing += 'DNS-over-TLS'
4329 endif
4330
4331 summary({
4332 'enabled' : ', '.join(found),
4333 'disabled' : ', '.join(missing)},
4334 section : 'Features')
4335
4336 if rootprefixdir != rootprefix_default
4337 warning('\n' +
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))
4341 endif