]> git.ipfire.org Git - thirdparty/systemd.git/blame - meson.build
meson: Add simple_tests list
[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 = []
c12e10d7 1939simple_tests = []
db7f5ab6 1940fuzzers = []
e93ada98 1941catalogs = []
db7f5ab6
JJ
1942
1943############################################################
5c23128d 1944
db7f5ab6 1945# Include these now as they provide gnu-efi detection.
34357545
MS
1946subdir('src/fundamental')
1947subdir('src/boot/efi')
34357545 1948
f6fe732f
YW
1949############################################################
1950
9c45bfb2
FS
1951pymod = import('python')
1952python = pymod.find_installation('python3', required : true, modules : ['jinja2'])
1953python_39 = python.language_version().version_compare('>=3.9')
1954
1955if get_option('ukify') == 'auto'
1956 want_ukify = python_39 and conf.get('HAVE_GNU_EFI') == 1
1957elif get_option('ukify') == 'true' and (not python_39 or conf.get('HAVE_GNU_EFI') != 1)
1958 error('ukify requires Python >= 3.9 and GNU EFI')
1959else
1960 want_ukify = get_option('ukify') == 'true'
1961endif
1962conf.set10('ENABLE_UKIFY', want_ukify)
1963
1964############################################################
1965#
d3821a33 1966generate_gperfs = find_program('tools/generate-gperfs.py')
f6fe732f
YW
1967make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
1968make_directive_index_py = find_program('tools/make-directive-index.py')
1969make_man_index_py = find_program('tools/make-man-index.py')
6b1aac3c 1970meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
d3821a33 1971update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
77d45f1f 1972update_man_rules_py = find_program('tools/update-man-rules.py')
d3821a33
ZJS
1973update_hwdb_sh = find_program('tools/update-hwdb.sh')
1974update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
1975update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
1976xml_helper_py = find_program('tools/xml_helper.py')
e3c68924 1977export_dbus_interfaces_py = find_program('tools/dbus_exporter.py')
f6fe732f 1978
db7f5ab6 1979############################################################
5c23128d 1980
7e43be7d
FS
1981if get_option('b_coverage')
1982 add_project_arguments('-include', 'src/basic/coverage.h', language : 'c')
1983endif
1984
1985############################################################
1986
5c23128d 1987config_h = configure_file(
37efbbd8
ZJS
1988 output : 'config.h',
1989 configuration : conf)
5c23128d 1990
f6fe732f
YW
1991add_project_arguments('-include', 'config.h', language : 'c')
1992
8f04a1ca
ZJS
1993jinja2_cmdline = [meson_render_jinja2, config_h, version_h]
1994
f6fe732f 1995############################################################
348b4437 1996
b61016f2
YW
1997# binaries that have --help and are intended for use by humans,
1998# usually, but not always, installed in /bin.
1999public_programs = []
2000
e3c68924 2001# D-Bus introspection XML export
2002dbus_programs = []
e3c68924 2003
8d40961c
YW
2004basic_includes = include_directories(
2005 'src/basic',
e5bc5f1f 2006 'src/fundamental',
8d40961c
YW
2007 'src/systemd',
2008 '.')
2009
2010libsystemd_includes = [basic_includes, include_directories(
2011 'src/libsystemd/sd-bus',
2012 'src/libsystemd/sd-device',
2013 'src/libsystemd/sd-event',
2014 'src/libsystemd/sd-hwdb',
2015 'src/libsystemd/sd-id128',
2016 'src/libsystemd/sd-journal',
2017 'src/libsystemd/sd-netlink',
2018 'src/libsystemd/sd-network',
2019 'src/libsystemd/sd-resolve')]
2020
2021includes = [libsystemd_includes, include_directories('src/shared')]
5c23128d 2022
5c23128d
ZJS
2023subdir('po')
2024subdir('catalog')
5c23128d
ZJS
2025subdir('src/basic')
2026subdir('src/libsystemd')
3976f372
YW
2027subdir('src/shared')
2028subdir('src/udev')
2029subdir('src/libudev')
d1ae38d8 2030subdir('src/cryptsetup/cryptsetup-tokens')
5c23128d 2031
039f1673
LB
2032alias_target('devel', libsystemd_pc, libudev_pc)
2033
5c23128d 2034libsystemd = shared_library(
37efbbd8 2035 'systemd',
56d50ab1 2036 version : libsystemd_version,
8d40961c 2037 include_directories : libsystemd_includes,
37efbbd8
ZJS
2038 link_args : ['-shared',
2039 '-Wl,--version-script=' + libsystemd_sym_path],
34e221a5 2040 link_with : [libbasic,
acc50c92
LP
2041 libbasic_gcrypt,
2042 libbasic_compress],
99b9f8fd 2043 link_whole : [libsystemd_static],
37efbbd8 2044 dependencies : [threads,
acc50c92 2045 librt],
37efbbd8
ZJS
2046 link_depends : libsystemd_sym,
2047 install : true,
0a5e638c 2048 install_tag: 'libsystemd',
37efbbd8 2049 install_dir : rootlibdir)
5c23128d 2050
039f1673
LB
2051alias_target('libsystemd', libsystemd)
2052
70848ecf
DC
2053install_libsystemd_static = static_library(
2054 'systemd',
2055 libsystemd_sources,
975464e0
ZJS
2056 basic_sources,
2057 basic_gcrypt_sources,
acc50c92 2058 basic_compress_sources,
e5bc5f1f 2059 fundamental_sources,
8d40961c 2060 include_directories : libsystemd_includes,
70848ecf
DC
2061 build_by_default : static_libsystemd != 'false',
2062 install : static_libsystemd != 'false',
0a5e638c 2063 install_tag: 'libsystemd',
70848ecf 2064 install_dir : rootlibdir,
40dbce36 2065 pic : static_libsystemd_pic,
70848ecf
DC
2066 dependencies : [threads,
2067 librt,
2068 libxz,
ef5924aa 2069 libzstd,
70848ecf 2070 liblz4,
c5fd89ad 2071 libdl,
975464e0
ZJS
2072 libcap,
2073 libblkid,
2074 libmount,
011d129c 2075 libgcrypt,
c47511da
ZJS
2076 libopenssl,
2077 versiondep],
70848ecf
DC
2078 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
2079
3976f372
YW
2080libudev = shared_library(
2081 'udev',
3976f372
YW
2082 version : libudev_version,
2083 include_directories : includes,
2084 link_args : ['-shared',
2085 '-Wl,--version-script=' + libudev_sym_path],
2086 link_with : [libsystemd_static, libshared_static],
2087 link_whole : libudev_basic,
2088 dependencies : [threads],
2089 link_depends : libudev_sym,
2090 install : true,
0a5e638c 2091 install_tag: 'libudev',
3976f372
YW
2092 install_dir : rootlibdir)
2093
039f1673
LB
2094alias_target('libudev', libudev)
2095
3976f372
YW
2096install_libudev_static = static_library(
2097 'udev',
2098 basic_sources,
e5bc5f1f 2099 fundamental_sources,
3976f372
YW
2100 shared_sources,
2101 libsystemd_sources,
2102 libudev_sources,
3976f372
YW
2103 include_directories : includes,
2104 build_by_default : static_libudev != 'false',
2105 install : static_libudev != 'false',
0a5e638c 2106 install_tag: 'libudev',
3976f372
YW
2107 install_dir : rootlibdir,
2108 link_depends : libudev_sym,
c47511da
ZJS
2109 dependencies : [libshared_deps,
2110 libmount,
2111 versiondep],
3976f372
YW
2112 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
2113 pic : static_libudev_pic)
2114
d1ae38d8
OK
2115if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
2116 if conf.get('HAVE_TPM2') == 1
6249face 2117 shared_library(
d1ae38d8 2118 'cryptsetup-token-systemd-tpm2',
c01543fd
ZJS
2119 cryptsetup_token_systemd_tpm2_sources,
2120 include_directories : includes,
d1ae38d8
OK
2121 link_args : ['-shared',
2122 '-Wl,--version-script=' + cryptsetup_token_sym_path],
c01543fd
ZJS
2123 link_with : [lib_cryptsetup_token_common,
2124 libshared],
2125 dependencies : [libcryptsetup,
2126 tpm2,
2127 versiondep],
d1ae38d8 2128 link_depends : cryptsetup_token_sym,
5fb22561 2129 install_rpath : rootpkglibdir,
d1ae38d8
OK
2130 install : true,
2131 install_dir : libcryptsetup_plugins_dir)
2132 endif
351716e1
OK
2133
2134 if conf.get('HAVE_LIBFIDO2') == 1
6249face 2135 shared_library(
351716e1 2136 'cryptsetup-token-systemd-fido2',
c01543fd
ZJS
2137 cryptsetup_token_systemd_fido2_sources,
2138 include_directories : includes,
351716e1
OK
2139 link_args : ['-shared',
2140 '-Wl,--version-script=' + cryptsetup_token_sym_path],
c01543fd
ZJS
2141 link_with : [lib_cryptsetup_token_common,
2142 libshared],
2143 dependencies : [libcryptsetup,
2144 libfido2,
2145 versiondep],
351716e1 2146 link_depends : cryptsetup_token_sym,
5fb22561 2147 install_rpath : rootpkglibdir,
351716e1
OK
2148 install : true,
2149 install_dir : libcryptsetup_plugins_dir)
2150 endif
8186022c
OK
2151
2152 if conf.get('HAVE_P11KIT') == 1
6249face 2153 shared_library(
8186022c 2154 'cryptsetup-token-systemd-pkcs11',
c01543fd
ZJS
2155 cryptsetup_token_systemd_pkcs11_sources,
2156 include_directories : includes,
8186022c
OK
2157 link_args : ['-shared',
2158 '-Wl,--version-script=' + cryptsetup_token_sym_path],
c01543fd
ZJS
2159 link_with : [lib_cryptsetup_token_common,
2160 libshared],
2161 dependencies : [libcryptsetup,
2162 libp11kit,
2163 versiondep],
8186022c 2164 link_depends : cryptsetup_token_sym,
5fb22561 2165 install_rpath : rootpkglibdir,
8186022c
OK
2166 install : true,
2167 install_dir : libcryptsetup_plugins_dir)
2168 endif
d1ae38d8
OK
2169endif
2170
47354b44
ZJS
2171############################################################
2172
b61016f2 2173# systemd-analyze requires 'libcore'
83b6af36 2174subdir('src/core')
b61016f2
YW
2175# systemd-journal-remote requires 'libjournal_core'
2176subdir('src/journal')
2177# systemd-networkd requires 'libsystemd_network'
2178subdir('src/libsystemd-network')
83b6af36
ZJS
2179
2180subdir('src/analyze')
cd4300f3 2181subdir('src/boot')
f98df767 2182subdir('src/busctl')
b61016f2 2183subdir('src/coredump')
2ad279cf 2184subdir('src/cryptenroll')
b4d1892a 2185subdir('src/cryptsetup')
b61016f2 2186subdir('src/home')
83b6af36
ZJS
2187subdir('src/hostname')
2188subdir('src/import')
b61016f2 2189subdir('src/journal-remote')
83b6af36
ZJS
2190subdir('src/kernel-install')
2191subdir('src/locale')
b61016f2 2192subdir('src/login')
83b6af36 2193subdir('src/machine')
b61016f2 2194subdir('src/network')
83b6af36 2195subdir('src/nspawn')
b61016f2
YW
2196subdir('src/oom')
2197subdir('src/partition')
2198subdir('src/portable')
2199subdir('src/pstore')
83b6af36 2200subdir('src/resolve')
2a9b4bbe 2201subdir('src/rpm')
b61016f2 2202subdir('src/shutdown')
9bca4ae4 2203subdir('src/sysext')
c3512573 2204subdir('src/systemctl')
43cc7a3e 2205subdir('src/sysupdate')
83b6af36
ZJS
2206subdir('src/timedate')
2207subdir('src/timesync')
db64ba81 2208subdir('src/tmpfiles')
b61016f2 2209subdir('src/userdb')
0275e918 2210subdir('src/xdg-autostart-generator')
83b6af36 2211
3976f372
YW
2212subdir('src/systemd')
2213
83b6af36 2214subdir('src/test')
7db7d5b7 2215subdir('src/fuzz')
ef2ad30a 2216subdir('rules.d')
83b6af36 2217subdir('test')
a1d6dbb1 2218subdir('src/ukify/test') # needs to be last for test_env variable
83b6af36
ZJS
2219
2220############################################################
2221
2222# only static linking apart from libdl, to make sure that the
2223# module is linked to all libraries that it uses.
2224test_dlopen = executable(
37efbbd8
ZJS
2225 'test-dlopen',
2226 test_dlopen_c,
2227 include_directories : includes,
2228 link_with : [libbasic],
fd1939fb
YW
2229 dependencies : [libdl],
2230 build_by_default : want_tests != 'false')
83b6af36 2231
08540a95 2232foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
cbaaf7b9 2233 ['systemd', 'ENABLE_NSS_SYSTEMD', ['nss-systemd.h', 'userdb-glue.c', 'userdb-glue.h']],
08540a95 2234 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
8d40961c 2235 ['resolve', 'ENABLE_NSS_RESOLVE', [], resolve_includes]]
5c23128d 2236
349cc4a5 2237 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
37efbbd8
ZJS
2238 if condition
2239 module = tuple[0]
37efbbd8
ZJS
2240
2241 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
fce9abb2 2242 version_script_arg = project_source_root / sym
37efbbd8 2243
1684c56f
LP
2244 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
2245 if tuple.length() > 2
cbaaf7b9
YW
2246 foreach s : tuple[2]
2247 sources += ['src/nss-@0@/@1@'.format(module, s)]
2248 endforeach
1684c56f
LP
2249 endif
2250
8d40961c
YW
2251 incs = tuple.length() > 3 ? tuple[3] : includes
2252
37efbbd8
ZJS
2253 nss = shared_library(
2254 'nss_' + module,
1684c56f 2255 sources,
37efbbd8 2256 version : '2',
8d40961c 2257 include_directories : incs,
b4b36f44
LP
2258 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
2259 link_args : ['-Wl,-z,nodelete',
2260 '-shared',
700805f6 2261 '-Wl,--version-script=' + version_script_arg],
37e4d7a8 2262 link_with : [libsystemd_static,
733cbd00 2263 libshared_static,
37efbbd8
ZJS
2264 libbasic],
2265 dependencies : [threads,
5486a31d 2266 librt],
37efbbd8
ZJS
2267 link_depends : sym,
2268 install : true,
35d17e15 2269 install_tag : 'nss',
37efbbd8
ZJS
2270 install_dir : rootlibdir)
2271
2272 # We cannot use shared_module because it does not support version suffix.
2273 # Unfortunately shared_library insists on creating the symlink…
7c22f07c 2274 meson.add_install_script('sh', '-c',
37efbbd8 2275 'rm $DESTDIR@0@/libnss_@1@.so'
35d17e15
MG
2276 .format(rootlibdir, module),
2277 install_tag : 'nss'
2278 )
37efbbd8 2279
938be089
ZJS
2280 if want_tests != 'false'
2281 test('dlopen-nss_' + module,
2282 test_dlopen,
2283 # path to dlopen must include a slash
e93ada98
DDM
2284 args : nss.full_path(),
2285 depends : nss)
938be089 2286 endif
37efbbd8 2287 endif
5c23128d
ZJS
2288endforeach
2289
2290############################################################
2291
3761002e 2292exe = executable(
6164ec4c
ZJS
2293 'systemd',
2294 systemd_sources,
2295 include_directories : includes,
2296 link_with : [libcore,
2297 libshared],
c47511da
ZJS
2298 dependencies : [libseccomp,
2299 versiondep],
5fb22561 2300 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2301 install : true,
2302 install_dir : rootlibexecdir)
3761002e
ZJS
2303dbus_programs += exe
2304public_programs += exe
5c23128d 2305
ba7f4ae6 2306meson.add_install_script(meson_make_symlink,
fce9abb2
ZJS
2307 rootlibexecdir / 'systemd',
2308 rootsbindir / 'init')
ba7f4ae6 2309
4e8295f4 2310exe = executable(
6164ec4c
ZJS
2311 'systemd-analyze',
2312 systemd_analyze_sources,
8d40961c 2313 include_directories : core_includes,
6164ec4c
ZJS
2314 link_with : [libcore,
2315 libshared],
c47511da
ZJS
2316 dependencies : [libseccomp,
2317 versiondep],
5fb22561 2318 install_rpath : rootpkglibdir,
9e4a50bc 2319 install : conf.get('ENABLE_ANALYZE') == 1)
4e8295f4
ZJS
2320public_programs += exe
2321
2322if want_tests != 'false'
2323 test('test-compare-versions',
2324 test_compare_versions_sh,
2325 args : exe.full_path())
2326endif
5c23128d 2327
6164ec4c
ZJS
2328executable(
2329 'systemd-journald',
2330 systemd_journald_sources,
2331 include_directories : includes,
2332 link_with : [libjournal_core,
2333 libshared],
2334 dependencies : [threads,
2335 libxz,
2336 liblz4,
ef5924aa 2337 libselinux,
c47511da
ZJS
2338 libzstd,
2339 versiondep],
5fb22561 2340 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2341 install : true,
2342 install_dir : rootlibexecdir)
5c23128d 2343
6164ec4c
ZJS
2344public_programs += executable(
2345 'systemd-cat',
2346 systemd_cat_sources,
2347 include_directories : includes,
2348 link_with : [libjournal_core,
2349 libshared],
3a21c554
FS
2350 dependencies : [threads,
2351 versiondep],
5fb22561 2352 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2353 install : true)
2354
0a0d4899 2355if get_option('link-journalctl-shared')
46fb302f 2356 journalctl_link_with = [libshared]
0a0d4899
JH
2357else
2358 journalctl_link_with = [libsystemd_static,
2359 libshared_static,
46fb302f 2360 libbasic_gcrypt]
0a0d4899
JH
2361endif
2362
6164ec4c
ZJS
2363public_programs += executable(
2364 'journalctl',
2365 journalctl_sources,
2366 include_directories : includes,
0a0d4899 2367 link_with : [journalctl_link_with],
6164ec4c 2368 dependencies : [threads,
e44b5004 2369 libdl,
6164ec4c
ZJS
2370 libxz,
2371 liblz4,
9200bb30 2372 libzstd,
c47511da
ZJS
2373 libdl,
2374 versiondep],
5fb22561 2375 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2376 install : true,
2377 install_dir : rootbindir)
35a1ff4c 2378
6164ec4c
ZJS
2379executable(
2380 'systemd-getty-generator',
2381 'src/getty-generator/getty-generator.c',
2382 include_directories : includes,
2383 link_with : [libshared],
5fb22561 2384 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2385 install : true,
2386 install_dir : systemgeneratordir)
5c23128d 2387
6164ec4c
ZJS
2388executable(
2389 'systemd-debug-generator',
2390 'src/debug-generator/debug-generator.c',
2391 include_directories : includes,
2392 link_with : [libshared],
5fb22561 2393 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2394 install : true,
2395 install_dir : systemgeneratordir)
2396
2397executable(
2398 'systemd-run-generator',
2399 'src/run-generator/run-generator.c',
2400 include_directories : includes,
2401 link_with : [libshared],
5fb22561 2402 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2403 install : true,
2404 install_dir : systemgeneratordir)
2405
8cc8a073 2406exe = executable(
6164ec4c
ZJS
2407 'systemd-fstab-generator',
2408 'src/fstab-generator/fstab-generator.c',
2409 include_directories : includes,
bac11cd6 2410 link_with : [libshared],
5fb22561 2411 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2412 install : true,
2413 install_dir : systemgeneratordir)
5c23128d 2414
028a981c
ZJS
2415meson.add_install_script(meson_make_symlink,
2416 systemgeneratordir / 'systemd-fstab-generator',
2417 rootlibexecdir / 'systemd-sysroot-fstab-check')
2418
8cc8a073
YW
2419if want_tests != 'false'
2420 test('test-fstab-generator',
2421 test_fstab_generator_sh,
2422 # https://github.com/mesonbuild/meson/issues/2681
e93ada98
DDM
2423 args : exe.full_path(),
2424 depends : exe)
8cc8a073
YW
2425endif
2426
349cc4a5 2427if conf.get('ENABLE_ENVIRONMENT_D') == 1
6164ec4c
ZJS
2428 executable(
2429 '30-systemd-environment-d-generator',
2430 'src/environment-d-generator/environment-d-generator.c',
2431 include_directories : includes,
2432 link_with : [libshared],
5fb22561 2433 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2434 install : true,
2435 install_dir : userenvgeneratordir)
7b76fce1 2436
37efbbd8 2437 meson.add_install_script(meson_make_symlink,
fce9abb2
ZJS
2438 sysconfdir / 'environment',
2439 environmentdir / '99-environment.conf')
5c23128d
ZJS
2440endif
2441
349cc4a5 2442if conf.get('ENABLE_HIBERNATE') == 1
6164ec4c
ZJS
2443 executable(
2444 'systemd-hibernate-resume-generator',
2445 'src/hibernate-resume/hibernate-resume-generator.c',
2446 include_directories : includes,
2447 link_with : [libshared],
5fb22561 2448 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2449 install : true,
2450 install_dir : systemgeneratordir)
2451
2452 executable(
2453 'systemd-hibernate-resume',
2454 'src/hibernate-resume/hibernate-resume.c',
2455 include_directories : includes,
2456 link_with : [libshared],
5fb22561 2457 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2458 install : true,
2459 install_dir : rootlibexecdir)
37efbbd8
ZJS
2460endif
2461
349cc4a5 2462if conf.get('HAVE_BLKID') == 1
6164ec4c
ZJS
2463 executable(
2464 'systemd-gpt-auto-generator',
2465 'src/gpt-auto-generator/gpt-auto-generator.c',
6164ec4c
ZJS
2466 include_directories : includes,
2467 link_with : [libshared],
2468 dependencies : libblkid,
5fb22561 2469 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2470 install : true,
2471 install_dir : systemgeneratordir)
2472
2473 public_programs += executable(
2474 'systemd-dissect',
2475 'src/dissect/dissect.c',
2476 include_directories : includes,
2477 link_with : [libshared],
3a21c554 2478 dependencies : [versiondep],
5fb22561 2479 install_rpath : rootpkglibdir,
5a151082 2480 install : true)
5c23128d
ZJS
2481endif
2482
1ec57f33 2483if conf.get('ENABLE_RESOLVE') == 1
e3c68924 2484 dbus_programs += executable(
6164ec4c
ZJS
2485 'systemd-resolved',
2486 systemd_resolved_sources,
8d40961c 2487 include_directories : resolve_includes,
6164ec4c
ZJS
2488 link_with : [libshared,
2489 libbasic_gcrypt,
2490 libsystemd_resolve_core],
2491 dependencies : systemd_resolved_dependencies,
5fb22561 2492 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2493 install : true,
2494 install_dir : rootlibexecdir)
2495
2496 public_programs += executable(
2497 'resolvectl',
2498 resolvectl_sources,
2499 include_directories : includes,
2500 link_with : [libshared,
2501 libbasic_gcrypt,
2502 libsystemd_resolve_core],
2503 dependencies : [threads,
0351cbb9 2504 lib_openssl_or_gcrypt,
6164ec4c 2505 libm,
c47511da
ZJS
2506 libidn,
2507 versiondep],
5fb22561 2508 install_rpath : rootpkglibdir,
6164ec4c 2509 install : true)
088c1363
LP
2510
2511 meson.add_install_script(meson_make_symlink,
fce9abb2
ZJS
2512 bindir / 'resolvectl',
2513 rootsbindir / 'resolvconf')
c2e84cab
YW
2514
2515 meson.add_install_script(meson_make_symlink,
fce9abb2
ZJS
2516 bindir / 'resolvectl',
2517 bindir / 'systemd-resolve')
5c23128d
ZJS
2518endif
2519
349cc4a5 2520if conf.get('ENABLE_LOGIND') == 1
e3c68924 2521 dbus_programs += executable(
6164ec4c
ZJS
2522 'systemd-logind',
2523 systemd_logind_sources,
2524 include_directories : includes,
2525 link_with : [liblogind_core,
2526 libshared],
2527 dependencies : [threads,
c47511da
ZJS
2528 libacl,
2529 versiondep],
5fb22561 2530 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2531 install : true,
2532 install_dir : rootlibexecdir)
2533
2534 public_programs += executable(
2535 'loginctl',
2536 loginctl_sources,
2537 include_directories : includes,
2538 link_with : [libshared],
2539 dependencies : [threads,
2540 liblz4,
ef5924aa 2541 libxz,
c47511da
ZJS
2542 libzstd,
2543 versiondep],
5fb22561 2544 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2545 install : true,
2546 install_dir : rootbindir)
2547
2548 public_programs += executable(
2549 'systemd-inhibit',
2550 'src/login/inhibit.c',
2551 include_directories : includes,
2552 link_with : [libshared],
3a21c554 2553 dependencies : [versiondep],
5fb22561 2554 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2555 install : true,
2556 install_dir : rootbindir)
37efbbd8 2557
349cc4a5 2558 if conf.get('HAVE_PAM') == 1
fce9abb2 2559 version_script_arg = project_source_root / pam_systemd_sym
37efbbd8
ZJS
2560 pam_systemd = shared_library(
2561 'pam_systemd',
2562 pam_systemd_c,
2563 name_prefix : '',
2564 include_directories : includes,
2565 link_args : ['-shared',
2566 '-Wl,--version-script=' + version_script_arg],
37e4d7a8 2567 link_with : [libsystemd_static,
37efbbd8
ZJS
2568 libshared_static],
2569 dependencies : [threads,
2570 libpam,
c47511da
ZJS
2571 libpam_misc,
2572 versiondep],
37efbbd8
ZJS
2573 link_depends : pam_systemd_sym,
2574 install : true,
48139c7c 2575 install_tag : 'pam',
37efbbd8
ZJS
2576 install_dir : pamlibdir)
2577
938be089
ZJS
2578 if want_tests != 'false'
2579 test('dlopen-pam_systemd',
2580 test_dlopen,
2581 # path to dlopen must include a slash
e93ada98
DDM
2582 args : pam_systemd.full_path(),
2583 depends : pam_systemd)
938be089 2584 endif
37efbbd8 2585 endif
005a29f2 2586
6164ec4c
ZJS
2587 executable(
2588 'systemd-user-runtime-dir',
2589 user_runtime_dir_sources,
2590 include_directories : includes,
2591 link_with : [libshared],
5fb22561 2592 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2593 install : true,
2594 install_dir : rootlibexecdir)
07ee5adb 2595endif
a9f0f5e5 2596
349cc4a5 2597if conf.get('HAVE_PAM') == 1
6164ec4c
ZJS
2598 executable(
2599 'systemd-user-sessions',
2600 'src/user-sessions/user-sessions.c',
2601 include_directories : includes,
2602 link_with : [libshared],
5fb22561 2603 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2604 install : true,
2605 install_dir : rootlibexecdir)
5c23128d
ZJS
2606endif
2607
34357545 2608if conf.get('HAVE_BLKID') == 1 and conf.get('HAVE_GNU_EFI') == 1
79647020
RS
2609 if get_option('link-boot-shared')
2610 boot_link_with = [libshared]
2611 else
2612 boot_link_with = [libsystemd_static, libshared_static]
2613 endif
2614
50f2c32c 2615 exe = executable(
6164ec4c 2616 'bootctl',
cd4300f3 2617 bootctl_sources,
6164ec4c 2618 include_directories : includes,
79647020 2619 link_with : [boot_link_with],
c47511da
ZJS
2620 dependencies : [libblkid,
2621 versiondep],
5fb22561 2622 install_rpath : rootpkglibdir,
6164ec4c 2623 install : true)
50f2c32c
ZJS
2624 public_programs += exe
2625
2626 if want_tests != 'false'
2627 test('test-bootctl-json',
2628 test_bootctl_json_sh,
2629 args : exe.full_path(),
2630 depends : exe)
2631 endif
6164ec4c
ZJS
2632
2633 public_programs += executable(
2634 'systemd-bless-boot',
2635 'src/boot/bless-boot.c',
2636 include_directories : includes,
79647020 2637 link_with : [boot_link_with],
c47511da
ZJS
2638 dependencies : [libblkid,
2639 versiondep],
5fb22561 2640 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2641 install : true,
2642 install_dir : rootlibexecdir)
2643
2644 executable(
2645 'systemd-bless-boot-generator',
2646 'src/boot/bless-boot-generator.c',
2647 include_directories : includes,
79647020 2648 link_with : [boot_link_with],
5fb22561 2649 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2650 install : true,
2651 install_dir : systemgeneratordir)
ca1092dc 2652
3286770d 2653 if conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_TPM2') == 1
ca1092dc
LP
2654 executable(
2655 'systemd-measure',
2656 'src/boot/measure.c',
2657 include_directories : includes,
2658 link_with : [libshared],
c47511da
ZJS
2659 dependencies : [libopenssl,
2660 versiondep],
ca1092dc
LP
2661 install_rpath : rootpkglibdir,
2662 install : true,
2663 install_dir : rootlibexecdir)
708d7524
LP
2664 executable(
2665 'systemd-pcrphase',
2666 'src/boot/pcrphase.c',
2667 include_directories : includes,
2668 link_with : [libshared],
c47511da
ZJS
2669 dependencies : [libopenssl,
2670 tpm2,
17984c55 2671 libblkid,
c47511da 2672 versiondep],
708d7524
LP
2673 install_rpath : rootpkglibdir,
2674 install : true,
2675 install_dir : rootlibexecdir)
ca1092dc 2676 endif
6164ec4c
ZJS
2677endif
2678
2679executable(
2680 'systemd-boot-check-no-failures',
2681 'src/boot/boot-check-no-failures.c',
2682 include_directories : includes,
2683 link_with : [libshared],
c47511da
ZJS
2684 dependencies : [libblkid,
2685 versiondep],
5fb22561 2686 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2687 install : true,
2688 install_dir : rootlibexecdir)
005a29f2 2689
6164ec4c
ZJS
2690public_programs += executable(
2691 'systemd-socket-activate',
2692 'src/activate/activate.c',
2693 include_directories : includes,
2694 link_with : [libshared],
c47511da
ZJS
2695 dependencies : [threads,
2696 versiondep],
5fb22561 2697 install_rpath : rootpkglibdir,
6164ec4c 2698 install : true)
f3794366 2699
2a2d002f 2700systemctl = executable(
6164ec4c 2701 'systemctl',
c3512573 2702 systemctl_sources,
6164ec4c
ZJS
2703 include_directories : includes,
2704 link_with : systemctl_link_with,
2705 dependencies : [threads,
2706 libcap,
2707 libselinux,
2708 libxz,
ef5924aa 2709 liblz4,
c47511da
ZJS
2710 libzstd,
2711 versiondep],
5fb22561 2712 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2713 install : true,
2714 install_dir : rootbindir)
2a2d002f 2715public_programs += systemctl
5c23128d 2716
61d0578b 2717if conf.get('ENABLE_PORTABLED') == 1
e3c68924 2718 dbus_programs += executable(
6164ec4c
ZJS
2719 'systemd-portabled',
2720 systemd_portabled_sources,
2721 include_directories : includes,
2722 link_with : [libshared],
c47511da
ZJS
2723 dependencies : [threads,
2724 libselinux,
2725 versiondep],
5fb22561 2726 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2727 install : true,
2728 install_dir : rootlibexecdir)
2729
2730 public_programs += executable(
2731 'portablectl',
2732 'src/portable/portablectl.c',
2733 include_directories : includes,
2734 link_with : [libshared],
c47511da
ZJS
2735 dependencies : [threads,
2736 versiondep],
5fb22561 2737 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2738 install : true,
2739 install_dir : rootbindir)
61d0578b
LP
2740endif
2741
9bca4ae4
LP
2742if conf.get('ENABLE_SYSEXT') == 1
2743 public_programs += executable(
2744 'systemd-sysext',
2745 systemd_sysext_sources,
2746 include_directories : includes,
2747 link_with : [libshared],
3a21c554 2748 dependencies : [versiondep],
5fb22561 2749 install_rpath : rootpkglibdir,
9bca4ae4 2750 install : true,
aac5fbff 2751 install_dir : rootbindir)
9bca4ae4
LP
2752endif
2753
d093b62c 2754if conf.get('ENABLE_USERDB') == 1
6164ec4c
ZJS
2755 executable(
2756 'systemd-userwork',
2757 systemd_userwork_sources,
2758 include_directories : includes,
2759 link_with : [libshared],
c47511da
ZJS
2760 dependencies : [threads,
2761 versiondep],
5fb22561 2762 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2763 install : true,
2764 install_dir : rootlibexecdir)
2765
2766 executable(
2767 'systemd-userdbd',
2768 systemd_userdbd_sources,
2769 include_directories : includes,
2770 link_with : [libshared],
c47511da
ZJS
2771 dependencies : [threads,
2772 versiondep],
5fb22561 2773 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2774 install : true,
2775 install_dir : rootlibexecdir)
2776
460e5af0 2777 public_programs += executable(
6164ec4c
ZJS
2778 'userdbctl',
2779 userdbctl_sources,
2780 include_directories : includes,
2781 link_with : [libshared],
c47511da
ZJS
2782 dependencies : [threads,
2783 versiondep],
5fb22561 2784 install_rpath : rootpkglibdir,
003a6761 2785 install : true)
d093b62c
LP
2786endif
2787
70a5db58 2788if conf.get('ENABLE_HOMED') == 1
6164ec4c
ZJS
2789 executable(
2790 'systemd-homework',
2791 systemd_homework_sources,
2792 include_directories : includes,
f8cf3d19
LP
2793 link_with : [libshared,
2794 libshared_fdisk],
6164ec4c 2795 dependencies : [threads,
6164ec4c
ZJS
2796 libblkid,
2797 libcrypt,
2798 libopenssl,
2799 libfdisk,
c47511da
ZJS
2800 libp11kit,
2801 versiondep],
5fb22561 2802 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2803 install : true,
2804 install_dir : rootlibexecdir)
2805
e3c68924 2806 dbus_programs += executable(
6164ec4c
ZJS
2807 'systemd-homed',
2808 systemd_homed_sources,
8d40961c 2809 include_directories : home_includes,
6164ec4c
ZJS
2810 link_with : [libshared],
2811 dependencies : [threads,
2812 libcrypt,
d357b80d 2813 libopenssl,
c47511da
ZJS
2814 libm,
2815 versiondep],
5fb22561 2816 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2817 install : true,
2818 install_dir : rootlibexecdir)
2819
460e5af0 2820 public_programs += executable(
6164ec4c
ZJS
2821 'homectl',
2822 homectl_sources,
2823 include_directories : includes,
2824 link_with : [libshared],
2825 dependencies : [threads,
2826 libcrypt,
2827 libopenssl,
2828 libp11kit,
c47511da
ZJS
2829 libdl,
2830 versiondep],
5fb22561 2831 install_rpath : rootpkglibdir,
003a6761 2832 install : true)
26cf9fb7
LP
2833
2834 if conf.get('HAVE_PAM') == 1
fce9abb2 2835 version_script_arg = project_source_root / pam_systemd_home_sym
a7127884 2836 pam_systemd_home = shared_library(
26cf9fb7
LP
2837 'pam_systemd_home',
2838 pam_systemd_home_c,
2839 name_prefix : '',
2840 include_directories : includes,
2841 link_args : ['-shared',
2842 '-Wl,--version-script=' + version_script_arg],
2843 link_with : [libsystemd_static,
2844 libshared_static],
2845 dependencies : [threads,
2846 libpam,
2847 libpam_misc,
c47511da
ZJS
2848 libcrypt,
2849 versiondep],
26cf9fb7
LP
2850 link_depends : pam_systemd_home_sym,
2851 install : true,
48139c7c 2852 install_tag : 'pam',
26cf9fb7 2853 install_dir : pamlibdir)
a7127884
YW
2854
2855 if want_tests != 'false'
2856 test('dlopen-pam_systemd_home',
2857 test_dlopen,
2858 # path to dlopen must include a slash
2859 args : pam_systemd_home.full_path(),
2860 depends : pam_systemd_home)
2861 endif
26cf9fb7 2862 endif
70a5db58
LP
2863endif
2864
6589a569 2865foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
ba081955 2866 (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
ba7f4ae6 2867 meson.add_install_script(meson_make_symlink,
fce9abb2
ZJS
2868 rootbindir / 'systemctl',
2869 rootsbindir / alias)
ba7f4ae6
ZJS
2870endforeach
2871
63e2d171 2872meson.add_install_script(meson_make_symlink,
fce9abb2
ZJS
2873 rootbindir / 'udevadm',
2874 rootlibexecdir / 'systemd-udevd')
63e2d171 2875
349cc4a5 2876if conf.get('ENABLE_BACKLIGHT') == 1
6164ec4c
ZJS
2877 executable(
2878 'systemd-backlight',
2879 'src/backlight/backlight.c',
2880 include_directories : includes,
2881 link_with : [libshared],
5fb22561 2882 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2883 install : true,
2884 install_dir : rootlibexecdir)
5c23128d
ZJS
2885endif
2886
349cc4a5 2887if conf.get('ENABLE_RFKILL') == 1
6164ec4c
ZJS
2888 executable(
2889 'systemd-rfkill',
2890 'src/rfkill/rfkill.c',
2891 include_directories : includes,
2892 link_with : [libshared],
5fb22561 2893 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2894 install : true,
2895 install_dir : rootlibexecdir)
2896endif
2897
2898executable(
2899 'systemd-system-update-generator',
2900 'src/system-update-generator/system-update-generator.c',
2901 include_directories : includes,
2902 link_with : [libshared],
5fb22561 2903 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2904 install : true,
2905 install_dir : systemgeneratordir)
5c23128d 2906
349cc4a5 2907if conf.get('HAVE_LIBCRYPTSETUP') == 1
6164ec4c
ZJS
2908 executable(
2909 'systemd-cryptsetup',
2910 systemd_cryptsetup_sources,
2911 include_directories : includes,
2912 link_with : [libshared],
2913 dependencies : [libcryptsetup,
c47511da 2914 libp11kit,
94c0c85e
LP
2915 versiondep,
2916 libopenssl],
5fb22561 2917 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2918 install : true,
2919 install_dir : rootlibexecdir)
2920
2921 executable(
2922 'systemd-cryptsetup-generator',
2923 'src/cryptsetup/cryptsetup-generator.c',
2924 include_directories : includes,
2925 link_with : [libshared],
5fb22561 2926 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2927 install : true,
2928 install_dir : systemgeneratordir)
2929
2930 executable(
2931 'systemd-veritysetup',
2932 'src/veritysetup/veritysetup.c',
2933 include_directories : includes,
2934 link_with : [libshared],
c47511da
ZJS
2935 dependencies : [libcryptsetup,
2936 versiondep],
5fb22561 2937 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2938 install : true,
2939 install_dir : rootlibexecdir)
2940
2941 executable(
2942 'systemd-veritysetup-generator',
2943 'src/veritysetup/veritysetup-generator.c',
2944 include_directories : includes,
2945 link_with : [libshared],
c47511da 2946 dependencies : [versiondep],
5fb22561 2947 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2948 install : true,
2949 install_dir : systemgeneratordir)
8710a681 2950
3761002e 2951 public_programs += executable(
8710a681
LP
2952 'systemd-cryptenroll',
2953 systemd_cryptenroll_sources,
2954 include_directories : includes,
2955 link_with : [libshared],
2956 dependencies : [libcryptsetup,
5e521624 2957 libdl,
8710a681 2958 libopenssl,
c47511da
ZJS
2959 libp11kit,
2960 versiondep],
5fb22561 2961 install_rpath : rootpkglibdir,
a1fd722b 2962 install : true)
1f1a2243
TA
2963
2964 executable(
2965 'systemd-integritysetup',
2966 ['src/integritysetup/integritysetup.c', 'src/integritysetup/integrity-util.c'],
2967 include_directories : includes,
2968 link_with : [libshared],
c47511da
ZJS
2969 dependencies : [libcryptsetup,
2970 versiondep],
5fb22561 2971 install_rpath : rootpkglibdir,
1f1a2243
TA
2972 install : true,
2973 install_dir : rootlibexecdir)
2974
2975 executable(
2976 'systemd-integritysetup-generator',
2977 ['src/integritysetup/integritysetup-generator.c', 'src/integritysetup/integrity-util.c'],
2978 include_directories : includes,
2979 link_with : [libshared],
5fb22561 2980 install_rpath : rootpkglibdir,
1f1a2243
TA
2981 install : true,
2982 install_dir : systemgeneratordir)
5c23128d
ZJS
2983endif
2984
349cc4a5 2985if conf.get('HAVE_SYSV_COMPAT') == 1
e93ada98 2986 exe = executable(
6164ec4c
ZJS
2987 'systemd-sysv-generator',
2988 'src/sysv-generator/sysv-generator.c',
2989 include_directories : includes,
2990 link_with : [libshared],
5fb22561 2991 install_rpath : rootpkglibdir,
6164ec4c
ZJS
2992 install : true,
2993 install_dir : systemgeneratordir)
2994
e93ada98
DDM
2995 sysv_generator_test_py = find_program('test/sysv-generator-test.py')
2996 if want_tests != 'false'
2997 test('sysv-generator-test',
2998 sysv_generator_test_py,
2999 depends : exe)
3000 endif
3001
6164ec4c
ZJS
3002 executable(
3003 'systemd-rc-local-generator',
3004 'src/rc-local-generator/rc-local-generator.c',
3005 include_directories : includes,
3006 link_with : [libshared],
5fb22561 3007 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3008 install : true,
3009 install_dir : systemgeneratordir)
5c23128d
ZJS
3010endif
3011
8feca247
BB
3012if conf.get('ENABLE_XDG_AUTOSTART') == 1
3013 executable(
3014 'systemd-xdg-autostart-generator',
0275e918 3015 systemd_xdg_autostart_generator_sources,
8feca247
BB
3016 include_directories : includes,
3017 link_with : [libshared],
5fb22561 3018 install_rpath : rootpkglibdir,
8feca247
BB
3019 install : true,
3020 install_dir : usergeneratordir)
3021
3022 executable(
3023 'systemd-xdg-autostart-condition',
3024 'src/xdg-autostart-generator/xdg-autostart-condition.c',
3025 include_directories : includes,
3026 link_with : [libshared],
5fb22561 3027 install_rpath : rootpkglibdir,
8feca247
BB
3028 install : true,
3029 install_dir : rootlibexecdir)
3030endif
3031
349cc4a5 3032if conf.get('ENABLE_HOSTNAMED') == 1
e3c68924 3033 dbus_programs += executable(
6164ec4c
ZJS
3034 'systemd-hostnamed',
3035 'src/hostname/hostnamed.c',
3036 include_directories : includes,
3037 link_with : [libshared],
5fb22561 3038 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3039 install : true,
3040 install_dir : rootlibexecdir)
3041
3042 public_programs += executable(
3043 'hostnamectl',
3044 'src/hostname/hostnamectl.c',
3045 include_directories : includes,
3046 link_with : [libshared],
3a21c554 3047 dependencies : [versiondep],
5fb22561 3048 install_rpath : rootpkglibdir,
6164ec4c 3049 install : true)
5c23128d
ZJS
3050endif
3051
349cc4a5
ZJS
3052if conf.get('ENABLE_LOCALED') == 1
3053 if conf.get('HAVE_XKBCOMMON') == 1
bfa0ade9
AK
3054 # logind will load libxkbcommon.so dynamically on its own, but we still
3055 # need to specify where the headers are
c47511da
ZJS
3056 deps = [libdl,
3057 libxkbcommon.partial_dependency(compile_args: true),
3058 versiondep]
37efbbd8 3059 else
c47511da 3060 deps = [versiondep]
37efbbd8
ZJS
3061 endif
3062
e3c68924 3063 dbus_programs += executable(
6164ec4c
ZJS
3064 'systemd-localed',
3065 systemd_localed_sources,
bfa0ade9 3066 include_directories : includes,
6164ec4c
ZJS
3067 link_with : [libshared],
3068 dependencies : deps,
5fb22561 3069 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3070 install : true,
3071 install_dir : rootlibexecdir)
3072
3073 public_programs += executable(
3074 'localectl',
3075 localectl_sources,
3076 include_directories : includes,
3077 link_with : [libshared],
3a21c554 3078 dependencies : [versiondep],
5fb22561 3079 install_rpath : rootpkglibdir,
6164ec4c 3080 install : true)
5c23128d
ZJS
3081endif
3082
349cc4a5 3083if conf.get('ENABLE_TIMEDATED') == 1
e3c68924 3084 dbus_programs += executable(
6164ec4c
ZJS
3085 'systemd-timedated',
3086 'src/timedate/timedated.c',
3087 include_directories : includes,
3088 link_with : [libshared],
5fb22561 3089 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3090 install : true,
3091 install_dir : rootlibexecdir)
6129ec85 3092endif
5c23128d 3093
6129ec85 3094if conf.get('ENABLE_TIMEDATECTL') == 1
6164ec4c
ZJS
3095 public_programs += executable(
3096 'timedatectl',
3097 'src/timedate/timedatectl.c',
3098 include_directories : includes,
5fb22561 3099 install_rpath : rootpkglibdir,
6164ec4c 3100 link_with : [libshared],
c47511da
ZJS
3101 dependencies : [libm,
3102 versiondep],
6164ec4c 3103 install : true)
5c23128d
ZJS
3104endif
3105
349cc4a5 3106if conf.get('ENABLE_TIMESYNCD') == 1
6164ec4c
ZJS
3107 executable(
3108 'systemd-timesyncd',
3109 systemd_timesyncd_sources,
3110 include_directories : includes,
f5a5284e 3111 link_with : [libtimesyncd_core],
6164ec4c 3112 dependencies : [threads,
c47511da
ZJS
3113 libm,
3114 versiondep],
5fb22561 3115 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3116 install : true,
3117 install_dir : rootlibexecdir)
3118
3119 executable(
3120 'systemd-time-wait-sync',
cf242350 3121 'src/timesync/wait-sync.c',
6164ec4c 3122 include_directories : includes,
f5a5284e 3123 link_with : [libtimesyncd_core],
5fb22561 3124 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3125 install : true,
3126 install_dir : rootlibexecdir)
5c23128d
ZJS
3127endif
3128
349cc4a5 3129if conf.get('ENABLE_MACHINED') == 1
e3c68924 3130 dbus_programs += executable(
6164ec4c
ZJS
3131 'systemd-machined',
3132 systemd_machined_sources,
3133 include_directories : includes,
3134 link_with : [libmachine_core,
3135 libshared],
5fb22561 3136 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3137 install : true,
3138 install_dir : rootlibexecdir)
3139
3140 public_programs += executable(
3141 'machinectl',
3142 'src/machine/machinectl.c',
3143 include_directories : includes,
3144 link_with : [libshared],
3145 dependencies : [threads,
3146 libxz,
ef5924aa 3147 liblz4,
c47511da
ZJS
3148 libzstd,
3149 versiondep],
5fb22561 3150 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3151 install : true,
3152 install_dir : rootbindir)
5c23128d
ZJS
3153endif
3154
349cc4a5 3155if conf.get('ENABLE_IMPORTD') == 1
e3c68924 3156 dbus_programs += executable(
6164ec4c
ZJS
3157 'systemd-importd',
3158 systemd_importd_sources,
3159 include_directories : includes,
3160 link_with : [libshared],
c47511da
ZJS
3161 dependencies : [threads,
3162 versiondep],
5fb22561 3163 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3164 install : true,
3165 install_dir : rootlibexecdir)
3166
3167 systemd_pull = executable(
3168 'systemd-pull',
3169 systemd_pull_sources,
3170 include_directories : includes,
b93f018f
ZJS
3171 link_with : [libshared,
3172 lib_import_common],
c47511da 3173 dependencies : [libcurl,
6214d42b 3174 lib_openssl_or_gcrypt,
6164ec4c
ZJS
3175 libz,
3176 libbzip2,
c47511da
ZJS
3177 libxz,
3178 versiondep],
5fb22561 3179 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3180 install : true,
3181 install_dir : rootlibexecdir)
3182
3183 systemd_import = executable(
3184 'systemd-import',
3185 systemd_import_sources,
3186 include_directories : includes,
b93f018f
ZJS
3187 link_with : [libshared,
3188 lib_import_common],
6164ec4c
ZJS
3189 dependencies : [libcurl,
3190 libz,
3191 libbzip2,
c47511da
ZJS
3192 libxz,
3193 versiondep],
5fb22561 3194 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3195 install : true,
3196 install_dir : rootlibexecdir)
3197
3198 systemd_import_fs = executable(
3199 'systemd-import-fs',
3200 systemd_import_fs_sources,
3201 include_directories : includes,
b93f018f
ZJS
3202 link_with : [libshared,
3203 lib_import_common],
3a21c554 3204 dependencies : [versiondep],
5fb22561 3205 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3206 install : true,
3207 install_dir : rootlibexecdir)
3208
3209 systemd_export = executable(
3210 'systemd-export',
3211 systemd_export_sources,
3212 include_directories : includes,
b93f018f
ZJS
3213 link_with : [libshared,
3214 lib_import_common],
6164ec4c
ZJS
3215 dependencies : [libcurl,
3216 libz,
3217 libbzip2,
c47511da
ZJS
3218 libxz,
3219 versiondep],
5fb22561 3220 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3221 install : true,
3222 install_dir : rootlibexecdir)
1d7579c4
LP
3223
3224 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
37efbbd8
ZJS
3225endif
3226
349cc4a5 3227if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
6164ec4c
ZJS
3228 public_programs += executable(
3229 'systemd-journal-upload',
3230 systemd_journal_upload_sources,
3231 include_directories : includes,
3232 link_with : [libshared],
c47511da 3233 dependencies : [threads,
6164ec4c
ZJS
3234 libcurl,
3235 libgnutls,
3236 libxz,
ef5924aa 3237 liblz4,
c47511da
ZJS
3238 libzstd,
3239 versiondep],
5fb22561 3240 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3241 install : true,
3242 install_dir : rootlibexecdir)
5c23128d
ZJS
3243endif
3244
349cc4a5 3245if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
6164ec4c
ZJS
3246 public_programs += executable(
3247 'systemd-journal-remote',
3248 systemd_journal_remote_sources,
035b0f8f 3249 include_directories : journal_includes,
6164ec4c
ZJS
3250 link_with : [libshared,
3251 libsystemd_journal_remote],
3252 dependencies : [threads,
3253 libmicrohttpd,
3254 libgnutls,
3255 libxz,
ef5924aa 3256 liblz4,
c47511da
ZJS
3257 libzstd,
3258 versiondep],
5fb22561 3259 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3260 install : true,
3261 install_dir : rootlibexecdir)
3262
3263 public_programs += executable(
3264 'systemd-journal-gatewayd',
3265 systemd_journal_gatewayd_sources,
035b0f8f 3266 include_directories : journal_includes,
6164ec4c
ZJS
3267 link_with : [libshared],
3268 dependencies : [threads,
3269 libmicrohttpd,
3270 libgnutls,
3271 libxz,
ef5924aa 3272 liblz4,
c47511da
ZJS
3273 libzstd,
3274 versiondep],
5fb22561 3275 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3276 install : true,
3277 install_dir : rootlibexecdir)
5c23128d
ZJS
3278endif
3279
349cc4a5 3280if conf.get('ENABLE_COREDUMP') == 1
6164ec4c
ZJS
3281 executable(
3282 'systemd-coredump',
3283 systemd_coredump_sources,
3284 include_directories : includes,
acc50c92
LP
3285 link_with : [libshared,
3286 libbasic_compress],
6164ec4c
ZJS
3287 dependencies : [threads,
3288 libacl,
6164ec4c 3289 libxz,
ef5924aa 3290 liblz4,
c47511da
ZJS
3291 libzstd,
3292 versiondep],
5fb22561 3293 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3294 install : true,
3295 install_dir : rootlibexecdir)
3296
3297 public_programs += executable(
3298 'coredumpctl',
3299 coredumpctl_sources,
3300 include_directories : includes,
acc50c92
LP
3301 link_with : [libshared,
3302 libbasic_compress],
6164ec4c
ZJS
3303 dependencies : [threads,
3304 libxz,
ef5924aa 3305 liblz4,
c47511da
ZJS
3306 libzstd,
3307 versiondep],
5fb22561 3308 install_rpath : rootpkglibdir,
6164ec4c 3309 install : true)
5c23128d
ZJS
3310endif
3311
9b4abc69 3312if conf.get('ENABLE_PSTORE') == 1
6164ec4c
ZJS
3313 executable(
3314 'systemd-pstore',
3315 systemd_pstore_sources,
3316 include_directories : includes,
3317 link_with : [libshared],
3318 dependencies : [threads,
3319 libacl,
6164ec4c 3320 libxz,
ef5924aa 3321 liblz4,
c47511da
ZJS
3322 libzstd,
3323 versiondep],
5fb22561 3324 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3325 install : true,
3326 install_dir : rootlibexecdir)
9b4abc69
ED
3327endif
3328
9de5e321 3329if conf.get('ENABLE_OOMD') == 1
e3c68924 3330 dbus_programs += executable('systemd-oomd',
9de5e321
AZ
3331 systemd_oomd_sources,
3332 include_directories : includes,
3333 link_with : [libshared],
c47511da
ZJS
3334 dependencies : [libatomic,
3335 versiondep],
5fb22561 3336 install_rpath : rootpkglibdir,
9de5e321
AZ
3337 install : true,
3338 install_dir : rootlibexecdir)
5c616ecf
AZ
3339
3340 public_programs += executable(
ba081955
ZJS
3341 'oomctl',
3342 oomctl_sources,
3343 include_directories : includes,
3344 link_with : [libshared],
c47511da 3345 dependencies : [versiondep],
5fb22561 3346 install_rpath : rootpkglibdir,
cfd4c84a 3347 install : true)
9de5e321
AZ
3348endif
3349
349cc4a5 3350if conf.get('ENABLE_BINFMT') == 1
6164ec4c
ZJS
3351 public_programs += executable(
3352 'systemd-binfmt',
3353 'src/binfmt/binfmt.c',
3354 include_directories : includes,
3355 link_with : [libshared],
3a21c554 3356 dependencies : [versiondep],
5fb22561 3357 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3358 install : true,
3359 install_dir : rootlibexecdir)
37efbbd8 3360
7c22f07c
ZJS
3361 meson.add_install_script('sh', '-c',
3362 mkdir_p.format(binfmtdir))
d7aa78c3 3363 if install_sysconfdir
7c22f07c 3364 meson.add_install_script('sh', '-c',
fce9abb2 3365 mkdir_p.format(sysconfdir / 'binfmt.d'))
d7aa78c3 3366 endif
37efbbd8
ZJS
3367endif
3368
43cc7a3e
LP
3369if conf.get('ENABLE_SYSUPDATE') == 1
3370 exe = executable(
3371 'systemd-sysupdate',
3372 systemd_sysupdate_sources,
3373 include_directories : includes,
f8cf3d19
LP
3374 link_with : [libshared,
3375 libshared_fdisk],
43cc7a3e
LP
3376 dependencies : [threads,
3377 libblkid,
3378 libfdisk,
c47511da
ZJS
3379 libopenssl,
3380 versiondep],
5fb22561 3381 install_rpath : rootpkglibdir,
43cc7a3e
LP
3382 install : true,
3383 install_dir : rootlibexecdir)
3384 public_programs += exe
3385endif
3386
349cc4a5 3387if conf.get('ENABLE_VCONSOLE') == 1
6164ec4c
ZJS
3388 executable(
3389 'systemd-vconsole-setup',
3390 'src/vconsole/vconsole-setup.c',
3391 include_directories : includes,
3392 link_with : [libshared],
5fb22561 3393 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3394 install : true,
3395 install_dir : rootlibexecdir)
5c23128d
ZJS
3396endif
3397
349cc4a5 3398if conf.get('ENABLE_RANDOMSEED') == 1
6164ec4c
ZJS
3399 executable(
3400 'systemd-random-seed',
3401 'src/random-seed/random-seed.c',
3402 include_directories : includes,
3403 link_with : [libshared],
3a21c554 3404 dependencies : [versiondep],
5fb22561 3405 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3406 install : true,
3407 install_dir : rootlibexecdir)
5c23128d
ZJS
3408endif
3409
349cc4a5 3410if conf.get('ENABLE_FIRSTBOOT') == 1
3761002e 3411 public_programs += executable(
6164ec4c
ZJS
3412 'systemd-firstboot',
3413 'src/firstboot/firstboot.c',
3414 include_directories : includes,
3415 link_with : [libshared],
c47511da
ZJS
3416 dependencies : [libcrypt,
3417 versiondep],
5fb22561 3418 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3419 install : true,
3420 install_dir : rootbindir)
3421endif
3422
3423executable(
3424 'systemd-remount-fs',
3425 'src/remount-fs/remount-fs.c',
3426 include_directories : includes,
bac11cd6 3427 link_with : [libshared],
c47511da 3428 dependencies : [versiondep],
5fb22561 3429 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3430 install : true,
3431 install_dir : rootlibexecdir)
5c23128d 3432
6164ec4c
ZJS
3433executable(
3434 'systemd-machine-id-setup',
3435 'src/machine-id-setup/machine-id-setup-main.c',
3436 include_directories : includes,
bac11cd6 3437 link_with : [libshared],
c47511da 3438 dependencies : [versiondep],
5fb22561 3439 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3440 install : true,
3441 install_dir : rootbindir)
5c23128d 3442
6164ec4c
ZJS
3443executable(
3444 'systemd-fsck',
3445 'src/fsck/fsck.c',
3446 include_directories : includes,
3447 link_with : [libshared],
c47511da 3448 dependencies : [versiondep],
5fb22561 3449 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3450 install : true,
3451 install_dir : rootlibexecdir)
5c23128d 3452
c47511da
ZJS
3453executable(
3454 'systemd-growfs',
3455 'src/partition/growfs.c',
3456 include_directories : includes,
3457 link_with : [libshared],
3458 dependencies : [versiondep],
3459 install_rpath : rootpkglibdir,
3460 install : true,
3461 install_dir : rootlibexecdir)
80750adb 3462
6164ec4c
ZJS
3463executable(
3464 'systemd-makefs',
3465 'src/partition/makefs.c',
3466 include_directories : includes,
3467 link_with : [libshared],
c47511da 3468 dependencies : [versiondep],
5fb22561 3469 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3470 install : true,
3471 install_dir : rootlibexecdir)
b7f28ac5 3472
6164ec4c
ZJS
3473executable(
3474 'systemd-sleep',
3475 'src/sleep/sleep.c',
3476 include_directories : includes,
3477 link_with : [libshared],
c47511da 3478 dependencies : [versiondep],
5fb22561 3479 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3480 install : true,
3481 install_dir : rootlibexecdir)
5c23128d 3482
225d08b8 3483if install_sysconfdir_samples
d7aa78c3
JT
3484 install_data('src/sleep/sleep.conf',
3485 install_dir : pkgsysconfdir)
3486endif
d25e127d 3487
6164ec4c
ZJS
3488public_programs += executable(
3489 'systemd-sysctl',
3490 'src/sysctl/sysctl.c',
3491 include_directories : includes,
3492 link_with : [libshared],
c47511da 3493 dependencies : [versiondep],
5fb22561 3494 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3495 install : true,
3496 install_dir : rootlibexecdir)
5c23128d 3497
251dc2f1 3498public_programs += executable(
6164ec4c
ZJS
3499 'systemd-ac-power',
3500 'src/ac-power/ac-power.c',
3501 include_directories : includes,
3502 link_with : [libshared],
c47511da 3503 dependencies : [versiondep],
5fb22561 3504 install_rpath : rootpkglibdir,
251dc2f1 3505 install : true)
5c23128d 3506
6164ec4c
ZJS
3507public_programs += executable(
3508 'systemd-detect-virt',
3509 'src/detect-virt/detect-virt.c',
3510 include_directories : includes,
3511 link_with : [libshared],
c47511da 3512 dependencies : [versiondep],
5fb22561 3513 install_rpath : rootpkglibdir,
6164ec4c 3514 install : true)
5c23128d 3515
6164ec4c
ZJS
3516public_programs += executable(
3517 'systemd-delta',
3518 'src/delta/delta.c',
3519 include_directories : includes,
3520 link_with : [libshared],
c47511da 3521 dependencies : [versiondep],
5fb22561 3522 install_rpath : rootpkglibdir,
6164ec4c 3523 install : true)
5c23128d 3524
6164ec4c
ZJS
3525public_programs += executable(
3526 'systemd-escape',
3527 'src/escape/escape.c',
3528 include_directories : includes,
3529 link_with : [libshared],
c47511da 3530 dependencies : [versiondep],
5fb22561 3531 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3532 install : true,
3533 install_dir : rootbindir)
3534
3535public_programs += executable(
3536 'systemd-notify',
3537 'src/notify/notify.c',
3538 include_directories : includes,
3539 link_with : [libshared],
c47511da 3540 dependencies : [versiondep],
5fb22561 3541 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3542 install : true,
3543 install_dir : rootbindir)
3544
5945640e
LP
3545public_programs += executable(
3546 'systemd-creds',
3547 'src/creds/creds.c',
3548 include_directories : includes,
3549 link_with : [libshared],
3550 dependencies : [threads,
c47511da
ZJS
3551 libopenssl,
3552 versiondep],
5fb22561 3553 install_rpath : rootpkglibdir,
5945640e
LP
3554 install : true,
3555 install_dir : rootbindir)
3556
6164ec4c
ZJS
3557executable(
3558 'systemd-volatile-root',
3559 'src/volatile-root/volatile-root.c',
3560 include_directories : includes,
3561 link_with : [libshared],
5fb22561 3562 install_rpath : rootpkglibdir,
cdf7ad38 3563 install : conf.get('ENABLE_INITRD') == 1,
6164ec4c
ZJS
3564 install_dir : rootlibexecdir)
3565
3566executable(
3567 'systemd-cgroups-agent',
3568 'src/cgroups-agent/cgroups-agent.c',
3569 include_directories : includes,
3570 link_with : [libshared],
5fb22561 3571 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3572 install : true,
3573 install_dir : rootlibexecdir)
3574
2a2d002f 3575systemd_id128 = executable(
6164ec4c
ZJS
3576 'systemd-id128',
3577 'src/id128/id128.c',
3578 include_directories : includes,
3579 link_with : [libshared],
3a21c554 3580 dependencies : [versiondep],
5fb22561 3581 install_rpath : rootpkglibdir,
6164ec4c 3582 install : true)
2a2d002f
ZJS
3583public_programs += systemd_id128
3584
3585if want_tests != 'false'
3586 test('test-systemctl-enable',
3587 test_systemctl_enable_sh,
3588 # https://github.com/mesonbuild/meson/issues/2681
3589 args : [systemctl.full_path(),
3590 systemd_id128.full_path()])
3591endif
6164ec4c
ZJS
3592
3593public_programs += executable(
3594 'systemd-path',
3595 'src/path/path.c',
3596 include_directories : includes,
3597 link_with : [libshared],
3a21c554 3598 dependencies : [versiondep],
5fb22561 3599 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3600 install : true)
3601
3602public_programs += executable(
3603 'systemd-ask-password',
3604 'src/ask-password/ask-password.c',
3605 include_directories : includes,
3606 link_with : [libshared],
3a21c554 3607 dependencies : [versiondep],
5fb22561 3608 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3609 install : true,
3610 install_dir : rootbindir)
3611
3612executable(
3613 'systemd-reply-password',
3614 'src/reply-password/reply-password.c',
3615 include_directories : includes,
3616 link_with : [libshared],
5fb22561 3617 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3618 install : true,
3619 install_dir : rootlibexecdir)
3620
3621public_programs += executable(
3622 'systemd-tty-ask-password-agent',
3623 'src/tty-ask-password-agent/tty-ask-password-agent.c',
3624 include_directories : includes,
3625 link_with : [libshared],
3a21c554 3626 dependencies : [versiondep],
5fb22561 3627 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3628 install : true,
3629 install_dir : rootbindir)
3630
3631public_programs += executable(
3632 'systemd-cgls',
3633 'src/cgls/cgls.c',
3634 include_directories : includes,
3635 link_with : [libshared],
3a21c554 3636 dependencies : [versiondep],
5fb22561 3637 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3638 install : true)
3639
3640public_programs += executable(
3641 'systemd-cgtop',
3642 'src/cgtop/cgtop.c',
3643 include_directories : includes,
3644 link_with : [libshared],
3a21c554 3645 dependencies : [versiondep],
5fb22561 3646 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3647 install : true)
3648
3649executable(
3650 'systemd-initctl',
3651 'src/initctl/initctl.c',
3652 include_directories : includes,
3653 link_with : [libshared],
5fb22561 3654 install_rpath : rootpkglibdir,
6589a569 3655 install : (conf.get('HAVE_SYSV_COMPAT') == 1),
6164ec4c 3656 install_dir : rootlibexecdir)
5c23128d 3657
6164ec4c
ZJS
3658public_programs += executable(
3659 'systemd-mount',
3660 'src/mount/mount-tool.c',
3661 include_directories : includes,
3662 link_with : [libshared],
c47511da
ZJS
3663 dependencies: [libmount,
3664 versiondep],
5fb22561 3665 install_rpath : rootpkglibdir,
6164ec4c 3666 install : true)
5c23128d 3667
7b76fce1 3668meson.add_install_script(meson_make_symlink,
fce9abb2 3669 'systemd-mount', bindir / 'systemd-umount')
7b76fce1 3670
6164ec4c
ZJS
3671public_programs += executable(
3672 'systemd-run',
3673 'src/run/run.c',
3674 include_directories : includes,
3675 link_with : [libshared],
c47511da 3676 dependencies : [versiondep],
5fb22561 3677 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3678 install : true)
3679
3680public_programs += executable(
3681 'systemd-stdio-bridge',
3682 'src/stdio-bridge/stdio-bridge.c',
3683 include_directories : includes,
3684 link_with : [libshared],
c47511da
ZJS
3685 dependencies : [versiondep,
3686 versiondep],
5fb22561 3687 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3688 install : true)
3689
3690public_programs += executable(
3691 'busctl',
f98df767 3692 busctl_sources,
6164ec4c
ZJS
3693 include_directories : includes,
3694 link_with : [libshared],
7c4bd9ac 3695 dependencies : [versiondep],
5fb22561 3696 install_rpath : rootpkglibdir,
6164ec4c 3697 install : true)
5c23128d 3698
bd7e6aa7
ZJS
3699if enable_sysusers
3700 exe = executable(
6164ec4c
ZJS
3701 'systemd-sysusers',
3702 'src/sysusers/sysusers.c',
3703 include_directories : includes,
3704 link_with : [libshared],
c47511da 3705 dependencies : [versiondep],
5fb22561 3706 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3707 install : true,
3708 install_dir : rootbindir)
bd7e6aa7
ZJS
3709 public_programs += exe
3710
3711 if want_tests != 'false'
3712 test('test-sysusers',
3713 test_sysusers_sh,
3714 # https://github.com/mesonbuild/meson/issues/2681
3715 args : exe.full_path())
3716 endif
8ef8f3d5
FB
3717
3718 if have_standalone_binaries
bd7e6aa7 3719 exe = executable(
8ef8f3d5
FB
3720 'systemd-sysusers.standalone',
3721 'src/sysusers/sysusers.c',
3722 include_directories : includes,
3537577c 3723 c_args : '-DSTANDALONE',
8ef8f3d5
FB
3724 link_with : [libshared_static,
3725 libbasic,
3726 libbasic_gcrypt,
99b9f8fd 3727 libsystemd_static],
c47511da 3728 dependencies : [versiondep],
8ef8f3d5
FB
3729 install : true,
3730 install_dir : rootbindir)
bd7e6aa7
ZJS
3731 public_programs += exe
3732
3733 if want_tests != 'false'
3734 test('test-sysusers.standalone',
3735 test_sysusers_sh,
3736 # https://github.com/mesonbuild/meson/issues/2681
3737 args : exe.full_path())
3738 endif
8ef8f3d5 3739 endif
5c23128d
ZJS
3740endif
3741
349cc4a5 3742if conf.get('ENABLE_TMPFILES') == 1
6164ec4c
ZJS
3743 exe = executable(
3744 'systemd-tmpfiles',
db64ba81 3745 systemd_tmpfiles_sources,
6164ec4c
ZJS
3746 include_directories : includes,
3747 link_with : [libshared],
c47511da
ZJS
3748 dependencies : [libacl,
3749 versiondep],
5fb22561 3750 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3751 install : true,
3752 install_dir : rootbindir)
5a8b1640 3753 public_programs += exe
d9daae55 3754
938be089
ZJS
3755 if want_tests != 'false'
3756 test('test-systemd-tmpfiles',
3757 test_systemd_tmpfiles_py,
3758 # https://github.com/mesonbuild/meson/issues/2681
3759 args : exe.full_path())
3760 endif
db64ba81
FB
3761
3762 if have_standalone_binaries
bf93f24a 3763 exe = executable(
db64ba81
FB
3764 'systemd-tmpfiles.standalone',
3765 systemd_tmpfiles_sources,
3766 include_directories : includes,
3537577c 3767 c_args : '-DSTANDALONE',
db64ba81
FB
3768 link_with : [libshared_static,
3769 libbasic,
3770 libbasic_gcrypt,
99b9f8fd 3771 libsystemd_static],
c47511da
ZJS
3772 dependencies : [libacl,
3773 versiondep],
db64ba81
FB
3774 install : true,
3775 install_dir : rootbindir)
bf93f24a
MG
3776 public_programs += exe
3777
3778 if want_tests != 'false'
3779 test('test-systemd-tmpfiles.standalone',
3780 test_systemd_tmpfiles_py,
3781 # https://github.com/mesonbuild/meson/issues/2681
3782 args : exe.full_path())
3783 endif
db64ba81 3784 endif
5c23128d
ZJS
3785endif
3786
349cc4a5 3787if conf.get('ENABLE_HWDB') == 1
ecd1bfdd 3788 systemd_hwdb = executable(
6164ec4c
ZJS
3789 'systemd-hwdb',
3790 'src/hwdb/hwdb.c',
6164ec4c 3791 include_directories : includes,
e4b127e2 3792 link_with : udev_link_with,
3a21c554 3793 dependencies : [versiondep],
6164ec4c
ZJS
3794 install_rpath : udev_rpath,
3795 install : true,
3796 install_dir : rootbindir)
ecd1bfdd
ZJS
3797 public_programs += systemd_hwdb
3798
3799 if want_tests != 'false'
3800 test('hwdb-test',
3801 hwdb_test_sh,
14056a52 3802 suite : 'dist-check',
ecd1bfdd
ZJS
3803 args : [systemd_hwdb.full_path()],
3804 timeout : 90)
3805 endif
37efbbd8
ZJS
3806endif
3807
349cc4a5 3808if conf.get('ENABLE_QUOTACHECK') == 1
6164ec4c
ZJS
3809 executable(
3810 'systemd-quotacheck',
3811 'src/quotacheck/quotacheck.c',
3812 include_directories : includes,
3813 link_with : [libshared],
5fb22561 3814 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3815 install : true,
3816 install_dir : rootlibexecdir)
3817endif
3818
3819public_programs += executable(
3820 'systemd-socket-proxyd',
3821 'src/socket-proxy/socket-proxyd.c',
3822 include_directories : includes,
3823 link_with : [libshared],
c47511da
ZJS
3824 dependencies : [threads,
3825 versiondep],
5fb22561 3826 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3827 install : true,
3828 install_dir : rootlibexecdir)
5c23128d 3829
9b264c1d 3830udevadm = executable(
6164ec4c
ZJS
3831 'udevadm',
3832 udevadm_sources,
6164ec4c 3833 include_directories : includes,
e4b127e2 3834 link_with : [libudevd_core],
c47511da 3835 dependencies : [threads,
6164ec4c
ZJS
3836 libkmod,
3837 libidn,
3838 libacl,
c47511da
ZJS
3839 libblkid,
3840 versiondep],
6164ec4c
ZJS
3841 install_rpath : udev_rpath,
3842 install : true,
3843 install_dir : rootbindir)
9b264c1d
FS
3844public_programs += udevadm
3845
3846if conf.get('ENABLE_REPART') == 1
3847 exe = executable(
3848 'systemd-repart',
3849 systemd_repart_sources,
3850 include_directories : includes,
f8cf3d19
LP
3851 link_with : [libshared,
3852 libshared_fdisk],
9b264c1d
FS
3853 dependencies : [threads,
3854 libblkid,
b456191d 3855 libfdisk,
c47511da
ZJS
3856 libopenssl,
3857 versiondep],
5fb22561 3858 install_rpath : rootpkglibdir,
9b264c1d
FS
3859 install : true,
3860 install_dir : rootbindir)
3861 public_programs += exe
3c3e14a7
ZJS
3862
3863 if have_standalone_binaries
3864 exe = executable(
3865 'systemd-repart.standalone',
3866 systemd_repart_sources,
3867 include_directories : includes,
3868 c_args : '-DSTANDALONE',
3869 link_with : [libshared_static,
3870 libbasic,
3871 libbasic_gcrypt,
f8cf3d19
LP
3872 libsystemd_static,
3873 libshared_fdisk],
3c3e14a7
ZJS
3874 dependencies : [threads,
3875 libblkid,
3876 libfdisk,
c47511da
ZJS
3877 libopenssl,
3878 versiondep],
3c3e14a7
ZJS
3879 install_rpath : rootpkglibdir,
3880 install : true,
3881 install_dir : rootbindir)
9702d824 3882 public_programs += exe
3c3e14a7 3883 endif
9b264c1d 3884endif
6164ec4c
ZJS
3885
3886executable(
3887 'systemd-shutdown',
3888 systemd_shutdown_sources,
3889 include_directories : includes,
bac11cd6 3890 link_with : [libshared],
c47511da
ZJS
3891 dependencies : [libmount,
3892 versiondep],
5fb22561 3893 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3894 install : true,
3895 install_dir : rootlibexecdir)
3896
6ed3aca5
ZJS
3897if have_standalone_binaries
3898 executable(
3899 'systemd-shutdown.standalone',
3900 systemd_shutdown_sources,
3901 include_directories : includes,
3902 c_args : '-DSTANDALONE',
3903 link_with : [libshared_static,
3904 libbasic,
3905 libsystemd_static],
3906 dependencies : [libmount,
3907 versiondep],
3908 install_rpath : rootpkglibdir,
3909 install : true,
3910 install_dir : rootlibexecdir)
3911endif
3912
6164ec4c
ZJS
3913executable(
3914 'systemd-update-done',
3915 'src/update-done/update-done.c',
3916 include_directories : includes,
3917 link_with : [libshared],
c47511da 3918 dependencies : [versiondep],
5fb22561 3919 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3920 install : true,
3921 install_dir : rootlibexecdir)
3922
3923executable(
3924 'systemd-update-utmp',
3925 'src/update-utmp/update-utmp.c',
3926 include_directories : includes,
3927 link_with : [libshared],
c47511da
ZJS
3928 dependencies : [libaudit,
3929 versiondep],
5fb22561 3930 install_rpath : rootpkglibdir,
55678b9e 3931 install : (conf.get('ENABLE_UTMP') == 1),
6164ec4c 3932 install_dir : rootlibexecdir)
5c23128d 3933
349cc4a5 3934if conf.get('HAVE_KMOD') == 1
6164ec4c
ZJS
3935 executable(
3936 'systemd-modules-load',
3937 'src/modules-load/modules-load.c',
3938 include_directories : includes,
3939 link_with : [libshared],
c47511da
ZJS
3940 dependencies : [libkmod,
3941 versiondep],
5fb22561 3942 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3943 install : true,
3944 install_dir : rootlibexecdir)
94e75a54 3945
7c22f07c
ZJS
3946 meson.add_install_script('sh', '-c',
3947 mkdir_p.format(modulesloaddir))
d7aa78c3 3948 if install_sysconfdir
7c22f07c 3949 meson.add_install_script('sh', '-c',
fce9abb2 3950 mkdir_p.format(sysconfdir / 'modules-load.d'))
d7aa78c3 3951 endif
5c23128d
ZJS
3952endif
3953
6164ec4c
ZJS
3954public_programs += executable(
3955 'systemd-nspawn',
3956 systemd_nspawn_sources,
3957 include_directories : includes,
bac11cd6 3958 link_with : [libnspawn_core,
6164ec4c
ZJS
3959 libshared],
3960 dependencies : [libblkid,
c47511da
ZJS
3961 libseccomp,
3962 versiondep],
5fb22561 3963 install_rpath : rootpkglibdir,
6164ec4c 3964 install : true)
5c23128d 3965
349cc4a5 3966if conf.get('ENABLE_NETWORKD') == 1
9ff2b35f 3967 dbus_programs += executable(
6164ec4c
ZJS
3968 'systemd-networkd',
3969 systemd_networkd_sources,
8d40961c 3970 include_directories : network_includes,
6164ec4c
ZJS
3971 link_with : [libnetworkd_core,
3972 libsystemd_network,
6164ec4c 3973 networkd_link_with],
c47511da
ZJS
3974 dependencies : [threads,
3975 versiondep],
5fb22561 3976 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3977 install : true,
3978 install_dir : rootlibexecdir)
3979
3761002e 3980 public_programs += executable(
6164ec4c
ZJS
3981 'systemd-networkd-wait-online',
3982 systemd_networkd_wait_online_sources,
3983 include_directories : includes,
8d40961c 3984 link_with : [networkd_link_with],
c47511da 3985 dependencies : [versiondep],
5fb22561 3986 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3987 install : true,
3988 install_dir : rootlibexecdir)
3989
3990 public_programs += executable(
3991 'networkctl',
3992 networkctl_sources,
8d40961c 3993 include_directories : libsystemd_network_includes,
6164ec4c
ZJS
3994 link_with : [libsystemd_network,
3995 networkd_link_with],
c47511da 3996 dependencies : [versiondep],
5fb22561 3997 install_rpath : rootpkglibdir,
6164ec4c
ZJS
3998 install : true,
3999 install_dir : rootbindir)
987dd89c 4000endif
6164ec4c 4001
987dd89c
YW
4002exe = executable(
4003 'systemd-network-generator',
4004 network_generator_sources,
4005 include_directories : includes,
4006 link_with : [networkd_link_with],
c47511da 4007 dependencies : [versiondep],
5fb22561 4008 install_rpath : rootpkglibdir,
987dd89c
YW
4009 install : true,
4010 install_dir : rootlibexecdir)
fbaa1137 4011
987dd89c
YW
4012if want_tests != 'false'
4013 test('test-network-generator-conversion',
4014 test_network_generator_conversion_sh,
4015 # https://github.com/mesonbuild/meson/issues/2681
e93ada98
DDM
4016 args : exe.full_path(),
4017 depends : exe)
dcfe072a 4018endif
e821f6a9 4019
6164ec4c
ZJS
4020executable(
4021 'systemd-sulogin-shell',
73e994f2 4022 'src/sulogin-shell/sulogin-shell.c',
6164ec4c
ZJS
4023 include_directories : includes,
4024 link_with : [libshared],
c47511da 4025 dependencies : [versiondep],
5fb22561 4026 install_rpath : rootpkglibdir,
6164ec4c
ZJS
4027 install : true,
4028 install_dir : rootlibexecdir)
e821f6a9 4029
f875e6bc 4030exe = custom_target(
99d8cbce
ZJS
4031 'kernel-install',
4032 input : kernel_install_in,
4033 output : 'kernel-install',
4034 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
4035 install : want_kernel_install,
4036 install_mode : 'rwxr-xr-x',
4037 install_dir : bindir)
f875e6bc
ZJS
4038public_programs += exe
4039
cc77a565 4040if want_tests != 'false' and want_kernel_install
f875e6bc
ZJS
4041 test('test-kernel-install',
4042 test_kernel_install_sh,
8702496b 4043 env : test_env,
f875e6bc
ZJS
4044 args : [exe.full_path(), loaderentry_install])
4045endif
99d8cbce 4046
30ec2eae
ZJS
4047if want_ukify
4048 exe = custom_target(
4049 'ukify',
4050 input : 'src/ukify/ukify.py',
4051 output : 'ukify',
4052 command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
4053 install : true,
4054 install_mode : 'rwxr-xr-x',
4055 install_dir : rootlibexecdir)
4056 public_programs += exe
4057endif
4058
69e96427
ZJS
4059############################################################
4060
e93ada98 4061runtest_env = custom_target(
e2d41370
FB
4062 'systemd-runtest.env',
4063 output : 'systemd-runtest.env',
0f4c4f38
ZJS
4064 command : [sh, '-c',
4065 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
fce9abb2
ZJS
4066 project_source_root / 'test',
4067 project_build_root / 'catalog')],
e93ada98 4068 depends : catalogs,
e2d41370
FB
4069 build_by_default : true)
4070
a626cb15
ZJS
4071test_cflags = ['-DTEST_CODE=1']
4072# We intentionally do not do inline initializations with definitions for a
4073# bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
4074# use the variable unexpectedly. This triggers a lot of maybe-uninitialized
4075# false positives when the combination of -O2 and -flto is used. Suppress them.
b528a628 4076if '-O2' in c_args and '-flto=auto' in c_args
a626cb15
ZJS
4077 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
4078endif
4079
c12e10d7
JJ
4080foreach test : simple_tests
4081 tests += [ [[test]] ]
4082endforeach
4083
69e96427 4084foreach tuple : tests
37efbbd8 4085 sources = tuple[0]
5acb3cab
YW
4086 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
4087 dependencies = tuple.length() > 2 ? tuple[2] : []
4088 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
4089 condition = tuple.length() > 4 ? tuple[4] : ''
4090 type = tuple.length() > 5 ? tuple[5] : ''
4091 defs = tuple.length() > 6 ? tuple[6] : []
a626cb15 4092 defs += test_cflags
5acb3cab 4093 parallel = tuple.length() > 7 ? tuple[7] : true
37efbbd8
ZJS
4094 timeout = 30
4095
e1eeebbb
JJ
4096 # FIXME: Use fs.stem() with meson >= 0.54.0
4097 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
37efbbd8
ZJS
4098 if type.startswith('timeout=')
4099 timeout = type.split('=')[1].to_int()
4100 type = ''
4101 endif
3b2bdd62 4102
c3191c6d
DDM
4103 suite = fs.name(fs.parent('@0@'.format(sources[0])))
4104 # FIXME: Use str.replace() with meson >= 0.58.0
4105 suite = suite.split('sd-')[-1]
4106
3b2bdd62 4107 if condition == '' or conf.get(condition) == 1
37efbbd8
ZJS
4108 exe = executable(
4109 name,
4110 sources,
4111 include_directories : incs,
4112 link_with : link_with,
60722ad7
ZJS
4113 dependencies : [versiondep,
4114 dependencies],
37efbbd8 4115 c_args : defs,
3b2bdd62 4116 build_by_default : want_tests != 'false',
5fb22561 4117 install_rpath : rootpkglibdir,
7cdd9783 4118 install : install_tests,
e93ada98
DDM
4119 install_dir : testsdir / type,
4120 link_depends : runtest_env)
37efbbd8
ZJS
4121
4122 if type == 'manual'
4123 message('@0@ is a manual test'.format(name))
4124 elif type == 'unsafe' and want_tests != 'unsafe'
4125 message('@0@ is an unsafe test'.format(name))
3b2bdd62 4126 elif want_tests != 'false'
37efbbd8
ZJS
4127 test(name, exe,
4128 env : test_env,
c3191c6d 4129 timeout : timeout,
57c15ca3
YW
4130 suite : suite,
4131 is_parallel : parallel)
37efbbd8
ZJS
4132 endif
4133 else
4134 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
4135 endif
69e96427
ZJS
4136endforeach
4137
0632b4cd 4138exe = executable(
37efbbd8
ZJS
4139 'test-libsystemd-sym',
4140 test_libsystemd_sym_c,
4141 include_directories : includes,
4142 link_with : [libsystemd],
fd1939fb 4143 build_by_default : want_tests != 'false',
37efbbd8
ZJS
4144 install : install_tests,
4145 install_dir : testsdir)
938be089
ZJS
4146if want_tests != 'false'
4147 test('test-libsystemd-sym', exe)
4148endif
37ab1a25 4149
0632b4cd
ZJS
4150exe = executable(
4151 'test-libsystemd-static-sym',
4152 test_libsystemd_sym_c,
4153 include_directories : includes,
0632b4cd
ZJS
4154 link_with : [install_libsystemd_static],
4155 dependencies : [threads], # threads is already included in dependencies on the library,
4156 # but does not seem to get propagated. Add here as a work-around.
fd1939fb 4157 build_by_default : want_tests != 'false' and static_libsystemd_pic,
20f3d32d 4158 install : install_tests and static_libsystemd_pic,
0632b4cd 4159 install_dir : testsdir)
938be089 4160if want_tests != 'false' and static_libsystemd_pic
0632b4cd
ZJS
4161 test('test-libsystemd-static-sym', exe)
4162endif
37ab1a25 4163
0632b4cd 4164exe = executable(
37efbbd8
ZJS
4165 'test-libudev-sym',
4166 test_libudev_sym_c,
e4b127e2 4167 include_directories : libudev_includes,
a626cb15 4168 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
37efbbd8 4169 link_with : [libudev],
fd1939fb 4170 build_by_default : want_tests != 'false',
37efbbd8
ZJS
4171 install : install_tests,
4172 install_dir : testsdir)
938be089
ZJS
4173if want_tests != 'false'
4174 test('test-libudev-sym', exe)
4175endif
0632b4cd
ZJS
4176
4177exe = executable(
4178 'test-libudev-static-sym',
4179 test_libudev_sym_c,
e4b127e2 4180 include_directories : libudev_includes,
a626cb15 4181 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
0632b4cd 4182 link_with : [install_libudev_static],
fd1939fb 4183 build_by_default : want_tests != 'false' and static_libudev_pic,
20f3d32d 4184 install : install_tests and static_libudev_pic,
0632b4cd 4185 install_dir : testsdir)
938be089 4186if want_tests != 'false' and static_libudev_pic
0632b4cd
ZJS
4187 test('test-libudev-static-sym', exe)
4188endif
e0bec52f 4189
69e96427 4190############################################################
5c23128d 4191
7db7d5b7
JR
4192fuzzer_exes = []
4193
7e299ffe
ZJS
4194foreach tuple : fuzzers
4195 sources = tuple[0]
5acb3cab
YW
4196 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
4197 dependencies = tuple.length() > 2 ? tuple[2] : []
4198 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
4199 defs = tuple.length() > 4 ? tuple[4] : []
7e299ffe
ZJS
4200 link_args = []
4201
4202 if want_ossfuzz
4203 dependencies += fuzzing_engine
4204 elif want_libfuzzer
4205 if fuzzing_engine.found()
9c5c4677
EV
4206 dependencies += fuzzing_engine
4207 else
7e299ffe 4208 link_args += ['-fsanitize=fuzzer']
9c5c4677 4209 endif
7e299ffe
ZJS
4210 else
4211 sources += 'src/fuzz/fuzz-main.c'
4212 endif
7e343b53 4213 sources += fuzz_generated_directives
7db7d5b7 4214
bbec46c8
JJ
4215 # FIXME: Use fs.stem() with meson >= 0.54.0
4216 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
7db7d5b7 4217
f78ad5f0 4218 exe = executable(
7e299ffe
ZJS
4219 name,
4220 sources,
4221 include_directories : [incs, include_directories('src/fuzz')],
4222 link_with : link_with,
c47511da
ZJS
4223 dependencies : [dependencies,
4224 versiondep],
a626cb15 4225 c_args : defs + test_cflags,
7e299ffe
ZJS
4226 link_args: link_args,
4227 install : false,
f78ad5f0
ZJS
4228 build_by_default : fuzzer_build)
4229 fuzzer_exes += exe
4230
7db5761d 4231 if want_tests != 'false' and name in fuzz_regression_tests
f78ad5f0
ZJS
4232 # Run the fuzz regression tests without any sanitizers enabled.
4233 # Additional invocations with sanitizers may be added below.
7e343b53
MK
4234 foreach tuple : fuzz_regression_tests[name]
4235 fuzz_dir = tuple[0]
4236 fuzz_in = tuple[1]
7db5761d
MK
4237 test('@0@_@1@'.format(name, fuzz_in),
4238 exe,
4239 suite : 'fuzzers',
7e343b53
MK
4240 args : [fuzz_dir != '' ? project_source_root / fuzz_dir / name / fuzz_in
4241 : fuzz_generated_in_dir / '@0@_@1@'.format(name, fuzz_in)])
f78ad5f0
ZJS
4242 endforeach
4243 endif
7e299ffe 4244endforeach
7db7d5b7 4245
6839ce33 4246alias_target('fuzzers', fuzzer_exes)
7db7d5b7
JR
4247
4248############################################################
4249
10783aef
ZJS
4250subdir('docs/sysvinit')
4251subdir('docs/var-log')
4252subdir('hwdb.d')
4253subdir('man')
378e9d2b 4254subdir('modprobe.d')
10783aef
ZJS
4255subdir('network')
4256subdir('presets')
4257subdir('shell-completion/bash')
4258subdir('shell-completion/zsh')
5c23128d
ZJS
4259subdir('sysctl.d')
4260subdir('sysusers.d')
4261subdir('tmpfiles.d')
4f10b807 4262subdir('units')
5c23128d 4263
5c23128d
ZJS
4264install_subdir('factory/etc',
4265 install_dir : factorydir)
623370e6 4266subdir('factory/templates')
5c23128d 4267
d7aa78c3
JT
4268if install_sysconfdir
4269 install_data('xorg/50-systemd-user.sh',
4270 install_dir : xinitrcdir)
4271endif
f09eb768 4272install_data('LICENSE.GPL2',
5c23128d 4273 'LICENSE.LGPL2.1',
f09eb768
LP
4274 'NEWS',
4275 'README',
eea98402 4276 'docs/CODING_STYLE.md',
1d1cb168 4277 'docs/DISTRO_PORTING.md',
9e825ebf 4278 'docs/ENVIRONMENT.md',
5425f8a5 4279 'docs/HACKING.md',
9e825ebf 4280 'docs/TRANSIENT-SETTINGS.md',
b6dc0d7d 4281 'docs/TRANSLATORS.md',
9e825ebf 4282 'docs/UIDS-GIDS.md',
5c23128d 4283 install_dir : docdir)
d68b342b 4284
9c6e32a2
LB
4285install_subdir('LICENSES',
4286 install_dir : docdir)
4287
7c22f07c
ZJS
4288meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
4289meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
94e75a54 4290
d68b342b
ZJS
4291############################################################
4292
2d4efd1d
LB
4293# Ensure that changes to the docs/ directory do not break the
4294# basic Github pages build. But only run it in developer mode,
4295# as it might be fragile due to changes in the tooling, and it is
4296# not generally useful for users.
4297jekyll = find_program('jekyll', required : false)
4298if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
4299 test('github-pages',
4300 jekyll,
14056a52 4301 suite : 'dist-check',
2d4efd1d 4302 args : ['build',
fce9abb2
ZJS
4303 '--source', project_source_root / 'docs',
4304 '--destination', project_build_root / '_site'])
2d4efd1d
LB
4305endif
4306
4307############################################################
4308
dd1e33c8 4309check_help = find_program('tools/check-help.sh')
ffb7406b 4310check_version = find_program('tools/check-version.sh')
005a29f2
ZJS
4311
4312foreach exec : public_programs
37efbbd8 4313 name = exec.full_path().split('/')[-1]
938be089
ZJS
4314 if want_tests != 'false'
4315 test('check-help-' + name,
dd1e33c8 4316 check_help,
14056a52 4317 suite : 'dist-check',
e93ada98
DDM
4318 args : exec.full_path(),
4319 depends: exec)
ffb7406b
ZJS
4320
4321 test('check-version-' + name,
4322 check_version,
14056a52 4323 suite : 'dist-check',
ffb7406b
ZJS
4324 args : [exec.full_path(),
4325 meson.project_version()],
4326 depends: exec)
938be089 4327 endif
005a29f2
ZJS
4328endforeach
4329
52d4d1d3 4330# Enable tests for all supported sanitizers
7db5761d 4331foreach tuple : fuzz_sanitizers
52d4d1d3
ZJS
4332 sanitizer = tuple[0]
4333 build = tuple[1]
b68dfb9e 4334
7a6397d2 4335 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
7db5761d
MK
4336 foreach fuzzer, fuzz_ins : fuzz_regression_tests
4337 name = '@0@:@1@'.format(fuzzer, sanitizer)
4338 if want_tests == 'false'
4339 message('Not compiling @0@ because tests is set to false'.format(name))
4340 continue
52d4d1d3 4341 endif
7db5761d
MK
4342 if not fuzz_tests
4343 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
4344 continue
4345 endif
4346 exe = custom_target(
4347 name,
4348 output : name,
7e343b53 4349 depends : [build] + fuzz_generated_directives,
7db5761d
MK
4350 command : [ln, '-fs',
4351 build.full_path() / fuzzer,
4352 '@OUTPUT@'],
4353 build_by_default : true)
4354
7e343b53
MK
4355 foreach tuple : fuzz_ins
4356 fuzz_dir = tuple[0]
4357 fuzz_in = tuple[1]
4358
7db5761d 4359 test('@0@_@1@_@2@'.format(fuzzer, fuzz_in, sanitizer),
52d4d1d3 4360 env,
14056a52 4361 suite : 'fuzz+san',
89767158
EV
4362 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
4363 timeout : 60,
52d4d1d3 4364 args : [exe.full_path(),
7e343b53
MK
4365 fuzz_dir != '' ? project_source_root / fuzz_dir / fuzzer / fuzz_in
4366 : fuzz_generated_in_dir / '@0@_@1@'.format(fuzzer, fuzz_in)])
7db5761d 4367 endforeach
52d4d1d3 4368 endforeach
b68dfb9e
ZJS
4369 endif
4370endforeach
4371
52d4d1d3 4372
b68dfb9e
ZJS
4373############################################################
4374
0700e8ba 4375if git.found()
37efbbd8 4376 all_files = run_command(
0f4c4f38
ZJS
4377 env, '-u', 'GIT_WORK_TREE',
4378 git, '--git-dir=@0@/.git'.format(project_source_root),
e92777d2
ZJS
4379 'ls-files', ':/*.[ch]',
4380 check : false)
4381 if all_files.returncode() == 0
4382 all_files = files(all_files.stdout().split())
4383
4384 custom_target(
4385 'tags',
4386 output : 'tags',
4387 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
4388 run_target(
4389 'ctags',
691db9a7 4390 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
e92777d2 4391 endif
d68b342b 4392endif
177929c2
ZJS
4393
4394if git.found()
dd1e33c8 4395 git_contrib_sh = find_program('tools/git-contrib.sh')
a923e085 4396 run_target(
37efbbd8 4397 'git-contrib',
dd1e33c8 4398 command : [git_contrib_sh])
177929c2 4399endif
dd6ab3df
ZJS
4400
4401if git.found()
4402 git_head = run_command(
e92777d2
ZJS
4403 git, '--git-dir=@0@/.git'.format(project_source_root),
4404 'rev-parse', 'HEAD',
4405 check : false).stdout().strip()
dd6ab3df 4406 git_head_short = run_command(
e92777d2
ZJS
4407 git, '--git-dir=@0@/.git'.format(project_source_root),
4408 'rev-parse', '--short=7', 'HEAD',
4409 check : false).stdout().strip()
dd6ab3df
ZJS
4410
4411 run_target(
4412 'git-snapshot',
0f4c4f38 4413 command : [git, 'archive',
1485aacb 4414 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
dd6ab3df
ZJS
4415 git_head_short),
4416 '--prefix', 'systemd-@0@/'.format(git_head),
4417 'HEAD'])
4418endif
829257d1
ZJS
4419
4420############################################################
4421
dd1e33c8 4422check_api_docs_sh = find_program('tools/check-api-docs.sh')
51b13863
LP
4423run_target(
4424 'check-api-docs',
4425 depends : [man, libsystemd, libudev],
dd1e33c8 4426 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
51b13863 4427
f12c5d36
ZJS
4428alias_target('update-dbus-docs', update_dbus_docs)
4429alias_target('update-man-rules', update_man_rules)
e3c368f6 4430
0628d48e
LB
4431if not meson.is_cross_build()
4432 custom_target(
4433 'export-dbus-interfaces',
4645074e 4434 output : fs.name(dbus_interfaces_dir),
0628d48e 4435 install : dbus_interfaces_dir != 'no',
4645074e 4436 install_dir : fs.parent(dbus_interfaces_dir),
0628d48e
LB
4437 command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
4438endif
e3c68924 4439
51b13863 4440############################################################
829257d1 4441
e92777d2
ZJS
4442alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
4443 check : true).stdout().strip()
12085ebb
ZJS
4444
4445summary({
12085ebb
ZJS
4446 'split /usr' : split_usr,
4447 'split bin-sbin' : split_bin,
4448 'prefix directory' : prefixdir,
4449 'rootprefix directory' : rootprefixdir,
4450 'sysconf directory' : sysconfdir,
4451 'include directory' : includedir,
4452 'lib directory' : libdir,
4453 'rootlib directory' : rootlibdir,
4454 'SysV init scripts' : sysvinit_path,
4455 'SysV rc?.d directories' : sysvrcnd_path,
4456 'PAM modules directory' : pamlibdir,
4457 'PAM configuration directory' : pamconfdir,
4458 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
4459 'RPM macros directory' : rpmmacrosdir,
4460 'modprobe.d directory' : modprobedir,
4461 'D-Bus policy directory' : dbuspolicydir,
4462 'D-Bus session directory' : dbussessionservicedir,
4463 'D-Bus system directory' : dbussystemservicedir,
7e560e79 4464 'D-Bus interfaces directory' : dbus_interfaces_dir,
12085ebb
ZJS
4465 'bash completions directory' : bashcompletiondir,
4466 'zsh completions directory' : zshcompletiondir,
a2b0cd3f 4467 'private shared lib version tag' : shared_lib_tag,
12085ebb
ZJS
4468 'extra start script' : get_option('rc-local'),
4469 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
4470 get_option('debug-tty')),
4471 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
4472 conf.get('SYSTEM_ALLOC_UID_MIN')),
4473 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
4474 conf.get('SYSTEM_ALLOC_GID_MIN')),
4475 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
4476 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
4477 'static UID/GID allocations' : ' '.join(static_ugids),
4478 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
4479 'render group access mode' : get_option('group-render-mode'),
4480 'certificate root directory' : get_option('certificate-root'),
4481 'support URL' : support_url,
4482 'nobody user name' : nobody_user,
4483 'nobody group name' : nobody_group,
4484 'fallback hostname' : get_option('fallback-hostname'),
9798deaf 4485 'default compression method' : compression,
12085ebb
ZJS
4486 'default DNSSEC mode' : default_dnssec,
4487 'default DNS-over-TLS mode' : default_dns_over_tls,
4488 'default mDNS mode' : default_mdns,
4489 'default LLMNR mode' : default_llmnr,
4490 'default DNS servers' : dns_servers.split(' '),
4491 'default NTP servers' : ntp_servers.split(' '),
4492 'default cgroup hierarchy' : default_hierarchy,
4493 'default net.naming-scheme value' : default_net_naming_scheme,
4494 'default KillUserProcesses value' : kill_user_processes,
4495 'default locale' : default_locale,
88b6f0de 4496 'default nspawn locale' : nspawn_locale,
79dec86a 4497 'default status unit format' : status_unit_format_default,
12085ebb
ZJS
4498 'default user $PATH' :
4499 default_user_path != '' ? default_user_path : '(same as system services)',
4500 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
4501 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
829257d1
ZJS
4502
4503# TODO:
4504# CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
4505# CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
4506# LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
4507
829257d1
ZJS
4508found = []
4509missing = []
4510
4511foreach tuple : [
56d68e71
ZJS
4512 # dependencies
4513 ['ACL'],
829257d1 4514 ['AUDIT'],
829257d1 4515 ['AppArmor'],
56d68e71
ZJS
4516 ['IMA'],
4517 ['PAM'],
829257d1 4518 ['SECCOMP'],
56d68e71 4519 ['SELinux'],
829257d1 4520 ['SMACK'],
56d68e71
ZJS
4521 ['blkid'],
4522 ['elfutils'],
829257d1 4523 ['gcrypt'],
829257d1 4524 ['gnutls'],
7d861e12 4525 ['libbpf'],
56d68e71 4526 ['libcryptsetup'],
d1ae38d8 4527 ['libcryptsetup-plugins'],
829257d1 4528 ['libcurl'],
56d68e71
ZJS
4529 ['libfdisk'],
4530 ['libfido2'],
829257d1 4531 ['libidn'],
56d68e71 4532 ['libidn2'],
829257d1 4533 ['libiptc'],
56d68e71
ZJS
4534 ['microhttpd'],
4535 ['openssl'],
4536 ['p11kit'],
4537 ['pcre2'],
4538 ['pwquality'],
4539 ['qrencode'],
4540 ['tpm2'],
4541 ['xkbcommon'],
4542
4543 # compression libs
4544 ['zstd'],
4545 ['lz4'],
4546 ['xz'],
4547 ['zlib'],
4548 ['bzip2'],
4549
4550 # components
4551 ['backlight'],
829257d1 4552 ['binfmt'],
0a0d4899 4553 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
56d68e71 4554 ['coredump'],
829257d1 4555 ['environment.d'],
56d68e71 4556 ['efi'],
9cf75222 4557 ['gnu-efi'],
829257d1 4558 ['firstboot'],
56d68e71
ZJS
4559 ['hibernate'],
4560 ['homed'],
4561 ['hostnamed'],
4562 ['hwdb'],
4563 ['importd'],
4564 ['initrd'],
f887eab1 4565 ['kernel-install'],
56d68e71 4566 ['localed'],
829257d1
ZJS
4567 ['logind'],
4568 ['machined'],
56d68e71
ZJS
4569 ['networkd'],
4570 ['nss-myhostname'],
4571 ['nss-mymachines'],
4572 ['nss-resolve'],
4573 ['nss-systemd'],
4574 ['oomd'],
61d0578b 4575 ['portabled'],
56d68e71
ZJS
4576 ['pstore'],
4577 ['quotacheck'],
4578 ['randomseed'],
4579 ['repart'],
4580 ['resolve'],
4581 ['rfkill'],
9bca4ae4 4582 ['sysext'],
0a0d4899 4583 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
43cc7a3e 4584 ['sysupdate'],
56d68e71 4585 ['sysusers'],
829257d1
ZJS
4586 ['timedated'],
4587 ['timesyncd'],
56d68e71
ZJS
4588 ['tmpfiles'],
4589 ['userdb'],
4590 ['vconsole'],
4591 ['xdg-autostart'],
4592
4593 # optional features
56d68e71 4594 ['idn'],
829257d1 4595 ['polkit'],
56d68e71 4596 ['nscd'],
0a0d4899 4597 ['legacy-pkla', install_polkit_pkla],
829257d1 4598 ['kmod'],
ede5a78f 4599 ['xenctrl'],
829257d1
ZJS
4600 ['dbus'],
4601 ['glib'],
829257d1 4602 ['tpm'],
0a0d4899
JH
4603 ['man pages', want_man],
4604 ['html pages', want_html],
4605 ['man page indices', want_man and have_lxml],
829257d1 4606 ['SysV compat'],
56d68e71 4607 ['compat-mutable-uid-boundaries'],
829257d1
ZJS
4608 ['utmp'],
4609 ['ldconfig'],
0a0d4899
JH
4610 ['adm group', get_option('adm-group')],
4611 ['wheel group', get_option('wheel-group')],
b14e1b43 4612 ['gshadow'],
829257d1
ZJS
4613 ['debug hashmap'],
4614 ['debug mmap cache'],
d6601495 4615 ['debug siphash'],
0a0d4899
JH
4616 ['valgrind', conf.get('VALGRIND') == 1],
4617 ['trace logging', conf.get('LOG_TRACE') == 1],
4618 ['install tests', install_tests],
4619 ['link-udev-shared', get_option('link-udev-shared')],
4620 ['link-systemctl-shared', get_option('link-systemctl-shared')],
4621 ['link-networkd-shared', get_option('link-networkd-shared')],
4622 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
4623 ['link-journalctl-shared', get_option('link-journalctl-shared')],
4624 ['link-boot-shared', get_option('link-boot-shared')],
93651582 4625 ['first-boot-full-preset'],
ceedbf81 4626 ['fexecve'],
0a0d4899
JH
4627 ['standalone-binaries', get_option('standalone-binaries')],
4628 ['coverage', get_option('b_coverage')],
829257d1
ZJS
4629]
4630
af4d7860
ZJS
4631 if tuple.length() >= 2
4632 cond = tuple[1]
4633 else
829257d1
ZJS
4634 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
4635 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
349cc4a5 4636 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
829257d1
ZJS
4637 endif
4638 if cond
5a8b1640 4639 found += tuple[0]
829257d1 4640 else
5a8b1640 4641 missing += tuple[0]
829257d1
ZJS
4642 endif
4643endforeach
4644
c716c253
ZJS
4645if static_libsystemd == 'false'
4646 missing += 'static-libsystemd'
4647else
4648 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
4649endif
4650
4651if static_libudev == 'false'
4652 missing += 'static-libudev'
4653else
4654 found += 'static-libudev(@0@)'.format(static_libudev)
4655endif
4656
57633d23
ZJS
4657if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
4658 found += 'cryptolib(openssl)'
4659elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
4660 found += 'cryptolib(gcrypt)'
4661else
4662 missing += 'cryptolib'
4663endif
4664
237f2da9
ZJS
4665if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
4666 found += 'DNS-over-TLS(gnutls)'
4667elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
4668 found += 'DNS-over-TLS(openssl)'
4669else
4670 missing += 'DNS-over-TLS'
4671endif
4672
12085ebb
ZJS
4673summary({
4674 'enabled' : ', '.join(found),
4675 'disabled' : ', '.join(missing)},
4676 section : 'Features')
9a8e64b0
ZJS
4677
4678if rootprefixdir != rootprefix_default
8ea9fad7
YW
4679 warning('\n' +
4680 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
4681 'systemd used fixed names for unit file directories and other paths, so anything\n' +
4682 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))
9a8e64b0 4683endif