1# =========================================================================== 2# http://www.gnu.org/software/autoconf-archive/ax_boost_asio.html 3# =========================================================================== 4# 5# SYNOPSIS 6# 7# AX_BOOST_ASIO 8# 9# DESCRIPTION 10# 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>. 14# 15# This macro calls: 16# 17# AC_SUBST(BOOST_ASIO_LIB) 18# 19# And sets: 20# 21# HAVE_BOOST_ASIO 22# 23# LICENSE 24# 25# Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de> 26# Copyright (c) 2008 Pete Greenwell <pete@mu.org> 27# 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 31# warranty. 32 33#serial 16 34 35AC_DEFUN([AX_BOOST_ASIO], 36[ 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 ]), 41 [ 42 if test "$withval" = "no"; then 43 want_boost="no" 44 elif test "$withval" = "yes"; then 45 want_boost="yes" 46 ax_boost_user_asio_lib="" 47 else 48 want_boost="yes" 49 ax_boost_user_asio_lib="$withval" 50 fi 51 ], 52 [want_boost="yes"] 53 ) 54 55 if test "x$want_boost" = "xyes"; then 56 AC_REQUIRE([AC_PROG_CC]) 57 CPPFLAGS_SAVED="$CPPFLAGS" 58 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" 59 export CPPFLAGS 60 61 LDFLAGS_SAVED="$LDFLAGS" 62 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" 63 export LDFLAGS 64 65 AC_CACHE_CHECK(whether the Boost::ASIO library is available, 66 ax_cv_boost_asio, 67 [AC_LANG_PUSH([C++]) 68 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ @%:@include <boost/asio.hpp> 69 ]], 70 [[ 71 72 boost::asio::io_service io; 73 boost::system::error_code timer_result; 74 boost::asio::deadline_timer t(io); 75 t.cancel(); 76 io.run_one(); 77 return 0; 78 ]])], 79 ax_cv_boost_asio=yes, ax_cv_boost_asio=no) 80 AC_LANG_POP([C++]) 81 ]) 82 if test "x$ax_cv_boost_asio" = "xyes"; then 83 AC_DEFINE(HAVE_BOOST_ASIO,,[define if the Boost::ASIO library is available]) 84 BN=boost_system 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], 89 [link_thread="no"]) 90 done 91 else 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], 95 [link_asio="no"]) 96 done 97 98 fi 99 if test "x$ax_lib" = "x"; then 100 AC_MSG_ERROR(Could not find a version of the library!) 101 fi 102 if test "x$link_asio" = "xno"; then 103 AC_MSG_ERROR(Could not link against $ax_lib !) 104 fi 105 fi 106 107 CPPFLAGS="$CPPFLAGS_SAVED" 108 LDFLAGS="$LDFLAGS_SAVED" 109 fi 110]) 111