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