curl-openssl.m4 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 1998 - 2011, 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 http://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 apprpriate
  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. 0x110) tst_show="1.1.0" ;;
  66. 0x101) tst_show="1.0.1" ;;
  67. 0x100) tst_show="1.0.0" ;;
  68. 0x099) tst_show="0.9.9" ;;
  69. 0x098) tst_show="0.9.8" ;;
  70. 0x097) tst_show="0.9.7" ;;
  71. 0x096) tst_show="0.9.6" ;;
  72. 0x095) tst_show="0.9.5" ;;
  73. 0x094) tst_show="0.9.4" ;;
  74. 0x093) tst_show="0.9.3" ;;
  75. 0x092) tst_show="0.9.2" ;;
  76. 0x091) tst_show="0.9.1" ;;
  77. *) tst_show="unknown" ;;
  78. esac
  79. tst_show="$tst_show - $curl_cv_def_OPENSSL_VERSION_NUMBER"
  80. else
  81. tst_show="unknown"
  82. fi
  83. AC_MSG_RESULT([$tst_show])
  84. #
  85. dnl if test "$tst_api" != "unknown"; then
  86. dnl AC_DEFINE_UNQUOTED(HAVE_OPENSSL_API_HEADERS, $tst_api,
  87. dnl [OpenSSL headers configure time API. Defined only by configure script.
  88. dnl No matter what, do not ever define this manually or by any other means.])
  89. dnl fi
  90. curl_openssl_api_headers=$tst_api
  91. ])
  92. dnl CURL_CHECK_OPENSSL_API_LIBRARY
  93. dnl -------------------------------------------------
  94. dnl Find out OpenSSL library API version, performing
  95. dnl only link tests in order to avoid getting fooled
  96. dnl by mismatched OpenSSL headers. No runtime checks
  97. dnl allowed here for cross-compilation support.
  98. dnl HAVE_OPENSSL_API_LIBRARY is defined as apprpriate
  99. dnl only for systems which actually run the configure
  100. dnl script. Config files generated manually or in any
  101. dnl other way shall not define this.
  102. dnl
  103. dnl Most probably we should not bother attempting to
  104. dnl detect OpenSSL library development API versions
  105. dnl 0.9.9 and 1.1.0. For our intended use, detecting
  106. dnl released versions should be good enough.
  107. dnl
  108. dnl Given that currently we are not using the result
  109. dnl of this check, except for informative purposes,
  110. dnl lets try to figure out everything.
  111. AC_DEFUN([CURL_CHECK_OPENSSL_API_LIBRARY], [
  112. #
  113. tst_api="unknown"
  114. #
  115. AC_MSG_CHECKING([for OpenSSL library version])
  116. if test "$tst_api" = "unknown"; then
  117. case $host in
  118. *-*-vms*)
  119. AC_LINK_IFELSE([
  120. AC_LANG_FUNC_LINK_TRY([SSL_CTX_set_not_resumbl_sess_cb])
  121. ],[
  122. tst_api="0x110"
  123. ])
  124. ;;
  125. *)
  126. AC_LINK_IFELSE([
  127. AC_LANG_FUNC_LINK_TRY([SSL_CTX_set_not_resumable_session_callback])
  128. ],[
  129. tst_api="0x110"
  130. ])
  131. ;;
  132. esac
  133. fi
  134. if test "$tst_api" = "unknown"; then
  135. AC_LINK_IFELSE([
  136. AC_LANG_FUNC_LINK_TRY([SSL_renegotiate_abbreviated])
  137. ],[
  138. tst_api="0x101"
  139. ])
  140. fi
  141. if test "$tst_api" = "unknown"; then
  142. AC_LINK_IFELSE([
  143. AC_LANG_FUNC_LINK_TRY([OBJ_add_sigid])
  144. ],[
  145. tst_api="0x100"
  146. ])
  147. fi
  148. if test "$tst_api" = "unknown"; then
  149. AC_LINK_IFELSE([
  150. AC_LANG_FUNC_LINK_TRY([ERR_set_mark])
  151. ],[
  152. tst_api="0x098"
  153. ])
  154. fi
  155. if test "$tst_api" = "unknown"; then
  156. AC_LINK_IFELSE([
  157. AC_LANG_FUNC_LINK_TRY([ERR_peek_last_error])
  158. ],[
  159. tst_api="0x097"
  160. ])
  161. fi
  162. if test "$tst_api" = "unknown"; then
  163. AC_LINK_IFELSE([
  164. AC_LANG_FUNC_LINK_TRY([c2i_ASN1_OBJECT])
  165. ],[
  166. tst_api="0x096"
  167. ])
  168. fi
  169. if test "$tst_api" = "unknown"; then
  170. AC_LINK_IFELSE([
  171. AC_LANG_FUNC_LINK_TRY([SSL_CTX_set_purpose])
  172. ],[
  173. tst_api="0x095"
  174. ])
  175. fi
  176. if test "$tst_api" = "unknown"; then
  177. AC_LINK_IFELSE([
  178. AC_LANG_FUNC_LINK_TRY([OBJ_obj2txt])
  179. ],[
  180. tst_api="0x094"
  181. ])
  182. fi
  183. if test "$tst_api" = "unknown"; then
  184. AC_LINK_IFELSE([
  185. AC_LANG_FUNC_LINK_TRY([SSL_get_verify_depth])
  186. ],[
  187. tst_api="0x093"
  188. ])
  189. fi
  190. if test "$tst_api" = "unknown"; then
  191. AC_LINK_IFELSE([
  192. AC_LANG_FUNC_LINK_TRY([SSL_library_init])
  193. ],[
  194. tst_api="0x092"
  195. ])
  196. fi
  197. if test "$tst_api" = "unknown"; then
  198. AC_LINK_IFELSE([
  199. AC_LANG_FUNC_LINK_TRY([SSL_CTX_set_cipher_list])
  200. ],[
  201. tst_api="0x091"
  202. ])
  203. fi
  204. case $tst_api in
  205. 0x110) tst_show="1.1.0" ;;
  206. 0x101) tst_show="1.0.1" ;;
  207. 0x100) tst_show="1.0.0" ;;
  208. 0x099) tst_show="0.9.9" ;;
  209. 0x098) tst_show="0.9.8" ;;
  210. 0x097) tst_show="0.9.7" ;;
  211. 0x096) tst_show="0.9.6" ;;
  212. 0x095) tst_show="0.9.5" ;;
  213. 0x094) tst_show="0.9.4" ;;
  214. 0x093) tst_show="0.9.3" ;;
  215. 0x092) tst_show="0.9.2" ;;
  216. 0x091) tst_show="0.9.1" ;;
  217. *) tst_show="unknown" ;;
  218. esac
  219. AC_MSG_RESULT([$tst_show])
  220. #
  221. dnl if test "$tst_api" != "unknown"; then
  222. dnl AC_DEFINE_UNQUOTED(HAVE_OPENSSL_API_LIBRARY, $tst_api,
  223. dnl [OpenSSL library link time API. Defined only by configure script.
  224. dnl No matter what, do not ever define this manually or by any other means.])
  225. dnl fi
  226. curl_openssl_api_library=$tst_api
  227. ])
  228. dnl CURL_CHECK_OPENSSL_API
  229. dnl -------------------------------------------------
  230. AC_DEFUN([CURL_CHECK_OPENSSL_API], [
  231. #
  232. CURL_CHECK_OPENSSL_API_HEADERS
  233. CURL_CHECK_OPENSSL_API_LIBRARY
  234. #
  235. tst_match="yes"
  236. #
  237. AC_MSG_CHECKING([for OpenSSL headers and library versions matching])
  238. if test "$curl_openssl_api_headers" = "unknown" ||
  239. test "$curl_openssl_api_library" = "unknown"; then
  240. tst_match="fail"
  241. tst_warns="Can not compare OpenSSL headers and library versions."
  242. elif test "$curl_openssl_api_headers" != "$curl_openssl_api_library"; then
  243. tst_match="no"
  244. tst_warns="OpenSSL headers and library versions do not match."
  245. fi
  246. AC_MSG_RESULT([$tst_match])
  247. if test "$tst_match" != "yes"; then
  248. AC_MSG_WARN([$tst_warns])
  249. fi
  250. ])