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