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