1 # ===========================================================================
2 # http://www.gnu.org/software/autoconf-archive/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
25 # Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
27 # Copying and distribution of this file, with or without modification, are
28 # permitted in any medium without royalty provided the copyright notice
29 # and this notice are preserved. This file is offered as-is, without any
34 AC_DEFUN([AX_BOOST_IOSTREAMS],
36 AC_ARG_WITH([boost-iostreams],
37 AS_HELP_STRING([--with-boost-iostreams@<:@=special-lib@:>@],
38 [use the IOStreams library from boost - it is possible to specify a certain library for the linker
39 e.g. --with-boost-iostreams=boost_iostreams-gcc-mt-d-1_33_1 ]),
41 if test "$withval" = "no"; then
43 elif test "$withval" = "yes"; then
45 ax_boost_user_iostreams_lib=""
48 ax_boost_user_iostreams_lib="$withval"
54 if test "x$want_boost" = "xyes"; then
55 AC_REQUIRE([AC_PROG_CC])
56 CPPFLAGS_SAVED="$CPPFLAGS"
57 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
60 LDFLAGS_SAVED="$LDFLAGS"
61 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
64 AC_CACHE_CHECK(whether the Boost::IOStreams library is available,
65 ax_cv_boost_iostreams,
67 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/iostreams/filtering_stream.hpp>
68 @%:@include <boost/range/iterator_range.hpp>
70 [[std::string input = "Hello World!";
71 namespace io = boost::iostreams;
72 io::filtering_istream in(boost::make_iterator_range(input));
75 ax_cv_boost_iostreams=yes, ax_cv_boost_iostreams=no)
78 if test "x$ax_cv_boost_iostreams" = "xyes"; then
79 AC_DEFINE(HAVE_BOOST_IOSTREAMS,,[define if the Boost::IOStreams library is available])
80 BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
81 if test "x$ax_boost_user_iostreams_lib" = "x"; then
82 for libextension in `ls $BOOSTLIBDIR/libboost_iostreams*.so* $BOOSTLIBDIR/libboost_iostream*.dylib* $BOOSTLIBDIR/libboost_iostreams*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_iostreams.*\)\.so.*$;\1;' -e 's;^lib\(boost_iostream.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_iostreams.*\)\.a.*$;\1;'` ; do
83 ax_lib=${libextension}
84 AC_CHECK_LIB($ax_lib, exit,
85 [BOOST_IOSTREAMS_LIB="-l$ax_lib"; AC_SUBST(BOOST_IOSTREAMS_LIB) link_iostreams="yes"; break],
86 [link_iostreams="no"])
88 if test "x$link_iostreams" != "xyes"; then
89 for libextension in `ls $BOOSTLIBDIR/boost_iostreams*.dll* $BOOSTLIBDIR/boost_iostreams*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_iostreams.*\)\.dll.*$;\1;' -e 's;^\(boost_iostreams.*\)\.a.*$;\1;'` ; do
90 ax_lib=${libextension}
91 AC_CHECK_LIB($ax_lib, exit,
92 [BOOST_IOSTREAMS_LIB="-l$ax_lib"; AC_SUBST(BOOST_IOSTREAMS_LIB) link_iostreams="yes"; break],
93 [link_iostreams="no"])
98 for ax_lib in $ax_boost_user_iostreams_lib boost_iostreams-$ax_boost_user_iostreams_lib; do
99 AC_CHECK_LIB($ax_lib, main,
100 [BOOST_IOSTREAMS_LIB="-l$ax_lib"; AC_SUBST(BOOST_IOSTREAMS_LIB) link_iostreams="yes"; break],
101 [link_iostreams="no"])
105 if test "x$ax_lib" = "x"; then
106 AC_MSG_ERROR(Could not find a version of the library!)
108 if test "x$link_iostreams" != "xyes"; then
109 AC_MSG_ERROR(Could not link against $ax_lib !)
113 CPPFLAGS="$CPPFLAGS_SAVED"
114 LDFLAGS="$LDFLAGS_SAVED"