-if test -n "$with_openssl"; then
- CPPFLAGS="$CPPFLAGS -I${with_openssl}/include"
- LDFLAGS="$LDFLAGS -L${with_openssl}/lib"
+AC_ARG_WITH(openssl, AC_HELP_STRING([--with-openssl=PATH], [use OpenSSL from PATH]))
+AC_ARG_WITH(gnutls, AC_HELP_STRING([--with-gnutls], [use GnuTLS instead of OpenSSL]),
+ use_gnutls=true, use_gnutls=false)
+AM_CONDITIONAL(USE_GNUTLS, test x$use_gnutls = xtrue)
+
+if $use_gnutls; then
+ AC_CHECK_HEADER(gnutls/gnutls.h, [
+ AC_DEFINE(USE_GNUTLS)
+ AC_CHECK_LIB(gnutls, gnutls_global_init, LIBS="-lgnutls $LIBS")],
+ [GnuTLS is selected, but it is not installed])
+else
+ if test -n "$with_openssl"; then
+ CPPFLAGS="$CPPFLAGS -I${with_openssl}/include"
+ LDFLAGS="$LDFLAGS -L${with_openssl}/lib"
+ fi
+ AC_CHECK_HEADER(openssl/ssl.h, [
+ AC_CHECK_LIB(crypto, BIO_accept, LIBS="-lcrypto $LIBS")
+ AC_CHECK_LIB(ssl, SSL_CTX_new, LIBS="-lssl $LIBS")],
+ AC_MSG_ERROR([OpenSSL not installed - please install first]))