1 # ===========================================================================
2 # http://www.gnu.org/software/autoconf-archive/ax_lib_mysql.html
3 # ===========================================================================
7 # AX_LIB_MYSQL([MINIMUM-VERSION])
11 # This macro provides tests of availability of MySQL client library of
12 # particular version or newer.
14 # AX_LIB_MYSQL macro takes only one argument which is optional. If there
15 # is no required version passed, then macro does not run version test.
17 # The --with-mysql option takes one of three possible values:
19 # no - do not check for MySQL client library
21 # yes - do check for MySQL library in standard locations (mysql_config
22 # should be in the PATH)
24 # path - complete path to mysql_config utility, use this option if
25 # mysql_config can't be found in the PATH
29 # AC_SUBST(MYSQL_CFLAGS)
30 # AC_SUBST(MYSQL_LDFLAGS)
31 # AC_SUBST(MYSQL_VERSION)
39 # Copyright (c) 2008 Mateusz Loskot <mateusz@loskot.net>
41 # Copying and distribution of this file, with or without modification, are
42 # permitted in any medium without royalty provided the copyright notice
43 # and this notice are preserved. This file is offered as-is, without any
48 AC_DEFUN([AX_LIB_MYSQL],
51 AS_HELP_STRING([--with-mysql=@<:@ARG@:>@],
52 [use MySQL client library @<:@default=yes@:>@, optionally specify path to mysql_config]
55 if test "$withval" = "no"; then
57 elif test "$withval" = "yes"; then
61 MYSQL_CONFIG="$withval"
66 AC_ARG_VAR([MYSQL_CONFIG], [Full path to mysql_config program])
73 dnl Check MySQL libraries
76 if test "$want_mysql" = "yes"; then
78 if test -z "$MYSQL_CONFIG" ; then
79 AC_PATH_PROGS([MYSQL_CONFIG], [mysql_config mysql_config5], [no])
82 if test "$MYSQL_CONFIG" != "no"; then
83 MYSQL_CFLAGS="`$MYSQL_CONFIG --cflags`"
84 MYSQL_LDFLAGS="`$MYSQL_CONFIG --libs`"
86 MYSQL_VERSION=`$MYSQL_CONFIG --version`
95 dnl Check if required version of MySQL is available
99 mysql_version_req=ifelse([$1], [], [], [$1])
101 if test "$found_mysql" = "yes" -a -n "$mysql_version_req"; then
103 AC_MSG_CHECKING([if MySQL version is >= $mysql_version_req])
105 dnl Decompose required version string of MySQL
106 dnl and calculate its number representation
107 mysql_version_req_major=`expr $mysql_version_req : '\([[0-9]]*\)'`
108 mysql_version_req_minor=`expr $mysql_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
109 mysql_version_req_micro=`expr $mysql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
110 if test "x$mysql_version_req_micro" = "x"; then
111 mysql_version_req_micro="0"
114 mysql_version_req_number=`expr $mysql_version_req_major \* 1000000 \
115 \+ $mysql_version_req_minor \* 1000 \
116 \+ $mysql_version_req_micro`
118 dnl Decompose version string of installed MySQL
119 dnl and calculate its number representation
120 mysql_version_major=`expr $MYSQL_VERSION : '\([[0-9]]*\)'`
121 mysql_version_minor=`expr $MYSQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
122 mysql_version_micro=`expr $MYSQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
123 if test "x$mysql_version_micro" = "x"; then
124 mysql_version_micro="0"
127 mysql_version_number=`expr $mysql_version_major \* 1000000 \
128 \+ $mysql_version_minor \* 1000 \
129 \+ $mysql_version_micro`
131 mysql_version_check=`expr $mysql_version_number \>\= $mysql_version_req_number`
132 if test "$mysql_version_check" = "1"; then
139 if test "$found_mysql" = "yes" ; then
140 AC_DEFINE([HAVE_MYSQL], [1],
141 [Define to 1 if MySQL libraries are available])
144 AC_SUBST([MYSQL_VERSION])
145 AC_SUBST([MYSQL_CFLAGS])
146 AC_SUBST([MYSQL_LDFLAGS])