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