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