Make gnurl and curl mutually exclusive.
authorFlorian Dold <florian.dold@gmail.com>
Tue, 30 Apr 2019 18:46:17 +0000 (20:46 +0200)
committerFlorian Dold <florian.dold@gmail.com>
Tue, 30 Apr 2019 18:48:23 +0000 (20:48 +0200)
This prevents issues when both curl and gnurl are available, but one of
them is outdated.

To get curl.h, we also now just include gnunet_curl_lib.h instead of
writing the preprocessor conditionals manually.

Fixes #5707

configure.ac
src/curl/curl.c
src/gns/gnunet-gns-proxy.c
src/gns/test_gns_proxy.c
src/hostlist/gnunet-daemon-hostlist_client.c
src/include/gnunet_curl_lib.h
src/pt/test_gns_vpn.c
src/pt/test_gnunet_vpn.c
src/transport/plugin_transport_http.h
src/transport/plugin_transport_http_client.c

index a9845d20208d63675e973f0abfcc76d75b5c0ebf..e00b8ae1b85f0518cd78567739ab0678a7fd23ac 100644 (file)
@@ -763,14 +763,6 @@ fi
 
 # libgnurl
 LIBGNURL_CHECK_CONFIG(,7.34.0,gnurl=1,gnurl=0)
-if test "$gnurl" = 1
-then
-       AM_CONDITIONAL(HAVE_LIBGNURL, true)
-       AC_DEFINE([HAVE_LIBGNURL],[1],[Have libgnurl])
-else
-       AM_CONDITIONAL(HAVE_LIBGNURL, false)
-       AC_DEFINE([HAVE_LIBGNURL],[0],[Lacking libgnurl])
-fi
 
 SAVE_CPPFLAGS=$CPPFLAGS
 CPPFLAGS="$LIBGNURL_CPPFLAGS $LIBCURL_CPPFLAGS $CPPFLAGS"
@@ -780,38 +772,30 @@ LIBS="$LIBGNURL $LIBCURL $LIBS"
 LIBCURL_CHECK_CONFIG(,7.34.0,[curl=true],[curl=false])
 if test "x$curl" = xtrue
 then
