1# LIBPCRE_CHECK_CONFIG ([DEFAULT-ACTION]) 2# ---------------------------------------------------------- 3# 4# Checks for pcre. 5# 6# This macro #defines HAVE_PCRE_H if required header files are 7# found, and sets @LIBPCRE_LDFLAGS@ and @LIBPCRE_CFLAGS@ to the necessary 8# values. 9# 10# This macro 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. 13 14AC_DEFUN([LIBPCRE_TRY_LINK], 15[ 16AC_TRY_LINK( 17[ 18#include <pcre.h> 19], 20[ 21 const char* error = NULL; 22 int error_offset = -1; 23 pcre *regexp = pcre_compile("test", PCRE_UTF8, &error, &error_offset, NULL); 24 pcre_free(regexp); 25], 26found_libpcre="yes") 27])dnl 28 29AC_DEFUN([LIBPCRE_CHECK_CONFIG], 30[ 31 AC_ARG_WITH([libpcre],[ 32If you want to specify libpcre installation directories: 33AC_HELP_STRING([--with-libpcre@<:@=DIR@:>@], [use libpcre from given base install directory (DIR), default is to search through a number of common places for the libpcre files.])], 34 [ 35 if test "$withval" = "yes"; then 36 if test -f /usr/local/include/pcre.h; then 37 withval="/usr/local" 38 else 39 withval="/usr" 40 fi 41 else 42 _libpcre_dir_lib="$withval/lib" 43 fi 44 _libpcre_dir="$withval" 45 test "x$withval" = "xyes" && withval=/usr 46 LIBPCRE_CFLAGS="-I$withval/include" 47 LIBPCRE_LDFLAGS="-L$withval/lib" 48 _libpcre_dir_set="yes" 49 ] 50 ) 51 52 AC_ARG_WITH([libpcre-include], 53 AC_HELP_STRING([--with-libpcre-include@<:@=DIR@:>@], 54 [use libpcre include headers from given path.] 55 ), 56 [ 57 LIBPCRE_CFLAGS="-I$withval" 58 _libpcre_dir_set="yes" 59 ] 60 ) 61 62 AC_ARG_WITH([libpcre-lib], 63 AC_HELP_STRING([--with-libpcre-lib@<:@=DIR@:>@], 64 [use libpcre libraries from given path.] 65 ), 66 [ 67 _libpcre_dir="$withval" 68 _libpcre_dir_lib="$withval" 69 LIBPCRE_LDFLAGS="-L$withval" 70 _libpcre_dir_set="yes" 71 ] 72 ) 73 74 if test "x$enable_static_libs" = "xyes"; then 75 AC_REQUIRE([PKG_PROG_PKG_CONFIG]) 76 PKG_PROG_PKG_CONFIG() 77 test -z "$PKG_CONFIG" -a -z "$_libpcre_dir_lib" && AC_MSG_ERROR([Not found pkg-config library]) 78 m4_pattern_allow([^PKG_CONFIG_LIBDIR$]) 79 fi 80 81 AC_MSG_CHECKING(for libpcre support) 82 83 LIBPCRE_LIBS="-lpcre" 84 85 if test "x$enable_static" = "xyes"; then 86 LIBPCRE_LIBS=" $LIBPCRE_LIBS -lpthread" 87 elif test "x$enable_static_libs" = "xyes" -a -z "$PKG_CONFIG"; then 88 LIBPCRE_LIBS="$_libpcre_dir_lib/libpcre.a" 89 elif test "x$enable_static_libs" = "xyes"; then 90 91 test "x$static_linking_support" = "xno" -a -z "$_libpcre_dir_lib" && AC_MSG_ERROR(["Compiler not support statically linked libs from default folders"]) 92 93 if test -z "$_libpcre_dir_lib"; then 94 PKG_CHECK_EXISTS(libpcre,[ 95 LIBPCRE_LIBS=`$PKG_CONFIG --static --libs libpcre` 96 ],[ 97 AC_MSG_ERROR([Not found libpcre package]) 98 ]) 99 else 100 AC_RUN_LOG([PKG_CONFIG_LIBDIR="$_libpcre_dir_lib/pkgconfig" $PKG_CONFIG --exists --print-errors libpcre]) || AC_MSG_ERROR(["Not found libpcre package in $_libpcre_dir/lib/pkgconfig"]) 101 LIBPCRE_LIBS=`PKG_CONFIG_LIBDIR="$_libpcre_dir_lib/pkgconfig" $PKG_CONFIG --static --libs libpcre` 102 test -z "$LIBPCRE_LIBS" && LIBPCRE_LIBS=`PKG_CONFIG_LIBDIR="$_libpcre_dir_lib/pkgconfig" $PKG_CONFIG --libs libpcre` 103 fi 104 105 if test "x$static_linking_support" = "xno"; then 106 LIBPCRE_LIBS=`echo "$LIBPCRE_LIBS"|sed "s|-lpcre|$_libpcre_dir_lib/libpcre.a|g"` 107 else 108 LIBPCRE_LIBS=`echo "$LIBPCRE_LIBS"|sed "s/-lpcre/${static_linking_support}static -lpcre ${static_linking_support}dynamic/g"` 109 fi 110 fi 111 112 if test -n "$_libpcre_dir_set" -o -f /usr/include/pcre.h; then 113 found_libpcre="yes" 114 elif test -f /usr/local/include/pcre.h; then 115 LIBPCRE_CFLAGS="-I/usr/local/include" 116 LIBPCRE_LDFLAGS="-L/usr/local/lib" 117 found_libpcre="yes" 118 elif test -f /usr/pkg/include/pcre.h; then 119 LIBPCRE_CFLAGS="-I/usr/pkg/include" 120 LIBPCRE_LDFLAGS="-L/usr/pkg/lib" 121 LIBPCRE_LDFLAGS="$LIBPCRE_LDFLAGS -Wl,-R/usr/pkg/lib" 122 found_libpcre="yes" 123 elif test -f /opt/csw/include/pcre.h; then 124 LIBPCRE_CFLAGS="-I/opt/csw/include" 125 LIBPCRE_LDFLAGS="-L/opt/csw/lib" 126 if $(echo "$CFLAGS"|grep -q -- "-m64") ; then 127 LIBPCRE_LDFLAGS="$LIBPCRE_LDFLAGS/64 -Wl,-R/opt/csw/lib/64" 128 else 129 LIBPCRE_LDFLAGS="$LIBPCRE_LDFLAGS -Wl,-R/opt/csw/lib" 130 fi 131 found_libpcre="yes" 132 else 133 found_libpcre="no" 134 AC_MSG_RESULT(no) 135 fi 136 137 if test "x$found_libpcre" = "xyes"; then 138 am_save_CFLAGS="$CFLAGS" 139 am_save_LDFLAGS="$LDFLAGS" 140 am_save_LIBS="$LIBS" 141 142 CFLAGS="$CFLAGS $LIBPCRE_CFLAGS" 143 LDFLAGS="$LDFLAGS $LIBPCRE_LDFLAGS" 144 LIBS="$LIBS $LIBPCRE_LIBS" 145 146 found_libpcre="no" 147 LIBPCRE_TRY_LINK([no]) 148 149 CFLAGS="$am_save_CFLAGS" 150 LDFLAGS="$am_save_LDFLAGS" 151 LIBS="$am_save_LIBS" 152 fi 153 154 if test "x$found_libpcre" = "xyes"; then 155 AC_DEFINE([HAVE_PCRE_H], 1, [Define to 1 if you have the 'libpcre' library (-lpcre)]) 156 AC_MSG_RESULT(yes) 157 else 158 LIBPCRE_CFLAGS="" 159 LIBPCRE_LDFLAGS="" 160 LIBPCRE_LIBS="" 161 fi 162 163 AC_SUBST(LIBPCRE_CFLAGS) 164 AC_SUBST(LIBPCRE_LDFLAGS) 165 AC_SUBST(LIBPCRE_LIBS) 166])dnl 167