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],
*/
#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
#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"