fix piece_picker piece-shuffle bug
[libtorrent.git] / m4 / ax_boost_asio-fixed.m4
blob9b0d549691fe72fb9174221429a806e057e79448
1 # ===========================================================================
2 #             http://autoconf-archive.cryp.to/ax_boost_asio.html
3 # ===========================================================================
5 # SYNOPSIS
7 #   AX_BOOST_ASIO
9 # DESCRIPTION
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>.
15 #   This macro calls:
17 #     AC_SUBST(BOOST_ASIO_LIB)
19 #   And sets:
21 #     HAVE_BOOST_ASIO
23 # LAST MODIFICATION
25 #   2008-04-12
27 # COPYLEFT
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 ]),
43         [
44         if test "$withval" = "no"; then
45                         want_boost="no"
46         elif test "$withval" = "yes"; then
47             want_boost="yes"
48             ax_boost_user_asio_lib=""
49         else
50                     want_boost="yes"
51                 ax_boost_user_asio_lib="$withval"
52                 fi
53         ],
54         [want_boost="yes"]
55         )
57         if test "x$want_boost" = "xyes"; then
58         AC_REQUIRE([AC_PROG_CC])
59                 CPPFLAGS_SAVED="$CPPFLAGS"
60                 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
61                 export CPPFLAGS
63                 LDFLAGS_SAVED="$LDFLAGS"
64                 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
65                 export LDFLAGS
67         AC_CACHE_CHECK(whether the Boost::ASIO library is available,
68                                            ax_cv_boost_asio,
69         [AC_LANG_PUSH([C++])
70                  AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[ @%:@include <boost/asio.hpp>
71                                                                                         ]],
72                                   [[
74                                     boost::asio::io_service io;
75                                     boost::system::error_code timer_result;
76                                     boost::asio::deadline_timer t(io);
77                                     t.cancel();
78                                     io.run_one();
79                                                                         return 0;
80                                    ]]),
81                              ax_cv_boost_asio=yes, ax_cv_boost_asio=no)
82          AC_LANG_POP([C++])
83                 ])
84                 if test "x$ax_cv_boost_asio" = "xyes"; then
85                         AC_DEFINE(HAVE_BOOST_ASIO,,[define if the Boost::ASIO library is available])
86                         BN=boost_system
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],
93                                  [link_thread="no"])
94                                 done
95             else
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],
99                                    [link_asio="no"])
100                   done
102             fi
103                         if test "x$link_asio" = "xno"; then
104                                 AC_MSG_ERROR(Could not link against $ax_lib !)
105                         fi
106                 fi
108                 CPPFLAGS="$CPPFLAGS_SAVED"
109         LDFLAGS="$LDFLAGS_SAVED"
110         fi