1 # ===========================================================================
2 # http://www.gnu.org/software/autoconf-archive/ax_boost_regex.html
3 # ===========================================================================
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>.
17 # AC_SUBST(BOOST_REGEX_LIB)
25 # Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
26 # Copyright (c) 2008 Michael Tindal
28 # Copying and distribution of this file, with or without modification, are
29 # permitted in any medium without royalty provided the copyright notice
30 # and this notice are preserved. This file is offered as-is, without any
35 AC_DEFUN([AX_BOOST_REGEX],
37 AC_ARG_WITH([boost-regex],
38 AS_HELP_STRING([--with-boost-regex@<:@=special-lib@:>@],
39 [use the Regex library from boost - it is possible to specify a certain library for the linker
40 e.g. --with-boost-regex=boost_regex-gcc-mt-d-1_33_1 ]),
42 if test "$withval" = "no"; then
44 elif test "$withval" = "yes"; then
46 ax_boost_user_regex_lib=""
49 ax_boost_user_regex_lib="$withval"
55 if test "x$want_boost" = "xyes"; then
56 AC_REQUIRE([AC_PROG_CC])
57 CPPFLAGS_SAVED="$CPPFLAGS"
58 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
61 LDFLAGS_SAVED="$LDFLAGS"
62 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
65 AC_CACHE_CHECK(whether the Boost::Regex library is available,
68 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/regex.hpp>
70 [[boost::regex r(); return 0;]])],
71 ax_cv_boost_regex=yes, ax_cv_boost_regex=no)
74 if test "x$ax_cv_boost_regex" = "xyes"; then
75 AC_DEFINE(HAVE_BOOST_REGEX,,[define if the Boost::Regex library is available])
76 BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
77 if test "x$ax_boost_user_regex_lib" = "x"; then
78 for libextension in `ls $BOOSTLIBDIR/libboost_regex*.so* $BOOSTLIBDIR/libboost_regex*.dylib* $BOOSTLIBDIR/libboost_regex*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_regex.*\)\.so.*$;\1;' -e 's;^lib\(boost_regex.*\)\.dylib.*;\1;' -e 's;^lib\(boost_regex.*\)\.a.*$;\1;'` ; do
79 ax_lib=${libextension}
80 AC_CHECK_LIB($ax_lib, exit,
81 [BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break],
84 if test "x$link_regex" != "xyes"; then
85 for libextension in `ls $BOOSTLIBDIR/boost_regex*.dll* $BOOSTLIBDIR/boost_regex*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_regex.*\)\.dll.*$;\1;' -e 's;^\(boost_regex.*\)\.a.*$;\1;'` ; do
86 ax_lib=${libextension}
87 AC_CHECK_LIB($ax_lib, exit,
88 [BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break],
94 for ax_lib in $ax_boost_user_regex_lib boost_regex-$ax_boost_user_regex_lib; do
95 AC_CHECK_LIB($ax_lib, main,
96 [BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break],
100 if test "x$ax_lib" = "x"; then
101 AC_MSG_ERROR(Could not find a version of the Boost::Regex library!)
103 if test "x$link_regex" != "xyes"; then
104 AC_MSG_ERROR(Could not link against $ax_lib !)
108 CPPFLAGS="$CPPFLAGS_SAVED"
109 LDFLAGS="$LDFLAGS_SAVED"