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.
18 # {{{ Boost program options
20 AC_DEFUN([AX_BOOST_PROGRAM_OPTIONS],
22 AC_ARG_WITH([boost-program-options],
23 AS_HELP_STRING([--with-boost-program-options@<:@=special-lib@:>@],
24 [use the program options library from boost - it is possible to specify a certain library for the linker
25 e.g. --with-boost-program-options=boost_program_options-gcc-mt-1_33_1 ]),
27 if test "$withval" = "no"; then
29 elif test "$withval" = "yes"; then
31 ax_boost_user_program_options_lib=""
34 ax_boost_user_program_options_lib="$withval"
40 CONFIG_BOOST_PROGRAM_OPTIONS=no
42 if test "x$want_boost" = "xyes"; then
43 AC_REQUIRE([AC_PROG_CC])
45 CPPFLAGS_SAVED="$CPPFLAGS"
46 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
48 LDFLAGS_SAVED="$LDFLAGS"
49 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
52 AC_CACHE_CHECK([whether the Boost::Program_Options library is available],
53 ax_cv_boost_program_options,
55 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/program_options.hpp>
57 [[boost::program_options::options_description generic("Generic options")]]),
58 ax_cv_boost_program_options=yes,
59 ax_cv_boost_program_options=no)
62 if test "$ax_cv_boost_program_options" = yes; then
63 AC_DEFINE(HAVE_BOOST_PROGRAM_OPTIONS,[1],[Define if the Boost::PROGRAM_OPTIONS library is available])
64 BN=boost_program_options
66 if test "x$ax_boost_user_program_options_lib" = "x"; then
67 for ax_lib in $BN $BN-$CC $BN-$CC-mt $BN-$CC-mt-s $BN-$CC-s \
68 lib$BN lib$BN-$CC lib$BN-$CC-mt lib$BN-$CC-mt-s lib$BN-$CC-s \
69 $BN-mgw $BN-mgw $BN-mgw-mt $BN-mgw-mt-s $BN-mgw-s ; do
70 AC_CHECK_LIB($ax_lib, main,
71 [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) CONFIG_BOOST_PROGRAM_OPTIONS="yes"; break],
72 [CONFIG_BOOST_PROGRAM_OPTIONS="no"])
75 for ax_lib in $ax_boost_user_program_options_lib $BN-$ax_boost_user_program_options_lib; do
76 AC_CHECK_LIB($ax_lib, main,
77 [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) CONFIG_BOOST_PROGRAM_OPTIONS="yes"; break],
78 [CONFIG_BOOST_PROGRAM_OPTIONS="no"])
82 if test "x$CONFIG_BOOST_PROGRAM_OPTIONS" = "xno"; then
83 AC_MSG_ERROR([Could not link against [$ax_lib] !])
86 CPPFLAGS="$CPPFLAGS_SAVED"
87 LDFLAGS="$LDFLAGS_SAVED"
94 AC_DEFUN([AX_LIB_MYSQL],
97 AC_HELP_STRING([--with-mysql=@<:@ARG@:>@],
98 [use MySQL client library @<:@default=yes@:>@, optionally specify path to mysql_config]
101 if test "$withval" = "no"; then
103 elif test "$withval" = "yes"; then
107 MYSQL_CONFIG="$withval"
119 dnl Check MySQL libraries (libpq)
122 if test "$want_mysql" = "yes"; then
124 if test -z "$MYSQL_CONFIG" -o test; then
125 AC_PATH_PROG([MYSQL_CONFIG], [mysql_config], [no])
128 if test "$MYSQL_CONFIG" != "no"; then
129 AC_MSG_CHECKING([for MySQL libraries])
131 MYSQL_CFLAGS="`$MYSQL_CONFIG --cflags`"
132 MYSQL_LDFLAGS="`$MYSQL_CONFIG --libs`"
133 MYSQL_VERSION=`$MYSQL_CONFIG --version`
135 AC_DEFINE([HAVE_MYSQL], [1],
136 [Define to 1 if MySQL libraries are available])
144 dnl Check if required version of MySQL is available
148 mysql_version_req=ifelse([$1], [], [], [$1])
150 if test "$CONFIG_MYSQL" = "yes" -a -n "$mysql_version_req"; then
152 AC_MSG_CHECKING([if MySQL version is >= $mysql_version_req])
154 dnl Decompose required version string of MySQL
155 dnl and calculate its number representation
156 mysql_version_req_major=`expr $mysql_version_req : '\([[0-9]]*\)'`
157 mysql_version_req_minor=`expr $mysql_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
158 mysql_version_req_micro=`expr $mysql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
159 if test "x$mysql_version_req_micro" = "x"; then
160 mysql_version_req_micro="0"
163 mysql_version_req_number=`expr $mysql_version_req_major \* 1000000 \
164 \+ $mysql_version_req_minor \* 1000 \
165 \+ $mysql_version_req_micro`
167 dnl Decompose version string of installed MySQL
168 dnl and calculate its number representation
169 mysql_version_major=`expr $MYSQL_VERSION : '\([[0-9]]*\)'`
170 mysql_version_minor=`expr $MYSQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
171 mysql_version_micro=`expr $MYSQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
172 if test "x$mysql_version_micro" = "x"; then
173 mysql_version_micro="0"
176 mysql_version_number=`expr $mysql_version_major \* 1000000 \
177 \+ $mysql_version_minor \* 1000 \
178 \+ $mysql_version_micro`
180 mysql_version_check=`expr $mysql_version_number \>\= $mysql_version_req_number`
181 if test "$mysql_version_check" = "1"; then
189 AC_SUBST([MYSQL_VERSION])
190 AC_SUBST([MYSQL_CFLAGS])
191 AC_SUBST([MYSQL_LDFLAGS])
197 AC_DEFUN([AX_LIB_MYSQLPP],
199 AC_ARG_WITH([mysqlpp],
200 AC_HELP_STRING([--with-mysqlpp=@<:@ARG@:>@],
201 [use MySQL client C++ library @<:@default=yes@:>@, optionally specify path to the library]),
203 if test "$withval" = "no"; then
205 elif test "$withval" = "yes"; then
210 ax_mysqlpp_path="$withval"
218 test -z "$ax_mysqlpp_path" || MYSQLPP_CXXFLAGS="-I$ax_myslpp_path"
220 if test "x$want_mysqlpp" = "xyes"; then
221 AC_REQUIRE([AC_PROG_CC])
222 CPPFLAGS_SAVED="$CPPFLAGS"
223 CPPFLAGS="$CPPFLAGS $MYSQLPP_CPPFLAGS"
226 CXXFLAGS_SAVED="$CXXFLAGS"
227 CXXFLAGS="$CPPFLAGS $MYSQL_CFLAGS $MYSQL_CXXFLAGS"
230 LDFLAGS_SAVED="$LDFLAGS"
231 LDFLAGS="$LDFLAGS $MYSQL_LDFLAGS $MYSQLPP_LDFLAGS"
234 AC_CACHE_CHECK(whether the MySQL++ library is available,
237 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <mysql++/mysql++.h>
239 [[mysqlpp::Connection con(false)]]),
245 if test "x$ax_cv_mysqlpp" = "xyes"; then
246 AC_DEFINE(HAVE_MYSQLPP,[1],[Define if the MySQL++ library is available])
248 AC_CHECK_LIB(mysqlpp, main,CONFIG_MYSQLPP=yes,CONFIG_MYSQLPP=no)
251 if test "x$CONFIG_MYSQLPP" = "xno"; then
252 AC_MSG_ERROR(Could not link against mysqlpp !)
256 CPPFLAGS="$CPPFLAGS_SAVED"
257 CXXFLAGS="$CXXFLAGS_SAVED"
258 LDFLAGS="$LDFLAGS_SAVED"
261 AC_SUBST([MYSQLPP_CPPFLAGS])
262 AC_SUBST([MYSQLPP_CXXFLAGS])