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