summaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2021-06-03 11:15:26 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2021-06-25 10:53:46 +0200
commit5761251138cb69c310e9df7dfc82c4c6fd2444e4 (patch)
treed1783c0d2a6b85c1ef223783dea240c1d9676e23 /meson.build
parent4c1f23cfb84c386a8f4f5433f0fd98e0c85d057b (diff)
downloadqemu-5761251138cb69c310e9df7dfc82c4c6fd2444e4.zip
configure, meson: convert crypto detection to meson
Reviewed-by: Richard Henderson <richard.henderson@liaro.org> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build81
1 files changed, 59 insertions, 22 deletions
diff --git a/meson.build b/meson.build
index 3809f51f7f..286b37aecb 100644
--- a/meson.build
+++ b/meson.build
@@ -320,21 +320,6 @@ urcubp = not_found
if 'CONFIG_TRACE_UST' in config_host
urcubp = declare_dependency(link_args: config_host['URCU_BP_LIBS'].split())
endif
-gcrypt = not_found
-if 'CONFIG_GCRYPT' in config_host
- gcrypt = declare_dependency(compile_args: config_host['GCRYPT_CFLAGS'].split(),
- link_args: config_host['GCRYPT_LIBS'].split())
-endif
-nettle = not_found
-if 'CONFIG_NETTLE' in config_host
- nettle = declare_dependency(compile_args: config_host['NETTLE_CFLAGS'].split(),
- link_args: config_host['NETTLE_LIBS'].split())
-endif
-gnutls = not_found
-if 'CONFIG_GNUTLS' in config_host
- gnutls = declare_dependency(compile_args: config_host['GNUTLS_CFLAGS'].split(),
- link_args: config_host['GNUTLS_LIBS'].split())
-endif
pixman = not_found
if have_system or have_tools
pixman = dependency('pixman-1', required: have_system, version:'>=0.21.8',
@@ -829,6 +814,54 @@ if 'CONFIG_OPENGL' in config_host
link_args: config_host['OPENGL_LIBS'].split())
endif
+gnutls = not_found
+if not get_option('gnutls').auto() or have_system
+ gnutls = dependency('gnutls', version: '>=3.5.18',
+ method: 'pkg-config',
+ required: get_option('gnutls'),
+ kwargs: static_kwargs)
+endif
+
+# Nettle has priority over gcrypt
+gcrypt = not_found
+nettle = not_found
+xts = 'private'
+if get_option('nettle').enabled() and get_option('gcrypt').enabled()
+ error('Only one of gcrypt & nettle can be enabled')
+elif (not get_option('nettle').auto() or have_system) and not get_option('gcrypt').enabled()
+ nettle = dependency('nettle', version: '>=3.4',
+ method: 'pkg-config',
+ required: get_option('nettle'),
+ kwargs: static_kwargs)
+ if nettle.found() and cc.has_header('nettle/xts.h', dependencies: nettle)
+ xts = 'nettle'
+ endif
+endif
+if (not get_option('gcrypt').auto() or have_system) and not nettle.found()
+ gcrypt = dependency('libgcrypt', version: '>=1.5',
+ method: 'config-tool',
+ required: get_option('gcrypt'),
+ kwargs: static_kwargs)
+ if gcrypt.found() and cc.compiles('''
+ #include <gcrypt.h>
+ int main(void) {
+ gcry_cipher_hd_t handle;
+ gcry_cipher_open(&handle, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_XTS, 0);
+ return 0;
+ }
+ ''', dependencies: gcrypt)
+ xts = 'gcrypt'
+ endif
+ # Debian has removed -lgpg-error from libgcrypt-config
+ # as it "spreads unnecessary dependencies" which in
+ # turn breaks static builds...
+ if gcrypt.found() and enable_static
+ gcrypt = declare_dependency(dependencies: [
+ gcrypt,
+ cc.find_library('gpg-error', required: true, kwargs: static_kwargs)])
+ endif
+endif
+
gtk = not_found
gtkx11 = not_found
if not get_option('gtk').auto() or (have_system and not cocoa.found())
@@ -1165,6 +1198,10 @@ config_host_data.set('CONFIG_VIRTFS', have_virtfs)
config_host_data.set('CONFIG_XKBCOMMON', xkbcommon.found())
config_host_data.set('CONFIG_KEYUTILS', keyutils.found())
config_host_data.set('CONFIG_GETTID', has_gettid)
+config_host_data.set('CONFIG_GNUTLS', gnutls.found())
+config_host_data.set('CONFIG_GCRYPT', gcrypt.found())
+config_host_data.set('CONFIG_NETTLE', nettle.found())
+config_host_data.set('CONFIG_QEMU_PRIVATE_XTS', xts == 'private')
config_host_data.set('CONFIG_MALLOC_TRIM', has_malloc_trim)
config_host_data.set('CONFIG_STATX', has_statx)
config_host_data.set('CONFIG_ZSTD', zstd.found())
@@ -2659,16 +2696,16 @@ summary(summary_info, bool_yn: true, section: 'Block layer support')
# Crypto
summary_info = {}
summary_info += {'TLS priority': config_host['CONFIG_TLS_PRIORITY']}
-summary_info += {'GNUTLS support': config_host.has_key('CONFIG_GNUTLS')}
+summary_info += {'GNUTLS support': gnutls.found()}
# TODO: add back version
-summary_info += {'libgcrypt': config_host.has_key('CONFIG_GCRYPT')}
-if config_host.has_key('CONFIG_GCRYPT')
- summary_info += {' XTS': not config_host.has_key('CONFIG_QEMU_PRIVATE_XTS')}
+summary_info += {'libgcrypt': gcrypt.found()}
+if gcrypt.found()
+ summary_info += {' XTS': xts != 'private'}
endif
# TODO: add back version
-summary_info += {'nettle': config_host.has_key('CONFIG_NETTLE')}
-if config_host.has_key('CONFIG_NETTLE')
- summary_info += {' XTS': not config_host.has_key('CONFIG_QEMU_PRIVATE_XTS')}
+summary_info += {'nettle': nettle.found()}
+if nettle.found()
+ summary_info += {' XTS': xts != 'private'}
endif
summary_info += {'crypto afalg': config_host.has_key('CONFIG_AF_ALG')}
summary_info += {'rng-none': config_host.has_key('CONFIG_RNG_NONE')}