fix piece_picker piece-shuffle bug
[libtorrent.git] / m4 / ax_boost_regex.m4
blobd5c39eff5fbdb875d73ee2b63d6c3b3eac7bf768
1 # ===========================================================================
2 #             http://autoconf-archive.cryp.to/ax_boost_regex.html
3 # ===========================================================================
5 # SYNOPSIS
7 #   AX_BOOST_REGEX
9 # DESCRIPTION
11 #   Test for Regex library from the Boost C++ libraries. The macro requires
12 #   a preceding call to AX_BOOST_BASE. Further documentation is available at
13 #   <http://randspringer.de/boost/index.html>.
15 #   This macro calls:
17 #     AC_SUBST(BOOST_REGEX_LIB)
19 #   And sets:
21 #     HAVE_BOOST_REGEX
23 # LAST MODIFICATION
25 #   2008-04-12
27 # COPYLEFT
29 #   Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
30 #   Copyright (c) 2008 Michael Tindal
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.
36 AC_DEFUN([AX_BOOST_REGEX],
38         AC_ARG_WITH([boost-regex],
39         AS_HELP_STRING([--with-boost-regex@<:@=special-lib@:>@],
40                    [use the Regex library from boost - it is possible to specify a certain library for the linker
41                         e.g. --with-boost-regex=boost_regex-gcc-mt-d-1_33_1 ]),
42         [
43         if test "$withval" = "no"; then
44                         want_boost="no"
45         elif test "$withval" = "yes"; then
46             want_boost="yes"
47             ax_boost_user_regex_lib=""
48         else
49                     want_boost="yes"
50                 ax_boost_user_regex_lib="$withval"
51                 fi
52         ],
53         [want_boost="yes"]
54         )
56         if test "x$want_boost" = "xyes"; then
57         AC_REQUIRE([AC_PROG_CC])
58                 CPPFLAGS_SAVED="$CPPFLAGS"
59                 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
60                 export CPPFLAGS
62                 LDFLAGS_SAVED="$LDFLAGS"
63                 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
64                 export LDFLAGS
66         AC_CACHE_CHECK(whether the Boost::Regex library is available,
67                                            ax_cv_boost_regex,
68         [AC_LANG_PUSH([C++])
69                          AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/regex.hpp>
70                                                                                                 ]],
71                                    [[boost::regex r(); return 0;]]),
72                    ax_cv_boost_regex=yes, ax_cv_boost_regex=no)
73          AC_LANG_POP([C++])
74                 ])
75                 if test "x$ax_cv_boost_regex" = "xyes"; then
76                         AC_DEFINE(HAVE_BOOST_REGEX,,[define if the Boost::Regex library is available])
77             BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
78             if test "x$ax_boost_user_regex_lib" = "x"; then
79                 for libextension in `ls $BOOSTLIBDIR/libboost_regex*.{so,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_regex.*\)\.so.*$;\1;' -e 's;^lib\(boost_regex.*\)\.a*$;\1;'` ; do
80                      ax_lib=${libextension}
81                                     AC_CHECK_LIB($ax_lib, exit,
82                                  [BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break],
83                                  [link_regex="no"])
84                                 done
85                 if test "x$link_regex" != "xyes"; then
86                 for libextension in `ls $BOOSTLIBDIR/boost_regex*.{dll,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_regex.*\)\.dll.*$;\1;' -e 's;^\(boost_regex.*\)\.a*$;\1;'` ; do
87                      ax_lib=${libextension}
88                                     AC_CHECK_LIB($ax_lib, exit,
89                                  [BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break],
90                                  [link_regex="no"])
91                                 done
92                 fi
94             else
95                for ax_lib in $ax_boost_user_regex_lib boost_regex-$ax_boost_user_regex_lib; do
96                                       AC_CHECK_LIB($ax_lib, main,
97                                    [BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break],
98                                    [link_regex="no"])
99                done
100             fi
101                         if test "x$link_regex" != "xyes"; then
102                                 AC_MSG_ERROR(Could not link against $ax_lib !)
103                         fi
104                 fi
106                 CPPFLAGS="$CPPFLAGS_SAVED"
107         LDFLAGS="$LDFLAGS_SAVED"
108         fi