1 # ===========================================================================
2 # http://autoconf-archive.cryp.to/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)
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 ]),
43 if test "$withval" = "no"; then
45 elif test "$withval" = "yes"; then
47 ax_boost_user_regex_lib=""
50 ax_boost_user_regex_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"
66 AC_CACHE_CHECK(whether the Boost::Regex library is available,
69 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/regex.hpp>
71 [[boost::regex r(); return 0;]]),
72 ax_cv_boost_regex=yes, ax_cv_boost_regex=no)
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],
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],
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],
101 if test "x$link_regex" != "xyes"; then
102 AC_MSG_ERROR(Could not link against $ax_lib !)
106 CPPFLAGS="$CPPFLAGS_SAVED"
107 LDFLAGS="$LDFLAGS_SAVED"