diff configure.in @ 7173:ff2ff2c09865

[project @ 2007-11-14 18:20:49 by jwe]
author jwe
date Wed, 14 Nov 2007 18:20:50 +0000
parents f83b2ca41b05
children ff4a4cc863a9
line wrap: on
line diff
--- a/configure.in	Wed Nov 14 16:17:11 2007 +0000
+++ b/configure.in	Wed Nov 14 18:20:50 2007 +0000
@@ -29,7 +29,7 @@
 EXTERN_CXXFLAGS="$CXXFLAGS"
 
 AC_INIT
-AC_REVISION($Revision: 1.593 $)
+AC_REVISION($Revision: 1.594 $)
 AC_PREREQ(2.57)
 AC_CONFIG_SRCDIR([src/octave.cc])
 AC_CONFIG_HEADER(config.h)
@@ -423,40 +423,39 @@
 AC_SUBST(TEXINFO_QHULL)
 
 ### Check for pcre/regex library.
-WITH_PCRE=no
-REGEX_LIBS=
-AC_CHECK_LIB(pcre, pcre_compile, [
-  m4_foreach_w([hdr], [pcre/pcre.h pcre.h],
-    [AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([hdr])),
-	   [Define to 1 if you have the <]m4_defn([hdr])[>
-	    header file, and it defines PCRE_INFO_NAMECOUNT,
-	    PCRE_INFO_NAMEENTRYSIZE, and PCRE_INFO_NAMETABLE.])])
-  for hdr in pcre/pcre.h pcre.h; do
-    AC_MSG_CHECKING([whether $hdr defines the macros we need])
-    AC_EGREP_CPP([PCRE_HAS_MACROS_WE_NEED], [
-#include <$hdr>
+
+## check for pcre-config, and if so, set CPPFLAGS appropriately
+AC_CHECK_PROG(WITH_PCRE_CONFIG, pcre-config, yes, no)
+if test $WITH_PCRE_CONFIG = yes ; then
+  CPPFLAGS="$CPPFLAGS $(pcre-config --cflags)"
+fi
+
+## NB: no need to do separate check for pcre.h header -- checking macros is good enough
+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], [
+#include <pcre.h>
 #if defined (PCRE_INFO_NAMECOUNT) \
   && defined (PCRE_INFO_NAMEENTRYSIZE) \
   && defined (PCRE_INFO_NAMETABLE)
 PCRE_HAS_MACROS_WE_NEED
-#endif], [
-dnl We check the header after the egrep to avoid defining HAVE_X_H macros
-dnl for headers that we can't use.
-      AC_MSG_RESULT([yes])
-      AC_CHECK_HEADER($hdr, [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$hdr), 1)])
-      AC_DEFINE(HAVE_PCRE, 1, [Define if PCRE is available.])
-      WITH_PCRE=yes
-      REGEX_LIBS=-lpcre
-      break
-    ], [AC_MSG_RESULT([no])])
-  done
-])
+#endif], ac_cv_pcre_h_macros_present=yes, ac_cv_pcre_h_macros_present=no)])
+WITH_PCRE="$ac_cv_pcre_h_macros_present"
 
+REGEX_LIBS=
+if test $WITH_PCRE = yes; then
+  AC_DEFINE(HAVE_PCRE, 1, [Define if PCRE is available.])
+  if test $WITH_PCRE_CONFIG = yes; then
+    REGEX_LIBS=$(pcre-config --libs)
+  else
+    REGEX_LIBS=-lpcre
+  fi
+fi
 if test $WITH_PCRE = no; then
   warn_pcre="PCRE library not found.  This will result in some loss of functionality for the regular expression matching functions."
   AC_MSG_WARN($warn_pcre)
 fi
 
+## not sure why we need to check for regex like this if pcre is defined, but it was like this when I got here ...
 AC_CHECK_FUNCS(regexec, WITH_REGEX=yes , [
   AC_CHECK_LIB(regex, regexec, WITH_REGEX=yes, WITH_REGEX=no)])
 if test $WITH_REGEX = yes ; then
@@ -470,6 +469,7 @@
   warn_regex="regular expression functions not found.  The regular expression matching functions will be disabled."
   AC_MSG_WARN($warn_regex)
 fi
+
 AC_SUBST(REGEX_LIBS)
 
 ### Check for ZLIB library.