use the new params parser
[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=4 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-libneon-dir], [],
12 [ --with-http-libneon-dir[=DIR] HTTP: where to find libneon], $PHP_HTTP, $PHP_HTTP)
13 PHP_ARG_WITH([http-libserf-dir], [],
14 [ --with-http-libserf-dir[=DIR] HTTP: where to find libserf], $PHP_HTTP, $PHP_HTTP)
15 PHP_ARG_WITH([http-libevent-dir], [],
16 [ --with-http-libevent-dir[=DIR] HTTP: where to find libevent], $PHP_HTTP_LIBCURL_DIR, "")
17
18 if test "$PHP_HTTP" != "no"; then
19
20 HTTP_HAVE_A_REQUEST_LIB=false
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 AC_PROG_CPP
38
39 if test "$PHP_HTTP_SHARED_DEPS" != "no"; then
40 AC_DEFINE([PHP_HTTP_SHARED_DEPS], [1], [ ])
41 else
42 AC_DEFINE([PHP_HTTP_SHARED_DEPS], [0], [ ])
43 fi
44
45 dnl
46 dnl HTTP_SHARED_DEP(name[, code-if-yes[, code-if-not]])
47 dnl
48 AC_DEFUN([HTTP_SHARED_DEP], [
49 extname=$1
50 haveext=$[PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)
51
52 AC_MSG_CHECKING([whether to add a dependency on ext/$extname])
53 if test "$PHP_HTTP_SHARED_DEPS" = "no"; then
54 AC_MSG_RESULT([no])
55 $3
56 elif test "$haveext"; then
57 AC_MSG_RESULT([yes])
58 AC_DEFINE([PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__), [1], [ ])
59 ifdef([PHP_ADD_EXTENSION_DEP], [
60 PHP_ADD_EXTENSION_DEP([http], $1, true)
61 ])
62 $2
63 else
64 AC_MSG_RESULT([no])
65 $3
66 fi
67 ])
68
69 dnl
70 dnl HTTP_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]])
71 dnl
72 AC_DEFUN([HTTP_HAVE_PHP_EXT], [
73 extname=$1
74 haveext=$[PHP_]translit($1,a-z_-,A-Z__)
75
76 AC_MSG_CHECKING([for ext/$extname support])
77 if test -x "$PHP_EXECUTABLE"; then
78 grepext=`$PHP_EXECUTABLE -m | $EGREP ^$extname\$`
79 if test "$grepext" = "$extname"; then
80 [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
81 AC_MSG_RESULT([yes])
82 $2
83 else
84 [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
85 AC_MSG_RESULT([no])
86 $3
87 fi
88 elif test "$haveext" != "no" && test "x$haveext" != "x"; then
89 [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
90 AC_MSG_RESULT([yes])
91 $2
92 else
93 [PHP_HTTP_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
94 AC_MSG_RESULT([no])
95 $3
96 fi
97 ])
98
99
100 dnl ----
101 dnl STDC
102 dnl ----
103 AC_CHECK_HEADERS([netdb.h unistd.h])
104 PHP_CHECK_FUNC(gethostname, nsl)
105 PHP_CHECK_FUNC(getdomainname, nsl)
106 PHP_CHECK_FUNC(getservbyport, nsl)
107 PHP_CHECK_FUNC(getservbyname, nsl)
108
109 dnl ----
110 dnl ZLIB
111 dnl ----
112 AC_MSG_CHECKING([for zlib.h])
113 ZLIB_DIR=
114 for i in "$PHP_HTTP_ZLIB_DIR" "$PHP_ZLIB_DIR" "$PHP_ZLIB" /usr/local /usr /opt; do
115 if test -f "$i/include/zlib.h"; then
116 ZLIB_DIR=$i
117 break;
118 fi
119 done
120 if test "x$ZLIB_DIR" = "x"; then
121 AC_MSG_RESULT([not found])
122 AC_MSG_ERROR([could not find zlib.h])
123 else
124 AC_MSG_RESULT([found in $ZLIB_DIR])
125 AC_MSG_CHECKING([for zlib version >= 1.2.0.4])
126 ZLIB_VERSION=`$EGREP "define ZLIB_VERSION" $ZLIB_DIR/include/zlib.h | $SED -e 's/[[^0-9\.]]//g'`
127 AC_MSG_RESULT([$ZLIB_VERSION])
128 if test `echo $ZLIB_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*1000000 + $2*10000 + $3*100 + $4}'` -lt 1020004; then
129 AC_MSG_ERROR([zlib version greater or equal to 1.2.0.4 required])
130 else
131 PHP_ADD_INCLUDE($ZLIB_DIR/include)
132 PHP_ADD_LIBRARY_WITH_PATH(z, $ZLIB_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
133 fi
134 fi
135
136 dnl ----
137 dnl NEON
138 dnl ----
139
140 if test "$PHP_HTTP_LIBNEON_DIR" = "no"; then
141 AC_DEFINE([PHP_HTTP_HAVE_NEON], [0], [ ])
142 else
143 AC_MSG_CHECKING([for neon/ne_session.h])
144 NEON_DIR=
145 for i in "$PHP_HTTP_LIBNEON_DIR" /usr/local /usr /opt; do
146 if test -f "$i/include/neon/ne_session.h"; then
147 NEON_DIR=$i
148 break
149 fi
150 done
151
152 if test "x$NEON_DIR" = "x"; then
153 AC_MSG_RESULT([not found])
154 AC_DEFINE([PHP_HTTP_HAVE_NEON], [0], [ ])
155 else
156 AC_MSG_RESULT([found in $NEON_DIR])
157
158 AC_MSG_CHECKING([for neon-config])
159 NEON_CONFIG=
160 for i in "$NEON_DIR/bin/neon-config" "$NEON_DIR/neon-config" `which neon-config`; do
161 if test -x "$i"; then
162 NEON_CONFIG=$i
163 break
164 fi
165 done
166 if test "x$NEON_CONFIG" = "x"; then
167 AC_MSG_RESULT([not found])
168 AC_DEFINE([PHP_HTTP_HAVE_NEON], [0], [ ])
169 else
170 AC_MSG_RESULT([found: $NEON_CONFIG])
171
172 AC_MSG_CHECKING([for libneon version])
173 PHP_HTTP_NEON_VERSION=`$NEON_CONFIG --version | $SED -re 's/^neon ([[^ :]]+).*/\1/g'`
174 if test "x$PHP_HTTP_NEON_VERSION" = "x"; then
175 AC_MSG_RESULT([unknown])
176 PHP_HTTP_NEON_VERSION="unknown"
177 else
178 AC_MSG_RESULT([$PHP_HTTP_NEON_VERSION])
179 fi
180 AC_DEFINE_UNQUOTED([PHP_HTTP_NEON_VERSION], ["$PHP_HTTP_NEON_VERSION"], [neon-config --version])
181 PHP_ADD_INCLUDE($NEON_DIR/include)
182 PHP_ADD_LIBRARY_WITH_PATH(neon, $NEON_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
183 AC_DEFINE([PHP_HTTP_HAVE_NEON], [1], [Have libneon support])
184 HTTP_HAVE_A_REQUEST_LIB=true
185 fi
186 fi
187 fi
188
189 dnl ----
190 dnl SERF
191 dnl ----
192
193 if test "$PHP_HTTP_LIBSERF_DIR" = "no"; then
194 AC_DEFINE([PHP_HTTP_HAVE_SERF], [0], [ ])
195 else
196 AC_MSG_CHECKING([for serf-?/serf.h])
197 SERF_DIR=
198 for i in "$PHP_HTTP_LIBSERF_DIR" /usr/local /usr /opt; do
199 if test -f "$i/include/serf-0/serf.h"; then
200 SERF_DIR=$i
201 SERF_VER=0
202 break
203 elif test -f "$i/include/serf-1/serf.h"; then
204 SERF_DIR=$i
205 SERF_VER=1
206 fi
207 done
208
209 if test "x$SERF_DIR" = "x"; then
210 AC_MSG_RESULT([not found])
211 AC_DEFINE([PHP_HTTP_HAVE_SERF], [0], [ ])
212 else
213 AC_MSG_RESULT([found in $SERF_DIR])
214
215 PHP_ADD_INCLUDE($SERF_DIR/include/serf-$SERF_VER)
216 PHP_ADD_LIBRARY_WITH_PATH(serf-$SERF_VER, $SERF_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
217 AC_DEFINE([PHP_HTTP_HAVE_SERF], [1], [Have libserf support])
218 HTTP_HAVE_A_REQUEST_LIB=true
219 fi
220 fi
221
222 dnl ----
223 dnl CURL
224 dnl ----
225
226 if test "$PHP_HTTP_LIBCURL_DIR" = "no"; then
227 AC_DEFINE([PHP_HTTP_HAVE_CURL], [0], [ ])
228 else
229 AC_MSG_CHECKING([for curl/curl.h])
230 CURL_DIR=
231 for i in "$PHP_HTTP_LIBCURL_DIR" /usr/local /usr /opt; do
232 if test -f "$i/include/curl/curl.h"; then
233 CURL_DIR=$i
234 break
235 fi
236 done
237 if test "x$CURL_DIR" = "x"; then
238 AC_MSG_RESULT([not found])
239 else
240 AC_MSG_RESULT([found in $CURL_DIR])
241
242 AC_MSG_CHECKING([for curl-config])
243 CURL_CONFIG=
244 for i in "$CURL_DIR/bin/curl-config" "$CURL_DIR/curl-config" `which curl-config`; do
245 if test -x "$i"; then
246 CURL_CONFIG=$i
247 break
248 fi
249 done
250 if test "x$CURL_CONFIG" = "x"; then
251 AC_MSG_RESULT([not found])
252 AC_MSG_ERROR([could not find curl-config])
253 else
254 AC_MSG_RESULT([found: $CURL_CONFIG])
255 fi
256
257 dnl Debian stable has currently 7.18.2
258 AC_MSG_CHECKING([for curl version >= 7.18.2])
259 CURL_VERSION=`$CURL_CONFIG --version | $SED -e 's/[[^0-9\.]]//g'`
260 AC_MSG_RESULT([$CURL_VERSION])
261 if test `echo $CURL_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*10000 + $2*100 + $3}'` -lt 71802; then
262 AC_MSG_ERROR([libcurl version greater or equal to 7.18.2 required])
263 fi
264
265 dnl
266 dnl compile tests
267 dnl
268
269 save_INCLUDES="$INCLUDES"
270 INCLUDES=
271 save_LIBS="$LIBS"
272 LIBS=
273 save_CFLAGS="$CFLAGS"
274 CFLAGS=`$CURL_CONFIG --cflags`
275 save_LDFLAGS="$LDFLAGS"
276 LDFLAGS=`$CURL_CONFIG --libs`
277 LDFLAGS="$LDFLAGS $ld_runpath_switch$CURL_DIR/$PHP_LIBDIR"
278
279 AC_MSG_CHECKING([for SSL support in libcurl])
280 CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
281 if test "$CURL_SSL" = "SSL"; then
282 AC_MSG_RESULT([yes])
283 AC_DEFINE([PHP_HTTP_HAVE_SSL], [1], [ ])
284
285 AC_MSG_CHECKING([for openssl support in libcurl])
286 AC_TRY_RUN([
287 #include <curl/curl.h>
288 int main(int argc, char *argv[]) {
289 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
290 if (data && data->ssl_version && *data->ssl_version) {
291 const char *ptr = data->ssl_version;
292 while(*ptr == ' ') ++ptr;
293 return strncasecmp(ptr, "OpenSSL", sizeof("OpenSSL")-1);
294 }
295 return 1;
296 }
297 ], [
298 AC_MSG_RESULT([yes])
299 AC_CHECK_HEADER([openssl/crypto.h], [
300 AC_DEFINE([PHP_HTTP_HAVE_OPENSSL], [1], [ ])
301 ])
302 ], [
303 AC_MSG_RESULT([no])
304 ], [
305 AC_MSG_RESULT([no])
306 ])
307
308 AC_MSG_CHECKING([for gnutls support in libcurl])
309 AC_TRY_RUN([
310 #include <curl/curl.h>
311 int main(int argc, char *argv[]) {
312 curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
313 if (data && data->ssl_version && *data->ssl_version) {
314 const char *ptr = data->ssl_version;
315 while(*ptr == ' ') ++ptr;
316 return strncasecmp(ptr, "GnuTLS", sizeof("GnuTLS")-1);
317 }
318 return 1;
319 }
320 ], [
321 AC_MSG_RESULT([yes])
322 AC_CHECK_HEADER([gcrypt.h], [
323 AC_DEFINE([PHP_HTTP_HAVE_GNUTLS], [1], [ ])
324 ])
325 ], [
326 AC_MSG_RESULT([no])
327 ], [
328 AC_MSG_RESULT([no])
329 ])
330 else
331 AC_MSG_RESULT([no])
332 fi
333
334 INCLUDES="$save_INCLUDES"
335 LIBS="$save_LIBS"
336 CFLAGS="$save_CFLAGS"
337 LDFLAGS="$save_LDFLAGS"
338
339 dnl end compile tests
340
341 AC_MSG_CHECKING([for bundled SSL CA info])
342 CURL_CAINFO=
343 for i in `$CURL_CONFIG --ca` "/etc/ssl/certs/ca-certificates.crt"; do
344 if test -f "$i"; then
345 CURL_CAINFO="$i"
346 break
347 fi
348 done
349 if test "x$CURL_CAINFO" = "x"; then
350 AC_MSG_RESULT([not found])
351 else
352 AC_MSG_RESULT([$CURL_CAINFO])
353 AC_DEFINE_UNQUOTED([PHP_HTTP_CURL_CAINFO], ["$CURL_CAINFO"], [path to bundled SSL CA info])
354 fi
355
356 PHP_ADD_INCLUDE($CURL_DIR/include)
357 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
358 PHP_EVAL_LIBLINE(`$CURL_CONFIG --libs`, HTTP_SHARED_LIBADD)
359 AC_DEFINE([PHP_HTTP_HAVE_CURL], [1], [Have libcurl support])
360 HTTP_HAVE_A_REQUEST_LIB=true
361 fi
362 fi
363
364 dnl ----
365 dnl EVENT
366 dnl ----
367
368 if test "$PHP_HTTP_LIBEVENT_DIR" = "no"; then
369 AC_DEFINE([PHP_HTTP_HAVE_EVENT], [0], [ ])
370 else
371 HTTP_HAVE_PHP_EXT([event], [
372 AC_MSG_WARN([event support is incompatible with pecl/event; continuing without libevent support])
373 AC_DEFINE([PHP_HTTP_HAVE_EVENT], [0], [ ])
374 ], [
375 AC_MSG_CHECKING([for event.h])
376 EVENT_DIR=
377 for i in "$PHP_HTTP_LIBEVENT_DIR" /usr/local /usr /opt; do
378 if test -f "$i/include/event.h"; then
379 EVENT_DIR=$i
380 break
381 fi
382 done
383 if test "x$EVENT_DIR" = "x"; then
384 AC_MSG_RESULT([not found])
385 AC_MSG_WARN([continuing without libevent support])
386 AC_DEFINE([PHP_HTTP_HAVE_EVENT], [0], [ ])
387 else
388 AC_MSG_RESULT([found in $EVENT_DIR])
389
390 AC_MSG_CHECKING([for libevent version, roughly])
391 EVENT_VER="1.1b or lower"
392 if test -f "$EVENT_DIR/include/evhttp.h" && test -f "$EVENT_DIR/include/evdns.h"; then
393 if test -f "$EVENT_DIR/include/evrpc.h"; then
394 EVENT_VER="1.4 or greater"
395 else
396 EVENT_VER="1.2 or greater"
397 fi
398 fi
399 AC_DEFINE_UNQUOTED([PHP_HTTP_EVENT_VERSION], ["$EVENT_VER"], [ ])
400 AC_MSG_RESULT([$EVENT_VER])
401
402 PHP_ADD_INCLUDE($EVENT_DIR/include)
403 PHP_ADD_LIBRARY_WITH_PATH(event, $EVENT_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
404 AC_DEFINE([PHP_HTTP_HAVE_EVENT], [1], [Have libevent support for cURL])
405 fi
406 ])
407 fi
408
409 PHP_ARG_WITH([http-shared-deps], [whether to depend on extensions which have been built shared],
410 [ --without-http-shared-deps HTTP: do not depend on extensions like hash
411 and iconv (when they're built shared)], $PHP_HTTP, $PHP_HTTP)
412 dnl ----
413 dnl HASH
414 dnl ----
415 HTTP_HAVE_PHP_EXT([hash], [
416 AC_MSG_CHECKING([for php_hash.h])
417 HTTP_EXT_HASH_INCDIR=
418 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../hash; do
419 if test -d $i; then
420 if test -f $i/php_hash.h; then
421 HTTP_EXT_HASH_INCDIR=$i
422 break
423 elif test -f $i/ext/hash/php_hash.h; then
424 HTTP_EXT_HASH_INCDIR=$i/ext/hash
425 break
426 fi
427 fi
428 done
429 if test "x$HTTP_EXT_HASH_INCDIR" = "x"; then
430 AC_MSG_RESULT([not found])
431 else
432 AC_MSG_RESULT([$HTTP_EXT_HASH_INCDIR])
433 AC_DEFINE([PHP_HTTP_HAVE_PHP_HASH_H], [1], [Have ext/hash support])
434 PHP_ADD_INCLUDE([$HTTP_EXT_HASH_INCDIR])
435 fi
436 ])
437
438 dnl ----
439 dnl ICONV
440 dnl ----
441 HTTP_HAVE_PHP_EXT([iconv])
442
443 dnl ----
444 dnl DONE
445 dnl ----
446 PHP_HTTP_SOURCES="\
447 php_http.c \
448 php_http_buffer.c \
449 php_http_cookie.c \
450 php_http_encoding.c \
451 php_http_env.c \
452 php_http_env_response.c \
453 php_http_etag.c \
454 php_http_exception.c \
455 php_http_filter.c \
456 php_http_headers.c \
457 php_http_header_parser.c \
458 php_http_info.c \
459 php_http_message_body.c \
460 php_http_message.c \
461 php_http_message_parser.c \
462 php_http_misc.c \
463 php_http_negotiate.c \
464 php_http_object.c \
465 php_http_params.c \
466 php_http_resource_factory.c \
467 php_http_persistent_handle.c \
468 php_http_property_proxy.c \
469 php_http_querystring.c \
470 php_http_request.c \
471 php_http_request_factory.c \
472 php_http_curl.c \
473 php_http_neon.c \
474 php_http_request_pool.c \
475 php_http_request_datashare.c \
476 php_http_request_method.c \
477 php_http_strlist.c \
478 php_http_url.c \
479 php_http_version.c \
480 "
481 PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, $ext_shared)
482
483 dnl shared extension deps
484 HTTP_SHARED_DEP([hash])
485 HTTP_SHARED_DEP([iconv])
486
487 PHP_SUBST([HTTP_SHARED_LIBADD])
488
489 PHP_HTTP_HEADERS="
490 php_http.h \
491 php_http_buffer.h \
492 php_http_cookie.h \
493 php_http_encoding.h \
494 php_http_env.h \
495 php_http_env_response.h \
496 php_http_etag.h \
497 php_http_exception.h \
498 php_http_filter.h \
499 php_http_headers.h \
500 php_http_header_parser.h \
501 php_http_info.h \
502 php_http_message_body.h \
503 php_http_message.h \
504 php_http_message_parser.h \
505 php_http_misc.h \
506 php_http_negotiate.h \
507 php_http_object.h \
508 php_http_params.h \
509 php_http_resource_factory.h \
510 php_http_persistent_handle.h \
511 php_http_property_proxy.h \
512 php_http_querystring.h \
513 php_http_request_datashare.h \
514 php_http_request.h \
515 php_http_request_factory.h \
516 php_http_curl.h \
517 php_http_neon.h \
518 php_http_request_method.h \
519 php_http_request_pool.h \
520 php_http_strlist.h \
521 php_http_url.h \
522 php_http_version.h \
523 "
524 PHP_INSTALL_HEADERS(ext/http, $PHP_HTTP_HEADERS)
525
526 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])
527 fi