3 # http://ac-archive.sourceforge.net/ac-archive/ax_lib_mysql.html
5 # FC_CHECK_MYSQL([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND[, VERSION]]])
7 AC_DEFUN([FC_CHECK_MYSQL],
9 AC_ARG_WITH([mysql-prefix],
10 AS_HELP_STRING([--with-mysql-prefix=PFX], [Prefix where MySql is installed (optional)]),
11 [mysql_prefix="$withval"], [mysql_prefix=""])
18 dnl Check MySQL libraries (libmysql)
21 if test -z "$MYSQL_CONFIG" -o test; then
22 AC_PATH_PROG([MYSQL_CONFIG], [mysql_config], [no])
25 if test "$MYSQL_CONFIG" != "no"; then
26 AC_MSG_CHECKING([for MySQL libraries])
28 mysql_cflags="`$MYSQL_CONFIG --cflags`"
29 mysql_ldflags="`$MYSQL_CONFIG --libs`"
30 MYSQL_VERSION=`$MYSQL_CONFIG --version`
32 # remove NDEBUG from MYSQL_CFLAGS
33 mysql_cflags=`echo $mysql_cflags | $SED -e 's/-DNDEBUG//g'`
41 dnl Check if required version of MySQL is available
45 mysql_version_req=ifelse([$3], [], [], [$3])
47 if test "$found_mysql" = "yes" -a -n "$mysql_version_req"; then
49 AC_MSG_CHECKING([if MySQL version is >= $mysql_version_req])
51 dnl Decompose required version string of MySQL
52 dnl and calculate its number representation
53 mysql_version_req_major=`expr $mysql_version_req : '\([[0-9]]*\)'`
54 mysql_version_req_minor=`expr $mysql_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
55 mysql_version_req_micro=`expr $mysql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
56 if test "x$mysql_version_req_micro" = "x"; then
57 mysql_version_req_micro="0"
60 mysql_version_req_number=`expr $mysql_version_req_major \* 1000000 \
61 \+ $mysql_version_req_minor \* 1000 \
62 \+ $mysql_version_req_micro`
64 dnl Decompose version string of installed MySQL
65 dnl and calculate its number representation
66 mysql_version_major=`expr $MYSQL_VERSION : '\([[0-9]]*\)'`
67 mysql_version_minor=`expr $MYSQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
68 mysql_version_micro=`expr $MYSQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
69 if test "x$mysql_version_micro" = "x"; then
70 mysql_version_micro="0"
73 mysql_version_number=`expr $mysql_version_major \* 1000000 \
74 \+ $mysql_version_minor \* 1000 \
75 \+ $mysql_version_micro`
77 mysql_version_check=`expr $mysql_version_number \>\= $mysql_version_req_number`
78 if test "$mysql_version_check" = "1"; then
85 AC_SUBST([MYSQL_VERSION])
86 AC_SUBST([mysql_cflags])
87 AC_SUBST([mysql_ldflags])
89 if test "x$found_mysql" = "xyes" ; then
90 ifelse([$1], , :, [$1])
92 ifelse([$2], , :, [$2])