# LIBPCRE_CHECK_CONFIG ([DEFAULT-ACTION])
# ----------------------------------------------------------
#
# Checks for pcre.
#
# This macro #defines HAVE_PCRE_H if required header files are
# found, and sets @LIBPCRE_LDFLAGS@ and @LIBPCRE_CFLAGS@ to the necessary
# values.
#
# This macro is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
AC_DEFUN([LIBPCRE_TRY_LINK],
[
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <pcre.h>
]], [[
const char* error = NULL;
int error_offset = -1;
pcre *regexp = pcre_compile("test", PCRE_UTF8, &error, &error_offset, NULL);
pcre_free(regexp);
]])],[found_libpcre="yes"],[])
])dnl
AC_DEFUN([LIBPCRE_CHECK_CONFIG],
[
want_libpcre=no
found_libpcre=no
libpcre_dir=""
libpcre_include_dir=""
libpcre_lib_dir=""
#
# process --with-* flags
#
AC_ARG_WITH([libpcre],[
If you want to specify libpcre installation directories:
AS_HELP_STRING([--with-libpcre@<:@=DIR@:>@], [use libpcre from given base install directory (DIR), default is to search through a number of common places for the libpcre files.])],
[
if test "$withval" != "no"; then
want_libpcre=yes
if test "$withval" != "yes"; then
libpcre_dir="$withval"
fi
fi
])
AC_ARG_WITH([libpcre-include], AS_HELP_STRING([--with-libpcre-include@<:@=DIR@:>@], [use libpcre include headers from given path.]), [
want_libpcre="yes"
libpcre_include_dir="$withval"
if ! test -d "$libpcre_include_dir"; then
AC_MSG_ERROR([cannot find $libpcre_include_dir directory])
fi
if ! test -f "$libpcre_include_dir/pcre.h"; then
AC_MSG_ERROR([cannot find $libpcre_include_dir/pcre.h])
fi
])
AC_ARG_WITH([libpcre-lib], AS_HELP_STRING([--with-libpcre-lib@<:@=DIR@:>@], [use libpcre libraries from given path.]), [
want_libpcre="yes"
libpcre_lib_dir="$withval"
if ! test -d "$libpcre_lib_dir"; then
AC_MSG_ERROR([cannot find $libpcre_lib_dir directory])
fi
])
#
# find actual compiler flags and include paths
#
if test "$1" != "flags-only"; then
AC_REQUIRE([PKG_PROG_PKG_CONFIG])
m4_ifdef([PKG_PROG_PKG_CONFIG], [PKG_PROG_PKG_CONFIG()], [:])
if test -n "$PKG_CONFIG"; then
#
# got pkg-config, use that
#
m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
if test -n "$libpcre_lib_dir"; then
export PKG_CONFIG_LIBDIR="$libpcre_lib_dir/pkgconfig"
elif test -n "$libpcre_dir"; then
export PKG_CONFIG_LIBDIR="$libpcre_dir/lib/pkgconfig"
fi
AC_RUN_LOG([$PKG_CONFIG --exists --print-errors libpcre]) || {