ax_boost_iostreams.m4 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. # ===========================================================================
  2. # http://autoconf-archive.cryp.to/ax_boost_iostreams.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_BOOST_IOSTREAMS
  8. #
  9. # DESCRIPTION
  10. #
  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>.
  14. #
  15. # This macro calls:
  16. #
  17. # AC_SUBST(BOOST_IOSTREAMS_LIB)
  18. #
  19. # And sets:
  20. #
  21. # HAVE_BOOST_IOSTREAMS
  22. #
  23. # LAST MODIFICATION
  24. #
  25. # 2008-04-12
  26. #
  27. # COPYLEFT
  28. #
  29. # Copyright (c) 2008 Thomas Porschberg <[email protected]>
  30. #
  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.
  34. AC_DEFUN([AX_BOOST_IOSTREAMS],
  35. [
  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 ]),
  40. [
  41. if test "$withval" = "no"; then
  42. want_boost="no"
  43. elif test "$withval" = "yes"; then
  44. want_boost="yes"
  45. ax_boost_user_iostreams_lib=""
  46. else
  47. want_boost="yes"
  48. ax_boost_user_iostreams_lib="$withval"
  49. fi
  50. ],
  51. [want_boost="yes"]
  52. )
  53. if test "x$want_boost" = "xyes"; then
  54. AC_REQUIRE([AC_PROG_CC])
  55. CPPFLAGS_SAVED="$CPPFLAGS"
  56. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  57. export CPPFLAGS
  58. LDFLAGS_SAVED="$LDFLAGS"
  59. LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
  60. export LDFLAGS
  61. AC_CACHE_CHECK(whether the Boost::IOStreams library is available,
  62. ax_cv_boost_iostreams,
  63. [AC_LANG_PUSH([C++])
  64. AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/iostreams/filtering_stream.hpp>
  65. @%:@include <boost/range/iterator_range.hpp>
  66. ]],
  67. [[std::string input = "Hello World!";
  68. namespace io = boost::iostreams;
  69. io::filtering_istream in(boost::make_iterator_range(input));
  70. return 0;
  71. ]]),
  72. ax_cv_boost_iostreams=yes, ax_cv_boost_iostreams=no)
  73. AC_LANG_POP([C++])
  74. ])
  75. if test "x$ax_cv_boost_iostreams" = "xyes"; then
  76. AC_DEFINE(HAVE_BOOST_IOSTREAMS,,[define if the Boost::IOStreams library is available])
  77. BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
  78. if test "x$ax_boost_user_iostreams_lib" = "x"; then
  79. 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
  80. ax_lib=${libextension}
  81. AC_CHECK_LIB($ax_lib, exit,
  82. [BOOST_IOSTREAMS_LIB="-l$ax_lib"; AC_SUBST(BOOST_IOSTREAMS_LIB) link_iostreams="yes"; break],
  83. [link_iostreams="no"])
  84. done
  85. if test "x$link_iostreams" != "xyes"; then
  86. 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
  87. ax_lib=${libextension}
  88. AC_CHECK_LIB($ax_lib, exit,
  89. [BOOST_IOSTREAMS_LIB="-l$ax_lib"; AC_SUBST(BOOST_IOSTREAMS_LIB) link_iostreams="yes"; break],
  90. [link_iostreams="no"])
  91. done
  92. fi
  93. else
  94. for ax_lib in $ax_boost_user_iostreams_lib boost_iostreams-$ax_boost_user_iostreams_lib; do
  95. AC_CHECK_LIB($ax_lib, main,
  96. [BOOST_IOSTREAMS_LIB="-l$ax_lib"; AC_SUBST(BOOST_IOSTREAMS_LIB) link_iostreams="yes"; break],
  97. [link_iostreams="no"])
  98. done
  99. fi
  100. if test "x$link_iostreams" != "xyes"; then
  101. AC_MSG_ERROR(Could not link against $ax_lib !)
  102. fi
  103. fi
  104. CPPFLAGS="$CPPFLAGS_SAVED"
  105. LDFLAGS="$LDFLAGS_SAVED"
  106. fi
  107. ])