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_INCLUDE)
30 # AC_SUBST(MYSQL_CFLAGS)
31 # AC_SUBST(MYSQL_LDFLAGS)
32 # AC_SUBST(MYSQL_VERSION)
40 # Copyright (c) 2008 Mateusz Loskot <mateusz@loskot.net>
42 # Copying and distribution of this file, with or without modification, are
43 # permitted in any medium without royalty provided the copyright notice
44 # and this notice are preserved. This file is offered as-is, without any
49 AC_DEFUN([AX_LIB_MYSQL],
52 AS_HELP_STRING([--with-mysql=@<:@ARG@:>@],
53 [use MySQL client library @<:@default=yes@:>@, optionally specify path to mysql_config]
56 if test "$withval" = "no"; then
58 elif test "$withval" = "yes"; then
62 MYSQL_CONFIG="$withval"
67 AC_ARG_VAR([MYSQL_CONFIG], [Full path to mysql_config program])
75 dnl Check MySQL libraries
78 if test "$want_mysql" = "yes"; then
80 if test -z "$MYSQL_CONFIG" ; then
81 AC_PATH_PROGS([MYSQL_CONFIG], [mysql_config mysql_config5], [no])
84 if test "$MYSQL_CONFIG" != "no"; then
85 MYSQL_INCLUDE="`$MYSQL_CONFIG --include`"
86 MYSQL_CFLAGS="`$MYSQL_CONFIG --cflags`"
87 MYSQL_LDFLAGS="`$MYSQL_CONFIG --libs`"
89 MYSQL_VERSION=`$MYSQL_CONFIG --version`
98 dnl Check if required version of MySQL is available
102 mysql_version_req=ifelse([$1], [], [], [$1])
104 if test "$found_mysql" = "yes" -a -n "$mysql_version_req"; then
106 AC_MSG_CHECKING([if MySQL version is >= $mysql_version_req])
108 dnl Decompose required version string of MySQL
109 dnl and calculate its number representation
110 mysql_version_req_major=`expr $mysql_version_req : '\([[0-9]]*\)'`
111 mysql_version_req_minor=`expr $mysql_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
112 mysql_version_req_micro=`expr $mysql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
113 if test "x$mysql_version_req_micro" = "x"; then
114 mysql_version_req_micro="0"
117 mysql_version_req_number=`expr $mysql_version_req_major \* 1000000 \
118 \+ $mysql_version_req_minor \* 1000 \
119 \+ $mysql_version_req_micro`
121 dnl Decompose version string of installed MySQL
122 dnl and calculate its number representation
123 mysql_version_major=`expr $MYSQL_VERSION : '\([[0-9]]*\)'`
124 mysql_version_minor=`expr $MYSQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
125 mysql_version_micro=`expr $MYSQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
126 if test "x$mysql_version_micro" = "x"; then
127 mysql_version_micro="0"
130 mysql_version_number=`expr $mysql_version_major \* 1000000 \
131 \+ $mysql_version_minor \* 1000 \
132 \+ $mysql_version_micro`
134 mysql_version_check=`expr $mysql_version_number \>\= $mysql_version_req_number`
135 if test "$mysql_version_check" = "1"; then
142 if test "$found_mysql" = "yes" ; then
143 AC_DEFINE([HAVE_MYSQL], [1],
144 [Define to 1 if MySQL libraries are available])
147 AC_SUBST([MYSQL_VERSION])
148 AC_SUBST([MYSQL_INCLUDE])
149 AC_SUBST([MYSQL_CFLAGS])
150 AC_SUBST([MYSQL_LDFLAGS])