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