You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

210 lines
5.8 KiB

  1. dnl ===========================================================================
  2. dnl Support for SSL
  3. dnl ===========================================================================
  4. dnl
  5. dnl
  6. dnl ---------------------------------------------------------------------------
  7. dnl Macro: MYSQL_USE_BUNDLED_YASSL
  8. dnl
  9. dnl SYNOPSIS
  10. dnl MYSQL_USE_BUNDLED_YASSL()
  11. dnl
  12. dnl DESCRIPTION
  13. dnl Add defines so yassl is built and linked with
  14. dnl ---------------------------------------------------------------------------
  15. AC_DEFUN([MYSQL_USE_BUNDLED_YASSL], [
  16. with_bundled_yassl="yes"
  17. yassl_dir="yassl"
  18. AC_SUBST([yassl_dir])
  19. yassl_libs="\$(top_builddir)/extra/yassl/src/libyassl.la \
  20. \$(top_builddir)/extra/yassl/taocrypt/src/libtaocrypt.la"
  21. AC_SUBST(yassl_libs)
  22. AC_DEFINE([HAVE_OPENSSL], [1], [Defined by configure. Using yaSSL for SSL.])
  23. AC_DEFINE([HAVE_YASSL], [1], [Defined by configure. Using yaSSL for SSL.])
  24. # System specific checks
  25. yassl_integer_extra_cxxflags=""
  26. case $host_cpu--$CXX_VERSION in
  27. sparc*--*Sun*C++*5.6*)
  28. # Disable inlining when compiling taocrypt/src/
  29. yassl_taocrypt_extra_cxxflags="+d"
  30. AC_MSG_NOTICE([disabling inlining for yassl/taocrypt/src/])
  31. ;;
  32. esac
  33. AC_SUBST([yassl_taocrypt_extra_cxxflags])
  34. # Link extra/yassl/include/openssl subdir to include/
  35. yassl_h_ln_cmd="\$(LN) -s \$(top_srcdir)/extra/yassl/include/openssl openssl"
  36. AC_SUBST(yassl_h_ln_cmd)
  37. AC_MSG_RESULT([using bundled yaSSL])
  38. ])
  39. dnl ---------------------------------------------------------------------------
  40. dnl Macro: MYSQL_CHECK_SSL_DIR
  41. dnl
  42. dnl SYNOPSIS
  43. dnl MYSQL_CHECK_SSL_DIR(includes, libs)
  44. dnl
  45. dnl DESCRIPTION
  46. dnl Auxiliary macro to check for ssl at given path
  47. dnl
  48. dnl ---------------------------------------------------------------------------
  49. AC_DEFUN([MYSQL_CHECK_SSL_DIR], [
  50. ssl_incs="$1"
  51. ssl_libs="$2"
  52. save_CPPFLAGS="$CPPFLAGS"
  53. save_LIBS="$LIBS"
  54. CPPFLAGS="$ssl_incs $CPPFLAGS"
  55. LIBS="$LIBS $ssl_libs"
  56. AC_TRY_LINK([#include <openssl/ssl.h>],
  57. [return SSL_library_init();],
  58. [mysql_ssl_found="yes"],
  59. [mysql_ssl_found="no"])
  60. CPPFLAGS="$save_CPPFLAGS"
  61. LIBS="$save_LIBS"
  62. ])
  63. dnl ---------------------------------------------------------------------------
  64. dnl Macro: MYSQL_FIND_OPENSSL
  65. dnl
  66. dnl SYNOPSIS
  67. dnl MYSQL_FIND_OPENSSL(location)
  68. dnl
  69. dnl DESCRIPTION
  70. dnl Search the location for OpenSSL support
  71. dnl
  72. dnl ---------------------------------------------------------------------------
  73. AC_DEFUN([MYSQL_FIND_OPENSSL], [
  74. location="$1"
  75. #
  76. # Set include paths
  77. #
  78. openssl_include="$location/include"
  79. openssl_includes=""
  80. # Don't set ssl_includes to /usr/include as this gives us a lot of
  81. # compiler warnings when using gcc 3.x
  82. if test "$openssl_include" != "/usr/include"
  83. then
  84. openssl_includes="-I$openssl_include"
  85. fi
  86. #
  87. # Try to link with openSSL libs in <location>
  88. #
  89. openssl_libs="-L$location/lib/ -lssl -lcrypto"
  90. MYSQL_CHECK_SSL_DIR([$openssl_includes], [$openssl_libs])
  91. if test "$mysql_ssl_found" == "no"
  92. then
  93. #
  94. # BUG 764: Compile failure with OpenSSL on Red Hat Linux (krb5.h missing)
  95. # Try to link with include paths to kerberos set
  96. #
  97. openssl_includes="$openssl_includes -I/usr/kerberos/include"
  98. MYSQL_CHECK_SSL_DIR([$openssl_includes], [$openssl_libs])
  99. fi
  100. if test "$mysql_ssl_found" == "no"
  101. then
  102. AC_MSG_ERROR([Could not link with SSL libs at $location])
  103. fi
  104. # openssl-devel-0.9.6 requires dlopen() and we can't link staticly
  105. # on many platforms (We should actually test this here, but it's quite
  106. # hard to do as we are doing libtool for linking.)
  107. case "$CLIENT_EXTRA_LDFLAGS $MYSQLD_EXTRA_LDFLAGS" in
  108. *-all-static*)
  109. AC_MSG_ERROR([You can't use the --all-static link option when using openssl.])
  110. ;;
  111. esac
  112. AC_SUBST(openssl_includes)
  113. AC_SUBST(openssl_libs)
  114. NON_THREADED_CLIENT_LIBS="$NON_THREADED_CLIENT_LIBS $openssl_libs"
  115. AC_DEFINE([HAVE_OPENSSL], [1], [OpenSSL])
  116. AC_MSG_RESULT([using openSSL from $location])
  117. ])
  118. dnl ------------------------------------------------------------------------
  119. dnl Macro: MYSQL_CHECK_SSL
  120. dnl
  121. dnl SYNOPSIS
  122. dnl MYSQL_CHECK_SSL
  123. dnl
  124. dnl Provides the following configure options:
  125. dnl --with-ssl=DIR
  126. dnl Possible DIR values are:
  127. dnl - no - the macro will disable use of ssl
  128. dnl - bundled, empty or not specified - means use ssl lib
  129. dnl bundled along with MySQL sources
  130. dnl - ssl location prefix - given location prefix, the macro expects
  131. dnl to find the header files in $prefix/include/, and libraries in
  132. dnl $prefix/lib. If headers or libraries weren't found at $prefix, the
  133. dnl macro bails out with error.
  134. dnl
  135. dnl ------------------------------------------------------------------------
  136. AC_DEFUN([MYSQL_CHECK_SSL], [
  137. AC_CONFIG_FILES(extra/yassl/Makefile dnl
  138. extra/yassl/taocrypt/Makefile dnl
  139. extra/yassl/taocrypt/benchmark/Makefile dnl
  140. extra/yassl/taocrypt/src/Makefile dnl
  141. extra/yassl/taocrypt/test/Makefile dnl
  142. extra/yassl/src/Makefile dnl
  143. extra/yassl/testsuite/Makefile)
  144. AC_MSG_CHECKING(for SSL)
  145. AC_ARG_WITH([ssl],
  146. [ --with-ssl[=DIR] Include SSL support],
  147. [mysql_ssl_dir="$withval"],
  148. [mysql_ssl_dir=no])
  149. if test "$with_yassl"
  150. then
  151. AC_MSG_ERROR([The flag --with-yassl is deprecated, use --with-ssl])
  152. fi
  153. if test "$with_openssl"
  154. then
  155. AC_MSG_ERROR([The flag --with-openssl is deprecated, use --with-ssl])
  156. fi
  157. case "$mysql_ssl_dir" in
  158. "no")
  159. #
  160. # Don't include SSL support
  161. #
  162. AC_MSG_RESULT([disabled])
  163. ;;
  164. "bundled"|"yes")
  165. #
  166. # Use the bundled SSL implementation (yaSSL)
  167. #
  168. MYSQL_USE_BUNDLED_YASSL
  169. ;;
  170. *)
  171. #
  172. # A location where to search for OpenSSL was specified
  173. #
  174. MYSQL_FIND_OPENSSL([$mysql_ssl_dir])
  175. ;;
  176. esac
  177. AM_CONDITIONAL([HAVE_YASSL], [ test "$with_bundled_yassl" = "yes" ])
  178. ])