Skip to content

Commit 000979b

Browse files
author
Sebastiano Merlino
committed
gnutls.h is now an optional dependency.
PKG_CHECK_MODULES is now used (instead of simple CHECK_LIB) to find out if libmicrohttpd is installed
1 parent 731bd36 commit 000979b

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

configure.ac

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,14 @@ AC_CHECK_HEADER([regex.h],[],[AC_MSG_ERROR("regex.h not found")])
5858
AC_CHECK_HEADER([sys/stat.h],[],[AC_MSG_ERROR("sys/stat.h not found")])
5959
AC_CHECK_HEADER([sys/types.h],[],[AC_MSG_ERROR("sys/types.h not found")])
6060
AC_CHECK_HEADER([arpa/inet.h],[],[AC_MSG_ERROR("arpa/inet.h not found")])
61-
AC_CHECK_HEADER([gnutls/gnutls.h],[],[AC_MSG_ERROR("gnutls/gnutls.h not found")])
6261
AC_CHECK_HEADER([signal.h],[],[AC_MSG_ERROR("signal.h not found")])
6362

63+
AC_CHECK_HEADER([gnutls/gnutls.h],[have_gnutls="yes"],[AC_MSG_WARN("gnutls/gnutls.h not found. TLS will be disabled"); have_gnutls="no"])
64+
6465
# Checks for libmicrohttpd
65-
#PKG_CHECK_MODULES([LIBMICROHTTPD],[libmicrohttpd >= 0.9.9],[],[AC_MSG_ERROR("libmicrohttpd not present or too old - install libmicrohttpd >= 0.9.9")])
66-
AC_CHECK_HEADER([microhttpd.h],[],[AC_MSG_ERROR("Microhttpd header files not found. Please use a version >= 0.9.9.")])
67-
AC_CHECK_LIB([microhttpd],[MHD_start_daemon],[],[AC_MSG_ERROR("Microhttpd header files not found. Please use a version >= 0.9.9.")])
66+
PKG_CHECK_MODULES([LIBMICROHTTPD],[libmicrohttpd >= 0.9.9],[],[AC_MSG_ERROR("libmicrohttpd not present or too old - install libmicrohttpd >= 0.9.9")])
67+
#AC_CHECK_HEADER([microhttpd.h],[],[AC_MSG_ERROR("Microhttpd header files not found. Please use a version >= 0.9.9.")])
68+
#AC_CHECK_LIB([microhttpd],[MHD_start_daemon],[],[AC_MSG_ERROR("Microhttpd header files not found. Please use a version >= 0.9.9.")])
6869

6970
# Checks for typedefs, structures, and compiler characteristics.
7071
AC_TYPE_SIZE_T
@@ -138,6 +139,10 @@ else
138139
AM_CXXFLAGS="$AM_CXXFLAGS -O3"
139140
fi
140141

142+
if test x"have_gnutls" = x"yes"; then
143+
AM_CXXFLAGS="$AM_CXXFLAGS -DHAVE_GNUTLS"
144+
fi
145+
141146
AC_MSG_CHECKING([whether to use c++0x std classes])
142147
AC_ARG_ENABLE([cpp0x],
143148
[AS_HELP_STRING([--enable-cpp0x],
@@ -378,5 +383,6 @@ AC_MSG_NOTICE([Configuration Summary:
378383
License : LGPL only
379384
Languages : ${LANGUAGES}
380385
Debug : ${debugit}
386+
TLS Enabled : ${have_gnutls}
381387
C++0x : ${cpp0x}
382388
])

src/Webserver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,10 @@ bool Webserver::start(bool blocking)
328328
iov.push_back(gen(MHD_OPTION_HTTPS_PRIORITIES, 0, (void*)httpsPriorities.c_str()));
329329
if(digestAuthRandom != "")
330330
iov.push_back(gen(MHD_OPTION_DIGEST_AUTH_RANDOM, digestAuthRandom.size(), (char*)digestAuthRandom.c_str()));
331+
#ifdef HAVE_GNUTLS
331332
if(credType != HttpUtils::NONE)
332333
iov.push_back(gen(MHD_OPTION_HTTPS_CRED_TYPE, credType));
334+
#endif
333335

334336
iov.push_back(gen(MHD_OPTION_END, 0, NULL ));
335337

src/httpserver/HttpUtils.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
#include <vector>
2828
#include <algorithm>
2929
#include <exception>
30+
#ifdef HAVE_GNUTLS
3031
#include <gnutls/gnutls.h>
32+
#endif
3133

3234
namespace httpserver {
3335
namespace http {
@@ -46,12 +48,14 @@ class HttpUtils
4648

4749
enum CredType_T
4850
{
49-
NONE = -1,
50-
CERTIFICATE = GNUTLS_CRD_CERTIFICATE,
51+
NONE = -1
52+
#ifdef HAVE_GNUTLS
53+
,CERTIFICATE = GNUTLS_CRD_CERTIFICATE,
5154
ANON = GNUTLS_CRD_ANON,
5255
SRP = GNUTLS_CRD_SRP,
5356
PSK = GNUTLS_CRD_PSK,
5457
IA = GNUTLS_CRD_IA
58+
#endif
5559
};
5660

5761
enum StartMethod_T

0 commit comments

Comments
 (0)