2
0

curl-rustls.m4 3.3 KB

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