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