- fix shared build witin the php src tree
[m6w6/ext-http] / config.m4
1 dnl config.m4 for pecl/http
2 dnl $Id$
3
4 PHP_ARG_ENABLE([http], [whether to enable extended HTTP support],
5 [ --enable-http Enable extended HTTP support])
6 PHP_ARG_WITH([http-curl-requests], [whether to enable cURL HTTP requests],
7 [ --with-http-curl-requests[=CURLDIR]
8 With cURL HTTP request support])
9 PHP_ARG_WITH([http-mhash-etags], [whether to enable mhash ETag generator],
10 [ --with-http-mhash-etags[=MHASHDIR]
11 With mhash ETag generator support])
12 PHP_ARG_WITH([http-magic-mime], [whether to enable response content type guessing],
13 [ --with-http-magic-mime[=MAGICDIR]
14 With magic mime response content type guessing])
15 PHP_ARG_WITH([http-zlib-compression], [whether to enable support for gzencoded/deflated message bodies],
16 [ --with-http-zlib-compression[=ZLIBDIR]
17 With zlib gzdecode and inflate support])
18
19 if test "$PHP_HTTP" != "no"; then
20
21 dnl -------
22 dnl NETDB.H
23 dnl -------
24 AC_CHECK_HEADERS([netdb.h])
25
26 dnl ----
27 dnl ZLIB
28 dnl ----
29 AC_MSG_CHECKING([for zlib.h])
30 ZLIB_DIR=
31 for i in "$PHP_HTTP_ZLIB_COMPRESSION" "$PHP_ZLIB_DIR" "$PHP_ZLIB" /user/local /usr /opt; do
32 if test -f "$i/include/zlib.h"; then
33 ZLIB_DIR=$i
34 break;
35 fi
36 done
37 if test -z "$ZLIB_DIR"; then
38 AC_MSG_RESULT([not found])
39 AC_MSG_WARN([gzip support not enabled; zlib.h not found])
40 else
41 AC_MSG_RESULT([found in $ZLIB_DIR])
42 PHP_ADD_INCLUDE($ZLIB_DIR/include)
43 PHP_ADD_LIBRARY_WITH_PATH(z, $ZLIB_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
44 AC_DEFINE([HTTP_HAVE_ZLIB], [1], [Have zlib support])
45 fi
46
47 dnl ----
48 dnl CURL
49 dnl ----
50 if test "$PHP_HTTP_CURL_REQUESTS" != "no"; then
51
52 AC_MSG_CHECKING([for curl/curl.h])
53 CURL_DIR=
54 for i in "$PHP_HTTP_CURL_REQUESTS" /usr/local /usr /opt; do
55 if test -f "$i/include/curl/curl.h"; then
56 CURL_DIR=$i
57 break
58 fi
59 done
60 if test -z "$CURL_DIR"; then
61 AC_MSG_RESULT([not found])
62 AC_MSG_ERROR([could not find curl/curl.h])
63 else
64 AC_MSG_RESULT([found in $CURL_DIR])
65 fi
66
67 AC_MSG_CHECKING([for curl-config])
68 CURL_CONFIG=
69 for i in "$CURL_DIR/bin/curl-config" "$CURL_DIR/curl-config" `which curl-config`; do
70 if test -x "$i"; then
71 CURL_CONFIG=$i
72 break
73 fi
74 done
75 if test -z "$CURL_CONFIG"; then
76 AC_MSG_RESULT([not found])
77 AC_MSG_ERROR([could not find curl-config])
78 else
79 AC_MSG_RESULT([found: $CURL_CONFIG])
80 fi
81
82 CURL_LIBS=`$CURL_CONFIG --libs`
83
84 AC_MSG_CHECKING([for SSL support in libcurl])
85 CURL_SSL=`$CURL_CONFIG --features | $EGREP SSL`
86 if test "$CURL_SSL" == "SSL"; then
87 AC_MSG_RESULT([yes])
88 AC_DEFINE([HTTP_HAVE_SSL], [1], [ ])
89
90 AC_MSG_CHECKING([for SSL library used])
91 CURL_SSL_FLAVOUR=
92 for i in $CURL_LIBS; do
93 if test "$i" == "-lssl"; then
94 CURL_SSL_FLAVOUR="openssl"
95 AC_MSG_RESULT([openssl])
96 AC_DEFINE([HTTP_HAVE_OPENSSL], [1], [ ])
97 AC_CHECK_HEADERS([openssl/crypto.h])
98 break
99 elif test "$i" == "-lgnutls"; then
100 CURL_SSL_FLAVOUR="gnutls"
101 AC_MSG_RESULT([gnutls])
102 AC_DEFINE([HTTP_HAVE_GNUTLS], [1], [ ])
103 AC_CHECK_HEADERS([gcrypt.h])
104 break
105 fi
106 done
107 if test -z "$CURL_SSL_FLAVOUR"; then
108 AC_MSG_RESULT([unknown!])
109 AC_MSG_WARN([Could not determine the type of SSL library used!])
110 AC_MSG_WARN([Building will fail in ZTS mode!])
111 fi
112 else
113 AC_MSG_RESULT([no])
114 fi
115
116 PHP_ADD_INCLUDE($CURL_DIR/include)
117 PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
118 PHP_EVAL_LIBLINE($CURL_LIBS, HTTP_SHARED_LIBADD)
119 AC_DEFINE([HTTP_HAVE_CURL], [1], [Have cURL support])
120
121 PHP_CHECK_LIBRARY(curl, curl_multi_strerror,
122 [AC_DEFINE([HAVE_CURL_MULTI_STRERROR], [1], [ ])], [ ],
123 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
124 )
125 PHP_CHECK_LIBRARY(curl, curl_easy_strerror,
126 [AC_DEFINE([HAVE_CURL_EASY_STRERROR], [1], [ ])], [ ],
127 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
128 )
129 PHP_CHECK_LIBRARY(curl, curl_easy_reset,
130 [AC_DEFINE([HAVE_CURL_EASY_RESET], [1], [ ])], [ ],
131 [$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR]
132 )
133 fi
134
135 dnl ----
136 dnl MHASH
137 dnl ----
138 if test "$PHP_HTTP_MHASH_ETAGS" != "no"; then
139
140 AC_MSG_CHECKING([for mhash.h])
141 MHASH_DIR=
142 for i in "$PHP_HTTP_MHASH_ETAGS" /usr/local /usr /opt; do
143 if test -f "$i/include/mhash.h"; then
144 MHASH_DIR=$i
145 break
146 fi
147 done
148 if test -z "$MHASH_DIR"; then
149 AC_MSG_RESULT([not found])
150 AC_MSG_ERROR([could not find mhash.h])
151 else
152 AC_MSG_RESULT([found in $MHASH_DIR])
153 fi
154
155 PHP_ADD_INCLUDE($MHASH_DIR/include)
156 PHP_ADD_LIBRARY_WITH_PATH(mhash, $MHASH_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
157 AC_DEFINE([HTTP_HAVE_MHASH], [1], [Have mhash support])
158 fi
159
160 dnl ----
161 dnl MAGIC
162 dnl ----
163 if test "$PHP_HTTP_MAGIC_MIME" != "no"; then
164
165 AC_MSG_CHECKING([for magic.h])
166 MAGIC_DIR=
167 for i in "$PHP_HTTP_MAGIC_MIME" /usr/local /usr /opt; do
168 if test -f "$i/include/magic.h"; then
169 MAGIC_DIR=$i
170 break
171 fi
172 done
173 if test -z "$MAGIC_DIR"; then
174 AC_MSG_RESULT([not found])
175 AC_MSG_ERROR([could not find magic.h])
176 else
177 AC_MSG_RESULT([found in $MAGIC_DIR])
178 fi
179
180 PHP_ADD_INCLUDE($MAGIC_DIR/include)
181 PHP_ADD_LIBRARY_WITH_PATH(magic, $MAGIC_DIR/$PHP_LIBDIR, HTTP_SHARED_LIBADD)
182 AC_DEFINE([HTTP_HAVE_MAGIC], [1], [Have magic mime support])
183 fi
184
185 dnl ----
186 dnl DONE
187 dnl ----
188 PHP_HTTP_SOURCES="missing.c http.c http_functions.c phpstr/phpstr.c \
189 http_util_object.c http_message_object.c http_request_object.c http_request_pool_api.c \
190 http_response_object.c http_exception_object.c http_requestpool_object.c \
191 http_api.c http_cache_api.c http_request_api.c http_date_api.c \
192 http_headers_api.c http_message_api.c http_send_api.c http_url_api.c \
193 http_info_api.c http_request_method_api.c http_encoding_api.c"
194 PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, $ext_shared)
195 PHP_ADD_BUILD_DIR($ext_builddir/phpstr, 1)
196 PHP_SUBST([HTTP_SHARED_LIBADD])
197
198 HTTP_HEADER_FILES="php_http_std_defs.h php_http.h php_http_api.h php_http_cache_api.h \
199 php_http_date_api.h php_http_headers_api.h php_http_info_api.h php_http_message_api.h \
200 php_http_request_api.h php_http_request_method_api.h php_http_send_api.h php_http_url_api.h \
201 php_http_encodig_api.h"
202 PHP_SUBST([HTTP_HEADER_FILES])
203
204 ifdef([PHP_INSTALL_HEADERS],
205 [
206 PHP_INSTALL_HEADERS(ext/http, $HTTP_HEADER_FILES)
207 PHP_INSTALL_HEADERS(ext/http/phpstr, [phpstr/phpstr.h])
208 ], [
209 PHP_ADD_MAKEFILE_FRAGMENT
210 ])
211
212 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])
213 fi