]>
Commit | Line | Data |
---|---|---|
d551412a DS |
1 | #*************************************************************************** |
2 | # _ _ ____ _ | |
3 | # Project ___| | | | _ \| | | |
4 | # / __| | | | |_) | | | |
5 | # | (__| |_| | _ <| |___ | |
6 | # \___|\___/|_| \_\_____| | |
7 | # | |
2df622fd | 8 | # Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al. |
d551412a DS |
9 | # |
10 | # This software is licensed as described in the file COPYING, which | |
11 | # you should have received as part of this distribution. The terms | |
12 | # are also available at http://curl.haxx.se/docs/copyright.html. | |
13 | # | |
14 | # You may opt to use, copy, modify, merge, publish, distribute and/or sell | |
15 | # copies of the Software, and permit persons to whom the Software is | |
16 | # furnished to do so, under the terms of the COPYING file. | |
17 | # | |
18 | # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | |
19 | # KIND, either express or implied. | |
20 | # | |
21 | # $Id$ | |
22 | ########################################################################### | |
51581c03 | 23 | |
bc2f0c7d | 24 | |
51581c03 YT |
25 | dnl CURL_CHECK_HEADER_WINDOWS |
26 | dnl ------------------------------------------------- | |
b9f39c27 | 27 | dnl Check for compilable and valid windows.h header |
51581c03 YT |
28 | |
29 | AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [ | |
30 | AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [ | |
31 | AC_COMPILE_IFELSE([ | |
32 | AC_LANG_PROGRAM([ | |
a6a5bba0 | 33 | #undef inline |
74ed5b5e | 34 | #ifndef WIN32_LEAN_AND_MEAN |
51581c03 | 35 | #define WIN32_LEAN_AND_MEAN |
74ed5b5e | 36 | #endif |
51581c03 YT |
37 | #include <windows.h> |
38 | ],[ | |
bc2f0c7d YT |
39 | #ifdef __CYGWIN__ |
40 | HAVE_WINDOWS_H shall not be defined. | |
41 | #else | |
51581c03 | 42 | int dummy=2*WINVER; |
bc2f0c7d | 43 | #endif |
51581c03 YT |
44 | ]) |
45 | ],[ | |
46 | ac_cv_header_windows_h="yes" | |
47 | ],[ | |
48 | ac_cv_header_windows_h="no" | |
49 | ]) | |
50 | ]) | |
8ef454dc YT |
51 | case "$ac_cv_header_windows_h" in |
52 | yes) | |
53 | AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1, | |
54 | [Define to 1 if you have the windows.h header file.]) | |
55 | AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1, | |
56 | [Define to avoid automatic inclusion of winsock.h]) | |
57 | ;; | |
58 | esac | |
51581c03 YT |
59 | ]) |
60 | ||
61 | ||
62 | dnl CURL_CHECK_HEADER_WINSOCK | |
63 | dnl ------------------------------------------------- | |
b9f39c27 | 64 | dnl Check for compilable and valid winsock.h header |
51581c03 YT |
65 | |
66 | AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [ | |
67 | AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl | |
68 | AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [ | |
69 | AC_COMPILE_IFELSE([ | |
70 | AC_LANG_PROGRAM([ | |
a6a5bba0 | 71 | #undef inline |
74ed5b5e | 72 | #ifndef WIN32_LEAN_AND_MEAN |
51581c03 | 73 | #define WIN32_LEAN_AND_MEAN |
74ed5b5e | 74 | #endif |
51581c03 YT |
75 | #include <windows.h> |
76 | #include <winsock.h> | |
77 | ],[ | |
bc2f0c7d YT |
78 | #ifdef __CYGWIN__ |
79 | HAVE_WINSOCK_H shall not be defined. | |
80 | #else | |
51581c03 | 81 | int dummy=WSACleanup(); |
bc2f0c7d | 82 | #endif |
51581c03 YT |
83 | ]) |
84 | ],[ | |
85 | ac_cv_header_winsock_h="yes" | |
86 | ],[ | |
87 | ac_cv_header_winsock_h="no" | |
88 | ]) | |
89 | ]) | |
8ef454dc YT |
90 | case "$ac_cv_header_winsock_h" in |
91 | yes) | |
92 | AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1, | |
93 | [Define to 1 if you have the winsock.h header file.]) | |
94 | ;; | |
95 | esac | |
51581c03 YT |
96 | ]) |
97 | ||
98 | ||
99 | dnl CURL_CHECK_HEADER_WINSOCK2 | |
100 | dnl ------------------------------------------------- | |
b9f39c27 | 101 | dnl Check for compilable and valid winsock2.h header |
51581c03 YT |
102 | |
103 | AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [ | |
104 | AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl | |
105 | AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [ | |
106 | AC_COMPILE_IFELSE([ | |
107 | AC_LANG_PROGRAM([ | |
a6a5bba0 | 108 | #undef inline |
74ed5b5e | 109 | #ifndef WIN32_LEAN_AND_MEAN |
51581c03 | 110 | #define WIN32_LEAN_AND_MEAN |
74ed5b5e | 111 | #endif |
51581c03 YT |
112 | #include <windows.h> |
113 | #include <winsock2.h> | |
114 | ],[ | |
bc2f0c7d YT |
115 | #ifdef __CYGWIN__ |
116 | HAVE_WINSOCK2_H shall not be defined. | |
117 | #else | |
51581c03 | 118 | int dummy=2*IPPROTO_ESP; |
bc2f0c7d | 119 | #endif |
51581c03 YT |
120 | ]) |
121 | ],[ | |
122 | ac_cv_header_winsock2_h="yes" | |
123 | ],[ | |
124 | ac_cv_header_winsock2_h="no" | |
125 | ]) | |
126 | ]) | |
8ef454dc YT |
127 | case "$ac_cv_header_winsock2_h" in |
128 | yes) | |
129 | AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1, | |
130 | [Define to 1 if you have the winsock2.h header file.]) | |
131 | ;; | |
132 | esac | |
51581c03 YT |
133 | ]) |
134 | ||
135 | ||
136 | dnl CURL_CHECK_HEADER_WS2TCPIP | |
137 | dnl ------------------------------------------------- | |
b9f39c27 | 138 | dnl Check for compilable and valid ws2tcpip.h header |
51581c03 YT |
139 | |
140 | AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [ | |
141 | AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl | |
142 | AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [ | |
143 | AC_COMPILE_IFELSE([ | |
144 | AC_LANG_PROGRAM([ | |
a6a5bba0 | 145 | #undef inline |
74ed5b5e | 146 | #ifndef WIN32_LEAN_AND_MEAN |
51581c03 | 147 | #define WIN32_LEAN_AND_MEAN |
74ed5b5e | 148 | #endif |
51581c03 YT |
149 | #include <windows.h> |
150 | #include <winsock2.h> | |
151 | #include <ws2tcpip.h> | |
152 | ],[ | |
bc2f0c7d YT |
153 | #ifdef __CYGWIN__ |
154 | HAVE_WS2TCPIP_H shall not be defined. | |
155 | #else | |
51581c03 | 156 | int dummy=2*IP_PKTINFO; |
bc2f0c7d | 157 | #endif |
51581c03 YT |
158 | ]) |
159 | ],[ | |
160 | ac_cv_header_ws2tcpip_h="yes" | |
161 | ],[ | |
162 | ac_cv_header_ws2tcpip_h="no" | |
163 | ]) | |
164 | ]) | |
8ef454dc YT |
165 | case "$ac_cv_header_ws2tcpip_h" in |
166 | yes) | |
167 | AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1, | |
168 | [Define to 1 if you have the ws2tcpip.h header file.]) | |
169 | ;; | |
170 | esac | |
51581c03 YT |
171 | ]) |
172 | ||
173 | ||
4d95d23d YT |
174 | dnl CURL_CHECK_HEADER_MALLOC |
175 | dnl ------------------------------------------------- | |
176 | dnl Check for compilable and valid malloc.h header, | |
177 | dnl and check if it is needed even with stdlib.h | |
178 | ||
179 | AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [ | |
180 | AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [ | |
181 | AC_COMPILE_IFELSE([ | |
182 | AC_LANG_PROGRAM([ | |
183 | #include <malloc.h> | |
184 | ],[ | |
185 | void *p = malloc(10); | |
186 | void *q = calloc(10,10); | |
187 | free(p); | |
188 | free(q); | |
189 | ]) | |
190 | ],[ | |
191 | ac_cv_header_malloc_h="yes" | |
192 | ],[ | |
193 | ac_cv_header_malloc_h="no" | |
194 | ]) | |
195 | ]) | |
196 | if test "$ac_cv_header_malloc_h" = "yes"; then | |
197 | AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1, | |
198 | [Define to 1 if you have the malloc.h header file.]) | |
199 | # | |
200 | AC_COMPILE_IFELSE([ | |
201 | AC_LANG_PROGRAM([ | |
202 | #include <stdlib.h> | |
203 | ],[ | |
204 | void *p = malloc(10); | |
205 | void *q = calloc(10,10); | |
206 | free(p); | |
207 | free(q); | |
208 | ]) | |
209 | ],[ | |
210 | curl_cv_need_header_malloc_h="no" | |
211 | ],[ | |
212 | curl_cv_need_header_malloc_h="yes" | |
213 | ]) | |
214 | # | |
215 | case "$curl_cv_need_header_malloc_h" in | |
216 | yes) | |
217 | AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1, | |
13616f8f | 218 | [Define to 1 if you need the malloc.h header file even with stdlib.h]) |
4d95d23d YT |
219 | ;; |
220 | esac | |
221 | fi | |
222 | ]) | |
223 | ||
224 | ||
a6a5bba0 YT |
225 | dnl CURL_CHECK_TYPE_SOCKLEN_T |
226 | dnl ------------------------------------------------- | |
b9f39c27 YT |
227 | dnl Check for existing socklen_t type, and provide |
228 | dnl an equivalent type if socklen_t not available | |
a6a5bba0 YT |
229 | |
230 | AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [ | |
231 | AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl | |
232 | AC_CHECK_TYPE([socklen_t], ,[ | |
5acac030 YT |
233 | AC_CACHE_CHECK([for socklen_t equivalent], |
234 | [curl_cv_socklen_t_equiv], [ | |
b9f39c27 | 235 | curl_cv_socklen_t_equiv="unknown" |
fea5ddf5 YT |
236 | for arg2 in "struct sockaddr" void; do |
237 | for t in int size_t unsigned long "unsigned long"; do | |
a6a5bba0 YT |
238 | AC_COMPILE_IFELSE([ |
239 | AC_LANG_PROGRAM([ | |
240 | #undef inline | |
241 | #ifdef HAVE_WINDOWS_H | |
74ed5b5e | 242 | #ifndef WIN32_LEAN_AND_MEAN |
a6a5bba0 | 243 | #define WIN32_LEAN_AND_MEAN |
74ed5b5e | 244 | #endif |
a6a5bba0 YT |
245 | #include <windows.h> |
246 | #ifdef HAVE_WINSOCK2_H | |
247 | #include <winsock2.h> | |
248 | #else | |
249 | #ifdef HAVE_WINSOCK_H | |
250 | #include <winsock.h> | |
251 | #endif | |
252 | #endif | |
253 | #else | |
254 | #ifdef HAVE_SYS_TYPES_H | |
255 | #include <sys/types.h> | |
256 | #endif | |
257 | #ifdef HAVE_SYS_SOCKET_H | |
258 | #include <sys/socket.h> | |
259 | #endif | |
260 | #endif | |
261 | int getpeername (int, $arg2 *, $t *); | |
a6a5bba0 | 262 | ],[ |
b9f39c27 | 263 | $t len=0; |
a6a5bba0 | 264 | getpeername(0,0,&len); |
a6a5bba0 YT |
265 | ]) |
266 | ],[ | |
5acac030 | 267 | curl_cv_socklen_t_equiv="$t" |
a6a5bba0 YT |
268 | break 2 |
269 | ]) | |
270 | done | |
271 | done | |
272 | ]) | |
8ef454dc YT |
273 | case "$curl_cv_socklen_t_equiv" in |
274 | unknown) | |
275 | AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) | |
276 | ;; | |
277 | *) | |
278 | AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv, | |
279 | [type to use in place of socklen_t if not defined]) | |
280 | ;; | |
281 | esac | |
a6a5bba0 | 282 | ],[ |
74ed5b5e | 283 | #undef inline |
a6a5bba0 | 284 | #ifdef HAVE_WINDOWS_H |
74ed5b5e YT |
285 | #ifndef WIN32_LEAN_AND_MEAN |
286 | #define WIN32_LEAN_AND_MEAN | |
287 | #endif | |
288 | #include <windows.h> | |
289 | #ifdef HAVE_WINSOCK2_H | |
290 | #include <winsock2.h> | |
a6a5bba0 YT |
291 | #ifdef HAVE_WS2TCPIP_H |
292 | #include <ws2tcpip.h> | |
293 | #endif | |
74ed5b5e | 294 | #endif |
a6a5bba0 YT |
295 | #else |
296 | #ifdef HAVE_SYS_TYPES_H | |
297 | #include <sys/types.h> | |
298 | #endif | |
299 | #ifdef HAVE_SYS_SOCKET_H | |
300 | #include <sys/socket.h> | |
301 | #endif | |
302 | #endif | |
303 | ]) | |
304 | ]) | |
305 | ||
306 | ||
e4388643 | 307 | dnl CURL_CHECK_FUNC_GETNAMEINFO |
d6ffb4c1 | 308 | dnl ------------------------------------------------- |
e4388643 YT |
309 | dnl Test if the getnameinfo function is available, |
310 | dnl and check the types of five of its arguments. | |
311 | dnl If the function succeeds HAVE_GETNAMEINFO will be | |
312 | dnl defined, defining the types of the arguments in | |
d6ffb4c1 | 313 | dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2, |
b1022ea4 YT |
314 | dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7, |
315 | dnl and also defining the type qualifier of first | |
316 | dnl argument in GETNAMEINFO_QUAL_ARG1. | |
d6ffb4c1 | 317 | |
e4388643 | 318 | AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [ |
d6ffb4c1 YT |
319 | AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl |
320 | AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl | |
8ef454dc | 321 | AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h) |
e4388643 YT |
322 | # |
323 | AC_MSG_CHECKING([for getnameinfo]) | |
324 | AC_LINK_IFELSE([ | |
325 | AC_LANG_FUNC_LINK_TRY([getnameinfo]) | |
326 | ],[ | |
327 | AC_MSG_RESULT([yes]) | |
328 | curl_cv_getnameinfo="yes" | |
329 | ],[ | |
330 | AC_MSG_RESULT([no]) | |
331 | curl_cv_getnameinfo="no" | |
332 | ]) | |
333 | # | |
334 | if test "$curl_cv_getnameinfo" != "yes"; then | |
335 | AC_MSG_CHECKING([deeper for getnameinfo]) | |
336 | AC_TRY_LINK([ | |
337 | ],[ | |
338 | getnameinfo(); | |
339 | ],[ | |
340 | AC_MSG_RESULT([yes]) | |
341 | curl_cv_getnameinfo="yes" | |
342 | ],[ | |
343 | AC_MSG_RESULT([but still no]) | |
344 | curl_cv_getnameinfo="no" | |
345 | ]) | |
346 | fi | |
347 | # | |
348 | if test "$curl_cv_getnameinfo" != "yes"; then | |
349 | AC_MSG_CHECKING([deeper and deeper for getnameinfo]) | |
350 | AC_TRY_LINK([ | |
351 | #undef inline | |
352 | #ifdef HAVE_WINDOWS_H | |
353 | #ifndef WIN32_LEAN_AND_MEAN | |
354 | #define WIN32_LEAN_AND_MEAN | |
355 | #endif | |
356 | #include <windows.h> | |
357 | #ifdef HAVE_WINSOCK2_H | |
358 | #include <winsock2.h> | |
359 | #ifdef HAVE_WS2TCPIP_H | |
360 | #include <ws2tcpip.h> | |
361 | #endif | |
362 | #endif | |
363 | #else | |
364 | #ifdef HAVE_SYS_TYPES_H | |
365 | #include <sys/types.h> | |
366 | #endif | |
367 | #ifdef HAVE_SYS_SOCKET_H | |
368 | #include <sys/socket.h> | |
369 | #endif | |
370 | #ifdef HAVE_NETDB_H | |
371 | #include <netdb.h> | |
372 | #endif | |
373 | #endif | |
374 | ],[ | |
375 | getnameinfo(0, 0, 0, 0, 0, 0, 0); | |
376 | ],[ | |
377 | AC_MSG_RESULT([yes]) | |
378 | curl_cv_getnameinfo="yes" | |
379 | ],[ | |
380 | AC_MSG_RESULT([but still no]) | |
381 | curl_cv_getnameinfo="no" | |
382 | ]) | |
383 | fi | |
384 | # | |
385 | if test "$curl_cv_getnameinfo" = "yes"; then | |
386 | AC_CACHE_CHECK([types of arguments for getnameinfo], | |
387 | [curl_cv_func_getnameinfo_args], [ | |
388 | curl_cv_func_getnameinfo_args="unknown" | |
389 | for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do | |
390 | for gni_arg2 in 'socklen_t' 'size_t' 'int'; do | |
391 | for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do | |
392 | for gni_arg7 in 'int' 'unsigned int'; do | |
393 | AC_COMPILE_IFELSE([ | |
394 | AC_LANG_PROGRAM([ | |
e3657644 | 395 | #undef inline |
d6ffb4c1 | 396 | #ifdef HAVE_WINDOWS_H |
74ed5b5e | 397 | #ifndef WIN32_LEAN_AND_MEAN |
d6ffb4c1 | 398 | #define WIN32_LEAN_AND_MEAN |
8a3280a2 | 399 | #endif |
e3657644 | 400 | #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501) |
f4481685 YT |
401 | #undef _WIN32_WINNT |
402 | #define _WIN32_WINNT 0x0501 | |
403 | #endif | |
d6ffb4c1 YT |
404 | #include <windows.h> |
405 | #ifdef HAVE_WINSOCK2_H | |
e3657644 | 406 | #include <winsock2.h> |
d6ffb4c1 YT |
407 | #ifdef HAVE_WS2TCPIP_H |
408 | #include <ws2tcpip.h> | |
409 | #endif | |
74ed5b5e | 410 | #endif |
e3657644 | 411 | #define GNICALLCONV WSAAPI |
d6ffb4c1 YT |
412 | #else |
413 | #ifdef HAVE_SYS_TYPES_H | |
414 | #include <sys/types.h> | |
415 | #endif | |
416 | #ifdef HAVE_SYS_SOCKET_H | |
417 | #include <sys/socket.h> | |
418 | #endif | |
419 | #ifdef HAVE_NETDB_H | |
420 | #include <netdb.h> | |
421 | #endif | |
e3657644 | 422 | #define GNICALLCONV |
d6ffb4c1 | 423 | #endif |
e4388643 YT |
424 | extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2, |
425 | char *, $gni_arg46, | |
426 | char *, $gni_arg46, | |
427 | $gni_arg7); | |
428 | ],[ | |
429 | $gni_arg2 salen=0; | |
430 | $gni_arg46 hostlen=0; | |
431 | $gni_arg46 servlen=0; | |
432 | $gni_arg7 flags=0; | |
433 | int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags); | |
434 | ]) | |
d6ffb4c1 | 435 | ],[ |
e4388643 YT |
436 | curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7" |
437 | break 4 | |
d6ffb4c1 | 438 | ]) |
e4388643 | 439 | done |
d6ffb4c1 YT |
440 | done |
441 | done | |
442 | done | |
e4388643 YT |
443 | ]) # AC_CACHE_CHECK |
444 | if test "$curl_cv_func_getnameinfo_args" = "unknown"; then | |
445 | AC_MSG_WARN([Cannot find proper types to use for getnameinfo args]) | |
446 | AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined]) | |
447 | else | |
448 | gni_prev_IFS=$IFS; IFS=',' | |
449 | set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'` | |
450 | IFS=$gni_prev_IFS | |
451 | shift | |
39745ac3 YT |
452 | # |
453 | gni_qual_type_arg1=$[1] | |
454 | # | |
e4388643 YT |
455 | AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2], |
456 | [Define to the type of arg 2 for getnameinfo.]) | |
457 | AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3], | |
458 | [Define to the type of args 4 and 6 for getnameinfo.]) | |
459 | AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4], | |
460 | [Define to the type of arg 7 for getnameinfo.]) | |
b1022ea4 | 461 | # |
55329b56 | 462 | prev_sh_opts=$- |
39745ac3 | 463 | # |
55329b56 | 464 | case $prev_sh_opts in |
39745ac3 YT |
465 | *f*) |
466 | ;; | |
467 | *) | |
468 | set -f | |
469 | ;; | |
470 | esac | |
b1022ea4 YT |
471 | # |
472 | case "$gni_qual_type_arg1" in | |
473 | const*) | |
474 | gni_qual_arg1=const | |
39745ac3 | 475 | gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'` |
b1022ea4 YT |
476 | ;; |
477 | *) | |
478 | gni_qual_arg1= | |
39745ac3 | 479 | gni_type_arg1=$gni_qual_type_arg1 |
b1022ea4 YT |
480 | ;; |
481 | esac | |
482 | # | |
7a6d7fca | 483 | AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1, |
b1022ea4 | 484 | [Define to the type qualifier of arg 1 for getnameinfo.]) |
7a6d7fca | 485 | AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1, |
b1022ea4 YT |
486 | [Define to the type of arg 1 for getnameinfo.]) |
487 | # | |
55329b56 | 488 | case $prev_sh_opts in |
39745ac3 YT |
489 | *f*) |
490 | ;; | |
491 | *) | |
492 | set +f | |
493 | ;; | |
494 | esac | |
495 | # | |
e4388643 YT |
496 | AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1, |
497 | [Define to 1 if you have the getnameinfo function.]) | |
498 | ac_cv_func_getnameinfo="yes" | |
499 | fi | |
d6ffb4c1 | 500 | fi |
e4388643 | 501 | ]) # AC_DEFUN |
d6ffb4c1 YT |
502 | |
503 | ||
bec19771 YT |
504 | dnl TYPE_SOCKADDR_STORAGE |
505 | dnl ------------------------------------------------- | |
506 | dnl Check for struct sockaddr_storage. Most IPv6-enabled | |
507 | dnl hosts have it, but AIX 4.3 is one known exception. | |
508 | ||
509 | AC_DEFUN([TYPE_SOCKADDR_STORAGE], | |
510 | [ | |
511 | AC_CHECK_TYPE([struct sockaddr_storage], | |
512 | AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1, | |
513 | [if struct sockaddr_storage is defined]), , | |
514 | [ | |
515 | #undef inline | |
516 | #ifdef HAVE_WINDOWS_H | |
517 | #ifndef WIN32_LEAN_AND_MEAN | |
518 | #define WIN32_LEAN_AND_MEAN | |
519 | #endif | |
520 | #include <windows.h> | |
521 | #ifdef HAVE_WINSOCK2_H | |
522 | #include <winsock2.h> | |
523 | #endif | |
524 | #else | |
525 | #ifdef HAVE_SYS_TYPES_H | |
526 | #include <sys/types.h> | |
527 | #endif | |
528 | #ifdef HAVE_SYS_SOCKET_H | |
529 | #include <sys/socket.h> | |
530 | #endif | |
531 | #ifdef HAVE_NETINET_IN_H | |
532 | #include <netinet/in.h> | |
533 | #endif | |
534 | #ifdef HAVE_ARPA_INET_H | |
535 | #include <arpa/inet.h> | |
536 | #endif | |
537 | #endif | |
538 | ]) | |
539 | ]) | |
540 | ||
541 | ||
4c08eb4b YT |
542 | dnl CURL_CHECK_NI_WITHSCOPEID |
543 | dnl ------------------------------------------------- | |
544 | dnl Check for working NI_WITHSCOPEID in getnameinfo() | |
545 | ||
546 | AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [ | |
bec19771 YT |
547 | AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl |
548 | AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl | |
8ef454dc | 549 | AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \ |
bec19771 YT |
550 | netdb.h netinet/in.h arpa/inet.h) |
551 | # | |
4c08eb4b YT |
552 | AC_CACHE_CHECK([for working NI_WITHSCOPEID], |
553 | [ac_cv_working_ni_withscopeid], [ | |
554 | AC_RUN_IFELSE([ | |
555 | AC_LANG_PROGRAM([ | |
bec19771 | 556 | #ifdef HAVE_STDIO_H |
4c08eb4b | 557 | #include <stdio.h> |
bec19771 YT |
558 | #endif |
559 | #ifdef HAVE_SYS_TYPES_H | |
4c08eb4b | 560 | #include <sys/types.h> |
bec19771 YT |
561 | #endif |
562 | #ifdef HAVE_SYS_SOCKET_H | |
4c08eb4b | 563 | #include <sys/socket.h> |
bec19771 YT |
564 | #endif |
565 | #ifdef HAVE_NETDB_H | |
4c08eb4b | 566 | #include <netdb.h> |
bec19771 YT |
567 | #endif |
568 | #ifdef HAVE_NETINET_IN_H | |
569 | #include <netinet/in.h> | |
570 | #endif | |
571 | #ifdef HAVE_ARPA_INET_H | |
572 | #include <arpa/inet.h> | |
573 | #endif | |
4c08eb4b | 574 | ],[ |
bec19771 YT |
575 | #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO) |
576 | #ifdef HAVE_STRUCT_SOCKADDR_STORAGE | |
577 | struct sockaddr_storage sa; | |
578 | #else | |
579 | unsigned char sa[256]; | |
580 | #endif | |
581 | char hostbuf[NI_MAXHOST]; | |
4c08eb4b | 582 | int rc; |
bec19771 YT |
583 | GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa); |
584 | GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf); | |
585 | GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID; | |
4c08eb4b YT |
586 | int fd = socket(AF_INET6, SOCK_STREAM, 0); |
587 | if(fd < 0) { | |
588 | perror("socket()"); | |
589 | return 1; /* Error creating socket */ | |
590 | } | |
bec19771 | 591 | rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen); |
4c08eb4b YT |
592 | if(rc) { |
593 | perror("getsockname()"); | |
594 | return 2; /* Error retrieving socket name */ | |
595 | } | |
bec19771 | 596 | rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags); |
4c08eb4b YT |
597 | if(rc) { |
598 | printf("rc = %s\n", gai_strerror(rc)); | |
599 | return 3; /* Error translating socket address */ | |
600 | } | |
601 | return 0; /* Ok, NI_WITHSCOPEID works */ | |
602 | #else | |
bec19771 | 603 | return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */ |
4c08eb4b YT |
604 | #endif |
605 | ]) # AC_LANG_PROGRAM | |
606 | ],[ | |
607 | # Exit code == 0. Program worked. | |
608 | ac_cv_working_ni_withscopeid="yes" | |
609 | ],[ | |
610 | # Exit code != 0. Program failed. | |
611 | ac_cv_working_ni_withscopeid="no" | |
612 | ],[ | |
613 | # Program is not run when cross-compiling. So we assume | |
614 | # NI_WITHSCOPEID will work if we are able to compile it. | |
615 | AC_COMPILE_IFELSE([ | |
616 | AC_LANG_PROGRAM([ | |
4c08eb4b YT |
617 | #include <sys/types.h> |
618 | #include <sys/socket.h> | |
619 | #include <netdb.h> | |
620 | ],[ | |
621 | unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID; | |
622 | ]) | |
623 | ],[ | |
624 | ac_cv_working_ni_withscopeid="yes" | |
625 | ],[ | |
626 | ac_cv_working_ni_withscopeid="no" | |
627 | ]) # AC_COMPILE_IFELSE | |
628 | ]) # AC_RUN_IFELSE | |
629 | ]) # AC_CACHE_CHECK | |
8ef454dc YT |
630 | case "$ac_cv_working_ni_withscopeid" in |
631 | yes) | |
632 | AC_DEFINE(HAVE_NI_WITHSCOPEID, 1, | |
633 | [Define to 1 if NI_WITHSCOPEID exists and works.]) | |
634 | ;; | |
635 | esac | |
4c08eb4b YT |
636 | ]) # AC_DEFUN |
637 | ||
638 | ||
01fa02d0 YT |
639 | dnl CURL_CHECK_FUNC_RECV |
640 | dnl ------------------------------------------------- | |
641 | dnl Test if the socket recv() function is available, | |
642 | dnl and check its return type and the types of its | |
643 | dnl arguments. If the function succeeds HAVE_RECV | |
644 | dnl will be defined, defining the types of the arguments | |
645 | dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3 | |
646 | dnl and RECV_TYPE_ARG4, defining the type of the function | |
647 | dnl return value in RECV_TYPE_RETV. | |
648 | ||
649 | AC_DEFUN([CURL_CHECK_FUNC_RECV], [ | |
bc2f0c7d YT |
650 | AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl |
651 | AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl | |
8ef454dc | 652 | AC_CHECK_HEADERS(sys/types.h sys/socket.h) |
01fa02d0 YT |
653 | # |
654 | AC_MSG_CHECKING([for recv]) | |
655 | AC_TRY_LINK([ | |
bc2f0c7d YT |
656 | #undef inline |
657 | #ifdef HAVE_WINDOWS_H | |
658 | #ifndef WIN32_LEAN_AND_MEAN | |
659 | #define WIN32_LEAN_AND_MEAN | |
660 | #endif | |
661 | #include <windows.h> | |
662 | #ifdef HAVE_WINSOCK2_H | |
663 | #include <winsock2.h> | |
664 | #else | |
665 | #ifdef HAVE_WINSOCK_H | |
666 | #include <winsock.h> | |
667 | #endif | |
668 | #endif | |
669 | #else | |
01fa02d0 YT |
670 | #ifdef HAVE_SYS_TYPES_H |
671 | #include <sys/types.h> | |
672 | #endif | |
673 | #ifdef HAVE_SYS_SOCKET_H | |
674 | #include <sys/socket.h> | |
bc2f0c7d | 675 | #endif |
01fa02d0 YT |
676 | #endif |
677 | ],[ | |
678 | recv(0, 0, 0, 0); | |
679 | ],[ | |
680 | AC_MSG_RESULT([yes]) | |
681 | curl_cv_recv="yes" | |
682 | ],[ | |
683 | AC_MSG_RESULT([no]) | |
684 | curl_cv_recv="no" | |
685 | ]) | |
686 | # | |
687 | if test "$curl_cv_recv" = "yes"; then | |
688 | AC_CACHE_CHECK([types of arguments and return type for recv], | |
689 | [curl_cv_func_recv_args], [ | |
690 | curl_cv_func_recv_args="unknown" | |
691 | for recv_retv in 'int' 'ssize_t'; do | |
0a4bba56 | 692 | for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do |
7e43d06b | 693 | for recv_arg2 in 'char *' 'void *'; do |
0a4bba56 | 694 | for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do |
01fa02d0 YT |
695 | for recv_arg4 in 'int' 'unsigned int'; do |
696 | AC_COMPILE_IFELSE([ | |
697 | AC_LANG_PROGRAM([ | |
698 | #undef inline | |
bc2f0c7d YT |
699 | #ifdef HAVE_WINDOWS_H |
700 | #ifndef WIN32_LEAN_AND_MEAN | |
701 | #define WIN32_LEAN_AND_MEAN | |
702 | #endif | |
703 | #include <windows.h> | |
704 | #ifdef HAVE_WINSOCK2_H | |
705 | #include <winsock2.h> | |
706 | #else | |
707 | #ifdef HAVE_WINSOCK_H | |
708 | #include <winsock.h> | |
709 | #endif | |
710 | #endif | |
0a4bba56 | 711 | #define RECVCALLCONV PASCAL |
bc2f0c7d | 712 | #else |
01fa02d0 YT |
713 | #ifdef HAVE_SYS_TYPES_H |
714 | #include <sys/types.h> | |
715 | #endif | |
716 | #ifdef HAVE_SYS_SOCKET_H | |
717 | #include <sys/socket.h> | |
bc2f0c7d | 718 | #endif |
0a4bba56 | 719 | #define RECVCALLCONV |
01fa02d0 | 720 | #endif |
0a4bba56 | 721 | extern $recv_retv RECVCALLCONV recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4); |
01fa02d0 YT |
722 | ],[ |
723 | $recv_arg1 s=0; | |
724 | $recv_arg2 buf=0; | |
725 | $recv_arg3 len=0; | |
726 | $recv_arg4 flags=0; | |
727 | $recv_retv res = recv(s, buf, len, flags); | |
728 | ]) | |
729 | ],[ | |
730 | curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv" | |
731 | break 5 | |
732 | ]) | |
733 | done | |
734 | done | |
735 | done | |
736 | done | |
737 | done | |
738 | ]) # AC_CACHE_CHECK | |
739 | if test "$curl_cv_func_recv_args" = "unknown"; then | |
740 | AC_MSG_WARN([Cannot find proper types to use for recv args]) | |
741 | AC_MSG_WARN([HAVE_RECV will not be defined]) | |
742 | else | |
743 | recv_prev_IFS=$IFS; IFS=',' | |
744 | set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'` | |
745 | IFS=$recv_prev_IFS | |
746 | shift | |
747 | # | |
748 | AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1], | |
749 | [Define to the type of arg 1 for recv.]) | |
750 | AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2], | |
751 | [Define to the type of arg 2 for recv.]) | |
752 | AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3], | |
753 | [Define to the type of arg 3 for recv.]) | |
754 | AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4], | |
755 | [Define to the type of arg 4 for recv.]) | |
756 | AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5], | |
757 | [Define to the function return type for recv.]) | |
758 | # | |
759 | AC_DEFINE_UNQUOTED(HAVE_RECV, 1, | |
760 | [Define to 1 if you have the recv function.]) | |
761 | ac_cv_func_recv="yes" | |
762 | fi | |
763 | fi | |
764 | ]) # AC_DEFUN | |
765 | ||
766 | ||
767 | dnl CURL_CHECK_FUNC_SEND | |
768 | dnl ------------------------------------------------- | |
769 | dnl Test if the socket send() function is available, | |
770 | dnl and check its return type and the types of its | |
771 | dnl arguments. If the function succeeds HAVE_SEND | |
772 | dnl will be defined, defining the types of the arguments | |
773 | dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3 | |
774 | dnl and SEND_TYPE_ARG4, defining the type of the function | |
7e43d06b YT |
775 | dnl return value in SEND_TYPE_RETV, and also defining the |
776 | dnl type qualifier of second argument in SEND_QUAL_ARG2. | |
01fa02d0 YT |
777 | |
778 | AC_DEFUN([CURL_CHECK_FUNC_SEND], [ | |
bc2f0c7d YT |
779 | AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl |
780 | AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl | |
8ef454dc | 781 | AC_CHECK_HEADERS(sys/types.h sys/socket.h) |
01fa02d0 YT |
782 | # |
783 | AC_MSG_CHECKING([for send]) | |
784 | AC_TRY_LINK([ | |
bc2f0c7d YT |
785 | #undef inline |
786 | #ifdef HAVE_WINDOWS_H | |
787 | #ifndef WIN32_LEAN_AND_MEAN | |
788 | #define WIN32_LEAN_AND_MEAN | |
789 | #endif | |
790 | #include <windows.h> | |
791 | #ifdef HAVE_WINSOCK2_H | |
792 | #include <winsock2.h> | |
793 | #else | |
794 | #ifdef HAVE_WINSOCK_H | |
795 | #include <winsock.h> | |
796 | #endif | |
797 | #endif | |
798 | #else | |
01fa02d0 YT |
799 | #ifdef HAVE_SYS_TYPES_H |
800 | #include <sys/types.h> | |
801 | #endif | |
802 | #ifdef HAVE_SYS_SOCKET_H | |
803 | #include <sys/socket.h> | |
bc2f0c7d | 804 | #endif |
01fa02d0 YT |
805 | #endif |
806 | ],[ | |
807 | send(0, 0, 0, 0); | |
808 | ],[ | |
809 | AC_MSG_RESULT([yes]) | |
810 | curl_cv_send="yes" | |
811 | ],[ | |
812 | AC_MSG_RESULT([no]) | |
813 | curl_cv_send="no" | |
814 | ]) | |
815 | # | |
816 | if test "$curl_cv_send" = "yes"; then | |
817 | AC_CACHE_CHECK([types of arguments and return type for send], | |
818 | [curl_cv_func_send_args], [ | |
819 | curl_cv_func_send_args="unknown" | |
820 | for send_retv in 'int' 'ssize_t'; do | |
0a4bba56 | 821 | for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do |
7e43d06b | 822 | for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do |
0a4bba56 | 823 | for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do |
01fa02d0 YT |
824 | for send_arg4 in 'int' 'unsigned int'; do |
825 | AC_COMPILE_IFELSE([ | |
826 | AC_LANG_PROGRAM([ | |
827 | #undef inline | |
bc2f0c7d YT |
828 | #ifdef HAVE_WINDOWS_H |
829 | #ifndef WIN32_LEAN_AND_MEAN | |
830 | #define WIN32_LEAN_AND_MEAN | |
831 | #endif | |
832 | #include <windows.h> | |
833 | #ifdef HAVE_WINSOCK2_H | |
834 | #include <winsock2.h> | |
835 | #else | |
836 | #ifdef HAVE_WINSOCK_H | |
837 | #include <winsock.h> | |
838 | #endif | |
839 | #endif | |
0a4bba56 | 840 | #define SENDCALLCONV PASCAL |
bc2f0c7d | 841 | #else |
01fa02d0 YT |
842 | #ifdef HAVE_SYS_TYPES_H |
843 | #include <sys/types.h> | |
844 | #endif | |
845 | #ifdef HAVE_SYS_SOCKET_H | |
846 | #include <sys/socket.h> | |
bc2f0c7d | 847 | #endif |
0a4bba56 | 848 | #define SENDCALLCONV |
01fa02d0 | 849 | #endif |
0a4bba56 | 850 | extern $send_retv SENDCALLCONV send($send_arg1, $send_arg2, $send_arg3, $send_arg4); |
01fa02d0 YT |
851 | ],[ |
852 | $send_arg1 s=0; | |
01fa02d0 YT |
853 | $send_arg3 len=0; |
854 | $send_arg4 flags=0; | |
7e43d06b | 855 | $send_retv res = send(s, 0, len, flags); |
01fa02d0 YT |
856 | ]) |
857 | ],[ | |
858 | curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv" | |
859 | break 5 | |
860 | ]) | |
861 | done | |
862 | done | |
863 | done | |
864 | done | |
865 | done | |
866 | ]) # AC_CACHE_CHECK | |
867 | if test "$curl_cv_func_send_args" = "unknown"; then | |
868 | AC_MSG_WARN([Cannot find proper types to use for send args]) | |
869 | AC_MSG_WARN([HAVE_SEND will not be defined]) | |
870 | else | |
871 | send_prev_IFS=$IFS; IFS=',' | |
872 | set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'` | |
873 | IFS=$send_prev_IFS | |
874 | shift | |
875 | # | |
7e43d06b YT |
876 | send_qual_type_arg2=$[2] |
877 | # | |
01fa02d0 YT |
878 | AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1], |
879 | [Define to the type of arg 1 for send.]) | |
01fa02d0 YT |
880 | AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3], |
881 | [Define to the type of arg 3 for send.]) | |
882 | AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4], | |
883 | [Define to the type of arg 4 for send.]) | |
884 | AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5], | |
885 | [Define to the function return type for send.]) | |
886 | # | |
55329b56 | 887 | prev_sh_opts=$- |
7e43d06b | 888 | # |
55329b56 | 889 | case $prev_sh_opts in |
7e43d06b YT |
890 | *f*) |
891 | ;; | |
892 | *) | |
893 | set -f | |
894 | ;; | |
895 | esac | |
896 | # | |
897 | case "$send_qual_type_arg2" in | |
898 | const*) | |
899 | send_qual_arg2=const | |
900 | send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'` | |
901 | ;; | |
902 | *) | |
903 | send_qual_arg2= | |
904 | send_type_arg2=$send_qual_type_arg2 | |
905 | ;; | |
906 | esac | |
907 | # | |
908 | AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2, | |
909 | [Define to the type qualifier of arg 2 for send.]) | |
910 | AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2, | |
911 | [Define to the type of arg 2 for send.]) | |
912 | # | |
55329b56 | 913 | case $prev_sh_opts in |
7e43d06b YT |
914 | *f*) |
915 | ;; | |
916 | *) | |
917 | set +f | |
918 | ;; | |
919 | esac | |
920 | # | |
01fa02d0 YT |
921 | AC_DEFINE_UNQUOTED(HAVE_SEND, 1, |
922 | [Define to 1 if you have the send function.]) | |
923 | ac_cv_func_send="yes" | |
924 | fi | |
925 | fi | |
926 | ]) # AC_DEFUN | |
927 | ||
928 | ||
77b3bc23 YT |
929 | dnl CURL_CHECK_MSG_NOSIGNAL |
930 | dnl ------------------------------------------------- | |
931 | dnl Check for MSG_NOSIGNAL | |
932 | ||
933 | AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [ | |
934 | AC_CHECK_HEADERS(sys/types.h sys/socket.h) | |
935 | AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [ | |
936 | AC_COMPILE_IFELSE([ | |
937 | AC_LANG_PROGRAM([ | |
938 | #ifdef HAVE_SYS_TYPES_H | |
939 | #include <sys/types.h> | |
940 | #endif | |
941 | #ifdef HAVE_SYS_SOCKET_H | |
942 | #include <sys/socket.h> | |
943 | #endif | |
944 | ],[ | |
945 | int flag=MSG_NOSIGNAL; | |
946 | ]) | |
947 | ],[ | |
948 | ac_cv_msg_nosignal="yes" | |
949 | ],[ | |
950 | ac_cv_msg_nosignal="no" | |
951 | ]) | |
952 | ]) | |
953 | case "$ac_cv_msg_nosignal" in | |
954 | yes) | |
955 | AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1, | |
956 | [Define to 1 if you have the MSG_NOSIGNAL flag.]) | |
957 | ;; | |
958 | esac | |
959 | ]) # AC_DEFUN | |
960 | ||
961 | ||
74ed5b5e YT |
962 | dnl CURL_CHECK_NONBLOCKING_SOCKET |
963 | dnl ------------------------------------------------- | |
6ca45bea DS |
964 | dnl Check for how to set a socket to non-blocking state. There seems to exist |
965 | dnl four known different ways, with the one used almost everywhere being POSIX | |
966 | dnl and XPG3, while the other different ways for different systems (old BSD, | |
967 | dnl Windows and Amiga). | |
968 | dnl | |
969 | dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the | |
970 | dnl O_NONBLOCK define is found but does not work. This condition is attempted | |
971 | dnl to get caught in this script by using an excessive number of #ifdefs... | |
972 | dnl | |
4c70c3e8 | 973 | AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], |
6ca45bea DS |
974 | [ |
975 | AC_MSG_CHECKING([non-blocking sockets style]) | |
976 | ||
977 | AC_TRY_COMPILE([ | |
978 | /* headers for O_NONBLOCK test */ | |
979 | #include <sys/types.h> | |
980 | #include <unistd.h> | |
981 | #include <fcntl.h> | |
982 | ],[ | |
983 | /* try to compile O_NONBLOCK */ | |
984 | ||
985 | #if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) | |
986 | # if defined(__SVR4) || defined(__srv4__) | |
987 | # define PLATFORM_SOLARIS | |
988 | # else | |
989 | # define PLATFORM_SUNOS4 | |
990 | # endif | |
991 | #endif | |
992 | #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX4) | |
993 | # define PLATFORM_AIX_V3 | |
994 | #endif | |
995 | ||
bf20ed59 | 996 | #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__) |
6ca45bea DS |
997 | #error "O_NONBLOCK does not work on this platform" |
998 | #endif | |
999 | int socket; | |
1000 | int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK); | |
1001 | ],[ | |
1002 | dnl the O_NONBLOCK test was fine | |
1003 | nonblock="O_NONBLOCK" | |
b9c60df0 | 1004 | AC_DEFINE(HAVE_O_NONBLOCK, 1, [use O_NONBLOCK for non-blocking sockets]) |
6ca45bea DS |
1005 | ],[ |
1006 | dnl the code was bad, try a different program now, test 2 | |
1007 | ||
1008 | AC_TRY_COMPILE([ | |
1009 | /* headers for FIONBIO test */ | |
1010 | #include <unistd.h> | |
1011 | #include <stropts.h> | |
1012 | ],[ | |
0bbe184f DS |
1013 | /* FIONBIO source test (old-style unix) */ |
1014 | int socket; | |
6ca45bea DS |
1015 | int flags = ioctl(socket, FIONBIO, &flags); |
1016 | ],[ | |
1017 | dnl FIONBIO test was good | |
1018 | nonblock="FIONBIO" | |
b9c60df0 | 1019 | AC_DEFINE(HAVE_FIONBIO, 1, [use FIONBIO for non-blocking sockets]) |
6ca45bea DS |
1020 | ],[ |
1021 | dnl FIONBIO test was also bad | |
1022 | dnl the code was bad, try a different program now, test 3 | |
1023 | ||
1024 | AC_TRY_COMPILE([ | |
74ed5b5e YT |
1025 | /* headers for ioctlsocket test (Windows) */ |
1026 | #undef inline | |
1027 | #ifdef HAVE_WINDOWS_H | |
1028 | #ifndef WIN32_LEAN_AND_MEAN | |
1029 | #define WIN32_LEAN_AND_MEAN | |
1030 | #endif | |
6ca45bea | 1031 | #include <windows.h> |
74ed5b5e YT |
1032 | #ifdef HAVE_WINSOCK2_H |
1033 | #include <winsock2.h> | |
1034 | #else | |
1035 | #ifdef HAVE_WINSOCK_H | |
1036 | #include <winsock.h> | |
1037 | #endif | |
1038 | #endif | |
1039 | #endif | |
6ca45bea DS |
1040 | ],[ |
1041 | /* ioctlsocket source code */ | |
df2b1251 YT |
1042 | SOCKET sd; |
1043 | unsigned long flags = 0; | |
1044 | sd = socket(0, 0, 0); | |
1045 | ioctlsocket(sd, FIONBIO, &flags); | |
6ca45bea DS |
1046 | ],[ |
1047 | dnl ioctlsocket test was good | |
1048 | nonblock="ioctlsocket" | |
b9c60df0 | 1049 | AC_DEFINE(HAVE_IOCTLSOCKET, 1, [use ioctlsocket() for non-blocking sockets]) |
6ca45bea | 1050 | ],[ |
0bbe184f | 1051 | dnl ioctlsocket didnt compile!, go to test 4 |
6ca45bea | 1052 | |
0bbe184f | 1053 | AC_TRY_LINK([ |
6ca45bea DS |
1054 | /* headers for IoctlSocket test (Amiga?) */ |
1055 | #include <sys/ioctl.h> | |
1056 | ],[ | |
1057 | /* IoctlSocket source code */ | |
0bbe184f | 1058 | int socket; |
6ca45bea DS |
1059 | int flags = IoctlSocket(socket, FIONBIO, (long)1); |
1060 | ],[ | |
1061 | dnl ioctlsocket test was good | |
1062 | nonblock="IoctlSocket" | |
b9c60df0 | 1063 | AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, [use Ioctlsocket() for non-blocking sockets]) |
6ca45bea | 1064 | ],[ |
0bbe184f DS |
1065 | dnl Ioctlsocket didnt compile, do test 5! |
1066 | AC_TRY_COMPILE([ | |
1067 | /* headers for SO_NONBLOCK test (BeOS) */ | |
58f4af79 | 1068 | #include <socket.h> |
0bbe184f DS |
1069 | ],[ |
1070 | /* SO_NONBLOCK source code */ | |
1071 | long b = 1; | |
1072 | int socket; | |
1073 | int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b)); | |
1074 | ],[ | |
1075 | dnl the SO_NONBLOCK test was good | |
1076 | nonblock="SO_NONBLOCK" | |
1077 | AC_DEFINE(HAVE_SO_NONBLOCK, 1, [use SO_NONBLOCK for non-blocking sockets]) | |
1078 | ],[ | |
1079 | dnl test 5 didnt compile! | |
6ca45bea | 1080 | nonblock="nada" |
b9c60df0 | 1081 | AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, [disabled non-blocking sockets]) |
0bbe184f DS |
1082 | ]) |
1083 | dnl end of fifth test | |
1084 | ||
6ca45bea DS |
1085 | ]) |
1086 | dnl end of forth test | |
1087 | ||
1088 | ]) | |
1089 | dnl end of third test | |
1090 | ||
1091 | ]) | |
1092 | dnl end of second test | |
1093 | ||
1094 | ]) | |
1095 | dnl end of non-blocking try-compile test | |
1096 | AC_MSG_RESULT($nonblock) | |
1097 | ||
1098 | if test "$nonblock" = "nada"; then | |
1099 | AC_MSG_WARN([non-block sockets disabled]) | |
1100 | fi | |
1101 | ]) | |
1102 | ||
74ed5b5e | 1103 | |
74ed5b5e YT |
1104 | dnl TYPE_IN_ADDR_T |
1105 | dnl ------------------------------------------------- | |
d09b4369 | 1106 | dnl Check for in_addr_t: it is used to receive the return code of inet_addr() |
ef355196 | 1107 | dnl and a few other things. |
d09b4369 DS |
1108 | AC_DEFUN([TYPE_IN_ADDR_T], |
1109 | [ | |
1110 | AC_CHECK_TYPE([in_addr_t], ,[ | |
1111 | AC_MSG_CHECKING([for in_addr_t equivalent]) | |
1112 | AC_CACHE_VAL([curl_cv_in_addr_t_equiv], | |
1113 | [ | |
d09b4369 | 1114 | curl_cv_in_addr_t_equiv= |
de9b76ce | 1115 | for t in "unsigned long" int size_t unsigned long; do |
820de919 | 1116 | AC_TRY_COMPILE([ |
74ed5b5e YT |
1117 | #undef inline |
1118 | #ifdef HAVE_WINDOWS_H | |
1119 | #ifndef WIN32_LEAN_AND_MEAN | |
1120 | #define WIN32_LEAN_AND_MEAN | |
1121 | #endif | |
1122 | #include <windows.h> | |
1123 | #ifdef HAVE_WINSOCK2_H | |
1124 | #include <winsock2.h> | |
1125 | #else | |
1126 | #ifdef HAVE_WINSOCK_H | |
1127 | #include <winsock.h> | |
1128 | #endif | |
1129 | #endif | |
1130 | #else | |
1131 | #ifdef HAVE_SYS_TYPES_H | |
1132 | #include <sys/types.h> | |
1133 | #endif | |
1134 | #ifdef HAVE_SYS_SOCKET_H | |
1135 | #include <sys/socket.h> | |
1136 | #endif | |
1137 | #ifdef HAVE_NETINET_IN_H | |
1138 | #include <netinet/in.h> | |
1139 | #endif | |
f4481685 YT |
1140 | #ifdef HAVE_ARPA_INET_H |
1141 | #include <arpa/inet.h> | |
1142 | #endif | |
74ed5b5e | 1143 | #endif |
820de919 DS |
1144 | ],[ |
1145 | $t data = inet_addr ("1.2.3.4"); | |
1146 | ],[ | |
1147 | curl_cv_in_addr_t_equiv="$t" | |
1148 | break | |
1149 | ]) | |
d09b4369 DS |
1150 | done |
1151 | ||
1152 | if test "x$curl_cv_in_addr_t_equiv" = x; then | |
1153 | AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t]) | |
1154 | fi | |
1155 | ]) | |
1156 | AC_MSG_RESULT($curl_cv_in_addr_t_equiv) | |
1157 | AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv, | |
1158 | [type to use in place of in_addr_t if not defined])], | |
74ed5b5e YT |
1159 | [ |
1160 | #undef inline | |
1161 | #ifdef HAVE_WINDOWS_H | |
1162 | #ifndef WIN32_LEAN_AND_MEAN | |
1163 | #define WIN32_LEAN_AND_MEAN | |
1164 | #endif | |
1165 | #include <windows.h> | |
1166 | #ifdef HAVE_WINSOCK2_H | |
1167 | #include <winsock2.h> | |
1168 | #else | |
1169 | #ifdef HAVE_WINSOCK_H | |
1170 | #include <winsock.h> | |
1171 | #endif | |
1172 | #endif | |
1173 | #else | |
1174 | #ifdef HAVE_SYS_TYPES_H | |
1175 | #include <sys/types.h> | |
1176 | #endif | |
1177 | #ifdef HAVE_SYS_SOCKET_H | |
d2203896 | 1178 | #include <sys/socket.h> |
74ed5b5e YT |
1179 | #endif |
1180 | #ifdef HAVE_NETINET_IN_H | |
1181 | #include <netinet/in.h> | |
1182 | #endif | |
f4481685 YT |
1183 | #ifdef HAVE_ARPA_INET_H |
1184 | #include <arpa/inet.h> | |
1185 | #endif | |
74ed5b5e | 1186 | #endif |
6de67a13 DS |
1187 | ]) dnl AC_CHECK_TYPE |
1188 | ]) dnl AC_DEFUN | |
d09b4369 | 1189 | |
a1cec0e4 DS |
1190 | dnl ************************************************************ |
1191 | dnl check for "localhost", if it doesn't exist, we can't do the | |
1192 | dnl gethostbyname_r tests! | |
1193 | dnl | |
1194 | ||
4c70c3e8 | 1195 | AC_DEFUN([CURL_CHECK_WORKING_RESOLVER],[ |
a1cec0e4 DS |
1196 | AC_MSG_CHECKING([if "localhost" resolves]) |
1197 | AC_TRY_RUN([ | |
1198 | #include <string.h> | |
1199 | #include <sys/types.h> | |
1200 | #include <netdb.h> | |
1201 | ||
1202 | int | |
1203 | main () { | |
1204 | struct hostent *h; | |
1205 | h = gethostbyname("localhost"); | |
1206 | exit (h == NULL ? 1 : 0); }],[ | |
1207 | AC_MSG_RESULT(yes)],[ | |
1208 | AC_MSG_RESULT(no) | |
1209 | AC_MSG_ERROR([can't figure out gethostbyname_r() since localhost doesn't resolve]) | |
1210 | ||
1211 | ] | |
1212 | ) | |
1213 | ]) | |
1214 | ||
1215 | dnl ************************************************************ | |
07e58aaa | 1216 | dnl check for working getaddrinfo() that works with AI_NUMERICHOST |
a1cec0e4 | 1217 | dnl |
4c70c3e8 | 1218 | AC_DEFUN([CURL_CHECK_WORKING_GETADDRINFO],[ |
a1cec0e4 DS |
1219 | AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[ |
1220 | AC_TRY_RUN( [ | |
1221 | #include <netdb.h> | |
1222 | #include <sys/types.h> | |
1223 | #include <sys/socket.h> | |
1224 | ||
a2ea0abf DS |
1225 | int main(void) |
1226 | { | |
a1cec0e4 DS |
1227 | struct addrinfo hints, *ai; |
1228 | int error; | |
1229 | ||
1230 | memset(&hints, 0, sizeof(hints)); | |
07e58aaa | 1231 | hints.ai_flags = AI_NUMERICHOST; |
a1cec0e4 DS |
1232 | hints.ai_family = AF_UNSPEC; |
1233 | hints.ai_socktype = SOCK_STREAM; | |
1234 | error = getaddrinfo("127.0.0.1", "8080", &hints, &ai); | |
1235 | if (error) { | |
a2ea0abf | 1236 | return 1; |
a1cec0e4 | 1237 | } |
a2ea0abf | 1238 | return 0; |
a1cec0e4 DS |
1239 | } |
1240 | ],[ | |
1241 | ac_cv_working_getaddrinfo="yes" | |
1242 | ],[ | |
1243 | ac_cv_working_getaddrinfo="no" | |
1244 | ],[ | |
1245 | ac_cv_working_getaddrinfo="yes" | |
1246 | ])]) | |
1247 | if test "$ac_cv_working_getaddrinfo" = "yes"; then | |
1248 | AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works]) | |
1249 | AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support]) | |
1250 | ||
1251 | IPV6_ENABLED=1 | |
1252 | AC_SUBST(IPV6_ENABLED) | |
1253 | fi | |
1254 | ]) | |
1255 | ||
1256 | ||
4c70c3e8 | 1257 | AC_DEFUN([CURL_CHECK_LOCALTIME_R], |
a1cec0e4 | 1258 | [ |
242be557 | 1259 | dnl check for localtime_r |
a1cec0e4 DS |
1260 | AC_CHECK_FUNCS(localtime_r,[ |
1261 | AC_MSG_CHECKING(whether localtime_r is declared) | |
1262 | AC_EGREP_CPP(localtime_r,[ | |
1263 | #include <time.h>],[ | |
1264 | AC_MSG_RESULT(yes)],[ | |
1265 | AC_MSG_RESULT(no) | |
1266 | AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared) | |
1267 | AC_EGREP_CPP(localtime_r,[ | |
1268 | #define _REENTRANT | |
1269 | #include <time.h>],[ | |
1270 | AC_DEFINE(NEED_REENTRANT) | |
1271 | AC_MSG_RESULT(yes)], | |
1272 | AC_MSG_RESULT(no))])]) | |
1273 | ]) | |
1274 | ||
7461592a DS |
1275 | dnl |
1276 | dnl This function checks for strerror_r(). If it isn't found at first, it | |
1277 | dnl retries with _THREAD_SAFE defined, as that is what AIX seems to require | |
1278 | dnl in order to find this function. | |
1279 | dnl | |
1280 | dnl If the function is found, it will then proceed to check how the function | |
1281 | dnl actually works: glibc-style or POSIX-style. | |
1282 | dnl | |
1283 | dnl glibc: | |
1284 | dnl char *strerror_r(int errnum, char *buf, size_t n); | |
1285 | dnl | |
1286 | dnl What this one does is to return the error string (no surprises there), | |
1287 | dnl but it doesn't usually copy anything into buf! The 'buf' and 'n' | |
1288 | dnl parameters are only meant as an optional working area, in case strerror_r | |
1289 | dnl needs it. A quick test on a few systems shows that it's generally not | |
1290 | dnl touched at all. | |
1291 | dnl | |
1292 | dnl POSIX: | |
1293 | dnl int strerror_r(int errnum, char *buf, size_t n); | |
1294 | dnl | |
242be557 DS |
1295 | AC_DEFUN([CURL_CHECK_STRERROR_R], |
1296 | [ | |
b9e5302f DS |
1297 | AC_CHECK_FUNCS(strerror_r) |
1298 | ||
1299 | if test "x$ac_cv_func_strerror_r" = "xyes"; then | |
1300 | ||
242be557 DS |
1301 | AC_MSG_CHECKING(whether strerror_r is declared) |
1302 | AC_EGREP_CPP(strerror_r,[ | |
1303 | #include <string.h>],[ | |
1304 | AC_MSG_RESULT(yes)],[ | |
1305 | AC_MSG_RESULT(no) | |
b9e5302f | 1306 | AC_MSG_CHECKING(whether strerror_r with -D_REENTRANT is declared) |
242be557 | 1307 | AC_EGREP_CPP(strerror_r,[ |
b9e5302f | 1308 | #define _REENTRANT |
242be557 | 1309 | #include <string.h>],[ |
b9e5302f | 1310 | CPPFLAGS="-D_REENTRANT $CPPFLAGS" |
242be557 | 1311 | AC_MSG_RESULT(yes)], |
b9e5302f DS |
1312 | AC_MSG_RESULT(no) |
1313 | AC_DEFINE(HAVE_NO_STRERROR_R_DECL, 1, [we have no strerror_r() proto]) | |
1314 | ) dnl with _THREAD_SAFE | |
1315 | ]) dnl plain cpp for it | |
6f74820c | 1316 | |
7461592a DS |
1317 | dnl determine if this strerror_r() is glibc or POSIX |
1318 | AC_MSG_CHECKING([for a glibc strerror_r API]) | |
1319 | AC_TRY_RUN([ | |
1320 | #include <string.h> | |
1321 | #include <errno.h> | |
1322 | int | |
1323 | main () { | |
1324 | char buffer[1024]; /* big enough to play with */ | |
1325 | char *string = | |
1326 | strerror_r(EACCES, buffer, sizeof(buffer)); | |
1327 | /* this should've returned a string */ | |
1328 | if(!string || !string[0]) | |
1329 | return 99; | |
1330 | return 0; | |
1331 | } | |
1332 | ], | |
18dd8154 | 1333 | GLIBC_STRERROR_R="1" |
7461592a DS |
1334 | AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()]) |
1335 | AC_MSG_RESULT([yes]), | |
18dd8154 | 1336 | AC_MSG_RESULT([no]), |
b37a0b05 DF |
1337 | |
1338 | dnl Use an inferior method of strerror_r detection while cross-compiling | |
1339 | AC_EGREP_CPP(yes, [ | |
1340 | #include <features.h> | |
1341 | #ifdef __GLIBC__ | |
1342 | yes | |
1343 | #endif | |
1344 | ], | |
1345 | dnl looks like glibc, so assume a glibc-style strerror_r() | |
1346 | GLIBC_STRERROR_R="1" | |
1347 | AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()]) | |
1348 | AC_MSG_RESULT([yes]), | |
1349 | AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!]) | |
1350 | ) dnl while cross-compiling | |
18dd8154 | 1351 | ) |
7461592a | 1352 | |
18dd8154 DS |
1353 | if test -z "$GLIBC_STRERROR_R"; then |
1354 | ||
1355 | AC_MSG_CHECKING([for a POSIX strerror_r API]) | |
1356 | AC_TRY_RUN([ | |
7461592a DS |
1357 | #include <string.h> |
1358 | #include <errno.h> | |
1359 | int | |
1360 | main () { | |
1361 | char buffer[1024]; /* big enough to play with */ | |
1362 | int error = | |
1363 | strerror_r(EACCES, buffer, sizeof(buffer)); | |
1364 | /* This should've returned zero, and written an error string in the | |
1365 | buffer.*/ | |
1366 | if(!buffer[0] || error) | |
1367 | return 99; | |
1368 | return 0; | |
1369 | } | |
1370 | ], | |
18dd8154 DS |
1371 | AC_DEFINE(HAVE_POSIX_STRERROR_R, 1, [we have a POSIX-style strerror_r()]) |
1372 | AC_MSG_RESULT([yes]), | |
1373 | AC_MSG_RESULT([no]) , | |
1374 | dnl cross-compiling! | |
1375 | AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!]) | |
1376 | ) | |
7461592a | 1377 | |
18dd8154 DS |
1378 | fi dnl if not using glibc API |
1379 | ||
1380 | fi dnl we have a strerror_r | |
7461592a | 1381 | |
242be557 DS |
1382 | ]) |
1383 | ||
4c70c3e8 | 1384 | AC_DEFUN([CURL_CHECK_INET_NTOA_R], |
a1cec0e4 DS |
1385 | [ |
1386 | dnl determine if function definition for inet_ntoa_r exists. | |
1387 | AC_CHECK_FUNCS(inet_ntoa_r,[ | |
1388 | AC_MSG_CHECKING(whether inet_ntoa_r is declared) | |
1389 | AC_EGREP_CPP(inet_ntoa_r,[ | |
1390 | #include <arpa/inet.h>],[ | |
b9c60df0 | 1391 | AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared]) |
a1cec0e4 DS |
1392 | AC_MSG_RESULT(yes)],[ |
1393 | AC_MSG_RESULT(no) | |
1394 | AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared) | |
1395 | AC_EGREP_CPP(inet_ntoa_r,[ | |
1396 | #define _REENTRANT | |
1397 | #include <arpa/inet.h>],[ | |
b9c60df0 DS |
1398 | AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared]) |
1399 | AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT defined]) | |
a1cec0e4 DS |
1400 | AC_MSG_RESULT(yes)], |
1401 | AC_MSG_RESULT(no))])]) | |
a1cec0e4 DS |
1402 | ]) |
1403 | ||
4c70c3e8 | 1404 | AC_DEFUN([CURL_CHECK_GETHOSTBYADDR_R], |
a1cec0e4 DS |
1405 | [ |
1406 | dnl check for number of arguments to gethostbyaddr_r. it might take | |
1407 | dnl either 5, 7, or 8 arguments. | |
1408 | AC_CHECK_FUNCS(gethostbyaddr_r,[ | |
1409 | AC_MSG_CHECKING(if gethostbyaddr_r takes 5 arguments) | |
1410 | AC_TRY_COMPILE([ | |
1411 | #include <sys/types.h> | |
1412 | #include <netdb.h>],[ | |
1413 | char * address; | |
1414 | int length; | |
1415 | int type; | |
1416 | struct hostent h; | |
1417 | struct hostent_data hdata; | |
1418 | int rc; | |
1419 | rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[ | |
1420 | AC_MSG_RESULT(yes) | |
b9c60df0 | 1421 | AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args]) |
a1cec0e4 DS |
1422 | ac_cv_gethostbyaddr_args=5],[ |
1423 | AC_MSG_RESULT(no) | |
1424 | AC_MSG_CHECKING(if gethostbyaddr_r with -D_REENTRANT takes 5 arguments) | |
1425 | AC_TRY_COMPILE([ | |
1426 | #define _REENTRANT | |
1427 | #include <sys/types.h> | |
1428 | #include <netdb.h>],[ | |
1429 | char * address; | |
1430 | int length; | |
1431 | int type; | |
1432 | struct hostent h; | |
1433 | struct hostent_data hdata; | |
1434 | int rc; | |
1435 | rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[ | |
1436 | AC_MSG_RESULT(yes) | |
b9c60df0 DS |
1437 | AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args]) |
1438 | AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT]) | |
a1cec0e4 DS |
1439 | ac_cv_gethostbyaddr_args=5],[ |
1440 | AC_MSG_RESULT(no) | |
1441 | AC_MSG_CHECKING(if gethostbyaddr_r takes 7 arguments) | |
1442 | AC_TRY_COMPILE([ | |
1443 | #include <sys/types.h> | |
1444 | #include <netdb.h>],[ | |
1445 | char * address; | |
1446 | int length; | |
1447 | int type; | |
1448 | struct hostent h; | |
1449 | char buffer[8192]; | |
1450 | int h_errnop; | |
1451 | struct hostent * hp; | |
1452 | ||
1453 | hp = gethostbyaddr_r(address, length, type, &h, | |
1454 | buffer, 8192, &h_errnop);],[ | |
1455 | AC_MSG_RESULT(yes) | |
b9c60df0 | 1456 | AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args] ) |
a1cec0e4 DS |
1457 | ac_cv_gethostbyaddr_args=7],[ |
1458 | AC_MSG_RESULT(no) | |
1459 | AC_MSG_CHECKING(if gethostbyaddr_r takes 8 arguments) | |
1460 | AC_TRY_COMPILE([ | |
1461 | #include <sys/types.h> | |
1462 | #include <netdb.h>],[ | |
1463 | char * address; | |
1464 | int length; | |
1465 | int type; | |
1466 | struct hostent h; | |
1467 | char buffer[8192]; | |
1468 | int h_errnop; | |
1469 | struct hostent * hp; | |
1470 | int rc; | |
1471 | ||
1472 | rc = gethostbyaddr_r(address, length, type, &h, | |
1473 | buffer, 8192, &hp, &h_errnop);],[ | |
1474 | AC_MSG_RESULT(yes) | |
b9c60df0 | 1475 | AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args]) |
a1cec0e4 DS |
1476 | ac_cv_gethostbyaddr_args=8],[ |
1477 | AC_MSG_RESULT(no) | |
1478 | have_missing_r_funcs="$have_missing_r_funcs gethostbyaddr_r"])])])])]) | |
a1cec0e4 DS |
1479 | ]) |
1480 | ||
4c70c3e8 | 1481 | AC_DEFUN([CURL_CHECK_GETHOSTBYNAME_R], |
a1cec0e4 DS |
1482 | [ |
1483 | dnl check for number of arguments to gethostbyname_r. it might take | |
1484 | dnl either 3, 5, or 6 arguments. | |
1485 | AC_CHECK_FUNCS(gethostbyname_r,[ | |
c3363f83 DS |
1486 | AC_MSG_CHECKING([if gethostbyname_r takes 3 arguments]) |
1487 | AC_TRY_COMPILE([ | |
a1cec0e4 DS |
1488 | #include <string.h> |
1489 | #include <sys/types.h> | |
1490 | #include <netdb.h> | |
6ebac3dc DS |
1491 | #undef NULL |
1492 | #define NULL (void *)0 | |
a1cec0e4 DS |
1493 | |
1494 | int | |
c3363f83 | 1495 | gethostbyname_r(const char *, struct hostent *, struct hostent_data *);],[ |
325391ae | 1496 | struct hostent_data data; |
c3363f83 | 1497 | gethostbyname_r(NULL, NULL, NULL);],[ |
a1cec0e4 | 1498 | AC_MSG_RESULT(yes) |
b9c60df0 | 1499 | AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args]) |
a1cec0e4 DS |
1500 | ac_cv_gethostbyname_args=3],[ |
1501 | AC_MSG_RESULT(no) | |
c3363f83 DS |
1502 | AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 3 arguments]) |
1503 | AC_TRY_COMPILE([ | |
a1cec0e4 DS |
1504 | #define _REENTRANT |
1505 | ||
1506 | #include <string.h> | |
1507 | #include <sys/types.h> | |
1508 | #include <netdb.h> | |
6ebac3dc DS |
1509 | #undef NULL |
1510 | #define NULL (void *)0 | |
a1cec0e4 DS |
1511 | |
1512 | int | |
c3363f83 | 1513 | gethostbyname_r(const char *,struct hostent *, struct hostent_data *);],[ |
325391ae | 1514 | struct hostent_data data; |
c3363f83 | 1515 | gethostbyname_r(NULL, NULL, NULL);],[ |
a1cec0e4 | 1516 | AC_MSG_RESULT(yes) |
b9c60df0 DS |
1517 | AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args]) |
1518 | AC_DEFINE(NEED_REENTRANT, 1, [needs REENTRANT]) | |
a1cec0e4 DS |
1519 | ac_cv_gethostbyname_args=3],[ |
1520 | AC_MSG_RESULT(no) | |
c3363f83 DS |
1521 | AC_MSG_CHECKING([if gethostbyname_r takes 5 arguments]) |
1522 | AC_TRY_COMPILE([ | |
a1cec0e4 DS |
1523 | #include <sys/types.h> |
1524 | #include <netdb.h> | |
6ebac3dc DS |
1525 | #undef NULL |
1526 | #define NULL (void *)0 | |
a1cec0e4 | 1527 | |
c3363f83 DS |
1528 | struct hostent * |
1529 | gethostbyname_r(const char *, struct hostent *, char *, int, int *);],[ | |
1530 | gethostbyname_r(NULL, NULL, NULL, 0, NULL);],[ | |
a1cec0e4 | 1531 | AC_MSG_RESULT(yes) |
b9c60df0 | 1532 | AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args]) |
a1cec0e4 DS |
1533 | ac_cv_gethostbyname_args=5],[ |
1534 | AC_MSG_RESULT(no) | |
c3363f83 DS |
1535 | AC_MSG_CHECKING([if gethostbyname_r takes 6 arguments]) |
1536 | AC_TRY_COMPILE([ | |
a1cec0e4 DS |
1537 | #include <sys/types.h> |
1538 | #include <netdb.h> | |
6ebac3dc DS |
1539 | #undef NULL |
1540 | #define NULL (void *)0 | |
a1cec0e4 DS |
1541 | |
1542 | int | |
c3363f83 DS |
1543 | gethostbyname_r(const char *, struct hostent *, char *, size_t, |
1544 | struct hostent **, int *);],[ | |
1545 | gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);],[ | |
a1cec0e4 | 1546 | AC_MSG_RESULT(yes) |
b9c60df0 | 1547 | AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args]) |
a1cec0e4 DS |
1548 | ac_cv_gethostbyname_args=6],[ |
1549 | AC_MSG_RESULT(no) | |
1550 | have_missing_r_funcs="$have_missing_r_funcs gethostbyname_r"], | |
1551 | [ac_cv_gethostbyname_args=0])], | |
1552 | [ac_cv_gethostbyname_args=0])], | |
1553 | [ac_cv_gethostbyname_args=0])], | |
1554 | [ac_cv_gethostbyname_args=0])]) | |
1555 | ||
1556 | if test "$ac_cv_func_gethostbyname_r" = "yes"; then | |
1557 | if test "$ac_cv_gethostbyname_args" = "0"; then | |
1558 | dnl there's a gethostbyname_r() function, but we don't know how | |
1559 | dnl many arguments it wants! | |
1560 | AC_MSG_ERROR([couldn't figure out how to use gethostbyname_r()]) | |
1561 | fi | |
1562 | fi | |
1563 | ]) | |
4fa58560 | 1564 | |
2645782f | 1565 | |
2df622fd DS |
1566 | dnl ********************************************************************** |
1567 | dnl CURL_DETECT_ICC ([ACTION-IF-YES]) | |
1568 | dnl | |
1569 | dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES | |
1570 | dnl sets the $ICC variable to "yes" or "no" | |
1571 | dnl ********************************************************************** | |
1572 | AC_DEFUN([CURL_DETECT_ICC], | |
1573 | [ | |
1574 | ICC="no" | |
1575 | AC_MSG_CHECKING([for icc in use]) | |
1576 | if test "$GCC" = "yes"; then | |
1577 | dnl check if this is icc acting as gcc in disguise | |
1578 | AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER], | |
1579 | dnl action if the text is found, this it has not been replaced by the | |
1580 | dnl cpp | |
1581 | ICC="no", | |
1582 | dnl the text was not found, it was replaced by the cpp | |
1583 | ICC="yes" | |
1584 | AC_MSG_RESULT([yes]) | |
1585 | [$1] | |
1586 | ) | |
1587 | fi | |
1588 | if test "$ICC" = "no"; then | |
1589 | # this is not ICC | |
1590 | AC_MSG_RESULT([no]) | |
1591 | fi | |
1592 | ]) | |
1593 | ||
4fa58560 DS |
1594 | dnl We create a function for detecting which compiler we use and then set as |
1595 | dnl pendantic compiler options as possible for that particular compiler. The | |
1596 | dnl options are only used for debug-builds. | |
1597 | ||
1598 | AC_DEFUN([CURL_CC_DEBUG_OPTS], | |
1599 | [ | |
2df622fd DS |
1600 | if test "z$ICC" = "z"; then |
1601 | CURL_DETECT_ICC | |
1602 | fi | |
1603 | ||
4fa58560 DS |
1604 | if test "$GCC" = "yes"; then |
1605 | ||
1606 | dnl figure out gcc version! | |
1607 | AC_MSG_CHECKING([gcc version]) | |
1608 | gccver=`$CC -dumpversion` | |
1609 | num1=`echo $gccver | cut -d . -f1` | |
1610 | num2=`echo $gccver | cut -d . -f2` | |
1611 | gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null` | |
1612 | AC_MSG_RESULT($gccver) | |
1613 | ||
4fa58560 DS |
1614 | if test "$ICC" = "yes"; then |
1615 | dnl this is icc, not gcc. | |
6bd2de0c | 1616 | |
85af357d | 1617 | dnl ICC warnings we ignore: |
85af357d DS |
1618 | dnl * 269 warns on our "%Od" printf formatters for curl_off_t output: |
1619 | dnl "invalid format string conversion" | |
78e0ba82 DS |
1620 | dnl * 279 warns on static conditions in while expressions |
1621 | dnl * 981 warns on "operands are evaluated in unspecified order" | |
bde6c668 | 1622 | dnl * 1418 "external definition with no prior declaration" |
7e6043f0 DS |
1623 | dnl * 1419 warns on "external declaration in primary source file" |
1624 | dnl which we know and do on purpose. | |
6bd2de0c | 1625 | |
55c015c1 | 1626 | WARN="-wd279,269,981,1418,1419" |
6bd2de0c DS |
1627 | |
1628 | if test "$gccnum" -gt "600"; then | |
85af357d | 1629 | dnl icc 6.0 and older doesn't have the -Wall flag |
6bd2de0c DS |
1630 | WARN="-Wall $WARN" |
1631 | fi | |
4fa58560 | 1632 | else dnl $ICC = yes |
6789dfc5 | 1633 | dnl this is a set of options we believe *ALL* gcc versions support: |
38181fbc | 1634 | WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes" |
4fa58560 | 1635 | |
6789dfc5 DS |
1636 | dnl -Wcast-align is a bit too annoying on all gcc versions ;-) |
1637 | ||
38181fbc | 1638 | if test "$gccnum" -ge "207"; then |
0e591829 DF |
1639 | dnl gcc 2.7 or later |
1640 | WARN="$WARN -Wmissing-declarations" | |
38181fbc DF |
1641 | fi |
1642 | ||
6789dfc5 DS |
1643 | if test "$gccnum" -gt "295"; then |
1644 | dnl only if the compiler is newer than 2.95 since we got lots of | |
1645 | dnl "`_POSIX_C_SOURCE' is not defined" in system headers with | |
1646 | dnl gcc 2.95.4 on FreeBSD 4.9! | |
0e591829 | 1647 | WARN="$WARN -Wundef -Wno-long-long -Wsign-compare" |
6789dfc5 | 1648 | fi |
4fa58560 DS |
1649 | |
1650 | if test "$gccnum" -ge "296"; then | |
1651 | dnl gcc 2.96 or later | |
1652 | WARN="$WARN -Wfloat-equal" | |
6789dfc5 DS |
1653 | fi |
1654 | ||
1655 | if test "$gccnum" -gt "296"; then | |
1656 | dnl this option does not exist in 2.96 | |
1657 | WARN="$WARN -Wno-format-nonliteral" | |
1658 | fi | |
4fa58560 | 1659 | |
6789dfc5 | 1660 | dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on |
c7b7bf32 DS |
1661 | dnl on i686-Linux as it gives us heaps with false positives. |
1662 | dnl Also, on gcc 4.0.X it is totally unbearable and complains all | |
1663 | dnl over making it unusable for generic purposes. Let's not use it. | |
1664 | ||
6789dfc5 DS |
1665 | if test "$gccnum" -ge "303"; then |
1666 | dnl gcc 3.3 and later | |
1667 | WARN="$WARN -Wendif-labels -Wstrict-prototypes" | |
4fa58560 DS |
1668 | fi |
1669 | ||
aae521d0 | 1670 | if test "$gccnum" -ge "304"; then |
e81d4ac8 | 1671 | # try these on gcc 3.4 |
c7b7bf32 | 1672 | WARN="$WARN -Wdeclaration-after-statement" |
aae521d0 DS |
1673 | fi |
1674 | ||
4fa58560 DS |
1675 | for flag in $CPPFLAGS; do |
1676 | case "$flag" in | |
1677 | -I*) | |
6789dfc5 DS |
1678 | dnl Include path, provide a -isystem option for the same dir |
1679 | dnl to prevent warnings in those dirs. The -isystem was not very | |
1680 | dnl reliable on earlier gcc versions. | |
4fa58560 | 1681 | add=`echo $flag | sed 's/^-I/-isystem /g'` |
6bd2de0c | 1682 | WARN="$WARN $add" |
4fa58560 DS |
1683 | ;; |
1684 | esac | |
1685 | done | |
1686 | ||
4fa58560 DS |
1687 | fi dnl $ICC = no |
1688 | ||
6bd2de0c DS |
1689 | CFLAGS="$CFLAGS $WARN" |
1690 | ||
193a652e DS |
1691 | AC_MSG_NOTICE([Added this set of compiler options: $WARN]) |
1692 | ||
1693 | else dnl $GCC = yes | |
1694 | ||
1695 | AC_MSG_NOTICE([Added no extra compiler options]) | |
1696 | ||
4fa58560 DS |
1697 | fi dnl $GCC = yes |
1698 | ||
1699 | dnl strip off optimizer flags | |
1700 | NEWFLAGS="" | |
1701 | for flag in $CFLAGS; do | |
1702 | case "$flag" in | |
1703 | -O*) | |
1704 | dnl echo "cut off $flag" | |
1705 | ;; | |
1706 | *) | |
1707 | NEWFLAGS="$NEWFLAGS $flag" | |
1708 | ;; | |
1709 | esac | |
1710 | done | |
1711 | CFLAGS=$NEWFLAGS | |
1712 | ||
1713 | ]) dnl end of AC_DEFUN() | |
1714 | ||
205f8b26 DF |
1715 | |
1716 | dnl Determine the name of the library to pass to dlopen() based on the name | |
1717 | dnl that would normally be given to AC_CHECK_LIB. The preprocessor symbol | |
1718 | dnl given is set to the quoted library file name. | |
1719 | dnl The standard dynamic library file name is first generated, based on the | |
1720 | dnl current system type, then a search is performed for that file on the | |
1721 | dnl standard dynamic library path. If it is a symbolic link, the destination | |
1722 | dnl of the link is used as the file name, after stripping off any minor | |
1723 | dnl version numbers. If a library file can't be found, a guess is made. | |
1724 | dnl This macro assumes AC_PROG_LIBTOOL has been called and requires perl | |
228e6274 | 1725 | dnl to be available in the PATH, or $PERL to be set to its location. |
205f8b26 DF |
1726 | dnl |
1727 | dnl CURL_DLLIB_NAME(VARIABLE, library_name) | |
1728 | dnl e.g. CURL_DLLIB_NAME(LDAP_NAME, ldap) on a Linux system might result | |
1729 | dnl in LDAP_NAME holding the string "libldap.so.2". | |
1730 | ||
1731 | AC_DEFUN([CURL_DLLIB_NAME], | |
1732 | [ | |
1733 | AC_MSG_CHECKING([name of dynamic library $2]) | |
1f68fa19 DF |
1734 | dnl The shared library extension variable name changes from version to |
1735 | dnl version of libtool. Try a few names then just set one statically. | |
b5112096 | 1736 | test -z "$shared_ext" && shared_ext="$shrext_cmds" |
1f68fa19 DF |
1737 | test -z "$shared_ext" && shared_ext="$shrext" |
1738 | test -z "$shared_ext" && shared_ext=".so" | |
205f8b26 | 1739 | |
1f68fa19 | 1740 | dnl Create the library link name of the correct form for this platform |
228e6274 | 1741 | LIBNAME_LINK_SPEC=`echo "$library_names_spec" | $SED 's/^.* //'` |
205f8b26 | 1742 | DLGUESSLIB=`name=$2 eval echo "$libname_spec"` |
228e6274 | 1743 | DLGUESSFILE=`libname="$DLGUESSLIB" release="" major="" versuffix="" eval echo "$LIBNAME_LINK_SPEC"` |
205f8b26 | 1744 | |
1f68fa19 DF |
1745 | dnl Synthesize a likely dynamic library name in case we can't find an actual one |
1746 | SO_NAME_SPEC="$soname_spec" | |
1747 | dnl soname_spec undefined when identical to the 1st entry in library_names_spec | |
1748 | test -z "$SO_NAME_SPEC" && SO_NAME_SPEC=`echo "$library_names_spec" | $SED 's/ .*$//'` | |
1749 | DLGUESSSOFILE=`libname="$DLGUESSLIB" release="" major="" versuffix="" eval echo "$SO_NAME_SPEC"` | |
1750 | ||
205f8b26 DF |
1751 | if test "$cross_compiling" = yes; then |
1752 | dnl Can't look at filesystem when cross-compiling | |
1f68fa19 DF |
1753 | AC_DEFINE_UNQUOTED($1, "$DLGUESSSOFILE", [$2 dynamic library file]) |
1754 | AC_MSG_RESULT([$DLGUESSSOFILE (guess while cross-compiling)]) | |
205f8b26 DF |
1755 | else |
1756 | ||
1757 | DLFOUNDFILE="" | |
1758 | if test "$sys_lib_dlsearch_path_spec" ; then | |
228e6274 | 1759 | dnl Search for the link library name and see what it points to. |
205f8b26 DF |
1760 | for direc in $sys_lib_dlsearch_path_spec ; do |
1761 | DLTRYFILE="$direc/$DLGUESSFILE" | |
1762 | dnl Find where the symbolic link for this name points | |
1763 | changequote(<<, >>)dnl | |
1764 | << | |
228e6274 | 1765 | DLFOUNDFILE=`${PERL:-perl} -e 'use File::Basename; (basename(readlink($ARGV[0])) =~ /^(.*[^\d]\.\d+)[\d\.]*$/ && print ${1}) || exit 1;' "$DLTRYFILE" 2>&5` |
205f8b26 DF |
1766 | >> |
1767 | changequote([, ])dnl | |
1768 | if test "$?" -eq "0"; then | |
1769 | dnl Found the file link | |
1770 | break | |
1771 | fi | |
1772 | done | |
1773 | fi | |
1774 | ||
1775 | if test -z "$DLFOUNDFILE" ; then | |
1f68fa19 DF |
1776 | dnl Couldn't find a link library, so guess at a name. |
1777 | DLFOUNDFILE="$DLGUESSSOFILE" | |
205f8b26 DF |
1778 | fi |
1779 | ||
1780 | AC_DEFINE_UNQUOTED($1, "$DLFOUNDFILE", [$2 dynamic library file]) | |
1781 | AC_MSG_RESULT($DLFOUNDFILE) | |
1782 | fi | |
1783 | ]) | |
65afc576 DS |
1784 | |
1785 | # This is only a temporary fix. This macro is here to replace the broken one | |
1786 | # delivered by the automake project (including the 1.9.6 release). As soon as | |
1787 | # they ship a working version we SHOULD remove this work-around. | |
1788 | ||
1789 | AC_DEFUN([AM_MISSING_HAS_RUN], | |
1790 | [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl | |
1791 | test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\"" | |
1792 | # Use eval to expand $SHELL | |
1793 | if eval "$MISSING --run true"; then | |
1794 | am_missing_run="$MISSING --run " | |
1795 | else | |
1796 | am_missing_run= | |
1797 | AC_MSG_WARN([`missing' script is too old or missing]) | |
1798 | fi | |
1799 | ]) |