MoteHost: Cleanup fdset related variables in serviceLoop()
[remote/remote-mci.git] / acinclude.m4
blobbed2e3da4cb965d54b013ee81ccf3f6bdf49fa87
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 ]),
26         [
27                 if test "$withval" = "no"; then
28                         want_boost="no"
29                 elif test "$withval" = "yes"; then
30                         want_boost="yes"
31                         ax_boost_user_program_options_lib=""
32                 else
33                         want_boost="yes"
34                         ax_boost_user_program_options_lib="$withval"
35                 fi
36         ],
37         [want_boost="yes"]
40 CONFIG_BOOST_PROGRAM_OPTIONS=no
42 if test "x$want_boost" = "xyes"; then
43         AC_REQUIRE([AC_PROG_CC])
44         export want_boost
45         CPPFLAGS_SAVED="$CPPFLAGS"
46         CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
47         export CPPFLAGS
48         LDFLAGS_SAVED="$LDFLAGS"
49         LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
50         export LDFLAGS
52         AC_CACHE_CHECK([whether the Boost::Program_Options library is available],
53                 ax_cv_boost_program_options,
54                 [AC_LANG_PUSH(C++)
55                 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/program_options.hpp>
56                                                   ]],
57                                                   [[boost::program_options::options_description generic("Generic options")]]),
58                                   ax_cv_boost_program_options=yes,
59                                   ax_cv_boost_program_options=no)
60                 AC_LANG_POP([C++])
61         ])
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"])
72                         done
73                 else
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"])
78                         done
79                 fi
80                 if test "x$CONFIG_BOOST_PROGRAM_OPTIONS" = "xno"; then
81                         AC_MSG_ERROR([Could not link against [$ax_lib] !])
82                 fi
83         fi
84         CPPFLAGS="$CPPFLAGS_SAVED"
85         LDFLAGS="$LDFLAGS_SAVED"
89 # }}}
90 # {{{ MySQL
92 AC_DEFUN([AX_LIB_MYSQL],
94 AC_ARG_WITH([mysql],
95         AC_HELP_STRING([--with-mysql=@<:@ARG@:>@],
96                 [use MySQL client library @<:@default=yes@:>@, optionally specify path to mysql_config]
97         ),
98         [
99         if test "$withval" = "no"; then
100                 want_mysql="no"
101         elif test "$withval" = "yes"; then
102                 want_mysql="yes"
103         else
104                 want_mysql="yes"
105                 MYSQL_CONFIG="$withval"
106         fi
107         ],
108         [want_mysql="yes"]
111 MYSQL_CFLAGS=""
112 MYSQL_LDFLAGS=""
113 MYSQL_VERSION=""
114 CONFIG_MYSQL=no
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])
124         fi
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])
136                 CONFIG_MYSQL="yes"
137                 AC_MSG_RESULT([yes])
138         fi
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"
159         fi
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"
172         fi
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
180                 AC_MSG_RESULT([yes])
181         else
182                 AC_MSG_RESULT([no])
183                 CONFIG_MYSQL=no
184         fi
187 AC_SUBST([MYSQL_VERSION])
188 AC_SUBST([MYSQL_CFLAGS])
189 AC_SUBST([MYSQL_LDFLAGS])
192 # }}}
193 # {{{ MySQL++
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]),
200         [
201                 if test "$withval" = "no"; then
202                         want_mysqlpp="no"
203                 elif test "$withval" = "yes"; then
204                         want_mysqlpp="yes"
205                         ax_mysqlpp_path=""
206                 else
207                         want_mysqlpp="yes"
208                         ax_mysqlpp_path="$withval"
209                 fi
210         ],
211         [want_mysqlpp="yes"]
214 CONFIG_MYSQLPP=no
215 MYSQLPP_CXXFLAGS=""
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"
222         export CPPFLAGS
224         CXXFLAGS_SAVED="$CXXFLAGS"
225         CXXFLAGS="$CPPFLAGS $MYSQL_CFLAGS $MYSQL_CXXFLAGS"
226         export CXXFLAGS
228         LDFLAGS_SAVED="$LDFLAGS"
229         LDFLAGS="$LDFLAGS $MYSQL_LDFLAGS $MYSQLPP_LDFLAGS"
230         export LDFLAGS
232         AC_CACHE_CHECK(whether the MySQL++ library is available,
233                 ax_cv_mysqlpp,
234                 [AC_LANG_PUSH([C++])
235                 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <mysql++/mysql++.h>
236                                                   ]],
237                                                   [[mysqlpp::Connection con(false)]]),
238                                   ax_cv_mysqlpp=yes,
239                                   ax_cv_mysqlpp=no)
240                 AC_LANG_POP([C++])
241                 ])
243         if test "x$ax_cv_mysqlpp" = "xyes"; then
244                 AC_DEFINE(HAVE_MYSQLPP,[1],[Define if the MySQL++ library is available])
245                 AC_LANG_PUSH([C++])
246                 AC_CHECK_LIB(mysqlpp, main,CONFIG_MYSQLPP=yes,CONFIG_MYSQLPP=no)
247                 AC_LANG_POP([C++])
249                 if test "x$CONFIG_MYSQLPP" = "xno"; then
250                         AC_MSG_ERROR(Could not link against mysqlpp !)
251                 fi
252         fi
254         CPPFLAGS="$CPPFLAGS_SAVED"
255         CXXFLAGS="$CXXFLAGS_SAVED"
256         LDFLAGS="$LDFLAGS_SAVED"
259 AC_SUBST([MYSQLPP_CPPFLAGS])
260 AC_SUBST([MYSQLPP_CXXFLAGS])
263 # }}}