2 AC_REVISION($Revision$)
3 AC_DEFUN(modname,[rlm_sql_mysql])
4 AC_CONFIG_HEADER(config.h)
11 if test x$with_[]modname != xno; then
13 targetname=modname # we change this if a test fails
15 dnl ############################################################
16 dnl # Check for command line options
17 dnl ############################################################
19 dnl extra argument: --with-mysql-dir=DIR
20 AC_ARG_WITH(mysql-dir,
21 [ --with-mysql-dir=DIR base directory where MySQL is installed ],
22 [ mysql_lib_dir="$withval/lib/mysql"
23 mysql_include_dir="$withval/include" ]
26 dnl extra argument: --with-mysql-lib-dir=DIR
27 AC_ARG_WITH(mysql-lib-dir,
28 [ --with-mysql-lib-dir=DIR directory where the MySQL libraries may be found ],
29 [ mysql_lib_dir="$withval" ]
32 dnl extra argument: --with-mysql-include-dir=DIR
33 AC_ARG_WITH(mysql-include-dir,
34 [ --with-mysql-include-dir=DIR directory where the MySQL includes may be found ],
35 [ mysql_include_dir="$withval" ]
38 dnl extra argument: --with-threads
39 mysql_with_threads=yes
41 [ --with-threads use threads, if available. (default=yes) ],
51 dnl ############################################################
52 dnl # Check for programs
53 dnl ############################################################
56 AC_CHECK_PROG(MYSQL_CONFIG, mysql_config, yes, no)
58 dnl ############################################################
59 dnl # Check for libraries
60 dnl ############################################################
62 dnl pthread stuff is usually in -lpthread
63 dnl or in -lc_r, on *BSD
64 if test "x$mysql_with_threads" = "xyes"; then
65 AC_CHECK_LIB(pthread, pthread_create,
66 [ LIBS="-lpthread $LIBS" ],
67 AC_CHECK_LIB(c_r, pthread_create,
68 [ LIBS="-lc_r $LIBS" ],
69 [ mysql_with_threads=no ]
74 if test "x$mysql_with_threads" = "xyes"; then
75 dnl try to link to libmysqlclient_r
76 if test "x$MYSQL_CONFIG" = "xyes"; then
77 mysql_libs="$(mysql_config --libs_r)"
79 LIBS="$mysql_libs $LIBS"
80 AC_MSG_CHECKING([for mysql_init in -lmysqlclient_r (using mysql_config)])
81 AC_TRY_LINK_FUNC(mysql_init, have_libmysqlclient_r=yes)
83 if test "x$have_libmysqlclient_r" = "xyes"; then
85 SMART_LIBS="$mysql_libs $SMART_LIBS"
90 if test "x$have_libmysqlclient_r" != "xyes"; then
91 dnl mysql_config didn't work :(
92 smart_try_dir="$mysql_lib_dir /usr/lib /usr/lib/mysql \
93 /usr/local/lib/mysql /usr/local/mysql/lib/mysql"
94 AC_SMART_CHECK_LIB(mysqlclient_r, mysql_init)
95 if test "x$ac_cv_lib_mysqlclient_r_mysql_init" != "xyes"
98 AC_MSG_WARN([mysql libraries not found. Use --with-mysql-lib-dir=<path>.])
99 targetname="" # disable module
103 dnl try to link to libmysqlclient (without threads support)
104 if test "x$MYSQL_CONFIG" = "xyes"; then
105 mysql_libs="$(mysql_config --libs)"
107 LIBS="$mysql_libs $LIBS"
108 AC_MSG_CHECKING([for mysql_init in -lmysqlclient (using mysql_config)])
109 AC_TRY_LINK_FUNC(mysql_init, have_libmysqlclient=yes)
111 if test "x$have_libmysqlclient" = "xyes"; then
113 SMART_LIBS="$mysql_libs $SMART_LIBS"
118 if test "x$have_libmysqlclient" != "xyes"; then
119 dnl mysql_config didn't work :(
120 smart_try_dir="$mysql_lib_dir /usr/lib /usr/lib/mysql \
121 /usr/local/lib/mysql /usr/local/mysql/lib/mysql"
122 AC_SMART_CHECK_LIB(mysqlclient, mysql_init)
123 if test "x$ac_cv_lib_mysqlclient_mysql_init" != "xyes"
125 dnl nothing worked :(
126 AC_MSG_WARN([mysql libraries not found. Use --with-mysql-lib-dir=<path>.])
127 targetname="" # disable module
132 dnl ############################################################
133 dnl # Check for header files
134 dnl ############################################################
136 if test "x$MYSQL_CONFIG" = "xyes"; then
137 mysql_cflags="$(mysql_config --cflags)"
139 CFLAGS="$CFLAGS $mysql_cflags"
140 AC_MSG_CHECKING([for mysql.h (using mysql_config)])
141 AC_TRY_COMPILE([#include <mysql.h>], [int a = 1;],
143 if test "x$have_mysql_h" = "xyes"; then
145 AC_DEFINE(HAVE_MYSQL_H, [], [Define if you have <mysql.h>])
146 SMART_CFLAGS="$SMART_CFLAGS $mysql_cflags"
152 if test "x$have_mysql_h" != "xyes"; then
153 dnl mysql_config didn't work :(
154 smart_try_dir="$mysql_include_dir /usr/local/include \
155 /usr/local/mysql/include"
156 AC_SMART_CHECK_INCLUDE(mysql/mysql.h)
157 if test "$ac_cv_header_mysql_mysql_h" = "yes"; then
158 AC_DEFINE(HAVE_MYSQL_MYSQL_H, [],
159 [Define if you have <mysql/mysql.h>])
161 dnl nothing worked :(
162 AC_MSG_WARN([mysql headers not found. Use --with-mysql-include-dir=<path>.])
163 targetname="" # disable module
167 if test "x$targetname" = "x"; then
168 AC_MSG_WARN([sql submodule 'mysql' disabled])
172 echo \*\*\* module modname is disabled.
175 sql_mysql_ldflags="$SMART_LIBS"
176 sql_mysql_cflags="$SMART_CFLAGS"
177 AC_SUBST(sql_mysql_ldflags)
178 AC_SUBST(sql_mysql_cflags)