ax_path_lib_pcre.m4 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. dnl @synopsis AX_PATH_LIB_PCRE [(A/NA)]
  2. dnl
  3. dnl check for pcre lib and set PCRE_LIBS and PCRE_CPPFLAGS accordingly.
  4. dnl
  5. dnl also provide --with-pcre option that may point to the $prefix of
  6. dnl the pcre installation - the macro will check $pcre/include and
  7. dnl $pcre/lib to contain the necessary files.
  8. dnl
  9. dnl the usual two ACTION-IF-FOUND / ACTION-IF-NOT-FOUND are supported
  10. dnl and they can take advantage of the LIBS/CFLAGS additions.
  11. dnl
  12. dnl @author Guido U. Draheim <guidod@gmx.de>
  13. dnl @author Slava Zanko <slavazanko@gmail.com>
  14. dnl @version 2009-07-06
  15. dnl @license GPLWithACException
  16. AC_DEFUN([AX_PATH_LIB_PCRE],[dnl
  17. AC_MSG_CHECKING([lib pcre])
  18. AC_ARG_WITH([pcre],
  19. AS_HELP_STRING([--with-pcre@<:@=prefix@:>@], [Compile pcre part (via libpcre check)]),
  20. ,
  21. [with_pcre="yes"]
  22. )
  23. if test x"$with_pcre" = "xno" ; then
  24. AC_MSG_RESULT([disabled])
  25. m4_ifval($2,$2)
  26. else
  27. AC_MSG_RESULT([(testing)])
  28. if test "x$with_pcre" = "xyes" ; then
  29. PCRE_CPPFLAGS="`pcre-config --cflags`"
  30. PCRE_LIBS="`pcre-config --libs`"
  31. else
  32. test_PCRE_LIBS="-L$with_pcre/lib"
  33. test_PCRE_CPPFLAGS="-I$with_pcre/include"
  34. OLDLDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $test_PCRE_LIBS"
  35. OLDCPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $test_PCRE_CPPFLAGS"
  36. AC_CHECK_LIB(pcre, pcre_compile)
  37. if test x"$ac_cv_lib_pcre_pcre_compile" = x"yes" ; then
  38. AC_MSG_RESULT(setting PCRE_LIBS -L$with_pcre/lib -lpcre)
  39. PCRE_LIBS=$test_PCRE_LIBS
  40. PCRE_CPPFLAGS=$test_PCRE_CPPFLAGS
  41. AC_MSG_CHECKING([lib pcre])
  42. AC_MSG_RESULT([$PCRE_LIBS])
  43. m4_ifval($1,$1)
  44. else
  45. AC_MSG_CHECKING([lib pcre])
  46. AC_MSG_RESULT([no, (WARNING)])
  47. m4_ifval($2,$2)
  48. fi
  49. CPPFLAGS="$OLDCFPPLAGS"
  50. LDFLAGS="$OLDLDFLAGS"
  51. fi
  52. fi
  53. AC_SUBST([PCRE_LIBS])
  54. AC_SUBST([PCRE_CPPFLAGS])
  55. ])