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