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