1 | # pcre.m4 - check for libpcre support
|
---|
2 |
|
---|
3 | # Copyright (C) 2010-2021 Free Software Foundation, Inc.
|
---|
4 | # This file is free software; the Free Software Foundation
|
---|
5 | # gives unlimited permission to copy and/or distribute it,
|
---|
6 | # with or without modifications, as long as this notice is preserved.
|
---|
7 |
|
---|
8 | AC_DEFUN([gl_FUNC_PCRE],
|
---|
9 | [
|
---|
10 | AC_ARG_ENABLE([perl-regexp],
|
---|
11 | AS_HELP_STRING([--disable-perl-regexp],
|
---|
12 | [disable perl-regexp (pcre) support]),
|
---|
13 | [case $enableval in
|
---|
14 | yes|no) test_pcre=$enableval;;
|
---|
15 | *) AC_MSG_ERROR([invalid value $enableval for --disable-perl-regexp]);;
|
---|
16 | esac],
|
---|
17 | [test_pcre=maybe])
|
---|
18 |
|
---|
19 | AC_SUBST([PCRE_CFLAGS])
|
---|
20 | AC_SUBST([PCRE_LIBS])
|
---|
21 | use_pcre=no
|
---|
22 |
|
---|
23 | if test $test_pcre != no; then
|
---|
24 | PKG_CHECK_MODULES([PCRE], [libpcre], [], [: ${PCRE_LIBS=-lpcre}])
|
---|
25 |
|
---|
26 | AC_CACHE_CHECK([for pcre_compile], [pcre_cv_have_pcre_compile],
|
---|
27 | [pcre_saved_CFLAGS=$CFLAGS
|
---|
28 | pcre_saved_LIBS=$LIBS
|
---|
29 | CFLAGS="$CFLAGS $PCRE_CFLAGS"
|
---|
30 | LIBS="$PCRE_LIBS $LIBS"
|
---|
31 | AC_LINK_IFELSE(
|
---|
32 | [AC_LANG_PROGRAM([[#include <pcre.h>
|
---|
33 | ]],
|
---|
34 | [[pcre *p = pcre_compile (0, 0, 0, 0, 0);
|
---|
35 | return !p;]])],
|
---|
36 | [pcre_cv_have_pcre_compile=yes],
|
---|
37 | [pcre_cv_have_pcre_compile=no])
|
---|
38 | CFLAGS=$pcre_saved_CFLAGS
|
---|
39 | LIBS=$pcre_saved_LIBS])
|
---|
40 |
|
---|
41 | if test "$pcre_cv_have_pcre_compile" = yes; then
|
---|
42 | use_pcre=yes
|
---|
43 | elif test $test_pcre = maybe; then
|
---|
44 | AC_MSG_WARN([AC_PACKAGE_NAME will be built without pcre support.])
|
---|
45 | else
|
---|
46 | AC_MSG_ERROR([pcre support not available])
|
---|
47 | fi
|
---|
48 | fi
|
---|
49 |
|
---|
50 | if test $use_pcre = yes; then
|
---|
51 | AC_DEFINE([HAVE_LIBPCRE], [1],
|
---|
52 | [Define to 1 if you have the Perl Compatible Regular Expressions
|
---|
53 | library (-lpcre).])
|
---|
54 | else
|
---|
55 | PCRE_CFLAGS=
|
---|
56 | PCRE_LIBS=
|
---|
57 | fi
|
---|
58 | ])
|
---|