# LIBPCRE2_CHECK_CONFIG ([DEFAULT-ACTION])
# ----------------------------------------------------------
#
# Checks for pcre2.
#
# This macro #defines HAVE_PCRE2_H if required header files are
# found, and sets @LIBPCRE2_LDFLAGS@ and @LIBPCRE2_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([LIBPCRE2_TRY_LINK],
[
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
]], [[
int error = 0;
PCRE2_SIZE error_offset = 0;
pcre2_code *regexp = pcre2_compile("test", PCRE2_ZERO_TERMINATED, PCRE2_UTF, &error, &error_offset, NULL);
pcre2_code_free(regexp);
]])],[found_libpcre2="yes"],[])
])dnl
AC_DEFUN([LIBPCRE2_CHECK_CONFIG],
[
want_libpcre2=no
found_libpcre2=no
libpcre2_dir=""
libpcre2_include_dir=""
libpcre2_lib_dir=""
#
# process --with-* flags
#
AC_ARG_WITH([libpcre2],[
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
want_libpcre2=yes
if test "$withval" != "yes"; then
libpcre2_dir="$withval"
fi
fi
])
AC_ARG_WITH([libpcre2-include], AS_HELP_STRING([--with-libpcre2-include@<:@=DIR@:>@], [use libpcre2 include headers from given path.]), [
want_libpcre2="yes"
libpcre2_include_dir="$withval"
if ! test -d "$libpcre2_include_dir"; then
AC_MSG_ERROR([cannot find $libpcre2_include_dir directory])
fi
if ! test -f "$libpcre2_include_dir/pcre2.h"; then
AC_MSG_ERROR([cannot find $libpcre2_include_dir/pcre2.h])
fi
])
AC_ARG_WITH([libpcre2-lib], AS_HELP_STRING([--with-libpcre2-lib@<:@=DIR@:>@], [use libpcre2 libraries from given path.]), [
want_libpcre2="yes"
libpcre2_lib_dir="$withval"
if ! test -d "$libpcre2_lib_dir"; then
AC_MSG_ERROR([cannot find $libpcre2_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 "$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"
fi