1 dnl @synopsis AC_PROG_MYSQL
3 dnl Check for the program 'mysql'
4 dnl let script continue if exists & works
5 dnl pops up error message if not.
7 dnl Testing of functionality is by invoking it with root password ''
8 dnl and a 'SELECT * FROM user' SQL statement.
9 dnl The user and passwd can be controlled with the --with-mysql-admin and
10 dnl the --with-mysql-admin-passwd
11 dnl We can also control the host with the --with-mysql-host switch.
12 dnl That SQL statement will select all user information from the 'user'
13 dnl privileges table, dnl and should work on every proper MySQL server.
15 dnl Besides checking mysql, this macro also set these environmentb
16 dnl variables upon completion:
18 dnl MYSQL = which mysql
20 dnl @version $Id: ac_prog_mysql.m4,v 1.2 2002/04/11 14:20:17 simons Exp $
21 dnl @author Gleen Salmon <gleensalmon@yahoo.com>
23 AC_DEFUN([AC_PROG_MYSQL],[
25 AC_REQUIRE([AC_EXEEXT])dnl
27 AC_PATH_PROG(MYSQL, mysql$EXEEXT, nocommand)
28 if test "$MYSQL" = nocommand; then
29 AC_MSG_WARN([mysql not found in $PATH])
30 enable_db_schema_create=no
33 AC_ARG_WITH(mysql-ho, AC_HELP_STRING([--with-mysql-ho],[the host of the mysql database (default: <blank>)]), MYSQL_HOST=${with_mysql_ho}, MYSQL_HOST="")
35 AC_ARG_WITH(mysql-admin,AC_HELP_STRING([--with-mysql-admin],[super user of your mysql database (default: <blank>)]), MYSQL_ADMIN=${with_mysql_admin}, MYSQL_ADMIN="")
37 AC_ARG_WITH(mysql-admin-passwd, AC_HELP_STRING([--with-mysql-admin-passwd],[super user password of your mysql database (default: <blank>)]), MYSQL_ADMIN_PASSWD=${with_mysql_admin_passwd}, MYSQL_ADMIN_PASSWD="")
39 if test "x$MYSQL_ADMIN" = "x"; then
42 user_switch="-u$MYSQL_ADMIN";
45 if test "x$MYSQL_ADMIN_PASSWD" = "x"; then
48 passwd_switch="-p$MYSQL_ADMIN_PASSWD";
51 if test "x$MYSQL_HOST" = "x"; then
54 host_switch="-h$MYSQL_HOST";
57 AC_MSG_CHECKING([if mysql works])
59 if echo 'SELECT * FROM user' | $MYSQL $user_switch $passwd_switch $host_switch mysql> /dev/null; then
62 AC_SUBST(MYSQL_ADMIN_PASSWD)
70 AC_MSG_WARN([mysql cannot execute SELECT with user=$MYSQL_ADMIN, passwd=$MYSQL_ADMIN_PASSWD, and host=$MYSQL_HOST. Please check your my.cnf file or configure options!])
71 MYSQL_CONNECTION=failed
72 enable_db_schema_create=no
74 AC_DEFINE_UNQUOTED(MYSQL_HOST,"$MYSQL_HOST", "the host running mysql")