pcre.m4 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # BEGIN COPYRIGHT BLOCK
  2. # Copyright (C) 2007 Red Hat, Inc.
  3. # All rights reserved.
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. #
  19. # END COPYRIGHT BLOCK
  20. AC_CHECKING(for PCRE)
  21. dnl - check for --with-pcre
  22. AC_MSG_CHECKING(for --with-pcre)
  23. AC_ARG_WITH(pcre, AS_HELP_STRING([--with-pcre@<:@=PATH@:>@],[Perl Compatible Regular Expression directory]),
  24. [
  25. if test "$withval" = "yes"; then
  26. AC_MSG_RESULT(yes)
  27. elif test "$withval" = "no"; then
  28. AC_MSG_RESULT(no)
  29. AC_MSG_ERROR([PCRE is required.])
  30. elif test -d "$withval"/include -a -d "$withval"/lib; then
  31. AC_MSG_RESULT([using $withval])
  32. dnl - check the user provided location
  33. PCREDIR=$withval
  34. pcre_lib="-L$PCREDIR/lib"
  35. pcre_libdir="$PCREDIR/lib"
  36. pcre_incdir="$PCREDIR/include"
  37. if ! test -e "$pcre_incdir/pcre.h" ; then
  38. AC_MSG_ERROR([$withval include dir not found])
  39. fi
  40. pcre_inc="-I$pcre_incdir"
  41. else
  42. echo
  43. AC_MSG_ERROR([$withval not found])
  44. fi
  45. ],
  46. AC_MSG_RESULT(yes))
  47. #
  48. # if PCRE is not found yet, try pkg-config
  49. if test -z "$pcre_inc" -o -z "$pcre_lib" -o -z "$pcre_libdir"; then
  50. AC_PATH_PROG(PKG_CONFIG, pkg-config)
  51. AC_MSG_CHECKING(for pcre with pkg-config)
  52. if test -n "$PKG_CONFIG"; then
  53. if $PKG_CONFIG --exists pcre; then
  54. pcre_inc=`$PKG_CONFIG --cflags-only-I pcre`
  55. pcre_lib=`$PKG_CONFIG --libs-only-L pcre`
  56. pcre_libdir=`$PKG_CONFIG --libs-only-L pcre | sed -e s/-L// | sed -e s/\ .*$//`
  57. AC_MSG_RESULT([using system PCRE])
  58. elif $PKG_CONFIG --exists libpcre; then
  59. pcre_inc=`$PKG_CONFIG --cflags-only-I libpcre`
  60. pcre_lib=`$PKG_CONFIG --libs-only-L libpcre`
  61. pcre_libdir=`$PKG_CONFIG --libs-only-L libpcre | sed -e s/-L// | sed -e s/\ .*$//`
  62. AC_MSG_RESULT([using system PCRE])
  63. else
  64. AC_MSG_ERROR([PCRE not found, specify with --with-pcre.])
  65. fi
  66. fi
  67. fi
  68. dnl last resort
  69. dnl - check in system locations
  70. if test -z "$pcre_inc"; then
  71. AC_MSG_CHECKING(for pcre.h)
  72. if test -f "/usr/include/pcre/pcre.h"; then
  73. AC_MSG_RESULT([using /usr/include/pcre/pcre.h])
  74. pcre_incdir="/usr/include/pcre"
  75. pcre_inc="-I/usr/include/pcre"
  76. pcre_lib='-L$(libdir)'
  77. pcre_libdir='$(libdir)'
  78. elif test -f "/usr/include/pcre.h"; then
  79. AC_MSG_RESULT([using /usr/include/pcre.h])
  80. pcre_incdir="/usr/include"
  81. pcre_inc="-I/usr/include"
  82. pcre_lib='-L$(libdir)'
  83. pcre_libdir='$(libdir)'
  84. else
  85. AC_MSG_RESULT(no)
  86. AC_MSG_ERROR([PCRE not found, specify with --with-pcre.])
  87. fi
  88. fi