-
- AC_CHECK_HEADERS([curl/curl.h],
+ AC_CHECK_HEADER([curl/curl.h],
   AC_CHECK_DECLS(CURLINFO_TLS_SESSION,[curl=true],[curl=false],[[#include <curl/curl.h>]]),
   [curl=false])
- AC_CHECK_HEADERS([gnurl/curl.h],
-  AC_CHECK_DECLS(CURLINFO_TLS_SESSION,[curl=true],,[[#include <gnurl/curl.h>]]))
  # 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
 
-# Check for curl/curl.h and gnurl/curl.h so we can use #ifdef
-# HAVE_CURL_CURL_H later (the above LIBCURL_CHECK_CONFIG accepted
-# *either* header set).
-AC_CHECK_HEADERS([curl/curl.h],,
-  curl=false
-  AC_CHECK_HEADERS([gnurl/curl.h],,
-  gnurl=false))
-
-
-
-if test x$curl = xfalse
-then
-       AM_CONDITIONAL(HAVE_LIBCURL, false)
-if test "$gnurl" = 0
-then
-       AC_MSG_WARN([ERROR: GNUnet requires libcurl-gnutls or gnurl >= 7.34])
-fi
-else
-       AM_CONDITIONAL(HAVE_LIBCURL, true)
-       AC_DEFINE([HAVE_LIBCURL],[1],[Have CURL])
-fi
+# libcurl and libgnurl should be mutually exclusive
+AS_IF([test "$gnurl" = 1],
+      [AM_CONDITIONAL(HAVE_LIBGNURL, true)
+       AC_DEFINE([HAVE_LIBGNURL],[1],[Have libgnurl])
+       AM_CONDITIONAL(HAVE_LIBCURL, false)
+       AC_DEFINE([HAVE_LIBCURL],[0],[Lacking libcurl])],
+      [AS_IF([test "$curl" = true],
+             [AM_CONDITIONAL(HAVE_LIBGNURL, false)
+              AC_DEFINE([HAVE_LIBGNURL],[0],[Lacking libgnurl])
+              AM_CONDITIONAL(HAVE_LIBCURL, true)
+              AC_DEFINE([HAVE_LIBCURL],[1],[Have libcurl])],
+             [AC_MSG_WARN([ERROR: GNUnet requires libcurl-gnutls or gnurl >= 7.34])
+              AM_CONDITIONAL(HAVE_LIBGNURL, false)
+              AC_DEFINE([HAVE_LIBGNURL],[0],[Lacking libgnurl])
+              AM_CONDITIONAL(HAVE_LIBCURL, false)
+              AC_DEFINE([HAVE_LIBCURL],[0],[Lacking libcurl])])])
 
 AC_SEARCH_LIBS(__atomic_load_8, atomic, [have_libatomic=1 AC_DEFINE(HAVE_LIBATOMIC,1,[external libatomic])])
 AM_CONDITIONAL(HAVE_LIBATOMIC, [test "$have_libatomic" = 1])
index 10475fe2e74c91f5d0da62fc2a6bc74bfd98a21c..5e1c216abb18c7cb0398eb044b9e07d54d34c843 100644 (file)
  * @author Christian Grothoff
  */
 #include "platform.h"
-#if HAVE_CURL_CURL_H
-#include <curl/curl.h>
-#elif HAVE_GNURL_CURL_H
-#include <gnurl/curl.h>
-#endif
 #include <jansson.h>
 #include "gnunet_curl_lib.h"
 
index bae222499b3ecf4f2cd84bfb035ed131ca820a71..eb811502605cbafe3129871b220bbf28bad2824b 100644 (file)
  */
 #include "platform.h"
 #include <microhttpd.h>
-#if HAVE_CURL_CURL_H
-#include <curl/curl.h>
-#elif HAVE_GNURL_CURL_H
-#include <gnurl/curl.h>
-#endif
+/* Just included for the right curl.h */
+#include "gnunet_curl_lib.h"
 #include <gnutls/gnutls.h>
 #include <gnutls/x509.h>
 #include <gnutls/abstract.h>
index 2a7f8104bbc1940207adbb5933a35b72aa3dac52..053f5f898cf3cc2024a51004de410652c43819a5 100644 (file)
  * @author Martin Schanzenbach
  */
 #include "platform.h"
-#if HAVE_CURL_CURL_H
-#include <curl/curl.h>
-#elif HAVE_GNURL_CURL_H
-#include <gnurl/curl.h>
-#endif
+/* Just included for the right curl.h */
+#include "gnunet_curl_lib.h"
 #include <microhttpd.h>
 #include "gnunet_util_lib.h"
 #include "gnutls/x509.h"
index f15cda2f3e7bec48e6bf260f1fdb040d3409ab8a..539760966fa4bd75b20448af149a345651572649 100644 (file)
 #include "gnunet_transport_service.h"
 #include "gnunet_peerinfo_service.h"
 #include "gnunet-daemon-hostlist.h"
-#if HAVE_CURL_CURL_H
-#include <curl/curl.h>
-#elif HAVE_GNURL_CURL_H
-#include <gnurl/curl.h>
-#endif
+/* Just included for the right curl.h */
+#include "gnunet_curl_lib.h"
 
 
 
index 0cbef9c73702de8a0a3cf495671282e7ef52803d..86cb54f6b8ff31cfc9bc4dec240240bc23028354 100644 (file)
@@ -29,9 +29,9 @@
  */
 #ifndef GNUNET_CURL_LIB_H
 #define GNUNET_CURL_LIB_H
-#if HAVE_CURL_CURL_H
+#if HAVE_LIBCURL
 #include <curl/curl.h>
-#elif HAVE_GNURL_CURL_H
+#elif HAVE_LIBGNURL
 #include <gnurl/curl.h>
 #else
 #error "needs curl or gnurl"
index 069277a00afa20721d05efc2cb58f0765326c0eb..90405fe3731ac5aac224e0639c0f4acc43e626f1 100644 (file)
  * you should get a warning that gnunet-dns2gns failed to 'bind'.
  */
 #include "platform.h"
-#if HAVE_CURL_CURL_H
-#include <curl/curl.h>
-#elif HAVE_GNURL_CURL_H
-#include <gnurl/curl.h>
-#endif
+/* Just included for the right curl.h */
+#include "gnunet_curl_lib.h"
 #include <microhttpd.h>
 #include "gnunet_identity_service.h"
 #include "gnunet_namestore_service.h"
index 0afd0f94b22aee630b660a882db1fa95f5e46517..7cc77fe2445d1a6903192eb3c83e47b6bb168d22 100644 (file)
  * @author Christian Grothoff
  */
 #include "platform.h"
-#if HAVE_CURL_CURL_H
-#include <curl/curl.h>
-#elif HAVE_GNURL_CURL_H
-#include <gnurl/curl.h>
-#endif
+/* Just included for the right curl.h */
+#include "gnunet_curl_lib.h"
 #include <microhttpd.h>
 #include "gnunet_vpn_service.h"
 #include "gnunet_testing_lib.h"
index 6867d3b9d31b5c3bc231404b288a7d46967823df..b6ada8f86d68bdea13f3ba51862266b148f1c44a 100644 (file)
 #include "gnunet_os_lib.h"
 #include "gnunet_nat_lib.h"
 #include "microhttpd.h"
-#if HAVE_CURL_CURL_H
-#include <curl/curl.h>
-#elif HAVE_GNURL_CURL_H
-#include <gnurl/curl.h>
-#endif
+/* Just included for the right curl.h */
+#include "gnunet_curl_lib.h"
 
 
 #define DEBUG_HTTP GNUNET_EXTRA_LOGGING
index 3c8dc21e5589a01d96fd3486a78bdbe87a1735ef..c4d70d4c364ae6209499b00fc0920604990f51c3 100644 (file)
 #include "gnunet_protocols.h"
 #include "gnunet_transport_plugin.h"
 #include "plugin_transport_http_common.h"
-#if HAVE_CURL_CURL_H
-#include <curl/curl.h>
-#elif HAVE_GNURL_CURL_H
-#include <gnurl/curl.h>
-#endif
+/* Just included for the right curl.h */
+#include "gnunet_curl_lib.h"
 
 
 #define LOG(kind,...) GNUNET_log_from(kind, PLUGIN_NAME, __VA_ARGS__)