medit/m4/moo-pcre.m4

220 lines
6.5 KiB
Plaintext

##############################################################################
# MOO_AC_PCRE
# This is essentially pcre's configure.in, contains checks and defines
# needed for pcre
#
AC_DEFUN([MOO_AC_PCRE],[
AC_ARG_WITH([system-pcre],
AC_HELP_STRING([--with-system-pcre], [whether to use system copy of pcre library (default = YES)]),[
if test x$with_system_pcre = "xyes"; then
MOO_BUILD_PCRE="no"
else
MOO_BUILD_PCRE="yes"
fi
],[
MOO_BUILD_PCRE="auto"
])
if test x$MOO_BUILD_PCRE != xyes; then
have_pcre="no"
PKG_CHECK_MODULES(PCRE, [libpcre >= 6.4], [
have_pcre="yes"
], [
have_pcre="no"
])
if test $have_pcre = yes; then
AC_MSG_CHECKING(pcre UTF8 support)
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $PCRE_CFLAGS"
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PCRE_CFLAGS"
save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $PCRE_LIBS"
AC_RUN_IFELSE([
AC_LANG_SOURCE([[
#include <pcre.h>
#include <stdlib.h>
int main (int argc, char *argv[])
{
int result = 0;
pcre_config (PCRE_CONFIG_UTF8, &result);
if (result)
pcre_config (PCRE_CONFIG_UNICODE_PROPERTIES, &result);
if (result)
exit (0);
else
exit (1);
}]
])],[
AC_MSG_RESULT(yes)
have_pcre=yes
],[
AC_MSG_RESULT(no)
have_pcre=no
],[
AC_MSG_RESULT(can't check when crosscompiling, assuming it's fine)
have_pcre=yes
])
CFLAGS="$save_CFLAGS"
CPPFLAGS="$save_CPPFLAGS"
LDFLAGS="$save_LDFLAGS"
fi
fi
if test x$MOO_BUILD_PCRE != xyes; then
if test x$have_pcre = xyes; then
MOO_BUILD_PCRE="no"
AC_MSG_NOTICE([using installed libpcre])
MOO_PCRE_CFLAGS="$PCRE_CFLAGS"
MOO_PCRE_LIBS="$PCRE_LIBS"
else
MOO_BUILD_PCRE="yes"
AC_MSG_NOTICE([building pcre library])
fi
else
MOO_BUILD_PCRE="yes"
AC_MSG_NOTICE([building pcre library])
fi
AM_CONDITIONAL(MOO_BUILD_PCRE, test x$MOO_BUILD_PCRE = xyes)
if test x$MOO_BUILD_PCRE = xyes; then
AC_DEFINE(MOO_BUILD_PCRE, , [MOO_BUILD_PCRE - build pcre library])
fi
## ===================================================================
## build pcre
##
if test x$MOO_BUILD_PCRE = xyes; then
dnl Provide the current PCRE version information. Do not use numbers
dnl with leading zeros for the minor version, as they end up in a C
dnl macro, and may be treated as octal constants. Stick to single
dnl digits for minor numbers less than 10. There are unlikely to be
dnl that many releases anyway.
PCRE_MAJOR=6
PCRE_MINOR=4
PCRE_DATE=05-Sep-2005
PCRE_VERSION=${PCRE_MAJOR}.${PCRE_MINOR}
AC_DEFINE([PCRE_MAJOR], $PCRE_MAJOR, [pcre library major version])
AC_DEFINE([PCRE_MINOR], $PCRE_MINOR, [pcre library minor version])
AC_DEFINE([PCRE_DATE], $PCRE_DATE, [pcre library release date])
dnl Default values for miscellaneous macros
AC_DEFINE(POSIX_MALLOC_THRESHOLD, 10, [POSIX_MALLOC_THRESHOLD])
AC_HEADER_STDC
AC_CHECK_HEADERS(limits.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_CHECK_TYPES([long long], [pcre_have_long_long="1"], [pcre_have_long_long="0"])
AC_CHECK_TYPES([unsigned long long], [pcre_have_ulong_long="1"], [pcre_have_ulong_long="0"])
AC_SUBST(pcre_have_long_long)
AC_SUBST(pcre_have_ulong_long)
dnl Checks for library functions.
AC_CHECK_FUNCS(bcopy memmove strerror strtoq strtoll)
dnl Handle --enable-utf8
AC_DEFINE(SUPPORT_UTF8, , [SUPPORT_UTF8])
# XXX
# dnl Handle --enable-unicode-properties
AC_DEFINE(SUPPORT_UCP, , [SUPPORT_UCP])
AC_DEFINE(PCRE_EXPORT, , [PCRE_EXPORT - empty since we do not need pcre api be exported])
# dnl Handle --enable-newline-is-cr
#
# AC_ARG_ENABLE(newline-is-cr,
# [ --enable-newline-is-cr use CR as the newline character],
# if test "$enableval" = "yes"; then
# NEWLINE=-DNEWLINE=13
# fi
# )
#
# dnl Handle --enable-newline-is-lf
#
# AC_ARG_ENABLE(newline-is-lf,
# [ --enable-newline-is-lf use LF as the newline character],
# if test "$enableval" = "yes"; then
# NEWLINE=-DNEWLINE=10
# fi
# )
AC_DEFINE(NEWLINE, '\n', [The value of NEWLINE determines the newline character])
# XXX
# dnl Handle --enable-ebcdic
#
# AC_ARG_ENABLE(ebcdic,
# [ --enable-ebcdic assume EBCDIC coding rather than ASCII],
# if test "$enableval" == "yes"; then
# EBCDIC=-DEBCDIC=1
# fi
# )
AC_DEFINE(EBCDIC, 0, [If you are compiling for a system that uses EBCDIC instead of ASCII dnl
character codes, define this macro as 1.])
# dnl Handle --disable-stack-for-recursion
#
# AC_ARG_ENABLE(stack-for-recursion,
# [ --disable-stack-for-recursion disable use of stack recursion when matching],
# if test "$enableval" = "no"; then
# NO_RECURSE=-DNO_RECURSE
# fi
# )
# dnl Handle --with-link-size=n
# AC_ARG_WITH(link-size,
# [ --with-link-size=2 internal link size (2, 3, or 4 allowed)],
# LINK_SIZE=-DLINK_SIZE=$withval
# )
AC_DEFINE(LINK_SIZE, 2, [The value of LINK_SIZE determines the number of bytes used to store dnl
links as offsets within the compiled regex. The default is 2, which allows for dnl
compiled patterns up to 64K long. This covers the vast majority of cases. dnl
However, PCRE can also be compiled to use 3 or 4 bytes instead. This allows for dnl
longer patterns in extreme cases.])
# dnl Handle --with-match_limit=n
#
# AC_ARG_WITH(match-limit,
# [ --with-match-limit=10000000 default limit on internal looping)],
# MATCH_LIMIT=-DMATCH_LIMIT=$withval
# )
AC_DEFINE(MATCH_LIMIT, 10000000, [The value of MATCH_LIMIT determines the default number of times the match() dnl
function can be called during a single execution of pcre_exec(). (There is a dnl
runtime method of setting a different limit.) The limit exists in order to dnl
catch runaway regular expressions that take for ever to determine that they do dnl
not match. The default is set very large so that it does not accidentally catch dnl
legitimate cases.])
AC_SUBST(PCRE_MAJOR)
AC_SUBST(PCRE_MINOR)
AC_SUBST(PCRE_DATE)
AC_SUBST(PCRE_VERSION)
fi
]) # end of MOO_AC_PCRE