1
# ===========================================================================
2
# http://autoconf-archive.cryp.to/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)
29
# Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
30
# Copyright (c) 2008 Pete Greenwell <pete@mu.org>
31
# Copyright (c) 2008 Roman Rybalko <libtorrent@romanr.info> (using BOOST_SYSTEM_LIB)
33
# Copying and distribution of this file, with or without modification, are
34
# permitted in any medium without royalty provided the copyright notice
35
# and this notice are preserved.
37
AC_DEFUN([AX_BOOST_ASIO],
39
AC_ARG_WITH([boost-asio],
40
AS_HELP_STRING([--with-boost-asio@<:@=special-lib@:>@],
41
[use the ASIO library from boost - it is possible to specify a certain library for the linker
42
e.g. --with-boost-asio=boost_system-gcc41-mt-1_34 ]),
44
if test "$withval" = "no"; then
46
elif test "$withval" = "yes"; then
48
ax_boost_user_asio_lib=""
51
ax_boost_user_asio_lib="$withval"
57
if test "x$want_boost" = "xyes"; then
58
AC_REQUIRE([AC_PROG_CC])
59
CPPFLAGS_SAVED="$CPPFLAGS"
60
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
63
LDFLAGS_SAVED="$LDFLAGS"
64
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
67
AC_CACHE_CHECK(whether the Boost::ASIO library is available,
70
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[ @%:@include <boost/asio.hpp>
74
boost::asio::io_service io;
75
boost::system::error_code timer_result;
76
boost::asio::deadline_timer t(io);
81
ax_cv_boost_asio=yes, ax_cv_boost_asio=no)
84
if test "x$ax_cv_boost_asio" = "xyes"; then
85
AC_DEFINE(HAVE_BOOST_ASIO,,[define if the Boost::ASIO library is available])
87
BN2=`echo $BOOST_SYSTEM_LIB | sed 's/-l//'`
88
if test "x$ax_boost_user_asio_lib" = "x"; then
89
for ax_lib in $BN2 $BN $BN-$CC $BN-$CC-mt $BN-$CC-mt-s $BN-$CC-s \
90
lib$BN lib$BN-$CC lib$BN-$CC-mt lib$BN-$CC-mt-s lib$BN-$CC-s \
91
$BN-mgw $BN-mgw $BN-mgw-mt $BN-mgw-mt-s $BN-mgw-s ; do
92
AC_CHECK_LIB($ax_lib, main, [BOOST_ASIO_LIB="-l$ax_lib" AC_SUBST(BOOST_ASIO_LIB) link_thread="yes" break],
96
for ax_lib in $ax_boost_user_asio_lib $BN-$ax_boost_user_asio_lib; do
97
AC_CHECK_LIB($ax_lib, main,
98
[BOOST_ASIO_LIB="-l$ax_lib" AC_SUBST(BOOST_ASIO_LIB) link_asio="yes" break],
103
if test "x$link_asio" = "xno"; then
104
AC_MSG_ERROR(Could not link against $ax_lib !)
108
CPPFLAGS="$CPPFLAGS_SAVED"
109
LDFLAGS="$LDFLAGS_SAVED"