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