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
65 if test "x$ax_boost_user_program_options_lib" = "x"; then
66 for ax_lib in $BN $BN-$CC $BN-$CC-mt $BN-$CC-mt-s $BN-$CC-s \
67 lib$BN lib$BN-$CC lib$BN-$CC-mt lib$BN-$CC-mt-s lib$BN-$CC-s \
68 $BN-mgw $BN-mgw $BN-mgw-mt $BN-mgw-mt-s $BN-mgw-s ; do
69 AC_CHECK_LIB($ax_lib, main,
70 [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) CONFIG_BOOST_PROGRAM_OPTIONS="yes"; break],
71 [CONFIG_BOOST_PROGRAM_OPTIONS="no"])
74 for ax_lib in $ax_boost_user_program_options_lib $BN-$ax_boost_user_program_options_lib; do
75 AC_CHECK_LIB($ax_lib, main,
76 [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) CONFIG_BOOST_PROGRAM_OPTIONS="yes"; break],
77 [CONFIG_BOOST_PROGRAM_OPTIONS="no"])
80 if test "x$CONFIG_BOOST_PROGRAM_OPTIONS" = "xno"; then
81 AC_MSG_ERROR([Could not link against [$ax_lib] !])
84 CPPFLAGS="$CPPFLAGS_SAVED"
85 LDFLAGS="$LDFLAGS_SAVED"
92 AC_DEFUN([AX_LIB_MYSQL],
95 AC_HELP_STRING([--with-mysql=@<:@ARG@:>@],
96 [use MySQL client library @<:@default=yes@:>@, optionally specify path to mysql_config]
99 if test "$withval" = "no"; then
101 elif test "$withval" = "yes"; then
105 MYSQL_CONFIG="$withval"
117 dnl Check MySQL libraries (libpq)
120 if test "$want_mysql" = "yes"; then
122 if test -z "$MYSQL_CONFIG" -o test; then
123 AC_PATH_PROG([MYSQL_CONFIG], [mysql_config], [no])
126 if test "$MYSQL_CONFIG" != "no"; then
127 AC_MSG_CHECKING([for MySQL libraries])
129 MYSQL_CFLAGS="`$MYSQL_CONFIG --cflags`"
130 MYSQL_LDFLAGS="`$MYSQL_CONFIG --libs`"
131 MYSQL_VERSION=`$MYSQL_CONFIG --version`
133 AC_DEFINE([HAVE_MYSQL], [1],
134 [Define to 1 if MySQL libraries are available])
142 dnl Check if required version of MySQL is available
146 mysql_version_req=ifelse([$1], [], [], [$1])
148 if test "$CONFIG_MYSQL" = "yes" -a -n "$mysql_version_req"; then
150 AC_MSG_CHECKING([if MySQL version is >= $mysql_version_req])
152 dnl Decompose required version string of MySQL
153 dnl and calculate its number representation
154 mysql_version_req_major=`expr $mysql_version_req : '\([[0-9]]*\)'`
155 mysql_version_req_minor=`expr $mysql_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
156 mysql_version_req_micro=`expr $mysql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
157 if test "x$mysql_version_req_micro" = "x"; then
158 mysql_version_req_micro="0"
161 mysql_version_req_number=`expr $mysql_version_req_major \* 1000000 \
162 \+ $mysql_version_req_minor \* 1000 \
163 \+ $mysql_version_req_micro`
165 dnl Decompose version string of installed MySQL
166 dnl and calculate its number representation
167 mysql_version_major=`expr $MYSQL_VERSION : '\([[0-9]]*\)'`
168 mysql_version_minor=`expr $MYSQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
169 mysql_version_micro=`expr $MYSQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
170 if test "x$mysql_version_micro" = "x"; then
171 mysql_version_micro="0"
174 mysql_version_number=`expr $mysql_version_major \* 1000000 \
175 \+ $mysql_version_minor \* 1000 \
176 \+ $mysql_version_micro`
178 mysql_version_check=`expr $mysql_version_number \>\= $mysql_version_req_number`
179 if test "$mysql_version_check" = "1"; then
187 AC_SUBST([MYSQL_VERSION])
188 AC_SUBST([MYSQL_CFLAGS])
189 AC_SUBST([MYSQL_LDFLAGS])
195 AC_DEFUN([AX_LIB_MYSQLPP],
197 AC_ARG_WITH([mysqlpp],
198 AC_HELP_STRING([--with-mysqlpp=@<:@ARG@:>@],
199 [use MySQL client C++ library @<:@default=yes@:>@, optionally specify path to the library]),
201 if test "$withval" = "no"; then
203 elif test "$withval" = "yes"; then
208 ax_mysqlpp_path="$withval"
216 test -z "$ax_mysqlpp_path" || MYSQLPP_CXXFLAGS="-I$ax_myslpp_path"
218 if test "x$want_mysqlpp" = "xyes"; then
219 AC_REQUIRE([AC_PROG_CC])
220 CPPFLAGS_SAVED="$CPPFLAGS"
221 CPPFLAGS="$CPPFLAGS $MYSQLPP_CPPFLAGS"
224 CXXFLAGS_SAVED="$CXXFLAGS"
225 CXXFLAGS="$CPPFLAGS $MYSQL_CFLAGS $MYSQL_CXXFLAGS"
228 LDFLAGS_SAVED="$LDFLAGS"
229 LDFLAGS="$LDFLAGS $MYSQL_LDFLAGS $MYSQLPP_LDFLAGS"
232 AC_CACHE_CHECK(whether the MySQL++ library is available,
235 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <mysql++/mysql++.h>
237 [[mysqlpp::Connection con(false)]]),
243 if test "x$ax_cv_mysqlpp" = "xyes"; then
244 AC_DEFINE(HAVE_MYSQLPP,[1],[Define if the MySQL++ library is available])
246 AC_CHECK_LIB(mysqlpp, main,CONFIG_MYSQLPP=yes,CONFIG_MYSQLPP=no)
249 if test "x$CONFIG_MYSQLPP" = "xno"; then
250 AC_MSG_ERROR(Could not link against mysqlpp !)
254 CPPFLAGS="$CPPFLAGS_SAVED"
255 CXXFLAGS="$CXXFLAGS_SAVED"
256 LDFLAGS="$LDFLAGS_SAVED"
259 AC_SUBST([MYSQLPP_CPPFLAGS])
260 AC_SUBST([MYSQLPP_CXXFLAGS])