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