Description: allows to build against libcurl instead of libgnurl
Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=758937
Origin: commits:r34268-r34272
Author: Christian Grothoff <christian@grothoff.org>
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -18,6 +18,8 @@
 isc-posix.m4\
 lcmessage.m4\
 libgcrypt.m4\
+libgnurl.m4\
+libcurl.m4\
 lib-ld.m4\
 lib-link.m4\
 lib-prefix.m4\
--- /dev/null
+++ b/m4/libcurl.m4
@@ -0,0 +1,251 @@
+# LIBCURL_CHECK_CONFIG ([DEFAULT-ACTION], [MINIMUM-VERSION],
+#                       [ACTION-IF-YES], [ACTION-IF-NO])
+# ----------------------------------------------------------
+#      David Shaw <dshaw@jabberwocky.com>   May-09-2006
+#
+# Checks for libcurl.  DEFAULT-ACTION is the string yes or no to
+# specify whether to default to --with-libcurl or --without-libcurl.
+# If not supplied, DEFAULT-ACTION is yes.  MINIMUM-VERSION is the
+# minimum version of libcurl to accept.  Pass the version as a regular
+# version number like 7.10.1. If not supplied, any version is
+# accepted.  ACTION-IF-YES is a list of shell commands to run if
+# libcurl was successfully found and passed the various tests.
+# ACTION-IF-NO is a list of shell commands that are run otherwise.
+# Note that using --without-libcurl does run ACTION-IF-NO.
+#
+# This macro #defines HAVE_LIBCURL if a working libcurl setup is
+# found, and sets @LIBCURL@ and @LIBCURL_CPPFLAGS@ to the necessary
+# values.  Other useful defines are LIBCURL_FEATURE_xxx where xxx are
+# the various features supported by libcurl, and LIBCURL_PROTOCOL_yyy
+# where yyy are the various protocols supported by libcurl.  Both xxx
+# and yyy are capitalized.  See the list of AH_TEMPLATEs at the top of
+# the macro for the complete list of possible defines.  Shell
+# variables $libcurl_feature_xxx and $libcurl_protocol_yyy are also
+# defined to 'yes' for those features and protocols that were found.
+# Note that xxx and yyy keep the same capitalization as in the
+# curl-config list (e.g. it's "HTTP" and not "http").
+#
+# Users may override the detected values by doing something like:
+# LIBCURL="-lcurl" LIBCURL_CPPFLAGS="-I/usr/myinclude" ./configure
+#
+# For the sake of sanity, this macro assumes that any libcurl that is
+# found is after version 7.7.2, the first version that included the
+# curl-config script.  Note that it is very important for people
+# packaging binary versions of libcurl to include this script!
+# Without curl-config, we can only guess what protocols are available,
+# or use curl_version_info to figure it out at runtime.
+
+AC_DEFUN([LIBCURL_CHECK_CONFIG],
+[
+  AH_TEMPLATE([LIBCURL_FEATURE_SSL],[Defined if libcurl supports SSL])
+  AH_TEMPLATE([LIBCURL_FEATURE_KRB4],[Defined if libcurl supports KRB4])
+  AH_TEMPLATE([LIBCURL_FEATURE_IPV6],[Defined if libcurl supports IPv6])
+  AH_TEMPLATE([LIBCURL_FEATURE_LIBZ],[Defined if libcurl supports libz])
+  AH_TEMPLATE([LIBCURL_FEATURE_ASYNCHDNS],[Defined if libcurl supports AsynchDNS])
+  AH_TEMPLATE([LIBCURL_FEATURE_IDN],[Defined if libcurl supports IDN])
+  AH_TEMPLATE([LIBCURL_FEATURE_SSPI],[Defined if libcurl supports SSPI])
+  AH_TEMPLATE([LIBCURL_FEATURE_NTLM],[Defined if libcurl supports NTLM])
+
+  AH_TEMPLATE([LIBCURL_PROTOCOL_HTTP],[Defined if libcurl supports HTTP])
+  AH_TEMPLATE([LIBCURL_PROTOCOL_HTTPS],[Defined if libcurl supports HTTPS])
+  AH_TEMPLATE([LIBCURL_PROTOCOL_FTP],[Defined if libcurl supports FTP])
+  AH_TEMPLATE([LIBCURL_PROTOCOL_FTPS],[Defined if libcurl supports FTPS])
+  AH_TEMPLATE([LIBCURL_PROTOCOL_FILE],[Defined if libcurl supports FILE])
+  AH_TEMPLATE([LIBCURL_PROTOCOL_TELNET],[Defined if libcurl supports TELNET])
+  AH_TEMPLATE([LIBCURL_PROTOCOL_LDAP],[Defined if libcurl supports LDAP])
+  AH_TEMPLATE([LIBCURL_PROTOCOL_DICT],[Defined if libcurl supports DICT])
+  AH_TEMPLATE([LIBCURL_PROTOCOL_TFTP],[Defined if libcurl supports TFTP])
+  AH_TEMPLATE([LIBCURL_PROTOCOL_RTSP],[Defined if libcurl supports RTSP])
+  AH_TEMPLATE([LIBCURL_PROTOCOL_POP3],[Defined if libcurl supports POP3])
+  AH_TEMPLATE([LIBCURL_PROTOCOL_IMAP],[Defined if libcurl supports IMAP])
+  AH_TEMPLATE([LIBCURL_PROTOCOL_SMTP],[Defined if libcurl supports SMTP])
+
+  AC_ARG_WITH(libcurl,
+     AC_HELP_STRING([--with-libcurl=PREFIX],[look for the curl library in PREFIX/lib and headers in PREFIX/include]),
+     [_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])])
+
+  if test "$_libcurl_with" != "no" ; then
+
+     AC_PROG_AWK
+
+     _libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'"
+
+     _libcurl_try_link=yes
+
+     if test -d "$_libcurl_with" ; then
+        LIBCURL_CPPFLAGS="-I$withval/include"
+        _libcurl_ldflags="-L$withval/lib"
+        AC_PATH_PROG([_libcurl_config],[curl-config],[],
+                     ["$withval/bin"])
+     else
+        AC_PATH_PROG([_libcurl_config],[curl-config],[],[$PATH])
+     fi
+
+     if test x$_libcurl_config != "x" ; then
+        AC_CACHE_CHECK([for the version of libcurl],
+           [libcurl_cv_lib_curl_version],
+           [libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $[]2}'`])
+
+        _libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse`
+        _libcurl_wanted=`echo ifelse([$2],,[0],[$2]) | $_libcurl_version_parse`
+
+        if test $_libcurl_wanted -gt 0 ; then
+           AC_CACHE_CHECK([for libcurl >= version $2],
+              [libcurl_cv_lib_version_ok],
+              [
+              if test $_libcurl_version -ge $_libcurl_wanted ; then
+                 libcurl_cv_lib_version_ok=yes
+              else
+                 libcurl_cv_lib_version_ok=no
+              fi
+              ])
+        fi
+
+        if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes ; then
+           if test x"$LIBCURL_CPPFLAGS" = "x" ; then
+              LIBCURL_CPPFLAGS=`$_libcurl_config --cflags`
+           fi
+           if test x"$LIBCURL" = "x" ; then
+              LIBCURL=`$_libcurl_config --libs`
+
+              # This is so silly, but Apple actually has a bug in their
+              # curl-config script.  Fixed in Tiger, but there are still
+              # lots of Panther installs around.
+              case "${host}" in
+                 powerpc-apple-darwin7*)
+                    LIBCURL=`echo $LIBCURL | sed -e 's|-arch i386||g'`
+                 ;;
+              esac
+           fi
+
+           # All curl-config scripts support --feature
+           _libcurl_features=`$_libcurl_config --feature`
+
+           # Is it modern enough to have --protocols? (7.12.4)
+           if test $_libcurl_version -ge 461828 ; then
+              _libcurl_protocols=`$_libcurl_config --protocols`
+           fi
+        else
+           _libcurl_try_link=no
+        fi
+
+        unset _libcurl_wanted
+     fi
+
+     if test $_libcurl_try_link = yes ; then
+
+        # we didn't find curl-config, so let's see if the user-supplied
+        # link line (or failing that, "-lcurl") is enough.
+        LIBCURL=${LIBCURL-"$_libcurl_ldflags -lcurl"}
+
+        AC_CACHE_CHECK([whether libcurl is usable],
+           [libcurl_cv_lib_curl_usable],
+           [
+           _libcurl_save_cppflags=$CPPFLAGS
+           CPPFLAGS="$LIBCURL_CPPFLAGS $CPPFLAGS"
+           _libcurl_save_libs=$LIBS
+           LIBS="$LIBCURL $LIBS"
+
+           AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <curl/curl.h>]],[[
+/* Try and use a few common options to force a failure if we are
+   missing symbols or can't link. */
+int x;
+curl_easy_setopt(NULL,CURLOPT_URL,NULL);
+x=CURL_ERROR_SIZE;
+x=CURLOPT_WRITEFUNCTION;
+x=CURLOPT_WRITEDATA;
+x=CURLOPT_ERRORBUFFER;
+x=CURLOPT_STDERR;
+x=CURLOPT_VERBOSE;
+if (x) ;
+]])],libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no)
+
+           CPPFLAGS=$_libcurl_save_cppflags
+           LIBS=$_libcurl_save_libs
+           unset _libcurl_save_cppflags
+           unset _libcurl_save_libs
+           ])
+
+        if test $libcurl_cv_lib_curl_usable = yes ; then
+
+           # Does curl_free() exist in this version of libcurl?
+           # If not, fake it with free()
+
+           _libcurl_save_cppflags=$CPPFLAGS
+           CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS"
+           _libcurl_save_libs=$LIBS
+           LIBS="$LIBS $LIBCURL"
+
+           AC_CHECK_FUNC(curl_free,,
+              AC_DEFINE(curl_free,free,
+                [Define curl_free() as free() if our version of curl lacks curl_free.]))
+
+           CPPFLAGS=$_libcurl_save_cppflags
+           LIBS=$_libcurl_save_libs
+           unset _libcurl_save_cppflags
+           unset _libcurl_save_libs
+
+           AC_DEFINE(HAVE_LIBCURL,1,
+             [Define to 1 if you have a functional curl library.])
+           AC_SUBST(LIBCURL_CPPFLAGS)
+           AC_SUBST(LIBCURL)
+
+           for _libcurl_feature in $_libcurl_features ; do
+              AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_feature_$_libcurl_feature),[1])
+              eval AS_TR_SH(libcurl_feature_$_libcurl_feature)=yes
+           done
+
+           if test "x$_libcurl_protocols" = "x" ; then
+
+              # We don't have --protocols, so just assume that all
+              # protocols are available
+              _libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT TFTP"
+
+              if test x$libcurl_feature_SSL = xyes ; then
+                 _libcurl_protocols="$_libcurl_protocols HTTPS"
+
+                 # FTPS wasn't standards-compliant until version
+                 # 7.11.0 (0x070b00 == 461568)
+                 if test $_libcurl_version -ge 461568; then
+                    _libcurl_protocols="$_libcurl_protocols FTPS"
+                 fi
+              fi
+
+              # RTSP, IMAP, POP3 and SMTP were added in
+              # 7.20.0 (0x071400 == 463872)
+              if test $_libcurl_version -ge 463872; then
+                 _libcurl_protocols="$_libcurl_protocols RTSP IMAP POP3 SMTP"
+              fi
+           fi
+
+           for _libcurl_protocol in $_libcurl_protocols ; do
+              AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_protocol_$_libcurl_protocol),[1])
+              eval AS_TR_SH(libcurl_protocol_$_libcurl_protocol)=yes
+           done
+        else
+           unset LIBCURL
+           unset LIBCURL_CPPFLAGS
+        fi
+     fi
+
+     unset _libcurl_try_link
+     unset _libcurl_version_parse
+     unset _libcurl_config
+     unset _libcurl_feature
+     unset _libcurl_features
+     unset _libcurl_protocol
+     unset _libcurl_protocols
+     unset _libcurl_version
+     unset _libcurl_ldflags
+  fi
+
+  if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then
+     # This is the IF-NO path
+     ifelse([$4],,:,[$4])
+  else
+     # This is the IF-YES path
+     ifelse([$3],,:,[$3])
+  fi
+
+  unset _libcurl_with
+])dnl
--- a/src/pt/Makefile.am
+++ b/src/pt/Makefile.am
@@ -34,7 +34,29 @@
 
 if HAVE_TESTING
 if HAVE_MHD
+
 if HAVE_LIBGNURL
+LIB_GNURL=@LIBGNURL@
+CPP_GNURL=@LIBGNURL_CPPFLAGS@
+if LINUX
+ VPN_TEST = \
+ test_gnunet_vpn-4_to_6 \
+ test_gnunet_vpn-6_to_4 \
+ test_gnunet_vpn-6_over \
+ test_gnunet_vpn-4_over \
+ test_gns_vpn
+endif
+if MINGW
+ VPN_TEST = \
+ test_gnunet_vpn-4_to_6 \
+ test_gnunet_vpn-6_to_4 \
+ test_gnunet_vpn-6_over \
+ test_gnunet_vpn-4_over
+endif
+else
+if HAVE_LIBCURL
+LIB_GNURL=@LIBCURL@
+CPP_GNURL=@LIBCURL_CPPFLAGS@
 if LINUX
  VPN_TEST = \
  test_gnunet_vpn-4_to_6 \
@@ -52,6 +74,8 @@
 endif
 endif
 endif
+
+endif
 endif
 
 check_PROGRAMS = $(VPN_TEST)
@@ -69,48 +93,48 @@
 
 test_gns_vpn_SOURCES = \
  test_gns_vpn.c
-test_gns_vpn_LDADD = -lmicrohttpd @LIBGNURL@ \
+test_gns_vpn_LDADD = -lmicrohttpd $(LIB_GNURL) \
  $(top_builddir)/src/namestore/libgnunetnamestore.la \
  $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la
 test_gns_vpn_CPPFLAGS = \
- @LIBGNURL_CPPFLAGS@ $(AM_CPPFLAGS)
+ $(CPP_GNURL) $(AM_CPPFLAGS)
 
 test_gnunet_vpn_4_over_SOURCES = \
  test_gnunet_vpn.c
-test_gnunet_vpn_4_over_LDADD = -lmicrohttpd @LIBGNURL@ \
+test_gnunet_vpn_4_over_LDADD = -lmicrohttpd $(LIB_GNURL) \
  $(top_builddir)/src/vpn/libgnunetvpn.la \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la
 test_gnunet_vpn_4_over_CPPFLAGS = \
- @LIBGNURL_CPPFLAGS@ $(AM_CPPFLAGS)
+ $(LIB_GNURL) $(AM_CPPFLAGS)
 
 test_gnunet_vpn_6_over_SOURCES = \
  test_gnunet_vpn.c
-test_gnunet_vpn_6_over_LDADD = -lmicrohttpd @LIBGNURL@ \
+test_gnunet_vpn_6_over_LDADD = -lmicrohttpd $(LIB_GNURL) \
  $(top_builddir)/src/vpn/libgnunetvpn.la \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la
 test_gnunet_vpn_6_over_CPPFLAGS = \
- @LIBGNURL_CPPFLAGS@ $(AM_CPPFLAGS)
+ $(CPP_GNURL) $(AM_CPPFLAGS)
 
 test_gnunet_vpn_4_to_6_SOURCES = \
  test_gnunet_vpn.c
-test_gnunet_vpn_4_to_6_LDADD = -lmicrohttpd @LIBGNURL@ \
+test_gnunet_vpn_4_to_6_LDADD = -lmicrohttpd $(LIB_GNURL) \
  $(top_builddir)/src/vpn/libgnunetvpn.la \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la
 test_gnunet_vpn_4_to_6_CPPFLAGS = \
- @LIBGNURL_CPPFLAGS@ $(AM_CPPFLAGS)
+ $(CPP_GNURL) $(AM_CPPFLAGS)
 
 test_gnunet_vpn_6_to_4_SOURCES = \
  test_gnunet_vpn.c
-test_gnunet_vpn_6_to_4_LDADD = -lmicrohttpd @LIBGNURL@ \
+test_gnunet_vpn_6_to_4_LDADD = -lmicrohttpd $(LIB_GNURL) \
  $(top_builddir)/src/vpn/libgnunetvpn.la \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la
 test_gnunet_vpn_6_to_4_CPPFLAGS = \
- @LIBGNURL_CPPFLAGS@ $(AM_CPPFLAGS)
+ $(CPP_GNURL) $(AM_CPPFLAGS)
 
 
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -23,6 +23,17 @@
  HTTPS_CLIENT_PLUGIN_TEST = test_plugin_https_client
  HTTP_CLIENT_PLUGIN_LA = libgnunet_plugin_transport_http_client.la
  HTTPS_CLIENT_PLUGIN_LA = libgnunet_plugin_transport_https_client.la
+LIB_GNURL=@LIBGNURL@
+CPP_GNURL=@LIBGNURL_CPPFLAGS@
+else
+if HAVE_LIBCURL
+ HTTP_CLIENT_PLUGIN_TEST = test_plugin_http_client
+ HTTPS_CLIENT_PLUGIN_TEST = test_plugin_https_client
+ HTTP_CLIENT_PLUGIN_LA = libgnunet_plugin_transport_http_client.la
+ HTTPS_CLIENT_PLUGIN_LA = libgnunet_plugin_transport_https_client.la
+LIB_GNURL=@LIBCURL@
+CPP_GNURL=@LIBCURL_CPPFLAGS@
+endif
 endif
 
 if HAVE_MHD
@@ -38,6 +49,22 @@
  HTTPS_REL_TEST = test_transport_api_reliability_https
  HTTPS_QUOTA_TEST = test_quota_compliance_https \
 		test_quota_compliance_https_asymmetric
+else
+if HAVE_LIBCURL
+ HTTP_API_TEST = test_transport_api_http
+ HTTP_REVERSE_API_TEST = test_transport_api_http_reverse
+ HTTP_API_TIMEOUT_TEST = test_transport_api_timeout_http
+ HTTP_REL_TEST = test_transport_api_reliability_http \
+		 test_transport_api_reliability_http_xhr
+ HTTP_QUOTA_TEST = test_quota_compliance_http \
+		   test_quota_compliance_http_asymmetric
+ HTTPS_API_TEST = test_transport_api_https
+ HTTPS_API_TIMEOUT_TEST = test_transport_api_timeout_https
+ HTTPS_REL_TEST = test_transport_api_reliability_https \
+		  test_transport_api_reliability_https_xhr
+ HTTPS_QUOTA_TEST = test_quota_compliance_https \
+		test_quota_compliance_https_asymmetric
+endif
 endif
 endif
 
@@ -319,7 +346,7 @@
   $(top_builddir)/src/hello/libgnunethello.la \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
   $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
-  @LIBGNURL@ \
+  $(LIB_GNURL) \
   $(top_builddir)/src/nat/libgnunetnat.la \
   $(top_builddir)/src/util/libgnunetutil.la
 libgnunet_plugin_transport_http_client_la_LDFLAGS = \
@@ -327,7 +354,7 @@
 libgnunet_plugin_transport_http_client_la_CFLAGS = \
  $(CFLAGS)
 libgnunet_plugin_transport_http_client_la_CPPFLAGS = \
- @LIBGNURL_CPPFLAGS@ $(AM_CPPFLAGS)
+ $(CPP_GNURL) $(AM_CPPFLAGS)
 
 
 libgnunet_plugin_transport_http_server_la_SOURCES = \
@@ -350,7 +377,7 @@
   $(top_builddir)/src/hello/libgnunethello.la \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
   $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
-  @LIBGNURL@ \
+  $(LIB_GNURL) \
   $(top_builddir)/src/nat/libgnunetnat.la \
   $(top_builddir)/src/util/libgnunetutil.la
 libgnunet_plugin_transport_https_client_la_LDFLAGS = \
@@ -358,7 +385,7 @@
 libgnunet_plugin_transport_https_client_la_CFLAGS = \
  $(CFLAGS) -DBUILD_HTTPS
 libgnunet_plugin_transport_https_client_la_CPPFLAGS = \
- @LIBGNURL_CPPFLAGS@ $(AM_CPPFLAGS)
+ $(CPP_GNURL) $(AM_CPPFLAGS)
 
 
 libgnunet_plugin_transport_https_server_la_SOURCES = \
--- a/src/hostlist/Makefile.am
+++ b/src/hostlist/Makefile.am
@@ -19,6 +19,15 @@
 if HAVE_LIBGNURL
 libexec_PROGRAMS = \
  gnunet-daemon-hostlist
+LIB_GNURL=@LIBGNURL@
+CPP_GNURL=@LIBGNURL_CPPFLAGS@
+else
+if HAVE_LIBCURL
+libexec_PROGRAMS = \
+ gnunet-daemon-hostlist
+LIB_GNURL=@LIBCURL@
+CPP_GNURL=@LIBCURL_CPPFLAGS@
+endif
 endif
 
 gnunet_daemon_hostlist_SOURCES = \
@@ -34,11 +43,12 @@
   $(top_builddir)/src/transport/libgnunettransport.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(GN_LIBMHD) \
-  @LIBGNURL@  \
+  $(LIB_GNURL) \
   $(GN_LIBINTL)
 
 gnunet_daemon_hostlist_CPPFLAGS = \
- @LIBGNURL_CPPFLAGS@  $(AM_CPPFLAGS)
+ $(CPP_GNURL) \
+ $(AM_CPPFLAGS)
 
 if HAVE_LIBGNURL
 check_PROGRAMS = \
--- a/src/gns/Makefile.am
+++ b/src/gns/Makefile.am
@@ -55,6 +55,14 @@
 if HAVE_GNUTLS
 if HAVE_LIBGNURL
   DO_PROXY=gnunet-gns-proxy
+LIB_GNURL=@LIBGNURL@
+CPP_GNURL=@LIBGNURL_CPPFLAGS@
+else
+if HAVE_LIBCURL
+  DO_PROXY=gnunet-gns-proxy
+LIB_GNURL=@LIBCURL@
+CPP_GNURL=@LIBCURL_CPPFLAGS@
+endif
 endif
 endif
 endif
@@ -140,7 +148,8 @@
 
 gnunet_gns_proxy_SOURCES = \
  gnunet-gns-proxy.c
-gnunet_gns_proxy_LDADD = -lmicrohttpd -lgnurl -lgnutls \
+gnunet_gns_proxy_CPPFLAGS = $(AM_CPPFLAGS) $(CPP_GNURL)
+gnunet_gns_proxy_LDADD = -lmicrohttpd $(LIB_GNURL) -lgnutls \
   $(top_builddir)/src/gns/libgnunetgns.la \
   $(top_builddir)/src/identity/libgnunetidentity.la \
   $(top_builddir)/src/util/libgnunetutil.la \
--- a/configure.ac
+++ b/configure.ac
@@ -462,6 +462,27 @@
 	AM_CONDITIONAL(HAVE_LIBGNURL, false)
 fi
 
+# libcurl-gnutls
+LIBCURL_CHECK_CONFIG(,7.34.0,[curl=true],[curl=false])
+if test "x$curl" = xtrue
+then
+ AC_CHECK_HEADERS([curl/curl.h],
+   AC_CHECK_DECLS(CURLINFO_TLS_SESSION,[curl=true],[curl=false],[[#include <curl/curl.h>]]),
+   [curl=false])
+ # need libcurl-gnutls.so, everything else is not acceptable
+ AC_CHECK_LIB([curl-gnutls],[curl_easy_getinfo],,[curl=false])
+ # cURL must support CURLINFO_TLS_SESSION, version >= 7.34
+ 
+fi
+if test x$curl = xfalse
+then
+	AM_CONDITIONAL(HAVE_LIBCURL, false)
+	AC_MSG_WARN([GNUnet requires libcurl-gnutls  >= 7.34])
+else
+	AM_CONDITIONAL(HAVE_LIBCURL, true)
+	AC_DEFINE([HAVE_LIBCURL],[1],[Have CURL])
+fi
+
 
 # libidn
 AC_MSG_CHECKING([if Libidn can be used])
@@ -1538,10 +1559,16 @@
 # libgnurl
 if test "x$gnurl" = "x0"
 then
-  AC_MSG_NOTICE([NOTICE: libgnurl not found.  http client support will not be compiled.])
-  AC_MSG_WARN([libgnurl not found.  hostlist daemon will not be compiled, and you probably WANT hostlist daemon])
+  if test "x$curl" = "x0"
+  then
+    AC_MSG_NOTICE([NOTICE: libgnurl not found.  http client support will not be compiled.])
+    AC_MSG_WARN([ERROR: libgnurl not found.  hostlist daemon will not be compiled, and you probably WANT the hostlist daemon])
+  else
+    AC_MSG_NOTICE([WARNING: libgnurl not found, trying to use libcurl-gnutls instead.])
+  fi
 fi
 
+
 # bluetooth
 if test "x$bluetooth" = "x0"
 then
