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