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