- first check for the SSL lib string in libcurl and then for the header
[m6w6/ext-http] / config9.m4
index 3edb363ce939389562056783826aad24d7ebc6b4..73783c1af92e8bdfdc0dca67d63e9f150b578a3e 100644 (file)
@@ -11,6 +11,9 @@ PHP_ARG_WITH([http-shared-deps], [whether to depend on extensions which have bee
 PHP_ARG_WITH([http-curl-requests], [whether to enable cURL HTTP request support],
 [  --with-http-curl-requests[=LIBCURLDIR]
                            HTTP: with cURL request support], $PHP_HTTP, $PHP_HTTP)
+PHP_ARG_WITH([http-curl-libevent], [whether to enable libevent support fur cURL],
+[  --with-http-curl-libevent[=LIBEVENTDIR]
+                           HTTP: libevent install directory], $PHP_HTTP_CURL_REQUESTS, "")
 PHP_ARG_WITH([http-zlib-compression], [whether to enable zlib encodings support],
 [  --with-http-zlib-compression[=LIBZDIR]
                            HTTP: with zlib encodings support], $PHP_HTTP, $PHP_HTTP)
@@ -175,39 +178,66 @@ dnl ----
                        AC_MSG_ERROR([libcurl version greater or equal to 7.12.3 required])
                fi
                
-               CURL_LIBS=`$CURL_CONFIG --libs`
-               
+               AC_PROG_CPP
                AC_MSG_CHECKING([for SSL support in libcurl])
                CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
                if test "$CURL_SSL" = "SSL"; then
                        AC_MSG_RESULT([yes])
                        AC_DEFINE([HTTP_HAVE_SSL], [1], [ ])
                        
-                       AC_MSG_CHECKING([for SSL library used])
-                       CURL_SSL_FLAVOUR=
-                       for i in $CURL_LIBS; do
-                               case $i in
-                                       -lssl* | -lyassl*)
-                                               CURL_SSL_FLAVOUR="openssl"
-                                               AC_MSG_RESULT([openssl])
-                                               AC_DEFINE([HTTP_HAVE_OPENSSL], [1], [ ])
-                                               AC_CHECK_HEADERS([openssl/crypto.h])
-                                               break
-                                       ;;
-                                       -lgnutls*)
-                                               CURL_SSL_FLAVOUR="gnutls"
-                                               AC_MSG_RESULT([gnutls])
-                                               AC_DEFINE([HTTP_HAVE_GNUTLS], [1], [ ])
-                                               AC_CHECK_HEADERS([gcrypt.h])
-                                               break
-                                       ;;
-                               esac
-                       done
-                       if test -z "$CURL_SSL_FLAVOUR"; then
-                               AC_MSG_RESULT([unknown!])
-                               AC_MSG_WARN([Could not determine the type of SSL library used!])
-                               AC_MSG_WARN([Building will fail in ZTS mode!])
-                       fi
+                       save_CFLAGS="$CFLAGS"
+                       CFLAGS="`$CURL_CONFIG --cflags`"
+                       save_LDFLAGS="$LDFALGS"
+                       LDFLAGS="`$CURL_CONFIG --libs` $ld_runpath_switch$CURL_DIR/$PHP_LIBDIR"
+                       
+                       AC_MSG_CHECKING([for openssl support in libcurl])
+                       AC_TRY_RUN([
+                               #include <curl/curl.h>
+                               int main(int argc, char *argv[]) {
+                                       curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
+                                       if (data && data->ssl_version && *data->ssl_version) {
+                                               const char *ptr = data->ssl_version;
+                                               while(*ptr == ' ') ++ptr;
+                                               return strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1);
+                                       }
+                                       return 1;
+                               }
+                       ], [
+                               AC_MSG_RESULT([yes])
+                               AC_CHECK_HEADER([openssl/crypto.h], [
+                                       AC_DEFINE([HTTP_HAVE_OPENSSL], [1], [ ])
+                               ])
+                       ], [
+                               AC_MSG_RESULT([no])
+                       ], [
+                               AC_MSG_RESULT([no])
+                       ])
+                       
+                       AC_MSG_CHECKING([for gnutls support in libcurl])
+                       AC_TRY_RUN([
+                               #include <curl/curl.h>
+                               int main(int argc, char *argv[]) {
+                                       curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
+                                       if (data && data->ssl_version && *data->ssl_version) {
+                                               const char *ptr = data->ssl_version;
+                                               while(*ptr == ' ') ++ptr;
+                                               return strncasecmp(ptr, "GnuTLS", sizeof("GnuTLS")-1);
+                                       }
+                                       return 1;
+                               }
+                       ], [
+                               AC_MSG_RESULT([yes])
+                               AC_CHECK_HEADER([gcrypt.h], [
+                                       AC_DEFINE([HTTP_HAVE_GNUTLS], [1], [ ])
+                               ])
+                       ], [
+                               AC_MSG_RESULT([no])
+                       ], [
+                               AC_MSG_RESULT([no])
+                       ])
+                       
+                       CFLAGS="$save_CFLAGS"
+                       LDFLAGS="$save_LDFLAGS"
                else
                        AC_MSG_RESULT([no])
                fi
@@ -267,6 +297,52 @@ dnl ----
                        [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
                )
                
+               dnl ----
+               dnl EVENT
+               dnl ----
+               
+               if test "$PHP_HTTP_CURL_LIBEVENT" != "no"; then
+                       AC_MSG_CHECKING([for event.h])
+                       EVENT_DIR=
+                       for i in "$PHP_HTTP_CURL_LIBEVENT" /usr/local /usr /opt; do
+                               if test -f "$i/include/event.h"; then
+                                       EVENT_DIR=$i
+                                       break
+                               fi
+                       done
+                       if test -z "$EVENT_DIR"; then
+                               AC_MSG_RESULT([not found])
+                               AC_MSG_WARN([continuing without libevent support])
+                       else
+                               AC_MSG_RESULT([found in $EVENT_DIR])
+                               
+                               AC_MSG_CHECKING([for libevent version, roughly])
+                               EVENT_VER="1.1b or lower"
+                               if test -f "$EVENT_DIR/include/evhttp.h" && test -f "$EVENT_DIR/include/evdns.h"; then
+                                       if test -f "$EVENT_DIR/include/evrpc.h"; then
+                                               EVENT_VER="1.4 or greater"
+                                       else
+                                               EVENT_VER="1.2 or greater"
+                                       fi
+                               fi
+                               AC_DEFINE_UNQUOTED([HTTP_EVENT_VERSION], ["$EVENT_VER"], [ ])
+                               AC_MSG_RESULT([$EVENT_VER])
+                               
+                               AC_MSG_CHECKING([for libcurl version >= 7.16.0])
+                               AC_MSG_RESULT([$CURL_VERSION])
+                               if test `echo $CURL_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*10000 + $2*100 + $3}'` -lt 71600; then
+                                       AC_MSG_WARN([libcurl version greater or equal to 7.16.0 required; continuing without libevent support])
+                               else
+                                       PHP_ADD_INCLUDE($EVENT_DIR/include)
+                                       PHP_ADD_LIBRARY_WITH_PATH(event, $EVENT_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
+                                       AC_DEFINE([HTTP_HAVE_EVENT], [1], [Have libevent support for cURL])
+                                       PHP_CHECK_LIBRARY(curl, curl_multi_socket_action, 
+                                               [AC_DEFINE([HAVE_CURL_MULTI_SOCKET_ACTION], [1], [ ])], [ ],
+                                               [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
+                                       )
+                               fi
+                       fi
+               fi
        fi
 
 dnl ----