2
AC_REVISION($Revision: 1.9 $)
2
AC_REVISION($Revision: 1.9.4.1 $)
3
3
AC_DEFUN(modname,[rlm_sql_mysql])
4
4
AC_CONFIG_HEADER(config.h)
9
AC_ARG_WITH(mysql-include-dir,
10
[ --with-mysql-include-dir=DIR Directory where the MySQL includes may be found ],
11
[ mysql_include_dir="$withval" ]
14
AC_ARG_WITH(mysql-lib-dir,
15
[ --with-mysql-lib-dir=DIR Directory where the MySQL libraries may be found ],
16
[ mysql_lib_dir="$withval" ]
19
AC_ARG_WITH(mysql-dir,
20
[ --with-mysql-dir=DIR Base directory where MySQL is installed ],
21
[ mysql_lib_dir="$withval/lib/mysql"
22
mysql_include_dir="$withval/include"
26
11
if test x$with_[]modname != xno; then
28
targetname=modname # we might change this later.
30
AC_CHECK_PROG(MYSQL_CONFIG, mysql_config, yes, no)
31
if test "x$MYSQL_CONFIG" = "xyes"
33
sql_mysql_ldflags=`mysql_config --libs`
34
sql_mysql_cflags=`mysql_config --cflags`
35
AC_DEFINE(HAVE_MYSQL_H)
37
AC_CHECK_LIB(z, compress, LIBS="$LIBS -lz")
39
AC_MSG_CHECKING([for mysql/mysql.h])
41
AC_TRY_COMPILE([#include <mysql/mysql.h>], [int a = 1;],
46
if test "x$MYSQL_INCLUDE" = "x"; then
49
dnl AC_LOCATE_DIR(mysql_include_dir,[mysql/mysql.h])
51
for try in $mysql_include_dir /usr/local/include /usr/local/mysql/include ; do
52
CFLAGS="$old_CFLAGS -I$try"
53
AC_TRY_COMPILE([#include <mysql/mysql.h>], [int a = 1;],
54
MYSQL_INCLUDE="-I$try",
57
if test "x$MYSQL_INCLUDE" != "x"; then
58
AC_DEFINE(HAVE_MYSQL_MYSQL_H)
65
if test "x$MYSQL_INCLUDE" = "x"; then
67
AC_MSG_WARN([mysql headers not found. Use --with-mysql-include-dir=<path>.])
68
targetname= # disabled module
70
sql_mysql_cflags="${sql_mysql_cflags} ${MYSQL_INCLUDE}"
72
AC_DEFINE(HAVE_MYSQL_H)
74
AC_MSG_CHECKING([for mysql_init in -lmysqlclient])
78
dnl AC_LOCATE_DIR(mysql_lib_dir,[libmysqlclient.so])
79
dnl AC_LOCATE_DIR(mysql_lib_dir,[libmysqlclient.a])
81
for try in $mysql_lib_dir /usr/lib /usr/lib/mysql /usr/local/lib/mysql /usr/local/mysql/lib/mysql; do
82
LIBS="$old_LIBS -L$try -lmysqlclient"
83
AC_TRY_LINK([extern char mysql_init();], [mysql_init()],
84
MYSQL_LIBS="-L$try -lmysqlclient $old_LIBS",
87
if test "x$MYSQL_LIBS" != "x"; then
93
dnl # If one or the other isn't found, disable them both..
94
dnl # If both are found, enable them both.
95
if test "x$MYSQL_LIBS" = "x"; then
98
AC_MSG_WARN([mysql libraries not found. Use --with-mysql-lib-dir=<path>.])
99
targetname= # disabled module
102
sql_mysql_ldflags="$sql_mysql_ldflags $MYSQL_LIBS"
105
sql_mysql_ldflags="$sql_mysql_ldflags $LIBS"
108
if test "x$targetname" = "x"; then
109
AC_MSG_WARN([sql submodule 'mysql' disabled])
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])
114
echo \*\*\* module modname is disabled.
172
echo \*\*\* module modname is disabled.
175
sql_mysql_ldflags="$SMART_LIBS"
176
sql_mysql_cflags="$SMART_CFLAGS"
117
177
AC_SUBST(sql_mysql_ldflags)
118
178
AC_SUBST(sql_mysql_cflags)
119
179
AC_SUBST(targetname)