]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix detection of GnuTLS 1.x.y
authorMatthias Bolte <matthias.bolte@googlemail.com>
Wed, 3 Aug 2011 16:23:21 +0000 (18:23 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Wed, 3 Aug 2011 17:22:29 +0000 (19:22 +0200)
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.

configure.ac
src/gnutls_1_0_compat.h
tests/virnettlscontexttest.c

index c8d291b0333ea328a4a5b4b572615b4e3a529d16..fe700b9d964f9f99e00356ff63f682ddbaa865b1 100644 (file)
@@ -834,20 +834,6 @@ 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.
-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>])
-CFLAGS="$old_cflags"
-LIBS="$old_libs"
-
 
 dnl Cyrus SASL
 AC_ARG_WITH([sasl],
index fb423f12a62deefcbc672d43d992b1088071ecae..ebe97fdf45eeb42b34e064d112bf9ba95b721d40 100644 (file)
  */
 
 #ifndef LIBVIRT_GNUTLS_1_0_COMPAT_H__
+# define LIBVIRT_GNUTLS_1_0_COMPAT_H__
 
 # include <config.h>
 
+# include <gnutls/gnutls.h>
+
+/* enable backward compatibility macros for gnutls 1.x.y */
+# if LIBGNUTLS_VERSION_MAJOR < 2
+#  define GNUTLS_1_0_COMPAT
+# endif
+
 # ifdef GNUTLS_1_0_COMPAT
 #  define gnutls_session_t                 gnutls_session
 #  define gnutls_x509_crt_t                gnutls_x509_crt
index 520b006a183121bf4c524b3027fd85d79e757d5d..ee7b6b4a6f8fc008ff11603b3035fdcffef8b684 100644 (file)
@@ -23,6 +23,8 @@
 #include <stdlib.h>
 #include <fcntl.h>
 #include <sys/socket.h>
+#include <gnutls/gnutls.h>
+#include <gnutls/x509.h>
 
 #include "testutils.h"
 #include "util.h"
 #include "virfile.h"
 #include "command.h"
 #include "network.h"
+#include "gnutls_1_0_compat.h"
 
 #if !defined WIN32 && HAVE_LIBTASN1_H && !defined GNUTLS_1_0_COMPAT
 # include <libtasn1.h>
-# include <gnutls/gnutls.h>
-# include <gnutls/x509.h>
-# include "gnutls_1_0_compat.h"
 
 # include "rpc/virnettlscontext.h"