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