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