1 # ===========================================================================
2 # http://www.gnu.org/software/autoconf-archive/ax_boost_asio.html
3 # ===========================================================================
11 # Test for Asio library from the Boost C++ libraries. The macro requires a
12 # preceding call to AX_BOOST_BASE. Further documentation is available at
13 # <http://randspringer.de/boost/index.html>.
17 # AC_SUBST(BOOST_ASIO_LIB)
25 # Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
26 # Copyright (c) 2008 Pete Greenwell <pete@mu.org>
28 # Copying and distribution of this file, with or without modification, are
29 # permitted in any medium without royalty provided the copyright notice
30 # and this notice are preserved. This file is offered as-is, without any
35 AC_DEFUN([AX_BOOST_ASIO],
37 AC_ARG_WITH([boost-asio],
38 AS_HELP_STRING([--with-boost-asio@<:@=special-lib@:>@],
39 [use the ASIO library from boost - it is possible to specify a certain library for the linker
40 e.g. --with-boost-asio=boost_system-gcc41-mt-1_34 ]),
42 if test "$withval" = "no"; then
44 elif test "$withval" = "yes"; then
46 ax_boost_user_asio_lib=""
49 ax_boost_user_asio_lib="$withval"
55 if test "x$want_boost" = "xyes"; then
56 AC_REQUIRE([AC_PROG_CC])
57 CPPFLAGS_SAVED="$CPPFLAGS"
58 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
61 LDFLAGS_SAVED="$LDFLAGS"
62 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
65 AC_CACHE_CHECK(whether the Boost::ASIO library is available,
68 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ @%:@include <boost/asio.hpp>
72 boost::asio::io_service io;
73 boost::system::error_code timer_result;
74 boost::asio::deadline_timer t(io);
79 ax_cv_boost_asio=yes, ax_cv_boost_asio=no)
82 if test "x$ax_cv_boost_asio" = "xyes"; then
83 AC_DEFINE(HAVE_BOOST_ASIO,,[define if the Boost::ASIO library is available])
85 BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
86 if test "x$ax_boost_user_asio_lib" = "x"; then
87 for ax_lib in `ls $BOOSTLIBDIR/libboost_system*.so* $BOOSTLIBDIR/libboost_system*.dylib* $BOOSTLIBDIR/libboost_system*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_system.*\)\.so.*$;\1;' -e 's;^lib\(boost_system.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_system.*\)\.a.*$;\1;' ` ; do
88 AC_CHECK_LIB($ax_lib, main, [BOOST_ASIO_LIB="-l$ax_lib" AC_SUBST(BOOST_ASIO_LIB) link_thread="yes" break],
92 for ax_lib in $ax_boost_user_asio_lib $BN-$ax_boost_user_asio_lib; do
93 AC_CHECK_LIB($ax_lib, main,
94 [BOOST_ASIO_LIB="-l$ax_lib" AC_SUBST(BOOST_ASIO_LIB) link_asio="yes" break],
99 if test "x$ax_lib" = "x"; then
100 AC_MSG_ERROR(Could not find a version of the library!)
102 if test "x$link_asio" = "xno"; then
103 AC_MSG_ERROR(Could not link against $ax_lib !)
107 CPPFLAGS="$CPPFLAGS_SAVED"
108 LDFLAGS="$LDFLAGS_SAVED"