1 # ===========================================================================
2 # http://www.gnu.org/software/autoconf-archive/ax_boost_filesystem.html
3 # ===========================================================================
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>.
17 # AC_SUBST(BOOST_FILESYSTEM_LIB)
21 # HAVE_BOOST_FILESYSTEM
25 # Copyright (c) 2009 Thomas Porschberg <thomas@randspringer.de>
26 # Copyright (c) 2009 Michael Tindal
27 # Copyright (c) 2009 Roman Rybalko <libtorrent@romanr.info>
29 # Copying and distribution of this file, with or without modification, are
30 # permitted in any medium without royalty provided the copyright notice
31 # and this notice are preserved. This file is offered as-is, without any
36 AC_DEFUN([AX_BOOST_FILESYSTEM],
38 AC_ARG_WITH([boost-filesystem],
39 AS_HELP_STRING([--with-boost-filesystem@<:@=special-lib@:>@],
40 [use the Filesystem library from boost - it is possible to specify a certain library for the linker
41 e.g. --with-boost-filesystem=boost_filesystem-gcc-mt ]),
43 if test "$withval" = "no"; then
45 elif test "$withval" = "yes"; then
47 ax_boost_user_filesystem_lib=""
50 ax_boost_user_filesystem_lib="$withval"
56 if test "x$want_boost" = "xyes"; then
57 AC_REQUIRE([AC_PROG_CC])
58 CPPFLAGS_SAVED="$CPPFLAGS"
59 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
62 LDFLAGS_SAVED="$LDFLAGS"
63 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
67 LIBS="$LIBS $BOOST_SYSTEM_LIB"
70 AC_CACHE_CHECK(whether the Boost::Filesystem library is available,
71 ax_cv_boost_filesystem,
73 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/filesystem/path.hpp>]],
74 [[using namespace boost::filesystem;
75 path my_path( "foo/bar/data.txt" );
77 ax_cv_boost_filesystem=yes, ax_cv_boost_filesystem=no)
80 if test "x$ax_cv_boost_filesystem" = "xyes"; then
81 AC_DEFINE(HAVE_BOOST_FILESYSTEM,,[define if the Boost::Filesystem library is available])
82 BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
84 if test "x$ax_boost_user_filesystem_lib" = "x"; then
85 for libextension in `ls -r $BOOSTLIBDIR/libboost_filesystem* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do
86 ax_lib=${libextension}
87 AC_CHECK_LIB($ax_lib, exit,
88 [BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break],
89 [link_filesystem="no"])
91 if test "x$link_filesystem" != "xyes"; then
92 for libextension in `ls -r $BOOSTLIBDIR/boost_filesystem* 2>/dev/null | sed 's,.*/,,' | sed -e 's,\..*,,'` ; do
93 ax_lib=${libextension}
94 AC_CHECK_LIB($ax_lib, exit,
95 [BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break],
96 [link_filesystem="no"])
100 for ax_lib in $ax_boost_user_filesystem_lib boost_filesystem-$ax_boost_user_filesystem_lib; do
101 AC_CHECK_LIB($ax_lib, exit,
102 [BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break],
103 [link_filesystem="no"])
107 if test "x$ax_lib" = "x"; then
108 AC_MSG_ERROR(Could not find a version of the boost_filesystem library!)
110 if test "x$link_filesystem" != "xyes"; then
111 AC_MSG_ERROR(Could not link against $ax_lib !)
115 CPPFLAGS="$CPPFLAGS_SAVED"
116 LDFLAGS="$LDFLAGS_SAVED"