1dnl config.m4 for extension curl 2 3PHP_ARG_WITH(curl, for cURL support, 4[ --with-curl[=DIR] Include cURL support]) 5 6if test "$PHP_CURL" != "no"; then 7 if test -z "$PKG_CONFIG"; then 8 AC_PATH_PROG(PKG_CONFIG, pkg-config, no) 9 fi 10 11 if test -x "$PKG_CONFIG"; then 12 dnl using pkg-config output 13 14 AC_MSG_CHECKING(for libcurl.pc) 15 if test "$PHP_CURL" = "yes" -o "$PHP_CURL" = "/usr"; then 16 PKNAME=libcurl 17 AC_MSG_RESULT(using default path) 18 elif test -r $PHP_CURL/$PHP_LIBDIR/pkgconfig/libcurl.pc; then 19 PKNAME=$PHP_CURL/$PHP_LIBDIR/pkgconfig/libcurl.pc 20 AC_MSG_RESULT(using $PKNAME) 21 elif test -r $PHP_CURL/lib/pkgconfig/libcurl.pc; then 22 PKNAME=$PHP_CURL/lib/pkgconfig/libcurl.pc 23 AC_MSG_RESULT(using $PKNAME) 24 else 25 AC_MSG_RESULT(not found) 26 AC_MSG_WARN(Could not find libcurl.pc. Try without $PHP_CURL or set PKG_CONFIG_PATH) 27 fi 28 fi 29 30 if test -n "$PKNAME"; then 31 AC_MSG_CHECKING(for cURL 7.15.5 or greater) 32 if $PKG_CONFIG --atleast-version 7.15.5 $PKNAME; then 33 curl_version_full=`$PKG_CONFIG --modversion $PKNAME` 34 AC_MSG_RESULT($curl_version_full) 35 else 36 AC_MSG_ERROR(cURL version 7.15.5 or later is required to compile php with cURL support) 37 fi 38 39 CURL_LIBS=`$PKG_CONFIG --libs $PKNAME` 40 CURL_INCL=`$PKG_CONFIG --cflags $PKNAME` 41 CURL_SSL=`$PKG_CONFIG --variable=supported_features $PKNAME| $EGREP SSL` 42 else 43 dnl fallback to old vay, using curl-config 44 AC_MSG_WARN(Fallback: search for curl headers and curl-config) 45 46 if test -r $PHP_CURL/include/curl/easy.h; then 47 CURL_DIR=$PHP_CURL 48 else 49 AC_MSG_CHECKING(for cURL in default path) 50 for i in /usr/local /usr; do 51 if test -r $i/include/curl/easy.h; then 52 CURL_DIR=$i 53 AC_MSG_RESULT(found in $i) 54 break 55 fi 56 done 57 fi 58 59 if test -z "$CURL_DIR"; then 60 AC_MSG_RESULT(not found) 61 AC_MSG_ERROR(Please reinstall the libcurl distribution - 62 easy.h should be in <curl-dir>/include/curl/) 63 fi 64 65 CURL_CONFIG="curl-config" 66 AC_MSG_CHECKING(for cURL 7.15.5 or greater) 67 68 if ${CURL_DIR}/bin/curl-config --libs > /dev/null 2>&1; then 69 CURL_CONFIG=${CURL_DIR}/bin/curl-config 70 else 71 if ${CURL_DIR}/curl-config --libs > /dev/null 2>&1; then 72 CURL_CONFIG=${CURL_DIR}/curl-config 73 fi 74 fi 75 76 curl_version_full=`$CURL_CONFIG --version` 77 curl_version=`echo ${curl_version_full} | sed -e 's/libcurl //' | $AWK 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'` 78 if test "$curl_version" -ge 7015005; then 79 AC_MSG_RESULT($curl_version_full) 80 CURL_LIBS=`$CURL_CONFIG --libs` 81 CURL_INCL=`$CURL_CONFIG --cflags` 82 CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL` 83 else 84 AC_MSG_ERROR(cURL version 7.15.5 or later is required to compile php with cURL support) 85 fi 86 fi 87 88 dnl common stuff (pkg-config / curl-config) 89 90 PHP_EVAL_LIBLINE($CURL_LIBS, CURL_SHARED_LIBADD) 91 PHP_EVAL_INCLINE($CURL_INCL, CURL_SHARED_LIBADD) 92 93 AC_MSG_CHECKING([for SSL support in libcurl]) 94 if test -n "$CURL_SSL"; then 95 AC_MSG_RESULT([yes]) 96 AC_DEFINE([HAVE_CURL_SSL], [1], [Have cURL with SSL support]) 97 98 save_CFLAGS="$CFLAGS" 99 CFLAGS=$CURL_INCL 100 save_LDFLAGS="$LDFLAGS" 101 LDFLAGS=$CURL_LIBS 102 103 AC_PROG_CPP 104 AC_MSG_CHECKING([for openssl support in libcurl]) 105 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 106#include <strings.h> 107#include <curl/curl.h> 108 109int main(int argc, char *argv[]) 110{ 111 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); 112 113 if (data && data->ssl_version && *data->ssl_version) { 114 const char *ptr = data->ssl_version; 115 116 while(*ptr == ' ') ++ptr; 117 return strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1); 118 } 119 return 1; 120} 121 ]])],[ 122 AC_MSG_RESULT([yes]) 123 AC_CHECK_HEADERS([openssl/crypto.h], [ 124 AC_DEFINE([HAVE_CURL_OPENSSL], [1], [Have cURL with OpenSSL support]) 125 ]) 126 ], [ 127 AC_MSG_RESULT([no]) 128 ], [ 129 AC_MSG_RESULT([no]) 130 ]) 131 132 AC_MSG_CHECKING([for gnutls support in libcurl]) 133 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 134#include <strings.h> 135#include <curl/curl.h> 136 137int main(int argc, char *argv[]) 138{ 139 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); 140 141 if (data && data->ssl_version && *data->ssl_version) { 142 const char *ptr = data->ssl_version; 143 144 while(*ptr == ' ') ++ptr; 145 return strncasecmp(ptr, "GnuTLS", sizeof("GnuTLS")-1); 146 } 147 return 1; 148} 149]])], [ 150 AC_MSG_RESULT([yes]) 151 AC_CHECK_HEADER([gcrypt.h], [ 152 AC_DEFINE([HAVE_CURL_GNUTLS], [1], [Have cURL with GnuTLS support]) 153 ]) 154 ], [ 155 AC_MSG_RESULT([no]) 156 ], [ 157 AC_MSG_RESULT([no]) 158 ]) 159 160 CFLAGS="$save_CFLAGS" 161 LDFLAGS="$save_LDFLAGS" 162 else 163 AC_MSG_RESULT([no]) 164 fi 165 166 PHP_CHECK_LIBRARY(curl,curl_easy_perform, 167 [ 168 AC_DEFINE(HAVE_CURL,1,[ ]) 169 ],[ 170 AC_MSG_ERROR(There is something wrong. Please check config.log for more information.) 171 ],[ 172 $CURL_LIBS 173 ]) 174 175 PHP_CHECK_LIBRARY(curl,curl_easy_strerror, 176 [ 177 AC_DEFINE(HAVE_CURL_EASY_STRERROR,1,[ ]) 178 ],[],[ 179 $CURL_LIBS 180 ]) 181 182 PHP_CHECK_LIBRARY(curl,curl_multi_strerror, 183 [ 184 AC_DEFINE(HAVE_CURL_MULTI_STRERROR,1,[ ]) 185 ],[],[ 186 $CURL_LIBS 187 ]) 188 189 PHP_NEW_EXTENSION(curl, interface.c multi.c share.c curl_file.c, $ext_shared) 190 PHP_SUBST(CURL_SHARED_LIBADD) 191fi 192