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 /opt/local"]) 23 24AC_MSG_CHECKING([for libpcre config script]) 25 26for x in ${test_paths}; do 27 dnl # Determine if the script was specified and use it directly 28 if test ! -d "$x" -a -e "$x"; then 29 PCRE_CONFIG=$x 30 pcre_path="no" 31 break 32 fi 33 34 dnl # Try known config script names/locations 35 for PCRE_CONFIG in pcre-config; do 36 if test -e "${x}/bin/${PCRE_CONFIG}"; then 37 pcre_path="${x}/bin" 38 break 39 elif test -e "${x}/${PCRE_CONFIG}"; then 40 pcre_path="${x}" 41 break 42 else 43 pcre_path="" 44 fi 45 done 46 if test -n "$pcre_path"; then 47 break 48 fi 49done 50 51if test -n "${pcre_path}"; then 52 if test "${pcre_path}" != "no"; then 53 PCRE_CONFIG="${pcre_path}/${PCRE_CONFIG}" 54 fi 55 AC_MSG_RESULT([${PCRE_CONFIG}]) 56 PCRE_VERSION="`${PCRE_CONFIG} --version`" 57 if test ! -z "${PCRE_VERSION}"; then AC_MSG_NOTICE(pcre VERSION: $PCRE_VERSION); fi 58 PCRE_CFLAGS="`${PCRE_CONFIG} --cflags`" 59 if test ! -z "${PCRE_CFLAGS}"; then AC_MSG_NOTICE(pcre CFLAGS: $PCRE_CFLAGS); fi 60 PCRE_LDADD="`${PCRE_CONFIG} --libs`" 61 if test ! -z "${PCRE_LDADD}"; then AC_MSG_NOTICE(pcre LDADD: $PCRE_LDADD); fi 62 PCRE_LD_PATH="/`${PCRE_CONFIG} --libs | cut -d'/' -f2,3,4,5,6 | cut -d ' ' -f1`" 63 if test ! -z "${PCRE_LD_PATH}"; then AC_MSG_NOTICE(pcre PCRE_LD_PATH: $PCRE_LD_PATH); fi 64else 65 AC_MSG_RESULT([no]) 66fi 67 68if test -n "${PCRE_VERSION}"; then 69 AC_MSG_CHECKING(for PCRE JIT) 70 save_CFLAGS=$CFLAGS 71 save_LDFLAGS=$LDFLAGS 72 save_LIBS=$LIBS 73 CFLAGS="${PCRE_CFLAGS} ${CFLAGS}" 74 LDFLAGS="${PCRE_LDADD} ${LDFLAGS}" 75 LIBS="${PCRE_LDADD} ${LIBS}" 76 AC_TRY_LINK([ #include <pcre.h> ], 77 [ pcre_jit_exec(NULL, NULL, NULL, 0, 0, 0, NULL, 0, NULL); ], 78 [ pcre_jit_available=yes ], [:] 79 ) 80 81 if test "x$pcre_jit_available" = "xyes"; then 82 AC_MSG_RESULT(yes) 83 PCRE_CFLAGS="${PCRE_CFLAGS} -DPCRE_HAVE_JIT" 84 else 85 AC_MSG_RESULT(no) 86 fi 87 CFLAGS=$save_CFLAGS 88 LDFLAGS=$save_LDFLAGS 89 LIBS=$save_LIBS 90fi 91 92AC_SUBST(PCRE_CONFIG) 93AC_SUBST(PCRE_VERSION) 94AC_SUBST(PCRE_CPPFLAGS) 95AC_SUBST(PCRE_CFLAGS) 96AC_SUBST(PCRE_LDFLAGS) 97AC_SUBST(PCRE_LDADD) 98AC_SUBST(PCRE_LD_PATH) 99 100if test -z "${PCRE_VERSION}"; then 101 AC_MSG_NOTICE([*** pcre library not found.]) 102 ifelse([$2], , AC_MSG_ERROR([pcre library is required]), $2) 103else 104 AC_MSG_NOTICE([using pcre v${PCRE_VERSION}]) 105 ifelse([$1], , , $1) 106 PCRE_LDADD="${PCRE_LDADD} -lpcre" 107fi 108]) 109