release 4.0.0beta1
[m6w6/ext-http] / config9.m4
1
2 m4_foreach(dir, [., ext/http], [
3 sinclude(dir/autoconf/pecl/pecl.m4)
4 sinclude(dir/autoconf/pecl/zlib.m4)
5 sinclude(dir/autoconf/pecl/libbrotli.m4)
6 sinclude(dir/autoconf/pecl/libcurl.m4)
7 sinclude(dir/autoconf/pecl/libevent.m4)
8 ])
9
10 PECL_INIT([http])
11
12 PHP_ARG_WITH([http], [whether to enable extended HTTP support],
13 [ --with-http Enable extended HTTP support])
14 if test "$PHP_HTTP" != "no"; then
15 dnl STDC
16 AC_TYPE_OFF_T
17 AC_TYPE_MBSTATE_T
18 dnl getdomainname() is declared in netdb.h on some platforms: AIX, OSF
19 AC_CHECK_HEADERS([netdb.h unistd.h wchar.h wctype.h arpa/inet.h])
20 AC_CHECK_FUNC(gethostname,,[
21 AC_CHECK_LIB(nsl, gethostname)
22 ])
23 AC_CHECK_FUNC(getdomainname,,[
24 AC_CHECK_LIB(nsl, getdomainname)
25 ])
26 AC_CHECK_FUNCS(mbrtowc mbtowc iswalnum inet_pton)
27
28 dnl ZLIB
29 PHP_ARG_WITH([http-zlib-dir], [whether/where to check for zlib],
30 [ --with-http-zlib-dir[=DIR] HTTP: where to find zlib], $PHP_HTTP, no)
31 PECL_CHECK_ZLIB([$PHP_HTTP_ZLIB_DIR], [1.2.0.4])
32 PECL_CHECK_DONE(zlib, $PECL_VAR([HAVE_ZLIB]))
33
34 dnl BROTLI
35 PHP_ARG_WITH([http-libbrotli-dir], [whether/where to check for libbrotli],
36 [ --with-http-libbrotli-dir[=DIR] HTTP: where to find libbrotli], $PHP_HTTP, no)
37 PECL_CHECK_LIBBROTLI([$PHP_HTTP_LIBBROTLI_DIR], [1.0])
38 PECL_CHECK_DONE(libbrotli, $PECL_VAR([HAVE_LIBBROTLI]))
39
40 dnl CURL
41 PHP_ARG_WITH([http-libcurl-dir], [whether/where to check for libcurl],
42 [ --with-http-libcurl-dir[=DIR] HTTP: where to find libcurl], $PHP_HTTP, no)
43 if test "$PHP_HTTP_LIBCURL_DIR" != "no"; then
44 PECL_CHECK_LIBCURL([$PHP_HTTP_LIBCURL_DIR], [7.18.2])
45 PECL_HAVE_LIBCURL_PROTOCOL([HTTP], [
46 PECL_HAVE_LIBCURL_FEATURE([HTTP2])
47 PECL_HAVE_LIBCURL_ARES
48 PECL_HAVE_LIBCURL_SSL
49 PECL_HAVE_LIBCURL_CA
50 PECL_DEFINE([HAVE_CLIENT])
51 ])
52 PECL_CHECK_DONE(libcurl, [$PECL_VAR([HAVE_LIBCURL_PROTOCOL_HTTP])])
53 fi
54
55 dnl EVENT
56 PHP_ARG_WITH([http-libevent-dir], [whether/where to check for libevent],
57 [ --with-http-libevent-dir[=DIR] HTTP: where to find libevent], $PHP_HTTP_LIBCURL_DIR, no)
58 if test "$PHP_HTTP_LIBEVENT_DIR" != "no"; then
59 PECL_CHECK_LIBEVENT([$PHP_HTTP_LIBEVENT_DIR])
60 PECL_CHECK_DONE(libevent, [$PECL_VAR([HAVE_LIBEVENT])])
61 fi
62
63 dnl GNU IDNA
64 PHP_ARG_WITH([http-libidn2-dir], [whether/where to check for libidn2],
65 [ --with-http-libidn2-dir[=DIR] HTTP: where to find libidn2], $PHP_HTTP_LIBCURL_DIR, no)
66 if test "$PHP_HTTP_LIBIDN2_DIR" != "no"; then
67 PECL_CHECK_CUSTOM(libidn2, "$PHP_HTTP_LIBIDN2_DIR", idn2.h, idn2,
68 [$($EGREP "define IDN2_VERSION " "include/idn2.h" | $SED -e's/^.*VERSION //g' -e 's/@<:@^0-9\.@:>@//g')])
69 if $PECL_VAR([HAVE_LIBIDN2]); then
70 PECL_DEFINE([HAVE_IDNA2008])
71 fi
72 PECL_CHECK_DONE(libidn2, $PECL_VAR([HAVE_LIBIDN2]))
73 fi
74 PHP_ARG_WITH([http-libidn-dir], [whether/where to check for libidn],
75 [ --with-http-libidn-dir[=DIR] HTTP: where to find libidn], $PHP_HTTP_LIBCURL_DIR, no)
76 if test "$PHP_HTTP_LIBIDN_DIR" != "no"; then
77 PECL_CHECK_PKGCONFIG(libidn, [$PHP_HTTP_LIBIDN_DIR])
78 if $PECL_VAR([HAVE_LIBIDN]); then
79 PECL_DEFINE([HAVE_IDNA2003])
80 fi
81 PECL_CHECK_DONE(libidn, $PECL_VAR([HAVE_LIBIDN]))
82 fi
83
84 dnl ICU IDNA
85 PHP_ARG_WITH([http-libicu-dir], [whether/where to check for libicu],
86 [ --with-http-libicu-dir[=DIR] HTTP: where to find libicu], $PHP_HTTP_LIBCURL_DIR, no)
87 if test "$PHP_HTTP_LIBICU_DIR" != "no"; then
88 AC_PATH_PROG(ICU_CONFIG, icu-config, false, [$PHP_HTTP_LIBICU_DIR/bin:$PATH:/usr/local/bin])
89
90 PECL_CHECK_CONFIG(libicu, [$ICU_CONFIG], [--version], [--cppflags], [--ldflags-searchpath], [--ldflags-libsonly])
91 AC_CACHE_CHECK([for uidna_IDNToASCII], PECL_CACHE_VAR([HAVE_UIDNA_IDNToASCII]), [
92 if printf "%s" "$CFLAGS" | $EGREP -q "(^|\s)-Werror\b"; then
93 if ! printf "%s" "$CFLAGS" | $EGREP -q "(^|\s)-Wno-error=deprecated-declarations\b"; then
94 CFLAGS="$CFLAGS -Wno-error=deprecated-declarations"
95 fi
96 fi
97 AC_TRY_LINK([
98 #include <unicode/uidna.h>
99 ], [
100 uidna_IDNToASCII(0, 0, 0, 0, 0, 0, 0);
101 ], [
102 PECL_CACHE_VAR([HAVE_UIDNA_IDNToASCII])=yes
103 ], [
104 PECL_CACHE_VAR([HAVE_UIDNA_IDNToASCII])=no
105 ])
106 ])
107 if $PECL_CACHE_VAR([HAVE_UIDNA_IDNTOASCII]); then
108 PECL_DEFINE([HAVE_IDNA2003])
109 PECL_DEFINE_FN([UIDNA_IDNTOASCII])
110 fi
111
112 AC_CACHE_CHECK([for uidna_nameToASCII_UTF8], PECL_CACHE_VAR([HAVE_UIDNA_NAMETOASCII_UTF8]), [
113 AC_TRY_LINK([
114 #include <unicode/uidna.h>
115 ], [
116 uidna_nameToASCII_UTF8(0, 0, 0, 0, 0, 0, 0);
117 ], [
118 PECL_CACHE_VAR([HAVE_UIDNA_NAMETOASCII_UTF8])=yes
119 ], [
120 PECL_CACHE_VAR([HAVE_UIDNA_NAMETOASCII_UTF8])=no
121 ])
122 ])
123 if $PECL_CACHE_VAR([HAVE_UIDNA_NAMETOASCII_UTF8]); then
124 PECL_DEFINE([HAVE_IDNA2008])
125 PECL_DEFINE_FN([uidna_nameToASCII_UTF8])
126 fi
127 PECL_CHECK_DONE(libicu, [$PECL_VAR([HAVE_LIBICU])])
128 fi
129
130 dnl IDNKIT2
131 PHP_ARG_WITH([http-libidnkit2-dir], [whether/where to check for libidnkit2],
132 [ --with-http-libidnkit2-dir[=DIR] HTTP: where to find libidnkit2], $PHP_HTTP_LIBCURL_DIR, no)
133 if test "$PHP_HTTP_LIBIDNKIT2_DIR" != "no"; then
134 PECL_CHECK_CUSTOM(libidnkit2, "$PHP_HTTP_LIBIDNKIT2_DIR", idn/api.h, idnkit,
135 [$($EGREP "define IDNKIT_VERSION_LIBIDN\b" "include/idn/version.h" | $SED -e's/^.*VERSION_LIBIDN//g' -e 's/@<:@^0-9\.@:>@//g')])
136 if $PECL_VAR([HAVE_LIBIDNKIT2]); then
137 PECL_DEFINE([HAVE_IDNA2008])
138 fi
139 PECL_CHECK_DONE(libidnkit2, [$PECL_VAR([HAVE_LIBIDNKIT2])])
140 fi
141 dnl IDNKIT1
142 PHP_ARG_WITH([http-libidnkit-dir], [whether/where to check for libidnkit],
143 [ --with-http-libidnkit-dir[=DIR] HTTP: where to find libidnkit], $PHP_HTTP_LIBCURL_DIR, no)
144 if test "$PHP_HTTP_LIBIDNKIT_DIR" != "no"; then
145 # libidnkit1 and libidnkit2 have the same API
146 if test "$PHP_HTTP_LIBIDNKIT2_DIR" != no && $PECL_VAR([HAVE_LIBIDNKIT2]); then
147 AC_MSG_WARN([libidnkit-$PECL_VAR([LIBIDNKIT2_VERSION]) already enabled, skipping libidnkit1])
148 else
149 PECL_CHECK_CUSTOM(libidnkit, "$PHP_HTTP_LIBIDNKIT_DIR", idn/api.h, idnkit,
150 [$($EGREP "define IDNKIT_VERSION\b" "include/idn/version.h" | $SED -e's/^.*VERSION//g' -e 's/@<:@^0-9\.@:>@//g')])
151 if $PECL_VAR([HAVE_LIBIDNKIT]); then
152 PECL_DEFINE([HAVE_IDNA2003])
153 fi
154 PECL_CHECK_DONE(libidnkit, [$PECL_VAR([HAVE_LIBIDNKIT])])
155 fi
156 fi
157
158 dnl EXTENSIONS
159 PECL_HAVE_PHP_EXT([raphf], [
160 PECL_HAVE_PHP_EXT_HEADER([raphf])
161 ], [
162 AC_MSG_ERROR([please install and enable pecl/raphf])
163 ])
164 PECL_HAVE_PHP_EXT([propro], [
165 PECL_HAVE_PHP_EXT_HEADER([propro])
166 ], [
167 AC_MSG_ERROR([please install and enable pecl/propro])
168 ])
169 PECL_HAVE_PHP_EXT([hash])
170 PECL_HAVE_PHP_EXT([iconv])
171
172 dnl DONE
173 PHP_SUBST([HTTP_SHARED_LIBADD])
174
175 PECL_VAR([SRCDIR])=PHP_EXT_SRCDIR(http)
176 PECL_VAR([BUILDDIR])=PHP_EXT_BUILDDIR(http)
177
178 PHP_ADD_INCLUDE([$PECL_VAR([SRCDIR])/src])
179 PHP_ADD_BUILD_DIR([$PECL_VAR([BUILDDIR])/src])
180
181 PECL_VAR([HEADERS])=$(cd $PECL_VAR([SRCDIR])/src && echo *.h)
182 PECL_VAR([SOURCES])=$(cd $PECL_VAR([SRCDIR]) && echo src/*.c)
183
184 PHP_NEW_EXTENSION(http, [$PECL_VAR([SOURCES])], [$ext_shared])
185 PHP_INSTALL_HEADERS(ext/http, [php_http.h $PECL_VAR([HEADERS])])
186
187 PHP_ARG_WITH([http-shared-deps], [whether to depend on extensions which have been built shared],
188 [ --without-http-shared-deps HTTP: do not depend on extensions like hash
189 and iconv (when they are built shared)], yes, no)
190 if test "$PHP_HTTP_SHARED_DEPS" != "no"; then
191 if $PECL_VAR([HAVE_EXT_HASH]); then
192 PHP_ADD_EXTENSION_DEP([http], [hash], true)
193 fi
194 if $PECL_VAR([HAVE_EXT_ICONV]); then
195 PHP_ADD_EXTENSION_DEP([http], [iconv], true)
196 fi
197 fi
198 PHP_ADD_EXTENSION_DEP([http], [raphf], true)
199 PHP_ADD_EXTENSION_DEP([http], [propro], true)
200
201 PHP_SUBST(PECL_VAR([HEADERS]))
202 PHP_SUBST(PECL_VAR([SOURCES]))
203
204 PHP_SUBST(PECL_VAR([SRCDIR]))
205 PHP_SUBST(PECL_VAR([BUILDDIR]))
206
207 PHP_ADD_MAKEFILE_FRAGMENT
208
209 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])
210 fi