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