diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2015-04-06 15:49:50 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2015-04-06 16:10:56 -0700 |
commit | 936ae4a5e6c8fd27d86c2f9e0f46c61c8c15c4ff (patch) | |
tree | 750e53c043e96311d6baf496401c269c714e2fe5 /m4 | |
parent | ff38f097a41ddf908e3036524319de5a3aa6188e (diff) | |
download | grep-936ae4a5e6c8fd27d86c2f9e0f46c61c8c15c4ff.tar.gz |
build: use pkg-config (if available) to configure libpcre
Problem reported by Mike Frysinger in: http://bugs.gnu.org/16757
* bootstrap.conf (bootstrap_post_import_hook):
Copy pkg-config's pkg.m4.
* configure.ac: Invoke PKG_PROG_PKG_CONFIG.
* m4/pcre.m4 (gl_FUNC_PCRE): Rewrite to use pkg-config if
available, and to test that pcre_compile can be linked to.
* src/Makefile.am (AM_CFLAGS): Add PCRE_CFLAGS.
(grep_LDADD): Add PCRE_LIBS.
* src/pcresearch.c: Simply include <pcre.h> if HAVE_LIBPCRE,
since 'configure' arranges for the appropriate -I option now.
Diffstat (limited to 'm4')
-rw-r--r-- | m4/pcre.m4 | 62 |
1 files changed, 39 insertions, 23 deletions
@@ -1,5 +1,4 @@ # pcre.m4 - check for libpcre support -# serial 1 # Copyright (C) 2010-2015 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -17,32 +16,49 @@ AC_DEFUN([gl_FUNC_PCRE], esac], [test_pcre=yes]) - LIB_PCRE= - AC_SUBST([LIB_PCRE]) + PCRE_CFLAGS= + PCRE_LIBS= + AC_SUBST([PCRE_CFLAGS]) + AC_SUBST([PCRE_LIBS]) use_pcre=no - if test x"$test_pcre" = x"yes"; then - AC_CHECK_HEADERS([pcre.h]) - AC_CHECK_HEADERS([pcre/pcre.h]) - if test $ac_cv_header_pcre_h = yes \ - || test $ac_cv_header_pcre_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.]) + if test $test_pcre = yes; then + PKG_CHECK_MODULES([PCRE], [libpcre], [], + [if test -r /usr/include/pcre/pcre.h && + test ! -r /usr/include/pcre.h + then + PCRE_CFLAGS=-I/usr/include/libpng + fi + PCRE_LIBS=-lpcre]) + + AC_CACHE_CHECK([for pcre_compile], [pcre_cv_have_pcre_compile], + [pcre_saved_CFLAGS=$CFLAGS + pcre_saved_LIBS=$LIBS + CFLAGS="$CFLAGS $PCRE_CFLAGS" + LIBS="$PCRE_LIBS $LIBS" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[#include <pcre.h> + ]], + [[pcre *p = pcre_compile (0, 0, 0, 0, 0); + return !p;]])], + [pcre_cv_have_pcre_compile=yes], + [pcre_cv_have_pcre_compile=no]) + CFLAGS=$pcre_saved_CFLAGS + LIBS=$pcre_saved_LIBS]) + + if test "$pcre_cv_have_pcre_compile" = yes; then + use_pcre=yes + else 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 Perl Compatible Regular Expressions - library (-lpcre).]) + if test $use_pcre = yes; then + AC_DEFINE([HAVE_LIBPCRE], [1], + [Define to 1 if you have the Perl Compatible Regular Expressions + library (-lpcre).]) + else + PCRE_CFLAGS= + PCRE_LIBS= + fi ]) |