1
## $Id: pcre.m4,v 1.15 2004/05/30 03:56:14 daniel Exp $
3
## Copyright (c) 2002 Daniel Elstner <daniel.elstner@gmx.net>
5
## This program is free software; you can redistribute it and/or modify
6
## it under the terms of the GNU General Public License VERSION 2 as
7
## published by the Free Software Foundation. You are not allowed to
8
## use any other version of the license; unless you got the explicit
9
## permission from the author to do so.
11
## This program is distributed in the hope that it will be useful,
12
## but WITHOUT ANY WARRANTY; without even the implied warranty of
13
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
## GNU General Public License for more details.
16
## You should have received a copy of the GNU General Public License
17
## along with this program; if not, write to the Free Software
18
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
## PCRE_CHECK_VERSION(min_version)
23
## Run pcre-config to determine the libpcre version number and
24
## bail out if it is insufficient. Also retrieve the necessary
25
## compiler flags and store them in PCRE_CFLAGS rpt. PCRE_LIBS.
27
AC_DEFUN([PCRE_CHECK_VERSION],
29
m4_if([$1],, [AC_FATAL([argument required])])
31
AC_ARG_VAR([PCRE_CONFIG], [path to pcre-config script])
32
AC_PATH_PROG([PCRE_CONFIG], [pcre-config])
34
AS_IF([test "x$PCRE_CONFIG" = x],
37
*** pcre-config is missing. Please install your distribution's
38
*** libpcre development package and then try again.
42
AC_MSG_CHECKING([[for libpcre >= ]$1])
44
pcre_version_string=`$PCRE_CONFIG --version 2>&5`
46
d='@<:@0123456789@:>@'
47
pcre_transform='s/^\('$d$d'*\)\.\('$d$d'*\)\.*\('$d'*\).*$/\1 \\* 1000000 + \2 \\* 1000 + 0\3/p'
48
pcre_required=`echo "$1" | sed -n "$pcre_transform" 2>&5`
49
pcre_version=`echo "$pcre_version_string" | sed -n "$pcre_transform" 2>&5`
51
AS_IF([eval "expr $pcre_version \\>= $pcre_required" >/dev/null 2>&5],
52
[pcre_version_ok=yes],
55
AC_MSG_RESULT([${pcre_version_ok}])
57
AS_IF([test "x$pcre_version_ok" = xno],
60
*** libpcre ]$1[ or higher is required, but you only have
61
*** version $pcre_version_string installed. Please upgrade and try again.
65
AC_MSG_CHECKING([[PCRE_CFLAGS]])
66
PCRE_CFLAGS=`$PCRE_CONFIG --cflags | sed 's,-I/usr/include$,,;s,-I/usr/include ,,g' 2>&5`
67
AC_MSG_RESULT([${PCRE_CFLAGS}])
68
AC_SUBST([PCRE_CFLAGS])
70
AC_MSG_CHECKING([[PCRE_LIBS]])
71
PCRE_LIBS=`$PCRE_CONFIG --libs | sed 's,-L/usr/lib$,,;s,-L/usr/lib ,,g' 2>&5`
72
AC_MSG_RESULT([${PCRE_LIBS}])
79
## Run a test program to determine whether PCRE was compiled with
80
## UTF-8 support. If it wasn't, bail out with an error message.
82
AC_DEFUN([PCRE_CHECK_UTF8],
84
AC_REQUIRE([PCRE_CHECK_VERSION])
87
[whether libpcre was compiled with UTF-8 support],
88
[pcre_cv_has_utf8_support],
91
pcre_saved_CPPFLAGS=$CPPFLAGS
93
CPPFLAGS="$CPPFLAGS $PCRE_CFLAGS"
94
LIBS="$LIBS $PCRE_LIBS"
104
const char* errmessage = NULL;
107
if (pcre_compile(".", PCRE_UTF8, &errmessage, &erroffset, NULL))
110
fprintf(stderr, "%s\n", errmessage);
114
[pcre_cv_has_utf8_support=yes],
115
[pcre_cv_has_utf8_support=no],
116
[pcre_cv_has_utf8_support="cross compile: assuming yes"])
118
CPPFLAGS=$pcre_saved_CPPFLAGS
119
LIBS=$pcre_saved_LIBS
123
AS_IF([test "x$pcre_cv_has_utf8_support" = xno],
126
*** Sorry, the PCRE library installed on your system doesn't support
127
*** UTF-8 encoding. Please install a libpcre package which includes
128
*** support for UTF-8. Note that if you compile libpcre from source
129
*** you have to pass the --enable-utf8 flag to its ./configure script.