2020-11-09 13:23:58 +09:00
# SPDX-License-Identifier: LGPL-2.1-or-later
2017-11-18 18:32:01 +01:00
2017-04-04 23:03:47 -04:00
project ( 'systemd' , 'c' ,
2024-02-14 11:04:36 +01:00
version : files ( 'meson.version' ) ,
2017-04-04 23:03:47 -04:00
license : 'LGPLv2+' ,
default_options : [
2022-03-11 15:13:23 +09:00
'c_std=gnu11' ,
2017-04-17 19:25:00 -04:00
'prefix=/usr' ,
'sysconfdir=/etc' ,
'localstatedir=/var' ,
2019-11-10 11:39:15 +01:00
'warning_level=2' ,
2017-04-04 23:03:47 -04:00
] ,
2022-05-16 04:08:21 +09:00
meson_version : '>= 0.60.0' ,
2017-04-04 23:03:47 -04:00
)
2024-04-25 22:26:08 +01:00
libsystemd_version = '0.39.0'
libudev_version = '1.7.9'
2017-09-28 19:24:16 +02:00
2017-04-04 23:03:47 -04:00
conf = configuration_data ( )
2022-05-19 13:58:15 +02:00
conf . set_quoted ( 'PROJECT_URL' , 'https://systemd.io/' )
2024-02-14 11:04:36 +01:00
conf . set ( 'PROJECT_VERSION' , meson . project_version ( ) . split ( '~' ) [ 0 ] ,
2020-02-28 11:09:16 +01:00
description : 'Numerical project version (used where a simple number is expected)' )
2024-02-14 11:04:36 +01:00
conf . set_quoted ( 'PROJECT_VERSION_FULL' , meson . project_version ( ) , description : 'Full project version' )
2017-04-04 23:03:47 -04:00
2019-02-27 11:19:07 -05:00
# This is to be used instead of meson.source_root(), as the latter will return
# the wrong result when systemd is being built as a meson subproject
project_source_root = meson . current_source_dir ( )
2020-04-24 20:12:03 +02:00
project_build_root = meson . current_build_dir ( )
2019-06-07 14:41:36 +02:00
relative_source_path = run_command ( 'realpath' ,
2020-04-24 20:12:03 +02:00
'--relative-to=@0@' . format ( project_build_root ) ,
2021-11-17 13:58:53 +01:00
project_source_root ,
check : true ) . stdout ( ) . strip ( )
2019-06-07 14:41:36 +02:00
conf . set_quoted ( 'RELATIVE_SOURCE_PATH' , relative_source_path )
2019-02-27 11:19:07 -05:00
2021-04-14 13:17:22 +02:00
conf . set10 ( 'BUILD_MODE_DEVELOPER' , get_option ( 'mode' ) == 'developer' ,
description : 'tailor build to development or release builds' )
2023-11-07 21:51:40 +01:00
2023-08-10 16:00:55 +02:00
feature = get_option ( 'log-message-verification' )
if feature . auto ( )
have = conf . get ( 'BUILD_MODE_DEVELOPER' ) == 1
2022-05-11 16:42:13 +02:00
else
2023-08-10 16:00:55 +02:00
have = feature . enabled ( )
2022-05-11 16:42:13 +02:00
endif
2023-08-10 16:00:55 +02:00
conf . set10 ( 'LOG_MESSAGE_VERIFICATION' , have )
2020-08-27 17:26:49 +02:00
2018-10-10 11:56:45 +02:00
want_ossfuzz = get_option ( 'oss-fuzz' )
want_libfuzzer = get_option ( 'llvm-fuzz' )
2021-09-03 12:43:33 -04:00
if want_ossfuzz and want_libfuzzer
2020-03-30 06:42:19 +00:00
error ( 'only one of oss-fuzz or llvm-fuzz can be specified' )
2018-10-10 11:56:45 +02:00
endif
2019-05-05 19:28:42 +00:00
2020-03-30 06:42:19 +00:00
fuzzer_build = want_ossfuzz or want_libfuzzer
2018-10-10 11:56:45 +02:00
2022-05-12 12:51:11 +02:00
# If we're building *not* for actual fuzzing, allow input samples of any size
# (for testing and for reproduction of issues discovered with previously-higher
# limits).
conf . set10 ( 'FUZZ_USE_SIZE_LIMIT' , fuzzer_build )
2023-01-10 14:25:57 +01:00
# We'll set this to '1' for EFI builds in a different place.
conf . set10 ( 'SD_BOOT' , false )
2021-12-23 13:05:01 +01:00
# Create a title-less summary section early, so it ends up first in the output.
# More items are added later after they have been detected.
summary ( { 'build mode' : get_option ( 'mode' ) } )
2017-04-04 23:03:47 -04:00
#####################################################################
2017-07-24 04:41:45 -04:00
# Try to install the git pre-commit hook
2024-03-14 10:29:55 +01:00
git_setup_sh = find_program ( 'tools/git-setup.sh' , required : false )
if git_setup_sh . found ( )
git_hook = run_command ( git_setup_sh , check : false )
2020-03-28 09:30:51 +01:00
if git_hook . returncode ( ) == 0
message ( git_hook . stdout ( ) . strip ( ) )
endif
2017-07-24 04:41:45 -04:00
endif
#####################################################################
2021-11-13 17:01:16 +01:00
fs = import ( 'fs' )
2018-03-01 10:28:29 +01:00
if get_option ( 'split-bin' ) == 'auto'
2021-11-13 17:01:16 +01:00
split_bin = not fs . is_symlink ( '/usr/sbin' )
2018-03-01 10:28:29 +01:00
else
split_bin = get_option ( 'split-bin' ) == 'true'
endif
2018-03-01 21:48:36 +01:00
conf . set10 ( 'HAVE_SPLIT_BIN' , split_bin ,
description : 'bin and sbin directories are separate' )
2018-03-01 10:28:29 +01:00
2020-06-03 14:02:59 -07:00
have_standalone_binaries = get_option ( 'standalone-binaries' )
2017-04-04 23:03:47 -04:00
sysvinit_path = get_option ( 'sysvinit-path' )
sysvrcnd_path = get_option ( 'sysvrcnd-path' )
2018-05-07 18:17:35 +09:00
conf . set10 ( 'HAVE_SYSV_COMPAT' , sysvinit_path != '' and sysvrcnd_path != '' ,
2017-10-03 10:41:51 +02:00
description : 'SysV init scripts and rcN.d links are supported' )
2021-07-08 09:47:32 +00:00
conf . set10 ( 'CREATE_LOG_DIRS' , get_option ( 'create-log-dirs' ) )
2017-04-04 23:03:47 -04:00
2020-04-08 23:59:13 +02:00
if get_option ( 'hibernate' ) and not get_option ( 'initrd' )
error ( 'hibernate depends on initrd' )
endif
2018-10-11 18:23:26 +02:00
conf . set10 ( 'BUMP_PROC_SYS_FS_FILE_MAX' , get_option ( 'bump-proc-sys-fs-file-max' ) )
conf . set10 ( 'BUMP_PROC_SYS_FS_NR_OPEN' , get_option ( 'bump-proc-sys-fs-nr-open' ) )
2018-11-15 09:50:42 +01:00
conf . set ( 'HIGH_RLIMIT_NOFILE' , 512 * 1024 )
2018-10-11 18:23:26 +02:00
2021-07-27 19:32:35 +02:00
# Meson ignores the preceding arguments when joining paths if an absolute
# component is encountered, so this should canonicalize various paths when they
# are absolute or relative.
2017-04-04 23:03:47 -04:00
prefixdir = get_option ( 'prefix' )
if not prefixdir . startswith ( '/' )
2017-04-17 19:25:00 -04:00
error ( 'Prefix is not absolute: "@0@"' . format ( prefixdir ) )
2017-04-04 23:03:47 -04:00
endif
2021-02-24 18:02:36 +01:00
2023-06-12 02:15:19 +01:00
prefixdir_noslash = '/' + prefixdir . strip ( '/' )
2021-07-27 19:32:35 +02:00
bindir = prefixdir / get_option ( 'bindir' )
2023-06-12 02:15:19 +01:00
sbindir = prefixdir / ( split_bin ? 'sbin' : 'bin' )
2023-08-08 10:38:47 +09:00
sbin_to_bin = split_bin ? '../bin/' : ''
2021-07-27 19:32:35 +02:00
libdir = prefixdir / get_option ( 'libdir' )
sysconfdir = prefixdir / get_option ( 'sysconfdir' )
includedir = prefixdir / get_option ( 'includedir' )
datadir = prefixdir / get_option ( 'datadir' )
localstatedir = '/' / get_option ( 'localstatedir' )
2017-04-04 23:03:47 -04:00
2023-06-12 02:15:19 +01:00
libexecdir = prefixdir / 'lib/systemd'
pkglibdir = libdir / 'systemd'
2017-04-04 23:03:47 -04:00
2020-12-30 15:11:30 -08:00
install_sysconfdir = get_option ( 'install-sysconfdir' ) != 'false'
install_sysconfdir_samples = get_option ( 'install-sysconfdir' ) == 'true'
2017-04-04 23:03:47 -04:00
# Dirs of external packages
2021-07-27 19:32:35 +02:00
pkgconfigdatadir = get_option ( 'pkgconfigdatadir' ) != '' ? get_option ( 'pkgconfigdatadir' ) : datadir / 'pkgconfig'
pkgconfiglibdir = get_option ( 'pkgconfiglibdir' ) != '' ? get_option ( 'pkgconfiglibdir' ) : libdir / 'pkgconfig'
polkitpolicydir = datadir / 'polkit-1/actions'
polkitrulesdir = datadir / 'polkit-1/rules.d'
polkitpkladir = localstatedir / 'lib/polkit-1/localauthority/10-vendor.d'
xinitrcdir = get_option ( 'xinitrcdir' ) != '' ? get_option ( 'xinitrcdir' ) : sysconfdir / 'X11/xinit/xinitrc.d'
2017-11-23 22:20:22 +09:00
rpmmacrosdir = get_option ( 'rpmmacrosdir' )
if rpmmacrosdir != 'no'
2021-07-27 19:32:35 +02:00
rpmmacrosdir = prefixdir / rpmmacrosdir
2017-11-23 22:20:22 +09:00
endif
2023-06-12 02:15:19 +01:00
modprobedir = prefixdir / 'lib/modprobe.d'
2017-04-04 23:03:47 -04:00
# Our own paths
2021-07-27 19:32:35 +02:00
pkgdatadir = datadir / 'systemd'
environmentdir = prefixdir / 'lib/environment.d'
pkgsysconfdir = sysconfdir / 'systemd'
userunitdir = prefixdir / 'lib/systemd/user'
userpresetdir = prefixdir / 'lib/systemd/user-preset'
tmpfilesdir = prefixdir / 'lib/tmpfiles.d'
2022-06-20 15:06:09 +02:00
usertmpfilesdir = prefixdir / 'share/user-tmpfiles.d'
2021-07-27 19:32:35 +02:00
sysusersdir = prefixdir / 'lib/sysusers.d'
sysctldir = prefixdir / 'lib/sysctl.d'
binfmtdir = prefixdir / 'lib/binfmt.d'
modulesloaddir = prefixdir / 'lib/modules-load.d'
2023-06-12 02:15:19 +01:00
networkdir = prefixdir / 'lib/systemd/network'
systemgeneratordir = libexecdir / 'system-generators'
2021-07-27 19:32:35 +02:00
usergeneratordir = prefixdir / 'lib/systemd/user-generators'
systemenvgeneratordir = prefixdir / 'lib/systemd/system-environment-generators'
userenvgeneratordir = prefixdir / 'lib/systemd/user-environment-generators'
2023-06-12 02:15:19 +01:00
systemshutdowndir = libexecdir / 'system-shutdown'
systemsleepdir = libexecdir / 'system-sleep'
systemunitdir = prefixdir / 'lib/systemd/system'
systempresetdir = prefixdir / 'lib/systemd/system-preset'
udevlibexecdir = prefixdir / 'lib/udev'
2021-07-27 19:32:35 +02:00
udevrulesdir = udevlibexecdir / 'rules.d'
udevhwdbdir = udevlibexecdir / 'hwdb.d'
catalogdir = prefixdir / 'lib/systemd/catalog'
2021-03-16 16:47:34 +01:00
kerneldir = prefixdir / 'lib/kernel'
kernelinstalldir = kerneldir / 'install.d'
2021-07-27 19:32:35 +02:00
factorydir = datadir / 'factory'
bootlibdir = prefixdir / 'lib/systemd/boot/efi'
testsdir = prefixdir / 'lib/systemd/tests'
2023-01-26 16:07:17 +01:00
unittestsdir = testsdir / 'unit-tests'
2023-03-17 14:14:16 +01:00
testdata_dir = testsdir / 'testdata'
2021-07-27 19:32:35 +02:00
systemdstatedir = localstatedir / 'lib/systemd'
catalogstatedir = systemdstatedir / 'catalog'
randomseeddir = localstatedir / 'lib/systemd'
2023-06-12 02:15:19 +01:00
profiledir = libexecdir / 'portable' / 'profile'
2023-09-28 18:16:59 +02:00
repartdefinitionsdir = libexecdir / 'repart/definitions'
2023-06-12 02:15:19 +01:00
ntpservicelistdir = prefixdir / 'lib/systemd/ntp-units.d'
2023-05-24 15:32:17 +02:00
credstoredir = prefixdir / 'lib/credstore'
2023-08-16 11:40:01 +02:00
pcrlockdir = prefixdir / 'lib/pcrlock.d'
2023-11-20 11:51:47 +01:00
mimepackagesdir = prefixdir / 'share/mime/packages'
2017-04-04 23:03:47 -04:00
2023-08-21 12:37:00 +02:00
configfiledir = get_option ( 'configfiledir' )
if configfiledir == ''
configfiledir = sysconfdir
endif
pkgconfigfiledir = configfiledir / 'systemd'
2018-02-01 22:46:15 +01:00
docdir = get_option ( 'docdir' )
if docdir == ''
2021-07-27 19:32:35 +02:00
docdir = datadir / 'doc/systemd'
2018-02-01 22:46:15 +01:00
endif
2017-04-04 23:03:47 -04:00
pamlibdir = get_option ( 'pamlibdir' )
if pamlibdir == ''
2023-06-12 02:15:19 +01:00
pamlibdir = libdir / 'security'
2017-04-04 23:03:47 -04:00
endif
pamconfdir = get_option ( 'pamconfdir' )
if pamconfdir == ''
2021-07-27 19:32:35 +02:00
pamconfdir = prefixdir / 'lib/pam.d'
2017-04-04 23:03:47 -04:00
endif
2024-01-04 23:31:51 +01:00
sshconfdir = get_option ( 'sshconfdir' )
if sshconfdir == ''
sshconfdir = sysconfdir / 'ssh/ssh_config.d'
endif
2023-11-16 18:47:52 +01:00
sshdconfdir = get_option ( 'sshdconfdir' )
if sshdconfdir == ''
sshdconfdir = sysconfdir / 'ssh/sshd_config.d'
endif
2024-03-01 11:25:52 +01:00
sshdprivsepdir = get_option ( 'sshdprivsepdir' )
conf . set10 ( 'CREATE_SSHDPRIVSEPDIR' , sshdprivsepdir != 'no' and not sshdprivsepdir . startswith ( '/usr/' ) )
conf . set ( 'SSHDPRIVSEPDIR' , sshdprivsepdir , description : 'SSH privilege separation directory' )
2021-03-16 20:13:28 +01:00
libcryptsetup_plugins_dir = get_option ( 'libcryptsetup-plugins-dir' )
if libcryptsetup_plugins_dir == ''
2023-06-12 02:15:19 +01:00
libcryptsetup_plugins_dir = libdir / 'cryptsetup'
2021-03-16 20:13:28 +01:00
endif
2018-02-15 11:43:08 +01:00
memory_accounting_default = get_option ( 'memory-accounting-default' )
2019-06-06 19:22:20 +02:00
status_unit_format_default = get_option ( 'status-unit-format-default' )
2022-06-09 20:33:29 +02:00
if status_unit_format_default == 'auto'
status_unit_format_default = conf . get ( 'BUILD_MODE_DEVELOPER' ) == 1 ? 'name' : 'description'
endif
2018-02-15 11:43:08 +01:00
2023-06-12 02:15:19 +01:00
conf . set_quoted ( 'BINDIR' , bindir )
2021-05-16 19:34:52 +02:00
conf . set_quoted ( 'BINFMT_DIR' , binfmtdir )
conf . set_quoted ( 'BOOTLIBDIR' , bootlibdir )
2021-07-27 19:32:35 +02:00
conf . set_quoted ( 'CATALOG_DATABASE' , catalogstatedir / 'database' )
2021-05-16 19:34:52 +02:00
conf . set_quoted ( 'CERTIFICATE_ROOT' , get_option ( 'certificate-root' ) )
2021-07-08 09:47:32 +00:00
conf . set_quoted ( 'DOC_DIR' , docdir )
2021-07-27 19:32:35 +02:00
conf . set_quoted ( 'DOCUMENT_ROOT' , pkgdatadir / 'gatewayd' )
2021-05-16 19:34:52 +02:00
conf . set_quoted ( 'ENVIRONMENT_DIR' , environmentdir )
conf . set_quoted ( 'INCLUDE_DIR' , includedir )
conf . set_quoted ( 'LIBDIR' , libdir )
2023-06-12 02:15:19 +01:00
conf . set_quoted ( 'LIBEXECDIR' , libexecdir )
2024-02-29 21:38:03 +01:00
conf . set_quoted ( 'KERNEL_INSTALL_DIR' , kernelinstalldir )
2021-05-16 19:34:52 +02:00
conf . set_quoted ( 'MODPROBE_DIR' , modprobedir )
conf . set_quoted ( 'MODULESLOAD_DIR' , modulesloaddir )
2017-04-04 23:03:47 -04:00
conf . set_quoted ( 'PKGSYSCONFDIR' , pkgsysconfdir )
2021-07-27 19:32:35 +02:00
conf . set_quoted ( 'POLKIT_AGENT_BINARY_PATH' , bindir / 'pkttyagent' )
2021-05-16 19:34:52 +02:00
conf . set_quoted ( 'PREFIX' , prefixdir )
2023-06-12 02:15:19 +01:00
conf . set_quoted ( 'PREFIX_NOSLASH' , prefixdir_noslash )
2021-07-27 19:32:35 +02:00
conf . set_quoted ( 'RANDOM_SEED' , randomseeddir / 'random-seed' )
2021-05-16 19:34:52 +02:00
conf . set_quoted ( 'RANDOM_SEED_DIR' , randomseeddir )
conf . set_quoted ( 'RC_LOCAL_PATH' , get_option ( 'rc-local' ) )
2024-01-04 23:31:51 +01:00
conf . set_quoted ( 'SSHCONFDIR' , sshconfdir )
2023-11-16 18:47:52 +01:00
conf . set_quoted ( 'SSHDCONFDIR' , sshdconfdir )
2021-05-16 19:34:52 +02:00
conf . set_quoted ( 'SYSCONF_DIR' , sysconfdir )
conf . set_quoted ( 'SYSCTL_DIR' , sysctldir )
2023-06-12 02:15:19 +01:00
conf . set_quoted ( 'SYSTEMCTL_BINARY_PATH' , bindir / 'systemctl' )
conf . set_quoted ( 'SYSTEMD_BINARY_PATH' , libexecdir / 'systemd' )
2023-06-01 19:51:42 +01:00
conf . set_quoted ( 'SYSTEMD_EXECUTOR_BINARY_PATH' , libexecdir / 'systemd-executor' )
2021-05-16 19:34:52 +02:00
conf . set_quoted ( 'SYSTEMD_CATALOG_DIR' , catalogdir )
2023-06-12 02:15:19 +01:00
conf . set_quoted ( 'SYSTEMD_CGROUPS_AGENT_PATH' , libexecdir / 'systemd-cgroups-agent' )
2023-09-22 18:47:05 +02:00
conf . set_quoted ( 'SYSTEMD_CRYPTSETUP_PATH' , bindir / 'systemd-cryptsetup' )
2023-06-12 02:15:19 +01:00
conf . set_quoted ( 'SYSTEMD_EXPORT_PATH' , libexecdir / 'systemd-export' )
conf . set_quoted ( 'SYSTEMD_FSCK_PATH' , libexecdir / 'systemd-fsck' )
conf . set_quoted ( 'SYSTEMD_GROWFS_PATH' , libexecdir / 'systemd-growfs' )
conf . set_quoted ( 'SYSTEMD_HOMEWORK_PATH' , libexecdir / 'systemd-homework' )
conf . set_quoted ( 'SYSTEMD_IMPORT_FS_PATH' , libexecdir / 'systemd-import-fs' )
conf . set_quoted ( 'SYSTEMD_IMPORT_PATH' , libexecdir / 'systemd-import' )
conf . set_quoted ( 'SYSTEMD_INTEGRITYSETUP_PATH' , libexecdir / 'systemd-integritysetup' )
2021-07-27 19:32:35 +02:00
conf . set_quoted ( 'SYSTEMD_KBD_MODEL_MAP' , pkgdatadir / 'kbd-model-map' )
conf . set_quoted ( 'SYSTEMD_LANGUAGE_FALLBACK_MAP' , pkgdatadir / 'language-fallback-map' )
2023-06-12 02:15:19 +01:00
conf . set_quoted ( 'SYSTEMD_MAKEFS_PATH' , libexecdir / 'systemd-makefs' )
conf . set_quoted ( 'SYSTEMD_PULL_PATH' , libexecdir / 'systemd-pull' )
conf . set_quoted ( 'SYSTEMD_SHUTDOWN_BINARY_PATH' , libexecdir / 'systemd-shutdown' )
2023-03-17 14:14:16 +01:00
conf . set_quoted ( 'SYSTEMD_TEST_DATA' , testdata_dir )
2023-06-12 02:15:19 +01:00
conf . set_quoted ( 'SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH' , bindir / 'systemd-tty-ask-password-agent' )
conf . set_quoted ( 'SYSTEMD_UPDATE_HELPER_PATH' , libexecdir / 'systemd-update-helper' )
conf . set_quoted ( 'SYSTEMD_USERWORK_PATH' , libexecdir / 'systemd-userwork' )
2023-03-09 12:27:29 +01:00
conf . set_quoted ( 'SYSTEMD_MOUNTWORK_PATH' , libexecdir / 'systemd-mountwork' )
2023-04-20 19:07:33 +02:00
conf . set_quoted ( 'SYSTEMD_NSRESOURCEWORK_PATH' , libexecdir / 'systemd-nsresourcework' )
2023-06-12 02:15:19 +01:00
conf . set_quoted ( 'SYSTEMD_VERITYSETUP_PATH' , libexecdir / 'systemd-veritysetup' )
2021-07-27 19:32:35 +02:00
conf . set_quoted ( 'SYSTEM_CONFIG_UNIT_DIR' , pkgsysconfdir / 'system' )
2021-05-16 16:44:47 +02:00
conf . set_quoted ( 'SYSTEM_DATA_UNIT_DIR' , systemunitdir )
2021-05-16 19:34:52 +02:00
conf . set_quoted ( 'SYSTEM_ENV_GENERATOR_DIR' , systemenvgeneratordir )
conf . set_quoted ( 'SYSTEM_GENERATOR_DIR' , systemgeneratordir )
2021-05-16 16:44:47 +02:00
conf . set_quoted ( 'SYSTEM_PRESET_DIR' , systempresetdir )
2021-05-16 19:34:52 +02:00
conf . set_quoted ( 'SYSTEM_SHUTDOWN_PATH' , systemshutdowndir )
conf . set_quoted ( 'SYSTEM_SLEEP_PATH' , systemsleepdir )
2017-04-04 23:03:47 -04:00
conf . set_quoted ( 'SYSTEM_SYSVINIT_PATH' , sysvinit_path )
conf . set_quoted ( 'SYSTEM_SYSVRCND_PATH' , sysvrcnd_path )
2021-05-16 19:34:52 +02:00
conf . set_quoted ( 'SYSUSERS_DIR' , sysusersdir )
conf . set_quoted ( 'TMPFILES_DIR' , tmpfilesdir )
2022-06-20 15:06:09 +02:00
conf . set_quoted ( 'USER_TMPFILES_DIR' , usertmpfilesdir )
2021-05-16 19:34:52 +02:00
conf . set_quoted ( 'UDEVLIBEXECDIR' , udevlibexecdir )
2021-05-16 16:44:47 +02:00
conf . set_quoted ( 'UDEV_HWDB_DIR' , udevhwdbdir )
conf . set_quoted ( 'UDEV_RULES_DIR' , udevrulesdir )
2021-07-27 19:32:35 +02:00
conf . set_quoted ( 'USER_CONFIG_UNIT_DIR' , pkgsysconfdir / 'user' )
2021-05-16 19:34:52 +02:00
conf . set_quoted ( 'USER_DATA_UNIT_DIR' , userunitdir )
conf . set_quoted ( 'USER_ENV_GENERATOR_DIR' , userenvgeneratordir )
conf . set_quoted ( 'USER_GENERATOR_DIR' , usergeneratordir )
2021-07-27 19:32:35 +02:00
conf . set_quoted ( 'USER_KEYRING_PATH' , pkgsysconfdir / 'import-pubring.gpg' )
2021-05-16 19:34:52 +02:00
conf . set_quoted ( 'USER_PRESET_DIR' , userpresetdir )
2023-06-12 02:15:19 +01:00
conf . set_quoted ( 'VENDOR_KEYRING_PATH' , libexecdir / 'import-pubring.gpg' )
2018-03-01 13:12:02 +01:00
2018-03-02 09:09:29 +01:00
conf . set ( 'ANSI_OK_COLOR' , 'ANSI_' + get_option ( 'ok-color' ) . underscorify ( ) . to_upper ( ) )
2021-07-11 04:39:33 -06:00
conf . set10 ( 'ENABLE_URLIFY' , get_option ( 'urlify' ) )
2020-11-06 15:01:13 +01:00
conf . set10 ( 'ENABLE_FEXECVE' , get_option ( 'fexecve' ) )
2018-10-17 14:36:09 +02:00
conf . set10 ( 'MEMORY_ACCOUNTING_DEFAULT' , memory_accounting_default )
2019-06-06 19:22:20 +02:00
conf . set ( 'STATUS_UNIT_FORMAT_DEFAULT' , 'STATUS_UNIT_FORMAT_' + status_unit_format_default . to_upper ( ) )
2021-05-16 17:52:42 +02:00
conf . set_quoted ( 'STATUS_UNIT_FORMAT_DEFAULT_STR' , status_unit_format_default )
2017-04-04 23:03:47 -04:00
2021-01-26 20:23:12 +01:00
conf . set ( 'DEFAULT_TIMEOUT_SEC' , get_option ( 'default-timeout-sec' ) )
conf . set ( 'DEFAULT_USER_TIMEOUT_SEC' , get_option ( 'default-user-timeout-sec' ) )
conf . set ( 'UPDATE_HELPER_USER_TIMEOUT_SEC' , get_option ( 'update-helper-user-timeout-sec' ) )
2023-11-08 08:31:13 +01:00
conf . set10 ( 'ENABLE_FIRST_BOOT_FULL_PRESET' , get_option ( 'first-boot-full-preset' ) )
2020-03-23 12:25:19 -04:00
2017-04-04 23:03:47 -04:00
#####################################################################
cc = meson . get_compiler ( 'c' )
2023-02-26 11:07:24 +01:00
userspace_c_args = [ ]
userspace_c_ld_args = [ ]
2018-01-19 17:54:30 +11:00
meson_build_sh = find_program ( 'tools/meson-build.sh' )
2017-04-04 23:03:47 -04:00
2018-09-12 11:02:58 +02:00
want_tests = get_option ( 'tests' )
slow_tests = want_tests != 'false' and get_option ( 'slow-tests' )
2020-05-21 16:59:40 +02:00
fuzz_tests = want_tests != 'false' and get_option ( 'fuzz-tests' )
2024-04-24 21:17:06 +02:00
integration_tests = want_tests != 'false' and get_option ( 'integration-tests' )
2024-02-13 13:43:49 +00:00
install_tests = want_tests != 'false' and get_option ( 'install-tests' )
2018-09-12 11:02:58 +02:00
2022-05-16 03:21:16 +09:00
if add_languages ( 'cpp' , native : false , required : fuzzer_build )
2018-09-12 16:52:08 +02:00
# Used only for tests
2019-11-10 12:16:41 +01:00
cxx = meson . get_compiler ( 'cpp' )
cxx_cmd = ' ' . join ( cxx . cmd_array ( ) )
2018-10-09 18:48:09 +02:00
else
2018-10-10 11:50:57 +02:00
cxx_cmd = ''
2017-05-13 13:23:28 -04:00
endif
2018-01-16 10:25:43 -05:00
if want_libfuzzer
2019-05-09 00:03:41 +02:00
fuzzing_engine = meson . get_compiler ( 'cpp' ) . find_library ( 'Fuzzer' , required : false )
if fuzzing_engine . found ( )
2023-02-26 11:07:24 +01:00
userspace_c_args + = '-fsanitize-coverage=trace-pc-guard,trace-cmp'
2019-05-09 00:03:41 +02:00
elif cc . has_argument ( '-fsanitize=fuzzer-no-link' )
2023-02-26 11:07:24 +01:00
userspace_c_args + = '-fsanitize=fuzzer-no-link'
2019-05-09 00:03:41 +02:00
else
error ( 'Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported' )
endif
2018-10-10 11:56:45 +02:00
elif want_ossfuzz
2018-01-13 19:51:07 -05:00
fuzzing_engine = meson . get_compiler ( 'cpp' ) . find_library ( 'FuzzingEngine' )
endif
2019-11-10 12:16:41 +01:00
# Those generate many false positives, and we do not want to change the code to
# avoid them.
basic_disabled_warnings = [
2021-06-02 15:53:29 +09:00
'-Wno-missing-field-initializers' ,
'-Wno-unused-parameter' ,
2024-01-16 22:25:04 +01:00
'-Wno-nonnull-compare' ,
2019-11-10 12:16:41 +01:00
]
2021-06-02 15:49:44 +09:00
possible_common_cc_flags = [
2023-02-05 20:44:19 +01:00
'-Warray-bounds' , # clang
'-Warray-bounds=2' ,
2021-06-02 15:53:29 +09:00
'-Wdate-time' ,
2018-05-10 15:30:42 +09:00
'-Wendif-labels' ,
2021-06-02 15:53:29 +09:00
'-Werror=format=2' ,
2022-08-30 09:57:53 +02:00
'-Werror=format-signedness' ,
2021-06-02 15:53:29 +09:00
'-Werror=implicit-function-declaration' ,
2023-01-31 16:12:09 +01:00
'-Werror=implicit-int' ,
2021-06-02 15:53:29 +09:00
'-Werror=incompatible-pointer-types' ,
2021-09-25 00:16:20 +09:00
'-Werror=int-conversion' ,
2023-03-10 09:57:50 +01:00
'-Werror=missing-declarations' ,
'-Werror=missing-prototypes' ,
2018-05-10 15:30:42 +09:00
'-Werror=overflow' ,
2021-11-26 11:52:04 +01:00
'-Werror=override-init' ,
2021-06-02 15:53:29 +09:00
'-Werror=return-type' ,
2018-06-09 13:12:52 +02:00
'-Werror=shift-count-overflow' ,
2018-06-11 13:17:43 +02:00
'-Werror=shift-overflow=2' ,
2023-05-30 10:30:15 +02:00
'-Werror=strict-flex-arrays' ,
2021-06-02 15:53:29 +09:00
'-Werror=undef' ,
'-Wfloat-equal' ,
2022-05-28 11:41:10 +02:00
# gperf prevents us from enabling this because it does not emit fallthrough
# attribute with clang.
#'-Wimplicit-fallthrough',
2021-06-02 15:53:29 +09:00
'-Wimplicit-fallthrough=5' ,
'-Winit-self' ,
'-Wlogical-op' ,
'-Wmissing-include-dirs' ,
'-Wmissing-noreturn' ,
2018-05-10 15:30:42 +09:00
'-Wnested-externs' ,
2021-06-02 15:53:29 +09:00
'-Wold-style-definition' ,
'-Wpointer-arith' ,
'-Wredundant-decls' ,
'-Wshadow' ,
'-Wstrict-aliasing=2' ,
'-Wstrict-prototypes' ,
'-Wsuggest-attribute=noreturn' ,
2021-11-16 09:52:39 +00:00
'-Wunused-function' ,
2021-06-02 15:53:29 +09:00
'-Wwrite-strings' ,
2023-02-06 09:46:55 +01:00
'-Wzero-length-bounds' ,
2018-09-08 13:55:09 -07:00
# negative arguments are correctly detected starting with meson 0.46.
2019-03-07 10:56:15 +01:00
'-Wno-error=#warnings' , # clang
'-Wno-string-plus-int' , # clang
2023-02-05 20:44:19 +01:00
2023-03-10 09:57:50 +01:00
'-fdiagnostics-show-option' ,
'-fno-common' ,
2023-03-10 09:01:29 +01:00
'-fstack-protector' ,
'-fstack-protector-strong' ,
2023-02-05 20:44:19 +01:00
'-fstrict-flex-arrays' ,
2023-03-10 09:01:29 +01:00
'--param=ssp-buffer-size=4' ,
]
possible_common_link_flags = [
'-fstack-protector' ,
2018-05-10 15:30:42 +09:00
]
2022-04-29 14:35:20 +02:00
c_args = get_option ( 'c_args' )
2022-07-18 05:02:48 +09:00
# Our json library does not support -ffinite-math-only, which is enabled by -Ofast or -ffast-math.
2022-08-09 14:48:14 +09:00
if ( ( '-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 )
2022-07-18 05:02:48 +09:00
error ( '-Ofast, -ffast-math, or -ffinite-math-only is specified in c_args.' )
endif
2022-03-07 15:32:22 +09:00
# Disable -Wmaybe-uninitialized when compiling with -Os/-O1/-O3/etc. There are
2021-03-31 17:05:49 +02:00
# too many false positives with gcc >= 8. Effectively, we only test with -O0
# and -O2; this should be enough to catch most important cases without too much
# busywork. See https://github.com/systemd/systemd/pull/19226.
if cc . get_id ( ) == 'gcc' and ( not '02' . contains ( get_option ( 'optimization' ) ) or
2022-04-29 14:35:20 +02:00
cc . version ( ) . version_compare ( '<10' ) or
'-Os' in c_args or
'-O1' in c_args or
'-O3' in c_args or
'-Og' in c_args )
2021-06-02 15:49:44 +09:00
possible_common_cc_flags + = '-Wno-maybe-uninitialized'
2021-03-31 17:05:49 +02:00
endif
2021-07-06 15:13:00 +02:00
# Disable -Wno-unused-result with gcc, see
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425.
if cc . get_id ( ) == 'gcc'
possible_common_cc_flags + = '-Wno-unused-result'
endif
2018-05-10 15:30:42 +09:00
# --as-needed and --no-undefined are provided by meson by default,
2021-07-27 16:16:07 +02:00
# run 'meson configure' to see what is enabled
2018-05-10 15:30:42 +09:00
possible_link_flags = [
2021-11-04 19:03:45 +01:00
'-Wl,--fatal-warnings' ,
2018-05-10 15:30:42 +09:00
'-Wl,-z,now' ,
2021-11-04 19:03:45 +01:00
'-Wl,-z,relro' ,
2018-05-10 15:30:42 +09:00
]
2017-04-04 23:03:47 -04:00
2021-11-04 19:03:45 +01:00
if get_option ( 'b_sanitize' ) == 'none'
possible_link_flags + = '-Wl,--warn-common'
endif
2018-05-10 15:30:42 +09:00
if cc . get_id ( ) == 'clang'
2021-06-02 15:49:44 +09:00
possible_common_cc_flags + = [
2018-05-10 15:30:42 +09:00
'-Wno-typedef-redefinition' ,
'-Wno-gnu-variable-sized-type-not-at-end' ,
]
endif
2022-05-07 11:31:26 +02:00
if get_option ( 'mode' ) == 'release'
# We could enable 'pattern' for developer mode, but that can interfere with
# valgrind and sanitizer builds. Also, clang does not zero-initialize unions,
# breaking some of our code (https://reviews.llvm.org/D68115).
possible_common_cc_flags + = '-ftrivial-auto-var-init=zero'
endif
2023-02-26 11:07:24 +01:00
possible_cc_flags = [
2021-06-08 09:23:50 +09:00
'-fno-strict-aliasing' ,
2022-11-09 23:56:46 +00:00
'-fstrict-flex-arrays=1' ,
2021-06-08 09:23:50 +09:00
'-fvisibility=hidden' ,
]
2018-05-10 15:30:42 +09:00
if get_option ( 'buildtype' ) != 'debug'
2021-06-08 09:23:50 +09:00
possible_cc_flags + = [
2018-05-10 15:30:42 +09:00
'-ffunction-sections' ,
'-fdata-sections' ,
]
possible_link_flags + = '-Wl,--gc-sections'
endif
2022-06-08 22:32:49 +02:00
if get_option ( 'mode' ) == 'developer'
possible_cc_flags + = '-fno-omit-frame-pointer'
endif
2023-02-26 11:07:24 +01:00
add_project_arguments (
cc . get_supported_arguments (
basic_disabled_warnings ,
possible_common_cc_flags
) ,
language : 'c' )
2023-03-10 09:01:29 +01:00
add_project_link_arguments (
cc . get_supported_link_arguments ( possible_common_link_flags ) ,
language : 'c' )
2023-02-26 11:07:24 +01:00
userspace_c_args + = cc . get_supported_arguments ( possible_cc_flags )
userspace_c_ld_args + = cc . get_supported_link_arguments ( possible_link_flags )
2018-05-10 15:30:42 +09:00
2020-05-09 09:09:11 +02:00
have = cc . has_argument ( '-Wzero-length-bounds' )
conf . set10 ( 'HAVE_ZERO_LENGTH_BOUNDS' , have )
2018-02-19 01:37:19 -08:00
if cc . compiles ( '''
2017-04-04 23:03:47 -04:00
#include <time.h>
#include <inttypes.h>
typedef uint64_t usec_t;
usec_t now(clockid_t clock);
int main(void) {
struct timespec now;
return 0;
}
2018-11-29 13:22:08 +01:00
''' , args : '-Werror=shadow' , name : '-Werror=shadow with local shadowing' )
2017-04-17 19:25:00 -04:00
add_project_arguments ( '-Werror=shadow' , language : 'c' )
2017-04-04 23:03:47 -04:00
endif
2019-11-10 12:16:41 +01:00
if cxx_cmd != ''
add_project_arguments ( cxx . get_supported_arguments ( basic_disabled_warnings ) , language : 'cpp' )
endif
2023-10-11 13:32:49 -05:00
cpp = ' ' . join ( cc . cmd_array ( ) + get_option ( 'c_args' ) ) + ' -E'
2017-04-11 10:25:34 -04:00
2019-05-07 15:10:58 +02:00
has_wstringop_truncation = cc . has_argument ( '-Wstringop-truncation' )
2017-04-04 23:03:47 -04:00
#####################################################################
# compilation result tests
2023-06-12 10:45:48 +02:00
conf . set ( '_GNU_SOURCE' , 1 )
2017-04-27 21:13:08 -04:00
conf . set ( '__SANE_USERSPACE_TYPES__' , true )
2019-05-07 15:10:58 +02:00
conf . set10 ( 'HAVE_WSTRINGOP_TRUNCATION' , has_wstringop_truncation )
2017-04-04 23:03:47 -04:00
conf . set ( 'SIZEOF_DEV_T' , cc . sizeof ( 'dev_t' , prefix : '#include <sys/types.h>' ) )
conf . set ( 'SIZEOF_INO_T' , cc . sizeof ( 'ino_t' , prefix : '#include <sys/types.h>' ) )
conf . set ( 'SIZEOF_RLIM_T' , cc . sizeof ( 'rlim_t' , prefix : '#include <sys/resource.h>' ) )
2023-06-01 08:18:15 +09:00
conf . set ( 'SIZEOF_TIME_T' , cc . sizeof ( 'time_t' , prefix : '#include <sys/time.h>' ) )
2021-12-21 20:10:09 +09:00
conf . set ( 'SIZEOF_TIMEX_MEMBER' , cc . sizeof ( 'typeof(((struct timex *)0)->freq)' , prefix : '#include <sys/timex.h>' ) )
2017-04-04 23:03:47 -04:00
2022-12-17 17:00:56 +01:00
long_max = cc . compute_int (
'LONG_MAX' ,
prefix : '#include <limits.h>' ,
guess : 0x7FFFFFFFFFFFFFFF ,
high : 0x7FFFFFFFFFFFFFFF )
2022-12-03 11:55:55 +01:00
assert ( long_max > 100000 )
conf . set_quoted ( 'LONG_MAX_STR' , '@0@' . format ( long_max ) )
2017-04-04 23:03:47 -04:00
decl_headers = '''
2023-05-10 01:47:13 +01:00
#include <dirent.h>
2017-04-04 23:03:47 -04:00
#include <uchar.h>
2021-04-27 14:16:06 +02:00
#include <sys/mount.h>
2018-02-20 12:48:33 +01:00
#include <sys/stat.h>
2017-04-04 23:03:47 -04:00
'''
foreach decl : [ 'char16_t' ,
'char32_t' ,
2021-04-27 14:16:06 +02:00
'struct mount_attr' ,
2018-02-20 12:48:33 +01:00
'struct statx' ,
2023-05-10 01:47:13 +01:00
'struct dirent64' ,
2017-04-04 23:03:47 -04:00
]
2017-04-27 21:13:08 -04:00
# We get -1 if the size cannot be determined
2018-07-18 17:26:17 +02:00
have = cc . sizeof ( decl , prefix : decl_headers , args : '-D_GNU_SOURCE' ) > 0
2022-07-23 10:38:49 +00:00
if decl == 'struct mount_attr'
if have
want_linux_fs_h = false
else
have = cc . sizeof ( decl ,
prefix : decl_headers + '#include <linux/fs.h>' ,
args : '-D_GNU_SOURCE' ) > 0
want_linux_fs_h = have
endif
endif
2018-07-18 17:26:17 +02:00
if decl == 'struct statx'
if have
want_linux_stat_h = false
else
have = cc . sizeof ( decl ,
prefix : decl_headers + '#include <linux/stat.h>' ,
args : '-D_GNU_SOURCE' ) > 0
want_linux_stat_h = have
endif
endif
2017-10-03 10:41:51 +02:00
conf . set10 ( 'HAVE_' + decl . underscorify ( ) . to_upper ( ) , have )
2017-04-04 23:03:47 -04:00
endforeach
2018-07-18 17:26:17 +02:00
conf . set10 ( 'WANT_LINUX_STAT_H' , want_linux_stat_h )
2022-07-23 10:38:49 +00:00
conf . set10 ( 'WANT_LINUX_FS_H' , want_linux_fs_h )
2018-07-15 22:43:35 -07:00
2017-04-04 23:03:47 -04:00
foreach ident : [ 'secure_getenv' , '__secure_getenv' ]
2017-10-03 10:41:51 +02:00
conf . set10 ( 'HAVE_' + ident . to_upper ( ) , cc . has_function ( ident ) )
2017-04-04 23:03:47 -04:00
endforeach
foreach ident : [
2017-12-25 12:01:14 +01:00
[ 'memfd_create' , '''#include <sys/mman.h>''' ] ,
2017-12-25 12:35:28 +01:00
[ 'gettid' , '''#include <sys/types.h>
#include <unistd.h>''' ] ,
2023-10-20 14:22:50 +03:00
[ 'fchmodat2' , '''#include <stdlib.h>
#include <fcntl.h>''' ] , # no known header declares fchmodat2
2017-12-25 12:07:40 +01:00
[ 'pivot_root' , '''#include <stdlib.h>
#include <unistd.h>''' ] , # no known header declares pivot_root
2021-09-14 16:27:32 +02:00
[ 'ioprio_get' , '''#include <sched.h>''' ] , # no known header declares ioprio_get
[ 'ioprio_set' , '''#include <sched.h>''' ] , # no known header declares ioprio_set
2017-12-25 12:01:14 +01:00
[ 'name_to_handle_at' , '''#include <sys/types.h>
2017-04-17 19:25:00 -04:00
#include <sys/stat.h>
#include <fcntl.h>''' ] ,
2017-12-25 12:01:14 +01:00
[ 'setns' , '''#include <sched.h>''' ] ,
2017-12-25 12:35:43 +01:00
[ 'renameat2' , '''#include <stdio.h>
#include <fcntl.h>''' ] ,
2017-04-17 19:25:00 -04:00
[ 'kcmp' , '''#include <linux/kcmp.h>''' ] ,
[ 'keyctl' , '''#include <sys/types.h>
#include <keyutils.h>''' ] ,
2017-12-25 12:01:14 +01:00
[ 'copy_file_range' , '''#include <sys/syscall.h>
2017-04-17 19:25:00 -04:00
#include <unistd.h>''' ] ,
2016-10-18 17:57:10 +02:00
[ 'bpf' , '''#include <sys/syscall.h>
#include <unistd.h>''' ] ,
2018-02-20 12:48:33 +01:00
[ 'statx' , '''#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>''' ] ,
2018-02-26 21:20:00 +01:00
[ 'explicit_bzero' , '''#include <string.h>''' ] ,
2020-12-12 16:15:57 -08:00
[ 'reallocarray' , '''#include <stdlib.h>''' ] ,
2019-03-12 18:58:26 +01:00
[ 'set_mempolicy' , '''#include <stdlib.h>
#include <unistd.h>''' ] ,
[ 'get_mempolicy' , '''#include <stdlib.h>
#include <unistd.h>''' ] ,
2019-10-25 16:06:06 +02:00
[ 'pidfd_send_signal' , '''#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>''' ] ,
[ 'pidfd_open' , '''#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>''' ] ,
2019-10-30 16:29:42 +01:00
[ 'rt_sigqueueinfo' , '''#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>''' ] ,
2022-11-16 15:03:11 +01:00
[ 'rt_tgsigqueueinfo' , '''#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>''' ] ,
2020-10-09 16:48:03 +02:00
[ 'mallinfo' , '''#include <malloc.h>''' ] ,
2021-05-03 20:36:32 +02:00
[ 'mallinfo2' , '''#include <malloc.h>''' ] ,
2020-09-23 16:23:30 +02:00
[ 'execveat' , '''#include <unistd.h>''' ] ,
2020-10-13 17:53:25 +02:00
[ 'close_range' , '''#include <unistd.h>''' ] ,
2021-02-25 16:56:07 +01:00
[ 'epoll_pwait2' , '''#include <sys/epoll.h>''' ] ,
2021-04-27 14:16:06 +02:00
[ 'mount_setattr' , '''#include <sys/mount.h>''' ] ,
[ 'move_mount' , '''#include <sys/mount.h>''' ] ,
[ 'open_tree' , '''#include <sys/mount.h>''' ] ,
2022-10-27 13:14:12 +02:00
[ 'fsopen' , '''#include <sys/mount.h>''' ] ,
[ 'fsconfig' , '''#include <sys/mount.h>''' ] ,
2023-03-07 14:36:03 +01:00
[ 'fsmount' , '''#include <sys/mount.h>''' ] ,
2021-10-08 10:46:02 +02:00
[ 'getdents64' , '''#include <dirent.h>''' ] ,
2024-01-12 21:32:20 +00:00
[ 'pidfd_spawn' , '''#include <spawn.h>''' ] ,
2017-04-17 19:25:00 -04:00
]
2017-04-04 23:03:47 -04:00
2017-12-25 12:01:14 +01:00
have = cc . has_function ( ident [ 0 ] , prefix : ident [ 1 ] , args : '-D_GNU_SOURCE' )
2017-10-03 10:32:34 +02:00
conf . set10 ( 'HAVE_' + ident [ 0 ] . to_upper ( ) , have )
2017-04-04 23:03:47 -04:00
endforeach
2017-12-25 12:01:14 +01:00
if cc . has_function ( 'getrandom' , prefix : '''#include <sys/random.h>''' , args : '-D_GNU_SOURCE' )
2017-10-03 10:41:51 +02:00
conf . set10 ( 'USE_SYS_RANDOM_H' , true )
2017-10-03 10:32:34 +02:00
conf . set10 ( 'HAVE_GETRANDOM' , true )
2017-04-19 21:20:54 -04:00
else
have = cc . has_function ( 'getrandom' , prefix : '''#include <linux/random.h>''' )
2017-10-03 10:41:51 +02:00
conf . set10 ( 'USE_SYS_RANDOM_H' , false )
2017-10-03 10:32:34 +02:00
conf . set10 ( 'HAVE_GETRANDOM' , have )
2017-04-19 21:20:54 -04:00
endif
2017-04-04 23:03:47 -04:00
#####################################################################
2021-05-14 14:16:17 +02:00
sh = find_program ( 'sh' )
echo = find_program ( 'echo' )
2017-04-04 23:03:47 -04:00
sed = find_program ( 'sed' )
awk = find_program ( 'awk' )
stat = find_program ( 'stat' )
2021-05-14 14:16:17 +02:00
ln = find_program ( 'ln' )
2017-04-06 14:33:27 -04:00
git = find_program ( 'git' , required : false )
2018-01-19 17:54:30 +11:00
env = find_program ( 'env' )
2021-05-14 14:16:17 +02:00
rsync = find_program ( 'rsync' , required : false )
2023-04-27 16:37:39 +02:00
diff = find_program ( 'diff' )
2023-05-01 10:25:18 +02:00
find = find_program ( 'find' )
2021-05-14 14:16:17 +02:00
2023-08-08 10:38:47 +09:00
ln_s = ln . full_path ( ) + ' -frsT -- "${DESTDIR:-}@0@" "${DESTDIR:-}@1@"'
2017-04-09 23:55:05 -04:00
2021-07-27 16:16:07 +02:00
# If -Dxxx-path option is found, use that. Otherwise, check in $PATH,
2017-04-04 23:03:47 -04:00
# /usr/sbin, /sbin, and fall back to the default from middle column.
2018-01-04 07:14:20 -05:00
progs = [ [ 'quotaon' , '/usr/sbin/quotaon' ] ,
2017-04-04 23:03:47 -04:00
[ 'quotacheck' , '/usr/sbin/quotacheck' ] ,
[ 'kmod' , '/usr/bin/kmod' ] ,
[ 'kexec' , '/usr/sbin/kexec' ] ,
[ 'sulogin' , '/usr/sbin/sulogin' ] ,
[ 'mount' , '/usr/bin/mount' , 'MOUNT_PATH' ] ,
[ 'umount' , '/usr/bin/umount' , 'UMOUNT_PATH' ] ,
[ 'loadkeys' , '/usr/bin/loadkeys' , 'KBD_LOADKEYS' ] ,
[ 'setfont' , '/usr/bin/setfont' , 'KBD_SETFONT' ] ,
2019-07-18 01:24:00 +02:00
[ 'nologin' , '/usr/sbin/nologin' , ] ,
2017-04-04 23:03:47 -04:00
]
foreach prog : progs
2017-04-17 19:25:00 -04:00
path = get_option ( prog [ 0 ] + '-path' )
if path != ''
message ( 'Using @1@ for @0@' . format ( prog [ 0 ] , path ) )
else
exe = find_program ( prog [ 0 ] ,
'/usr/sbin/' + prog [ 0 ] ,
'/sbin/' + prog [ 0 ] ,
required : false )
2022-05-16 03:22:33 +09:00
path = exe . found ( ) ? exe . full_path ( ) : prog [ 1 ]
2017-04-17 19:25:00 -04:00
endif
name = prog . length ( ) > 2 ? prog [ 2 ] : prog [ 0 ] . to_upper ( )
conf . set_quoted ( name , path )
2017-04-04 23:03:47 -04:00
endforeach
2021-11-17 13:58:53 +01:00
if run_command ( ln , '--relative' , '--help' , check : false ) . returncode ( ) != 0
2018-03-09 08:56:23 +01:00
error ( 'ln does not support --relative (added in coreutils 8.16)' )
2017-04-18 19:11:54 -04:00
endif
2017-04-04 23:03:47 -04:00
2023-12-14 18:35:00 -03:00
#####################################################################
2017-04-04 23:03:47 -04:00
gperf = find_program ( 'gperf' )
gperf_test_format = '''
#include <string.h>
const char * in_word_set(const char *, @0@);
@1@
'''
2022-05-15 11:11:24 -04:00
gperf_snippet = run_command ( sh , '-c' , 'echo foo,bar | "$1" -L ANSI-C' , '_' , gperf ,
2021-11-17 13:58:53 +01:00
check : true )
2017-04-04 23:03:47 -04:00
gperf_test = gperf_test_format . format ( 'size_t' , gperf_snippet . stdout ( ) )
if cc . compiles ( gperf_test )
2017-04-17 19:25:00 -04:00
gperf_len_type = 'size_t'
2017-04-04 23:03:47 -04:00
else
2017-04-17 19:25:00 -04:00
gperf_test = gperf_test_format . format ( 'unsigned' , gperf_snippet . stdout ( ) )
if cc . compiles ( gperf_test )
gperf_len_type = 'unsigned'
else
error ( 'unable to determine gperf len type' )
endif
2017-04-04 23:03:47 -04:00
endif
message ( 'gperf len type is @0@' . format ( gperf_len_type ) )
2017-04-17 19:25:00 -04:00
conf . set ( 'GPERF_LEN_TYPE' , gperf_len_type ,
description : 'The type of gperf "len" parameter' )
2017-04-04 23:03:47 -04:00
2023-12-14 18:35:00 -03:00
#####################################################################
2017-04-04 23:03:47 -04:00
if not cc . has_header ( 'sys/capability.h' )
2017-04-17 19:25:00 -04:00
error ( 'POSIX caps headers not found' )
2017-04-04 23:03:47 -04:00
endif
2018-01-25 15:30:15 +01:00
foreach header : [ 'crypt.h' ,
2024-03-20 11:51:08 +01:00
'linux/ioprio.h' ,
2017-04-04 23:03:47 -04:00
'linux/memfd.h' ,
2024-03-20 11:51:08 +01:00
'linux/time_types.h' ,
2017-04-04 23:03:47 -04:00
'linux/vm_sockets.h' ,
2017-10-03 12:09:40 +02:00
'sys/auxv.h' ,
2024-03-20 11:51:08 +01:00
'sys/sdt.h' ,
2023-01-03 17:52:08 +00:00
'threads.h' ,
2017-04-04 23:03:47 -04:00
'valgrind/memcheck.h' ,
'valgrind/valgrind.h' ,
]
2017-04-27 21:13:08 -04:00
2017-10-03 10:41:51 +02:00
conf . set10 ( 'HAVE_' + header . underscorify ( ) . to_upper ( ) ,
cc . has_header ( header ) )
2017-04-04 23:03:47 -04:00
endforeach
2023-12-14 18:35:00 -03:00
#####################################################################
2017-04-04 23:03:47 -04:00
2020-05-07 17:30:02 +02:00
fallback_hostname = get_option ( 'fallback-hostname' )
if fallback_hostname == '' or fallback_hostname [ 0 ] == '.' or fallback_hostname [ 0 ] == '-'
error ( 'Invalid fallback-hostname configuration' )
# A more extensive test is done in test-hostname-util. Let's catch
# the most obvious errors here so we don't fail with an assert later.
endif
conf . set_quoted ( 'FALLBACK_HOSTNAME' , fallback_hostname )
2021-09-28 10:12:36 +02:00
extra_net_naming_schemes = [ ]
extra_net_naming_map = [ ]
foreach scheme : get_option ( 'extra-net-naming-schemes' ) . split ( ',' )
if scheme != ''
name = scheme . split ( '=' ) [ 0 ]
value = scheme . split ( '=' ) [ 1 ]
NAME = name . underscorify ( ) . to_upper ( )
VALUE = [ ]
foreach field : value . split ( '+' )
VALUE + = 'NAMING_' + field . underscorify ( ) . to_upper ( )
endforeach
extra_net_naming_schemes + = 'NAMING_@0@ = @1@,' . format ( NAME , '|' . join ( VALUE ) )
extra_net_naming_map + = '{ "@0@", NAMING_@1@ },' . format ( name , NAME )
endif
endforeach
conf . set ( 'EXTRA_NET_NAMING_SCHEMES' , ' ' . join ( extra_net_naming_schemes ) )
conf . set ( 'EXTRA_NET_NAMING_MAP' , ' ' . join ( extra_net_naming_map ) )
2018-12-11 23:28:29 +01:00
default_net_naming_scheme = get_option ( 'default-net-naming-scheme' )
2023-10-16 12:53:10 +02:00
conf . set_quoted ( 'DEFAULT_NET_NAMING_SCHEME' , default_net_naming_scheme ,
description : 'Default naming scheme as a string' )
2021-09-28 09:33:30 +02:00
if default_net_naming_scheme != 'latest'
2023-10-16 12:53:10 +02:00
conf . set ( '_DEFAULT_NET_NAMING_SCHEME' ,
'NAMING_' + default_net_naming_scheme . underscorify ( ) . to_upper ( ) ,
description : 'Default naming scheme as a constant' )
2021-09-28 09:33:30 +02:00
endif
2018-12-11 23:28:29 +01:00
2017-04-04 23:03:47 -04:00
time_epoch = get_option ( 'time-epoch' )
2022-07-30 13:44:11 +09:00
if time_epoch < = 0
2021-11-17 13:58:53 +01:00
time_epoch = run_command ( sh , '-c' , 'echo "$SOURCE_DATE_EPOCH"' , check : true ) . stdout ( ) . strip ( )
2023-03-01 22:54:06 +01:00
if time_epoch == '' and git . found ( ) and fs . is_dir ( '.git' )
2020-07-20 20:41:48 +01:00
# If we're in a git repository, use the creation time of the latest git tag.
2021-11-17 13:58:53 +01:00
latest_tag = run_command ( git , 'describe' , '--abbrev=0' , '--tags' ,
check : false )
if latest_tag . returncode ( ) == 0
time_epoch = run_command (
git , 'log' , '--no-show-signature' , '-1' , '--format=%at' ,
latest_tag . stdout ( ) . strip ( ) ,
check : false ) . stdout ( )
endif
2020-05-15 19:16:05 +01:00
endif
2020-07-23 12:23:58 +02:00
if time_epoch == ''
NEWS = files ( 'NEWS' )
2021-11-17 13:58:53 +01:00
time_epoch = run_command ( stat , '-c' , '%Y' , NEWS ,
check : true ) . stdout ( )
2020-07-23 12:23:58 +02:00
endif
2022-07-26 21:13:55 -04:00
time_epoch = time_epoch . strip ( ) . to_int ( )
2017-04-04 23:03:47 -04:00
endif
conf . set ( 'TIME_EPOCH' , time_epoch )
2021-07-28 12:13:31 +03:00
conf . set ( 'CLOCK_VALID_RANGE_USEC_MAX' , get_option ( 'clock-valid-range-usec-max' ) )
2022-03-24 17:15:39 +01:00
default_user_shell = get_option ( 'default-user-shell' )
conf . set_quoted ( 'DEFAULT_USER_SHELL' , default_user_shell )
conf . set_quoted ( 'DEFAULT_USER_SHELL_NAME' , fs . name ( default_user_shell ) )
2020-09-25 16:50:45 +02:00
foreach tuple : [ [ 'system-alloc-uid-min' , 'SYS_UID_MIN' , 1 ] , # Also see login.defs(5).
[ 'system-uid-max' , 'SYS_UID_MAX' , 999 ] ,
[ 'system-alloc-gid-min' , 'SYS_GID_MIN' , 1 ] ,
[ 'system-gid-max' , 'SYS_GID_MAX' , 999 ] ]
v = get_option ( tuple [ 0 ] )
2022-07-30 13:44:11 +09:00
if v < = 0
2020-09-25 16:50:45 +02:00
v = run_command (
awk ,
'/^\s*@0@\s+/ { uid=$2 } END { print uid }' . format ( tuple [ 1 ] ) ,
2021-11-17 13:58:53 +01:00
'/etc/login.defs' ,
check : false ) . stdout ( ) . strip ( )
2020-09-25 16:50:45 +02:00
if v == ''
v = tuple [ 2 ]
else
v = v . to_int ( )
endif
2018-02-18 18:33:16 -08:00
endif
2020-09-25 16:50:45 +02:00
conf . set ( tuple [ 0 ] . underscorify ( ) . to_upper ( ) , v )
endforeach
if conf . get ( 'SYSTEM_ALLOC_UID_MIN' ) > = conf . get ( 'SYSTEM_UID_MAX' )
error ( 'Invalid uid allocation range' )
2017-04-04 23:03:47 -04:00
endif
2020-09-25 16:50:45 +02:00
if conf . get ( 'SYSTEM_ALLOC_GID_MIN' ) > = conf . get ( 'SYSTEM_GID_MAX' )
error ( 'Invalid gid allocation range' )
2017-04-04 23:03:47 -04:00
endif
2018-05-10 16:04:16 +09:00
dynamic_uid_min = get_option ( 'dynamic-uid-min' )
dynamic_uid_max = get_option ( 'dynamic-uid-max' )
2017-12-02 12:48:31 +01:00
conf . set ( 'DYNAMIC_UID_MIN' , dynamic_uid_min )
conf . set ( 'DYNAMIC_UID_MAX' , dynamic_uid_max )
2018-05-10 16:04:16 +09:00
container_uid_base_min = get_option ( 'container-uid-base-min' )
container_uid_base_max = get_option ( 'container-uid-base-max' )
2017-12-02 12:48:31 +01:00
conf . set ( 'CONTAINER_UID_BASE_MIN' , container_uid_base_min )
conf . set ( 'CONTAINER_UID_BASE_MAX' , container_uid_base_max )
2017-12-05 11:00:24 +01:00
nobody_user = get_option ( 'nobody-user' )
nobody_group = get_option ( 'nobody-group' )
2018-07-23 14:53:09 +08:00
if not meson . is_cross_build ( )
2021-11-17 13:58:53 +01:00
getent_result = run_command ( 'getent' , 'passwd' , '65534' , check : false )
2018-07-23 14:53:09 +08:00
if getent_result . returncode ( ) == 0
name = getent_result . stdout ( ) . split ( ':' ) [ 0 ]
if name != nobody_user
warning ( '\n' +
'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 ) +
'Your build will result in an user table setup that is incompatible with the local system.' )
endif
2017-12-05 11:00:24 +01:00
endif
2021-11-17 13:58:53 +01:00
id_result = run_command ( 'id' , '-u' , nobody_user , check : false )
2018-07-23 14:53:09 +08:00
if id_result . returncode ( ) == 0
2022-07-26 21:13:55 -04:00
id = id_result . stdout ( ) . strip ( ) . to_int ( )
2018-07-23 14:53:09 +08:00
if id != 65534
warning ( '\n' +
'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 ) +
'Your build will result in an user table setup that is incompatible with the local system.' )
endif
2017-12-05 11:00:24 +01:00
endif
2021-11-17 13:58:53 +01:00
getent_result = run_command ( 'getent' , 'group' , '65534' , check : false )
2018-07-23 14:53:09 +08:00
if getent_result . returncode ( ) == 0
name = getent_result . stdout ( ) . split ( ':' ) [ 0 ]
if name != nobody_group
warning ( '\n' +
'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 ) +
'Your build will result in an group table setup that is incompatible with the local system.' )
endif
2017-12-05 11:00:24 +01:00
endif
2021-11-17 13:58:53 +01:00
id_result = run_command ( 'id' , '-g' , nobody_group , check : false )
2018-07-23 14:53:09 +08:00
if id_result . returncode ( ) == 0
2022-07-26 21:13:55 -04:00
id = id_result . stdout ( ) . strip ( ) . to_int ( )
2018-07-23 14:53:09 +08:00
if id != 65534
warning ( '\n' +
2021-04-15 00:01:53 +01:00
'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 ) +
2018-07-23 14:53:09 +08:00
'Your build will result in an group table setup that is incompatible with the local system.' )
endif
2017-12-05 11:00:24 +01:00
endif
endif
2017-12-07 17:19:11 +09:00
if nobody_user != nobody_group and not ( nobody_user == 'nobody' and nobody_group == 'nogroup' )
2018-05-10 14:50:52 +09:00
warning ( '\n' +
2023-10-16 16:47:41 +02:00
'The configured user name "@0@" and group name "@1@" of the nobody user/group are not equivalent.\n' . format ( nobody_user , nobody_group ) +
2018-05-10 14:50:52 +09:00
'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.' )
2017-12-07 17:19:11 +09:00
endif
2017-12-05 11:00:24 +01:00
conf . set_quoted ( 'NOBODY_USER_NAME' , nobody_user )
conf . set_quoted ( 'NOBODY_GROUP_NAME' , nobody_group )
2017-12-02 12:48:31 +01:00
2021-05-23 22:00:22 +02:00
static_ugids = [ ]
foreach option : [ 'adm-gid' ,
'audio-gid' ,
'cdrom-gid' ,
'dialout-gid' ,
'disk-gid' ,
'input-gid' ,
'kmem-gid' ,
'kvm-gid' ,
'lp-gid' ,
'render-gid' ,
'sgx-gid' ,
'tape-gid' ,
'tty-gid' ,
'users-gid' ,
'utmp-gid' ,
'video-gid' ,
'wheel-gid' ,
'systemd-journal-gid' ,
'systemd-network-uid' ,
'systemd-resolve-uid' ,
'systemd-timesync-uid' ]
name = option . underscorify ( ) . to_upper ( )
val = get_option ( option )
2017-04-04 23:03:47 -04:00
2021-05-23 22:00:22 +02:00
# Ensure provided GID argument is numeric, otherwise fall back to default assignment
2022-07-30 13:44:11 +09:00
conf . set ( name , val > 0 ? val : '-' )
if val > 0
2021-05-23 22:00:22 +02:00
static_ugids + = '@0@:@1@' . format ( option , val )
endif
endforeach
2017-12-03 12:28:23 +00:00
2018-05-07 18:17:35 +09:00
conf . set10 ( 'ENABLE_ADM_GROUP' , get_option ( 'adm-group' ) )
conf . set10 ( 'ENABLE_WHEEL_GROUP' , get_option ( 'wheel-group' ) )
2017-04-04 23:03:47 -04:00
2018-07-13 23:36:13 +02:00
dev_kvm_mode = get_option ( 'dev-kvm-mode' )
2021-05-16 13:35:51 +02:00
conf . set_quoted ( 'DEV_KVM_MODE' , dev_kvm_mode ) # FIXME: convert to 0o… notation
2018-07-13 23:36:13 +02:00
conf . set10 ( 'DEV_KVM_UACCESS' , dev_kvm_mode != '0666' )
2019-03-13 23:22:26 +01:00
group_render_mode = get_option ( 'group-render-mode' )
2021-05-16 15:51:17 +02:00
conf . set_quoted ( 'GROUP_RENDER_MODE' , group_render_mode )
2019-03-13 23:22:26 +01:00
conf . set10 ( 'GROUP_RENDER_UACCESS' , group_render_mode != '0666' )
2017-04-04 23:03:47 -04:00
2017-04-12 19:54:33 -04:00
kill_user_processes = get_option ( 'default-kill-user-processes' )
conf . set10 ( 'KILL_USER_PROCESSES' , kill_user_processes )
2017-04-04 23:03:47 -04:00
2017-04-27 20:54:52 -04:00
dns_servers = get_option ( 'dns-servers' )
conf . set_quoted ( 'DNS_SERVERS' , dns_servers )
2017-04-04 23:03:47 -04:00
2017-04-27 20:54:52 -04:00
ntp_servers = get_option ( 'ntp-servers' )
conf . set_quoted ( 'NTP_SERVERS' , ntp_servers )
2017-04-04 23:03:47 -04:00
2018-12-28 07:38:36 -05:00
default_locale = get_option ( 'default-locale' )
conf . set_quoted ( 'SYSTEMD_DEFAULT_LOCALE' , default_locale )
2022-06-03 13:18:10 +02:00
nspawn_locale = get_option ( 'nspawn-locale' )
conf . set_quoted ( 'SYSTEMD_NSPAWN_LOCALE' , nspawn_locale )
2023-01-18 01:21:59 +08:00
default_keymap = get_option ( 'default-keymap' )
2023-08-03 21:42:00 +08:00
if default_keymap == ''
2023-08-10 15:12:15 +02:00
# We canonicalize empty keymap to '@kernel', as it makes the default value
2023-08-03 21:42:00 +08:00
# in the factory provided /etc/vconsole.conf more obvious.
2023-08-10 15:12:15 +02:00
default_keymap = '@kernel'
2023-08-03 21:42:00 +08:00
endif
2023-01-18 01:21:59 +08:00
conf . set_quoted ( 'SYSTEMD_DEFAULT_KEYMAP' , default_keymap )
2021-01-08 23:59:38 +01:00
localegen_path = get_option ( 'localegen-path' )
if localegen_path != ''
conf . set_quoted ( 'LOCALEGEN_PATH' , localegen_path )
endif
2021-05-16 20:13:14 +02:00
conf . set10 ( 'HAVE_LOCALEGEN' , localegen_path != '' )
2021-01-08 23:59:38 +01:00
2017-04-04 23:03:47 -04:00
conf . set_quoted ( 'GETTEXT_PACKAGE' , meson . project_name ( ) )
2019-10-25 12:17:24 +02:00
service_watchdog = get_option ( 'service-watchdog' )
2019-10-25 15:46:21 -07:00
watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
2021-05-16 11:55:36 +02:00
conf . set_quoted ( 'SERVICE_WATCHDOG' , watchdog_value )
2019-10-25 12:17:24 +02:00
2021-05-16 11:55:36 +02:00
conf . set_quoted ( 'SUSHELL' , get_option ( 'debug-shell' ) )
2019-04-25 12:19:16 +02:00
conf . set_quoted ( 'DEBUGTTY' , get_option ( 'debug-tty' ) )
2017-04-10 19:06:45 -04:00
2017-10-03 10:41:51 +02:00
enable_debug_hashmap = false
enable_debug_mmap_cache = false
2018-11-23 00:36:35 +09:00
enable_debug_siphash = false
2018-08-19 19:11:30 +02:00
foreach name : get_option ( 'debug-extra' )
2018-05-02 13:56:28 +09:00
if name == 'hashmap'
enable_debug_hashmap = true
elif name == 'mmap-cache'
enable_debug_mmap_cache = true
2018-11-23 00:36:35 +09:00
elif name == 'siphash'
enable_debug_siphash = true
2018-05-02 13:56:28 +09:00
else
message ( 'unknown debug option "@0@", ignoring' . format ( name ) )
endif
endforeach
2017-10-03 10:41:51 +02:00
conf . set10 ( 'ENABLE_DEBUG_HASHMAP' , enable_debug_hashmap )
conf . set10 ( 'ENABLE_DEBUG_MMAP_CACHE' , enable_debug_mmap_cache )
2018-11-23 00:36:35 +09:00
conf . set10 ( 'ENABLE_DEBUG_SIPHASH' , enable_debug_siphash )
2018-08-07 17:34:47 +02:00
conf . set10 ( 'LOG_TRACE' , get_option ( 'log-trace' ) )
2018-05-13 22:28:24 +02:00
2019-11-12 15:38:19 +01:00
default_user_path = get_option ( 'user-path' )
if default_user_path != ''
conf . set_quoted ( 'DEFAULT_USER_PATH' , default_user_path )
endif
2017-04-04 23:03:47 -04:00
#####################################################################
threads = dependency ( 'threads' )
librt = cc . find_library ( 'rt' )
libm = cc . find_library ( 'm' )
libdl = cc . find_library ( 'dl' )
2023-07-07 18:49:04 +09:00
libcrypt = dependency ( 'libcrypt' , 'libxcrypt' , required : false )
if not libcrypt . found ( )
# fallback to use find_library() if libcrypt is provided by glibc, e.g. for LibreELEC.
libcrypt = cc . find_library ( 'crypt' )
endif
2023-06-27 04:53:13 +09:00
libcap = dependency ( 'libcap' )
2017-04-04 23:03:47 -04:00
2022-10-19 16:23:41 +02:00
# On some architectures, libatomic is required. But on some installations,
# it is found, but actual linking fails. So let's try to use it opportunistically.
# If it is installed, but not needed, it will be dropped because of --as-needed.
if cc . links ( '''int main(int argc, char **argv) { return 0; }''' ,
args : '-latomic' ,
name : 'libatomic' )
libatomic = declare_dependency ( link_args : '-latomic' )
else
libatomic = [ ]
endif
2020-09-21 11:41:17 -07:00
crypt_header = conf . get ( 'HAVE_CRYPT_H' ) == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
2020-09-08 20:02:31 +02:00
foreach ident : [
2020-09-25 11:19:56 +01:00
[ 'crypt_ra' , crypt_header ] ,
[ 'crypt_preferred_method' , crypt_header ] ,
[ 'crypt_gensalt_ra' , crypt_header ] ]
2020-09-08 20:02:31 +02:00
have = cc . has_function ( ident [ 0 ] , prefix : ident [ 1 ] , args : '-D_GNU_SOURCE' ,
dependencies : libcrypt )
conf . set10 ( 'HAVE_' + ident [ 0 ] . to_upper ( ) , have )
endforeach
2023-08-10 16:33:37 +02:00
bpf_framework = get_option ( 'bpf-framework' )
2022-10-01 00:09:53 +00:00
bpf_compiler = get_option ( 'bpf-compiler' )
2023-08-10 16:33:37 +02:00
libbpf = dependency ( 'libbpf' ,
required : bpf_framework ,
version : bpf_compiler == 'gcc' ? '>= 1.0.0' : '>= 0.1.0' )
2020-11-13 17:08:15 -08:00
conf . set10 ( 'HAVE_LIBBPF' , libbpf . found ( ) )
2023-08-10 16:33:37 +02:00
if not libbpf . found ( )
2022-05-15 18:10:25 +09:00
conf . set10 ( 'BPF_FRAMEWORK' , false )
2020-11-13 17:08:15 -08:00
else
2022-06-08 10:13:42 +00:00
clang_found = false
clang_supports_bpf = false
bpf_gcc_found = false
2022-10-01 00:09:53 +00:00
bpftool_strip = false
2022-06-08 10:13:42 +00:00
deps_found = false
if bpf_compiler == 'clang'
# Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu
# (like clang-10/llvm-strip-10)
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' )
2023-08-10 16:33:37 +02:00
r = find_program ( 'clang' ,
required : bpf_framework ,
version : '>= 10.0.0' )
2022-06-08 10:13:42 +00:00
clang_found = r . found ( )
if clang_found
2022-05-16 03:22:33 +09:00
clang = r . full_path ( )
2022-06-08 10:13:42 +00:00
endif
else
clang_found = true
clang = cc . cmd_array ( )
2022-01-13 15:43:24 +09:00
endif
2022-06-08 10:13:42 +00:00
if clang_found
# Check if 'clang -target bpf' is supported.
clang_supports_bpf = run_command ( clang , '-target' , 'bpf' , '--print-supported-cpus' , check : false ) . returncode ( ) == 0
endif
elif bpf_compiler == 'gcc'
bpf_gcc = find_program ( 'bpf-gcc' ,
2023-05-29 15:45:13 -06:00
'bpf-none-gcc' ,
2022-06-08 10:13:42 +00:00
required : true ,
2023-05-29 15:01:34 -06:00
version : '>= 13.1.0' )
2022-06-08 10:13:42 +00:00
bpf_gcc_found = bpf_gcc . found ( )
2021-12-21 21:05:10 +00:00
endif
2022-01-13 15:33:46 +09:00
2022-06-08 10:13:42 +00:00
if clang_supports_bpf or bpf_gcc_found
# Debian installs this in /usr/sbin/ which is not in $PATH.
# We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian.
# We use 'bpftool gen object' subcommand for bpftool strip, it was added by d80b2fcbe0a023619e0fc73112f2a02c2662f6ab (v5.13).
2022-01-30 21:47:38 -07:00
bpftool = find_program ( 'bpftool' ,
'/usr/sbin/bpftool' ,
2023-08-10 16:33:37 +02:00
required : bpf_framework . enabled ( ) and bpf_compiler == 'gcc' ,
version : bpf_compiler == 'gcc' ? '>= 7.0.0' : '>= 5.13.0' )
2022-01-30 21:47:38 -07:00
2022-06-08 10:13:42 +00:00
if bpftool . found ( )
bpftool_strip = true
deps_found = true
2022-10-01 00:09:53 +00:00
elif bpf_compiler == 'clang'
2022-06-08 10:13:42 +00:00
# We require the 'bpftool gen skeleton' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6).
bpftool = find_program ( 'bpftool' ,
'/usr/sbin/bpftool' ,
2023-08-10 16:33:37 +02:00
required : bpf_framework ,
2022-06-08 10:13:42 +00:00
version : '>= 5.6.0' )
2022-01-30 21:47:38 -07:00
endif
2022-06-08 10:13:42 +00:00
# We use `llvm-strip` as a fallback if `bpftool gen object` strip support is not available.
if not bpftool_strip and bpftool . found ( ) and clang_supports_bpf
if not meson . is_cross_build ( )
llvm_strip_bin = run_command ( clang , '--print-prog-name' , 'llvm-strip' ,
check : true ) . stdout ( ) . strip ( )
else
llvm_strip_bin = 'llvm-strip'
endif
2023-08-10 16:33:37 +02:00
llvm_strip = find_program ( llvm_strip_bin ,
required : bpf_framework ,
version : '>= 10.0.0' )
2022-06-08 10:13:42 +00:00
deps_found = llvm_strip . found ( )
endif
endif
2021-07-27 16:20:40 +02:00
2020-11-13 17:08:15 -08:00
# Can build BPF program from source code in restricted C
2021-08-11 21:59:19 -06:00
conf . set10 ( 'BPF_FRAMEWORK' , deps_found )
2020-11-13 17:08:15 -08:00
endif
2017-04-04 23:03:47 -04:00
libmount = dependency ( 'mount' ,
2018-03-09 14:58:47 +01:00
version : fuzzer_build ? '>= 0' : '>= 2.30' )
2017-04-04 23:03:47 -04:00
2023-08-09 18:07:19 +02:00
libfdisk = dependency ( 'fdisk' ,
version : '>= 2.32' ,
disabler : true ,
required : get_option ( 'fdisk' ) )
conf . set10 ( 'HAVE_LIBFDISK' , libfdisk . found ( ) )
2019-12-10 21:31:41 +01:00
2023-08-10 16:00:55 +02:00
# This prefers pwquality if both are enabled or auto.
feature = get_option ( 'pwquality' ) . disable_auto_if ( get_option ( 'passwdqc' ) . enabled ( ) )
libpwquality = dependency ( 'pwquality' ,
version : '>= 1.4.1' ,
required : feature )
have = libpwquality . found ( )
if not have
# libpwquality is used for both features for simplicity
libpwquality = dependency ( 'passwdqc' ,
required : get_option ( 'passwdqc' ) )
2019-07-04 18:35:39 +02:00
endif
conf . set10 ( 'HAVE_PWQUALITY' , have )
2023-08-10 16:00:55 +02:00
conf . set10 ( 'HAVE_PASSWDQC' , not have and libpwquality . found ( ) )
2019-07-04 18:35:39 +02:00
2023-08-09 18:15:29 +02:00
libseccomp = dependency ( 'libseccomp' ,
version : '>= 2.3.1' ,
required : get_option ( 'seccomp' ) )
conf . set10 ( 'HAVE_SECCOMP' , libseccomp . found ( ) )
2021-08-06 11:41:01 +03:00
2023-08-09 18:15:29 +02:00
libselinux = dependency ( 'libselinux' ,
version : '>= 2.1.9' ,
required : get_option ( 'selinux' ) )
conf . set10 ( 'HAVE_SELINUX' , libselinux . found ( ) )
2017-04-04 23:03:47 -04:00
2023-08-09 18:15:29 +02:00
libapparmor = dependency ( 'libapparmor' ,
version : '>= 2.13' ,
required : get_option ( 'apparmor' ) )
conf . set10 ( 'HAVE_APPARMOR' , libapparmor . found ( ) )
2017-04-04 23:03:47 -04:00
2021-09-21 19:53:20 +02:00
have = get_option ( 'smack' ) and get_option ( 'smack-run-label' ) != ''
conf . set10 ( 'HAVE_SMACK_RUN_LABEL' , have )
if have
conf . set_quoted ( 'SMACK_RUN_LABEL' , get_option ( 'smack-run-label' ) )
endif
2017-04-04 23:03:47 -04:00
2022-07-06 13:09:51 +02:00
have = get_option ( 'smack' ) and get_option ( 'smack-default-process-label' ) != ''
if have
conf . set_quoted ( 'SMACK_DEFAULT_PROCESS_LABEL' , get_option ( 'smack-default-process-label' ) )
endif
2023-08-09 19:52:57 +02:00
feature = get_option ( 'polkit' )
libpolkit = dependency ( 'polkit-gobject-1' ,
required : feature . disabled ( ) ? feature : false )
install_polkit = feature . allowed ( )
install_polkit_pkla = libpolkit . found ( ) and libpolkit . version ( ) . version_compare ( '< 0.106' )
if install_polkit_pkla
message ( 'Old polkit detected, will install pkla files' )
2017-04-12 19:09:26 -04:00
endif
2017-10-03 10:41:51 +02:00
conf . set10 ( 'ENABLE_POLKIT' , install_polkit )
2017-04-12 19:09:26 -04:00
2023-08-09 18:15:29 +02:00
libacl = dependency ( 'libacl' ,
required : get_option ( 'acl' ) )
conf . set10 ( 'HAVE_ACL' , libacl . found ( ) )
2017-04-21 13:53:59 -04:00
2023-08-09 18:15:29 +02:00
libaudit = dependency ( 'audit' ,
required : get_option ( 'audit' ) )
conf . set10 ( 'HAVE_AUDIT' , libaudit . found ( ) )
2017-04-04 23:03:47 -04:00
2023-08-09 18:15:29 +02:00
libblkid = dependency ( 'blkid' ,
required : get_option ( 'blkid' ) )
conf . set10 ( 'HAVE_BLKID' , libblkid . found ( ) )
conf . set10 ( 'HAVE_BLKID_PROBE_SET_HINT' ,
libblkid . found ( ) and cc . has_function ( 'blkid_probe_set_hint' , dependencies : libblkid ) )
2020-11-30 11:38:21 +01:00
2023-08-09 18:15:29 +02:00
libkmod = dependency ( 'libkmod' ,
version : '>= 15' ,
required : get_option ( 'kmod' ) )
conf . set10 ( 'HAVE_KMOD' , libkmod . found ( ) )
2024-01-30 14:50:35 +01:00
libkmod_cflags = libkmod . partial_dependency ( includes : true , compile_args : true )
2017-04-04 23:03:47 -04:00
2023-08-09 18:15:29 +02:00
libxenctrl = dependency ( 'xencontrol' ,
version : '>= 4.9' ,
required : get_option ( 'xenctrl' ) )
conf . set10 ( 'HAVE_XENCTRL' , libxenctrl . found ( ) )
2023-11-02 15:57:34 +01:00
libxenctrl_cflags = libxenctrl . partial_dependency ( includes : true , compile_args : true )
2022-11-01 16:53:02 +01:00
2023-08-09 19:52:57 +02:00
feature = get_option ( 'pam' )
libpam = dependency ( 'pam' ,
required : feature . disabled ( ) ? feature : false )
if not libpam . found ( )
# Debian older than bookworm and Ubuntu older than 22.10 do not provide the .pc file.
libpam = cc . find_library ( 'pam' , required : feature )
2017-04-21 13:53:59 -04:00
endif
2023-08-09 19:52:57 +02:00
libpam_misc = dependency ( 'pam_misc' ,
required : feature . disabled ( ) ? feature : false )
if not libpam_misc . found ( )
libpam_misc = cc . find_library ( 'pam_misc' , required : feature )
2017-04-04 23:03:47 -04:00
endif
2023-08-09 19:52:57 +02:00
conf . set10 ( 'HAVE_PAM' , libpam . found ( ) and libpam_misc . found ( ) )
2017-04-04 23:03:47 -04:00
2023-08-09 18:15:29 +02:00
libmicrohttpd = dependency ( 'libmicrohttpd' ,
version : '>= 0.9.33' ,
required : get_option ( 'microhttpd' ) )
conf . set10 ( 'HAVE_MICROHTTPD' , libmicrohttpd . found ( ) )
2020-11-30 11:38:21 +01:00
2023-08-10 16:00:55 +02:00
libcryptsetup = get_option ( 'libcryptsetup' )
libcryptsetup_plugins = get_option ( 'libcryptsetup-plugins' )
if libcryptsetup_plugins . enabled ( )
if libcryptsetup . disabled ( )
2023-11-08 13:50:39 +01:00
error ( 'libcryptsetup-plugins cannot be requested without libcryptsetup' )
2023-06-27 04:53:13 +09:00
endif
2023-08-10 16:00:55 +02:00
libcryptsetup = libcryptsetup_plugins
2021-03-16 20:13:28 +01:00
endif
2023-08-10 16:00:55 +02:00
libcryptsetup = dependency ( 'libcryptsetup' ,
version : libcryptsetup_plugins . enabled ( ) ? '>= 2.4.0' : '>= 2.0.1' ,
required : libcryptsetup )
2019-07-04 18:35:39 +02:00
2023-08-10 16:00:55 +02:00
have = libcryptsetup . found ( )
foreach ident : [ 'crypt_set_metadata_size' ,
'crypt_activate_by_signed_key' ,
'crypt_token_max' ,
'crypt_reencrypt_init_by_passphrase' ,
'crypt_reencrypt' ,
2024-01-31 13:11:21 +01:00
'crypt_set_data_offset' ,
2024-01-31 23:49:24 -05:00
'crypt_set_keyring_to_link' ,
'crypt_resume_by_volume_key' ]
2023-08-10 16:00:55 +02:00
have_ident = have and cc . has_function (
ident ,
prefix : '#include <libcryptsetup.h>' ,
dependencies : libcryptsetup )
conf . set10 ( 'HAVE_' + ident . to_upper ( ) , have_ident )
endforeach
2017-10-03 10:41:51 +02:00
conf . set10 ( 'HAVE_LIBCRYPTSETUP' , have )
2017-04-04 23:03:47 -04:00
2023-08-10 16:00:55 +02:00
# TODO: Use has_function(required : libcryptsetup_plugins) with meson >= 1.3.0
if libcryptsetup_plugins . allowed ( )
2021-12-30 14:51:44 +01:00
have = ( cc . has_function (
'crypt_activate_by_token_pin' ,
prefix : '#include <libcryptsetup.h>' ,
dependencies : libcryptsetup ) and
cc . has_function (
'crypt_token_external_path' ,
prefix : '#include <libcryptsetup.h>' ,
dependencies : libcryptsetup ) )
2021-03-16 20:13:28 +01:00
else
have = false
endif
conf . set10 ( 'HAVE_LIBCRYPTSETUP_PLUGINS' , have )
2023-08-09 18:15:29 +02:00
libcurl = dependency ( 'libcurl' ,
version : '>= 7.32.0' ,
required : get_option ( 'libcurl' ) )
conf . set10 ( 'HAVE_LIBCURL' , libcurl . found ( ) )
2021-04-14 13:17:22 +02:00
conf . set10 ( 'CURL_NO_OLDIES' , conf . get ( 'BUILD_MODE_DEVELOPER' ) == 1 )
2017-04-04 23:03:47 -04:00
2023-08-10 16:00:55 +02:00
feature = get_option ( 'libidn2' ) . disable_auto_if ( get_option ( 'libidn' ) . enabled ( ) )
libidn = dependency ( 'libidn2' ,
required : feature )
have = libidn . found ( )
if not have
2019-06-29 03:13:30 +09:00
# libidn is used for both libidn and libidn2 objects
libidn = dependency ( 'libidn' ,
2023-08-10 16:00:55 +02:00
required : get_option ( 'libidn' ) )
2019-06-29 03:13:30 +09:00
endif
2023-08-10 16:00:55 +02:00
conf . set10 ( 'HAVE_LIBIDN' , not have and libidn . found ( ) )
conf . set10 ( 'HAVE_LIBIDN2' , have )
2017-04-04 23:03:47 -04:00
2023-08-09 18:15:29 +02:00
libiptc = dependency ( 'libiptc' ,
required : get_option ( 'libiptc' ) )
conf . set10 ( 'HAVE_LIBIPTC' , libiptc . found ( ) )
2023-11-02 15:57:10 +01:00
libiptc_cflags = libiptc . partial_dependency ( includes : true , compile_args : true )
2017-04-04 23:03:47 -04:00
2023-08-09 18:15:29 +02:00
libqrencode = dependency ( 'libqrencode' ,
version : '>= 3' ,
required : get_option ( 'qrencode' ) )
conf . set10 ( 'HAVE_QRENCODE' , libqrencode . found ( ) )
2017-04-04 23:03:47 -04:00
2023-08-09 19:52:57 +02:00
feature = get_option ( 'gcrypt' )
libgcrypt = dependency ( 'libgcrypt' ,
required : feature )
libgpg_error = dependency ( 'gpg-error' ,
required : feature . disabled ( ) ? feature : false )
if not libgpg_error . found ( )
# CentOS 8 does not provide the .pc file.
libgpg_error = cc . find_library ( 'gpg-error' , required : feature )
2017-10-03 10:41:51 +02:00
endif
2023-08-09 19:52:57 +02:00
have = libgcrypt . found ( ) and libgpg_error . found ( )
2017-10-03 10:41:51 +02:00
if not have
# link to neither of the libs if one is not found
2017-07-26 14:08:46 -04:00
libgcrypt = [ ]
libgpg_error = [ ]
2024-03-29 23:36:51 +00:00
libgcrypt_cflags = [ ]
else
libgcrypt_cflags = libgcrypt . partial_dependency ( includes : true , compile_args : true )
2017-07-26 14:08:46 -04:00
endif
2017-10-03 10:41:51 +02:00
conf . set10 ( 'HAVE_GCRYPT' , have )
2017-07-26 14:08:46 -04:00
2023-08-09 18:15:29 +02:00
libgnutls = dependency ( 'gnutls' ,
version : '>= 3.1.4' ,
required : get_option ( 'gnutls' ) )
conf . set10 ( 'HAVE_GNUTLS' , libgnutls . found ( ) )
2017-04-04 23:03:47 -04:00
2023-08-09 18:15:29 +02:00
libopenssl = dependency ( 'openssl' ,
version : '>= 1.1.0' ,
required : get_option ( 'openssl' ) )
conf . set10 ( 'HAVE_OPENSSL' , libopenssl . found ( ) )
2018-07-26 22:47:50 +01:00
2023-08-09 18:15:29 +02:00
libp11kit = dependency ( 'p11-kit-1' ,
version : '>= 0.23.3' ,
required : get_option ( 'p11kit' ) )
conf . set10 ( 'HAVE_P11KIT' , libp11kit . found ( ) )
libp11kit_cflags = libp11kit . partial_dependency ( includes : true , compile_args : true )
2019-11-05 11:49:27 +01:00
2023-08-10 15:44:11 +02:00
feature = get_option ( 'libfido2' ) . require (
conf . get ( 'HAVE_OPENSSL' ) == 1 ,
error_message : 'openssl required' )
libfido2 = dependency ( 'libfido2' ,
required : feature )
conf . set10 ( 'HAVE_LIBFIDO2' , libfido2 . found ( ) )
2020-04-14 15:54:52 +02:00
2023-08-09 18:15:29 +02:00
tpm2 = dependency ( 'tss2-esys tss2-rc tss2-mu tss2-tcti-device' ,
required : get_option ( 'tpm2' ) )
conf . set10 ( 'HAVE_TPM2' , tpm2 . found ( ) )
conf . set10 ( 'HAVE_TSS2_ESYS3' , tpm2 . found ( ) and tpm2 . version ( ) . version_compare ( '>= 3.0.0' ) )
2020-11-28 15:27:34 +01:00
2023-08-09 18:15:29 +02:00
libdw = dependency ( 'libdw' ,
required : get_option ( 'elfutils' ) )
conf . set10 ( 'HAVE_ELFUTILS' , libdw . found ( ) )
# New in elfutils 0.177
conf . set10 ( 'HAVE_DWELF_ELF_E_MACHINE_STRING' ,
libdw . found ( ) and cc . has_function ( 'dwelf_elf_e_machine_string' , dependencies : libdw ) )
2021-11-18 00:03:48 +00:00
2023-08-09 18:15:29 +02:00
libz = dependency ( 'zlib' ,
required : get_option ( 'zlib' ) )
conf . set10 ( 'HAVE_ZLIB' , libz . found ( ) )
2017-04-04 23:03:47 -04:00
2023-08-09 19:52:57 +02:00
feature = get_option ( 'bzip2' )
libbzip2 = dependency ( 'bzip2' ,
required : feature . disabled ( ) ? feature : false )
if not libbzip2 . found ( )
# Debian and Ubuntu do not provide the .pc file.
libbzip2 = cc . find_library ( 'bz2' , required : feature )
2017-04-04 23:03:47 -04:00
endif
2023-08-09 19:52:57 +02:00
conf . set10 ( 'HAVE_BZIP2' , libbzip2 . found ( ) )
2017-04-04 23:03:47 -04:00
2023-08-09 18:15:29 +02:00
libxz = dependency ( 'liblzma' ,
required : get_option ( 'xz' ) )
conf . set10 ( 'HAVE_XZ' , libxz . found ( ) )
2024-02-27 21:28:14 +01:00
libxz_cflags = libxz . partial_dependency ( includes : true , compile_args : true )
2018-07-26 22:47:50 +01:00
2023-08-09 18:15:29 +02:00
liblz4 = dependency ( 'liblz4' ,
version : '>= 1.3.0' ,
required : get_option ( 'lz4' ) )
conf . set10 ( 'HAVE_LZ4' , liblz4 . found ( ) )
2024-02-27 21:28:14 +01:00
liblz4_cflags = liblz4 . partial_dependency ( includes : true , compile_args : true )
2019-11-05 11:49:27 +01:00
2023-08-09 18:15:29 +02:00
libzstd = dependency ( 'libzstd' ,
version : '>= 1.4.0' ,
required : get_option ( 'zstd' ) )
conf . set10 ( 'HAVE_ZSTD' , libzstd . found ( ) )
2024-02-27 21:28:14 +01:00
libzstd_cflags = libzstd . partial_dependency ( includes : true , compile_args : true )
2020-04-14 15:54:52 +02:00
2023-08-09 18:15:29 +02:00
conf . set10 ( 'HAVE_COMPRESSION' , libxz . found ( ) or liblz4 . found ( ) or libzstd . found ( ) )
2020-04-12 01:09:05 +02:00
2022-04-09 18:38:06 +01:00
compression = get_option ( 'default-compression' )
if compression == 'auto'
2023-08-09 18:15:29 +02:00
if libzstd . found ( )
2022-04-09 18:38:06 +01:00
compression = 'zstd'
2023-08-09 18:15:29 +02:00
elif liblz4 . found ( )
2022-04-09 18:38:06 +01:00
compression = 'lz4'
2023-08-09 18:15:29 +02:00
elif libxz . found ( )
2022-04-09 18:38:06 +01:00
compression = 'xz'
else
compression = 'none'
endif
2023-08-09 18:15:29 +02:00
elif compression == 'zstd' and not libzstd . found ( )
2022-04-09 18:38:06 +01:00
error ( 'default-compression=zstd requires zstd' )
2023-08-09 18:15:29 +02:00
elif compression == 'lz4' and not liblz4 . found ( )
2022-04-09 18:38:06 +01:00
error ( 'default-compression=lz4 requires lz4' )
2023-08-09 18:15:29 +02:00
elif compression == 'xz' and not libxz . found ( )
2022-04-09 18:38:06 +01:00
error ( 'default-compression=xz requires xz' )
endif
2022-04-27 20:49:17 +09:00
conf . set ( 'DEFAULT_COMPRESSION' , 'COMPRESSION_@0@' . format ( compression . to_upper ( ) ) )
2022-04-09 18:38:06 +01:00
2024-01-24 12:28:41 +01:00
libarchive = dependency ( 'libarchive' ,
version : '>= 3.0' ,
required : get_option ( 'libarchive' ) )
conf . set10 ( 'HAVE_LIBARCHIVE' , libarchive . found ( ) )
2023-08-09 18:15:29 +02:00
libxkbcommon = dependency ( 'xkbcommon' ,
version : '>= 0.3.0' ,
required : get_option ( 'xkbcommon' ) )
conf . set10 ( 'HAVE_XKBCOMMON' , libxkbcommon . found ( ) )
2017-07-26 14:08:46 -04:00
2023-08-09 18:15:29 +02:00
libpcre2 = dependency ( 'libpcre2-8' ,
required : get_option ( 'pcre2' ) )
conf . set10 ( 'HAVE_PCRE2' , libpcre2 . found ( ) )
2018-01-12 05:47:17 +01:00
2023-08-09 18:15:29 +02:00
libglib = dependency ( 'glib-2.0' ,
version : '>= 2.22.0' ,
required : get_option ( 'glib' ) )
libgobject = dependency ( 'gobject-2.0' ,
version : '>= 2.22.0' ,
required : get_option ( 'glib' ) )
libgio = dependency ( 'gio-2.0' ,
required : get_option ( 'glib' ) )
conf . set10 ( 'HAVE_GLIB' , libglib . found ( ) and libgobject . found ( ) and libgio . found ( ) )
2017-04-07 00:19:09 -04:00
2023-08-10 15:16:56 +02:00
libdbus = dependency ( 'dbus-1' ,
version : '>= 1.3.2' ,
required : get_option ( 'dbus' ) )
conf . set10 ( 'HAVE_DBUS' , libdbus . found ( ) )
2017-04-07 00:19:09 -04:00
2023-08-10 15:16:56 +02:00
dbusdatadir = libdbus . get_variable ( pkgconfig : 'datadir' , default_value : datadir ) / 'dbus-1'
2021-12-26 16:19:17 +09:00
dbuspolicydir = get_option ( 'dbuspolicydir' )
if dbuspolicydir == ''
dbuspolicydir = dbusdatadir / 'system.d'
endif
dbussessionservicedir = get_option ( 'dbussessionservicedir' )
if dbussessionservicedir == ''
2023-08-10 15:16:56 +02:00
dbussessionservicedir = libdbus . get_variable ( pkgconfig : 'session_bus_services_dir' , default_value : dbusdatadir / 'services' )
2021-12-26 16:19:17 +09:00
endif
dbussystemservicedir = get_option ( 'dbussystemservicedir' )
if dbussystemservicedir == ''
2023-08-10 15:16:56 +02:00
dbussystemservicedir = libdbus . get_variable ( pkgconfig : 'system_bus_services_dir' , default_value : dbusdatadir / 'system-services' )
2021-12-26 16:19:17 +09:00
endif
dbus_interfaces_dir = get_option ( 'dbus-interfaces-dir' )
if dbus_interfaces_dir == '' or dbus_interfaces_dir == 'yes'
if meson . is_cross_build ( ) and dbus_interfaces_dir != 'yes'
dbus_interfaces_dir = 'no'
warning ( 'Exporting D-Bus interface XML files is disabled during cross build. Pass path or "yes" to force enable.' )
else
2023-08-10 15:16:56 +02:00
dbus_interfaces_dir = libdbus . get_variable ( pkgconfig : 'interfaces_dir' , default_value : dbusdatadir / 'interfaces' )
2021-12-26 16:19:17 +09:00
endif
endif
2023-07-30 06:32:53 +09:00
dmi_arches = [ 'x86' , 'x86_64' , 'aarch64' , 'arm' , 'ia64' , 'loongarch64' , 'mips' ]
conf . set10 ( 'HAVE_DMI' , host_machine . cpu_family ( ) in dmi_arches )
2021-12-02 11:29:45 +01:00
# We support one or the other. If gcrypt is available, we assume it's there to
# be used, and use it in preference.
opt = get_option ( 'cryptolib' )
if opt == 'openssl' and conf . get ( 'HAVE_OPENSSL' ) == 0
error ( 'openssl requested as the default cryptolib, but not available' )
2018-01-15 18:27:37 -05:00
endif
2021-12-02 11:29:45 +01:00
conf . set10 ( 'PREFER_OPENSSL' ,
opt == 'openssl' or ( opt == 'auto' and conf . get ( 'HAVE_OPENSSL' ) == 1 and conf . get ( 'HAVE_GCRYPT' ) == 0 ) )
conf . set10 ( 'HAVE_OPENSSL_OR_GCRYPT' ,
conf . get ( 'HAVE_OPENSSL' ) == 1 or conf . get ( 'HAVE_GCRYPT' ) == 1 )
2021-12-24 10:06:13 +09:00
lib_openssl_or_gcrypt = conf . get ( 'PREFER_OPENSSL' ) == 1 ? [ libopenssl ] : [ libgcrypt , libgpg_error ]
2017-06-18 05:22:32 +09:00
2018-06-21 01:29:49 +09:00
dns_over_tls = get_option ( 'dns-over-tls' )
if dns_over_tls != 'false'
2021-12-02 11:29:45 +01:00
if dns_over_tls == 'gnutls' and conf . get ( 'PREFER_OPENSSL' ) == 1
error ( 'Sorry, -Ddns-over-tls=gnutls is not supported when openssl is used as the cryptolib' )
endif
2022-05-17 20:09:49 +01:00
if dns_over_tls == 'gnutls'
2018-07-26 22:47:50 +01:00
have_openssl = false
else
have_openssl = conf . get ( 'HAVE_OPENSSL' ) == 1
2022-05-17 20:09:49 +01:00
if dns_over_tls == 'openssl' and not have_openssl
error ( 'DNS-over-TLS support was requested with openssl, but dependencies are not available' )
endif
endif
if dns_over_tls == 'openssl' or have_openssl
have_gnutls = false
else
have_gnutls = conf . get ( 'HAVE_GNUTLS' ) == 1 and libgnutls . version ( ) . version_compare ( '>= 3.6.0' )
if dns_over_tls != 'auto' and not have_gnutls
str = dns_over_tls == 'gnutls' ? ' with gnutls' : ''
2019-06-17 10:22:54 +09:00
error ( 'DNS-over-TLS support was requested@0@, but dependencies are not available' . format ( str ) )
2018-07-26 22:47:50 +01:00
endif
endif
have = have_gnutls or have_openssl
2018-06-21 01:29:49 +09:00
else
2018-11-11 11:30:53 +01:00
have = false
have_gnutls = false
have_openssl = false
2018-06-21 01:29:49 +09:00
endif
conf . set10 ( 'ENABLE_DNS_OVER_TLS' , have )
2018-07-26 22:47:50 +01:00
conf . set10 ( 'DNS_OVER_TLS_USE_GNUTLS' , have_gnutls )
conf . set10 ( 'DNS_OVER_TLS_USE_OPENSSL' , have_openssl )
2018-06-21 01:29:49 +09:00
2018-06-13 20:26:24 +02:00
default_dns_over_tls = get_option ( 'default-dns-over-tls' )
2018-06-21 01:29:49 +09:00
if default_dns_over_tls != 'no' and conf . get ( 'ENABLE_DNS_OVER_TLS' ) == 0
2019-02-18 20:41:46 +01:00
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.' )
2018-06-13 20:26:24 +02:00
default_dns_over_tls = 'no'
2018-04-27 17:50:38 +02:00
endif
2018-06-13 20:26:24 +02:00
conf . set ( 'DEFAULT_DNS_OVER_TLS_MODE' ,
'DNS_OVER_TLS_' + default_dns_over_tls . underscorify ( ) . to_upper ( ) )
2021-05-16 16:55:16 +02:00
conf . set_quoted ( 'DEFAULT_DNS_OVER_TLS_MODE_STR' , default_dns_over_tls )
2018-04-27 17:50:38 +02:00
2020-04-14 22:18:18 +02:00
default_mdns = get_option ( 'default-mdns' )
conf . set ( 'DEFAULT_MDNS_MODE' ,
'RESOLVE_SUPPORT_' + default_mdns . to_upper ( ) )
2021-05-16 16:55:16 +02:00
conf . set_quoted ( 'DEFAULT_MDNS_MODE_STR' , default_mdns )
2020-04-14 22:18:18 +02:00
default_llmnr = get_option ( 'default-llmnr' )
conf . set ( 'DEFAULT_LLMNR_MODE' ,
'RESOLVE_SUPPORT_' + default_llmnr . to_upper ( ) )
2021-05-16 16:55:16 +02:00
conf . set_quoted ( 'DEFAULT_LLMNR_MODE_STR' , default_llmnr )
2020-04-14 22:18:18 +02:00
2023-08-10 15:44:11 +02:00
have = get_option ( 'repart' ) . require (
conf . get ( 'HAVE_LIBFDISK' ) == 1 ,
error_message : 'fdisk required' ) . allowed ( )
2019-12-10 21:31:41 +01:00
conf . set10 ( 'ENABLE_REPART' , have )
2021-10-27 15:39:48 +02:00
default_dnssec = get_option ( 'default-dnssec' )
if default_dnssec != 'no' and conf . get ( 'HAVE_OPENSSL_OR_GCRYPT' ) == 0
message ( 'default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.' )
default_dnssec = 'no'
endif
conf . set ( 'DEFAULT_DNSSEC_MODE' ,
'DNSSEC_' + default_dnssec . underscorify ( ) . to_upper ( ) )
conf . set_quoted ( 'DEFAULT_DNSSEC_MODE_STR' , default_dnssec )
2023-08-10 15:44:11 +02:00
have = get_option ( 'sysupdate' ) . require (
conf . get ( 'HAVE_OPENSSL' ) == 1 and
conf . get ( 'HAVE_LIBFDISK' ) == 1 ,
error_message : 'fdisk and openssl required' ) . allowed ( )
2020-12-28 15:17:54 +01:00
conf . set10 ( 'ENABLE_SYSUPDATE' , have )
2023-10-27 14:25:49 +02:00
conf . set10 ( 'ENABLE_STORAGETM' , get_option ( 'storagetm' ) )
2023-08-10 15:44:11 +02:00
have = get_option ( 'importd' ) . require (
conf . get ( 'HAVE_LIBCURL' ) == 1 and
conf . get ( 'HAVE_OPENSSL_OR_GCRYPT' ) == 1 and
conf . get ( 'HAVE_ZLIB' ) == 1 and
conf . get ( 'HAVE_XZ' ) == 1 ,
error_message : 'curl, openssl/grypt, zlib and xz required' ) . allowed ( )
2017-10-03 10:41:51 +02:00
conf . set10 ( 'ENABLE_IMPORTD' , have )
2017-04-04 23:03:47 -04:00
2023-08-10 15:44:11 +02:00
have = get_option ( 'homed' ) . require (
conf . get ( 'HAVE_OPENSSL' ) == 1 and
conf . get ( 'HAVE_LIBFDISK' ) == 1 and
2024-01-31 23:49:24 -05:00
conf . get ( 'HAVE_LIBCRYPTSETUP' ) == 1 and
conf . get ( 'HAVE_CRYPT_RESUME_BY_VOLUME_KEY' ) == 1 ,
2023-08-10 15:44:11 +02:00
error_message : 'openssl, fdisk and libcryptsetup required' ) . allowed ( )
2019-07-04 18:35:39 +02:00
conf . set10 ( 'ENABLE_HOMED' , have )
2020-02-01 11:01:41 +09:00
have = have and conf . get ( 'HAVE_PAM' ) == 1
conf . set10 ( 'ENABLE_PAM_HOME' , have )
2023-08-10 16:00:55 +02:00
feature = get_option ( 'remote' )
have_deps = [ conf . get ( 'HAVE_MICROHTTPD' ) == 1 ,
conf . get ( 'HAVE_LIBCURL' ) == 1 ]
# sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
# it's possible to build one without the other. Complain only if
# support was explicitly requested. The auxiliary files like sysusers
# config should be installed when any of the programs are built.
if feature . enabled ( ) and not ( have_deps [ 0 ] and have_deps [ 1 ] )
error ( 'remote support was requested, but dependencies are not available' )
2017-04-04 23:03:47 -04:00
endif
2023-08-10 16:00:55 +02:00
have = feature . allowed ( ) and ( have_deps [ 0 ] or have_deps [ 1 ] )
2017-10-03 10:41:51 +02:00
conf . set10 ( 'ENABLE_REMOTE' , have )
2017-04-04 23:03:47 -04:00
2023-11-07 21:51:40 +01:00
feature = get_option ( 'vmspawn' ) . disable_auto_if ( conf . get ( 'BUILD_MODE_DEVELOPER' ) == 0 )
conf . set10 ( 'ENABLE_VMSPAWN' , feature . allowed ( ) )
2023-03-09 12:27:29 +01:00
conf . set10 ( 'DEFAULT_MOUNTFSD_TRUSTED_DIRECTORIES' , get_option ( 'default-mountfsd-trusted-directories' ) )
2020-08-20 17:35:50 +02:00
foreach term : [ 'analyze' ,
'backlight' ,
2017-10-03 13:15:27 +02:00
'binfmt' ,
2023-02-26 14:09:44 +01:00
'compat-mutable-uid-boundaries' ,
2017-10-03 13:15:27 +02:00
'coredump' ,
2020-08-20 17:35:50 +02:00
'efi' ,
'environment-d' ,
'firstboot' ,
'gshadow' ,
'hibernate' ,
2017-10-03 13:15:27 +02:00
'hostnamed' ,
2020-08-20 17:35:50 +02:00
'hwdb' ,
'idn' ,
'ima' ,
'initrd' ,
2023-06-20 08:06:43 +09:00
'kernel-install' ,
2020-08-20 17:35:50 +02:00
'ldconfig' ,
2017-10-03 13:15:27 +02:00
'localed' ,
2020-08-20 17:35:50 +02:00
'logind' ,
2017-10-03 13:15:27 +02:00
'machined' ,
2023-03-09 12:27:29 +01:00
'mountfsd' ,
2017-10-03 13:15:27 +02:00
'networkd' ,
2023-02-26 14:09:44 +01:00
'nscd' ,
2023-04-20 19:07:33 +02:00
'nsresourced' ,
2020-08-20 17:35:50 +02:00
'nss-myhostname' ,
'nss-systemd' ,
2023-06-20 08:06:43 +09:00
'oomd' ,
2020-08-20 17:35:50 +02:00
'portabled' ,
'pstore' ,
'quotacheck' ,
'randomseed' ,
'resolve' ,
'rfkill' ,
'smack' ,
2023-02-26 14:09:44 +01:00
'sysext' ,
2020-08-20 17:35:50 +02:00
'sysusers' ,
2017-10-03 13:15:27 +02:00
'timedated' ,
'timesyncd' ,
'tmpfiles' ,
'tpm' ,
2020-08-20 17:35:50 +02:00
'userdb' ,
'utmp' ,
'vconsole' ,
'xdg-autostart' ]
2017-10-03 13:15:27 +02:00
have = get_option ( term )
name = 'ENABLE_' + term . underscorify ( ) . to_upper ( )
conf . set10 ( name , have )
2017-04-04 23:03:47 -04:00
endforeach
2020-09-26 11:58:24 +02:00
enable_sysusers = conf . get ( 'ENABLE_SYSUSERS' ) == 1
2018-07-18 09:25:57 +09:00
foreach tuple : [ [ 'nss-mymachines' , 'machined' ] ,
[ 'nss-resolve' , 'resolve' ] ]
want = get_option ( tuple [ 0 ] )
2023-08-10 16:00:55 +02:00
if want . allowed ( )
2018-07-18 09:25:57 +09:00
have = get_option ( tuple [ 1 ] )
2023-08-10 16:00:55 +02:00
if want . enabled ( ) and not have
2018-07-18 09:25:57 +09:00
error ( '@0@ is requested but @1@ is disabled' . format ( tuple [ 0 ] , tuple [ 1 ] ) )
endif
else
have = false
endif
name = 'ENABLE_' + tuple [ 0 ] . underscorify ( ) . to_upper ( )
conf . set10 ( name , have )
endforeach
enable_nss = false
foreach term : [ 'ENABLE_NSS_MYHOSTNAME' ,
'ENABLE_NSS_MYMACHINES' ,
'ENABLE_NSS_RESOLVE' ,
'ENABLE_NSS_SYSTEMD' ]
if conf . get ( term ) == 1
enable_nss = true
endif
endforeach
conf . set10 ( 'ENABLE_NSS' , enable_nss )
2018-05-07 18:17:35 +09:00
conf . set10 ( 'ENABLE_TIMEDATECTL' , get_option ( 'timedated' ) or get_option ( 'timesyncd' ) )
2018-05-03 18:07:43 +09:00
2024-01-30 11:25:19 +01:00
conf . set10 ( 'ENABLE_SSH_PROXY_CONFIG' , sshconfdir != 'no' )
conf . set10 ( 'ENABLE_SSH_USERDB_CONFIG' , conf . get ( 'ENABLE_USERDB' ) == 1 and sshdconfdir != 'no' )
2018-01-19 17:54:30 +11:00
conf . set10 ( 'SYSTEMD_SLOW_TESTS_DEFAULT' , slow_tests )
2017-07-12 21:25:17 +00:00
2023-12-14 18:35:00 -03:00
#####################################################################
2017-04-04 23:03:47 -04:00
2023-01-31 21:43:53 +01:00
pymod = import ( 'python' )
python = pymod . find_installation ( 'python3' , required : true , modules : [ 'jinja2' ] )
python_39 = python . language_version ( ) . version_compare ( '>=3.9' )
2023-12-14 18:35:00 -03:00
#####################################################################
2023-03-16 15:36:26 +01:00
if conf . get ( 'BPF_FRAMEWORK' ) == 1
bpf_clang_flags = [
'-std=gnu11' ,
'-Wno-compare-distinct-pointer-types' ,
'-fno-stack-protector' ,
'-O2' ,
'-target' ,
'bpf' ,
'-g' ,
'-c' ,
]
bpf_gcc_flags = [
'-std=gnu11' ,
'-fno-stack-protector' ,
2024-04-04 23:42:45 +01:00
'-fno-ssa-phiopt' ,
2023-03-16 15:36:26 +01:00
'-O2' ,
'-mcpu=v3' ,
'-mco-re' ,
'-gbtf' ,
'-c' ,
]
# Generate defines that are appropriate to tell the compiler what architecture
# we're compiling for. By default we just map meson's cpu_family to __<cpu_family>__.
# This dictionary contains the exceptions where this doesn't work.
#
# C.f. https://mesonbuild.com/Reference-tables.html#cpu-families
# and src/basic/missing_syscall_def.h.
cpu_arch_defines = {
'ppc' : [ '-D__powerpc__' ] ,
'ppc64' : [ '-D__powerpc64__' , '-D_CALL_ELF=2' ] ,
'riscv32' : [ '-D__riscv' , '-D__riscv_xlen=32' ] ,
'riscv64' : [ '-D__riscv' , '-D__riscv_xlen=64' ] ,
'x86' : [ '-D__i386__' ] ,
# For arm, assume hardware fp is available.
'arm' : [ '-D__arm__' , '-D__ARM_PCS_VFP' ] ,
}
bpf_arch_flags = cpu_arch_defines . get ( host_machine . cpu_family ( ) ,
[ '-D__@0@__' . format ( host_machine . cpu_family ( ) ) ] )
if bpf_compiler == 'gcc'
bpf_arch_flags + = [ '-m' + host_machine . endian ( ) + '-endian' ]
endif
libbpf_include_dir = libbpf . get_variable ( pkgconfig : 'includedir' )
bpf_o_unstripped_cmd = [ ]
if bpf_compiler == 'clang'
bpf_o_unstripped_cmd + = [
clang ,
bpf_clang_flags ,
bpf_arch_flags ,
]
elif bpf_compiler == 'gcc'
bpf_o_unstripped_cmd + = [
bpf_gcc ,
bpf_gcc_flags ,
bpf_arch_flags ,
]
endif
bpf_o_unstripped_cmd + = [ '-I.' ]
2024-03-22 13:26:45 +01:00
if not meson . is_cross_build ( )
2023-03-16 15:36:26 +01:00
target_triplet_cmd = run_command ( 'gcc' , '-dumpmachine' , check : false )
if target_triplet_cmd . returncode ( ) == 0
target_triplet = target_triplet_cmd . stdout ( ) . strip ( )
bpf_o_unstripped_cmd + = [
'-isystem' ,
'/usr/include/@0@' . format ( target_triplet )
]
endif
endif
bpf_o_unstripped_cmd + = [
'-idirafter' ,
libbpf_include_dir ,
'@INPUT@' ,
'-o' ,
'@OUTPUT@'
]
if bpftool_strip
bpf_o_cmd = [
bpftool ,
'gen' ,
'object' ,
'@OUTPUT@' ,
'@INPUT@'
]
elif bpf_compiler == 'clang'
bpf_o_cmd = [
llvm_strip ,
'-g' ,
'@INPUT@' ,
'-o' ,
'@OUTPUT@'
]
endif
skel_h_cmd = [
bpftool ,
'gen' ,
'skeleton' ,
'@INPUT@'
]
endif
2023-02-26 14:09:44 +01:00
#####################################################################
efi_arch = {
2023-02-28 18:05:18 +01:00
'aarch64' : 'aa64' ,
'arm' : 'arm' ,
'loongarch32' : 'loongarch32' ,
'loongarch64' : 'loongarch64' ,
'riscv32' : 'riscv32' ,
'riscv64' : 'riscv64' ,
'x86_64' : 'x64' ,
'x86' : 'ia32' ,
2023-02-26 14:09:44 +01:00
} . get ( host_machine . cpu_family ( ) , '' )
2023-08-10 15:44:11 +02:00
pyelftools = pymod . find_installation ( 'python3' ,
required : get_option ( 'bootloader' ) ,
modules : [ 'elftools' ] )
have = get_option ( 'bootloader' ) . require (
pyelftools . found ( ) and get_option ( 'efi' ) and efi_arch != '' ,
error_message : 'unsupported EFI arch or EFI support is disabled' ) . allowed ( )
conf . set10 ( 'ENABLE_BOOTLOADER' , have )
conf . set_quoted ( 'EFI_MACHINE_TYPE_NAME' , have ? efi_arch : '' )
2023-02-27 16:54:48 +01:00
efi_arch_alt = ''
2023-07-09 19:30:27 +02:00
efi_cpu_family_alt = ''
2023-08-10 15:44:11 +02:00
if have and efi_arch == 'x64' and cc . links ( '''
2023-02-27 16:54:48 +01:00
#include <limits.h>
int main(int argc, char *argv[]) {
return __builtin_popcount(argc - CHAR_MAX);
}''' , args : [ '-m32' , '-march=i686' ] , name : '32bit build possible' )
efi_arch_alt = 'ia32'
2023-07-09 19:30:27 +02:00
efi_cpu_family_alt = 'x86'
2023-02-27 16:54:48 +01:00
endif
2023-12-23 09:56:31 +01:00
pefile = pymod . find_installation ( 'python3' , required : false , modules : [ 'pefile' ] )
want_ukify = get_option ( 'ukify' ) . require ( python_39 and ( want_tests != 'true' or pefile . found ( ) ) , error_message : 'Python >= 3.9 and pefile required' ) . allowed ( )
2023-01-31 21:43:53 +01:00
conf . set10 ( 'ENABLE_UKIFY' , want_ukify )
2023-12-14 18:35:00 -03:00
#####################################################################
2023-05-05 09:36:00 +02:00
2024-03-22 13:35:38 +01:00
check_efi_alignment_py = find_program ( 'tools/check-efi-alignment.py' )
2023-12-06 18:37:31 +01:00
#####################################################################
use_provided_vmlinux_h = false
use_generated_vmlinux_h = false
provided_vmlinux_h_path = get_option ( 'vmlinux-h-path' )
# For the more complex BPF programs we really want a vmlinux.h (which is arch
# specific, but only somewhat bound to kernel version). Ideally the kernel
# development headers would ship that, but right now they don't. Hence address
# this in two ways:
#
# 1. Provide a vmlinux.h at build time
# 2. Generate the file on the fly where possible (which requires /sys/ to be mounted)
#
# We generally prefer the former (to support reproducible builds), but will
# fallback to the latter.
if conf . get ( 'BPF_FRAMEWORK' ) == 1
enable_vmlinux_h = get_option ( 'vmlinux-h' )
if enable_vmlinux_h == 'auto'
if provided_vmlinux_h_path != ''
use_provided_vmlinux_h = true
elif fs . exists ( '/sys/kernel/btf/vmlinux' ) and \
bpftool . found ( ) and \
( host_machine . cpu_family ( ) == build_machine . cpu_family ( ) ) and \
host_machine . cpu_family ( ) in [ 'x86_64' , 'aarch64' ]
# We will only generate a vmlinux.h from the running
# kernel if the host and build machine are of the same
# family. Also for now we focus on x86_64 and aarch64,
# since other archs don't seem to be ready yet.
use_generated_vmlinux_h = true
endif
elif enable_vmlinux_h == 'provided'
use_provided_vmlinux_h = true
elif enable_vmlinux_h == 'generated'
if not fs . exists ( '/sys/kernel/btf/vmlinux' )
error ( 'BTF data from kernel not available (/sys/kernel/btf/vmlinux missing), cannot generate vmlinux.h, but was asked to.' )
endif
if not bpftool . found ( )
error ( 'bpftool not available, cannot generate vmlinux.h, but was asked to.' )
endif
use_generated_vmlinux_h = true
endif
endif
if use_provided_vmlinux_h
if not fs . exists ( provided_vmlinux_h_path )
error ( 'Path to provided vmlinux.h does not exist.' )
endif
vmlinux_h_dependency = [ ]
bpf_o_unstripped_cmd + = [ '-I' + fs . parent ( provided_vmlinux_h_path ) ]
message ( 'Using provided @0@' . format ( provided_vmlinux_h_path ) )
elif use_generated_vmlinux_h
vmlinux_h_dependency = custom_target (
'vmlinux.h' ,
output : 'vmlinux.h' ,
command : [ bpftool , 'btf' , 'dump' , 'file' , '/sys/kernel/btf/vmlinux' , 'format' , 'c' ] ,
capture : true )
bpf_o_unstripped_cmd + = [ '-I' + fs . parent ( vmlinux_h_dependency . full_path ( ) ) ]
message ( 'Using generated @0@' . format ( vmlinux_h_dependency . full_path ( ) ) )
else
message ( 'Using neither provided nor generated vmlinux.h, some features will not be available.' )
endif
conf . set10 ( 'HAVE_VMLINUX_H' , use_provided_vmlinux_h or use_generated_vmlinux_h )
#####################################################################
2023-09-26 18:25:06 +01:00
check_version_history_py = find_program ( 'tools/check-version-history.py' )
2023-02-27 16:54:48 +01:00
elf2efi_py = find_program ( 'tools/elf2efi.py' )
export_dbus_interfaces_py = find_program ( 'tools/dbus_exporter.py' )
2021-01-27 14:04:14 +01:00
generate_gperfs = find_program ( 'tools/generate-gperfs.py' )
2021-01-04 20:47:00 +09:00
make_autosuspend_rules_py = find_program ( 'tools/make-autosuspend-rules.py' )
make_directive_index_py = find_program ( 'tools/make-directive-index.py' )
2023-10-03 20:00:19 +01:00
sync_docs_py = find_program ( 'tools/sync-docs.py' )
2021-01-04 20:47:00 +09:00
make_man_index_py = find_program ( 'tools/make-man-index.py' )
2021-05-16 11:55:36 +02:00
meson_render_jinja2 = find_program ( 'tools/meson-render-jinja2.py' )
2021-01-27 14:04:14 +01:00
update_dbus_docs_py = find_program ( 'tools/update-dbus-docs.py' )
update_hwdb_autosuspend_sh = find_program ( 'tools/update-hwdb-autosuspend.sh' )
2023-02-27 16:54:48 +01:00
update_hwdb_sh = find_program ( 'tools/update-hwdb.sh' )
update_man_rules_py = find_program ( 'tools/update-man-rules.py' )
2021-01-27 14:04:14 +01:00
update_syscall_tables_sh = find_program ( 'tools/update-syscall-tables.sh' )
xml_helper_py = find_program ( 'tools/xml_helper.py' )
2021-01-04 20:47:00 +09:00
2023-12-14 18:35:00 -03:00
#####################################################################
2017-04-04 23:03:47 -04:00
2023-07-29 22:41:43 +09:00
version_tag = get_option ( 'version-tag' )
2024-02-16 16:58:58 +01:00
if version_tag == ''
version_tag = meson . project_version ( )
endif
conf . set_quoted ( 'VERSION_TAG' , version_tag )
vcs_tag = get_option ( 'vcs-tag' )
2024-03-13 18:33:59 +01:00
command = [ 'sh' , '-c' ,
vcs_tag and fs . exists ( project_source_root / '.git' ) ?
'echo "-g$(git -C . describe --abbrev=7 --match="" --always --dirty=^)"' : ':' ]
version_h = vcs_tag (
input : 'src/version/version.h.in' ,
output : 'version.h' ,
fallback : '' ,
command : command ,
)
2023-08-26 09:17:44 +02:00
2023-07-29 22:41:43 +09:00
shared_lib_tag = get_option ( 'shared-lib-tag' )
if shared_lib_tag == ''
2024-02-14 11:04:36 +01:00
shared_lib_tag = meson . project_version ( ) . split ( '~' ) [ 0 ]
2023-07-29 22:41:43 +09:00
endif
2023-12-14 18:35:00 -03:00
#####################################################################
2023-07-29 22:41:43 +09:00
2022-04-08 13:20:15 +02:00
if get_option ( 'b_coverage' )
2023-02-26 11:07:24 +01:00
userspace_c_args + = [ '-include' , 'src/basic/coverage.h' ]
2022-04-08 13:20:15 +02:00
endif
2023-12-14 18:35:00 -03:00
#####################################################################
2022-04-08 13:20:15 +02:00
2017-04-04 23:03:47 -04:00
config_h = configure_file (
2017-04-17 19:25:00 -04:00
output : 'config.h' ,
configuration : conf )
2017-04-04 23:03:47 -04:00
2023-02-26 11:07:24 +01:00
userspace_c_args + = [ '-include' , 'config.h' ]
2021-01-04 20:47:00 +09:00
2024-03-06 15:16:52 +01:00
jinja2_cmdline = [ meson_render_jinja2 , config_h ]
2022-04-05 16:52:44 +02:00
2023-02-26 11:07:24 +01:00
userspace = declare_dependency (
compile_args : userspace_c_args ,
link_args : userspace_c_ld_args ,
2023-08-28 14:46:24 +03:00
sources : version_h ,
2023-02-26 11:07:24 +01:00
)
2023-05-30 13:02:57 +02:00
man_page_depends = [ ]
2023-12-14 18:35:00 -03:00
#####################################################################
2018-05-07 18:17:35 +09:00
2023-06-23 11:00:17 +09:00
simple_tests = [ ]
2023-06-26 08:52:26 +09:00
libsystemd_tests = [ ]
2023-06-23 11:00:17 +09:00
simple_fuzzers = [ ]
catalogs = [ ]
2023-06-23 11:09:10 +09:00
modules = [ ] # nss, pam, and other plugins
executables = [ ]
executables_by_name = { }
2023-06-27 01:07:25 +09:00
fuzzer_exes = [ ]
2023-06-23 11:00:17 +09:00
2021-01-04 21:27:00 +09:00
# binaries that have --help and are intended for use by humans,
# usually, but not always, installed in /bin.
public_programs = [ ]
2021-07-24 10:30:42 +03:00
# D-Bus introspection XML export
dbus_programs = [ ]
2023-04-14 18:45:24 +02:00
# A list of boot stubs. Required for testing of ukify.
boot_stubs = [ ]
2023-08-26 11:36:02 +02:00
build_dir_include = include_directories ( '.' )
2021-01-04 23:36:00 +09:00
basic_includes = include_directories (
'src/basic' ,
2021-02-04 03:21:08 +09:00
'src/fundamental' ,
2021-01-04 23:36:00 +09:00
'src/systemd' ,
'.' )
libsystemd_includes = [ basic_includes , include_directories (
'src/libsystemd/sd-bus' ,
'src/libsystemd/sd-device' ,
'src/libsystemd/sd-event' ,
'src/libsystemd/sd-hwdb' ,
'src/libsystemd/sd-id128' ,
'src/libsystemd/sd-journal' ,
'src/libsystemd/sd-netlink' ,
'src/libsystemd/sd-network' ,
'src/libsystemd/sd-resolve' ) ]
includes = [ libsystemd_includes , include_directories ( 'src/shared' ) ]
2017-04-04 23:03:47 -04:00
subdir ( 'po' )
subdir ( 'catalog' )
2023-02-26 14:09:44 +01:00
subdir ( 'src/fundamental' )
2017-04-04 23:03:47 -04:00
subdir ( 'src/basic' )
subdir ( 'src/libsystemd' )
2021-01-04 21:13:30 +09:00
subdir ( 'src/shared' )
subdir ( 'src/libudev' )
2017-04-04 23:03:47 -04:00
libsystemd = shared_library (
2017-04-17 19:25:00 -04:00
'systemd' ,
2017-09-28 19:24:16 +02:00
version : libsystemd_version ,
2021-01-04 23:36:00 +09:00
include_directories : libsystemd_includes ,
2017-04-17 19:25:00 -04:00
link_args : [ '-shared' ,
'-Wl,--version-script=' + libsystemd_sym_path ] ,
2024-03-29 23:36:51 +00:00
link_with : [ libbasic ] ,
2021-01-01 04:30:47 +09:00
link_whole : [ libsystemd_static ] ,
2023-02-26 11:07:24 +01:00
dependencies : [ librt ,
threads ,
userspace ] ,
2017-04-17 19:25:00 -04:00
link_depends : libsystemd_sym ,
install : true ,
2022-04-27 10:54:14 +01:00
install_tag : 'libsystemd' ,
2023-06-12 02:15:19 +01:00
install_dir : libdir )
2017-04-04 23:03:47 -04:00
2022-06-11 18:34:08 +01:00
alias_target ( 'libsystemd' , libsystemd )
2018-04-09 02:43:35 -07:00
install_libsystemd_static = static_library (
'systemd' ,
libsystemd_sources ,
2018-04-25 15:29:48 +02:00
basic_sources ,
2021-02-04 03:21:08 +09:00
fundamental_sources ,
2021-01-04 23:36:00 +09:00
include_directories : libsystemd_includes ,
2018-04-09 02:43:35 -07:00
build_by_default : static_libsystemd != 'false' ,
install : static_libsystemd != 'false' ,
2022-04-27 10:54:14 +01:00
install_tag : 'libsystemd' ,
2023-06-12 02:15:19 +01:00
install_dir : libdir ,
2021-01-05 14:51:17 +09:00
pic : static_libsystemd_pic ,
2023-02-26 11:07:24 +01:00
dependencies : [ libblkid ,
libcap ,
libdl ,
2024-03-29 23:36:51 +00:00
libgcrypt_cflags ,
2024-02-27 21:28:14 +01:00
liblz4_cflags ,
2023-02-26 11:07:24 +01:00
libmount ,
libopenssl ,
2018-04-09 02:43:35 -07:00
librt ,
2024-02-27 21:28:14 +01:00
libxz_cflags ,
libzstd_cflags ,
2023-02-26 11:07:24 +01:00
threads ,
2023-07-29 22:28:58 +09:00
userspace ] ,
2018-04-09 02:43:35 -07:00
c_args : libsystemd_c_args + ( static_libsystemd_pic ? [ ] : [ '-fno-PIC' ] ) )
2021-01-04 21:13:30 +09:00
libudev = shared_library (
'udev' ,
version : libudev_version ,
include_directories : includes ,
link_args : [ '-shared' ,
'-Wl,--version-script=' + libudev_sym_path ] ,
link_with : [ libsystemd_static , libshared_static ] ,
link_whole : libudev_basic ,
2023-02-26 11:07:24 +01:00
dependencies : [ threads ,
userspace ] ,
2021-01-04 21:13:30 +09:00
link_depends : libudev_sym ,
install : true ,
2022-04-27 10:54:14 +01:00
install_tag : 'libudev' ,
2023-06-12 02:15:19 +01:00
install_dir : libdir )
2021-01-04 21:13:30 +09:00
2022-06-11 18:34:08 +01:00
alias_target ( 'libudev' , libudev )
2021-01-04 21:13:30 +09:00
install_libudev_static = static_library (
'udev' ,
basic_sources ,
2021-02-04 03:21:08 +09:00
fundamental_sources ,
2021-01-04 21:13:30 +09:00
shared_sources ,
libsystemd_sources ,
libudev_sources ,
include_directories : includes ,
build_by_default : static_libudev != 'false' ,
install : static_libudev != 'false' ,
2022-04-27 10:54:14 +01:00
install_tag : 'libudev' ,
2023-06-12 02:15:19 +01:00
install_dir : libdir ,
2021-01-04 21:13:30 +09:00
link_depends : libudev_sym ,
2023-02-26 11:07:24 +01:00
dependencies : [ libmount ,
libshared_deps ,
2023-07-29 22:28:58 +09:00
userspace ] ,
2021-01-04 21:13:30 +09:00
c_args : static_libudev_pic ? [ ] : [ '-fno-PIC' ] ,
pic : static_libudev_pic )
2023-12-14 18:35:00 -03:00
#####################################################################
2020-08-18 16:27:20 +02:00
2023-06-26 08:52:26 +09:00
runtest_env = custom_target (
'systemd-runtest.env' ,
output : 'systemd-runtest.env' ,
command : [ sh , '-c' ,
'{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@' . format (
project_source_root / 'test' ,
project_build_root / 'catalog' ) ] ,
depends : catalogs ,
build_by_default : true )
test_cflags = [ '-DTEST_CODE=1' ]
# We intentionally do not do inline initializations with definitions for a
# bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
# use the variable unexpectedly. This triggers a lot of maybe-uninitialized
# false positives when the combination of -O2 and -flto is used. Suppress them.
if '-O2' in c_args and '-flto=auto' in c_args
test_cflags + = cc . first_supported_argument ( '-Wno-maybe-uninitialized' )
endif
2023-12-14 18:35:00 -03:00
#####################################################################
2023-06-26 08:52:26 +09:00
2023-06-23 11:09:10 +09:00
executable_template = {
'include_directories' : includes ,
'link_with' : libshared ,
'install_rpath' : pkglibdir ,
'install' : true ,
}
generator_template = executable_template + {
'install_dir' : systemgeneratordir ,
}
libexec_template = executable_template + {
'install_dir' : libexecdir ,
}
executable_additional_kwargs = {
'dependencies' : userspace ,
}
2023-06-26 08:52:26 +09:00
test_template = executable_template + {
'build_by_default' : want_tests != 'false' ,
'install' : install_tests ,
'install_dir' : unittestsdir ,
}
test_additional_kwargs = {
'c_args' : test_cflags ,
'link_depends' : runtest_env ,
}
2023-06-27 01:07:25 +09:00
fuzz_template = executable_template + {
'build_by_default' : fuzzer_build ,
'install' : false ,
}
if want_ossfuzz or ( want_libfuzzer and fuzzing_engine . found ( ) )
fuzz_additional_kwargs = {
'dependencies' : fuzzing_engine ,
}
elif want_libfuzzer and not fuzzing_engine . found ( )
fuzz_additional_kwargs = {
'link_args' : [ '-fsanitize=fuzzer' ] ,
}
else
fuzz_additional_kwargs = {
'sources' : files ( 'src/fuzz/fuzz-main.c' ) ,
}
endif
fuzz_additional_kwargs + = {
'include_directories' : include_directories ( 'src/fuzz' ) ,
'c_args' : test_cflags ,
}
2023-06-23 11:09:10 +09:00
nss_template = {
'version' : '2' ,
'include_directories' : includes ,
# Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
'link_args' : [ '-z' , 'nodelete' ] ,
'link_with' : [
libsystemd_static ,
libshared_static ,
libbasic ,
] ,
'dependencies' : [
librt ,
threads ,
] ,
'install' : true ,
'install_tag' : 'nss' ,
'install_dir' : libdir ,
}
pam_template = {
'name_prefix' : '' ,
'include_directories' : includes ,
'link_with' : [
libsystemd_static ,
libshared_static ,
] ,
'dependencies' : [
libpam_misc ,
libpam ,
threads ,
] ,
'install' : true ,
'install_tag' : 'pam' ,
'install_dir' : pamlibdir ,
}
module_additional_kwargs = {
'link_args' : [ '-shared' ] ,
'dependencies' : userspace ,
}
2023-12-14 18:35:00 -03:00
#####################################################################
2023-06-23 11:09:10 +09:00
2021-01-04 21:27:00 +09:00
# systemd-analyze requires 'libcore'
2017-04-04 23:03:47 -04:00
subdir ( 'src/core' )
2021-01-04 21:27:00 +09:00
# systemd-networkd requires 'libsystemd_network'
subdir ( 'src/libsystemd-network' )
2023-06-26 03:35:47 +09:00
# hwdb requires 'udev_link_with' and 'udev_rpath'
subdir ( 'src/udev' )
2017-04-04 23:03:47 -04:00
2023-06-25 16:28:21 +09:00
subdir ( 'src/ac-power' )
2017-04-07 00:19:09 -04:00
subdir ( 'src/analyze' )
2023-06-26 03:18:38 +09:00
subdir ( 'src/ask-password' )
2023-06-25 15:55:33 +09:00
subdir ( 'src/backlight' )
2023-06-25 16:31:06 +09:00
subdir ( 'src/battery-check' )
2023-06-25 16:10:00 +09:00
subdir ( 'src/binfmt' )
2023-01-23 14:41:26 +01:00
subdir ( 'src/boot' )
2023-02-26 14:09:44 +01:00
subdir ( 'src/boot/efi' )
2021-01-04 20:35:33 +09:00
subdir ( 'src/busctl' )
2023-06-26 03:21:42 +09:00
subdir ( 'src/cgls' )
2023-06-25 16:34:27 +09:00
subdir ( 'src/cgroups-agent' )
2023-06-26 03:21:42 +09:00
subdir ( 'src/cgtop' )
2021-01-04 21:27:00 +09:00
subdir ( 'src/coredump' )
2023-06-25 16:31:06 +09:00
subdir ( 'src/creds' )
2021-01-04 20:29:01 +09:00
subdir ( 'src/cryptenroll' )
2021-01-04 20:26:20 +09:00
subdir ( 'src/cryptsetup' )
2023-06-25 15:20:29 +09:00
subdir ( 'src/debug-generator' )
2023-06-25 16:31:06 +09:00
subdir ( 'src/delta' )
2023-06-25 16:28:21 +09:00
subdir ( 'src/detect-virt' )
2023-06-25 15:34:09 +09:00
subdir ( 'src/dissect' )
2023-06-25 15:20:29 +09:00
subdir ( 'src/environment-d-generator' )
2023-06-25 16:31:06 +09:00
subdir ( 'src/escape' )
2023-06-25 16:21:17 +09:00
subdir ( 'src/firstboot' )
subdir ( 'src/fsck' )
2023-06-25 15:20:29 +09:00
subdir ( 'src/fstab-generator' )
subdir ( 'src/getty-generator' )
2023-06-25 15:34:09 +09:00
subdir ( 'src/gpt-auto-generator' )
2023-06-25 15:31:38 +09:00
subdir ( 'src/hibernate-resume' )
2021-01-04 21:27:00 +09:00
subdir ( 'src/home' )
2017-04-07 00:19:09 -04:00
subdir ( 'src/hostname' )
2023-06-26 03:28:32 +09:00
subdir ( 'src/hwdb' )
2023-06-25 16:34:27 +09:00
subdir ( 'src/id128' )
2017-04-07 00:19:09 -04:00
subdir ( 'src/import' )
2023-06-26 03:21:42 +09:00
subdir ( 'src/initctl' )
2023-06-25 15:57:47 +09:00
subdir ( 'src/integritysetup' )
2023-09-30 19:08:23 +09:00
subdir ( 'src/journal' )
2021-01-04 21:27:00 +09:00
subdir ( 'src/journal-remote' )
2017-04-07 00:19:09 -04:00
subdir ( 'src/kernel-install' )
subdir ( 'src/locale' )
2021-01-04 21:27:00 +09:00
subdir ( 'src/login' )
2017-04-07 00:19:09 -04:00
subdir ( 'src/machine' )
2023-06-25 16:21:17 +09:00
subdir ( 'src/machine-id-setup' )
2023-03-09 12:27:29 +01:00
subdir ( 'src/mountfsd' )
2023-06-26 03:38:48 +09:00
subdir ( 'src/modules-load' )
2023-06-26 03:21:42 +09:00
subdir ( 'src/mount' )
2021-01-04 21:27:00 +09:00
subdir ( 'src/network' )
2023-06-25 16:31:06 +09:00
subdir ( 'src/notify' )
2017-04-07 00:19:09 -04:00
subdir ( 'src/nspawn' )
2023-04-20 19:07:33 +02:00
subdir ( 'src/nsresourced' )
2023-06-23 11:28:22 +09:00
subdir ( 'src/nss-myhostname' )
subdir ( 'src/nss-mymachines' )
subdir ( 'src/nss-resolve' )
subdir ( 'src/nss-systemd' )
2021-01-04 21:27:00 +09:00
subdir ( 'src/oom' )
subdir ( 'src/partition' )
2023-06-25 16:34:27 +09:00
subdir ( 'src/path' )
2023-09-25 10:38:01 +02:00
subdir ( 'src/pcrextend' )
2023-08-16 11:39:23 +02:00
subdir ( 'src/pcrlock' )
2021-01-04 21:27:00 +09:00
subdir ( 'src/portable' )
subdir ( 'src/pstore' )
2023-06-26 03:35:47 +09:00
subdir ( 'src/quotacheck' )
2023-06-25 16:11:55 +09:00
subdir ( 'src/random-seed' )
2023-06-25 15:59:49 +09:00
subdir ( 'src/rc-local-generator' )
2023-06-25 16:21:17 +09:00
subdir ( 'src/remount-fs' )
2023-06-26 03:18:38 +09:00
subdir ( 'src/reply-password' )
2017-04-07 00:19:09 -04:00
subdir ( 'src/resolve' )
2023-06-25 15:55:33 +09:00
subdir ( 'src/rfkill' )
2021-01-31 17:16:32 +01:00
subdir ( 'src/rpm' )
2023-06-26 03:23:59 +09:00
subdir ( 'src/run' )
2023-06-25 15:20:29 +09:00
subdir ( 'src/run-generator' )
2021-01-04 21:27:00 +09:00
subdir ( 'src/shutdown' )
2023-06-25 16:28:21 +09:00
subdir ( 'src/sleep' )
2023-06-25 15:42:23 +09:00
subdir ( 'src/socket-activate' )
2023-06-26 03:35:47 +09:00
subdir ( 'src/socket-proxy' )
2024-01-04 18:39:03 +01:00
subdir ( 'src/ssh-generator' )
2023-06-26 03:23:59 +09:00
subdir ( 'src/stdio-bridge' )
2023-06-26 03:44:39 +09:00
subdir ( 'src/sulogin-shell' )
2023-06-25 16:28:21 +09:00
subdir ( 'src/sysctl' )
2021-01-08 16:57:27 +01:00
subdir ( 'src/sysext' )
2023-06-25 15:55:33 +09:00
subdir ( 'src/system-update-generator' )
2021-01-04 20:12:28 +09:00
subdir ( 'src/systemctl' )
2020-12-28 15:17:54 +01:00
subdir ( 'src/sysupdate' )
2023-06-26 03:28:32 +09:00
subdir ( 'src/sysusers' )
2023-06-25 15:59:49 +09:00
subdir ( 'src/sysv-generator' )
2023-10-27 14:25:49 +02:00
subdir ( 'src/storagetm' )
2017-04-07 00:19:09 -04:00
subdir ( 'src/timedate' )
subdir ( 'src/timesync' )
2020-06-03 14:49:53 -07:00
subdir ( 'src/tmpfiles' )
2023-10-27 14:25:49 +02:00
subdir ( 'src/tpm2-setup' )
2023-06-26 03:18:38 +09:00
subdir ( 'src/tty-ask-password-agent' )
2023-06-26 03:38:48 +09:00
subdir ( 'src/update-done' )
subdir ( 'src/update-utmp' )
2023-06-25 15:39:45 +09:00
subdir ( 'src/user-sessions' )
2021-01-04 21:27:00 +09:00
subdir ( 'src/userdb' )
2023-09-22 22:44:28 +02:00
subdir ( 'src/varlinkctl' )
2023-06-25 16:11:55 +09:00
subdir ( 'src/vconsole' )
2023-06-25 15:57:47 +09:00
subdir ( 'src/veritysetup' )
2023-10-12 13:13:19 +01:00
subdir ( 'src/vmspawn' )
2023-06-25 16:34:27 +09:00
subdir ( 'src/volatile-root' )
2023-03-03 18:26:45 +01:00
subdir ( 'src/vpick' )
2021-01-04 20:41:37 +09:00
subdir ( 'src/xdg-autostart-generator' )
2017-04-07 00:19:09 -04:00
2021-01-04 21:13:30 +09:00
subdir ( 'src/systemd' )
2017-04-07 00:19:09 -04:00
subdir ( 'src/test' )
2018-01-13 19:51:07 -05:00
subdir ( 'src/fuzz' )
2022-11-25 17:21:40 +01:00
subdir ( 'src/ukify/test' ) # needs to be last for test_env variable
2023-06-27 01:07:25 +09:00
subdir ( 'test/fuzz' )
2017-04-07 00:19:09 -04:00
2023-11-20 11:51:47 +01:00
subdir ( 'mime' )
2023-06-12 00:41:49 +01:00
alias_target ( 'devel' , libsystemd_pc , libudev_pc , systemd_pc , udev_pc )
2023-12-14 18:35:00 -03:00
#####################################################################
2017-04-14 20:10:28 -04:00
2023-06-26 08:52:26 +09:00
foreach test : simple_tests
executables + = test_template + { 'sources' : [ test ] }
endforeach
foreach test : libsystemd_tests
executables + = test_template + test
endforeach
2023-06-27 01:07:25 +09:00
foreach fuzzer : simple_fuzzers
executables + = fuzz_template + { 'sources' : [ fuzzer ] }
endforeach
2023-06-23 11:09:10 +09:00
foreach dict : executables
2023-06-26 08:52:26 +09:00
name = dict . get ( 'name' , '' )
if name == ''
name = fs . stem ( dict . get ( 'sources' ) [ 0 ] )
2023-06-27 01:07:25 +09:00
assert ( name . split ( '-' ) [ 0 ] in [ 'test' , 'fuzz' ] )
2023-06-26 08:52:26 +09:00
endif
is_test = name . startswith ( 'test-' )
2023-06-27 01:07:25 +09:00
is_fuzz = name . startswith ( 'fuzz-' )
2023-06-23 11:09:10 +09:00
build = true
foreach cond : dict . get ( 'conditions' , [ ] )
if conf . get ( cond ) != 1
build = false
break
endif
endforeach
if not build
continue
endif
kwargs = { }
foreach key , val : dict
2023-06-26 08:52:26 +09:00
if key in [ 'name' , 'dbus' , 'public' , 'conditions' ,
'type' , 'suite' , 'timeout' , 'parallel' ]
2023-06-23 11:09:10 +09:00
continue
endif
2023-06-26 08:52:26 +09:00
2023-06-23 11:09:10 +09:00
kwargs + = { key : val }
endforeach
foreach key , val : executable_additional_kwargs
kwargs + = { key : [ kwargs . get ( key , [ ] ) , val ] }
endforeach
2023-06-26 08:52:26 +09:00
if is_test
kwargs + = { 'install_dir' : kwargs . get ( 'install_dir' ) / dict . get ( 'type' , '' ) }
foreach key , val : test_additional_kwargs
kwargs + = { key : [ kwargs . get ( key , [ ] ) , val ] }
endforeach
endif
2023-06-27 01:07:25 +09:00
if is_fuzz
foreach key , val : fuzz_additional_kwargs
kwargs + = { key : [ kwargs . get ( key , [ ] ) , val ] }
endforeach
endif
2023-06-23 11:09:10 +09:00
exe = executable (
name ,
kwargs : kwargs ,
)
executables_by_name + = { name : exe }
if dict . get ( 'build_by_default' , true )
if dict . get ( 'dbus' , false )
dbus_programs + = exe
endif
if dict . get ( 'public' , false )
public_programs + = exe
endif
endif
2023-06-26 08:52:26 +09:00
if is_test
type = dict . get ( 'type' , '' )
suite = dict . get ( 'suite' , '' )
if suite == ''
suite = fs . name ( fs . parent ( dict . get ( 'sources' ) [ 0 ] ) )
if suite . startswith ( 'sd-' )
suite = 'libsystemd'
endif
endif
if type == 'manual'
message ( '@0@/@1@ is a manual test' . format ( suite , name ) )
elif type == 'unsafe' and want_tests != 'unsafe'
message ( '@0@/@1@ is an unsafe test' . format ( suite , name ) )
elif dict . get ( 'build_by_default' )
test ( name , exe ,
env : test_env ,
timeout : dict . get ( 'timeout' , 30 ) ,
suite : suite ,
is_parallel : dict . get ( 'parallel' , true ) )
endif
endif
2023-06-27 01:07:25 +09:00
if is_fuzz
fuzzer_exes + = exe
if want_tests != 'false'
# Run the fuzz regression tests without any sanitizers enabled.
2023-09-02 17:23:22 +03:00
# Additional invocations with sanitizers may get added below.
2023-06-27 01:07:25 +09:00
fuzz_ins = fuzz_regression_tests . get ( name , { } )
foreach directive : fuzz_ins . get ( 'directives' , [ ] )
2023-09-02 17:23:22 +03:00
tt = '@0@_@1@' . format ( name , fs . name ( directive . full_path ( ) ) )
if tt . substring ( 45 ) != ''
error ( 'Directive sample name is too long:' , directive . full_path ( ) )
endif
test ( tt ,
2023-06-27 01:07:25 +09:00
exe ,
suite : 'fuzz' ,
args : directive . full_path ( ) ,
depends : directive )
endforeach
foreach file : fuzz_ins . get ( 'files' , [ ] )
2023-09-02 17:23:22 +03:00
tt = '@0@_@1@' . format ( name , fs . name ( file ) )
if tt . substring ( 45 ) != ''
error ( 'Fuzz sample name is too long:' , fs . name ( file ) )
endif
test ( tt ,
2023-06-27 01:07:25 +09:00
exe ,
suite : 'fuzz' ,
args : file )
endforeach
endif
endif
2023-06-23 11:09:10 +09:00
endforeach
2023-06-27 01:07:25 +09:00
alias_target ( 'fuzzers' , fuzzer_exes )
2023-12-14 18:35:00 -03:00
#####################################################################
2023-06-23 11:09:10 +09:00
2023-06-26 08:52:26 +09:00
test_dlopen = executables_by_name . get ( 'test-dlopen' )
2017-04-14 20:10:28 -04:00
2023-06-23 11:09:10 +09:00
foreach dict : modules
name = dict . get ( 'name' )
is_nss = name . startswith ( 'nss_' )
is_pam = name . startswith ( 'pam_' )
build = true
foreach cond : dict . get ( 'conditions' , [ ] )
if conf . get ( cond ) != 1
build = false
break
endif
endforeach
if not build
continue
endif
kwargs = { }
foreach key , val : dict
2023-09-26 15:14:38 +02:00
if key in [ 'name' , 'conditions' , 'version-script' ]
2023-06-23 11:09:10 +09:00
continue
endif
kwargs + = { key : val }
endforeach
kwargs + = {
'link_args' : [
kwargs . get ( 'link_args' , [ ] ) ,
2023-09-26 15:14:38 +02:00
'-Wl,--version-script=' + dict . get ( 'version-script' ) ,
] ,
'link_depends' : [
kwargs . get ( 'link_depends' , [ ] ) ,
dict . get ( 'version-script' ) ,
2023-06-23 11:09:10 +09:00
] ,
}
foreach key , val : module_additional_kwargs
kwargs + = { key : [ kwargs . get ( key , [ ] ) , val ] }
endforeach
lib = shared_library (
name ,
kwargs : kwargs ,
)
if is_nss
# We cannot use shared_module because it does not support version suffix.
# Unfortunately shared_library insists on creating the symlink…
2023-08-23 12:23:50 +02:00
meson . add_install_script ( sh , '-c' , 'rm $DESTDIR@0@/lib@1@.so' . format ( libdir , name ) ,
2023-06-23 11:09:10 +09:00
install_tag : 'nss' )
endif
if want_tests != 'false' and ( is_nss or is_pam )
test ( 'dlopen-' + name ,
test_dlopen ,
# path to dlopen must include a slash
args : lib . full_path ( ) ,
2023-06-27 01:28:32 +09:00
depends : lib ,
suite : is_nss ? 'nss' : 'pam' )
2023-06-23 11:09:10 +09:00
endif
endforeach
2023-12-14 18:35:00 -03:00
#####################################################################
2017-04-14 20:10:28 -04:00
2023-04-13 18:11:39 +02:00
ukify = custom_target (
2022-11-16 15:52:47 +01:00
'ukify' ,
input : 'src/ukify/ukify.py' ,
output : 'ukify' ,
command : [ jinja2_cmdline , '@INPUT@' , '@OUTPUT@' ] ,
2023-04-14 18:10:58 +02:00
install : want_ukify ,
2022-11-16 15:52:47 +01:00
install_mode : 'rwxr-xr-x' ,
2023-08-28 18:22:43 +03:00
install_dir : bindir )
2023-04-14 18:10:58 +02:00
if want_ukify
2023-03-14 23:55:18 +09:00
public_programs + = ukify
2023-08-28 18:22:43 +03:00
2023-09-26 17:03:15 +02:00
# symlink for backwards compatibility after rename
2023-08-28 18:22:43 +03:00
meson . add_install_script ( sh , '-c' ,
ln_s . format ( bindir / 'ukify' ,
libexecdir / 'ukify' ) )
2023-04-13 18:11:39 +02:00
endif
2023-12-14 18:35:00 -03:00
#####################################################################
2017-04-07 00:19:09 -04:00
2024-04-19 09:17:58 +02:00
mkosi = find_program ( 'mkosi' , required : false )
2024-04-24 21:17:06 +02:00
if integration_tests and not mkosi . found ( )
error ( 'Could not find mkosi which is required to run the integration tests' )
endif
mkosi_depends = public_programs
foreach executable : [ 'systemd-journal-remote' , 'systemd-measure' ]
if executable in executables_by_name
mkosi_depends + = [ executables_by_name [ executable ] ]
endif
endforeach
2024-04-19 09:17:58 +02:00
if mkosi . found ( )
custom_target ( 'mkosi' ,
2024-04-05 17:19:59 +01:00
build_always_stale : true ,
2024-04-19 09:17:58 +02:00
build_by_default : false ,
2024-04-05 17:19:59 +01:00
console : true ,
2024-04-19 09:17:58 +02:00
output : '.' ,
command : [
'mkosi' ,
'--directory' , meson . current_source_dir ( ) ,
'--output-dir' , meson . current_build_dir ( ) / 'mkosi.output' ,
'--cache-dir' , meson . current_build_dir ( ) / 'mkosi.cache' ,
'--build-dir' , meson . current_build_dir ( ) / 'mkosi.builddir' ,
'--force' ,
2024-04-24 17:31:41 +01:00
'--debug' ,
2024-04-24 21:17:06 +02:00
'build' ,
2024-04-19 09:17:58 +02:00
] ,
2024-04-24 21:17:06 +02:00
depends : mkosi_depends ,
2024-04-05 17:19:59 +01:00
)
endif
############################################################
2023-06-26 03:46:05 +09:00
subdir ( 'rules.d' )
subdir ( 'test' )
2023-12-14 18:35:00 -03:00
#####################################################################
2017-04-04 23:03:47 -04:00
2022-11-16 15:52:15 +01:00
subdir ( 'docs/sysvinit' )
subdir ( 'docs/var-log' )
subdir ( 'hwdb.d' )
subdir ( 'man' )
2021-07-07 12:39:33 +02:00
subdir ( 'modprobe.d' )
2022-11-16 15:52:15 +01:00
subdir ( 'network' )
subdir ( 'presets' )
subdir ( 'shell-completion/bash' )
subdir ( 'shell-completion/zsh' )
2017-04-04 23:03:47 -04:00
subdir ( 'sysctl.d' )
subdir ( 'sysusers.d' )
subdir ( 'tmpfiles.d' )
2019-10-08 16:52:10 +02:00
subdir ( 'units' )
2017-04-04 23:03:47 -04:00
install_subdir ( 'factory/etc' ,
install_dir : factorydir )
2021-12-23 11:01:07 +00:00
subdir ( 'factory/templates' )
2017-04-04 23:03:47 -04:00
2020-11-12 08:01:39 +01:00
if install_sysconfdir
install_data ( 'xorg/50-systemd-user.sh' ,
install_dir : xinitrcdir )
endif
2018-02-26 11:48:46 +01:00
install_data ( 'LICENSE.GPL2' ,
2017-04-04 23:03:47 -04:00
'LICENSE.LGPL2.1' ,
2018-02-26 11:48:46 +01:00
'NEWS' ,
'README' ,
2024-02-23 09:48:47 +01:00
'docs/CODING_STYLE.md' ,
'docs/DISTRO_PORTING.md' ,
'docs/ENVIRONMENT.md' ,
'docs/HACKING.md' ,
'docs/TRANSIENT-SETTINGS.md' ,
'docs/TRANSLATORS.md' ,
'docs/UIDS-GIDS.md' ,
2017-04-04 23:03:47 -04:00
install_dir : docdir )
2017-04-06 14:33:27 -04:00
2021-09-29 22:10:34 +01:00
install_subdir ( 'LICENSES' ,
install_dir : docdir )
2023-08-08 10:38:47 +09:00
install_emptydir ( systemdstatedir )
2017-04-09 23:55:05 -04:00
2023-12-14 18:35:00 -03:00
#####################################################################
2017-04-06 14:33:27 -04:00
2021-05-19 14:45:47 +01:00
# Ensure that changes to the docs/ directory do not break the
# basic Github pages build. But only run it in developer mode,
# as it might be fragile due to changes in the tooling, and it is
# not generally useful for users.
jekyll = find_program ( 'jekyll' , required : false )
if get_option ( 'mode' ) == 'developer' and want_tests != 'false' and jekyll . found ( )
test ( 'github-pages' ,
jekyll ,
2023-05-18 17:16:33 +02:00
suite : 'dist' ,
2021-05-19 14:45:47 +01:00
args : [ 'build' ,
2021-07-27 19:32:35 +02:00
'--source' , project_source_root / 'docs' ,
'--destination' , project_build_root / '_site' ] )
2021-05-19 14:45:47 +01:00
endif
2023-12-14 18:35:00 -03:00
#####################################################################
2021-05-19 14:45:47 +01:00
2020-05-07 13:54:10 +02:00
check_help = find_program ( 'tools/check-help.sh' )
2022-04-05 10:51:21 +02:00
check_version = find_program ( 'tools/check-version.sh' )
2017-04-13 11:52:05 -04:00
foreach exec : public_programs
2023-06-14 16:05:52 +02:00
name = fs . name ( exec . full_path ( ) )
2018-09-12 11:08:49 +02:00
if want_tests != 'false'
test ( 'check-help-' + name ,
2020-05-07 13:54:10 +02:00
check_help ,
2023-05-18 17:16:33 +02:00
suite : 'dist' ,
2022-01-21 14:28:23 +00:00
args : exec . full_path ( ) ,
depends : exec )
2022-04-05 10:51:21 +02:00
2024-02-14 11:04:36 +01:00
version = meson . project_version ( )
if name == 'udevadm'
# For compatibility reasons we can't use the full version in udevadm.
version = version . split ( '~' ) [ 0 ]
endif
2022-04-05 10:51:21 +02:00
test ( 'check-version-' + name ,
check_version ,
2023-05-18 17:16:33 +02:00
suite : 'dist' ,
2022-04-05 10:51:21 +02:00
args : [ exec . full_path ( ) ,
2024-02-14 11:04:36 +01:00
version ] ,
2022-04-05 10:51:21 +02:00
depends : exec )
2018-09-12 11:08:49 +02:00
endif
2017-04-13 11:52:05 -04:00
endforeach
2018-03-14 14:27:04 +01:00
# Enable tests for all supported sanitizers
2022-10-06 19:06:08 +02:00
foreach tuple : fuzz_sanitizers
2018-03-14 14:27:04 +01:00
sanitizer = tuple [ 0 ]
build = tuple [ 1 ]
2018-01-19 17:54:30 +11:00
2018-05-15 20:18:24 +09:00
if cc . has_link_argument ( '-fsanitize=@0@' . format ( sanitizer ) )
2022-10-06 19:06:08 +02:00
foreach fuzzer , fuzz_ins : fuzz_regression_tests
name = '@0@:@1@' . format ( fuzzer , sanitizer )
if want_tests == 'false'
message ( 'Not compiling @0@ because tests is set to false' . format ( name ) )
continue
2018-03-14 14:27:04 +01:00
endif
2022-10-06 19:06:08 +02:00
if not fuzz_tests
message ( 'Not compiling @0@ because fuzz-tests is set to false' . format ( name ) )
continue
endif
exe = custom_target (
name ,
output : name ,
2023-06-27 01:07:25 +09:00
depends : build ,
2022-10-06 19:06:08 +02:00
command : [ ln , '-fs' ,
build . full_path ( ) / fuzzer ,
'@OUTPUT@' ] ,
build_by_default : true )
2018-03-14 14:27:04 +01:00
2023-06-27 01:07:25 +09:00
foreach directive : fuzz_ins . get ( 'directives' , [ ] )
test ( '@0@_@1@_@2@' . format ( fuzzer , fs . name ( directive . full_path ( ) ) , sanitizer ) ,
2018-03-14 14:27:04 +01:00
env ,
2022-05-02 11:12:34 +02:00
suite : 'fuzz+san' ,
2020-05-20 11:33:12 +02:00
env : [ 'UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1' ] ,
timeout : 60 ,
2023-06-27 01:07:25 +09:00
args : [ exe . full_path ( ) , directive . full_path ( ) ] ,
depends : directive )
endforeach
foreach file : fuzz_ins . get ( 'files' , [ ] )
test ( '@0@_@1@_@2@' . format ( fuzzer , fs . name ( file ) , sanitizer ) ,
env ,
suite : 'fuzz+san' ,
env : [ 'UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1' ] ,
timeout : 60 ,
args : [ exe . full_path ( ) , file ] )
2022-10-06 19:06:08 +02:00
endforeach
2018-03-14 14:27:04 +01:00
endforeach
2018-01-19 17:54:30 +11:00
endif
endforeach
2023-12-14 18:35:00 -03:00
#####################################################################
2018-01-19 17:54:30 +11:00
2017-07-03 12:42:29 -04:00
if git . found ( )
2017-04-17 19:25:00 -04:00
all_files = run_command (
2021-05-14 14:16:17 +02:00
env , '-u' , 'GIT_WORK_TREE' ,
git , '--git-dir=@0@/.git' . format ( project_source_root ) ,
2023-05-05 09:33:12 +02:00
'ls-files' , ':/*.[ch]' , ':/*.cc' ,
2021-11-17 13:58:53 +01:00
check : false )
if all_files . returncode ( ) == 0
all_files = files ( all_files . stdout ( ) . split ( ) )
2021-01-08 20:27:48 +01:00
2021-11-17 13:58:53 +01:00
custom_target (
'tags' ,
output : 'tags' ,
command : [ env , 'etags' , '-o' , '@0@/TAGS' . format ( project_source_root ) ] + all_files )
run_target (
'ctags' ,
2022-01-16 06:06:15 +00:00
command : [ env , 'ctags' , '--tag-relative=never' , '-o' , '@0@/tags' . format ( project_source_root ) ] + all_files )
2017-04-15 00:16:23 -04:00
2023-05-05 09:35:54 +02:00
############################################
if want_tests != 'false' and conf . get ( 'BUILD_MODE_DEVELOPER' ) == 1
test ( 'check-includes' ,
files ( 'tools/check-includes.py' ) ,
args : all_files ,
2023-06-27 01:28:32 +09:00
env : [ 'PROJECT_SOURCE_ROOT=@0@' . format ( project_source_root ) ] ,
suite : 'headers' )
2023-05-05 09:35:54 +02:00
endif
endif
####################################################
2020-05-07 13:54:10 +02:00
git_contrib_sh = find_program ( 'tools/git-contrib.sh' )
2017-04-17 19:48:20 -04:00
run_target (
2017-04-17 19:25:00 -04:00
'git-contrib' ,
2020-05-07 13:54:10 +02:00
command : [ git_contrib_sh ] )
2017-04-24 19:28:05 -04:00
2023-05-05 09:35:54 +02:00
####################################################
2017-04-24 19:28:05 -04:00
git_head = run_command (
2021-11-17 13:58:53 +01:00
git , '--git-dir=@0@/.git' . format ( project_source_root ) ,
'rev-parse' , 'HEAD' ,
check : false ) . stdout ( ) . strip ( )
2017-04-24 19:28:05 -04:00
git_head_short = run_command (
2021-11-17 13:58:53 +01:00
git , '--git-dir=@0@/.git' . format ( project_source_root ) ,
'rev-parse' , '--short=7' , 'HEAD' ,
check : false ) . stdout ( ) . strip ( )
2017-04-24 19:28:05 -04:00
run_target (
'git-snapshot' ,
2021-05-14 14:16:17 +02:00
command : [ git , 'archive' ,
2019-02-27 11:19:07 -05:00
'-o' , '@0@/systemd-@1@.tar.gz' . format ( project_source_root ,
2017-04-24 19:28:05 -04:00
git_head_short ) ,
'--prefix' , 'systemd-@0@/' . format ( git_head ) ,
'HEAD' ] )
endif
2017-04-27 20:54:52 -04:00
2023-12-14 18:35:00 -03:00
#####################################################################
2017-04-27 20:54:52 -04:00
2020-05-07 13:54:10 +02:00
check_api_docs_sh = find_program ( 'tools/check-api-docs.sh' )
2017-12-20 12:51:14 +01:00
run_target (
'check-api-docs' ,
depends : [ man , libsystemd , libudev ] ,
2020-05-07 13:54:10 +02:00
command : [ check_api_docs_sh , libsystemd . full_path ( ) , libudev . full_path ( ) ] )
2017-12-20 12:51:14 +01:00
2021-07-27 20:11:41 +02:00
alias_target ( 'update-dbus-docs' , update_dbus_docs )
alias_target ( 'update-man-rules' , update_man_rules )
2021-01-27 09:10:25 +01:00
2022-02-08 13:19:52 +00:00
if not meson . is_cross_build ( )
custom_target (
'export-dbus-interfaces' ,
2022-05-16 04:05:51 +09:00
output : fs . name ( dbus_interfaces_dir ) ,
2022-02-08 13:19:52 +00:00
install : dbus_interfaces_dir != 'no' ,
2022-05-16 04:05:51 +09:00
install_dir : fs . parent ( dbus_interfaces_dir ) ,
2022-02-08 13:19:52 +00:00
command : [ export_dbus_interfaces_py , '@OUTPUT@' , dbus_programs ] )
endif
2021-07-24 10:30:42 +03:00
2024-02-19 20:41:49 +01:00
meson_extract_unit_files = find_program ( 'tools/meson-extract-unit-files.py' )
custom_target ( 'installed-unit-files.txt' ,
output : 'installed-unit-files.txt' ,
capture : true ,
install : want_tests != 'no' and install_tests ,
install_dir : testdata_dir ,
command : [ meson_extract_unit_files , project_build_root ] )
2023-12-14 18:35:00 -03:00
#####################################################################
2017-04-27 20:54:52 -04:00
2021-11-17 13:58:53 +01:00
alt_time_epoch = run_command ( 'date' , '-Is' , '-u' , '-d' , '@@0@' . format ( time_epoch ) ,
check : true ) . stdout ( ) . strip ( )
2021-07-28 10:04:01 +02:00
summary ( {
'split bin-sbin' : split_bin ,
'prefix directory' : prefixdir ,
'sysconf directory' : sysconfdir ,
'include directory' : includedir ,
'lib directory' : libdir ,
'SysV init scripts' : sysvinit_path ,
'SysV rc?.d directories' : sysvrcnd_path ,
'PAM modules directory' : pamlibdir ,
'PAM configuration directory' : pamconfdir ,
2024-01-04 23:31:51 +01:00
'ssh server configuration directory' : sshdconfdir ,
2024-03-01 11:25:52 +01:00
'ssh server privilege separation directory' : sshdprivsepdir ,
2024-01-04 23:31:51 +01:00
'ssh client configuration directory' : sshconfdir ,
2021-07-28 10:04:01 +02:00
'libcryptsetup plugins directory' : libcryptsetup_plugins_dir ,
'RPM macros directory' : rpmmacrosdir ,
'modprobe.d directory' : modprobedir ,
'D-Bus policy directory' : dbuspolicydir ,
'D-Bus session directory' : dbussessionservicedir ,
'D-Bus system directory' : dbussystemservicedir ,
2021-12-26 10:44:52 +09:00
'D-Bus interfaces directory' : dbus_interfaces_dir ,
2021-07-28 10:04:01 +02:00
'bash completions directory' : bashcompletiondir ,
'zsh completions directory' : zshcompletiondir ,
2021-12-14 18:03:06 +01:00
'private shared lib version tag' : shared_lib_tag ,
2021-07-28 10:04:01 +02:00
'extra start script' : get_option ( 'rc-local' ) ,
'debug shell' : '@0@ @ @1@' . format ( get_option ( 'debug-shell' ) ,
get_option ( 'debug-tty' ) ) ,
'system UIDs' : '<=@0@ (alloc >=@1@)' . format ( conf . get ( 'SYSTEM_UID_MAX' ) ,
conf . get ( 'SYSTEM_ALLOC_UID_MIN' ) ) ,
'system GIDs' : '<=@0@ (alloc >=@1@)' . format ( conf . get ( 'SYSTEM_GID_MAX' ) ,
conf . get ( 'SYSTEM_ALLOC_GID_MIN' ) ) ,
'dynamic UIDs' : '@0@…@1@' . format ( dynamic_uid_min , dynamic_uid_max ) ,
'container UID bases' : '@0@…@1@' . format ( container_uid_base_min , container_uid_base_max ) ,
'static UID/GID allocations' : ' ' . join ( static_ugids ) ,
'/dev/kvm access mode' : get_option ( 'dev-kvm-mode' ) ,
'render group access mode' : get_option ( 'group-render-mode' ) ,
'certificate root directory' : get_option ( 'certificate-root' ) ,
'support URL' : support_url ,
'nobody user name' : nobody_user ,
'nobody group name' : nobody_group ,
'fallback hostname' : get_option ( 'fallback-hostname' ) ,
2022-04-27 20:47:38 +09:00
'default compression method' : compression ,
2021-07-28 10:04:01 +02:00
'default DNSSEC mode' : default_dnssec ,
'default DNS-over-TLS mode' : default_dns_over_tls ,
'default mDNS mode' : default_mdns ,
'default LLMNR mode' : default_llmnr ,
'default DNS servers' : dns_servers . split ( ' ' ) ,
'default NTP servers' : ntp_servers . split ( ' ' ) ,
2024-02-28 15:31:27 +01:00
'default net.naming_scheme= value' : default_net_naming_scheme ,
'default KillUserProcesses= value' : kill_user_processes ,
2021-07-28 10:04:01 +02:00
'default locale' : default_locale ,
2022-06-27 12:46:57 +09:00
'default nspawn locale' : nspawn_locale ,
2022-06-09 20:32:22 +02:00
'default status unit format' : status_unit_format_default ,
2021-07-28 10:04:01 +02:00
'default user $PATH' :
default_user_path != '' ? default_user_path : '(same as system services)' ,
'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog ,
'time epoch' : '@0@ (@1@)' . format ( time_epoch , alt_time_epoch ) } )
2017-04-27 20:54:52 -04:00
# TODO:
# CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
# CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
# LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
found = [ ]
missing = [ ]
foreach tuple : [
2021-04-15 10:59:03 +02:00
# dependencies
[ 'ACL' ] ,
2017-04-27 20:54:52 -04:00
[ 'AUDIT' ] ,
[ 'AppArmor' ] ,
2021-04-15 10:59:03 +02:00
[ 'IMA' ] ,
[ 'PAM' ] ,
2017-04-27 20:54:52 -04:00
[ 'SECCOMP' ] ,
2021-04-15 10:59:03 +02:00
[ 'SELinux' ] ,
2017-04-27 20:54:52 -04:00
[ 'SMACK' ] ,
2021-04-15 10:59:03 +02:00
[ 'blkid' ] ,
[ 'elfutils' ] ,
[ 'gcrypt' ] ,
[ 'gnutls' ] ,
2020-11-13 17:08:15 -08:00
[ 'libbpf' ] ,
2021-04-15 10:59:03 +02:00
[ 'libcryptsetup' ] ,
2021-03-16 20:13:28 +01:00
[ 'libcryptsetup-plugins' ] ,
2021-04-15 10:59:03 +02:00
[ 'libcurl' ] ,
[ 'libfdisk' ] ,
[ 'libfido2' ] ,
[ 'libidn' ] ,
[ 'libidn2' ] ,
[ 'libiptc' ] ,
[ 'microhttpd' ] ,
[ 'openssl' ] ,
[ 'p11kit' ] ,
2021-08-06 11:41:01 +03:00
[ 'passwdqc' ] ,
2021-04-15 10:59:03 +02:00
[ 'pcre2' ] ,
[ 'pwquality' ] ,
[ 'qrencode' ] ,
[ 'tpm2' ] ,
[ 'xkbcommon' ] ,
# compression libs
2020-04-12 01:09:05 +02:00
[ 'zstd' ] ,
2017-04-27 20:54:52 -04:00
[ 'lz4' ] ,
2021-04-15 10:59:03 +02:00
[ 'xz' ] ,
[ 'zlib' ] ,
2017-04-27 20:54:52 -04:00
[ 'bzip2' ] ,
2021-04-15 10:59:03 +02:00
# components
2017-04-27 20:54:52 -04:00
[ 'backlight' ] ,
2021-04-15 10:59:03 +02:00
[ 'binfmt' ] ,
2023-02-26 14:09:44 +01:00
[ 'bootloader' ] ,
2022-07-27 15:28:09 -06:00
[ 'bpf-framework' , conf . get ( 'BPF_FRAMEWORK' ) == 1 ] ,
2017-04-27 20:54:52 -04:00
[ 'coredump' ] ,
[ 'efi' ] ,
2023-02-26 14:09:44 +01:00
[ 'environment.d' ] ,
2021-04-15 10:59:03 +02:00
[ 'firstboot' ] ,
[ 'hibernate' ] ,
[ 'homed' ] ,
[ 'hostnamed' ] ,
[ 'hwdb' ] ,
[ 'importd' ] ,
[ 'initrd' ] ,
2022-03-31 11:17:10 +02:00
[ 'kernel-install' ] ,
2021-04-15 10:59:03 +02:00
[ 'localed' ] ,
2017-04-27 20:54:52 -04:00
[ 'logind' ] ,
[ 'machined' ] ,
[ 'networkd' ] ,
2018-08-07 18:10:53 +02:00
[ 'nss-myhostname' ] ,
[ 'nss-mymachines' ] ,
[ 'nss-resolve' ] ,
[ 'nss-systemd' ] ,
2021-04-15 10:59:03 +02:00
[ 'oomd' ] ,
[ 'portabled' ] ,
[ 'pstore' ] ,
[ 'quotacheck' ] ,
[ 'randomseed' ] ,
[ 'repart' ] ,
[ 'resolve' ] ,
[ 'rfkill' ] ,
[ 'sysext' ] ,
2022-07-27 15:28:09 -06:00
[ 'systemd-analyze' , conf . get ( 'ENABLE_ANALYZE' ) == 1 ] ,
2020-12-28 15:17:54 +01:00
[ 'sysupdate' ] ,
2021-04-15 10:59:03 +02:00
[ 'sysusers' ] ,
2023-10-27 14:25:49 +02:00
[ 'storagetm' ] ,
2021-04-15 10:59:03 +02:00
[ 'timedated' ] ,
[ 'timesyncd' ] ,
[ 'tmpfiles' ] ,
[ 'userdb' ] ,
[ 'vconsole' ] ,
2023-10-12 13:13:19 +01:00
[ 'vmspawn' ] ,
2021-04-15 10:59:03 +02:00
[ 'xdg-autostart' ] ,
# optional features
2023-07-30 06:32:53 +09:00
[ 'dmi' ] ,
2021-04-15 10:59:03 +02:00
[ 'idn' ] ,
[ 'polkit' ] ,
[ 'nscd' ] ,
2022-07-27 15:28:09 -06:00
[ 'legacy-pkla' , install_polkit_pkla ] ,
2021-04-15 10:59:03 +02:00
[ 'kmod' ] ,
2022-11-01 16:53:02 +01:00
[ 'xenctrl' ] ,
2021-04-15 10:59:03 +02:00
[ 'dbus' ] ,
[ 'glib' ] ,
2017-04-27 20:54:52 -04:00
[ 'tpm' ] ,
2022-07-27 15:28:09 -06:00
[ 'man pages' , want_man ] ,
[ 'html pages' , want_html ] ,
[ 'man page indices' , want_man and have_lxml ] ,
2017-04-27 20:54:52 -04:00
[ 'SysV compat' ] ,
2021-04-15 10:59:03 +02:00
[ 'compat-mutable-uid-boundaries' ] ,
2017-04-27 20:54:52 -04:00
[ 'utmp' ] ,
[ 'ldconfig' ] ,
2022-07-27 15:28:09 -06:00
[ 'adm group' , get_option ( 'adm-group' ) ] ,
[ 'wheel group' , get_option ( 'wheel-group' ) ] ,
2017-05-09 14:02:37 +02:00
[ 'gshadow' ] ,
2017-04-27 20:54:52 -04:00
[ 'debug hashmap' ] ,
[ 'debug mmap cache' ] ,
2018-11-23 00:36:35 +09:00
[ 'debug siphash' ] ,
2022-07-27 15:28:09 -06:00
[ 'trace logging' , conf . get ( 'LOG_TRACE' ) == 1 ] ,
2023-03-03 20:15:07 +09:00
[ 'slow tests' , slow_tests ] ,
[ 'fuzz tests' , fuzz_tests ] ,
2022-07-27 15:28:09 -06:00
[ 'install tests' , install_tests ] ,
[ 'link-udev-shared' , get_option ( 'link-udev-shared' ) ] ,
[ 'link-systemctl-shared' , get_option ( 'link-systemctl-shared' ) ] ,
[ 'link-networkd-shared' , get_option ( 'link-networkd-shared' ) ] ,
[ 'link-timesyncd-shared' , get_option ( 'link-timesyncd-shared' ) ] ,
[ 'link-journalctl-shared' , get_option ( 'link-journalctl-shared' ) ] ,
[ 'link-boot-shared' , get_option ( 'link-boot-shared' ) ] ,
2023-05-14 03:17:47 +02:00
[ 'link-portabled-shared' , get_option ( 'link-portabled-shared' ) ] ,
2020-03-23 12:25:19 -04:00
[ 'first-boot-full-preset' ] ,
2020-11-06 15:01:13 +01:00
[ 'fexecve' ] ,
2022-07-27 15:28:09 -06:00
[ 'standalone-binaries' , get_option ( 'standalone-binaries' ) ] ,
[ 'coverage' , get_option ( 'b_coverage' ) ] ,
2017-04-27 20:54:52 -04:00
]
2018-03-09 14:21:08 +01:00
if tuple . length ( ) > = 2
cond = tuple [ 1 ]
else
2017-04-27 20:54:52 -04:00
ident1 = 'HAVE_' + tuple [ 0 ] . underscorify ( ) . to_upper ( )
ident2 = 'ENABLE_' + tuple [ 0 ] . underscorify ( ) . to_upper ( )
2017-10-03 10:41:51 +02:00
cond = conf . get ( ident1 , 0 ) == 1 or conf . get ( ident2 , 0 ) == 1
2017-04-27 20:54:52 -04:00
endif
if cond
2018-07-31 09:44:11 +02:00
found + = tuple [ 0 ]
2017-04-27 20:54:52 -04:00
else
2018-07-31 09:44:11 +02:00
missing + = tuple [ 0 ]
2017-04-27 20:54:52 -04:00
endif
endforeach
2021-04-15 09:56:06 +02:00
if static_libsystemd == 'false'
missing + = 'static-libsystemd'
else
found + = 'static-libsystemd(@0@)' . format ( static_libsystemd )
endif
if static_libudev == 'false'
missing + = 'static-libudev'
else
found + = 'static-libudev(@0@)' . format ( static_libudev )
endif
2021-11-02 09:44:12 +01:00
if conf . get ( 'HAVE_OPENSSL_OR_GCRYPT' ) == 1 and conf . get ( 'PREFER_OPENSSL' ) == 1
found + = 'cryptolib(openssl)'
elif conf . get ( 'HAVE_OPENSSL_OR_GCRYPT' ) == 1
found + = 'cryptolib(gcrypt)'
else
missing + = 'cryptolib'
endif
2021-04-15 11:04:14 +02:00
if conf . get ( 'DNS_OVER_TLS_USE_GNUTLS' ) == 1
found + = 'DNS-over-TLS(gnutls)'
elif conf . get ( 'DNS_OVER_TLS_USE_OPENSSL' ) == 1
found + = 'DNS-over-TLS(openssl)'
else
missing + = 'DNS-over-TLS'
endif
2021-07-28 10:04:01 +02:00
summary ( {
'enabled' : ', ' . join ( found ) ,
'disabled' : ', ' . join ( missing ) } ,
section : 'Features' )