1
# Copyright (C) 2007 MySQL AB
3
# This program is free software; you can redistribute it and/or modify it
4
# under the terms of the GNU General Public License as published by the Free
5
# Software Foundation; version 2 of the License.
7
# This program is distributed in the hope that it will be useful, but
8
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
9
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
# You should have received a copy of the GNU General Public License along
13
# with this program; if not, write to the Free Software Foundation, Inc., 59
14
# Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
AC_DEFUN([_DRIZZLE_CONFIG],[
17
AC_ARG_WITH([mysql-config],
18
AS_HELP_STRING([--with-mysql-config=PATH], [A path to mysql_config script]),
19
[mysql_config="$withval"], [mysql_config=mysql_config])
25
dnl DRIZZLE_CLIENT([version], [client|thread-safe|embedded])
27
dnl Two optional arguments:
28
dnl first: The minimal version of the MySQL to use
29
dnl if not specified, any version will be accepted.
30
dnl The version should be specified as three numbers,
31
dnl without suffixes. E.g. 4.10.15 or 5.0.3
32
dnl second: force the specified library flavor to be selected,
33
dnl if not specified, a user will be able to choose
34
dnl between client (non-thread-safe) and embedded
36
dnl On successful execution sets DRIZZLE_CLIENT_CFLAGS and
37
dnl DRIZZLE_CLIENT_LIBS shell variables and makes substitutions
38
dnl out of them (calls AC_SUBST)
41
AC_DEFUN([DRIZZLE_CLIENT],[
42
AC_REQUIRE([_DRIZZLE_CONFIG])
43
AC_MSG_CHECKING([for MySQL])
44
ifelse([$2], [client],
45
[mysql_libs=--libs mysql_cflags=--cflags],
47
[mysql_libs=--libs_r mysql_cflags=--cflags],
49
[mysql_libs=--libmysqld-libs mysql_cflags=--cflags],
51
AC_ARG_WITH([mysql-library],
52
AS_HELP_STRING([--with-mysql-library], ['client' or 'embedded']),
53
[mysql_lib="$withval"], [mysql_lib=client])
56
client) mysql_libs=--libs mysql_cflags=--cflags ;;
57
embedded) mysql_libs=--libmysqld-libs mysql_cflags=--cflags ;;
58
*) ]AC_MSG_ERROR([Bad value for --with-mysql-library])[
62
[AC_FATAL([Bad second (library flavor) argument to DRIZZLE_CLIENT])])
64
mysql_version=`$mysql_config --version`
65
if test -z "$mysql_version" ; then
66
]AC_MSG_ERROR([Cannot execute $mysql_config])[
69
ifelse([$1], [], [], [
70
ifelse(regexp([$1], [^[0-9][0-9]?\.[0-9][0-9]?\.[0-9][0-9]?$]), -1,
71
[AC_FATAL([Bad first (version) argument to DRIZZLE_CLIENT])], [
73
dnl Transformation below works as follows:
74
dnl assume, we have a number 1.2.3-beta
75
dnl *a* line removes the suffix and adds first and last dot to the version:
77
dnl *b* line adds a 0 to a "single digit surrounded by dots"
79
dnl note that the pattern that matched .1. has eaten the dot for .2.
80
dnl and 2 still has no 0
81
dnl *c* we repeat the same replacement as in *b*, matching .2. this time
83
dnl the last replacement removes all dots
85
dnl giving us a number we can compare with
87
mysql_ver=`echo ${mysql_version}|dnl
88
sed 's/[[-a-z]].*//; s/.*/.&./;dnl *a*
89
s/\.\([[0-9]]\)\./.0\1./g;dnl *b*
90
s/\.\([[0-9]]\)\./.0\1./g;dnl *c*
92
if test "$mysql_ver" -lt]dnl
93
dnl the same as sed transformation above, without suffix-stripping, in m4
94
patsubst(patsubst(patsubst(.[$1]., [\.\([0-9]\)\.], [.0\1.]), [\.\([0-9]\)\.], [.0\1.]), [\.], [])[ ; then
95
AC_MSG_ERROR([MySQL version $mysql_version is too low, minimum of $1 is required])
99
DRIZZLE_CLIENT_CFLAGS=`$mysql_config $mysql_cflags`
100
DRIZZLE_CLIENT_LIBS=`$mysql_config $mysql_libs`
101
AC_SUBST(DRIZZLE_CLIENT_CFLAGS)
102
AC_SUBST(DRIZZLE_CLIENT_LIBS)
104
# should we try to build a test program ?
106
AC_MSG_RESULT([$mysql_version])