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