]> git.ipfire.org Git - thirdparty/systemd.git/blob - meson.build
Merge pull request #27830 from 1awesomeJ/initrd
[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.60.0',
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', native : false, 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', 1)
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_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
537 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.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.full_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 threads = dependency('threads')
1060 librt = cc.find_library('rt')
1061 libm = cc.find_library('m')
1062 libdl = cc.find_library('dl')
1063 libcrypt = cc.find_library('crypt')
1064
1065 # On some architectures, libatomic is required. But on some installations,
1066 # it is found, but actual linking fails. So let's try to use it opportunistically.
1067 # If it is installed, but not needed, it will be dropped because of --as-needed.
1068 if cc.links('''int main(int argc, char **argv) { return 0; }''',
1069 args : '-latomic',
1070 name : 'libatomic')
1071 libatomic = declare_dependency(link_args : '-latomic')
1072 else
1073 libatomic = []
1074 endif
1075
1076 crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
1077 foreach ident : [
1078 ['crypt_ra', crypt_header],
1079 ['crypt_preferred_method', crypt_header],
1080 ['crypt_gensalt_ra', crypt_header]]
1081
1082 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
1083 dependencies : libcrypt)
1084 conf.set10('HAVE_' + ident[0].to_upper(), have)
1085 endforeach
1086
1087 libcap = dependency('libcap', required : false)
1088 if not libcap.found()
1089 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
1090 libcap = cc.find_library('cap')
1091 endif
1092
1093 want_bpf_framework = get_option('bpf-framework')
1094 bpf_compiler = get_option('bpf-compiler')
1095 bpf_framework_required = want_bpf_framework == 'true'
1096
1097 libbpf_version_requirement = '>= 0.1.0'
1098 if bpf_compiler == 'gcc'
1099 libbpf_version_requirement = '>= 1.0.0'
1100 endif
1101 libbpf = dependency('libbpf', required : bpf_framework_required, version : libbpf_version_requirement)
1102 conf.set10('HAVE_LIBBPF', libbpf.found())
1103
1104 bpftool_strip_version_requirement = '>= 5.13.0'
1105 if bpf_compiler == 'gcc'
1106 bpftool_strip_version_requirement = '>= 7.0.0'
1107 endif
1108
1109 if want_bpf_framework == 'false' or not libbpf.found() or skip_deps
1110 conf.set10('BPF_FRAMEWORK', false)
1111 else
1112 clang_found = false
1113 clang_supports_bpf = false
1114 bpf_gcc_found = false
1115 bpftool_strip = false
1116 deps_found = false
1117
1118 if bpf_compiler == 'clang'
1119 # Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu
1120 # (like clang-10/llvm-strip-10)
1121 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')
1122 r = find_program('clang', required : bpf_framework_required, version : '>= 10.0.0')
1123 clang_found = r.found()
1124 if clang_found
1125 clang = r.full_path()
1126 endif
1127 else
1128 clang_found = true
1129 clang = cc.cmd_array()
1130 endif
1131
1132 if clang_found
1133 # Check if 'clang -target bpf' is supported.
1134 clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0
1135 endif
1136 elif bpf_compiler == 'gcc'
1137 bpf_gcc = find_program('bpf-gcc',
1138 'bpf-none-gcc',
1139 required : true,
1140 version : '>= 13.1.0')
1141 bpf_gcc_found = bpf_gcc.found()
1142 endif
1143
1144 if clang_supports_bpf or bpf_gcc_found
1145 # Debian installs this in /usr/sbin/ which is not in $PATH.
1146 # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian.
1147 # We use 'bpftool gen object' subcommand for bpftool strip, it was added by d80b2fcbe0a023619e0fc73112f2a02c2662f6ab (v5.13).
1148 bpftool_strip_required = bpf_framework_required and bpf_compiler == 'gcc'
1149 bpftool = find_program('bpftool',
1150 '/usr/sbin/bpftool',
1151 required : bpftool_strip_required,
1152 version : bpftool_strip_version_requirement)
1153
1154 if bpftool.found()
1155 bpftool_strip = true
1156 deps_found = true
1157 elif bpf_compiler == 'clang'
1158 # We require the 'bpftool gen skeleton' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6).
1159 bpftool = find_program('bpftool',
1160 '/usr/sbin/bpftool',
1161 required : bpf_framework_required,
1162 version : '>= 5.6.0')
1163 endif
1164
1165 # We use `llvm-strip` as a fallback if `bpftool gen object` strip support is not available.
1166 if not bpftool_strip and bpftool.found() and clang_supports_bpf
1167 if not meson.is_cross_build()
1168 llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip',
1169 check : true).stdout().strip()
1170 else
1171 llvm_strip_bin = 'llvm-strip'
1172 endif
1173 llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0')
1174 deps_found = llvm_strip.found()
1175 endif
1176 endif
1177
1178 # Can build BPF program from source code in restricted C
1179 conf.set10('BPF_FRAMEWORK', deps_found)
1180 endif
1181
1182 libmount = dependency('mount',
1183 version : fuzzer_build ? '>= 0' : '>= 2.30')
1184
1185 want_libfdisk = get_option('fdisk')
1186 if want_libfdisk != 'false' and not skip_deps
1187 libfdisk = dependency('fdisk',
1188 version : '>= 2.32',
1189 required : want_libfdisk == 'true')
1190 have = libfdisk.found()
1191 else
1192 have = false
1193 libfdisk = []
1194 endif
1195 conf.set10('HAVE_LIBFDISK', have)
1196
1197 want_pwquality = get_option('pwquality')
1198 if want_pwquality != 'false' and not skip_deps
1199 libpwquality = dependency('pwquality',
1200 version : '>= 1.4.1',
1201 required : want_pwquality == 'true')
1202 have = libpwquality.found()
1203 else
1204 have = false
1205 libpwquality = []
1206 endif
1207 conf.set10('HAVE_PWQUALITY', have)
1208
1209 want_seccomp = get_option('seccomp')
1210 if want_seccomp != 'false' and not skip_deps
1211 libseccomp = dependency('libseccomp',
1212 version : '>= 2.3.1',
1213 required : want_seccomp == 'true')
1214 have = libseccomp.found()
1215 else
1216 have = false
1217 libseccomp = []
1218 endif
1219 conf.set10('HAVE_SECCOMP', have)
1220
1221 want_selinux = get_option('selinux')
1222 if want_selinux != 'false' and not skip_deps
1223 libselinux = dependency('libselinux',
1224 version : '>= 2.1.9',
1225 required : want_selinux == 'true')
1226 have = libselinux.found()
1227 else
1228 have = false
1229 libselinux = []
1230 endif
1231 conf.set10('HAVE_SELINUX', have)
1232
1233 want_apparmor = get_option('apparmor')
1234 if want_apparmor != 'false' and not skip_deps
1235 libapparmor = dependency('libapparmor',
1236 version : '>= 2.13',
1237 required : want_apparmor == 'true')
1238 have = libapparmor.found()
1239 else
1240 have = false
1241 libapparmor = []
1242 endif
1243 conf.set10('HAVE_APPARMOR', have)
1244
1245 have = get_option('smack') and get_option('smack-run-label') != ''
1246 conf.set10('HAVE_SMACK_RUN_LABEL', have)
1247 if have
1248 conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
1249 endif
1250
1251 have = get_option('smack') and get_option('smack-default-process-label') != ''
1252 if have
1253 conf.set_quoted('SMACK_DEFAULT_PROCESS_LABEL', get_option('smack-default-process-label'))
1254 endif
1255
1256 want_polkit = get_option('polkit')
1257 install_polkit = false
1258 install_polkit_pkla = false
1259 if want_polkit != 'false' and not skip_deps
1260 install_polkit = true
1261
1262 libpolkit = dependency('polkit-gobject-1',
1263 required : false)
1264 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
1265 message('Old polkit detected, will install pkla files')
1266 install_polkit_pkla = true
1267 endif
1268 endif
1269 conf.set10('ENABLE_POLKIT', install_polkit)
1270
1271 want_acl = get_option('acl')
1272 if want_acl != 'false' and not skip_deps
1273 libacl = cc.find_library('acl', required : want_acl == 'true')
1274 have = libacl.found()
1275 else
1276 have = false
1277 libacl = []
1278 endif
1279 conf.set10('HAVE_ACL', have)
1280
1281 want_audit = get_option('audit')
1282 if want_audit != 'false' and not skip_deps
1283 libaudit = dependency('audit', required : want_audit == 'true')
1284 have = libaudit.found()
1285 else
1286 have = false
1287 libaudit = []
1288 endif
1289 conf.set10('HAVE_AUDIT', have)
1290
1291 want_blkid = get_option('blkid')
1292 if want_blkid != 'false' and not skip_deps
1293 libblkid = dependency('blkid', required : want_blkid == 'true')
1294 have = libblkid.found()
1295
1296 conf.set10('HAVE_BLKID_PROBE_SET_HINT',
1297 have and cc.has_function('blkid_probe_set_hint', dependencies : libblkid))
1298 else
1299 have = false
1300 libblkid = []
1301 endif
1302 conf.set10('HAVE_BLKID', have)
1303
1304 want_kmod = get_option('kmod')
1305 if want_kmod != 'false' and not skip_deps
1306 libkmod = dependency('libkmod',
1307 version : '>= 15',
1308 required : want_kmod == 'true')
1309 have = libkmod.found()
1310 else
1311 have = false
1312 libkmod = []
1313 endif
1314 conf.set10('HAVE_KMOD', have)
1315
1316 want_xenctrl = get_option('xenctrl')
1317 if want_xenctrl != 'false' and not skip_deps
1318 libxenctrl = dependency('xencontrol',
1319 version : '>= 4.9',
1320 required : want_xenctrl == 'true')
1321 have = libxenctrl.found()
1322 else
1323 have = false
1324 libxenctrl = []
1325 endif
1326 conf.set10('HAVE_XENCTRL', have)
1327
1328 want_pam = get_option('pam')
1329 if want_pam != 'false' and not skip_deps
1330 libpam = cc.find_library('pam', required : want_pam == 'true')
1331 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1332 have = libpam.found() and libpam_misc.found()
1333 else
1334 have = false
1335 libpam = []
1336 libpam_misc = []
1337 endif
1338 conf.set10('HAVE_PAM', have)
1339
1340 want_microhttpd = get_option('microhttpd')
1341 if want_microhttpd != 'false' and not skip_deps
1342 libmicrohttpd = dependency('libmicrohttpd',
1343 version : '>= 0.9.33',
1344 required : want_microhttpd == 'true')
1345 have = libmicrohttpd.found()
1346 else
1347 have = false
1348 libmicrohttpd = []
1349 endif
1350 conf.set10('HAVE_MICROHTTPD', have)
1351
1352 want_libcryptsetup = get_option('libcryptsetup')
1353 want_libcryptsetup_plugins = get_option('libcryptsetup-plugins')
1354
1355 if want_libcryptsetup_plugins == 'true' and want_libcryptsetup == 'false'
1356 error('libcryptsetup-plugins can not be requested without libcryptsetup')
1357 endif
1358
1359 if want_libcryptsetup != 'false' and not skip_deps
1360 libcryptsetup = dependency('libcryptsetup',
1361 version : want_libcryptsetup_plugins == 'true' ? '>= 2.4.0' : '>= 2.0.1',
1362 required : want_libcryptsetup == 'true' or want_libcryptsetup_plugins == 'true')
1363 have = libcryptsetup.found()
1364
1365 foreach ident : ['crypt_set_metadata_size',
1366 'crypt_activate_by_signed_key',
1367 'crypt_token_max',
1368 'crypt_reencrypt_init_by_passphrase',
1369 'crypt_reencrypt',
1370 'crypt_set_data_offset']
1371 have_ident = have and cc.has_function(
1372 ident,
1373 prefix : '#include <libcryptsetup.h>',
1374 dependencies : libcryptsetup)
1375 conf.set10('HAVE_' + ident.to_upper(), have_ident)
1376 endforeach
1377 else
1378 have = false
1379 libcryptsetup = []
1380 endif
1381 conf.set10('HAVE_LIBCRYPTSETUP', have)
1382
1383 if want_libcryptsetup_plugins != 'false' and not skip_deps
1384 have = (cc.has_function(
1385 'crypt_activate_by_token_pin',
1386 prefix : '#include <libcryptsetup.h>',
1387 dependencies : libcryptsetup) and
1388 cc.has_function(
1389 'crypt_token_external_path',
1390 prefix : '#include <libcryptsetup.h>',
1391 dependencies : libcryptsetup))
1392 else
1393 have = false
1394 endif
1395 conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have)
1396
1397 want_libcurl = get_option('libcurl')
1398 if want_libcurl != 'false' and not skip_deps
1399 libcurl = dependency('libcurl',
1400 version : '>= 7.32.0',
1401 required : want_libcurl == 'true')
1402 have = libcurl.found()
1403 else
1404 have = false
1405 libcurl = []
1406 endif
1407 conf.set10('HAVE_LIBCURL', have)
1408 conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
1409
1410 want_libidn = get_option('libidn')
1411 want_libidn2 = get_option('libidn2')
1412 if want_libidn == 'true' and want_libidn2 == 'true'
1413 error('libidn and libidn2 cannot be requested simultaneously')
1414 endif
1415
1416 if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps
1417 libidn = dependency('libidn2',
1418 required : want_libidn2 == 'true')
1419 have = libidn.found()
1420 else
1421 have = false
1422 libidn = []
1423 endif
1424 conf.set10('HAVE_LIBIDN2', have)
1425 if not have and want_libidn != 'false' and not skip_deps
1426 # libidn is used for both libidn and libidn2 objects
1427 libidn = dependency('libidn',
1428 required : want_libidn == 'true')
1429 have = libidn.found()
1430 else
1431 have = false
1432 endif
1433 conf.set10('HAVE_LIBIDN', have)
1434
1435 want_libiptc = get_option('libiptc')
1436 if want_libiptc != 'false' and not skip_deps
1437 libiptc = dependency('libiptc',
1438 required : want_libiptc == 'true')
1439 have = libiptc.found()
1440 else
1441 have = false
1442 libiptc = []
1443 endif
1444 conf.set10('HAVE_LIBIPTC', have)
1445
1446 want_qrencode = get_option('qrencode')
1447 if want_qrencode != 'false' and not skip_deps
1448 libqrencode = dependency('libqrencode',
1449 version : '>= 3',
1450 required : want_qrencode == 'true')
1451 have = libqrencode.found()
1452 else
1453 have = false
1454 libqrencode = []
1455 endif
1456 conf.set10('HAVE_QRENCODE', have)
1457
1458 want_gcrypt = get_option('gcrypt')
1459 if want_gcrypt != 'false' and not skip_deps
1460 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1461 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1462 have = libgcrypt.found() and libgpg_error.found()
1463 else
1464 have = false
1465 endif
1466 if not have
1467 # link to neither of the libs if one is not found
1468 libgcrypt = []
1469 libgpg_error = []
1470 endif
1471 conf.set10('HAVE_GCRYPT', have)
1472
1473 want_gnutls = get_option('gnutls')
1474 if want_gnutls != 'false' and not skip_deps
1475 libgnutls = dependency('gnutls',
1476 version : '>= 3.1.4',
1477 required : want_gnutls == 'true')
1478 have = libgnutls.found()
1479 else
1480 have = false
1481 libgnutls = []
1482 endif
1483 conf.set10('HAVE_GNUTLS', have)
1484
1485 want_openssl = get_option('openssl')
1486 if want_openssl != 'false' and not skip_deps
1487 libopenssl = dependency('openssl',
1488 version : '>= 1.1.0',
1489 required : want_openssl == 'true')
1490 have = libopenssl.found()
1491 else
1492 have = false
1493 libopenssl = []
1494 endif
1495 conf.set10('HAVE_OPENSSL', have)
1496
1497 want_p11kit = get_option('p11kit')
1498 if want_p11kit != 'false' and not skip_deps
1499 libp11kit = dependency('p11-kit-1',
1500 version : '>= 0.23.3',
1501 required : want_p11kit == 'true')
1502 have = libp11kit.found()
1503 libp11kit_cflags = libp11kit.partial_dependency(includes: true, compile_args: true)
1504 else
1505 have = false
1506 libp11kit_cflags = []
1507 libp11kit = []
1508 endif
1509 conf.set10('HAVE_P11KIT', have)
1510
1511 want_libfido2 = get_option('libfido2')
1512 if want_libfido2 != 'false' and not skip_deps
1513 if conf.get('HAVE_OPENSSL') == 1
1514 libfido2 = dependency('libfido2',
1515 required : want_libfido2 == 'true')
1516 have = libfido2.found()
1517 elif want_libfido2 == 'true'
1518 error('libfido2=true requires openssl')
1519 else
1520 have = false
1521 libfido2 = []
1522 endif
1523 else
1524 have = false
1525 libfido2 = []
1526 endif
1527 conf.set10('HAVE_LIBFIDO2', have)
1528
1529 want_tpm2 = get_option('tpm2')
1530 if want_tpm2 != 'false' and not skip_deps
1531 tpm2 = dependency('tss2-esys tss2-rc tss2-mu tss2-tcti-device',
1532 required : want_tpm2 == 'true')
1533 have = tpm2.found()
1534 have_esys3 = tpm2.version().version_compare('>= 3.0.0')
1535 else
1536 have = false
1537 have_esys3 = false
1538 tpm2 = []
1539 endif
1540 conf.set10('HAVE_TPM2', have)
1541 conf.set10('HAVE_TSS2_ESYS3', have_esys3)
1542
1543 want_elfutils = get_option('elfutils')
1544 if want_elfutils != 'false' and not skip_deps
1545 libdw = dependency('libdw',
1546 required : want_elfutils == 'true')
1547 have = libdw.found()
1548
1549 # New in elfutils 0.177
1550 conf.set10('HAVE_DWELF_ELF_E_MACHINE_STRING',
1551 have and cc.has_function('dwelf_elf_e_machine_string', dependencies : libdw))
1552 else
1553 have = false
1554 libdw = []
1555 endif
1556 conf.set10('HAVE_ELFUTILS', have)
1557
1558 want_zlib = get_option('zlib')
1559 if want_zlib != 'false' and not skip_deps
1560 libz = dependency('zlib',
1561 required : want_zlib == 'true')
1562 have = libz.found()
1563 else
1564 have = false
1565 libz = []
1566 endif
1567 conf.set10('HAVE_ZLIB', have)
1568
1569 want_bzip2 = get_option('bzip2')
1570 if want_bzip2 != 'false' and not skip_deps
1571 libbzip2 = cc.find_library('bz2',
1572 required : want_bzip2 == 'true')
1573 have = libbzip2.found()
1574 else
1575 have = false
1576 libbzip2 = []
1577 endif
1578 conf.set10('HAVE_BZIP2', have)
1579
1580 want_xz = get_option('xz')
1581 if want_xz != 'false' and not skip_deps
1582 libxz = dependency('liblzma',
1583 required : want_xz == 'true')
1584 have_xz = libxz.found()
1585 else
1586 have_xz = false
1587 libxz = []
1588 endif
1589 conf.set10('HAVE_XZ', have_xz)
1590
1591 want_lz4 = get_option('lz4')
1592 if want_lz4 != 'false' and not skip_deps
1593 liblz4 = dependency('liblz4',
1594 version : '>= 1.3.0',
1595 required : want_lz4 == 'true')
1596 have_lz4 = liblz4.found()
1597 else
1598 have_lz4 = false
1599 liblz4 = []
1600 endif
1601 conf.set10('HAVE_LZ4', have_lz4)
1602
1603 want_zstd = get_option('zstd')
1604 if want_zstd != 'false' and not skip_deps
1605 libzstd = dependency('libzstd',
1606 required : want_zstd == 'true',
1607 version : '>= 1.4.0')
1608 have_zstd = libzstd.found()
1609 else
1610 have_zstd = false
1611 libzstd = []
1612 endif
1613 conf.set10('HAVE_ZSTD', have_zstd)
1614
1615 conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
1616
1617 compression = get_option('default-compression')
1618 if compression == 'auto'
1619 if have_zstd
1620 compression = 'zstd'
1621 elif have_lz4
1622 compression = 'lz4'
1623 elif have_xz
1624 compression = 'xz'
1625 else
1626 compression = 'none'
1627 endif
1628 elif compression == 'zstd' and not have_zstd
1629 error('default-compression=zstd requires zstd')
1630 elif compression == 'lz4' and not have_lz4
1631 error('default-compression=lz4 requires lz4')
1632 elif compression == 'xz' and not have_xz
1633 error('default-compression=xz requires xz')
1634 endif
1635 conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper()))
1636
1637 want_xkbcommon = get_option('xkbcommon')
1638 if want_xkbcommon != 'false' and not skip_deps
1639 libxkbcommon = dependency('xkbcommon',
1640 version : '>= 0.3.0',
1641 required : want_xkbcommon == 'true')
1642 have = libxkbcommon.found()
1643 else
1644 have = false
1645 libxkbcommon = []
1646 endif
1647 conf.set10('HAVE_XKBCOMMON', have)
1648
1649 want_pcre2 = get_option('pcre2')
1650 if want_pcre2 != 'false' and not skip_deps
1651 libpcre2 = dependency('libpcre2-8',
1652 required : want_pcre2 == 'true')
1653 have = libpcre2.found()
1654 else
1655 have = false
1656 libpcre2 = []
1657 endif
1658 conf.set10('HAVE_PCRE2', have)
1659
1660 want_glib = get_option('glib')
1661 if want_glib != 'false' and not skip_deps
1662 libglib = dependency('glib-2.0',
1663 version : '>= 2.22.0',
1664 required : want_glib == 'true')
1665 libgobject = dependency('gobject-2.0',
1666 version : '>= 2.22.0',
1667 required : want_glib == 'true')
1668 libgio = dependency('gio-2.0',
1669 required : want_glib == 'true')
1670 have = libglib.found() and libgobject.found() and libgio.found()
1671 else
1672 have = false
1673 libglib = []
1674 libgobject = []
1675 libgio = []
1676 endif
1677 conf.set10('HAVE_GLIB', have)
1678
1679 want_dbus = get_option('dbus')
1680 if want_dbus != 'false' and not skip_deps
1681 libdbus = dependency('dbus-1',
1682 version : '>= 1.3.2',
1683 required : want_dbus == 'true')
1684 have = libdbus.found()
1685 else
1686 have = false
1687 libdbus = []
1688 endif
1689 conf.set10('HAVE_DBUS', have)
1690
1691 dbusdatadir = datadir / 'dbus-1'
1692 if conf.get('HAVE_DBUS') == 1
1693 dbusdatadir = libdbus.get_variable(pkgconfig: 'datadir', default_value: datadir) / 'dbus-1'
1694 endif
1695
1696 dbuspolicydir = get_option('dbuspolicydir')
1697 if dbuspolicydir == ''
1698 dbuspolicydir = dbusdatadir / 'system.d'
1699 endif
1700
1701 dbussessionservicedir = get_option('dbussessionservicedir')
1702 if dbussessionservicedir == ''
1703 dbussessionservicedir = dbusdatadir / 'services'
1704 if conf.get('HAVE_DBUS') == 1
1705 dbussessionservicedir = libdbus.get_variable(pkgconfig: 'session_bus_services_dir', default_value: dbussessionservicedir)
1706 endif
1707 endif
1708
1709 dbussystemservicedir = get_option('dbussystemservicedir')
1710 if dbussystemservicedir == ''
1711 dbussystemservicedir = dbusdatadir / 'system-services'
1712 if conf.get('HAVE_DBUS') == 1
1713 dbussystemservicedir = libdbus.get_variable(pkgconfig: 'system_bus_services_dir', default_value: dbussystemservicedir)
1714 endif
1715 endif
1716
1717 dbus_interfaces_dir = get_option('dbus-interfaces-dir')
1718 if dbus_interfaces_dir == '' or dbus_interfaces_dir == 'yes'
1719 if meson.is_cross_build() and dbus_interfaces_dir != 'yes'
1720 dbus_interfaces_dir = 'no'
1721 warning('Exporting D-Bus interface XML files is disabled during cross build. Pass path or "yes" to force enable.')
1722 else
1723 dbus_interfaces_dir = dbusdatadir / 'interfaces'
1724 if conf.get('HAVE_DBUS') == 1
1725 dbus_interfaces_dir = libdbus.get_variable(pkgconfig: 'interfaces_dir', default_value: dbus_interfaces_dir)
1726 endif
1727 endif
1728 endif
1729
1730 # We support one or the other. If gcrypt is available, we assume it's there to
1731 # be used, and use it in preference.
1732 opt = get_option('cryptolib')
1733 if opt == 'openssl' and conf.get('HAVE_OPENSSL') == 0
1734 error('openssl requested as the default cryptolib, but not available')
1735 endif
1736 conf.set10('PREFER_OPENSSL',
1737 opt == 'openssl' or (opt == 'auto' and conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_GCRYPT') == 0))
1738 conf.set10('HAVE_OPENSSL_OR_GCRYPT',
1739 conf.get('HAVE_OPENSSL') == 1 or conf.get('HAVE_GCRYPT') == 1)
1740 lib_openssl_or_gcrypt = conf.get('PREFER_OPENSSL') == 1 ? [libopenssl] : [libgcrypt, libgpg_error]
1741
1742 dns_over_tls = get_option('dns-over-tls')
1743 if dns_over_tls != 'false'
1744 if dns_over_tls == 'gnutls' and conf.get('PREFER_OPENSSL') == 1
1745 error('Sorry, -Ddns-over-tls=gnutls is not supported when openssl is used as the cryptolib')
1746 endif
1747
1748 if dns_over_tls == 'gnutls'
1749 have_openssl = false
1750 else
1751 have_openssl = conf.get('HAVE_OPENSSL') == 1
1752 if dns_over_tls == 'openssl' and not have_openssl
1753 error('DNS-over-TLS support was requested with openssl, but dependencies are not available')
1754 endif
1755 endif
1756 if dns_over_tls == 'openssl' or have_openssl
1757 have_gnutls = false
1758 else
1759 have_gnutls = conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0')
1760 if dns_over_tls != 'auto' and not have_gnutls
1761 str = dns_over_tls == 'gnutls' ? ' with gnutls' : ''
1762 error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
1763 endif
1764 endif
1765 have = have_gnutls or have_openssl
1766 else
1767 have = false
1768 have_gnutls = false
1769 have_openssl = false
1770 endif
1771 conf.set10('ENABLE_DNS_OVER_TLS', have)
1772 conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1773 conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
1774
1775 default_dns_over_tls = get_option('default-dns-over-tls')
1776 if skip_deps
1777 default_dns_over_tls = 'no'
1778 endif
1779 if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
1780 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.')
1781 default_dns_over_tls = 'no'
1782 endif
1783 conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1784 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
1785 conf.set_quoted('DEFAULT_DNS_OVER_TLS_MODE_STR', default_dns_over_tls)
1786
1787 default_mdns = get_option('default-mdns')
1788 conf.set('DEFAULT_MDNS_MODE',
1789 'RESOLVE_SUPPORT_' + default_mdns.to_upper())
1790 conf.set_quoted('DEFAULT_MDNS_MODE_STR', default_mdns)
1791
1792 default_llmnr = get_option('default-llmnr')
1793 conf.set('DEFAULT_LLMNR_MODE',
1794 'RESOLVE_SUPPORT_' + default_llmnr.to_upper())
1795 conf.set_quoted('DEFAULT_LLMNR_MODE_STR', default_llmnr)
1796
1797 want_repart = get_option('repart')
1798 if want_repart != 'false'
1799 have = conf.get('HAVE_LIBFDISK') == 1
1800 if want_repart == 'true' and not have
1801 error('repart support was requested, but dependencies are not available')
1802 endif
1803 else
1804 have = false
1805 endif
1806 conf.set10('ENABLE_REPART', have)
1807
1808 default_dnssec = get_option('default-dnssec')
1809 if skip_deps
1810 default_dnssec = 'no'
1811 endif
1812 if default_dnssec != 'no' and conf.get('HAVE_OPENSSL_OR_GCRYPT') == 0
1813 message('default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.')
1814 default_dnssec = 'no'
1815 endif
1816 conf.set('DEFAULT_DNSSEC_MODE',
1817 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1818 conf.set_quoted('DEFAULT_DNSSEC_MODE_STR', default_dnssec)
1819
1820 want_sysupdate = get_option('sysupdate')
1821 if want_sysupdate != 'false'
1822 have = (conf.get('HAVE_OPENSSL') == 1 and
1823 conf.get('HAVE_LIBFDISK') == 1)
1824 if want_sysupdate == 'true' and not have
1825 error('sysupdate support was requested, but dependencies are not available')
1826 endif
1827 else
1828 have = false
1829 endif
1830 conf.set10('ENABLE_SYSUPDATE', have)
1831
1832 want_importd = get_option('importd')
1833 if want_importd != 'false'
1834 have = (conf.get('HAVE_LIBCURL') == 1 and
1835 conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and
1836 conf.get('HAVE_ZLIB') == 1 and
1837 conf.get('HAVE_XZ') == 1)
1838 if want_importd == 'true' and not have
1839 error('importd support was requested, but dependencies are not available')
1840 endif
1841 else
1842 have = false
1843 endif
1844 conf.set10('ENABLE_IMPORTD', have)
1845
1846 want_homed = get_option('homed')
1847 if want_homed != 'false'
1848 have = (conf.get('HAVE_OPENSSL') == 1 and
1849 conf.get('HAVE_LIBFDISK') == 1 and
1850 conf.get('HAVE_LIBCRYPTSETUP') == 1)
1851 if want_homed == 'true' and not have
1852 error('homed support was requested, but dependencies are not available')
1853 endif
1854 else
1855 have = false
1856 endif
1857 conf.set10('ENABLE_HOMED', have)
1858
1859 have = have and conf.get('HAVE_PAM') == 1
1860 conf.set10('ENABLE_PAM_HOME', have)
1861
1862 want_remote = get_option('remote')
1863 if want_remote != 'false'
1864 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1865 conf.get('HAVE_LIBCURL') == 1]
1866 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1867 # it's possible to build one without the other. Complain only if
1868 # support was explicitly requested. The auxiliary files like sysusers
1869 # config should be installed when any of the programs are built.
1870 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1871 error('remote support was requested, but dependencies are not available')
1872 endif
1873 have = have_deps[0] or have_deps[1]
1874 else
1875 have = false
1876 endif
1877 conf.set10('ENABLE_REMOTE', have)
1878
1879 foreach term : ['analyze',
1880 'backlight',
1881 'binfmt',
1882 'compat-mutable-uid-boundaries',
1883 'coredump',
1884 'efi',
1885 'environment-d',
1886 'firstboot',
1887 'gshadow',
1888 'hibernate',
1889 'hostnamed',
1890 'hwdb',
1891 'idn',
1892 'ima',
1893 'initrd',
1894 'kernel-install',
1895 'ldconfig',
1896 'localed',
1897 'logind',
1898 'machined',
1899 'networkd',
1900 'nscd',
1901 'nss-myhostname',
1902 'nss-systemd',
1903 'oomd',
1904 'portabled',
1905 'pstore',
1906 'quotacheck',
1907 'randomseed',
1908 'resolve',
1909 'rfkill',
1910 'smack',
1911 'sysext',
1912 'sysusers',
1913 'timedated',
1914 'timesyncd',
1915 'tmpfiles',
1916 'tpm',
1917 'userdb',
1918 'utmp',
1919 'vconsole',
1920 'xdg-autostart']
1921 have = get_option(term)
1922 name = 'ENABLE_' + term.underscorify().to_upper()
1923 conf.set10(name, have)
1924 endforeach
1925
1926 enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
1927
1928 foreach tuple : [['nss-mymachines', 'machined'],
1929 ['nss-resolve', 'resolve']]
1930 want = get_option(tuple[0])
1931 if want != 'false'
1932 have = get_option(tuple[1])
1933 if want == 'true' and not have
1934 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1935 endif
1936 else
1937 have = false
1938 endif
1939 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1940 conf.set10(name, have)
1941 endforeach
1942
1943 enable_nss = false
1944 foreach term : ['ENABLE_NSS_MYHOSTNAME',
1945 'ENABLE_NSS_MYMACHINES',
1946 'ENABLE_NSS_RESOLVE',
1947 'ENABLE_NSS_SYSTEMD']
1948 if conf.get(term) == 1
1949 enable_nss = true
1950 endif
1951 endforeach
1952 conf.set10('ENABLE_NSS', enable_nss)
1953
1954 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1955
1956 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1957
1958 ############################################################
1959
1960 tests = []
1961 simple_tests = []
1962 fuzzers = []
1963 simple_fuzzers = []
1964 catalogs = []
1965
1966 ############################################################
1967
1968 pymod = import('python')
1969 python = pymod.find_installation('python3', required : true, modules : ['jinja2'])
1970 python_39 = python.language_version().version_compare('>=3.9')
1971
1972 ############################################################
1973
1974 if conf.get('BPF_FRAMEWORK') == 1
1975 bpf_clang_flags = [
1976 '-std=gnu11',
1977 '-Wno-compare-distinct-pointer-types',
1978 '-fno-stack-protector',
1979 '-O2',
1980 '-target',
1981 'bpf',
1982 '-g',
1983 '-c',
1984 ]
1985
1986 bpf_gcc_flags = [
1987 '-std=gnu11',
1988 '-fno-stack-protector',
1989 '-O2',
1990 '-mkernel=5.2',
1991 '-mcpu=v3',
1992 '-mco-re',
1993 '-gbtf',
1994 '-c',
1995 ]
1996
1997 # Generate defines that are appropriate to tell the compiler what architecture
1998 # we're compiling for. By default we just map meson's cpu_family to __<cpu_family>__.
1999 # This dictionary contains the exceptions where this doesn't work.
2000 #
2001 # C.f. https://mesonbuild.com/Reference-tables.html#cpu-families
2002 # and src/basic/missing_syscall_def.h.
2003 cpu_arch_defines = {
2004 'ppc' : ['-D__powerpc__'],
2005 'ppc64' : ['-D__powerpc64__', '-D_CALL_ELF=2'],
2006 'riscv32' : ['-D__riscv', '-D__riscv_xlen=32'],
2007 'riscv64' : ['-D__riscv', '-D__riscv_xlen=64'],
2008 'x86' : ['-D__i386__'],
2009
2010 # For arm, assume hardware fp is available.
2011 'arm' : ['-D__arm__', '-D__ARM_PCS_VFP'],
2012 }
2013
2014 bpf_arch_flags = cpu_arch_defines.get(host_machine.cpu_family(),
2015 ['-D__@0@__'.format(host_machine.cpu_family())])
2016 if bpf_compiler == 'gcc'
2017 bpf_arch_flags += ['-m' + host_machine.endian() + '-endian']
2018 endif
2019
2020 libbpf_include_dir = libbpf.get_variable(pkgconfig : 'includedir')
2021
2022 bpf_o_unstripped_cmd = []
2023 if bpf_compiler == 'clang'
2024 bpf_o_unstripped_cmd += [
2025 clang,
2026 bpf_clang_flags,
2027 bpf_arch_flags,
2028 ]
2029 elif bpf_compiler == 'gcc'
2030 bpf_o_unstripped_cmd += [
2031 bpf_gcc,
2032 bpf_gcc_flags,
2033 bpf_arch_flags,
2034 ]
2035 endif
2036
2037 bpf_o_unstripped_cmd += ['-I.']
2038
2039 if not meson.is_cross_build() and bpf_compiler == 'clang'
2040 target_triplet_cmd = run_command('gcc', '-dumpmachine', check: false)
2041 if target_triplet_cmd.returncode() == 0
2042 target_triplet = target_triplet_cmd.stdout().strip()
2043 bpf_o_unstripped_cmd += [
2044 '-isystem',
2045 '/usr/include/@0@'.format(target_triplet)
2046 ]
2047 endif
2048 endif
2049
2050 bpf_o_unstripped_cmd += [
2051 '-idirafter',
2052 libbpf_include_dir,
2053 '@INPUT@',
2054 '-o',
2055 '@OUTPUT@'
2056 ]
2057
2058 if bpftool_strip
2059 bpf_o_cmd = [
2060 bpftool,
2061 'gen',
2062 'object',
2063 '@OUTPUT@',
2064 '@INPUT@'
2065 ]
2066 elif bpf_compiler == 'clang'
2067 bpf_o_cmd = [
2068 llvm_strip,
2069 '-g',
2070 '@INPUT@',
2071 '-o',
2072 '@OUTPUT@'
2073 ]
2074 endif
2075
2076 skel_h_cmd = [
2077 bpftool,
2078 'gen',
2079 'skeleton',
2080 '@INPUT@'
2081 ]
2082 endif
2083
2084 #####################################################################
2085
2086 efi_arch = {
2087 'aarch64' : 'aa64',
2088 'arm' : 'arm',
2089 'loongarch32' : 'loongarch32',
2090 'loongarch64' : 'loongarch64',
2091 'riscv32' : 'riscv32',
2092 'riscv64' : 'riscv64',
2093 'x86_64' : 'x64',
2094 'x86' : 'ia32',
2095 }.get(host_machine.cpu_family(), '')
2096
2097 if get_option('bootloader') != 'false' and efi_arch != ''
2098 conf.set_quoted('EFI_MACHINE_TYPE_NAME', efi_arch)
2099 elif get_option('bootloader') == 'true' and efi_arch == ''
2100 error('EFI not supported for this arch.')
2101 endif
2102
2103 efi_arch_alt = ''
2104 if efi_arch == 'x64' and cc.links('''
2105 #include <limits.h>
2106 int main(int argc, char *argv[]) {
2107 return __builtin_popcount(argc - CHAR_MAX);
2108 }''', args : ['-m32', '-march=i686'], name : '32bit build possible')
2109 efi_arch_alt = 'ia32'
2110 endif
2111
2112 have_pyelftools = pymod.find_installation('python3', required : false, modules : ['elftools']).found()
2113 if get_option('bootloader') == 'true' and (not python_39 or not have_pyelftools)
2114 error('EFI bootloader support requires Python >= 3.9 and pyelftools.')
2115 endif
2116
2117 conf.set10(
2118 'ENABLE_BOOTLOADER',
2119 get_option('efi') and
2120 get_option('bootloader') in ['auto', 'true'] and
2121 efi_arch != '' and
2122 python_39 and
2123 have_pyelftools,
2124 )
2125
2126 if get_option('ukify') == 'auto'
2127 want_ukify = python_39 and conf.get('ENABLE_BOOTLOADER') == 1
2128 elif get_option('ukify') == 'true' and (not python_39 or conf.get('ENABLE_BOOTLOADER') != 1)
2129 error('ukify requires Python >= 3.9 and -Dbootloader=true')
2130 else
2131 want_ukify = get_option('ukify') == 'true'
2132 endif
2133 conf.set10('ENABLE_UKIFY', want_ukify)
2134
2135 ############################################################
2136
2137 elf2efi_lds = project_source_root / 'tools/elf2efi.lds'
2138 elf2efi_py = find_program('tools/elf2efi.py')
2139 export_dbus_interfaces_py = find_program('tools/dbus_exporter.py')
2140 generate_gperfs = find_program('tools/generate-gperfs.py')
2141 make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
2142 make_directive_index_py = find_program('tools/make-directive-index.py')
2143 make_man_index_py = find_program('tools/make-man-index.py')
2144 meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
2145 update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
2146 update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
2147 update_hwdb_sh = find_program('tools/update-hwdb.sh')
2148 update_man_rules_py = find_program('tools/update-man-rules.py')
2149 update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
2150 xml_helper_py = find_program('tools/xml_helper.py')
2151
2152 ############################################################
2153
2154 if get_option('b_coverage')
2155 userspace_c_args += ['-include', 'src/basic/coverage.h']
2156 endif
2157
2158 ############################################################
2159
2160 config_h = configure_file(
2161 output : 'config.h',
2162 configuration : conf)
2163
2164 userspace_c_args += ['-include', 'config.h']
2165
2166 jinja2_cmdline = [meson_render_jinja2, config_h, version_h]
2167
2168 userspace = declare_dependency(
2169 compile_args : userspace_c_args,
2170 link_args : userspace_c_ld_args,
2171 )
2172
2173 man_page_depends = []
2174
2175 ############################################################
2176
2177 # binaries that have --help and are intended for use by humans,
2178 # usually, but not always, installed in /bin.
2179 public_programs = []
2180
2181 # D-Bus introspection XML export
2182 dbus_programs = []
2183
2184 # A list of boot stubs. Required for testing of ukify.
2185 boot_stubs = []
2186
2187 basic_includes = include_directories(
2188 'src/basic',
2189 'src/fundamental',
2190 'src/systemd',
2191 '.')
2192
2193 libsystemd_includes = [basic_includes, include_directories(
2194 'src/libsystemd/sd-bus',
2195 'src/libsystemd/sd-device',
2196 'src/libsystemd/sd-event',
2197 'src/libsystemd/sd-hwdb',
2198 'src/libsystemd/sd-id128',
2199 'src/libsystemd/sd-journal',
2200 'src/libsystemd/sd-netlink',
2201 'src/libsystemd/sd-network',
2202 'src/libsystemd/sd-resolve')]
2203
2204 includes = [libsystemd_includes, include_directories('src/shared')]
2205
2206 subdir('po')
2207 subdir('catalog')
2208 subdir('src/fundamental')
2209 subdir('src/basic')
2210 subdir('src/libsystemd')
2211 subdir('src/shared')
2212 subdir('src/udev')
2213 subdir('src/libudev')
2214 subdir('src/cryptsetup/cryptsetup-tokens')
2215
2216 libsystemd = shared_library(
2217 'systemd',
2218 version : libsystemd_version,
2219 include_directories : libsystemd_includes,
2220 link_args : ['-shared',
2221 '-Wl,--version-script=' + libsystemd_sym_path],
2222 link_with : [libbasic,
2223 libbasic_gcrypt,
2224 libbasic_compress],
2225 link_whole : [libsystemd_static],
2226 dependencies : [librt,
2227 threads,
2228 userspace],
2229 link_depends : libsystemd_sym,
2230 install : true,
2231 install_tag: 'libsystemd',
2232 install_dir : rootlibdir)
2233
2234 alias_target('libsystemd', libsystemd)
2235
2236 install_libsystemd_static = static_library(
2237 'systemd',
2238 libsystemd_sources,
2239 basic_sources,
2240 basic_gcrypt_sources,
2241 basic_compress_sources,
2242 fundamental_sources,
2243 include_directories : libsystemd_includes,
2244 build_by_default : static_libsystemd != 'false',
2245 install : static_libsystemd != 'false',
2246 install_tag: 'libsystemd',
2247 install_dir : rootlibdir,
2248 pic : static_libsystemd_pic,
2249 dependencies : [libblkid,
2250 libcap,
2251 libdl,
2252 libgcrypt,
2253 liblz4,
2254 libmount,
2255 libopenssl,
2256 librt,
2257 libxz,
2258 libzstd,
2259 threads,
2260 userspace,
2261 versiondep],
2262 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
2263
2264 libudev = shared_library(
2265 'udev',
2266 version : libudev_version,
2267 include_directories : includes,
2268 link_args : ['-shared',
2269 '-Wl,--version-script=' + libudev_sym_path],
2270 link_with : [libsystemd_static, libshared_static],
2271 link_whole : libudev_basic,
2272 dependencies : [threads,
2273 userspace],
2274 link_depends : libudev_sym,
2275 install : true,
2276 install_tag: 'libudev',
2277 install_dir : rootlibdir)
2278
2279 alias_target('libudev', libudev)
2280
2281 install_libudev_static = static_library(
2282 'udev',
2283 basic_sources,
2284 fundamental_sources,
2285 shared_sources,
2286 libsystemd_sources,
2287 libudev_sources,
2288 include_directories : includes,
2289 build_by_default : static_libudev != 'false',
2290 install : static_libudev != 'false',
2291 install_tag: 'libudev',
2292 install_dir : rootlibdir,
2293 link_depends : libudev_sym,
2294 dependencies : [libmount,
2295 libshared_deps,
2296 userspace,
2297 versiondep],
2298 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
2299 pic : static_libudev_pic)
2300
2301 if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
2302 if conf.get('HAVE_TPM2') == 1
2303 shared_library(
2304 'cryptsetup-token-systemd-tpm2',
2305 cryptsetup_token_systemd_tpm2_sources,
2306 include_directories : includes,
2307 link_args : ['-shared',
2308 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2309 link_with : [lib_cryptsetup_token_common,
2310 libshared],
2311 dependencies : [libcryptsetup,
2312 tpm2,
2313 userspace,
2314 versiondep],
2315 link_depends : cryptsetup_token_sym,
2316 install_rpath : rootpkglibdir,
2317 install : true,
2318 install_dir : libcryptsetup_plugins_dir)
2319 endif
2320
2321 if conf.get('HAVE_LIBFIDO2') == 1
2322 shared_library(
2323 'cryptsetup-token-systemd-fido2',
2324 cryptsetup_token_systemd_fido2_sources,
2325 include_directories : includes,
2326 link_args : ['-shared',
2327 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2328 link_with : [lib_cryptsetup_token_common,
2329 libshared],
2330 dependencies : [libcryptsetup,
2331 libfido2,
2332 userspace,
2333 versiondep],
2334 link_depends : cryptsetup_token_sym,
2335 install_rpath : rootpkglibdir,
2336 install : true,
2337 install_dir : libcryptsetup_plugins_dir)
2338 endif
2339
2340 if conf.get('HAVE_P11KIT') == 1
2341 shared_library(
2342 'cryptsetup-token-systemd-pkcs11',
2343 cryptsetup_token_systemd_pkcs11_sources,
2344 include_directories : includes,
2345 link_args : ['-shared',
2346 '-Wl,--version-script=' + cryptsetup_token_sym_path],
2347 link_with : [lib_cryptsetup_token_common,
2348 libshared],
2349 dependencies : [libcryptsetup,
2350 libp11kit,
2351 userspace,
2352 versiondep],
2353 link_depends : cryptsetup_token_sym,
2354 install_rpath : rootpkglibdir,
2355 install : true,
2356 install_dir : libcryptsetup_plugins_dir)
2357 endif
2358 endif
2359
2360 ############################################################
2361
2362 # systemd-analyze requires 'libcore'
2363 subdir('src/core')
2364 # systemd-journal-remote requires 'libjournal_core'
2365 subdir('src/journal')
2366 # systemd-networkd requires 'libsystemd_network'
2367 subdir('src/libsystemd-network')
2368
2369 subdir('src/analyze')
2370 subdir('src/boot')
2371 subdir('src/boot/efi')
2372 subdir('src/busctl')
2373 subdir('src/coredump')
2374 subdir('src/cryptenroll')
2375 subdir('src/cryptsetup')
2376 subdir('src/home')
2377 subdir('src/hostname')
2378 subdir('src/import')
2379 subdir('src/journal-remote')
2380 subdir('src/kernel-install')
2381 subdir('src/locale')
2382 subdir('src/login')
2383 subdir('src/machine')
2384 subdir('src/network')
2385 subdir('src/nspawn')
2386 subdir('src/oom')
2387 subdir('src/partition')
2388 subdir('src/portable')
2389 subdir('src/pstore')
2390 subdir('src/resolve')
2391 subdir('src/rpm')
2392 subdir('src/shutdown')
2393 subdir('src/sysext')
2394 subdir('src/systemctl')
2395 subdir('src/sysupdate')
2396 subdir('src/timedate')
2397 subdir('src/timesync')
2398 subdir('src/tmpfiles')
2399 subdir('src/userdb')
2400 subdir('src/xdg-autostart-generator')
2401
2402 subdir('src/systemd')
2403
2404 subdir('src/test')
2405 subdir('src/fuzz')
2406 subdir('rules.d')
2407 subdir('test')
2408 subdir('src/ukify/test') # needs to be last for test_env variable
2409
2410 alias_target('devel', libsystemd_pc, libudev_pc, systemd_pc, udev_pc)
2411
2412 ############################################################
2413
2414 # only static linking apart from libdl, to make sure that the
2415 # module is linked to all libraries that it uses.
2416 test_dlopen = executable(
2417 'test-dlopen',
2418 test_dlopen_c,
2419 include_directories : includes,
2420 link_with : [libbasic],
2421 dependencies : [libdl,
2422 userspace],
2423 build_by_default : want_tests != 'false')
2424
2425 foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
2426 ['systemd', 'ENABLE_NSS_SYSTEMD', ['nss-systemd.h', 'userdb-glue.c', 'userdb-glue.h']],
2427 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
2428 ['resolve', 'ENABLE_NSS_RESOLVE', [], resolve_includes]]
2429
2430 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
2431 if condition
2432 module = tuple[0]
2433
2434 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
2435 version_script_arg = project_source_root / sym
2436
2437 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
2438 if tuple.length() > 2
2439 foreach s : tuple[2]
2440 sources += ['src/nss-@0@/@1@'.format(module, s)]
2441 endforeach
2442 endif
2443
2444 incs = tuple.length() > 3 ? tuple[3] : includes
2445
2446 nss = shared_library(
2447 'nss_' + module,
2448 sources,
2449 version : '2',
2450 include_directories : incs,
2451 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
2452 link_args : ['-Wl,-z,nodelete',
2453 '-shared',
2454 '-Wl,--version-script=' + version_script_arg],
2455 link_with : [libsystemd_static,
2456 libshared_static,
2457 libbasic],
2458 dependencies : [librt,
2459 threads,
2460 userspace],
2461 link_depends : sym,
2462 install : true,
2463 install_tag : 'nss',
2464 install_dir : rootlibdir)
2465
2466 # We cannot use shared_module because it does not support version suffix.
2467 # Unfortunately shared_library insists on creating the symlink…
2468 meson.add_install_script('sh', '-c',
2469 'rm $DESTDIR@0@/libnss_@1@.so'
2470 .format(rootlibdir, module),
2471 install_tag : 'nss'
2472 )
2473
2474 if want_tests != 'false'
2475 test('dlopen-nss_' + module,
2476 test_dlopen,
2477 # path to dlopen must include a slash
2478 args : nss.full_path(),
2479 depends : nss)
2480 endif
2481 endif
2482 endforeach
2483
2484 ############################################################
2485
2486 exe = executable(
2487 'systemd',
2488 systemd_sources,
2489 include_directories : includes,
2490 link_with : [libcore,
2491 libshared],
2492 dependencies : [libseccomp,
2493 userspace,
2494 versiondep],
2495 install_rpath : rootpkglibdir,
2496 install : true,
2497 install_dir : rootlibexecdir)
2498 dbus_programs += exe
2499 public_programs += exe
2500
2501 meson.add_install_script(meson_make_symlink,
2502 rootlibexecdir / 'systemd',
2503 rootsbindir / 'init')
2504
2505 exe = executable(
2506 'systemd-analyze',
2507 systemd_analyze_sources,
2508 include_directories : core_includes,
2509 link_with : [libcore,
2510 libshared],
2511 dependencies : [libseccomp,
2512 userspace,
2513 versiondep],
2514 install_rpath : rootpkglibdir,
2515 install : conf.get('ENABLE_ANALYZE') == 1)
2516 if conf.get('ENABLE_ANALYZE') == 1
2517 public_programs += exe
2518 endif
2519
2520 if want_tests != 'false'
2521 test('test-compare-versions',
2522 test_compare_versions_sh,
2523 args : exe.full_path())
2524 endif
2525
2526 executable(
2527 'systemd-journald',
2528 systemd_journald_sources,
2529 include_directories : includes,
2530 link_with : [libjournal_core,
2531 libshared],
2532 dependencies : [liblz4,
2533 libselinux,
2534 libxz,
2535 libzstd,
2536 threads,
2537 userspace,
2538 versiondep],
2539 install_rpath : rootpkglibdir,
2540 install : true,
2541 install_dir : rootlibexecdir)
2542
2543 public_programs += executable(
2544 'systemd-cat',
2545 systemd_cat_sources,
2546 include_directories : includes,
2547 link_with : [libjournal_core,
2548 libshared],
2549 dependencies : [threads,
2550 userspace,
2551 versiondep],
2552 install_rpath : rootpkglibdir,
2553 install : true)
2554
2555 if get_option('link-journalctl-shared')
2556 journalctl_link_with = [libshared]
2557 else
2558 journalctl_link_with = [libsystemd_static,
2559 libshared_static,
2560 libbasic_gcrypt]
2561 endif
2562
2563 public_programs += executable(
2564 'journalctl',
2565 journalctl_sources,
2566 include_directories : includes,
2567 link_with : [journalctl_link_with],
2568 dependencies : [libdl,
2569 liblz4,
2570 libxz,
2571 libzstd,
2572 threads,
2573 userspace,
2574 versiondep],
2575 install_rpath : rootpkglibdir,
2576 install : true,
2577 install_dir : rootbindir)
2578
2579 executable(
2580 'systemd-getty-generator',
2581 'src/getty-generator/getty-generator.c',
2582 include_directories : includes,
2583 link_with : [libshared],
2584 dependencies : userspace,
2585 install_rpath : rootpkglibdir,
2586 install : true,
2587 install_dir : systemgeneratordir)
2588
2589 executable(
2590 'systemd-debug-generator',
2591 'src/debug-generator/debug-generator.c',
2592 include_directories : includes,
2593 link_with : [libshared],
2594 dependencies : userspace,
2595 install_rpath : rootpkglibdir,
2596 install : true,
2597 install_dir : systemgeneratordir)
2598
2599 executable(
2600 'systemd-run-generator',
2601 'src/run-generator/run-generator.c',
2602 include_directories : includes,
2603 link_with : [libshared],
2604 dependencies : userspace,
2605 install_rpath : rootpkglibdir,
2606 install : true,
2607 install_dir : systemgeneratordir)
2608
2609 exe = executable(
2610 'systemd-fstab-generator',
2611 'src/fstab-generator/fstab-generator.c',
2612 include_directories : includes,
2613 link_with : [libshared],
2614 dependencies : userspace,
2615 install_rpath : rootpkglibdir,
2616 install : true,
2617 install_dir : systemgeneratordir)
2618
2619 meson.add_install_script(meson_make_symlink,
2620 systemgeneratordir / 'systemd-fstab-generator',
2621 rootlibexecdir / 'systemd-sysroot-fstab-check')
2622
2623 if want_tests != 'false'
2624 test('test-fstab-generator',
2625 test_fstab_generator_sh,
2626 # https://github.com/mesonbuild/meson/issues/2681
2627 args : exe.full_path(),
2628 depends : exe)
2629 endif
2630
2631 if conf.get('ENABLE_ENVIRONMENT_D') == 1
2632 executable(
2633 '30-systemd-environment-d-generator',
2634 'src/environment-d-generator/environment-d-generator.c',
2635 include_directories : includes,
2636 link_with : [libshared],
2637 dependencies : userspace,
2638 install_rpath : rootpkglibdir,
2639 install : true,
2640 install_dir : userenvgeneratordir)
2641
2642 meson.add_install_script(meson_make_symlink,
2643 sysconfdir / 'environment',
2644 environmentdir / '99-environment.conf')
2645 endif
2646
2647 if conf.get('ENABLE_HIBERNATE') == 1
2648 executable(
2649 'systemd-hibernate-resume-generator',
2650 'src/hibernate-resume/hibernate-resume-generator.c',
2651 include_directories : includes,
2652 link_with : [libshared],
2653 dependencies : userspace,
2654 install_rpath : rootpkglibdir,
2655 install : true,
2656 install_dir : systemgeneratordir)
2657
2658 executable(
2659 'systemd-hibernate-resume',
2660 'src/hibernate-resume/hibernate-resume.c',
2661 include_directories : includes,
2662 link_with : [libshared],
2663 dependencies : userspace,
2664 install_rpath : rootpkglibdir,
2665 install : true,
2666 install_dir : rootlibexecdir)
2667 endif
2668
2669 if conf.get('HAVE_BLKID') == 1
2670 executable(
2671 'systemd-gpt-auto-generator',
2672 'src/gpt-auto-generator/gpt-auto-generator.c',
2673 include_directories : includes,
2674 link_with : [libshared],
2675 dependencies : [libblkid,
2676 userspace],
2677 install_rpath : rootpkglibdir,
2678 install : true,
2679 install_dir : systemgeneratordir)
2680
2681 public_programs += executable(
2682 'systemd-dissect',
2683 'src/dissect/dissect.c',
2684 include_directories : includes,
2685 link_with : [libshared],
2686 dependencies : [userspace,
2687 versiondep],
2688 install_rpath : rootpkglibdir,
2689 install : true)
2690
2691 meson.add_install_script(meson_make_symlink,
2692 bindir / 'systemd-dissect',
2693 rootsbindir / 'mount.ddi')
2694 endif
2695
2696 if conf.get('ENABLE_RESOLVE') == 1
2697 dbus_programs += executable(
2698 'systemd-resolved',
2699 systemd_resolved_sources,
2700 include_directories : resolve_includes,
2701 link_with : [libshared,
2702 libbasic_gcrypt,
2703 libsystemd_resolve_core],
2704 dependencies : [systemd_resolved_dependencies,
2705 userspace],
2706 install_rpath : rootpkglibdir,
2707 install : true,
2708 install_dir : rootlibexecdir)
2709
2710 public_programs += executable(
2711 'resolvectl',
2712 resolvectl_sources,
2713 include_directories : includes,
2714 link_with : [libshared,
2715 libbasic_gcrypt,
2716 libsystemd_resolve_core],
2717 dependencies : [lib_openssl_or_gcrypt,
2718 libidn,
2719 libm,
2720 threads,
2721 userspace,
2722 versiondep],
2723 install_rpath : rootpkglibdir,
2724 install : true)
2725
2726 meson.add_install_script(meson_make_symlink,
2727 bindir / 'resolvectl',
2728 rootsbindir / 'resolvconf')
2729
2730 meson.add_install_script(meson_make_symlink,
2731 bindir / 'resolvectl',
2732 bindir / 'systemd-resolve')
2733 endif
2734
2735 if conf.get('ENABLE_LOGIND') == 1
2736 dbus_programs += executable(
2737 'systemd-logind',
2738 systemd_logind_sources,
2739 include_directories : includes,
2740 link_with : [liblogind_core,
2741 libshared],
2742 dependencies : [libacl,
2743 threads,
2744 userspace,
2745 versiondep],
2746 install_rpath : rootpkglibdir,
2747 install : true,
2748 install_dir : rootlibexecdir)
2749
2750 public_programs += executable(
2751 'loginctl',
2752 loginctl_sources,
2753 include_directories : includes,
2754 link_with : [libshared],
2755 dependencies : [liblz4,
2756 libxz,
2757 libzstd,
2758 threads,
2759 userspace,
2760 versiondep],
2761 install_rpath : rootpkglibdir,
2762 install : true,
2763 install_dir : rootbindir)
2764
2765 public_programs += executable(
2766 'systemd-inhibit',
2767 'src/login/inhibit.c',
2768 include_directories : includes,
2769 link_with : [libshared],
2770 dependencies : [userspace,
2771 versiondep],
2772 install_rpath : rootpkglibdir,
2773 install : true,
2774 install_dir : rootbindir)
2775
2776 if conf.get('HAVE_PAM') == 1
2777 version_script_arg = project_source_root / pam_systemd_sym
2778 pam_systemd = shared_library(
2779 'pam_systemd',
2780 pam_systemd_c,
2781 name_prefix : '',
2782 include_directories : includes,
2783 link_args : ['-shared',
2784 '-Wl,--version-script=' + version_script_arg],
2785 link_with : [libsystemd_static,
2786 libshared_static],
2787 dependencies : [libpam_misc,
2788 libpam,
2789 threads,
2790 userspace,
2791 versiondep],
2792 link_depends : pam_systemd_sym,
2793 install : true,
2794 install_tag : 'pam',
2795 install_dir : pamlibdir)
2796
2797 if want_tests != 'false'
2798 test('dlopen-pam_systemd',
2799 test_dlopen,
2800 # path to dlopen must include a slash
2801 args : pam_systemd.full_path(),
2802 depends : pam_systemd)
2803 endif
2804 endif
2805
2806 executable(
2807 'systemd-user-runtime-dir',
2808 user_runtime_dir_sources,
2809 include_directories : includes,
2810 link_with : [libshared],
2811 dependencies : userspace,
2812 install_rpath : rootpkglibdir,
2813 install : true,
2814 install_dir : rootlibexecdir)
2815 endif
2816
2817 if conf.get('HAVE_PAM') == 1
2818 executable(
2819 'systemd-user-sessions',
2820 'src/user-sessions/user-sessions.c',
2821 include_directories : includes,
2822 link_with : [libshared],
2823 dependencies : userspace,
2824 install_rpath : rootpkglibdir,
2825 install : true,
2826 install_dir : rootlibexecdir)
2827 endif
2828
2829 if conf.get('HAVE_BLKID') == 1 and conf.get('ENABLE_BOOTLOADER') == 1
2830 if get_option('link-boot-shared')
2831 boot_link_with = [libshared]
2832 else
2833 boot_link_with = [libsystemd_static, libshared_static]
2834 endif
2835
2836 exe = executable(
2837 'bootctl',
2838 bootctl_sources,
2839 include_directories : includes,
2840 link_with : [boot_link_with],
2841 dependencies : [libblkid,
2842 userspace,
2843 versiondep],
2844 install_rpath : rootpkglibdir,
2845 install : true)
2846 public_programs += exe
2847
2848 if want_tests != 'false'
2849 test('test-bootctl-json',
2850 test_bootctl_json_sh,
2851 args : exe.full_path(),
2852 depends : exe)
2853 endif
2854
2855 public_programs += executable(
2856 'systemd-bless-boot',
2857 'src/boot/bless-boot.c',
2858 include_directories : includes,
2859 link_with : [boot_link_with],
2860 dependencies : [libblkid,
2861 userspace,
2862 versiondep],
2863 install_rpath : rootpkglibdir,
2864 install : true,
2865 install_dir : rootlibexecdir)
2866
2867 executable(
2868 'systemd-bless-boot-generator',
2869 'src/boot/bless-boot-generator.c',
2870 include_directories : includes,
2871 link_with : [boot_link_with],
2872 dependencies : userspace,
2873 install_rpath : rootpkglibdir,
2874 install : true,
2875 install_dir : systemgeneratordir)
2876
2877 if conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_TPM2') == 1
2878 executable(
2879 'systemd-measure',
2880 'src/boot/measure.c',
2881 include_directories : includes,
2882 link_with : [libshared],
2883 dependencies : [libopenssl,
2884 userspace,
2885 versiondep],
2886 install_rpath : rootpkglibdir,
2887 install : true,
2888 install_dir : rootlibexecdir)
2889 executable(
2890 'systemd-pcrphase',
2891 'src/boot/pcrphase.c',
2892 include_directories : includes,
2893 link_with : [libshared],
2894 dependencies : [libblkid,
2895 libopenssl,
2896 tpm2,
2897 userspace,
2898 versiondep],
2899 install_rpath : rootpkglibdir,
2900 install : true,
2901 install_dir : rootlibexecdir)
2902 endif
2903 endif
2904
2905 executable(
2906 'systemd-boot-check-no-failures',
2907 'src/boot/boot-check-no-failures.c',
2908 include_directories : includes,
2909 link_with : [libshared],
2910 dependencies : [libblkid,
2911 userspace,
2912 versiondep],
2913 install_rpath : rootpkglibdir,
2914 install : true,
2915 install_dir : rootlibexecdir)
2916
2917 public_programs += executable(
2918 'systemd-socket-activate',
2919 'src/socket-activate/socket-activate.c',
2920 include_directories : includes,
2921 link_with : [libshared],
2922 dependencies : [threads,
2923 userspace,
2924 versiondep],
2925 install_rpath : rootpkglibdir,
2926 install : true)
2927
2928 systemctl = executable(
2929 'systemctl',
2930 systemctl_sources,
2931 include_directories : includes,
2932 link_with : systemctl_link_with,
2933 dependencies : [libcap,
2934 liblz4,
2935 libselinux,
2936 libxz,
2937 libzstd,
2938 threads,
2939 userspace,
2940 versiondep],
2941 install_rpath : rootpkglibdir,
2942 install : true,
2943 install_dir : rootbindir)
2944 public_programs += systemctl
2945
2946 if conf.get('ENABLE_PORTABLED') == 1
2947 if get_option('link-portabled-shared')
2948 portabled_link_with = [libshared]
2949 else
2950 portabled_link_with = [libsystemd_static,
2951 libshared_static]
2952 endif
2953
2954 dbus_programs += executable(
2955 'systemd-portabled',
2956 systemd_portabled_sources,
2957 include_directories : includes,
2958 link_with : [portabled_link_with],
2959 dependencies : [libselinux,
2960 threads,
2961 userspace,
2962 versiondep],
2963 install_rpath : rootpkglibdir,
2964 install : true,
2965 install_dir : rootlibexecdir)
2966
2967 public_programs += executable(
2968 'portablectl',
2969 'src/portable/portablectl.c',
2970 include_directories : includes,
2971 link_with : [portabled_link_with],
2972 dependencies : [threads,
2973 userspace,
2974 versiondep],
2975 install_rpath : rootpkglibdir,
2976 install : true,
2977 install_dir : rootbindir)
2978 endif
2979
2980 if conf.get('ENABLE_SYSEXT') == 1
2981 public_programs += executable(
2982 'systemd-sysext',
2983 systemd_sysext_sources,
2984 include_directories : includes,
2985 link_with : [libshared],
2986 dependencies : [userspace,
2987 versiondep],
2988 install_rpath : rootpkglibdir,
2989 install : true,
2990 install_dir : rootbindir)
2991 endif
2992
2993 if conf.get('ENABLE_USERDB') == 1
2994 executable(
2995 'systemd-userwork',
2996 systemd_userwork_sources,
2997 include_directories : includes,
2998 link_with : [libshared],
2999 dependencies : [threads,
3000 userspace,
3001 versiondep],
3002 install_rpath : rootpkglibdir,
3003 install : true,
3004 install_dir : rootlibexecdir)
3005
3006 executable(
3007 'systemd-userdbd',
3008 systemd_userdbd_sources,
3009 include_directories : includes,
3010 link_with : [libshared],
3011 dependencies : [threads,
3012 userspace,
3013 versiondep],
3014 install_rpath : rootpkglibdir,
3015 install : true,
3016 install_dir : rootlibexecdir)
3017
3018 public_programs += executable(
3019 'userdbctl',
3020 userdbctl_sources,
3021 include_directories : includes,
3022 link_with : [libshared],
3023 dependencies : [threads,
3024 userspace,
3025 versiondep],
3026 install_rpath : rootpkglibdir,
3027 install : true)
3028 endif
3029
3030 if conf.get('ENABLE_HOMED') == 1
3031 executable(
3032 'systemd-homework',
3033 systemd_homework_sources,
3034 include_directories : includes,
3035 link_with : [libshared,
3036 libshared_fdisk],
3037 dependencies : [libblkid,
3038 libcrypt,
3039 libfdisk,
3040 libopenssl,
3041 libp11kit,
3042 threads,
3043 userspace,
3044 versiondep],
3045 install_rpath : rootpkglibdir,
3046 install : true,
3047 install_dir : rootlibexecdir)
3048
3049 dbus_programs += executable(
3050 'systemd-homed',
3051 systemd_homed_sources,
3052 include_directories : home_includes,
3053 link_with : [libshared],
3054 dependencies : [libcrypt,
3055 libm,
3056 libopenssl,
3057 threads,
3058 userspace,
3059 versiondep],
3060 install_rpath : rootpkglibdir,
3061 install : true,
3062 install_dir : rootlibexecdir)
3063
3064 public_programs += executable(
3065 'homectl',
3066 homectl_sources,
3067 include_directories : includes,
3068 link_with : [libshared],
3069 dependencies : [libcrypt,
3070 libdl,
3071 libopenssl,
3072 libp11kit,
3073 threads,
3074 userspace,
3075 versiondep],
3076 install_rpath : rootpkglibdir,
3077 install : true)
3078
3079 if conf.get('HAVE_PAM') == 1
3080 version_script_arg = project_source_root / pam_systemd_home_sym
3081 pam_systemd_home = shared_library(
3082 'pam_systemd_home',
3083 pam_systemd_home_c,
3084 name_prefix : '',
3085 include_directories : includes,
3086 link_args : ['-shared',
3087 '-Wl,--version-script=' + version_script_arg],
3088 link_with : [libsystemd_static,
3089 libshared_static],
3090 dependencies : [libcrypt,
3091 libpam_misc,
3092 libpam,
3093 threads,
3094 userspace,
3095 versiondep],
3096 link_depends : pam_systemd_home_sym,
3097 install : true,
3098 install_tag : 'pam',
3099 install_dir : pamlibdir)
3100
3101 if want_tests != 'false'
3102 test('dlopen-pam_systemd_home',
3103 test_dlopen,
3104 # path to dlopen must include a slash
3105 args : pam_systemd_home.full_path(),
3106 depends : pam_systemd_home)
3107 endif
3108 endif
3109 endif
3110
3111 foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
3112 (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
3113 meson.add_install_script(meson_make_symlink,
3114 rootbindir / 'systemctl',
3115 rootsbindir / alias)
3116 endforeach
3117
3118 meson.add_install_script(meson_make_symlink,
3119 rootbindir / 'udevadm',
3120 rootlibexecdir / 'systemd-udevd')
3121
3122 if conf.get('ENABLE_BACKLIGHT') == 1
3123 executable(
3124 'systemd-backlight',
3125 'src/backlight/backlight.c',
3126 include_directories : includes,
3127 link_with : [libshared],
3128 dependencies : userspace,
3129 install_rpath : rootpkglibdir,
3130 install : true,
3131 install_dir : rootlibexecdir)
3132 endif
3133
3134 if conf.get('ENABLE_RFKILL') == 1
3135 executable(
3136 'systemd-rfkill',
3137 'src/rfkill/rfkill.c',
3138 include_directories : includes,
3139 link_with : [libshared],
3140 dependencies : userspace,
3141 install_rpath : rootpkglibdir,
3142 install : true,
3143 install_dir : rootlibexecdir)
3144 endif
3145
3146 executable(
3147 'systemd-system-update-generator',
3148 'src/system-update-generator/system-update-generator.c',
3149 include_directories : includes,
3150 link_with : [libshared],
3151 dependencies : userspace,
3152 install_rpath : rootpkglibdir,
3153 install : true,
3154 install_dir : systemgeneratordir)
3155
3156 if conf.get('HAVE_LIBCRYPTSETUP') == 1
3157 executable(
3158 'systemd-cryptsetup',
3159 systemd_cryptsetup_sources,
3160 include_directories : includes,
3161 link_with : [libshared],
3162 dependencies : [libcryptsetup,
3163 libopenssl,
3164 libp11kit,
3165 userspace,
3166 versiondep],
3167 install_rpath : rootpkglibdir,
3168 install : true,
3169 install_dir : rootlibexecdir)
3170
3171 executable(
3172 'systemd-cryptsetup-generator',
3173 'src/cryptsetup/cryptsetup-generator.c',
3174 include_directories : includes,
3175 link_with : [libshared],
3176 dependencies : userspace,
3177 install_rpath : rootpkglibdir,
3178 install : true,
3179 install_dir : systemgeneratordir)
3180
3181 executable(
3182 'systemd-veritysetup',
3183 'src/veritysetup/veritysetup.c',
3184 include_directories : includes,
3185 link_with : [libshared],
3186 dependencies : [libcryptsetup,
3187 userspace,
3188 versiondep],
3189 install_rpath : rootpkglibdir,
3190 install : true,
3191 install_dir : rootlibexecdir)
3192
3193 executable(
3194 'systemd-veritysetup-generator',
3195 'src/veritysetup/veritysetup-generator.c',
3196 include_directories : includes,
3197 link_with : [libshared],
3198 dependencies : [userspace,
3199 versiondep],
3200 install_rpath : rootpkglibdir,
3201 install : true,
3202 install_dir : systemgeneratordir)
3203
3204 public_programs += executable(
3205 'systemd-cryptenroll',
3206 systemd_cryptenroll_sources,
3207 include_directories : includes,
3208 link_with : [libshared],
3209 dependencies : [libcryptsetup,
3210 libdl,
3211 libopenssl,
3212 libp11kit,
3213 userspace,
3214 versiondep],
3215 install_rpath : rootpkglibdir,
3216 install : true)
3217
3218 executable(
3219 'systemd-integritysetup',
3220 ['src/integritysetup/integritysetup.c', 'src/integritysetup/integrity-util.c'],
3221 include_directories : includes,
3222 link_with : [libshared],
3223 dependencies : [libcryptsetup,
3224 userspace,
3225 versiondep],
3226 install_rpath : rootpkglibdir,
3227 install : true,
3228 install_dir : rootlibexecdir)
3229
3230 executable(
3231 'systemd-integritysetup-generator',
3232 ['src/integritysetup/integritysetup-generator.c', 'src/integritysetup/integrity-util.c'],
3233 include_directories : includes,
3234 link_with : [libshared],
3235 dependencies : userspace,
3236 install_rpath : rootpkglibdir,
3237 install : true,
3238 install_dir : systemgeneratordir)
3239 endif
3240
3241 if conf.get('HAVE_SYSV_COMPAT') == 1
3242 exe = executable(
3243 'systemd-sysv-generator',
3244 'src/sysv-generator/sysv-generator.c',
3245 include_directories : includes,
3246 link_with : [libshared],
3247 dependencies : userspace,
3248 install_rpath : rootpkglibdir,
3249 install : true,
3250 install_dir : systemgeneratordir)
3251
3252 sysv_generator_test_py = find_program('test/sysv-generator-test.py')
3253 if want_tests != 'false'
3254 test('sysv-generator-test',
3255 sysv_generator_test_py,
3256 depends : exe)
3257 endif
3258
3259 executable(
3260 'systemd-rc-local-generator',
3261 'src/rc-local-generator/rc-local-generator.c',
3262 include_directories : includes,
3263 link_with : [libshared],
3264 dependencies : userspace,
3265 install_rpath : rootpkglibdir,
3266 install : true,
3267 install_dir : systemgeneratordir)
3268 endif
3269
3270 if conf.get('ENABLE_XDG_AUTOSTART') == 1
3271 executable(
3272 'systemd-xdg-autostart-generator',
3273 systemd_xdg_autostart_generator_sources,
3274 include_directories : includes,
3275 link_with : [libshared],
3276 dependencies : userspace,
3277 install_rpath : rootpkglibdir,
3278 install : true,
3279 install_dir : usergeneratordir)
3280
3281 executable(
3282 'systemd-xdg-autostart-condition',
3283 'src/xdg-autostart-generator/xdg-autostart-condition.c',
3284 include_directories : includes,
3285 link_with : [libshared],
3286 dependencies : userspace,
3287 install_rpath : rootpkglibdir,
3288 install : true,
3289 install_dir : rootlibexecdir)
3290 endif
3291
3292 if conf.get('ENABLE_HOSTNAMED') == 1
3293 dbus_programs += executable(
3294 'systemd-hostnamed',
3295 'src/hostname/hostnamed.c',
3296 include_directories : includes,
3297 link_with : [libshared],
3298 dependencies : userspace,
3299 install_rpath : rootpkglibdir,
3300 install : true,
3301 install_dir : rootlibexecdir)
3302
3303 public_programs += executable(
3304 'hostnamectl',
3305 'src/hostname/hostnamectl.c',
3306 include_directories : includes,
3307 link_with : [libshared],
3308 dependencies : [userspace,
3309 versiondep],
3310 install_rpath : rootpkglibdir,
3311 install : true)
3312 endif
3313
3314 if conf.get('ENABLE_LOCALED') == 1
3315 dbus_programs += executable(
3316 'systemd-localed',
3317 systemd_localed_sources,
3318 include_directories : includes,
3319 link_with : [libshared],
3320 dependencies : libxkbcommon_deps +
3321 [userspace,
3322 versiondep],
3323 install_rpath : rootpkglibdir,
3324 install : true,
3325 install_dir : rootlibexecdir)
3326
3327 public_programs += executable(
3328 'localectl',
3329 localectl_sources,
3330 include_directories : includes,
3331 link_with : [libshared],
3332 dependencies : [userspace,
3333 versiondep],
3334 install_rpath : rootpkglibdir,
3335 install : true)
3336 endif
3337
3338 if conf.get('ENABLE_TIMEDATED') == 1
3339 dbus_programs += executable(
3340 'systemd-timedated',
3341 'src/timedate/timedated.c',
3342 include_directories : includes,
3343 link_with : [libshared],
3344 dependencies : userspace,
3345 install_rpath : rootpkglibdir,
3346 install : true,
3347 install_dir : rootlibexecdir)
3348 endif
3349
3350 if conf.get('ENABLE_TIMEDATECTL') == 1
3351 public_programs += executable(
3352 'timedatectl',
3353 'src/timedate/timedatectl.c',
3354 include_directories : includes,
3355 install_rpath : rootpkglibdir,
3356 link_with : [libshared],
3357 dependencies : [libm,
3358 userspace,
3359 versiondep],
3360 install : true)
3361 endif
3362
3363 if conf.get('ENABLE_TIMESYNCD') == 1
3364 executable(
3365 'systemd-timesyncd',
3366 systemd_timesyncd_sources,
3367 include_directories : includes,
3368 link_with : [libtimesyncd_core],
3369 dependencies : [libm,
3370 threads,
3371 userspace,
3372 versiondep],
3373 install_rpath : rootpkglibdir,
3374 install : true,
3375 install_dir : rootlibexecdir)
3376
3377 executable(
3378 'systemd-time-wait-sync',
3379 'src/timesync/wait-sync.c',
3380 include_directories : includes,
3381 link_with : [libtimesyncd_core],
3382 dependencies : userspace,
3383 install_rpath : rootpkglibdir,
3384 install : true,
3385 install_dir : rootlibexecdir)
3386 endif
3387
3388 if conf.get('ENABLE_MACHINED') == 1
3389 dbus_programs += executable(
3390 'systemd-machined',
3391 systemd_machined_sources,
3392 include_directories : includes,
3393 link_with : [libmachine_core,
3394 libshared],
3395 dependencies : userspace,
3396 install_rpath : rootpkglibdir,
3397 install : true,
3398 install_dir : rootlibexecdir)
3399
3400 public_programs += executable(
3401 'machinectl',
3402 'src/machine/machinectl.c',
3403 include_directories : includes,
3404 link_with : [libshared],
3405 dependencies : [liblz4,
3406 libxz,
3407 libzstd,
3408 threads,
3409 userspace,
3410 versiondep],
3411 install_rpath : rootpkglibdir,
3412 install : true,
3413 install_dir : rootbindir)
3414 endif
3415
3416 if conf.get('ENABLE_IMPORTD') == 1
3417 dbus_programs += executable(
3418 'systemd-importd',
3419 systemd_importd_sources,
3420 include_directories : includes,
3421 link_with : [libshared],
3422 dependencies : [threads,
3423 userspace,
3424 versiondep],
3425 install_rpath : rootpkglibdir,
3426 install : true,
3427 install_dir : rootlibexecdir)
3428
3429 systemd_pull = executable(
3430 'systemd-pull',
3431 systemd_pull_sources,
3432 include_directories : includes,
3433 link_with : [libshared,
3434 lib_import_common],
3435 dependencies : [lib_openssl_or_gcrypt,
3436 libbzip2,
3437 libcurl,
3438 libxz,
3439 libz,
3440 userspace,
3441 versiondep],
3442 install_rpath : rootpkglibdir,
3443 install : true,
3444 install_dir : rootlibexecdir)
3445
3446 systemd_import = executable(
3447 'systemd-import',
3448 systemd_import_sources,
3449 include_directories : includes,
3450 link_with : [libshared,
3451 lib_import_common],
3452 dependencies : [libbzip2,
3453 libcurl,
3454 libxz,
3455 libz,
3456 userspace,
3457 versiondep],
3458 install_rpath : rootpkglibdir,
3459 install : true,
3460 install_dir : rootlibexecdir)
3461
3462 systemd_import_fs = executable(
3463 'systemd-import-fs',
3464 systemd_import_fs_sources,
3465 include_directories : includes,
3466 link_with : [libshared,
3467 lib_import_common],
3468 dependencies : [userspace,
3469 versiondep],
3470 install_rpath : rootpkglibdir,
3471 install : true,
3472 install_dir : rootlibexecdir)
3473
3474 systemd_export = executable(
3475 'systemd-export',
3476 systemd_export_sources,
3477 include_directories : includes,
3478 link_with : [libshared,
3479 lib_import_common],
3480 dependencies : [libbzip2,
3481 libcurl,
3482 libxz,
3483 libz,
3484 userspace,
3485 versiondep],
3486 install_rpath : rootpkglibdir,
3487 install : true,
3488 install_dir : rootlibexecdir)
3489
3490 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
3491 endif
3492
3493 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
3494 public_programs += executable(
3495 'systemd-journal-upload',
3496 systemd_journal_upload_sources,
3497 include_directories : includes,
3498 link_with : [libshared],
3499 dependencies : [libcurl,
3500 libgnutls,
3501 liblz4,
3502 libxz,
3503 libzstd,
3504 threads,
3505 userspace,
3506 versiondep],
3507 install_rpath : rootpkglibdir,
3508 install : true,
3509 install_dir : rootlibexecdir)
3510 endif
3511
3512 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
3513 public_programs += executable(
3514 'systemd-journal-remote',
3515 systemd_journal_remote_sources,
3516 include_directories : journal_includes,
3517 link_with : [libshared,
3518 libsystemd_journal_remote],
3519 dependencies : [libgnutls,
3520 liblz4,
3521 libmicrohttpd,
3522 libxz,
3523 libzstd,
3524 threads,
3525 userspace,
3526 versiondep],
3527 install_rpath : rootpkglibdir,
3528 install : true,
3529 install_dir : rootlibexecdir)
3530
3531 public_programs += executable(
3532 'systemd-journal-gatewayd',
3533 systemd_journal_gatewayd_sources,
3534 include_directories : journal_includes,
3535 link_with : [libshared],
3536 dependencies : [libgnutls,
3537 liblz4,
3538 libmicrohttpd,
3539 libxz,
3540 libzstd,
3541 threads,
3542 userspace,
3543 versiondep],
3544 install_rpath : rootpkglibdir,
3545 install : true,
3546 install_dir : rootlibexecdir)
3547 endif
3548
3549 if conf.get('ENABLE_COREDUMP') == 1
3550 executable(
3551 'systemd-coredump',
3552 systemd_coredump_sources,
3553 include_directories : includes,
3554 link_with : [libshared,
3555 libbasic_compress],
3556 dependencies : [libacl,
3557 liblz4,
3558 libxz,
3559 libzstd,
3560 threads,
3561 userspace,
3562 versiondep],
3563 install_rpath : rootpkglibdir,
3564 install : true,
3565 install_dir : rootlibexecdir)
3566
3567 public_programs += executable(
3568 'coredumpctl',
3569 coredumpctl_sources,
3570 include_directories : includes,
3571 link_with : [libshared,
3572 libbasic_compress],
3573 dependencies : [liblz4,
3574 libxz,
3575 libzstd,
3576 threads,
3577 userspace,
3578 versiondep],
3579 install_rpath : rootpkglibdir,
3580 install : true)
3581 endif
3582
3583 if conf.get('ENABLE_PSTORE') == 1
3584 executable(
3585 'systemd-pstore',
3586 systemd_pstore_sources,
3587 include_directories : includes,
3588 link_with : [libshared],
3589 dependencies : [libacl,
3590 liblz4,
3591 libxz,
3592 libzstd,
3593 threads,
3594 userspace,
3595 versiondep],
3596 install_rpath : rootpkglibdir,
3597 install : true,
3598 install_dir : rootlibexecdir)
3599 endif
3600
3601 if conf.get('ENABLE_OOMD') == 1
3602 dbus_programs += executable('systemd-oomd',
3603 systemd_oomd_sources,
3604 include_directories : includes,
3605 link_with : [libshared],
3606 dependencies : [libatomic,
3607 userspace,
3608 versiondep],
3609 install_rpath : rootpkglibdir,
3610 install : true,
3611 install_dir : rootlibexecdir)
3612
3613 public_programs += executable(
3614 'oomctl',
3615 oomctl_sources,
3616 include_directories : includes,
3617 link_with : [libshared],
3618 dependencies : [userspace,
3619 versiondep],
3620 install_rpath : rootpkglibdir,
3621 install : true)
3622 endif
3623
3624 if conf.get('ENABLE_BINFMT') == 1
3625 public_programs += executable(
3626 'systemd-binfmt',
3627 'src/binfmt/binfmt.c',
3628 include_directories : includes,
3629 link_with : [libshared],
3630 dependencies : [userspace,
3631 versiondep],
3632 install_rpath : rootpkglibdir,
3633 install : true,
3634 install_dir : rootlibexecdir)
3635
3636 meson.add_install_script('sh', '-c',
3637 mkdir_p.format(binfmtdir))
3638 if install_sysconfdir
3639 meson.add_install_script('sh', '-c',
3640 mkdir_p.format(sysconfdir / 'binfmt.d'))
3641 endif
3642 endif
3643
3644 if conf.get('ENABLE_SYSUPDATE') == 1
3645 exe = executable(
3646 'systemd-sysupdate',
3647 systemd_sysupdate_sources,
3648 include_directories : includes,
3649 link_with : [libshared,
3650 libshared_fdisk],
3651 dependencies : [libblkid,
3652 libfdisk,
3653 libopenssl,
3654 threads,
3655 userspace,
3656 versiondep],
3657 install_rpath : rootpkglibdir,
3658 install : true,
3659 install_dir : rootlibexecdir)
3660 public_programs += exe
3661 endif
3662
3663 if conf.get('ENABLE_VCONSOLE') == 1
3664 executable(
3665 'systemd-vconsole-setup',
3666 'src/vconsole/vconsole-setup.c',
3667 include_directories : includes,
3668 link_with : [libshared],
3669 dependencies : userspace,
3670 install_rpath : rootpkglibdir,
3671 install : true,
3672 install_dir : rootlibexecdir)
3673 endif
3674
3675 if conf.get('ENABLE_RANDOMSEED') == 1
3676 executable(
3677 'systemd-random-seed',
3678 'src/random-seed/random-seed.c',
3679 include_directories : includes,
3680 link_with : [libshared],
3681 dependencies : [userspace,
3682 versiondep],
3683 install_rpath : rootpkglibdir,
3684 install : true,
3685 install_dir : rootlibexecdir)
3686 endif
3687
3688 if conf.get('ENABLE_FIRSTBOOT') == 1
3689 public_programs += executable(
3690 'systemd-firstboot',
3691 'src/firstboot/firstboot.c',
3692 include_directories : includes,
3693 link_with : [libshared],
3694 dependencies : [libcrypt,
3695 userspace,
3696 versiondep],
3697 install_rpath : rootpkglibdir,
3698 install : true,
3699 install_dir : rootbindir)
3700 endif
3701
3702 executable(
3703 'systemd-remount-fs',
3704 'src/remount-fs/remount-fs.c',
3705 include_directories : includes,
3706 link_with : [libshared],
3707 dependencies : [userspace,
3708 versiondep],
3709 install_rpath : rootpkglibdir,
3710 install : true,
3711 install_dir : rootlibexecdir)
3712
3713 executable(
3714 'systemd-machine-id-setup',
3715 'src/machine-id-setup/machine-id-setup-main.c',
3716 include_directories : includes,
3717 link_with : [libshared],
3718 dependencies : [userspace,
3719 versiondep],
3720 install_rpath : rootpkglibdir,
3721 install : true,
3722 install_dir : rootbindir)
3723
3724 executable(
3725 'systemd-fsck',
3726 'src/fsck/fsck.c',
3727 include_directories : includes,
3728 link_with : [libshared],
3729 dependencies : [userspace,
3730 versiondep],
3731 install_rpath : rootpkglibdir,
3732 install : true,
3733 install_dir : rootlibexecdir)
3734
3735 executable(
3736 'systemd-growfs',
3737 'src/partition/growfs.c',
3738 include_directories : includes,
3739 link_with : [libshared],
3740 dependencies : [userspace,
3741 versiondep],
3742 install_rpath : rootpkglibdir,
3743 install : true,
3744 install_dir : rootlibexecdir)
3745
3746 executable(
3747 'systemd-makefs',
3748 'src/partition/makefs.c',
3749 include_directories : includes,
3750 link_with : [libshared],
3751 dependencies : [userspace,
3752 versiondep],
3753 install_rpath : rootpkglibdir,
3754 install : true,
3755 install_dir : rootlibexecdir)
3756
3757 executable(
3758 'systemd-sleep',
3759 'src/sleep/sleep.c',
3760 include_directories : includes,
3761 link_with : [libshared],
3762 dependencies : [userspace,
3763 versiondep],
3764 install_rpath : rootpkglibdir,
3765 install : true,
3766 install_dir : rootlibexecdir)
3767
3768 if install_sysconfdir_samples
3769 install_data('src/sleep/sleep.conf',
3770 install_dir : pkgsysconfdir)
3771 endif
3772
3773 public_programs += executable(
3774 'systemd-sysctl',
3775 'src/sysctl/sysctl.c',
3776 include_directories : includes,
3777 link_with : [libshared],
3778 dependencies : [userspace,
3779 versiondep],
3780 install_rpath : rootpkglibdir,
3781 install : true,
3782 install_dir : rootlibexecdir)
3783
3784 public_programs += executable(
3785 'systemd-ac-power',
3786 'src/ac-power/ac-power.c',
3787 include_directories : includes,
3788 link_with : [libshared],
3789 dependencies : [userspace,
3790 versiondep],
3791 install_rpath : rootpkglibdir,
3792 install : true)
3793
3794 public_programs += executable(
3795 'systemd-detect-virt',
3796 'src/detect-virt/detect-virt.c',
3797 include_directories : includes,
3798 link_with : [libshared],
3799 dependencies : [userspace,
3800 versiondep],
3801 install_rpath : rootpkglibdir,
3802 install : true)
3803
3804 public_programs += executable(
3805 'systemd-delta',
3806 'src/delta/delta.c',
3807 include_directories : includes,
3808 link_with : [libshared],
3809 dependencies : [userspace,
3810 versiondep],
3811 install_rpath : rootpkglibdir,
3812 install : true)
3813
3814 public_programs += executable(
3815 'systemd-escape',
3816 'src/escape/escape.c',
3817 include_directories : includes,
3818 link_with : [libshared],
3819 dependencies : [userspace,
3820 versiondep],
3821 install_rpath : rootpkglibdir,
3822 install : true,
3823 install_dir : rootbindir)
3824
3825 public_programs += executable(
3826 'systemd-notify',
3827 'src/notify/notify.c',
3828 include_directories : includes,
3829 link_with : [libshared],
3830 dependencies : [userspace,
3831 versiondep],
3832 install_rpath : rootpkglibdir,
3833 install : true,
3834 install_dir : rootbindir)
3835
3836 public_programs += executable(
3837 'systemd-creds',
3838 'src/creds/creds.c',
3839 include_directories : includes,
3840 link_with : [libshared],
3841 dependencies : [threads,
3842 libopenssl,
3843 userspace,
3844 versiondep],
3845 install_rpath : rootpkglibdir,
3846 install : true,
3847 install_dir : rootbindir)
3848
3849 public_programs += executable(
3850 'systemd-battery-check',
3851 'src/battery-check/battery-check.c',
3852 include_directories : includes,
3853 link_with : [libshared],
3854 dependencies : [userspace, versiondep],
3855 install_rpath : rootpkglibdir,
3856 install_dir : rootlibexecdir,
3857 install : true)
3858
3859 # Protecting files from the distro in /usr doesn't make sense since they can be trivially accessed otherwise,
3860 # so don't restrict the access mode in /usr. That doesn't apply to /etc, so we do restrict the access mode
3861 # there.
3862 meson.add_install_script('sh', '-c', mkdir_p.format(credstoredir))
3863 if install_sysconfdir
3864 # Keep in sync with tmpfiles.d/credstore.conf
3865 meson.add_install_script('sh', '-c', mkdir_p_mode.format(sysconfdir / 'credstore', '0700'))
3866 meson.add_install_script('sh', '-c', mkdir_p_mode.format(sysconfdir / 'credstore.encrypted', '0700'))
3867 endif
3868
3869 executable(
3870 'systemd-volatile-root',
3871 'src/volatile-root/volatile-root.c',
3872 include_directories : includes,
3873 link_with : [libshared],
3874 dependencies : userspace,
3875 install_rpath : rootpkglibdir,
3876 install : conf.get('ENABLE_INITRD') == 1,
3877 install_dir : rootlibexecdir)
3878
3879 executable(
3880 'systemd-cgroups-agent',
3881 'src/cgroups-agent/cgroups-agent.c',
3882 include_directories : includes,
3883 link_with : [libshared],
3884 dependencies : userspace,
3885 install_rpath : rootpkglibdir,
3886 install : true,
3887 install_dir : rootlibexecdir)
3888
3889 systemd_id128 = executable(
3890 'systemd-id128',
3891 'src/id128/id128.c',
3892 include_directories : includes,
3893 link_with : [libshared],
3894 dependencies : [userspace,
3895 versiondep],
3896 install_rpath : rootpkglibdir,
3897 install : true)
3898 public_programs += systemd_id128
3899
3900 if want_tests != 'false'
3901 test('test-systemctl-enable',
3902 test_systemctl_enable_sh,
3903 # https://github.com/mesonbuild/meson/issues/2681
3904 args : [systemctl.full_path(),
3905 systemd_id128.full_path()])
3906 endif
3907
3908 public_programs += executable(
3909 'systemd-path',
3910 'src/path/path.c',
3911 include_directories : includes,
3912 link_with : [libshared],
3913 dependencies : [userspace,
3914 versiondep],
3915 install_rpath : rootpkglibdir,
3916 install : true)
3917
3918 public_programs += executable(
3919 'systemd-ask-password',
3920 'src/ask-password/ask-password.c',
3921 include_directories : includes,
3922 link_with : [libshared],
3923 dependencies : [userspace,
3924 versiondep],
3925 install_rpath : rootpkglibdir,
3926 install : true,
3927 install_dir : rootbindir)
3928
3929 executable(
3930 'systemd-reply-password',
3931 'src/reply-password/reply-password.c',
3932 include_directories : includes,
3933 link_with : [libshared],
3934 dependencies : userspace,
3935 install_rpath : rootpkglibdir,
3936 install : true,
3937 install_dir : rootlibexecdir)
3938
3939 public_programs += executable(
3940 'systemd-tty-ask-password-agent',
3941 'src/tty-ask-password-agent/tty-ask-password-agent.c',
3942 include_directories : includes,
3943 link_with : [libshared],
3944 dependencies : [userspace,
3945 versiondep],
3946 install_rpath : rootpkglibdir,
3947 install : true,
3948 install_dir : rootbindir)
3949
3950 public_programs += executable(
3951 'systemd-cgls',
3952 'src/cgls/cgls.c',
3953 include_directories : includes,
3954 link_with : [libshared],
3955 dependencies : [userspace,
3956 versiondep],
3957 install_rpath : rootpkglibdir,
3958 install : true)
3959
3960 public_programs += executable(
3961 'systemd-cgtop',
3962 'src/cgtop/cgtop.c',
3963 include_directories : includes,
3964 link_with : [libshared],
3965 dependencies : [userspace,
3966 versiondep],
3967 install_rpath : rootpkglibdir,
3968 install : true)
3969
3970 executable(
3971 'systemd-initctl',
3972 'src/initctl/initctl.c',
3973 include_directories : includes,
3974 link_with : [libshared],
3975 dependencies : userspace,
3976 install_rpath : rootpkglibdir,
3977 install : (conf.get('HAVE_SYSV_COMPAT') == 1),
3978 install_dir : rootlibexecdir)
3979
3980 public_programs += executable(
3981 'systemd-mount',
3982 'src/mount/mount-tool.c',
3983 include_directories : includes,
3984 link_with : [libshared],
3985 dependencies: [libmount,
3986 userspace,
3987 versiondep],
3988 install_rpath : rootpkglibdir,
3989 install : true)
3990
3991 meson.add_install_script(meson_make_symlink,
3992 'systemd-mount', bindir / 'systemd-umount')
3993
3994 public_programs += executable(
3995 'systemd-run',
3996 'src/run/run.c',
3997 include_directories : includes,
3998 link_with : [libshared],
3999 dependencies : [userspace,
4000 versiondep],
4001 install_rpath : rootpkglibdir,
4002 install : true)
4003
4004 public_programs += executable(
4005 'systemd-stdio-bridge',
4006 'src/stdio-bridge/stdio-bridge.c',
4007 include_directories : includes,
4008 link_with : [libshared],
4009 dependencies : [userspace,
4010 versiondep],
4011 install_rpath : rootpkglibdir,
4012 install : true)
4013
4014 public_programs += executable(
4015 'busctl',
4016 busctl_sources,
4017 include_directories : includes,
4018 link_with : [libshared],
4019 dependencies : [userspace,
4020 versiondep],
4021 install_rpath : rootpkglibdir,
4022 install : true)
4023
4024 if enable_sysusers
4025 exe = executable(
4026 'systemd-sysusers',
4027 'src/sysusers/sysusers.c',
4028 include_directories : includes,
4029 link_with : [libshared],
4030 dependencies : [userspace,
4031 versiondep],
4032 install_rpath : rootpkglibdir,
4033 install : true,
4034 install_dir : rootbindir)
4035 public_programs += exe
4036
4037 if want_tests != 'false'
4038 test('test-sysusers',
4039 test_sysusers_sh,
4040 # https://github.com/mesonbuild/meson/issues/2681
4041 args : exe.full_path())
4042 endif
4043
4044 exe = executable(
4045 'systemd-sysusers.standalone',
4046 'src/sysusers/sysusers.c',
4047 include_directories : includes,
4048 c_args : '-DSTANDALONE',
4049 link_with : [libshared_static,
4050 libbasic,
4051 libbasic_gcrypt,
4052 libsystemd_static],
4053 dependencies : [userspace,
4054 versiondep],
4055 build_by_default: have_standalone_binaries,
4056 install : have_standalone_binaries,
4057 install_dir : rootbindir)
4058 if have_standalone_binaries
4059 public_programs += exe
4060
4061 if want_tests != 'false'
4062 test('test-sysusers.standalone',
4063 test_sysusers_sh,
4064 # https://github.com/mesonbuild/meson/issues/2681
4065 args : exe.full_path())
4066 endif
4067 endif
4068 endif
4069
4070 if conf.get('ENABLE_TMPFILES') == 1
4071 exe = executable(
4072 'systemd-tmpfiles',
4073 systemd_tmpfiles_sources,
4074 include_directories : includes,
4075 link_with : [libshared],
4076 dependencies : [libacl,
4077 userspace,
4078 versiondep],
4079 install_rpath : rootpkglibdir,
4080 install : true,
4081 install_dir : rootbindir)
4082 public_programs += exe
4083
4084 if want_tests != 'false'
4085 test('test-systemd-tmpfiles',
4086 test_systemd_tmpfiles_py,
4087 # https://github.com/mesonbuild/meson/issues/2681
4088 args : exe.full_path())
4089 endif
4090
4091 exe = executable(
4092 'systemd-tmpfiles.standalone',
4093 systemd_tmpfiles_sources,
4094 include_directories : includes,
4095 c_args : '-DSTANDALONE',
4096 link_with : [libshared_static,
4097 libbasic,
4098 libbasic_gcrypt,
4099 libsystemd_static],
4100 dependencies : [libacl,
4101 userspace,
4102 versiondep],
4103 build_by_default: have_standalone_binaries,
4104 install : have_standalone_binaries,
4105 install_dir : rootbindir)
4106 if have_standalone_binaries
4107 public_programs += exe
4108
4109 if want_tests != 'false'
4110 test('test-systemd-tmpfiles.standalone',
4111 test_systemd_tmpfiles_py,
4112 # https://github.com/mesonbuild/meson/issues/2681
4113 args : exe.full_path())
4114 endif
4115 endif
4116 endif
4117
4118 if conf.get('ENABLE_HWDB') == 1
4119 systemd_hwdb = executable(
4120 'systemd-hwdb',
4121 'src/hwdb/hwdb.c',
4122 include_directories : includes,
4123 link_with : udev_link_with,
4124 dependencies : [userspace,
4125 versiondep],
4126 install_rpath : udev_rpath,
4127 install : true,
4128 install_dir : rootbindir)
4129 public_programs += systemd_hwdb
4130
4131 if want_tests != 'false'
4132 test('hwdb-test',
4133 hwdb_test_sh,
4134 suite : 'dist',
4135 args : [systemd_hwdb.full_path()],
4136 timeout : 90)
4137 endif
4138 endif
4139
4140 if conf.get('ENABLE_QUOTACHECK') == 1
4141 executable(
4142 'systemd-quotacheck',
4143 'src/quotacheck/quotacheck.c',
4144 include_directories : includes,
4145 link_with : [libshared],
4146 dependencies : userspace,
4147 install_rpath : rootpkglibdir,
4148 install : true,
4149 install_dir : rootlibexecdir)
4150 endif
4151
4152 public_programs += executable(
4153 'systemd-socket-proxyd',
4154 'src/socket-proxy/socket-proxyd.c',
4155 include_directories : includes,
4156 link_with : [libshared],
4157 dependencies : [threads,
4158 userspace,
4159 versiondep],
4160 install_rpath : rootpkglibdir,
4161 install : true,
4162 install_dir : rootlibexecdir)
4163
4164 udevadm = executable(
4165 'udevadm',
4166 udevadm_sources,
4167 include_directories : includes,
4168 link_with : [libudevd_core],
4169 dependencies : [libacl,
4170 libblkid,
4171 libidn,
4172 libkmod,
4173 threads,
4174 userspace,
4175 versiondep],
4176 install_rpath : udev_rpath,
4177 install : true,
4178 install_dir : rootbindir)
4179 public_programs += udevadm
4180
4181 if want_tests != 'false'
4182 test('udev-rules-check',
4183 udevadm,
4184 suite : 'dist',
4185 args : ['verify', '--resolve-names=never', all_rules])
4186 endif
4187
4188 if conf.get('ENABLE_REPART') == 1
4189 exe = executable(
4190 'systemd-repart',
4191 systemd_repart_sources,
4192 include_directories : includes,
4193 link_with : [libshared,
4194 libshared_fdisk],
4195 dependencies : [libblkid,
4196 libfdisk,
4197 libopenssl,
4198 threads,
4199 userspace,
4200 versiondep],
4201 install_rpath : rootpkglibdir,
4202 install : true,
4203 install_dir : rootbindir)
4204 public_programs += exe
4205
4206 exe = executable(
4207 'systemd-repart.standalone',
4208 systemd_repart_sources,
4209 include_directories : includes,
4210 c_args : '-DSTANDALONE',
4211 link_with : [libshared_static,
4212 libbasic,
4213 libbasic_gcrypt,
4214 libsystemd_static,
4215 libshared_fdisk],
4216 dependencies : [libblkid,
4217 libfdisk,
4218 libopenssl,
4219 threads,
4220 userspace,
4221 versiondep],
4222 build_by_default: have_standalone_binaries,
4223 install_rpath : rootpkglibdir,
4224 install : have_standalone_binaries,
4225 install_dir : rootbindir)
4226 if have_standalone_binaries
4227 public_programs += exe
4228 endif
4229 endif
4230
4231 executable(
4232 'systemd-shutdown',
4233 systemd_shutdown_sources,
4234 include_directories : includes,
4235 link_with : [libshared],
4236 dependencies : [libmount,
4237 userspace,
4238 versiondep],
4239 install_rpath : rootpkglibdir,
4240 install : true,
4241 install_dir : rootlibexecdir)
4242
4243 executable(
4244 'systemd-shutdown.standalone',
4245 systemd_shutdown_sources,
4246 include_directories : includes,
4247 c_args : '-DSTANDALONE',
4248 link_with : [libshared_static,
4249 libbasic,
4250 libsystemd_static],
4251 dependencies : [libmount,
4252 userspace,
4253 versiondep],
4254 build_by_default: have_standalone_binaries,
4255 install_rpath : rootpkglibdir,
4256 install : have_standalone_binaries,
4257 install_dir : rootlibexecdir)
4258
4259 executable(
4260 'systemd-update-done',
4261 'src/update-done/update-done.c',
4262 include_directories : includes,
4263 link_with : [libshared],
4264 dependencies : [userspace,
4265 versiondep],
4266 install_rpath : rootpkglibdir,
4267 install : true,
4268 install_dir : rootlibexecdir)
4269
4270 executable(
4271 'systemd-update-utmp',
4272 'src/update-utmp/update-utmp.c',
4273 include_directories : includes,
4274 link_with : [libshared],
4275 dependencies : [libaudit,
4276 userspace,
4277 versiondep],
4278 install_rpath : rootpkglibdir,
4279 install : (conf.get('ENABLE_UTMP') == 1),
4280 install_dir : rootlibexecdir)
4281
4282 if conf.get('HAVE_KMOD') == 1
4283 executable(
4284 'systemd-modules-load',
4285 'src/modules-load/modules-load.c',
4286 include_directories : includes,
4287 link_with : [libshared],
4288 dependencies : [libkmod,
4289 userspace,
4290 versiondep],
4291 install_rpath : rootpkglibdir,
4292 install : true,
4293 install_dir : rootlibexecdir)
4294
4295 meson.add_install_script('sh', '-c',
4296 mkdir_p.format(modulesloaddir))
4297 if install_sysconfdir
4298 meson.add_install_script('sh', '-c',
4299 mkdir_p.format(sysconfdir / 'modules-load.d'))
4300 endif
4301 endif
4302
4303 public_programs += executable(
4304 'systemd-nspawn',
4305 systemd_nspawn_sources,
4306 include_directories : includes,
4307 link_with : [libnspawn_core,
4308 libshared],
4309 dependencies : [libblkid,
4310 libseccomp,
4311 userspace,
4312 versiondep],
4313 install_rpath : rootpkglibdir,
4314 install : true)
4315
4316 if conf.get('ENABLE_NETWORKD') == 1
4317 dbus_programs += executable(
4318 'systemd-networkd',
4319 systemd_networkd_sources,
4320 include_directories : network_includes,
4321 link_with : [libnetworkd_core,
4322 libsystemd_network,
4323 networkd_link_with],
4324 dependencies : [threads,
4325 userspace,
4326 versiondep],
4327 install_rpath : rootpkglibdir,
4328 install : true,
4329 install_dir : rootlibexecdir)
4330
4331 public_programs += executable(
4332 'systemd-networkd-wait-online',
4333 systemd_networkd_wait_online_sources,
4334 include_directories : includes,
4335 link_with : [networkd_link_with],
4336 dependencies : [userspace,
4337 versiondep],
4338 install_rpath : rootpkglibdir,
4339 install : true,
4340 install_dir : rootlibexecdir)
4341
4342 public_programs += executable(
4343 'networkctl',
4344 networkctl_sources,
4345 include_directories : libsystemd_network_includes,
4346 link_with : [libsystemd_network,
4347 networkd_link_with],
4348 dependencies : [userspace,
4349 versiondep],
4350 install_rpath : rootpkglibdir,
4351 install : true,
4352 install_dir : rootbindir)
4353 endif
4354
4355 exe = executable(
4356 'systemd-network-generator',
4357 network_generator_sources,
4358 include_directories : includes,
4359 link_with : [networkd_link_with],
4360 dependencies : [userspace,
4361 versiondep],
4362 install_rpath : rootpkglibdir,
4363 install : true,
4364 install_dir : rootlibexecdir)
4365
4366 if want_tests != 'false'
4367 test('test-network-generator-conversion',
4368 test_network_generator_conversion_sh,
4369 # https://github.com/mesonbuild/meson/issues/2681
4370 args : exe.full_path(),
4371 depends : exe)
4372 endif
4373
4374 executable(
4375 'systemd-sulogin-shell',
4376 'src/sulogin-shell/sulogin-shell.c',
4377 include_directories : includes,
4378 link_with : [libshared],
4379 dependencies : [userspace,
4380 versiondep],
4381 install_rpath : rootpkglibdir,
4382 install : true,
4383 install_dir : rootlibexecdir)
4384
4385 kernel_install = executable(
4386 'kernel-install',
4387 'src/kernel-install/kernel-install.c',
4388 include_directories : includes,
4389 link_with : [libshared],
4390 dependencies : [userspace,
4391 versiondep],
4392 install_rpath : rootpkglibdir,
4393 install : want_kernel_install,
4394 install_dir : bindir)
4395 public_programs += kernel_install
4396
4397 ukify = custom_target(
4398 'ukify',
4399 input : 'src/ukify/ukify.py',
4400 output : 'ukify',
4401 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
4402 install : want_ukify,
4403 install_mode : 'rwxr-xr-x',
4404 install_dir : rootlibexecdir)
4405 if want_ukify
4406 public_programs += ukify
4407 endif
4408
4409 if want_tests != 'false' and want_kernel_install
4410 args = [kernel_install.full_path(), loaderentry_install.full_path(), uki_copy_install]
4411 deps = [kernel_install, loaderentry_install]
4412 if want_ukify and boot_stubs.length() > 0
4413 args += [ukify.full_path(), ukify_install.full_path(), boot_stubs[0]]
4414 deps += [ukify, ukify_install, boot_stubs[0]]
4415 endif
4416
4417 test('test-kernel-install',
4418 test_kernel_install_sh,
4419 env : test_env,
4420 args : args,
4421 depends: deps)
4422 endif
4423
4424 ############################################################
4425
4426 runtest_env = custom_target(
4427 'systemd-runtest.env',
4428 output : 'systemd-runtest.env',
4429 command : [sh, '-c',
4430 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
4431 project_source_root / 'test',
4432 project_build_root / 'catalog')],
4433 depends : catalogs,
4434 build_by_default : true)
4435
4436 test_cflags = ['-DTEST_CODE=1']
4437 # We intentionally do not do inline initializations with definitions for a
4438 # bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
4439 # use the variable unexpectedly. This triggers a lot of maybe-uninitialized
4440 # false positives when the combination of -O2 and -flto is used. Suppress them.
4441 if '-O2' in c_args and '-flto=auto' in c_args
4442 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
4443 endif
4444
4445 foreach test : simple_tests
4446 tests += { 'sources' : [test] }
4447 endforeach
4448
4449 TESTS = {}
4450 foreach test : tests
4451 sources = test.get('sources')
4452 condition = test.get('condition', '')
4453 type = test.get('type', '')
4454 base = test.get('base', {})
4455 deps = [
4456 base.get('dependencies', []),
4457 test.get('dependencies', []),
4458 versiondep,
4459 ]
4460
4461 name = fs.name(sources[0])
4462 if not name.endswith('.cc')
4463 deps += [userspace]
4464 endif
4465 name = fs.stem(name)
4466
4467 suite = fs.name(fs.parent(sources[0])).replace('sd-', '')
4468
4469 if condition != '' and conf.get(condition) == 0
4470 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
4471 continue
4472 endif
4473
4474 exe = executable(
4475 name,
4476 sources,
4477 include_directories : [base.get('includes', []), test.get('includes', includes)],
4478 link_with : [base.get('link_with', []), test.get('link_with', libshared)],
4479 dependencies : deps,
4480 c_args : [test_cflags, test.get('c_args', [])],
4481 build_by_default : want_tests != 'false',
4482 install_rpath : rootpkglibdir,
4483 install : install_tests,
4484 install_dir : unittestsdir / type,
4485 link_depends : runtest_env)
4486
4487 if type == 'manual'
4488 message('@0@ is a manual test'.format(name))
4489 elif type == 'unsafe' and want_tests != 'unsafe'
4490 message('@0@ is an unsafe test'.format(name))
4491 elif want_tests != 'false'
4492 test(name, exe,
4493 env : test_env,
4494 timeout : test.get('timeout', 30),
4495 suite : suite,
4496 is_parallel : test.get('parallel', true))
4497 endif
4498
4499 TESTS += { name : exe }
4500 endforeach
4501
4502 exe = executable(
4503 'test-libsystemd-sym',
4504 test_libsystemd_sym_c,
4505 include_directories : includes,
4506 link_with : [libsystemd],
4507 dependencies : userspace,
4508 build_by_default : want_tests != 'false',
4509 install : install_tests,
4510 install_dir : unittestsdir)
4511 if want_tests != 'false'
4512 test('test-libsystemd-sym', exe)
4513 endif
4514
4515 exe = executable(
4516 'test-libsystemd-static-sym',
4517 test_libsystemd_sym_c,
4518 include_directories : includes,
4519 link_with : [install_libsystemd_static],
4520 dependencies : [
4521 # threads is already included in dependencies on the library,
4522 # but does not seem to get propagated. Add here as a work-around.
4523 threads,
4524 userspace,
4525 ],
4526 build_by_default : want_tests != 'false' and static_libsystemd != 'false',
4527 install : install_tests and static_libsystemd != 'false',
4528 install_dir : unittestsdir)
4529 if want_tests != 'false' and static_libsystemd != 'false'
4530 test('test-libsystemd-static-sym', exe)
4531 endif
4532
4533 exe = executable(
4534 'test-libudev-sym',
4535 test_libudev_sym_c,
4536 include_directories : libudev_includes,
4537 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
4538 link_with : [libudev],
4539 dependencies : userspace,
4540 build_by_default : want_tests != 'false',
4541 install : install_tests,
4542 install_dir : unittestsdir)
4543 if want_tests != 'false'
4544 test('test-libudev-sym', exe)
4545 endif
4546
4547 exe = executable(
4548 'test-libudev-static-sym',
4549 test_libudev_sym_c,
4550 include_directories : libudev_includes,
4551 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
4552 link_with : [install_libudev_static],
4553 dependencies : userspace,
4554 build_by_default : want_tests != 'false' and static_libudev != 'false',
4555 install : install_tests and static_libudev != 'false',
4556 install_dir : unittestsdir)
4557 if want_tests != 'false' and static_libudev != 'false'
4558 test('test-libudev-static-sym', exe)
4559 endif
4560
4561 if want_tests != 'false'
4562 exe = TESTS.get('udev-rule-runner')
4563 test('test-udev',
4564 test_udev_py,
4565 args : ['-v'],
4566 env : ['UDEV_RULE_RUNNER=' + exe.full_path()],
4567 depends : exe,
4568 timeout : 180)
4569 endif
4570
4571 ############################################################
4572
4573 foreach fuzzer : simple_fuzzers
4574 fuzzers += { 'sources' : [fuzzer] }
4575 endforeach
4576
4577 fuzzer_exes = []
4578
4579 foreach fuzzer : fuzzers
4580 sources = fuzzer.get('sources')
4581 base = fuzzer.get('base', {})
4582 dependencies = [base.get('dependencies', []), fuzzer.get('dependencies', [])]
4583 link_args = []
4584
4585 if want_ossfuzz
4586 dependencies += fuzzing_engine
4587 elif want_libfuzzer
4588 if fuzzing_engine.found()
4589 dependencies += fuzzing_engine
4590 else
4591 link_args += ['-fsanitize=fuzzer']
4592 endif
4593 else
4594 sources += files('src/fuzz/fuzz-main.c')
4595 endif
4596 sources += fuzz_generated_directives
4597
4598 name = fs.stem(sources[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 = fs.name(exec.full_path())
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 if git.found()
4764 all_files = run_command(
4765 env, '-u', 'GIT_WORK_TREE',
4766 git, '--git-dir=@0@/.git'.format(project_source_root),
4767 'ls-files', ':/*.[ch]', ':/*.cc',
4768 check : false)
4769 if all_files.returncode() == 0
4770 all_files = files(all_files.stdout().split())
4771
4772 custom_target(
4773 'tags',
4774 output : 'tags',
4775 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
4776 run_target(
4777 'ctags',
4778 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
4779
4780 ############################################
4781
4782 if want_tests != 'false' and conf.get('BUILD_MODE_DEVELOPER') == 1
4783 test('check-includes',
4784 files('tools/check-includes.py'),
4785 args: all_files,
4786 env : ['PROJECT_SOURCE_ROOT=@0@'.format(project_source_root)])
4787 endif
4788 endif
4789
4790 ####################################################
4791
4792 git_contrib_sh = find_program('tools/git-contrib.sh')
4793 run_target(
4794 'git-contrib',
4795 command : [git_contrib_sh])
4796
4797 ####################################################
4798
4799 git_head = run_command(
4800 git, '--git-dir=@0@/.git'.format(project_source_root),
4801 'rev-parse', 'HEAD',
4802 check : false).stdout().strip()
4803 git_head_short = run_command(
4804 git, '--git-dir=@0@/.git'.format(project_source_root),
4805 'rev-parse', '--short=7', 'HEAD',
4806 check : false).stdout().strip()
4807
4808 run_target(
4809 'git-snapshot',
4810 command : [git, 'archive',
4811 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
4812 git_head_short),
4813 '--prefix', 'systemd-@0@/'.format(git_head),
4814 'HEAD'])
4815 endif
4816
4817 ############################################################
4818
4819 check_api_docs_sh = find_program('tools/check-api-docs.sh')
4820 run_target(
4821 'check-api-docs',
4822 depends : [man, libsystemd, libudev],
4823 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
4824
4825 alias_target('update-dbus-docs', update_dbus_docs)
4826 alias_target('update-man-rules', update_man_rules)
4827
4828 if not meson.is_cross_build()
4829 custom_target(
4830 'export-dbus-interfaces',
4831 output : fs.name(dbus_interfaces_dir),
4832 install : dbus_interfaces_dir != 'no',
4833 install_dir : fs.parent(dbus_interfaces_dir),
4834 command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
4835 endif
4836
4837 ############################################################
4838
4839 alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
4840 check : true).stdout().strip()
4841
4842 summary({
4843 'split /usr' : split_usr,
4844 'split bin-sbin' : split_bin,
4845 'prefix directory' : prefixdir,
4846 'rootprefix directory' : rootprefixdir,
4847 'sysconf directory' : sysconfdir,
4848 'include directory' : includedir,
4849 'lib directory' : libdir,
4850 'rootlib directory' : rootlibdir,
4851 'SysV init scripts' : sysvinit_path,
4852 'SysV rc?.d directories' : sysvrcnd_path,
4853 'PAM modules directory' : pamlibdir,
4854 'PAM configuration directory' : pamconfdir,
4855 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
4856 'RPM macros directory' : rpmmacrosdir,
4857 'modprobe.d directory' : modprobedir,
4858 'D-Bus policy directory' : dbuspolicydir,
4859 'D-Bus session directory' : dbussessionservicedir,
4860 'D-Bus system directory' : dbussystemservicedir,
4861 'D-Bus interfaces directory' : dbus_interfaces_dir,
4862 'bash completions directory' : bashcompletiondir,
4863 'zsh completions directory' : zshcompletiondir,
4864 'private shared lib version tag' : shared_lib_tag,
4865 'extra start script' : get_option('rc-local'),
4866 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
4867 get_option('debug-tty')),
4868 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
4869 conf.get('SYSTEM_ALLOC_UID_MIN')),
4870 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
4871 conf.get('SYSTEM_ALLOC_GID_MIN')),
4872 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
4873 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
4874 'static UID/GID allocations' : ' '.join(static_ugids),
4875 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
4876 'render group access mode' : get_option('group-render-mode'),
4877 'certificate root directory' : get_option('certificate-root'),
4878 'support URL' : support_url,
4879 'nobody user name' : nobody_user,
4880 'nobody group name' : nobody_group,
4881 'fallback hostname' : get_option('fallback-hostname'),
4882 'default compression method' : compression,
4883 'default DNSSEC mode' : default_dnssec,
4884 'default DNS-over-TLS mode' : default_dns_over_tls,
4885 'default mDNS mode' : default_mdns,
4886 'default LLMNR mode' : default_llmnr,
4887 'default DNS servers' : dns_servers.split(' '),
4888 'default NTP servers' : ntp_servers.split(' '),
4889 'default cgroup hierarchy' : default_hierarchy,
4890 'default net.naming-scheme value' : default_net_naming_scheme,
4891 'default KillUserProcesses value' : kill_user_processes,
4892 'default locale' : default_locale,
4893 'default nspawn locale' : nspawn_locale,
4894 'default status unit format' : status_unit_format_default,
4895 'default user $PATH' :
4896 default_user_path != '' ? default_user_path : '(same as system services)',
4897 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
4898 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
4899
4900 # TODO:
4901 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
4902 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
4903 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
4904
4905 found = []
4906 missing = []
4907
4908 foreach tuple : [
4909 # dependencies
4910 ['ACL'],
4911 ['AUDIT'],
4912 ['AppArmor'],
4913 ['IMA'],
4914 ['PAM'],
4915 ['SECCOMP'],
4916 ['SELinux'],
4917 ['SMACK'],
4918 ['blkid'],
4919 ['elfutils'],
4920 ['gcrypt'],
4921 ['gnutls'],
4922 ['libbpf'],
4923 ['libcryptsetup'],
4924 ['libcryptsetup-plugins'],
4925 ['libcurl'],
4926 ['libfdisk'],
4927 ['libfido2'],
4928 ['libidn'],
4929 ['libidn2'],
4930 ['libiptc'],
4931 ['microhttpd'],
4932 ['openssl'],
4933 ['p11kit'],
4934 ['pcre2'],
4935 ['pwquality'],
4936 ['qrencode'],
4937 ['tpm2'],
4938 ['xkbcommon'],
4939
4940 # compression libs
4941 ['zstd'],
4942 ['lz4'],
4943 ['xz'],
4944 ['zlib'],
4945 ['bzip2'],
4946
4947 # components
4948 ['backlight'],
4949 ['binfmt'],
4950 ['bootloader'],
4951 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
4952 ['coredump'],
4953 ['efi'],
4954 ['environment.d'],
4955 ['firstboot'],
4956 ['hibernate'],
4957 ['homed'],
4958 ['hostnamed'],
4959 ['hwdb'],
4960 ['importd'],
4961 ['initrd'],
4962 ['kernel-install'],
4963 ['localed'],
4964 ['logind'],
4965 ['machined'],
4966 ['networkd'],
4967 ['nss-myhostname'],
4968 ['nss-mymachines'],
4969 ['nss-resolve'],
4970 ['nss-systemd'],
4971 ['oomd'],
4972 ['portabled'],
4973 ['pstore'],
4974 ['quotacheck'],
4975 ['randomseed'],
4976 ['repart'],
4977 ['resolve'],
4978 ['rfkill'],
4979 ['sysext'],
4980 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
4981 ['sysupdate'],
4982 ['sysusers'],
4983 ['timedated'],
4984 ['timesyncd'],
4985 ['tmpfiles'],
4986 ['userdb'],
4987 ['vconsole'],
4988 ['xdg-autostart'],
4989
4990 # optional features
4991 ['idn'],
4992 ['polkit'],
4993 ['nscd'],
4994 ['legacy-pkla', install_polkit_pkla],
4995 ['kmod'],
4996 ['xenctrl'],
4997 ['dbus'],
4998 ['glib'],
4999 ['tpm'],
5000 ['man pages', want_man],
5001 ['html pages', want_html],
5002 ['man page indices', want_man and have_lxml],
5003 ['SysV compat'],
5004 ['compat-mutable-uid-boundaries'],
5005 ['utmp'],
5006 ['ldconfig'],
5007 ['adm group', get_option('adm-group')],
5008 ['wheel group', get_option('wheel-group')],
5009 ['gshadow'],
5010 ['debug hashmap'],
5011 ['debug mmap cache'],
5012 ['debug siphash'],
5013 ['trace logging', conf.get('LOG_TRACE') == 1],
5014 ['slow tests', slow_tests],
5015 ['fuzz tests', fuzz_tests],
5016 ['install tests', install_tests],
5017 ['link-udev-shared', get_option('link-udev-shared')],
5018 ['link-systemctl-shared', get_option('link-systemctl-shared')],
5019 ['link-networkd-shared', get_option('link-networkd-shared')],
5020 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
5021 ['link-journalctl-shared', get_option('link-journalctl-shared')],
5022 ['link-boot-shared', get_option('link-boot-shared')],
5023 ['link-portabled-shared', get_option('link-portabled-shared')],
5024 ['first-boot-full-preset'],
5025 ['fexecve'],
5026 ['standalone-binaries', get_option('standalone-binaries')],
5027 ['coverage', get_option('b_coverage')],
5028 ]
5029
5030 if tuple.length() >= 2
5031 cond = tuple[1]
5032 else
5033 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
5034 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
5035 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
5036 endif
5037 if cond
5038 found += tuple[0]
5039 else
5040 missing += tuple[0]
5041 endif
5042 endforeach
5043
5044 if static_libsystemd == 'false'
5045 missing += 'static-libsystemd'
5046 else
5047 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
5048 endif
5049
5050 if static_libudev == 'false'
5051 missing += 'static-libudev'
5052 else
5053 found += 'static-libudev(@0@)'.format(static_libudev)
5054 endif
5055
5056 if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
5057 found += 'cryptolib(openssl)'
5058 elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
5059 found += 'cryptolib(gcrypt)'
5060 else
5061 missing += 'cryptolib'
5062 endif
5063
5064 if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
5065 found += 'DNS-over-TLS(gnutls)'
5066 elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
5067 found += 'DNS-over-TLS(openssl)'
5068 else
5069 missing += 'DNS-over-TLS'
5070 endif
5071
5072 summary({
5073 'enabled' : ', '.join(found),
5074 'disabled' : ', '.join(missing)},
5075 section : 'Features')
5076
5077 if rootprefixdir != rootprefix_default
5078 warning('\n' +
5079 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
5080 'systemd used fixed names for unit file directories and other paths, so anything\n' +
5081 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))
5082 endif