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