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