2 AC_REVISION($Revision$)
3 AC_DEFUN(modname,[rlm_sql_mysql])
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 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])
114 echo \*\*\* module modname is disabled.
117 AC_SUBST(sql_mysql_ldflags)
118 AC_SUBST(sql_mysql_cflags)