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