]> git.ipfire.org Git - thirdparty/systemd.git/blame - meson.build
Revert "lgtm: disable cpp/missing-return"
[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: [
2b2dbcbb 7 'c_std=gnu11',
37efbbd8
ZJS
8 'prefix=/usr',
9 'sysconfdir=/etc',
10 'localstatedir=/var',
827ca909 11 'warning_level=2',
5c23128d 12 ],
9247df5a 13 meson_version : '>= 0.53.2',
5c23128d
ZJS
14 )
15
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
678ba020 43skip_deps = want_ossfuzz or get_option('skip-deps')
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
a17e5478 364# Disable -Wmaybe-uninitialized when compiling with -Os/-O1/-O3/etc. There are
68c98a41
ZJS
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',
baec7d78 1055 version : '>= 2.32',
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
43cc7a3e
LP
1647want_sysupdate = get_option('sysupdate')
1648if want_sysupdate != 'false'
1649 have = (conf.get('HAVE_OPENSSL') == 1 and
1650 conf.get('HAVE_LIBFDISK') == 1)
1651 if want_sysupdate == 'true' and not have
1652 error('sysupdate support was requested, but dependencies are not available')
1653 endif
1654else
1655 have = false
1656endif
1657conf.set10('ENABLE_SYSUPDATE', have)
1658
5c23128d 1659want_importd = get_option('importd')
4390be30 1660if want_importd != 'false'
349cc4a5 1661 have = (conf.get('HAVE_LIBCURL') == 1 and
6214d42b 1662 conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and
349cc4a5 1663 conf.get('HAVE_ZLIB') == 1 and
6214d42b 1664 conf.get('HAVE_XZ') == 1)
349cc4a5 1665 if want_importd == 'true' and not have
37efbbd8
ZJS
1666 error('importd support was requested, but dependencies are not available')
1667 endif
349cc4a5
ZJS
1668else
1669 have = false
5c23128d 1670endif
349cc4a5 1671conf.set10('ENABLE_IMPORTD', have)
5c23128d 1672
70a5db58
LP
1673want_homed = get_option('homed')
1674if want_homed != 'false'
1675 have = (conf.get('HAVE_OPENSSL') == 1 and
1676 conf.get('HAVE_LIBFDISK') == 1 and
1677 conf.get('HAVE_LIBCRYPTSETUP') == 1)
1678 if want_homed == 'true' and not have
1679 error('homed support was requested, but dependencies are not available')
1680 endif
1681else
1682 have = false
1683endif
1684conf.set10('ENABLE_HOMED', have)
1685
af06ddf5
YW
1686have = have and conf.get('HAVE_PAM') == 1
1687conf.set10('ENABLE_PAM_HOME', have)
1688
d58c5f0f 1689have = get_option('oomd')
c199dd3f
AZ
1690conf.set10('ENABLE_OOMD', have)
1691
5c23128d 1692want_remote = get_option('remote')
4390be30 1693if want_remote != 'false'
349cc4a5
ZJS
1694 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1695 conf.get('HAVE_LIBCURL') == 1]
37efbbd8
ZJS
1696 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1697 # it's possible to build one without the other. Complain only if
5238e957 1698 # support was explicitly requested. The auxiliary files like sysusers
37efbbd8
ZJS
1699 # config should be installed when any of the programs are built.
1700 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1701 error('remote support was requested, but dependencies are not available')
1702 endif
349cc4a5
ZJS
1703 have = have_deps[0] or have_deps[1]
1704else
1705 have = false
5c23128d 1706endif
349cc4a5 1707conf.set10('ENABLE_REMOTE', have)
5c23128d 1708
b3259a6e
ZJS
1709foreach term : ['analyze',
1710 'backlight',
a9149d87
ZJS
1711 'binfmt',
1712 'coredump',
b3259a6e
ZJS
1713 'efi',
1714 'environment-d',
1715 'firstboot',
1716 'gshadow',
1717 'hibernate',
a9149d87 1718 'hostnamed',
b3259a6e
ZJS
1719 'hwdb',
1720 'idn',
1721 'ima',
1722 'initrd',
53393c89 1723 'compat-mutable-uid-boundaries',
7e0079f9 1724 'nscd',
b3259a6e 1725 'ldconfig',
a9149d87 1726 'localed',
b3259a6e 1727 'logind',
a9149d87
ZJS
1728 'machined',
1729 'networkd',
b3259a6e
ZJS
1730 'nss-myhostname',
1731 'nss-systemd',
1732 'portabled',
9bca4ae4 1733 'sysext',
b3259a6e 1734 'pstore',
a9149d87 1735 'quotacheck',
b3259a6e
ZJS
1736 'randomseed',
1737 'resolve',
1738 'rfkill',
1739 'smack',
a9149d87 1740 'sysusers',
b3259a6e
ZJS
1741 'timedated',
1742 'timesyncd',
a9149d87 1743 'tmpfiles',
a9149d87 1744 'tpm',
b3259a6e
ZJS
1745 'userdb',
1746 'utmp',
1747 'vconsole',
1748 'xdg-autostart']
a9149d87
ZJS
1749 have = get_option(term)
1750 name = 'ENABLE_' + term.underscorify().to_upper()
1751 conf.set10(name, have)
5c23128d
ZJS
1752endforeach
1753
bd7e6aa7
ZJS
1754enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
1755
08540a95
YW
1756foreach tuple : [['nss-mymachines', 'machined'],
1757 ['nss-resolve', 'resolve']]
1758 want = get_option(tuple[0])
1759 if want != 'false'
1760 have = get_option(tuple[1])
1761 if want == 'true' and not have
1762 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1763 endif
1764 else
1765 have = false
1766 endif
1767 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1768 conf.set10(name, have)
1769endforeach
1770
1771enable_nss = false
1772foreach term : ['ENABLE_NSS_MYHOSTNAME',
1773 'ENABLE_NSS_MYMACHINES',
1774 'ENABLE_NSS_RESOLVE',
1775 'ENABLE_NSS_SYSTEMD']
1776 if conf.get(term) == 1
1777 enable_nss = true
1778 endif
1779endforeach
1780conf.set10('ENABLE_NSS', enable_nss)
1781
348b4437 1782conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
6129ec85 1783
b68dfb9e 1784conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
00d82c81 1785
db7f5ab6
JJ
1786############################################################
1787
1788tests = []
1789fuzzers = []
e93ada98 1790catalogs = []
db7f5ab6
JJ
1791
1792############################################################
5c23128d 1793
db7f5ab6 1794# Include these now as they provide gnu-efi detection.
34357545
MS
1795subdir('src/fundamental')
1796subdir('src/boot/efi')
34357545 1797
f6fe732f
YW
1798############################################################
1799
d3821a33 1800generate_gperfs = find_program('tools/generate-gperfs.py')
f6fe732f
YW
1801make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
1802make_directive_index_py = find_program('tools/make-directive-index.py')
1803make_man_index_py = find_program('tools/make-man-index.py')
6b1aac3c 1804meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
d3821a33 1805update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
77d45f1f 1806update_man_rules_py = find_program('tools/update-man-rules.py')
d3821a33
ZJS
1807update_hwdb_sh = find_program('tools/update-hwdb.sh')
1808update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
1809update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
1810xml_helper_py = find_program('tools/xml_helper.py')
e3c68924 1811export_dbus_interfaces_py = find_program('tools/dbus_exporter.py')
f6fe732f 1812
db7f5ab6 1813############################################################
5c23128d
ZJS
1814
1815config_h = configure_file(
37efbbd8
ZJS
1816 output : 'config.h',
1817 configuration : conf)
5c23128d 1818
f6fe732f
YW
1819add_project_arguments('-include', 'config.h', language : 'c')
1820
1821############################################################
348b4437 1822
b61016f2
YW
1823# binaries that have --help and are intended for use by humans,
1824# usually, but not always, installed in /bin.
1825public_programs = []
1826
e3c68924 1827# D-Bus introspection XML export
1828dbus_programs = []
e3c68924 1829
8d40961c
YW
1830basic_includes = include_directories(
1831 'src/basic',
e5bc5f1f 1832 'src/fundamental',
8d40961c
YW
1833 'src/systemd',
1834 '.')
1835
1836libsystemd_includes = [basic_includes, include_directories(
1837 'src/libsystemd/sd-bus',
1838 'src/libsystemd/sd-device',
1839 'src/libsystemd/sd-event',
1840 'src/libsystemd/sd-hwdb',
1841 'src/libsystemd/sd-id128',
1842 'src/libsystemd/sd-journal',
1843 'src/libsystemd/sd-netlink',
1844 'src/libsystemd/sd-network',
1845 'src/libsystemd/sd-resolve')]
1846
1847includes = [libsystemd_includes, include_directories('src/shared')]
5c23128d 1848
5c23128d
ZJS
1849subdir('po')
1850subdir('catalog')
5c23128d
ZJS
1851subdir('src/basic')
1852subdir('src/libsystemd')
3976f372
YW
1853subdir('src/shared')
1854subdir('src/udev')
1855subdir('src/libudev')
d1ae38d8 1856subdir('src/cryptsetup/cryptsetup-tokens')
5c23128d 1857
5c23128d 1858libsystemd = shared_library(
37efbbd8 1859 'systemd',
a5d8835c 1860 disable_mempool_c,
56d50ab1 1861 version : libsystemd_version,
8d40961c 1862 include_directories : libsystemd_includes,
37efbbd8
ZJS
1863 link_args : ['-shared',
1864 '-Wl,--version-script=' + libsystemd_sym_path],
34e221a5
ZJS
1865 link_with : [libbasic,
1866 libbasic_gcrypt],
99b9f8fd 1867 link_whole : [libsystemd_static],
37efbbd8
ZJS
1868 dependencies : [threads,
1869 librt,
1870 libxz,
ef5924aa 1871 libzstd,
37efbbd8
ZJS
1872 liblz4],
1873 link_depends : libsystemd_sym,
1874 install : true,
1875 install_dir : rootlibdir)
5c23128d 1876
70848ecf
DC
1877install_libsystemd_static = static_library(
1878 'systemd',
1879 libsystemd_sources,
975464e0
ZJS
1880 basic_sources,
1881 basic_gcrypt_sources,
e5bc5f1f 1882 fundamental_sources,
be44b572 1883 disable_mempool_c,
8d40961c 1884 include_directories : libsystemd_includes,
70848ecf
DC
1885 build_by_default : static_libsystemd != 'false',
1886 install : static_libsystemd != 'false',
1887 install_dir : rootlibdir,
40dbce36 1888 pic : static_libsystemd_pic,
70848ecf
DC
1889 dependencies : [threads,
1890 librt,
1891 libxz,
ef5924aa 1892 libzstd,
70848ecf 1893 liblz4,
c5fd89ad 1894 libdl,
975464e0
ZJS
1895 libcap,
1896 libblkid,
1897 libmount,
011d129c
LP
1898 libgcrypt,
1899 libopenssl],
70848ecf
DC
1900 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
1901
3976f372
YW
1902libudev = shared_library(
1903 'udev',
1904 disable_mempool_c,
1905 version : libudev_version,
1906 include_directories : includes,
1907 link_args : ['-shared',
1908 '-Wl,--version-script=' + libudev_sym_path],
1909 link_with : [libsystemd_static, libshared_static],
1910 link_whole : libudev_basic,
1911 dependencies : [threads],
1912 link_depends : libudev_sym,
1913 install : true,
1914 install_dir : rootlibdir)
1915
1916install_libudev_static = static_library(
1917 'udev',
1918 basic_sources,
e5bc5f1f 1919 fundamental_sources,
3976f372
YW
1920 shared_sources,
1921 libsystemd_sources,
1922 libudev_sources,
1923 disable_mempool_c,
1924 include_directories : includes,
1925 build_by_default : static_libudev != 'false',
1926 install : static_libudev != 'false',
1927 install_dir : rootlibdir,
1928 link_depends : libudev_sym,
1929 dependencies : libshared_deps + [libmount],
1930 c_args : static_libudev_pic ? [] : ['-fno-PIC'],
1931 pic : static_libudev_pic)
1932
d1ae38d8
OK
1933if conf.get('HAVE_LIBCRYPTSETUP_PLUGINS') == 1
1934 if conf.get('HAVE_TPM2') == 1
1935 cryptsetup_token_systemd_tpm2 = shared_library(
1936 'cryptsetup-token-systemd-tpm2',
c01543fd
ZJS
1937 cryptsetup_token_systemd_tpm2_sources,
1938 include_directories : includes,
d1ae38d8
OK
1939 link_args : ['-shared',
1940 '-Wl,--version-script=' + cryptsetup_token_sym_path],
c01543fd
ZJS
1941 link_with : [lib_cryptsetup_token_common,
1942 libshared],
1943 dependencies : [libcryptsetup,
1944 tpm2,
1945 versiondep],
d1ae38d8
OK
1946 link_depends : cryptsetup_token_sym,
1947 install_rpath : rootlibexecdir,
1948 install : true,
1949 install_dir : libcryptsetup_plugins_dir)
1950 endif
351716e1
OK
1951
1952 if conf.get('HAVE_LIBFIDO2') == 1
1953 cryptsetup_token_systemd_fido2 = shared_library(
1954 'cryptsetup-token-systemd-fido2',
c01543fd
ZJS
1955 cryptsetup_token_systemd_fido2_sources,
1956 include_directories : includes,
351716e1
OK
1957 link_args : ['-shared',
1958 '-Wl,--version-script=' + cryptsetup_token_sym_path],
c01543fd
ZJS
1959 link_with : [lib_cryptsetup_token_common,
1960 libshared],
1961 dependencies : [libcryptsetup,
1962 libfido2,
1963 versiondep],
351716e1
OK
1964 link_depends : cryptsetup_token_sym,
1965 install_rpath : rootlibexecdir,
1966 install : true,
1967 install_dir : libcryptsetup_plugins_dir)
1968 endif
8186022c
OK
1969
1970 if conf.get('HAVE_P11KIT') == 1
1971 cryptsetup_token_systemd_pkcs11 = shared_library(
1972 'cryptsetup-token-systemd-pkcs11',
c01543fd
ZJS
1973 cryptsetup_token_systemd_pkcs11_sources,
1974 include_directories : includes,
8186022c
OK
1975 link_args : ['-shared',
1976 '-Wl,--version-script=' + cryptsetup_token_sym_path],
c01543fd
ZJS
1977 link_with : [lib_cryptsetup_token_common,
1978 libshared],
1979 dependencies : [libcryptsetup,
1980 libp11kit,
1981 versiondep],
8186022c
OK
1982 link_depends : cryptsetup_token_sym,
1983 install_rpath : rootlibexecdir,
1984 install : true,
1985 install_dir : libcryptsetup_plugins_dir)
1986 endif
d1ae38d8
OK
1987endif
1988
47354b44
ZJS
1989############################################################
1990
b61016f2 1991# systemd-analyze requires 'libcore'
83b6af36 1992subdir('src/core')
b61016f2
YW
1993# systemd-journal-remote requires 'libjournal_core'
1994subdir('src/journal')
1995# systemd-networkd requires 'libsystemd_network'
1996subdir('src/libsystemd-network')
83b6af36
ZJS
1997
1998subdir('src/analyze')
f98df767 1999subdir('src/busctl')
b61016f2 2000subdir('src/coredump')
2ad279cf 2001subdir('src/cryptenroll')
b4d1892a 2002subdir('src/cryptsetup')
b61016f2 2003subdir('src/home')
83b6af36
ZJS
2004subdir('src/hostname')
2005subdir('src/import')
b61016f2 2006subdir('src/journal-remote')
83b6af36
ZJS
2007subdir('src/kernel-install')
2008subdir('src/locale')
b61016f2 2009subdir('src/login')
83b6af36 2010subdir('src/machine')
b61016f2 2011subdir('src/network')
83b6af36 2012subdir('src/nspawn')
b61016f2
YW
2013subdir('src/oom')
2014subdir('src/partition')
2015subdir('src/portable')
2016subdir('src/pstore')
83b6af36 2017subdir('src/resolve')
2a9b4bbe 2018subdir('src/rpm')
b61016f2 2019subdir('src/shutdown')
9bca4ae4 2020subdir('src/sysext')
c3512573 2021subdir('src/systemctl')
43cc7a3e 2022subdir('src/sysupdate')
83b6af36
ZJS
2023subdir('src/timedate')
2024subdir('src/timesync')
db64ba81 2025subdir('src/tmpfiles')
b61016f2 2026subdir('src/userdb')
83b6af36 2027subdir('src/vconsole')
0275e918 2028subdir('src/xdg-autostart-generator')
83b6af36 2029
3976f372
YW
2030subdir('src/systemd')
2031
83b6af36 2032subdir('src/test')
7db7d5b7 2033subdir('src/fuzz')
ef2ad30a 2034subdir('rules.d')
83b6af36
ZJS
2035subdir('test')
2036
2037############################################################
2038
2039# only static linking apart from libdl, to make sure that the
2040# module is linked to all libraries that it uses.
2041test_dlopen = executable(
37efbbd8
ZJS
2042 'test-dlopen',
2043 test_dlopen_c,
a5d8835c 2044 disable_mempool_c,
37efbbd8
ZJS
2045 include_directories : includes,
2046 link_with : [libbasic],
fd1939fb
YW
2047 dependencies : [libdl],
2048 build_by_default : want_tests != 'false')
83b6af36 2049
08540a95 2050foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
cbaaf7b9 2051 ['systemd', 'ENABLE_NSS_SYSTEMD', ['nss-systemd.h', 'userdb-glue.c', 'userdb-glue.h']],
08540a95 2052 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
8d40961c 2053 ['resolve', 'ENABLE_NSS_RESOLVE', [], resolve_includes]]
5c23128d 2054
349cc4a5 2055 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
37efbbd8
ZJS
2056 if condition
2057 module = tuple[0]
37efbbd8
ZJS
2058
2059 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
fce9abb2 2060 version_script_arg = project_source_root / sym
37efbbd8 2061
1684c56f
LP
2062 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
2063 if tuple.length() > 2
cbaaf7b9
YW
2064 foreach s : tuple[2]
2065 sources += ['src/nss-@0@/@1@'.format(module, s)]
2066 endforeach
1684c56f
LP
2067 endif
2068
8d40961c
YW
2069 incs = tuple.length() > 3 ? tuple[3] : includes
2070
37efbbd8
ZJS
2071 nss = shared_library(
2072 'nss_' + module,
1684c56f 2073 sources,
a5d8835c 2074 disable_mempool_c,
37efbbd8 2075 version : '2',
8d40961c 2076 include_directories : incs,
b4b36f44
LP
2077 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
2078 link_args : ['-Wl,-z,nodelete',
2079 '-shared',
700805f6 2080 '-Wl,--version-script=' + version_script_arg],
37e4d7a8 2081 link_with : [libsystemd_static,
733cbd00 2082 libshared_static,
37efbbd8
ZJS
2083 libbasic],
2084 dependencies : [threads,
5486a31d 2085 librt],
37efbbd8
ZJS
2086 link_depends : sym,
2087 install : true,
2088 install_dir : rootlibdir)
2089
2090 # We cannot use shared_module because it does not support version suffix.
2091 # Unfortunately shared_library insists on creating the symlink…
7c22f07c 2092 meson.add_install_script('sh', '-c',
37efbbd8
ZJS
2093 'rm $DESTDIR@0@/libnss_@1@.so'
2094 .format(rootlibdir, module))
2095
938be089
ZJS
2096 if want_tests != 'false'
2097 test('dlopen-nss_' + module,
2098 test_dlopen,
2099 # path to dlopen must include a slash
e93ada98
DDM
2100 args : nss.full_path(),
2101 depends : nss)
938be089 2102 endif
37efbbd8 2103 endif
5c23128d
ZJS
2104endforeach
2105
2106############################################################
2107
e3c68924 2108dbus_programs += executable(
6164ec4c
ZJS
2109 'systemd',
2110 systemd_sources,
2111 include_directories : includes,
2112 link_with : [libcore,
2113 libshared],
2114 dependencies : [versiondep,
4287c855 2115 libseccomp],
6164ec4c
ZJS
2116 install_rpath : rootlibexecdir,
2117 install : true,
2118 install_dir : rootlibexecdir)
5c23128d 2119
ba7f4ae6 2120meson.add_install_script(meson_make_symlink,
fce9abb2
ZJS
2121 rootlibexecdir / 'systemd',
2122 rootsbindir / 'init')
ba7f4ae6 2123
6164ec4c
ZJS
2124public_programs += executable(
2125 'systemd-analyze',
2126 systemd_analyze_sources,
8d40961c 2127 include_directories : core_includes,
6164ec4c
ZJS
2128 link_with : [libcore,
2129 libshared],
2130 dependencies : [versiondep,
4287c855 2131 libseccomp],
6164ec4c 2132 install_rpath : rootlibexecdir,
b3259a6e 2133 install : conf.get('ENABLE_ANALYZE'))
5c23128d 2134
6164ec4c
ZJS
2135executable(
2136 'systemd-journald',
2137 systemd_journald_sources,
2138 include_directories : includes,
2139 link_with : [libjournal_core,
2140 libshared],
2141 dependencies : [threads,
2142 libxz,
2143 liblz4,
ef5924aa
NL
2144 libselinux,
2145 libzstd],
6164ec4c
ZJS
2146 install_rpath : rootlibexecdir,
2147 install : true,
2148 install_dir : rootlibexecdir)
5c23128d 2149
6164ec4c
ZJS
2150public_programs += executable(
2151 'systemd-cat',
2152 systemd_cat_sources,
2153 include_directories : includes,
2154 link_with : [libjournal_core,
2155 libshared],
2156 dependencies : [threads],
2157 install_rpath : rootlibexecdir,
2158 install : true)
2159
2160public_programs += executable(
2161 'journalctl',
2162 journalctl_sources,
2163 include_directories : includes,
2164 link_with : [libshared],
2165 dependencies : [threads,
e44b5004 2166 libdl,
6164ec4c
ZJS
2167 libxz,
2168 liblz4,
9200bb30
LP
2169 libzstd,
2170 libdl],
6164ec4c
ZJS
2171 install_rpath : rootlibexecdir,
2172 install : true,
2173 install_dir : rootbindir)
35a1ff4c 2174
6164ec4c
ZJS
2175executable(
2176 'systemd-getty-generator',
2177 'src/getty-generator/getty-generator.c',
2178 include_directories : includes,
2179 link_with : [libshared],
2180 install_rpath : rootlibexecdir,
2181 install : true,
2182 install_dir : systemgeneratordir)
5c23128d 2183
6164ec4c
ZJS
2184executable(
2185 'systemd-debug-generator',
2186 'src/debug-generator/debug-generator.c',
2187 include_directories : includes,
2188 link_with : [libshared],
2189 install_rpath : rootlibexecdir,
2190 install : true,
2191 install_dir : systemgeneratordir)
2192
2193executable(
2194 'systemd-run-generator',
2195 'src/run-generator/run-generator.c',
2196 include_directories : includes,
2197 link_with : [libshared],
2198 install_rpath : rootlibexecdir,
2199 install : true,
2200 install_dir : systemgeneratordir)
2201
8cc8a073 2202exe = executable(
6164ec4c
ZJS
2203 'systemd-fstab-generator',
2204 'src/fstab-generator/fstab-generator.c',
2205 include_directories : includes,
bac11cd6 2206 link_with : [libshared],
6164ec4c
ZJS
2207 install_rpath : rootlibexecdir,
2208 install : true,
2209 install_dir : systemgeneratordir)
5c23128d 2210
8cc8a073
YW
2211if want_tests != 'false'
2212 test('test-fstab-generator',
2213 test_fstab_generator_sh,
2214 # https://github.com/mesonbuild/meson/issues/2681
e93ada98
DDM
2215 args : exe.full_path(),
2216 depends : exe)
8cc8a073
YW
2217endif
2218
349cc4a5 2219if conf.get('ENABLE_ENVIRONMENT_D') == 1
6164ec4c
ZJS
2220 executable(
2221 '30-systemd-environment-d-generator',
2222 'src/environment-d-generator/environment-d-generator.c',
2223 include_directories : includes,
2224 link_with : [libshared],
2225 install_rpath : rootlibexecdir,
2226 install : true,
2227 install_dir : userenvgeneratordir)
7b76fce1 2228
37efbbd8 2229 meson.add_install_script(meson_make_symlink,
fce9abb2
ZJS
2230 sysconfdir / 'environment',
2231 environmentdir / '99-environment.conf')
5c23128d
ZJS
2232endif
2233
349cc4a5 2234if conf.get('ENABLE_HIBERNATE') == 1
6164ec4c
ZJS
2235 executable(
2236 'systemd-hibernate-resume-generator',
2237 'src/hibernate-resume/hibernate-resume-generator.c',
2238 include_directories : includes,
2239 link_with : [libshared],
2240 install_rpath : rootlibexecdir,
2241 install : true,
2242 install_dir : systemgeneratordir)
2243
2244 executable(
2245 'systemd-hibernate-resume',
2246 'src/hibernate-resume/hibernate-resume.c',
2247 include_directories : includes,
2248 link_with : [libshared],
2249 install_rpath : rootlibexecdir,
2250 install : true,
2251 install_dir : rootlibexecdir)
37efbbd8
ZJS
2252endif
2253
349cc4a5 2254if conf.get('HAVE_BLKID') == 1
6164ec4c
ZJS
2255 executable(
2256 'systemd-gpt-auto-generator',
2257 'src/gpt-auto-generator/gpt-auto-generator.c',
6164ec4c
ZJS
2258 include_directories : includes,
2259 link_with : [libshared],
2260 dependencies : libblkid,
2261 install_rpath : rootlibexecdir,
2262 install : true,
2263 install_dir : systemgeneratordir)
2264
2265 public_programs += executable(
2266 'systemd-dissect',
2267 'src/dissect/dissect.c',
2268 include_directories : includes,
2269 link_with : [libshared],
2270 install_rpath : rootlibexecdir,
5a151082 2271 install : true)
5c23128d
ZJS
2272endif
2273
1ec57f33 2274if conf.get('ENABLE_RESOLVE') == 1
e3c68924 2275 dbus_programs += executable(
6164ec4c
ZJS
2276 'systemd-resolved',
2277 systemd_resolved_sources,
8d40961c 2278 include_directories : resolve_includes,
6164ec4c
ZJS
2279 link_with : [libshared,
2280 libbasic_gcrypt,
2281 libsystemd_resolve_core],
2282 dependencies : systemd_resolved_dependencies,
2283 install_rpath : rootlibexecdir,
2284 install : true,
2285 install_dir : rootlibexecdir)
2286
2287 public_programs += executable(
2288 'resolvectl',
2289 resolvectl_sources,
2290 include_directories : includes,
2291 link_with : [libshared,
2292 libbasic_gcrypt,
2293 libsystemd_resolve_core],
2294 dependencies : [threads,
0351cbb9 2295 lib_openssl_or_gcrypt,
6164ec4c
ZJS
2296 libm,
2297 libidn],
2298 install_rpath : rootlibexecdir,
2299 install : true)
088c1363
LP
2300
2301 meson.add_install_script(meson_make_symlink,
fce9abb2
ZJS
2302 bindir / 'resolvectl',
2303 rootsbindir / 'resolvconf')
c2e84cab
YW
2304
2305 meson.add_install_script(meson_make_symlink,
fce9abb2
ZJS
2306 bindir / 'resolvectl',
2307 bindir / 'systemd-resolve')
5c23128d
ZJS
2308endif
2309
349cc4a5 2310if conf.get('ENABLE_LOGIND') == 1
e3c68924 2311 dbus_programs += executable(
6164ec4c
ZJS
2312 'systemd-logind',
2313 systemd_logind_sources,
2314 include_directories : includes,
2315 link_with : [liblogind_core,
2316 libshared],
2317 dependencies : [threads,
2318 libacl],
2319 install_rpath : rootlibexecdir,
2320 install : true,
2321 install_dir : rootlibexecdir)
2322
2323 public_programs += executable(
2324 'loginctl',
2325 loginctl_sources,
2326 include_directories : includes,
2327 link_with : [libshared],
2328 dependencies : [threads,
2329 liblz4,
ef5924aa
NL
2330 libxz,
2331 libzstd],
6164ec4c
ZJS
2332 install_rpath : rootlibexecdir,
2333 install : true,
2334 install_dir : rootbindir)
2335
2336 public_programs += executable(
2337 'systemd-inhibit',
2338 'src/login/inhibit.c',
2339 include_directories : includes,
2340 link_with : [libshared],
2341 install_rpath : rootlibexecdir,
2342 install : true,
2343 install_dir : rootbindir)
37efbbd8 2344
349cc4a5 2345 if conf.get('HAVE_PAM') == 1
fce9abb2 2346 version_script_arg = project_source_root / pam_systemd_sym
37efbbd8
ZJS
2347 pam_systemd = shared_library(
2348 'pam_systemd',
2349 pam_systemd_c,
2350 name_prefix : '',
2351 include_directories : includes,
2352 link_args : ['-shared',
2353 '-Wl,--version-script=' + version_script_arg],
37e4d7a8 2354 link_with : [libsystemd_static,
37efbbd8
ZJS
2355 libshared_static],
2356 dependencies : [threads,
2357 libpam,
2358 libpam_misc],
2359 link_depends : pam_systemd_sym,
2360 install : true,
2361 install_dir : pamlibdir)
2362
938be089
ZJS
2363 if want_tests != 'false'
2364 test('dlopen-pam_systemd',
2365 test_dlopen,
2366 # path to dlopen must include a slash
e93ada98
DDM
2367 args : pam_systemd.full_path(),
2368 depends : pam_systemd)
938be089 2369 endif
37efbbd8 2370 endif
005a29f2 2371
6164ec4c
ZJS
2372 executable(
2373 'systemd-user-runtime-dir',
2374 user_runtime_dir_sources,
2375 include_directories : includes,
2376 link_with : [libshared],
2377 install_rpath : rootlibexecdir,
2378 install : true,
2379 install_dir : rootlibexecdir)
07ee5adb 2380endif
a9f0f5e5 2381
349cc4a5 2382if conf.get('HAVE_PAM') == 1
6164ec4c
ZJS
2383 executable(
2384 'systemd-user-sessions',
2385 'src/user-sessions/user-sessions.c',
2386 include_directories : includes,
2387 link_with : [libshared],
2388 install_rpath : rootlibexecdir,
2389 install : true,
2390 install_dir : rootlibexecdir)
5c23128d
ZJS
2391endif
2392
34357545 2393if conf.get('HAVE_BLKID') == 1 and conf.get('HAVE_GNU_EFI') == 1
79647020
RS
2394 if get_option('link-boot-shared')
2395 boot_link_with = [libshared]
2396 else
2397 boot_link_with = [libsystemd_static, libshared_static]
2398 endif
2399
6164ec4c
ZJS
2400 public_programs += executable(
2401 'bootctl',
2402 'src/boot/bootctl.c',
2403 include_directories : includes,
79647020 2404 link_with : [boot_link_with],
6164ec4c
ZJS
2405 dependencies : [libblkid],
2406 install_rpath : rootlibexecdir,
2407 install : true)
2408
2409 public_programs += executable(
2410 'systemd-bless-boot',
2411 'src/boot/bless-boot.c',
2412 include_directories : includes,
79647020 2413 link_with : [boot_link_with],
6164ec4c
ZJS
2414 dependencies : [libblkid],
2415 install_rpath : rootlibexecdir,
2416 install : true,
2417 install_dir : rootlibexecdir)
2418
2419 executable(
2420 'systemd-bless-boot-generator',
2421 'src/boot/bless-boot-generator.c',
2422 include_directories : includes,
79647020 2423 link_with : [boot_link_with],
6164ec4c
ZJS
2424 install_rpath : rootlibexecdir,
2425 install : true,
2426 install_dir : systemgeneratordir)
2427endif
2428
2429executable(
2430 'systemd-boot-check-no-failures',
2431 'src/boot/boot-check-no-failures.c',
2432 include_directories : includes,
2433 link_with : [libshared],
2434 dependencies : [libblkid],
2435 install_rpath : rootlibexecdir,
2436 install : true,
2437 install_dir : rootlibexecdir)
005a29f2 2438
6164ec4c
ZJS
2439public_programs += executable(
2440 'systemd-socket-activate',
2441 'src/activate/activate.c',
2442 include_directories : includes,
2443 link_with : [libshared],
2444 dependencies : [threads],
2445 install_rpath : rootlibexecdir,
2446 install : true)
f3794366 2447
6164ec4c
ZJS
2448public_programs += executable(
2449 'systemctl',
c3512573 2450 systemctl_sources,
6164ec4c
ZJS
2451 include_directories : includes,
2452 link_with : systemctl_link_with,
2453 dependencies : [threads,
2454 libcap,
2455 libselinux,
2456 libxz,
ef5924aa
NL
2457 liblz4,
2458 libzstd],
6164ec4c
ZJS
2459 install_rpath : rootlibexecdir,
2460 install : true,
2461 install_dir : rootbindir)
5c23128d 2462
61d0578b 2463if conf.get('ENABLE_PORTABLED') == 1
e3c68924 2464 dbus_programs += executable(
6164ec4c
ZJS
2465 'systemd-portabled',
2466 systemd_portabled_sources,
2467 include_directories : includes,
2468 link_with : [libshared],
409f4cf1 2469 dependencies : [threads, libselinux],
6164ec4c
ZJS
2470 install_rpath : rootlibexecdir,
2471 install : true,
2472 install_dir : rootlibexecdir)
2473
2474 public_programs += executable(
2475 'portablectl',
2476 'src/portable/portablectl.c',
2477 include_directories : includes,
2478 link_with : [libshared],
2479 dependencies : [threads],
2480 install_rpath : rootlibexecdir,
2481 install : true,
2482 install_dir : rootbindir)
61d0578b
LP
2483endif
2484
9bca4ae4
LP
2485if conf.get('ENABLE_SYSEXT') == 1
2486 public_programs += executable(
2487 'systemd-sysext',
2488 systemd_sysext_sources,
2489 include_directories : includes,
2490 link_with : [libshared],
2491 install_rpath : rootlibexecdir,
2492 install : true,
aac5fbff 2493 install_dir : rootbindir)
9bca4ae4
LP
2494endif
2495
d093b62c 2496if conf.get('ENABLE_USERDB') == 1
6164ec4c
ZJS
2497 executable(
2498 'systemd-userwork',
2499 systemd_userwork_sources,
2500 include_directories : includes,
2501 link_with : [libshared],
2502 dependencies : [threads],
2503 install_rpath : rootlibexecdir,
2504 install : true,
2505 install_dir : rootlibexecdir)
2506
2507 executable(
2508 'systemd-userdbd',
2509 systemd_userdbd_sources,
2510 include_directories : includes,
2511 link_with : [libshared],
2512 dependencies : [threads],
2513 install_rpath : rootlibexecdir,
2514 install : true,
2515 install_dir : rootlibexecdir)
2516
460e5af0 2517 public_programs += executable(
6164ec4c
ZJS
2518 'userdbctl',
2519 userdbctl_sources,
2520 include_directories : includes,
2521 link_with : [libshared],
2522 dependencies : [threads],
2523 install_rpath : rootlibexecdir,
2524 install : true,
2525 install_dir : rootbindir)
d093b62c
LP
2526endif
2527
70a5db58 2528if conf.get('ENABLE_HOMED') == 1
6164ec4c
ZJS
2529 executable(
2530 'systemd-homework',
2531 systemd_homework_sources,
2532 include_directories : includes,
2533 link_with : [libshared],
2534 dependencies : [threads,
6164ec4c
ZJS
2535 libblkid,
2536 libcrypt,
2537 libopenssl,
2538 libfdisk,
69cb2896 2539 libp11kit],
6164ec4c
ZJS
2540 install_rpath : rootlibexecdir,
2541 install : true,
2542 install_dir : rootlibexecdir)
2543
e3c68924 2544 dbus_programs += executable(
6164ec4c
ZJS
2545 'systemd-homed',
2546 systemd_homed_sources,
8d40961c 2547 include_directories : home_includes,
6164ec4c
ZJS
2548 link_with : [libshared],
2549 dependencies : [threads,
2550 libcrypt,
d357b80d
LP
2551 libopenssl,
2552 libm],
6164ec4c
ZJS
2553 install_rpath : rootlibexecdir,
2554 install : true,
2555 install_dir : rootlibexecdir)
2556
460e5af0 2557 public_programs += executable(
6164ec4c
ZJS
2558 'homectl',
2559 homectl_sources,
2560 include_directories : includes,
2561 link_with : [libshared],
2562 dependencies : [threads,
2563 libcrypt,
2564 libopenssl,
2565 libp11kit,
da3920c3 2566 libdl],
6164ec4c
ZJS
2567 install_rpath : rootlibexecdir,
2568 install : true,
2569 install_dir : rootbindir)
26cf9fb7
LP
2570
2571 if conf.get('HAVE_PAM') == 1
fce9abb2 2572 version_script_arg = project_source_root / pam_systemd_home_sym
26cf9fb7
LP
2573 pam_systemd = shared_library(
2574 'pam_systemd_home',
2575 pam_systemd_home_c,
2576 name_prefix : '',
2577 include_directories : includes,
2578 link_args : ['-shared',
2579 '-Wl,--version-script=' + version_script_arg],
2580 link_with : [libsystemd_static,
2581 libshared_static],
2582 dependencies : [threads,
2583 libpam,
2584 libpam_misc,
2585 libcrypt],
2586 link_depends : pam_systemd_home_sym,
2587 install : true,
2588 install_dir : pamlibdir)
2589 endif
70a5db58
LP
2590endif
2591
6589a569 2592foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
ba081955 2593 (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
ba7f4ae6 2594 meson.add_install_script(meson_make_symlink,
fce9abb2
ZJS
2595 rootbindir / 'systemctl',
2596 rootsbindir / alias)
ba7f4ae6
ZJS
2597endforeach
2598
63e2d171 2599meson.add_install_script(meson_make_symlink,
fce9abb2
ZJS
2600 rootbindir / 'udevadm',
2601 rootlibexecdir / 'systemd-udevd')
63e2d171 2602
349cc4a5 2603if conf.get('ENABLE_BACKLIGHT') == 1
6164ec4c
ZJS
2604 executable(
2605 'systemd-backlight',
2606 'src/backlight/backlight.c',
2607 include_directories : includes,
2608 link_with : [libshared],
2609 install_rpath : rootlibexecdir,
2610 install : true,
2611 install_dir : rootlibexecdir)
5c23128d
ZJS
2612endif
2613
349cc4a5 2614if conf.get('ENABLE_RFKILL') == 1
6164ec4c
ZJS
2615 executable(
2616 'systemd-rfkill',
2617 'src/rfkill/rfkill.c',
2618 include_directories : includes,
2619 link_with : [libshared],
2620 install_rpath : rootlibexecdir,
2621 install : true,
2622 install_dir : rootlibexecdir)
2623endif
2624
2625executable(
2626 'systemd-system-update-generator',
2627 'src/system-update-generator/system-update-generator.c',
2628 include_directories : includes,
2629 link_with : [libshared],
2630 install_rpath : rootlibexecdir,
2631 install : true,
2632 install_dir : systemgeneratordir)
5c23128d 2633
349cc4a5 2634if conf.get('HAVE_LIBCRYPTSETUP') == 1
6164ec4c
ZJS
2635 executable(
2636 'systemd-cryptsetup',
2637 systemd_cryptsetup_sources,
2638 include_directories : includes,
2639 link_with : [libshared],
2640 dependencies : [libcryptsetup,
2641 libp11kit],
2642 install_rpath : rootlibexecdir,
2643 install : true,
2644 install_dir : rootlibexecdir)
2645
2646 executable(
2647 'systemd-cryptsetup-generator',
2648 'src/cryptsetup/cryptsetup-generator.c',
2649 include_directories : includes,
2650 link_with : [libshared],
6164ec4c
ZJS
2651 install_rpath : rootlibexecdir,
2652 install : true,
2653 install_dir : systemgeneratordir)
2654
2655 executable(
2656 'systemd-veritysetup',
2657 'src/veritysetup/veritysetup.c',
2658 include_directories : includes,
2659 link_with : [libshared],
2660 dependencies : [libcryptsetup],
2661 install_rpath : rootlibexecdir,
2662 install : true,
2663 install_dir : rootlibexecdir)
2664
2665 executable(
2666 'systemd-veritysetup-generator',
2667 'src/veritysetup/veritysetup-generator.c',
2668 include_directories : includes,
2669 link_with : [libshared],
6164ec4c
ZJS
2670 install_rpath : rootlibexecdir,
2671 install : true,
2672 install_dir : systemgeneratordir)
8710a681 2673
8710a681
LP
2674 executable(
2675 'systemd-cryptenroll',
2676 systemd_cryptenroll_sources,
2677 include_directories : includes,
2678 link_with : [libshared],
2679 dependencies : [libcryptsetup,
5e521624 2680 libdl,
8710a681
LP
2681 libopenssl,
2682 libp11kit],
2683 install_rpath : rootlibexecdir,
a1fd722b 2684 install : true)
1f1a2243
TA
2685
2686 executable(
2687 'systemd-integritysetup',
2688 ['src/integritysetup/integritysetup.c', 'src/integritysetup/integrity-util.c'],
2689 include_directories : includes,
2690 link_with : [libshared],
2691 dependencies : [libcryptsetup],
2692 install_rpath : rootlibexecdir,
2693 install : true,
2694 install_dir : rootlibexecdir)
2695
2696 executable(
2697 'systemd-integritysetup-generator',
2698 ['src/integritysetup/integritysetup-generator.c', 'src/integritysetup/integrity-util.c'],
2699 include_directories : includes,
2700 link_with : [libshared],
2701 install_rpath : rootlibexecdir,
2702 install : true,
2703 install_dir : systemgeneratordir)
5c23128d
ZJS
2704endif
2705
349cc4a5 2706if conf.get('HAVE_SYSV_COMPAT') == 1
e93ada98 2707 exe = executable(
6164ec4c
ZJS
2708 'systemd-sysv-generator',
2709 'src/sysv-generator/sysv-generator.c',
2710 include_directories : includes,
2711 link_with : [libshared],
2712 install_rpath : rootlibexecdir,
2713 install : true,
2714 install_dir : systemgeneratordir)
2715
e93ada98
DDM
2716 sysv_generator_test_py = find_program('test/sysv-generator-test.py')
2717 if want_tests != 'false'
2718 test('sysv-generator-test',
2719 sysv_generator_test_py,
2720 depends : exe)
2721 endif
2722
6164ec4c
ZJS
2723 executable(
2724 'systemd-rc-local-generator',
2725 'src/rc-local-generator/rc-local-generator.c',
2726 include_directories : includes,
2727 link_with : [libshared],
2728 install_rpath : rootlibexecdir,
2729 install : true,
2730 install_dir : systemgeneratordir)
5c23128d
ZJS
2731endif
2732
8feca247
BB
2733if conf.get('ENABLE_XDG_AUTOSTART') == 1
2734 executable(
2735 'systemd-xdg-autostart-generator',
0275e918 2736 systemd_xdg_autostart_generator_sources,
8feca247
BB
2737 include_directories : includes,
2738 link_with : [libshared],
2739 install_rpath : rootlibexecdir,
2740 install : true,
2741 install_dir : usergeneratordir)
2742
2743 executable(
2744 'systemd-xdg-autostart-condition',
2745 'src/xdg-autostart-generator/xdg-autostart-condition.c',
2746 include_directories : includes,
2747 link_with : [libshared],
2748 install_rpath : rootlibexecdir,
2749 install : true,
2750 install_dir : rootlibexecdir)
2751endif
2752
349cc4a5 2753if conf.get('ENABLE_HOSTNAMED') == 1
e3c68924 2754 dbus_programs += executable(
6164ec4c
ZJS
2755 'systemd-hostnamed',
2756 'src/hostname/hostnamed.c',
2757 include_directories : includes,
2758 link_with : [libshared],
2759 install_rpath : rootlibexecdir,
2760 install : true,
2761 install_dir : rootlibexecdir)
2762
2763 public_programs += executable(
2764 'hostnamectl',
2765 'src/hostname/hostnamectl.c',
2766 include_directories : includes,
2767 link_with : [libshared],
2768 install_rpath : rootlibexecdir,
2769 install : true)
5c23128d
ZJS
2770endif
2771
349cc4a5
ZJS
2772if conf.get('ENABLE_LOCALED') == 1
2773 if conf.get('HAVE_XKBCOMMON') == 1
bfa0ade9
AK
2774 # logind will load libxkbcommon.so dynamically on its own, but we still
2775 # need to specify where the headers are
2776 deps = [libdl, libxkbcommon.partial_dependency(compile_args: true)]
37efbbd8
ZJS
2777 else
2778 deps = []
2779 endif
2780
e3c68924 2781 dbus_programs += executable(
6164ec4c
ZJS
2782 'systemd-localed',
2783 systemd_localed_sources,
bfa0ade9 2784 include_directories : includes,
6164ec4c
ZJS
2785 link_with : [libshared],
2786 dependencies : deps,
2787 install_rpath : rootlibexecdir,
2788 install : true,
2789 install_dir : rootlibexecdir)
2790
2791 public_programs += executable(
2792 'localectl',
2793 localectl_sources,
2794 include_directories : includes,
2795 link_with : [libshared],
2796 install_rpath : rootlibexecdir,
2797 install : true)
5c23128d
ZJS
2798endif
2799
349cc4a5 2800if conf.get('ENABLE_TIMEDATED') == 1
e3c68924 2801 dbus_programs += executable(
6164ec4c
ZJS
2802 'systemd-timedated',
2803 'src/timedate/timedated.c',
2804 include_directories : includes,
2805 link_with : [libshared],
2806 install_rpath : rootlibexecdir,
2807 install : true,
2808 install_dir : rootlibexecdir)
6129ec85 2809endif
5c23128d 2810
6129ec85 2811if conf.get('ENABLE_TIMEDATECTL') == 1
6164ec4c
ZJS
2812 public_programs += executable(
2813 'timedatectl',
2814 'src/timedate/timedatectl.c',
2815 include_directories : includes,
2816 install_rpath : rootlibexecdir,
2817 link_with : [libshared],
2818 dependencies : [libm],
2819 install : true)
5c23128d
ZJS
2820endif
2821
349cc4a5 2822if conf.get('ENABLE_TIMESYNCD') == 1
6164ec4c
ZJS
2823 executable(
2824 'systemd-timesyncd',
2825 systemd_timesyncd_sources,
2826 include_directories : includes,
f5a5284e 2827 link_with : [libtimesyncd_core],
6164ec4c
ZJS
2828 dependencies : [threads,
2829 libm],
2830 install_rpath : rootlibexecdir,
2831 install : true,
2832 install_dir : rootlibexecdir)
2833
2834 executable(
2835 'systemd-time-wait-sync',
cf242350 2836 'src/timesync/wait-sync.c',
6164ec4c 2837 include_directories : includes,
f5a5284e 2838 link_with : [libtimesyncd_core],
6164ec4c
ZJS
2839 install_rpath : rootlibexecdir,
2840 install : true,
2841 install_dir : rootlibexecdir)
5c23128d
ZJS
2842endif
2843
349cc4a5 2844if conf.get('ENABLE_MACHINED') == 1
e3c68924 2845 dbus_programs += executable(
6164ec4c
ZJS
2846 'systemd-machined',
2847 systemd_machined_sources,
2848 include_directories : includes,
2849 link_with : [libmachine_core,
2850 libshared],
2851 install_rpath : rootlibexecdir,
2852 install : true,
2853 install_dir : rootlibexecdir)
2854
2855 public_programs += executable(
2856 'machinectl',
2857 'src/machine/machinectl.c',
2858 include_directories : includes,
2859 link_with : [libshared],
2860 dependencies : [threads,
2861 libxz,
ef5924aa
NL
2862 liblz4,
2863 libzstd],
6164ec4c
ZJS
2864 install_rpath : rootlibexecdir,
2865 install : true,
2866 install_dir : rootbindir)
5c23128d
ZJS
2867endif
2868
349cc4a5 2869if conf.get('ENABLE_IMPORTD') == 1
e3c68924 2870 dbus_programs += executable(
6164ec4c
ZJS
2871 'systemd-importd',
2872 systemd_importd_sources,
2873 include_directories : includes,
2874 link_with : [libshared],
2875 dependencies : [threads],
2876 install_rpath : rootlibexecdir,
2877 install : true,
2878 install_dir : rootlibexecdir)
2879
2880 systemd_pull = executable(
2881 'systemd-pull',
2882 systemd_pull_sources,
2883 include_directories : includes,
b93f018f
ZJS
2884 link_with : [libshared,
2885 lib_import_common],
6164ec4c
ZJS
2886 dependencies : [versiondep,
2887 libcurl,
6214d42b 2888 lib_openssl_or_gcrypt,
6164ec4c
ZJS
2889 libz,
2890 libbzip2,
6214d42b 2891 libxz],
6164ec4c
ZJS
2892 install_rpath : rootlibexecdir,
2893 install : true,
2894 install_dir : rootlibexecdir)
2895
2896 systemd_import = executable(
2897 'systemd-import',
2898 systemd_import_sources,
2899 include_directories : includes,
b93f018f
ZJS
2900 link_with : [libshared,
2901 lib_import_common],
6164ec4c
ZJS
2902 dependencies : [libcurl,
2903 libz,
2904 libbzip2,
2905 libxz],
2906 install_rpath : rootlibexecdir,
2907 install : true,
2908 install_dir : rootlibexecdir)
2909
2910 systemd_import_fs = executable(
2911 'systemd-import-fs',
2912 systemd_import_fs_sources,
2913 include_directories : includes,
b93f018f
ZJS
2914 link_with : [libshared,
2915 lib_import_common],
6164ec4c
ZJS
2916 install_rpath : rootlibexecdir,
2917 install : true,
2918 install_dir : rootlibexecdir)
2919
2920 systemd_export = executable(
2921 'systemd-export',
2922 systemd_export_sources,
2923 include_directories : includes,
b93f018f
ZJS
2924 link_with : [libshared,
2925 lib_import_common],
6164ec4c
ZJS
2926 dependencies : [libcurl,
2927 libz,
2928 libbzip2,
2929 libxz],
2930 install_rpath : rootlibexecdir,
2931 install : true,
2932 install_dir : rootlibexecdir)
1d7579c4
LP
2933
2934 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
37efbbd8
ZJS
2935endif
2936
349cc4a5 2937if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
6164ec4c
ZJS
2938 public_programs += executable(
2939 'systemd-journal-upload',
2940 systemd_journal_upload_sources,
2941 include_directories : includes,
2942 link_with : [libshared],
2943 dependencies : [versiondep,
2944 threads,
2945 libcurl,
2946 libgnutls,
2947 libxz,
ef5924aa
NL
2948 liblz4,
2949 libzstd],
6164ec4c
ZJS
2950 install_rpath : rootlibexecdir,
2951 install : true,
2952 install_dir : rootlibexecdir)
5c23128d
ZJS
2953endif
2954
349cc4a5 2955if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
6164ec4c
ZJS
2956 public_programs += executable(
2957 'systemd-journal-remote',
2958 systemd_journal_remote_sources,
035b0f8f 2959 include_directories : journal_includes,
6164ec4c
ZJS
2960 link_with : [libshared,
2961 libsystemd_journal_remote],
2962 dependencies : [threads,
2963 libmicrohttpd,
2964 libgnutls,
2965 libxz,
ef5924aa
NL
2966 liblz4,
2967 libzstd],
6164ec4c
ZJS
2968 install_rpath : rootlibexecdir,
2969 install : true,
2970 install_dir : rootlibexecdir)
2971
2972 public_programs += executable(
2973 'systemd-journal-gatewayd',
2974 systemd_journal_gatewayd_sources,
035b0f8f 2975 include_directories : journal_includes,
6164ec4c
ZJS
2976 link_with : [libshared],
2977 dependencies : [threads,
2978 libmicrohttpd,
2979 libgnutls,
2980 libxz,
ef5924aa
NL
2981 liblz4,
2982 libzstd],
6164ec4c
ZJS
2983 install_rpath : rootlibexecdir,
2984 install : true,
2985 install_dir : rootlibexecdir)
5c23128d
ZJS
2986endif
2987
349cc4a5 2988if conf.get('ENABLE_COREDUMP') == 1
6164ec4c
ZJS
2989 executable(
2990 'systemd-coredump',
2991 systemd_coredump_sources,
2992 include_directories : includes,
2993 link_with : [libshared],
2994 dependencies : [threads,
2995 libacl,
6164ec4c 2996 libxz,
ef5924aa
NL
2997 liblz4,
2998 libzstd],
6164ec4c
ZJS
2999 install_rpath : rootlibexecdir,
3000 install : true,
3001 install_dir : rootlibexecdir)
3002
3003 public_programs += executable(
3004 'coredumpctl',
3005 coredumpctl_sources,
3006 include_directories : includes,
3007 link_with : [libshared],
3008 dependencies : [threads,
3009 libxz,
ef5924aa
NL
3010 liblz4,
3011 libzstd],
6164ec4c
ZJS
3012 install_rpath : rootlibexecdir,
3013 install : true)
5c23128d
ZJS
3014endif
3015
9b4abc69 3016if conf.get('ENABLE_PSTORE') == 1
6164ec4c
ZJS
3017 executable(
3018 'systemd-pstore',
3019 systemd_pstore_sources,
3020 include_directories : includes,
3021 link_with : [libshared],
3022 dependencies : [threads,
3023 libacl,
6164ec4c 3024 libxz,
ef5924aa
NL
3025 liblz4,
3026 libzstd],
6164ec4c
ZJS
3027 install_rpath : rootlibexecdir,
3028 install : true,
3029 install_dir : rootlibexecdir)
9b4abc69
ED
3030endif
3031
9de5e321 3032if conf.get('ENABLE_OOMD') == 1
e3c68924 3033 dbus_programs += executable('systemd-oomd',
9de5e321
AZ
3034 systemd_oomd_sources,
3035 include_directories : includes,
3036 link_with : [libshared],
3037 dependencies : [],
3038 install_rpath : rootlibexecdir,
3039 install : true,
3040 install_dir : rootlibexecdir)
5c616ecf
AZ
3041
3042 public_programs += executable(
ba081955
ZJS
3043 'oomctl',
3044 oomctl_sources,
3045 include_directories : includes,
3046 link_with : [libshared],
3047 dependencies : [],
3048 install_rpath : rootlibexecdir,
cfd4c84a 3049 install : true)
9de5e321
AZ
3050endif
3051
349cc4a5 3052if conf.get('ENABLE_BINFMT') == 1
6164ec4c
ZJS
3053 public_programs += executable(
3054 'systemd-binfmt',
3055 'src/binfmt/binfmt.c',
3056 include_directories : includes,
3057 link_with : [libshared],
3058 install_rpath : rootlibexecdir,
3059 install : true,
3060 install_dir : rootlibexecdir)
37efbbd8 3061
7c22f07c
ZJS
3062 meson.add_install_script('sh', '-c',
3063 mkdir_p.format(binfmtdir))
d7aa78c3 3064 if install_sysconfdir
7c22f07c 3065 meson.add_install_script('sh', '-c',
fce9abb2 3066 mkdir_p.format(sysconfdir / 'binfmt.d'))
d7aa78c3 3067 endif
37efbbd8
ZJS
3068endif
3069
e594a3b1 3070if conf.get('ENABLE_REPART') == 1
6164ec4c
ZJS
3071 exe = executable(
3072 'systemd-repart',
3073 systemd_repart_sources,
3074 include_directories : includes,
3075 link_with : [libshared],
3076 dependencies : [threads,
6164ec4c 3077 libblkid,
6b12086e 3078 libfdisk],
6164ec4c
ZJS
3079 install_rpath : rootlibexecdir,
3080 install : true,
3081 install_dir : rootbindir)
2d2d0a57 3082 public_programs += exe
e29e4d57
ZJS
3083
3084 if want_tests != 'false'
3085 test('test-repart',
3086 test_repart_sh,
3087 args : exe.full_path())
3088 endif
e594a3b1
LP
3089endif
3090
43cc7a3e
LP
3091if conf.get('ENABLE_SYSUPDATE') == 1
3092 exe = executable(
3093 'systemd-sysupdate',
3094 systemd_sysupdate_sources,
3095 include_directories : includes,
3096 link_with : [libshared],
3097 dependencies : [threads,
3098 libblkid,
3099 libfdisk,
3100 libopenssl],
3101 install_rpath : rootlibexecdir,
3102 install : true,
3103 install_dir : rootlibexecdir)
3104 public_programs += exe
3105endif
3106
349cc4a5 3107if conf.get('ENABLE_VCONSOLE') == 1
6164ec4c
ZJS
3108 executable(
3109 'systemd-vconsole-setup',
3110 'src/vconsole/vconsole-setup.c',
3111 include_directories : includes,
3112 link_with : [libshared],
3113 install_rpath : rootlibexecdir,
3114 install : true,
3115 install_dir : rootlibexecdir)
5c23128d
ZJS
3116endif
3117
349cc4a5 3118if conf.get('ENABLE_RANDOMSEED') == 1
6164ec4c
ZJS
3119 executable(
3120 'systemd-random-seed',
3121 'src/random-seed/random-seed.c',
3122 include_directories : includes,
3123 link_with : [libshared],
3124 install_rpath : rootlibexecdir,
3125 install : true,
3126 install_dir : rootlibexecdir)
5c23128d
ZJS
3127endif
3128
349cc4a5 3129if conf.get('ENABLE_FIRSTBOOT') == 1
6164ec4c
ZJS
3130 executable(
3131 'systemd-firstboot',
3132 'src/firstboot/firstboot.c',
3133 include_directories : includes,
3134 link_with : [libshared],
3135 dependencies : [libcrypt],
3136 install_rpath : rootlibexecdir,
3137 install : true,
3138 install_dir : rootbindir)
3139endif
3140
3141executable(
3142 'systemd-remount-fs',
3143 'src/remount-fs/remount-fs.c',
3144 include_directories : includes,
bac11cd6 3145 link_with : [libshared],
6164ec4c
ZJS
3146 install_rpath : rootlibexecdir,
3147 install : true,
3148 install_dir : rootlibexecdir)
5c23128d 3149
6164ec4c
ZJS
3150executable(
3151 'systemd-machine-id-setup',
3152 'src/machine-id-setup/machine-id-setup-main.c',
3153 include_directories : includes,
bac11cd6 3154 link_with : [libshared],
6164ec4c
ZJS
3155 install_rpath : rootlibexecdir,
3156 install : true,
3157 install_dir : rootbindir)
5c23128d 3158
6164ec4c
ZJS
3159executable(
3160 'systemd-fsck',
3161 'src/fsck/fsck.c',
3162 include_directories : includes,
3163 link_with : [libshared],
3164 install_rpath : rootlibexecdir,
3165 install : true,
3166 install_dir : rootlibexecdir)
5c23128d 3167
80750adb
ZJS
3168executable('systemd-growfs',
3169 'src/partition/growfs.c',
3170 include_directories : includes,
3171 link_with : [libshared],
3172 install_rpath : rootlibexecdir,
3173 install : true,
3174 install_dir : rootlibexecdir)
3175
6164ec4c
ZJS
3176executable(
3177 'systemd-makefs',
3178 'src/partition/makefs.c',
3179 include_directories : includes,
3180 link_with : [libshared],
3181 install_rpath : rootlibexecdir,
3182 install : true,
3183 install_dir : rootlibexecdir)
b7f28ac5 3184
6164ec4c
ZJS
3185executable(
3186 'systemd-sleep',
3187 'src/sleep/sleep.c',
3188 include_directories : includes,
3189 link_with : [libshared],
3190 install_rpath : rootlibexecdir,
3191 install : true,
3192 install_dir : rootlibexecdir)
5c23128d 3193
225d08b8 3194if install_sysconfdir_samples
d7aa78c3
JT
3195 install_data('src/sleep/sleep.conf',
3196 install_dir : pkgsysconfdir)
3197endif
d25e127d 3198
6164ec4c
ZJS
3199public_programs += executable(
3200 'systemd-sysctl',
3201 'src/sysctl/sysctl.c',
3202 include_directories : includes,
3203 link_with : [libshared],
3204 install_rpath : rootlibexecdir,
3205 install : true,
3206 install_dir : rootlibexecdir)
5c23128d 3207
6164ec4c
ZJS
3208executable(
3209 'systemd-ac-power',
3210 'src/ac-power/ac-power.c',
3211 include_directories : includes,
3212 link_with : [libshared],
3213 install_rpath : rootlibexecdir,
3214 install : true,
3215 install_dir : rootlibexecdir)
5c23128d 3216
6164ec4c
ZJS
3217public_programs += executable(
3218 'systemd-detect-virt',
3219 'src/detect-virt/detect-virt.c',
3220 include_directories : includes,
3221 link_with : [libshared],
3222 install_rpath : rootlibexecdir,
3223 install : true)
5c23128d 3224
6164ec4c
ZJS
3225public_programs += executable(
3226 'systemd-delta',
3227 'src/delta/delta.c',
3228 include_directories : includes,
3229 link_with : [libshared],
3230 install_rpath : rootlibexecdir,
3231 install : true)
5c23128d 3232
6164ec4c
ZJS
3233public_programs += executable(
3234 'systemd-escape',
3235 'src/escape/escape.c',
3236 include_directories : includes,
3237 link_with : [libshared],
3238 install_rpath : rootlibexecdir,
3239 install : true,
3240 install_dir : rootbindir)
3241
3242public_programs += executable(
3243 'systemd-notify',
3244 'src/notify/notify.c',
3245 include_directories : includes,
3246 link_with : [libshared],
3247 install_rpath : rootlibexecdir,
3248 install : true,
3249 install_dir : rootbindir)
3250
5945640e
LP
3251public_programs += executable(
3252 'systemd-creds',
3253 'src/creds/creds.c',
3254 include_directories : includes,
3255 link_with : [libshared],
3256 dependencies : [threads,
3257 libopenssl],
3258 install_rpath : rootlibexecdir,
3259 install : true,
3260 install_dir : rootbindir)
3261
6164ec4c
ZJS
3262executable(
3263 'systemd-volatile-root',
3264 'src/volatile-root/volatile-root.c',
3265 include_directories : includes,
3266 link_with : [libshared],
3267 install_rpath : rootlibexecdir,
cdf7ad38 3268 install : conf.get('ENABLE_INITRD') == 1,
6164ec4c
ZJS
3269 install_dir : rootlibexecdir)
3270
3271executable(
3272 'systemd-cgroups-agent',
3273 'src/cgroups-agent/cgroups-agent.c',
3274 include_directories : includes,
3275 link_with : [libshared],
3276 install_rpath : rootlibexecdir,
3277 install : true,
3278 install_dir : rootlibexecdir)
3279
3280public_programs += executable(
3281 'systemd-id128',
3282 'src/id128/id128.c',
3283 include_directories : includes,
3284 link_with : [libshared],
3285 install_rpath : rootlibexecdir,
3286 install : true)
3287
3288public_programs += executable(
3289 'systemd-path',
3290 'src/path/path.c',
3291 include_directories : includes,
3292 link_with : [libshared],
3293 install_rpath : rootlibexecdir,
3294 install : true)
3295
3296public_programs += executable(
3297 'systemd-ask-password',
3298 'src/ask-password/ask-password.c',
3299 include_directories : includes,
3300 link_with : [libshared],
3301 install_rpath : rootlibexecdir,
3302 install : true,
3303 install_dir : rootbindir)
3304
3305executable(
3306 'systemd-reply-password',
3307 'src/reply-password/reply-password.c',
3308 include_directories : includes,
3309 link_with : [libshared],
3310 install_rpath : rootlibexecdir,
3311 install : true,
3312 install_dir : rootlibexecdir)
3313
3314public_programs += executable(
3315 'systemd-tty-ask-password-agent',
3316 'src/tty-ask-password-agent/tty-ask-password-agent.c',
3317 include_directories : includes,
3318 link_with : [libshared],
3319 install_rpath : rootlibexecdir,
3320 install : true,
3321 install_dir : rootbindir)
3322
3323public_programs += executable(
3324 'systemd-cgls',
3325 'src/cgls/cgls.c',
3326 include_directories : includes,
3327 link_with : [libshared],
3328 install_rpath : rootlibexecdir,
3329 install : true)
3330
3331public_programs += executable(
3332 'systemd-cgtop',
3333 'src/cgtop/cgtop.c',
3334 include_directories : includes,
3335 link_with : [libshared],
3336 install_rpath : rootlibexecdir,
3337 install : true)
3338
3339executable(
3340 'systemd-initctl',
3341 'src/initctl/initctl.c',
3342 include_directories : includes,
3343 link_with : [libshared],
3344 install_rpath : rootlibexecdir,
6589a569 3345 install : (conf.get('HAVE_SYSV_COMPAT') == 1),
6164ec4c 3346 install_dir : rootlibexecdir)
5c23128d 3347
6164ec4c
ZJS
3348public_programs += executable(
3349 'systemd-mount',
3350 'src/mount/mount-tool.c',
3351 include_directories : includes,
3352 link_with : [libshared],
3353 dependencies: [libmount],
3354 install_rpath : rootlibexecdir,
3355 install : true)
5c23128d 3356
7b76fce1 3357meson.add_install_script(meson_make_symlink,
fce9abb2 3358 'systemd-mount', bindir / 'systemd-umount')
7b76fce1 3359
6164ec4c
ZJS
3360public_programs += executable(
3361 'systemd-run',
3362 'src/run/run.c',
3363 include_directories : includes,
3364 link_with : [libshared],
3365 install_rpath : rootlibexecdir,
3366 install : true)
3367
3368public_programs += executable(
3369 'systemd-stdio-bridge',
3370 'src/stdio-bridge/stdio-bridge.c',
3371 include_directories : includes,
3372 link_with : [libshared],
3373 dependencies : [versiondep],
3374 install_rpath : rootlibexecdir,
3375 install : true)
3376
3377public_programs += executable(
3378 'busctl',
f98df767 3379 busctl_sources,
6164ec4c
ZJS
3380 include_directories : includes,
3381 link_with : [libshared],
7c4bd9ac 3382 dependencies : [versiondep],
6164ec4c
ZJS
3383 install_rpath : rootlibexecdir,
3384 install : true)
5c23128d 3385
bd7e6aa7
ZJS
3386if enable_sysusers
3387 exe = executable(
6164ec4c
ZJS
3388 'systemd-sysusers',
3389 'src/sysusers/sysusers.c',
3390 include_directories : includes,
3391 link_with : [libshared],
3392 install_rpath : rootlibexecdir,
3393 install : true,
3394 install_dir : rootbindir)
bd7e6aa7
ZJS
3395 public_programs += exe
3396
3397 if want_tests != 'false'
3398 test('test-sysusers',
3399 test_sysusers_sh,
3400 # https://github.com/mesonbuild/meson/issues/2681
3401 args : exe.full_path())
3402 endif
8ef8f3d5
FB
3403
3404 if have_standalone_binaries
bd7e6aa7 3405 exe = executable(
8ef8f3d5
FB
3406 'systemd-sysusers.standalone',
3407 'src/sysusers/sysusers.c',
3408 include_directories : includes,
3537577c 3409 c_args : '-DSTANDALONE',
8ef8f3d5
FB
3410 link_with : [libshared_static,
3411 libbasic,
3412 libbasic_gcrypt,
99b9f8fd 3413 libsystemd_static],
8ef8f3d5
FB
3414 install : true,
3415 install_dir : rootbindir)
bd7e6aa7
ZJS
3416 public_programs += exe
3417
3418 if want_tests != 'false'
3419 test('test-sysusers.standalone',
3420 test_sysusers_sh,
3421 # https://github.com/mesonbuild/meson/issues/2681
3422 args : exe.full_path())
3423 endif
8ef8f3d5 3424 endif
5c23128d
ZJS
3425endif
3426
349cc4a5 3427if conf.get('ENABLE_TMPFILES') == 1
6164ec4c
ZJS
3428 exe = executable(
3429 'systemd-tmpfiles',
db64ba81 3430 systemd_tmpfiles_sources,
6164ec4c
ZJS
3431 include_directories : includes,
3432 link_with : [libshared],
3433 dependencies : [libacl],
3434 install_rpath : rootlibexecdir,
3435 install : true,
3436 install_dir : rootbindir)
5a8b1640 3437 public_programs += exe
d9daae55 3438
938be089
ZJS
3439 if want_tests != 'false'
3440 test('test-systemd-tmpfiles',
3441 test_systemd_tmpfiles_py,
3442 # https://github.com/mesonbuild/meson/issues/2681
3443 args : exe.full_path())
3444 endif
db64ba81
FB
3445
3446 if have_standalone_binaries
3447 public_programs += executable(
3448 'systemd-tmpfiles.standalone',
3449 systemd_tmpfiles_sources,
3450 include_directories : includes,
3537577c 3451 c_args : '-DSTANDALONE',
db64ba81
FB
3452 link_with : [libshared_static,
3453 libbasic,
3454 libbasic_gcrypt,
99b9f8fd 3455 libsystemd_static],
db64ba81
FB
3456 dependencies : [libacl],
3457 install : true,
3458 install_dir : rootbindir)
3459 endif
5c23128d
ZJS
3460endif
3461
349cc4a5 3462if conf.get('ENABLE_HWDB') == 1
ecd1bfdd 3463 systemd_hwdb = executable(
6164ec4c
ZJS
3464 'systemd-hwdb',
3465 'src/hwdb/hwdb.c',
6164ec4c 3466 include_directories : includes,
e4b127e2 3467 link_with : udev_link_with,
6164ec4c
ZJS
3468 install_rpath : udev_rpath,
3469 install : true,
3470 install_dir : rootbindir)
ecd1bfdd
ZJS
3471 public_programs += systemd_hwdb
3472
3473 if want_tests != 'false'
3474 test('hwdb-test',
3475 hwdb_test_sh,
3476 args : [systemd_hwdb.full_path()],
3477 timeout : 90)
3478 endif
37efbbd8
ZJS
3479endif
3480
349cc4a5 3481if conf.get('ENABLE_QUOTACHECK') == 1
6164ec4c
ZJS
3482 executable(
3483 'systemd-quotacheck',
3484 'src/quotacheck/quotacheck.c',
3485 include_directories : includes,
3486 link_with : [libshared],
3487 install_rpath : rootlibexecdir,
3488 install : true,
3489 install_dir : rootlibexecdir)
3490endif
3491
3492public_programs += executable(
3493 'systemd-socket-proxyd',
3494 'src/socket-proxy/socket-proxyd.c',
3495 include_directories : includes,
3496 link_with : [libshared],
3497 dependencies : [threads],
3498 install_rpath : rootlibexecdir,
3499 install : true,
3500 install_dir : rootlibexecdir)
5c23128d 3501
6164ec4c
ZJS
3502public_programs += executable(
3503 'udevadm',
3504 udevadm_sources,
6164ec4c 3505 include_directories : includes,
e4b127e2 3506 link_with : [libudevd_core],
6164ec4c
ZJS
3507 dependencies : [versiondep,
3508 threads,
3509 libkmod,
3510 libidn,
3511 libacl,
3512 libblkid],
3513 install_rpath : udev_rpath,
3514 install : true,
3515 install_dir : rootbindir)
3516
3517executable(
3518 'systemd-shutdown',
3519 systemd_shutdown_sources,
3520 include_directories : includes,
bac11cd6 3521 link_with : [libshared],
6164ec4c
ZJS
3522 dependencies : [libmount],
3523 install_rpath : rootlibexecdir,
3524 install : true,
3525 install_dir : rootlibexecdir)
3526
3527executable(
3528 'systemd-update-done',
3529 'src/update-done/update-done.c',
3530 include_directories : includes,
3531 link_with : [libshared],
3532 install_rpath : rootlibexecdir,
3533 install : true,
3534 install_dir : rootlibexecdir)
3535
3536executable(
3537 'systemd-update-utmp',
3538 'src/update-utmp/update-utmp.c',
3539 include_directories : includes,
3540 link_with : [libshared],
3541 dependencies : [libaudit],
3542 install_rpath : rootlibexecdir,
55678b9e 3543 install : (conf.get('ENABLE_UTMP') == 1),
6164ec4c 3544 install_dir : rootlibexecdir)
5c23128d 3545
349cc4a5 3546if conf.get('HAVE_KMOD') == 1
6164ec4c
ZJS
3547 executable(
3548 'systemd-modules-load',
3549 'src/modules-load/modules-load.c',
3550 include_directories : includes,
3551 link_with : [libshared],
3552 dependencies : [libkmod],
3553 install_rpath : rootlibexecdir,
3554 install : true,
3555 install_dir : rootlibexecdir)
94e75a54 3556
7c22f07c
ZJS
3557 meson.add_install_script('sh', '-c',
3558 mkdir_p.format(modulesloaddir))
d7aa78c3 3559 if install_sysconfdir
7c22f07c 3560 meson.add_install_script('sh', '-c',
fce9abb2 3561 mkdir_p.format(sysconfdir / 'modules-load.d'))
d7aa78c3 3562 endif
5c23128d
ZJS
3563endif
3564
6164ec4c
ZJS
3565public_programs += executable(
3566 'systemd-nspawn',
3567 systemd_nspawn_sources,
3568 include_directories : includes,
bac11cd6 3569 link_with : [libnspawn_core,
6164ec4c
ZJS
3570 libshared],
3571 dependencies : [libblkid,
3572 libseccomp],
3573 install_rpath : rootlibexecdir,
3574 install : true)
5c23128d 3575
349cc4a5 3576if conf.get('ENABLE_NETWORKD') == 1
9ff2b35f 3577 dbus_programs += executable(
6164ec4c
ZJS
3578 'systemd-networkd',
3579 systemd_networkd_sources,
8d40961c 3580 include_directories : network_includes,
6164ec4c
ZJS
3581 link_with : [libnetworkd_core,
3582 libsystemd_network,
6164ec4c
ZJS
3583 networkd_link_with],
3584 dependencies : [threads],
3585 install_rpath : rootlibexecdir,
3586 install : true,
3587 install_dir : rootlibexecdir)
3588
3589 executable(
3590 'systemd-networkd-wait-online',
3591 systemd_networkd_wait_online_sources,
3592 include_directories : includes,
8d40961c 3593 link_with : [networkd_link_with],
6164ec4c
ZJS
3594 install_rpath : rootlibexecdir,
3595 install : true,
3596 install_dir : rootlibexecdir)
3597
3598 public_programs += executable(
3599 'networkctl',
3600 networkctl_sources,
8d40961c 3601 include_directories : libsystemd_network_includes,
6164ec4c
ZJS
3602 link_with : [libsystemd_network,
3603 networkd_link_with],
3604 install_rpath : rootlibexecdir,
3605 install : true,
3606 install_dir : rootbindir)
987dd89c 3607endif
6164ec4c 3608
987dd89c
YW
3609exe = executable(
3610 'systemd-network-generator',
3611 network_generator_sources,
3612 include_directories : includes,
3613 link_with : [networkd_link_with],
3614 install_rpath : rootlibexecdir,
3615 install : true,
3616 install_dir : rootlibexecdir)
fbaa1137 3617
987dd89c
YW
3618if want_tests != 'false'
3619 test('test-network-generator-conversion',
3620 test_network_generator_conversion_sh,
3621 # https://github.com/mesonbuild/meson/issues/2681
e93ada98
DDM
3622 args : exe.full_path(),
3623 depends : exe)
dcfe072a 3624endif
e821f6a9 3625
6164ec4c
ZJS
3626executable(
3627 'systemd-sulogin-shell',
73e994f2 3628 'src/sulogin-shell/sulogin-shell.c',
6164ec4c
ZJS
3629 include_directories : includes,
3630 link_with : [libshared],
3631 install_rpath : rootlibexecdir,
3632 install : true,
3633 install_dir : rootlibexecdir)
e821f6a9 3634
69e96427
ZJS
3635############################################################
3636
e93ada98 3637runtest_env = custom_target(
e2d41370
FB
3638 'systemd-runtest.env',
3639 output : 'systemd-runtest.env',
0f4c4f38
ZJS
3640 command : [sh, '-c',
3641 '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format(
fce9abb2
ZJS
3642 project_source_root / 'test',
3643 project_build_root / 'catalog')],
e93ada98 3644 depends : catalogs,
e2d41370
FB
3645 build_by_default : true)
3646
a626cb15
ZJS
3647test_cflags = ['-DTEST_CODE=1']
3648# We intentionally do not do inline initializations with definitions for a
3649# bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
3650# use the variable unexpectedly. This triggers a lot of maybe-uninitialized
3651# false positives when the combination of -O2 and -flto is used. Suppress them.
3652if '-O2' in get_option('c_args') and '-flto=auto' in get_option('c_args')
3653 test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
3654endif
3655
69e96427 3656foreach tuple : tests
37efbbd8 3657 sources = tuple[0]
5acb3cab
YW
3658 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3659 dependencies = tuple.length() > 2 ? tuple[2] : []
3660 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3661 condition = tuple.length() > 4 ? tuple[4] : ''
3662 type = tuple.length() > 5 ? tuple[5] : ''
3663 defs = tuple.length() > 6 ? tuple[6] : []
a626cb15 3664 defs += test_cflags
5acb3cab 3665 parallel = tuple.length() > 7 ? tuple[7] : true
37efbbd8
ZJS
3666 timeout = 30
3667
e1eeebbb
JJ
3668 # FIXME: Use fs.stem() with meson >= 0.54.0
3669 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
37efbbd8
ZJS
3670 if type.startswith('timeout=')
3671 timeout = type.split('=')[1].to_int()
3672 type = ''
3673 endif
3b2bdd62
ZJS
3674
3675 if condition == '' or conf.get(condition) == 1
37efbbd8
ZJS
3676 exe = executable(
3677 name,
3678 sources,
3679 include_directories : incs,
3680 link_with : link_with,
60722ad7
ZJS
3681 dependencies : [versiondep,
3682 dependencies],
37efbbd8 3683 c_args : defs,
3b2bdd62 3684 build_by_default : want_tests != 'false',
37efbbd8 3685 install_rpath : rootlibexecdir,
7cdd9783 3686 install : install_tests,
e93ada98
DDM
3687 install_dir : testsdir / type,
3688 link_depends : runtest_env)
37efbbd8
ZJS
3689
3690 if type == 'manual'
3691 message('@0@ is a manual test'.format(name))
3692 elif type == 'unsafe' and want_tests != 'unsafe'
3693 message('@0@ is an unsafe test'.format(name))
3b2bdd62 3694 elif want_tests != 'false'
37efbbd8
ZJS
3695 test(name, exe,
3696 env : test_env,
3697 timeout : timeout)
3698 endif
3699 else
3700 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
3701 endif
69e96427
ZJS
3702endforeach
3703
0632b4cd 3704exe = executable(
37efbbd8
ZJS
3705 'test-libsystemd-sym',
3706 test_libsystemd_sym_c,
3707 include_directories : includes,
3708 link_with : [libsystemd],
fd1939fb 3709 build_by_default : want_tests != 'false',
37efbbd8
ZJS
3710 install : install_tests,
3711 install_dir : testsdir)
938be089
ZJS
3712if want_tests != 'false'
3713 test('test-libsystemd-sym', exe)
3714endif
37ab1a25 3715
0632b4cd
ZJS
3716exe = executable(
3717 'test-libsystemd-static-sym',
3718 test_libsystemd_sym_c,
3719 include_directories : includes,
0632b4cd
ZJS
3720 link_with : [install_libsystemd_static],
3721 dependencies : [threads], # threads is already included in dependencies on the library,
3722 # but does not seem to get propagated. Add here as a work-around.
fd1939fb 3723 build_by_default : want_tests != 'false' and static_libsystemd_pic,
20f3d32d 3724 install : install_tests and static_libsystemd_pic,
0632b4cd 3725 install_dir : testsdir)
938be089 3726if want_tests != 'false' and static_libsystemd_pic
0632b4cd
ZJS
3727 test('test-libsystemd-static-sym', exe)
3728endif
37ab1a25 3729
0632b4cd 3730exe = executable(
37efbbd8
ZJS
3731 'test-libudev-sym',
3732 test_libudev_sym_c,
e4b127e2 3733 include_directories : libudev_includes,
a626cb15 3734 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
37efbbd8 3735 link_with : [libudev],
fd1939fb 3736 build_by_default : want_tests != 'false',
37efbbd8
ZJS
3737 install : install_tests,
3738 install_dir : testsdir)
938be089
ZJS
3739if want_tests != 'false'
3740 test('test-libudev-sym', exe)
3741endif
0632b4cd
ZJS
3742
3743exe = executable(
3744 'test-libudev-static-sym',
3745 test_libudev_sym_c,
e4b127e2 3746 include_directories : libudev_includes,
a626cb15 3747 c_args : ['-Wno-deprecated-declarations'] + test_cflags,
0632b4cd 3748 link_with : [install_libudev_static],
fd1939fb 3749 build_by_default : want_tests != 'false' and static_libudev_pic,
20f3d32d 3750 install : install_tests and static_libudev_pic,
0632b4cd 3751 install_dir : testsdir)
938be089 3752if want_tests != 'false' and static_libudev_pic
0632b4cd
ZJS
3753 test('test-libudev-static-sym', exe)
3754endif
e0bec52f 3755
69e96427 3756############################################################
5c23128d 3757
7db7d5b7
JR
3758fuzzer_exes = []
3759
7e299ffe
ZJS
3760foreach tuple : fuzzers
3761 sources = tuple[0]
5acb3cab
YW
3762 link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
3763 dependencies = tuple.length() > 2 ? tuple[2] : []
3764 incs = tuple.length() > 3 and tuple[3].length() > 0 ? tuple[3] : includes
3765 defs = tuple.length() > 4 ? tuple[4] : []
7e299ffe
ZJS
3766 link_args = []
3767
3768 if want_ossfuzz
3769 dependencies += fuzzing_engine
3770 elif want_libfuzzer
3771 if fuzzing_engine.found()
9c5c4677
EV
3772 dependencies += fuzzing_engine
3773 else
7e299ffe 3774 link_args += ['-fsanitize=fuzzer']
9c5c4677 3775 endif
7e299ffe
ZJS
3776 else
3777 sources += 'src/fuzz/fuzz-main.c'
3778 endif
7db7d5b7 3779
bbec46c8
JJ
3780 # FIXME: Use fs.stem() with meson >= 0.54.0
3781 name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
7db7d5b7 3782
f78ad5f0 3783 exe = executable(
7e299ffe
ZJS
3784 name,
3785 sources,
3786 include_directories : [incs, include_directories('src/fuzz')],
3787 link_with : link_with,
3788 dependencies : dependencies,
a626cb15 3789 c_args : defs + test_cflags,
7e299ffe
ZJS
3790 link_args: link_args,
3791 install : false,
f78ad5f0
ZJS
3792 build_by_default : fuzzer_build)
3793 fuzzer_exes += exe
3794
3795 if want_tests != 'false'
3796 # Run the fuzz regression tests without any sanitizers enabled.
3797 # Additional invocations with sanitizers may be added below.
3798 foreach p : fuzz_regression_tests
3799 b = p.split('/')[-2]
3800 c = p.split('/')[-1]
3801
3802 if b == name
3803 test('@0@_@1@'.format(b, c),
3804 exe,
fce9abb2 3805 args : [project_source_root / p])
f78ad5f0
ZJS
3806 endif
3807 endforeach
3808 endif
7e299ffe 3809endforeach
7db7d5b7 3810
6839ce33 3811alias_target('fuzzers', fuzzer_exes)
7db7d5b7
JR
3812
3813############################################################
3814
378e9d2b 3815subdir('modprobe.d')
5c23128d
ZJS
3816subdir('sysctl.d')
3817subdir('sysusers.d')
3818subdir('tmpfiles.d')
4f10b807
ZJS
3819subdir('hwdb.d')
3820subdir('units')
e783f957 3821subdir('presets')
5c23128d
ZJS
3822subdir('network')
3823subdir('man')
3824subdir('shell-completion/bash')
3825subdir('shell-completion/zsh')
9e825ebf
FB
3826subdir('docs/sysvinit')
3827subdir('docs/var-log')
5c23128d 3828
5c23128d
ZJS
3829install_subdir('factory/etc',
3830 install_dir : factorydir)
623370e6 3831subdir('factory/templates')
5c23128d 3832
d7aa78c3
JT
3833if install_sysconfdir
3834 install_data('xorg/50-systemd-user.sh',
3835 install_dir : xinitrcdir)
3836endif
f09eb768 3837install_data('LICENSE.GPL2',
5c23128d 3838 'LICENSE.LGPL2.1',
f09eb768
LP
3839 'NEWS',
3840 'README',
eea98402 3841 'docs/CODING_STYLE.md',
1d1cb168 3842 'docs/DISTRO_PORTING.md',
9e825ebf 3843 'docs/ENVIRONMENT.md',
5425f8a5 3844 'docs/HACKING.md',
9e825ebf 3845 'docs/TRANSIENT-SETTINGS.md',
b6dc0d7d 3846 'docs/TRANSLATORS.md',
9e825ebf 3847 'docs/UIDS-GIDS.md',
2bc48bbd 3848 'docs/GVARIANT-SERIALIZATION.md',
5c23128d 3849 install_dir : docdir)
d68b342b 3850
9c6e32a2
LB
3851install_subdir('LICENSES',
3852 install_dir : docdir)
3853
7c22f07c
ZJS
3854meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
3855meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
94e75a54 3856
d68b342b
ZJS
3857############################################################
3858
2d4efd1d
LB
3859# Ensure that changes to the docs/ directory do not break the
3860# basic Github pages build. But only run it in developer mode,
3861# as it might be fragile due to changes in the tooling, and it is
3862# not generally useful for users.
3863jekyll = find_program('jekyll', required : false)
3864if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
3865 test('github-pages',
3866 jekyll,
3867 args : ['build',
fce9abb2
ZJS
3868 '--source', project_source_root / 'docs',
3869 '--destination', project_build_root / '_site'])
2d4efd1d
LB
3870endif
3871
3872############################################################
3873
dd1e33c8 3874check_help = find_program('tools/check-help.sh')
005a29f2
ZJS
3875
3876foreach exec : public_programs
37efbbd8 3877 name = exec.full_path().split('/')[-1]
938be089
ZJS
3878 if want_tests != 'false'
3879 test('check-help-' + name,
dd1e33c8 3880 check_help,
e93ada98
DDM
3881 args : exec.full_path(),
3882 depends: exec)
938be089 3883 endif
005a29f2
ZJS
3884endforeach
3885
3886############################################################
3887
c6448ee3
ZJS
3888check_directives_sh = find_program('tools/check-directives.sh')
3889
3890if want_tests != 'false'
3891 test('check-directives',
3892 check_directives_sh,
34fde9f8 3893 args : [project_source_root, project_build_root])
c6448ee3
ZJS
3894endif
3895
3896############################################################
3897
52d4d1d3
ZJS
3898# Enable tests for all supported sanitizers
3899foreach tuple : sanitizers
3900 sanitizer = tuple[0]
3901 build = tuple[1]
b68dfb9e 3902
7a6397d2 3903 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
52d4d1d3
ZJS
3904 prev = ''
3905 foreach p : fuzz_regression_tests
3906 b = p.split('/')[-2]
3907 c = p.split('/')[-1]
3908
3909 name = '@0@:@1@'.format(b, sanitizer)
3910
3911 if name != prev
3912 if want_tests == 'false'
3913 message('Not compiling @0@ because tests is set to false'.format(name))
1763ef1d 3914 elif fuzz_tests
52d4d1d3
ZJS
3915 exe = custom_target(
3916 name,
3917 output : name,
3918 depends : build,
0f4c4f38 3919 command : [ln, '-fs',
fce9abb2 3920 build.full_path() / b,
52d4d1d3
ZJS
3921 '@OUTPUT@'],
3922 build_by_default : true)
3923 else
1763ef1d 3924 message('Not compiling @0@ because fuzz-tests is set to false'.format(name))
52d4d1d3
ZJS
3925 endif
3926 endif
3927 prev = name
3928
1763ef1d 3929 if fuzz_tests
0f82a2ab 3930 test('@0@_@1@_@2@'.format(b, c, sanitizer),
52d4d1d3 3931 env,
89767158
EV
3932 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
3933 timeout : 60,
52d4d1d3 3934 args : [exe.full_path(),
fce9abb2 3935 project_source_root / p])
52d4d1d3
ZJS
3936 endif
3937 endforeach
b68dfb9e
ZJS
3938 endif
3939endforeach
3940
52d4d1d3 3941
b68dfb9e
ZJS
3942############################################################
3943
0700e8ba 3944if git.found()
37efbbd8 3945 all_files = run_command(
0f4c4f38
ZJS
3946 env, '-u', 'GIT_WORK_TREE',
3947 git, '--git-dir=@0@/.git'.format(project_source_root),
e92777d2
ZJS
3948 'ls-files', ':/*.[ch]',
3949 check : false)
3950 if all_files.returncode() == 0
3951 all_files = files(all_files.stdout().split())
3952
3953 custom_target(
3954 'tags',
3955 output : 'tags',
3956 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
3957 run_target(
3958 'ctags',
691db9a7 3959 command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files)
e92777d2 3960 endif
d68b342b 3961endif
177929c2
ZJS
3962
3963if git.found()
dd1e33c8 3964 git_contrib_sh = find_program('tools/git-contrib.sh')
a923e085 3965 run_target(
37efbbd8 3966 'git-contrib',
dd1e33c8 3967 command : [git_contrib_sh])
177929c2 3968endif
dd6ab3df
ZJS
3969
3970if git.found()
3971 git_head = run_command(
e92777d2
ZJS
3972 git, '--git-dir=@0@/.git'.format(project_source_root),
3973 'rev-parse', 'HEAD',
3974 check : false).stdout().strip()
dd6ab3df 3975 git_head_short = run_command(
e92777d2
ZJS
3976 git, '--git-dir=@0@/.git'.format(project_source_root),
3977 'rev-parse', '--short=7', 'HEAD',
3978 check : false).stdout().strip()
dd6ab3df
ZJS
3979
3980 run_target(
3981 'git-snapshot',
0f4c4f38 3982 command : [git, 'archive',
1485aacb 3983 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
dd6ab3df
ZJS
3984 git_head_short),
3985 '--prefix', 'systemd-@0@/'.format(git_head),
3986 'HEAD'])
3987endif
829257d1
ZJS
3988
3989############################################################
3990
dd1e33c8 3991check_api_docs_sh = find_program('tools/check-api-docs.sh')
51b13863
LP
3992run_target(
3993 'check-api-docs',
3994 depends : [man, libsystemd, libudev],
dd1e33c8 3995 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
51b13863 3996
f12c5d36
ZJS
3997alias_target('update-dbus-docs', update_dbus_docs)
3998alias_target('update-man-rules', update_man_rules)
e3c368f6 3999
0628d48e
LB
4000if not meson.is_cross_build()
4001 custom_target(
4002 'export-dbus-interfaces',
4003 output : dbus_interfaces_dir_name,
4004 install : dbus_interfaces_dir != 'no',
4005 install_dir : dbus_interfaces_dir_parent,
4006 command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
4007endif
e3c68924 4008
51b13863 4009############################################################
829257d1 4010
e92777d2
ZJS
4011alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
4012 check : true).stdout().strip()
12085ebb
ZJS
4013
4014summary({
12085ebb
ZJS
4015 'split /usr' : split_usr,
4016 'split bin-sbin' : split_bin,
4017 'prefix directory' : prefixdir,
4018 'rootprefix directory' : rootprefixdir,
4019 'sysconf directory' : sysconfdir,
4020 'include directory' : includedir,
4021 'lib directory' : libdir,
4022 'rootlib directory' : rootlibdir,
4023 'SysV init scripts' : sysvinit_path,
4024 'SysV rc?.d directories' : sysvrcnd_path,
4025 'PAM modules directory' : pamlibdir,
4026 'PAM configuration directory' : pamconfdir,
4027 'libcryptsetup plugins directory' : libcryptsetup_plugins_dir,
4028 'RPM macros directory' : rpmmacrosdir,
4029 'modprobe.d directory' : modprobedir,
4030 'D-Bus policy directory' : dbuspolicydir,
4031 'D-Bus session directory' : dbussessionservicedir,
4032 'D-Bus system directory' : dbussystemservicedir,
7e560e79 4033 'D-Bus interfaces directory' : dbus_interfaces_dir,
12085ebb
ZJS
4034 'bash completions directory' : bashcompletiondir,
4035 'zsh completions directory' : zshcompletiondir,
a2b0cd3f 4036 'private shared lib version tag' : shared_lib_tag,
12085ebb
ZJS
4037 'extra start script' : get_option('rc-local'),
4038 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'),
4039 get_option('debug-tty')),
4040 'system UIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
4041 conf.get('SYSTEM_ALLOC_UID_MIN')),
4042 'system GIDs' : '<=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
4043 conf.get('SYSTEM_ALLOC_GID_MIN')),
4044 'dynamic UIDs' : '@0@…@1@'.format(dynamic_uid_min, dynamic_uid_max),
4045 'container UID bases' : '@0@…@1@'.format(container_uid_base_min, container_uid_base_max),
4046 'static UID/GID allocations' : ' '.join(static_ugids),
4047 '/dev/kvm access mode' : get_option('dev-kvm-mode'),
4048 'render group access mode' : get_option('group-render-mode'),
4049 'certificate root directory' : get_option('certificate-root'),
4050 'support URL' : support_url,
4051 'nobody user name' : nobody_user,
4052 'nobody group name' : nobody_group,
4053 'fallback hostname' : get_option('fallback-hostname'),
4054 'default DNSSEC mode' : default_dnssec,
4055 'default DNS-over-TLS mode' : default_dns_over_tls,
4056 'default mDNS mode' : default_mdns,
4057 'default LLMNR mode' : default_llmnr,
4058 'default DNS servers' : dns_servers.split(' '),
4059 'default NTP servers' : ntp_servers.split(' '),
4060 'default cgroup hierarchy' : default_hierarchy,
4061 'default net.naming-scheme value' : default_net_naming_scheme,
4062 'default KillUserProcesses value' : kill_user_processes,
4063 'default locale' : default_locale,
4064 'default user $PATH' :
4065 default_user_path != '' ? default_user_path : '(same as system services)',
4066 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog,
4067 'time epoch' : '@0@ (@1@)'.format(time_epoch, alt_time_epoch)})
829257d1
ZJS
4068
4069# TODO:
4070# CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
4071# CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
4072# LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
4073
829257d1
ZJS
4074found = []
4075missing = []
4076
4077foreach tuple : [
56d68e71
ZJS
4078 # dependencies
4079 ['ACL'],
829257d1 4080 ['AUDIT'],
829257d1 4081 ['AppArmor'],
56d68e71
ZJS
4082 ['IMA'],
4083 ['PAM'],
829257d1 4084 ['SECCOMP'],
56d68e71 4085 ['SELinux'],
829257d1 4086 ['SMACK'],
56d68e71
ZJS
4087 ['blkid'],
4088 ['elfutils'],
829257d1 4089 ['gcrypt'],
829257d1 4090 ['gnutls'],
7d861e12 4091 ['libbpf'],
56d68e71 4092 ['libcryptsetup'],
d1ae38d8 4093 ['libcryptsetup-plugins'],
829257d1 4094 ['libcurl'],
56d68e71
ZJS
4095 ['libfdisk'],
4096 ['libfido2'],
829257d1 4097 ['libidn'],
56d68e71 4098 ['libidn2'],
829257d1 4099 ['libiptc'],
56d68e71
ZJS
4100 ['microhttpd'],
4101 ['openssl'],
4102 ['p11kit'],
4103 ['pcre2'],
4104 ['pwquality'],
4105 ['qrencode'],
4106 ['tpm2'],
4107 ['xkbcommon'],
4108
4109 # compression libs
4110 ['zstd'],
4111 ['lz4'],
4112 ['xz'],
4113 ['zlib'],
4114 ['bzip2'],
4115
4116 # components
4117 ['backlight'],
829257d1 4118 ['binfmt'],
ff7e7c2b 4119 ['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
56d68e71 4120 ['coredump'],
829257d1 4121 ['environment.d'],
56d68e71 4122 ['efi'],
9cf75222 4123 ['gnu-efi'],
829257d1 4124 ['firstboot'],
56d68e71
ZJS
4125 ['hibernate'],
4126 ['homed'],
4127 ['hostnamed'],
4128 ['hwdb'],
4129 ['importd'],
4130 ['initrd'],
4131 ['kernel-install', get_option('kernel-install')],
4132 ['localed'],
829257d1
ZJS
4133 ['logind'],
4134 ['machined'],
56d68e71
ZJS
4135 ['networkd'],
4136 ['nss-myhostname'],
4137 ['nss-mymachines'],
4138 ['nss-resolve'],
4139 ['nss-systemd'],
4140 ['oomd'],
61d0578b 4141 ['portabled'],
56d68e71
ZJS
4142 ['pstore'],
4143 ['quotacheck'],
4144 ['randomseed'],
4145 ['repart'],
4146 ['resolve'],
4147 ['rfkill'],
9bca4ae4 4148 ['sysext'],
56d68e71 4149 ['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
43cc7a3e 4150 ['sysupdate'],
56d68e71 4151 ['sysusers'],
829257d1
ZJS
4152 ['timedated'],
4153 ['timesyncd'],
56d68e71
ZJS
4154 ['tmpfiles'],
4155 ['userdb'],
4156 ['vconsole'],
4157 ['xdg-autostart'],
4158
4159 # optional features
56d68e71 4160 ['idn'],
829257d1 4161 ['polkit'],
56d68e71
ZJS
4162 ['nscd'],
4163 ['legacy-pkla', install_polkit_pkla],
829257d1 4164 ['kmod'],
829257d1
ZJS
4165 ['dbus'],
4166 ['glib'],
829257d1 4167 ['tpm'],
ba081955
ZJS
4168 ['man pages', want_man],
4169 ['html pages', want_html],
4170 ['man page indices', want_man and have_lxml],
829257d1 4171 ['SysV compat'],
56d68e71 4172 ['compat-mutable-uid-boundaries'],
829257d1
ZJS
4173 ['utmp'],
4174 ['ldconfig'],
ba081955
ZJS
4175 ['adm group', get_option('adm-group')],
4176 ['wheel group', get_option('wheel-group')],
b14e1b43 4177 ['gshadow'],
829257d1
ZJS
4178 ['debug hashmap'],
4179 ['debug mmap cache'],
d6601495 4180 ['debug siphash'],
ff7e7c2b 4181 ['valgrind', conf.get('VALGRIND') == 1],
ba081955
ZJS
4182 ['trace logging', conf.get('LOG_TRACE') == 1],
4183 ['install tests', install_tests],
19d8c9c9
LP
4184 ['link-udev-shared', get_option('link-udev-shared')],
4185 ['link-systemctl-shared', get_option('link-systemctl-shared')],
5ac8b50d 4186 ['link-networkd-shared', get_option('link-networkd-shared')],
fd74a13e 4187 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
79647020 4188 ['link-boot-shared', get_option('link-boot-shared')],
ceedbf81 4189 ['fexecve'],
18b49798 4190 ['standalone-binaries', get_option('standalone-binaries')],
829257d1
ZJS
4191]
4192
af4d7860
ZJS
4193 if tuple.length() >= 2
4194 cond = tuple[1]
4195 else
829257d1
ZJS
4196 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
4197 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
349cc4a5 4198 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
829257d1
ZJS
4199 endif
4200 if cond
5a8b1640 4201 found += tuple[0]
829257d1 4202 else
5a8b1640 4203 missing += tuple[0]
829257d1
ZJS
4204 endif
4205endforeach
4206
c716c253
ZJS
4207if static_libsystemd == 'false'
4208 missing += 'static-libsystemd'
4209else
4210 found += 'static-libsystemd(@0@)'.format(static_libsystemd)
4211endif
4212
4213if static_libudev == 'false'
4214 missing += 'static-libudev'
4215else
4216 found += 'static-libudev(@0@)'.format(static_libudev)
4217endif
4218
57633d23
ZJS
4219if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
4220 found += 'cryptolib(openssl)'
4221elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
4222 found += 'cryptolib(gcrypt)'
4223else
4224 missing += 'cryptolib'
4225endif
4226
237f2da9
ZJS
4227if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
4228 found += 'DNS-over-TLS(gnutls)'
4229elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
4230 found += 'DNS-over-TLS(openssl)'
4231else
4232 missing += 'DNS-over-TLS'
4233endif
4234
12085ebb
ZJS
4235summary({
4236 'enabled' : ', '.join(found),
4237 'disabled' : ', '.join(missing)},
4238 section : 'Features')
9a8e64b0
ZJS
4239
4240if rootprefixdir != rootprefix_default
8ea9fad7
YW
4241 warning('\n' +
4242 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
4243 'systemd used fixed names for unit file directories and other paths, so anything\n' +
4244 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))
9a8e64b0 4245endif