curl-rustls.m4 3.5 KB

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