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