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