1 # The boost library autoconf macros were taken from
3 # http://autoconf-archive.cryp.to/ax_boost_program_options.html
5 # and the mysql client library autoconf macro was taken from:
7 # http://autoconf-archive.cryp.to/ax_lib_mysql.html
9 # Both have the following license:
11 # Copyright (c) 2007 Thomas Porschberg <thomas@randspringer.de>
12 # Copyright (c) 2006 Mateusz Loskot <mateusz@loskot.net>
14 # Copying and distribution of this file, with or without modification,
15 # are permitted in any medium without royalty provided the copyright
16 # notice and this notice are preserved.
20 AC_DEFUN([AX_LIB_MYSQL],
23 AC_HELP_STRING([--with-mysql=@<:@ARG@:>@],
24 [use MySQL client library @<:@default=yes@:>@, optionally specify path to mysql_config]
27 if test "$withval" = "no"; then
29 elif test "$withval" = "yes"; then
33 MYSQL_CONFIG="$withval"
45 dnl Check MySQL libraries (libpq)
48 if test "$want_mysql" = "yes"; then
50 if test -z "$MYSQL_CONFIG" -o test; then
51 AC_PATH_PROG([MYSQL_CONFIG], [mysql_config], [no])
54 if test "$MYSQL_CONFIG" != "no"; then
55 AC_MSG_CHECKING([for MySQL libraries])
57 MYSQL_CFLAGS="`$MYSQL_CONFIG --cflags`"
58 MYSQL_LDFLAGS="`$MYSQL_CONFIG --libs`"
59 MYSQL_VERSION=`$MYSQL_CONFIG --version`
61 AC_DEFINE([HAVE_MYSQL], [1],
62 [Define to 1 if MySQL libraries are available])
70 dnl Check if required version of MySQL is available
74 mysql_version_req=ifelse([$1], [], [], [$1])
76 if test "$CONFIG_MYSQL" = "yes" -a -n "$mysql_version_req"; then
78 AC_MSG_CHECKING([if MySQL version is >= $mysql_version_req])
80 dnl Decompose required version string of MySQL
81 dnl and calculate its number representation
82 mysql_version_req_major=`expr $mysql_version_req : '\([[0-9]]*\)'`
83 mysql_version_req_minor=`expr $mysql_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
84 mysql_version_req_micro=`expr $mysql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
85 if test "x$mysql_version_req_micro" = "x"; then
86 mysql_version_req_micro="0"
89 mysql_version_req_number=`expr $mysql_version_req_major \* 1000000 \
90 \+ $mysql_version_req_minor \* 1000 \
91 \+ $mysql_version_req_micro`
93 dnl Decompose version string of installed MySQL
94 dnl and calculate its number representation
95 mysql_version_major=`expr $MYSQL_VERSION : '\([[0-9]]*\)'`
96 mysql_version_minor=`expr $MYSQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
97 mysql_version_micro=`expr $MYSQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
98 if test "x$mysql_version_micro" = "x"; then
99 mysql_version_micro="0"
102 mysql_version_number=`expr $mysql_version_major \* 1000000 \
103 \+ $mysql_version_minor \* 1000 \
104 \+ $mysql_version_micro`
106 mysql_version_check=`expr $mysql_version_number \>\= $mysql_version_req_number`
107 if test "$mysql_version_check" = "1"; then
115 AC_SUBST([MYSQL_VERSION])
116 AC_SUBST([MYSQL_CFLAGS])
117 AC_SUBST([MYSQL_LDFLAGS])
123 AC_DEFUN([AX_LIB_MYSQLPP],
125 AC_ARG_WITH([mysqlpp],
126 AC_HELP_STRING([--with-mysqlpp=@<:@ARG@:>@],
127 [use MySQL client C++ library @<:@default=yes@:>@, optionally specify path to the library]),
129 if test "$withval" = "no"; then
131 elif test "$withval" = "yes"; then
136 ax_mysqlpp_path="$withval"
144 test -z "$ax_mysqlpp_path" || MYSQLPP_CXXFLAGS="-I$ax_myslpp_path"
146 if test "x$want_mysqlpp" = "xyes"; then
147 AC_REQUIRE([AC_PROG_CC])
148 CPPFLAGS_SAVED="$CPPFLAGS"
149 CPPFLAGS="$CPPFLAGS $MYSQLPP_CPPFLAGS"
152 CXXFLAGS_SAVED="$CXXFLAGS"
153 CXXFLAGS="$CPPFLAGS $MYSQL_CFLAGS $MYSQL_CXXFLAGS"
156 LDFLAGS_SAVED="$LDFLAGS"
157 LDFLAGS="$LDFLAGS $MYSQL_LDFLAGS $MYSQLPP_LDFLAGS"
160 AC_CACHE_CHECK(whether the MySQL++ library is available,
163 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <mysql++/mysql++.h>
165 [[mysqlpp::Connection con(false)]]),
171 if test "x$ax_cv_mysqlpp" = "xyes"; then
172 AC_DEFINE(HAVE_MYSQLPP,[1],[Define if the MySQL++ library is available])
174 AC_CHECK_LIB(mysqlpp, main,CONFIG_MYSQLPP=yes,CONFIG_MYSQLPP=no)
177 if test "x$CONFIG_MYSQLPP" = "xno"; then
178 AC_MSG_ERROR(Could not link against mysqlpp !)
182 CPPFLAGS="$CPPFLAGS_SAVED"
183 CXXFLAGS="$CXXFLAGS_SAVED"
184 LDFLAGS="$LDFLAGS_SAVED"
187 AC_SUBST([MYSQLPP_CPPFLAGS])
188 AC_SUBST([MYSQLPP_CXXFLAGS])