fix old and add new http\Client\Curl\Versions constants
[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)
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)
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)
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 if $ICU_CONFIG --exists >/dev/null 2>/dev/null; then
91 PECL_CHECK_CONFIG(libicu, [$ICU_CONFIG], [--version], [--cppflags], [--ldflags-searchpath], [--ldflags-libsonly])
92 else
93 PECL_CHECK_PKGCONFIG(icu-i18n, [$PHP_HTTP_LIBICU_DIR])
94 fi
95 AC_CACHE_CHECK([for uidna_IDNToASCII], PECL_CACHE_VAR([HAVE_UIDNA_IDNToASCII]), [
96 if printf "%s" "$CFLAGS" | $EGREP -q "(^|\s)-Werror\b"; then
97 if ! printf "%s" "$CFLAGS" | $EGREP -q "(^|\s)-Wno-error=deprecated-declarations\b"; then
98 CFLAGS="$CFLAGS -Wno-error=deprecated-declarations"
99 fi
100 fi
101 AC_TRY_LINK([
102 #include <unicode/uidna.h>
103 ], [
104 uidna_IDNToASCII(0, 0, 0, 0, 0, 0, 0);
105 ], [
106 PECL_CACHE_VAR([HAVE_UIDNA_IDNToASCII])=yes
107 ], [
108 PECL_CACHE_VAR([HAVE_UIDNA_IDNToASCII])=no
109 ])
110 ])
111 if $PECL_CACHE_VAR([HAVE_UIDNA_IDNTOASCII]); then
112 PECL_DEFINE([HAVE_IDNA2003])
113 PECL_DEFINE_FN([UIDNA_IDNTOASCII])
114 fi
115
116 AC_CACHE_CHECK([for uidna_nameToASCII_UTF8], PECL_CACHE_VAR([HAVE_UIDNA_NAMETOASCII_UTF8]), [
117 AC_TRY_LINK([
118 #include <unicode/uidna.h>
119 ], [
120 uidna_nameToASCII_UTF8(0, 0, 0, 0, 0, 0, 0);
121 ], [
122 PECL_CACHE_VAR([HAVE_UIDNA_NAMETOASCII_UTF8])=yes
123 ], [
124 PECL_CACHE_VAR([HAVE_UIDNA_NAMETOASCII_UTF8])=no
125 ])
126 ])
127 if $PECL_CACHE_VAR([HAVE_UIDNA_NAMETOASCII_UTF8]); then
128 PECL_DEFINE([HAVE_IDNA2008])
129 PECL_DEFINE_FN([uidna_nameToASCII_UTF8])
130 fi
131 PECL_CHECK_DONE(libicu, [$PECL_VAR([HAVE_LIBICU])])
132 fi
133
134 dnl IDNKIT2
135 PHP_ARG_WITH([http-libidnkit2-dir], [whether/where to check for libidnkit2],
136 [ --with-http-libidnkit2-dir[=DIR] HTTP: where to find libidnkit2], $PHP_HTTP_LIBCURL_DIR, no)
137 if test "$PHP_HTTP_LIBIDNKIT2_DIR" != "no"; then
138 PECL_CHECK_CUSTOM(libidnkit2, "$PHP_HTTP_LIBIDNKIT2_DIR", idn/api.h, idnkit,
139 [$($EGREP "define IDNKIT_VERSION_LIBIDN\b" "include/idn/version.h" | $SED -e's/^.*VERSION_LIBIDN//g' -e 's/@<:@^0-9\.@:>@//g')])
140 if $PECL_VAR([HAVE_LIBIDNKIT2]); then
141 PECL_DEFINE([HAVE_IDNA2008])
142 fi
143 PECL_CHECK_DONE(libidnkit2, [$PECL_VAR([HAVE_LIBIDNKIT2])])
144 fi
145 dnl IDNKIT1
146 PHP_ARG_WITH([http-libidnkit-dir], [whether/where to check for libidnkit],
147 [ --with-http-libidnkit-dir[=DIR] HTTP: where to find libidnkit], $PHP_HTTP_LIBCURL_DIR, no)
148 if test "$PHP_HTTP_LIBIDNKIT_DIR" != "no"; then
149 # libidnkit1 and libidnkit2 have the same API
150 if test "$PHP_HTTP_LIBIDNKIT2_DIR" != no && $PECL_VAR([HAVE_LIBIDNKIT2]); then
151 AC_MSG_WARN([libidnkit-$PECL_VAR([LIBIDNKIT2_VERSION]) already enabled, skipping libidnkit1])
152 else
153 PECL_CHECK_CUSTOM(libidnkit, "$PHP_HTTP_LIBIDNKIT_DIR", idn/api.h, idnkit,
154 [$($EGREP "define IDNKIT_VERSION\b" "include/idn/version.h" | $SED -e's/^.*VERSION//g' -e 's/@<:@^0-9\.@:>@//g')])
155 if $PECL_VAR([HAVE_LIBIDNKIT]); then
156 PECL_DEFINE([HAVE_IDNA2003])
157 fi
158 PECL_CHECK_DONE(libidnkit, [$PECL_VAR([HAVE_LIBIDNKIT])])
159 fi
160 fi
161
162 dnl EXTENSIONS
163 PECL_HAVE_PHP_EXT([raphf], [
164 PECL_HAVE_PHP_EXT_HEADER([raphf])
165 ], [
166 AC_MSG_ERROR([please install and enable pecl/raphf])
167 ])
168 PECL_HAVE_PHP_EXT([iconv])
169
170 dnl DONE
171 PHP_SUBST([HTTP_SHARED_LIBADD])
172
173 PECL_VAR([SRCDIR])=PHP_EXT_SRCDIR(http)
174 PECL_VAR([BUILDDIR])=PHP_EXT_BUILDDIR(http)
175
176 PHP_ADD_INCLUDE([$PECL_VAR([SRCDIR])/src])
177 PHP_ADD_BUILD_DIR([$PECL_VAR([BUILDDIR])/src])
178
179 PECL_VAR([HEADERS])=$(cd $PECL_VAR([SRCDIR])/src && echo *.h)
180 PECL_VAR([SOURCES])=$(cd $PECL_VAR([SRCDIR]) && echo src/*.c)
181
182 PHP_NEW_EXTENSION(http, [$PECL_VAR([SOURCES])], [$ext_shared])
183 PHP_INSTALL_HEADERS(ext/http, [php_http.h $PECL_VAR([HEADERS])])
184
185 PHP_ARG_WITH([http-shared-deps], [whether to depend on extensions which have been built shared],
186 [ --without-http-shared-deps HTTP: do not depend on extensions like hash
187 and iconv (when they are built shared)], yes, no)
188 if test "$PHP_HTTP_SHARED_DEPS" != "no"; then
189 if $PECL_VAR([HAVE_EXT_HASH]); then
190 PHP_ADD_EXTENSION_DEP([http], [hash], true)
191 fi
192 if $PECL_VAR([HAVE_EXT_ICONV]); then
193 PHP_ADD_EXTENSION_DEP([http], [iconv], true)
194 fi
195 fi
196 PHP_ADD_EXTENSION_DEP([http], [raphf], true)
197
198 PHP_SUBST(PECL_VAR([HEADERS]))
199 PHP_SUBST(PECL_VAR([SOURCES]))
200
201 PHP_SUBST(PECL_VAR([SRCDIR]))
202 PHP_SUBST(PECL_VAR([BUILDDIR]))
203
204 PHP_ADD_MAKEFILE_FRAGMENT
205
206 AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support])
207 fi