1dnl Check for PCRE Libraries 2dnl CHECK_PCRE(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]) 3dnl Sets: 4dnl PCRE_CFLAGS 5dnl PCRE_LIBS 6 7PCRE_CONFIG="" 8PCRE_VERSION="" 9PCRE_CPPFLAGS="" 10PCRE_CFLAGS="" 11PCRE_LDFLAGS="" 12PCRE_LDADD="" 13PCRE_LD_PATH="" 14 15AC_DEFUN([CHECK_PCRE], 16[dnl 17 18AC_ARG_WITH( 19 pcre, 20 [AC_HELP_STRING([--with-pcre=PATH],[Path to pcre prefix or config script])], 21 [test_paths="${with_pcre}"], 22 [test_paths="/usr/local/libpcre /usr/local/pcre /usr/local /opt/libpcre /opt/pcre /opt /usr"]) 23 24AC_MSG_CHECKING([for libpcre config script]) 25 26dnl # Determine pcre lib directory 27if test -z "${with_pcre}"; then 28 test_paths="/usr/local/pcre /usr/local /usr" 29else 30 test_paths="${with_pcre}" 31fi 32 33for x in ${test_paths}; do 34 dnl # Determine if the script was specified and use it directly 35 if test ! -d "$x" -a -e "$x"; then 36 PCRE_CONFIG=$x 37 pcre_path="no" 38 break 39 fi 40 41 dnl # Try known config script names/locations 42 for PCRE_CONFIG in pcre-config; do 43 if test -e "${x}/bin/${PCRE_CONFIG}"; then 44 pcre_path="${x}/bin" 45 break 46 elif test -e "${x}/${PCRE_CONFIG}"; then 47 pcre_path="${x}" 48 break 49 else 50 pcre_path="" 51 fi 52 done 53 if test -n "$pcre_path"; then 54 break 55 fi 56done 57 58if test -n "${pcre_path}"; then 59 if test "${pcre_path}" != "no"; then 60 PCRE_CONFIG="${pcre_path}/${PCRE_CONFIG}" 61 fi 62 AC_MSG_RESULT([${PCRE_CONFIG}]) 63 PCRE_VERSION="`${PCRE_CONFIG} --version`" 64 if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(pcre VERSION: $PCRE_VERSION); fi 65 PCRE_CFLAGS="`${PCRE_CONFIG} --cflags`" 66 if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(pcre CFLAGS: $PCRE_CFLAGS); fi 67 PCRE_LDADD="`${PCRE_CONFIG} --libs`" 68 if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(pcre LDADD: $PCRE_LDADD); fi 69 PCRE_LD_PATH="/`${PCRE_CONFIG} --libs | cut -d'/' -f2,3,4,5,6 | cut -d ' ' -f1`" 70 if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(pcre PCRE_LD_PATH: $PCRE_LD_PATH); fi 71else 72 AC_MSG_RESULT([no]) 73fi 74 75AC_SUBST(PCRE_CONFIG) 76AC_SUBST(PCRE_VERSION) 77AC_SUBST(PCRE_CPPFLAGS) 78AC_SUBST(PCRE_CFLAGS) 79AC_SUBST(PCRE_LDFLAGS) 80AC_SUBST(PCRE_LDADD) 81AC_SUBST(PCRE_LD_PATH) 82 83if test -z "${PCRE_VERSION}"; then 84 AC_MSG_NOTICE([*** pcre library not found.]) 85 ifelse([$2], , AC_MSG_ERROR([pcre library is required]), $2) 86else 87 AC_MSG_NOTICE([using pcre v${PCRE_VERSION}]) 88 ifelse([$1], , , $1) 89fi 90]) 91