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