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