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