fix mime-type
[m6w6/ext-http] / config9.m4
1 dnl config.m4 for pecl/http
2 dnl $Id: config9.m4 242664 2007-09-18 19:13:37Z mike $
3 dnl vim: noet ts=1 sw=4
4
5 PHP_ARG_WITH([http], [whether to enable extended HTTP support],
6 [ --with-http Enable extended HTTP support])
7 PHP_ARG_WITH([http-zlib-dir], [],
8 [ --with-http-zlib-dir[=DIR] HTTP: where to find zlib], $PHP_HTTP, $PHP_HTTP)
9 PHP_ARG_WITH([http-libcurl-dir], [],
10 [ --with-http-libcurl-dir[=DIR] HTTP: where to find libcurl], $PHP_HTTP, $PHP_HTTP)
11 PHP_ARG_WITH([http-libevent-dir], [],
12 [ --with-http-libevent-dir[=DIR] HTTP: where to find libevent], $PHP_HTTP_LIBCURL_DIR, "")
13
14 if test "$PHP_HTTP" != "no"; then
15
16 ifdef([AC_PROG_EGREP], [
17 AC_PROG_EGREP
18 ], [
19 AC_CHECK_PROG(EGREP, egrep, egrep)
20 ])
21 ifdef([AC_PROG_SED], [
22 AC_PROG_SED
23 ], [
24 ifdef([LT_AC_PROG_SED], [
25 LT_AC_PROG_SED
26 ], [
27 AC_CHECK_PROG(SED, sed, sed)
28 ])
29 ])
30
31 AC_PROG_CPP
32
33 if test "$PHP_HTTP_SHARED_DEPS" != "no"; then
34 AC_DEFINE([PHP_HTTP_SHARED_DEPS], [1], [ ])
35 else
36 AC_DEFINE([PHP_HTTP_SHARED_DEPS], [0], [ ])
37 fi
38
39 dnl
40 dnl HTTP_SHARED_DEP(name[, code-if-yes[, code-if-not]])
41 dnl
42 AC_DEFUN([HTTP_SHARED_DEP], [
43 extname=$1
44 haveext=$[PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)
45
46 AC_MSG_CHECKING([whether to add a dependency on ext/$extname])
47 if test "$PHP_HTTP_SHARED_DEPS" = "no"; then
48 AC_MSG_RESULT([no])
49 $3
50 elif test "$haveext"; then
51 AC_MSG_RESULT([yes])
52 AC_DEFINE([PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__), [1], [ ])
53 ifdef([PHP_ADD_EXTENSION_DEP], [
54 PHP_ADD_EXTENSION_DEP([http], $1, true)
55 ])
56 $2
57 else
58 AC_MSG_RESULT([no])
59 $3
60 fi
61 ])
62
63 dnl
64 dnl HTTP_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]])
65 dnl
66 AC_DEFUN([HTTP_HAVE_PHP_EXT], [
67 extname=$1
68 haveext=$[PHP_]translit($1,a-z_-,A-Z__)
69
70 AC_MSG_CHECKING([for ext/$extname support])
71 if test -x "$PHP_EXECUTABLE"; then
72 grepext=`$PHP_EXECUTABLE -m | $EGREP ^$extname\$`
73 if test "$grepext" = "$extname"; then
74 [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
75 AC_MSG_RESULT([yes])
76 $2
77 else
78 [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
79 AC_MSG_RESULT([no])
80 $3
81 fi
82 elif test "$haveext" != "no" && test "x$haveext" != "x"; then
83 [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
84 AC_MSG_RESULT([yes])
85 $2
86 else
87 [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
88 AC_MSG_RESULT([no])
89 $3
90 fi
91 ])
92
93
94 dnl ----
95 dnl STDC
96 dnl ----
97 AC_CHECK_HEADERS([netdb.h unistd.h])
98 PHP_CHECK_FUNC(gethostname, nsl)
99 PHP_CHECK_FUNC(getdomainname, nsl)
100 PHP_CHECK_FUNC(getservbyport, nsl)
101 PHP_CHECK_FUNC(getservbyname, nsl)
102
103 dnl ----
104 dnl ZLIB
105 dnl ----
106 AC_MSG_CHECKING([for zlib.h])
107 ZLIB_DIR=
108 for i in "$PHP_HTTP_ZLIB_DIR" "$PHP_ZLIB_DIR" "$PHP_ZLIB" /usr/local /usr /opt; do
109 if test -f "$i/include/zlib.h"; then
110 ZLIB_DIR=$i
111 break;
112 fi
113 done
114 if test "x$ZLIB_DIR" = "x"; then
115 AC_MSG_RESULT([not found])
116 AC_MSG_ERROR([could not find zlib.h])
117 else
118 AC_MSG_RESULT([found in $ZLIB_DIR])
119 AC_MSG_CHECKING([for zlib version >= 1.2.0.4])
120 ZLIB_VERSION=`$EGREP "define ZLIB_VERSION" $ZLIB_DIR/include/zlib.h | $SED -e 's/[[^0-9\.]]//g'`
121 AC_MSG_RESULT([$ZLIB_VERSION])
122 if test `echo $ZLIB_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*1000000 + $2*10000 + $3*100 + $4}'` -lt 1020004; then
123 AC_MSG_ERROR([zlib version greater or equal to 1.2.0.4 required])
124 else
125 PHP_ADD_INCLUDE($ZLIB_DIR/include)
126 PHP_ADD_LIBRARY_WITH_PATH(z, $ZLIB_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
127 AC_DEFINE([PHP_HTTP_HAVE_ZLIB], [1], [Have zlib support])
128 fi
129 fi
130
131 dnl ----
132 dnl CURL
133 dnl ----
134 AC_MSG_CHECKING([for curl/curl.h])
135 CURL_DIR=
136 for i in "$PHP_HTTP_LIBCURL_DIR" /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 "x$CURL_DIR" = "x"; 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 "x$CURL_CONFIG" = "x"; 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.18.2
165 AC_MSG_CHECKING([for curl version >= 7.18.2])
166 CURL_VERSION=`$CURL_CONFIG --version | $SED -e 's/[[^0-9\.]]//g'`
167 AC_MSG_RESULT([$CURL_VERSION])
168 if test `echo $CURL_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*10000 + $2*100 + $3}'` -lt 71802; then
169 AC_MSG_ERROR([libcurl version greater or equal to 7.18.2 required])
170 fi
171
172 dnl
173 dnl compile tests
174 dnl
175
176 save_INCLUDES="$INCLUDES"
177 INCLUDES=
178 save_LIBS="$LIBS"
179 LIBS=
180 save_CFLAGS="$CFLAGS"
181 CFLAGS=`$CURL_CONFIG --cflags`
182 save_LDFLAGS="$LDFLAGS"
183 LDFLAGS=`$CURL_CONFIG --libs`
184 LDFLAGS="$LDFLAGS $ld_runpath_switch$CURL_DIR/$PHP_LIBDIR"
185
186 AC_MSG_CHECKING([for SSL support in libcurl])
187 CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
188 if test "$CURL_SSL" = "SSL"; then
189 AC_MSG_RESULT([yes])
190 AC_DEFINE([PHP_HTTP_HAVE_SSL], [1], [ ])
191
192 AC_MSG_CHECKING([for openssl support in libcurl])
193 AC_TRY_RUN([
194 #include <curl/curl.h>
195 int main(int argc, char *argv[]) {
196 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
197 if (data && data->ssl_version && *data->ssl_version) {
198 const char *ptr = data->ssl_version;
199 while(*ptr == ' ') ++ptr;
200 return strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1);
201 }
202 return 1;
203 }
204 ], [
205 AC_MSG_RESULT([yes])
206 AC_CHECK_HEADER([openssl/crypto.h], [
207 AC_DEFINE([PHP_HTTP_HAVE_OPENSSL], [1], [ ])
208 ])
209 ], [
210 AC_MSG_RESULT([no])
211 ], [
212 AC_MSG_RESULT([no])
213 ])
214
215 AC_MSG_CHECKING([for gnutls support in libcurl])
216 AC_TRY_RUN([
217 #include <curl/curl.h>
218 int main(int argc, char *argv[]) {
219 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
220 if (data && data->ssl_version && *data->ssl_version) {
221 const char *ptr = data->ssl_version;
222 while(*ptr == ' ') ++ptr;
223 return strncasecmp(ptr, "GnuTLS", sizeof("GnuTLS")-1);
224 }
225 return 1;
226 }
227 ], [
228 AC_MSG_RESULT([yes])
229 AC_CHECK_HEADER([gcrypt.h], [
230 AC_DEFINE([PHP_HTTP_HAVE_GNUTLS], [1], [ ])
231 ])
232 ], [
233 AC_MSG_RESULT([no])
234 ], [
235 AC_MSG_RESULT([no])
236 ])
237 else
238 AC_MSG_RESULT([no])
239 fi
240
241 INCLUDES="$save_INCLUDES"
242 LIBS="$save_LIBS"
243 CFLAGS="$save_CFLAGS"
244 LDFLAGS="$save_LDFLAGS"
245
246 dnl end compile tests
247
248 AC_MSG_CHECKING([for bundled SSL CA info])
249 CURL_CAINFO=
250 for i in `$CURL_CONFIG --ca` "/etc/ssl/certs/ca-certificates.crt"; do
251 if test -f "$i"; then
252 CURL_CAINFO="$i"
253 break
254 fi
255 done
256 if test "x$CURL_CAINFO" = "x"; then
257 AC_MSG_RESULT([not found])
258 else
259 AC_MSG_RESULT([$CURL_CAINFO])
260 AC_DEFINE_UNQUOTED([PHP_HTTP_CURL_CAINFO], ["$CURL_CAINFO"], [path to bundled SSL CA info])
261 fi
262
263 PHP_ADD_INCLUDE($CURL_DIR/include)
264 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
265 PHP_EVAL_LIBLINE(`$CURL_CONFIG --libs`, HTTP_SHARED_LIBADD)
266 AC_DEFINE([PHP_HTTP_HAVE_CURL], [1], [Have cURL support])
267
268 dnl ----
269 dnl EVENT
270 dnl ----
271
272 if test "$PHP_HTTP_LIBEVENT_DIR" != "no"; then
273 HTTP_HAVE_PHP_EXT([event], [
274 AC_MSG_WARN([event support is incompatible with pecl/event; continuing without libevent support])
275 ], [
276 AC_MSG_CHECKING([for event.h])
277 EVENT_DIR=
278 for i in "$PHP_HTTP_LIBEVENT_DIR" /usr/local /usr /opt; do
279 if test -f "$i/include/event.h"; then
280 EVENT_DIR=$i
281 break
282 fi
283 done
284 if test "x$EVENT_DIR" = "x"; then
285 AC_MSG_RESULT([not found])
286 AC_MSG_WARN([continuing without libevent support])
287 else
288 AC_MSG_RESULT([found in $EVENT_DIR])
289
290 AC_MSG_CHECKING([for libevent version, roughly])
291 EVENT_VER="1.1b or lower"
292 if test -f "$EVENT_DIR/include/evhttp.h" && test -f "$EVENT_DIR/include/evdns.h"; then
293 if test -f "$EVENT_DIR/include/evrpc.h"; then
294 EVENT_VER="1.4 or greater"
295 else
296 EVENT_VER="1.2 or greater"
297 fi
298 fi
299 AC_DEFINE_UNQUOTED([PHP_HTTP_EVENT_VERSION], ["$EVENT_VER"], [ ])
300 AC_MSG_RESULT([$EVENT_VER])
301
302 PHP_ADD_INCLUDE($EVENT_DIR/include)
303 PHP_ADD_LIBRARY_WITH_PATH(event, $EVENT_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
304 AC_DEFINE([PHP_HTTP_HAVE_EVENT], [1], [Have libevent support for cURL])
305 fi
306 ])
307 fi
308
309 PHP_ARG_WITH([http-shared-deps], [whether to depend on extensions which have been built shared],
310 [ --without-http-shared-deps HTTP: do not depend on extensions like hash
311 and iconv (when they're built shared)], $PHP_HTTP, $PHP_HTTP)
312 dnl ----
313 dnl HASH
314 dnl ----
315 HTTP_HAVE_PHP_EXT([hash], [
316 AC_MSG_CHECKING([for php_hash.h])
317 HTTP_EXT_HASH_INCDIR=
318 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../hash; do
319 if test -d $i; then
320 if test -f $i/php_hash.h; then
321 HTTP_EXT_HASH_INCDIR=$i
322 break
323 elif test -f $i/ext/hash/php_hash.h; then
324 HTTP_EXT_HASH_INCDIR=$i/ext/hash
325 break
326 fi
327 fi
328 done
329 if test "x$HTTP_EXT_HASH_INCDIR" = "x"; then
330 AC_MSG_RESULT([not found])
331 else
332 AC_MSG_RESULT([$HTTP_EXT_HASH_INCDIR])
333 AC_DEFINE([PHP_HTTP_HAVE_PHP_HASH_H], [1], [Have ext/hash support])
334 PHP_ADD_INCLUDE([$HTTP_EXT_HASH_INCDIR])
335 fi
336 ])
337
338 dnl ----
339 dnl ICONV
340 dnl ----
341 HTTP_HAVE_PHP_EXT([iconv])
342
343 dnl ----
344 dnl DONE
345 dnl ----
346 PHP_HTTP_SOURCES="\
347 php_http.c \
348 php_http_buffer.c \
349 php_http_cookie.c \
350 php_http_encoding.c \
351 php_http_env.c \
352 php_http_etag.c \
353 php_http_exception.c \
354 php_http_filter.c \
355 php_http_headers.c \
356 php_http_header_parser.c \
357 php_http_info.c \
358 php_http_message_body.c \
359 php_http_message.c \
360 php_http_message_parser.c \
361 php_http_misc.c \
362 php_http_negotiate.c \
363 php_http_object.c \
364 php_http_params.c \
365 php_http_persistent_handle.c \
366 php_http_property_proxy.c \
367 php_http_querystring.c \
368 php_http_request.c \
369 php_http_request_datashare.c \
370 php_http_request_info.c \
371 php_http_request_method.c \
372 php_http_request_pool.c \
373 php_http_strlist.c \
374 php_http_url.c \
375 php_http_version.c \
376 "
377 PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, $ext_shared)
378
379 dnl shared extension deps
380 HTTP_SHARED_DEP([hash])
381 HTTP_SHARED_DEP([iconv])
382
383 PHP_SUBST([HTTP_SHARED_LIBADD])
384
385 PHP_HTTP_HEADERS="
386 php_http.h \
387 php_http_buffer.h \
388 php_http_cookie.h \
389 php_http_encoding.h \
390 php_http_env.h \
391 php_http_etag.h \
392 php_http_exception.h \
393 php_http_filter.h \
394 php_http_headers.h \
395 php_http_header_parser.h \
396 php_http_info.h \
397 php_http_message_body.h \
398 php_http_message.h \
399 php_http_message_parser.h \
400 php_http_misc.h \
401 php_http_negotiate.h \
402 php_http_object.h \
403 php_http_params.h \
404 php_http_persistent_handle.h \
405 php_http_property_proxy.h \
406 php_http_querystring.h \
407 php_http_request_datashare.h \
408 php_http_request.h \
409 php_http_request_method.h \
410 php_http_request_pool.h \
411 php_http_strlist.h \
412 php_http_url.h \
413 php_http_version.h \
414 "
415 ifdef([PHP_INSTALL_HEADERS], [
416 PHP_INSTALL_HEADERS(ext/http, $PHP_HTTP_HEADERS)
417 ], [
418 PHP_SUBST([PHP_HTTP_HEADERS])
419 PHP_ADD_MAKEFILE_FRAGMENT
420 ])
421
422 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])
423 fi