pcre.m4 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # BEGIN COPYRIGHT BLOCK
  2. # Copyright (C) 2007 Red Hat, Inc.
  3. # All rights reserved.
  4. #
  5. # License: GPL (version 3 or any later version).
  6. # See LICENSE for details.
  7. # END COPYRIGHT BLOCK
  8. AC_CHECKING(for PCRE)
  9. dnl - check for --with-pcre
  10. AC_MSG_CHECKING(for --with-pcre)
  11. AC_ARG_WITH(pcre, AS_HELP_STRING([--with-pcre@<:@=PATH@:>@],[Perl Compatible Regular Expression directory]),
  12. [
  13. if test "$withval" = "yes"; then
  14. AC_MSG_RESULT(yes)
  15. elif test "$withval" = "no"; then
  16. AC_MSG_RESULT(no)
  17. AC_MSG_ERROR([PCRE is required.])
  18. elif test -d "$withval"/include -a -d "$withval"/lib; then
  19. AC_MSG_RESULT([using $withval])
  20. dnl - check the user provided location
  21. PCREDIR=$withval
  22. pcre_lib="-L$PCREDIR/lib"
  23. pcre_libdir="$PCREDIR/lib"
  24. pcre_incdir="$PCREDIR/include"
  25. if ! test -e "$pcre_incdir/pcre.h" ; then
  26. AC_MSG_ERROR([$withval include dir not found])
  27. fi
  28. pcre_inc="-I$pcre_incdir"
  29. else
  30. echo
  31. AC_MSG_ERROR([$withval not found])
  32. fi
  33. ],
  34. AC_MSG_RESULT(yes))
  35. #
  36. # if PCRE is not found yet, try pkg-config
  37. if test -z "$pcre_inc" -o -z "$pcre_lib" -o -z "$pcre_libdir"; then
  38. AC_PATH_PROG(PKG_CONFIG, pkg-config)
  39. AC_MSG_CHECKING(for pcre with pkg-config)
  40. if test -n "$PKG_CONFIG"; then
  41. if $PKG_CONFIG --exists pcre; then
  42. pcre_inc=`$PKG_CONFIG --cflags-only-I pcre`
  43. pcre_lib=`$PKG_CONFIG --libs-only-L pcre`
  44. pcre_libdir=`$PKG_CONFIG --libs-only-L pcre | sed -e s/-L// | sed -e s/\ .*$//`
  45. AC_MSG_RESULT([using system PCRE])
  46. elif $PKG_CONFIG --exists libpcre; then
  47. pcre_inc=`$PKG_CONFIG --cflags-only-I libpcre`
  48. pcre_lib=`$PKG_CONFIG --libs-only-L libpcre`
  49. pcre_libdir=`$PKG_CONFIG --libs-only-L libpcre | sed -e s/-L// | sed -e s/\ .*$//`
  50. AC_MSG_RESULT([using system PCRE])
  51. else
  52. AC_MSG_ERROR([PCRE not found, specify with --with-pcre.])
  53. fi
  54. fi
  55. fi
  56. dnl last resort
  57. dnl - check in system locations
  58. if test -z "$pcre_inc"; then
  59. AC_MSG_CHECKING(for pcre.h)
  60. if test -f "/usr/include/pcre/pcre.h"; then
  61. AC_MSG_RESULT([using /usr/include/pcre/pcre.h])
  62. pcre_incdir="/usr/include/pcre"
  63. pcre_inc="-I/usr/include/pcre"
  64. pcre_lib='-L$(libdir)'
  65. pcre_libdir='$(libdir)'
  66. elif test -f "/usr/include/pcre.h"; then
  67. AC_MSG_RESULT([using /usr/include/pcre.h])
  68. pcre_incdir="/usr/include"
  69. pcre_inc="-I/usr/include"
  70. pcre_lib='-L$(libdir)'
  71. pcre_libdir='$(libdir)'
  72. else
  73. AC_MSG_RESULT(no)
  74. AC_MSG_ERROR([PCRE not found, specify with --with-pcre.])
  75. fi
  76. fi