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