[libvirt] [PATCH] Fix detection of GnuTLS 1.x.y

Detection based on gnutls_session doesn't work because GnuTLS 2.x.y comes with a compat.h that defines gnutls_session to gnutls_session_t. Instead detect this based on LIBGNUTLS_VERSION_MAJOR. --- configure.ac | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index c8d291b..6a20366 100644 --- a/configure.ac +++ b/configure.ac @@ -834,17 +834,25 @@ fi AC_SUBST([GNUTLS_CFLAGS]) AC_SUBST([GNUTLS_LIBS]) -dnl Old versions of GnuTLS uses types like 'gnutls_session' instead -dnl of 'gnutls_session_t'. Try to detect this type if defined so -dnl that we can offer backwards compatibility. +dnl Detect GnuTLS 1.x.y and enable backwards compatibility macros if found. old_cflags="$CFLAGS" old_libs="$LIBS" CFLAGS="$CFLAGS $GNUTLS_CFLAGS" LIBS="$LIBS $GNUTLS_LIBS" -AC_CHECK_TYPE([gnutls_session], - AC_DEFINE([GNUTLS_1_0_COMPAT],[], - [enable GnuTLS 1.0 compatibility macros]),, - [#include <gnutls/gnutls.h>]) +AC_MSG_CHECKING([whether GnuTLS 1.0 compatibility macros are required]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gnutls/gnutls.h>]], + [[ + #if LIBGNUTLS_VERSION_MAJOR < 2 + # error gnutls 1.x.y detected + #endif + ]])], + [have_gnutlsv1=no], + [have_gnutlsv1=yes]) +if test "x$have_gnutlsv1" = xyes; then + AC_DEFINE_UNQUOTED([GNUTLS_1_0_COMPAT], 1, + [enable GnuTLS 1.0 compatibility macros]) +fi +AC_MSG_RESULT([$have_gnutlsv1]) CFLAGS="$old_cflags" LIBS="$old_libs" -- 1.7.4.1

On 08/03/2011 08:22 AM, Matthias Bolte wrote:
Detection based on gnutls_session doesn't work because GnuTLS 2.x.y comes with a compat.h that defines gnutls_session to gnutls_session_t.
Instead detect this based on LIBGNUTLS_VERSION_MAJOR. --- configure.ac | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-)
ACK for correctness. However, I wonder if it is the most efficient. We aren't using this as a Makefile conditional, and LIBGNUTLS_VERSION_MAJOR is available at compile time. That is, I think that we could skip the configure check altogether, and just move the #if LIBGNUTLS_VERSION_MAJOR < 2 check into a common header used by all files that want to use gnutls in the first place, for a slightly smaller and faster configure. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

2011/8/3 Eric Blake <eblake@redhat.com>:
On 08/03/2011 08:22 AM, Matthias Bolte wrote:
Detection based on gnutls_session doesn't work because GnuTLS 2.x.y comes with a compat.h that defines gnutls_session to gnutls_session_t.
Instead detect this based on LIBGNUTLS_VERSION_MAJOR. --- configure.ac | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-)
ACK for correctness.
However, I wonder if it is the most efficient. We aren't using this as a Makefile conditional, and LIBGNUTLS_VERSION_MAJOR is available at compile time. That is, I think that we could skip the configure check altogether, and just move the #if LIBGNUTLS_VERSION_MAJOR < 2 check into a common header used by all files that want to use gnutls in the first place, for a slightly smaller and faster configure.
Here's a v2 that does this. -- Matthias Bolte http://photron.blogspot.com

On 08/03/2011 10:28 AM, Matthias Bolte wrote:
2011/8/3 Eric Blake<eblake@redhat.com>:
On 08/03/2011 08:22 AM, Matthias Bolte wrote:
Detection based on gnutls_session doesn't work because GnuTLS 2.x.y comes with a compat.h that defines gnutls_session to gnutls_session_t.
Instead detect this based on LIBGNUTLS_VERSION_MAJOR. --- configure.ac | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-)
ACK for correctness.
However, I wonder if it is the most efficient. We aren't using this as a Makefile conditional, and LIBGNUTLS_VERSION_MAJOR is available at compile time. That is, I think that we could skip the configure check altogether, and just move the #if LIBGNUTLS_VERSION_MAJOR< 2 check into a common header used by all files that want to use gnutls in the first place, for a slightly smaller and faster configure.
Here's a v2 that does this.
Nicer - thanks for that work.
Detection based on gnutls_session doesn't work because GnuTLS 2.x.y comes with a compat.h that defines gnutls_session to gnutls_session_t.
Instead detect this based on LIBGNUTLS_VERSION_MAJOR. Move this from configure/config.h to gnutls_1_0_compat.h and make sure that all users include gnutls_1_0_compat.h properly.
Also fix header guard in gnutls_1_0_compat.h.
ACK. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

2011/8/3 Eric Blake <eblake@redhat.com>:
On 08/03/2011 10:28 AM, Matthias Bolte wrote:
2011/8/3 Eric Blake<eblake@redhat.com>:
On 08/03/2011 08:22 AM, Matthias Bolte wrote:
Detection based on gnutls_session doesn't work because GnuTLS 2.x.y comes with a compat.h that defines gnutls_session to gnutls_session_t.
Instead detect this based on LIBGNUTLS_VERSION_MAJOR. --- configure.ac | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-)
ACK for correctness.
However, I wonder if it is the most efficient. We aren't using this as a Makefile conditional, and LIBGNUTLS_VERSION_MAJOR is available at compile time. That is, I think that we could skip the configure check altogether, and just move the #if LIBGNUTLS_VERSION_MAJOR< 2 check into a common header used by all files that want to use gnutls in the first place, for a slightly smaller and faster configure.
Here's a v2 that does this.
Nicer - thanks for that work.
Detection based on gnutls_session doesn't work because GnuTLS 2.x.y comes with a compat.h that defines gnutls_session to gnutls_session_t.
Instead detect this based on LIBGNUTLS_VERSION_MAJOR. Move this from configure/config.h to gnutls_1_0_compat.h and make sure that all users include gnutls_1_0_compat.h properly.
Also fix header guard in gnutls_1_0_compat.h.
ACK.
Thanks, pushed. -- Matthias Bolte http://photron.blogspot.com
participants (2)
-
Eric Blake
-
Matthias Bolte