1#*************************************************************************** 2# _ _ ____ _ 3# Project ___| | | | _ \| | 4# / __| | | | |_) | | 5# | (__| |_| | _ <| |___ 6# \___|\___/|_| \_\_____| 7# 8# Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al. 9# 10# This software is licensed as described in the file COPYING, which 11# you should have received as part of this distribution. The terms 12# are also available at https://curl.se/docs/copyright.html. 13# 14# You may opt to use, copy, modify, merge, publish, distribute and/or sell 15# copies of the Software, and permit persons to whom the Software is 16# furnished to do so, under the terms of the COPYING file. 17# 18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 19# KIND, either express or implied. 20# 21#*************************************************************************** 22 23dnl ---------------------------------------------------- 24dnl check for GnuTLS 25dnl ---------------------------------------------------- 26 27AC_DEFUN([CURL_WITH_GNUTLS], [ 28if test "x$OPT_GNUTLS" != xno; then 29 ssl_msg= 30 31 if test X"$OPT_GNUTLS" != Xno; then 32 33 addld="" 34 addlib="" 35 gtlslib="" 36 version="" 37 addcflags="" 38 39 if test "x$OPT_GNUTLS" = "xyes"; then 40 dnl this is with no partiular path given 41 CURL_CHECK_PKGCONFIG(gnutls) 42 43 if test "$PKGCONFIG" != "no" ; then 44 addlib=`$PKGCONFIG --libs-only-l gnutls` 45 addld=`$PKGCONFIG --libs-only-L gnutls` 46 addcflags=`$PKGCONFIG --cflags-only-I gnutls` 47 version=`$PKGCONFIG --modversion gnutls` 48 gtlslib=`echo $addld | $SED -e 's/^-L//'` 49 else 50 dnl without pkg-config, we try libgnutls-config as that was how it 51 dnl used to be done 52 check=`libgnutls-config --version 2>/dev/null` 53 if test -n "$check"; then 54 addlib=`libgnutls-config --libs` 55 addcflags=`libgnutls-config --cflags` 56 version=`libgnutls-config --version` 57 gtlslib=`libgnutls-config --prefix`/lib$libsuff 58 fi 59 fi 60 else 61 dnl this is with a given path, first check if there's a libgnutls-config 62 dnl there and if not, make an educated guess 63 cfg=$OPT_GNUTLS/bin/libgnutls-config 64 check=`$cfg --version 2>/dev/null` 65 if test -n "$check"; then 66 addlib=`$cfg --libs` 67 addcflags=`$cfg --cflags` 68 version=`$cfg --version` 69 gtlslib=`$cfg --prefix`/lib$libsuff 70 else 71 dnl without pkg-config and libgnutls-config, we guess a lot! 72 addlib=-lgnutls 73 addld=-L$OPT_GNUTLS/lib$libsuff 74 addcflags=-I$OPT_GNUTLS/include 75 version="" # we just don't know 76 gtlslib=$OPT_GNUTLS/lib$libsuff 77 fi 78 fi 79 80 if test -z "$version"; then 81 dnl lots of efforts, still no go 82 version="unknown" 83 fi 84 85 if test -n "$addlib"; then 86 87 CLEANLIBS="$LIBS" 88 CLEANCPPFLAGS="$CPPFLAGS" 89 CLEANLDFLAGS="$LDFLAGS" 90 91 LIBS="$addlib $LIBS" 92 LDFLAGS="$LDFLAGS $addld" 93 if test "$addcflags" != "-I/usr/include"; then 94 CPPFLAGS="$CPPFLAGS $addcflags" 95 fi 96 97 dnl this function is selected since it was introduced in 3.1.10 98 AC_CHECK_LIB(gnutls, gnutls_x509_crt_get_dn2, 99 [ 100 AC_DEFINE(USE_GNUTLS, 1, [if GnuTLS is enabled]) 101 AC_SUBST(USE_GNUTLS, [1]) 102 GNUTLS_ENABLED=1 103 USE_GNUTLS="yes" 104 ssl_msg="GnuTLS" 105 test gnutls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes 106 ], 107 [ 108 LIBS="$CLEANLIBS" 109 CPPFLAGS="$CLEANCPPFLAGS" 110 ]) 111 112 if test "x$USE_GNUTLS" = "xyes"; then 113 AC_MSG_NOTICE([detected GnuTLS version $version]) 114 check_for_ca_bundle=1 115 if test -n "$gtlslib"; then 116 dnl when shared libs were found in a path that the run-time 117 dnl linker doesn't search through, we need to add it to 118 dnl CURL_LIBRARY_PATH to prevent further configure tests to fail 119 dnl due to this 120 if test "x$cross_compiling" != "xyes"; then 121 CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$gtlslib" 122 export CURL_LIBRARY_PATH 123 AC_MSG_NOTICE([Added $gtlslib to CURL_LIBRARY_PATH]) 124 fi 125 fi 126 fi 127 128 fi 129 130 fi dnl GNUTLS not disabled 131 132 test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg" 133fi 134 135dnl --- 136dnl Check which crypto backend GnuTLS uses 137dnl --- 138 139if test "$GNUTLS_ENABLED" = "1"; then 140 USE_GNUTLS_NETTLE= 141 # First check if we can detect either crypto library via transitive linking 142 AC_CHECK_LIB(gnutls, nettle_MD5Init, [ USE_GNUTLS_NETTLE=1 ]) 143 144 # If not, try linking directly to both of them to see if they are available 145 if test "$USE_GNUTLS_NETTLE" = ""; then 146 AC_CHECK_LIB(nettle, nettle_MD5Init, [ USE_GNUTLS_NETTLE=1 ]) 147 fi 148 if test "$USE_GNUTLS_NETTLE" = ""; then 149 AC_MSG_ERROR([GnuTLS found, but nettle was not found]) 150 fi 151 LIBS="-lnettle $LIBS" 152fi 153 154dnl --- 155dnl We require GnuTLS with SRP support. 156dnl --- 157if test "$GNUTLS_ENABLED" = "1"; then 158 AC_CHECK_LIB(gnutls, gnutls_srp_verifier, 159 [ 160 AC_DEFINE(HAVE_GNUTLS_SRP, 1, [if you have the function gnutls_srp_verifier]) 161 AC_SUBST(HAVE_GNUTLS_SRP, [1]) 162 ]) 163fi 164 165]) 166