dnl CF_WITH_PCRE version: 8 updated: 2010/06/05 11:30:21
dnl ------------
dnl Add PCRE (Perl-compatible regular expressions) to the build if it is
dnl available and the user requests it.  Assume the application will otherwise
dnl use the POSIX interface.
dnl
dnl TODO allow $withval to specify package location
AC_DEFUN([CF_WITH_PCRE],
[
AC_REQUIRE([CF_PKG_CONFIG])

AC_MSG_CHECKING(if you want to use PCRE for regular-expressions)
AC_ARG_WITH(pcre,
	[  --with-pcre             use PCRE for regular-expressions])
test -z "$with_pcre" && with_pcre=no
AC_MSG_RESULT($with_pcre)

if test "$with_pcre" != no ; then
	CF_TRY_PKG_CONFIG(libpcre,,[
		AC_CHECK_LIB(pcre,pcre_compile,,
			AC_MSG_ERROR(Cannot find PCRE library))])

		AC_DEFINE(HAVE_LIB_PCRE)

		case $LIBS in #(vi
		*pcreposix*) #(vi
			;;
		*)
			AC_CHECK_LIB(pcreposix,pcreposix_regcomp,
				[AC_DEFINE(HAVE_PCREPOSIX_H)
				 CF_ADD_LIB(pcreposix)],
				[AC_CHECK_LIB(pcreposix,regcomp,[
					AC_DEFINE(HAVE_PCREPOSIX_H)
					CF_ADD_LIB(pcreposix)],
					AC_MSG_ERROR(Cannot find PCRE POSIX library)]))
			;;
		esac
fi
])dnl
