+dnl # Check for libexecinfo support, on some systems this is built into libc
+dnl # on others it's a separate library.
+dnl #
+dnl extra argument: --with-execinfo-lib-dir
+execinfo_lib_dir=
+AC_ARG_WITH(execinfo-lib-dir,
+[AS_HELP_STRING([--with-execinfo-lib-dir=DIR],
+[directory in which to look for execinfo library files])],
+[ case "$withval" in
+ no)
+ AC_MSG_ERROR([Need execinfo-lib-dir])
+ ;;
+ yes)
+ ;;
+ *)
+ execinfo_lib_dir="$withval"
+ ;;
+ esac ]
+)
+
+dnl extra argument: --with-execinfo-include-dir
+execinfo_include_dir=
+AC_ARG_WITH(execinfo-include-dir,
+[AS_HELP_STRING([--with-execinfo-include-dir=DIR],
+[directory in which to look for execinfo include files])],
+[ case "$withval" in
+ no)
+ AC_MSG_ERROR([Need execinfo-include-dir])
+ ;;
+ yes)
+ ;;
+ *)
+ execinfo_include_dir="$withval"
+ ;;
+ esac ]
+)
+
+dnl #
+dnl # Look for execinfo.h and symbols
+dnl #
+smart_try_dir=$execinfo_include_dir
+FR_SMART_CHECK_INCLUDE(execinfo.h)
+if test "x$ac_cv_header_execinfo_h" = "xyes"; then
+ smart_try_dir=$execinfo_lib_dir
+ FR_SMART_CHECK_LIB(execinfo, backtrace_symbols)
+ if test "x$ac_cv_lib_execinfo_backtrace_symbols" != "xyes"; then
+ dnl # Might be provided as part of libc
+ AC_MSG_CHECKING([if execinfo provided as part of libc])
+ AC_TRY_LINK(
+ [
+ #include <execinfo.h>
+ ],
+ [
+ void *sym[1];
+ backtrace_symbols(&sym, sizeof(sym)) ],
+ [
+ AC_MSG_RESULT(yes)
+ ac_cv_lib_execinfo_backtrace_symbols="yes"
+ ],
+ [
+ AC_MSG_RESULT(no)
+ ]
+ )
+ fi
+
+ if test "x$ac_cv_lib_execinfo_backtrace_symbols" = "xyes"; then
+ AC_DEFINE(HAVE_EXECINFO, [1], [define this if we have <execinfo.h> and symbols])
+ fi
+fi
+
+dnl #
+dnl # Check for regular expression support.
+dnl #
+dnl extra argument: --with-pcre
+PCRE=yes
+AC_ARG_WITH(pcre,
+[AS_HELP_STRING([--with-pcre],
+[use libpcre (if available). (default=yes)])],
+[ case "$withval" in
+ no)
+ PCRE=no
+ ;;
+ yes)
+ PCRE=yes
+ ;;
+ esac ]
+)
+
+dnl extra argument: --with-pcre-lib-dir
+pcre_lib_dir=
+AC_ARG_WITH(pcre-lib-dir,
+[AS_HELP_STRING([--with-pcre-lib-dir=DIR],
+[directory in which to look for pcre library files])],
+[ case "$withval" in
+ no)
+ AC_MSG_ERROR(Need pcre-lib-dir)
+ ;;
+ yes)
+ ;;
+ *)
+ pcre_lib_dir="$withval"
+ ;;
+ esac ]
+)
+
+dnl extra argument: --with-pcre-include-dir
+pcre_include_dir=
+AC_ARG_WITH(pcre-include-dir,
+[AS_HELP_STRING([--with-pcre-include-dir=DIR],
+[directory in which to look for pcre include files])],
+[ case "$withval" in
+ no)
+ AC_MSG_ERROR(Need pcre-include-dir)
+ ;;
+ yes)
+ ;;
+ *)
+ pcre_include_dir="$withval"
+ ;;
+ esac ]
+)
+
+dnl extra argument: --with-regex
+REGEX=
+AC_ARG_WITH(regex,
+[AS_HELP_STRING([--with-regex],
+[Whether to build with regular expressions (default=yes)])],
+[ case "$withval" in
+ no)
+ REGEX=no
+ ;;
+ *)
+ ;;
+ esac ]
+)
+
+dnl #
+dnl # First look for PCRE
+dnl #
+if test "x$REGEX" != "xno" && test "x$PCRE" != "xno"; then
+ smart_try_dir=$pcre_include_dir
+ FR_SMART_CHECK_INCLUDE(pcre.h)
+ if test "x$ac_cv_header_pcre_h" = "xyes"; then
+ smart_try_dir=$pcre_lib_dir
+ FR_SMART_CHECK_LIB(pcre, pcre_compile)
+ if test "x$ac_cv_lib_pcre_pcre_compile" = "xyes"; then
+ REGEX=yes
+ AC_DEFINE(HAVE_PCRE, [1], [define this if we have libpcre])
+ AC_DEFINE(HAVE_BINSAFE_REGEX, 1, [Define if we have a binary safe regular expression library])
+ fi
+ fi
+fi
+
+dnl #
+dnl # If no PCRE, fallback to POSIX regular expressions
+dnl #
+if test "x$REGEX" = "x"; then
+ smart_try_dir=
+ FR_SMART_CHECK_INCLUDE(regex.h)
+ if test "x$ac_cv_header_regex_h" = "xyes"; then
+ REGEX=yes
+ AC_MSG_CHECKING([for extended regular expressions])
+ AC_EGREP_CPP(yes,
+ [
+ #include <regex.h>
+ #ifdef REG_EXTENDED
+ yes
+ #endif
+ ],
+ [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_REG_EXTENDED, [1], [define this if we have REG_EXTENDED (from <regex.h>)])
+ ],
+ [
+ AC_MSG_RESULT(no)
+ ]
+ )
+
+ dnl #
+ dnl # Some platforms require the regex library to be linked explicitly
+ dnl #
+ AC_CHECK_LIB(regex, regcomp,
+ [
+ LIBS="-lregex $LIBS"
+ ]
+ )
+
+ dnl #
+ dnl # Check for some BSD extensions which allow normal regexes to be
+ dnl # binary safe.
+ dnl #
+ AC_CHECK_FUNCS(\
+ regncomp \
+ regnexec
+ )
+ if test x"$ac_cv_func_regncomp" = x"yes" && test x"$ac_cv_func_regnexec" = x"yes"; then
+ AC_DEFINE(HAVE_BINSAFE_REGEX, 1, [Define if we have a binary safe regular expression library])
+ fi
+ fi
+fi
+
+if test "x$REGEX" = "xyes"; then
+ AC_DEFINE(HAVE_REGEX, 1, [Define if we have any regular expression library])
+fi
+
+dnl #