1 # ===========================================================================
2 # http://autoconf-archive.cryp.to/ax_boost_iostreams.html
3 # ===========================================================================
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>.
17 # AC_SUBST(BOOST_IOSTREAMS_LIB)
21 # HAVE_BOOST_IOSTREAMS
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 ]),
42 if test "$withval" = "no"; then
44 elif test "$withval" = "yes"; then
46 ax_boost_user_iostreams_lib=""
49 ax_boost_user_iostreams_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::IOStreams library is available,
66 ax_cv_boost_iostreams,
68 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/iostreams/filtering_stream.hpp>
69 @%:@include <boost/range/iterator_range.hpp>
71 [[std::string input = "Hello World!";
72 namespace io = boost::iostreams;
73 io::filtering_istream in(boost::make_iterator_range(input));
76 ax_cv_boost_iostreams=yes, ax_cv_boost_iostreams=no)
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"])
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"])
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"])
106 if test "x$link_iostreams" != "xyes"; then
107 AC_MSG_ERROR(Could not link against $ax_lib !)
111 CPPFLAGS="$CPPFLAGS_SAVED"
112 LDFLAGS="$LDFLAGS_SAVED"