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