bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: test-fcntl-h-c++.cc:32: error: 'open' is not a member of 'gnulib'


From: Jim Meyering
Subject: Re: test-fcntl-h-c++.cc:32: error: 'open' is not a member of 'gnulib'
Date: Wed, 24 Mar 2010 08:46:45 +0100

Bruno Haible wrote:
>> I am ambivalent about pkg-config, and cannot justify
>> its use in grep, but will wait until after 2.6 to remove it.
>
> I wasn't asking to remove pkg-config, but only to distribute the complete
> source code of aclocal.m4, excluding released versions of Automake.

Thanks for raising the pkg-config issue.  I understood what you suggested,
but prefer to avoid pkg-config altogether, when convenient.  I'm using
the following patch, which is similar to coreutils' m4/xattr.m4:


>From ca128fdf6db35466eef14b87cb19ec6c1065ab2c Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 24 Mar 2010 08:40:05 +0100
Subject: [PATCH] build: do not use pkg-config to test for PCRE support

* configure.ac: Do not use PKG_PROG_PKG_CONFIG or PKG_CHECK_MODULES.
Do not modify CPPFLAGS; that belongs to those who invoke make.
Instead, use autoconf's AC_CHECK_HEADERS and AC_SEARCH_LIBS via the
new macro, gl_FUNC_PCRE, defined in...
* m4/pcre.m4 (gl_FUNC_PCRE): New macro, to handle pcre-related
configure-time tests.
* src/Makefile.am (grep_LDADD): Use LIB_PCRE, not PCRE_LIBS.
* src/pcresearch.c: Test HAVE_LIBPCRE via "#if", not "#ifdef".
All other cpp tests of this symbol used "#if".
Prompted by a suggestion from Bruno Haible.
---
 configure.ac     |   19 +------------------
 m4/pcre.m4       |   45 +++++++++++++++++++++++++++++++++++++++++++++
 src/Makefile.am  |    2 +-
 src/pcresearch.c |    2 +-
 4 files changed, 48 insertions(+), 20 deletions(-)
 create mode 100644 m4/pcre.m4

diff --git a/configure.ac b/configure.ac
index 474a9ae..f43c92f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,15 +33,6 @@ AM_SILENT_RULES([yes]) # make --enable-silent-rules the 
default.

 AC_CONFIG_HEADERS([config.h:config.hin])

-dnl Check for arguments
-AC_ARG_ENABLE(perl-regexp,
- [  --disable-perl-regexp           disable perl-regexp],
- [case "${enableval}" in
-  yes) testpcre=yes ;;
-  no)  testpcre=no ;;
-  *)   AC_MSG_ERROR(bad value ${enableval} for --disable-perl-regexp) ;;
- esac],[testpcre=yes])
-
 dnl Checks for programs.
 AC_CANONICAL_HOST
 AC_PROG_AWK
@@ -158,15 +149,7 @@ if test "$ac_use_included_regex" = no; then
   AC_MSG_WARN([Included lib/regex.c not used])
 fi

-# support for pcre
-PKG_PROG_PKG_CONFIG
-if test x"$testpcre" = x"yes"; then
-  PKG_CHECK_MODULES(PCRE, [libpcre],
-         [AC_DEFINE([HAVE_LIBPCRE], 1,
-           [Define to 1 if you have the `pcre' library (-lpcre).])
-          CPPFLAGS="$CPPFLAGS $PCRE_CFLAGS"],
-         [:])
-fi
+gl_FUNC_PCRE

 AC_CONFIG_FILES([
   Makefile
diff --git a/m4/pcre.m4 b/m4/pcre.m4
new file mode 100644
index 0000000..001806e
--- /dev/null
+++ b/m4/pcre.m4
@@ -0,0 +1,45 @@
+# pcre.m4 - check for libpcre support
+# serial 1
+
+# Copyright (C) 2010 Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_PCRE],
+[
+  AC_ARG_ENABLE([perl-regexp],
+    AC_HELP_STRING([--disable-perl-regexp],
+                   [disable perl-regexp (pcre) support]),
+    [case $enableval in
+       yes|no) test_pcre=$enableval;;
+       *) AC_MSG_ERROR([invalid value $enableval for --disable-perl-regexp]);;
+     esac],
+    [test_pcre=yes])
+
+  LIB_PCRE=
+  AC_SUBST([LIB_PCRE])
+  use_pcre=no
+
+  if test x"$test_pcre" = x"yes"; then
+    AC_CHECK_HEADERS([pcre.h])
+    if test $ac_cv_header_pcre_h = yes; then
+      pcre_saved_LIBS=$LIBS
+      AC_SEARCH_LIBS([pcre_compile], [pcre],
+       [test "$ac_cv_search_pcre_compile" = "none required" ||
+        LIB_PCRE=$ac_cv_search_pcre_compile])
+      AC_CHECK_FUNCS([pcre_compile])
+      LIBS=$pcre_saved_LIBS
+      if test $ac_cv_func_pcre_compile = yes; then
+       use_pcre=yes
+      fi
+    fi
+    if test $use_pcre = no; then
+      AC_MSG_WARN([libpcre development library was not found or not usable.])
+      AC_MSG_WARN([AC_PACKAGE_NAME will be built without pcre support.])
+    fi
+  fi
+
+  AC_DEFINE_UNQUOTED([HAVE_LIBPCRE], [`test $use_pcre != yes; echo $?`],
+    [Define to 1 if you have the `pcre' library (-lpcre).])
+])
diff --git a/src/Makefile.am b/src/Makefile.am
index 08f7aac..a5d8eca 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -35,7 +35,7 @@ libgrep_a_SOURCES = kwset.c dfa.c searchutils.c dfasearch.c 
kwsearch.c \
 # replacement functions defined in libgreputils.a.
 LDADD = libgrep.a ../lib/libgreputils.a $(LIBINTL) ../lib/libgreputils.a

-grep_LDADD = $(LDADD) $(PCRE_LIBS)
+grep_LDADD = $(LDADD) $(LIB_PCRE)
 localedir = $(datadir)/locale
 INCLUDES = -I$(top_srcdir)/lib -DLOCALEDIR=\"$(localedir)\"

diff --git a/src/pcresearch.c b/src/pcresearch.c
index 4dedf24..6a82be2 100644
--- a/src/pcresearch.c
+++ b/src/pcresearch.c
@@ -20,7 +20,7 @@

 #include <config.h>
 #include "search.h"
-#ifdef HAVE_LIBPCRE
+#if HAVE_LIBPCRE
 # include <pcre.h>
 #endif

--
1.7.0.3.435.g097f4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]