- SPL cannot be built shared, so no need to check
[m6w6/ext-http] / config9.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 extensions which have been built shared],
17 [ --with-http-shared-deps HTTP: disable to not depend on extensions like hash,
18 iconv and session (when built shared)], $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 HTTP_SHARED_DEP(name[, code-if-yes[, code-if-not]])
45 dnl
46 AC_DEFUN([HTTP_SHARED_DEP], [
47 extname=$1
48 haveext=$[HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)
49
50 AC_MSG_CHECKING([whether to add a dependency on ext/$extname])
51 if test "$PHP_HTTP_SHARED_DEPS" = "no"; then
52 AC_MSG_RESULT([no])
53 $3
54 elif test "$haveext"; then
55 AC_MSG_RESULT([yes])
56 ifdef([PHP_ADD_EXTENSION_DEP], [
57 PHP_ADD_EXTENSION_DEP([http], $1, 0)
58 ])
59 $2
60 else
61 AC_MSG_RESULT([no])
62 $3
63 fi
64 ])
65
66 dnl
67 dnl HTTP_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]])
68 dnl
69 AC_DEFUN([HTTP_HAVE_PHP_EXT], [
70 extname=$1
71 haveext=$[PHP_]translit($1,a-z_-,A-Z__)
72
73 AC_MSG_CHECKING([for ext/$extname support])
74 if test -x "$PHP_EXECUTABLE"; then
75 if test "`$PHP_EXECUTABLE -m | $EGREP ^$extname\$`" = "$extname"; then
76 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
77 AC_MSG_RESULT([yes])
78 $2
79 else
80 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
81 AC_MSG_RESULT([no])
82 $3
83 fi
84 elif test "$haveext" != "no" && test "x$haveext" != "x"; then
85 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
86 AC_MSG_RESULT([yes])
87 $2
88 else
89 [HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
90 AC_MSG_RESULT([no])
91 $3
92 fi
93 ])
94
95 dnl -------
96 dnl HEADERS
97 dnl -------
98 AC_CHECK_HEADERS([netdb.h unistd.h])
99
100 dnl ----
101 dnl ZLIB
102 dnl ----
103 if test "$PHP_HTTP_ZLIB_COMPRESSION" != "no"; then
104 AC_MSG_CHECKING([for zlib.h])
105 ZLIB_DIR=
106 for i in "$PHP_HTTP_ZLIB_COMPRESSION" "$PHP_ZLIB_DIR" "$PHP_ZLIB" /usr/local /usr /opt; do
107 if test -f "$i/include/zlib.h"; then
108 ZLIB_DIR=$i
109 break;
110 fi
111 done
112 if test -z "$ZLIB_DIR"; then
113 AC_MSG_RESULT([not found])
114 AC_MSG_WARN([could not find zlib.h])
115 else
116 AC_MSG_RESULT([found in $ZLIB_DIR])
117 AC_MSG_CHECKING([for zlib version >= 1.2.0.4])
118 ZLIB_VERSION=`$EGREP "define ZLIB_VERSION" $ZLIB_DIR/include/zlib.h | $SED -e 's/[[^0-9\.]]//g'`
119 AC_MSG_RESULT([$ZLIB_VERSION])
120 if test `echo $ZLIB_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*1000000 + $2*10000 + $3*100 + $4}'` -lt 1020004; then
121 AC_MSG_ERROR([libz version greater or equal to 1.2.0.4 required])
122 else
123 PHP_ADD_INCLUDE($ZLIB_DIR/include)
124 PHP_ADD_LIBRARY_WITH_PATH(z, $ZLIB_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
125 AC_DEFINE([HTTP_HAVE_ZLIB], [1], [Have zlib support])
126 fi
127 fi
128 fi
129
130 dnl ----
131 dnl CURL
132 dnl ----
133 if test "$PHP_HTTP_CURL_REQUESTS" != "no"; then
134 AC_MSG_CHECKING([for curl/curl.h])
135 CURL_DIR=
136 for i in "$PHP_HTTP_CURL_REQUESTS" /usr/local /usr /opt; do
137 if test -f "$i/include/curl/curl.h"; then
138 CURL_DIR=$i
139 break
140 fi
141 done
142 if test -z "$CURL_DIR"; then
143 AC_MSG_RESULT([not found])
144 AC_MSG_ERROR([could not find curl/curl.h])
145 else
146 AC_MSG_RESULT([found in $CURL_DIR])
147 fi
148
149 AC_MSG_CHECKING([for curl-config])
150 CURL_CONFIG=
151 for i in "$CURL_DIR/bin/curl-config" "$CURL_DIR/curl-config" `which curl-config`; do
152 if test -x "$i"; then
153 CURL_CONFIG=$i
154 break
155 fi
156 done
157 if test -z "$CURL_CONFIG"; then
158 AC_MSG_RESULT([not found])
159 AC_MSG_ERROR([could not find curl-config])
160 else
161 AC_MSG_RESULT([found: $CURL_CONFIG])
162 fi
163
164 dnl Debian stable has currently 7.13.2 (this is not a typo)
165 AC_MSG_CHECKING([for curl version >= 7.12.3])
166 CURL_VERSION=`$CURL_CONFIG --version | $SED -e 's/[[^0-9\.]]//g'`
167 AC_MSG_RESULT([$CURL_VERSION])
168 if test `echo $CURL_VERSION | $AWK '{print $1*10000 + $2*100 + $3}'` -lt 71203; then
169 AC_MSG_ERROR([libcurl version greater or equal to 7.12.3 required])
170 fi
171
172 CURL_LIBS=`$CURL_CONFIG --libs`
173
174 AC_MSG_CHECKING([for SSL support in libcurl])
175 CURL_SSL=`$CURL_CONFIG --features | $EGREP SSL`
176 if test "$CURL_SSL" = "SSL"; then
177 AC_MSG_RESULT([yes])
178 AC_DEFINE([HTTP_HAVE_SSL], [1], [ ])
179
180 AC_MSG_CHECKING([for SSL library used])
181 CURL_SSL_FLAVOUR=
182 for i in $CURL_LIBS; do
183 if test "$i" = "-lssl"; then
184 CURL_SSL_FLAVOUR="openssl"
185 AC_MSG_RESULT([openssl])
186 AC_DEFINE([HTTP_HAVE_OPENSSL], [1], [ ])
187 AC_CHECK_HEADERS([openssl/crypto.h])
188 break
189 elif test "$i" = "-lgnutls"; then
190 CURL_SSL_FLAVOUR="gnutls"
191 AC_MSG_RESULT([gnutls])
192 AC_DEFINE([HTTP_HAVE_GNUTLS], [1], [ ])
193 AC_CHECK_HEADERS([gcrypt.h])
194 break
195 fi
196 done
197 if test -z "$CURL_SSL_FLAVOUR"; then
198 AC_MSG_RESULT([unknown!])
199 AC_MSG_WARN([Could not determine the type of SSL library used!])
200 AC_MSG_WARN([Building will fail in ZTS mode!])
201 fi
202 else
203 AC_MSG_RESULT([no])
204 fi
205
206 PHP_ADD_INCLUDE($CURL_DIR/include)
207 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
208 PHP_EVAL_LIBLINE($CURL_LIBS, HTTP_SHARED_LIBADD)
209 AC_DEFINE([HTTP_HAVE_CURL], [1], [Have cURL support])
210
211 PHP_CHECK_LIBRARY(curl, curl_multi_strerror,
212 [AC_DEFINE([HAVE_CURL_MULTI_STRERROR], [1], [ ])], [ ],
213 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
214 )
215 PHP_CHECK_LIBRARY(curl, curl_easy_strerror,
216 [AC_DEFINE([HAVE_CURL_EASY_STRERROR], [1], [ ])], [ ],
217 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
218 )
219 PHP_CHECK_LIBRARY(curl, curl_easy_reset,
220 [AC_DEFINE([HAVE_CURL_EASY_RESET], [1], [ ])], [ ],
221 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
222 )
223 dnl Debian suddenly (>=7.14.1-2) hides all symbols not starting with "curl"
224 PHP_CHECK_LIBRARY(curl, Curl_getFormData,
225 [AC_DEFINE([HAVE_CURL_GETFORMDATA], [1], [ ])], [ ],
226 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
227 )
228 fi
229
230 dnl ----
231 dnl MAGIC
232 dnl ----
233 if test "$PHP_HTTP_MAGIC_MIME" != "no"; then
234 AC_MSG_CHECKING([for magic.h])
235 MAGIC_DIR=
236 for i in "$PHP_HTTP_MAGIC_MIME" /usr/local /usr /opt; do
237 if test -f "$i/include/magic.h"; then
238 MAGIC_DIR=$i
239 break
240 fi
241 done
242 if test -z "$MAGIC_DIR"; then
243 AC_MSG_RESULT([not found])
244 AC_MSG_ERROR([could not find magic.h])
245 else
246 AC_MSG_RESULT([found in $MAGIC_DIR])
247 fi
248
249 PHP_ADD_INCLUDE($MAGIC_DIR/include)
250 PHP_ADD_LIBRARY_WITH_PATH(magic, $MAGIC_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
251 AC_DEFINE([HTTP_HAVE_MAGIC], [1], [Have magic mime support])
252 fi
253
254 dnl ----
255 dnl HASH
256 dnl ----
257 HTTP_HAVE_PHP_EXT([hash], [
258 if test -d ../hash; then
259 PHP_ADD_INCLUDE([../hash])
260 fi
261 old_CPPFLAGS=$CPPFLAGS
262 CPPFLAGS=$INCLUDES
263 AC_CHECK_HEADER([ext/hash/php_hash.h], [
264 AC_DEFINE([HTTP_HAVE_EXT_HASH_EXT_HASH], [1], [Have ext/hash support])
265 ], [
266 AC_CHECK_HEADER([hash/php_hash.h], [
267 AC_DEFINE([HTTP_HAVE_HASH_EXT_HASH], [1], [Have ext/hash support])
268 ], [
269 AC_CHECK_HEADER([php_hash.h], [
270 AC_DEFINE([HTTP_HAVE_EXT_HASH], [1], [Have ext/hash support])
271 ])
272 ])
273 ])
274 CPPFLAGS=$old_CPPFLAGS
275 ])
276
277 dnl ----
278 dnl ICONV
279 dnl ----
280 HTTP_HAVE_PHP_EXT([iconv])
281
282 dnl ----
283 dnl SESSION
284 dnl ----
285 HTTP_HAVE_PHP_EXT([session])
286
287 dnl ----
288 dnl DONE
289 dnl ----
290 PHP_HTTP_SOURCES="missing.c http.c http_functions.c phpstr/phpstr.c \
291 http_util_object.c http_message_object.c http_request_object.c http_request_pool_api.c \
292 http_response_object.c http_exception_object.c http_requestpool_object.c \
293 http_api.c http_cache_api.c http_request_api.c http_date_api.c \
294 http_headers_api.c http_message_api.c http_send_api.c http_url_api.c \
295 http_info_api.c http_request_method_api.c http_encoding_api.c \
296 http_filter_api.c http_request_body_api.c http_querystring_object.c \
297 http_deflatestream_object.c http_inflatestream_object.c http_cookie_api.c \
298 http_querystring_api.c"
299
300 PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, $ext_shared)
301
302 dnl shared extension deps
303 HTTP_SHARED_DEP([hash])
304 HTTP_SHARED_DEP([iconv])
305 HTTP_SHARED_DEP([session])
306
307 PHP_ADD_BUILD_DIR($ext_builddir/phpstr, 1)
308 PHP_SUBST([HTTP_SHARED_LIBADD])
309
310 PHP_HTTP_HEADERS="php_http_std_defs.h php_http.h php_http_api.h php_http_cache_api.h \
311 php_http_date_api.h php_http_headers_api.h php_http_info_api.h php_http_message_api.h \
312 php_http_request_api.h php_http_request_method_api.h php_http_send_api.h php_http_url_api.h \
313 php_http_encoding_api.h phpstr/phpstr.h missing.h php_http_request_body_api.h \
314 php_http_exception_object.h php_http_message_object.h php_http_request_object.h \
315 php_http_requestpool_object.h php_http_response_object.h php_http_util_object.h \
316 php_http_querystring_object.h php_http_deflatestream_object.h php_http_inflatestream_object.h \
317 php_http_cookie_api.h php_http_querystring_api.h"
318 ifdef([PHP_INSTALL_HEADERS], [
319 PHP_INSTALL_HEADERS(ext/http, $PHP_HTTP_HEADERS)
320 ], [
321 PHP_SUBST([PHP_HTTP_HEADERS])
322 PHP_ADD_MAKEFILE_FRAGMENT
323 ])
324
325 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])
326 fi