curl-rustls.m4 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. AC_DEFUN([CURL_WITH_RUSTLS], [
  23. dnl ----------------------------------------------------
  24. dnl check for rustls
  25. dnl ----------------------------------------------------
  26. if test "x$OPT_RUSTLS" != xno; then
  27. _cppflags=$CPPFLAGS
  28. _ldflags=$LDFLAGS
  29. ssl_msg=
  30. if test X"$OPT_RUSTLS" != Xno; then
  31. if test "$OPT_RUSTLS" = "yes"; then
  32. OPT_RUSTLS=""
  33. fi
  34. if test -z "$OPT_RUSTLS" ; then
  35. dnl check for lib first without setting any new path
  36. AC_CHECK_LIB(rustls, rustls_client_session_read,
  37. dnl librustls found, set the variable
  38. [
  39. AC_DEFINE(USE_RUSTLS, 1, [if rustls is enabled])
  40. AC_SUBST(USE_RUSTLS, [1])
  41. RUSTLS_ENABLED=1
  42. USE_RUSTLS="yes"
  43. ssl_msg="rustls"
  44. test rustls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
  45. ], [], -lpthread -ldl -lm)
  46. fi
  47. if test "x$USE_RUSTLS" != "xyes"; then
  48. dnl add the path and test again
  49. addld=-L$OPT_RUSTLS/lib$libsuff
  50. addcflags=-I$OPT_RUSTLS/include
  51. rustlslib=$OPT_RUSTLS/lib$libsuff
  52. LDFLAGS="$LDFLAGS $addld"
  53. if test "$addcflags" != "-I/usr/include"; then
  54. CPPFLAGS="$CPPFLAGS $addcflags"
  55. fi
  56. AC_CHECK_LIB(rustls, rustls_connection_read,
  57. [
  58. AC_DEFINE(USE_RUSTLS, 1, [if rustls is enabled])
  59. AC_SUBST(USE_RUSTLS, [1])
  60. RUSTLS_ENABLED=1
  61. USE_RUSTLS="yes"
  62. ssl_msg="rustls"
  63. test rustls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
  64. ],
  65. AC_MSG_ERROR([--with-rustls was specified but could not find rustls.]),
  66. -lpthread -ldl -lm)
  67. fi
  68. if test "x$USE_RUSTLS" = "xyes"; then
  69. AC_MSG_NOTICE([detected rustls])
  70. check_for_ca_bundle=1
  71. LIBS="-lrustls -lpthread -ldl -lm $LIBS"
  72. if test -n "$rustlslib"; then
  73. dnl when shared libs were found in a path that the run-time
  74. dnl linker doesn't search through, we need to add it to
  75. dnl CURL_LIBRARY_PATH to prevent further configure tests to fail
  76. dnl due to this
  77. if test "x$cross_compiling" != "xyes"; then
  78. CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$rustlslib"
  79. export CURL_LIBRARY_PATH
  80. AC_MSG_NOTICE([Added $rustlslib to CURL_LIBRARY_PATH])
  81. fi
  82. fi
  83. fi
  84. fi dnl rustls not disabled
  85. test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
  86. fi
  87. ])