ax_boost_filesystem.m4 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. # ===========================================================================
  2. # http://autoconf-archive.cryp.to/ax_boost_filesystem.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_BOOST_FILESYSTEM
  8. #
  9. # DESCRIPTION
  10. #
  11. # Test for Filesystem 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_FILESYSTEM_LIB)
  18. #
  19. # And sets:
  20. #
  21. # HAVE_BOOST_FILESYSTEM
  22. #
  23. # LAST MODIFICATION
  24. #
  25. # 2008-04-12
  26. #
  27. # COPYLEFT
  28. #
  29. # Copyright (c) 2008 Thomas Porschberg <[email protected]>
  30. # Copyright (c) 2008 Michael Tindal
  31. #
  32. # Copying and distribution of this file, with or without modification, are
  33. # permitted in any medium without royalty provided the copyright notice
  34. # and this notice are preserved.
  35. AC_DEFUN([AX_BOOST_FILESYSTEM],
  36. [
  37. AC_ARG_WITH([boost-filesystem],
  38. AS_HELP_STRING([--with-boost-filesystem@<:@=special-lib@:>@],
  39. [use the Filesystem library from boost - it is possible to specify a certain library for the linker
  40. e.g. --with-boost-filesystem=boost_filesystem-gcc-mt ]),
  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_filesystem_lib=""
  47. else
  48. want_boost="yes"
  49. ax_boost_user_filesystem_lib="$withval"
  50. fi
  51. ],
  52. [want_boost="yes"]
  53. )
  54. if test "x$want_boost" = "xyes"; then
  55. AC_REQUIRE([AC_PROG_CC])
  56. CPPFLAGS_SAVED="$CPPFLAGS"
  57. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  58. export CPPFLAGS
  59. LDFLAGS_SAVED="$LDFLAGS"
  60. LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
  61. export LDFLAGS
  62. AC_CACHE_CHECK(whether the Boost::Filesystem library is available,
  63. ax_cv_boost_filesystem,
  64. [AC_LANG_PUSH([C++])
  65. AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/filesystem/path.hpp>]],
  66. [[using namespace boost::filesystem;
  67. path my_path( "foo/bar/data.txt" );
  68. return 0;]]),
  69. ax_cv_boost_filesystem=yes, ax_cv_boost_filesystem=no)
  70. AC_LANG_POP([C++])
  71. ])
  72. if test "x$ax_cv_boost_filesystem" = "xyes"; then
  73. AC_DEFINE(HAVE_BOOST_FILESYSTEM,,[define if the Boost::Filesystem library is available])
  74. BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
  75. if test "x$ax_boost_user_filesystem_lib" = "x"; then
  76. for libextension in `ls $BOOSTLIBDIR/libboost_filesystem*.{so,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_filesystem.*\)\.so.*$;\1;' -e 's;^lib\(boost_filesystem.*\)\.a*$;\1;'` ; do
  77. ax_lib=${libextension}
  78. AC_CHECK_LIB($ax_lib, exit,
  79. [BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break],
  80. [link_filesystem="no"])
  81. done
  82. if test "x$link_program_options" != "xyes"; then
  83. for libextension in `ls $BOOSTLIBDIR/boost_filesystem*.{dll,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_filesystem.*\)\.dll.*$;\1;' -e 's;^\(boost_filesystem.*\)\.a*$;\1;'` ; do
  84. ax_lib=${libextension}
  85. AC_CHECK_LIB($ax_lib, exit,
  86. [BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break],
  87. [link_filesystem="no"])
  88. done
  89. fi
  90. else
  91. for ax_lib in $ax_boost_user_filesystem_lib boost_filesystem-$ax_boost_user_filesystem_lib; do
  92. AC_CHECK_LIB($ax_lib, exit,
  93. [BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break],
  94. [link_filesystem="no"])
  95. done
  96. fi
  97. if test "x$link_filesystem" != "xyes"; then
  98. AC_MSG_ERROR(Could not link against $ax_lib !)
  99. fi
  100. fi
  101. CPPFLAGS="$CPPFLAGS_SAVED"
  102. LDFLAGS="$LDFLAGS_SAVED"
  103. fi
  104. ])