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