]> git.ipfire.org Git - thirdparty/systemd.git/blob - meson.build
sleep: store battery discharge rate/hour with hash
[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 # This will be a relative path if libdir is in prefix.
148 rootlibdir = get_option('libdir')
149 endif
150 if not rootlibdir.startswith('/')
151 # If we have a relative path, add rootprefixdir to the front.
152 rootlibdir = rootprefixdir / rootlibdir
153 endif
154 rootpkglibdir = rootlibdir / 'systemd'
155
156 install_sysconfdir = get_option('install-sysconfdir') != 'false'
157 install_sysconfdir_samples = get_option('install-sysconfdir') == 'true'
158 # Dirs of external packages
159 pkgconfigdatadir = get_option('pkgconfigdatadir') != '' ? get_option('pkgconfigdatadir') : datadir / 'pkgconfig'
160 pkgconfiglibdir = get_option('pkgconfiglibdir') != '' ? get_option('pkgconfiglibdir') : libdir / 'pkgconfig'
161 polkitpolicydir = datadir / 'polkit-1/actions'
162 polkitrulesdir = datadir / 'polkit-1/rules.d'
163 polkitpkladir = localstatedir / 'lib/polkit-1/localauthority/10-vendor.d'
164 xinitrcdir = get_option('xinitrcdir') != '' ? get_option('xinitrcdir') : sysconfdir / 'X11/xinit/xinitrc.d'
165 rpmmacrosdir = get_option('rpmmacrosdir')
166 if rpmmacrosdir != 'no'
167 rpmmacrosdir = prefixdir / rpmmacrosdir
168 endif
169 modprobedir = rootprefixdir / 'lib/modprobe.d'
170
171 # Our own paths
172 pkgdatadir = datadir / 'systemd'
173 environmentdir = prefixdir / 'lib/environment.d'
174 pkgsysconfdir = sysconfdir / 'systemd'
175 userunitdir = prefixdir / 'lib/systemd/user'
176 userpresetdir = prefixdir / 'lib/systemd/user-preset'
177 tmpfilesdir = prefixdir / 'lib/tmpfiles.d'
178 usertmpfilesdir = prefixdir / 'share/user-tmpfiles.d'
179 sysusersdir = prefixdir / 'lib/sysusers.d'
180 sysctldir = prefixdir / 'lib/sysctl.d'
181 binfmtdir = prefixdir / 'lib/binfmt.d'
182 modulesloaddir = prefixdir / 'lib/modules-load.d'
183 networkdir = rootprefixdir / 'lib/systemd/network'
184 pkgincludedir = includedir / 'systemd'
185 systemgeneratordir = rootlibexecdir / 'system-generators'
186 usergeneratordir = prefixdir / 'lib/systemd/user-generators'
187 systemenvgeneratordir = prefixdir / 'lib/systemd/system-environment-generators'
188 userenvgeneratordir = prefixdir / 'lib/systemd/user-environment-generators'
189 systemshutdowndir = rootlibexecdir / 'system-shutdown'
190 systemsleepdir = rootlibexecdir / 'system-sleep'
191 systemunitdir = rootprefixdir / 'lib/systemd/system'
192 systempresetdir = rootprefixdir / 'lib/systemd/system-preset'
193 udevlibexecdir = rootprefixdir / 'lib/udev'
194 udevrulesdir = udevlibexecdir / 'rules.d'
195 udevhwdbdir = udevlibexecdir / 'hwdb.d'
196 catalogdir = prefixdir / 'lib/systemd/catalog'
197 kerneldir = prefixdir / 'lib/kernel'
198 kernelinstalldir = kerneldir / 'install.d'
199 factorydir = datadir / 'factory'
200 bootlibdir = prefixdir / 'lib/systemd/boot/efi'
201 testsdir = prefixdir / 'lib/systemd/tests'
202 systemdstatedir = localstatedir / 'lib/systemd'
203 catalogstatedir = systemdstatedir / 'catalog'
204 randomseeddir = localstatedir / 'lib/systemd'
205 profiledir = rootlibexecdir / 'portable' / 'profile'
206 ntpservicelistdir = rootprefixdir / 'lib/systemd/ntp-units.d'
207
208 docdir = get_option('docdir')
209 if docdir == ''
210 docdir = datadir / 'doc/systemd'
211 endif
212
213 pamlibdir = get_option('pamlibdir')
214 if pamlibdir == ''
215 pamlibdir = rootlibdir / 'security'
216 endif
217
218 pamconfdir = get_option('pamconfdir')
219 if pamconfdir == ''
220 pamconfdir = prefixdir / 'lib/pam.d'
221 endif
222
223 libcryptsetup_plugins_dir = get_option('libcryptsetup-plugins-dir')
224 if libcryptsetup_plugins_dir == ''
225 libcryptsetup_plugins_dir = rootlibdir / 'cryptsetup'
226 endif
227
228 memory_accounting_default = get_option('memory-accounting-default')
229 status_unit_format_default = get_option('status-unit-format-default')
230 if status_unit_format_default == 'auto'
231 status_unit_format_default = conf.get('BUILD_MODE_DEVELOPER') == 1 ? 'name' : 'description'
232 endif
233
234 conf.set_quoted('BINFMT_DIR', binfmtdir)
235 conf.set_quoted('BOOTLIBDIR', bootlibdir)
236 conf.set_quoted('CATALOG_DATABASE', catalogstatedir / 'database')
237 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
238 conf.set_quoted('DOC_DIR', docdir)
239 conf.set_quoted('DOCUMENT_ROOT', pkgdatadir / 'gatewayd')
240 conf.set_quoted('ENVIRONMENT_DIR', environmentdir)
241 conf.set_quoted('INCLUDE_DIR', includedir)
242 conf.set_quoted('LIBDIR', libdir)
243 conf.set_quoted('MODPROBE_DIR', modprobedir)
244 conf.set_quoted('MODULESLOAD_DIR', modulesloaddir)
245 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
246 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', bindir / 'pkttyagent')
247 conf.set_quoted('PREFIX', prefixdir)
248 conf.set_quoted('RANDOM_SEED', randomseeddir / 'random-seed')
249 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
250 conf.set_quoted('RC_LOCAL_PATH', get_option('rc-local'))
251 conf.set_quoted('ROOTBINDIR', rootbindir)
252 conf.set_quoted('ROOTLIBDIR', rootlibdir)
253 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
254 conf.set_quoted('ROOTPREFIX', rootprefixdir)
255 conf.set_quoted('ROOTPREFIX_NOSLASH', rootprefixdir_noslash)
256 conf.set_quoted('SYSCONF_DIR', sysconfdir)
257 conf.set_quoted('SYSCTL_DIR', sysctldir)
258 conf.set_quoted('SYSTEMCTL_BINARY_PATH', rootbindir / 'systemctl')
259 conf.set_quoted('SYSTEMD_BINARY_PATH', rootlibexecdir / 'systemd')
260 conf.set_quoted('SYSTEMD_CATALOG_DIR', catalogdir)
261 conf.set_quoted('SYSTEMD_CGROUPS_AGENT_PATH', rootlibexecdir / 'systemd-cgroups-agent')
262 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', rootlibexecdir / 'systemd-cryptsetup')
263 conf.set_quoted('SYSTEMD_EXPORT_PATH', rootlibexecdir / 'systemd-export')
264 conf.set_quoted('SYSTEMD_FSCK_PATH', rootlibexecdir / 'systemd-fsck')
265 conf.set_quoted('SYSTEMD_GROWFS_PATH', rootlibexecdir / 'systemd-growfs')
266 conf.set_quoted('SYSTEMD_HOMEWORK_PATH', rootlibexecdir / 'systemd-homework')
267 conf.set_quoted('SYSTEMD_IMPORT_FS_PATH', rootlibexecdir / 'systemd-import-fs')
268 conf.set_quoted('SYSTEMD_IMPORT_PATH', rootlibexecdir / 'systemd-import')
269 conf.set_quoted('SYSTEMD_INTEGRITYSETUP_PATH', rootlibexecdir / 'systemd-integritysetup')
270 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', pkgdatadir / 'kbd-model-map')
271 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', pkgdatadir / 'language-fallback-map')
272 conf.set_quoted('SYSTEMD_MAKEFS_PATH', rootlibexecdir / 'systemd-makefs')
273 conf.set_quoted('SYSTEMD_PULL_PATH', rootlibexecdir / 'systemd-pull')
274 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', rootlibexecdir / 'systemd-shutdown')
275 conf.set_quoted('SYSTEMD_TEST_DATA', testsdir / 'testdata')
276 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', rootbindir / 'systemd-tty-ask-password-agent')
277 conf.set_quoted('SYSTEMD_UPDATE_HELPER_PATH', rootlibexecdir / 'systemd-update-helper')
278 conf.set_quoted('SYSTEMD_USERWORK_PATH', rootlibexecdir / 'systemd-userwork')
279 conf.set_quoted('SYSTEMD_VERITYSETUP_PATH', rootlibexecdir / 'systemd-veritysetup')
280 conf.set_quoted('SYSTEM_CONFIG_UNIT_DIR', pkgsysconfdir / 'system')
281 conf.set_quoted('SYSTEM_DATA_UNIT_DIR', systemunitdir)
282 conf.set_quoted('SYSTEM_ENV_GENERATOR_DIR', systemenvgeneratordir)
283 conf.set_quoted('SYSTEM_GENERATOR_DIR', systemgeneratordir)
284 conf.set_quoted('SYSTEM_PRESET_DIR', systempresetdir)
285 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
286 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
287 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
288 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
289 conf.set_quoted('SYSUSERS_DIR', sysusersdir)
290 conf.set_quoted('TMPFILES_DIR', tmpfilesdir)
291 conf.set_quoted('USER_TMPFILES_DIR', usertmpfilesdir)
292 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
293 conf.set_quoted('UDEV_HWDB_DIR', udevhwdbdir)
294 conf.set_quoted('UDEV_RULES_DIR', udevrulesdir)
295 conf.set_quoted('UPDATE_HELPER_USER_TIMEOUT', get_option('update-helper-user-timeout'))
296 conf.set_quoted('USER_CONFIG_UNIT_DIR', pkgsysconfdir / 'user')
297 conf.set_quoted('USER_DATA_UNIT_DIR', userunitdir)
298 conf.set_quoted('USER_ENV_GENERATOR_DIR', userenvgeneratordir)
299 conf.set_quoted('USER_GENERATOR_DIR', usergeneratordir)
300 conf.set_quoted('USER_KEYRING_PATH', pkgsysconfdir / 'import-pubring.gpg')
301 conf.set_quoted('USER_PRESET_DIR', userpresetdir)
302 conf.set_quoted('VENDOR_KEYRING_PATH', rootlibexecdir / 'import-pubring.gpg')
303
304 conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
305 conf.set10('ENABLE_URLIFY', get_option('urlify'))
306 conf.set10('ENABLE_FEXECVE', get_option('fexecve'))
307 conf.set10('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default)
308 conf.set('STATUS_UNIT_FORMAT_DEFAULT', 'STATUS_UNIT_FORMAT_' + status_unit_format_default.to_upper())
309 conf.set_quoted('STATUS_UNIT_FORMAT_DEFAULT_STR', status_unit_format_default)
310
311 conf.set10('FIRST_BOOT_FULL_PRESET', get_option('first-boot-full-preset'))
312
313 #####################################################################
314
315 cc = meson.get_compiler('c')
316 pkgconfig = import('pkgconfig')
317 meson_build_sh = find_program('tools/meson-build.sh')
318
319 want_tests = get_option('tests')
320 slow_tests = want_tests != 'false' and get_option('slow-tests')
321 fuzz_tests = want_tests != 'false' and get_option('fuzz-tests')
322 install_tests = get_option('install-tests')
323
324 if add_languages('cpp', required : fuzzer_build)
325 # Used only for tests
326 cxx = meson.get_compiler('cpp')
327 cxx_cmd = ' '.join(cxx.cmd_array())
328 else
329 cxx_cmd = ''
330 endif
331
332 if want_libfuzzer
333 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer', required : false)
334 if fuzzing_engine.found()
335 add_project_arguments('-fsanitize-coverage=trace-pc-guard,trace-cmp', language : 'c')
336 elif cc.has_argument('-fsanitize=fuzzer-no-link')
337 add_project_arguments('-fsanitize=fuzzer-no-link', language : 'c')
338 else
339 error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported')
340 endif
341 elif want_ossfuzz
342 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
343 endif
344
345 # Those generate many false positives, and we do not want to change the code to
346 # avoid them.
347 basic_disabled_warnings = [
348 '-Wno-format-signedness',
349 '-Wno-missing-field-initializers',
350 '-Wno-unused-parameter',
351 ]
352
353 possible_common_cc_flags = [
354 '-Wdate-time',
355 '-Wendif-labels',
356 '-Werror=format=2',
357 '-Werror=implicit-function-declaration',
358 '-Werror=incompatible-pointer-types',
359 '-Werror=int-conversion',
360 '-Werror=overflow',
361 '-Werror=override-init',
362 '-Werror=return-type',
363 '-Werror=shift-count-overflow',
364 '-Werror=shift-overflow=2',
365 '-Werror=undef',
366 '-Wfloat-equal',
367 # gperf prevents us from enabling this because it does not emit fallthrough
368 # attribute with clang.
369 #'-Wimplicit-fallthrough',
370 '-Wimplicit-fallthrough=5',
371 '-Winit-self',
372 '-Wlogical-op',
373 '-Wmissing-include-dirs',
374 '-Wmissing-noreturn',
375 '-Wnested-externs',
376 '-Wold-style-definition',
377 '-Wpointer-arith',
378 '-Wredundant-decls',
379 '-Wshadow',
380 '-Wstrict-aliasing=2',
381 '-Wstrict-prototypes',
382 '-Wsuggest-attribute=noreturn',
383 '-Wunused-function',
384 '-Wwrite-strings',
385
386 # negative arguments are correctly detected starting with meson 0.46.
387 '-Wno-error=#warnings', # clang
388 '-Wno-string-plus-int', # clang
389 ]
390
391 c_args = get_option('c_args')
392
393 # Disable -Wmaybe-uninitialized when compiling with -Os/-O1/-O3/etc. There are
394 # too many false positives with gcc >= 8. Effectively, we only test with -O0
395 # and -O2; this should be enough to catch most important cases without too much
396 # busywork. See https://github.com/systemd/systemd/pull/19226.
397 if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or
398 cc.version().version_compare('<10') or
399 '-Os' in c_args or
400 '-O1' in c_args or
401 '-O3' in c_args or
402 '-Og' in c_args)
403 possible_common_cc_flags += '-Wno-maybe-uninitialized'
404 endif
405
406 # Disable -Wno-unused-result with gcc, see
407 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425.
408 if cc.get_id() == 'gcc'
409 possible_common_cc_flags += '-Wno-unused-result'
410 endif
411
412 # --as-needed and --no-undefined are provided by meson by default,
413 # run 'meson configure' to see what is enabled
414 possible_link_flags = [
415 '-Wl,--fatal-warnings',
416 '-Wl,-z,now',
417 '-Wl,-z,relro',
418 '-fstack-protector',
419 ]
420
421 if get_option('b_sanitize') == 'none'
422 possible_link_flags += '-Wl,--warn-common'
423 endif
424
425 if cc.get_id() == 'clang'
426 possible_common_cc_flags += [
427 '-Wno-typedef-redefinition',
428 '-Wno-gnu-variable-sized-type-not-at-end',
429 ]
430 endif
431
432 if get_option('mode') == 'release'
433 # We could enable 'pattern' for developer mode, but that can interfere with
434 # valgrind and sanitizer builds. Also, clang does not zero-initialize unions,
435 # breaking some of our code (https://reviews.llvm.org/D68115).
436 possible_common_cc_flags += '-ftrivial-auto-var-init=zero'
437 endif
438
439 possible_cc_flags = possible_common_cc_flags + [
440 '-Werror=missing-declarations',
441 '-Werror=missing-prototypes',
442 '-fdiagnostics-show-option',
443 '-fno-common',
444 '-fno-strict-aliasing',
445 '-fstack-protector',
446 '-fstack-protector-strong',
447 '-fvisibility=hidden',
448 '--param=ssp-buffer-size=4',
449 ]
450
451 if get_option('buildtype') != 'debug'
452 possible_cc_flags += [
453 '-ffunction-sections',
454 '-fdata-sections',
455 ]
456
457 possible_link_flags += '-Wl,--gc-sections'
458 endif
459
460 if get_option('mode') == 'developer'
461 possible_cc_flags += '-fno-omit-frame-pointer'
462 endif
463
464 add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
465 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
466 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
467
468 have = cc.has_argument('-Wzero-length-bounds')
469 conf.set10('HAVE_ZERO_LENGTH_BOUNDS', have)
470
471 if cc.compiles('''
472 #include <time.h>
473 #include <inttypes.h>
474 typedef uint64_t usec_t;
475 usec_t now(clockid_t clock);
476 int main(void) {
477 struct timespec now;
478 return 0;
479 }
480 ''', args: '-Werror=shadow', name : '-Werror=shadow with local shadowing')
481 add_project_arguments('-Werror=shadow', language : 'c')
482 endif
483
484 if cxx_cmd != ''
485 add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
486 endif
487
488 cpp = ' '.join(cc.cmd_array()) + ' -E'
489
490 has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
491
492 #####################################################################
493 # compilation result tests
494
495 conf.set('_GNU_SOURCE', true)
496 conf.set('__SANE_USERSPACE_TYPES__', true)
497 conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)
498
499 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
500 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
501 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
502 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
503 conf.set('SIZEOF_TIMEX_MEMBER', cc.sizeof('typeof(((struct timex *)0)->freq)', prefix : '#include <sys/timex.h>'))
504
505 decl_headers = '''
506 #include <uchar.h>
507 #include <sys/mount.h>
508 #include <sys/stat.h>
509 #include <linux/fs.h>
510 '''
511
512 foreach decl : ['char16_t',
513 'char32_t',
514 'struct mount_attr',
515 'struct statx',
516 ]
517
518 # We get -1 if the size cannot be determined
519 have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
520
521 if decl == 'struct statx'
522 if have
523 want_linux_stat_h = false
524 else
525 have = cc.sizeof(decl,
526 prefix : decl_headers + '#include <linux/stat.h>',
527 args : '-D_GNU_SOURCE') > 0
528 want_linux_stat_h = have
529 endif
530 endif
531
532 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
533 endforeach
534
535 conf.set10('WANT_LINUX_STAT_H', want_linux_stat_h)
536
537 foreach ident : ['secure_getenv', '__secure_getenv']
538 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
539 endforeach
540
541 foreach ident : [
542 ['memfd_create', '''#include <sys/mman.h>'''],
543 ['gettid', '''#include <sys/types.h>
544 #include <unistd.h>'''],
545 ['pivot_root', '''#include <stdlib.h>
546 #include <unistd.h>'''], # no known header declares pivot_root
547 ['ioprio_get', '''#include <sched.h>'''], # no known header declares ioprio_get
548 ['ioprio_set', '''#include <sched.h>'''], # no known header declares ioprio_set
549 ['name_to_handle_at', '''#include <sys/types.h>
550 #include <sys/stat.h>
551 #include <fcntl.h>'''],
552 ['setns', '''#include <sched.h>'''],
553 ['renameat2', '''#include <stdio.h>
554 #include <fcntl.h>'''],
555 ['kcmp', '''#include <linux/kcmp.h>'''],
556 ['keyctl', '''#include <sys/types.h>
557 #include <keyutils.h>'''],
558 ['copy_file_range', '''#include <sys/syscall.h>
559 #include <unistd.h>'''],
560 ['bpf', '''#include <sys/syscall.h>
561 #include <unistd.h>'''],
562 ['statx', '''#include <sys/types.h>
563 #include <sys/stat.h>
564 #include <unistd.h>'''],
565 ['explicit_bzero' , '''#include <string.h>'''],
566 ['reallocarray', '''#include <stdlib.h>'''],
567 ['set_mempolicy', '''#include <stdlib.h>
568 #include <unistd.h>'''],
569 ['get_mempolicy', '''#include <stdlib.h>
570 #include <unistd.h>'''],
571 ['pidfd_send_signal', '''#include <stdlib.h>
572 #include <unistd.h>
573 #include <signal.h>
574 #include <sys/wait.h>'''],
575 ['pidfd_open', '''#include <stdlib.h>
576 #include <unistd.h>
577 #include <signal.h>
578 #include <sys/wait.h>'''],
579 ['rt_sigqueueinfo', '''#include <stdlib.h>
580 #include <unistd.h>
581 #include <signal.h>
582 #include <sys/wait.h>'''],
583 ['mallinfo', '''#include <malloc.h>'''],
584 ['mallinfo2', '''#include <malloc.h>'''],
585 ['execveat', '''#include <unistd.h>'''],
586 ['close_range', '''#include <unistd.h>'''],
587 ['epoll_pwait2', '''#include <sys/epoll.h>'''],
588 ['mount_setattr', '''#include <sys/mount.h>'''],
589 ['move_mount', '''#include <sys/mount.h>'''],
590 ['open_tree', '''#include <sys/mount.h>'''],
591 ['getdents64', '''#include <dirent.h>'''],
592 ]
593
594 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
595 conf.set10('HAVE_' + ident[0].to_upper(), have)
596 endforeach
597
598 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
599 conf.set10('USE_SYS_RANDOM_H', true)
600 conf.set10('HAVE_GETRANDOM', true)
601 else
602 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
603 conf.set10('USE_SYS_RANDOM_H', false)
604 conf.set10('HAVE_GETRANDOM', have)
605 endif
606
607 #####################################################################
608
609 version_tag = get_option('version-tag')
610 if version_tag != ''
611 vcs_data = configuration_data()
612 vcs_data.set('VCS_TAG', version_tag)
613 version_h = configure_file(configuration : vcs_data,
614 input : 'src/version/version.h.in',
615 output : 'version.h')
616 else
617 vcs_tagger = [
618 project_source_root + '/tools/meson-vcs-tag.sh',
619 project_source_root,
620 meson.project_version()]
621
622 version_h = vcs_tag(
623 input : 'src/version/version.h.in',
624 output : 'version.h',
625 command: vcs_tagger)
626 endif
627
628 versiondep = declare_dependency(sources: version_h)
629
630 shared_lib_tag = get_option('shared-lib-tag')
631 if shared_lib_tag == ''
632 shared_lib_tag = meson.project_version()
633 endif
634
635 sh = find_program('sh')
636 echo = find_program('echo')
637 sed = find_program('sed')
638 awk = find_program('awk')
639 stat = find_program('stat')
640 ln = find_program('ln')
641 git = find_program('git', required : false)
642 env = find_program('env')
643 perl = find_program('perl', required : false)
644 rsync = find_program('rsync', required : false)
645 meson_make_symlink = project_source_root + '/tools/meson-make-symlink.sh'
646
647 mkdir_p = 'mkdir -p $DESTDIR/@0@'
648
649 # If -Dxxx-path option is found, use that. Otherwise, check in $PATH,
650 # /usr/sbin, /sbin, and fall back to the default from middle column.
651 progs = [['quotaon', '/usr/sbin/quotaon' ],
652 ['quotacheck', '/usr/sbin/quotacheck' ],
653 ['kmod', '/usr/bin/kmod' ],
654 ['kexec', '/usr/sbin/kexec' ],
655 ['sulogin', '/usr/sbin/sulogin' ],
656 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
657 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
658 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
659 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
660 ['nologin', '/usr/sbin/nologin', ],
661 ]
662 foreach prog : progs
663 path = get_option(prog[0] + '-path')
664 if path != ''
665 message('Using @1@ for @0@'.format(prog[0], path))
666 else
667 exe = find_program(prog[0],
668 '/usr/sbin/' + prog[0],
669 '/sbin/' + prog[0],
670 required: false)
671 path = exe.found() ? exe.path() : prog[1]
672 endif
673 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
674 conf.set_quoted(name, path)
675 endforeach
676
677 conf.set_quoted('TELINIT', get_option('telinit-path'))
678
679 if run_command(ln, '--relative', '--help', check : false).returncode() != 0
680 error('ln does not support --relative (added in coreutils 8.16)')
681 endif
682
683 ############################################################
684
685 python = find_program('python3')
686 if run_command(python, '-c', 'import jinja2', check : false).returncode() != 0
687 error('python3 jinja2 missing')
688 endif
689
690 ############################################################
691
692 gperf = find_program('gperf')
693
694 gperf_test_format = '''
695 #include <string.h>
696 const char * in_word_set(const char *, @0@);
697 @1@
698 '''
699 gperf_snippet = run_command(sh, '-c', 'echo foo,bar | "$1" -L ANSI-C', '_', gperf,
700 check : true)
701 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
702 if cc.compiles(gperf_test)
703 gperf_len_type = 'size_t'
704 else
705 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
706 if cc.compiles(gperf_test)
707 gperf_len_type = 'unsigned'
708 else
709 error('unable to determine gperf len type')
710 endif
711 endif
712 message('gperf len type is @0@'.format(gperf_len_type))
713 conf.set('GPERF_LEN_TYPE', gperf_len_type,
714 description : 'The type of gperf "len" parameter')
715
716 ############################################################
717
718 if not cc.has_header('sys/capability.h')
719 error('POSIX caps headers not found')
720 endif
721 foreach header : ['crypt.h',
722 'linux/memfd.h',
723 'linux/vm_sockets.h',
724 'sys/auxv.h',
725 'valgrind/memcheck.h',
726 'valgrind/valgrind.h',
727 'linux/time_types.h',
728 'sys/sdt.h',
729 ]
730
731 conf.set10('HAVE_' + header.underscorify().to_upper(),
732 cc.has_header(header))
733 endforeach
734
735 ############################################################
736
737 fallback_hostname = get_option('fallback-hostname')
738 if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0] == '-'
739 error('Invalid fallback-hostname configuration')
740 # A more extensive test is done in test-hostname-util. Let's catch
741 # the most obvious errors here so we don't fail with an assert later.
742 endif
743 conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
744
745 default_hierarchy = get_option('default-hierarchy')
746 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
747 description : 'default cgroup hierarchy as string')
748 if default_hierarchy == 'legacy'
749 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
750 elif default_hierarchy == 'hybrid'
751 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
752 else
753 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
754 endif
755
756 extra_net_naming_schemes = []
757 extra_net_naming_map = []
758 foreach scheme: get_option('extra-net-naming-schemes').split(',')
759 if scheme != ''
760 name = scheme.split('=')[0]
761 value = scheme.split('=')[1]
762 NAME = name.underscorify().to_upper()
763 VALUE = []
764 foreach field: value.split('+')
765 VALUE += 'NAMING_' + field.underscorify().to_upper()
766 endforeach
767 extra_net_naming_schemes += 'NAMING_@0@ = @1@,'.format(NAME, '|'.join(VALUE))
768 extra_net_naming_map += '{ "@0@", NAMING_@1@ },'.format(name, NAME)
769 endif
770 endforeach
771 conf.set('EXTRA_NET_NAMING_SCHEMES', ' '.join(extra_net_naming_schemes))
772 conf.set('EXTRA_NET_NAMING_MAP', ' '.join(extra_net_naming_map))
773
774 default_net_naming_scheme = get_option('default-net-naming-scheme')
775 conf.set_quoted('DEFAULT_NET_NAMING_SCHEME', default_net_naming_scheme)
776 if default_net_naming_scheme != 'latest'
777 conf.set('_DEFAULT_NET_NAMING_SCHEME_TEST',
778 'NAMING_' + default_net_naming_scheme.underscorify().to_upper())
779 endif
780
781 time_epoch = get_option('time-epoch')
782 if time_epoch == -1
783 time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check : true).stdout().strip()
784 if time_epoch == '' and git.found() and fs.exists('.git')
785 # If we're in a git repository, use the creation time of the latest git tag.
786 latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags',
787 check : false)
788 if latest_tag.returncode() == 0
789 time_epoch = run_command(
790 git, 'log', '--no-show-signature', '-1', '--format=%at',
791 latest_tag.stdout().strip(),
792 check : false).stdout()
793 endif
794 endif
795 if time_epoch == ''
796 NEWS = files('NEWS')
797 time_epoch = run_command(stat, '-c', '%Y', NEWS,
798 check : true).stdout()
799 endif
800 time_epoch = time_epoch.to_int()
801 endif
802 conf.set('TIME_EPOCH', time_epoch)
803
804 conf.set('CLOCK_VALID_RANGE_USEC_MAX', get_option('clock-valid-range-usec-max'))
805
806 default_user_shell = get_option('default-user-shell')
807 conf.set_quoted('DEFAULT_USER_SHELL', default_user_shell)
808 conf.set_quoted('DEFAULT_USER_SHELL_NAME', fs.name(default_user_shell))
809
810 foreach tuple : [['system-alloc-uid-min', 'SYS_UID_MIN', 1], # Also see login.defs(5).
811 ['system-uid-max', 'SYS_UID_MAX', 999],
812 ['system-alloc-gid-min', 'SYS_GID_MIN', 1],
813 ['system-gid-max', 'SYS_GID_MAX', 999]]
814 v = get_option(tuple[0])
815 if v == -1
816 v = run_command(
817 awk,
818 '/^\s*@0@\s+/ { uid=$2 } END { print uid }'.format(tuple[1]),
819 '/etc/login.defs',
820 check : false).stdout().strip()
821 if v == ''
822 v = tuple[2]
823 else
824 v = v.to_int()
825 endif
826 endif
827 conf.set(tuple[0].underscorify().to_upper(), v)
828 endforeach
829 if conf.get('SYSTEM_ALLOC_UID_MIN') >= conf.get('SYSTEM_UID_MAX')
830 error('Invalid uid allocation range')
831 endif
832 if conf.get('SYSTEM_ALLOC_GID_MIN') >= conf.get('SYSTEM_GID_MAX')
833 error('Invalid gid allocation range')
834 endif
835
836 dynamic_uid_min = get_option('dynamic-uid-min')
837 dynamic_uid_max = get_option('dynamic-uid-max')
838 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
839 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
840
841 container_uid_base_min = get_option('container-uid-base-min')
842 container_uid_base_max = get_option('container-uid-base-max')
843 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
844 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
845
846 nobody_user = get_option('nobody-user')
847 nobody_group = get_option('nobody-group')
848
849 if not meson.is_cross_build()
850 getent_result = run_command('getent', 'passwd', '65534', check : false)
851 if getent_result.returncode() == 0
852 name = getent_result.stdout().split(':')[0]
853 if name != nobody_user
854 warning('\n' +
855 'The local user with the UID 65534 does not match the configured user name "@0@" of the nobody user (its name is @1@).\n'.format(nobody_user, name) +
856 'Your build will result in an user table setup that is incompatible with the local system.')
857 endif
858 endif
859 id_result = run_command('id', '-u', nobody_user, check : false)
860 if id_result.returncode() == 0
861 id = id_result.stdout().to_int()
862 if id != 65534
863 warning('\n' +
864 'The local user with the configured user name "@0@" of the nobody user does not have UID 65534 (it has @1@).\n'.format(nobody_user, id) +
865 'Your build will result in an user table setup that is incompatible with the local system.')
866 endif
867 endif
868
869 getent_result = run_command('getent', 'group', '65534', check : false)
870 if getent_result.returncode() == 0
871 name = getent_result.stdout().split(':')[0]
872 if name != nobody_group
873 warning('\n' +
874 'The local group with the GID 65534 does not match the configured group name "@0@" of the nobody group (its name is @1@).\n'.format(nobody_group, name) +
875 'Your build will result in an group table setup that is incompatible with the local system.')
876 endif
877 endif
878 id_result = run_command('id', '-g', nobody_group, check : false)
879 if id_result.returncode() == 0
880 id = id_result.stdout().to_int()
881 if id != 65534
882 warning('\n' +
883 'The local group with the configured group name "@0@" of the nobody group does not have GID 65534 (it has @1@).\n'.format(nobody_group, id) +
884 'Your build will result in an group table setup that is incompatible with the local system.')
885 endif
886 endif
887 endif
888 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
889 warning('\n' +
890 'The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
891 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
892 endif
893
894 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
895 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
896
897 static_ugids = []
898 foreach option : ['adm-gid',
899 'audio-gid',
900 'cdrom-gid',
901 'dialout-gid',
902 'disk-gid',
903 'input-gid',
904 'kmem-gid',
905 'kvm-gid',
906 'lp-gid',
907 'render-gid',
908 'sgx-gid',
909 'tape-gid',
910 'tty-gid',
911 'users-gid',
912 'utmp-gid',
913 'video-gid',
914 'wheel-gid',
915 'systemd-journal-gid',
916 'systemd-network-uid',
917 'systemd-resolve-uid',
918 'systemd-timesync-uid']
919 name = option.underscorify().to_upper()
920 val = get_option(option)
921
922 # Ensure provided GID argument is numeric, otherwise fall back to default assignment
923 conf.set(name, val >= 0 ? val : '-')
924 if val >= 0
925 static_ugids += '@0@:@1@'.format(option, val)
926 endif
927 endforeach
928
929 conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
930 conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
931
932 dev_kvm_mode = get_option('dev-kvm-mode')
933 conf.set_quoted('DEV_KVM_MODE', dev_kvm_mode) # FIXME: convert to 0o… notation
934 conf.set10('DEV_KVM_UACCESS', dev_kvm_mode != '0666')
935 group_render_mode = get_option('group-render-mode')
936 conf.set_quoted('GROUP_RENDER_MODE', group_render_mode)
937 conf.set10('GROUP_RENDER_UACCESS', group_render_mode != '0666')
938
939 kill_user_processes = get_option('default-kill-user-processes')
940 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
941
942 dns_servers = get_option('dns-servers')
943 conf.set_quoted('DNS_SERVERS', dns_servers)
944
945 ntp_servers = get_option('ntp-servers')
946 conf.set_quoted('NTP_SERVERS', ntp_servers)
947
948 default_locale = get_option('default-locale')
949 conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale)
950
951 nspawn_locale = get_option('nspawn-locale')
952 conf.set_quoted('SYSTEMD_NSPAWN_LOCALE', nspawn_locale)
953
954 localegen_path = get_option('localegen-path')
955 if localegen_path != ''
956 conf.set_quoted('LOCALEGEN_PATH', localegen_path)
957 endif
958 conf.set10('HAVE_LOCALEGEN', localegen_path != '')
959
960 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
961
962 service_watchdog = get_option('service-watchdog')
963 watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
964 conf.set_quoted('SERVICE_WATCHDOG', watchdog_value)
965
966 conf.set_quoted('SUSHELL', get_option('debug-shell'))
967 conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
968
969 enable_debug_hashmap = false
970 enable_debug_mmap_cache = false
971 enable_debug_siphash = false
972 foreach name : get_option('debug-extra')
973 if name == 'hashmap'
974 enable_debug_hashmap = true
975 elif name == 'mmap-cache'
976 enable_debug_mmap_cache = true
977 elif name == 'siphash'
978 enable_debug_siphash = true
979 else
980 message('unknown debug option "@0@", ignoring'.format(name))
981 endif
982 endforeach
983 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
984 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
985 conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash)
986
987 conf.set10('VALGRIND', get_option('valgrind'))
988 conf.set10('LOG_TRACE', get_option('log-trace'))
989
990 default_user_path = get_option('user-path')
991 if default_user_path != ''
992 conf.set_quoted('DEFAULT_USER_PATH', default_user_path)
993 endif
994
995
996 #####################################################################
997
998 threads = dependency('threads')
999 librt = cc.find_library('rt')
1000 libm = cc.find_library('m')
1001 libdl = cc.find_library('dl')
1002 libcrypt = cc.find_library('crypt')
1003
1004 crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
1005 foreach ident : [
1006 ['crypt_ra', crypt_header],
1007 ['crypt_preferred_method', crypt_header],
1008 ['crypt_gensalt_ra', crypt_header]]
1009
1010 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
1011 dependencies : libcrypt)
1012 conf.set10('HAVE_' + ident[0].to_upper(), have)
1013 endforeach
1014
1015 libcap = dependency('libcap', required : false)
1016 if not libcap.found()
1017 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
1018 libcap = cc.find_library('cap')
1019 endif
1020
1021 want_bpf_framework = get_option('bpf-framework')
1022 bpf_framework_required = want_bpf_framework == 'true'
1023
1024 libbpf = dependency('libbpf', required : bpf_framework_required, version : '>= 0.2')
1025 conf.set10('HAVE_LIBBPF', libbpf.found())
1026
1027 if want_bpf_framework == 'false' or not libbpf.found() or skip_deps
1028 conf.set10('BPF_FRAMEWORK', false)
1029 else
1030 bpf_compiler = get_option('bpf-compiler')
1031 clang_found = false
1032 clang_supports_bpf = false
1033 bpf_gcc_found = false
1034 deps_found = false
1035
1036 if bpf_compiler == 'clang'
1037 # Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu
1038 # (like clang-10/llvm-strip-10)
1039 if meson.is_cross_build() or cc.get_id() != 'clang' or cc.cmd_array()[0].contains('afl-clang') or cc.cmd_array()[0].contains('hfuzz-clang')
1040 r = find_program('clang', required : bpf_framework_required, version : '>= 10.0.0')
1041 clang_found = r.found()
1042 if clang_found
1043 clang = r.path()
1044 endif
1045 # Assume that the required flags are supported by the found clang.
1046 clang_supports_flags = clang_found
1047 else
1048 clang_found = true
1049 clang = cc.cmd_array()
1050 clang_supports_flags = cc.has_argument('-Wno-compare-distinct-pointer-types')
1051 endif
1052
1053 if clang_found
1054 # Check if 'clang -target bpf' is supported.
1055 clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0
1056 endif
1057 elif bpf_compiler == 'gcc'
1058 warning('GCC BPF Compiler support is experimental and not recommended.')
1059 bpf_gcc = find_program('bpf-gcc',
1060 required : true,
1061 version : '>= 12.1.0')
1062 bpf_gcc_found = bpf_gcc.found()
1063 endif
1064
1065 if clang_supports_bpf or bpf_gcc_found
1066 # Debian installs this in /usr/sbin/ which is not in $PATH.
1067 # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian.
1068 # We use 'bpftool gen object' subcommand for bpftool strip, it was added by d80b2fcbe0a023619e0fc73112f2a02c2662f6ab (v5.13).
1069 bpftool = find_program('bpftool',
1070 '/usr/sbin/bpftool',
1071 required : false,
1072 version : '>= 5.13.0')
1073
1074 if bpftool.found()
1075 bpftool_strip = true
1076 deps_found = true
1077 else
1078 bpftool_strip = false
1079 # We require the 'bpftool gen skeleton' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6).
1080 bpftool = find_program('bpftool',
1081 '/usr/sbin/bpftool',
1082 required : bpf_framework_required,
1083 version : '>= 5.6.0')
1084 endif
1085
1086 # We use `llvm-strip` as a fallback if `bpftool gen object` strip support is not available.
1087 if not bpftool_strip and bpftool.found() and clang_supports_bpf
1088 if not meson.is_cross_build()
1089 llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip',
1090 check : true).stdout().strip()
1091 else
1092 llvm_strip_bin = 'llvm-strip'
1093 endif
1094 llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0')
1095 deps_found = llvm_strip.found()
1096 endif
1097 endif
1098
1099 # Can build BPF program from source code in restricted C
1100 conf.set10('BPF_FRAMEWORK', deps_found)
1101 endif
1102
1103 libmount = dependency('mount',
1104 version : fuzzer_build ? '>= 0' : '>= 2.30')
1105
1106 want_libfdisk = get_option('fdisk')
1107 if want_libfdisk != 'false' and not skip_deps
1108 libfdisk = dependency('fdisk',
1109 version : '>= 2.32',
1110 required : want_libfdisk == 'true')
1111 have = libfdisk.found()
1112 else
1113 have = false
1114 libfdisk = []
1115 endif
1116 conf.set10('HAVE_LIBFDISK', have)
1117
1118 want_pwquality = get_option('pwquality')
1119 if want_pwquality != 'false' and not skip_deps
1120 libpwquality = dependency('pwquality', required : want_pwquality == 'true')
1121 have = libpwquality.found()
1122 else
1123 have = false
1124 libpwquality = []
1125 endif
1126 conf.set10('HAVE_PWQUALITY', have)
1127
1128 want_seccomp = get_option('seccomp')
1129 if want_seccomp != 'false' and not skip_deps
1130 libseccomp = dependency('libseccomp',
1131 version : '>= 2.3.1',
1132 required : want_seccomp == 'true')
1133 have = libseccomp.found()
1134 else
1135 have = false
1136 libseccomp = []
1137 endif
1138 conf.set10('HAVE_SECCOMP', have)
1139
1140 want_selinux = get_option('selinux')
1141 if want_selinux != 'false' and not skip_deps
1142 libselinux = dependency('libselinux',
1143 version : '>= 2.1.9',
1144 required : want_selinux == 'true')
1145 have = libselinux.found()
1146 else
1147 have = false
1148 libselinux = []
1149 endif
1150 conf.set10('HAVE_SELINUX', have)
1151
1152 want_apparmor = get_option('apparmor')
1153 if want_apparmor != 'false' and not skip_deps
1154 libapparmor = dependency('libapparmor',
1155 version : '>= 2.13',
1156 required : want_apparmor == 'true')
1157 have = libapparmor.found()
1158 else
1159 have = false
1160 libapparmor = []
1161 endif
1162 conf.set10('HAVE_APPARMOR', have)
1163
1164 have = get_option('smack') and get_option('smack-run-label') != ''
1165 conf.set10('HAVE_SMACK_RUN_LABEL', have)
1166 if have
1167 conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
1168 endif
1169
1170 have = get_option('smack') and get_option('smack-default-process-label') != ''
1171 if have
1172 conf.set_quoted('SMACK_DEFAULT_PROCESS_LABEL', get_option('smack-default-process-label'))
1173 endif
1174
1175 want_polkit = get_option('polkit')
1176 install_polkit = false
1177 install_polkit_pkla = false
1178 if want_polkit != 'false' and not skip_deps
1179 install_polkit = true
1180
1181 libpolkit = dependency('polkit-gobject-1',
1182 required : false)
1183 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
1184 message('Old polkit detected, will install pkla files')
1185 install_polkit_pkla = true
1186 endif
1187 endif
1188 conf.set10('ENABLE_POLKIT', install_polkit)
1189
1190 want_acl = get_option('acl')
1191 if want_acl != 'false' and not skip_deps
1192 libacl = cc.find_library('acl', required : want_acl == 'true')
1193 have = libacl.found()
1194 else
1195 have = false
1196 libacl = []
1197 endif
1198 conf.set10('HAVE_ACL', have)
1199
1200 want_audit = get_option('audit')
1201 if want_audit != 'false' and not skip_deps
1202 libaudit = dependency('audit', required : want_audit == 'true')
1203 have = libaudit.found()
1204 else
1205 have = false
1206 libaudit = []
1207 endif
1208 conf.set10('HAVE_AUDIT', have)
1209
1210 want_blkid = get_option('blkid')
1211 if want_blkid != 'false' and not skip_deps
1212 libblkid = dependency('blkid', required : want_blkid == 'true')
1213 have = libblkid.found()
1214
1215 conf.set10('HAVE_BLKID_PROBE_SET_HINT',
1216 have and cc.has_function('blkid_probe_set_hint', dependencies : libblkid))
1217 else
1218 have = false
1219 libblkid = []
1220 endif
1221 conf.set10('HAVE_BLKID', have)
1222
1223 want_kmod = get_option('kmod')
1224 if want_kmod != 'false' and not skip_deps
1225 libkmod = dependency('libkmod',
1226 version : '>= 15',
1227 required : want_kmod == 'true')
1228 have = libkmod.found()
1229 else
1230 have = false
1231 libkmod = []
1232 endif
1233 conf.set10('HAVE_KMOD', have)
1234
1235 want_pam = get_option('pam')
1236 if want_pam != 'false' and not skip_deps
1237 libpam = cc.find_library('pam', required : want_pam == 'true')
1238 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1239 have = libpam.found() and libpam_misc.found()
1240 else
1241 have = false
1242 libpam = []
1243 libpam_misc = []
1244 endif
1245 conf.set10('HAVE_PAM', have)
1246
1247 want_microhttpd = get_option('microhttpd')
1248 if want_microhttpd != 'false' and not skip_deps
1249 libmicrohttpd = dependency('libmicrohttpd',
1250 version : '>= 0.9.33',
1251 required : want_microhttpd == 'true')
1252 have = libmicrohttpd.found()
1253 else
1254 have = false
1255 libmicrohttpd = []
1256 endif
1257 conf.set10('HAVE_MICROHTTPD', have)
1258
1259 want_libcryptsetup = get_option('libcryptsetup')
1260 want_libcryptsetup_plugins = get_option('libcryptsetup-plugins')
1261
1262 if want_libcryptsetup_plugins == 'true' and want_libcryptsetup == 'false'
1263 error('libcryptsetup-plugins can not be requested without libcryptsetup')
1264 endif
1265
1266 if want_libcryptsetup != 'false' and not skip_deps
1267 libcryptsetup = dependency('libcryptsetup',
1268 version : want_libcryptsetup_plugins == 'true' ? '>= 2.4.0' : '>= 2.0.1',
1269 required : want_libcryptsetup == 'true' or want_libcryptsetup_plugins == 'true')
1270 have = libcryptsetup.found()
1271
1272 foreach ident : ['crypt_set_metadata_size',
1273 'crypt_activate_by_signed_key',
1274 'crypt_token_max']
1275 have_ident = have and cc.has_function(
1276 ident,
1277 prefix : '#include <libcryptsetup.h>',
1278 dependencies : libcryptsetup)
1279 conf.set10('HAVE_' + ident.to_upper(), have_ident)
1280 endforeach
1281 else
1282 have = false
1283 libcryptsetup = []
1284 endif
1285 conf.set10('HAVE_LIBCRYPTSETUP', have)
1286
1287 if want_libcryptsetup_plugins != 'false' and not skip_deps
1288 have = (cc.has_function(
1289 'crypt_activate_by_token_pin',
1290 prefix : '#include <libcryptsetup.h>',
1291 dependencies : libcryptsetup) and
1292 cc.has_function(
1293 'crypt_token_external_path',
1294 prefix : '#include <libcryptsetup.h>',
1295 dependencies : libcryptsetup))
1296 else
1297 have = false
1298 endif
1299 conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have)
1300
1301 want_libcurl = get_option('libcurl')
1302 if want_libcurl != 'false' and not skip_deps
1303 libcurl = dependency('libcurl',
1304 version : '>= 7.32.0',
1305 required : want_libcurl == 'true')
1306 have = libcurl.found()
1307 else
1308 have = false
1309 libcurl = []
1310 endif
1311 conf.set10('HAVE_LIBCURL', have)
1312 conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
1313
1314 want_libidn = get_option('libidn')
1315 want_libidn2 = get_option('libidn2')
1316 if want_libidn == 'true' and want_libidn2 == 'true'
1317 error('libidn and libidn2 cannot be requested simultaneously')
1318 endif
1319
1320 if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps
1321 libidn = dependency('libidn2',
1322 required : want_libidn2 == 'true')
1323 have = libidn.found()
1324 else
1325 have = false
1326 libidn = []
1327 endif
1328 conf.set10('HAVE_LIBIDN2', have)
1329 if not have and want_libidn != 'false' and not skip_deps
1330 # libidn is used for both libidn and libidn2 objects
1331 libidn = dependency('libidn',
1332 required : want_libidn == 'true')
1333 have = libidn.found()
1334 else
1335 have = false
1336 endif
1337 conf.set10('HAVE_LIBIDN', have)
1338
1339 want_libiptc = get_option('libiptc')
1340 if want_libiptc != 'false' and not skip_deps
1341 libiptc = dependency('libiptc',
1342 required : want_libiptc == 'true')
1343 have = libiptc.found()
1344 else
1345 have = false
1346 libiptc = []
1347 endif
1348 conf.set10('HAVE_LIBIPTC', have)
1349
1350 want_qrencode = get_option('qrencode')
1351 if want_qrencode != 'false' and not skip_deps
1352 libqrencode = dependency('libqrencode',
1353 version : '>= 4',
1354 required : want_qrencode == 'true')
1355 have = libqrencode.found()
1356 else
1357 have = false
1358 libqrencode = []
1359 endif
1360 conf.set10('HAVE_QRENCODE', have)
1361
1362 want_gcrypt = get_option('gcrypt')
1363 if want_gcrypt != 'false' and not skip_deps
1364 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1365 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1366 have = libgcrypt.found() and libgpg_error.found()
1367 else
1368 have = false
1369 endif
1370 if not have
1371 # link to neither of the libs if one is not found
1372 libgcrypt = []
1373 libgpg_error = []
1374 endif
1375 conf.set10('HAVE_GCRYPT', have)
1376
1377 want_gnutls = get_option('gnutls')
1378 if want_gnutls != 'false' and not skip_deps
1379 libgnutls = dependency('gnutls',
1380 version : '>= 3.1.4',
1381 required : want_gnutls == 'true')
1382 have = libgnutls.found()
1383 else
1384 have = false
1385 libgnutls = []
1386 endif
1387 conf.set10('HAVE_GNUTLS', have)
1388
1389 want_openssl = get_option('openssl')
1390 if want_openssl != 'false' and not skip_deps
1391 libopenssl = dependency('openssl',
1392 version : '>= 1.1.0',
1393 required : want_openssl == 'true')
1394 have = libopenssl.found()
1395 else
1396 have = false
1397 libopenssl = []
1398 endif
1399 conf.set10('HAVE_OPENSSL', have)
1400
1401 want_p11kit = get_option('p11kit')
1402 if want_p11kit != 'false' and not skip_deps
1403 libp11kit = dependency('p11-kit-1',
1404 version : '>= 0.23.3',
1405 required : want_p11kit == 'true')
1406 have = libp11kit.found()
1407 else
1408 have = false
1409 libp11kit = []
1410 endif
1411 conf.set10('HAVE_P11KIT', have)
1412
1413 want_libfido2 = get_option('libfido2')
1414 if want_libfido2 != 'false' and not skip_deps
1415 libfido2 = dependency('libfido2',
1416 required : want_libfido2 == 'true')
1417 have = libfido2.found()
1418 else
1419 have = false
1420 libfido2 = []
1421 endif
1422 conf.set10('HAVE_LIBFIDO2', have)
1423
1424 want_tpm2 = get_option('tpm2')
1425 if want_tpm2 != 'false' and not skip_deps
1426 tpm2 = dependency('tss2-esys tss2-rc tss2-mu',
1427 required : want_tpm2 == 'true')
1428 have = tpm2.found()
1429 else
1430 have = false
1431 tpm2 = []
1432 endif
1433 conf.set10('HAVE_TPM2', have)
1434
1435 want_elfutils = get_option('elfutils')
1436 if want_elfutils != 'false' and not skip_deps
1437 libdw = dependency('libdw',
1438 required : want_elfutils == 'true')
1439 have = libdw.found()
1440
1441 # New in elfutils 0.177
1442 conf.set10('HAVE_DWELF_ELF_E_MACHINE_STRING',
1443 have and cc.has_function('dwelf_elf_e_machine_string', dependencies : libdw))
1444 else
1445 have = false
1446 libdw = []
1447 endif
1448 conf.set10('HAVE_ELFUTILS', have)
1449
1450 want_zlib = get_option('zlib')
1451 if want_zlib != 'false' and not skip_deps
1452 libz = dependency('zlib',
1453 required : want_zlib == 'true')
1454 have = libz.found()
1455 else
1456 have = false
1457 libz = []
1458 endif
1459 conf.set10('HAVE_ZLIB', have)
1460
1461 want_bzip2 = get_option('bzip2')
1462 if want_bzip2 != 'false' and not skip_deps
1463 libbzip2 = cc.find_library('bz2',
1464 required : want_bzip2 == 'true')
1465 have = libbzip2.found()
1466 else
1467 have = false
1468 libbzip2 = []
1469 endif
1470 conf.set10('HAVE_BZIP2', have)
1471
1472 want_xz = get_option('xz')
1473 if want_xz != 'false' and not skip_deps
1474 libxz = dependency('liblzma',
1475 required : want_xz == 'true')
1476 have_xz = libxz.found()
1477 else
1478 have_xz = false
1479 libxz = []
1480 endif
1481 conf.set10('HAVE_XZ', have_xz)
1482
1483 want_lz4 = get_option('lz4')
1484 if want_lz4 != 'false' and not skip_deps
1485 liblz4 = dependency('liblz4',
1486 version : '>= 1.3.0',
1487 required : want_lz4 == 'true')
1488 have_lz4 = liblz4.found()
1489 else
1490 have_lz4 = false
1491 liblz4 = []
1492 endif
1493 conf.set10('HAVE_LZ4', have_lz4)
1494
1495 want_zstd = get_option('zstd')
1496 if want_zstd != 'false' and not skip_deps
1497 libzstd = dependency('libzstd',
1498 required : want_zstd == 'true',
1499 version : '>= 1.4.0')
1500 have_zstd = libzstd.found()
1501 else
1502 have_zstd = false
1503 libzstd = []
1504 endif
1505 conf.set10('HAVE_ZSTD', have_zstd)
1506
1507 conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
1508
1509 compression = get_option('default-compression')
1510 if compression == 'auto'
1511 if have_zstd
1512 compression = 'zstd'
1513 elif have_lz4
1514 compression = 'lz4'
1515 elif have_xz
1516 compression = 'xz'
1517 else
1518 compression = 'none'
1519 endif
1520 elif compression == 'zstd' and not have_zstd
1521 error('default-compression=zstd requires zstd')
1522 elif compression == 'lz4' and not have_lz4
1523 error('default-compression=lz4 requires lz4')
1524 elif compression == 'xz' and not have_xz
1525 error('default-compression=xz requires xz')
1526 endif
1527 conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper()))
1528
1529 want_xkbcommon = get_option('xkbcommon')
1530 if want_xkbcommon != 'false' and not skip_deps
1531 libxkbcommon = dependency('xkbcommon',
1532 version : '>= 0.3.0',
1533 required : want_xkbcommon == 'true')
1534 have = libxkbcommon.found()
1535 else
1536 have = false
1537 libxkbcommon = []
1538 endif
1539 conf.set10('HAVE_XKBCOMMON', have)
1540
1541 want_pcre2 = get_option('pcre2')
1542 if want_pcre2 != 'false' and not skip_deps
1543 libpcre2 = dependency('libpcre2-8',
1544 required : want_pcre2 == 'true')
1545 have = libpcre2.found()
1546 else
1547 have = false
1548 libpcre2 = []
1549 endif
1550 conf.set10('HAVE_PCRE2', have)
1551
1552 want_glib = get_option('glib')
1553 if want_glib != 'false' and not skip_deps
1554 libglib = dependency('glib-2.0',
1555 version : '>= 2.22.0',
1556 required : want_glib == 'true')
1557 libgobject = dependency('gobject-2.0',
1558 version : '>= 2.22.0',
1559 required : want_glib == 'true')
1560 libgio = dependency('gio-2.0',
1561 required : want_glib == 'true')
1562 have = libglib.found() and libgobject.found() and libgio.found()
1563 else
1564 have = false
1565 libglib = []
1566 libgobject = []
1567 libgio = []
1568 endif
1569 conf.set10('HAVE_GLIB', have)
1570
1571 want_dbus = get_option('dbus')
1572 if want_dbus != 'false' and not skip_deps
1573 libdbus = dependency('dbus-1',
1574 version : '>= 1.3.2',
1575 required : want_dbus == 'true')
1576 have = libdbus.found()
1577 else
1578 have = false
1579 libdbus = []
1580 endif
1581 conf.set10('HAVE_DBUS', have)
1582
1583 dbusdatadir = datadir / 'dbus-1'
1584 if conf.get('HAVE_DBUS') == 1
1585 dbusdatadir = libdbus.get_variable(pkgconfig: 'datadir', default_value: datadir) / 'dbus-1'
1586 endif
1587
1588 dbuspolicydir = get_option('dbuspolicydir')
1589 if dbuspolicydir == ''
1590 dbuspolicydir = dbusdatadir / 'system.d'
1591 endif
1592
1593 dbussessionservicedir = get_option('dbussessionservicedir')
1594 if dbussessionservicedir == ''
1595 dbussessionservicedir = dbusdatadir / 'services'
1596 if conf.get('HAVE_DBUS') == 1
1597 dbussessionservicedir = libdbus.get_variable(pkgconfig: 'session_bus_services_dir', default_value: dbussessionservicedir)
1598 endif
1599 endif
1600
1601 dbussystemservicedir = get_option('dbussystemservicedir')
1602 if dbussystemservicedir == ''
1603 dbussystemservicedir = dbusdatadir / 'system-services'
1604 if conf.get('HAVE_DBUS') == 1
1605 dbussystemservicedir = libdbus.get_variable(pkgconfig: 'system_bus_services_dir', default_value: dbussystemservicedir)
1606 endif
1607 endif
1608
1609 dbus_interfaces_dir = get_option('dbus-interfaces-dir')
1610 if dbus_interfaces_dir == '' or dbus_interfaces_dir == 'yes'
1611 if meson.is_cross_build() and dbus_interfaces_dir != 'yes'
1612 dbus_interfaces_dir = 'no'
1613 warning('Exporting D-Bus interface XML files is disabled during cross build. Pass path or "yes" to force enable.')
1614 else
1615 dbus_interfaces_dir = dbusdatadir / 'interfaces'
1616 if conf.get('HAVE_DBUS') == 1
1617 dbus_interfaces_dir = libdbus.get_variable(pkgconfig: 'interfaces_dir', default_value: dbus_interfaces_dir)
1618 endif
1619 endif
1620 endif
1621
1622 # We support one or the other. If gcrypt is available, we assume it's there to
1623 # be used, and use it in preference.
1624 opt = get_option('cryptolib')
1625 if opt == 'openssl' and conf.get('HAVE_OPENSSL') == 0
1626 error('openssl requested as the default cryptolib, but not available')
1627 endif
1628 conf.set10('PREFER_OPENSSL',
1629 opt == 'openssl' or (opt == 'auto' and conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_GCRYPT') == 0))
1630 conf.set10('HAVE_OPENSSL_OR_GCRYPT',
1631 conf.get('HAVE_OPENSSL') == 1 or conf.get('HAVE_GCRYPT') == 1)
1632 lib_openssl_or_gcrypt = conf.get('PREFER_OPENSSL') == 1 ? [libopenssl] : [libgcrypt, libgpg_error]
1633
1634 dns_over_tls = get_option('dns-over-tls')
1635 if dns_over_tls != 'false'
1636 if dns_over_tls == 'gnutls' and conf.get('PREFER_OPENSSL') == 1
1637 error('Sorry, -Ddns-over-tls=gnutls is not supported when openssl is used as the cryptolib')
1638 endif
1639
1640 if dns_over_tls == 'gnutls'
1641 have_openssl = false
1642 else
1643 have_openssl = conf.get('HAVE_OPENSSL') == 1
1644 if dns_over_tls == 'openssl' and not have_openssl
1645 error('DNS-over-TLS support was requested with openssl, but dependencies are not available')
1646 endif
1647 endif
1648 if dns_over_tls == 'openssl' or have_openssl
1649 have_gnutls = false
1650 else
1651 have_gnutls = conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0')
1652 if dns_over_tls != 'auto' and not have_gnutls
1653 str = dns_over_tls == 'gnutls' ? ' with gnutls' : ''
1654 error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
1655 endif
1656 endif
1657 have = have_gnutls or have_openssl
1658 else
1659 have = false
1660 have_gnutls = false
1661 have_openssl = false
1662 endif
1663 conf.set10('ENABLE_DNS_OVER_TLS', have)
1664 conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1665 conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
1666
1667 default_dns_over_tls = get_option('default-dns-over-tls')
1668 if skip_deps
1669 default_dns_over_tls = 'no'
1670 endif
1671 if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
1672 message('default-dns-over-tls cannot be enabled or set to opportunistic when DNS-over-TLS support is disabled. Setting default-dns-over-tls to no.')
1673 default_dns_over_tls = 'no'
1674 endif
1675 conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1676 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
1677 conf.set_quoted('DEFAULT_DNS_OVER_TLS_MODE_STR', default_dns_over_tls)
1678
1679 default_mdns = get_option('default-mdns')
1680 conf.set('DEFAULT_MDNS_MODE',
1681 'RESOLVE_SUPPORT_' + default_mdns.to_upper())
1682 conf.set_quoted('DEFAULT_MDNS_MODE_STR', default_mdns)
1683
1684 default_llmnr = get_option('default-llmnr')
1685 conf.set('DEFAULT_LLMNR_MODE',
1686 'RESOLVE_SUPPORT_' + default_llmnr.to_upper())
1687 conf.set_quoted('DEFAULT_LLMNR_MODE_STR', default_llmnr)
1688
1689 want_repart = get_option('repart')
1690 if want_repart != 'false'
1691 have = conf.get('HAVE_LIBFDISK') == 1
1692 if want_repart == 'true' and not have
1693 error('repart support was requested, but dependencies are not available')
1694 endif
1695 else
1696 have = false
1697 endif
1698 conf.set10('ENABLE_REPART', have)
1699
1700 default_dnssec = get_option('default-dnssec')
1701 if skip_deps
1702 default_dnssec = 'no'
1703 endif
1704 if default_dnssec != 'no' and conf.get('HAVE_OPENSSL_OR_GCRYPT') == 0
1705 message('default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.')
1706 default_dnssec = 'no'
1707 endif
1708 conf.set('DEFAULT_DNSSEC_MODE',
1709 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1710 conf.set_quoted('DEFAULT_DNSSEC_MODE_STR', default_dnssec)
1711
1712 want_sysupdate = get_option('sysupdate')
1713 if want_sysupdate != 'false'
1714 have = (conf.get('HAVE_OPENSSL') == 1 and
1715 conf.get('HAVE_LIBFDISK') == 1)
1716 if want_sysupdate == 'true' and not have
1717 error('sysupdate support was requested, but dependencies are not available')
1718 endif
1719 else
1720 have = false
1721 endif
1722 conf.set10('ENABLE_SYSUPDATE', have)
1723
1724 want_importd = get_option('importd')
1725 if want_importd != 'false'
1726 have = (conf.get('HAVE_LIBCURL') == 1 and
1727 conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and
1728 conf.get('HAVE_ZLIB') == 1 and
1729 conf.get('HAVE_XZ') == 1)
1730 if want_importd == 'true' and not have
1731 error('importd support was requested, but dependencies are not available')
1732 endif
1733 else
1734 have = false
1735 endif
1736 conf.set10('ENABLE_IMPORTD', have)
1737
1738 want_kernel_install = get_option('kernel-install')
1739 conf.set10('ENABLE_KERNEL_INSTALL', want_kernel_install)
1740
1741 want_homed = get_option('homed')
1742 if want_homed != 'false'
1743 have = (conf.get('HAVE_OPENSSL') == 1 and
1744 conf.get('HAVE_LIBFDISK') == 1 and
1745 conf.get('HAVE_LIBCRYPTSETUP') == 1)
1746 if want_homed == 'true' and not have
1747 error('homed support was requested, but dependencies are not available')
1748 endif
1749 else
1750 have = false
1751 endif
1752 conf.set10('ENABLE_HOMED', have)
1753
1754 have = have and conf.get('HAVE_PAM') == 1
1755 conf.set10('ENABLE_PAM_HOME', have)
1756
1757 have = get_option('oomd')
1758 conf.set10('ENABLE_OOMD', have)
1759
1760 want_remote = get_option('remote')
1761 if want_remote != 'false'
1762 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1763 conf.get('HAVE_LIBCURL') == 1]
1764 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1765 # it's possible to build one without the other. Complain only if
1766 # support was explicitly requested. The auxiliary files like sysusers
1767 # config should be installed when any of the programs are built.
1768 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1769 error('remote support was requested, but dependencies are not available')
1770 endif
1771 have = have_deps[0] or have_deps[1]
1772 else
1773 have = false
1774 endif
1775 conf.set10('ENABLE_REMOTE', have)
1776
1777 foreach term : ['analyze',
1778 'backlight',
1779 'binfmt',
1780 'coredump',
1781 'efi',
1782 'environment-d',
1783 'firstboot',
1784 'gshadow',
1785 'hibernate',
1786 'hostnamed',
1787 'hwdb',
1788 'idn',
1789 'ima',
1790 'initrd',
1791 'compat-mutable-uid-boundaries',
1792 'nscd',
1793 'ldconfig',
1794 'localed',
1795 'logind',
1796 'machined',
1797 'networkd',
1798 'nss-myhostname',
1799 'nss-systemd',
1800 'portabled',
1801 'sysext',
1802 'pstore',
1803 'quotacheck',
1804 'randomseed',
1805 'resolve',
1806 'rfkill',
1807 'smack',
1808 'sysusers',
1809 'timedated',
1810 'timesyncd',
1811 'tmpfiles',
1812 'tpm',
1813 'userdb',
1814 'utmp',
1815 'vconsole',
1816 'xdg-autostart']
1817 have = get_option(term)
1818 name = 'ENABLE_' + term.underscorify().to_upper()
1819 conf.set10(name, have)
1820 endforeach
1821
1822 enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
1823
1824 foreach tuple : [['nss-mymachines', 'machined'],
1825 ['nss-resolve', 'resolve']]
1826 want = get_option(tuple[0])
1827 if want != 'false'
1828 have = get_option(tuple[1])
1829 if want == 'true' and not have
1830 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1831 endif
1832 else
1833 have = false
1834 endif
1835 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1836 conf.set10(name, have)
1837 endforeach
1838
1839 enable_nss = false
1840 foreach term : ['ENABLE_NSS_MYHOSTNAME',
1841 'ENABLE_NSS_MYMACHINES',
1842 'ENABLE_NSS_RESOLVE',
1843 'ENABLE_NSS_SYSTEMD']
1844 if conf.get(term) == 1
1845 enable_nss = true
1846 endif
1847 endforeach
1848 conf.set10('ENABLE_NSS', enable_nss)
1849
1850 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1851
1852 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1853
1854 ############################################################
1855
1856 tests = []
1857 fuzzers = []
1858 catalogs = []
1859
1860 ############################################################
1861
1862 # Include these now as they provide gnu-efi detection.
1863 subdir('src/fundamental')
1864 subdir('src/boot/efi')
1865
1866 ############################################################
1867
1868 generate_gperfs = find_program('tools/generate-gperfs.py')
1869 make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
1870 make_directive_index_py = find_program('tools/make-directive-index.py')
1871 make_man_index_py = find_program('tools/make-man-index.py')
1872 meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
1873 update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
1874 update_man_rules_py = find_program('tools/update-man-rules.py')
1875 update_hwdb_sh = find_program('tools/update-hwdb.sh')
1876 update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
1877 update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
1878 xml_helper_py = find_program('tools/xml_helper.py')
1879 export_dbus_interfaces_py = find_program('tools/dbus_exporter.py')
1880
1881 ############################################################
1882
1883 if get_option('b_coverage')
1884 add_project_arguments('-include', 'src/basic/coverage.h', language : 'c')
1885 endif
1886
1887 ############################################################
1888
1889 config_h = configure_file(
1890 output : 'config.h',
1891 configuration : conf)
1892
1893 add_project_arguments('-include', 'config.h', language : 'c')
1894
1895 jinja2_cmdline = [meson_render_jinja2, config_h, version_h]
1896
1897 ############################################################
1898
1899 # binaries that have --help and are intended for use by humans,
1900 # usually, but not always, installed in /bin.
1901 public_programs = []
1902
1903 # D-Bus introspection XML export
1904 dbus_programs = []
1905
1906 basic_includes = include_directories(
1907 'src/basic',
1908 'src/fundamental',
1909 'src/systemd',
1910 '.')
1911
1912 libsystemd_includes = [basic_includes, include_directories(
1913 'src/libsystemd/sd-bus',
1914 'src/libsystemd/sd-device',
1915 'src/libsystemd/sd-event',
1916 'src/libsystemd/sd-hwdb',
1917 'src/libsystemd/sd-id128',
1918 'src/libsystemd/sd-journal',
1919 'src/libsystemd/sd-netlink',
1920 'src/libsystemd/sd-network',
1921 'src/libsystemd/sd-resolve')]
1922
1923 includes = [libsystemd_includes, include_directories('src/shared')]
1924
1925 subdir('po')
1926 subdir('catalog')
1927 subdir('src/basic')
1928 subdir('src/libsystemd')
1929 subdir('src/shared')
1930 subdir('src/udev')
1931 subdir('src/libudev')
1932 subdir('src/cryptsetup/cryptsetup-tokens')
1933
1934 alias_target('devel', libsystemd_pc, libudev_pc)
1935
1936 libsystemd = shared_library(
1937 'systemd',
1938 version : libsystemd_version,
1939 include_directories : libsystemd_includes,
1940 link_args : ['-shared',
1941 '-Wl,--version-script=' + libsystemd_sym_path],
1942 link_with : [libbasic,
1943 libbasic_gcrypt,
1944 libbasic_compress],
1945 link_whole : [libsystemd_static],
1946 dependencies : [threads,
1947 librt],
1948 link_depends : libsystemd_sym,
1949 install : true,
1950 install_tag: 'libsystemd',
1951 install_dir : rootlibdir)
1952
1953 alias_target('libsystemd', libsystemd)
1954
1955 install_libsystemd_static = static_library(
1956 'systemd',
1957 libsystemd_sources,
1958 basic_sources,
1959 basic_gcrypt_sources,
1960 basic_compress_sources,
1961 fundamental_sources,
1962 include_directories : libsystemd_includes,
1963 build_by_default : static_libsystemd != 'false',
1964 install : static_libsystemd != 'false',
1965 install_tag: 'libsystemd',
1966 install_dir : rootlibdir,
1967 pic : static_libsystemd_pic,
1968 dependencies : [threads,
1969 librt,
1970 libxz,
1971 libzstd,
1972 liblz4,
1973 libdl,
1974 libcap,
1975 libblkid,
1976 libmount,
1977 libgcrypt,
1978 libopenssl],
1979 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
1980
1981 libudev = shared_library(
1982 'udev',
1983 version : libudev_version,
1984 include_directories : includes,
1985 link_args : ['-shared',
1986 '-Wl,--version-script=' + libudev_sym_path],
1987 link_with : [libsystemd_static, libshared_static],
1988 link_whole : libudev_basic,
1989 dependencies : [threads],
1990 link_depends : libudev_sym,
1991 install : true,
1992 install_tag: 'libudev',
1993 install_dir : rootlibdir)
1994
1995 alias_target('libudev', libudev)
1996
1997 install_libudev_static = static_library(
1998 'udev',
1999 basic_sources,
2000 fundamental_sources,
2001 shared_sources,
2002 libsystemd_sources,
2003 libudev_sources,
2004 include_directories : includes,
2005 build_by_default : static_libudev != 'false',
2006 install : static_libudev != 'false',
2007 install_tag: 'libudev',
2008 install_dir : rootlibdir,
2009 link_depends : libudev_sym,
2010 dependencies : libshared_deps + [libmount],
2011 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
2012 pic : static_libudev_pic)
2013
2014 if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
2015 if conf.get('HAVE_TPM2') == 1
2016 cryptsetup_token_systemd_tpm2 = shared_library(
2017 'cryptsetup-token-systemd-tpm2',
2018 cryptsetup_token_systemd_tpm2_sources,
2019 include_directories : includes,
2020 link_args : ['-shared',
2021 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2022 link_with : [lib_cryptsetup_token_common,
2023 libshared],
2024 dependencies : [libcryptsetup,
2025 tpm2,
2026 versiondep],
2027 link_depends : cryptsetup_token_sym,
2028 install_rpath : rootpkglibdir,
2029 install : true,
2030 install_dir : libcryptsetup_plugins_dir)
2031 endif
2032
2033 if conf.get('HAVE_LIBFIDO2') == 1
2034 cryptsetup_token_systemd_fido2 = shared_library(
2035 'cryptsetup-token-systemd-fido2',
2036 cryptsetup_token_systemd_fido2_sources,
2037 include_directories : includes,
2038 link_args : ['-shared',
2039 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2040 link_with : [lib_cryptsetup_token_common,
2041 libshared],
2042 dependencies : [libcryptsetup,
2043 libfido2,
2044 versiondep],
2045 link_depends : cryptsetup_token_sym,
2046 install_rpath : rootpkglibdir,
2047 install : true,
2048 install_dir : libcryptsetup_plugins_dir)
2049 endif
2050
2051 if conf.get('HAVE_P11KIT') == 1
2052 cryptsetup_token_systemd_pkcs11 = shared_library(
2053 'cryptsetup-token-systemd-pkcs11',
2054 cryptsetup_token_systemd_pkcs11_sources,
2055 include_directories : includes,
2056 link_args : ['-shared',
2057 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2058 link_with : [lib_cryptsetup_token_common,
2059 libshared],
2060 dependencies : [libcryptsetup,
2061 libp11kit,
2062 versiondep],
2063 link_depends : cryptsetup_token_sym,
2064 install_rpath : rootpkglibdir,
2065 install : true,
2066 install_dir : libcryptsetup_plugins_dir)
2067 endif
2068 endif
2069
2070 ############################################################
2071
2072 # systemd-analyze requires 'libcore'
2073 subdir('src/core')
2074 # systemd-journal-remote requires 'libjournal_core'
2075 subdir('src/journal')
2076 # systemd-networkd requires 'libsystemd_network'
2077 subdir('src/libsystemd-network')
2078
2079 subdir('src/analyze')
2080 subdir('src/busctl')
2081 subdir('src/coredump')
2082 subdir('src/cryptenroll')
2083 subdir('src/cryptsetup')
2084 subdir('src/home')
2085 subdir('src/hostname')
2086 subdir('src/import')
2087 subdir('src/journal-remote')
2088 subdir('src/kernel-install')
2089 subdir('src/locale')
2090 subdir('src/login')
2091 subdir('src/machine')
2092 subdir('src/network')
2093 subdir('src/nspawn')
2094 subdir('src/oom')
2095 subdir('src/partition')
2096 subdir('src/portable')
2097 subdir('src/pstore')
2098 subdir('src/resolve')
2099 subdir('src/rpm')
2100 subdir('src/shutdown')
2101 subdir('src/sysext')
2102 subdir('src/systemctl')
2103 subdir('src/sysupdate')
2104 subdir('src/timedate')
2105 subdir('src/timesync')
2106 subdir('src/tmpfiles')
2107 subdir('src/userdb')
2108 subdir('src/xdg-autostart-generator')
2109
2110 subdir('src/systemd')
2111
2112 subdir('src/test')
2113 subdir('src/fuzz')
2114 subdir('rules.d')
2115 subdir('test')
2116
2117 ############################################################
2118
2119 # only static linking apart from libdl, to make sure that the
2120 # module is linked to all libraries that it uses.
2121 test_dlopen = executable(
2122 'test-dlopen',
2123 test_dlopen_c,
2124 include_directories : includes,
2125 link_with : [libbasic],
2126 dependencies : [libdl],
2127 build_by_default : want_tests != 'false')
2128
2129 foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
2130 ['systemd', 'ENABLE_NSS_SYSTEMD', ['nss-systemd.h', 'userdb-glue.c', 'userdb-glue.h']],
2131 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
2132 ['resolve', 'ENABLE_NSS_RESOLVE', [], resolve_includes]]
2133
2134 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
2135 if condition
2136 module = tuple[0]
2137
2138 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
2139 version_script_arg = project_source_root / sym
2140
2141 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
2142 if tuple.length() > 2
2143 foreach s : tuple[2]
2144 sources += ['src/nss-@0@/@1@'.format(module, s)]
2145 endforeach
2146 endif
2147
2148 incs = tuple.length() > 3 ? tuple[3] : includes
2149
2150 nss = shared_library(
2151 'nss_' + module,
2152 sources,
2153 version : '2',
2154 include_directories : incs,
2155 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
2156 link_args : ['-Wl,-z,nodelete',
2157 '-shared',
2158 '-Wl,--version-script=' + version_script_arg],
2159 link_with : [libsystemd_static,
2160 libshared_static,
2161 libbasic],
2162 dependencies : [threads,
2163 librt],
2164 link_depends : sym,
2165 install : true,
2166 install_tag : 'nss',
2167 install_dir : rootlibdir)
2168
2169 # We cannot use shared_module because it does not support version suffix.
2170 # Unfortunately shared_library insists on creating the symlink…
2171 meson.add_install_script('sh', '-c',
2172 'rm $DESTDIR@0@/libnss_@1@.so'
2173 .format(rootlibdir, module),
2174 install_tag : 'nss'
2175 )
2176
2177 if want_tests != 'false'
2178 test('dlopen-nss_' + module,
2179 test_dlopen,
2180 # path to dlopen must include a slash
2181 args : nss.full_path(),
2182 depends : nss)
2183 endif
2184 endif
2185 endforeach
2186
2187 ############################################################
2188
2189 exe = executable(
2190 'systemd',
2191 systemd_sources,
2192 include_directories : includes,
2193 link_with : [libcore,
2194 libshared],
2195 dependencies : [versiondep,
2196 libseccomp],
2197 install_rpath : rootpkglibdir,
2198 install : true,
2199 install_dir : rootlibexecdir)
2200 dbus_programs += exe
2201 public_programs += exe
2202
2203 meson.add_install_script(meson_make_symlink,
2204 rootlibexecdir / 'systemd',
2205 rootsbindir / 'init')
2206
2207 exe = executable(
2208 'systemd-analyze',
2209 systemd_analyze_sources,
2210 include_directories : core_includes,
2211 link_with : [libcore,
2212 libshared],
2213 dependencies : [versiondep,
2214 libseccomp],
2215 install_rpath : rootpkglibdir,
2216 install : conf.get('ENABLE_ANALYZE'))
2217 public_programs += exe
2218
2219 if want_tests != 'false'
2220 test('test-compare-versions',
2221 test_compare_versions_sh,
2222 args : exe.full_path())
2223 endif
2224
2225 executable(
2226 'systemd-journald',
2227 systemd_journald_sources,
2228 include_directories : includes,
2229 link_with : [libjournal_core,
2230 libshared],
2231 dependencies : [threads,
2232 libxz,
2233 liblz4,
2234 libselinux,
2235 libzstd],
2236 install_rpath : rootpkglibdir,
2237 install : true,
2238 install_dir : rootlibexecdir)
2239
2240 public_programs += executable(
2241 'systemd-cat',
2242 systemd_cat_sources,
2243 include_directories : includes,
2244 link_with : [libjournal_core,
2245 libshared],
2246 dependencies : [threads],
2247 install_rpath : rootpkglibdir,
2248 install : true)
2249
2250 public_programs += executable(
2251 'journalctl',
2252 journalctl_sources,
2253 include_directories : includes,
2254 link_with : [libshared],
2255 dependencies : [threads,
2256 libdl,
2257 libxz,
2258 liblz4,
2259 libzstd,
2260 libdl],
2261 install_rpath : rootpkglibdir,
2262 install : true,
2263 install_dir : rootbindir)
2264
2265 executable(
2266 'systemd-getty-generator',
2267 'src/getty-generator/getty-generator.c',
2268 include_directories : includes,
2269 link_with : [libshared],
2270 install_rpath : rootpkglibdir,
2271 install : true,
2272 install_dir : systemgeneratordir)
2273
2274 executable(
2275 'systemd-debug-generator',
2276 'src/debug-generator/debug-generator.c',
2277 include_directories : includes,
2278 link_with : [libshared],
2279 install_rpath : rootpkglibdir,
2280 install : true,
2281 install_dir : systemgeneratordir)
2282
2283 executable(
2284 'systemd-run-generator',
2285 'src/run-generator/run-generator.c',
2286 include_directories : includes,
2287 link_with : [libshared],
2288 install_rpath : rootpkglibdir,
2289 install : true,
2290 install_dir : systemgeneratordir)
2291
2292 exe = executable(
2293 'systemd-fstab-generator',
2294 'src/fstab-generator/fstab-generator.c',
2295 include_directories : includes,
2296 link_with : [libshared],
2297 install_rpath : rootpkglibdir,
2298 install : true,
2299 install_dir : systemgeneratordir)
2300
2301 if want_tests != 'false'
2302 test('test-fstab-generator',
2303 test_fstab_generator_sh,
2304 # https://github.com/mesonbuild/meson/issues/2681
2305 args : exe.full_path(),
2306 depends : exe)
2307 endif
2308
2309 if conf.get('ENABLE_ENVIRONMENT_D') == 1
2310 executable(
2311 '30-systemd-environment-d-generator',
2312 'src/environment-d-generator/environment-d-generator.c',
2313 include_directories : includes,
2314 link_with : [libshared],
2315 install_rpath : rootpkglibdir,
2316 install : true,
2317 install_dir : userenvgeneratordir)
2318
2319 meson.add_install_script(meson_make_symlink,
2320 sysconfdir / 'environment',
2321 environmentdir / '99-environment.conf')
2322 endif
2323
2324 if conf.get('ENABLE_HIBERNATE') == 1
2325 executable(
2326 'systemd-hibernate-resume-generator',
2327 'src/hibernate-resume/hibernate-resume-generator.c',
2328 include_directories : includes,
2329 link_with : [libshared],
2330 install_rpath : rootpkglibdir,
2331 install : true,
2332 install_dir : systemgeneratordir)
2333
2334 executable(
2335 'systemd-hibernate-resume',
2336 'src/hibernate-resume/hibernate-resume.c',
2337 include_directories : includes,
2338 link_with : [libshared],
2339 install_rpath : rootpkglibdir,
2340 install : true,
2341 install_dir : rootlibexecdir)
2342 endif
2343
2344 if conf.get('HAVE_BLKID') == 1
2345 executable(
2346 'systemd-gpt-auto-generator',
2347 'src/gpt-auto-generator/gpt-auto-generator.c',
2348 include_directories : includes,
2349 link_with : [libshared],
2350 dependencies : libblkid,
2351 install_rpath : rootpkglibdir,
2352 install : true,
2353 install_dir : systemgeneratordir)
2354
2355 public_programs += executable(
2356 'systemd-dissect',
2357 'src/dissect/dissect.c',
2358 include_directories : includes,
2359 link_with : [libshared],
2360 install_rpath : rootpkglibdir,
2361 install : true)
2362 endif
2363
2364 if conf.get('ENABLE_RESOLVE') == 1
2365 dbus_programs += executable(
2366 'systemd-resolved',
2367 systemd_resolved_sources,
2368 include_directories : resolve_includes,
2369 link_with : [libshared,
2370 libbasic_gcrypt,
2371 libsystemd_resolve_core],
2372 dependencies : systemd_resolved_dependencies,
2373 install_rpath : rootpkglibdir,
2374 install : true,
2375 install_dir : rootlibexecdir)
2376
2377 public_programs += executable(
2378 'resolvectl',
2379 resolvectl_sources,
2380 include_directories : includes,
2381 link_with : [libshared,
2382 libbasic_gcrypt,
2383 libsystemd_resolve_core],
2384 dependencies : [threads,
2385 lib_openssl_or_gcrypt,
2386 libm,
2387 libidn],
2388 install_rpath : rootpkglibdir,
2389 install : true)
2390
2391 meson.add_install_script(meson_make_symlink,
2392 bindir / 'resolvectl',
2393 rootsbindir / 'resolvconf')
2394
2395 meson.add_install_script(meson_make_symlink,
2396 bindir / 'resolvectl',
2397 bindir / 'systemd-resolve')
2398 endif
2399
2400 if conf.get('ENABLE_LOGIND') == 1
2401 dbus_programs += executable(
2402 'systemd-logind',
2403 systemd_logind_sources,
2404 include_directories : includes,
2405 link_with : [liblogind_core,
2406 libshared],
2407 dependencies : [threads,
2408 libacl],
2409 install_rpath : rootpkglibdir,
2410 install : true,
2411 install_dir : rootlibexecdir)
2412
2413 public_programs += executable(
2414 'loginctl',
2415 loginctl_sources,
2416 include_directories : includes,
2417 link_with : [libshared],
2418 dependencies : [threads,
2419 liblz4,
2420 libxz,
2421 libzstd],
2422 install_rpath : rootpkglibdir,
2423 install : true,
2424 install_dir : rootbindir)
2425
2426 public_programs += executable(
2427 'systemd-inhibit',
2428 'src/login/inhibit.c',
2429 include_directories : includes,
2430 link_with : [libshared],
2431 install_rpath : rootpkglibdir,
2432 install : true,
2433 install_dir : rootbindir)
2434
2435 if conf.get('HAVE_PAM') == 1
2436 version_script_arg = project_source_root / pam_systemd_sym
2437 pam_systemd = shared_library(
2438 'pam_systemd',
2439 pam_systemd_c,
2440 name_prefix : '',
2441 include_directories : includes,
2442 link_args : ['-shared',
2443 '-Wl,--version-script=' + version_script_arg],
2444 link_with : [libsystemd_static,
2445 libshared_static],
2446 dependencies : [threads,
2447 libpam,
2448 libpam_misc],
2449 link_depends : pam_systemd_sym,
2450 install : true,
2451 install_tag : 'pam',
2452 install_dir : pamlibdir)
2453
2454 if want_tests != 'false'
2455 test('dlopen-pam_systemd',
2456 test_dlopen,
2457 # path to dlopen must include a slash
2458 args : pam_systemd.full_path(),
2459 depends : pam_systemd)
2460 endif
2461 endif
2462
2463 executable(
2464 'systemd-user-runtime-dir',
2465 user_runtime_dir_sources,
2466 include_directories : includes,
2467 link_with : [libshared],
2468 install_rpath : rootpkglibdir,
2469 install : true,
2470 install_dir : rootlibexecdir)
2471 endif
2472
2473 if conf.get('HAVE_PAM') == 1
2474 executable(
2475 'systemd-user-sessions',
2476 'src/user-sessions/user-sessions.c',
2477 include_directories : includes,
2478 link_with : [libshared],
2479 install_rpath : rootpkglibdir,
2480 install : true,
2481 install_dir : rootlibexecdir)
2482 endif
2483
2484 if conf.get('HAVE_BLKID') == 1 and conf.get('HAVE_GNU_EFI') == 1
2485 if get_option('link-boot-shared')
2486 boot_link_with = [libshared]
2487 else
2488 boot_link_with = [libsystemd_static, libshared_static]
2489 endif
2490
2491 public_programs += executable(
2492 'bootctl',
2493 'src/boot/bootctl.c',
2494 include_directories : includes,
2495 link_with : [boot_link_with],
2496 dependencies : [libblkid],
2497 install_rpath : rootpkglibdir,
2498 install : true)
2499
2500 public_programs += executable(
2501 'systemd-bless-boot',
2502 'src/boot/bless-boot.c',
2503 include_directories : includes,
2504 link_with : [boot_link_with],
2505 dependencies : [libblkid],
2506 install_rpath : rootpkglibdir,
2507 install : true,
2508 install_dir : rootlibexecdir)
2509
2510 executable(
2511 'systemd-bless-boot-generator',
2512 'src/boot/bless-boot-generator.c',
2513 include_directories : includes,
2514 link_with : [boot_link_with],
2515 install_rpath : rootpkglibdir,
2516 install : true,
2517 install_dir : systemgeneratordir)
2518 endif
2519
2520 executable(
2521 'systemd-boot-check-no-failures',
2522 'src/boot/boot-check-no-failures.c',
2523 include_directories : includes,
2524 link_with : [libshared],
2525 dependencies : [libblkid],
2526 install_rpath : rootpkglibdir,
2527 install : true,
2528 install_dir : rootlibexecdir)
2529
2530 public_programs += executable(
2531 'systemd-socket-activate',
2532 'src/activate/activate.c',
2533 include_directories : includes,
2534 link_with : [libshared],
2535 dependencies : [threads],
2536 install_rpath : rootpkglibdir,
2537 install : true)
2538
2539 systemctl = executable(
2540 'systemctl',
2541 systemctl_sources,
2542 include_directories : includes,
2543 link_with : systemctl_link_with,
2544 dependencies : [threads,
2545 libcap,
2546 libselinux,
2547 libxz,
2548 liblz4,
2549 libzstd],
2550 install_rpath : rootpkglibdir,
2551 install : true,
2552 install_dir : rootbindir)
2553 public_programs += systemctl
2554
2555 if conf.get('ENABLE_PORTABLED') == 1
2556 dbus_programs += executable(
2557 'systemd-portabled',
2558 systemd_portabled_sources,
2559 include_directories : includes,
2560 link_with : [libshared],
2561 dependencies : [threads, libselinux],
2562 install_rpath : rootpkglibdir,
2563 install : true,
2564 install_dir : rootlibexecdir)
2565
2566 public_programs += executable(
2567 'portablectl',
2568 'src/portable/portablectl.c',
2569 include_directories : includes,
2570 link_with : [libshared],
2571 dependencies : [threads],
2572 install_rpath : rootpkglibdir,
2573 install : true,
2574 install_dir : rootbindir)
2575 endif
2576
2577 if conf.get('ENABLE_SYSEXT') == 1
2578 public_programs += executable(
2579 'systemd-sysext',
2580 systemd_sysext_sources,
2581 include_directories : includes,
2582 link_with : [libshared],
2583 install_rpath : rootpkglibdir,
2584 install : true,
2585 install_dir : rootbindir)
2586 endif
2587
2588 if conf.get('ENABLE_USERDB') == 1
2589 executable(
2590 'systemd-userwork',
2591 systemd_userwork_sources,
2592 include_directories : includes,
2593 link_with : [libshared],
2594 dependencies : [threads],
2595 install_rpath : rootpkglibdir,
2596 install : true,
2597 install_dir : rootlibexecdir)
2598
2599 executable(
2600 'systemd-userdbd',
2601 systemd_userdbd_sources,
2602 include_directories : includes,
2603 link_with : [libshared],
2604 dependencies : [threads],
2605 install_rpath : rootpkglibdir,
2606 install : true,
2607 install_dir : rootlibexecdir)
2608
2609 public_programs += executable(
2610 'userdbctl',
2611 userdbctl_sources,
2612 include_directories : includes,
2613 link_with : [libshared],
2614 dependencies : [threads],
2615 install_rpath : rootpkglibdir,
2616 install : true)
2617 endif
2618
2619 if conf.get('ENABLE_HOMED') == 1
2620 executable(
2621 'systemd-homework',
2622 systemd_homework_sources,
2623 include_directories : includes,
2624 link_with : [libshared],
2625 dependencies : [threads,
2626 libblkid,
2627 libcrypt,
2628 libopenssl,
2629 libfdisk,
2630 libp11kit],
2631 install_rpath : rootpkglibdir,
2632 install : true,
2633 install_dir : rootlibexecdir)
2634
2635 dbus_programs += executable(
2636 'systemd-homed',
2637 systemd_homed_sources,
2638 include_directories : home_includes,
2639 link_with : [libshared],
2640 dependencies : [threads,
2641 libcrypt,
2642 libopenssl,
2643 libm],
2644 install_rpath : rootpkglibdir,
2645 install : true,
2646 install_dir : rootlibexecdir)
2647
2648 public_programs += executable(
2649 'homectl',
2650 homectl_sources,
2651 include_directories : includes,
2652 link_with : [libshared],
2653 dependencies : [threads,
2654 libcrypt,
2655 libopenssl,
2656 libp11kit,
2657 libdl],
2658 install_rpath : rootpkglibdir,
2659 install : true)
2660
2661 if conf.get('HAVE_PAM') == 1
2662 version_script_arg = project_source_root / pam_systemd_home_sym
2663 pam_systemd_home = shared_library(
2664 'pam_systemd_home',
2665 pam_systemd_home_c,
2666 name_prefix : '',
2667 include_directories : includes,
2668 link_args : ['-shared',
2669 '-Wl,--version-script=' + version_script_arg],
2670 link_with : [libsystemd_static,
2671 libshared_static],
2672 dependencies : [threads,
2673 libpam,
2674 libpam_misc,
2675 libcrypt],
2676 link_depends : pam_systemd_home_sym,
2677 install : true,
2678 install_tag : 'pam',
2679 install_dir : pamlibdir)
2680
2681 if want_tests != 'false'
2682 test('dlopen-pam_systemd_home',
2683 test_dlopen,
2684 # path to dlopen must include a slash
2685 args : pam_systemd_home.full_path(),
2686 depends : pam_systemd_home)
2687 endif
2688 endif
2689 endif
2690
2691 foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
2692 (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
2693 meson.add_install_script(meson_make_symlink,
2694 rootbindir / 'systemctl',
2695 rootsbindir / alias)
2696 endforeach
2697
2698 meson.add_install_script(meson_make_symlink,
2699 rootbindir / 'udevadm',
2700 rootlibexecdir / 'systemd-udevd')
2701
2702 if conf.get('ENABLE_BACKLIGHT') == 1
2703 executable(
2704 'systemd-backlight',
2705 'src/backlight/backlight.c',
2706 include_directories : includes,
2707 link_with : [libshared],
2708 install_rpath : rootpkglibdir,
2709 install : true,
2710 install_dir : rootlibexecdir)
2711 endif
2712
2713 if conf.get('ENABLE_RFKILL') == 1
2714 executable(
2715 'systemd-rfkill',
2716 'src/rfkill/rfkill.c',
2717 include_directories : includes,
2718 link_with : [libshared],
2719 install_rpath : rootpkglibdir,
2720 install : true,
2721 install_dir : rootlibexecdir)
2722 endif
2723
2724 executable(
2725 'systemd-system-update-generator',
2726 'src/system-update-generator/system-update-generator.c',
2727 include_directories : includes,
2728 link_with : [libshared],
2729 install_rpath : rootpkglibdir,
2730 install : true,
2731 install_dir : systemgeneratordir)
2732
2733 if conf.get('HAVE_LIBCRYPTSETUP') == 1
2734 executable(
2735 'systemd-cryptsetup',
2736 systemd_cryptsetup_sources,
2737 include_directories : includes,
2738 link_with : [libshared],
2739 dependencies : [libcryptsetup,
2740 libp11kit],
2741 install_rpath : rootpkglibdir,
2742 install : true,
2743 install_dir : rootlibexecdir)
2744
2745 executable(
2746 'systemd-cryptsetup-generator',
2747 'src/cryptsetup/cryptsetup-generator.c',
2748 include_directories : includes,
2749 link_with : [libshared],
2750 install_rpath : rootpkglibdir,
2751 install : true,
2752 install_dir : systemgeneratordir)
2753
2754 executable(
2755 'systemd-veritysetup',
2756 'src/veritysetup/veritysetup.c',
2757 include_directories : includes,
2758 link_with : [libshared],
2759 dependencies : [libcryptsetup],
2760 install_rpath : rootpkglibdir,
2761 install : true,
2762 install_dir : rootlibexecdir)
2763
2764 executable(
2765 'systemd-veritysetup-generator',
2766 'src/veritysetup/veritysetup-generator.c',
2767 include_directories : includes,
2768 link_with : [libshared],
2769 install_rpath : rootpkglibdir,
2770 install : true,
2771 install_dir : systemgeneratordir)
2772
2773 public_programs += executable(
2774 'systemd-cryptenroll',
2775 systemd_cryptenroll_sources,
2776 include_directories : includes,
2777 link_with : [libshared],
2778 dependencies : [libcryptsetup,
2779 libdl,
2780 libopenssl,
2781 libp11kit],
2782 install_rpath : rootpkglibdir,
2783 install : true)
2784
2785 executable(
2786 'systemd-integritysetup',
2787 ['src/integritysetup/integritysetup.c', 'src/integritysetup/integrity-util.c'],
2788 include_directories : includes,
2789 link_with : [libshared],
2790 dependencies : [libcryptsetup],
2791 install_rpath : rootpkglibdir,
2792 install : true,
2793 install_dir : rootlibexecdir)
2794
2795 executable(
2796 'systemd-integritysetup-generator',
2797 ['src/integritysetup/integritysetup-generator.c', 'src/integritysetup/integrity-util.c'],
2798 include_directories : includes,
2799 link_with : [libshared],
2800 install_rpath : rootpkglibdir,
2801 install : true,
2802 install_dir : systemgeneratordir)
2803 endif
2804
2805 if conf.get('HAVE_SYSV_COMPAT') == 1
2806 exe = executable(
2807 'systemd-sysv-generator',
2808 'src/sysv-generator/sysv-generator.c',
2809 include_directories : includes,
2810 link_with : [libshared],
2811 install_rpath : rootpkglibdir,
2812 install : true,
2813 install_dir : systemgeneratordir)
2814
2815 sysv_generator_test_py = find_program('test/sysv-generator-test.py')
2816 if want_tests != 'false'
2817 test('sysv-generator-test',
2818 sysv_generator_test_py,
2819 depends : exe)
2820 endif
2821
2822 executable(
2823 'systemd-rc-local-generator',
2824 'src/rc-local-generator/rc-local-generator.c',
2825 include_directories : includes,
2826 link_with : [libshared],
2827 install_rpath : rootpkglibdir,
2828 install : true,
2829 install_dir : systemgeneratordir)
2830 endif
2831
2832 if conf.get('ENABLE_XDG_AUTOSTART') == 1
2833 executable(
2834 'systemd-xdg-autostart-generator',
2835 systemd_xdg_autostart_generator_sources,
2836 include_directories : includes,
2837 link_with : [libshared],
2838 install_rpath : rootpkglibdir,
2839 install : true,
2840 install_dir : usergeneratordir)
2841
2842 executable(
2843 'systemd-xdg-autostart-condition',
2844 'src/xdg-autostart-generator/xdg-autostart-condition.c',
2845 include_directories : includes,
2846 link_with : [libshared],
2847 install_rpath : rootpkglibdir,
2848 install : true,
2849 install_dir : rootlibexecdir)
2850 endif
2851
2852 if conf.get('ENABLE_HOSTNAMED') == 1
2853 dbus_programs += executable(
2854 'systemd-hostnamed',
2855 'src/hostname/hostnamed.c',
2856 include_directories : includes,
2857 link_with : [libshared],
2858 install_rpath : rootpkglibdir,
2859 install : true,
2860 install_dir : rootlibexecdir)
2861
2862 public_programs += executable(
2863 'hostnamectl',
2864 'src/hostname/hostnamectl.c',
2865 include_directories : includes,
2866 link_with : [libshared],
2867 install_rpath : rootpkglibdir,
2868 install : true)
2869 endif
2870
2871 if conf.get('ENABLE_LOCALED') == 1
2872 if conf.get('HAVE_XKBCOMMON') == 1
2873 # logind will load libxkbcommon.so dynamically on its own, but we still
2874 # need to specify where the headers are
2875 deps = [libdl, libxkbcommon.partial_dependency(compile_args: true)]
2876 else
2877 deps = []
2878 endif
2879
2880 dbus_programs += executable(
2881 'systemd-localed',
2882 systemd_localed_sources,
2883 include_directories : includes,
2884 link_with : [libshared],
2885 dependencies : deps,
2886 install_rpath : rootpkglibdir,
2887 install : true,
2888 install_dir : rootlibexecdir)
2889
2890 public_programs += executable(
2891 'localectl',
2892 localectl_sources,
2893 include_directories : includes,
2894 link_with : [libshared],
2895 install_rpath : rootpkglibdir,
2896 install : true)
2897 endif
2898
2899 if conf.get('ENABLE_TIMEDATED') == 1
2900 dbus_programs += executable(
2901 'systemd-timedated',
2902 'src/timedate/timedated.c',
2903 include_directories : includes,
2904 link_with : [libshared],
2905 install_rpath : rootpkglibdir,
2906 install : true,
2907 install_dir : rootlibexecdir)
2908 endif
2909
2910 if conf.get('ENABLE_TIMEDATECTL') == 1
2911 public_programs += executable(
2912 'timedatectl',
2913 'src/timedate/timedatectl.c',
2914 include_directories : includes,
2915 install_rpath : rootpkglibdir,
2916 link_with : [libshared],
2917 dependencies : [libm],
2918 install : true)
2919 endif
2920
2921 if conf.get('ENABLE_TIMESYNCD') == 1
2922 executable(
2923 'systemd-timesyncd',
2924 systemd_timesyncd_sources,
2925 include_directories : includes,
2926 link_with : [libtimesyncd_core],
2927 dependencies : [threads,
2928 libm],
2929 install_rpath : rootpkglibdir,
2930 install : true,
2931 install_dir : rootlibexecdir)
2932
2933 executable(
2934 'systemd-time-wait-sync',
2935 'src/timesync/wait-sync.c',
2936 include_directories : includes,
2937 link_with : [libtimesyncd_core],
2938 install_rpath : rootpkglibdir,
2939 install : true,
2940 install_dir : rootlibexecdir)
2941 endif
2942
2943 if conf.get('ENABLE_MACHINED') == 1
2944 dbus_programs += executable(
2945 'systemd-machined',
2946 systemd_machined_sources,
2947 include_directories : includes,
2948 link_with : [libmachine_core,
2949 libshared],
2950 install_rpath : rootpkglibdir,
2951 install : true,
2952 install_dir : rootlibexecdir)
2953
2954 public_programs += executable(
2955 'machinectl',
2956 'src/machine/machinectl.c',
2957 include_directories : includes,
2958 link_with : [libshared],
2959 dependencies : [threads,
2960 libxz,
2961 liblz4,
2962 libzstd],
2963 install_rpath : rootpkglibdir,
2964 install : true,
2965 install_dir : rootbindir)
2966 endif
2967
2968 if conf.get('ENABLE_IMPORTD') == 1
2969 dbus_programs += executable(
2970 'systemd-importd',
2971 systemd_importd_sources,
2972 include_directories : includes,
2973 link_with : [libshared],
2974 dependencies : [threads],
2975 install_rpath : rootpkglibdir,
2976 install : true,
2977 install_dir : rootlibexecdir)
2978
2979 systemd_pull = executable(
2980 'systemd-pull',
2981 systemd_pull_sources,
2982 include_directories : includes,
2983 link_with : [libshared,
2984 lib_import_common],
2985 dependencies : [versiondep,
2986 libcurl,
2987 lib_openssl_or_gcrypt,
2988 libz,
2989 libbzip2,
2990 libxz],
2991 install_rpath : rootpkglibdir,
2992 install : true,
2993 install_dir : rootlibexecdir)
2994
2995 systemd_import = executable(
2996 'systemd-import',
2997 systemd_import_sources,
2998 include_directories : includes,
2999 link_with : [libshared,
3000 lib_import_common],
3001 dependencies : [libcurl,
3002 libz,
3003 libbzip2,
3004 libxz],
3005 install_rpath : rootpkglibdir,
3006 install : true,
3007 install_dir : rootlibexecdir)
3008
3009 systemd_import_fs = executable(
3010 'systemd-import-fs',
3011 systemd_import_fs_sources,
3012 include_directories : includes,
3013 link_with : [libshared,
3014 lib_import_common],
3015 install_rpath : rootpkglibdir,
3016 install : true,
3017 install_dir : rootlibexecdir)
3018
3019 systemd_export = executable(
3020 'systemd-export',
3021 systemd_export_sources,
3022 include_directories : includes,
3023 link_with : [libshared,
3024 lib_import_common],
3025 dependencies : [libcurl,
3026 libz,
3027 libbzip2,
3028 libxz],
3029 install_rpath : rootpkglibdir,
3030 install : true,
3031 install_dir : rootlibexecdir)
3032
3033 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
3034 endif
3035
3036 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
3037 public_programs += executable(
3038 'systemd-journal-upload',
3039 systemd_journal_upload_sources,
3040 include_directories : includes,
3041 link_with : [libshared],
3042 dependencies : [versiondep,
3043 threads,
3044 libcurl,
3045 libgnutls,
3046 libxz,
3047 liblz4,
3048 libzstd],
3049 install_rpath : rootpkglibdir,
3050 install : true,
3051 install_dir : rootlibexecdir)
3052 endif
3053
3054 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
3055 public_programs += executable(
3056 'systemd-journal-remote',
3057 systemd_journal_remote_sources,
3058 include_directories : journal_includes,
3059 link_with : [libshared,
3060 libsystemd_journal_remote],
3061 dependencies : [threads,
3062 libmicrohttpd,
3063 libgnutls,
3064 libxz,
3065 liblz4,
3066 libzstd],
3067 install_rpath : rootpkglibdir,
3068 install : true,
3069 install_dir : rootlibexecdir)
3070
3071 public_programs += executable(
3072 'systemd-journal-gatewayd',
3073 systemd_journal_gatewayd_sources,
3074 include_directories : journal_includes,
3075 link_with : [libshared],
3076 dependencies : [threads,
3077 libmicrohttpd,
3078 libgnutls,
3079 libxz,
3080 liblz4,
3081 libzstd],
3082 install_rpath : rootpkglibdir,
3083 install : true,
3084 install_dir : rootlibexecdir)
3085 endif
3086
3087 if conf.get('ENABLE_COREDUMP') == 1
3088 executable(
3089 'systemd-coredump',
3090 systemd_coredump_sources,
3091 include_directories : includes,
3092 link_with : [libshared,
3093 libbasic_compress],
3094 dependencies : [threads,
3095 libacl,
3096 libxz,
3097 liblz4,
3098 libzstd],
3099 install_rpath : rootpkglibdir,
3100 install : true,
3101 install_dir : rootlibexecdir)
3102
3103 public_programs += executable(
3104 'coredumpctl',
3105 coredumpctl_sources,
3106 include_directories : includes,
3107 link_with : [libshared,
3108 libbasic_compress],
3109 dependencies : [threads,
3110 libxz,
3111 liblz4,
3112 libzstd],
3113 install_rpath : rootpkglibdir,
3114 install : true)
3115 endif
3116
3117 if conf.get('ENABLE_PSTORE') == 1
3118 executable(
3119 'systemd-pstore',
3120 systemd_pstore_sources,
3121 include_directories : includes,
3122 link_with : [libshared],
3123 dependencies : [threads,
3124 libacl,
3125 libxz,
3126 liblz4,
3127 libzstd],
3128 install_rpath : rootpkglibdir,
3129 install : true,
3130 install_dir : rootlibexecdir)
3131 endif
3132
3133 if conf.get('ENABLE_OOMD') == 1
3134 dbus_programs += executable('systemd-oomd',
3135 systemd_oomd_sources,
3136 include_directories : includes,
3137 link_with : [libshared],
3138 dependencies : [],
3139 install_rpath : rootpkglibdir,
3140 install : true,
3141 install_dir : rootlibexecdir)
3142
3143 public_programs += executable(
3144 'oomctl',
3145 oomctl_sources,
3146 include_directories : includes,
3147 link_with : [libshared],
3148 dependencies : [],
3149 install_rpath : rootpkglibdir,
3150 install : true)
3151 endif
3152
3153 if conf.get('ENABLE_BINFMT') == 1
3154 public_programs += executable(
3155 'systemd-binfmt',
3156 'src/binfmt/binfmt.c',
3157 include_directories : includes,
3158 link_with : [libshared],
3159 install_rpath : rootpkglibdir,
3160 install : true,
3161 install_dir : rootlibexecdir)
3162
3163 meson.add_install_script('sh', '-c',
3164 mkdir_p.format(binfmtdir))
3165 if install_sysconfdir
3166 meson.add_install_script('sh', '-c',
3167 mkdir_p.format(sysconfdir / 'binfmt.d'))
3168 endif
3169 endif
3170
3171 if conf.get('ENABLE_SYSUPDATE') == 1
3172 exe = executable(
3173 'systemd-sysupdate',
3174 systemd_sysupdate_sources,
3175 include_directories : includes,
3176 link_with : [libshared],
3177 dependencies : [threads,
3178 libblkid,
3179 libfdisk,
3180 libopenssl],
3181 install_rpath : rootpkglibdir,
3182 install : true,
3183 install_dir : rootlibexecdir)
3184 public_programs += exe
3185 endif
3186
3187 if conf.get('ENABLE_VCONSOLE') == 1
3188 executable(
3189 'systemd-vconsole-setup',
3190 'src/vconsole/vconsole-setup.c',
3191 include_directories : includes,
3192 link_with : [libshared],
3193 install_rpath : rootpkglibdir,
3194 install : true,
3195 install_dir : rootlibexecdir)
3196 endif
3197
3198 if conf.get('ENABLE_RANDOMSEED') == 1
3199 executable(
3200 'systemd-random-seed',
3201 'src/random-seed/random-seed.c',
3202 include_directories : includes,
3203 link_with : [libshared],
3204 install_rpath : rootpkglibdir,
3205 install : true,
3206 install_dir : rootlibexecdir)
3207 endif
3208
3209 if conf.get('ENABLE_FIRSTBOOT') == 1
3210 public_programs += executable(
3211 'systemd-firstboot',
3212 'src/firstboot/firstboot.c',
3213 include_directories : includes,
3214 link_with : [libshared],
3215 dependencies : [libcrypt],
3216 install_rpath : rootpkglibdir,
3217 install : true,
3218 install_dir : rootbindir)
3219 endif
3220
3221 executable(
3222 'systemd-remount-fs',
3223 'src/remount-fs/remount-fs.c',
3224 include_directories : includes,
3225 link_with : [libshared],
3226 install_rpath : rootpkglibdir,
3227 install : true,
3228 install_dir : rootlibexecdir)
3229
3230 executable(
3231 'systemd-machine-id-setup',
3232 'src/machine-id-setup/machine-id-setup-main.c',
3233 include_directories : includes,
3234 link_with : [libshared],
3235 install_rpath : rootpkglibdir,
3236 install : true,
3237 install_dir : rootbindir)
3238
3239 executable(
3240 'systemd-fsck',
3241 'src/fsck/fsck.c',
3242 include_directories : includes,
3243 link_with : [libshared],
3244 install_rpath : rootpkglibdir,
3245 install : true,
3246 install_dir : rootlibexecdir)
3247
3248 executable('systemd-growfs',
3249 'src/partition/growfs.c',
3250 include_directories : includes,
3251 link_with : [libshared],
3252 install_rpath : rootpkglibdir,
3253 install : true,
3254 install_dir : rootlibexecdir)
3255
3256 executable(
3257 'systemd-makefs',
3258 'src/partition/makefs.c',
3259 include_directories : includes,
3260 link_with : [libshared],
3261 install_rpath : rootpkglibdir,
3262 install : true,
3263 install_dir : rootlibexecdir)
3264
3265 executable(
3266 'systemd-sleep',
3267 'src/sleep/sleep.c',
3268 include_directories : includes,
3269 link_with : [libshared],
3270 install_rpath : rootpkglibdir,
3271 install : true,
3272 install_dir : rootlibexecdir)
3273
3274 if install_sysconfdir_samples
3275 install_data('src/sleep/sleep.conf',
3276 install_dir : pkgsysconfdir)
3277 endif
3278
3279 public_programs += executable(
3280 'systemd-sysctl',
3281 'src/sysctl/sysctl.c',
3282 include_directories : includes,
3283 link_with : [libshared],
3284 install_rpath : rootpkglibdir,
3285 install : true,
3286 install_dir : rootlibexecdir)
3287
3288 executable(
3289 'systemd-ac-power',
3290 'src/ac-power/ac-power.c',
3291 include_directories : includes,
3292 link_with : [libshared],
3293 install_rpath : rootpkglibdir,
3294 install : true,
3295 install_dir : rootlibexecdir)
3296
3297 public_programs += executable(
3298 'systemd-detect-virt',
3299 'src/detect-virt/detect-virt.c',
3300 include_directories : includes,
3301 link_with : [libshared],
3302 install_rpath : rootpkglibdir,
3303 install : true)
3304
3305 public_programs += executable(
3306 'systemd-delta',
3307 'src/delta/delta.c',
3308 include_directories : includes,
3309 link_with : [libshared],
3310 install_rpath : rootpkglibdir,
3311 install : true)
3312
3313 public_programs += executable(
3314 'systemd-escape',
3315 'src/escape/escape.c',
3316 include_directories : includes,
3317 link_with : [libshared],
3318 install_rpath : rootpkglibdir,
3319 install : true,
3320 install_dir : rootbindir)
3321
3322 public_programs += executable(
3323 'systemd-notify',
3324 'src/notify/notify.c',
3325 include_directories : includes,
3326 link_with : [libshared],
3327 install_rpath : rootpkglibdir,
3328 install : true,
3329 install_dir : rootbindir)
3330
3331 public_programs += executable(
3332 'systemd-creds',
3333 'src/creds/creds.c',
3334 include_directories : includes,
3335 link_with : [libshared],
3336 dependencies : [threads,
3337 libopenssl],
3338 install_rpath : rootpkglibdir,
3339 install : true,
3340 install_dir : rootbindir)
3341
3342 executable(
3343 'systemd-volatile-root',
3344 'src/volatile-root/volatile-root.c',
3345 include_directories : includes,
3346 link_with : [libshared],
3347 install_rpath : rootpkglibdir,
3348 install : conf.get('ENABLE_INITRD') == 1,
3349 install_dir : rootlibexecdir)
3350
3351 executable(
3352 'systemd-cgroups-agent',
3353 'src/cgroups-agent/cgroups-agent.c',
3354 include_directories : includes,
3355 link_with : [libshared],
3356 install_rpath : rootpkglibdir,
3357 install : true,
3358 install_dir : rootlibexecdir)
3359
3360 systemd_id128 = executable(
3361 'systemd-id128',
3362 'src/id128/id128.c',
3363 include_directories : includes,
3364 link_with : [libshared],
3365 install_rpath : rootpkglibdir,
3366 install : true)
3367 public_programs += systemd_id128
3368
3369 if want_tests != 'false'
3370 test('test-systemctl-enable',
3371 test_systemctl_enable_sh,
3372 # https://github.com/mesonbuild/meson/issues/2681
3373 args : [systemctl.full_path(),
3374 systemd_id128.full_path()])
3375 endif
3376
3377 public_programs += executable(
3378 'systemd-path',
3379 'src/path/path.c',
3380 include_directories : includes,
3381 link_with : [libshared],
3382 install_rpath : rootpkglibdir,
3383 install : true)
3384
3385 public_programs += executable(
3386 'systemd-ask-password',
3387 'src/ask-password/ask-password.c',
3388 include_directories : includes,
3389 link_with : [libshared],
3390 install_rpath : rootpkglibdir,
3391 install : true,
3392 install_dir : rootbindir)
3393
3394 executable(
3395 'systemd-reply-password',
3396 'src/reply-password/reply-password.c',
3397 include_directories : includes,
3398 link_with : [libshared],
3399 install_rpath : rootpkglibdir,
3400 install : true,
3401 install_dir : rootlibexecdir)
3402
3403 public_programs += executable(
3404 'systemd-tty-ask-password-agent',
3405 'src/tty-ask-password-agent/tty-ask-password-agent.c',
3406 include_directories : includes,
3407 link_with : [libshared],
3408 install_rpath : rootpkglibdir,
3409 install : true,
3410 install_dir : rootbindir)
3411
3412 public_programs += executable(
3413 'systemd-cgls',
3414 'src/cgls/cgls.c',
3415 include_directories : includes,
3416 link_with : [libshared],
3417 install_rpath : rootpkglibdir,
3418 install : true)
3419
3420 public_programs += executable(
3421 'systemd-cgtop',
3422 'src/cgtop/cgtop.c',
3423 include_directories : includes,
3424 link_with : [libshared],
3425 install_rpath : rootpkglibdir,
3426 install : true)
3427
3428 executable(
3429 'systemd-initctl',
3430 'src/initctl/initctl.c',
3431 include_directories : includes,
3432 link_with : [libshared],
3433 install_rpath : rootpkglibdir,
3434 install : (conf.get('HAVE_SYSV_COMPAT') == 1),
3435 install_dir : rootlibexecdir)
3436
3437 public_programs += executable(
3438 'systemd-mount',
3439 'src/mount/mount-tool.c',
3440 include_directories : includes,
3441 link_with : [libshared],
3442 dependencies: [libmount],
3443 install_rpath : rootpkglibdir,
3444 install : true)
3445
3446 meson.add_install_script(meson_make_symlink,
3447 'systemd-mount', bindir / 'systemd-umount')
3448
3449 public_programs += executable(
3450 'systemd-run',
3451 'src/run/run.c',
3452 include_directories : includes,
3453 link_with : [libshared],
3454 install_rpath : rootpkglibdir,
3455 install : true)
3456
3457 public_programs += executable(
3458 'systemd-stdio-bridge',
3459 'src/stdio-bridge/stdio-bridge.c',
3460 include_directories : includes,
3461 link_with : [libshared],
3462 dependencies : [versiondep],
3463 install_rpath : rootpkglibdir,
3464 install : true)
3465
3466 public_programs += executable(
3467 'busctl',
3468 busctl_sources,
3469 include_directories : includes,
3470 link_with : [libshared],
3471 dependencies : [versiondep],
3472 install_rpath : rootpkglibdir,
3473 install : true)
3474
3475 if enable_sysusers
3476 exe = executable(
3477 'systemd-sysusers',
3478 'src/sysusers/sysusers.c',
3479 include_directories : includes,
3480 link_with : [libshared],
3481 install_rpath : rootpkglibdir,
3482 install : true,
3483 install_dir : rootbindir)
3484 public_programs += exe
3485
3486 if want_tests != 'false'
3487 test('test-sysusers',
3488 test_sysusers_sh,
3489 # https://github.com/mesonbuild/meson/issues/2681
3490 args : exe.full_path())
3491 endif
3492
3493 if have_standalone_binaries
3494 exe = executable(
3495 'systemd-sysusers.standalone',
3496 'src/sysusers/sysusers.c',
3497 include_directories : includes,
3498 c_args : '-DSTANDALONE',
3499 link_with : [libshared_static,
3500 libbasic,
3501 libbasic_gcrypt,
3502 libsystemd_static],
3503 install : true,
3504 install_dir : rootbindir)
3505 public_programs += exe
3506
3507 if want_tests != 'false'
3508 test('test-sysusers.standalone',
3509 test_sysusers_sh,
3510 # https://github.com/mesonbuild/meson/issues/2681
3511 args : exe.full_path())
3512 endif
3513 endif
3514 endif
3515
3516 if conf.get('ENABLE_TMPFILES') == 1
3517 exe = executable(
3518 'systemd-tmpfiles',
3519 systemd_tmpfiles_sources,
3520 include_directories : includes,
3521 link_with : [libshared],
3522 dependencies : [libacl],
3523 install_rpath : rootpkglibdir,
3524 install : true,
3525 install_dir : rootbindir)
3526 public_programs += exe
3527
3528 if want_tests != 'false'
3529 test('test-systemd-tmpfiles',
3530 test_systemd_tmpfiles_py,
3531 # https://github.com/mesonbuild/meson/issues/2681
3532 args : exe.full_path())
3533 endif
3534
3535 if have_standalone_binaries
3536 exe = executable(
3537 'systemd-tmpfiles.standalone',
3538 systemd_tmpfiles_sources,
3539 include_directories : includes,
3540 c_args : '-DSTANDALONE',
3541 link_with : [libshared_static,
3542 libbasic,
3543 libbasic_gcrypt,
3544 libsystemd_static],
3545 dependencies : [libacl],
3546 install : true,
3547 install_dir : rootbindir)
3548 public_programs += exe
3549
3550 if want_tests != 'false'
3551 test('test-systemd-tmpfiles.standalone',
3552 test_systemd_tmpfiles_py,
3553 # https://github.com/mesonbuild/meson/issues/2681
3554 args : exe.full_path())
3555 endif
3556 endif
3557 endif
3558
3559 if conf.get('ENABLE_HWDB') == 1
3560 systemd_hwdb = executable(
3561 'systemd-hwdb',
3562 'src/hwdb/hwdb.c',
3563 include_directories : includes,
3564 link_with : udev_link_with,
3565 install_rpath : udev_rpath,
3566 install : true,
3567 install_dir : rootbindir)
3568 public_programs += systemd_hwdb
3569
3570 if want_tests != 'false'
3571 test('hwdb-test',
3572 hwdb_test_sh,
3573 suite : 'dist-check',
3574 args : [systemd_hwdb.full_path()],
3575 timeout : 90)
3576 endif
3577 endif
3578
3579 if conf.get('ENABLE_QUOTACHECK') == 1
3580 executable(
3581 'systemd-quotacheck',
3582 'src/quotacheck/quotacheck.c',
3583 include_directories : includes,
3584 link_with : [libshared],
3585 install_rpath : rootpkglibdir,
3586 install : true,
3587 install_dir : rootlibexecdir)
3588 endif
3589
3590 public_programs += executable(
3591 'systemd-socket-proxyd',
3592 'src/socket-proxy/socket-proxyd.c',
3593 include_directories : includes,
3594 link_with : [libshared],
3595 dependencies : [threads],
3596 install_rpath : rootpkglibdir,
3597 install : true,
3598 install_dir : rootlibexecdir)
3599
3600 udevadm = executable(
3601 'udevadm',
3602 udevadm_sources,
3603 include_directories : includes,
3604 link_with : [libudevd_core],
3605 dependencies : [versiondep,
3606 threads,
3607 libkmod,
3608 libidn,
3609 libacl,
3610 libblkid],
3611 install_rpath : udev_rpath,
3612 install : true,
3613 install_dir : rootbindir)
3614 public_programs += udevadm
3615
3616 if conf.get('ENABLE_REPART') == 1
3617 exe = executable(
3618 'systemd-repart',
3619 systemd_repart_sources,
3620 include_directories : includes,
3621 link_with : [libshared],
3622 dependencies : [threads,
3623 libblkid,
3624 libfdisk],
3625 install_rpath : rootpkglibdir,
3626 install : true,
3627 install_dir : rootbindir)
3628 public_programs += exe
3629
3630 if want_tests != 'false'
3631 test('test-repart',
3632 test_repart_sh,
3633 args : [exe.full_path(), udevadm.full_path()])
3634 endif
3635 endif
3636
3637 executable(
3638 'systemd-shutdown',
3639 systemd_shutdown_sources,
3640 include_directories : includes,
3641 link_with : [libshared],
3642 dependencies : [libmount],
3643 install_rpath : rootpkglibdir,
3644 install : true,
3645 install_dir : rootlibexecdir)
3646
3647 executable(
3648 'systemd-update-done',
3649 'src/update-done/update-done.c',
3650 include_directories : includes,
3651 link_with : [libshared],
3652 install_rpath : rootpkglibdir,
3653 install : true,
3654 install_dir : rootlibexecdir)
3655
3656 executable(
3657 'systemd-update-utmp',
3658 'src/update-utmp/update-utmp.c',
3659 include_directories : includes,
3660 link_with : [libshared],
3661 dependencies : [libaudit],
3662 install_rpath : rootpkglibdir,
3663 install : (conf.get('ENABLE_UTMP') == 1),
3664 install_dir : rootlibexecdir)
3665
3666 if conf.get('HAVE_KMOD') == 1
3667 executable(
3668 'systemd-modules-load',
3669 'src/modules-load/modules-load.c',
3670 include_directories : includes,
3671 link_with : [libshared],
3672 dependencies : [libkmod],
3673 install_rpath : rootpkglibdir,
3674 install : true,
3675 install_dir : rootlibexecdir)
3676
3677 meson.add_install_script('sh', '-c',
3678 mkdir_p.format(modulesloaddir))
3679 if install_sysconfdir
3680 meson.add_install_script('sh', '-c',
3681 mkdir_p.format(sysconfdir / 'modules-load.d'))
3682 endif
3683 endif
3684
3685 public_programs += executable(
3686 'systemd-nspawn',
3687 systemd_nspawn_sources,
3688 include_directories : includes,
3689 link_with : [libnspawn_core,
3690 libshared],
3691 dependencies : [libblkid,
3692 libseccomp],
3693 install_rpath : rootpkglibdir,
3694 install : true)
3695
3696 if conf.get('ENABLE_NETWORKD') == 1
3697 dbus_programs += executable(
3698 'systemd-networkd',
3699 systemd_networkd_sources,
3700 include_directories : network_includes,
3701 link_with : [libnetworkd_core,
3702 libsystemd_network,
3703 networkd_link_with],
3704 dependencies : [threads],
3705 install_rpath : rootpkglibdir,
3706 install : true,
3707 install_dir : rootlibexecdir)
3708
3709 public_programs += executable(
3710 'systemd-networkd-wait-online',
3711 systemd_networkd_wait_online_sources,
3712 include_directories : includes,
3713 link_with : [networkd_link_with],
3714 install_rpath : rootpkglibdir,
3715 install : true,
3716 install_dir : rootlibexecdir)
3717
3718 public_programs += executable(
3719 'networkctl',
3720 networkctl_sources,
3721 include_directories : libsystemd_network_includes,
3722 link_with : [libsystemd_network,
3723 networkd_link_with],
3724 install_rpath : rootpkglibdir,
3725 install : true,
3726 install_dir : rootbindir)
3727 endif
3728
3729 exe = executable(
3730 'systemd-network-generator',
3731 network_generator_sources,
3732 include_directories : includes,
3733 link_with : [networkd_link_with],
3734 install_rpath : rootpkglibdir,
3735 install : true,
3736 install_dir : rootlibexecdir)
3737
3738 if want_tests != 'false'
3739 test('test-network-generator-conversion',
3740 test_network_generator_conversion_sh,
3741 # https://github.com/mesonbuild/meson/issues/2681
3742 args : exe.full_path(),
3743 depends : exe)
3744 endif
3745
3746 executable(
3747 'systemd-sulogin-shell',
3748 'src/sulogin-shell/sulogin-shell.c',
3749 include_directories : includes,
3750 link_with : [libshared],
3751 install_rpath : rootpkglibdir,
3752 install : true,
3753 install_dir : rootlibexecdir)
3754
3755 exe = custom_target(
3756 'kernel-install',
3757 input : kernel_install_in,
3758 output : 'kernel-install',
3759 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
3760 install : want_kernel_install,
3761 install_mode : 'rwxr-xr-x',
3762 install_dir : bindir)
3763 public_programs += exe
3764
3765 if want_tests != 'false'
3766 test('test-kernel-install',
3767 test_kernel_install_sh,
3768 args : [exe.full_path(), loaderentry_install])
3769 endif
3770
3771 ############################################################
3772
3773 runtest_env = custom_target(
3774 'systemd-runtest.env',
3775 output : 'systemd-runtest.env',
3776 command : [sh, '-c',
3777 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
3778 project_source_root / 'test',
3779 project_build_root / 'catalog')],
3780 depends : catalogs,
3781 build_by_default : true)
3782
3783 test_cflags = ['-DTEST_CODE=1']
3784 # We intentionally do not do inline initializations with definitions for a
3785 # bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
3786 # use the variable unexpectedly. This triggers a lot of maybe-uninitialized
3787 # false positives when the combination of -O2 and -flto is used. Suppress them.
3788 if '-O2' in c_args and '-flto=auto' in c_args
3789 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
3790 endif
3791
3792 foreach tuple : tests
3793 sources = tuple[0]
3794 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3795 dependencies = tuple.length() > 2 ? tuple[2] : []
3796 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3797 condition = tuple.length() > 4 ? tuple[4] : ''
3798 type = tuple.length() > 5 ? tuple[5] : ''
3799 defs = tuple.length() > 6 ? tuple[6] : []
3800 defs += test_cflags
3801 parallel = tuple.length() > 7 ? tuple[7] : true
3802 timeout = 30
3803
3804 # FIXME: Use fs.stem() with meson >= 0.54.0
3805 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
3806 if type.startswith('timeout=')
3807 timeout = type.split('=')[1].to_int()
3808 type = ''
3809 endif
3810
3811 suite = fs.name(fs.parent('@0@'.format(sources[0])))
3812 # FIXME: Use str.replace() with meson >= 0.58.0
3813 suite = suite.split('sd-')[-1]
3814
3815 if condition == '' or conf.get(condition) == 1
3816 exe = executable(
3817 name,
3818 sources,
3819 include_directories : incs,
3820 link_with : link_with,
3821 dependencies : [versiondep,
3822 dependencies],
3823 c_args : defs,
3824 build_by_default : want_tests != 'false',
3825 install_rpath : rootpkglibdir,
3826 install : install_tests,
3827 install_dir : testsdir / type,
3828 link_depends : runtest_env)
3829
3830 if type == 'manual'
3831 message('@0@ is a manual test'.format(name))
3832 elif type == 'unsafe' and want_tests != 'unsafe'
3833 message('@0@ is an unsafe test'.format(name))
3834 elif want_tests != 'false'
3835 test(name, exe,
3836 env : test_env,
3837 timeout : timeout,
3838 suite : suite)
3839 endif
3840 else
3841 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
3842 endif
3843 endforeach
3844
3845 exe = executable(
3846 'test-libsystemd-sym',
3847 test_libsystemd_sym_c,
3848 include_directories : includes,
3849 link_with : [libsystemd],
3850 build_by_default : want_tests != 'false',
3851 install : install_tests,
3852 install_dir : testsdir)
3853 if want_tests != 'false'
3854 test('test-libsystemd-sym', exe)
3855 endif
3856
3857 exe = executable(
3858 'test-libsystemd-static-sym',
3859 test_libsystemd_sym_c,
3860 include_directories : includes,
3861 link_with : [install_libsystemd_static],
3862 dependencies : [threads], # threads is already included in dependencies on the library,
3863 # but does not seem to get propagated. Add here as a work-around.
3864 build_by_default : want_tests != 'false' and static_libsystemd_pic,
3865 install : install_tests and static_libsystemd_pic,
3866 install_dir : testsdir)
3867 if want_tests != 'false' and static_libsystemd_pic
3868 test('test-libsystemd-static-sym', exe)
3869 endif
3870
3871 exe = executable(
3872 'test-libudev-sym',
3873 test_libudev_sym_c,
3874 include_directories : libudev_includes,
3875 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
3876 link_with : [libudev],
3877 build_by_default : want_tests != 'false',
3878 install : install_tests,
3879 install_dir : testsdir)
3880 if want_tests != 'false'
3881 test('test-libudev-sym', exe)
3882 endif
3883
3884 exe = executable(
3885 'test-libudev-static-sym',
3886 test_libudev_sym_c,
3887 include_directories : libudev_includes,
3888 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
3889 link_with : [install_libudev_static],
3890 build_by_default : want_tests != 'false' and static_libudev_pic,
3891 install : install_tests and static_libudev_pic,
3892 install_dir : testsdir)
3893 if want_tests != 'false' and static_libudev_pic
3894 test('test-libudev-static-sym', exe)
3895 endif
3896
3897 ############################################################
3898
3899 fuzzer_exes = []
3900
3901 foreach tuple : fuzzers
3902 sources = tuple[0]
3903 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3904 dependencies = tuple.length() > 2 ? tuple[2] : []
3905 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3906 defs = tuple.length() > 4 ? tuple[4] : []
3907 link_args = []
3908
3909 if want_ossfuzz
3910 dependencies += fuzzing_engine
3911 elif want_libfuzzer
3912 if fuzzing_engine.found()
3913 dependencies += fuzzing_engine
3914 else
3915 link_args += ['-fsanitize=fuzzer']
3916 endif
3917 else
3918 sources += 'src/fuzz/fuzz-main.c'
3919 endif
3920
3921 # FIXME: Use fs.stem() with meson >= 0.54.0
3922 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
3923
3924 exe = executable(
3925 name,
3926 sources,
3927 include_directories : [incs, include_directories('src/fuzz')],
3928 link_with : link_with,
3929 dependencies : dependencies,
3930 c_args : defs + test_cflags,
3931 link_args: link_args,
3932 install : false,
3933 build_by_default : fuzzer_build)
3934 fuzzer_exes += exe
3935
3936 if want_tests != 'false'
3937 # Run the fuzz regression tests without any sanitizers enabled.
3938 # Additional invocations with sanitizers may be added below.
3939 foreach p : fuzz_regression_tests
3940 b = p.split('/')[-2]
3941 c = p.split('/')[-1]
3942
3943 if b == name
3944 test('@0@_@1@'.format(b, c),
3945 exe,
3946 suite : 'fuzzers',
3947 args : [project_source_root / p])
3948 endif
3949 endforeach
3950 endif
3951 endforeach
3952
3953 alias_target('fuzzers', fuzzer_exes)
3954
3955 ############################################################
3956
3957 subdir('modprobe.d')
3958 subdir('sysctl.d')
3959 subdir('sysusers.d')
3960 subdir('tmpfiles.d')
3961 subdir('hwdb.d')
3962 subdir('units')
3963 subdir('presets')
3964 subdir('network')
3965 subdir('man')
3966 subdir('shell-completion/bash')
3967 subdir('shell-completion/zsh')
3968 subdir('docs/sysvinit')
3969 subdir('docs/var-log')
3970
3971 install_subdir('factory/etc',
3972 install_dir : factorydir)
3973 subdir('factory/templates')
3974
3975 if install_sysconfdir
3976 install_data('xorg/50-systemd-user.sh',
3977 install_dir : xinitrcdir)
3978 endif
3979 install_data('LICENSE.GPL2',
3980 'LICENSE.LGPL2.1',
3981 'NEWS',
3982 'README',
3983 'docs/CODING_STYLE.md',
3984 'docs/DISTRO_PORTING.md',
3985 'docs/ENVIRONMENT.md',
3986 'docs/HACKING.md',
3987 'docs/TRANSIENT-SETTINGS.md',
3988 'docs/TRANSLATORS.md',
3989 'docs/UIDS-GIDS.md',
3990 install_dir : docdir)
3991
3992 install_subdir('LICENSES',
3993 install_dir : docdir)
3994
3995 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
3996 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
3997
3998 ############################################################
3999
4000 # Ensure that changes to the docs/ directory do not break the
4001 # basic Github pages build. But only run it in developer mode,
4002 # as it might be fragile due to changes in the tooling, and it is
4003 # not generally useful for users.
4004 jekyll = find_program('jekyll', required : false)
4005 if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
4006 test('github-pages',
4007 jekyll,
4008 suite : 'dist-check',
4009 args : ['build',
4010 '--source', project_source_root / 'docs',
4011 '--destination', project_build_root / '_site'])
4012 endif
4013
4014 ############################################################
4015
4016 check_help = find_program('tools/check-help.sh')
4017 check_version = find_program('tools/check-version.sh')
4018
4019 foreach exec : public_programs
4020 name = exec.full_path().split('/')[-1]
4021 if want_tests != 'false'
4022 test('check-help-' + name,
4023 check_help,
4024 suite : 'dist-check',
4025 args : exec.full_path(),
4026 depends: exec)
4027
4028 test('check-version-' + name,
4029 check_version,
4030 suite : 'dist-check',
4031 args : [exec.full_path(),
4032 meson.project_version()],
4033 depends: exec)
4034 endif
4035 endforeach
4036
4037 ############################################################
4038
4039 check_directives_sh = find_program('tools/check-directives.sh')
4040
4041 if want_tests != 'false'
4042 test('check-directives',
4043 check_directives_sh,
4044 suite : 'dist-check',
4045 args : [project_source_root, project_build_root])
4046 endif
4047
4048 ############################################################
4049
4050 # Enable tests for all supported sanitizers
4051 foreach tuple : sanitizers
4052 sanitizer = tuple[0]
4053 build = tuple[1]
4054
4055 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
4056 prev = ''
4057 foreach p : fuzz_regression_tests
4058 b = p.split('/')[-2]
4059 c = p.split('/')[-1]
4060
4061 name = '@0@:@1@'.format(b, sanitizer)
4062
4063 if name != prev
4064 if want_tests == 'false'
4065 message('Not compiling @0@ because tests is set to false'.format(name))
4066 elif fuzz_tests
4067 exe = custom_target(
4068 name,
4069 output : name,
4070 depends : build,
4071 command : [ln, '-fs',
4072 build.full_path() / b,
4073 '@OUTPUT@'],
4074 build_by_default : true)
4075 else
4076 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
4077 endif
4078 endif
4079 prev = name
4080
4081 if fuzz_tests
4082 test('@0@_@1@_@2@'.format(b, c, sanitizer),
4083 env,
4084 suite : 'fuzz+san',
4085 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
4086 timeout : 60,
4087 args : [exe.full_path(),
4088 project_source_root / p])
4089 endif
4090 endforeach
4091 endif
4092 endforeach
4093
4094
4095 ############################################################
4096
4097 if git.found()
4098 all_files = run_command(
4099 env, '-u', 'GIT_WORK_TREE',
4100 git, '--git-dir=@0@/.git'.format(project_source_root),
4101 'ls-files', ':/*.[ch]',
4102 check : false)
4103 if all_files.returncode() == 0
4104 all_files = files(all_files.stdout().split())
4105
4106 custom_target(
4107 'tags',
4108 output : 'tags',
4109 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
4110 run_target(
4111 'ctags',
4112 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
4113 endif
4114 endif
4115
4116 if git.found()
4117 git_contrib_sh = find_program('tools/git-contrib.sh')
4118 run_target(
4119 'git-contrib',
4120 command : [git_contrib_sh])
4121 endif
4122
4123 if git.found()
4124 git_head = run_command(
4125 git, '--git-dir=@0@/.git'.format(project_source_root),
4126 'rev-parse', 'HEAD',
4127 check : false).stdout().strip()
4128 git_head_short = run_command(
4129 git, '--git-dir=@0@/.git'.format(project_source_root),
4130 'rev-parse', '--short=7', 'HEAD',
4131 check : false).stdout().strip()
4132
4133 run_target(
4134 'git-snapshot',
4135 command : [git, 'archive',
4136 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
4137 git_head_short),
4138 '--prefix', 'systemd-@0@/'.format(git_head),
4139 'HEAD'])
4140 endif
4141
4142 ############################################################
4143
4144 check_api_docs_sh = find_program('tools/check-api-docs.sh')
4145 run_target(
4146 'check-api-docs',
4147 depends : [man, libsystemd, libudev],
4148 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
4149
4150 alias_target('update-dbus-docs', update_dbus_docs)
4151 alias_target('update-man-rules', update_man_rules)
4152
4153 if not meson.is_cross_build()
4154 custom_target(
4155 'export-dbus-interfaces',
4156 output : fs.name(dbus_interfaces_dir),
4157 install : dbus_interfaces_dir != 'no',
4158 install_dir : fs.parent(dbus_interfaces_dir),
4159 command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
4160 endif
4161
4162 ############################################################
4163
4164 alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
4165 check : true).stdout().strip()
4166
4167 summary({
4168 'split /usr' : split_usr,
4169 'split bin-sbin' : split_bin,
4170 'prefix directory' : prefixdir,
4171 'rootprefix directory' : rootprefixdir,
4172 'sysconf directory' : sysconfdir,
4173 'include directory' : includedir,
4174 'lib directory' : libdir,
4175 'rootlib directory' : rootlibdir,
4176 'SysV init scripts' : sysvinit_path,
4177 'SysV rc?.d directories' : sysvrcnd_path,
4178 'PAM modules directory' : pamlibdir,
4179 'PAM configuration directory' : pamconfdir,
4180 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
4181 'RPM macros directory' : rpmmacrosdir,
4182 'modprobe.d directory' : modprobedir,
4183 'D-Bus policy directory' : dbuspolicydir,
4184 'D-Bus session directory' : dbussessionservicedir,
4185 'D-Bus system directory' : dbussystemservicedir,
4186 'D-Bus interfaces directory' : dbus_interfaces_dir,
4187 'bash completions directory' : bashcompletiondir,
4188 'zsh completions directory' : zshcompletiondir,
4189 'private shared lib version tag' : shared_lib_tag,
4190 'extra start script' : get_option('rc-local'),
4191 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
4192 get_option('debug-tty')),
4193 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
4194 conf.get('SYSTEM_ALLOC_UID_MIN')),
4195 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
4196 conf.get('SYSTEM_ALLOC_GID_MIN')),
4197 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
4198 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
4199 'static UID/GID allocations' : ' '.join(static_ugids),
4200 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
4201 'render group access mode' : get_option('group-render-mode'),
4202 'certificate root directory' : get_option('certificate-root'),
4203 'support URL' : support_url,
4204 'nobody user name' : nobody_user,
4205 'nobody group name' : nobody_group,
4206 'fallback hostname' : get_option('fallback-hostname'),
4207 'default compression method' : compression,
4208 'default DNSSEC mode' : default_dnssec,
4209 'default DNS-over-TLS mode' : default_dns_over_tls,
4210 'default mDNS mode' : default_mdns,
4211 'default LLMNR mode' : default_llmnr,
4212 'default DNS servers' : dns_servers.split(' '),
4213 'default NTP servers' : ntp_servers.split(' '),
4214 'default cgroup hierarchy' : default_hierarchy,
4215 'default net.naming-scheme value' : default_net_naming_scheme,
4216 'default KillUserProcesses value' : kill_user_processes,
4217 'default locale' : default_locale,
4218 'default nspawn locale' : nspawn_locale,
4219 'default status unit format' : status_unit_format_default,
4220 'default user $PATH' :
4221 default_user_path != '' ? default_user_path : '(same as system services)',
4222 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
4223 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
4224
4225 # TODO:
4226 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
4227 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
4228 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
4229
4230 found = []
4231 missing = []
4232
4233 foreach tuple : [
4234 # dependencies
4235 ['ACL'],
4236 ['AUDIT'],
4237 ['AppArmor'],
4238 ['IMA'],
4239 ['PAM'],
4240 ['SECCOMP'],
4241 ['SELinux'],
4242 ['SMACK'],
4243 ['blkid'],
4244 ['elfutils'],
4245 ['gcrypt'],
4246 ['gnutls'],
4247 ['libbpf'],
4248 ['libcryptsetup'],
4249 ['libcryptsetup-plugins'],
4250 ['libcurl'],
4251 ['libfdisk'],
4252 ['libfido2'],
4253 ['libidn'],
4254 ['libidn2'],
4255 ['libiptc'],
4256 ['microhttpd'],
4257 ['openssl'],
4258 ['p11kit'],
4259 ['pcre2'],
4260 ['pwquality'],
4261 ['qrencode'],
4262 ['tpm2'],
4263 ['xkbcommon'],
4264
4265 # compression libs
4266 ['zstd'],
4267 ['lz4'],
4268 ['xz'],
4269 ['zlib'],
4270 ['bzip2'],
4271
4272 # components
4273 ['backlight'],
4274 ['binfmt'],
4275 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
4276 ['coredump'],
4277 ['environment.d'],
4278 ['efi'],
4279 ['gnu-efi'],
4280 ['firstboot'],
4281 ['hibernate'],
4282 ['homed'],
4283 ['hostnamed'],
4284 ['hwdb'],
4285 ['importd'],
4286 ['initrd'],
4287 ['kernel-install'],
4288 ['localed'],
4289 ['logind'],
4290 ['machined'],
4291 ['networkd'],
4292 ['nss-myhostname'],
4293 ['nss-mymachines'],
4294 ['nss-resolve'],
4295 ['nss-systemd'],
4296 ['oomd'],
4297 ['portabled'],
4298 ['pstore'],
4299 ['quotacheck'],
4300 ['randomseed'],
4301 ['repart'],
4302 ['resolve'],
4303 ['rfkill'],
4304 ['sysext'],
4305 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
4306 ['sysupdate'],
4307 ['sysusers'],
4308 ['timedated'],
4309 ['timesyncd'],
4310 ['tmpfiles'],
4311 ['userdb'],
4312 ['vconsole'],
4313 ['xdg-autostart'],
4314
4315 # optional features
4316 ['idn'],
4317 ['polkit'],
4318 ['nscd'],
4319 ['legacy-pkla', install_polkit_pkla],
4320 ['kmod'],
4321 ['dbus'],
4322 ['glib'],
4323 ['tpm'],
4324 ['man pages', want_man],
4325 ['html pages', want_html],
4326 ['man page indices', want_man and have_lxml],
4327 ['SysV compat'],
4328 ['compat-mutable-uid-boundaries'],
4329 ['utmp'],
4330 ['ldconfig'],
4331 ['adm group', get_option('adm-group')],
4332 ['wheel group', get_option('wheel-group')],
4333 ['gshadow'],
4334 ['debug hashmap'],
4335 ['debug mmap cache'],
4336 ['debug siphash'],
4337 ['valgrind', conf.get('VALGRIND') == 1],
4338 ['trace logging', conf.get('LOG_TRACE') == 1],
4339 ['install tests', install_tests],
4340 ['link-udev-shared', get_option('link-udev-shared')],
4341 ['link-systemctl-shared', get_option('link-systemctl-shared')],
4342 ['link-networkd-shared', get_option('link-networkd-shared')],
4343 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
4344 ['link-boot-shared', get_option('link-boot-shared')],
4345 ['first-boot-full-preset'],
4346 ['fexecve'],
4347 ['standalone-binaries', get_option('standalone-binaries')],
4348 ['coverage', get_option('b_coverage')],
4349 ]
4350
4351 if tuple.length() >= 2
4352 cond = tuple[1]
4353 else
4354 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
4355 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
4356 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
4357 endif
4358 if cond
4359 found += tuple[0]
4360 else
4361 missing += tuple[0]
4362 endif
4363 endforeach
4364
4365 if static_libsystemd == 'false'
4366 missing += 'static-libsystemd'
4367 else
4368 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
4369 endif
4370
4371 if static_libudev == 'false'
4372 missing += 'static-libudev'
4373 else
4374 found += 'static-libudev(@0@)'.format(static_libudev)
4375 endif
4376
4377 if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
4378 found += 'cryptolib(openssl)'
4379 elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
4380 found += 'cryptolib(gcrypt)'
4381 else
4382 missing += 'cryptolib'
4383 endif
4384
4385 if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
4386 found += 'DNS-over-TLS(gnutls)'
4387 elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
4388 found += 'DNS-over-TLS(openssl)'
4389 else
4390 missing += 'DNS-over-TLS'
4391 endif
4392
4393 summary({
4394 'enabled' : ', '.join(found),
4395 'disabled' : ', '.join(missing)},
4396 section : 'Features')
4397
4398 if rootprefixdir != rootprefix_default
4399 warning('\n' +
4400 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
4401 'systemd used fixed names for unit file directories and other paths, so anything\n' +
4402 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))
4403 endif