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