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