- Fix language
[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 request support],
8 [ --with-http-curl-requests[=LIBCURLDIR]
9 HTTP: with cURL request support], $PHP_HTTP, $PHP_HTTP)
10 PHP_ARG_WITH([http-zlib-compression], [whether to enable zlib encodings support],
11 [ --with-http-zlib-compression[=LIBZDIR]
12 HTTP: with zlib encodings support], $PHP_HTTP, $PHP_HTTP)
13 PHP_ARG_WITH([http-magic-mime], [whether to enable response content type guessing],
14 [ --with-http-magic-mime[=LIBMAGICDIR]
15 HTTP: with magic mime response content type guessing], "no", "no")
16 PHP_ARG_WITH([http-shared-deps], [whether to depend on shared extensions],
17 [ --with-http-shared-deps HTTP: disable to not depend on shared extensions
18 like SPL, hash, iconv and session], $PHP_HTTP, $PHP_HTTP)
19
20 if test "$PHP_HTTP" != "no"; then
21
22 ifdef([AC_PROG_EGREP], [
23 AC_PROG_EGREP
24 ], [
25 AC_CHECK_PROG(EGREP, egrep, egrep)
26 ])
27 ifdef([AC_PROG_SED], [
28 AC_PROG_SED
29 ], [
30 ifdef([LT_AC_PROG_SED], [
31 LT_AC_PROG_SED
32 ], [
33 AC_CHECK_PROG(SED, sed, sed)
34 ])
35 ])
36
37 if test "PHP_HTTP_SHARED_DEPS" != "no"; then
38 AC_DEFINE([HTTP_SHARED_DEPS], [1], [ ])
39 else
40 AC_DEFINE([HTTP_SHARED_DEPS], [0], [ ])
41 fi
42
43 dnl -------
44 dnl HEADERS
45 dnl -------
46 AC_CHECK_HEADERS([netdb.h unistd.h])
47
48 dnl ----
49 dnl ZLIB
50 dnl ----
51 if test "$PHP_HTTP_ZLIB_COMPRESSION" != "no"; then
52 AC_MSG_CHECKING([for zlib.h])
53 ZLIB_DIR=
54 for i in "$PHP_HTTP_ZLIB_COMPRESSION" "$PHP_ZLIB_DIR" "$PHP_ZLIB" /usr/local /usr /opt; do
55 if test -f "$i/include/zlib.h"; then
56 ZLIB_DIR=$i
57 break;
58 fi
59 done
60 if test -z "$ZLIB_DIR"; then
61 AC_MSG_RESULT([not found])
62 AC_MSG_WARN([could not find zlib.h])
63 else
64 AC_MSG_RESULT([found in $ZLIB_DIR])
65 AC_MSG_CHECKING([for zlib version >= 1.2.0.4])
66 ZLIB_VERSION=`$EGREP "define ZLIB_VERSION" $ZLIB_DIR/include/zlib.h | $SED -e 's/[[^0-9\.]]//g'`
67 AC_MSG_RESULT([$ZLIB_VERSION])
68 if test `echo $ZLIB_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*1000000 + $2*10000 + $3*100 + $4}'` -lt 1020004; then
69 AC_MSG_ERROR([libz version greater or equal to 1.2.0.4 required])
70 else
71 PHP_ADD_INCLUDE($ZLIB_DIR/include)
72 PHP_ADD_LIBRARY_WITH_PATH(z, $ZLIB_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
73 AC_DEFINE([HTTP_HAVE_ZLIB], [1], [Have zlib support])
74 fi
75 fi
76 fi
77
78 dnl ----
79 dnl CURL
80 dnl ----
81 if test "$PHP_HTTP_CURL_REQUESTS" != "no"; then
82 AC_MSG_CHECKING([for curl/curl.h])
83 CURL_DIR=
84 for i in "$PHP_HTTP_CURL_REQUESTS" /usr/local /usr /opt; do
85 if test -f "$i/include/curl/curl.h"; then
86 CURL_DIR=$i
87 break
88 fi
89 done
90 if test -z "$CURL_DIR"; then
91 AC_MSG_RESULT([not found])
92 AC_MSG_ERROR([could not find curl/curl.h])
93 else
94 AC_MSG_RESULT([found in $CURL_DIR])
95 fi
96
97 AC_MSG_CHECKING([for curl-config])
98 CURL_CONFIG=
99 for i in "$CURL_DIR/bin/curl-config" "$CURL_DIR/curl-config" `which curl-config`; do
100 if test -x "$i"; then
101 CURL_CONFIG=$i
102 break
103 fi
104 done
105 if test -z "$CURL_CONFIG"; then
106 AC_MSG_RESULT([not found])
107 AC_MSG_ERROR([could not find curl-config])
108 else
109 AC_MSG_RESULT([found: $CURL_CONFIG])
110 fi
111
112 dnl Debian stable has currently 7.13.2 (this is not a typo)
113 AC_MSG_CHECKING([for curl version >= 7.12.3])
114 CURL_VERSION=`$CURL_CONFIG --version | $SED -e 's/[[^0-9\.]]//g'`
115 AC_MSG_RESULT([$CURL_VERSION])
116 if test `echo $CURL_VERSION | $AWK '{print $1*10000 + $2*100 + $3}'` -lt 71203; then
117 AC_MSG_ERROR([libcurl version greater or equal to 7.12.3 required])
118 fi
119
120 CURL_LIBS=`$CURL_CONFIG --libs`
121
122 AC_MSG_CHECKING([for SSL support in libcurl])
123 CURL_SSL=`$CURL_CONFIG --features | $EGREP SSL`
124 if test "$CURL_SSL" = "SSL"; then
125 AC_MSG_RESULT([yes])
126 AC_DEFINE([HTTP_HAVE_SSL], [1], [ ])
127
128 AC_MSG_CHECKING([for SSL library used])
129 CURL_SSL_FLAVOUR=
130 for i in $CURL_LIBS; do
131 if test "$i" = "-lssl"; then
132 CURL_SSL_FLAVOUR="openssl"
133 AC_MSG_RESULT([openssl])
134 AC_DEFINE([HTTP_HAVE_OPENSSL], [1], [ ])
135 AC_CHECK_HEADERS([openssl/crypto.h])
136 break
137 elif test "$i" = "-lgnutls"; then
138 CURL_SSL_FLAVOUR="gnutls"
139 AC_MSG_RESULT([gnutls])
140 AC_DEFINE([HTTP_HAVE_GNUTLS], [1], [ ])
141 AC_CHECK_HEADERS([gcrypt.h])
142 break
143 fi
144 done
145 if test -z "$CURL_SSL_FLAVOUR"; then
146 AC_MSG_RESULT([unknown!])
147 AC_MSG_WARN([Could not determine the type of SSL library used!])
148 AC_MSG_WARN([Building will fail in ZTS mode!])
149 fi
150 else
151 AC_MSG_RESULT([no])
152 fi
153
154 PHP_ADD_INCLUDE($CURL_DIR/include)
155 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
156 PHP_EVAL_LIBLINE($CURL_LIBS, HTTP_SHARED_LIBADD)
157 AC_DEFINE([HTTP_HAVE_CURL], [1], [Have cURL support])
158
159 PHP_CHECK_LIBRARY(curl, curl_multi_strerror,
160 [AC_DEFINE([HAVE_CURL_MULTI_STRERROR], [1], [ ])], [ ],
161 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
162 )
163 PHP_CHECK_LIBRARY(curl, curl_easy_strerror,
164 [AC_DEFINE([HAVE_CURL_EASY_STRERROR], [1], [ ])], [ ],
165 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
166 )
167 PHP_CHECK_LIBRARY(curl, curl_easy_reset,
168 [AC_DEFINE([HAVE_CURL_EASY_RESET], [1], [ ])], [ ],
169 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
170 )
171 dnl Debian suddenly (>=7.14.1-2) hides all symbols not starting with "curl"
172 PHP_CHECK_LIBRARY(curl, Curl_getFormData,
173 [AC_DEFINE([HAVE_CURL_GETFORMDATA], [1], [ ])], [ ],
174 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
175 )
176 fi
177
178 dnl ----
179 dnl MAGIC
180 dnl ----
181 if test "$PHP_HTTP_MAGIC_MIME" != "no"; then
182 AC_MSG_CHECKING([for magic.h])
183 MAGIC_DIR=
184 for i in "$PHP_HTTP_MAGIC_MIME" /usr/local /usr /opt; do
185 if test -f "$i/include/magic.h"; then
186 MAGIC_DIR=$i
187 break
188 fi
189 done
190 if test -z "$MAGIC_DIR"; then
191 AC_MSG_RESULT([not found])
192 AC_MSG_ERROR([could not find magic.h])
193 else
194 AC_MSG_RESULT([found in $MAGIC_DIR])
195 fi
196
197 PHP_ADD_INCLUDE($MAGIC_DIR/include)
198 PHP_ADD_LIBRARY_WITH_PATH(magic, $MAGIC_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
199 AC_DEFINE([HTTP_HAVE_MAGIC], [1], [Have magic mime support])
200 fi
201
202 dnl ----
203 dnl HASH
204 dnl ----
205 AC_MSG_CHECKING(for ext/hash support)
206 if test -x "$PHP_EXECUTABLE"; then
207 if test "`$PHP_EXECUTABLE -m | $EGREP '^hash$'`" = "hash"; then
208 if test -d ../hash; then
209 PHP_ADD_INCLUDE([../hash])
210 fi
211 old_CPPFLAGS=$CPPFLAGS
212 CPPFLAGS=$INCLUDES
213 AC_MSG_RESULT([looking for php_hash.h])
214 AC_CHECK_HEADER([ext/hash/php_hash.h], [
215 AC_DEFINE([HTTP_HAVE_EXT_HASH_EXT_HASH], [1], [Have ext/hash support])
216 ], [
217 AC_CHECK_HEADER([hash/php_hash.h], [
218 AC_DEFINE([HTTP_HAVE_HASH_EXT_HASH], [1], [Have ext/hash support])
219 ], [
220 AC_CHECK_HEADER([php_hash.h], [
221 AC_DEFINE([HTTP_HAVE_EXT_HASH], [1], [Have ext/hash support])
222 ])
223 ])
224 ])
225 CPPFLAGS=$old_CPPFLAGS;
226 else
227 AC_MSG_RESULT(disabled)
228 fi
229 elif test "$PHP_HASH" != "no" && test "x$PHP_HASH" != "x"; then
230 AC_MSG_RESULT(enabled)
231 ifdef([PHP_ADD_EXTENSION_DEP], [
232 PHP_ADD_EXTENSION_DEP([http], [hash], 0)
233 AC_DEFINE([HTTP_HAVE_EXT_HASH_EXT_HASH], [1], [Have ext/hash support])
234 ])
235 else
236 AC_MSG_RESULT(disabled)
237 fi
238
239 dnl ----
240 dnl DONE
241 dnl ----
242 PHP_HTTP_SOURCES="missing.c http.c http_functions.c phpstr/phpstr.c \
243 http_util_object.c http_message_object.c http_request_object.c http_request_pool_api.c \
244 http_response_object.c http_exception_object.c http_requestpool_object.c \
245 http_api.c http_cache_api.c http_request_api.c http_date_api.c \
246 http_headers_api.c http_message_api.c http_send_api.c http_url_api.c \
247 http_info_api.c http_request_method_api.c http_encoding_api.c \
248 http_filter_api.c http_request_body_api.c http_querystring_object.c \
249 http_deflatestream_object.c http_inflatestream_object.c http_cookie_api.c \
250 http_querystring_api.c"
251 PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, $ext_shared)
252 PHP_ADD_BUILD_DIR($ext_builddir/phpstr, 1)
253 PHP_SUBST([HTTP_SHARED_LIBADD])
254
255 PHP_HTTP_HEADERS="php_http_std_defs.h php_http.h php_http_api.h php_http_cache_api.h \
256 php_http_date_api.h php_http_headers_api.h php_http_info_api.h php_http_message_api.h \
257 php_http_request_api.h php_http_request_method_api.h php_http_send_api.h php_http_url_api.h \
258 php_http_encoding_api.h phpstr/phpstr.h missing.h php_http_request_body_api.h \
259 php_http_exception_object.h php_http_message_object.h php_http_request_object.h \
260 php_http_requestpool_object.h php_http_response_object.h php_http_util_object.h \
261 php_http_querystring_object.h php_http_deflatestream_object.h php_http_inflatestream_object.h \
262 php_http_cookie_api.h php_http_querystring_api.h"
263 ifdef([PHP_INSTALL_HEADERS], [
264 PHP_INSTALL_HEADERS(ext/http, $PHP_HTTP_HEADERS)
265 ], [
266 PHP_SUBST([PHP_HTTP_HEADERS])
267 PHP_ADD_MAKEFILE_FRAGMENT
268 ])
269
270 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])
271 fi