From 9fa53f1a1bde42381c10d14b5b246420683733b1 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 24 Mar 2010 08:40:05 +0100 Subject: 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. * NEWS (Build-related): Mention this. --- m4/pcre.m4 | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 m4/pcre.m4 (limited to 'm4') diff --git a/m4/pcre.m4 b/m4/pcre.m4 new file mode 100644 index 00000000..001806e0 --- /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).]) +]) -- cgit v1.2.1