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