fixes bug where priorities where lost when force-rechecking.
[libtorrent.git] / m4 / ax_boost_iostreams.m4
blobc5fc565f1384b3d007a2feb3d4a9c50ec5c73284
1 # ===========================================================================
2 #           http://autoconf-archive.cryp.to/ax_boost_iostreams.html
3 # ===========================================================================
5 # SYNOPSIS
7 #   AX_BOOST_IOSTREAMS
9 # DESCRIPTION
11 #   Test for IOStreams library from the Boost C++ libraries. The macro
12 #   requires a preceding call to AX_BOOST_BASE. Further documentation is
13 #   available at <http://randspringer.de/boost/index.html>.
15 #   This macro calls:
17 #     AC_SUBST(BOOST_IOSTREAMS_LIB)
19 #   And sets:
21 #     HAVE_BOOST_IOSTREAMS
23 # LAST MODIFICATION
25 #   2008-04-12
27 # COPYLEFT
29 #   Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
31 #   Copying and distribution of this file, with or without modification, are
32 #   permitted in any medium without royalty provided the copyright notice
33 #   and this notice are preserved.
35 AC_DEFUN([AX_BOOST_IOSTREAMS],
37         AC_ARG_WITH([boost-iostreams],
38         AS_HELP_STRING([--with-boost-iostreams@<:@=special-lib@:>@],
39                    [use the IOStreams library from boost - it is possible to specify a certain library for the linker
40                         e.g. --with-boost-iostreams=boost_iostreams-gcc-mt-d-1_33_1 ]),
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_iostreams_lib=""
47         else
48                     want_boost="yes"
49                 ax_boost_user_iostreams_lib="$withval"
50                 fi
51         ],
52         [want_boost="yes"]
53         )
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
61                 LDFLAGS_SAVED="$LDFLAGS"
62                 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
63                 export LDFLAGS
65         AC_CACHE_CHECK(whether the Boost::IOStreams library is available,
66                                            ax_cv_boost_iostreams,
67         [AC_LANG_PUSH([C++])
68                  AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/iostreams/filtering_stream.hpp>
69                                                                                          @%:@include <boost/range/iterator_range.hpp>
70                                                                                         ]],
71                                   [[std::string  input = "Hello World!";
72                                                                  namespace io = boost::iostreams;
73                                                                          io::filtering_istream  in(boost::make_iterator_range(input));
74                                                                          return 0;
75                                    ]]),
76                              ax_cv_boost_iostreams=yes, ax_cv_boost_iostreams=no)
77          AC_LANG_POP([C++])
78                 ])
79                 if test "x$ax_cv_boost_iostreams" = "xyes"; then
80                         AC_DEFINE(HAVE_BOOST_IOSTREAMS,,[define if the Boost::IOStreams library is available])
81             BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
82             if test "x$ax_boost_user_iostreams_lib" = "x"; then
83                 for libextension in `ls $BOOSTLIBDIR/libboost_iostreams*.{so,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_iostreams.*\)\.so.*$;\1;' -e 's;^lib\(boost_iostreams.*\)\.a*$;\1;'` ; do
84                      ax_lib=${libextension}
85                                     AC_CHECK_LIB($ax_lib, exit,
86                                  [BOOST_IOSTREAMS_LIB="-l$ax_lib"; AC_SUBST(BOOST_IOSTREAMS_LIB) link_iostreams="yes"; break],
87                                  [link_iostreams="no"])
88                                 done
89                 if test "x$link_iostreams" != "xyes"; then
90                 for libextension in `ls $BOOSTLIBDIR/boost_iostreams*.{dll,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_iostreams.*\)\.dll.*$;\1;' -e 's;^\(boost_iostreams.*\)\.a*$;\1;'` ; do
91                      ax_lib=${libextension}
92                                     AC_CHECK_LIB($ax_lib, exit,
93                                  [BOOST_IOSTREAMS_LIB="-l$ax_lib"; AC_SUBST(BOOST_IOSTREAMS_LIB) link_iostreams="yes"; break],
94                                  [link_iostreams="no"])
95                                 done
96                 fi
98             else
99                for ax_lib in $ax_boost_user_iostreams_lib boost_iostreams-$ax_boost_user_iostreams_lib; do
100                                       AC_CHECK_LIB($ax_lib, main,
101                                    [BOOST_IOSTREAMS_LIB="-l$ax_lib"; AC_SUBST(BOOST_IOSTREAMS_LIB) link_iostreams="yes"; break],
102                                    [link_iostreams="no"])
103                   done
105             fi
106                         if test "x$link_iostreams" != "xyes"; then
107                                 AC_MSG_ERROR(Could not link against $ax_lib !)
108                         fi
109                 fi
111                 CPPFLAGS="$CPPFLAGS_SAVED"
112         LDFLAGS="$LDFLAGS_SAVED"
113         fi