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