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