From 63a362ee53c0e30c9723123553e899ed76fea0a7 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 8 Feb 2009 17:21:03 +0200 Subject: [PATCH] Bug 1060: Try TRE_LIBS=-ltre if pkg-config tre fails. This works around Debian bug 513055 in libtre-dev. --- configure.in | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/configure.in b/configure.in index 154182347..27c7a8473 100644 --- a/configure.in +++ b/configure.in @@ -903,23 +903,46 @@ fi # =================================================================== # Check for TRE library # =================================================================== -AC_MSG_CHECKING([for TRE]) -cf_result=no + +AC_MSG_CHECKING([[for TRE in pkg-config]]) if pkg-config tre; then TRE_CFLAGS=`pkg-config --cflags tre` TRE_LIBS=`pkg-config --libs tre` - AC_SUBST(TRE_CFLAGS) - AC_SUBST(TRE_LIBS) - CFLAGS="$TRE_CFLAGS $CFLAGS" - LIBS="$TRE_LIBS $LIBS" - cf_result=yes -fi -AC_MSG_RESULT($cf_result) -if test "$cf_result" = yes; then - AC_CHECK_HEADERS(tre/regex.h) - AC_CHECK_SIZEOF(wchar_t, 4, [#include ]) + AC_MSG_RESULT([[yes]]) +else + # + # "libtre-dev: /usr/lib/pkgconfig/tre.pc missing" + # so we look for the library even if pkg-config doesn't know about it. + TRE_CFLAGS= + TRE_LIBS=-ltre + AC_MSG_RESULT([[no, but let's try defaults]]) fi +AC_MSG_CHECKING([[for TRE header and library]]) +EL_SAVE_FLAGS +CFLAGS="$TRE_CFLAGS $CFLAGS" +LIBS="$TRE_LIBS $LIBS" +AC_TRY_LINK([#include ], + [regex_t re; + regmatch_t match[1]; + regwcomp(&re, L"zap", REG_ICASE); + regwexec(&re, L"ELIZAPROGRAM", 1, match, 0);], + [AC_MSG_RESULT([[yes]]) + AC_DEFINE([HAVE_TRE_REGEX_H], [1], + [Define to 1 if you have the header file.]) + # TRE_CFLAGS will be used only where needed. + # TRE_LIBS will be kept in LIBS and used everywhere. + EL_RESTORE_FLAGS + LIBS="$TRE_LIBS $LIBS"], + [AC_MSG_RESULT([[no]]) + TRE_CFLAGS= + TRE_LIBS= + EL_RESTORE_FLAGS]) +AC_SUBST(TRE_CFLAGS) +AC_SUBST(TRE_LIBS) + +AC_CHECK_SIZEOF([wchar_t], [4], [[#include ]]) + # =================================================================== # Check for Ruby, optional even if installed. # ===================================================================