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