From 57a15651b46a0f1f84a4dd15d67d104fbfbe3f6e Mon Sep 17 00:00:00 2001
From: Koen Kooi <koen.kooi@linaro.org>
Date: Tue, 17 Jun 2014 08:18:17 +0200
Subject: [PATCH] configure: use pkg-config for pcre detection

Signed-off-by: Koen Kooi <koen.kooi@linaro.org>
Upstream-Status: Pending

---
 configure.ac | 39 +++++++--------------------------------
 1 file changed, 7 insertions(+), 32 deletions(-)

diff --git a/configure.ac b/configure.ac
index c060028..a330266 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,39 +49,14 @@ AC_MSG_RESULT([$with_pcre])
 
 dnl To make configuring easier, check for a locally built PCRE using the Tools/pcre-build.sh script
 if test x"${with_pcre}" = xyes ; then
-  AC_MSG_CHECKING([whether to use local PCRE2])
-  local_pcre_config=no
-  if test -z "$PCRE2_CONFIG"; then
-    if test -f `pwd`/pcre/pcre-swig-install/bin/pcre2-config; then
-      PCRE2_CONFIG=`pwd`/pcre/pcre-swig-install/bin/pcre2-config
-      local_pcre_config=$PCRE2_CONFIG
-    fi
-  fi
-  AC_MSG_RESULT([$local_pcre_config])
-fi
-AS_IF([test "x$with_pcre" != xno],
-  [AX_PATH_GENERIC([pcre2],
-    [], dnl Minimal version of PCRE we need -- accept any
-    [], dnl custom sed script for version parsing is not needed
-    [AC_DEFINE([HAVE_PCRE], [1], [Define if you have PCRE2 library])
-     LIBS="$LIBS $PCRE2_LIBS"
-     CPPFLAGS="$CPPFLAGS $PCRE2_CFLAGS"
-    ],
-    [AC_MSG_FAILURE([
-        Cannot find pcre2-config script from PCRE2 (Perl Compatible Regular Expressions)
-        library package. This dependency is needed for configure to complete,
-        Either:
-        - Install the PCRE2 developer package on your system (preferred approach).
-        - Download the PCRE2 source tarball, build and install on your system
-          as you would for any package built from source distribution.
-        - Use the Tools/pcre-build.sh script to build PCRE2 just for SWIG to statically
-          link against. Run 'Tools/pcre-build.sh --help' for instructions.
-          (quite easy and does not require privileges to install PCRE2 on your system)
-        - Use configure --without-pcre to disable regular expressions support in SWIG
-          (not recommended).])
-    ],
-    [],[],[--libs8])
+  PKG_CHECK_MODULES([PCRE], [libpcre2], [
+    AC_DEFINE([HAVE_PCRE], [1], [Define if you have PCRE library])
+    LIBS="$LIBS $PCRE_LIBS"
+    CPPFLAGS="$CPPFLAGS $PCRE_CFLAGS"
+  ], [
+    AC_MSG_WARN([$PCRE_PKG_ERRORS])
   ])
+fi
 
 
 dnl CCache
