diff configure.ac @ 23005:8e9dd0d6e337

update check for pcre library to use pkg-config (bug #49993) * configure.ac: Use PKG_CONFIG to check for pcre library. Define PCRE_LDFLAGS separately from PCRE_LIBS. Display PCRE_LDFLAGS in summary message. * subst-config-vals.in.sh, subst-cross-config-vals.in.sh: Also substitute PCRE_LDFLAGS. * libinterp/corefcn/toplev.cc (F__octave_config_info__): Also include PCRE_LDFLAGS in the struct. * libinterp/build-env.in.cc, libinterp/build-env.h (PCRE_LDFLAGS): New variable.
author John W. Eaton <jwe@octave.org>
date Fri, 06 Jan 2017 08:08:58 -0500
parents 5fdf29cb4ab8
children b8cef5f05dcd
line wrap: on
line diff
--- a/configure.ac	Thu Jan 05 13:26:10 2017 -0500
+++ b/configure.ac	Fri Jan 06 08:08:58 2017 -0500
@@ -1339,47 +1339,15 @@
 
 ### Check for PCRE regex library.
 
-PCRE_LIBS=
-
-pcre_fail_msg="to build Octave, you must have the PCRE library and header files installed"
-
-AC_CHECK_HEADERS([pcre.h pcre/pcre.h])
-
-AC_CACHE_CHECK([whether pcre.h defines the macros we need],
-  [ac_cv_pcre_h_macros_present],
-  [AC_EGREP_CPP([PCRE_HAS_MACROS_WE_NEED], [
-    #if defined (HAVE_PCRE_H)
-    # include <pcre.h>
-    #elif defined (HAVE_PCRE_PCRE_H)
-    # include <pcre/pcre.h>
-    #error "NO PCRE HEADER"
-    #endif
-    #if defined (PCRE_INFO_NAMECOUNT) \
-      && defined (PCRE_INFO_NAMEENTRYSIZE) \
-      && defined (PCRE_INFO_NAMETABLE)
-      PCRE_HAS_MACROS_WE_NEED
-    #endif],
-    ac_cv_pcre_h_macros_present=yes, ac_cv_pcre_h_macros_present=no)])
-
-if test $ac_cv_pcre_h_macros_present = yes; then
-  ## check for pcre-config, and if so, get build variables
-  AC_CHECK_PROG(HAVE_PCRE_CONFIG, pcre-config, [yes], [no])
-  if test $HAVE_PCRE_CONFIG = yes; then
-    PCRE_CPPFLAGS=`pcre-config --cflags`
-    PCRE_LIBS=`pcre-config --libs`
-  else
-    PCRE_LIBS="-lpcre"
-  fi
-  save_LIBS="$LIBS"
-  LIBS="$PCRE_LIBS $LIBS"
-  AC_CHECK_FUNCS([pcre_compile],
-    [AC_SUBST(PCRE_CPPFLAGS)
-     AC_SUBST(PCRE_LIBS)],
-    [AC_MSG_ERROR([$pcre_fail_msg])])
-  LIBS="$save_LIBS"
-else
-  AC_MSG_ERROR([$pcre_fail_msg])
-fi
+PKG_CHECK_EXISTS([libpcre],
+  [AC_CHECK_HEADERS([pcre.h pcre/pcre.h])
+   PCRE_CPPFLAGS=`$PKG_CONFIG --cflags-only-I libpcre`
+   PCRE_LDFLAGS=`$PKG_CONFIG --libs-only-L libpcre`
+   PCRE_LIBS=`$PKG_CONFIG --libs-only-l libpcre`
+   AC_SUBST(PCRE_CPPFLAGS)
+   AC_SUBST(PCRE_LDFLAGS)
+   AC_SUBST(PCRE_LIBS)],
+  [AC_MSG_ERROR([to build Octave, you must have the PCRE library and header files installed])])
 
 ### Check for ZLIB library.
 
@@ -1392,7 +1360,6 @@
   AC_DEFINE(HAVE_ZLIB, 1, [Define to 1 if ZLIB is available.])
 fi
 
-
 ### Check for BZIP2 library.
 
 OCTAVE_CHECK_LIB(bz2, BZIP2,
@@ -3024,7 +2991,7 @@
 
 LIBOCTAVE_LINK_DEPS="$GNULIB_LINK_DEPS $CURL_LIBS $SPARSE_XLIBS $ARPACK_LIBS $QRUPDATE_LIBS $FFTW_XLIBS $LAPACK_LIBS $BLAS_LIBS $READLINE_LIBS $TERM_LIBS $LIBGLOB $PCRE_LIBS $DL_LIBS $PTHREAD_LIBS $FLIBS $LIBS"
 
-LIBOCTAVE_LINK_OPTS="$CURL_LDFLAGS $SPARSE_XLDFLAGS $ARPACK_LDFLAGS $QRUPDATE_LDFLAGS $FFTW_XLDFLAGS"
+LIBOCTAVE_LINK_OPTS="$CURL_LDFLAGS $SPARSE_XLDFLAGS $ARPACK_LDFLAGS $QRUPDATE_LDFLAGS $FFTW_XLDFLAGS $PCRE_LDFLAGS"
 
 AC_SUBST(LIBOCTAVE_LINK_DEPS)
 AC_SUBST(LIBOCTAVE_LINK_OPTS)
@@ -3323,6 +3290,7 @@
   OSMesa LDFLAGS:                $OSMESA_LDFLAGS
   OSMesa libraries:              $OSMESA_LIBS
   PCRE CPPFLAGS:                 $PCRE_CPPFLAGS
+  PCRE LDFLAGS:                  $PCRE_LDFLAGS
   PCRE libraries:                $PCRE_LIBS
   PortAudio CPPFLAGS:            $PORTAUDIO_CPPFLAGS
   PortAudio LDFLAGS:             $PORTAUDIO_LDFLAGS