]> git.ipfire.org Git - thirdparty/systemd.git/blame - meson.build
units: add Before=shutdown.target to systemd-networkd-persistent-storage.service
[thirdparty/systemd.git] / meson.build
CommitLineData
db9ecf05 1# SPDX-License-Identifier: LGPL-2.1-or-later
3a726fcd 2
5c23128d 3project('systemd', 'c',
ea2a57be 4 version : files('meson.version'),
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 ],
35c035a1 13 meson_version : '>= 0.60.0',
5c23128d
ZJS
14 )
15
d1b04070
LB
16libsystemd_version = '0.39.0'
17libudev_version = '1.7.9'
56d50ab1 18
5c23128d 19conf = configuration_data()
a8c03388 20conf.set_quoted('PROJECT_URL', 'https://systemd.io/')
ea2a57be 21conf.set('PROJECT_VERSION', meson.project_version().split('~')[0],
6ffeca8c 22 description : 'Numerical project version (used where a simple number is expected)')
ea2a57be 23conf.set_quoted('PROJECT_VERSION_FULL', meson.project_version(), description : 'Full project version')
5c23128d 24
1485aacb
DC
25# This is to be used instead of meson.source_root(), as the latter will return
26# the wrong result when systemd is being built as a meson subproject
27project_source_root = meson.current_source_dir()
81e06775 28project_build_root = meson.current_build_dir()
a0b15b41 29relative_source_path = run_command('realpath',
81e06775 30 '--relative-to=@0@'.format(project_build_root),
e92777d2
ZJS
31 project_source_root,
32 check : true).stdout().strip()
a0b15b41 33conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)
1485aacb 34
47350c5f
ZJS
35conf.set10('BUILD_MODE_DEVELOPER', get_option('mode') == 'developer',
36 description : 'tailor build to development or release builds')
2b84d628 37
1e73a64a
JJ
38feature = get_option('log-message-verification')
39if feature.auto()
40 have = conf.get('BUILD_MODE_DEVELOPER') == 1
011a03a3 41else
1e73a64a 42 have = feature.enabled()
011a03a3 43endif
1e73a64a 44conf.set10('LOG_MESSAGE_VERIFICATION', have)
839bdf25 45
c09edc79
ZJS
46want_ossfuzz = get_option('oss-fuzz')
47want_libfuzzer = get_option('llvm-fuzz')
c29537f3 48if want_ossfuzz and want_libfuzzer
6b8d32ea 49 error('only one of oss-fuzz or llvm-fuzz can be specified')
c09edc79 50endif
87ac55a1 51
6b8d32ea 52fuzzer_build = want_ossfuzz or want_libfuzzer
c09edc79 53
c4f883b7
ZJS
54# If we're building *not* for actual fuzzing, allow input samples of any size
55# (for testing and for reproduction of issues discovered with previously-higher
56# limits).
57conf.set10('FUZZ_USE_SIZE_LIMIT', fuzzer_build)
58
493cd503
ZJS
59# We'll set this to '1' for EFI builds in a different place.
60conf.set10('SD_BOOT', false)
61
3f871f12
ZJS
62# Create a title-less summary section early, so it ends up first in the output.
63# More items are added later after they have been detected.
64summary({'build mode' : get_option('mode')})
65
5c23128d
ZJS
66#####################################################################
67
003c8879 68# Try to install the git pre-commit hook
6233a769
DDM
69git_setup_sh = find_program('tools/git-setup.sh', required : false)
70if git_setup_sh.found()
71 git_hook = run_command(git_setup_sh, check : false)
e2d612a8
ZJS
72 if git_hook.returncode() == 0
73 message(git_hook.stdout().strip())
74 endif
003c8879
ZJS
75endif
76
77#####################################################################
78
4cf8a609 79fs = import('fs')
157baa87 80if get_option('split-bin') == 'auto'
4cf8a609 81 split_bin = not fs.is_symlink('/usr/sbin')
157baa87
ZJS
82else
83 split_bin = get_option('split-bin') == 'true'
84endif
671f0f8d
ZJS
85conf.set10('HAVE_SPLIT_BIN', split_bin,
86 description : 'bin and sbin directories are separate')
157baa87 87
8ef8f3d5
FB
88have_standalone_binaries = get_option('standalone-binaries')
89
5c23128d
ZJS
90sysvinit_path = get_option('sysvinit-path')
91sysvrcnd_path = get_option('sysvrcnd-path')
348b4437 92conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '',
349cc4a5 93 description : 'SysV init scripts and rcN.d links are supported')
6fe23ff3 94conf.set10('CREATE_LOG_DIRS', get_option('create-log-dirs'))
5c23128d 95
cdf7ad38
NL
96if get_option('hibernate') and not get_option('initrd')
97 error('hibernate depends on initrd')
98endif
99
a8b627aa
LP
100conf.set10('BUMP_PROC_SYS_FS_FILE_MAX', get_option('bump-proc-sys-fs-file-max'))
101conf.set10('BUMP_PROC_SYS_FS_NR_OPEN', get_option('bump-proc-sys-fs-nr-open'))
09dad04c 102conf.set('HIGH_RLIMIT_NOFILE', 512*1024)
a8b627aa 103
fce9abb2
ZJS
104# Meson ignores the preceding arguments when joining paths if an absolute
105# component is encountered, so this should canonicalize various paths when they
106# are absolute or relative.
5c23128d
ZJS
107prefixdir = get_option('prefix')
108if not prefixdir.startswith('/')
37efbbd8 109 error('Prefix is not absolute: "@0@"'.format(prefixdir))
5c23128d 110endif
d895e10a 111
b0d3095f 112prefixdir_noslash = '/' + prefixdir.strip('/')
fce9abb2 113bindir = prefixdir / get_option('bindir')
b0d3095f 114sbindir = prefixdir / (split_bin ? 'sbin' : 'bin')
9289e093 115sbin_to_bin = split_bin ? '../bin/' : ''
fce9abb2
ZJS
116libdir = prefixdir / get_option('libdir')
117sysconfdir = prefixdir / get_option('sysconfdir')
118includedir = prefixdir / get_option('includedir')
119datadir = prefixdir / get_option('datadir')
120localstatedir = '/' / get_option('localstatedir')
5c23128d 121
b0d3095f
LB
122libexecdir = prefixdir / 'lib/systemd'
123pkglibdir = libdir / 'systemd'
5c23128d 124
225d08b8
JT
125install_sysconfdir = get_option('install-sysconfdir') != 'false'
126install_sysconfdir_samples = get_option('install-sysconfdir') == 'true'
5c23128d 127# Dirs of external packages
fce9abb2
ZJS
128pkgconfigdatadir = get_option('pkgconfigdatadir') != '' ? get_option('pkgconfigdatadir') : datadir / 'pkgconfig'
129pkgconfiglibdir = get_option('pkgconfiglibdir') != '' ? get_option('pkgconfiglibdir') : libdir / 'pkgconfig'
130polkitpolicydir = datadir / 'polkit-1/actions'
131polkitrulesdir = datadir / 'polkit-1/rules.d'
132polkitpkladir = localstatedir / 'lib/polkit-1/localauthority/10-vendor.d'
133xinitrcdir = get_option('xinitrcdir') != '' ? get_option('xinitrcdir') : sysconfdir / 'X11/xinit/xinitrc.d'
8a38aac3
YW
134rpmmacrosdir = get_option('rpmmacrosdir')
135if rpmmacrosdir != 'no'
fce9abb2 136 rpmmacrosdir = prefixdir / rpmmacrosdir
8a38aac3 137endif
b0d3095f 138modprobedir = prefixdir / 'lib/modprobe.d'
5c23128d
ZJS
139
140# Our own paths
fce9abb2
ZJS
141pkgdatadir = datadir / 'systemd'
142environmentdir = prefixdir / 'lib/environment.d'
143pkgsysconfdir = sysconfdir / 'systemd'
144userunitdir = prefixdir / 'lib/systemd/user'
145userpresetdir = prefixdir / 'lib/systemd/user-preset'
146tmpfilesdir = prefixdir / 'lib/tmpfiles.d'
107795a7 147usertmpfilesdir = prefixdir / 'share/user-tmpfiles.d'
fce9abb2
ZJS
148sysusersdir = prefixdir / 'lib/sysusers.d'
149sysctldir = prefixdir / 'lib/sysctl.d'
150binfmtdir = prefixdir / 'lib/binfmt.d'
151modulesloaddir = prefixdir / 'lib/modules-load.d'
b0d3095f
LB
152networkdir = prefixdir / 'lib/systemd/network'
153systemgeneratordir = libexecdir / 'system-generators'
fce9abb2
ZJS
154usergeneratordir = prefixdir / 'lib/systemd/user-generators'
155systemenvgeneratordir = prefixdir / 'lib/systemd/system-environment-generators'
156userenvgeneratordir = prefixdir / 'lib/systemd/user-environment-generators'
b0d3095f
LB
157systemshutdowndir = libexecdir / 'system-shutdown'
158systemsleepdir = libexecdir / 'system-sleep'
159systemunitdir = prefixdir / 'lib/systemd/system'
160systempresetdir = prefixdir / 'lib/systemd/system-preset'
161udevlibexecdir = prefixdir / 'lib/udev'
fce9abb2
ZJS
162udevrulesdir = udevlibexecdir / 'rules.d'
163udevhwdbdir = udevlibexecdir / 'hwdb.d'
164catalogdir = prefixdir / 'lib/systemd/catalog'
641e2124 165kerneldir = prefixdir / 'lib/kernel'
166kernelinstalldir = kerneldir / 'install.d'
fce9abb2
ZJS
167factorydir = datadir / 'factory'
168bootlibdir = prefixdir / 'lib/systemd/boot/efi'
169testsdir = prefixdir / 'lib/systemd/tests'
26c2b302 170unittestsdir = testsdir / 'unit-tests'
539ee7ab 171testdata_dir = testsdir / 'testdata'
fce9abb2
ZJS
172systemdstatedir = localstatedir / 'lib/systemd'
173catalogstatedir = systemdstatedir / 'catalog'
174randomseeddir = localstatedir / 'lib/systemd'
b0d3095f 175profiledir = libexecdir / 'portable' / 'profile'
a121b331 176repartdefinitionsdir = libexecdir / 'repart/definitions'
b0d3095f 177ntpservicelistdir = prefixdir / 'lib/systemd/ntp-units.d'
24039e12 178credstoredir = prefixdir / 'lib/credstore'
8e35338d 179pcrlockdir = prefixdir / 'lib/pcrlock.d'
eb981a5b 180mimepackagesdir = prefixdir / 'share/mime/packages'
5c23128d 181
6495361c
FB
182configfiledir = get_option('configfiledir')
183if configfiledir == ''
184 configfiledir= sysconfdir
185endif
186pkgconfigfiledir = configfiledir / 'systemd'
187
75aaade1
TB
188docdir = get_option('docdir')
189if docdir == ''
fce9abb2 190 docdir = datadir / 'doc/systemd'
75aaade1
TB
191endif
192
5c23128d
ZJS
193pamlibdir = get_option('pamlibdir')
194if pamlibdir == ''
b0d3095f 195 pamlibdir = libdir / 'security'
5c23128d
ZJS
196endif
197
198pamconfdir = get_option('pamconfdir')
199if pamconfdir == ''
fce9abb2 200 pamconfdir = prefixdir / 'lib/pam.d'
5c23128d
ZJS
201endif
202
0abd510f
LP
203sshconfdir = get_option('sshconfdir')
204if sshconfdir == ''
205 sshconfdir = sysconfdir / 'ssh/ssh_config.d'
206endif
207
7e360799
LP
208sshdconfdir = get_option('sshdconfdir')
209if sshdconfdir == ''
210 sshdconfdir = sysconfdir / 'ssh/sshd_config.d'
211endif
212
5360b10f
LP
213sshdprivsepdir = get_option('sshdprivsepdir')
214conf.set10('CREATE_SSHDPRIVSEPDIR', sshdprivsepdir != 'no' and not sshdprivsepdir.startswith('/usr/'))
215conf.set('SSHDPRIVSEPDIR', sshdprivsepdir, description : 'SSH privilege separation directory')
216
d1ae38d8
OK
217libcryptsetup_plugins_dir = get_option('libcryptsetup-plugins-dir')
218if libcryptsetup_plugins_dir == ''
b0d3095f 219 libcryptsetup_plugins_dir = libdir / 'cryptsetup'
d1ae38d8
OK
220endif
221
444d5863 222memory_accounting_default = get_option('memory-accounting-default')
36cf4507 223status_unit_format_default = get_option('status-unit-format-default')
819c0dcb
ZJS
224if status_unit_format_default == 'auto'
225 status_unit_format_default = conf.get('BUILD_MODE_DEVELOPER') == 1 ? 'name' : 'description'
226endif
444d5863 227
b0d3095f 228conf.set_quoted('BINDIR', bindir)
491bf10c
ZJS
229conf.set_quoted('BINFMT_DIR', binfmtdir)
230conf.set_quoted('BOOTLIBDIR', bootlibdir)
fce9abb2 231conf.set_quoted('CATALOG_DATABASE', catalogstatedir / 'database')
491bf10c 232conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
6fe23ff3 233conf.set_quoted('DOC_DIR', docdir)
fce9abb2 234conf.set_quoted('DOCUMENT_ROOT', pkgdatadir / 'gatewayd')
491bf10c
ZJS
235conf.set_quoted('ENVIRONMENT_DIR', environmentdir)
236conf.set_quoted('INCLUDE_DIR', includedir)
237conf.set_quoted('LIBDIR', libdir)
b0d3095f 238conf.set_quoted('LIBEXECDIR', libexecdir)
5248a0c5 239conf.set_quoted('KERNEL_INSTALL_DIR', kernelinstalldir)
491bf10c
ZJS
240conf.set_quoted('MODPROBE_DIR', modprobedir)
241conf.set_quoted('MODULESLOAD_DIR', modulesloaddir)
5c23128d 242conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
fce9abb2 243conf.set_quoted('POLKIT_AGENT_BINARY_PATH', bindir / 'pkttyagent')
491bf10c 244conf.set_quoted('PREFIX', prefixdir)
b0d3095f 245conf.set_quoted('PREFIX_NOSLASH', prefixdir_noslash)
fce9abb2 246conf.set_quoted('RANDOM_SEED', randomseeddir / 'random-seed')
491bf10c 247conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
452d2dfd 248conf.set_quoted('RC_LOCAL_PATH', get_option('rc-local'))
0abd510f 249conf.set_quoted('SSHCONFDIR', sshconfdir)
7e360799 250conf.set_quoted('SSHDCONFDIR', sshdconfdir)
491bf10c
ZJS
251conf.set_quoted('SYSCONF_DIR', sysconfdir)
252conf.set_quoted('SYSCTL_DIR', sysctldir)
b0d3095f
LB
253conf.set_quoted('SYSTEMCTL_BINARY_PATH', bindir / 'systemctl')
254conf.set_quoted('SYSTEMD_BINARY_PATH', libexecdir / 'systemd')
bb5232b6 255conf.set_quoted('SYSTEMD_EXECUTOR_BINARY_PATH', libexecdir / 'systemd-executor')
491bf10c 256conf.set_quoted('SYSTEMD_CATALOG_DIR', catalogdir)
b0d3095f 257conf.set_quoted('SYSTEMD_CGROUPS_AGENT_PATH', libexecdir / 'systemd-cgroups-agent')
fb8d67cd 258conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', bindir / 'systemd-cryptsetup')
b0d3095f
LB
259conf.set_quoted('SYSTEMD_EXPORT_PATH', libexecdir / 'systemd-export')
260conf.set_quoted('SYSTEMD_FSCK_PATH', libexecdir / 'systemd-fsck')
261conf.set_quoted('SYSTEMD_GROWFS_PATH', libexecdir / 'systemd-growfs')
262conf.set_quoted('SYSTEMD_HOMEWORK_PATH', libexecdir / 'systemd-homework')
263conf.set_quoted('SYSTEMD_IMPORT_FS_PATH', libexecdir / 'systemd-import-fs')
264conf.set_quoted('SYSTEMD_IMPORT_PATH', libexecdir / 'systemd-import')
265conf.set_quoted('SYSTEMD_INTEGRITYSETUP_PATH', libexecdir / 'systemd-integritysetup')
fce9abb2
ZJS
266conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', pkgdatadir / 'kbd-model-map')
267conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', pkgdatadir / 'language-fallback-map')
b0d3095f
LB
268conf.set_quoted('SYSTEMD_MAKEFS_PATH', libexecdir / 'systemd-makefs')
269conf.set_quoted('SYSTEMD_PULL_PATH', libexecdir / 'systemd-pull')
270conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', libexecdir / 'systemd-shutdown')
539ee7ab 271conf.set_quoted('SYSTEMD_TEST_DATA', testdata_dir)
b0d3095f
LB
272conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', bindir / 'systemd-tty-ask-password-agent')
273conf.set_quoted('SYSTEMD_UPDATE_HELPER_PATH', libexecdir / 'systemd-update-helper')
274conf.set_quoted('SYSTEMD_USERWORK_PATH', libexecdir / 'systemd-userwork')
702a52f4 275conf.set_quoted('SYSTEMD_MOUNTWORK_PATH', libexecdir / 'systemd-mountwork')
8aee931e 276conf.set_quoted('SYSTEMD_NSRESOURCEWORK_PATH', libexecdir / 'systemd-nsresourcework')
b0d3095f 277conf.set_quoted('SYSTEMD_VERITYSETUP_PATH', libexecdir / 'systemd-veritysetup')
fce9abb2 278conf.set_quoted('SYSTEM_CONFIG_UNIT_DIR', pkgsysconfdir / 'system')
491bf10c 279conf.set_quoted('SYSTEM_DATA_UNIT_DIR', systemunitdir)
96d33e4a 280conf.set_quoted('SYSTEM_ENV_GENERATOR_DIR', systemenvgeneratordir)
491bf10c
ZJS
281conf.set_quoted('SYSTEM_GENERATOR_DIR', systemgeneratordir)
282conf.set_quoted('SYSTEM_PRESET_DIR', systempresetdir)
5c23128d
ZJS
283conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
284conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
491bf10c
ZJS
285conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
286conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
835cf75a
ZJS
287conf.set_quoted('SYSUSERS_DIR', sysusersdir)
288conf.set_quoted('TMPFILES_DIR', tmpfilesdir)
107795a7 289conf.set_quoted('USER_TMPFILES_DIR', usertmpfilesdir)
5c23128d 290conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
491bf10c
ZJS
291conf.set_quoted('UDEV_HWDB_DIR', udevhwdbdir)
292conf.set_quoted('UDEV_RULES_DIR', udevrulesdir)
fce9abb2 293conf.set_quoted('USER_CONFIG_UNIT_DIR', pkgsysconfdir / 'user')
491bf10c
ZJS
294conf.set_quoted('USER_DATA_UNIT_DIR', userunitdir)
295conf.set_quoted('USER_ENV_GENERATOR_DIR', userenvgeneratordir)
296conf.set_quoted('USER_GENERATOR_DIR', usergeneratordir)
fce9abb2 297conf.set_quoted('USER_KEYRING_PATH', pkgsysconfdir / 'import-pubring.gpg')
491bf10c 298conf.set_quoted('USER_PRESET_DIR', userpresetdir)
b0d3095f 299conf.set_quoted('VENDOR_KEYRING_PATH', libexecdir / 'import-pubring.gpg')
491bf10c
ZJS
300
301conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
e5d86ebe 302conf.set10('ENABLE_URLIFY', get_option('urlify'))
491bf10c 303conf.set10('ENABLE_FEXECVE', get_option('fexecve'))
30538ff1 304conf.set10('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default)
36cf4507 305conf.set('STATUS_UNIT_FORMAT_DEFAULT', 'STATUS_UNIT_FORMAT_' + status_unit_format_default.to_upper())
e11a25ca 306conf.set_quoted('STATUS_UNIT_FORMAT_DEFAULT_STR', status_unit_format_default)
5c23128d 307
e4c7b5f5
ZJS
308conf.set('DEFAULT_TIMEOUT_SEC', get_option('default-timeout-sec'))
309conf.set('DEFAULT_USER_TIMEOUT_SEC', get_option('default-user-timeout-sec'))
310conf.set('UPDATE_HELPER_USER_TIMEOUT_SEC', get_option('update-helper-user-timeout-sec'))
311
22330352 312conf.set10('ENABLE_FIRST_BOOT_FULL_PRESET', get_option('first-boot-full-preset'))
93651582 313
5c23128d
ZJS
314#####################################################################
315
316cc = meson.get_compiler('c')
92148283
JJ
317userspace_c_args = []
318userspace_c_ld_args = []
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')
ff4fe9de 324integration_tests = want_tests != 'false' and get_option('integration-tests')
311efaae 325install_tests = want_tests != 'false' and get_option('install-tests')
d3da291e 326
daf4e78e 327if add_languages('cpp', native : false, required : fuzzer_build)
3b2bdd62 328 # Used only for tests
e9f4f566
ZJS
329 cxx = meson.get_compiler('cpp')
330 cxx_cmd = ' '.join(cxx.cmd_array())
1b2acaa7 331else
9b0ca019 332 cxx_cmd = ''
94e2523b
ZJS
333endif
334
31e57a35 335if want_libfuzzer
9c5c4677
EV
336 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer', required : false)
337 if fuzzing_engine.found()
92148283 338 userspace_c_args += '-fsanitize-coverage=trace-pc-guard,trace-cmp'
9c5c4677 339 elif cc.has_argument('-fsanitize=fuzzer-no-link')
92148283 340 userspace_c_args += '-fsanitize=fuzzer-no-link'
9c5c4677
EV
341 else
342 error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported')
343 endif
c09edc79 344elif want_ossfuzz
7db7d5b7
JR
345 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
346endif
347
e9f4f566
ZJS
348# Those generate many false positives, and we do not want to change the code to
349# avoid them.
350basic_disabled_warnings = [
e9f4f566 351 '-Wno-missing-field-initializers',
505ab9dd 352 '-Wno-unused-parameter',
b59bce30 353 '-Wno-nonnull-compare',
e9f4f566 354]
e9f4f566 355
65267363 356possible_common_cc_flags = [
fc568837
ZJS
357 '-Warray-bounds', # clang
358 '-Warray-bounds=2',
505ab9dd
YW
359 '-Wdate-time',
360 '-Wendif-labels',
361 '-Werror=format=2',
a4ea5d19 362 '-Werror=format-signedness',
505ab9dd 363 '-Werror=implicit-function-declaration',
a0d613ec 364 '-Werror=implicit-int',
505ab9dd 365 '-Werror=incompatible-pointer-types',
ebbb1e36 366 '-Werror=int-conversion',
0b482b37
JJ
367 '-Werror=missing-declarations',
368 '-Werror=missing-prototypes',
505ab9dd 369 '-Werror=overflow',
48c67fdf 370 '-Werror=override-init',
505ab9dd
YW
371 '-Werror=return-type',
372 '-Werror=shift-count-overflow',
373 '-Werror=shift-overflow=2',
6405afda 374 '-Werror=strict-flex-arrays',
30a4ddff 375 '-Werror=undef',
505ab9dd 376 '-Wfloat-equal',
c0f5d58c
JJ
377 # gperf prevents us from enabling this because it does not emit fallthrough
378 # attribute with clang.
379 #'-Wimplicit-fallthrough',
505ab9dd
YW
380 '-Wimplicit-fallthrough=5',
381 '-Winit-self',
30a4ddff
YW
382 '-Wlogical-op',
383 '-Wmissing-include-dirs',
505ab9dd
YW
384 '-Wmissing-noreturn',
385 '-Wnested-externs',
30a4ddff
YW
386 '-Wold-style-definition',
387 '-Wpointer-arith',
30a4ddff 388 '-Wredundant-decls',
30a4ddff 389 '-Wshadow',
30a4ddff 390 '-Wstrict-aliasing=2',
505ab9dd
YW
391 '-Wstrict-prototypes',
392 '-Wsuggest-attribute=noreturn',
054ed430 393 '-Wunused-function',
30a4ddff 394 '-Wwrite-strings',
31560245 395 '-Wzero-length-bounds',
bf7efeb1
FB
396
397 # negative arguments are correctly detected starting with meson 0.46.
eed33623
ZJS
398 '-Wno-error=#warnings', # clang
399 '-Wno-string-plus-int', # clang
fc568837 400
0b482b37
JJ
401 '-fdiagnostics-show-option',
402 '-fno-common',
48e1b2c2
JJ
403 '-fstack-protector',
404 '-fstack-protector-strong',
fc568837 405 '-fstrict-flex-arrays',
48e1b2c2
JJ
406 '--param=ssp-buffer-size=4',
407]
408
409possible_common_link_flags = [
410 '-fstack-protector',
30a4ddff
YW
411]
412
b528a628
ZJS
413c_args = get_option('c_args')
414
60f97fee 415# Our json library does not support -ffinite-math-only, which is enabled by -Ofast or -ffast-math.
53403091 416if (('-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
417 error('-Ofast, -ffast-math, or -ffinite-math-only is specified in c_args.')
418endif
419
a17e5478 420# Disable -Wmaybe-uninitialized when compiling with -Os/-O1/-O3/etc. There are
68c98a41
ZJS
421# too many false positives with gcc >= 8. Effectively, we only test with -O0
422# and -O2; this should be enough to catch most important cases without too much
423# busywork. See https://github.com/systemd/systemd/pull/19226.
424if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or
b528a628
ZJS
425 cc.version().version_compare('<10') or
426 '-Os' in c_args or
427 '-O1' in c_args or
428 '-O3' in c_args or
429 '-Og' in c_args)
65267363 430 possible_common_cc_flags += '-Wno-maybe-uninitialized'
68c98a41
ZJS
431endif
432
bc2a4af2
ZJS
433# Disable -Wno-unused-result with gcc, see
434# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425.
435if cc.get_id() == 'gcc'
436 possible_common_cc_flags += '-Wno-unused-result'
437endif
438
30a4ddff 439# --as-needed and --no-undefined are provided by meson by default,
9247df5a 440# run 'meson configure' to see what is enabled
30a4ddff 441possible_link_flags = [
42e3bb35 442 '-Wl,--fatal-warnings',
30a4ddff 443 '-Wl,-z,now',
42e3bb35 444 '-Wl,-z,relro',
30a4ddff 445]
5c23128d 446
42e3bb35
JJ
447if get_option('b_sanitize') == 'none'
448 possible_link_flags += '-Wl,--warn-common'
449endif
450
30a4ddff 451if cc.get_id() == 'clang'
65267363 452 possible_common_cc_flags += [
30a4ddff
YW
453 '-Wno-typedef-redefinition',
454 '-Wno-gnu-variable-sized-type-not-at-end',
455 ]
456endif
457
1a4e3927
JJ
458if get_option('mode') == 'release'
459 # We could enable 'pattern' for developer mode, but that can interfere with
460 # valgrind and sanitizer builds. Also, clang does not zero-initialize unions,
461 # breaking some of our code (https://reviews.llvm.org/D68115).
462 possible_common_cc_flags += '-ftrivial-auto-var-init=zero'
463endif
464
92148283 465possible_cc_flags = [
16e09d51 466 '-fno-strict-aliasing',
afd8e1d9 467 '-fstrict-flex-arrays=1',
16e09d51 468 '-fvisibility=hidden',
16e09d51
YW
469]
470
30a4ddff 471if get_option('buildtype') != 'debug'
16e09d51 472 possible_cc_flags += [
30a4ddff
YW
473 '-ffunction-sections',
474 '-fdata-sections',
475 ]
476
477 possible_link_flags += '-Wl,--gc-sections'
478endif
479
82390022
DDM
480if get_option('mode') == 'developer'
481 possible_cc_flags += '-fno-omit-frame-pointer'
482endif
483
92148283
JJ
484add_project_arguments(
485 cc.get_supported_arguments(
486 basic_disabled_warnings,
487 possible_common_cc_flags
488 ),
489 language : 'c')
490
48e1b2c2
JJ
491add_project_link_arguments(
492 cc.get_supported_link_arguments(possible_common_link_flags),
493 language : 'c')
494
92148283
JJ
495userspace_c_args += cc.get_supported_arguments(possible_cc_flags)
496userspace_c_ld_args += cc.get_supported_link_arguments(possible_link_flags)
30a4ddff 497
94c0c5b7
ZJS
498have = cc.has_argument('-Wzero-length-bounds')
499conf.set10('HAVE_ZERO_LENGTH_BOUNDS', have)
500
9e70f2f8 501if cc.compiles('''
5c23128d
ZJS
502 #include <time.h>
503 #include <inttypes.h>
504 typedef uint64_t usec_t;
505 usec_t now(clockid_t clock);
506 int main(void) {
507 struct timespec now;
508 return 0;
509 }
38c1c96d 510''', args: '-Werror=shadow', name : '-Werror=shadow with local shadowing')
37efbbd8 511 add_project_arguments('-Werror=shadow', language : 'c')
5c23128d
ZJS
512endif
513
e9f4f566
ZJS
514if cxx_cmd != ''
515 add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
516endif
517
465104b4 518cpp = ' '.join(cc.cmd_array() + get_option('c_args')) + ' -E'
9cc0e6e9 519
6695c200
ZJS
520has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
521
5c23128d
ZJS
522#####################################################################
523# compilation result tests
524
78103450 525conf.set('_GNU_SOURCE', 1)
2c201c21 526conf.set('__SANE_USERSPACE_TYPES__', true)
6695c200 527conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)
5c23128d 528
5c23128d
ZJS
529conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
530conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
5c23128d 531conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
84d953e8 532conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
3112d756 533conf.set('SIZEOF_TIMEX_MEMBER', cc.sizeof('typeof(((struct timex *)0)->freq)', prefix : '#include <sys/timex.h>'))
5c23128d 534
2736a0c6 535long_max = cc.compute_int(
536 'LONG_MAX',
537 prefix : '#include <limits.h>',
538 guess : 0x7FFFFFFFFFFFFFFF,
539 high : 0x7FFFFFFFFFFFFFFF)
a5fac1df
ZJS
540assert(long_max > 100000)
541conf.set_quoted('LONG_MAX_STR', '@0@'.format(long_max))
542
5c23128d 543decl_headers = '''
eb292969 544#include <dirent.h>
5c23128d 545#include <uchar.h>
84e8edec 546#include <sys/mount.h>
4c2e1b39 547#include <sys/stat.h>
5c23128d 548'''
5c23128d
ZJS
549
550foreach decl : ['char16_t',
551 'char32_t',
84e8edec 552 'struct mount_attr',
4c2e1b39 553 'struct statx',
eb292969 554 'struct dirent64',
5c23128d 555 ]
2c201c21
ZJS
556
557 # We get -1 if the size cannot be determined
9c869d08
ZJS
558 have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
559
3657d3a0
RH
560 if decl == 'struct mount_attr'
561 if have
562 want_linux_fs_h = false
563 else
564 have = cc.sizeof(decl,
565 prefix : decl_headers + '#include <linux/fs.h>',
566 args : '-D_GNU_SOURCE') > 0
567 want_linux_fs_h = have
568 endif
569 endif
570
9c869d08
ZJS
571 if decl == 'struct statx'
572 if have
573 want_linux_stat_h = false
574 else
575 have = cc.sizeof(decl,
576 prefix : decl_headers + '#include <linux/stat.h>',
577 args : '-D_GNU_SOURCE') > 0
578 want_linux_stat_h = have
579 endif
580 endif
581
349cc4a5 582 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
5c23128d
ZJS
583endforeach
584
9c869d08 585conf.set10('WANT_LINUX_STAT_H', want_linux_stat_h)
3657d3a0 586conf.set10('WANT_LINUX_FS_H', want_linux_fs_h)
75720bff 587
5c23128d 588foreach ident : ['secure_getenv', '__secure_getenv']
349cc4a5 589 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
5c23128d
ZJS
590endforeach
591
592foreach ident : [
85db59b7 593 ['memfd_create', '''#include <sys/mman.h>'''],
7b961e40
LP
594 ['gettid', '''#include <sys/types.h>
595 #include <unistd.h>'''],
c21566d9
AM
596 ['fchmodat2', '''#include <stdlib.h>
597 #include <fcntl.h>'''], # no known header declares fchmodat2
3c042add
LP
598 ['pivot_root', '''#include <stdlib.h>
599 #include <unistd.h>'''], # no known header declares pivot_root
51fe206f
ZJS
600 ['ioprio_get', '''#include <sched.h>'''], # no known header declares ioprio_get
601 ['ioprio_set', '''#include <sched.h>'''], # no known header declares ioprio_set
85db59b7 602 ['name_to_handle_at', '''#include <sys/types.h>
37efbbd8
ZJS
603 #include <sys/stat.h>
604 #include <fcntl.h>'''],
85db59b7 605 ['setns', '''#include <sched.h>'''],
2acfd0ff
LP
606 ['renameat2', '''#include <stdio.h>
607 #include <fcntl.h>'''],
37efbbd8
ZJS
608 ['kcmp', '''#include <linux/kcmp.h>'''],
609 ['keyctl', '''#include <sys/types.h>
610 #include <keyutils.h>'''],
85db59b7 611 ['copy_file_range', '''#include <sys/syscall.h>
37efbbd8 612 #include <unistd.h>'''],
71e5200f
DM
613 ['bpf', '''#include <sys/syscall.h>
614 #include <unistd.h>'''],
4c2e1b39
LP
615 ['statx', '''#include <sys/types.h>
616 #include <sys/stat.h>
617 #include <unistd.h>'''],
aa484f35 618 ['explicit_bzero' , '''#include <string.h>'''],
5bb20fd3 619 ['reallocarray', '''#include <stdlib.h>'''],
b070c7c0
MS
620 ['set_mempolicy', '''#include <stdlib.h>
621 #include <unistd.h>'''],
622 ['get_mempolicy', '''#include <stdlib.h>
623 #include <unistd.h>'''],
5f152f43
LP
624 ['pidfd_send_signal', '''#include <stdlib.h>
625 #include <unistd.h>
626 #include <signal.h>
627 #include <sys/wait.h>'''],
628 ['pidfd_open', '''#include <stdlib.h>
629 #include <unistd.h>
630 #include <signal.h>
631 #include <sys/wait.h>'''],
5ead4e85
LP
632 ['rt_sigqueueinfo', '''#include <stdlib.h>
633 #include <unistd.h>
634 #include <signal.h>
635 #include <sys/wait.h>'''],
a5421953
DDM
636 ['rt_tgsigqueueinfo', '''#include <stdlib.h>
637 #include <unistd.h>
638 #include <signal.h>
639 #include <sys/wait.h>'''],
4b6f74f5 640 ['mallinfo', '''#include <malloc.h>'''],
1885169c 641 ['mallinfo2', '''#include <malloc.h>'''],
8939eeae 642 ['execveat', '''#include <unistd.h>'''],
441e0fdb 643 ['close_range', '''#include <unistd.h>'''],
420297c9 644 ['epoll_pwait2', '''#include <sys/epoll.h>'''],
84e8edec
LP
645 ['mount_setattr', '''#include <sys/mount.h>'''],
646 ['move_mount', '''#include <sys/mount.h>'''],
647 ['open_tree', '''#include <sys/mount.h>'''],
1c265fcd
DDM
648 ['fsopen', '''#include <sys/mount.h>'''],
649 ['fsconfig', '''#include <sys/mount.h>'''],
34a9da0d 650 ['fsmount', '''#include <sys/mount.h>'''],
aab35b1e 651 ['getdents64', '''#include <dirent.h>'''],
2e106312 652 ['pidfd_spawn', '''#include <spawn.h>'''],
37efbbd8
ZJS
653]
654
85db59b7 655 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
4b9545f1 656 conf.set10('HAVE_' + ident[0].to_upper(), have)
5c23128d
ZJS
657endforeach
658
85db59b7 659if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
349cc4a5 660 conf.set10('USE_SYS_RANDOM_H', true)
4b9545f1 661 conf.set10('HAVE_GETRANDOM', true)
4984c8be
ZJS
662else
663 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
349cc4a5 664 conf.set10('USE_SYS_RANDOM_H', false)
4b9545f1 665 conf.set10('HAVE_GETRANDOM', have)
4984c8be
ZJS
666endif
667
5c23128d
ZJS
668#####################################################################
669
0f4c4f38
ZJS
670sh = find_program('sh')
671echo = find_program('echo')
5c23128d 672sed = find_program('sed')
5c23128d 673awk = find_program('awk')
5c23128d 674stat = find_program('stat')
0f4c4f38 675ln = find_program('ln')
d68b342b 676git = find_program('git', required : false)
b68dfb9e 677env = find_program('env')
0f4c4f38 678rsync = find_program('rsync', required : false)
4d56d084 679diff = find_program('diff')
d9081eb0 680find = find_program('find')
5c23128d 681
9289e093 682ln_s = ln.full_path() + ' -frsT -- "${DESTDIR:-}@0@" "${DESTDIR:-}@1@"'
94e75a54 683
9247df5a 684# If -Dxxx-path option is found, use that. Otherwise, check in $PATH,
5c23128d 685# /usr/sbin, /sbin, and fall back to the default from middle column.
2fa645f1 686progs = [['quotaon', '/usr/sbin/quotaon' ],
5c23128d 687 ['quotacheck', '/usr/sbin/quotacheck' ],
5c23128d
ZJS
688 ['kmod', '/usr/bin/kmod' ],
689 ['kexec', '/usr/sbin/kexec' ],
690 ['sulogin', '/usr/sbin/sulogin' ],
691 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
692 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
693 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
694 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
6db90462 695 ['nologin', '/usr/sbin/nologin', ],
5c23128d
ZJS
696 ]
697foreach prog : progs
37efbbd8
ZJS
698 path = get_option(prog[0] + '-path')
699 if path != ''
700 message('Using @1@ for @0@'.format(prog[0], path))
701 else
702 exe = find_program(prog[0],
703 '/usr/sbin/' + prog[0],
704 '/sbin/' + prog[0],
705 required: false)
573c0dc1 706 path = exe.found() ? exe.full_path() : prog[1]
37efbbd8
ZJS
707 endif
708 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
709 conf.set_quoted(name, path)
5c23128d
ZJS
710endforeach
711
e92777d2 712if run_command(ln, '--relative', '--help', check : false).returncode() != 0
cd001016 713 error('ln does not support --relative (added in coreutils 8.16)')
1276a9f6 714endif
5c23128d 715
e6267e83 716#####################################################################
5c23128d
ZJS
717
718gperf = find_program('gperf')
719
720gperf_test_format = '''
721#include <string.h>
722const char * in_word_set(const char *, @0@);
723@1@
724'''
ac3eda34 725gperf_snippet = run_command(sh, '-c', 'echo foo,bar | "$1" -L ANSI-C', '_', gperf,
e92777d2 726 check : true)
5c23128d
ZJS
727gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
728if cc.compiles(gperf_test)
37efbbd8 729 gperf_len_type = 'size_t'
5c23128d 730else
37efbbd8
ZJS
731 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
732 if cc.compiles(gperf_test)
733 gperf_len_type = 'unsigned'
734 else
735 error('unable to determine gperf len type')
736 endif
5c23128d
ZJS
737endif
738message('gperf len type is @0@'.format(gperf_len_type))
37efbbd8
ZJS
739conf.set('GPERF_LEN_TYPE', gperf_len_type,
740 description : 'The type of gperf "len" parameter')
5c23128d 741
e6267e83 742#####################################################################
5c23128d
ZJS
743
744if not cc.has_header('sys/capability.h')
37efbbd8 745 error('POSIX caps headers not found')
5c23128d 746endif
9f555bba 747foreach header : ['crypt.h',
7258971b 748 'linux/ioprio.h',
5c23128d 749 'linux/memfd.h',
7258971b 750 'linux/time_types.h',
5c23128d 751 'linux/vm_sockets.h',
af8786b1 752 'sys/auxv.h',
7258971b 753 'sys/sdt.h',
5545f336 754 'threads.h',
5c23128d
ZJS
755 'valgrind/memcheck.h',
756 'valgrind/valgrind.h',
757 ]
2c201c21 758
349cc4a5
ZJS
759 conf.set10('HAVE_' + header.underscorify().to_upper(),
760 cc.has_header(header))
5c23128d
ZJS
761endforeach
762
e6267e83 763#####################################################################
5c23128d 764
eef4b800
ZJS
765fallback_hostname = get_option('fallback-hostname')
766if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0] == '-'
767 error('Invalid fallback-hostname configuration')
768 # A more extensive test is done in test-hostname-util. Let's catch
769 # the most obvious errors here so we don't fail with an assert later.
770endif
771conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
772
681cb84a
ZJS
773extra_net_naming_schemes = []
774extra_net_naming_map = []
775foreach scheme: get_option('extra-net-naming-schemes').split(',')
776 if scheme != ''
777 name = scheme.split('=')[0]
778 value = scheme.split('=')[1]
779 NAME = name.underscorify().to_upper()
780 VALUE = []
781 foreach field: value.split('+')
782 VALUE += 'NAMING_' + field.underscorify().to_upper()
783 endforeach
784 extra_net_naming_schemes += 'NAMING_@0@ = @1@,'.format(NAME, '|'.join(VALUE))
785 extra_net_naming_map += '{ "@0@", NAMING_@1@ },'.format(name, NAME)
786 endif
787endforeach
788conf.set('EXTRA_NET_NAMING_SCHEMES', ' '.join(extra_net_naming_schemes))
789conf.set('EXTRA_NET_NAMING_MAP', ' '.join(extra_net_naming_map))
790
06da5c63 791default_net_naming_scheme = get_option('default-net-naming-scheme')
386256e6
ZJS
792conf.set_quoted('DEFAULT_NET_NAMING_SCHEME', default_net_naming_scheme,
793 description : 'Default naming scheme as a string')
77faadfd 794if default_net_naming_scheme != 'latest'
386256e6
ZJS
795 conf.set('_DEFAULT_NET_NAMING_SCHEME',
796 'NAMING_' + default_net_naming_scheme.underscorify().to_upper(),
797 description : 'Default naming scheme as a constant')
77faadfd 798endif
06da5c63 799
5c23128d 800time_epoch = get_option('time-epoch')
a36be3e5 801if time_epoch <= 0
e92777d2 802 time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check : true).stdout().strip()
edd84b8e 803 if time_epoch == '' and git.found() and fs.is_dir('.git')
bd190899 804 # If we're in a git repository, use the creation time of the latest git tag.
e92777d2
ZJS
805 latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags',
806 check : false)
807 if latest_tag.returncode() == 0
808 time_epoch = run_command(
809 git, 'log', '--no-show-signature', '-1', '--format=%at',
810 latest_tag.stdout().strip(),
811 check : false).stdout()
812 endif
0390b094
ZJS
813 endif
814 if time_epoch == ''
6dbf352c 815 NEWS = files('NEWS')
e92777d2
ZJS
816 time_epoch = run_command(stat, '-c', '%Y', NEWS,
817 check : true).stdout()
6dbf352c 818 endif
89cdbe1f 819 time_epoch = time_epoch.strip().to_int()
5c23128d 820endif
5c23128d
ZJS
821conf.set('TIME_EPOCH', time_epoch)
822
b10abe4b
EI
823conf.set('CLOCK_VALID_RANGE_USEC_MAX', get_option('clock-valid-range-usec-max'))
824
53350c7b 825default_user_shell = get_option('default-user-shell')
826conf.set_quoted('DEFAULT_USER_SHELL', default_user_shell)
827conf.set_quoted('DEFAULT_USER_SHELL_NAME', fs.name(default_user_shell))
828
fc1a5d1a
ZJS
829foreach tuple : [['system-alloc-uid-min', 'SYS_UID_MIN', 1], # Also see login.defs(5).
830 ['system-uid-max', 'SYS_UID_MAX', 999],
831 ['system-alloc-gid-min', 'SYS_GID_MIN', 1],
832 ['system-gid-max', 'SYS_GID_MAX', 999]]
833 v = get_option(tuple[0])
a36be3e5 834 if v <= 0
fc1a5d1a
ZJS
835 v = run_command(
836 awk,
837 '/^\s*@0@\s+/ { uid=$2 } END { print uid }'.format(tuple[1]),
e92777d2
ZJS
838 '/etc/login.defs',
839 check : false).stdout().strip()
fc1a5d1a
ZJS
840 if v == ''
841 v = tuple[2]
842 else
843 v = v.to_int()
844 endif
2f62cf35 845 endif
fc1a5d1a 846 conf.set(tuple[0].underscorify().to_upper(), v)
fc1a5d1a
ZJS
847endforeach
848if conf.get('SYSTEM_ALLOC_UID_MIN') >= conf.get('SYSTEM_UID_MAX')
849 error('Invalid uid allocation range')
5c23128d 850endif
fc1a5d1a
ZJS
851if conf.get('SYSTEM_ALLOC_GID_MIN') >= conf.get('SYSTEM_GID_MAX')
852 error('Invalid gid allocation range')
5c23128d 853endif
5c23128d 854
ac09340e
YW
855dynamic_uid_min = get_option('dynamic-uid-min')
856dynamic_uid_max = get_option('dynamic-uid-max')
87d5e4f2
LP
857conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
858conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
87d5e4f2 859
ac09340e
YW
860container_uid_base_min = get_option('container-uid-base-min')
861container_uid_base_max = get_option('container-uid-base-max')
87d5e4f2
LP
862conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
863conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
87d5e4f2 864
afde4574
LP
865nobody_user = get_option('nobody-user')
866nobody_group = get_option('nobody-group')
867
2484bff3 868if not meson.is_cross_build()
e92777d2 869 getent_result = run_command('getent', 'passwd', '65534', check : false)
2484bff3
CQ
870 if getent_result.returncode() == 0
871 name = getent_result.stdout().split(':')[0]
872 if name != nobody_user
873 warning('\n' +
874 '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) +
875 'Your build will result in an user table setup that is incompatible with the local system.')
876 endif
afde4574 877 endif
e92777d2 878 id_result = run_command('id', '-u', nobody_user, check : false)
2484bff3 879 if id_result.returncode() == 0
89cdbe1f 880 id = id_result.stdout().strip().to_int()
2484bff3
CQ
881 if id != 65534
882 warning('\n' +
883 '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) +
884 'Your build will result in an user table setup that is incompatible with the local system.')
885 endif
afde4574 886 endif
afde4574 887
e92777d2 888 getent_result = run_command('getent', 'group', '65534', check : false)
2484bff3
CQ
889 if getent_result.returncode() == 0
890 name = getent_result.stdout().split(':')[0]
891 if name != nobody_group
892 warning('\n' +
893 '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) +
894 'Your build will result in an group table setup that is incompatible with the local system.')
895 endif
afde4574 896 endif
e92777d2 897 id_result = run_command('id', '-g', nobody_group, check : false)
2484bff3 898 if id_result.returncode() == 0
89cdbe1f 899 id = id_result.stdout().strip().to_int()
2484bff3
CQ
900 if id != 65534
901 warning('\n' +
d5b3e510 902 '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
903 'Your build will result in an group table setup that is incompatible with the local system.')
904 endif
afde4574
LP
905 endif
906endif
8374cc62 907if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
8ea9fad7 908 warning('\n' +
79f48703 909 'The configured user name "@0@" and group name "@1@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
8ea9fad7 910 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
8374cc62 911endif
afde4574
LP
912
913conf.set_quoted('NOBODY_USER_NAME', nobody_user)
914conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
87d5e4f2 915
9a797ddc
ZJS
916static_ugids = []
917foreach option : ['adm-gid',
918 'audio-gid',
919 'cdrom-gid',
920 'dialout-gid',
921 'disk-gid',
922 'input-gid',
923 'kmem-gid',
924 'kvm-gid',
925 'lp-gid',
926 'render-gid',
927 'sgx-gid',
928 'tape-gid',
929 'tty-gid',
930 'users-gid',
931 'utmp-gid',
932 'video-gid',
933 'wheel-gid',
934 'systemd-journal-gid',
935 'systemd-network-uid',
936 'systemd-resolve-uid',
937 'systemd-timesync-uid']
938 name = option.underscorify().to_upper()
939 val = get_option(option)
940
941 # Ensure provided GID argument is numeric, otherwise fall back to default assignment
a36be3e5
YW
942 conf.set(name, val > 0 ? val : '-')
943 if val > 0
9a797ddc
ZJS
944 static_ugids += '@0@:@1@'.format(option, val)
945 endif
946endforeach
84786b8e 947
348b4437
YW
948conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
949conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
5c23128d 950
ace5e311 951dev_kvm_mode = get_option('dev-kvm-mode')
d924a938 952conf.set_quoted('DEV_KVM_MODE', dev_kvm_mode) # FIXME: convert to 0o… notation
ace5e311 953conf.set10('DEV_KVM_UACCESS', dev_kvm_mode != '0666')
055a083a 954group_render_mode = get_option('group-render-mode')
8feaea5e 955conf.set_quoted('GROUP_RENDER_MODE', group_render_mode)
055a083a 956conf.set10('GROUP_RENDER_UACCESS', group_render_mode != '0666')
5c23128d 957
2a4c156d
ZJS
958kill_user_processes = get_option('default-kill-user-processes')
959conf.set10('KILL_USER_PROCESSES', kill_user_processes)
5c23128d 960
829257d1
ZJS
961dns_servers = get_option('dns-servers')
962conf.set_quoted('DNS_SERVERS', dns_servers)
5c23128d 963
829257d1
ZJS
964ntp_servers = get_option('ntp-servers')
965conf.set_quoted('NTP_SERVERS', ntp_servers)
5c23128d 966
8ca9e92c
DR
967default_locale = get_option('default-locale')
968conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale)
969
a22f5186
DDM
970nspawn_locale = get_option('nspawn-locale')
971conf.set_quoted('SYSTEMD_NSPAWN_LOCALE', nspawn_locale)
972
f129d0e7 973default_keymap = get_option('default-keymap')
ef7f5baa 974if default_keymap == ''
bf77d597 975 # We canonicalize empty keymap to '@kernel', as it makes the default value
ef7f5baa 976 # in the factory provided /etc/vconsole.conf more obvious.
bf77d597 977 default_keymap = '@kernel'
ef7f5baa 978endif
f129d0e7
MY
979conf.set_quoted('SYSTEMD_DEFAULT_KEYMAP', default_keymap)
980
8f20232f 981localegen_path = get_option('localegen-path')
8f20232f
MK
982if localegen_path != ''
983 conf.set_quoted('LOCALEGEN_PATH', localegen_path)
8f20232f 984endif
71ae5ce5 985conf.set10('HAVE_LOCALEGEN', localegen_path != '')
8f20232f 986
5c23128d
ZJS
987conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
988
21d0dd5a 989service_watchdog = get_option('service-watchdog')
7bc9ea51 990watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
059cc610 991conf.set_quoted('SERVICE_WATCHDOG', watchdog_value)
21d0dd5a 992
059cc610 993conf.set_quoted('SUSHELL', get_option('debug-shell'))
93912e87 994conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
3131bfe3 995
349cc4a5
ZJS
996enable_debug_hashmap = false
997enable_debug_mmap_cache = false
d6601495 998enable_debug_siphash = false
8f6b442a 999foreach name : get_option('debug-extra')
ad7aa760
YW
1000 if name == 'hashmap'
1001 enable_debug_hashmap = true
1002 elif name == 'mmap-cache'
1003 enable_debug_mmap_cache = true
d6601495
YW
1004 elif name == 'siphash'
1005 enable_debug_siphash = true
ad7aa760
YW
1006 else
1007 message('unknown debug option "@0@", ignoring'.format(name))
1008 endif
1009endforeach
349cc4a5
ZJS
1010conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
1011conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
d6601495 1012conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash)
fd5dec9a 1013conf.set10('LOG_TRACE', get_option('log-trace'))
d18cb393 1014
3602ca6f
ZJS
1015default_user_path = get_option('user-path')
1016if default_user_path != ''
1017 conf.set_quoted('DEFAULT_USER_PATH', default_user_path)
1018endif
1019
5c23128d
ZJS
1020#####################################################################
1021
1022threads = dependency('threads')
1023librt = cc.find_library('rt')
1024libm = cc.find_library('m')
1025libdl = cc.find_library('dl')
55573787
YW
1026libcrypt = dependency('libcrypt', 'libxcrypt', required : false)
1027if not libcrypt.found()
1028 # fallback to use find_library() if libcrypt is provided by glibc, e.g. for LibreELEC.
1029 libcrypt = cc.find_library('crypt')
1030endif
d625f717 1031libcap = dependency('libcap')
5c23128d 1032
96f8c636
ZJS
1033# On some architectures, libatomic is required. But on some installations,
1034# it is found, but actual linking fails. So let's try to use it opportunistically.
1035# If it is installed, but not needed, it will be dropped because of --as-needed.
1036if cc.links('''int main(int argc, char **argv) { return 0; }''',
1037 args : '-latomic',
1038 name : 'libatomic')
1039 libatomic = declare_dependency(link_args : '-latomic')
1040else
1041 libatomic = []
1042endif
1043
06ca077b 1044crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
e8644a41 1045foreach ident : [
feee7f62
LB
1046 ['crypt_ra', crypt_header],
1047 ['crypt_preferred_method', crypt_header],
1048 ['crypt_gensalt_ra', crypt_header]]
e8644a41
ZJS
1049
1050 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
1051 dependencies : libcrypt)
1052 conf.set10('HAVE_' + ident[0].to_upper(), have)
1053endforeach
1054
847e5585 1055bpf_framework = get_option('bpf-framework')
b88323e4 1056bpf_compiler = get_option('bpf-compiler')
847e5585
JJ
1057libbpf = dependency('libbpf',
1058 required : bpf_framework,
1059 version : bpf_compiler == 'gcc' ? '>= 1.0.0' : '>= 0.1.0')
7d861e12
JK
1060conf.set10('HAVE_LIBBPF', libbpf.found())
1061
847e5585 1062if not libbpf.found()
cf2dc690 1063 conf.set10('BPF_FRAMEWORK', false)
7d861e12 1064else
76abad4d
JH
1065 clang_found = false
1066 clang_supports_bpf = false
1067 bpf_gcc_found = false
b88323e4 1068 bpftool_strip = false
76abad4d
JH
1069 deps_found = false
1070
1071 if bpf_compiler == 'clang'
1072 # Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu
1073 # (like clang-10/llvm-strip-10)
1074 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')
847e5585
JJ
1075 r = find_program('clang',
1076 required : bpf_framework,
1077 version : '>= 10.0.0')
76abad4d
JH
1078 clang_found = r.found()
1079 if clang_found
573c0dc1 1080 clang = r.full_path()
76abad4d 1081 endif
76abad4d
JH
1082 else
1083 clang_found = true
1084 clang = cc.cmd_array()
dc7e9c1b 1085 endif
a6ac8b5a 1086
76abad4d
JH
1087 if clang_found
1088 # Check if 'clang -target bpf' is supported.
1089 clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0
1090 endif
1091 elif bpf_compiler == 'gcc'
76abad4d 1092 bpf_gcc = find_program('bpf-gcc',
e4086f7d 1093 'bpf-none-gcc',
76abad4d 1094 required : true,
4a7a13b5 1095 version : '>= 13.1.0')
76abad4d 1096 bpf_gcc_found = bpf_gcc.found()
a6ac8b5a
YW
1097 endif
1098
76abad4d
JH
1099 if clang_supports_bpf or bpf_gcc_found
1100 # Debian installs this in /usr/sbin/ which is not in $PATH.
1101 # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian.
1102 # We use 'bpftool gen object' subcommand for bpftool strip, it was added by d80b2fcbe0a023619e0fc73112f2a02c2662f6ab (v5.13).
e3759ac4
JH
1103 bpftool = find_program('bpftool',
1104 '/usr/sbin/bpftool',
847e5585
JJ
1105 required : bpf_framework.enabled() and bpf_compiler == 'gcc',
1106 version : bpf_compiler == 'gcc' ? '>= 7.0.0' : '>= 5.13.0')
e3759ac4 1107
76abad4d
JH
1108 if bpftool.found()
1109 bpftool_strip = true
1110 deps_found = true
b88323e4 1111 elif bpf_compiler == 'clang'
76abad4d
JH
1112 # We require the 'bpftool gen skeleton' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6).
1113 bpftool = find_program('bpftool',
1114 '/usr/sbin/bpftool',
847e5585 1115 required : bpf_framework,
76abad4d 1116 version : '>= 5.6.0')
e3759ac4 1117 endif
68e101da 1118
76abad4d
JH
1119 # We use `llvm-strip` as a fallback if `bpftool gen object` strip support is not available.
1120 if not bpftool_strip and bpftool.found() and clang_supports_bpf
1121 if not meson.is_cross_build()
1122 llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip',
1123 check : true).stdout().strip()
1124 else
1125 llvm_strip_bin = 'llvm-strip'
1126 endif
847e5585
JJ
1127 llvm_strip = find_program(llvm_strip_bin,
1128 required : bpf_framework,
1129 version : '>= 10.0.0')
76abad4d
JH
1130 deps_found = llvm_strip.found()
1131 endif
1132 endif
68e101da 1133
7d861e12 1134 # Can build BPF program from source code in restricted C
d40ce018 1135 conf.set10('BPF_FRAMEWORK', deps_found)
7d861e12
JK
1136endif
1137
5c23128d 1138libmount = dependency('mount',
c0b4b0f8 1139 version : fuzzer_build ? '>= 0' : '>= 2.30')
5c23128d 1140
9ee80846
JJ
1141libfdisk = dependency('fdisk',
1142 version : '>= 2.32',
1143 disabler : true,
1144 required : get_option('fdisk'))
1145conf.set10('HAVE_LIBFDISK', libfdisk.found())
e594a3b1 1146
1e73a64a
JJ
1147# This prefers pwquality if both are enabled or auto.
1148feature = get_option('pwquality').disable_auto_if(get_option('passwdqc').enabled())
1149libpwquality = dependency('pwquality',
1150 version : '>= 1.4.1',
1151 required : feature)
1152have = libpwquality.found()
1153if not have
1154 # libpwquality is used for both features for simplicity
1155 libpwquality = dependency('passwdqc',
1156 required : get_option('passwdqc'))
70a5db58
LP
1157endif
1158conf.set10('HAVE_PWQUALITY', have)
1e73a64a 1159conf.set10('HAVE_PASSWDQC', not have and libpwquality.found())
70a5db58 1160
43abc59a
JJ
1161libseccomp = dependency('libseccomp',
1162 version : '>= 2.3.1',
1163 required : get_option('seccomp'))
1164conf.set10('HAVE_SECCOMP', libseccomp.found())
1d8aae43 1165
43abc59a
JJ
1166libselinux = dependency('libselinux',
1167 version : '>= 2.1.9',
1168 required : get_option('selinux'))
1169conf.set10('HAVE_SELINUX', libselinux.found())
5c23128d 1170
43abc59a
JJ
1171libapparmor = dependency('libapparmor',
1172 version : '>= 2.13',
1173 required : get_option('apparmor'))
1174conf.set10('HAVE_APPARMOR', libapparmor.found())
5c23128d 1175
07b382cc
ZJS
1176have = get_option('smack') and get_option('smack-run-label') != ''
1177conf.set10('HAVE_SMACK_RUN_LABEL', have)
1178if have
1179 conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
1180endif
5c23128d 1181
aa5ae971
ŁS
1182have = get_option('smack') and get_option('smack-default-process-label') != ''
1183if have
1184 conf.set_quoted('SMACK_DEFAULT_PROCESS_LABEL', get_option('smack-default-process-label'))
1185endif
1186
a0c9ac9a
JJ
1187feature = get_option('polkit')
1188libpolkit = dependency('polkit-gobject-1',
1189 required : feature.disabled() ? feature : false)
1190install_polkit = feature.allowed()
1191install_polkit_pkla = libpolkit.found() and libpolkit.version().version_compare('< 0.106')
1192if install_polkit_pkla
1193 message('Old polkit detected, will install pkla files')
3ca0cb73 1194endif
349cc4a5 1195conf.set10('ENABLE_POLKIT', install_polkit)
3ca0cb73 1196
43abc59a
JJ
1197libacl = dependency('libacl',
1198 required : get_option('acl'))
1199conf.set10('HAVE_ACL', libacl.found())
36f0387e 1200
43abc59a
JJ
1201libaudit = dependency('audit',
1202 required : get_option('audit'))
1203conf.set10('HAVE_AUDIT', libaudit.found())
4fcc033b 1204
43abc59a
JJ
1205libblkid = dependency('blkid',
1206 required : get_option('blkid'))
1207conf.set10('HAVE_BLKID', libblkid.found())
1208conf.set10('HAVE_BLKID_PROBE_SET_HINT',
1209 libblkid.found() and cc.has_function('blkid_probe_set_hint', dependencies : libblkid))
5c23128d 1210
43abc59a
JJ
1211libkmod = dependency('libkmod',
1212 version : '>= 15',
1213 required : get_option('kmod'))
1214conf.set10('HAVE_KMOD', libkmod.found())
1d98716e 1215libkmod_cflags = libkmod.partial_dependency(includes: true, compile_args: true)
5c23128d 1216
43abc59a
JJ
1217libxenctrl = dependency('xencontrol',
1218 version : '>= 4.9',
1219 required : get_option('xenctrl'))
1220conf.set10('HAVE_XENCTRL', libxenctrl.found())
2bdd7a8a 1221libxenctrl_cflags = libxenctrl.partial_dependency(includes: true, compile_args: true)
ede5a78f 1222
a0c9ac9a
JJ
1223feature = get_option('pam')
1224libpam = dependency('pam',
1225 required : feature.disabled() ? feature : false)
1226if not libpam.found()
1227 # Debian older than bookworm and Ubuntu older than 22.10 do not provide the .pc file.
1228 libpam = cc.find_library('pam', required : feature)
1229endif
1230libpam_misc = dependency('pam_misc',
1231 required : feature.disabled() ? feature : false)
1232if not libpam_misc.found()
1233 libpam_misc = cc.find_library('pam_misc', required : feature)
5c23128d 1234endif
a0c9ac9a 1235conf.set10('HAVE_PAM', libpam.found() and libpam_misc.found())
5c23128d 1236
43abc59a
JJ
1237libmicrohttpd = dependency('libmicrohttpd',
1238 version : '>= 0.9.33',
1239 required : get_option('microhttpd'))
1240conf.set10('HAVE_MICROHTTPD', libmicrohttpd.found())
5c23128d 1241
1e73a64a
JJ
1242libcryptsetup = get_option('libcryptsetup')
1243libcryptsetup_plugins = get_option('libcryptsetup-plugins')
1244if libcryptsetup_plugins.enabled()
1245 if libcryptsetup.disabled()
cee60fc3 1246 error('libcryptsetup-plugins cannot be requested without libcryptsetup')
d625f717 1247 endif
1e73a64a
JJ
1248 libcryptsetup = libcryptsetup_plugins
1249endif
1250
1251libcryptsetup = dependency('libcryptsetup',
1252 version : libcryptsetup_plugins.enabled() ? '>= 2.4.0' : '>= 2.0.1',
1253 required : libcryptsetup)
1254
1255have = libcryptsetup.found()
1256foreach ident : ['crypt_set_metadata_size',
1257 'crypt_activate_by_signed_key',
1258 'crypt_token_max',
1259 'crypt_reencrypt_init_by_passphrase',
1260 'crypt_reencrypt',
c5daf14c 1261 'crypt_set_data_offset',
d0eff7a1
AV
1262 'crypt_set_keyring_to_link',
1263 'crypt_resume_by_volume_key']
1e73a64a
JJ
1264 have_ident = have and cc.has_function(
1265 ident,
1266 prefix : '#include <libcryptsetup.h>',
1267 dependencies : libcryptsetup)
1268 conf.set10('HAVE_' + ident.to_upper(), have_ident)
1269endforeach
349cc4a5 1270conf.set10('HAVE_LIBCRYPTSETUP', have)
5c23128d 1271
1e73a64a
JJ
1272# TODO: Use has_function(required : libcryptsetup_plugins) with meson >= 1.3.0
1273if libcryptsetup_plugins.allowed()
aac80717
ZJS
1274 have = (cc.has_function(
1275 'crypt_activate_by_token_pin',
1276 prefix : '#include <libcryptsetup.h>',
1277 dependencies : libcryptsetup) and
1278 cc.has_function(
1279 'crypt_token_external_path',
1280 prefix : '#include <libcryptsetup.h>',
1281 dependencies : libcryptsetup))
d1ae38d8
OK
1282else
1283 have = false
1284endif
1285conf.set10('HAVE_LIBCRYPTSETUP_PLUGINS', have)
1286
43abc59a
JJ
1287libcurl = dependency('libcurl',
1288 version : '>= 7.32.0',
1289 required : get_option('libcurl'))
1290conf.set10('HAVE_LIBCURL', libcurl.found())
47350c5f 1291conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
5c23128d 1292
1e73a64a
JJ
1293feature = get_option('libidn2').disable_auto_if(get_option('libidn').enabled())
1294libidn = dependency('libidn2',
1295 required : feature)
1296have = libidn.found()
1297if not have
7f7ab228 1298 # libidn is used for both libidn and libidn2 objects
1b931399 1299 libidn = dependency('libidn',
1e73a64a 1300 required : get_option('libidn'))
5c23128d 1301endif
1e73a64a
JJ
1302conf.set10('HAVE_LIBIDN', not have and libidn.found())
1303conf.set10('HAVE_LIBIDN2', have)
5c23128d 1304
43abc59a
JJ
1305libiptc = dependency('libiptc',
1306 required : get_option('libiptc'))
1307conf.set10('HAVE_LIBIPTC', libiptc.found())
5b5f8f8b 1308libiptc_cflags = libiptc.partial_dependency(includes: true, compile_args: true)
5c23128d 1309
43abc59a
JJ
1310libqrencode = dependency('libqrencode',
1311 version : '>= 3',
1312 required : get_option('qrencode'))
1313conf.set10('HAVE_QRENCODE', libqrencode.found())
5c23128d 1314
a0c9ac9a
JJ
1315feature = get_option('gcrypt')
1316libgcrypt = dependency('libgcrypt',
1317 required : feature)
1318libgpg_error = dependency('gpg-error',
1319 required : feature.disabled() ? feature : false)
1320if not libgpg_error.found()
1321 # CentOS 8 does not provide the .pc file.
1322 libgpg_error = cc.find_library('gpg-error', required : feature)
349cc4a5 1323endif
a0c9ac9a
JJ
1324
1325have = libgcrypt.found() and libgpg_error.found()
349cc4a5
ZJS
1326if not have
1327 # link to neither of the libs if one is not found
a44fb601
ZJS
1328 libgcrypt = []
1329 libgpg_error = []
8707c9b2
LB
1330 libgcrypt_cflags = []
1331else
1332 libgcrypt_cflags = libgcrypt.partial_dependency(includes: true, compile_args: true)
a44fb601 1333endif
349cc4a5 1334conf.set10('HAVE_GCRYPT', have)
a44fb601 1335
43abc59a
JJ
1336libgnutls = dependency('gnutls',
1337 version : '>= 3.1.4',
1338 required : get_option('gnutls'))
1339conf.set10('HAVE_GNUTLS', libgnutls.found())
5c23128d 1340
43abc59a
JJ
1341libopenssl = dependency('openssl',
1342 version : '>= 1.1.0',
1343 required : get_option('openssl'))
1344conf.set10('HAVE_OPENSSL', libopenssl.found())
096cbdce 1345
43abc59a
JJ
1346libp11kit = dependency('p11-kit-1',
1347 version : '>= 0.23.3',
1348 required : get_option('p11kit'))
1349conf.set10('HAVE_P11KIT', libp11kit.found())
1350libp11kit_cflags = libp11kit.partial_dependency(includes: true, compile_args: true)
839fddbe 1351
40e9c4e4
JJ
1352feature = get_option('libfido2').require(
1353 conf.get('HAVE_OPENSSL') == 1,
1354 error_message : 'openssl required')
1355libfido2 = dependency('libfido2',
1356 required : feature)
1357conf.set10('HAVE_LIBFIDO2', libfido2.found())
af4fbd46 1358
43abc59a
JJ
1359tpm2 = dependency('tss2-esys tss2-rc tss2-mu tss2-tcti-device',
1360 required : get_option('tpm2'))
1361conf.set10('HAVE_TPM2', tpm2.found())
1362conf.set10('HAVE_TSS2_ESYS3', tpm2.found() and tpm2.version().version_compare('>= 3.0.0'))
5e521624 1363
43abc59a
JJ
1364libdw = dependency('libdw',
1365 required : get_option('elfutils'))
1366conf.set10('HAVE_ELFUTILS', libdw.found())
1367# New in elfutils 0.177
1368conf.set10('HAVE_DWELF_ELF_E_MACHINE_STRING',
1369 libdw.found() and cc.has_function('dwelf_elf_e_machine_string', dependencies : libdw))
d48c2721 1370
43abc59a
JJ
1371libz = dependency('zlib',
1372 required : get_option('zlib'))
1373conf.set10('HAVE_ZLIB', libz.found())
5c23128d 1374
a0c9ac9a
JJ
1375feature = get_option('bzip2')
1376libbzip2 = dependency('bzip2',
1377 required : feature.disabled() ? feature : false)
1378if not libbzip2.found()
1379 # Debian and Ubuntu do not provide the .pc file.
1380 libbzip2 = cc.find_library('bz2', required : feature)
5c23128d 1381endif
a0c9ac9a 1382conf.set10('HAVE_BZIP2', libbzip2.found())
5c23128d 1383
43abc59a
JJ
1384libxz = dependency('liblzma',
1385 required : get_option('xz'))
1386conf.set10('HAVE_XZ', libxz.found())
3fc72d54 1387libxz_cflags = libxz.partial_dependency(includes: true, compile_args: true)
5c23128d 1388
43abc59a
JJ
1389liblz4 = dependency('liblz4',
1390 version : '>= 1.3.0',
1391 required : get_option('lz4'))
1392conf.set10('HAVE_LZ4', liblz4.found())
3fc72d54 1393liblz4_cflags = liblz4.partial_dependency(includes: true, compile_args: true)
5c23128d 1394
43abc59a
JJ
1395libzstd = dependency('libzstd',
1396 version : '>= 1.4.0',
1397 required : get_option('zstd'))
1398conf.set10('HAVE_ZSTD', libzstd.found())
3fc72d54 1399libzstd_cflags = libzstd.partial_dependency(includes: true, compile_args: true)
d80b051c 1400
43abc59a 1401conf.set10('HAVE_COMPRESSION', libxz.found() or liblz4.found() or libzstd.found())
ef5924aa 1402
cd3c6322
LB
1403compression = get_option('default-compression')
1404if compression == 'auto'
43abc59a 1405 if libzstd.found()
cd3c6322 1406 compression = 'zstd'
43abc59a 1407 elif liblz4.found()
cd3c6322 1408 compression = 'lz4'
43abc59a 1409 elif libxz.found()
cd3c6322
LB
1410 compression = 'xz'
1411 else
1412 compression = 'none'
1413 endif
43abc59a 1414elif compression == 'zstd' and not libzstd.found()
cd3c6322 1415 error('default-compression=zstd requires zstd')
43abc59a 1416elif compression == 'lz4' and not liblz4.found()
cd3c6322 1417 error('default-compression=lz4 requires lz4')
43abc59a 1418elif compression == 'xz' and not libxz.found()
cd3c6322
LB
1419 error('default-compression=xz requires xz')
1420endif
1788c6f3 1421conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper()))
cd3c6322 1422
b68f4cad
LP
1423libarchive = dependency('libarchive',
1424 version : '>= 3.0',
1425 required : get_option('libarchive'))
1426conf.set10('HAVE_LIBARCHIVE', libarchive.found())
1427
43abc59a
JJ
1428libxkbcommon = dependency('xkbcommon',
1429 version : '>= 0.3.0',
1430 required : get_option('xkbcommon'))
1431conf.set10('HAVE_XKBCOMMON', libxkbcommon.found())
a44fb601 1432
43abc59a
JJ
1433libpcre2 = dependency('libpcre2-8',
1434 required : get_option('pcre2'))
1435conf.set10('HAVE_PCRE2', libpcre2.found())
69e96427 1436
43abc59a
JJ
1437libglib = dependency('glib-2.0',
1438 version : '>= 2.22.0',
1439 required : get_option('glib'))
1440libgobject = dependency('gobject-2.0',
1441 version : '>= 2.22.0',
1442 required : get_option('glib'))
1443libgio = dependency('gio-2.0',
1444 required : get_option('glib'))
1445conf.set10('HAVE_GLIB', libglib.found() and libgobject.found() and libgio.found())
69e96427 1446
101b5943
JJ
1447libdbus = dependency('dbus-1',
1448 version : '>= 1.3.2',
1449 required : get_option('dbus'))
1450conf.set10('HAVE_DBUS', libdbus.found())
69e96427 1451
101b5943 1452dbusdatadir = libdbus.get_variable(pkgconfig: 'datadir', default_value: datadir) / 'dbus-1'
1bd0cc45
YW
1453
1454dbuspolicydir = get_option('dbuspolicydir')
1455if dbuspolicydir == ''
1456 dbuspolicydir = dbusdatadir / 'system.d'
1457endif
1458
1459dbussessionservicedir = get_option('dbussessionservicedir')
1460if dbussessionservicedir == ''
101b5943 1461 dbussessionservicedir = libdbus.get_variable(pkgconfig: 'session_bus_services_dir', default_value: dbusdatadir / 'services')
1bd0cc45
YW
1462endif
1463
1464dbussystemservicedir = get_option('dbussystemservicedir')
1465if dbussystemservicedir == ''
101b5943 1466 dbussystemservicedir = libdbus.get_variable(pkgconfig: 'system_bus_services_dir', default_value: dbusdatadir / 'system-services')
1bd0cc45
YW
1467endif
1468
1469dbus_interfaces_dir = get_option('dbus-interfaces-dir')
1470if dbus_interfaces_dir == '' or dbus_interfaces_dir == 'yes'
1471 if meson.is_cross_build() and dbus_interfaces_dir != 'yes'
1472 dbus_interfaces_dir = 'no'
1473 warning('Exporting D-Bus interface XML files is disabled during cross build. Pass path or "yes" to force enable.')
1474 else
101b5943 1475 dbus_interfaces_dir = libdbus.get_variable(pkgconfig: 'interfaces_dir', default_value: dbusdatadir / 'interfaces')
1bd0cc45
YW
1476 endif
1477endif
1bd0cc45 1478
12b4cffd
YW
1479dmi_arches = ['x86', 'x86_64', 'aarch64', 'arm', 'ia64', 'loongarch64', 'mips']
1480conf.set10('HAVE_DMI', host_machine.cpu_family() in dmi_arches)
1481
e37ad765
ZJS
1482# We support one or the other. If gcrypt is available, we assume it's there to
1483# be used, and use it in preference.
1484opt = get_option('cryptolib')
1485if opt == 'openssl' and conf.get('HAVE_OPENSSL') == 0
1486 error('openssl requested as the default cryptolib, but not available')
1487endif
1488conf.set10('PREFER_OPENSSL',
1489 opt == 'openssl' or (opt == 'auto' and conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_GCRYPT') == 0))
1490conf.set10('HAVE_OPENSSL_OR_GCRYPT',
1491 conf.get('HAVE_OPENSSL') == 1 or conf.get('HAVE_GCRYPT') == 1)
9bcf483b 1492lib_openssl_or_gcrypt = conf.get('PREFER_OPENSSL') == 1 ? [libopenssl] : [libgcrypt, libgpg_error]
42303dcb 1493
56ddbf10
YW
1494dns_over_tls = get_option('dns-over-tls')
1495if dns_over_tls != 'false'
e37ad765
ZJS
1496 if dns_over_tls == 'gnutls' and conf.get('PREFER_OPENSSL') == 1
1497 error('Sorry, -Ddns-over-tls=gnutls is not supported when openssl is used as the cryptolib')
1498 endif
1499
1f9aa3d2
LB
1500 if dns_over_tls == 'gnutls'
1501 have_openssl = false
096cbdce 1502 else
1f9aa3d2
LB
1503 have_openssl = conf.get('HAVE_OPENSSL') == 1
1504 if dns_over_tls == 'openssl' and not have_openssl
1505 error('DNS-over-TLS support was requested with openssl, but dependencies are not available')
096cbdce 1506 endif
56ddbf10 1507 endif
1f9aa3d2
LB
1508 if dns_over_tls == 'openssl' or have_openssl
1509 have_gnutls = false
096cbdce 1510 else
1f9aa3d2
LB
1511 have_gnutls = conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0')
1512 if dns_over_tls != 'auto' and not have_gnutls
1513 str = dns_over_tls == 'gnutls' ? ' with gnutls' : ''
b349bc59 1514 error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
096cbdce
IT
1515 endif
1516 endif
1517 have = have_gnutls or have_openssl
56ddbf10 1518else
be5536a6
MO
1519 have = false
1520 have_gnutls = false
1521 have_openssl = false
56ddbf10
YW
1522endif
1523conf.set10('ENABLE_DNS_OVER_TLS', have)
096cbdce
IT
1524conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1525conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
56ddbf10 1526
c9299be2 1527default_dns_over_tls = get_option('default-dns-over-tls')
56ddbf10 1528if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
4310bfc2 1529 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 1530 default_dns_over_tls = 'no'
5d67a7ae 1531endif
c9299be2
IT
1532conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1533 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
411d1f4c 1534conf.set_quoted('DEFAULT_DNS_OVER_TLS_MODE_STR', default_dns_over_tls)
5d67a7ae 1535
3614df05
ZJS
1536default_mdns = get_option('default-mdns')
1537conf.set('DEFAULT_MDNS_MODE',
1538 'RESOLVE_SUPPORT_' + default_mdns.to_upper())
411d1f4c 1539conf.set_quoted('DEFAULT_MDNS_MODE_STR', default_mdns)
3614df05
ZJS
1540
1541default_llmnr = get_option('default-llmnr')
1542conf.set('DEFAULT_LLMNR_MODE',
1543 'RESOLVE_SUPPORT_' + default_llmnr.to_upper())
411d1f4c 1544conf.set_quoted('DEFAULT_LLMNR_MODE_STR', default_llmnr)
3614df05 1545
40e9c4e4
JJ
1546have = get_option('repart').require(
1547 conf.get('HAVE_LIBFDISK') == 1,
1548 error_message : 'fdisk required').allowed()
e594a3b1
LP
1549conf.set10('ENABLE_REPART', have)
1550
7e8facb3 1551default_dnssec = get_option('default-dnssec')
7e8facb3
ZJS
1552if default_dnssec != 'no' and conf.get('HAVE_OPENSSL_OR_GCRYPT') == 0
1553 message('default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.')
1554 default_dnssec = 'no'
1555endif
1556conf.set('DEFAULT_DNSSEC_MODE',
1557 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1558conf.set_quoted('DEFAULT_DNSSEC_MODE_STR', default_dnssec)
1559
40e9c4e4
JJ
1560have = get_option('sysupdate').require(
1561 conf.get('HAVE_OPENSSL') == 1 and
1562 conf.get('HAVE_LIBFDISK') == 1,
1563 error_message : 'fdisk and openssl required').allowed()
43cc7a3e
LP
1564conf.set10('ENABLE_SYSUPDATE', have)
1565
1761066b
LP
1566conf.set10('ENABLE_STORAGETM', get_option('storagetm'))
1567
40e9c4e4
JJ
1568have = get_option('importd').require(
1569 conf.get('HAVE_LIBCURL') == 1 and
1570 conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and
1571 conf.get('HAVE_ZLIB') == 1 and
1572 conf.get('HAVE_XZ') == 1,
1573 error_message : 'curl, openssl/grypt, zlib and xz required').allowed()
349cc4a5 1574conf.set10('ENABLE_IMPORTD', have)
5c23128d 1575
40e9c4e4
JJ
1576have = get_option('homed').require(
1577 conf.get('HAVE_OPENSSL') == 1 and
1578 conf.get('HAVE_LIBFDISK') == 1 and
d0eff7a1
AV
1579 conf.get('HAVE_LIBCRYPTSETUP') == 1 and
1580 conf.get('HAVE_CRYPT_RESUME_BY_VOLUME_KEY') == 1,
40e9c4e4 1581 error_message : 'openssl, fdisk and libcryptsetup required').allowed()
70a5db58
LP
1582conf.set10('ENABLE_HOMED', have)
1583
af06ddf5
YW
1584have = have and conf.get('HAVE_PAM') == 1
1585conf.set10('ENABLE_PAM_HOME', have)
1586
1e73a64a
JJ
1587feature = get_option('remote')
1588have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1589 conf.get('HAVE_LIBCURL') == 1]
1590# sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1591# it's possible to build one without the other. Complain only if
1592# support was explicitly requested. The auxiliary files like sysusers
1593# config should be installed when any of the programs are built.
1594if feature.enabled() and not (have_deps[0] and have_deps[1])
1595 error('remote support was requested, but dependencies are not available')
1596endif
1597have = feature.allowed() and (have_deps[0] or have_deps[1])
349cc4a5 1598conf.set10('ENABLE_REMOTE', have)
5c23128d 1599
2b84d628
ZJS
1600feature = get_option('vmspawn').disable_auto_if(conf.get('BUILD_MODE_DEVELOPER') == 0)
1601conf.set10('ENABLE_VMSPAWN', feature.allowed())
1602
702a52f4
LP
1603conf.set10('DEFAULT_MOUNTFSD_TRUSTED_DIRECTORIES', get_option('default-mountfsd-trusted-directories'))
1604
b3259a6e
ZJS
1605foreach term : ['analyze',
1606 'backlight',
a9149d87 1607 'binfmt',
dfca5587 1608 'compat-mutable-uid-boundaries',
a9149d87 1609 'coredump',
b3259a6e
ZJS
1610 'efi',
1611 'environment-d',
1612 'firstboot',
1613 'gshadow',
1614 'hibernate',
a9149d87 1615 'hostnamed',
b3259a6e
ZJS
1616 'hwdb',
1617 'idn',
1618 'ima',
1619 'initrd',
1782534b 1620 'kernel-install',
b3259a6e 1621 'ldconfig',
a9149d87 1622 'localed',
b3259a6e 1623 'logind',
a9149d87 1624 'machined',
702a52f4 1625 'mountfsd',
a9149d87 1626 'networkd',
dfca5587 1627 'nscd',
8aee931e 1628 'nsresourced',
b3259a6e
ZJS
1629 'nss-myhostname',
1630 'nss-systemd',
1782534b 1631 'oomd',
b3259a6e
ZJS
1632 'portabled',
1633 'pstore',
a9149d87 1634 'quotacheck',
b3259a6e
ZJS
1635 'randomseed',
1636 'resolve',
1637 'rfkill',
1638 'smack',
dfca5587 1639 'sysext',
a9149d87 1640 'sysusers',
b3259a6e
ZJS
1641 'timedated',
1642 'timesyncd',
a9149d87 1643 'tmpfiles',
a9149d87 1644 'tpm',
b3259a6e
ZJS
1645 'userdb',
1646 'utmp',
1647 'vconsole',
1648 'xdg-autostart']
a9149d87
ZJS
1649 have = get_option(term)
1650 name = 'ENABLE_' + term.underscorify().to_upper()
1651 conf.set10(name, have)
5c23128d
ZJS
1652endforeach
1653
bd7e6aa7
ZJS
1654enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
1655
08540a95
YW
1656foreach tuple : [['nss-mymachines', 'machined'],
1657 ['nss-resolve', 'resolve']]
1658 want = get_option(tuple[0])
1e73a64a 1659 if want.allowed()
08540a95 1660 have = get_option(tuple[1])
1e73a64a 1661 if want.enabled() and not have
08540a95
YW
1662 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1663 endif
1664 else
1665 have = false
1666 endif
1667 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1668 conf.set10(name, have)
1669endforeach
1670
1671enable_nss = false
1672foreach term : ['ENABLE_NSS_MYHOSTNAME',
1673 'ENABLE_NSS_MYMACHINES',
1674 'ENABLE_NSS_RESOLVE',
1675 'ENABLE_NSS_SYSTEMD']
1676 if conf.get(term) == 1
1677 enable_nss = true
1678 endif
1679endforeach
1680conf.set10('ENABLE_NSS', enable_nss)
1681
348b4437 1682conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
6129ec85 1683
62670a77
FS
1684conf.set10('ENABLE_SSH_PROXY_CONFIG', sshconfdir != 'no')
1685conf.set10('ENABLE_SSH_USERDB_CONFIG', conf.get('ENABLE_USERDB') == 1 and sshdconfdir != 'no')
1686
b68dfb9e 1687conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
00d82c81 1688
e6267e83 1689#####################################################################
db7f5ab6 1690
9c45bfb2
FS
1691pymod = import('python')
1692python = pymod.find_installation('python3', required : true, modules : ['jinja2'])
1693python_39 = python.language_version().version_compare('>=3.9')
1694
e6267e83 1695#####################################################################
4d3ef2d1
LP
1696
1697if conf.get('BPF_FRAMEWORK') == 1
1698 bpf_clang_flags = [
1699 '-std=gnu11',
1700 '-Wno-compare-distinct-pointer-types',
1701 '-fno-stack-protector',
1702 '-O2',
1703 '-target',
1704 'bpf',
1705 '-g',
1706 '-c',
1707 ]
1708
1709 bpf_gcc_flags = [
1710 '-std=gnu11',
1711 '-fno-stack-protector',
1ce28e5a 1712 '-fno-ssa-phiopt',
4d3ef2d1 1713 '-O2',
4d3ef2d1
LP
1714 '-mcpu=v3',
1715 '-mco-re',
1716 '-gbtf',
1717 '-c',
1718 ]
1719
1720 # Generate defines that are appropriate to tell the compiler what architecture
1721 # we're compiling for. By default we just map meson's cpu_family to __<cpu_family>__.
1722 # This dictionary contains the exceptions where this doesn't work.
1723 #
1724 # C.f. https://mesonbuild.com/Reference-tables.html#cpu-families
1725 # and src/basic/missing_syscall_def.h.
1726 cpu_arch_defines = {
1727 'ppc' : ['-D__powerpc__'],
1728 'ppc64' : ['-D__powerpc64__', '-D_CALL_ELF=2'],
1729 'riscv32' : ['-D__riscv', '-D__riscv_xlen=32'],
1730 'riscv64' : ['-D__riscv', '-D__riscv_xlen=64'],
1731 'x86' : ['-D__i386__'],
1732
1733 # For arm, assume hardware fp is available.
1734 'arm' : ['-D__arm__', '-D__ARM_PCS_VFP'],
1735 }
1736
1737 bpf_arch_flags = cpu_arch_defines.get(host_machine.cpu_family(),
1738 ['-D__@0@__'.format(host_machine.cpu_family())])
1739 if bpf_compiler == 'gcc'
1740 bpf_arch_flags += ['-m' + host_machine.endian() + '-endian']
1741 endif
1742
1743 libbpf_include_dir = libbpf.get_variable(pkgconfig : 'includedir')
1744
1745 bpf_o_unstripped_cmd = []
1746 if bpf_compiler == 'clang'
1747 bpf_o_unstripped_cmd += [
1748 clang,
1749 bpf_clang_flags,
1750 bpf_arch_flags,
1751 ]
1752 elif bpf_compiler == 'gcc'
1753 bpf_o_unstripped_cmd += [
1754 bpf_gcc,
1755 bpf_gcc_flags,
1756 bpf_arch_flags,
1757 ]
1758 endif
1759
1760 bpf_o_unstripped_cmd += ['-I.']
1761
1df02192 1762 if not meson.is_cross_build()
4d3ef2d1
LP
1763 target_triplet_cmd = run_command('gcc', '-dumpmachine', check: false)
1764 if target_triplet_cmd.returncode() == 0
1765 target_triplet = target_triplet_cmd.stdout().strip()
1766 bpf_o_unstripped_cmd += [
1767 '-isystem',
1768 '/usr/include/@0@'.format(target_triplet)
1769 ]
1770 endif
1771 endif
1772
1773 bpf_o_unstripped_cmd += [
1774 '-idirafter',
1775 libbpf_include_dir,
1776 '@INPUT@',
1777 '-o',
1778 '@OUTPUT@'
1779 ]
1780
1781 if bpftool_strip
1782 bpf_o_cmd = [
1783 bpftool,
1784 'gen',
1785 'object',
1786 '@OUTPUT@',
1787 '@INPUT@'
1788 ]
1789 elif bpf_compiler == 'clang'
1790 bpf_o_cmd = [
1791 llvm_strip,
1792 '-g',
1793 '@INPUT@',
1794 '-o',
1795 '@OUTPUT@'
1796 ]
1797 endif
1798
1799 skel_h_cmd = [
1800 bpftool,
1801 'gen',
1802 'skeleton',
1803 '@INPUT@'
1804 ]
1805endif
1806
dfca5587
JJ
1807#####################################################################
1808
1809efi_arch = {
31ffb6b1
JJ
1810 'aarch64' : 'aa64',
1811 'arm' : 'arm',
1812 'loongarch32' : 'loongarch32',
1813 'loongarch64' : 'loongarch64',
1814 'riscv32' : 'riscv32',
1815 'riscv64' : 'riscv64',
1816 'x86_64' : 'x64',
1817 'x86' : 'ia32',
dfca5587
JJ
1818}.get(host_machine.cpu_family(), '')
1819
40e9c4e4
JJ
1820pyelftools = pymod.find_installation('python3',
1821 required : get_option('bootloader'),
1822 modules : ['elftools'])
1823
1824have = get_option('bootloader').require(
1825 pyelftools.found() and get_option('efi') and efi_arch != '',
1826 error_message : 'unsupported EFI arch or EFI support is disabled').allowed()
1827conf.set10('ENABLE_BOOTLOADER', have)
1828conf.set_quoted('EFI_MACHINE_TYPE_NAME', have ? efi_arch : '')
2afeaf16
JJ
1829
1830efi_arch_alt = ''
7ea44f17 1831efi_cpu_family_alt = ''
40e9c4e4 1832if have and efi_arch == 'x64' and cc.links('''
2afeaf16
JJ
1833 #include <limits.h>
1834 int main(int argc, char *argv[]) {
1835 return __builtin_popcount(argc - CHAR_MAX);
1836 }''', args : ['-m32', '-march=i686'], name : '32bit build possible')
1837 efi_arch_alt = 'ia32'
7ea44f17 1838 efi_cpu_family_alt = 'x86'
2afeaf16
JJ
1839endif
1840
85915f31
LB
1841pefile = pymod.find_installation('python3', required: false, modules : ['pefile'])
1842
1843want_ukify = get_option('ukify').require(python_39 and (want_tests != 'true' or pefile.found()), error_message : 'Python >= 3.9 and pefile required').allowed()
9c45bfb2
FS
1844conf.set10('ENABLE_UKIFY', want_ukify)
1845
e6267e83 1846#####################################################################
b0bd2ae8 1847
7ff3b883 1848check_efi_alignment_py = find_program('tools/check-efi-alignment.py')
59342868
LP
1849
1850#####################################################################
1851
1852use_provided_vmlinux_h = false
1853use_generated_vmlinux_h = false
1854provided_vmlinux_h_path = get_option('vmlinux-h-path')
1855
1856# For the more complex BPF programs we really want a vmlinux.h (which is arch
1857# specific, but only somewhat bound to kernel version). Ideally the kernel
1858# development headers would ship that, but right now they don't. Hence address
1859# this in two ways:
1860#
1861# 1. Provide a vmlinux.h at build time
1862# 2. Generate the file on the fly where possible (which requires /sys/ to be mounted)
1863#
1864# We generally prefer the former (to support reproducible builds), but will
1865# fallback to the latter.
1866
1867if conf.get('BPF_FRAMEWORK') == 1
1868 enable_vmlinux_h = get_option('vmlinux-h')
1869
1870 if enable_vmlinux_h == 'auto'
1871 if provided_vmlinux_h_path != ''
1872 use_provided_vmlinux_h = true
1873 elif fs.exists('/sys/kernel/btf/vmlinux') and \
1874 bpftool.found() and \
1875 (host_machine.cpu_family() == build_machine.cpu_family()) and \
1876 host_machine.cpu_family() in ['x86_64', 'aarch64']
1877
1878 # We will only generate a vmlinux.h from the running
1879 # kernel if the host and build machine are of the same
1880 # family. Also for now we focus on x86_64 and aarch64,
1881 # since other archs don't seem to be ready yet.
1882
1883 use_generated_vmlinux_h = true
1884 endif
1885 elif enable_vmlinux_h == 'provided'
1886 use_provided_vmlinux_h = true
1887 elif enable_vmlinux_h == 'generated'
1888 if not fs.exists('/sys/kernel/btf/vmlinux')
1889 error('BTF data from kernel not available (/sys/kernel/btf/vmlinux missing), cannot generate vmlinux.h, but was asked to.')
1890 endif
1891 if not bpftool.found()
1892 error('bpftool not available, cannot generate vmlinux.h, but was asked to.')
1893 endif
1894 use_generated_vmlinux_h = true
1895 endif
1896endif
1897
1898if use_provided_vmlinux_h
1899 if not fs.exists(provided_vmlinux_h_path)
1900 error('Path to provided vmlinux.h does not exist.')
1901 endif
1902 vmlinux_h_dependency = []
1903 bpf_o_unstripped_cmd += ['-I' + fs.parent(provided_vmlinux_h_path)]
1904 message('Using provided @0@'.format(provided_vmlinux_h_path))
1905elif use_generated_vmlinux_h
1906 vmlinux_h_dependency = custom_target(
1907 'vmlinux.h',
1908 output: 'vmlinux.h',
1909 command : [ bpftool, 'btf', 'dump', 'file', '/sys/kernel/btf/vmlinux', 'format', 'c' ],
1910 capture : true)
1911
1912 bpf_o_unstripped_cmd += ['-I' + fs.parent(vmlinux_h_dependency.full_path())]
1913 message('Using generated @0@'.format(vmlinux_h_dependency.full_path()))
1914else
1915 message('Using neither provided nor generated vmlinux.h, some features will not be available.')
1916endif
1917
1918conf.set10('HAVE_VMLINUX_H', use_provided_vmlinux_h or use_generated_vmlinux_h)
1919
1920#####################################################################
1921
3691e7fc 1922check_version_history_py = find_program('tools/check-version-history.py')
2afeaf16
JJ
1923elf2efi_py = find_program('tools/elf2efi.py')
1924export_dbus_interfaces_py = find_program('tools/dbus_exporter.py')
d3821a33 1925generate_gperfs = find_program('tools/generate-gperfs.py')
f6fe732f
YW
1926make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
1927make_directive_index_py = find_program('tools/make-directive-index.py')
3c1f396f 1928sync_docs_py = find_program('tools/sync-docs.py')
f6fe732f 1929make_man_index_py = find_program('tools/make-man-index.py')
6b1aac3c 1930meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
d3821a33 1931update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
d3821a33 1932update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
2afeaf16
JJ
1933update_hwdb_sh = find_program('tools/update-hwdb.sh')
1934update_man_rules_py = find_program('tools/update-man-rules.py')
d3821a33
ZJS
1935update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
1936xml_helper_py = find_program('tools/xml_helper.py')
f6fe732f 1937
e6267e83 1938#####################################################################
5c23128d 1939
e95acdfe 1940version_tag = get_option('version-tag')
3f6ce3d4
DDM
1941if version_tag == ''
1942 version_tag = meson.project_version()
1943endif
1944
1945conf.set_quoted('VERSION_TAG', version_tag)
1946
1947vcs_tag = get_option('vcs-tag')
d5dd917a
ZJS
1948command = ['sh', '-c',
1949 vcs_tag and fs.exists(project_source_root / '.git') ?
1950 'echo "-g$(git -C . describe --abbrev=7 --match="" --always --dirty=^)"' : ':']
1951version_h = vcs_tag(
1952 input : 'src/version/version.h.in',
1953 output : 'version.h',
1954 fallback : '',
1955 command : command,
1956)
e95acdfe 1957
e95acdfe
YW
1958shared_lib_tag = get_option('shared-lib-tag')
1959if shared_lib_tag == ''
ea2a57be 1960 shared_lib_tag = meson.project_version().split('~')[0]
e95acdfe
YW
1961endif
1962
e6267e83 1963#####################################################################
e95acdfe 1964
7e43be7d 1965if get_option('b_coverage')
92148283 1966 userspace_c_args += ['-include', 'src/basic/coverage.h']
7e43be7d
FS
1967endif
1968
e6267e83 1969#####################################################################
7e43be7d 1970
5c23128d 1971config_h = configure_file(
37efbbd8
ZJS
1972 output : 'config.h',
1973 configuration : conf)
5c23128d 1974
92148283 1975userspace_c_args += ['-include', 'config.h']
f6fe732f 1976
5c25f9db 1977jinja2_cmdline = [meson_render_jinja2, config_h]
8f04a1ca 1978
92148283
JJ
1979userspace = declare_dependency(
1980 compile_args : userspace_c_args,
1981 link_args : userspace_c_ld_args,
56a0b906 1982 sources : version_h,
92148283
JJ
1983)
1984
c18dde32
ZJS
1985man_page_depends = []
1986
e6267e83 1987#####################################################################
348b4437 1988
1d21a7bd 1989simple_tests = []
130c87b1 1990libsystemd_tests = []
1d21a7bd
YW
1991simple_fuzzers = []
1992catalogs = []
c335921e
YW
1993modules = [] # nss, pam, and other plugins
1994executables = []
1995executables_by_name = {}
cbc55c4c 1996fuzzer_exes = []
1d21a7bd 1997
b61016f2
YW
1998# binaries that have --help and are intended for use by humans,
1999# usually, but not always, installed in /bin.
2000public_programs = []
2001
e3c68924 2002# D-Bus introspection XML export
2003dbus_programs = []
e3c68924 2004
3f80c139
ZJS
2005# A list of boot stubs. Required for testing of ukify.
2006boot_stubs = []
2007
3c1eee5b
ZJS
2008build_dir_include = include_directories('.')
2009
8d40961c
YW
2010basic_includes = include_directories(
2011 'src/basic',
e5bc5f1f 2012 'src/fundamental',
8d40961c
YW
2013 'src/systemd',
2014 '.')
2015
2016libsystemd_includes = [basic_includes, include_directories(
2017 'src/libsystemd/sd-bus',
2018 'src/libsystemd/sd-device',
2019 'src/libsystemd/sd-event',
2020 'src/libsystemd/sd-hwdb',
2021 'src/libsystemd/sd-id128',
2022 'src/libsystemd/sd-journal',
2023 'src/libsystemd/sd-netlink',
2024 'src/libsystemd/sd-network',
2025 'src/libsystemd/sd-resolve')]
2026
2027includes = [libsystemd_includes, include_directories('src/shared')]
5c23128d 2028
5c23128d
ZJS
2029subdir('po')
2030subdir('catalog')
dfca5587 2031subdir('src/fundamental')
5c23128d
ZJS
2032subdir('src/basic')
2033subdir('src/libsystemd')
3976f372 2034subdir('src/shared')
3976f372 2035subdir('src/libudev')
5c23128d 2036
5c23128d 2037libsystemd = shared_library(
37efbbd8 2038 'systemd',
56d50ab1 2039 version : libsystemd_version,
8d40961c 2040 include_directories : libsystemd_includes,
37efbbd8
ZJS
2041 link_args : ['-shared',
2042 '-Wl,--version-script=' + libsystemd_sym_path],
8707c9b2 2043 link_with : [libbasic],
99b9f8fd 2044 link_whole : [libsystemd_static],
92148283
JJ
2045 dependencies : [librt,
2046 threads,
2047 userspace],
37efbbd8
ZJS
2048 link_depends : libsystemd_sym,
2049 install : true,
0a5e638c 2050 install_tag: 'libsystemd',
b0d3095f 2051 install_dir : libdir)
5c23128d 2052
039f1673
LB
2053alias_target('libsystemd', libsystemd)
2054
70848ecf
DC
2055install_libsystemd_static = static_library(
2056 'systemd',
2057 libsystemd_sources,
975464e0 2058 basic_sources,
e5bc5f1f 2059 fundamental_sources,
8d40961c 2060 include_directories : libsystemd_includes,
70848ecf
DC
2061 build_by_default : static_libsystemd != 'false',
2062 install : static_libsystemd != 'false',
0a5e638c 2063 install_tag: 'libsystemd',
b0d3095f 2064 install_dir : libdir,
40dbce36 2065 pic : static_libsystemd_pic,
92148283 2066 dependencies : [libblkid,
975464e0 2067 libcap,
92148283 2068 libdl,
8707c9b2 2069 libgcrypt_cflags,
3fc72d54 2070 liblz4_cflags,
92148283 2071 libmount,
c47511da 2072 libopenssl,
92148283 2073 librt,
3fc72d54
MC
2074 libxz_cflags,
2075 libzstd_cflags,
92148283 2076 threads,
40c7d3c7 2077 userspace],
70848ecf
DC
2078 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
2079
3976f372
YW
2080libudev = shared_library(
2081 'udev',
3976f372
YW
2082 version : libudev_version,
2083 include_directories : includes,
2084 link_args : ['-shared',
2085 '-Wl,--version-script=' + libudev_sym_path],
2086 link_with : [libsystemd_static, libshared_static],
2087 link_whole : libudev_basic,
92148283
JJ
2088 dependencies : [threads,
2089 userspace],
3976f372
YW
2090 link_depends : libudev_sym,
2091 install : true,
0a5e638c 2092 install_tag: 'libudev',
b0d3095f 2093 install_dir : libdir)
3976f372 2094
039f1673
LB
2095alias_target('libudev', libudev)
2096
3976f372
YW
2097install_libudev_static = static_library(
2098 'udev',
2099 basic_sources,
e5bc5f1f 2100 fundamental_sources,
3976f372
YW
2101 shared_sources,
2102 libsystemd_sources,
2103 libudev_sources,
3976f372
YW
2104 include_directories : includes,
2105 build_by_default : static_libudev != 'false',
2106 install : static_libudev != 'false',
0a5e638c 2107 install_tag: 'libudev',
b0d3095f 2108 install_dir : libdir,
3976f372 2109 link_depends : libudev_sym,
92148283
JJ
2110 dependencies : [libmount,
2111 libshared_deps,
40c7d3c7 2112 userspace],
3976f372
YW
2113 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
2114 pic : static_libudev_pic)
2115
e6267e83 2116#####################################################################
47354b44 2117
130c87b1
YW
2118runtest_env = custom_target(
2119 'systemd-runtest.env',
2120 output : 'systemd-runtest.env',
2121 command : [sh, '-c',
2122 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
2123 project_source_root / 'test',
2124 project_build_root / 'catalog')],
2125 depends : catalogs,
2126 build_by_default : true)
2127
2128test_cflags = ['-DTEST_CODE=1']
2129# We intentionally do not do inline initializations with definitions for a
2130# bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
2131# use the variable unexpectedly. This triggers a lot of maybe-uninitialized
2132# false positives when the combination of -O2 and -flto is used. Suppress them.
2133if '-O2' in c_args and '-flto=auto' in c_args
2134 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
2135endif
2136
e6267e83 2137#####################################################################
130c87b1 2138
c335921e
YW
2139executable_template = {
2140 'include_directories' : includes,
2141 'link_with' : libshared,
2142 'install_rpath' : pkglibdir,
2143 'install' : true,
2144}
2145
2146generator_template = executable_template + {
2147 'install_dir' : systemgeneratordir,
2148}
2149
2150libexec_template = executable_template + {
2151 'install_dir' : libexecdir,
2152}
2153
2154executable_additional_kwargs = {
2155 'dependencies' : userspace,
2156}
2157
130c87b1
YW
2158test_template = executable_template + {
2159 'build_by_default' : want_tests != 'false',
2160 'install' : install_tests,
2161 'install_dir' : unittestsdir,
2162}
2163
2164test_additional_kwargs = {
2165 'c_args' : test_cflags,
2166 'link_depends' : runtest_env,
2167}
2168
cbc55c4c
YW
2169fuzz_template = executable_template + {
2170 'build_by_default' : fuzzer_build,
2171 'install' : false,
2172}
2173
2174if want_ossfuzz or (want_libfuzzer and fuzzing_engine.found())
2175 fuzz_additional_kwargs = {
2176 'dependencies' : fuzzing_engine,
2177 }
2178elif want_libfuzzer and not fuzzing_engine.found()
2179 fuzz_additional_kwargs = {
2180 'link_args' : ['-fsanitize=fuzzer'],
2181 }
2182else
2183 fuzz_additional_kwargs = {
2184 'sources' : files('src/fuzz/fuzz-main.c'),
2185 }
2186endif
2187fuzz_additional_kwargs += {
2188 'include_directories' : include_directories('src/fuzz'),
2189 'c_args' : test_cflags,
2190}
2191
c335921e
YW
2192nss_template = {
2193 'version' : '2',
2194 'include_directories' : includes,
2195 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
2196 'link_args' : ['-z', 'nodelete'],
2197 'link_with' : [
2198 libsystemd_static,
2199 libshared_static,
2200 libbasic,
2201 ],
2202 'dependencies' : [
2203 librt,
2204 threads,
2205 ],
2206 'install' : true,
2207 'install_tag' : 'nss',
2208 'install_dir' : libdir,
2209}
2210
2211pam_template = {
2212 'name_prefix' : '',
2213 'include_directories' : includes,
2214 'link_with' : [
2215 libsystemd_static,
2216 libshared_static,
2217 ],
2218 'dependencies' : [
2219 libpam_misc,
2220 libpam,
2221 threads,
2222 ],
2223 'install' : true,
2224 'install_tag' : 'pam',
2225 'install_dir' : pamlibdir,
2226}
2227
2228module_additional_kwargs = {
2229 'link_args' : ['-shared'],
2230 'dependencies' : userspace,
2231}
2232
e6267e83 2233#####################################################################
c335921e 2234
b61016f2 2235# systemd-analyze requires 'libcore'
83b6af36 2236subdir('src/core')
b61016f2
YW
2237# systemd-networkd requires 'libsystemd_network'
2238subdir('src/libsystemd-network')
5371c269
YW
2239# hwdb requires 'udev_link_with' and 'udev_rpath'
2240subdir('src/udev')
83b6af36 2241
16b081d6 2242subdir('src/ac-power')
83b6af36 2243subdir('src/analyze')
cb935625 2244subdir('src/ask-password')
7e6ca26f 2245subdir('src/backlight')
98e39a55 2246subdir('src/battery-check')
2c2c3daa 2247subdir('src/binfmt')
cd4300f3 2248subdir('src/boot')
dfca5587 2249subdir('src/boot/efi')
f98df767 2250subdir('src/busctl')
9f907d30 2251subdir('src/cgls')
e2bdf00a 2252subdir('src/cgroups-agent')
9f907d30 2253subdir('src/cgtop')
b61016f2 2254subdir('src/coredump')
98e39a55 2255subdir('src/creds')
2ad279cf 2256subdir('src/cryptenroll')
b4d1892a 2257subdir('src/cryptsetup')
2a456620 2258subdir('src/debug-generator')
98e39a55 2259subdir('src/delta')
16b081d6 2260subdir('src/detect-virt')
ec57a4ea 2261subdir('src/dissect')
2a456620 2262subdir('src/environment-d-generator')
98e39a55 2263subdir('src/escape')
df490fc7
YW
2264subdir('src/firstboot')
2265subdir('src/fsck')
2a456620
YW
2266subdir('src/fstab-generator')
2267subdir('src/getty-generator')
ec57a4ea 2268subdir('src/gpt-auto-generator')
74093422 2269subdir('src/hibernate-resume')
b61016f2 2270subdir('src/home')
83b6af36 2271subdir('src/hostname')
6fab49e4 2272subdir('src/hwdb')
e2bdf00a 2273subdir('src/id128')
83b6af36 2274subdir('src/import')
9f907d30 2275subdir('src/initctl')
81fe141b 2276subdir('src/integritysetup')
f7b349e8 2277subdir('src/journal')
b61016f2 2278subdir('src/journal-remote')
83b6af36
ZJS
2279subdir('src/kernel-install')
2280subdir('src/locale')
b61016f2 2281subdir('src/login')
83b6af36 2282subdir('src/machine')
df490fc7 2283subdir('src/machine-id-setup')
702a52f4 2284subdir('src/mountfsd')
eb51c09d 2285subdir('src/modules-load')
9f907d30 2286subdir('src/mount')
b61016f2 2287subdir('src/network')
98e39a55 2288subdir('src/notify')
83b6af36 2289subdir('src/nspawn')
8aee931e 2290subdir('src/nsresourced')
2080c097
YW
2291subdir('src/nss-myhostname')
2292subdir('src/nss-mymachines')
2293subdir('src/nss-resolve')
2294subdir('src/nss-systemd')
b61016f2
YW
2295subdir('src/oom')
2296subdir('src/partition')
e2bdf00a 2297subdir('src/path')
32295fa0 2298subdir('src/pcrextend')
a4342701 2299subdir('src/pcrlock')
b61016f2
YW
2300subdir('src/portable')
2301subdir('src/pstore')
5371c269 2302subdir('src/quotacheck')
c8c78771 2303subdir('src/random-seed')
6c713961 2304subdir('src/rc-local-generator')
df490fc7 2305subdir('src/remount-fs')
cb935625 2306subdir('src/reply-password')
83b6af36 2307subdir('src/resolve')
7e6ca26f 2308subdir('src/rfkill')
2a9b4bbe 2309subdir('src/rpm')
5c707c8c 2310subdir('src/run')
2a456620 2311subdir('src/run-generator')
b61016f2 2312subdir('src/shutdown')
16b081d6 2313subdir('src/sleep')
22f37744 2314subdir('src/socket-activate')
5371c269 2315subdir('src/socket-proxy')
0e322068 2316subdir('src/ssh-generator')
5c707c8c 2317subdir('src/stdio-bridge')
87e7979d 2318subdir('src/sulogin-shell')
16b081d6 2319subdir('src/sysctl')
9bca4ae4 2320subdir('src/sysext')
7e6ca26f 2321subdir('src/system-update-generator')
c3512573 2322subdir('src/systemctl')
43cc7a3e 2323subdir('src/sysupdate')
6fab49e4 2324subdir('src/sysusers')
6c713961 2325subdir('src/sysv-generator')
1761066b 2326subdir('src/storagetm')
83b6af36
ZJS
2327subdir('src/timedate')
2328subdir('src/timesync')
db64ba81 2329subdir('src/tmpfiles')
1761066b 2330subdir('src/tpm2-setup')
cb935625 2331subdir('src/tty-ask-password-agent')
eb51c09d
YW
2332subdir('src/update-done')
2333subdir('src/update-utmp')
dbab4fb9 2334subdir('src/user-sessions')
b61016f2 2335subdir('src/userdb')
d408a53f 2336subdir('src/varlinkctl')
c8c78771 2337subdir('src/vconsole')
81fe141b 2338subdir('src/veritysetup')
9de3cc14 2339subdir('src/vmspawn')
e2bdf00a 2340subdir('src/volatile-root')
9e61ed11 2341subdir('src/vpick')
0275e918 2342subdir('src/xdg-autostart-generator')
83b6af36 2343
3976f372
YW
2344subdir('src/systemd')
2345
83b6af36 2346subdir('src/test')
7db7d5b7 2347subdir('src/fuzz')
a1d6dbb1 2348subdir('src/ukify/test') # needs to be last for test_env variable
cbc55c4c 2349subdir('test/fuzz')
83b6af36 2350
eb981a5b
LP
2351subdir('mime')
2352
d30d9bf0
LB
2353alias_target('devel', libsystemd_pc, libudev_pc, systemd_pc, udev_pc)
2354
e6267e83 2355#####################################################################
83b6af36 2356
130c87b1
YW
2357foreach test : simple_tests
2358 executables += test_template + { 'sources' : [test] }
2359endforeach
2360
2361foreach test : libsystemd_tests
2362 executables += test_template + test
2363endforeach
2364
cbc55c4c
YW
2365foreach fuzzer : simple_fuzzers
2366 executables += fuzz_template + { 'sources' : [fuzzer] }
2367endforeach
2368
c335921e 2369foreach dict : executables
130c87b1
YW
2370 name = dict.get('name', '')
2371 if name == ''
2372 name = fs.stem(dict.get('sources')[0])
cbc55c4c 2373 assert(name.split('-')[0] in ['test', 'fuzz'])
130c87b1
YW
2374 endif
2375
2376 is_test = name.startswith('test-')
cbc55c4c 2377 is_fuzz = name.startswith('fuzz-')
c335921e
YW
2378
2379 build = true
2380 foreach cond : dict.get('conditions', [])
2381 if conf.get(cond) != 1
2382 build = false
2383 break
2384 endif
2385 endforeach
2386 if not build
2387 continue
2388 endif
2389
2390 kwargs = {}
2391 foreach key, val : dict
130c87b1
YW
2392 if key in ['name', 'dbus', 'public', 'conditions',
2393 'type', 'suite', 'timeout', 'parallel']
c335921e
YW
2394 continue
2395 endif
130c87b1 2396
c335921e
YW
2397 kwargs += { key : val }
2398 endforeach
2399
2400 foreach key, val : executable_additional_kwargs
2401 kwargs += { key : [ kwargs.get(key, []), val ]}
2402 endforeach
2403
130c87b1
YW
2404 if is_test
2405 kwargs += { 'install_dir' : kwargs.get('install_dir') / dict.get('type', '') }
2406 foreach key, val : test_additional_kwargs
2407 kwargs += { key : [ kwargs.get(key, []), val ] }
2408 endforeach
2409 endif
2410
cbc55c4c
YW
2411 if is_fuzz
2412 foreach key, val : fuzz_additional_kwargs
2413 kwargs += { key : [ kwargs.get(key, []), val ] }
2414 endforeach
2415 endif
2416
c335921e
YW
2417 exe = executable(
2418 name,
2419 kwargs : kwargs,
2420 )
2421
2422 executables_by_name += { name : exe }
2423
2424 if dict.get('build_by_default', true)
2425 if dict.get('dbus', false)
2426 dbus_programs += exe
2427 endif
2428 if dict.get('public', false)
2429 public_programs += exe
2430 endif
2431 endif
130c87b1
YW
2432
2433 if is_test
2434 type = dict.get('type', '')
2435 suite = dict.get('suite', '')
2436 if suite == ''
2437 suite = fs.name(fs.parent(dict.get('sources')[0]))
2438 if suite.startswith('sd-')
2439 suite = 'libsystemd'
2440 endif
2441 endif
2442
2443 if type == 'manual'
2444 message('@0@/@1@ is a manual test'.format(suite, name))
2445 elif type == 'unsafe' and want_tests != 'unsafe'
2446 message('@0@/@1@ is an unsafe test'.format(suite, name))
2447 elif dict.get('build_by_default')
2448 test(name, exe,
2449 env : test_env,
2450 timeout : dict.get('timeout', 30),
2451 suite : suite,
2452 is_parallel : dict.get('parallel', true))
2453 endif
2454 endif
cbc55c4c
YW
2455
2456 if is_fuzz
2457 fuzzer_exes += exe
2458
2459 if want_tests != 'false'
2460 # Run the fuzz regression tests without any sanitizers enabled.
f933f752 2461 # Additional invocations with sanitizers may get added below.
cbc55c4c
YW
2462 fuzz_ins = fuzz_regression_tests.get(name, {})
2463 foreach directive : fuzz_ins.get('directives', [])
f933f752
ZJS
2464 tt = '@0@_@1@'.format(name, fs.name(directive.full_path()))
2465 if tt.substring(45) != ''
2466 error('Directive sample name is too long:', directive.full_path())
2467 endif
2468
2469 test(tt,
cbc55c4c
YW
2470 exe,
2471 suite : 'fuzz',
2472 args : directive.full_path(),
2473 depends : directive)
2474 endforeach
2475 foreach file : fuzz_ins.get('files', [])
f933f752
ZJS
2476 tt = '@0@_@1@'.format(name, fs.name(file))
2477 if tt.substring(45) != ''
2478 error('Fuzz sample name is too long:', fs.name(file))
2479 endif
2480
2481 test(tt,
cbc55c4c
YW
2482 exe,
2483 suite : 'fuzz',
2484 args : file)
2485 endforeach
2486 endif
2487 endif
c335921e
YW
2488endforeach
2489
cbc55c4c
YW
2490alias_target('fuzzers', fuzzer_exes)
2491
e6267e83 2492#####################################################################
c335921e 2493
130c87b1 2494test_dlopen = executables_by_name.get('test-dlopen')
83b6af36 2495
c335921e
YW
2496foreach dict : modules
2497 name = dict.get('name')
2498 is_nss = name.startswith('nss_')
2499 is_pam = name.startswith('pam_')
2500
2501 build = true
2502 foreach cond : dict.get('conditions', [])
2503 if conf.get(cond) != 1
2504 build = false
2505 break
2506 endif
2507 endforeach
2508 if not build
2509 continue
2510 endif
2511
2512 kwargs = {}
2513 foreach key, val : dict
90461ef5 2514 if key in ['name', 'conditions', 'version-script']
c335921e
YW
2515 continue
2516 endif
2517 kwargs += { key : val }
2518 endforeach
2519
c335921e
YW
2520 kwargs += {
2521 'link_args' : [
2522 kwargs.get('link_args', []),
90461ef5
JJ
2523 '-Wl,--version-script=' + dict.get('version-script'),
2524 ],
2525 'link_depends' : [
2526 kwargs.get('link_depends', []),
2527 dict.get('version-script'),
c335921e
YW
2528 ],
2529 }
2530 foreach key, val : module_additional_kwargs
2531 kwargs += { key : [ kwargs.get(key, []), val ]}
2532 endforeach
2533
2534 lib = shared_library(
2535 name,
2536 kwargs : kwargs,
2537 )
2538
2539 if is_nss
2540 # We cannot use shared_module because it does not support version suffix.
2541 # Unfortunately shared_library insists on creating the symlink…
c31ba5cf 2542 meson.add_install_script(sh, '-c', 'rm $DESTDIR@0@/lib@1@.so'.format(libdir, name),
c335921e
YW
2543 install_tag : 'nss')
2544 endif
2545
2546 if want_tests != 'false' and (is_nss or is_pam)
2547 test('dlopen-' + name,
2548 test_dlopen,
2549 # path to dlopen must include a slash
2550 args : lib.full_path(),
dc4a0055
YW
2551 depends : lib,
2552 suite : is_nss ? 'nss' : 'pam')
c335921e
YW
2553 endif
2554endforeach
2555
e6267e83 2556#####################################################################
5c23128d 2557
f9a6cb0e 2558ukify = custom_target(
30ec2eae
ZJS
2559 'ukify',
2560 input : 'src/ukify/ukify.py',
2561 output : 'ukify',
2562 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
9a01fe39 2563 install : want_ukify,
30ec2eae 2564 install_mode : 'rwxr-xr-x',
f65aa477 2565 install_dir : bindir)
9a01fe39 2566if want_ukify
42551ea7 2567 public_programs += ukify
f65aa477 2568
a1ca52c2 2569 # symlink for backwards compatibility after rename
f65aa477
ZJS
2570 meson.add_install_script(sh, '-c',
2571 ln_s.format(bindir / 'ukify',
2572 libexecdir / 'ukify'))
f9a6cb0e
ZJS
2573endif
2574
e6267e83 2575#####################################################################
69e96427 2576
b85e5496 2577mkosi = find_program('mkosi', required : false)
ff4fe9de
DDM
2578if integration_tests and not mkosi.found()
2579 error('Could not find mkosi which is required to run the integration tests')
2580endif
2581
2582mkosi_depends = public_programs
2583
2584foreach executable : ['systemd-journal-remote', 'systemd-measure']
2585 if executable in executables_by_name
2586 mkosi_depends += [executables_by_name[executable]]
2587 endif
2588endforeach
2589
b85e5496
DDM
2590if mkosi.found()
2591 custom_target('mkosi',
945b722f 2592 build_always_stale : true,
b85e5496 2593 build_by_default: false,
945b722f 2594 console : true,
b85e5496
DDM
2595 output : '.',
2596 command : [
2597 'mkosi',
2598 '--directory', meson.current_source_dir(),
2599 '--output-dir', meson.current_build_dir() / 'mkosi.output',
2600 '--cache-dir', meson.current_build_dir() / 'mkosi.cache',
2601 '--build-dir', meson.current_build_dir() / 'mkosi.builddir',
2602 '--force',
4933a51d 2603 '--debug',
ff4fe9de 2604 'build',
b85e5496 2605 ],
ff4fe9de 2606 depends : mkosi_depends,
945b722f
RM
2607 )
2608endif
2609
2610############################################################
2611
e5cc6d10
YW
2612subdir('rules.d')
2613subdir('test')
2614
e6267e83 2615#####################################################################
5c23128d 2616
10783aef
ZJS
2617subdir('docs/sysvinit')
2618subdir('docs/var-log')
2619subdir('hwdb.d')
2620subdir('man')
378e9d2b 2621subdir('modprobe.d')
10783aef
ZJS
2622subdir('network')
2623subdir('presets')
2624subdir('shell-completion/bash')
2625subdir('shell-completion/zsh')
5c23128d
ZJS
2626subdir('sysctl.d')
2627subdir('sysusers.d')
2628subdir('tmpfiles.d')
4f10b807 2629subdir('units')
5c23128d 2630
5c23128d
ZJS
2631install_subdir('factory/etc',
2632 install_dir : factorydir)
623370e6 2633subdir('factory/templates')
5c23128d 2634
d7aa78c3
JT
2635if install_sysconfdir
2636 install_data('xorg/50-systemd-user.sh',
2637 install_dir : xinitrcdir)
2638endif
f09eb768 2639install_data('LICENSE.GPL2',
5c23128d 2640 'LICENSE.LGPL2.1',
f09eb768
LP
2641 'NEWS',
2642 'README',
8e3fee33
ZJS
2643 'docs/CODING_STYLE.md',
2644 'docs/DISTRO_PORTING.md',
2645 'docs/ENVIRONMENT.md',
2646 'docs/HACKING.md',
2647 'docs/TRANSIENT-SETTINGS.md',
2648 'docs/TRANSLATORS.md',
2649 'docs/UIDS-GIDS.md',
5c23128d 2650 install_dir : docdir)
d68b342b 2651
9c6e32a2
LB
2652install_subdir('LICENSES',
2653 install_dir : docdir)
2654
9289e093 2655install_emptydir(systemdstatedir)
94e75a54 2656
e6267e83 2657#####################################################################
d68b342b 2658
2d4efd1d
LB
2659# Ensure that changes to the docs/ directory do not break the
2660# basic Github pages build. But only run it in developer mode,
2661# as it might be fragile due to changes in the tooling, and it is
2662# not generally useful for users.
2663jekyll = find_program('jekyll', required : false)
2664if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
2665 test('github-pages',
2666 jekyll,
02e0f430 2667 suite : 'dist',
2d4efd1d 2668 args : ['build',
fce9abb2
ZJS
2669 '--source', project_source_root / 'docs',
2670 '--destination', project_build_root / '_site'])
2d4efd1d
LB
2671endif
2672
e6267e83 2673#####################################################################
2d4efd1d 2674
dd1e33c8 2675check_help = find_program('tools/check-help.sh')
ffb7406b 2676check_version = find_program('tools/check-version.sh')
005a29f2
ZJS
2677
2678foreach exec : public_programs
739a62bb 2679 name = fs.name(exec.full_path())
938be089
ZJS
2680 if want_tests != 'false'
2681 test('check-help-' + name,
dd1e33c8 2682 check_help,
02e0f430 2683 suite : 'dist',
e93ada98
DDM
2684 args : exec.full_path(),
2685 depends: exec)
ffb7406b 2686
ea2a57be
DDM
2687 version = meson.project_version()
2688 if name == 'udevadm'
2689 # For compatibility reasons we can't use the full version in udevadm.
2690 version = version.split('~')[0]
2691 endif
2692
ffb7406b
ZJS
2693 test('check-version-' + name,
2694 check_version,
02e0f430 2695 suite : 'dist',
ffb7406b 2696 args : [exec.full_path(),
ea2a57be 2697 version],
ffb7406b 2698 depends: exec)
938be089 2699 endif
005a29f2
ZJS
2700endforeach
2701
52d4d1d3 2702# Enable tests for all supported sanitizers
7db5761d 2703foreach tuple : fuzz_sanitizers
52d4d1d3
ZJS
2704 sanitizer = tuple[0]
2705 build = tuple[1]
b68dfb9e 2706
7a6397d2 2707 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
7db5761d
MK
2708 foreach fuzzer, fuzz_ins : fuzz_regression_tests
2709 name = '@0@:@1@'.format(fuzzer, sanitizer)
2710 if want_tests == 'false'
2711 message('Not compiling @0@ because tests is set to false'.format(name))
2712 continue
52d4d1d3 2713 endif
7db5761d
MK
2714 if not fuzz_tests
2715 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
2716 continue
2717 endif
2718 exe = custom_target(
2719 name,
2720 output : name,
cbc55c4c 2721 depends : build,
7db5761d
MK
2722 command : [ln, '-fs',
2723 build.full_path() / fuzzer,
2724 '@OUTPUT@'],
2725 build_by_default : true)
2726
cbc55c4c
YW
2727 foreach directive : fuzz_ins.get('directives', [])
2728 test('@0@_@1@_@2@'.format(fuzzer, fs.name(directive.full_path()), sanitizer),
2729 env,
2730 suite : 'fuzz+san',
2731 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
2732 timeout : 60,
2733 args : [exe.full_path(), directive.full_path()],
2734 depends : directive)
2735 endforeach
2736 foreach file : fuzz_ins.get('files', [])
2737 test('@0@_@1@_@2@'.format(fuzzer, fs.name(file), sanitizer),
52d4d1d3 2738 env,
14056a52 2739 suite : 'fuzz+san',
89767158
EV
2740 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
2741 timeout : 60,
cbc55c4c 2742 args : [exe.full_path(), file])
7db5761d 2743 endforeach
52d4d1d3 2744 endforeach
b68dfb9e
ZJS
2745 endif
2746endforeach
2747
e6267e83 2748#####################################################################
b68dfb9e 2749
0700e8ba 2750if git.found()
37efbbd8 2751 all_files = run_command(
0f4c4f38
ZJS
2752 env, '-u', 'GIT_WORK_TREE',
2753 git, '--git-dir=@0@/.git'.format(project_source_root),
ba9ca60a 2754 'ls-files', ':/*.[ch]', ':/*.cc',
e92777d2
ZJS
2755 check : false)
2756 if all_files.returncode() == 0
2757 all_files = files(all_files.stdout().split())
2758
2759 custom_target(
2760 'tags',
2761 output : 'tags',
2762 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
2763 run_target(
2764 'ctags',
691db9a7 2765 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
60892358
ZJS
2766
2767 ############################################
2768
2769 if want_tests != 'false' and conf.get('BUILD_MODE_DEVELOPER') == 1
2770 test('check-includes',
2771 files('tools/check-includes.py'),
2772 args: all_files,
dc4a0055
YW
2773 env : ['PROJECT_SOURCE_ROOT=@0@'.format(project_source_root)],
2774 suite : 'headers')
60892358 2775 endif
e92777d2 2776 endif
177929c2 2777
60892358
ZJS
2778 ####################################################
2779
dd1e33c8 2780 git_contrib_sh = find_program('tools/git-contrib.sh')
a923e085 2781 run_target(
37efbbd8 2782 'git-contrib',
dd1e33c8 2783 command : [git_contrib_sh])
dd6ab3df 2784
60892358
ZJS
2785 ####################################################
2786
dd6ab3df 2787 git_head = run_command(
e92777d2
ZJS
2788 git, '--git-dir=@0@/.git'.format(project_source_root),
2789 'rev-parse', 'HEAD',
2790 check : false).stdout().strip()
dd6ab3df 2791 git_head_short = run_command(
e92777d2
ZJS
2792 git, '--git-dir=@0@/.git'.format(project_source_root),
2793 'rev-parse', '--short=7', 'HEAD',
2794 check : false).stdout().strip()
dd6ab3df
ZJS
2795
2796 run_target(
2797 'git-snapshot',
0f4c4f38 2798 command : [git, 'archive',
1485aacb 2799 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
dd6ab3df
ZJS
2800 git_head_short),
2801 '--prefix', 'systemd-@0@/'.format(git_head),
2802 'HEAD'])
2803endif
829257d1 2804
e6267e83 2805#####################################################################
829257d1 2806
dd1e33c8 2807check_api_docs_sh = find_program('tools/check-api-docs.sh')
51b13863
LP
2808run_target(
2809 'check-api-docs',
2810 depends : [man, libsystemd, libudev],
dd1e33c8 2811 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
51b13863 2812
f12c5d36
ZJS
2813alias_target('update-dbus-docs', update_dbus_docs)
2814alias_target('update-man-rules', update_man_rules)
e3c368f6 2815
0628d48e
LB
2816if not meson.is_cross_build()
2817 custom_target(
2818 'export-dbus-interfaces',
4645074e 2819 output : fs.name(dbus_interfaces_dir),
0628d48e 2820 install : dbus_interfaces_dir != 'no',
4645074e 2821 install_dir : fs.parent(dbus_interfaces_dir),
0628d48e
LB
2822 command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
2823endif
e3c68924 2824
5083e427
FS
2825meson_extract_unit_files = find_program('tools/meson-extract-unit-files.py')
2826custom_target('installed-unit-files.txt',
2827 output : 'installed-unit-files.txt',
2828 capture : true,
2829 install : want_tests != 'no' and install_tests,
2830 install_dir : testdata_dir,
2831 command : [meson_extract_unit_files, project_build_root])
2832
e6267e83 2833#####################################################################
829257d1 2834
e92777d2
ZJS
2835alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
2836 check : true).stdout().strip()
12085ebb
ZJS
2837
2838summary({
12085ebb
ZJS
2839 'split bin-sbin' : split_bin,
2840 'prefix directory' : prefixdir,
12085ebb
ZJS
2841 'sysconf directory' : sysconfdir,
2842 'include directory' : includedir,
2843 'lib directory' : libdir,
12085ebb
ZJS
2844 'SysV init scripts' : sysvinit_path,
2845 'SysV rc?.d directories' : sysvrcnd_path,
2846 'PAM modules directory' : pamlibdir,
2847 'PAM configuration directory' : pamconfdir,
0abd510f 2848 'ssh server configuration directory' : sshdconfdir,
5360b10f 2849 'ssh server privilege separation directory' : sshdprivsepdir,
0abd510f 2850 'ssh client configuration directory' : sshconfdir,
12085ebb
ZJS
2851 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
2852 'RPM macros directory' : rpmmacrosdir,
2853 'modprobe.d directory' : modprobedir,
2854 'D-Bus policy directory' : dbuspolicydir,
2855 'D-Bus session directory' : dbussessionservicedir,
2856 'D-Bus system directory' : dbussystemservicedir,
7e560e79 2857 'D-Bus interfaces directory' : dbus_interfaces_dir,
12085ebb
ZJS
2858 'bash completions directory' : bashcompletiondir,
2859 'zsh completions directory' : zshcompletiondir,
a2b0cd3f 2860 'private shared lib version tag' : shared_lib_tag,
12085ebb
ZJS
2861 'extra start script' : get_option('rc-local'),
2862 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
2863 get_option('debug-tty')),
2864 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
2865 conf.get('SYSTEM_ALLOC_UID_MIN')),
2866 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
2867 conf.get('SYSTEM_ALLOC_GID_MIN')),
2868 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
2869 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
2870 'static UID/GID allocations' : ' '.join(static_ugids),
2871 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
2872 'render group access mode' : get_option('group-render-mode'),
2873 'certificate root directory' : get_option('certificate-root'),
2874 'support URL' : support_url,
2875 'nobody user name' : nobody_user,
2876 'nobody group name' : nobody_group,
2877 'fallback hostname' : get_option('fallback-hostname'),
9798deaf 2878 'default compression method' : compression,
12085ebb
ZJS
2879 'default DNSSEC mode' : default_dnssec,
2880 'default DNS-over-TLS mode' : default_dns_over_tls,
2881 'default mDNS mode' : default_mdns,
2882 'default LLMNR mode' : default_llmnr,
2883 'default DNS servers' : dns_servers.split(' '),
2884 'default NTP servers' : ntp_servers.split(' '),
78266a54
LP
2885 'default net.naming_scheme= value': default_net_naming_scheme,
2886 'default KillUserProcesses= value': kill_user_processes,
12085ebb 2887 'default locale' : default_locale,
88b6f0de 2888 'default nspawn locale' : nspawn_locale,
79dec86a 2889 'default status unit format' : status_unit_format_default,
12085ebb
ZJS
2890 'default user $PATH' :
2891 default_user_path != '' ? default_user_path : '(same as system services)',
2892 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
2893 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
829257d1
ZJS
2894
2895# TODO:
2896# CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
2897# CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
2898# LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
2899
829257d1
ZJS
2900found = []
2901missing = []
2902
2903foreach tuple : [
56d68e71
ZJS
2904 # dependencies
2905 ['ACL'],
829257d1 2906 ['AUDIT'],
829257d1 2907 ['AppArmor'],
56d68e71
ZJS
2908 ['IMA'],
2909 ['PAM'],
829257d1 2910 ['SECCOMP'],
56d68e71 2911 ['SELinux'],
829257d1 2912 ['SMACK'],
56d68e71
ZJS
2913 ['blkid'],
2914 ['elfutils'],
829257d1 2915 ['gcrypt'],
829257d1 2916 ['gnutls'],
7d861e12 2917 ['libbpf'],
56d68e71 2918 ['libcryptsetup'],
d1ae38d8 2919 ['libcryptsetup-plugins'],
829257d1 2920 ['libcurl'],
56d68e71
ZJS
2921 ['libfdisk'],
2922 ['libfido2'],
829257d1 2923 ['libidn'],
56d68e71 2924 ['libidn2'],
829257d1 2925 ['libiptc'],
56d68e71
ZJS
2926 ['microhttpd'],
2927 ['openssl'],
2928 ['p11kit'],
1d8aae43 2929 ['passwdqc'],
56d68e71
ZJS
2930 ['pcre2'],
2931 ['pwquality'],
2932 ['qrencode'],
2933 ['tpm2'],
2934 ['xkbcommon'],
2935
2936 # compression libs
2937 ['zstd'],
2938 ['lz4'],
2939 ['xz'],
2940 ['zlib'],
2941 ['bzip2'],
2942
2943 # components
2944 ['backlight'],
829257d1 2945 ['binfmt'],
dfca5587 2946 ['bootloader'],
0a0d4899 2947 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
56d68e71 2948 ['coredump'],
56d68e71 2949 ['efi'],
dfca5587 2950 ['environment.d'],
829257d1 2951 ['firstboot'],
56d68e71
ZJS
2952 ['hibernate'],
2953 ['homed'],
2954 ['hostnamed'],
2955 ['hwdb'],
2956 ['importd'],
2957 ['initrd'],
f887eab1 2958 ['kernel-install'],
56d68e71 2959 ['localed'],
829257d1
ZJS
2960 ['logind'],
2961 ['machined'],
56d68e71
ZJS
2962 ['networkd'],
2963 ['nss-myhostname'],
2964 ['nss-mymachines'],
2965 ['nss-resolve'],
2966 ['nss-systemd'],
2967 ['oomd'],
61d0578b 2968 ['portabled'],
56d68e71
ZJS
2969 ['pstore'],
2970 ['quotacheck'],
2971 ['randomseed'],
2972 ['repart'],
2973 ['resolve'],
2974 ['rfkill'],
9bca4ae4 2975 ['sysext'],
0a0d4899 2976 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
43cc7a3e 2977 ['sysupdate'],
56d68e71 2978 ['sysusers'],
1761066b 2979 ['storagetm'],
829257d1
ZJS
2980 ['timedated'],
2981 ['timesyncd'],
56d68e71
ZJS
2982 ['tmpfiles'],
2983 ['userdb'],
2984 ['vconsole'],
9de3cc14 2985 ['vmspawn'],
56d68e71
ZJS
2986 ['xdg-autostart'],
2987
2988 # optional features
12b4cffd 2989 ['dmi'],
56d68e71 2990 ['idn'],
829257d1 2991 ['polkit'],
56d68e71 2992 ['nscd'],
0a0d4899 2993 ['legacy-pkla', install_polkit_pkla],
829257d1 2994 ['kmod'],
ede5a78f 2995 ['xenctrl'],
829257d1
ZJS
2996 ['dbus'],
2997 ['glib'],
829257d1 2998 ['tpm'],
0a0d4899
JH
2999 ['man pages', want_man],
3000 ['html pages', want_html],
3001 ['man page indices', want_man and have_lxml],
829257d1 3002 ['SysV compat'],
56d68e71 3003 ['compat-mutable-uid-boundaries'],
829257d1
ZJS
3004 ['utmp'],
3005 ['ldconfig'],
0a0d4899
JH
3006 ['adm group', get_option('adm-group')],
3007 ['wheel group', get_option('wheel-group')],
b14e1b43 3008 ['gshadow'],
829257d1
ZJS
3009 ['debug hashmap'],
3010 ['debug mmap cache'],
d6601495 3011 ['debug siphash'],
0a0d4899 3012 ['trace logging', conf.get('LOG_TRACE') == 1],
69525346
YW
3013 ['slow tests', slow_tests],
3014 ['fuzz tests', fuzz_tests],
0a0d4899
JH
3015 ['install tests', install_tests],
3016 ['link-udev-shared', get_option('link-udev-shared')],
3017 ['link-systemctl-shared', get_option('link-systemctl-shared')],
3018 ['link-networkd-shared', get_option('link-networkd-shared')],
3019 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
3020 ['link-journalctl-shared', get_option('link-journalctl-shared')],
3021 ['link-boot-shared', get_option('link-boot-shared')],
c06d2e44 3022 ['link-portabled-shared', get_option('link-portabled-shared')],
93651582 3023 ['first-boot-full-preset'],
ceedbf81 3024 ['fexecve'],
0a0d4899
JH
3025 ['standalone-binaries', get_option('standalone-binaries')],
3026 ['coverage', get_option('b_coverage')],
829257d1
ZJS
3027]
3028
af4d7860
ZJS
3029 if tuple.length() >= 2
3030 cond = tuple[1]
3031 else
829257d1
ZJS
3032 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
3033 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
349cc4a5 3034 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
829257d1
ZJS
3035 endif
3036 if cond
5a8b1640 3037 found += tuple[0]
829257d1 3038 else
5a8b1640 3039 missing += tuple[0]
829257d1
ZJS
3040 endif
3041endforeach
3042
c716c253
ZJS
3043if static_libsystemd == 'false'
3044 missing += 'static-libsystemd'
3045else
3046 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
3047endif
3048
3049if static_libudev == 'false'
3050 missing += 'static-libudev'
3051else
3052 found += 'static-libudev(@0@)'.format(static_libudev)
3053endif
3054
57633d23
ZJS
3055if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
3056 found += 'cryptolib(openssl)'
3057elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
3058 found += 'cryptolib(gcrypt)'
3059else
3060 missing += 'cryptolib'
3061endif
3062
237f2da9
ZJS
3063if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
3064 found += 'DNS-over-TLS(gnutls)'
3065elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
3066 found += 'DNS-over-TLS(openssl)'
3067else
3068 missing += 'DNS-over-TLS'
3069endif
3070
12085ebb
ZJS
3071summary({
3072 'enabled' : ', '.join(found),
3073 'disabled' : ', '.join(missing)},
3074 section : 'Features')