- aliases for HttpUtil
[m6w6/ext-http] / config.m4
1 dnl config.m4 for pecl/http
2 dnl $Id$
3 dnl vim: noet ts=1 sw=1
4
5 PHP_ARG_ENABLE([http], [whether to enable extended HTTP support],
6 [ --enable-http Enable extended HTTP support])
7 PHP_ARG_WITH([http-curl-requests], [whether to enable cURL HTTP requests],
8 [ --with-http-curl-requests[=CURLDIR]
9 With cURL HTTP request support])
10 PHP_ARG_WITH([http-mhash-etags], [whether to enable mhash ETag generator],
11 [ --with-http-mhash-etags[=MHASHDIR]
12 With mhash ETag generator support])
13 PHP_ARG_WITH([http-magic-mime], [whether to enable response content type guessing],
14 [ --with-http-magic-mime[=MAGICDIR]
15 With magic mime response content type guessing])
16 PHP_ARG_WITH([http-zlib-compression], [whether to enable support for gzencoded/deflated message bodies],
17 [ --with-http-zlib-compression[=ZLIBDIR]
18 With zlib gzdecode and inflate support])
19
20 if test "$PHP_HTTP" != "no"; then
21
22 dnl -------
23 dnl NETDB.H
24 dnl -------
25 AC_CHECK_HEADERS([netdb.h])
26
27 dnl ----
28 dnl ZLIB
29 dnl ----
30 AC_MSG_CHECKING([for zlib.h])
31 ZLIB_DIR=
32 for i in "$PHP_HTTP_ZLIB_COMPRESSION" "$PHP_ZLIB_DIR" "$PHP_ZLIB" /user/local /usr /opt; do
33 if test -f "$i/include/zlib.h"; then
34 ZLIB_DIR=$i
35 break;
36 fi
37 done
38 if test -z "$ZLIB_DIR"; then
39 AC_MSG_RESULT([not found])
40 AC_MSG_WARN([gzip support not enabled; zlib.h not found])
41 else
42 AC_MSG_RESULT([found in $ZLIB_DIR])
43 PHP_ADD_INCLUDE($ZLIB_DIR/include)
44 PHP_ADD_LIBRARY_WITH_PATH(z, $ZLIB_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
45 AC_DEFINE([HTTP_HAVE_ZLIB], [1], [Have zlib support])
46 fi
47
48 dnl ----
49 dnl CURL
50 dnl ----
51 if test "$PHP_HTTP_CURL_REQUESTS" != "no"; then
52
53 AC_MSG_CHECKING([for curl/curl.h])
54 CURL_DIR=
55 for i in "$PHP_HTTP_CURL_REQUESTS" /usr/local /usr /opt; do
56 if test -f "$i/include/curl/curl.h"; then
57 CURL_DIR=$i
58 break
59 fi
60 done
61 if test -z "$CURL_DIR"; then
62 AC_MSG_RESULT([not found])
63 AC_MSG_ERROR([could not find curl/curl.h])
64 else
65 AC_MSG_RESULT([found in $CURL_DIR])
66 fi
67
68 AC_MSG_CHECKING([for curl-config])
69 CURL_CONFIG=
70 for i in "$CURL_DIR/bin/curl-config" "$CURL_DIR/curl-config" `which curl-config`; do
71 if test -x "$i"; then
72 CURL_CONFIG=$i
73 break
74 fi
75 done
76 if test -z "$CURL_CONFIG"; then
77 AC_MSG_RESULT([not found])
78 AC_MSG_ERROR([could not find curl-config])
79 else
80 AC_MSG_RESULT([found: $CURL_CONFIG])
81 fi
82
83 CURL_LIBS=`$CURL_CONFIG --libs`
84
85 AC_MSG_CHECKING([for SSL support in libcurl])
86 CURL_SSL=`$CURL_CONFIG --features | $EGREP SSL`
87 if test "$CURL_SSL" = "SSL"; then
88 AC_MSG_RESULT([yes])
89 AC_DEFINE([HTTP_HAVE_SSL], [1], [ ])
90
91 AC_MSG_CHECKING([for SSL library used])
92 CURL_SSL_FLAVOUR=
93 for i in $CURL_LIBS; do
94 if test "$i" = "-lssl"; then
95 CURL_SSL_FLAVOUR="openssl"
96 AC_MSG_RESULT([openssl])
97 AC_DEFINE([HTTP_HAVE_OPENSSL], [1], [ ])
98 AC_CHECK_HEADERS([openssl/crypto.h])
99 break
100 elif test "$i" = "-lgnutls"; then
101 CURL_SSL_FLAVOUR="gnutls"
102 AC_MSG_RESULT([gnutls])
103 AC_DEFINE([HTTP_HAVE_GNUTLS], [1], [ ])
104 AC_CHECK_HEADERS([gcrypt.h])
105 break
106 fi
107 done
108 if test -z "$CURL_SSL_FLAVOUR"; then
109 AC_MSG_RESULT([unknown!])
110 AC_MSG_WARN([Could not determine the type of SSL library used!])
111 AC_MSG_WARN([Building will fail in ZTS mode!])
112 fi
113 else
114 AC_MSG_RESULT([no])
115 fi
116
117 PHP_ADD_INCLUDE($CURL_DIR/include)
118 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
119 PHP_EVAL_LIBLINE($CURL_LIBS, HTTP_SHARED_LIBADD)
120 AC_DEFINE([HTTP_HAVE_CURL], [1], [Have cURL support])
121
122 PHP_CHECK_LIBRARY(curl, curl_multi_strerror,
123 [AC_DEFINE([HAVE_CURL_MULTI_STRERROR], [1], [ ])], [ ],
124 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
125 )
126 PHP_CHECK_LIBRARY(curl, curl_easy_strerror,
127 [AC_DEFINE([HAVE_CURL_EASY_STRERROR], [1], [ ])], [ ],
128 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
129 )
130 PHP_CHECK_LIBRARY(curl, curl_easy_reset,
131 [AC_DEFINE([HAVE_CURL_EASY_RESET], [1], [ ])], [ ],
132 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
133 )
134 fi
135
136 dnl ----
137 dnl MHASH
138 dnl ----
139 if test "$PHP_HTTP_MHASH_ETAGS" != "no"; then
140
141 AC_MSG_CHECKING([for mhash.h])
142 MHASH_DIR=
143 for i in "$PHP_HTTP_MHASH_ETAGS" /usr/local /usr /opt; do
144 if test -f "$i/include/mhash.h"; then
145 MHASH_DIR=$i
146 break
147 fi
148 done
149 if test -z "$MHASH_DIR"; then
150 AC_MSG_RESULT([not found])
151 AC_MSG_ERROR([could not find mhash.h])
152 else
153 AC_MSG_RESULT([found in $MHASH_DIR])
154 fi
155
156 PHP_ADD_INCLUDE($MHASH_DIR/include)
157 PHP_ADD_LIBRARY_WITH_PATH(mhash, $MHASH_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
158 AC_DEFINE([HTTP_HAVE_MHASH], [1], [Have mhash support])
159 fi
160
161 dnl ----
162 dnl MAGIC
163 dnl ----
164 if test "$PHP_HTTP_MAGIC_MIME" != "no"; then
165
166 AC_MSG_CHECKING([for magic.h])
167 MAGIC_DIR=
168 for i in "$PHP_HTTP_MAGIC_MIME" /usr/local /usr /opt; do
169 if test -f "$i/include/magic.h"; then
170 MAGIC_DIR=$i
171 break
172 fi
173 done
174 if test -z "$MAGIC_DIR"; then
175 AC_MSG_RESULT([not found])
176 AC_MSG_ERROR([could not find magic.h])
177 else
178 AC_MSG_RESULT([found in $MAGIC_DIR])
179 fi
180
181 PHP_ADD_INCLUDE($MAGIC_DIR/include)
182 PHP_ADD_LIBRARY_WITH_PATH(magic, $MAGIC_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
183 AC_DEFINE([HTTP_HAVE_MAGIC], [1], [Have magic mime support])
184 fi
185
186 dnl ----
187 dnl DONE
188 dnl ----
189 PHP_HTTP_SOURCES="missing.c http.c http_functions.c phpstr/phpstr.c \
190 http_util_object.c http_message_object.c http_request_object.c http_request_pool_api.c \
191 http_response_object.c http_exception_object.c http_requestpool_object.c \
192 http_api.c http_cache_api.c http_request_api.c http_date_api.c \
193 http_headers_api.c http_message_api.c http_send_api.c http_url_api.c \
194 http_info_api.c http_request_method_api.c http_encoding_api.c \
195 http_filter_api.c"
196 PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, $ext_shared)
197 PHP_ADD_BUILD_DIR($ext_builddir/phpstr, 1)
198 PHP_SUBST([HTTP_SHARED_LIBADD])
199
200 PHP_HTTP_HEADERS="php_http_std_defs.h php_http.h php_http_api.h php_http_cache_api.h \
201 php_http_date_api.h php_http_headers_api.h php_http_info_api.h php_http_message_api.h \
202 php_http_request_api.h php_http_request_method_api.h php_http_send_api.h php_http_url_api.h \
203 php_http_encoding_api.h phpstr/phpstr.h"
204 PHP_SUBST([PHP_HTTP_HEADERS])
205
206 dnl outside src dir, adds install-http target
207 PHP_ADD_MAKEFILE_FRAGMENT
208 dnl within src dir, installs http headers
209 ifdef([PHP_INSTALL_HEADERS], [PHP_INSTALL_HEADERS(ext/http, $PHP_HTTP_HEADER_FILES)], [ ])
210
211 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])
212 fi