curl-nss.m4 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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_NSS], [
  23. if test "x$OPT_NSS" != xno; then
  24. ssl_msg=
  25. if test X"$OPT_NSS" != Xno; then
  26. addld=""
  27. addlib=""
  28. addcflags=""
  29. nssprefix=""
  30. version=""
  31. if test "x$OPT_NSS" = "xyes"; then
  32. CURL_CHECK_PKGCONFIG(nss)
  33. if test "$PKGCONFIG" != "no" ; then
  34. addlib=`$PKGCONFIG --libs nss`
  35. addcflags=`$PKGCONFIG --cflags nss`
  36. version=`$PKGCONFIG --modversion nss`
  37. nssprefix=`$PKGCONFIG --variable=prefix nss`
  38. else
  39. dnl Without pkg-config, we check for nss-config
  40. check=`nss-config --version 2>/dev/null`
  41. if test -n "$check"; then
  42. addlib=`nss-config --libs`
  43. addcflags=`nss-config --cflags`
  44. version=`nss-config --version`
  45. nssprefix=`nss-config --prefix`
  46. else
  47. addlib="-lnss3"
  48. addcflags=""
  49. version="unknown"
  50. fi
  51. fi
  52. else
  53. NSS_PCDIR="$OPT_NSS/lib/pkgconfig"
  54. if test -f "$NSS_PCDIR/nss.pc"; then
  55. CURL_CHECK_PKGCONFIG(nss, [$NSS_PCDIR])
  56. if test "$PKGCONFIG" != "no" ; then
  57. addld=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --libs-only-L nss`
  58. addlib=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --libs-only-l nss`
  59. addcflags=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --cflags nss`
  60. version=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --modversion nss`
  61. nssprefix=`CURL_EXPORT_PCDIR([$NSS_PCDIR]) $PKGCONFIG --variable=prefix nss`
  62. fi
  63. fi
  64. fi
  65. if test -z "$addlib"; then
  66. # Without pkg-config, we'll kludge in some defaults
  67. AC_MSG_WARN([Using hard-wired libraries and compilation flags for NSS.])
  68. addld="-L$OPT_NSS/lib"
  69. addlib="-lssl3 -lsmime3 -lnss3 -lplds4 -lplc4 -lnspr4"
  70. addcflags="-I$OPT_NSS/include"
  71. version="unknown"
  72. nssprefix=$OPT_NSS
  73. fi
  74. CLEANLDFLAGS="$LDFLAGS"
  75. CLEANLIBS="$LIBS"
  76. CLEANCPPFLAGS="$CPPFLAGS"
  77. LDFLAGS="$addld $LDFLAGS"
  78. LIBS="$addlib $LIBS"
  79. if test "$addcflags" != "-I/usr/include"; then
  80. CPPFLAGS="$CPPFLAGS $addcflags"
  81. fi
  82. dnl The function SSL_VersionRangeSet() is needed to enable TLS > 1.0
  83. AC_CHECK_LIB(nss3, SSL_VersionRangeSet,
  84. [
  85. AC_DEFINE(USE_NSS, 1, [if NSS is enabled])
  86. AC_SUBST(USE_NSS, [1])
  87. USE_NSS="yes"
  88. NSS_ENABLED=1
  89. ssl_msg="NSS"
  90. test nss != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
  91. ],
  92. [
  93. LDFLAGS="$CLEANLDFLAGS"
  94. LIBS="$CLEANLIBS"
  95. CPPFLAGS="$CLEANCPPFLAGS"
  96. ])
  97. if test "x$USE_NSS" = "xyes"; then
  98. AC_MSG_NOTICE([detected NSS version $version])
  99. dnl PK11_CreateManagedGenericObject() was introduced in NSS 3.34 because
  100. dnl PK11_DestroyGenericObject() does not release resources allocated by
  101. dnl PK11_CreateGenericObject() early enough.
  102. AC_CHECK_FUNC(PK11_CreateManagedGenericObject,
  103. [
  104. AC_DEFINE(HAVE_PK11_CREATEMANAGEDGENERICOBJECT, 1,
  105. [if you have the PK11_CreateManagedGenericObject function])
  106. ])
  107. dnl needed when linking the curl tool without USE_EXPLICIT_LIB_DEPS
  108. NSS_LIBS=$addlib
  109. AC_SUBST([NSS_LIBS])
  110. dnl when shared libs were found in a path that the run-time
  111. dnl linker doesn't search through, we need to add it to
  112. dnl CURL_LIBRARY_PATH to prevent further configure tests to fail
  113. dnl due to this
  114. if test "x$cross_compiling" != "xyes"; then
  115. CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$nssprefix/lib$libsuff"
  116. export CURL_LIBRARY_PATH
  117. AC_MSG_NOTICE([Added $nssprefix/lib$libsuff to CURL_LIBRARY_PATH])
  118. fi
  119. fi dnl NSS found
  120. fi dnl NSS not disabled
  121. test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
  122. fi
  123. ])