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