2
0

curl-gnutls.m4 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 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. # SPDX-License-Identifier: curl
  22. #
  23. #***************************************************************************
  24. dnl ----------------------------------------------------
  25. dnl check for GnuTLS
  26. dnl ----------------------------------------------------
  27. AC_DEFUN([CURL_WITH_GNUTLS], [
  28. if test "x$OPT_GNUTLS" != xno; then
  29. ssl_msg=
  30. if test X"$OPT_GNUTLS" != Xno; then
  31. addld=""
  32. addlib=""
  33. gtlslib=""
  34. version=""
  35. addcflags=""
  36. if test "x$OPT_GNUTLS" = "xyes"; then
  37. dnl this is with no particular path given
  38. CURL_CHECK_PKGCONFIG(gnutls)
  39. if test "$PKGCONFIG" != "no" ; then
  40. addlib=`$PKGCONFIG --libs-only-l gnutls`
  41. addld=`$PKGCONFIG --libs-only-L gnutls`
  42. addcflags=`$PKGCONFIG --cflags-only-I gnutls`
  43. version=`$PKGCONFIG --modversion gnutls`
  44. gtlslib=`echo $addld | $SED -e 's/^-L//'`
  45. else
  46. dnl without pkg-config, we try libgnutls-config as that was how it
  47. dnl used to be done
  48. check=`libgnutls-config --version 2>/dev/null`
  49. if test -n "$check"; then
  50. addlib=`libgnutls-config --libs`
  51. addcflags=`libgnutls-config --cflags`
  52. version=`libgnutls-config --version`
  53. gtlslib=`libgnutls-config --prefix`/lib$libsuff
  54. fi
  55. fi
  56. else
  57. dnl this is with a given path, first check if there's a libgnutls-config
  58. dnl there and if not, make an educated guess
  59. cfg=$OPT_GNUTLS/bin/libgnutls-config
  60. check=`$cfg --version 2>/dev/null`
  61. if test -n "$check"; then
  62. addlib=`$cfg --libs`
  63. addcflags=`$cfg --cflags`
  64. version=`$cfg --version`
  65. gtlslib=`$cfg --prefix`/lib$libsuff
  66. else
  67. dnl without pkg-config and libgnutls-config, we guess a lot!
  68. addlib=-lgnutls
  69. addld=-L$OPT_GNUTLS/lib$libsuff
  70. addcflags=-I$OPT_GNUTLS/include
  71. version="" # we just don't know
  72. gtlslib=$OPT_GNUTLS/lib$libsuff
  73. fi
  74. fi
  75. if test -z "$version"; then
  76. dnl lots of efforts, still no go
  77. version="unknown"
  78. fi
  79. if test -n "$addlib"; then
  80. CLEANLIBS="$LIBS"
  81. CLEANCPPFLAGS="$CPPFLAGS"
  82. CLEANLDFLAGS="$LDFLAGS"
  83. CLEANLDFLAGSPC="$LDFLAGSPC"
  84. LIBS="$addlib $LIBS"
  85. LDFLAGS="$LDFLAGS $addld"
  86. LDFLAGSPC="$LDFLAGSPC $addld"
  87. if test "$addcflags" != "-I/usr/include"; then
  88. CPPFLAGS="$CPPFLAGS $addcflags"
  89. fi
  90. dnl this function is selected since it was introduced in 3.1.10
  91. AC_CHECK_LIB(gnutls, gnutls_x509_crt_get_dn2,
  92. [
  93. AC_DEFINE(USE_GNUTLS, 1, [if GnuTLS is enabled])
  94. GNUTLS_ENABLED=1
  95. USE_GNUTLS="yes"
  96. ssl_msg="GnuTLS"
  97. QUIC_ENABLED=yes
  98. test gnutls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
  99. ],
  100. [
  101. LIBS="$CLEANLIBS"
  102. CPPFLAGS="$CLEANCPPFLAGS"
  103. ])
  104. if test "x$USE_GNUTLS" = "xyes"; then
  105. AC_MSG_NOTICE([detected GnuTLS version $version])
  106. check_for_ca_bundle=1
  107. if test -n "$gtlslib"; then
  108. dnl when shared libs were found in a path that the run-time
  109. dnl linker doesn't search through, we need to add it to
  110. dnl CURL_LIBRARY_PATH to prevent further configure tests to fail
  111. dnl due to this
  112. if test "x$cross_compiling" != "xyes"; then
  113. CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$gtlslib"
  114. export CURL_LIBRARY_PATH
  115. AC_MSG_NOTICE([Added $gtlslib to CURL_LIBRARY_PATH])
  116. fi
  117. fi
  118. LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE gnutls nettle"
  119. fi
  120. fi
  121. fi dnl GNUTLS not disabled
  122. test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
  123. fi
  124. dnl ---
  125. dnl Check which crypto backend GnuTLS uses
  126. dnl ---
  127. if test "$GNUTLS_ENABLED" = "1"; then
  128. USE_GNUTLS_NETTLE=
  129. # First check if we can detect either crypto library via transitive linking
  130. AC_CHECK_LIB(gnutls, nettle_MD5Init, [ USE_GNUTLS_NETTLE=1 ])
  131. # If not, try linking directly to both of them to see if they are available
  132. if test "$USE_GNUTLS_NETTLE" = ""; then
  133. AC_CHECK_LIB(nettle, nettle_MD5Init, [ USE_GNUTLS_NETTLE=1 ])
  134. fi
  135. if test "$USE_GNUTLS_NETTLE" = ""; then
  136. AC_MSG_ERROR([GnuTLS found, but nettle was not found])
  137. fi
  138. LIBS="-lnettle $LIBS"
  139. fi
  140. dnl ---
  141. dnl We require GnuTLS with SRP support.
  142. dnl ---
  143. if test "$GNUTLS_ENABLED" = "1"; then
  144. AC_CHECK_LIB(gnutls, gnutls_srp_verifier,
  145. [
  146. AC_DEFINE(HAVE_GNUTLS_SRP, 1, [if you have the function gnutls_srp_verifier])
  147. HAVE_GNUTLS_SRP=1
  148. ])
  149. fi
  150. ])