curl-openssl.m4 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 1998 - 2020, 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.haxx.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. # File version for 'aclocal' use. Keep it a single number.
  23. # serial 5
  24. dnl CURL_CHECK_OPENSSL_API_HEADERS
  25. dnl -------------------------------------------------
  26. dnl Find out OpenSSL headers API version, as reported
  27. dnl by OPENSSL_VERSION_NUMBER. No runtime checks
  28. dnl allowed here for cross-compilation support.
  29. dnl HAVE_OPENSSL_API_HEADERS is defined as appropriate
  30. dnl only for systems which actually run the configure
  31. dnl script. Config files generated manually or in any
  32. dnl other way shall not define this.
  33. AC_DEFUN([CURL_CHECK_OPENSSL_API_HEADERS], [
  34. #
  35. tst_api="unknown"
  36. #
  37. AC_MSG_CHECKING([for OpenSSL headers version])
  38. CURL_CHECK_DEF([OPENSSL_VERSION_NUMBER], [
  39. # ifdef USE_OPENSSL
  40. # include <openssl/crypto.h>
  41. # else
  42. # include <crypto.h>
  43. # endif
  44. ], [silent])
  45. if test "$curl_cv_have_def_OPENSSL_VERSION_NUMBER" = "yes"; then
  46. tst_verlen=`expr "$curl_cv_def_OPENSSL_VERSION_NUMBER" : '.*'`
  47. case "x$tst_verlen" in
  48. x6)
  49. tst_vermaj=`echo $curl_cv_def_OPENSSL_VERSION_NUMBER | cut -c 3`
  50. tst_vermin=`echo $curl_cv_def_OPENSSL_VERSION_NUMBER | cut -c 4`
  51. tst_verfix=`echo $curl_cv_def_OPENSSL_VERSION_NUMBER | cut -c 5`
  52. tst_api=0x$tst_vermaj$tst_vermin$tst_verfix
  53. ;;
  54. x11|x10)
  55. tst_vermaj=`echo $curl_cv_def_OPENSSL_VERSION_NUMBER | cut -c 3`
  56. tst_vermin=`echo $curl_cv_def_OPENSSL_VERSION_NUMBER | cut -c 5`
  57. tst_verfix=`echo $curl_cv_def_OPENSSL_VERSION_NUMBER | cut -c 7`
  58. tst_api=0x$tst_vermaj$tst_vermin$tst_verfix
  59. ;;
  60. *)
  61. tst_api="unknown"
  62. ;;
  63. esac
  64. case $tst_api in
  65. 0x111) tst_show="1.1.1" ;;
  66. 0x110) tst_show="1.1.0" ;;
  67. 0x102) tst_show="1.0.2" ;;
  68. 0x101) tst_show="1.0.1" ;;
  69. 0x100) tst_show="1.0.0" ;;
  70. 0x099) tst_show="0.9.9" ;;
  71. 0x098) tst_show="0.9.8" ;;
  72. 0x097) tst_show="0.9.7" ;;
  73. 0x096) tst_show="0.9.6" ;;
  74. 0x095) tst_show="0.9.5" ;;
  75. 0x094) tst_show="0.9.4" ;;
  76. 0x093) tst_show="0.9.3" ;;
  77. 0x092) tst_show="0.9.2" ;;
  78. 0x091) tst_show="0.9.1" ;;
  79. *) tst_show="unknown" ;;
  80. esac
  81. tst_show="$tst_show - $curl_cv_def_OPENSSL_VERSION_NUMBER"
  82. else
  83. tst_show="unknown"
  84. fi
  85. AC_MSG_RESULT([$tst_show])
  86. #
  87. dnl if test "$tst_api" != "unknown"; then
  88. dnl AC_DEFINE_UNQUOTED(HAVE_OPENSSL_API_HEADERS, $tst_api,
  89. dnl [OpenSSL headers configure time API. Defined only by configure script.
  90. dnl No matter what, do not ever define this manually or by any other means.])
  91. dnl fi
  92. curl_openssl_api_headers=$tst_api
  93. ])
  94. dnl CURL_CHECK_OPENSSL_API_LIBRARY
  95. dnl -------------------------------------------------
  96. dnl Find out OpenSSL library API version, performing
  97. dnl only link tests in order to avoid getting fooled
  98. dnl by mismatched OpenSSL headers. No runtime checks
  99. dnl allowed here for cross-compilation support.
  100. dnl HAVE_OPENSSL_API_LIBRARY is defined as appropriate
  101. dnl only for systems which actually run the configure
  102. dnl script. Config files generated manually or in any
  103. dnl other way shall not define this.
  104. dnl
  105. dnl Most probably we should not bother attempting to
  106. dnl detect OpenSSL library development API versions
  107. dnl 0.9.9 and 1.1.0. For our intended use, detecting
  108. dnl released versions should be good enough.
  109. dnl
  110. dnl Given that currently we are not using the result
  111. dnl of this check, except for informative purposes,
  112. dnl lets try to figure out everything.
  113. AC_DEFUN([CURL_CHECK_OPENSSL_API_LIBRARY], [
  114. #
  115. tst_api="unknown"
  116. #
  117. AC_MSG_CHECKING([for OpenSSL library version])
  118. if test "$tst_api" = "unknown"; then
  119. AC_LINK_IFELSE([
  120. AC_LANG_FUNC_LINK_TRY([ERR_clear_last_mark])
  121. ],[
  122. tst_api="0x111"
  123. ])
  124. fi
  125. if test "$tst_api" = "unknown"; then
  126. case $host in
  127. *-*-vms*)
  128. AC_LINK_IFELSE([
  129. AC_LANG_FUNC_LINK_TRY([SSL_CTX_set_not_resumbl_sess_cb])
  130. ],[
  131. tst_api="0x110"
  132. ])
  133. ;;
  134. *)
  135. AC_LINK_IFELSE([
  136. AC_LANG_FUNC_LINK_TRY([SSL_CTX_set_not_resumable_session_callback])
  137. ],[
  138. tst_api="0x110"
  139. ])
  140. ;;
  141. esac
  142. fi
  143. if test "$tst_api" = "unknown"; then
  144. AC_LINK_IFELSE([
  145. AC_LANG_FUNC_LINK_TRY([SSL_CONF_CTX_new])
  146. ],[
  147. tst_api="0x102"
  148. ])
  149. fi
  150. if test "$tst_api" = "unknown"; then
  151. AC_LINK_IFELSE([
  152. AC_LANG_FUNC_LINK_TRY([SSL_renegotiate_abbreviated])
  153. ],[
  154. tst_api="0x101"
  155. ])
  156. fi
  157. if test "$tst_api" = "unknown"; then
  158. AC_LINK_IFELSE([
  159. AC_LANG_FUNC_LINK_TRY([OBJ_add_sigid])
  160. ],[
  161. tst_api="0x100"
  162. ])
  163. fi
  164. if test "$tst_api" = "unknown"; then
  165. AC_LINK_IFELSE([
  166. AC_LANG_FUNC_LINK_TRY([ERR_set_mark])
  167. ],[
  168. tst_api="0x098"
  169. ])
  170. fi
  171. if test "$tst_api" = "unknown"; then
  172. AC_LINK_IFELSE([
  173. AC_LANG_FUNC_LINK_TRY([ERR_peek_last_error])
  174. ],[
  175. tst_api="0x097"
  176. ])
  177. fi
  178. if test "$tst_api" = "unknown"; then
  179. AC_LINK_IFELSE([
  180. AC_LANG_FUNC_LINK_TRY([c2i_ASN1_OBJECT])
  181. ],[
  182. tst_api="0x096"
  183. ])
  184. fi
  185. if test "$tst_api" = "unknown"; then
  186. AC_LINK_IFELSE([
  187. AC_LANG_FUNC_LINK_TRY([SSL_CTX_set_purpose])
  188. ],[
  189. tst_api="0x095"
  190. ])
  191. fi
  192. if test "$tst_api" = "unknown"; then
  193. AC_LINK_IFELSE([
  194. AC_LANG_FUNC_LINK_TRY([OBJ_obj2txt])
  195. ],[
  196. tst_api="0x094"
  197. ])
  198. fi
  199. if test "$tst_api" = "unknown"; then
  200. AC_LINK_IFELSE([
  201. AC_LANG_FUNC_LINK_TRY([SSL_get_verify_depth])
  202. ],[
  203. tst_api="0x093"
  204. ])
  205. fi
  206. if test "$tst_api" = "unknown"; then
  207. AC_LINK_IFELSE([
  208. AC_LANG_FUNC_LINK_TRY([SSL_library_init])
  209. ],[
  210. tst_api="0x092"
  211. ])
  212. fi
  213. if test "$tst_api" = "unknown"; then
  214. AC_LINK_IFELSE([
  215. AC_LANG_FUNC_LINK_TRY([SSL_CTX_set_cipher_list])
  216. ],[
  217. tst_api="0x091"
  218. ])
  219. fi
  220. case $tst_api in
  221. 0x111) tst_show="1.1.1" ;;
  222. 0x110) tst_show="1.1.0" ;;
  223. 0x102) tst_show="1.0.2" ;;
  224. 0x101) tst_show="1.0.1" ;;
  225. 0x100) tst_show="1.0.0" ;;
  226. 0x099) tst_show="0.9.9" ;;
  227. 0x098) tst_show="0.9.8" ;;
  228. 0x097) tst_show="0.9.7" ;;
  229. 0x096) tst_show="0.9.6" ;;
  230. 0x095) tst_show="0.9.5" ;;
  231. 0x094) tst_show="0.9.4" ;;
  232. 0x093) tst_show="0.9.3" ;;
  233. 0x092) tst_show="0.9.2" ;;
  234. 0x091) tst_show="0.9.1" ;;
  235. *) tst_show="unknown" ;;
  236. esac
  237. AC_MSG_RESULT([$tst_show])
  238. #
  239. dnl if test "$tst_api" != "unknown"; then
  240. dnl AC_DEFINE_UNQUOTED(HAVE_OPENSSL_API_LIBRARY, $tst_api,
  241. dnl [OpenSSL library link time API. Defined only by configure script.
  242. dnl No matter what, do not ever define this manually or by any other means.])
  243. dnl fi
  244. curl_openssl_api_library=$tst_api
  245. ])
  246. dnl CURL_CHECK_OPENSSL_API
  247. dnl -------------------------------------------------
  248. AC_DEFUN([CURL_CHECK_OPENSSL_API], [
  249. #
  250. CURL_CHECK_OPENSSL_API_HEADERS
  251. CURL_CHECK_OPENSSL_API_LIBRARY
  252. #
  253. tst_match="yes"
  254. #
  255. AC_MSG_CHECKING([for OpenSSL headers and library versions matching])
  256. if test "$curl_openssl_api_headers" = "unknown" ||
  257. test "$curl_openssl_api_library" = "unknown"; then
  258. tst_match="fail"
  259. tst_warns="Can not compare OpenSSL headers and library versions."
  260. elif test "$curl_openssl_api_headers" != "$curl_openssl_api_library"; then
  261. tst_match="no"
  262. tst_warns="OpenSSL headers and library versions do not match."
  263. fi
  264. AC_MSG_RESULT([$tst_match])
  265. if test "$tst_match" != "yes"; then
  266. AC_MSG_WARN([$tst_warns])
  267. fi
  268. ])