# LIBPCRE2_CHECK_CONFIG ([DEFAULT-ACTION])
# ----------------------------------------------------------
# This macro #defines HAVE_PCRE2_H if required header files are
# found, and sets @LIBPCRE2_LDFLAGS@ and @LIBPCRE2_CFLAGS@ to the necessary
# 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([LIBPCRE2_TRY_LINK],
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#define PCRE2_CODE_UNIT_WIDTH 8
PCRE2_SIZE error_offset = 0;
pcre2_code *regexp = pcre2_compile("test", PCRE2_ZERO_TERMINATED, PCRE2_UTF, &error, &error_offset, NULL);
]])],[found_libpcre2="yes"],[])
AC_DEFUN([LIBPCRE2_CHECK_CONFIG],
If you want to specify libpcre2 installation directories:
AS_HELP_STRING([--with-libpcre2@<:@=DIR@:>@], [use libpcre2 from given base install directory (DIR), default is to search through a number of common places for the libpcre2 files.])],
if test "$withval" != "no"; then
if test "$withval" != "yes"; then
AC_ARG_WITH([libpcre2-include], AS_HELP_STRING([--with-libpcre2-include@<:@=DIR@:>@], [use libpcre2 include headers from given path.]), [
libpcre2_include_dir="$withval"
if ! test -d "$libpcre2_include_dir"; then
AC_MSG_ERROR([cannot find $libpcre2_include_dir directory])
if ! test -f "$libpcre2_include_dir/pcre2.h"; then
AC_MSG_ERROR([cannot find $libpcre2_include_dir/pcre2.h])
AC_ARG_WITH([libpcre2-lib], AS_HELP_STRING([--with-libpcre2-lib@<:@=DIR@:>@], [use libpcre2 libraries from given path.]), [
libpcre2_lib_dir="$withval"
if ! test -d "$libpcre2_lib_dir"; then
AC_MSG_ERROR([cannot find $libpcre2_lib_dir directory])
# 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 "$libpcre2_lib_dir"; then
export PKG_CONFIG_LIBDIR="$libpcre2_lib_dir/pkgconfig"
elif test -n "$libpcre2_dir"; then
export PKG_CONFIG_LIBDIR="$libpcre2_dir/lib/pkgconfig"