]> git.ipfire.org Git - thirdparty/systemd.git/blame - meson.build
fuzz: shorten name of fuzz test case
[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
132c73b5
HS
1016libatomic = []
1017if not cc.links('''#include <stdint.h>
1018 int main() {
1019 char i;
1020 __atomic_exchange_1(&i, 1, 0);
1021 return 1;
1022 }''',
1023 name : 'Atomic builtin requires -latomic')
1024 libatomic = cc.find_library('atomic')
1025endif
5c23128d
ZJS
1026threads = dependency('threads')
1027librt = cc.find_library('rt')
1028libm = cc.find_library('m')
1029libdl = cc.find_library('dl')
1030libcrypt = cc.find_library('crypt')
1031
06ca077b 1032crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
e8644a41 1033foreach ident : [
feee7f62
LB
1034 ['crypt_ra', crypt_header],
1035 ['crypt_preferred_method', crypt_header],
1036 ['crypt_gensalt_ra', crypt_header]]
e8644a41
ZJS
1037
1038 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
1039 dependencies : libcrypt)
1040 conf.set10('HAVE_' + ident[0].to_upper(), have)
1041endforeach
1042
1800cc85
ZJS
1043libcap = dependency('libcap', required : false)
1044if not libcap.found()
1045 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
1046 libcap = cc.find_library('cap')
1047endif
1048
7d861e12 1049want_bpf_framework = get_option('bpf-framework')
b88323e4 1050bpf_compiler = get_option('bpf-compiler')
7d861e12
JK
1051bpf_framework_required = want_bpf_framework == 'true'
1052
87e462f7 1053libbpf_version_requirement = '>= 0.1.0'
b88323e4
JH
1054if bpf_compiler == 'gcc'
1055 libbpf_version_requirement = '>= 1.0.0'
1056endif
1057libbpf = dependency('libbpf', required : bpf_framework_required, version : libbpf_version_requirement)
7d861e12
JK
1058conf.set10('HAVE_LIBBPF', libbpf.found())
1059
b88323e4
JH
1060bpftool_strip_version_requirement = '>= 5.13.0'
1061if bpf_compiler == 'gcc'
1062 bpftool_strip_version_requirement = '>= 7.0.0'
1063endif
1064
3d954ef1 1065if want_bpf_framework == 'false' or not libbpf.found() or skip_deps
cf2dc690 1066 conf.set10('BPF_FRAMEWORK', false)
7d861e12 1067else
76abad4d
JH
1068 clang_found = false
1069 clang_supports_bpf = false
1070 bpf_gcc_found = false
b88323e4 1071 bpftool_strip = false
76abad4d
JH
1072 deps_found = false
1073
1074 if bpf_compiler == 'clang'
1075 # Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu
1076 # (like clang-10/llvm-strip-10)
1077 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')
1078 r = find_program('clang', required : bpf_framework_required, version : '>= 10.0.0')
1079 clang_found = r.found()
1080 if clang_found
1081 clang = r.path()
1082 endif
1083 # Assume that the required flags are supported by the found clang.
1084 clang_supports_flags = clang_found
1085 else
1086 clang_found = true
1087 clang = cc.cmd_array()
1088 clang_supports_flags = cc.has_argument('-Wno-compare-distinct-pointer-types')
dc7e9c1b 1089 endif
a6ac8b5a 1090
76abad4d
JH
1091 if clang_found
1092 # Check if 'clang -target bpf' is supported.
1093 clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0
1094 endif
1095 elif bpf_compiler == 'gcc'
1096 warning('GCC BPF Compiler support is experimental and not recommended.')
1097 bpf_gcc = find_program('bpf-gcc',
1098 required : true,
1099 version : '>= 12.1.0')
1100 bpf_gcc_found = bpf_gcc.found()
a6ac8b5a
YW
1101 endif
1102
76abad4d
JH
1103 if clang_supports_bpf or bpf_gcc_found
1104 # Debian installs this in /usr/sbin/ which is not in $PATH.
1105 # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian.
1106 # We use 'bpftool gen object' subcommand for bpftool strip, it was added by d80b2fcbe0a023619e0fc73112f2a02c2662f6ab (v5.13).
b88323e4 1107 bpftool_strip_required = bpf_framework_required and bpf_compiler == 'gcc'
e3759ac4
JH
1108 bpftool = find_program('bpftool',
1109 '/usr/sbin/bpftool',
b88323e4
JH
1110 required : bpftool_strip_required,
1111 version : bpftool_strip_version_requirement)
e3759ac4 1112
76abad4d
JH
1113 if bpftool.found()
1114 bpftool_strip = true
1115 deps_found = true
b88323e4 1116 elif bpf_compiler == 'clang'
76abad4d
JH
1117 # We require the 'bpftool gen skeleton' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6).
1118 bpftool = find_program('bpftool',
1119 '/usr/sbin/bpftool',
1120 required : bpf_framework_required,
1121 version : '>= 5.6.0')
e3759ac4 1122 endif
68e101da 1123
76abad4d
JH
1124 # We use `llvm-strip` as a fallback if `bpftool gen object` strip support is not available.
1125 if not bpftool_strip and bpftool.found() and clang_supports_bpf
1126 if not meson.is_cross_build()
1127 llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip',
1128 check : true).stdout().strip()
1129 else
1130 llvm_strip_bin = 'llvm-strip'
1131 endif
1132 llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0')
1133 deps_found = llvm_strip.found()
1134 endif
1135 endif
68e101da 1136
7d861e12 1137 # Can build BPF program from source code in restricted C
d40ce018 1138 conf.set10('BPF_FRAMEWORK', deps_found)
7d861e12
JK
1139endif
1140
5c23128d 1141libmount = dependency('mount',
c0b4b0f8 1142 version : fuzzer_build ? '>= 0' : '>= 2.30')
5c23128d 1143
e594a3b1
LP
1144want_libfdisk = get_option('fdisk')
1145if want_libfdisk != 'false' and not skip_deps
1146 libfdisk = dependency('fdisk',
baec7d78 1147 version : '>= 2.32',
e594a3b1
LP
1148 required : want_libfdisk == 'true')
1149 have = libfdisk.found()
1150else
1151 have = false
1152 libfdisk = []
1153endif
1154conf.set10('HAVE_LIBFDISK', have)
1155
70a5db58
LP
1156want_pwquality = get_option('pwquality')
1157if want_pwquality != 'false' and not skip_deps
1158 libpwquality = dependency('pwquality', required : want_pwquality == 'true')
1159 have = libpwquality.found()
1160else
1161 have = false
1162 libpwquality = []
1163endif
1164conf.set10('HAVE_PWQUALITY', have)
1165
5c23128d 1166want_seccomp = get_option('seccomp')
87ac55a1 1167if want_seccomp != 'false' and not skip_deps
37efbbd8 1168 libseccomp = dependency('libseccomp',
9f0e9c01 1169 version : '>= 2.3.1',
37efbbd8 1170 required : want_seccomp == 'true')
349cc4a5 1171 have = libseccomp.found()
5c23128d 1172else
349cc4a5 1173 have = false
37efbbd8 1174 libseccomp = []
5c23128d 1175endif
349cc4a5 1176conf.set10('HAVE_SECCOMP', have)
5c23128d
ZJS
1177
1178want_selinux = get_option('selinux')
87ac55a1 1179if want_selinux != 'false' and not skip_deps
37efbbd8
ZJS
1180 libselinux = dependency('libselinux',
1181 version : '>= 2.1.9',
1182 required : want_selinux == 'true')
349cc4a5 1183 have = libselinux.found()
5c23128d 1184else
349cc4a5 1185 have = false
37efbbd8 1186 libselinux = []
5c23128d 1187endif
349cc4a5 1188conf.set10('HAVE_SELINUX', have)
5c23128d
ZJS
1189
1190want_apparmor = get_option('apparmor')
87ac55a1 1191if want_apparmor != 'false' and not skip_deps
37efbbd8 1192 libapparmor = dependency('libapparmor',
2ffadd3c 1193 version : '>= 2.13',
37efbbd8 1194 required : want_apparmor == 'true')
349cc4a5 1195 have = libapparmor.found()
5c23128d 1196else
349cc4a5 1197 have = false
37efbbd8 1198 libapparmor = []
5c23128d 1199endif
349cc4a5 1200conf.set10('HAVE_APPARMOR', have)
5c23128d 1201
07b382cc
ZJS
1202have = get_option('smack') and get_option('smack-run-label') != ''
1203conf.set10('HAVE_SMACK_RUN_LABEL', have)
1204if have
1205 conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
1206endif
5c23128d 1207
aa5ae971
ŁS
1208have = get_option('smack') and get_option('smack-default-process-label') != ''
1209if have
1210 conf.set_quoted('SMACK_DEFAULT_PROCESS_LABEL', get_option('smack-default-process-label'))
1211endif
1212
3ca0cb73
ZJS
1213want_polkit = get_option('polkit')
1214install_polkit = false
1215install_polkit_pkla = false
87ac55a1 1216if want_polkit != 'false' and not skip_deps
37efbbd8 1217 install_polkit = true
3ca0cb73 1218
37efbbd8
ZJS
1219 libpolkit = dependency('polkit-gobject-1',
1220 required : false)
1221 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
1222 message('Old polkit detected, will install pkla files')
1223 install_polkit_pkla = true
1224 endif
3ca0cb73 1225endif
349cc4a5 1226conf.set10('ENABLE_POLKIT', install_polkit)
3ca0cb73 1227
36f0387e 1228want_acl = get_option('acl')
87ac55a1 1229if want_acl != 'false' and not skip_deps
36f0387e 1230 libacl = cc.find_library('acl', required : want_acl == 'true')
349cc4a5 1231 have = libacl.found()
36f0387e 1232else
349cc4a5 1233 have = false
36f0387e
ZJS
1234 libacl = []
1235endif
349cc4a5 1236conf.set10('HAVE_ACL', have)
36f0387e 1237
5c23128d 1238want_audit = get_option('audit')
87ac55a1 1239if want_audit != 'false' and not skip_deps
37efbbd8 1240 libaudit = dependency('audit', required : want_audit == 'true')
349cc4a5 1241 have = libaudit.found()
5c23128d 1242else
349cc4a5 1243 have = false
37efbbd8 1244 libaudit = []
5c23128d 1245endif
349cc4a5 1246conf.set10('HAVE_AUDIT', have)
5c23128d
ZJS
1247
1248want_blkid = get_option('blkid')
87ac55a1 1249if want_blkid != 'false' and not skip_deps
37efbbd8 1250 libblkid = dependency('blkid', required : want_blkid == 'true')
349cc4a5 1251 have = libblkid.found()
4fcc033b
KZ
1252
1253 conf.set10('HAVE_BLKID_PROBE_SET_HINT',
1254 have and cc.has_function('blkid_probe_set_hint', dependencies : libblkid))
5c23128d 1255else
349cc4a5 1256 have = false
37efbbd8 1257 libblkid = []
5c23128d 1258endif
349cc4a5 1259conf.set10('HAVE_BLKID', have)
5c23128d
ZJS
1260
1261want_kmod = get_option('kmod')
87ac55a1 1262if want_kmod != 'false' and not skip_deps
37efbbd8
ZJS
1263 libkmod = dependency('libkmod',
1264 version : '>= 15',
1265 required : want_kmod == 'true')
349cc4a5 1266 have = libkmod.found()
5c23128d 1267else
349cc4a5 1268 have = false
37efbbd8 1269 libkmod = []
5c23128d 1270endif
349cc4a5 1271conf.set10('HAVE_KMOD', have)
5c23128d
ZJS
1272
1273want_pam = get_option('pam')
87ac55a1 1274if want_pam != 'false' and not skip_deps
37efbbd8
ZJS
1275 libpam = cc.find_library('pam', required : want_pam == 'true')
1276 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
349cc4a5 1277 have = libpam.found() and libpam_misc.found()
5c23128d 1278else
349cc4a5 1279 have = false
37efbbd8
ZJS
1280 libpam = []
1281 libpam_misc = []
5c23128d 1282endif
349cc4a5 1283conf.set10('HAVE_PAM', have)
5c23128d
ZJS
1284
1285want_microhttpd = get_option('microhttpd')
87ac55a1 1286if want_microhttpd != 'false' and not skip_deps
37efbbd8
ZJS
1287 libmicrohttpd = dependency('libmicrohttpd',
1288 version : '>= 0.9.33',
1289 required : want_microhttpd == 'true')
349cc4a5 1290 have = libmicrohttpd.found()
5c23128d 1291else
349cc4a5 1292 have = false
37efbbd8 1293 libmicrohttpd = []
5c23128d 1294endif
349cc4a5 1295conf.set10('HAVE_MICROHTTPD', have)
5c23128d
ZJS
1296
1297want_libcryptsetup = get_option('libcryptsetup')
d1ae38d8
OK
1298want_libcryptsetup_plugins = get_option('libcryptsetup-plugins')
1299
1300if want_libcryptsetup_plugins == 'true' and want_libcryptsetup == 'false'
1301 error('libcryptsetup-plugins can not be requested without libcryptsetup')
1302endif
1303
87ac55a1 1304if want_libcryptsetup != 'false' and not skip_deps
37efbbd8 1305 libcryptsetup = dependency('libcryptsetup',
d1ae38d8
OK
1306 version : want_libcryptsetup_plugins == 'true' ? '>= 2.4.0' : '>= 2.0.1',
1307 required : want_libcryptsetup == 'true' or want_libcryptsetup_plugins == 'true')
349cc4a5 1308 have = libcryptsetup.found()
70a5db58 1309
aac80717
ZJS
1310 foreach ident : ['crypt_set_metadata_size',
1311 'crypt_activate_by_signed_key',
1312 'crypt_token_max']
1313 have_ident = have and cc.has_function(
1314 ident,
1315 prefix : '#include <libcryptsetup.h>',
1316 dependencies : libcryptsetup)
1317 conf.set10('HAVE_' + ident.to_upper(), have_ident)
1318 endforeach
5c23128d 1319else
349cc4a5 1320 have = false
37efbbd8 1321 libcryptsetup = []
5c23128d 1322endif
349cc4a5 1323conf.set10('HAVE_LIBCRYPTSETUP', have)
5c23128d 1324
d1ae38d8 1325if want_libcryptsetup_plugins != 'false' and not skip_deps
aac80717
ZJS
1326 have = (cc.has_function(
1327 'crypt_activate_by_token_pin',
1328 prefix : '#include <libcryptsetup.h>',
1329 dependencies : libcryptsetup) and
1330 cc.has_function(
1331 'crypt_token_external_path',
1332 prefix : '#include <libcryptsetup.h>',
1333 dependencies : libcryptsetup))
d1ae38d8
OK
1334else
1335 have = false
1336endif
1337conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have)
1338
5c23128d 1339want_libcurl = get_option('libcurl')
87ac55a1 1340if want_libcurl != 'false' and not skip_deps
37efbbd8
ZJS
1341 libcurl = dependency('libcurl',
1342 version : '>= 7.32.0',
1343 required : want_libcurl == 'true')
349cc4a5 1344 have = libcurl.found()
5c23128d 1345else
349cc4a5 1346 have = false
37efbbd8 1347 libcurl = []
5c23128d 1348endif
349cc4a5 1349conf.set10('HAVE_LIBCURL', have)
47350c5f 1350conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
5c23128d
ZJS
1351
1352want_libidn = get_option('libidn')
87057e24
ZJS
1353want_libidn2 = get_option('libidn2')
1354if want_libidn == 'true' and want_libidn2 == 'true'
1355 error('libidn and libidn2 cannot be requested simultaneously')
1356endif
1357
1b931399
YW
1358if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps
1359 libidn = dependency('libidn2',
1360 required : want_libidn2 == 'true')
349cc4a5 1361 have = libidn.found()
87057e24 1362else
349cc4a5 1363 have = false
87057e24
ZJS
1364 libidn = []
1365endif
1b931399
YW
1366conf.set10('HAVE_LIBIDN2', have)
1367if not have and want_libidn != 'false' and not skip_deps
7f7ab228 1368 # libidn is used for both libidn and libidn2 objects
1b931399
YW
1369 libidn = dependency('libidn',
1370 required : want_libidn == 'true')
349cc4a5
ZJS
1371 have = libidn.found()
1372else
1373 have = false
5c23128d 1374endif
1b931399 1375conf.set10('HAVE_LIBIDN', have)
5c23128d
ZJS
1376
1377want_libiptc = get_option('libiptc')
87ac55a1 1378if want_libiptc != 'false' and not skip_deps
37efbbd8
ZJS
1379 libiptc = dependency('libiptc',
1380 required : want_libiptc == 'true')
349cc4a5 1381 have = libiptc.found()
5c23128d 1382else
349cc4a5 1383 have = false
37efbbd8 1384 libiptc = []
5c23128d 1385endif
349cc4a5 1386conf.set10('HAVE_LIBIPTC', have)
5c23128d
ZJS
1387
1388want_qrencode = get_option('qrencode')
87ac55a1 1389if want_qrencode != 'false' and not skip_deps
37efbbd8 1390 libqrencode = dependency('libqrencode',
a6c7811f 1391 version : '>= 4',
37efbbd8 1392 required : want_qrencode == 'true')
349cc4a5 1393 have = libqrencode.found()
5c23128d 1394else
349cc4a5 1395 have = false
37efbbd8 1396 libqrencode = []
5c23128d 1397endif
349cc4a5 1398conf.set10('HAVE_QRENCODE', have)
5c23128d 1399
a44fb601 1400want_gcrypt = get_option('gcrypt')
87ac55a1 1401if want_gcrypt != 'false' and not skip_deps
a44fb601
ZJS
1402 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1403 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
349cc4a5 1404 have = libgcrypt.found() and libgpg_error.found()
a44fb601 1405else
349cc4a5
ZJS
1406 have = false
1407endif
1408if not have
1409 # link to neither of the libs if one is not found
a44fb601
ZJS
1410 libgcrypt = []
1411 libgpg_error = []
1412endif
349cc4a5 1413conf.set10('HAVE_GCRYPT', have)
a44fb601 1414
5c23128d 1415want_gnutls = get_option('gnutls')
87ac55a1 1416if want_gnutls != 'false' and not skip_deps
37efbbd8
ZJS
1417 libgnutls = dependency('gnutls',
1418 version : '>= 3.1.4',
1419 required : want_gnutls == 'true')
349cc4a5 1420 have = libgnutls.found()
5c23128d 1421else
349cc4a5 1422 have = false
37efbbd8 1423 libgnutls = []
5c23128d 1424endif
349cc4a5 1425conf.set10('HAVE_GNUTLS', have)
5c23128d 1426
096cbdce 1427want_openssl = get_option('openssl')
87ac55a1 1428if want_openssl != 'false' and not skip_deps
096cbdce
IT
1429 libopenssl = dependency('openssl',
1430 version : '>= 1.1.0',
1431 required : want_openssl == 'true')
1432 have = libopenssl.found()
1433else
1434 have = false
1435 libopenssl = []
1436endif
1437conf.set10('HAVE_OPENSSL', have)
1438
839fddbe
LP
1439want_p11kit = get_option('p11kit')
1440if want_p11kit != 'false' and not skip_deps
1441 libp11kit = dependency('p11-kit-1',
6164ec4c
ZJS
1442 version : '>= 0.23.3',
1443 required : want_p11kit == 'true')
839fddbe
LP
1444 have = libp11kit.found()
1445else
1446 have = false
1447 libp11kit = []
1448endif
1449conf.set10('HAVE_P11KIT', have)
1450
af4fbd46
LP
1451want_libfido2 = get_option('libfido2')
1452if want_libfido2 != 'false' and not skip_deps
e0f435f9
YW
1453 if conf.get('HAVE_OPENSSL') == 1
1454 libfido2 = dependency('libfido2',
1455 required : want_libfido2 == 'true')
1456 have = libfido2.found()
1457 elif want_libfido2 == 'true'
1458 error('libfido2=true requires openssl')
1459 else
1460 have = false
1461 libfido2 = []
1462 endif
af4fbd46
LP
1463else
1464 have = false
1465 libfido2 = []
1466endif
1467conf.set10('HAVE_LIBFIDO2', have)
1468
5e521624
LP
1469want_tpm2 = get_option('tpm2')
1470if want_tpm2 != 'false' and not skip_deps
1471 tpm2 = dependency('tss2-esys tss2-rc tss2-mu',
ba081955 1472 required : want_tpm2 == 'true')
5e521624
LP
1473 have = tpm2.found()
1474else
1475 have = false
1476 tpm2 = []
1477endif
1478conf.set10('HAVE_TPM2', have)
1479
5c23128d 1480want_elfutils = get_option('elfutils')
87ac55a1 1481if want_elfutils != 'false' and not skip_deps
37efbbd8
ZJS
1482 libdw = dependency('libdw',
1483 required : want_elfutils == 'true')
349cc4a5 1484 have = libdw.found()
d48c2721
LB
1485
1486 # New in elfutils 0.177
1487 conf.set10('HAVE_DWELF_ELF_E_MACHINE_STRING',
1488 have and cc.has_function('dwelf_elf_e_machine_string', dependencies : libdw))
5c23128d 1489else
349cc4a5 1490 have = false
37efbbd8 1491 libdw = []
5c23128d 1492endif
349cc4a5 1493conf.set10('HAVE_ELFUTILS', have)
5c23128d
ZJS
1494
1495want_zlib = get_option('zlib')
87ac55a1 1496if want_zlib != 'false' and not skip_deps
37efbbd8
ZJS
1497 libz = dependency('zlib',
1498 required : want_zlib == 'true')
349cc4a5 1499 have = libz.found()
5c23128d 1500else
349cc4a5 1501 have = false
37efbbd8 1502 libz = []
5c23128d 1503endif
349cc4a5 1504conf.set10('HAVE_ZLIB', have)
5c23128d
ZJS
1505
1506want_bzip2 = get_option('bzip2')
87ac55a1 1507if want_bzip2 != 'false' and not skip_deps
37efbbd8
ZJS
1508 libbzip2 = cc.find_library('bz2',
1509 required : want_bzip2 == 'true')
349cc4a5 1510 have = libbzip2.found()
5c23128d 1511else
349cc4a5 1512 have = false
37efbbd8 1513 libbzip2 = []
5c23128d 1514endif
349cc4a5 1515conf.set10('HAVE_BZIP2', have)
5c23128d
ZJS
1516
1517want_xz = get_option('xz')
87ac55a1 1518if want_xz != 'false' and not skip_deps
37efbbd8
ZJS
1519 libxz = dependency('liblzma',
1520 required : want_xz == 'true')
d80b051c 1521 have_xz = libxz.found()
5c23128d 1522else
d80b051c 1523 have_xz = false
37efbbd8 1524 libxz = []
5c23128d 1525endif
d80b051c 1526conf.set10('HAVE_XZ', have_xz)
5c23128d
ZJS
1527
1528want_lz4 = get_option('lz4')
87ac55a1 1529if want_lz4 != 'false' and not skip_deps
37efbbd8 1530 liblz4 = dependency('liblz4',
e0a1d4b0 1531 version : '>= 1.3.0',
37efbbd8 1532 required : want_lz4 == 'true')
d80b051c 1533 have_lz4 = liblz4.found()
5c23128d 1534else
d80b051c 1535 have_lz4 = false
37efbbd8 1536 liblz4 = []
5c23128d 1537endif
d80b051c 1538conf.set10('HAVE_LZ4', have_lz4)
5c23128d 1539
ef5924aa
NL
1540want_zstd = get_option('zstd')
1541if want_zstd != 'false' and not skip_deps
1542 libzstd = dependency('libzstd',
1543 required : want_zstd == 'true',
1544 version : '>= 1.4.0')
d80b051c 1545 have_zstd = libzstd.found()
ef5924aa 1546else
d80b051c 1547 have_zstd = false
ef5924aa
NL
1548 libzstd = []
1549endif
d80b051c
LP
1550conf.set10('HAVE_ZSTD', have_zstd)
1551
1552conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
ef5924aa 1553
cd3c6322
LB
1554compression = get_option('default-compression')
1555if compression == 'auto'
1556 if have_zstd
1557 compression = 'zstd'
1558 elif have_lz4
1559 compression = 'lz4'
1560 elif have_xz
1561 compression = 'xz'
1562 else
1563 compression = 'none'
1564 endif
1565elif compression == 'zstd' and not have_zstd
1566 error('default-compression=zstd requires zstd')
1567elif compression == 'lz4' and not have_lz4
1568 error('default-compression=lz4 requires lz4')
1569elif compression == 'xz' and not have_xz
1570 error('default-compression=xz requires xz')
1571endif
1788c6f3 1572conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper()))
cd3c6322 1573
a44fb601 1574want_xkbcommon = get_option('xkbcommon')
87ac55a1 1575if want_xkbcommon != 'false' and not skip_deps
a44fb601
ZJS
1576 libxkbcommon = dependency('xkbcommon',
1577 version : '>= 0.3.0',
1578 required : want_xkbcommon == 'true')
349cc4a5 1579 have = libxkbcommon.found()
a44fb601 1580else
349cc4a5 1581 have = false
a44fb601
ZJS
1582 libxkbcommon = []
1583endif
349cc4a5 1584conf.set10('HAVE_XKBCOMMON', have)
a44fb601 1585
c4c978a0 1586want_pcre2 = get_option('pcre2')
8739f309 1587if want_pcre2 != 'false' and not skip_deps
c4c978a0
ZJS
1588 libpcre2 = dependency('libpcre2-8',
1589 required : want_pcre2 == 'true')
1590 have = libpcre2.found()
1591else
1592 have = false
1593 libpcre2 = []
1594endif
1595conf.set10('HAVE_PCRE2', have)
1596
69e96427 1597want_glib = get_option('glib')
87ac55a1 1598if want_glib != 'false' and not skip_deps
37efbbd8
ZJS
1599 libglib = dependency('glib-2.0',
1600 version : '>= 2.22.0',
1601 required : want_glib == 'true')
1602 libgobject = dependency('gobject-2.0',
1603 version : '>= 2.22.0',
1604 required : want_glib == 'true')
1605 libgio = dependency('gio-2.0',
1606 required : want_glib == 'true')
2c201c21 1607 have = libglib.found() and libgobject.found() and libgio.found()
69e96427 1608else
349cc4a5 1609 have = false
37efbbd8
ZJS
1610 libglib = []
1611 libgobject = []
1612 libgio = []
69e96427 1613endif
349cc4a5 1614conf.set10('HAVE_GLIB', have)
69e96427
ZJS
1615
1616want_dbus = get_option('dbus')
87ac55a1 1617if want_dbus != 'false' and not skip_deps
37efbbd8
ZJS
1618 libdbus = dependency('dbus-1',
1619 version : '>= 1.3.2',
1620 required : want_dbus == 'true')
349cc4a5 1621 have = libdbus.found()
69e96427 1622else
349cc4a5 1623 have = false
37efbbd8 1624 libdbus = []
69e96427 1625endif
349cc4a5 1626conf.set10('HAVE_DBUS', have)
69e96427 1627
1bd0cc45
YW
1628dbusdatadir = datadir / 'dbus-1'
1629if conf.get('HAVE_DBUS') == 1
1630 dbusdatadir = libdbus.get_variable(pkgconfig: 'datadir', default_value: datadir) / 'dbus-1'
1631endif
1632
1633dbuspolicydir = get_option('dbuspolicydir')
1634if dbuspolicydir == ''
1635 dbuspolicydir = dbusdatadir / 'system.d'
1636endif
1637
1638dbussessionservicedir = get_option('dbussessionservicedir')
1639if dbussessionservicedir == ''
1640 dbussessionservicedir = dbusdatadir / 'services'
1641 if conf.get('HAVE_DBUS') == 1
1642 dbussessionservicedir = libdbus.get_variable(pkgconfig: 'session_bus_services_dir', default_value: dbussessionservicedir)
1643 endif
1644endif
1645
1646dbussystemservicedir = get_option('dbussystemservicedir')
1647if dbussystemservicedir == ''
1648 dbussystemservicedir = dbusdatadir / 'system-services'
1649 if conf.get('HAVE_DBUS') == 1
1650 dbussystemservicedir = libdbus.get_variable(pkgconfig: 'system_bus_services_dir', default_value: dbussystemservicedir)
1651 endif
1652endif
1653
1654dbus_interfaces_dir = get_option('dbus-interfaces-dir')
1655if dbus_interfaces_dir == '' or dbus_interfaces_dir == 'yes'
1656 if meson.is_cross_build() and dbus_interfaces_dir != 'yes'
1657 dbus_interfaces_dir = 'no'
1658 warning('Exporting D-Bus interface XML files is disabled during cross build. Pass path or "yes" to force enable.')
1659 else
1660 dbus_interfaces_dir = dbusdatadir / 'interfaces'
1661 if conf.get('HAVE_DBUS') == 1
1662 dbus_interfaces_dir = libdbus.get_variable(pkgconfig: 'interfaces_dir', default_value: dbus_interfaces_dir)
1663 endif
1664 endif
1665endif
1bd0cc45 1666
e37ad765
ZJS
1667# We support one or the other. If gcrypt is available, we assume it's there to
1668# be used, and use it in preference.
1669opt = get_option('cryptolib')
1670if opt == 'openssl' and conf.get('HAVE_OPENSSL') == 0
1671 error('openssl requested as the default cryptolib, but not available')
1672endif
1673conf.set10('PREFER_OPENSSL',
1674 opt == 'openssl' or (opt == 'auto' and conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_GCRYPT') == 0))
1675conf.set10('HAVE_OPENSSL_OR_GCRYPT',
1676 conf.get('HAVE_OPENSSL') == 1 or conf.get('HAVE_GCRYPT') == 1)
9bcf483b 1677lib_openssl_or_gcrypt = conf.get('PREFER_OPENSSL') == 1 ? [libopenssl] : [libgcrypt, libgpg_error]
42303dcb 1678
56ddbf10
YW
1679dns_over_tls = get_option('dns-over-tls')
1680if dns_over_tls != 'false'
e37ad765
ZJS
1681 if dns_over_tls == 'gnutls' and conf.get('PREFER_OPENSSL') == 1
1682 error('Sorry, -Ddns-over-tls=gnutls is not supported when openssl is used as the cryptolib')
1683 endif
1684
1f9aa3d2
LB
1685 if dns_over_tls == 'gnutls'
1686 have_openssl = false
096cbdce 1687 else
1f9aa3d2
LB
1688 have_openssl = conf.get('HAVE_OPENSSL') == 1
1689 if dns_over_tls == 'openssl' and not have_openssl
1690 error('DNS-over-TLS support was requested with openssl, but dependencies are not available')
096cbdce 1691 endif
56ddbf10 1692 endif
1f9aa3d2
LB
1693 if dns_over_tls == 'openssl' or have_openssl
1694 have_gnutls = false
096cbdce 1695 else
1f9aa3d2
LB
1696 have_gnutls = conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0')
1697 if dns_over_tls != 'auto' and not have_gnutls
1698 str = dns_over_tls == 'gnutls' ? ' with gnutls' : ''
b349bc59 1699 error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
096cbdce
IT
1700 endif
1701 endif
1702 have = have_gnutls or have_openssl
56ddbf10 1703else
be5536a6
MO
1704 have = false
1705 have_gnutls = false
1706 have_openssl = false
56ddbf10
YW
1707endif
1708conf.set10('ENABLE_DNS_OVER_TLS', have)
096cbdce
IT
1709conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1710conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
56ddbf10 1711
c9299be2 1712default_dns_over_tls = get_option('default-dns-over-tls')
87ac55a1 1713if skip_deps
c9299be2 1714 default_dns_over_tls = 'no'
5d67a7ae 1715endif
56ddbf10 1716if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
4310bfc2 1717 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 1718 default_dns_over_tls = 'no'
5d67a7ae 1719endif
c9299be2
IT
1720conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1721 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
411d1f4c 1722conf.set_quoted('DEFAULT_DNS_OVER_TLS_MODE_STR', default_dns_over_tls)
5d67a7ae 1723
3614df05
ZJS
1724default_mdns = get_option('default-mdns')
1725conf.set('DEFAULT_MDNS_MODE',
1726 'RESOLVE_SUPPORT_' + default_mdns.to_upper())
411d1f4c 1727conf.set_quoted('DEFAULT_MDNS_MODE_STR', default_mdns)
3614df05
ZJS
1728
1729default_llmnr = get_option('default-llmnr')
1730conf.set('DEFAULT_LLMNR_MODE',
1731 'RESOLVE_SUPPORT_' + default_llmnr.to_upper())
411d1f4c 1732conf.set_quoted('DEFAULT_LLMNR_MODE_STR', default_llmnr)
3614df05 1733
e594a3b1
LP
1734want_repart = get_option('repart')
1735if want_repart != 'false'
6b12086e 1736 have = conf.get('HAVE_LIBFDISK') == 1
e594a3b1
LP
1737 if want_repart == 'true' and not have
1738 error('repart support was requested, but dependencies are not available')
1739 endif
1740else
1741 have = false
1742endif
1743conf.set10('ENABLE_REPART', have)
1744
7e8facb3
ZJS
1745default_dnssec = get_option('default-dnssec')
1746if skip_deps
1747 default_dnssec = 'no'
1748endif
1749if default_dnssec != 'no' and conf.get('HAVE_OPENSSL_OR_GCRYPT') == 0
1750 message('default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.')
1751 default_dnssec = 'no'
1752endif
1753conf.set('DEFAULT_DNSSEC_MODE',
1754 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1755conf.set_quoted('DEFAULT_DNSSEC_MODE_STR', default_dnssec)
1756
43cc7a3e
LP
1757want_sysupdate = get_option('sysupdate')
1758if want_sysupdate != 'false'
1759 have = (conf.get('HAVE_OPENSSL') == 1 and
1760 conf.get('HAVE_LIBFDISK') == 1)
1761 if want_sysupdate == 'true' and not have
1762 error('sysupdate support was requested, but dependencies are not available')
1763 endif
1764else
1765 have = false
1766endif
1767conf.set10('ENABLE_SYSUPDATE', have)
1768
5c23128d 1769want_importd = get_option('importd')
4390be30 1770if want_importd != 'false'
349cc4a5 1771 have = (conf.get('HAVE_LIBCURL') == 1 and
6214d42b 1772 conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and
349cc4a5 1773 conf.get('HAVE_ZLIB') == 1 and
6214d42b 1774 conf.get('HAVE_XZ') == 1)
349cc4a5 1775 if want_importd == 'true' and not have
37efbbd8
ZJS
1776 error('importd support was requested, but dependencies are not available')
1777 endif
349cc4a5
ZJS
1778else
1779 have = false
5c23128d 1780endif
349cc4a5 1781conf.set10('ENABLE_IMPORTD', have)
5c23128d 1782
f887eab1
FB
1783want_kernel_install = get_option('kernel-install')
1784conf.set10('ENABLE_KERNEL_INSTALL', want_kernel_install)
1785
70a5db58
LP
1786want_homed = get_option('homed')
1787if want_homed != 'false'
1788 have = (conf.get('HAVE_OPENSSL') == 1 and
1789 conf.get('HAVE_LIBFDISK') == 1 and
1790 conf.get('HAVE_LIBCRYPTSETUP') == 1)
1791 if want_homed == 'true' and not have
1792 error('homed support was requested, but dependencies are not available')
1793 endif
1794else
1795 have = false
1796endif
1797conf.set10('ENABLE_HOMED', have)
1798
af06ddf5
YW
1799have = have and conf.get('HAVE_PAM') == 1
1800conf.set10('ENABLE_PAM_HOME', have)
1801
d58c5f0f 1802have = get_option('oomd')
c199dd3f
AZ
1803conf.set10('ENABLE_OOMD', have)
1804
5c23128d 1805want_remote = get_option('remote')
4390be30 1806if want_remote != 'false'
349cc4a5
ZJS
1807 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1808 conf.get('HAVE_LIBCURL') == 1]
37efbbd8
ZJS
1809 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1810 # it's possible to build one without the other. Complain only if
5238e957 1811 # support was explicitly requested. The auxiliary files like sysusers
37efbbd8
ZJS
1812 # config should be installed when any of the programs are built.
1813 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1814 error('remote support was requested, but dependencies are not available')
1815 endif
349cc4a5
ZJS
1816 have = have_deps[0] or have_deps[1]
1817else
1818 have = false
5c23128d 1819endif
349cc4a5 1820conf.set10('ENABLE_REMOTE', have)
5c23128d 1821
b3259a6e
ZJS
1822foreach term : ['analyze',
1823 'backlight',
a9149d87
ZJS
1824 'binfmt',
1825 'coredump',
b3259a6e
ZJS
1826 'efi',
1827 'environment-d',
1828 'firstboot',
1829 'gshadow',
1830 'hibernate',
a9149d87 1831 'hostnamed',
b3259a6e
ZJS
1832 'hwdb',
1833 'idn',
1834 'ima',
1835 'initrd',
53393c89 1836 'compat-mutable-uid-boundaries',
7e0079f9 1837 'nscd',
b3259a6e 1838 'ldconfig',
a9149d87 1839 'localed',
b3259a6e 1840 'logind',
a9149d87
ZJS
1841 'machined',
1842 'networkd',
b3259a6e
ZJS
1843 'nss-myhostname',
1844 'nss-systemd',
1845 'portabled',
9bca4ae4 1846 'sysext',
b3259a6e 1847 'pstore',
a9149d87 1848 'quotacheck',
b3259a6e
ZJS
1849 'randomseed',
1850 'resolve',
1851 'rfkill',
1852 'smack',
a9149d87 1853 'sysusers',
b3259a6e
ZJS
1854 'timedated',
1855 'timesyncd',
a9149d87 1856 'tmpfiles',
a9149d87 1857 'tpm',
b3259a6e
ZJS
1858 'userdb',
1859 'utmp',
1860 'vconsole',
1861 'xdg-autostart']
a9149d87
ZJS
1862 have = get_option(term)
1863 name = 'ENABLE_' + term.underscorify().to_upper()
1864 conf.set10(name, have)
5c23128d
ZJS
1865endforeach
1866
bd7e6aa7
ZJS
1867enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
1868
08540a95
YW
1869foreach tuple : [['nss-mymachines', 'machined'],
1870 ['nss-resolve', 'resolve']]
1871 want = get_option(tuple[0])
1872 if want != 'false'
1873 have = get_option(tuple[1])
1874 if want == 'true' and not have
1875 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1876 endif
1877 else
1878 have = false
1879 endif
1880 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1881 conf.set10(name, have)
1882endforeach
1883
1884enable_nss = false
1885foreach term : ['ENABLE_NSS_MYHOSTNAME',
1886 'ENABLE_NSS_MYMACHINES',
1887 'ENABLE_NSS_RESOLVE',
1888 'ENABLE_NSS_SYSTEMD']
1889 if conf.get(term) == 1
1890 enable_nss = true
1891 endif
1892endforeach
1893conf.set10('ENABLE_NSS', enable_nss)
1894
348b4437 1895conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
6129ec85 1896
b68dfb9e 1897conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
00d82c81 1898
db7f5ab6
JJ
1899############################################################
1900
1901tests = []
1902fuzzers = []
e93ada98 1903catalogs = []
db7f5ab6
JJ
1904
1905############################################################
5c23128d 1906
db7f5ab6 1907# Include these now as they provide gnu-efi detection.
34357545
MS
1908subdir('src/fundamental')
1909subdir('src/boot/efi')
34357545 1910
f6fe732f
YW
1911############################################################
1912
d3821a33 1913generate_gperfs = find_program('tools/generate-gperfs.py')
f6fe732f
YW
1914make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
1915make_directive_index_py = find_program('tools/make-directive-index.py')
1916make_man_index_py = find_program('tools/make-man-index.py')
6b1aac3c 1917meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
d3821a33 1918update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
77d45f1f 1919update_man_rules_py = find_program('tools/update-man-rules.py')
d3821a33
ZJS
1920update_hwdb_sh = find_program('tools/update-hwdb.sh')
1921update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
1922update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
1923xml_helper_py = find_program('tools/xml_helper.py')
e3c68924 1924export_dbus_interfaces_py = find_program('tools/dbus_exporter.py')
f6fe732f 1925
db7f5ab6 1926############################################################
5c23128d 1927
7e43be7d
FS
1928if get_option('b_coverage')
1929 add_project_arguments('-include', 'src/basic/coverage.h', language : 'c')
1930endif
1931
1932############################################################
1933
5c23128d 1934config_h = configure_file(
37efbbd8
ZJS
1935 output : 'config.h',
1936 configuration : conf)
5c23128d 1937
f6fe732f
YW
1938add_project_arguments('-include', 'config.h', language : 'c')
1939
8f04a1ca
ZJS
1940jinja2_cmdline = [meson_render_jinja2, config_h, version_h]
1941
f6fe732f 1942############################################################
348b4437 1943
b61016f2
YW
1944# binaries that have --help and are intended for use by humans,
1945# usually, but not always, installed in /bin.
1946public_programs = []
1947
e3c68924 1948# D-Bus introspection XML export
1949dbus_programs = []
e3c68924 1950
8d40961c
YW
1951basic_includes = include_directories(
1952 'src/basic',
e5bc5f1f 1953 'src/fundamental',
8d40961c
YW
1954 'src/systemd',
1955 '.')
1956
1957libsystemd_includes = [basic_includes, include_directories(
1958 'src/libsystemd/sd-bus',
1959 'src/libsystemd/sd-device',
1960 'src/libsystemd/sd-event',
1961 'src/libsystemd/sd-hwdb',
1962 'src/libsystemd/sd-id128',
1963 'src/libsystemd/sd-journal',
1964 'src/libsystemd/sd-netlink',
1965 'src/libsystemd/sd-network',
1966 'src/libsystemd/sd-resolve')]
1967
1968includes = [libsystemd_includes, include_directories('src/shared')]
5c23128d 1969
5c23128d
ZJS
1970subdir('po')
1971subdir('catalog')
5c23128d
ZJS
1972subdir('src/basic')
1973subdir('src/libsystemd')
3976f372
YW
1974subdir('src/shared')
1975subdir('src/udev')
1976subdir('src/libudev')
d1ae38d8 1977subdir('src/cryptsetup/cryptsetup-tokens')
5c23128d 1978
039f1673
LB
1979alias_target('devel', libsystemd_pc, libudev_pc)
1980
5c23128d 1981libsystemd = shared_library(
37efbbd8 1982 'systemd',
56d50ab1 1983 version : libsystemd_version,
8d40961c 1984 include_directories : libsystemd_includes,
37efbbd8
ZJS
1985 link_args : ['-shared',
1986 '-Wl,--version-script=' + libsystemd_sym_path],
34e221a5 1987 link_with : [libbasic,
acc50c92
LP
1988 libbasic_gcrypt,
1989 libbasic_compress],
99b9f8fd 1990 link_whole : [libsystemd_static],
37efbbd8 1991 dependencies : [threads,
acc50c92 1992 librt],
37efbbd8
ZJS
1993 link_depends : libsystemd_sym,
1994 install : true,
0a5e638c 1995 install_tag: 'libsystemd',
37efbbd8 1996 install_dir : rootlibdir)
5c23128d 1997
039f1673
LB
1998alias_target('libsystemd', libsystemd)
1999
70848ecf
DC
2000install_libsystemd_static = static_library(
2001 'systemd',
2002 libsystemd_sources,
975464e0
ZJS
2003 basic_sources,
2004 basic_gcrypt_sources,
acc50c92 2005 basic_compress_sources,
e5bc5f1f 2006 fundamental_sources,
8d40961c 2007 include_directories : libsystemd_includes,
70848ecf
DC
2008 build_by_default : static_libsystemd != 'false',
2009 install : static_libsystemd != 'false',
0a5e638c 2010 install_tag: 'libsystemd',
70848ecf 2011 install_dir : rootlibdir,
40dbce36 2012 pic : static_libsystemd_pic,
70848ecf
DC
2013 dependencies : [threads,
2014 librt,
2015 libxz,
ef5924aa 2016 libzstd,
70848ecf 2017 liblz4,
c5fd89ad 2018 libdl,
975464e0
ZJS
2019 libcap,
2020 libblkid,
2021 libmount,
011d129c
LP
2022 libgcrypt,
2023 libopenssl],
70848ecf
DC
2024 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
2025
3976f372
YW
2026libudev = shared_library(
2027 'udev',
3976f372
YW
2028 version : libudev_version,
2029 include_directories : includes,
2030 link_args : ['-shared',
2031 '-Wl,--version-script=' + libudev_sym_path],
2032 link_with : [libsystemd_static, libshared_static],
2033 link_whole : libudev_basic,
2034 dependencies : [threads],
2035 link_depends : libudev_sym,
2036 install : true,
0a5e638c 2037 install_tag: 'libudev',
3976f372
YW
2038 install_dir : rootlibdir)
2039
039f1673
LB
2040alias_target('libudev', libudev)
2041
3976f372
YW
2042install_libudev_static = static_library(
2043 'udev',
2044 basic_sources,
e5bc5f1f 2045 fundamental_sources,
3976f372
YW
2046 shared_sources,
2047 libsystemd_sources,
2048 libudev_sources,
3976f372
YW
2049 include_directories : includes,
2050 build_by_default : static_libudev != 'false',
2051 install : static_libudev != 'false',
0a5e638c 2052 install_tag: 'libudev',
3976f372
YW
2053 install_dir : rootlibdir,
2054 link_depends : libudev_sym,
2055 dependencies : libshared_deps + [libmount],
2056 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
2057 pic : static_libudev_pic)
2058
d1ae38d8
OK
2059if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
2060 if conf.get('HAVE_TPM2') == 1
2061 cryptsetup_token_systemd_tpm2 = shared_library(
2062 'cryptsetup-token-systemd-tpm2',
c01543fd
ZJS
2063 cryptsetup_token_systemd_tpm2_sources,
2064 include_directories : includes,
d1ae38d8
OK
2065 link_args : ['-shared',
2066 '-Wl,--version-script=' + cryptsetup_token_sym_path],
c01543fd
ZJS
2067 link_with : [lib_cryptsetup_token_common,
2068 libshared],
2069 dependencies : [libcryptsetup,
2070 tpm2,
2071 versiondep],
d1ae38d8 2072 link_depends : cryptsetup_token_sym,
5fb22561 2073 install_rpath : rootpkglibdir,
d1ae38d8
OK
2074 install : true,
2075 install_dir : libcryptsetup_plugins_dir)
2076 endif
351716e1
OK
2077
2078 if conf.get('HAVE_LIBFIDO2') == 1
2079 cryptsetup_token_systemd_fido2 = shared_library(
2080 'cryptsetup-token-systemd-fido2',
c01543fd
ZJS
2081 cryptsetup_token_systemd_fido2_sources,
2082 include_directories : includes,
351716e1
OK
2083 link_args : ['-shared',
2084 '-Wl,--version-script=' + cryptsetup_token_sym_path],
c01543fd
ZJS
2085 link_with : [lib_cryptsetup_token_common,
2086 libshared],
2087 dependencies : [libcryptsetup,
2088 libfido2,
2089 versiondep],
351716e1 2090 link_depends : cryptsetup_token_sym,
5fb22561 2091 install_rpath : rootpkglibdir,
351716e1
OK
2092 install : true,
2093 install_dir : libcryptsetup_plugins_dir)
2094 endif
8186022c
OK
2095
2096 if conf.get('HAVE_P11KIT') == 1
2097 cryptsetup_token_systemd_pkcs11 = shared_library(
2098 'cryptsetup-token-systemd-pkcs11',
c01543fd
ZJS
2099 cryptsetup_token_systemd_pkcs11_sources,
2100 include_directories : includes,
8186022c
OK
2101 link_args : ['-shared',
2102 '-Wl,--version-script=' + cryptsetup_token_sym_path],
c01543fd
ZJS
2103 link_with : [lib_cryptsetup_token_common,
2104 libshared],
2105 dependencies : [libcryptsetup,
2106 libp11kit,
2107 versiondep],
8186022c 2108 link_depends : cryptsetup_token_sym,
5fb22561 2109 install_rpath : rootpkglibdir,
8186022c
OK
2110 install : true,
2111 install_dir : libcryptsetup_plugins_dir)
2112 endif
d1ae38d8
OK
2113endif
2114
47354b44
ZJS
2115############################################################
2116
b61016f2 2117# systemd-analyze requires 'libcore'
83b6af36 2118subdir('src/core')
b61016f2
YW
2119# systemd-journal-remote requires 'libjournal_core'
2120subdir('src/journal')
2121# systemd-networkd requires 'libsystemd_network'
2122subdir('src/libsystemd-network')
83b6af36
ZJS
2123
2124subdir('src/analyze')
f98df767 2125subdir('src/busctl')
b61016f2 2126subdir('src/coredump')
2ad279cf 2127subdir('src/cryptenroll')
b4d1892a 2128subdir('src/cryptsetup')
b61016f2 2129subdir('src/home')
83b6af36
ZJS
2130subdir('src/hostname')
2131subdir('src/import')
b61016f2 2132subdir('src/journal-remote')
83b6af36
ZJS
2133subdir('src/kernel-install')
2134subdir('src/locale')
b61016f2 2135subdir('src/login')
83b6af36 2136subdir('src/machine')
b61016f2 2137subdir('src/network')
83b6af36 2138subdir('src/nspawn')
b61016f2
YW
2139subdir('src/oom')
2140subdir('src/partition')
2141subdir('src/portable')
2142subdir('src/pstore')
83b6af36 2143subdir('src/resolve')
2a9b4bbe 2144subdir('src/rpm')
b61016f2 2145subdir('src/shutdown')
9bca4ae4 2146subdir('src/sysext')
c3512573 2147subdir('src/systemctl')
43cc7a3e 2148subdir('src/sysupdate')
83b6af36
ZJS
2149subdir('src/timedate')
2150subdir('src/timesync')
db64ba81 2151subdir('src/tmpfiles')
b61016f2 2152subdir('src/userdb')
0275e918 2153subdir('src/xdg-autostart-generator')
83b6af36 2154
3976f372
YW
2155subdir('src/systemd')
2156
83b6af36 2157subdir('src/test')
7db7d5b7 2158subdir('src/fuzz')
ef2ad30a 2159subdir('rules.d')
83b6af36
ZJS
2160subdir('test')
2161
2162############################################################
2163
2164# only static linking apart from libdl, to make sure that the
2165# module is linked to all libraries that it uses.
2166test_dlopen = executable(
37efbbd8
ZJS
2167 'test-dlopen',
2168 test_dlopen_c,
2169 include_directories : includes,
2170 link_with : [libbasic],
fd1939fb
YW
2171 dependencies : [libdl],
2172 build_by_default : want_tests != 'false')
83b6af36 2173
08540a95 2174foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
cbaaf7b9 2175 ['systemd', 'ENABLE_NSS_SYSTEMD', ['nss-systemd.h', 'userdb-glue.c', 'userdb-glue.h']],
08540a95 2176 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
8d40961c 2177 ['resolve', 'ENABLE_NSS_RESOLVE', [], resolve_includes]]
5c23128d 2178
349cc4a5 2179 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
37efbbd8
ZJS
2180 if condition
2181 module = tuple[0]
37efbbd8
ZJS
2182
2183 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
fce9abb2 2184 version_script_arg = project_source_root / sym
37efbbd8 2185
1684c56f
LP
2186 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
2187 if tuple.length() > 2
cbaaf7b9
YW
2188 foreach s : tuple[2]
2189 sources += ['src/nss-@0@/@1@'.format(module, s)]
2190 endforeach
1684c56f
LP
2191 endif
2192
8d40961c
YW
2193 incs = tuple.length() > 3 ? tuple[3] : includes
2194
37efbbd8
ZJS
2195 nss = shared_library(
2196 'nss_' + module,
1684c56f 2197 sources,
37efbbd8 2198 version : '2',
8d40961c 2199 include_directories : incs,
b4b36f44
LP
2200 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
2201 link_args : ['-Wl,-z,nodelete',
2202 '-shared',
700805f6 2203 '-Wl,--version-script=' + version_script_arg],
37e4d7a8 2204 link_with : [libsystemd_static,
733cbd00 2205 libshared_static,
37efbbd8
ZJS
2206 libbasic],
2207 dependencies : [threads,
5486a31d 2208 librt],
37efbbd8
ZJS
2209 link_depends : sym,
2210 install : true,
35d17e15 2211 install_tag : 'nss',
37efbbd8
ZJS
2212 install_dir : rootlibdir)
2213
2214 # We cannot use shared_module because it does not support version suffix.
2215 # Unfortunately shared_library insists on creating the symlink…
7c22f07c 2216 meson.add_install_script('sh', '-c',
37efbbd8 2217 'rm $DESTDIR@0@/libnss_@1@.so'
35d17e15
MG
2218 .format(rootlibdir, module),
2219 install_tag : 'nss'
2220 )
37efbbd8 2221
938be089
ZJS
2222 if want_tests != 'false'
2223 test('dlopen-nss_' + module,
2224 test_dlopen,
2225 # path to dlopen must include a slash
e93ada98
DDM
2226 args : nss.full_path(),
2227 depends : nss)
938be089 2228 endif
37efbbd8 2229 endif
5c23128d
ZJS
2230endforeach
2231
2232############################################################
2233
3761002e 2234exe = executable(
6164ec4c
ZJS
2235 'systemd',
2236 systemd_sources,
2237 include_directories : includes,
2238 link_with : [libcore,
2239 libshared],
2240 dependencies : [versiondep,
4287c855 2241 libseccomp],
5fb22561 2242 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2243 install : true,
2244 install_dir : rootlibexecdir)
3761002e
ZJS
2245dbus_programs += exe
2246public_programs += exe
5c23128d 2247
ba7f4ae6 2248meson.add_install_script(meson_make_symlink,
fce9abb2
ZJS
2249 rootlibexecdir / 'systemd',
2250 rootsbindir / 'init')
ba7f4ae6 2251
4e8295f4 2252exe = executable(
6164ec4c
ZJS
2253 'systemd-analyze',
2254 systemd_analyze_sources,
8d40961c 2255 include_directories : core_includes,
6164ec4c
ZJS
2256 link_with : [libcore,
2257 libshared],
2258 dependencies : [versiondep,
4287c855 2259 libseccomp],
5fb22561 2260 install_rpath : rootpkglibdir,
9e4a50bc 2261 install : conf.get('ENABLE_ANALYZE') == 1)
4e8295f4
ZJS
2262public_programs += exe
2263
2264if want_tests != 'false'
2265 test('test-compare-versions',
2266 test_compare_versions_sh,
2267 args : exe.full_path())
2268endif
5c23128d 2269
6164ec4c
ZJS
2270executable(
2271 'systemd-journald',
2272 systemd_journald_sources,
2273 include_directories : includes,
2274 link_with : [libjournal_core,
2275 libshared],
2276 dependencies : [threads,
2277 libxz,
2278 liblz4,
ef5924aa
NL
2279 libselinux,
2280 libzstd],
5fb22561 2281 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2282 install : true,
2283 install_dir : rootlibexecdir)
5c23128d 2284
6164ec4c
ZJS
2285public_programs += executable(
2286 'systemd-cat',
2287 systemd_cat_sources,
2288 include_directories : includes,
2289 link_with : [libjournal_core,
2290 libshared],
2291 dependencies : [threads],
5fb22561 2292 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2293 install : true)
2294
0a0d4899 2295if get_option('link-journalctl-shared')
721620e8
DDM
2296 journalctl_link_with = [libshared,
2297 libjournal_core]
0a0d4899
JH
2298else
2299 journalctl_link_with = [libsystemd_static,
2300 libshared_static,
721620e8
DDM
2301 libbasic_gcrypt,
2302 libjournal_core]
0a0d4899
JH
2303endif
2304
6164ec4c
ZJS
2305public_programs += executable(
2306 'journalctl',
2307 journalctl_sources,
2308 include_directories : includes,
0a0d4899 2309 link_with : [journalctl_link_with],
6164ec4c 2310 dependencies : [threads,
e44b5004 2311 libdl,
6164ec4c
ZJS
2312 libxz,
2313 liblz4,
9200bb30
LP
2314 libzstd,
2315 libdl],
5fb22561 2316 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2317 install : true,
2318 install_dir : rootbindir)
35a1ff4c 2319
6164ec4c
ZJS
2320executable(
2321 'systemd-getty-generator',
2322 'src/getty-generator/getty-generator.c',
2323 include_directories : includes,
2324 link_with : [libshared],
5fb22561 2325 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2326 install : true,
2327 install_dir : systemgeneratordir)
5c23128d 2328
6164ec4c
ZJS
2329executable(
2330 'systemd-debug-generator',
2331 'src/debug-generator/debug-generator.c',
2332 include_directories : includes,
2333 link_with : [libshared],
5fb22561 2334 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2335 install : true,
2336 install_dir : systemgeneratordir)
2337
2338executable(
2339 'systemd-run-generator',
2340 'src/run-generator/run-generator.c',
2341 include_directories : includes,
2342 link_with : [libshared],
5fb22561 2343 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2344 install : true,
2345 install_dir : systemgeneratordir)
2346
8cc8a073 2347exe = executable(
6164ec4c
ZJS
2348 'systemd-fstab-generator',
2349 'src/fstab-generator/fstab-generator.c',
2350 include_directories : includes,
bac11cd6 2351 link_with : [libshared],
5fb22561 2352 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2353 install : true,
2354 install_dir : systemgeneratordir)
5c23128d 2355
028a981c
ZJS
2356meson.add_install_script(meson_make_symlink,
2357 systemgeneratordir / 'systemd-fstab-generator',
2358 rootlibexecdir / 'systemd-sysroot-fstab-check')
2359
8cc8a073
YW
2360if want_tests != 'false'
2361 test('test-fstab-generator',
2362 test_fstab_generator_sh,
2363 # https://github.com/mesonbuild/meson/issues/2681
e93ada98
DDM
2364 args : exe.full_path(),
2365 depends : exe)
8cc8a073
YW
2366endif
2367
349cc4a5 2368if conf.get('ENABLE_ENVIRONMENT_D') == 1
6164ec4c
ZJS
2369 executable(
2370 '30-systemd-environment-d-generator',
2371 'src/environment-d-generator/environment-d-generator.c',
2372 include_directories : includes,
2373 link_with : [libshared],
5fb22561 2374 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2375 install : true,
2376 install_dir : userenvgeneratordir)
7b76fce1 2377
37efbbd8 2378 meson.add_install_script(meson_make_symlink,
fce9abb2
ZJS
2379 sysconfdir / 'environment',
2380 environmentdir / '99-environment.conf')
5c23128d
ZJS
2381endif
2382
349cc4a5 2383if conf.get('ENABLE_HIBERNATE') == 1
6164ec4c
ZJS
2384 executable(
2385 'systemd-hibernate-resume-generator',
2386 'src/hibernate-resume/hibernate-resume-generator.c',
2387 include_directories : includes,
2388 link_with : [libshared],
5fb22561 2389 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2390 install : true,
2391 install_dir : systemgeneratordir)
2392
2393 executable(
2394 'systemd-hibernate-resume',
2395 'src/hibernate-resume/hibernate-resume.c',
2396 include_directories : includes,
2397 link_with : [libshared],
5fb22561 2398 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2399 install : true,
2400 install_dir : rootlibexecdir)
37efbbd8
ZJS
2401endif
2402
349cc4a5 2403if conf.get('HAVE_BLKID') == 1
6164ec4c
ZJS
2404 executable(
2405 'systemd-gpt-auto-generator',
2406 'src/gpt-auto-generator/gpt-auto-generator.c',
6164ec4c
ZJS
2407 include_directories : includes,
2408 link_with : [libshared],
2409 dependencies : libblkid,
5fb22561 2410 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2411 install : true,
2412 install_dir : systemgeneratordir)
2413
2414 public_programs += executable(
2415 'systemd-dissect',
2416 'src/dissect/dissect.c',
2417 include_directories : includes,
2418 link_with : [libshared],
5fb22561 2419 install_rpath : rootpkglibdir,
5a151082 2420 install : true)
5c23128d
ZJS
2421endif
2422
1ec57f33 2423if conf.get('ENABLE_RESOLVE') == 1
e3c68924 2424 dbus_programs += executable(
6164ec4c
ZJS
2425 'systemd-resolved',
2426 systemd_resolved_sources,
8d40961c 2427 include_directories : resolve_includes,
6164ec4c
ZJS
2428 link_with : [libshared,
2429 libbasic_gcrypt,
2430 libsystemd_resolve_core],
2431 dependencies : systemd_resolved_dependencies,
5fb22561 2432 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2433 install : true,
2434 install_dir : rootlibexecdir)
2435
2436 public_programs += executable(
2437 'resolvectl',
2438 resolvectl_sources,
2439 include_directories : includes,
2440 link_with : [libshared,
2441 libbasic_gcrypt,
2442 libsystemd_resolve_core],
2443 dependencies : [threads,
0351cbb9 2444 lib_openssl_or_gcrypt,
6164ec4c
ZJS
2445 libm,
2446 libidn],
5fb22561 2447 install_rpath : rootpkglibdir,
6164ec4c 2448 install : true)
088c1363
LP
2449
2450 meson.add_install_script(meson_make_symlink,
fce9abb2
ZJS
2451 bindir / 'resolvectl',
2452 rootsbindir / 'resolvconf')
c2e84cab
YW
2453
2454 meson.add_install_script(meson_make_symlink,
fce9abb2
ZJS
2455 bindir / 'resolvectl',
2456 bindir / 'systemd-resolve')
5c23128d
ZJS
2457endif
2458
349cc4a5 2459if conf.get('ENABLE_LOGIND') == 1
e3c68924 2460 dbus_programs += executable(
6164ec4c
ZJS
2461 'systemd-logind',
2462 systemd_logind_sources,
2463 include_directories : includes,
2464 link_with : [liblogind_core,
2465 libshared],
2466 dependencies : [threads,
2467 libacl],
5fb22561 2468 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2469 install : true,
2470 install_dir : rootlibexecdir)
2471
2472 public_programs += executable(
2473 'loginctl',
2474 loginctl_sources,
2475 include_directories : includes,
2476 link_with : [libshared],
2477 dependencies : [threads,
2478 liblz4,
ef5924aa
NL
2479 libxz,
2480 libzstd],
5fb22561 2481 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2482 install : true,
2483 install_dir : rootbindir)
2484
2485 public_programs += executable(
2486 'systemd-inhibit',
2487 'src/login/inhibit.c',
2488 include_directories : includes,
2489 link_with : [libshared],
5fb22561 2490 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2491 install : true,
2492 install_dir : rootbindir)
37efbbd8 2493
349cc4a5 2494 if conf.get('HAVE_PAM') == 1
fce9abb2 2495 version_script_arg = project_source_root / pam_systemd_sym
37efbbd8
ZJS
2496 pam_systemd = shared_library(
2497 'pam_systemd',
2498 pam_systemd_c,
2499 name_prefix : '',
2500 include_directories : includes,
2501 link_args : ['-shared',
2502 '-Wl,--version-script=' + version_script_arg],
37e4d7a8 2503 link_with : [libsystemd_static,
37efbbd8
ZJS
2504 libshared_static],
2505 dependencies : [threads,
2506 libpam,
2507 libpam_misc],
2508 link_depends : pam_systemd_sym,
2509 install : true,
48139c7c 2510 install_tag : 'pam',
37efbbd8
ZJS
2511 install_dir : pamlibdir)
2512
938be089
ZJS
2513 if want_tests != 'false'
2514 test('dlopen-pam_systemd',
2515 test_dlopen,
2516 # path to dlopen must include a slash
e93ada98
DDM
2517 args : pam_systemd.full_path(),
2518 depends : pam_systemd)
938be089 2519 endif
37efbbd8 2520 endif
005a29f2 2521
6164ec4c
ZJS
2522 executable(
2523 'systemd-user-runtime-dir',
2524 user_runtime_dir_sources,
2525 include_directories : includes,
2526 link_with : [libshared],
5fb22561 2527 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2528 install : true,
2529 install_dir : rootlibexecdir)
07ee5adb 2530endif
a9f0f5e5 2531
349cc4a5 2532if conf.get('HAVE_PAM') == 1
6164ec4c
ZJS
2533 executable(
2534 'systemd-user-sessions',
2535 'src/user-sessions/user-sessions.c',
2536 include_directories : includes,
2537 link_with : [libshared],
5fb22561 2538 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2539 install : true,
2540 install_dir : rootlibexecdir)
5c23128d
ZJS
2541endif
2542
34357545 2543if conf.get('HAVE_BLKID') == 1 and conf.get('HAVE_GNU_EFI') == 1
79647020
RS
2544 if get_option('link-boot-shared')
2545 boot_link_with = [libshared]
2546 else
2547 boot_link_with = [libsystemd_static, libshared_static]
2548 endif
2549
6164ec4c
ZJS
2550 public_programs += executable(
2551 'bootctl',
2552 'src/boot/bootctl.c',
2553 include_directories : includes,
79647020 2554 link_with : [boot_link_with],
6164ec4c 2555 dependencies : [libblkid],
5fb22561 2556 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2557 install : true)
2558
2559 public_programs += executable(
2560 'systemd-bless-boot',
2561 'src/boot/bless-boot.c',
2562 include_directories : includes,
79647020 2563 link_with : [boot_link_with],
6164ec4c 2564 dependencies : [libblkid],
5fb22561 2565 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2566 install : true,
2567 install_dir : rootlibexecdir)
2568
2569 executable(
2570 'systemd-bless-boot-generator',
2571 'src/boot/bless-boot-generator.c',
2572 include_directories : includes,
79647020 2573 link_with : [boot_link_with],
5fb22561 2574 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2575 install : true,
2576 install_dir : systemgeneratordir)
ca1092dc 2577
3286770d 2578 if conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_TPM2') == 1
ca1092dc
LP
2579 executable(
2580 'systemd-measure',
2581 'src/boot/measure.c',
2582 include_directories : includes,
2583 link_with : [libshared],
2584 dependencies : [libopenssl],
2585 install_rpath : rootpkglibdir,
2586 install : true,
2587 install_dir : rootlibexecdir)
708d7524
LP
2588 executable(
2589 'systemd-pcrphase',
2590 'src/boot/pcrphase.c',
2591 include_directories : includes,
2592 link_with : [libshared],
2593 dependencies : [libopenssl, tpm2],
2594 install_rpath : rootpkglibdir,
2595 install : true,
2596 install_dir : rootlibexecdir)
ca1092dc 2597 endif
6164ec4c
ZJS
2598endif
2599
2600executable(
2601 'systemd-boot-check-no-failures',
2602 'src/boot/boot-check-no-failures.c',
2603 include_directories : includes,
2604 link_with : [libshared],
2605 dependencies : [libblkid],
5fb22561 2606 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2607 install : true,
2608 install_dir : rootlibexecdir)
005a29f2 2609
6164ec4c
ZJS
2610public_programs += executable(
2611 'systemd-socket-activate',
2612 'src/activate/activate.c',
2613 include_directories : includes,
2614 link_with : [libshared],
2615 dependencies : [threads],
5fb22561 2616 install_rpath : rootpkglibdir,
6164ec4c 2617 install : true)
f3794366 2618
2a2d002f 2619systemctl = executable(
6164ec4c 2620 'systemctl',
c3512573 2621 systemctl_sources,
6164ec4c
ZJS
2622 include_directories : includes,
2623 link_with : systemctl_link_with,
2624 dependencies : [threads,
2625 libcap,
2626 libselinux,
2627 libxz,
ef5924aa
NL
2628 liblz4,
2629 libzstd],
5fb22561 2630 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2631 install : true,
2632 install_dir : rootbindir)
2a2d002f 2633public_programs += systemctl
5c23128d 2634
61d0578b 2635if conf.get('ENABLE_PORTABLED') == 1
e3c68924 2636 dbus_programs += executable(
6164ec4c
ZJS
2637 'systemd-portabled',
2638 systemd_portabled_sources,
2639 include_directories : includes,
2640 link_with : [libshared],
409f4cf1 2641 dependencies : [threads, libselinux],
5fb22561 2642 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2643 install : true,
2644 install_dir : rootlibexecdir)
2645
2646 public_programs += executable(
2647 'portablectl',
2648 'src/portable/portablectl.c',
2649 include_directories : includes,
2650 link_with : [libshared],
2651 dependencies : [threads],
5fb22561 2652 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2653 install : true,
2654 install_dir : rootbindir)
61d0578b
LP
2655endif
2656
9bca4ae4
LP
2657if conf.get('ENABLE_SYSEXT') == 1
2658 public_programs += executable(
2659 'systemd-sysext',
2660 systemd_sysext_sources,
2661 include_directories : includes,
2662 link_with : [libshared],
5fb22561 2663 install_rpath : rootpkglibdir,
9bca4ae4 2664 install : true,
aac5fbff 2665 install_dir : rootbindir)
9bca4ae4
LP
2666endif
2667
d093b62c 2668if conf.get('ENABLE_USERDB') == 1
6164ec4c
ZJS
2669 executable(
2670 'systemd-userwork',
2671 systemd_userwork_sources,
2672 include_directories : includes,
2673 link_with : [libshared],
2674 dependencies : [threads],
5fb22561 2675 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2676 install : true,
2677 install_dir : rootlibexecdir)
2678
2679 executable(
2680 'systemd-userdbd',
2681 systemd_userdbd_sources,
2682 include_directories : includes,
2683 link_with : [libshared],
2684 dependencies : [threads],
5fb22561 2685 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2686 install : true,
2687 install_dir : rootlibexecdir)
2688
460e5af0 2689 public_programs += executable(
6164ec4c
ZJS
2690 'userdbctl',
2691 userdbctl_sources,
2692 include_directories : includes,
2693 link_with : [libshared],
2694 dependencies : [threads],
5fb22561 2695 install_rpath : rootpkglibdir,
003a6761 2696 install : true)
d093b62c
LP
2697endif
2698
70a5db58 2699if conf.get('ENABLE_HOMED') == 1
6164ec4c
ZJS
2700 executable(
2701 'systemd-homework',
2702 systemd_homework_sources,
2703 include_directories : includes,
2704 link_with : [libshared],
2705 dependencies : [threads,
6164ec4c
ZJS
2706 libblkid,
2707 libcrypt,
2708 libopenssl,
2709 libfdisk,
69cb2896 2710 libp11kit],
5fb22561 2711 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2712 install : true,
2713 install_dir : rootlibexecdir)
2714
e3c68924 2715 dbus_programs += executable(
6164ec4c
ZJS
2716 'systemd-homed',
2717 systemd_homed_sources,
8d40961c 2718 include_directories : home_includes,
6164ec4c
ZJS
2719 link_with : [libshared],
2720 dependencies : [threads,
2721 libcrypt,
d357b80d
LP
2722 libopenssl,
2723 libm],
5fb22561 2724 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2725 install : true,
2726 install_dir : rootlibexecdir)
2727
460e5af0 2728 public_programs += executable(
6164ec4c
ZJS
2729 'homectl',
2730 homectl_sources,
2731 include_directories : includes,
2732 link_with : [libshared],
2733 dependencies : [threads,
2734 libcrypt,
2735 libopenssl,
2736 libp11kit,
da3920c3 2737 libdl],
5fb22561 2738 install_rpath : rootpkglibdir,
003a6761 2739 install : true)
26cf9fb7
LP
2740
2741 if conf.get('HAVE_PAM') == 1
fce9abb2 2742 version_script_arg = project_source_root / pam_systemd_home_sym
a7127884 2743 pam_systemd_home = shared_library(
26cf9fb7
LP
2744 'pam_systemd_home',
2745 pam_systemd_home_c,
2746 name_prefix : '',
2747 include_directories : includes,
2748 link_args : ['-shared',
2749 '-Wl,--version-script=' + version_script_arg],
2750 link_with : [libsystemd_static,
2751 libshared_static],
2752 dependencies : [threads,
2753 libpam,
2754 libpam_misc,
2755 libcrypt],
2756 link_depends : pam_systemd_home_sym,
2757 install : true,
48139c7c 2758 install_tag : 'pam',
26cf9fb7 2759 install_dir : pamlibdir)
a7127884
YW
2760
2761 if want_tests != 'false'
2762 test('dlopen-pam_systemd_home',
2763 test_dlopen,
2764 # path to dlopen must include a slash
2765 args : pam_systemd_home.full_path(),
2766 depends : pam_systemd_home)
2767 endif
26cf9fb7 2768 endif
70a5db58
LP
2769endif
2770
6589a569 2771foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
ba081955 2772 (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
ba7f4ae6 2773 meson.add_install_script(meson_make_symlink,
fce9abb2
ZJS
2774 rootbindir / 'systemctl',
2775 rootsbindir / alias)
ba7f4ae6
ZJS
2776endforeach
2777
63e2d171 2778meson.add_install_script(meson_make_symlink,
fce9abb2
ZJS
2779 rootbindir / 'udevadm',
2780 rootlibexecdir / 'systemd-udevd')
63e2d171 2781
349cc4a5 2782if conf.get('ENABLE_BACKLIGHT') == 1
6164ec4c
ZJS
2783 executable(
2784 'systemd-backlight',
2785 'src/backlight/backlight.c',
2786 include_directories : includes,
2787 link_with : [libshared],
5fb22561 2788 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2789 install : true,
2790 install_dir : rootlibexecdir)
5c23128d
ZJS
2791endif
2792
349cc4a5 2793if conf.get('ENABLE_RFKILL') == 1
6164ec4c
ZJS
2794 executable(
2795 'systemd-rfkill',
2796 'src/rfkill/rfkill.c',
2797 include_directories : includes,
2798 link_with : [libshared],
5fb22561 2799 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2800 install : true,
2801 install_dir : rootlibexecdir)
2802endif
2803
2804executable(
2805 'systemd-system-update-generator',
2806 'src/system-update-generator/system-update-generator.c',
2807 include_directories : includes,
2808 link_with : [libshared],
5fb22561 2809 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2810 install : true,
2811 install_dir : systemgeneratordir)
5c23128d 2812
349cc4a5 2813if conf.get('HAVE_LIBCRYPTSETUP') == 1
6164ec4c
ZJS
2814 executable(
2815 'systemd-cryptsetup',
2816 systemd_cryptsetup_sources,
2817 include_directories : includes,
2818 link_with : [libshared],
2819 dependencies : [libcryptsetup,
2820 libp11kit],
5fb22561 2821 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2822 install : true,
2823 install_dir : rootlibexecdir)
2824
2825 executable(
2826 'systemd-cryptsetup-generator',
2827 'src/cryptsetup/cryptsetup-generator.c',
2828 include_directories : includes,
2829 link_with : [libshared],
5fb22561 2830 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2831 install : true,
2832 install_dir : systemgeneratordir)
2833
2834 executable(
2835 'systemd-veritysetup',
2836 'src/veritysetup/veritysetup.c',
2837 include_directories : includes,
2838 link_with : [libshared],
2839 dependencies : [libcryptsetup],
5fb22561 2840 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2841 install : true,
2842 install_dir : rootlibexecdir)
2843
2844 executable(
2845 'systemd-veritysetup-generator',
2846 'src/veritysetup/veritysetup-generator.c',
2847 include_directories : includes,
2848 link_with : [libshared],
5fb22561 2849 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2850 install : true,
2851 install_dir : systemgeneratordir)
8710a681 2852
3761002e 2853 public_programs += executable(
8710a681
LP
2854 'systemd-cryptenroll',
2855 systemd_cryptenroll_sources,
2856 include_directories : includes,
2857 link_with : [libshared],
2858 dependencies : [libcryptsetup,
5e521624 2859 libdl,
8710a681
LP
2860 libopenssl,
2861 libp11kit],
5fb22561 2862 install_rpath : rootpkglibdir,
a1fd722b 2863 install : true)
1f1a2243
TA
2864
2865 executable(
2866 'systemd-integritysetup',
2867 ['src/integritysetup/integritysetup.c', 'src/integritysetup/integrity-util.c'],
2868 include_directories : includes,
2869 link_with : [libshared],
2870 dependencies : [libcryptsetup],
5fb22561 2871 install_rpath : rootpkglibdir,
1f1a2243
TA
2872 install : true,
2873 install_dir : rootlibexecdir)
2874
2875 executable(
2876 'systemd-integritysetup-generator',
2877 ['src/integritysetup/integritysetup-generator.c', 'src/integritysetup/integrity-util.c'],
2878 include_directories : includes,
2879 link_with : [libshared],
5fb22561 2880 install_rpath : rootpkglibdir,
1f1a2243
TA
2881 install : true,
2882 install_dir : systemgeneratordir)
5c23128d
ZJS
2883endif
2884
349cc4a5 2885if conf.get('HAVE_SYSV_COMPAT') == 1
e93ada98 2886 exe = executable(
6164ec4c
ZJS
2887 'systemd-sysv-generator',
2888 'src/sysv-generator/sysv-generator.c',
2889 include_directories : includes,
2890 link_with : [libshared],
5fb22561 2891 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2892 install : true,
2893 install_dir : systemgeneratordir)
2894
e93ada98
DDM
2895 sysv_generator_test_py = find_program('test/sysv-generator-test.py')
2896 if want_tests != 'false'
2897 test('sysv-generator-test',
2898 sysv_generator_test_py,
2899 depends : exe)
2900 endif
2901
6164ec4c
ZJS
2902 executable(
2903 'systemd-rc-local-generator',
2904 'src/rc-local-generator/rc-local-generator.c',
2905 include_directories : includes,
2906 link_with : [libshared],
5fb22561 2907 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2908 install : true,
2909 install_dir : systemgeneratordir)
5c23128d
ZJS
2910endif
2911
8feca247
BB
2912if conf.get('ENABLE_XDG_AUTOSTART') == 1
2913 executable(
2914 'systemd-xdg-autostart-generator',
0275e918 2915 systemd_xdg_autostart_generator_sources,
8feca247
BB
2916 include_directories : includes,
2917 link_with : [libshared],
5fb22561 2918 install_rpath : rootpkglibdir,
8feca247
BB
2919 install : true,
2920 install_dir : usergeneratordir)
2921
2922 executable(
2923 'systemd-xdg-autostart-condition',
2924 'src/xdg-autostart-generator/xdg-autostart-condition.c',
2925 include_directories : includes,
2926 link_with : [libshared],
5fb22561 2927 install_rpath : rootpkglibdir,
8feca247
BB
2928 install : true,
2929 install_dir : rootlibexecdir)
2930endif
2931
349cc4a5 2932if conf.get('ENABLE_HOSTNAMED') == 1
e3c68924 2933 dbus_programs += executable(
6164ec4c
ZJS
2934 'systemd-hostnamed',
2935 'src/hostname/hostnamed.c',
2936 include_directories : includes,
2937 link_with : [libshared],
5fb22561 2938 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2939 install : true,
2940 install_dir : rootlibexecdir)
2941
2942 public_programs += executable(
2943 'hostnamectl',
2944 'src/hostname/hostnamectl.c',
2945 include_directories : includes,
2946 link_with : [libshared],
5fb22561 2947 install_rpath : rootpkglibdir,
6164ec4c 2948 install : true)
5c23128d
ZJS
2949endif
2950
349cc4a5
ZJS
2951if conf.get('ENABLE_LOCALED') == 1
2952 if conf.get('HAVE_XKBCOMMON') == 1
bfa0ade9
AK
2953 # logind will load libxkbcommon.so dynamically on its own, but we still
2954 # need to specify where the headers are
2955 deps = [libdl, libxkbcommon.partial_dependency(compile_args: true)]
37efbbd8
ZJS
2956 else
2957 deps = []
2958 endif
2959
e3c68924 2960 dbus_programs += executable(
6164ec4c
ZJS
2961 'systemd-localed',
2962 systemd_localed_sources,
bfa0ade9 2963 include_directories : includes,
6164ec4c
ZJS
2964 link_with : [libshared],
2965 dependencies : deps,
5fb22561 2966 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2967 install : true,
2968 install_dir : rootlibexecdir)
2969
2970 public_programs += executable(
2971 'localectl',
2972 localectl_sources,
2973 include_directories : includes,
2974 link_with : [libshared],
5fb22561 2975 install_rpath : rootpkglibdir,
6164ec4c 2976 install : true)
5c23128d
ZJS
2977endif
2978
349cc4a5 2979if conf.get('ENABLE_TIMEDATED') == 1
e3c68924 2980 dbus_programs += executable(
6164ec4c
ZJS
2981 'systemd-timedated',
2982 'src/timedate/timedated.c',
2983 include_directories : includes,
2984 link_with : [libshared],
5fb22561 2985 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2986 install : true,
2987 install_dir : rootlibexecdir)
6129ec85 2988endif
5c23128d 2989
6129ec85 2990if conf.get('ENABLE_TIMEDATECTL') == 1
6164ec4c
ZJS
2991 public_programs += executable(
2992 'timedatectl',
2993 'src/timedate/timedatectl.c',
2994 include_directories : includes,
5fb22561 2995 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2996 link_with : [libshared],
2997 dependencies : [libm],
2998 install : true)
5c23128d
ZJS
2999endif
3000
349cc4a5 3001if conf.get('ENABLE_TIMESYNCD') == 1
6164ec4c
ZJS
3002 executable(
3003 'systemd-timesyncd',
3004 systemd_timesyncd_sources,
3005 include_directories : includes,
f5a5284e 3006 link_with : [libtimesyncd_core],
6164ec4c
ZJS
3007 dependencies : [threads,
3008 libm],
5fb22561 3009 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3010 install : true,
3011 install_dir : rootlibexecdir)
3012
3013 executable(
3014 'systemd-time-wait-sync',
cf242350 3015 'src/timesync/wait-sync.c',
6164ec4c 3016 include_directories : includes,
f5a5284e 3017 link_with : [libtimesyncd_core],
5fb22561 3018 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3019 install : true,
3020 install_dir : rootlibexecdir)
5c23128d
ZJS
3021endif
3022
349cc4a5 3023if conf.get('ENABLE_MACHINED') == 1
e3c68924 3024 dbus_programs += executable(
6164ec4c
ZJS
3025 'systemd-machined',
3026 systemd_machined_sources,
3027 include_directories : includes,
3028 link_with : [libmachine_core,
3029 libshared],
5fb22561 3030 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3031 install : true,
3032 install_dir : rootlibexecdir)
3033
3034 public_programs += executable(
3035 'machinectl',
3036 'src/machine/machinectl.c',
3037 include_directories : includes,
3038 link_with : [libshared],
3039 dependencies : [threads,
3040 libxz,
ef5924aa
NL
3041 liblz4,
3042 libzstd],
5fb22561 3043 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3044 install : true,
3045 install_dir : rootbindir)
5c23128d
ZJS
3046endif
3047
349cc4a5 3048if conf.get('ENABLE_IMPORTD') == 1
e3c68924 3049 dbus_programs += executable(
6164ec4c
ZJS
3050 'systemd-importd',
3051 systemd_importd_sources,
3052 include_directories : includes,
3053 link_with : [libshared],
3054 dependencies : [threads],
5fb22561 3055 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3056 install : true,
3057 install_dir : rootlibexecdir)
3058
3059 systemd_pull = executable(
3060 'systemd-pull',
3061 systemd_pull_sources,
3062 include_directories : includes,
b93f018f
ZJS
3063 link_with : [libshared,
3064 lib_import_common],
6164ec4c
ZJS
3065 dependencies : [versiondep,
3066 libcurl,
6214d42b 3067 lib_openssl_or_gcrypt,
6164ec4c
ZJS
3068 libz,
3069 libbzip2,
6214d42b 3070 libxz],
5fb22561 3071 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3072 install : true,
3073 install_dir : rootlibexecdir)
3074
3075 systemd_import = executable(
3076 'systemd-import',
3077 systemd_import_sources,
3078 include_directories : includes,
b93f018f
ZJS
3079 link_with : [libshared,
3080 lib_import_common],
6164ec4c
ZJS
3081 dependencies : [libcurl,
3082 libz,
3083 libbzip2,
3084 libxz],
5fb22561 3085 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3086 install : true,
3087 install_dir : rootlibexecdir)
3088
3089 systemd_import_fs = executable(
3090 'systemd-import-fs',
3091 systemd_import_fs_sources,
3092 include_directories : includes,
b93f018f
ZJS
3093 link_with : [libshared,
3094 lib_import_common],
5fb22561 3095 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3096 install : true,
3097 install_dir : rootlibexecdir)
3098
3099 systemd_export = executable(
3100 'systemd-export',
3101 systemd_export_sources,
3102 include_directories : includes,
b93f018f
ZJS
3103 link_with : [libshared,
3104 lib_import_common],
6164ec4c
ZJS
3105 dependencies : [libcurl,
3106 libz,
3107 libbzip2,
3108 libxz],
5fb22561 3109 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3110 install : true,
3111 install_dir : rootlibexecdir)
1d7579c4
LP
3112
3113 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
37efbbd8
ZJS
3114endif
3115
349cc4a5 3116if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
6164ec4c
ZJS
3117 public_programs += executable(
3118 'systemd-journal-upload',
3119 systemd_journal_upload_sources,
3120 include_directories : includes,
3121 link_with : [libshared],
3122 dependencies : [versiondep,
3123 threads,
3124 libcurl,
3125 libgnutls,
3126 libxz,
ef5924aa
NL
3127 liblz4,
3128 libzstd],
5fb22561 3129 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3130 install : true,
3131 install_dir : rootlibexecdir)
5c23128d
ZJS
3132endif
3133
349cc4a5 3134if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
6164ec4c
ZJS
3135 public_programs += executable(
3136 'systemd-journal-remote',
3137 systemd_journal_remote_sources,
035b0f8f 3138 include_directories : journal_includes,
6164ec4c
ZJS
3139 link_with : [libshared,
3140 libsystemd_journal_remote],
3141 dependencies : [threads,
3142 libmicrohttpd,
3143 libgnutls,
3144 libxz,
ef5924aa
NL
3145 liblz4,
3146 libzstd],
5fb22561 3147 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3148 install : true,
3149 install_dir : rootlibexecdir)
3150
3151 public_programs += executable(
3152 'systemd-journal-gatewayd',
3153 systemd_journal_gatewayd_sources,
035b0f8f 3154 include_directories : journal_includes,
6164ec4c
ZJS
3155 link_with : [libshared],
3156 dependencies : [threads,
3157 libmicrohttpd,
3158 libgnutls,
3159 libxz,
ef5924aa
NL
3160 liblz4,
3161 libzstd],
5fb22561 3162 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3163 install : true,
3164 install_dir : rootlibexecdir)
5c23128d
ZJS
3165endif
3166
349cc4a5 3167if conf.get('ENABLE_COREDUMP') == 1
6164ec4c
ZJS
3168 executable(
3169 'systemd-coredump',
3170 systemd_coredump_sources,
3171 include_directories : includes,
acc50c92
LP
3172 link_with : [libshared,
3173 libbasic_compress],
6164ec4c
ZJS
3174 dependencies : [threads,
3175 libacl,
6164ec4c 3176 libxz,
ef5924aa
NL
3177 liblz4,
3178 libzstd],
5fb22561 3179 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3180 install : true,
3181 install_dir : rootlibexecdir)
3182
3183 public_programs += executable(
3184 'coredumpctl',
3185 coredumpctl_sources,
3186 include_directories : includes,
acc50c92
LP
3187 link_with : [libshared,
3188 libbasic_compress],
6164ec4c
ZJS
3189 dependencies : [threads,
3190 libxz,
ef5924aa
NL
3191 liblz4,
3192 libzstd],
5fb22561 3193 install_rpath : rootpkglibdir,
6164ec4c 3194 install : true)
5c23128d
ZJS
3195endif
3196
9b4abc69 3197if conf.get('ENABLE_PSTORE') == 1
6164ec4c
ZJS
3198 executable(
3199 'systemd-pstore',
3200 systemd_pstore_sources,
3201 include_directories : includes,
3202 link_with : [libshared],
3203 dependencies : [threads,
3204 libacl,
6164ec4c 3205 libxz,
ef5924aa
NL
3206 liblz4,
3207 libzstd],
5fb22561 3208 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3209 install : true,
3210 install_dir : rootlibexecdir)
9b4abc69
ED
3211endif
3212
9de5e321 3213if conf.get('ENABLE_OOMD') == 1
e3c68924 3214 dbus_programs += executable('systemd-oomd',
9de5e321
AZ
3215 systemd_oomd_sources,
3216 include_directories : includes,
3217 link_with : [libshared],
132c73b5 3218 dependencies : [libatomic],
5fb22561 3219 install_rpath : rootpkglibdir,
9de5e321
AZ
3220 install : true,
3221 install_dir : rootlibexecdir)
5c616ecf
AZ
3222
3223 public_programs += executable(
ba081955
ZJS
3224 'oomctl',
3225 oomctl_sources,
3226 include_directories : includes,
3227 link_with : [libshared],
3228 dependencies : [],
5fb22561 3229 install_rpath : rootpkglibdir,
cfd4c84a 3230 install : true)
9de5e321
AZ
3231endif
3232
349cc4a5 3233if conf.get('ENABLE_BINFMT') == 1
6164ec4c
ZJS
3234 public_programs += executable(
3235 'systemd-binfmt',
3236 'src/binfmt/binfmt.c',
3237 include_directories : includes,
3238 link_with : [libshared],
5fb22561 3239 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3240 install : true,
3241 install_dir : rootlibexecdir)
37efbbd8 3242
7c22f07c
ZJS
3243 meson.add_install_script('sh', '-c',
3244 mkdir_p.format(binfmtdir))
d7aa78c3 3245 if install_sysconfdir
7c22f07c 3246 meson.add_install_script('sh', '-c',
fce9abb2 3247 mkdir_p.format(sysconfdir / 'binfmt.d'))
d7aa78c3 3248 endif
37efbbd8
ZJS
3249endif
3250
43cc7a3e
LP
3251if conf.get('ENABLE_SYSUPDATE') == 1
3252 exe = executable(
3253 'systemd-sysupdate',
3254 systemd_sysupdate_sources,
3255 include_directories : includes,
3256 link_with : [libshared],
3257 dependencies : [threads,
3258 libblkid,
3259 libfdisk,
3260 libopenssl],
5fb22561 3261 install_rpath : rootpkglibdir,
43cc7a3e
LP
3262 install : true,
3263 install_dir : rootlibexecdir)
3264 public_programs += exe
3265endif
3266
349cc4a5 3267if conf.get('ENABLE_VCONSOLE') == 1
6164ec4c
ZJS
3268 executable(
3269 'systemd-vconsole-setup',
3270 'src/vconsole/vconsole-setup.c',
3271 include_directories : includes,
3272 link_with : [libshared],
5fb22561 3273 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3274 install : true,
3275 install_dir : rootlibexecdir)
5c23128d
ZJS
3276endif
3277
349cc4a5 3278if conf.get('ENABLE_RANDOMSEED') == 1
6164ec4c
ZJS
3279 executable(
3280 'systemd-random-seed',
3281 'src/random-seed/random-seed.c',
3282 include_directories : includes,
3283 link_with : [libshared],
5fb22561 3284 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3285 install : true,
3286 install_dir : rootlibexecdir)
5c23128d
ZJS
3287endif
3288
349cc4a5 3289if conf.get('ENABLE_FIRSTBOOT') == 1
3761002e 3290 public_programs += executable(
6164ec4c
ZJS
3291 'systemd-firstboot',
3292 'src/firstboot/firstboot.c',
3293 include_directories : includes,
3294 link_with : [libshared],
3295 dependencies : [libcrypt],
5fb22561 3296 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3297 install : true,
3298 install_dir : rootbindir)
3299endif
3300
3301executable(
3302 'systemd-remount-fs',
3303 'src/remount-fs/remount-fs.c',
3304 include_directories : includes,
bac11cd6 3305 link_with : [libshared],
5fb22561 3306 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3307 install : true,
3308 install_dir : rootlibexecdir)
5c23128d 3309
6164ec4c
ZJS
3310executable(
3311 'systemd-machine-id-setup',
3312 'src/machine-id-setup/machine-id-setup-main.c',
3313 include_directories : includes,
bac11cd6 3314 link_with : [libshared],
5fb22561 3315 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3316 install : true,
3317 install_dir : rootbindir)
5c23128d 3318
6164ec4c
ZJS
3319executable(
3320 'systemd-fsck',
3321 'src/fsck/fsck.c',
3322 include_directories : includes,
3323 link_with : [libshared],
5fb22561 3324 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3325 install : true,
3326 install_dir : rootlibexecdir)
5c23128d 3327
80750adb
ZJS
3328executable('systemd-growfs',
3329 'src/partition/growfs.c',
3330 include_directories : includes,
3331 link_with : [libshared],
5fb22561 3332 install_rpath : rootpkglibdir,
80750adb
ZJS
3333 install : true,
3334 install_dir : rootlibexecdir)
3335
6164ec4c
ZJS
3336executable(
3337 'systemd-makefs',
3338 'src/partition/makefs.c',
3339 include_directories : includes,
3340 link_with : [libshared],
5fb22561 3341 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3342 install : true,
3343 install_dir : rootlibexecdir)
b7f28ac5 3344
6164ec4c
ZJS
3345executable(
3346 'systemd-sleep',
3347 'src/sleep/sleep.c',
3348 include_directories : includes,
3349 link_with : [libshared],
5fb22561 3350 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3351 install : true,
3352 install_dir : rootlibexecdir)
5c23128d 3353
225d08b8 3354if install_sysconfdir_samples
d7aa78c3
JT
3355 install_data('src/sleep/sleep.conf',
3356 install_dir : pkgsysconfdir)
3357endif
d25e127d 3358
6164ec4c
ZJS
3359public_programs += executable(
3360 'systemd-sysctl',
3361 'src/sysctl/sysctl.c',
3362 include_directories : includes,
3363 link_with : [libshared],
5fb22561 3364 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3365 install : true,
3366 install_dir : rootlibexecdir)
5c23128d 3367
6164ec4c
ZJS
3368executable(
3369 'systemd-ac-power',
3370 'src/ac-power/ac-power.c',
3371 include_directories : includes,
3372 link_with : [libshared],
5fb22561 3373 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3374 install : true,
3375 install_dir : rootlibexecdir)
5c23128d 3376
6164ec4c
ZJS
3377public_programs += executable(
3378 'systemd-detect-virt',
3379 'src/detect-virt/detect-virt.c',
3380 include_directories : includes,
3381 link_with : [libshared],
5fb22561 3382 install_rpath : rootpkglibdir,
6164ec4c 3383 install : true)
5c23128d 3384
6164ec4c
ZJS
3385public_programs += executable(
3386 'systemd-delta',
3387 'src/delta/delta.c',
3388 include_directories : includes,
3389 link_with : [libshared],
5fb22561 3390 install_rpath : rootpkglibdir,
6164ec4c 3391 install : true)
5c23128d 3392
6164ec4c
ZJS
3393public_programs += executable(
3394 'systemd-escape',
3395 'src/escape/escape.c',
3396 include_directories : includes,
3397 link_with : [libshared],
5fb22561 3398 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3399 install : true,
3400 install_dir : rootbindir)
3401
3402public_programs += executable(
3403 'systemd-notify',
3404 'src/notify/notify.c',
3405 include_directories : includes,
3406 link_with : [libshared],
5fb22561 3407 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3408 install : true,
3409 install_dir : rootbindir)
3410
5945640e
LP
3411public_programs += executable(
3412 'systemd-creds',
3413 'src/creds/creds.c',
3414 include_directories : includes,
3415 link_with : [libshared],
3416 dependencies : [threads,
3417 libopenssl],
5fb22561 3418 install_rpath : rootpkglibdir,
5945640e
LP
3419 install : true,
3420 install_dir : rootbindir)
3421
6164ec4c
ZJS
3422executable(
3423 'systemd-volatile-root',
3424 'src/volatile-root/volatile-root.c',
3425 include_directories : includes,
3426 link_with : [libshared],
5fb22561 3427 install_rpath : rootpkglibdir,
cdf7ad38 3428 install : conf.get('ENABLE_INITRD') == 1,
6164ec4c
ZJS
3429 install_dir : rootlibexecdir)
3430
3431executable(
3432 'systemd-cgroups-agent',
3433 'src/cgroups-agent/cgroups-agent.c',
3434 include_directories : includes,
3435 link_with : [libshared],
5fb22561 3436 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3437 install : true,
3438 install_dir : rootlibexecdir)
3439
2a2d002f 3440systemd_id128 = executable(
6164ec4c
ZJS
3441 'systemd-id128',
3442 'src/id128/id128.c',
3443 include_directories : includes,
3444 link_with : [libshared],
5fb22561 3445 install_rpath : rootpkglibdir,
6164ec4c 3446 install : true)
2a2d002f
ZJS
3447public_programs += systemd_id128
3448
3449if want_tests != 'false'
3450 test('test-systemctl-enable',
3451 test_systemctl_enable_sh,
3452 # https://github.com/mesonbuild/meson/issues/2681
3453 args : [systemctl.full_path(),
3454 systemd_id128.full_path()])
3455endif
6164ec4c
ZJS
3456
3457public_programs += executable(
3458 'systemd-path',
3459 'src/path/path.c',
3460 include_directories : includes,
3461 link_with : [libshared],
5fb22561 3462 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3463 install : true)
3464
3465public_programs += executable(
3466 'systemd-ask-password',
3467 'src/ask-password/ask-password.c',
3468 include_directories : includes,
3469 link_with : [libshared],
5fb22561 3470 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3471 install : true,
3472 install_dir : rootbindir)
3473
3474executable(
3475 'systemd-reply-password',
3476 'src/reply-password/reply-password.c',
3477 include_directories : includes,
3478 link_with : [libshared],
5fb22561 3479 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3480 install : true,
3481 install_dir : rootlibexecdir)
3482
3483public_programs += executable(
3484 'systemd-tty-ask-password-agent',
3485 'src/tty-ask-password-agent/tty-ask-password-agent.c',
3486 include_directories : includes,
3487 link_with : [libshared],
5fb22561 3488 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3489 install : true,
3490 install_dir : rootbindir)
3491
3492public_programs += executable(
3493 'systemd-cgls',
3494 'src/cgls/cgls.c',
3495 include_directories : includes,
3496 link_with : [libshared],
5fb22561 3497 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3498 install : true)
3499
3500public_programs += executable(
3501 'systemd-cgtop',
3502 'src/cgtop/cgtop.c',
3503 include_directories : includes,
3504 link_with : [libshared],
5fb22561 3505 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3506 install : true)
3507
3508executable(
3509 'systemd-initctl',
3510 'src/initctl/initctl.c',
3511 include_directories : includes,
3512 link_with : [libshared],
5fb22561 3513 install_rpath : rootpkglibdir,
6589a569 3514 install : (conf.get('HAVE_SYSV_COMPAT') == 1),
6164ec4c 3515 install_dir : rootlibexecdir)
5c23128d 3516
6164ec4c
ZJS
3517public_programs += executable(
3518 'systemd-mount',
3519 'src/mount/mount-tool.c',
3520 include_directories : includes,
3521 link_with : [libshared],
3522 dependencies: [libmount],
5fb22561 3523 install_rpath : rootpkglibdir,
6164ec4c 3524 install : true)
5c23128d 3525
7b76fce1 3526meson.add_install_script(meson_make_symlink,
fce9abb2 3527 'systemd-mount', bindir / 'systemd-umount')
7b76fce1 3528
6164ec4c
ZJS
3529public_programs += executable(
3530 'systemd-run',
3531 'src/run/run.c',
3532 include_directories : includes,
3533 link_with : [libshared],
5fb22561 3534 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3535 install : true)
3536
3537public_programs += executable(
3538 'systemd-stdio-bridge',
3539 'src/stdio-bridge/stdio-bridge.c',
3540 include_directories : includes,
3541 link_with : [libshared],
3542 dependencies : [versiondep],
5fb22561 3543 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3544 install : true)
3545
3546public_programs += executable(
3547 'busctl',
f98df767 3548 busctl_sources,
6164ec4c
ZJS
3549 include_directories : includes,
3550 link_with : [libshared],
7c4bd9ac 3551 dependencies : [versiondep],
5fb22561 3552 install_rpath : rootpkglibdir,
6164ec4c 3553 install : true)
5c23128d 3554
bd7e6aa7
ZJS
3555if enable_sysusers
3556 exe = executable(
6164ec4c
ZJS
3557 'systemd-sysusers',
3558 'src/sysusers/sysusers.c',
3559 include_directories : includes,
3560 link_with : [libshared],
5fb22561 3561 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3562 install : true,
3563 install_dir : rootbindir)
bd7e6aa7
ZJS
3564 public_programs += exe
3565
3566 if want_tests != 'false'
3567 test('test-sysusers',
3568 test_sysusers_sh,
3569 # https://github.com/mesonbuild/meson/issues/2681
3570 args : exe.full_path())
3571 endif
8ef8f3d5
FB
3572
3573 if have_standalone_binaries
bd7e6aa7 3574 exe = executable(
8ef8f3d5
FB
3575 'systemd-sysusers.standalone',
3576 'src/sysusers/sysusers.c',
3577 include_directories : includes,
3537577c 3578 c_args : '-DSTANDALONE',
8ef8f3d5
FB
3579 link_with : [libshared_static,
3580 libbasic,
3581 libbasic_gcrypt,
99b9f8fd 3582 libsystemd_static],
8ef8f3d5
FB
3583 install : true,
3584 install_dir : rootbindir)
bd7e6aa7
ZJS
3585 public_programs += exe
3586
3587 if want_tests != 'false'
3588 test('test-sysusers.standalone',
3589 test_sysusers_sh,
3590 # https://github.com/mesonbuild/meson/issues/2681
3591 args : exe.full_path())
3592 endif
8ef8f3d5 3593 endif
5c23128d
ZJS
3594endif
3595
349cc4a5 3596if conf.get('ENABLE_TMPFILES') == 1
6164ec4c
ZJS
3597 exe = executable(
3598 'systemd-tmpfiles',
db64ba81 3599 systemd_tmpfiles_sources,
6164ec4c
ZJS
3600 include_directories : includes,
3601 link_with : [libshared],
3602 dependencies : [libacl],
5fb22561 3603 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3604 install : true,
3605 install_dir : rootbindir)
5a8b1640 3606 public_programs += exe
d9daae55 3607
938be089
ZJS
3608 if want_tests != 'false'
3609 test('test-systemd-tmpfiles',
3610 test_systemd_tmpfiles_py,
3611 # https://github.com/mesonbuild/meson/issues/2681
3612 args : exe.full_path())
3613 endif
db64ba81
FB
3614
3615 if have_standalone_binaries
bf93f24a 3616 exe = executable(
db64ba81
FB
3617 'systemd-tmpfiles.standalone',
3618 systemd_tmpfiles_sources,
3619 include_directories : includes,
3537577c 3620 c_args : '-DSTANDALONE',
db64ba81
FB
3621 link_with : [libshared_static,
3622 libbasic,
3623 libbasic_gcrypt,
99b9f8fd 3624 libsystemd_static],
db64ba81
FB
3625 dependencies : [libacl],
3626 install : true,
3627 install_dir : rootbindir)
bf93f24a
MG
3628 public_programs += exe
3629
3630 if want_tests != 'false'
3631 test('test-systemd-tmpfiles.standalone',
3632 test_systemd_tmpfiles_py,
3633 # https://github.com/mesonbuild/meson/issues/2681
3634 args : exe.full_path())
3635 endif
db64ba81 3636 endif
5c23128d
ZJS
3637endif
3638
349cc4a5 3639if conf.get('ENABLE_HWDB') == 1
ecd1bfdd 3640 systemd_hwdb = executable(
6164ec4c
ZJS
3641 'systemd-hwdb',
3642 'src/hwdb/hwdb.c',
6164ec4c 3643 include_directories : includes,
e4b127e2 3644 link_with : udev_link_with,
6164ec4c
ZJS
3645 install_rpath : udev_rpath,
3646 install : true,
3647 install_dir : rootbindir)
ecd1bfdd
ZJS
3648 public_programs += systemd_hwdb
3649
3650 if want_tests != 'false'
3651 test('hwdb-test',
3652 hwdb_test_sh,
14056a52 3653 suite : 'dist-check',
ecd1bfdd
ZJS
3654 args : [systemd_hwdb.full_path()],
3655 timeout : 90)
3656 endif
37efbbd8
ZJS
3657endif
3658
349cc4a5 3659if conf.get('ENABLE_QUOTACHECK') == 1
6164ec4c
ZJS
3660 executable(
3661 'systemd-quotacheck',
3662 'src/quotacheck/quotacheck.c',
3663 include_directories : includes,
3664 link_with : [libshared],
5fb22561 3665 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3666 install : true,
3667 install_dir : rootlibexecdir)
3668endif
3669
3670public_programs += executable(
3671 'systemd-socket-proxyd',
3672 'src/socket-proxy/socket-proxyd.c',
3673 include_directories : includes,
3674 link_with : [libshared],
3675 dependencies : [threads],
5fb22561 3676 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3677 install : true,
3678 install_dir : rootlibexecdir)
5c23128d 3679
9b264c1d 3680udevadm = executable(
6164ec4c
ZJS
3681 'udevadm',
3682 udevadm_sources,
6164ec4c 3683 include_directories : includes,
e4b127e2 3684 link_with : [libudevd_core],
6164ec4c
ZJS
3685 dependencies : [versiondep,
3686 threads,
3687 libkmod,
3688 libidn,
3689 libacl,
3690 libblkid],
3691 install_rpath : udev_rpath,
3692 install : true,
3693 install_dir : rootbindir)
9b264c1d
FS
3694public_programs += udevadm
3695
3696if conf.get('ENABLE_REPART') == 1
3697 exe = executable(
3698 'systemd-repart',
3699 systemd_repart_sources,
3700 include_directories : includes,
3701 link_with : [libshared],
3702 dependencies : [threads,
3703 libblkid,
b456191d
DDM
3704 libfdisk,
3705 libopenssl],
5fb22561 3706 install_rpath : rootpkglibdir,
9b264c1d
FS
3707 install : true,
3708 install_dir : rootbindir)
3709 public_programs += exe
9b264c1d 3710endif
6164ec4c
ZJS
3711
3712executable(
3713 'systemd-shutdown',
3714 systemd_shutdown_sources,
3715 include_directories : includes,
bac11cd6 3716 link_with : [libshared],
6164ec4c 3717 dependencies : [libmount],
5fb22561 3718 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3719 install : true,
3720 install_dir : rootlibexecdir)
3721
3722executable(
3723 'systemd-update-done',
3724 'src/update-done/update-done.c',
3725 include_directories : includes,
3726 link_with : [libshared],
5fb22561 3727 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3728 install : true,
3729 install_dir : rootlibexecdir)
3730
3731executable(
3732 'systemd-update-utmp',
3733 'src/update-utmp/update-utmp.c',
3734 include_directories : includes,
3735 link_with : [libshared],
3736 dependencies : [libaudit],
5fb22561 3737 install_rpath : rootpkglibdir,
55678b9e 3738 install : (conf.get('ENABLE_UTMP') == 1),
6164ec4c 3739 install_dir : rootlibexecdir)
5c23128d 3740
349cc4a5 3741if conf.get('HAVE_KMOD') == 1
6164ec4c
ZJS
3742 executable(
3743 'systemd-modules-load',
3744 'src/modules-load/modules-load.c',
3745 include_directories : includes,
3746 link_with : [libshared],
3747 dependencies : [libkmod],
5fb22561 3748 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3749 install : true,
3750 install_dir : rootlibexecdir)
94e75a54 3751
7c22f07c
ZJS
3752 meson.add_install_script('sh', '-c',
3753 mkdir_p.format(modulesloaddir))
d7aa78c3 3754 if install_sysconfdir
7c22f07c 3755 meson.add_install_script('sh', '-c',
fce9abb2 3756 mkdir_p.format(sysconfdir / 'modules-load.d'))
d7aa78c3 3757 endif
5c23128d
ZJS
3758endif
3759
6164ec4c
ZJS
3760public_programs += executable(
3761 'systemd-nspawn',
3762 systemd_nspawn_sources,
3763 include_directories : includes,
bac11cd6 3764 link_with : [libnspawn_core,
6164ec4c
ZJS
3765 libshared],
3766 dependencies : [libblkid,
3767 libseccomp],
5fb22561 3768 install_rpath : rootpkglibdir,
6164ec4c 3769 install : true)
5c23128d 3770
349cc4a5 3771if conf.get('ENABLE_NETWORKD') == 1
9ff2b35f 3772 dbus_programs += executable(
6164ec4c
ZJS
3773 'systemd-networkd',
3774 systemd_networkd_sources,
8d40961c 3775 include_directories : network_includes,
6164ec4c
ZJS
3776 link_with : [libnetworkd_core,
3777 libsystemd_network,
6164ec4c
ZJS
3778 networkd_link_with],
3779 dependencies : [threads],
5fb22561 3780 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3781 install : true,
3782 install_dir : rootlibexecdir)
3783
3761002e 3784 public_programs += executable(
6164ec4c
ZJS
3785 'systemd-networkd-wait-online',
3786 systemd_networkd_wait_online_sources,
3787 include_directories : includes,
8d40961c 3788 link_with : [networkd_link_with],
5fb22561 3789 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3790 install : true,
3791 install_dir : rootlibexecdir)
3792
3793 public_programs += executable(
3794 'networkctl',
3795 networkctl_sources,
8d40961c 3796 include_directories : libsystemd_network_includes,
6164ec4c
ZJS
3797 link_with : [libsystemd_network,
3798 networkd_link_with],
5fb22561 3799 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3800 install : true,
3801 install_dir : rootbindir)
987dd89c 3802endif
6164ec4c 3803
987dd89c
YW
3804exe = executable(
3805 'systemd-network-generator',
3806 network_generator_sources,
3807 include_directories : includes,
3808 link_with : [networkd_link_with],
5fb22561 3809 install_rpath : rootpkglibdir,
987dd89c
YW
3810 install : true,
3811 install_dir : rootlibexecdir)
fbaa1137 3812
987dd89c
YW
3813if want_tests != 'false'
3814 test('test-network-generator-conversion',
3815 test_network_generator_conversion_sh,
3816 # https://github.com/mesonbuild/meson/issues/2681
e93ada98
DDM
3817 args : exe.full_path(),
3818 depends : exe)
dcfe072a 3819endif
e821f6a9 3820
6164ec4c
ZJS
3821executable(
3822 'systemd-sulogin-shell',
73e994f2 3823 'src/sulogin-shell/sulogin-shell.c',
6164ec4c
ZJS
3824 include_directories : includes,
3825 link_with : [libshared],
5fb22561 3826 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3827 install : true,
3828 install_dir : rootlibexecdir)
e821f6a9 3829
f875e6bc 3830exe = custom_target(
99d8cbce
ZJS
3831 'kernel-install',
3832 input : kernel_install_in,
3833 output : 'kernel-install',
3834 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
3835 install : want_kernel_install,
3836 install_mode : 'rwxr-xr-x',
3837 install_dir : bindir)
f875e6bc
ZJS
3838public_programs += exe
3839
3840if want_tests != 'false'
3841 test('test-kernel-install',
3842 test_kernel_install_sh,
3843 args : [exe.full_path(), loaderentry_install])
3844endif
99d8cbce 3845
69e96427
ZJS
3846############################################################
3847
e93ada98 3848runtest_env = custom_target(
e2d41370
FB
3849 'systemd-runtest.env',
3850 output : 'systemd-runtest.env',
0f4c4f38
ZJS
3851 command : [sh, '-c',
3852 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
fce9abb2
ZJS
3853 project_source_root / 'test',
3854 project_build_root / 'catalog')],
e93ada98 3855 depends : catalogs,
e2d41370
FB
3856 build_by_default : true)
3857
a626cb15
ZJS
3858test_cflags = ['-DTEST_CODE=1']
3859# We intentionally do not do inline initializations with definitions for a
3860# bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
3861# use the variable unexpectedly. This triggers a lot of maybe-uninitialized
3862# false positives when the combination of -O2 and -flto is used. Suppress them.
b528a628 3863if '-O2' in c_args and '-flto=auto' in c_args
a626cb15
ZJS
3864 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
3865endif
3866
69e96427 3867foreach tuple : tests
37efbbd8 3868 sources = tuple[0]
5acb3cab
YW
3869 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3870 dependencies = tuple.length() > 2 ? tuple[2] : []
3871 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3872 condition = tuple.length() > 4 ? tuple[4] : ''
3873 type = tuple.length() > 5 ? tuple[5] : ''
3874 defs = tuple.length() > 6 ? tuple[6] : []
a626cb15 3875 defs += test_cflags
5acb3cab 3876 parallel = tuple.length() > 7 ? tuple[7] : true
37efbbd8
ZJS
3877 timeout = 30
3878
e1eeebbb
JJ
3879 # FIXME: Use fs.stem() with meson >= 0.54.0
3880 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
37efbbd8
ZJS
3881 if type.startswith('timeout=')
3882 timeout = type.split('=')[1].to_int()
3883 type = ''
3884 endif
3b2bdd62 3885
c3191c6d
DDM
3886 suite = fs.name(fs.parent('@0@'.format(sources[0])))
3887 # FIXME: Use str.replace() with meson >= 0.58.0
3888 suite = suite.split('sd-')[-1]
3889
3b2bdd62 3890 if condition == '' or conf.get(condition) == 1
37efbbd8
ZJS
3891 exe = executable(
3892 name,
3893 sources,
3894 include_directories : incs,
3895 link_with : link_with,
60722ad7
ZJS
3896 dependencies : [versiondep,
3897 dependencies],
37efbbd8 3898 c_args : defs,
3b2bdd62 3899 build_by_default : want_tests != 'false',
5fb22561 3900 install_rpath : rootpkglibdir,
7cdd9783 3901 install : install_tests,
e93ada98
DDM
3902 install_dir : testsdir / type,
3903 link_depends : runtest_env)
37efbbd8
ZJS
3904
3905 if type == 'manual'
3906 message('@0@ is a manual test'.format(name))
3907 elif type == 'unsafe' and want_tests != 'unsafe'
3908 message('@0@ is an unsafe test'.format(name))
3b2bdd62 3909 elif want_tests != 'false'
37efbbd8
ZJS
3910 test(name, exe,
3911 env : test_env,
c3191c6d 3912 timeout : timeout,
57c15ca3
YW
3913 suite : suite,
3914 is_parallel : parallel)
37efbbd8
ZJS
3915 endif
3916 else
3917 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
3918 endif
69e96427
ZJS
3919endforeach
3920
0632b4cd 3921exe = executable(
37efbbd8
ZJS
3922 'test-libsystemd-sym',
3923 test_libsystemd_sym_c,
3924 include_directories : includes,
3925 link_with : [libsystemd],
fd1939fb 3926 build_by_default : want_tests != 'false',
37efbbd8
ZJS
3927 install : install_tests,
3928 install_dir : testsdir)
938be089
ZJS
3929if want_tests != 'false'
3930 test('test-libsystemd-sym', exe)
3931endif
37ab1a25 3932
0632b4cd
ZJS
3933exe = executable(
3934 'test-libsystemd-static-sym',
3935 test_libsystemd_sym_c,
3936 include_directories : includes,
0632b4cd
ZJS
3937 link_with : [install_libsystemd_static],
3938 dependencies : [threads], # threads is already included in dependencies on the library,
3939 # but does not seem to get propagated. Add here as a work-around.
fd1939fb 3940 build_by_default : want_tests != 'false' and static_libsystemd_pic,
20f3d32d 3941 install : install_tests and static_libsystemd_pic,
0632b4cd 3942 install_dir : testsdir)
938be089 3943if want_tests != 'false' and static_libsystemd_pic
0632b4cd
ZJS
3944 test('test-libsystemd-static-sym', exe)
3945endif
37ab1a25 3946
0632b4cd 3947exe = executable(
37efbbd8
ZJS
3948 'test-libudev-sym',
3949 test_libudev_sym_c,
e4b127e2 3950 include_directories : libudev_includes,
a626cb15 3951 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
37efbbd8 3952 link_with : [libudev],
fd1939fb 3953 build_by_default : want_tests != 'false',
37efbbd8
ZJS
3954 install : install_tests,
3955 install_dir : testsdir)
938be089
ZJS
3956if want_tests != 'false'
3957 test('test-libudev-sym', exe)
3958endif
0632b4cd
ZJS
3959
3960exe = executable(
3961 'test-libudev-static-sym',
3962 test_libudev_sym_c,
e4b127e2 3963 include_directories : libudev_includes,
a626cb15 3964 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
0632b4cd 3965 link_with : [install_libudev_static],
fd1939fb 3966 build_by_default : want_tests != 'false' and static_libudev_pic,
20f3d32d 3967 install : install_tests and static_libudev_pic,
0632b4cd 3968 install_dir : testsdir)
938be089 3969if want_tests != 'false' and static_libudev_pic
0632b4cd
ZJS
3970 test('test-libudev-static-sym', exe)
3971endif
e0bec52f 3972
69e96427 3973############################################################
5c23128d 3974
7db7d5b7
JR
3975fuzzer_exes = []
3976
7e299ffe
ZJS
3977foreach tuple : fuzzers
3978 sources = tuple[0]
5acb3cab
YW
3979 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3980 dependencies = tuple.length() > 2 ? tuple[2] : []
3981 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3982 defs = tuple.length() > 4 ? tuple[4] : []
7e299ffe
ZJS
3983 link_args = []
3984
3985 if want_ossfuzz
3986 dependencies += fuzzing_engine
3987 elif want_libfuzzer
3988 if fuzzing_engine.found()
9c5c4677
EV
3989 dependencies += fuzzing_engine
3990 else
7e299ffe 3991 link_args += ['-fsanitize=fuzzer']
9c5c4677 3992 endif
7e299ffe
ZJS
3993 else
3994 sources += 'src/fuzz/fuzz-main.c'
3995 endif
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
4012 if want_tests != 'false'
4013 # Run the fuzz regression tests without any sanitizers enabled.
4014 # Additional invocations with sanitizers may be added below.
4015 foreach p : fuzz_regression_tests
4016 b = p.split('/')[-2]
4017 c = p.split('/')[-1]
4018
4019 if b == name
4020 test('@0@_@1@'.format(b, c),
4021 exe,
14056a52 4022 suite : 'fuzzers',
fce9abb2 4023 args : [project_source_root / p])
f78ad5f0
ZJS
4024 endif
4025 endforeach
4026 endif
7e299ffe 4027endforeach
7db7d5b7 4028
6839ce33 4029alias_target('fuzzers', fuzzer_exes)
7db7d5b7
JR
4030
4031############################################################
4032
378e9d2b 4033subdir('modprobe.d')
5c23128d
ZJS
4034subdir('sysctl.d')
4035subdir('sysusers.d')
4036subdir('tmpfiles.d')
4f10b807
ZJS
4037subdir('hwdb.d')
4038subdir('units')
e783f957 4039subdir('presets')
5c23128d
ZJS
4040subdir('network')
4041subdir('man')
4042subdir('shell-completion/bash')
4043subdir('shell-completion/zsh')
9e825ebf
FB
4044subdir('docs/sysvinit')
4045subdir('docs/var-log')
5c23128d 4046
5c23128d
ZJS
4047install_subdir('factory/etc',
4048 install_dir : factorydir)
623370e6 4049subdir('factory/templates')
5c23128d 4050
d7aa78c3
JT
4051if install_sysconfdir
4052 install_data('xorg/50-systemd-user.sh',
4053 install_dir : xinitrcdir)
4054endif
f09eb768 4055install_data('LICENSE.GPL2',
5c23128d 4056 'LICENSE.LGPL2.1',
f09eb768
LP
4057 'NEWS',
4058 'README',
eea98402 4059 'docs/CODING_STYLE.md',
1d1cb168 4060 'docs/DISTRO_PORTING.md',
9e825ebf 4061 'docs/ENVIRONMENT.md',
5425f8a5 4062 'docs/HACKING.md',
9e825ebf 4063 'docs/TRANSIENT-SETTINGS.md',
b6dc0d7d 4064 'docs/TRANSLATORS.md',
9e825ebf 4065 'docs/UIDS-GIDS.md',
5c23128d 4066 install_dir : docdir)
d68b342b 4067
9c6e32a2
LB
4068install_subdir('LICENSES',
4069 install_dir : docdir)
4070
7c22f07c
ZJS
4071meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
4072meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
94e75a54 4073
d68b342b
ZJS
4074############################################################
4075
2d4efd1d
LB
4076# Ensure that changes to the docs/ directory do not break the
4077# basic Github pages build. But only run it in developer mode,
4078# as it might be fragile due to changes in the tooling, and it is
4079# not generally useful for users.
4080jekyll = find_program('jekyll', required : false)
4081if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
4082 test('github-pages',
4083 jekyll,
14056a52 4084 suite : 'dist-check',
2d4efd1d 4085 args : ['build',
fce9abb2
ZJS
4086 '--source', project_source_root / 'docs',
4087 '--destination', project_build_root / '_site'])
2d4efd1d
LB
4088endif
4089
4090############################################################
4091
dd1e33c8 4092check_help = find_program('tools/check-help.sh')
ffb7406b 4093check_version = find_program('tools/check-version.sh')
005a29f2
ZJS
4094
4095foreach exec : public_programs
37efbbd8 4096 name = exec.full_path().split('/')[-1]
938be089
ZJS
4097 if want_tests != 'false'
4098 test('check-help-' + name,
dd1e33c8 4099 check_help,
14056a52 4100 suite : 'dist-check',
e93ada98
DDM
4101 args : exec.full_path(),
4102 depends: exec)
ffb7406b
ZJS
4103
4104 test('check-version-' + name,
4105 check_version,
14056a52 4106 suite : 'dist-check',
ffb7406b
ZJS
4107 args : [exec.full_path(),
4108 meson.project_version()],
4109 depends: exec)
938be089 4110 endif
005a29f2
ZJS
4111endforeach
4112
4113############################################################
4114
c6448ee3
ZJS
4115check_directives_sh = find_program('tools/check-directives.sh')
4116
4117if want_tests != 'false'
4118 test('check-directives',
4119 check_directives_sh,
14056a52 4120 suite : 'dist-check',
34fde9f8 4121 args : [project_source_root, project_build_root])
c6448ee3
ZJS
4122endif
4123
4124############################################################
4125
52d4d1d3
ZJS
4126# Enable tests for all supported sanitizers
4127foreach tuple : sanitizers
4128 sanitizer = tuple[0]
4129 build = tuple[1]
b68dfb9e 4130
7a6397d2 4131 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
52d4d1d3
ZJS
4132 prev = ''
4133 foreach p : fuzz_regression_tests
4134 b = p.split('/')[-2]
4135 c = p.split('/')[-1]
4136
4137 name = '@0@:@1@'.format(b, sanitizer)
4138
4139 if name != prev
4140 if want_tests == 'false'
4141 message('Not compiling @0@ because tests is set to false'.format(name))
1763ef1d 4142 elif fuzz_tests
52d4d1d3
ZJS
4143 exe = custom_target(
4144 name,
4145 output : name,
4146 depends : build,
0f4c4f38 4147 command : [ln, '-fs',
fce9abb2 4148 build.full_path() / b,
52d4d1d3
ZJS
4149 '@OUTPUT@'],
4150 build_by_default : true)
4151 else
1763ef1d 4152 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
52d4d1d3
ZJS
4153 endif
4154 endif
4155 prev = name
4156
1763ef1d 4157 if fuzz_tests
0f82a2ab 4158 test('@0@_@1@_@2@'.format(b, c, sanitizer),
52d4d1d3 4159 env,
14056a52 4160 suite : 'fuzz+san',
89767158
EV
4161 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
4162 timeout : 60,
52d4d1d3 4163 args : [exe.full_path(),
fce9abb2 4164 project_source_root / p])
52d4d1d3
ZJS
4165 endif
4166 endforeach
b68dfb9e
ZJS
4167 endif
4168endforeach
4169
52d4d1d3 4170
b68dfb9e
ZJS
4171############################################################
4172
0700e8ba 4173if git.found()
37efbbd8 4174 all_files = run_command(
0f4c4f38
ZJS
4175 env, '-u', 'GIT_WORK_TREE',
4176 git, '--git-dir=@0@/.git'.format(project_source_root),
e92777d2
ZJS
4177 'ls-files', ':/*.[ch]',
4178 check : false)
4179 if all_files.returncode() == 0
4180 all_files = files(all_files.stdout().split())
4181
4182 custom_target(
4183 'tags',
4184 output : 'tags',
4185 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
4186 run_target(
4187 'ctags',
691db9a7 4188 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
e92777d2 4189 endif
d68b342b 4190endif
177929c2
ZJS
4191
4192if git.found()
dd1e33c8 4193 git_contrib_sh = find_program('tools/git-contrib.sh')
a923e085 4194 run_target(
37efbbd8 4195 'git-contrib',
dd1e33c8 4196 command : [git_contrib_sh])
177929c2 4197endif
dd6ab3df
ZJS
4198
4199if git.found()
4200 git_head = run_command(
e92777d2
ZJS
4201 git, '--git-dir=@0@/.git'.format(project_source_root),
4202 'rev-parse', 'HEAD',
4203 check : false).stdout().strip()
dd6ab3df 4204 git_head_short = run_command(
e92777d2
ZJS
4205 git, '--git-dir=@0@/.git'.format(project_source_root),
4206 'rev-parse', '--short=7', 'HEAD',
4207 check : false).stdout().strip()
dd6ab3df
ZJS
4208
4209 run_target(
4210 'git-snapshot',
0f4c4f38 4211 command : [git, 'archive',
1485aacb 4212 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
dd6ab3df
ZJS
4213 git_head_short),
4214 '--prefix', 'systemd-@0@/'.format(git_head),
4215 'HEAD'])
4216endif
829257d1
ZJS
4217
4218############################################################
4219
dd1e33c8 4220check_api_docs_sh = find_program('tools/check-api-docs.sh')
51b13863
LP
4221run_target(
4222 'check-api-docs',
4223 depends : [man, libsystemd, libudev],
dd1e33c8 4224 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
51b13863 4225
f12c5d36
ZJS
4226alias_target('update-dbus-docs', update_dbus_docs)
4227alias_target('update-man-rules', update_man_rules)
e3c368f6 4228
0628d48e
LB
4229if not meson.is_cross_build()
4230 custom_target(
4231 'export-dbus-interfaces',
4645074e 4232 output : fs.name(dbus_interfaces_dir),
0628d48e 4233 install : dbus_interfaces_dir != 'no',
4645074e 4234 install_dir : fs.parent(dbus_interfaces_dir),
0628d48e
LB
4235 command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
4236endif
e3c68924 4237
51b13863 4238############################################################
829257d1 4239
e92777d2
ZJS
4240alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
4241 check : true).stdout().strip()
12085ebb
ZJS
4242
4243summary({
12085ebb
ZJS
4244 'split /usr' : split_usr,
4245 'split bin-sbin' : split_bin,
4246 'prefix directory' : prefixdir,
4247 'rootprefix directory' : rootprefixdir,
4248 'sysconf directory' : sysconfdir,
4249 'include directory' : includedir,
4250 'lib directory' : libdir,
4251 'rootlib directory' : rootlibdir,
4252 'SysV init scripts' : sysvinit_path,
4253 'SysV rc?.d directories' : sysvrcnd_path,
4254 'PAM modules directory' : pamlibdir,
4255 'PAM configuration directory' : pamconfdir,
4256 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
4257 'RPM macros directory' : rpmmacrosdir,
4258 'modprobe.d directory' : modprobedir,
4259 'D-Bus policy directory' : dbuspolicydir,
4260 'D-Bus session directory' : dbussessionservicedir,
4261 'D-Bus system directory' : dbussystemservicedir,
7e560e79 4262 'D-Bus interfaces directory' : dbus_interfaces_dir,
12085ebb
ZJS
4263 'bash completions directory' : bashcompletiondir,
4264 'zsh completions directory' : zshcompletiondir,
a2b0cd3f 4265 'private shared lib version tag' : shared_lib_tag,
12085ebb
ZJS
4266 'extra start script' : get_option('rc-local'),
4267 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
4268 get_option('debug-tty')),
4269 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
4270 conf.get('SYSTEM_ALLOC_UID_MIN')),
4271 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
4272 conf.get('SYSTEM_ALLOC_GID_MIN')),
4273 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
4274 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
4275 'static UID/GID allocations' : ' '.join(static_ugids),
4276 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
4277 'render group access mode' : get_option('group-render-mode'),
4278 'certificate root directory' : get_option('certificate-root'),
4279 'support URL' : support_url,
4280 'nobody user name' : nobody_user,
4281 'nobody group name' : nobody_group,
4282 'fallback hostname' : get_option('fallback-hostname'),
9798deaf 4283 'default compression method' : compression,
12085ebb
ZJS
4284 'default DNSSEC mode' : default_dnssec,
4285 'default DNS-over-TLS mode' : default_dns_over_tls,
4286 'default mDNS mode' : default_mdns,
4287 'default LLMNR mode' : default_llmnr,
4288 'default DNS servers' : dns_servers.split(' '),
4289 'default NTP servers' : ntp_servers.split(' '),
4290 'default cgroup hierarchy' : default_hierarchy,
4291 'default net.naming-scheme value' : default_net_naming_scheme,
4292 'default KillUserProcesses value' : kill_user_processes,
4293 'default locale' : default_locale,
88b6f0de 4294 'default nspawn locale' : nspawn_locale,
79dec86a 4295 'default status unit format' : status_unit_format_default,
12085ebb
ZJS
4296 'default user $PATH' :
4297 default_user_path != '' ? default_user_path : '(same as system services)',
4298 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
4299 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
829257d1
ZJS
4300
4301# TODO:
4302# CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
4303# CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
4304# LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
4305
829257d1
ZJS
4306found = []
4307missing = []
4308
4309foreach tuple : [
56d68e71
ZJS
4310 # dependencies
4311 ['ACL'],
829257d1 4312 ['AUDIT'],
829257d1 4313 ['AppArmor'],
56d68e71
ZJS
4314 ['IMA'],
4315 ['PAM'],
829257d1 4316 ['SECCOMP'],
56d68e71 4317 ['SELinux'],
829257d1 4318 ['SMACK'],
56d68e71
ZJS
4319 ['blkid'],
4320 ['elfutils'],
829257d1 4321 ['gcrypt'],
829257d1 4322 ['gnutls'],
7d861e12 4323 ['libbpf'],
56d68e71 4324 ['libcryptsetup'],
d1ae38d8 4325 ['libcryptsetup-plugins'],
829257d1 4326 ['libcurl'],
56d68e71
ZJS
4327 ['libfdisk'],
4328 ['libfido2'],
829257d1 4329 ['libidn'],
56d68e71 4330 ['libidn2'],
829257d1 4331 ['libiptc'],
56d68e71
ZJS
4332 ['microhttpd'],
4333 ['openssl'],
4334 ['p11kit'],
4335 ['pcre2'],
4336 ['pwquality'],
4337 ['qrencode'],
4338 ['tpm2'],
4339 ['xkbcommon'],
4340
4341 # compression libs
4342 ['zstd'],
4343 ['lz4'],
4344 ['xz'],
4345 ['zlib'],
4346 ['bzip2'],
4347
4348 # components
4349 ['backlight'],
829257d1 4350 ['binfmt'],
0a0d4899 4351 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
56d68e71 4352 ['coredump'],
829257d1 4353 ['environment.d'],
56d68e71 4354 ['efi'],
9cf75222 4355 ['gnu-efi'],
829257d1 4356 ['firstboot'],
56d68e71
ZJS
4357 ['hibernate'],
4358 ['homed'],
4359 ['hostnamed'],
4360 ['hwdb'],
4361 ['importd'],
4362 ['initrd'],
f887eab1 4363 ['kernel-install'],
56d68e71 4364 ['localed'],
829257d1
ZJS
4365 ['logind'],
4366 ['machined'],
56d68e71
ZJS
4367 ['networkd'],
4368 ['nss-myhostname'],
4369 ['nss-mymachines'],
4370 ['nss-resolve'],
4371 ['nss-systemd'],
4372 ['oomd'],
61d0578b 4373 ['portabled'],
56d68e71
ZJS
4374 ['pstore'],
4375 ['quotacheck'],
4376 ['randomseed'],
4377 ['repart'],
4378 ['resolve'],
4379 ['rfkill'],
9bca4ae4 4380 ['sysext'],
0a0d4899 4381 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
43cc7a3e 4382 ['sysupdate'],
56d68e71 4383 ['sysusers'],
829257d1
ZJS
4384 ['timedated'],
4385 ['timesyncd'],
56d68e71
ZJS
4386 ['tmpfiles'],
4387 ['userdb'],
4388 ['vconsole'],
4389 ['xdg-autostart'],
4390
4391 # optional features
56d68e71 4392 ['idn'],
829257d1 4393 ['polkit'],
56d68e71 4394 ['nscd'],
0a0d4899 4395 ['legacy-pkla', install_polkit_pkla],
829257d1 4396 ['kmod'],
829257d1
ZJS
4397 ['dbus'],
4398 ['glib'],
829257d1 4399 ['tpm'],
0a0d4899
JH
4400 ['man pages', want_man],
4401 ['html pages', want_html],
4402 ['man page indices', want_man and have_lxml],
829257d1 4403 ['SysV compat'],
56d68e71 4404 ['compat-mutable-uid-boundaries'],
829257d1
ZJS
4405 ['utmp'],
4406 ['ldconfig'],
0a0d4899
JH
4407 ['adm group', get_option('adm-group')],
4408 ['wheel group', get_option('wheel-group')],
b14e1b43 4409 ['gshadow'],
829257d1
ZJS
4410 ['debug hashmap'],
4411 ['debug mmap cache'],
d6601495 4412 ['debug siphash'],
0a0d4899
JH
4413 ['valgrind', conf.get('VALGRIND') == 1],
4414 ['trace logging', conf.get('LOG_TRACE') == 1],
4415 ['install tests', install_tests],
4416 ['link-udev-shared', get_option('link-udev-shared')],
4417 ['link-systemctl-shared', get_option('link-systemctl-shared')],
4418 ['link-networkd-shared', get_option('link-networkd-shared')],
4419 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
4420 ['link-journalctl-shared', get_option('link-journalctl-shared')],
4421 ['link-boot-shared', get_option('link-boot-shared')],
93651582 4422 ['first-boot-full-preset'],
ceedbf81 4423 ['fexecve'],
0a0d4899
JH
4424 ['standalone-binaries', get_option('standalone-binaries')],
4425 ['coverage', get_option('b_coverage')],
829257d1
ZJS
4426]
4427
af4d7860
ZJS
4428 if tuple.length() >= 2
4429 cond = tuple[1]
4430 else
829257d1
ZJS
4431 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
4432 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
349cc4a5 4433 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
829257d1
ZJS
4434 endif
4435 if cond
5a8b1640 4436 found += tuple[0]
829257d1 4437 else
5a8b1640 4438 missing += tuple[0]
829257d1
ZJS
4439 endif
4440endforeach
4441
c716c253
ZJS
4442if static_libsystemd == 'false'
4443 missing += 'static-libsystemd'
4444else
4445 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
4446endif
4447
4448if static_libudev == 'false'
4449 missing += 'static-libudev'
4450else
4451 found += 'static-libudev(@0@)'.format(static_libudev)
4452endif
4453
57633d23
ZJS
4454if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
4455 found += 'cryptolib(openssl)'
4456elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
4457 found += 'cryptolib(gcrypt)'
4458else
4459 missing += 'cryptolib'
4460endif
4461
237f2da9
ZJS
4462if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
4463 found += 'DNS-over-TLS(gnutls)'
4464elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
4465 found += 'DNS-over-TLS(openssl)'
4466else
4467 missing += 'DNS-over-TLS'
4468endif
4469
12085ebb
ZJS
4470summary({
4471 'enabled' : ', '.join(found),
4472 'disabled' : ', '.join(missing)},
4473 section : 'Features')
9a8e64b0
ZJS
4474
4475if rootprefixdir != rootprefix_default
8ea9fad7
YW
4476 warning('\n' +
4477 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
4478 'systemd used fixed names for unit file directories and other paths, so anything\n' +
4479 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))
9a8e64b0 4480endif