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