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