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