Refactor how libraries are checked for connect() function,
[platform/upstream/curl.git] / acinclude.m4
1 #***************************************************************************
2 #                                  _   _ ____  _
3 #  Project                     ___| | | |  _ \| |
4 #                             / __| | | | |_) | |
5 #                            | (__| |_| |  _ <| |___
6 #                             \___|\___/|_| \_\_____|
7 #
8 # Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
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 #***************************************************************************
23
24
25 dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
26 dnl -------------------------------------------------
27 dnl Use the C preprocessor to find out if the given object-style symbol
28 dnl is defined and get its expansion. This macro will not use default
29 dnl includes even if no INCLUDES argument is given. This macro will run
30 dnl silently when invoked with three arguments. If the expansion would
31 dnl result in a set of double-quoted strings the returned expansion will
32 dnl actually be a single double-quoted string concatenating all them.
33
34 AC_DEFUN([CURL_CHECK_DEF], [
35   AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
36   AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
37   if test -z "$SED"; then
38     AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
39   fi
40   if test -z "$GREP"; then
41     AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
42   fi
43   ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
44   tmp_exp=""
45   AC_PREPROC_IFELSE([
46     AC_LANG_SOURCE(
47 ifelse($2,,,[$2])[[
48 #ifdef $1
49 CURL_DEF_TOKEN $1
50 #endif
51     ]])
52   ],[
53     tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
54       "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
55       "$SED" 's/.*CURL_DEF_TOKEN[[ ]]//' 2>/dev/null | \
56       "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
57     if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
58       tmp_exp=""
59     fi
60   ])
61   if test -z "$tmp_exp"; then
62     AS_VAR_SET(ac_HaveDef, no)
63     ifelse($3,,[AC_MSG_RESULT([no])])
64   else
65     AS_VAR_SET(ac_HaveDef, yes)
66     AS_VAR_SET(ac_Def, $tmp_exp)
67     ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
68   fi
69   AS_VAR_POPDEF([ac_Def])dnl
70   AS_VAR_POPDEF([ac_HaveDef])dnl
71 ])
72
73
74 dnl CURL_CHECK_DEF_CC (SYMBOL, [INCLUDES], [SILENT])
75 dnl -------------------------------------------------
76 dnl Use the C compiler to find out only if the given symbol is defined
77 dnl or not, this can not find out its expansion. This macro will not use
78 dnl default includes even if no INCLUDES argument is given. This macro
79 dnl will run silently when invoked with three arguments.
80
81 AC_DEFUN([CURL_CHECK_DEF_CC], [
82   AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
83   ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
84   AC_COMPILE_IFELSE([
85     AC_LANG_SOURCE(
86 ifelse($2,,,[$2])[[
87 int main (void)
88 {
89 #ifdef $1
90   return 0;
91 #else
92   force compilation error
93 #endif
94 }
95     ]])
96   ],[
97     tst_symbol_defined="yes"
98   ],[
99     tst_symbol_defined="no"
100   ])
101   if test "$tst_symbol_defined" = "yes"; then
102     AS_VAR_SET(ac_HaveDef, yes)
103     ifelse($3,,[AC_MSG_RESULT([yes])])
104   else
105     AS_VAR_SET(ac_HaveDef, no)
106     ifelse($3,,[AC_MSG_RESULT([no])])
107   fi
108   AS_VAR_POPDEF([ac_HaveDef])dnl
109 ])
110
111
112 dnl CURL_CHECK_LIB_XNET
113 dnl -------------------------------------------------
114 dnl Verify if X/Open network library is required.
115
116 AC_DEFUN([CURL_CHECK_LIB_XNET], [
117   AC_MSG_CHECKING([if X/Open network library is required])
118   tst_lib_xnet_required="no"
119   AC_COMPILE_IFELSE([
120     AC_LANG_SOURCE([[
121 int main (void)
122 {
123 #if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
124   return 0;
125 #elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
126   return 0;
127 #else
128   force compilation error
129 #endif
130 }
131     ]])
132   ],[
133     tst_lib_xnet_required="yes"
134     LIBS="$LIBS -lxnet"
135   ])
136   AC_MSG_RESULT([$tst_lib_xnet_required])
137 ])
138
139
140 dnl CURL_CHECK_AIX_ALL_SOURCE
141 dnl -------------------------------------------------
142 dnl Provides a replacement of traditional AC_AIX with
143 dnl an uniform behaviour across all autoconf versions,
144 dnl and with our own placement rules.
145
146 AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
147   AH_VERBATIM([_ALL_SOURCE],
148     [/* Define to 1 if OS is AIX. */
149 #ifndef _ALL_SOURCE
150 #  undef _ALL_SOURCE
151 #endif])
152   AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
153   AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
154   AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
155   AC_EGREP_CPP([yes_this_is_aix],[
156 #ifdef _AIX
157    yes_this_is_aix
158 #endif
159   ],[
160     AC_MSG_RESULT([yes])
161     AC_DEFINE(_ALL_SOURCE)
162   ],[
163     AC_MSG_RESULT([no])
164   ])
165 ])
166
167
168 dnl CURL_CHECK_HEADER_WINDOWS
169 dnl -------------------------------------------------
170 dnl Check for compilable and valid windows.h header 
171
172 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
173   AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
174     AC_COMPILE_IFELSE([
175       AC_LANG_PROGRAM([[
176 #undef inline
177 #ifndef WIN32_LEAN_AND_MEAN
178 #define WIN32_LEAN_AND_MEAN
179 #endif
180 #include <windows.h>
181       ]],[[
182 #if defined(__CYGWIN__) || defined(__CEGCC__)
183         HAVE_WINDOWS_H shall not be defined.
184 #else
185         int dummy=2*WINVER;
186 #endif
187       ]])
188     ],[
189       ac_cv_header_windows_h="yes"
190     ],[
191       ac_cv_header_windows_h="no"
192     ])
193   ])
194   case "$ac_cv_header_windows_h" in
195     yes)
196       AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
197         [Define to 1 if you have the windows.h header file.])
198       AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
199         [Define to avoid automatic inclusion of winsock.h])
200       ;;
201   esac
202 ])
203
204
205 dnl CURL_CHECK_NATIVE_WINDOWS
206 dnl -------------------------------------------------
207 dnl Check if building a native Windows target
208
209 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
210   AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
211   AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
212     if test "$ac_cv_header_windows_h" = "no"; then
213       ac_cv_native_windows="no"
214     else
215       AC_COMPILE_IFELSE([
216         AC_LANG_PROGRAM([[
217         ]],[[
218 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
219    (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
220           int dummy=1;
221 #else
222           Not a native Windows build target.
223 #endif
224         ]])
225       ],[
226         ac_cv_native_windows="yes"
227       ],[
228         ac_cv_native_windows="no"
229       ])
230     fi
231   ])
232   case "$ac_cv_native_windows" in
233     yes)
234       AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
235         [Define to 1 if you are building a native Windows target.])
236       ;;
237   esac
238 ])
239
240
241 dnl CURL_CHECK_HEADER_WINSOCK
242 dnl -------------------------------------------------
243 dnl Check for compilable and valid winsock.h header 
244
245 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
246   AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
247   AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
248     AC_COMPILE_IFELSE([
249       AC_LANG_PROGRAM([[
250 #undef inline
251 #ifndef WIN32_LEAN_AND_MEAN
252 #define WIN32_LEAN_AND_MEAN
253 #endif
254 #include <windows.h>
255 #include <winsock.h>
256       ]],[[
257 #if defined(__CYGWIN__) || defined(__CEGCC__)
258         HAVE_WINSOCK_H shall not be defined.
259 #else
260         int dummy=WSACleanup();
261 #endif
262       ]])
263     ],[
264       ac_cv_header_winsock_h="yes"
265     ],[
266       ac_cv_header_winsock_h="no"
267     ])
268   ])
269   case "$ac_cv_header_winsock_h" in
270     yes)
271       AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
272         [Define to 1 if you have the winsock.h header file.])
273       ;;
274   esac
275 ])
276
277
278 dnl CURL_CHECK_HEADER_WINSOCK2
279 dnl -------------------------------------------------
280 dnl Check for compilable and valid winsock2.h header 
281
282 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
283   AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
284   AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
285     AC_COMPILE_IFELSE([
286       AC_LANG_PROGRAM([[
287 #undef inline
288 #ifndef WIN32_LEAN_AND_MEAN
289 #define WIN32_LEAN_AND_MEAN
290 #endif
291 #include <windows.h>
292 #include <winsock2.h>
293       ]],[[
294 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
295         HAVE_WINSOCK2_H shall not be defined.
296 #else
297         int dummy=2*IPPROTO_ESP;
298 #endif
299       ]])
300     ],[
301       ac_cv_header_winsock2_h="yes"
302     ],[
303       ac_cv_header_winsock2_h="no"
304     ])
305   ])
306   case "$ac_cv_header_winsock2_h" in
307     yes)
308       AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
309         [Define to 1 if you have the winsock2.h header file.])
310       ;;
311   esac
312 ])
313
314
315 dnl CURL_CHECK_HEADER_WS2TCPIP
316 dnl -------------------------------------------------
317 dnl Check for compilable and valid ws2tcpip.h header
318
319 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
320   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
321   AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
322     AC_COMPILE_IFELSE([
323       AC_LANG_PROGRAM([[
324 #undef inline
325 #ifndef WIN32_LEAN_AND_MEAN
326 #define WIN32_LEAN_AND_MEAN
327 #endif
328 #include <windows.h>
329 #include <winsock2.h>
330 #include <ws2tcpip.h>
331       ]],[[
332 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
333         HAVE_WS2TCPIP_H shall not be defined.
334 #else
335         int dummy=2*IP_PKTINFO;
336 #endif
337       ]])
338     ],[
339       ac_cv_header_ws2tcpip_h="yes"
340     ],[
341       ac_cv_header_ws2tcpip_h="no"
342     ])
343   ])
344   case "$ac_cv_header_ws2tcpip_h" in
345     yes)
346       AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
347         [Define to 1 if you have the ws2tcpip.h header file.])
348       ;;
349   esac
350 ])
351
352
353 dnl CURL_CHECK_HEADER_WINLDAP
354 dnl -------------------------------------------------
355 dnl Check for compilable and valid winldap.h header
356
357 AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
358   AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
359   AC_CACHE_CHECK([for winldap.h], [ac_cv_header_winldap_h], [
360     AC_COMPILE_IFELSE([
361       AC_LANG_PROGRAM([[
362 #undef inline
363 #ifdef HAVE_WINDOWS_H
364 #ifndef WIN32_LEAN_AND_MEAN
365 #define WIN32_LEAN_AND_MEAN
366 #endif
367 #include <windows.h>
368 #endif
369 #include <winldap.h>
370       ]],[[
371 #if defined(__CYGWIN__) || defined(__CEGCC__)
372         HAVE_WINLDAP_H shall not be defined.
373 #else
374         LDAP *ldp = ldap_init("dummy", LDAP_PORT);
375         ULONG res = ldap_unbind(ldp);
376 #endif
377       ]])
378     ],[
379       ac_cv_header_winldap_h="yes"
380     ],[
381       ac_cv_header_winldap_h="no"
382     ])
383   ])
384   case "$ac_cv_header_winldap_h" in
385     yes)
386       AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
387         [Define to 1 if you have the winldap.h header file.])
388       ;;
389   esac
390 ])
391
392
393 dnl CURL_CHECK_HEADER_WINBER
394 dnl -------------------------------------------------
395 dnl Check for compilable and valid winber.h header
396
397 AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
398   AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
399   AC_CACHE_CHECK([for winber.h], [ac_cv_header_winber_h], [
400     AC_COMPILE_IFELSE([
401       AC_LANG_PROGRAM([[
402 #undef inline
403 #ifdef HAVE_WINDOWS_H
404 #ifndef WIN32_LEAN_AND_MEAN
405 #define WIN32_LEAN_AND_MEAN
406 #endif
407 #include <windows.h>
408 #endif
409 #include <winldap.h>
410 #include <winber.h>
411       ]],[[
412 #if defined(__CYGWIN__) || defined(__CEGCC__)
413         HAVE_WINBER_H shall not be defined.
414 #else
415         BERVAL *bvp = NULL;
416         BerElement *bep = ber_init(bvp);
417         ber_free(bep, 1);
418 #endif
419       ]])
420     ],[
421       ac_cv_header_winber_h="yes"
422     ],[
423       ac_cv_header_winber_h="no"
424     ])
425   ])
426   case "$ac_cv_header_winber_h" in
427     yes)
428       AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
429         [Define to 1 if you have the winber.h header file.])
430       ;;
431   esac
432 ])
433
434
435 dnl CURL_CHECK_HEADER_LBER
436 dnl -------------------------------------------------
437 dnl Check for compilable and valid lber.h header,
438 dnl and check if it is needed even with ldap.h
439
440 AC_DEFUN([CURL_CHECK_HEADER_LBER], [
441   AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
442   AC_CACHE_CHECK([for lber.h], [ac_cv_header_lber_h], [
443     AC_COMPILE_IFELSE([
444       AC_LANG_PROGRAM([[
445 #undef inline
446 #ifdef HAVE_WINDOWS_H
447 #ifndef WIN32_LEAN_AND_MEAN
448 #define WIN32_LEAN_AND_MEAN
449 #endif
450 #include <windows.h>
451 #else
452 #ifdef HAVE_SYS_TYPES_H
453 #include <sys/types.h>
454 #endif
455 #endif
456 #ifndef NULL
457 #define NULL (void *)0
458 #endif
459 #include <lber.h>
460       ]],[[
461         BerValue *bvp = NULL;
462         BerElement *bep = ber_init(bvp);
463         ber_free(bep, 1);
464       ]])
465     ],[
466       ac_cv_header_lber_h="yes"
467     ],[
468       ac_cv_header_lber_h="no"
469     ])
470   ])
471   if test "$ac_cv_header_lber_h" = "yes"; then
472     AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
473       [Define to 1 if you have the lber.h header file.])
474     #
475     AC_COMPILE_IFELSE([
476       AC_LANG_PROGRAM([[
477 #undef inline
478 #ifdef HAVE_WINDOWS_H
479 #ifndef WIN32_LEAN_AND_MEAN
480 #define WIN32_LEAN_AND_MEAN
481 #endif
482 #include <windows.h>
483 #else
484 #ifdef HAVE_SYS_TYPES_H
485 #include <sys/types.h>
486 #endif
487 #endif
488 #ifndef NULL
489 #define NULL (void *)0
490 #endif
491 #ifndef LDAP_DEPRECATED
492 #define LDAP_DEPRECATED 1
493 #endif
494 #include <ldap.h>
495       ]],[[
496         BerValue *bvp = NULL;
497         BerElement *bep = ber_init(bvp);
498         ber_free(bep, 1);
499       ]])
500     ],[
501       curl_cv_need_header_lber_h="no"
502     ],[
503       curl_cv_need_header_lber_h="yes"
504     ])
505     #
506     case "$curl_cv_need_header_lber_h" in
507       yes)
508         AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
509           [Define to 1 if you need the lber.h header file even with ldap.h])
510         ;;
511     esac
512   fi
513 ])
514
515
516 dnl CURL_CHECK_HEADER_LDAP
517 dnl -------------------------------------------------
518 dnl Check for compilable and valid ldap.h header
519
520 AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
521   AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
522   AC_CACHE_CHECK([for ldap.h], [ac_cv_header_ldap_h], [
523     AC_COMPILE_IFELSE([
524       AC_LANG_PROGRAM([[
525 #undef inline
526 #ifdef HAVE_WINDOWS_H
527 #ifndef WIN32_LEAN_AND_MEAN
528 #define WIN32_LEAN_AND_MEAN
529 #endif
530 #include <windows.h>
531 #else
532 #ifdef HAVE_SYS_TYPES_H
533 #include <sys/types.h>
534 #endif
535 #endif
536 #ifndef LDAP_DEPRECATED
537 #define LDAP_DEPRECATED 1
538 #endif
539 #ifdef NEED_LBER_H
540 #include <lber.h>
541 #endif
542 #include <ldap.h>
543       ]],[[
544         LDAP *ldp = ldap_init("dummy", LDAP_PORT);
545         int res = ldap_unbind(ldp);
546       ]])
547     ],[
548       ac_cv_header_ldap_h="yes"
549     ],[
550       ac_cv_header_ldap_h="no"
551     ])
552   ])
553   case "$ac_cv_header_ldap_h" in
554     yes)
555       AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
556         [Define to 1 if you have the ldap.h header file.])
557       ;;
558   esac
559 ])
560
561
562 dnl CURL_CHECK_HEADER_LDAP_SSL
563 dnl -------------------------------------------------
564 dnl Check for compilable and valid ldap_ssl.h header
565
566 AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
567   AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
568   AC_CACHE_CHECK([for ldap_ssl.h], [ac_cv_header_ldap_ssl_h], [
569     AC_COMPILE_IFELSE([
570       AC_LANG_PROGRAM([[
571 #undef inline
572 #ifdef HAVE_WINDOWS_H
573 #ifndef WIN32_LEAN_AND_MEAN
574 #define WIN32_LEAN_AND_MEAN
575 #endif
576 #include <windows.h>
577 #else
578 #ifdef HAVE_SYS_TYPES_H
579 #include <sys/types.h>
580 #endif
581 #endif
582 #ifndef LDAP_DEPRECATED
583 #define LDAP_DEPRECATED 1
584 #endif
585 #ifdef NEED_LBER_H
586 #include <lber.h>
587 #endif
588 #ifdef HAVE_LDAP_H
589 #include <ldap.h>
590 #endif
591 #include <ldap_ssl.h>
592       ]],[[
593         LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
594       ]])
595     ],[
596       ac_cv_header_ldap_ssl_h="yes"
597     ],[
598       ac_cv_header_ldap_ssl_h="no"
599     ])
600   ])
601   case "$ac_cv_header_ldap_ssl_h" in
602     yes)
603       AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
604         [Define to 1 if you have the ldap_ssl.h header file.])
605       ;;
606   esac
607 ])
608
609
610 dnl CURL_CHECK_HEADER_LDAPSSL
611 dnl -------------------------------------------------
612 dnl Check for compilable and valid ldapssl.h header
613
614 AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
615   AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
616   AC_CACHE_CHECK([for ldapssl.h], [ac_cv_header_ldapssl_h], [
617     AC_COMPILE_IFELSE([
618       AC_LANG_PROGRAM([[
619 #undef inline
620 #ifdef HAVE_WINDOWS_H
621 #ifndef WIN32_LEAN_AND_MEAN
622 #define WIN32_LEAN_AND_MEAN
623 #endif
624 #include <windows.h>
625 #else
626 #ifdef HAVE_SYS_TYPES_H
627 #include <sys/types.h>
628 #endif
629 #endif
630 #ifndef NULL
631 #define NULL (void *)0
632 #endif
633 #ifndef LDAP_DEPRECATED
634 #define LDAP_DEPRECATED 1
635 #endif
636 #ifdef NEED_LBER_H
637 #include <lber.h>
638 #endif
639 #ifdef HAVE_LDAP_H
640 #include <ldap.h>
641 #endif
642 #include <ldapssl.h>
643       ]],[[
644         char *cert_label = NULL;
645         LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
646       ]])
647     ],[
648       ac_cv_header_ldapssl_h="yes"
649     ],[
650       ac_cv_header_ldapssl_h="no"
651     ])
652   ])
653   case "$ac_cv_header_ldapssl_h" in
654     yes)
655       AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
656         [Define to 1 if you have the ldapssl.h header file.])
657       ;;
658   esac
659 ])
660
661
662 dnl CURL_CHECK_LIBS_WINLDAP
663 dnl -------------------------------------------------
664 dnl Check for libraries needed for WINLDAP support,
665 dnl and prepended to LIBS any needed libraries.
666 dnl This macro can take an optional parameter with a
667 dnl white space separated list of libraries to check
668 dnl before the WINLDAP default ones.
669
670 AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
671   AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
672   #
673   AC_MSG_CHECKING([for WINLDAP libraries])
674   #
675   u_libs=""
676   #
677   ifelse($1,,,[
678     for x_lib in $1; do
679       case "$x_lib" in
680         -l*)
681           l_lib="$x_lib"
682           ;;
683         *)
684           l_lib="-l$x_lib"
685           ;;
686       esac
687       if test -z "$u_libs"; then
688         u_libs="$l_lib"
689       else
690         u_libs="$u_libs $l_lib"
691       fi
692     done
693   ])
694   #
695   curl_cv_save_LIBS="$LIBS"
696   curl_cv_ldap_LIBS="unknown"
697   #
698   for x_nlibs in '' "$u_libs" \
699     '-lwldap32' ; do
700     if test "$curl_cv_ldap_LIBS" = "unknown"; then
701       if test -z "$x_nlibs"; then
702         LIBS="$curl_cv_save_LIBS"
703       else
704         LIBS="$x_nlibs $curl_cv_save_LIBS"
705       fi
706       AC_LINK_IFELSE([
707         AC_LANG_PROGRAM([[
708 #undef inline
709 #ifdef HAVE_WINDOWS_H
710 #ifndef WIN32_LEAN_AND_MEAN
711 #define WIN32_LEAN_AND_MEAN
712 #endif
713 #include <windows.h>
714 #ifdef HAVE_WINLDAP_H
715 #include <winldap.h>
716 #endif
717 #ifdef HAVE_WINBER_H
718 #include <winber.h>
719 #endif
720 #endif
721         ]],[[
722           BERVAL *bvp = NULL;
723           BerElement *bep = ber_init(bvp);
724           LDAP *ldp = ldap_init("dummy", LDAP_PORT);
725           ULONG res = ldap_unbind(ldp);
726           ber_free(bep, 1);
727         ]])
728       ],[
729         curl_cv_ldap_LIBS="$x_nlibs"
730       ])
731     fi
732   done
733   #
734   LIBS="$curl_cv_save_LIBS"
735   #
736   case X-"$curl_cv_ldap_LIBS" in
737     X-unknown)
738       AC_MSG_RESULT([cannot find WINLDAP libraries])
739       ;;
740     X-)
741       AC_MSG_RESULT([no additional lib required])
742       ;;
743     *)
744       if test -z "$curl_cv_save_LIBS"; then
745         LIBS="$curl_cv_ldap_LIBS"
746       else
747         LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
748       fi
749       AC_MSG_RESULT([$curl_cv_ldap_LIBS])
750       ;;
751   esac
752   #
753 ])
754
755
756 dnl CURL_CHECK_LIBS_LDAP
757 dnl -------------------------------------------------
758 dnl Check for libraries needed for LDAP support,
759 dnl and prepended to LIBS any needed libraries.
760 dnl This macro can take an optional parameter with a
761 dnl white space separated list of libraries to check
762 dnl before the default ones.
763
764 AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
765   AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
766   #
767   AC_MSG_CHECKING([for LDAP libraries])
768   #
769   u_libs=""
770   #
771   ifelse($1,,,[
772     for x_lib in $1; do
773       case "$x_lib" in
774         -l*)
775           l_lib="$x_lib"
776           ;;
777         *)
778           l_lib="-l$x_lib"
779           ;;
780       esac
781       if test -z "$u_libs"; then
782         u_libs="$l_lib"
783       else
784         u_libs="$u_libs $l_lib"
785       fi
786     done
787   ])
788   #
789   curl_cv_save_LIBS="$LIBS"
790   curl_cv_ldap_LIBS="unknown"
791   #
792   for x_nlibs in '' "$u_libs" \
793     '-lldap' \
794     '-llber -lldap' \
795     '-lldap -llber' \
796     '-lldapssl -lldapx -lldapsdk' \
797     '-lldapsdk -lldapx -lldapssl' ; do
798     if test "$curl_cv_ldap_LIBS" = "unknown"; then
799       if test -z "$x_nlibs"; then
800         LIBS="$curl_cv_save_LIBS"
801       else
802         LIBS="$x_nlibs $curl_cv_save_LIBS"
803       fi
804       AC_LINK_IFELSE([
805         AC_LANG_PROGRAM([[
806 #undef inline
807 #ifdef HAVE_WINDOWS_H
808 #ifndef WIN32_LEAN_AND_MEAN
809 #define WIN32_LEAN_AND_MEAN
810 #endif
811 #include <windows.h>
812 #else
813 #ifdef HAVE_SYS_TYPES_H
814 #include <sys/types.h>
815 #endif
816 #endif
817 #ifndef NULL
818 #define NULL (void *)0
819 #endif
820 #ifndef LDAP_DEPRECATED
821 #define LDAP_DEPRECATED 1
822 #endif
823 #ifdef NEED_LBER_H
824 #include <lber.h>
825 #endif
826 #ifdef HAVE_LDAP_H
827 #include <ldap.h>
828 #endif
829         ]],[[
830           BerValue *bvp = NULL;
831           BerElement *bep = ber_init(bvp);
832           LDAP *ldp = ldap_init("dummy", LDAP_PORT);
833           int res = ldap_unbind(ldp);
834           ber_free(bep, 1);
835         ]])
836       ],[
837         curl_cv_ldap_LIBS="$x_nlibs"
838       ])
839     fi
840   done
841   #
842   LIBS="$curl_cv_save_LIBS"
843   #
844   case X-"$curl_cv_ldap_LIBS" in
845     X-unknown)
846       AC_MSG_RESULT([cannot find LDAP libraries])
847       ;;
848     X-)
849       AC_MSG_RESULT([no additional lib required])
850       ;;
851     *)
852       if test -z "$curl_cv_save_LIBS"; then
853         LIBS="$curl_cv_ldap_LIBS"
854       else
855         LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
856       fi
857       AC_MSG_RESULT([$curl_cv_ldap_LIBS])
858       ;;
859   esac
860   #
861 ])
862
863
864 dnl CURL_CHECK_HEADER_MALLOC
865 dnl -------------------------------------------------
866 dnl Check for compilable and valid malloc.h header,
867 dnl and check if it is needed even with stdlib.h
868
869 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
870   AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
871     AC_COMPILE_IFELSE([
872       AC_LANG_PROGRAM([[
873 #include <malloc.h>
874       ]],[[
875         void *p = malloc(10);
876         void *q = calloc(10,10);
877         free(p);
878         free(q);
879       ]])
880     ],[
881       ac_cv_header_malloc_h="yes"
882     ],[
883       ac_cv_header_malloc_h="no"
884     ])
885   ])
886   if test "$ac_cv_header_malloc_h" = "yes"; then
887     AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
888       [Define to 1 if you have the malloc.h header file.])
889     #
890     AC_COMPILE_IFELSE([
891       AC_LANG_PROGRAM([[
892 #include <stdlib.h>
893       ]],[[
894         void *p = malloc(10);
895         void *q = calloc(10,10);
896         free(p);
897         free(q);
898       ]])
899     ],[
900       curl_cv_need_header_malloc_h="no"
901     ],[
902       curl_cv_need_header_malloc_h="yes"
903     ])
904     #
905     case "$curl_cv_need_header_malloc_h" in
906       yes)
907         AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
908           [Define to 1 if you need the malloc.h header file even with stdlib.h])
909         ;;
910     esac
911   fi
912 ])
913
914
915 dnl CURL_CHECK_HEADER_MEMORY
916 dnl -------------------------------------------------
917 dnl Check for compilable and valid memory.h header,
918 dnl and check if it is needed even with stdlib.h for
919 dnl memory related functions.
920
921 AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
922   AC_CACHE_CHECK([for memory.h], [ac_cv_header_memory_h], [
923     AC_COMPILE_IFELSE([
924       AC_LANG_PROGRAM([[
925 #include <memory.h>
926       ]],[[
927         void *p = malloc(10);
928         void *q = calloc(10,10);
929         free(p);
930         free(q);
931       ]])
932     ],[
933       ac_cv_header_memory_h="yes"
934     ],[
935       ac_cv_header_memory_h="no"
936     ])
937   ])
938   if test "$ac_cv_header_memory_h" = "yes"; then
939     AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1,
940       [Define to 1 if you have the memory.h header file.])
941     #
942     AC_COMPILE_IFELSE([
943       AC_LANG_PROGRAM([[
944 #include <stdlib.h>
945       ]],[[
946         void *p = malloc(10);
947         void *q = calloc(10,10);
948         free(p);
949         free(q);
950       ]])
951     ],[
952       curl_cv_need_header_memory_h="no"
953     ],[
954       curl_cv_need_header_memory_h="yes"
955     ])
956     #
957     case "$curl_cv_need_header_memory_h" in
958       yes)
959         AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1,
960           [Define to 1 if you need the memory.h header file even with stdlib.h])
961         ;;
962     esac
963   fi
964 ])
965
966
967 dnl CURL_CHECK_FUNC_GETNAMEINFO
968 dnl -------------------------------------------------
969 dnl Test if the getnameinfo function is available, 
970 dnl and check the types of five of its arguments.
971 dnl If the function succeeds HAVE_GETNAMEINFO will be
972 dnl defined, defining the types of the arguments in
973 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
974 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
975 dnl and also defining the type qualifier of first 
976 dnl argument in GETNAMEINFO_QUAL_ARG1.
977
978 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
979   AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
980   AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
981   #
982   AC_MSG_CHECKING([for getnameinfo])
983   AC_LINK_IFELSE([
984     AC_LANG_FUNC_LINK_TRY([getnameinfo])
985   ],[
986     AC_MSG_RESULT([yes])
987     curl_cv_getnameinfo="yes"
988   ],[
989     AC_MSG_RESULT([no])
990     curl_cv_getnameinfo="no"
991   ])
992   #
993   if test "$curl_cv_getnameinfo" != "yes"; then
994     AC_MSG_CHECKING([deeper for getnameinfo])
995     AC_LINK_IFELSE([
996       AC_LANG_PROGRAM([[
997       ]],[[
998         getnameinfo();
999       ]])
1000     ],[
1001       AC_MSG_RESULT([yes])
1002       curl_cv_getnameinfo="yes"
1003     ],[
1004       AC_MSG_RESULT([but still no])
1005       curl_cv_getnameinfo="no"
1006     ])
1007   fi
1008   #
1009   if test "$curl_cv_getnameinfo" != "yes"; then
1010     AC_MSG_CHECKING([deeper and deeper for getnameinfo])
1011     AC_LINK_IFELSE([
1012       AC_LANG_PROGRAM([[
1013 #undef inline
1014 #ifdef HAVE_WINDOWS_H
1015 #ifndef WIN32_LEAN_AND_MEAN
1016 #define WIN32_LEAN_AND_MEAN
1017 #endif
1018 #include <windows.h>
1019 #ifdef HAVE_WINSOCK2_H
1020 #include <winsock2.h>
1021 #ifdef HAVE_WS2TCPIP_H
1022 #include <ws2tcpip.h>
1023 #endif
1024 #endif
1025 #else
1026 #ifdef HAVE_SYS_TYPES_H
1027 #include <sys/types.h>
1028 #endif
1029 #ifdef HAVE_SYS_SOCKET_H
1030 #include <sys/socket.h>
1031 #endif
1032 #ifdef HAVE_NETDB_H
1033 #include <netdb.h>
1034 #endif
1035 #endif
1036       ]],[[
1037         getnameinfo(0, 0, 0, 0, 0, 0, 0);
1038       ]])
1039     ],[
1040       AC_MSG_RESULT([yes])
1041       curl_cv_getnameinfo="yes"
1042     ],[
1043       AC_MSG_RESULT([but still no])
1044       curl_cv_getnameinfo="no"
1045     ])
1046   fi
1047   #
1048   if test "$curl_cv_getnameinfo" = "yes"; then
1049     AC_CACHE_CHECK([types of arguments for getnameinfo],
1050       [curl_cv_func_getnameinfo_args], [
1051       curl_cv_func_getnameinfo_args="unknown"
1052       for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
1053         for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
1054           for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
1055             for gni_arg7 in 'int' 'unsigned int'; do
1056               if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1057                 AC_COMPILE_IFELSE([
1058                   AC_LANG_PROGRAM([[
1059 #undef inline 
1060 #ifdef HAVE_WINDOWS_H
1061 #ifndef WIN32_LEAN_AND_MEAN
1062 #define WIN32_LEAN_AND_MEAN
1063 #endif
1064 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
1065 #undef _WIN32_WINNT
1066 #define _WIN32_WINNT 0x0501
1067 #endif
1068 #include <windows.h>
1069 #ifdef HAVE_WINSOCK2_H
1070 #include <winsock2.h> 
1071 #ifdef HAVE_WS2TCPIP_H
1072 #include <ws2tcpip.h>
1073 #endif
1074 #endif
1075 #define GNICALLCONV WSAAPI
1076 #else
1077 #ifdef HAVE_SYS_TYPES_H
1078 #include <sys/types.h>
1079 #endif
1080 #ifdef HAVE_SYS_SOCKET_H
1081 #include <sys/socket.h>
1082 #endif
1083 #ifdef HAVE_NETDB_H
1084 #include <netdb.h>
1085 #endif
1086 #define GNICALLCONV
1087 #endif
1088                     extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
1089                                            char *, $gni_arg46,
1090                                            char *, $gni_arg46,
1091                                            $gni_arg7);
1092                   ]],[[
1093                     $gni_arg2 salen=0;
1094                     $gni_arg46 hostlen=0;
1095                     $gni_arg46 servlen=0;
1096                     $gni_arg7 flags=0;
1097                     int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
1098                   ]])
1099                 ],[
1100                   curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
1101                 ])
1102               fi
1103             done
1104           done
1105         done
1106       done
1107     ]) # AC-CACHE-CHECK
1108     if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1109       AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
1110       AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
1111     else
1112       gni_prev_IFS=$IFS; IFS=','
1113       set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
1114       IFS=$gni_prev_IFS
1115       shift
1116       #
1117       gni_qual_type_arg1=$[1]
1118       #
1119       AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
1120         [Define to the type of arg 2 for getnameinfo.])
1121       AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
1122         [Define to the type of args 4 and 6 for getnameinfo.])
1123       AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
1124         [Define to the type of arg 7 for getnameinfo.])
1125       #
1126       prev_sh_opts=$-
1127       #
1128       case $prev_sh_opts in
1129         *f*)
1130           ;;
1131         *)
1132           set -f
1133           ;;
1134       esac
1135       #
1136       case "$gni_qual_type_arg1" in
1137         const*)
1138           gni_qual_arg1=const
1139           gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
1140         ;;
1141         *)
1142           gni_qual_arg1=
1143           gni_type_arg1=$gni_qual_type_arg1
1144         ;;
1145       esac
1146       #
1147       AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
1148         [Define to the type qualifier of arg 1 for getnameinfo.])
1149       AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
1150         [Define to the type of arg 1 for getnameinfo.])
1151       #
1152       case $prev_sh_opts in
1153         *f*)
1154           ;;
1155         *)
1156           set +f
1157           ;;
1158       esac
1159       #
1160       AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
1161         [Define to 1 if you have the getnameinfo function.])
1162       ac_cv_func_getnameinfo="yes"
1163     fi
1164   fi
1165 ])
1166
1167
1168 dnl TYPE_SOCKADDR_STORAGE
1169 dnl -------------------------------------------------
1170 dnl Check for struct sockaddr_storage. Most IPv6-enabled 
1171 dnl hosts have it, but AIX 4.3 is one known exception.
1172
1173 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
1174 [
1175    AC_CHECK_TYPE([struct sockaddr_storage],
1176         AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
1177                   [if struct sockaddr_storage is defined]), ,
1178    [
1179 #undef inline
1180 #ifdef HAVE_WINDOWS_H
1181 #ifndef WIN32_LEAN_AND_MEAN
1182 #define WIN32_LEAN_AND_MEAN
1183 #endif
1184 #include <windows.h>
1185 #ifdef HAVE_WINSOCK2_H
1186 #include <winsock2.h>
1187 #endif
1188 #else
1189 #ifdef HAVE_SYS_TYPES_H
1190 #include <sys/types.h>
1191 #endif
1192 #ifdef HAVE_SYS_SOCKET_H
1193 #include <sys/socket.h>
1194 #endif
1195 #ifdef HAVE_NETINET_IN_H
1196 #include <netinet/in.h>
1197 #endif
1198 #ifdef HAVE_ARPA_INET_H
1199 #include <arpa/inet.h>
1200 #endif
1201 #endif
1202    ])
1203 ])
1204
1205
1206 dnl CURL_CHECK_NI_WITHSCOPEID
1207 dnl -------------------------------------------------
1208 dnl Check for working NI_WITHSCOPEID in getnameinfo()
1209
1210 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
1211   AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
1212   AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
1213   AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
1214                    netdb.h netinet/in.h arpa/inet.h)
1215   #
1216   AC_CACHE_CHECK([for working NI_WITHSCOPEID], 
1217     [ac_cv_working_ni_withscopeid], [
1218     AC_RUN_IFELSE([
1219       AC_LANG_PROGRAM([[
1220 #ifdef HAVE_STDLIB_H
1221 #include <stdlib.h>
1222 #endif
1223 #ifdef HAVE_STDIO_H
1224 #include <stdio.h>
1225 #endif
1226 #ifdef HAVE_SYS_TYPES_H
1227 #include <sys/types.h>
1228 #endif
1229 #ifdef HAVE_SYS_SOCKET_H
1230 #include <sys/socket.h>
1231 #endif
1232 #ifdef HAVE_NETDB_H
1233 #include <netdb.h>
1234 #endif
1235 #ifdef HAVE_NETINET_IN_H
1236 #include <netinet/in.h>
1237 #endif
1238 #ifdef HAVE_ARPA_INET_H
1239 #include <arpa/inet.h>
1240 #endif
1241       ]],[[
1242 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
1243 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
1244         struct sockaddr_storage sa;
1245 #else
1246         unsigned char sa[256];
1247 #endif
1248         char hostbuf[NI_MAXHOST];
1249         int rc;
1250         GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
1251         GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
1252         GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1253         int fd = socket(AF_INET6, SOCK_STREAM, 0);
1254         if(fd < 0) {
1255           perror("socket()");
1256           return 1; /* Error creating socket */
1257         }
1258         rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
1259         if(rc) {
1260           perror("getsockname()");
1261           return 2; /* Error retrieving socket name */
1262         }
1263         rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
1264         if(rc) {
1265           printf("rc = %s\n", gai_strerror(rc));
1266           return 3; /* Error translating socket address */
1267         }
1268         return 0; /* Ok, NI_WITHSCOPEID works */
1269 #else
1270         return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
1271 #endif
1272       ]]) # AC-LANG-PROGRAM
1273     ],[
1274       # Exit code == 0. Program worked.
1275       ac_cv_working_ni_withscopeid="yes"
1276     ],[
1277       # Exit code != 0. Program failed.
1278       ac_cv_working_ni_withscopeid="no"
1279     ],[
1280       # Program is not run when cross-compiling. So we assume
1281       # NI_WITHSCOPEID will work if we are able to compile it.
1282       AC_COMPILE_IFELSE([
1283         AC_LANG_PROGRAM([[
1284 #include <sys/types.h>
1285 #include <sys/socket.h>
1286 #include <netdb.h>
1287         ]],[[
1288           unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1289         ]])
1290       ],[
1291         ac_cv_working_ni_withscopeid="yes"
1292       ],[
1293         ac_cv_working_ni_withscopeid="no"
1294       ]) # AC-COMPILE-IFELSE
1295     ]) # AC-RUN-IFELSE
1296   ]) # AC-CACHE-CHECK
1297   case "$ac_cv_working_ni_withscopeid" in
1298     yes)
1299       AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
1300         [Define to 1 if NI_WITHSCOPEID exists and works.])
1301       ;;
1302   esac
1303 ])
1304
1305
1306 dnl CURL_CHECK_FUNC_RECV
1307 dnl -------------------------------------------------
1308 dnl Test if the socket recv() function is available, 
1309 dnl and check its return type and the types of its 
1310 dnl arguments. If the function succeeds HAVE_RECV 
1311 dnl will be defined, defining the types of the arguments 
1312 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3 
1313 dnl and RECV_TYPE_ARG4, defining the type of the function
1314 dnl return value in RECV_TYPE_RETV.
1315
1316 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
1317   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1318   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1319   AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1320   #
1321   AC_MSG_CHECKING([for recv])
1322   AC_LINK_IFELSE([
1323     AC_LANG_PROGRAM([[
1324 #undef inline 
1325 #ifdef HAVE_WINDOWS_H
1326 #ifndef WIN32_LEAN_AND_MEAN
1327 #define WIN32_LEAN_AND_MEAN
1328 #endif
1329 #include <windows.h>
1330 #ifdef HAVE_WINSOCK2_H
1331 #include <winsock2.h>
1332 #else
1333 #ifdef HAVE_WINSOCK_H
1334 #include <winsock.h>
1335 #endif
1336 #endif
1337 #else
1338 #ifdef HAVE_SYS_TYPES_H
1339 #include <sys/types.h>
1340 #endif
1341 #ifdef HAVE_SYS_SOCKET_H
1342 #include <sys/socket.h>
1343 #endif
1344 #endif
1345     ]],[[
1346       recv(0, 0, 0, 0);
1347     ]])
1348   ],[
1349     AC_MSG_RESULT([yes])
1350     curl_cv_recv="yes"
1351   ],[
1352     AC_MSG_RESULT([no])
1353     curl_cv_recv="no"
1354   ])
1355   #
1356   if test "$curl_cv_recv" = "yes"; then
1357     AC_CACHE_CHECK([types of args and return type for recv],
1358       [curl_cv_func_recv_args], [
1359       curl_cv_func_recv_args="unknown"
1360       for recv_retv in 'int' 'ssize_t'; do
1361         for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1362           for recv_arg2 in 'char *' 'void *'; do
1363             for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1364               for recv_arg4 in 'int' 'unsigned int'; do
1365                 if test "$curl_cv_func_recv_args" = "unknown"; then
1366                   AC_COMPILE_IFELSE([
1367                     AC_LANG_PROGRAM([[
1368 #undef inline 
1369 #ifdef HAVE_WINDOWS_H
1370 #ifndef WIN32_LEAN_AND_MEAN
1371 #define WIN32_LEAN_AND_MEAN
1372 #endif
1373 #include <windows.h>
1374 #ifdef HAVE_WINSOCK2_H
1375 #include <winsock2.h>
1376 #else
1377 #ifdef HAVE_WINSOCK_H
1378 #include <winsock.h>
1379 #endif
1380 #endif
1381 #define RECVCALLCONV PASCAL
1382 #else
1383 #ifdef HAVE_SYS_TYPES_H
1384 #include <sys/types.h>
1385 #endif
1386 #ifdef HAVE_SYS_SOCKET_H
1387 #include <sys/socket.h>
1388 #endif
1389 #define RECVCALLCONV
1390 #endif
1391                       extern $recv_retv RECVCALLCONV
1392                       recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
1393                     ]],[[
1394                       $recv_arg1 s=0;
1395                       $recv_arg2 buf=0;
1396                       $recv_arg3 len=0;
1397                       $recv_arg4 flags=0;
1398                       $recv_retv res = recv(s, buf, len, flags);
1399                     ]])
1400                   ],[
1401                     curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
1402                   ])
1403                 fi
1404               done
1405             done
1406           done
1407         done
1408       done
1409     ]) # AC-CACHE-CHECK
1410     if test "$curl_cv_func_recv_args" = "unknown"; then
1411       AC_MSG_ERROR([Cannot find proper types to use for recv args])
1412     else
1413       recv_prev_IFS=$IFS; IFS=','
1414       set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
1415       IFS=$recv_prev_IFS
1416       shift
1417       #
1418       AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
1419         [Define to the type of arg 1 for recv.])
1420       AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
1421         [Define to the type of arg 2 for recv.])
1422       AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
1423         [Define to the type of arg 3 for recv.])
1424       AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
1425         [Define to the type of arg 4 for recv.])
1426       AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
1427         [Define to the function return type for recv.])
1428       #
1429       AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
1430         [Define to 1 if you have the recv function.])
1431       ac_cv_func_recv="yes"
1432     fi
1433   else
1434     AC_MSG_ERROR([Unable to link function recv])
1435   fi
1436 ])
1437
1438
1439 dnl CURL_CHECK_FUNC_SEND
1440 dnl -------------------------------------------------
1441 dnl Test if the socket send() function is available, 
1442 dnl and check its return type and the types of its 
1443 dnl arguments. If the function succeeds HAVE_SEND 
1444 dnl will be defined, defining the types of the arguments 
1445 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3 
1446 dnl and SEND_TYPE_ARG4, defining the type of the function
1447 dnl return value in SEND_TYPE_RETV, and also defining the 
1448 dnl type qualifier of second argument in SEND_QUAL_ARG2.
1449
1450 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
1451   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1452   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1453   AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1454   #
1455   AC_MSG_CHECKING([for send])
1456   AC_LINK_IFELSE([
1457     AC_LANG_PROGRAM([[
1458 #undef inline 
1459 #ifdef HAVE_WINDOWS_H
1460 #ifndef WIN32_LEAN_AND_MEAN
1461 #define WIN32_LEAN_AND_MEAN
1462 #endif
1463 #include <windows.h>
1464 #ifdef HAVE_WINSOCK2_H
1465 #include <winsock2.h>
1466 #else
1467 #ifdef HAVE_WINSOCK_H
1468 #include <winsock.h>
1469 #endif
1470 #endif
1471 #else
1472 #ifdef HAVE_SYS_TYPES_H
1473 #include <sys/types.h>
1474 #endif
1475 #ifdef HAVE_SYS_SOCKET_H
1476 #include <sys/socket.h>
1477 #endif
1478 #endif
1479     ]],[[
1480       send(0, 0, 0, 0);
1481     ]])
1482   ],[
1483     AC_MSG_RESULT([yes])
1484     curl_cv_send="yes"
1485   ],[
1486     AC_MSG_RESULT([no])
1487     curl_cv_send="no"
1488   ])
1489   #
1490   if test "$curl_cv_send" = "yes"; then
1491     AC_CACHE_CHECK([types of args and return type for send],
1492       [curl_cv_func_send_args], [
1493       curl_cv_func_send_args="unknown"
1494       for send_retv in 'int' 'ssize_t'; do
1495         for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1496           for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
1497             for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1498               for send_arg4 in 'int' 'unsigned int'; do
1499                 if test "$curl_cv_func_send_args" = "unknown"; then
1500                   AC_COMPILE_IFELSE([
1501                     AC_LANG_PROGRAM([[
1502 #undef inline 
1503 #ifdef HAVE_WINDOWS_H
1504 #ifndef WIN32_LEAN_AND_MEAN
1505 #define WIN32_LEAN_AND_MEAN
1506 #endif
1507 #include <windows.h>
1508 #ifdef HAVE_WINSOCK2_H
1509 #include <winsock2.h>
1510 #else
1511 #ifdef HAVE_WINSOCK_H
1512 #include <winsock.h>
1513 #endif
1514 #endif
1515 #define SENDCALLCONV PASCAL
1516 #else
1517 #ifdef HAVE_SYS_TYPES_H
1518 #include <sys/types.h>
1519 #endif
1520 #ifdef HAVE_SYS_SOCKET_H
1521 #include <sys/socket.h>
1522 #endif
1523 #define SENDCALLCONV
1524 #endif
1525                       extern $send_retv SENDCALLCONV
1526                       send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1527                     ]],[[
1528                       $send_arg1 s=0;
1529                       $send_arg3 len=0;
1530                       $send_arg4 flags=0;
1531                       $send_retv res = send(s, 0, len, flags);
1532                     ]])
1533                   ],[
1534                     curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1535                   ])
1536                 fi
1537               done
1538             done
1539           done
1540         done
1541       done
1542     ]) # AC-CACHE-CHECK
1543     if test "$curl_cv_func_send_args" = "unknown"; then
1544       AC_MSG_ERROR([Cannot find proper types to use for send args])
1545     else
1546       send_prev_IFS=$IFS; IFS=','
1547       set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1548       IFS=$send_prev_IFS
1549       shift
1550       #
1551       send_qual_type_arg2=$[2]
1552       #
1553       AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1554         [Define to the type of arg 1 for send.])
1555       AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1556         [Define to the type of arg 3 for send.])
1557       AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1558         [Define to the type of arg 4 for send.])
1559       AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1560         [Define to the function return type for send.])
1561       #
1562       prev_sh_opts=$-
1563       #
1564       case $prev_sh_opts in
1565         *f*)
1566           ;;
1567         *)
1568           set -f
1569           ;;
1570       esac
1571       #
1572       case "$send_qual_type_arg2" in
1573         const*)
1574           send_qual_arg2=const
1575           send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1576         ;;
1577         *)
1578           send_qual_arg2=
1579           send_type_arg2=$send_qual_type_arg2
1580         ;;
1581       esac
1582       #
1583       AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1584         [Define to the type qualifier of arg 2 for send.])
1585       AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1586         [Define to the type of arg 2 for send.])
1587       #
1588       case $prev_sh_opts in
1589         *f*)
1590           ;;
1591         *)
1592           set +f
1593           ;;
1594       esac
1595       #
1596       AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1597         [Define to 1 if you have the send function.])
1598       ac_cv_func_send="yes"
1599     fi
1600   else
1601     AC_MSG_ERROR([Unable to link function send])
1602   fi
1603 ])
1604
1605
1606 dnl CURL_CHECK_FUNC_RECVFROM
1607 dnl -------------------------------------------------
1608 dnl Test if the socket recvfrom() function is available,
1609 dnl and check its return type and the types of its
1610 dnl arguments. If the function succeeds HAVE_RECVFROM
1611 dnl will be defined, defining the types of the arguments
1612 dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
1613 dnl to RECVFROM_TYPE_ARG6, defining also the type of the
1614 dnl function return value in RECVFROM_TYPE_RETV.
1615 dnl Notice that the types returned for pointer arguments
1616 dnl will actually be the type pointed by the pointer.
1617
1618 AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
1619   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1620   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1621   AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1622   #
1623   AC_MSG_CHECKING([for recvfrom])
1624   AC_LINK_IFELSE([
1625     AC_LANG_PROGRAM([[
1626 #undef inline 
1627 #ifdef HAVE_WINDOWS_H
1628 #ifndef WIN32_LEAN_AND_MEAN
1629 #define WIN32_LEAN_AND_MEAN
1630 #endif
1631 #include <windows.h>
1632 #ifdef HAVE_WINSOCK2_H
1633 #include <winsock2.h>
1634 #else
1635 #ifdef HAVE_WINSOCK_H
1636 #include <winsock.h>
1637 #endif
1638 #endif
1639 #else
1640 #ifdef HAVE_SYS_TYPES_H
1641 #include <sys/types.h>
1642 #endif
1643 #ifdef HAVE_SYS_SOCKET_H
1644 #include <sys/socket.h>
1645 #endif
1646 #endif
1647     ]],[[
1648       recvfrom(0, 0, 0, 0, 0, 0);
1649     ]])
1650   ],[
1651     AC_MSG_RESULT([yes])
1652     curl_cv_recvfrom="yes"
1653   ],[
1654     AC_MSG_RESULT([no])
1655     curl_cv_recvfrom="no"
1656   ])
1657   #
1658   if test "$curl_cv_recvfrom" = "yes"; then
1659     AC_CACHE_CHECK([types of args and return type for recvfrom],
1660       [curl_cv_func_recvfrom_args], [
1661       curl_cv_func_recvfrom_args="unknown"
1662       for recvfrom_retv in 'int' 'ssize_t'; do
1663         for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1664           for recvfrom_arg2 in 'char *' 'void *'; do
1665             for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1666               for recvfrom_arg4 in 'int' 'unsigned int'; do
1667                 for recvfrom_arg5 in 'struct sockaddr *' 'void *'; do
1668                   for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
1669                     if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1670                       AC_COMPILE_IFELSE([
1671                         AC_LANG_PROGRAM([[
1672 #undef inline 
1673 #ifdef HAVE_WINDOWS_H
1674 #ifndef WIN32_LEAN_AND_MEAN
1675 #define WIN32_LEAN_AND_MEAN
1676 #endif
1677 #include <windows.h>
1678 #ifdef HAVE_WINSOCK2_H
1679 #include <winsock2.h>
1680 #else
1681 #ifdef HAVE_WINSOCK_H
1682 #include <winsock.h>
1683 #endif
1684 #endif
1685 #define RECVFROMCALLCONV PASCAL
1686 #else
1687 #ifdef HAVE_SYS_TYPES_H
1688 #include <sys/types.h>
1689 #endif
1690 #ifdef HAVE_SYS_SOCKET_H
1691 #include <sys/socket.h>
1692 #endif
1693 #define RECVFROMCALLCONV
1694 #endif
1695                           extern $recvfrom_retv RECVFROMCALLCONV
1696                           recvfrom($recvfrom_arg1, $recvfrom_arg2,
1697                                    $recvfrom_arg3, $recvfrom_arg4,
1698                                    $recvfrom_arg5, $recvfrom_arg6);
1699                         ]],[[
1700                           $recvfrom_arg1 s=0;
1701                           $recvfrom_arg2 buf=0;
1702                           $recvfrom_arg3 len=0;
1703                           $recvfrom_arg4 flags=0;
1704                           $recvfrom_arg5 addr=0;
1705                           $recvfrom_arg6 addrlen=0;
1706                           $recvfrom_retv res=0;
1707                           res = recvfrom(s, buf, len, flags, addr, addrlen);
1708                         ]])
1709                       ],[
1710                         curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
1711                       ])
1712                     fi
1713                   done
1714                 done
1715               done
1716             done
1717           done
1718         done
1719       done
1720     ]) # AC-CACHE-CHECK
1721     # Nearly last minute change for this release starts here
1722     AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1723       [Define to 1 if you have the recvfrom function.])
1724     ac_cv_func_recvfrom="yes"
1725     # Nearly last minute change for this release ends here
1726     if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1727       AC_MSG_WARN([Cannot find proper types to use for recvfrom args])
1728     else
1729       recvfrom_prev_IFS=$IFS; IFS=','
1730       set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
1731       IFS=$recvfrom_prev_IFS
1732       shift
1733       #
1734       recvfrom_ptrt_arg2=$[2]
1735       recvfrom_ptrt_arg5=$[5]
1736       recvfrom_ptrt_arg6=$[6]
1737       #
1738       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
1739         [Define to the type of arg 1 for recvfrom.])
1740       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
1741         [Define to the type of arg 3 for recvfrom.])
1742       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
1743         [Define to the type of arg 4 for recvfrom.])
1744       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
1745         [Define to the function return type for recvfrom.])
1746       #
1747       prev_sh_opts=$-
1748       #
1749       case $prev_sh_opts in
1750         *f*)
1751           ;;
1752         *)
1753           set -f
1754           ;;
1755       esac
1756       #
1757       recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
1758       recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
1759       recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
1760       #
1761       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
1762         [Define to the type pointed by arg 2 for recvfrom.])
1763       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
1764         [Define to the type pointed by arg 5 for recvfrom.])
1765       AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
1766         [Define to the type pointed by arg 6 for recvfrom.])
1767       #
1768       if test "$recvfrom_type_arg2" = "void"; then
1769         AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2_IS_VOID, 1,
1770           [Define to 1 if the type pointed by arg 2 for recvfrom is void.])
1771       fi
1772       if test "$recvfrom_type_arg5" = "void"; then
1773         AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5_IS_VOID, 1,
1774           [Define to 1 if the type pointed by arg 5 for recvfrom is void.])
1775       fi
1776       if test "$recvfrom_type_arg6" = "void"; then
1777         AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6_IS_VOID, 1,
1778           [Define to 1 if the type pointed by arg 6 for recvfrom is void.])
1779       fi
1780       #
1781       case $prev_sh_opts in
1782         *f*)
1783           ;;
1784         *)
1785           set +f
1786           ;;
1787       esac
1788       #
1789       AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1790         [Define to 1 if you have the recvfrom function.])
1791       ac_cv_func_recvfrom="yes"
1792     fi
1793   else
1794     AC_MSG_WARN([Unable to link function recvfrom])
1795   fi
1796 ])
1797
1798
1799 dnl CURL_CHECK_MSG_NOSIGNAL
1800 dnl -------------------------------------------------
1801 dnl Check for MSG_NOSIGNAL
1802
1803 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1804   AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1805   AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1806     AC_COMPILE_IFELSE([
1807       AC_LANG_PROGRAM([[
1808 #undef inline 
1809 #ifdef HAVE_WINDOWS_H
1810 #ifndef WIN32_LEAN_AND_MEAN
1811 #define WIN32_LEAN_AND_MEAN
1812 #endif
1813 #include <windows.h>
1814 #ifdef HAVE_WINSOCK2_H
1815 #include <winsock2.h>
1816 #else
1817 #ifdef HAVE_WINSOCK_H
1818 #include <winsock.h>
1819 #endif
1820 #endif
1821 #else
1822 #ifdef HAVE_SYS_TYPES_H
1823 #include <sys/types.h>
1824 #endif
1825 #ifdef HAVE_SYS_SOCKET_H
1826 #include <sys/socket.h>
1827 #endif
1828 #endif
1829       ]],[[
1830         int flag=MSG_NOSIGNAL;
1831       ]])
1832     ],[
1833       ac_cv_msg_nosignal="yes"
1834     ],[
1835       ac_cv_msg_nosignal="no"
1836     ])
1837   ])
1838   case "$ac_cv_msg_nosignal" in
1839     yes)
1840       AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1841         [Define to 1 if you have the MSG_NOSIGNAL flag.])
1842       ;;
1843   esac
1844 ])
1845
1846
1847 dnl CURL_CHECK_STRUCT_TIMEVAL
1848 dnl -------------------------------------------------
1849 dnl Check for timeval struct
1850
1851 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1852   AC_REQUIRE([AC_HEADER_TIME])dnl
1853   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1854   AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1855   AC_CHECK_HEADERS(sys/types.h sys/time.h time.h sys/socket.h)
1856   AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1857     AC_COMPILE_IFELSE([
1858       AC_LANG_PROGRAM([[
1859 #undef inline 
1860 #ifdef HAVE_WINDOWS_H
1861 #ifndef WIN32_LEAN_AND_MEAN
1862 #define WIN32_LEAN_AND_MEAN
1863 #endif
1864 #include <windows.h>
1865 #ifdef HAVE_WINSOCK2_H
1866 #include <winsock2.h>
1867 #else
1868 #ifdef HAVE_WINSOCK_H
1869 #include <winsock.h>
1870 #endif
1871 #endif
1872 #endif
1873 #ifdef HAVE_SYS_TYPES_H
1874 #include <sys/types.h>
1875 #endif
1876 #ifdef HAVE_SYS_TIME_H
1877 #include <sys/time.h>
1878 #ifdef TIME_WITH_SYS_TIME
1879 #include <time.h>
1880 #endif
1881 #else
1882 #ifdef HAVE_TIME_H
1883 #include <time.h>
1884 #endif
1885 #endif
1886 #ifdef HAVE_SYS_SOCKET_H
1887 #include <sys/socket.h>
1888 #endif
1889       ]],[[
1890         struct timeval ts;
1891         ts.tv_sec  = 0;
1892         ts.tv_usec = 0;
1893       ]])
1894     ],[
1895       ac_cv_struct_timeval="yes"
1896     ],[
1897       ac_cv_struct_timeval="no"
1898     ])
1899   ])
1900   case "$ac_cv_struct_timeval" in
1901     yes)
1902       AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1903         [Define to 1 if you have the timeval struct.])
1904       ;;
1905   esac
1906 ])
1907
1908
1909 dnl TYPE_SIG_ATOMIC_T
1910 dnl -------------------------------------------------
1911 dnl Check if the sig_atomic_t type is available, and
1912 dnl verify if it is already defined as volatile.
1913
1914 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1915   AC_CHECK_HEADERS(signal.h)
1916   AC_CHECK_TYPE([sig_atomic_t],[
1917     AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1918       [Define to 1 if sig_atomic_t is an available typedef.])
1919   ], ,[
1920 #ifdef HAVE_SIGNAL_H
1921 #include <signal.h>
1922 #endif
1923   ])
1924   case "$ac_cv_type_sig_atomic_t" in
1925     yes)
1926       #
1927       AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1928       AC_LINK_IFELSE([
1929         AC_LANG_PROGRAM([[
1930 #ifdef HAVE_SIGNAL_H
1931 #include <signal.h>
1932 #endif
1933         ]],[[
1934           static volatile sig_atomic_t dummy = 0;
1935         ]])
1936       ],[
1937         AC_MSG_RESULT([no])
1938         ac_cv_sig_atomic_t_volatile="no"
1939       ],[
1940         AC_MSG_RESULT([yes])
1941         ac_cv_sig_atomic_t_volatile="yes"
1942       ])
1943       #
1944       if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1945         AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1946           [Define to 1 if sig_atomic_t is already defined as volatile.])
1947       fi
1948       ;;
1949   esac
1950 ])
1951
1952
1953 dnl TYPE_IN_ADDR_T
1954 dnl -------------------------------------------------
1955 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1956 dnl and a few other things.
1957
1958 AC_DEFUN([TYPE_IN_ADDR_T], [
1959   AC_CHECK_TYPE([in_addr_t], ,[
1960     dnl in_addr_t not available
1961     AC_CACHE_CHECK([for in_addr_t equivalent],
1962       [curl_cv_in_addr_t_equiv], [
1963       curl_cv_in_addr_t_equiv="unknown"
1964       for t in "unsigned long" int size_t unsigned long; do
1965         if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
1966           AC_LINK_IFELSE([
1967             AC_LANG_PROGRAM([[
1968 #undef inline
1969 #ifdef HAVE_WINDOWS_H
1970 #ifndef WIN32_LEAN_AND_MEAN
1971 #define WIN32_LEAN_AND_MEAN
1972 #endif
1973 #include <windows.h>
1974 #ifdef HAVE_WINSOCK2_H
1975 #include <winsock2.h>
1976 #else
1977 #ifdef HAVE_WINSOCK_H
1978 #include <winsock.h>
1979 #endif
1980 #endif
1981 #else
1982 #ifdef HAVE_SYS_TYPES_H
1983 #include <sys/types.h>
1984 #endif
1985 #ifdef HAVE_SYS_SOCKET_H
1986 #include <sys/socket.h>
1987 #endif
1988 #ifdef HAVE_NETINET_IN_H
1989 #include <netinet/in.h>
1990 #endif
1991 #ifdef HAVE_ARPA_INET_H
1992 #include <arpa/inet.h>
1993 #endif
1994 #endif
1995             ]],[[
1996               $t data = inet_addr ("1.2.3.4");
1997             ]])
1998           ],[
1999             curl_cv_in_addr_t_equiv="$t"
2000           ])
2001         fi
2002       done
2003     ])
2004     case "$curl_cv_in_addr_t_equiv" in
2005       unknown)
2006         AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
2007         ;;
2008       *)
2009         AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
2010           [Type to use in place of in_addr_t when system does not provide it.])
2011         ;;
2012     esac
2013   ],[
2014 #undef inline
2015 #ifdef HAVE_WINDOWS_H
2016 #ifndef WIN32_LEAN_AND_MEAN
2017 #define WIN32_LEAN_AND_MEAN
2018 #endif
2019 #include <windows.h>
2020 #ifdef HAVE_WINSOCK2_H
2021 #include <winsock2.h>
2022 #else
2023 #ifdef HAVE_WINSOCK_H
2024 #include <winsock.h>
2025 #endif
2026 #endif
2027 #else
2028 #ifdef HAVE_SYS_TYPES_H
2029 #include <sys/types.h>
2030 #endif
2031 #ifdef HAVE_SYS_SOCKET_H
2032 #include <sys/socket.h>
2033 #endif
2034 #ifdef HAVE_NETINET_IN_H
2035 #include <netinet/in.h>
2036 #endif
2037 #ifdef HAVE_ARPA_INET_H
2038 #include <arpa/inet.h>
2039 #endif
2040 #endif
2041   ])
2042 ])
2043
2044
2045 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
2046 dnl -------------------------------------------------
2047 dnl Check if monotonic clock_gettime is available.
2048
2049 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
2050   AC_REQUIRE([AC_HEADER_TIME])dnl
2051   AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
2052   AC_MSG_CHECKING([for monotonic clock_gettime])
2053   AC_COMPILE_IFELSE([
2054     AC_LANG_PROGRAM([[
2055 #ifdef HAVE_SYS_TYPES_H
2056 #include <sys/types.h>
2057 #endif
2058 #ifdef HAVE_SYS_TIME_H
2059 #include <sys/time.h>
2060 #ifdef TIME_WITH_SYS_TIME
2061 #include <time.h>
2062 #endif
2063 #else
2064 #ifdef HAVE_TIME_H
2065 #include <time.h>
2066 #endif
2067 #endif
2068     ]],[[
2069       struct timespec ts;
2070       (void)clock_gettime(CLOCK_MONOTONIC, &ts);
2071     ]])
2072   ],[
2073     AC_MSG_RESULT([yes])
2074     ac_cv_func_clock_gettime="yes"
2075   ],[
2076     AC_MSG_RESULT([no])
2077     ac_cv_func_clock_gettime="no"
2078   ])
2079   dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
2080   dnl until library linking and run-time checks for clock_gettime succeed.
2081 ])
2082
2083
2084 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
2085 dnl -------------------------------------------------
2086 dnl If monotonic clock_gettime is available then,
2087 dnl check and prepended to LIBS any needed libraries.
2088
2089 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
2090   AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
2091   #
2092   if test "$ac_cv_func_clock_gettime" = "yes"; then
2093     #
2094     AC_MSG_CHECKING([for clock_gettime in libraries])
2095     #
2096     curl_cv_save_LIBS="$LIBS"
2097     curl_cv_gclk_LIBS="unknown"
2098     #
2099     for x_xlibs in '' '-lrt' '-lposix4' ; do
2100       if test "$curl_cv_gclk_LIBS" = "unknown"; then
2101         if test -z "$x_xlibs"; then
2102           LIBS="$curl_cv_save_LIBS"
2103         else
2104           LIBS="$x_xlibs $curl_cv_save_LIBS"
2105         fi
2106         AC_LINK_IFELSE([
2107           AC_LANG_PROGRAM([[
2108 #ifdef HAVE_SYS_TYPES_H
2109 #include <sys/types.h>
2110 #endif
2111 #ifdef HAVE_SYS_TIME_H
2112 #include <sys/time.h>
2113 #ifdef TIME_WITH_SYS_TIME
2114 #include <time.h>
2115 #endif
2116 #else
2117 #ifdef HAVE_TIME_H
2118 #include <time.h>
2119 #endif
2120 #endif
2121           ]],[[
2122             struct timespec ts;
2123             (void)clock_gettime(CLOCK_MONOTONIC, &ts);
2124           ]])
2125         ],[
2126           curl_cv_gclk_LIBS="$x_xlibs"
2127         ])
2128       fi
2129     done
2130     #
2131     LIBS="$curl_cv_save_LIBS"
2132     #
2133     case X-"$curl_cv_gclk_LIBS" in
2134       X-unknown)
2135         AC_MSG_RESULT([cannot find clock_gettime])
2136         AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
2137         ac_cv_func_clock_gettime="no"
2138         ;;
2139       X-)
2140         AC_MSG_RESULT([no additional lib required])
2141         ac_cv_func_clock_gettime="yes"
2142         ;;
2143       *)
2144         if test -z "$curl_cv_save_LIBS"; then
2145           LIBS="$curl_cv_gclk_LIBS"
2146         else
2147           LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
2148         fi
2149         AC_MSG_RESULT([$curl_cv_gclk_LIBS])
2150         ac_cv_func_clock_gettime="yes"
2151         ;;
2152     esac
2153     #
2154     dnl only do runtime verification when not cross-compiling
2155     if test "x$cross_compiling" != "xyes" &&
2156       test "$ac_cv_func_clock_gettime" = "yes"; then
2157       AC_MSG_CHECKING([if monotonic clock_gettime works])
2158       AC_RUN_IFELSE([
2159         AC_LANG_PROGRAM([[
2160 #ifdef HAVE_STDLIB_H
2161 #include <stdlib.h>
2162 #endif
2163 #ifdef HAVE_SYS_TYPES_H
2164 #include <sys/types.h>
2165 #endif
2166 #ifdef HAVE_SYS_TIME_H
2167 #include <sys/time.h>
2168 #ifdef TIME_WITH_SYS_TIME
2169 #include <time.h>
2170 #endif
2171 #else
2172 #ifdef HAVE_TIME_H
2173 #include <time.h>
2174 #endif
2175 #endif
2176         ]],[[
2177           struct timespec ts;
2178           if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
2179             exit(0);
2180           else
2181             exit(1);
2182         ]])
2183       ],[
2184         AC_MSG_RESULT([yes])
2185       ],[
2186         AC_MSG_RESULT([no])
2187         AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
2188         ac_cv_func_clock_gettime="no"
2189         LIBS="$curl_cv_save_LIBS"
2190       ])
2191     fi
2192     #
2193     case "$ac_cv_func_clock_gettime" in
2194       yes)
2195         AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
2196           [Define to 1 if you have the clock_gettime function and monotonic timer.])
2197         ;;
2198     esac
2199     #
2200   fi
2201   #
2202 ])
2203
2204
2205 dnl CURL_CHECK_LIBS_CONNECT
2206 dnl -------------------------------------------------
2207 dnl Verify if network connect function is already available
2208 dnl using current libraries or if another one is required.
2209
2210 AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [
2211   AC_MSG_CHECKING([for connect in libraries])
2212   tst_connect_save_LIBS="$LIBS"
2213   tst_connect_need_LIBS="unknown"
2214   for tst_lib in '' '-lsocket' ; do
2215     if test "$tst_connect_need_LIBS" = "unknown"; then
2216       LIBS="$tst_lib $tst_connect_save_LIBS"
2217       AC_LINK_IFELSE([
2218         AC_LANG_PROGRAM([[
2219         ]],[[
2220           if(0 != connect(0, 0, 0))
2221             return 1;
2222         ]])
2223       ],[
2224         tst_connect_need_LIBS="$tst_lib"
2225       ])
2226     fi
2227   done
2228   LIBS="$tst_connect_save_LIBS"
2229   #
2230   case X-"$tst_connect_need_LIBS" in
2231     X-unknown)
2232       AC_MSG_RESULT([cannot find connect])
2233       AC_MSG_ERROR([cannot find connect function in libraries.])
2234       ;;
2235     X-)
2236       AC_MSG_RESULT([yes])
2237       ;;
2238     *)
2239       AC_MSG_RESULT([$tst_connect_need_LIBS])
2240       LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS"
2241       ;;
2242   esac
2243 ])
2244
2245
2246 dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
2247 dnl -------------------------------------------------
2248 dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
2249 dnl symbol that can be further used in custom template configuration
2250 dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
2251 dnl argument for the description. Symbol definitions done with this
2252 dnl macro are intended to be exclusively used in handcrafted *.h.in
2253 dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
2254 dnl prevents autoheader generation and insertion of symbol template
2255 dnl stub and definition into the first configuration header file. Do
2256 dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
2257 dnl one serves different functional needs.
2258
2259 AC_DEFUN([CURL_DEFINE_UNQUOTED], [
2260 cat >>confdefs.h <<_EOF
2261 [@%:@define] $1 ifelse($#, 2, [$2], 1)
2262 _EOF
2263 ])
2264
2265
2266 dnl CURL_CONFIGURE_LONG
2267 dnl -------------------------------------------------
2268 dnl Find out the size of long as reported by sizeof() and define
2269 dnl CURL_SIZEOF_LONG as appropriate to be used in template file
2270 dnl include/curl/curlbuild.h.in to properly configure the library.
2271 dnl The size of long is a build time characteristic and as such
2272 dnl must be recorded in curlbuild.h
2273
2274 AC_DEFUN([CURL_CONFIGURE_LONG], [
2275   if test -z "$ac_cv_sizeof_long" ||
2276     test "$ac_cv_sizeof_long" -eq "0"; then
2277     AC_MSG_ERROR([cannot find out size of long.])
2278   fi
2279   CURL_DEFINE_UNQUOTED([CURL_SIZEOF_LONG], [$ac_cv_sizeof_long])
2280 ])
2281
2282
2283 dnl CURL_CONFIGURE_CURL_SOCKLEN_T
2284 dnl -------------------------------------------------
2285 dnl Find out suitable curl_socklen_t data type definition and size, making
2286 dnl appropriate definitions for template file include/curl/curlbuild.h.in
2287 dnl to properly configure and use the library.
2288 dnl
2289 dnl The need for the curl_socklen_t definition arises mainly to properly
2290 dnl interface HP-UX systems which on one hand have a typedef'ed socklen_t
2291 dnl data type which is 32 or 64-Bit wide depending on the data model being
2292 dnl used, and that on the other hand is only actually used when interfacing
2293 dnl the X/Open sockets provided in the xnet library.
2294
2295 AC_DEFUN([CURL_CONFIGURE_CURL_SOCKLEN_T], [
2296   AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
2297   AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
2298   AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
2299   #
2300   AC_MSG_CHECKING([for curl_socklen_t data type])
2301   curl_typeof_curl_socklen_t="unknown"
2302   for arg1 in int SOCKET; do
2303     for arg2 in 'struct sockaddr' void; do
2304       for t in socklen_t int size_t 'unsigned int' long 'unsigned long' void; do
2305         if test "$curl_typeof_curl_socklen_t" = "unknown"; then
2306           AC_COMPILE_IFELSE([
2307             AC_LANG_PROGRAM([[
2308               $curl_includes_ws2tcpip
2309               $curl_includes_sys_socket
2310               $curl_preprocess_callconv
2311               extern int FUNCALLCONV getpeername($arg1, $arg2 *, $t *);
2312             ]],[[
2313               $t *lenptr = 0;
2314               if(0 != getpeername(0, 0, lenptr))
2315                 return 1;
2316             ]])
2317           ],[
2318             curl_typeof_curl_socklen_t="$t"
2319           ])
2320         fi
2321       done
2322     done
2323   done
2324   for t in socklen_t int; do
2325     if test "$curl_typeof_curl_socklen_t" = "void"; then
2326       AC_COMPILE_IFELSE([
2327         AC_LANG_PROGRAM([[
2328           $curl_includes_sys_socket
2329           typedef $t curl_socklen_t;
2330         ]],[[
2331           curl_socklen_t dummy;
2332         ]])
2333       ],[
2334         curl_typeof_curl_socklen_t="$t"
2335       ])
2336     fi
2337   done
2338   AC_MSG_RESULT([$curl_typeof_curl_socklen_t])
2339   if test "$curl_typeof_curl_socklen_t" = "void" ||
2340     test "$curl_typeof_curl_socklen_t" = "unknown"; then
2341     AC_MSG_ERROR([cannot find data type for curl_socklen_t.])
2342   fi
2343   #
2344   AC_MSG_CHECKING([size of curl_socklen_t])
2345   curl_sizeof_curl_socklen_t="unknown"
2346   curl_pull_headers_socklen_t="unknown"
2347   if test "$ac_cv_header_ws2tcpip_h" = "yes"; then
2348     tst_pull_header_checks='none ws2tcpip'
2349     tst_size_checks='4'
2350   else
2351     tst_pull_header_checks='none systypes syssocket'
2352     tst_size_checks='4 8 2'
2353   fi
2354   for tst_size in $tst_size_checks; do
2355     for tst_pull_headers in $tst_pull_header_checks; do
2356       if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
2357         case $tst_pull_headers in
2358           ws2tcpip)
2359             tmp_includes="$curl_includes_ws2tcpip"
2360             ;;
2361           systypes)
2362             tmp_includes="$curl_includes_sys_types"
2363             ;;
2364           syssocket)
2365             tmp_includes="$curl_includes_sys_socket"
2366             ;;
2367           *)
2368             tmp_includes=""
2369             ;;
2370         esac
2371         AC_COMPILE_IFELSE([
2372           AC_LANG_PROGRAM([[
2373             $tmp_includes
2374             typedef $curl_typeof_curl_socklen_t curl_socklen_t;
2375             typedef char dummy_arr[sizeof(curl_socklen_t) == $tst_size ? 1 : -1];
2376           ]],[[
2377             curl_socklen_t dummy;
2378           ]])
2379         ],[
2380           curl_sizeof_curl_socklen_t="$tst_size"
2381           curl_pull_headers_socklen_t="$tst_pull_headers"
2382         ])
2383       fi
2384     done
2385   done
2386   AC_MSG_RESULT([$curl_sizeof_curl_socklen_t])
2387   if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
2388     AC_MSG_ERROR([cannot find out size of curl_socklen_t.])
2389   fi
2390   #
2391   case $curl_pull_headers_socklen_t in
2392     ws2tcpip)
2393       CURL_DEFINE_UNQUOTED([CURL_PULL_WS2TCPIP_H])
2394       ;;
2395     systypes)
2396       CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
2397       ;;
2398     syssocket)
2399       CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
2400       CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_SOCKET_H])
2401       ;;
2402   esac
2403   CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_SOCKLEN_T], [$curl_typeof_curl_socklen_t])
2404   CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_SOCKLEN_T], [$curl_sizeof_curl_socklen_t])
2405 ])
2406
2407
2408 dnl CURL_CHECK_FUNC_SELECT
2409 dnl -------------------------------------------------
2410 dnl Test if the socket select() function is available,
2411 dnl and check its return type and the types of its
2412 dnl arguments. If the function succeeds HAVE_SELECT
2413 dnl will be defined, defining the types of the
2414 dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
2415 dnl and SELECT_TYPE_ARG5, defining the type of the
2416 dnl function return value in SELECT_TYPE_RETV, and
2417 dnl also defining the type qualifier of fifth argument
2418 dnl in SELECT_QUAL_ARG5.
2419
2420 AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
2421   AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
2422   AC_CHECK_HEADERS(sys/select.h sys/socket.h)
2423   #
2424   AC_MSG_CHECKING([for select])
2425   AC_LINK_IFELSE([
2426     AC_LANG_PROGRAM([[
2427 #undef inline
2428 #ifdef HAVE_WINDOWS_H
2429 #ifndef WIN32_LEAN_AND_MEAN
2430 #define WIN32_LEAN_AND_MEAN
2431 #endif
2432 #include <windows.h>
2433 #ifdef HAVE_WINSOCK2_H
2434 #include <winsock2.h>
2435 #else
2436 #ifdef HAVE_WINSOCK_H
2437 #include <winsock.h>
2438 #endif
2439 #endif
2440 #endif
2441 #ifdef HAVE_SYS_TYPES_H
2442 #include <sys/types.h>
2443 #endif
2444 #ifdef HAVE_SYS_TIME_H
2445 #include <sys/time.h>
2446 #ifdef TIME_WITH_SYS_TIME
2447 #include <time.h>
2448 #endif
2449 #else
2450 #ifdef HAVE_TIME_H
2451 #include <time.h>
2452 #endif
2453 #endif
2454 #ifndef HAVE_WINDOWS_H
2455 #ifdef HAVE_SYS_SELECT_H
2456 #include <sys/select.h>
2457 #endif
2458 #ifdef HAVE_SYS_SOCKET_H
2459 #include <sys/socket.h>
2460 #endif
2461 #endif
2462     ]],[[
2463       select(0, 0, 0, 0, 0);
2464     ]])
2465   ],[
2466     AC_MSG_RESULT([yes])
2467     curl_cv_select="yes"
2468   ],[
2469     AC_MSG_RESULT([no])
2470     curl_cv_select="no"
2471   ])
2472   #
2473   if test "$curl_cv_select" = "yes"; then
2474     AC_CACHE_CHECK([types of args and return type for select],
2475       [curl_cv_func_select_args], [
2476       curl_cv_func_select_args="unknown"
2477       for sel_retv in 'int' 'ssize_t'; do
2478         for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
2479           for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
2480             for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
2481               if test "$curl_cv_func_select_args" = "unknown"; then
2482                 AC_COMPILE_IFELSE([
2483                   AC_LANG_PROGRAM([[
2484 #undef inline
2485 #ifdef HAVE_WINDOWS_H
2486 #ifndef WIN32_LEAN_AND_MEAN
2487 #define WIN32_LEAN_AND_MEAN
2488 #endif
2489 #include <windows.h>
2490 #ifdef HAVE_WINSOCK2_H
2491 #include <winsock2.h>
2492 #else
2493 #ifdef HAVE_WINSOCK_H
2494 #include <winsock.h>
2495 #endif
2496 #endif
2497 #define SELECTCALLCONV PASCAL
2498 #endif
2499 #ifdef HAVE_SYS_TYPES_H
2500 #include <sys/types.h>
2501 #endif
2502 #ifdef HAVE_SYS_TIME_H
2503 #include <sys/time.h>
2504 #ifdef TIME_WITH_SYS_TIME
2505 #include <time.h>
2506 #endif
2507 #else
2508 #ifdef HAVE_TIME_H
2509 #include <time.h>
2510 #endif
2511 #endif
2512 #ifndef HAVE_WINDOWS_H
2513 #ifdef HAVE_SYS_SELECT_H
2514 #include <sys/select.h>
2515 #endif
2516 #ifdef HAVE_SYS_SOCKET_H
2517 #include <sys/socket.h>
2518 #endif
2519 #define SELECTCALLCONV
2520 #endif
2521 #ifndef HAVE_STRUCT_TIMEVAL
2522                     struct timeval {
2523                       long tv_sec;
2524                       long tv_usec;
2525                     };
2526 #endif
2527                     extern $sel_retv SELECTCALLCONV select($sel_arg1,
2528                                                            $sel_arg234,
2529                                                            $sel_arg234,
2530                                                            $sel_arg234,
2531                                                            $sel_arg5);
2532                   ]],[[
2533                     $sel_arg1   nfds=0;
2534                     $sel_arg234 rfds=0;
2535                     $sel_arg234 wfds=0;
2536                     $sel_arg234 efds=0;
2537                     $sel_retv res = select(nfds, rfds, wfds, efds, 0);
2538                   ]])
2539                 ],[
2540                   curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
2541                 ])
2542               fi
2543             done
2544           done
2545         done
2546       done
2547     ]) # AC-CACHE-CHECK
2548     if test "$curl_cv_func_select_args" = "unknown"; then
2549       AC_MSG_WARN([Cannot find proper types to use for select args])
2550       AC_MSG_WARN([HAVE_SELECT will not be defined])
2551     else
2552       select_prev_IFS=$IFS; IFS=','
2553       set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
2554       IFS=$select_prev_IFS
2555       shift
2556       #
2557       sel_qual_type_arg5=$[3]
2558       #
2559       AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
2560         [Define to the type of arg 1 for select.])
2561       AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
2562         [Define to the type of args 2, 3 and 4 for select.])
2563       AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
2564         [Define to the function return type for select.])
2565       #
2566       prev_sh_opts=$-
2567       #
2568       case $prev_sh_opts in
2569         *f*)
2570           ;;
2571         *)
2572           set -f
2573           ;;
2574       esac
2575       #
2576       case "$sel_qual_type_arg5" in
2577         const*)
2578           sel_qual_arg5=const
2579           sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
2580         ;;
2581         *)
2582           sel_qual_arg5=
2583           sel_type_arg5=$sel_qual_type_arg5
2584         ;;
2585       esac
2586       #
2587       AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
2588         [Define to the type qualifier of arg 5 for select.])
2589       AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
2590         [Define to the type of arg 5 for select.])
2591       #
2592       case $prev_sh_opts in
2593         *f*)
2594           ;;
2595         *)
2596           set +f
2597           ;;
2598       esac
2599       #
2600       AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
2601         [Define to 1 if you have the select function.])
2602       ac_cv_func_select="yes"
2603     fi
2604   fi
2605 ])
2606
2607
2608 # This is only a temporary fix. This macro is here to replace the broken one
2609 # delivered by the automake project (including the 1.9.6 release). As soon as
2610 # they ship a working version we SHOULD remove this work-around.
2611
2612 AC_DEFUN([AM_MISSING_HAS_RUN],
2613 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
2614 test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\""
2615 # Use eval to expand $SHELL
2616 if eval "$MISSING --run true"; then
2617   am_missing_run="$MISSING --run "
2618 else
2619   am_missing_run=
2620   AC_MSG_WARN([`missing' script is too old or missing])
2621 fi
2622 ])
2623
2624
2625 dnl CURL_VERIFY_RUNTIMELIBS
2626 dnl -------------------------------------------------
2627 dnl Verify that the shared libs found so far can be used when running
2628 dnl programs, since otherwise the situation will create odd configure errors
2629 dnl that are misleading people.
2630 dnl
2631 dnl Make sure this test is run BEFORE the first test in the script that
2632 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
2633 dnl macro. It must also run AFTER all lib-checking macros are complete.
2634
2635 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
2636
2637   dnl this test is of course not sensible if we are cross-compiling!
2638   if test "x$cross_compiling" != xyes; then
2639
2640     dnl just run a program to verify that the libs checked for previous to this
2641     dnl point also is available run-time!
2642     AC_MSG_CHECKING([run-time libs availability])
2643     AC_TRY_RUN([
2644 main()
2645 {
2646   return 0;
2647 }
2648 ],
2649     AC_MSG_RESULT([fine]),
2650     AC_MSG_RESULT([failed])
2651     AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
2652     )
2653
2654     dnl if this test fails, configure has already stopped
2655   fi
2656 ])
2657
2658
2659 dnl CURL_CHECK_VARIADIC_MACROS
2660 dnl -------------------------------------------------
2661 dnl Check compiler support of variadic macros
2662
2663 AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
2664   AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
2665     [curl_cv_variadic_macros_c99], [
2666     AC_COMPILE_IFELSE([
2667       AC_LANG_PROGRAM([[
2668 #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
2669 #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
2670         int fun3(int arg1, int arg2, int arg3);
2671         int fun2(int arg1, int arg2);
2672         int fun3(int arg1, int arg2, int arg3)
2673         { return arg1 + arg2 + arg3; }
2674         int fun2(int arg1, int arg2)
2675         { return arg1 + arg2; }
2676       ]],[[
2677         int res3 = c99_vmacro3(1, 2, 3);
2678         int res2 = c99_vmacro2(1, 2);
2679       ]])
2680     ],[
2681       curl_cv_variadic_macros_c99="yes"
2682     ],[
2683       curl_cv_variadic_macros_c99="no"
2684     ])
2685   ])
2686   case "$curl_cv_variadic_macros_c99" in
2687     yes)
2688       AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
2689         [Define to 1 if compiler supports C99 variadic macro style.])
2690       ;;
2691   esac
2692   AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
2693     [curl_cv_variadic_macros_gcc], [
2694     AC_COMPILE_IFELSE([
2695       AC_LANG_PROGRAM([[
2696 #define gcc_vmacro3(first, args...) fun3(first, args)
2697 #define gcc_vmacro2(first, args...) fun2(first, args)
2698         int fun3(int arg1, int arg2, int arg3);
2699         int fun2(int arg1, int arg2);
2700         int fun3(int arg1, int arg2, int arg3)
2701         { return arg1 + arg2 + arg3; }
2702         int fun2(int arg1, int arg2)
2703         { return arg1 + arg2; }
2704       ]],[[
2705         int res3 = gcc_vmacro3(1, 2, 3);
2706         int res2 = gcc_vmacro2(1, 2);
2707       ]])
2708     ],[
2709       curl_cv_variadic_macros_gcc="yes"
2710     ],[
2711       curl_cv_variadic_macros_gcc="no"
2712     ])
2713   ])
2714   case "$curl_cv_variadic_macros_gcc" in
2715     yes)
2716       AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
2717         [Define to 1 if compiler supports old gcc variadic macro style.])
2718       ;;
2719   esac
2720 ])
2721
2722
2723 dnl CURL_CHECK_CA_BUNDLE
2724 dnl -------------------------------------------------
2725 dnl Check if a default ca-bundle should be used
2726 dnl
2727 dnl regarding the paths this will scan:
2728 dnl /etc/ssl/certs/ca-certificates.crt Debian systems
2729 dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
2730 dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
2731 dnl /usr/local/share/certs/ca-root.crt FreeBSD
2732 dnl /etc/ssl/cert.pem OpenBSD
2733 dnl /etc/ssl/certs/ (ca path) SUSE
2734
2735 AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
2736
2737   AC_MSG_CHECKING([default CA cert bundle/path])
2738
2739   AC_ARG_WITH(ca-bundle,
2740 AC_HELP_STRING([--with-ca-bundle=FILE], [File name to use as CA bundle])
2741 AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
2742   [
2743     want_ca="$withval"
2744     if test "x$want_ca" = "xyes"; then
2745       AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
2746     fi
2747   ],
2748   [ want_ca="unset" ])
2749   AC_ARG_WITH(ca-path,
2750 AC_HELP_STRING([--with-ca-path=DIRECTORY], [Directory to use as CA path])
2751 AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
2752   [
2753     want_capath="$withval"
2754     if test "x$want_capath" = "xyes"; then
2755       AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
2756     fi
2757   ],
2758   [ want_capath="unset"])
2759
2760   if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
2761           "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2762     dnl both given
2763     AC_MSG_ERROR([Can't specify both --with-ca-bundle and --with-ca-path.])
2764   elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
2765     dnl --with-ca-bundle given
2766     ca="$want_ca"
2767     capath="no"
2768   elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2769     dnl --with-ca-path given
2770     if test "x$OPENSSL_ENABLED" != "x1"; then
2771       AC_MSG_ERROR([--with-ca-path only works with openSSL])
2772     fi
2773     capath="$want_capath"
2774     ca="no"
2775   else
2776     dnl neither of --with-ca-* given
2777     dnl first try autodetecting a CA bundle , then a CA path
2778     dnl both autodetections can be skipped by --without-ca-*
2779     ca="no"
2780     capath="no"
2781     if test "x$want_ca" = "xunset"; then
2782       dnl the path we previously would have installed the curl ca bundle
2783       dnl to, and thus we now check for an already existing cert in that place
2784       dnl in case we find no other
2785       if test "x$prefix" != xNONE; then
2786         cac="${prefix}/share/curl/curl-ca-bundle.crt"
2787       else
2788         cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
2789       fi
2790
2791       for a in /etc/ssl/certs/ca-certificates.crt \
2792                /etc/pki/tls/certs/ca-bundle.crt \
2793                /usr/share/ssl/certs/ca-bundle.crt \
2794                /usr/local/share/certs/ca-root.crt \
2795                /etc/ssl/cert.pem \
2796                "$cac"; do
2797         if test -f "$a"; then
2798           ca="$a"
2799           break
2800         fi
2801       done
2802     fi
2803     if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
2804             "x$OPENSSL_ENABLED" = "x1"; then
2805       for a in /etc/ssl/certs/; do
2806         if test -d "$a" && ls "$a"/[[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]].0 >/dev/null 2>/dev/null; then
2807           capath="$a"
2808           break
2809         fi
2810       done
2811     fi
2812   fi
2813         
2814     
2815
2816   if test "x$ca" != "xno"; then
2817     CURL_CA_BUNDLE='"'$ca'"'
2818     AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
2819     AC_SUBST(CURL_CA_BUNDLE)
2820     AC_MSG_RESULT([$ca])
2821   elif test "x$capath" != "xno"; then
2822     CURL_CA_PATH="\"$capath\""
2823     AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
2824     AC_MSG_RESULT([$capath (capath)])
2825   else
2826     AC_MSG_RESULT([no])
2827   fi
2828 ])
2829
2830
2831 dnl DO_CURL_OFF_T_CHECK (TYPE, SIZE)
2832 dnl -------------------------------------------------
2833 dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
2834
2835 AC_DEFUN([DO_CURL_OFF_T_CHECK], [
2836   AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
2837   if test "$curl_typeof_curl_off_t" = "unknown" && test ! -z "$1"; then
2838     tmp_includes=""
2839     tmp_source=""
2840     tmp_fmt=""
2841     case AS_TR_SH([$1]) in
2842       int64_t)
2843         tmp_includes="$curl_includes_inttypes"
2844         tmp_source="char f@<:@@:>@ = PRId64;"
2845         tmp_fmt="PRId64"
2846         ;;
2847       int32_t)
2848         tmp_includes="$curl_includes_inttypes"
2849         tmp_source="char f@<:@@:>@ = PRId32;"
2850         tmp_fmt="PRId32"
2851         ;;
2852       int16_t)
2853         tmp_includes="$curl_includes_inttypes"
2854         tmp_source="char f@<:@@:>@ = PRId16;"
2855         tmp_fmt="PRId16"
2856         ;;
2857     esac
2858     AC_COMPILE_IFELSE([
2859       AC_LANG_PROGRAM([[
2860         $tmp_includes
2861         typedef $1 curl_off_t;
2862         typedef char dummy_arr[sizeof(curl_off_t) == $2 ? 1 : -1];
2863       ]],[[
2864         $tmp_source
2865         curl_off_t dummy;
2866       ]])
2867     ],[
2868       if test -z "$tmp_fmt"; then
2869         curl_typeof_curl_off_t="$1"
2870         curl_sizeof_curl_off_t="$2"
2871       else
2872         CURL_CHECK_DEF([$tmp_fmt], [$curl_includes_inttypes], [silent])
2873         AS_VAR_PUSHDEF([tmp_HaveFmtDef], [curl_cv_have_def_$tmp_fmt])dnl
2874         AS_VAR_PUSHDEF([tmp_FmtDef], [curl_cv_def_$tmp_fmt])dnl
2875         if test AS_VAR_GET(tmp_HaveFmtDef) = "yes"; then
2876           curl_format_curl_off_t=AS_VAR_GET(tmp_FmtDef)
2877           curl_typeof_curl_off_t="$1"
2878           curl_sizeof_curl_off_t="$2"
2879         fi
2880         AS_VAR_POPDEF([tmp_FmtDef])dnl
2881         AS_VAR_POPDEF([tmp_HaveFmtDef])dnl
2882       fi
2883     ])
2884   fi
2885 ])
2886
2887
2888 dnl DO_CURL_OFF_T_SUFFIX_CHECK (TYPE)
2889 dnl -------------------------------------------------
2890 dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
2891
2892 AC_DEFUN([DO_CURL_OFF_T_SUFFIX_CHECK], [
2893   AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
2894   AC_MSG_CHECKING([constant suffix string for curl_off_t])
2895   #
2896   curl_suffix_curl_off_t="unknown"
2897   curl_suffix_curl_off_tu="unknown"
2898   #
2899   case AS_TR_SH([$1]) in
2900     long_long | __longlong | __longlong_t)
2901       tst_suffixes="LL::"
2902       ;;
2903     long)
2904       tst_suffixes="L::"
2905       ;;
2906     int)
2907       tst_suffixes="::"
2908       ;;
2909     __int64 | int64_t)
2910       tst_suffixes="LL:i64::"
2911       ;;
2912     __int32 | int32_t)
2913       tst_suffixes="L:i32::"
2914       ;;
2915     __int16 | int16_t)
2916       tst_suffixes="L:i16::"
2917       ;;
2918     *)
2919       AC_MSG_ERROR([unexpected data type $1])
2920       ;;
2921   esac
2922   #
2923   old_IFS=$IFS; IFS=':'
2924   for tmp_ssuf in $tst_suffixes ; do
2925     IFS=$old_IFS
2926     if test "x$curl_suffix_curl_off_t" = "xunknown"; then
2927       case $tmp_ssuf in
2928         i64 | i32 | i16)
2929           tmp_usuf="u$tmp_ssuf"
2930           ;;
2931         LL | L)
2932           tmp_usuf="U$tmp_ssuf"
2933           ;;
2934         *)
2935           tmp_usuf=""
2936           ;;
2937       esac
2938       AC_COMPILE_IFELSE([
2939         AC_LANG_PROGRAM([[
2940           $curl_includes_inttypes
2941           typedef $1 new_t;
2942         ]],[[
2943           new_t s1;
2944           new_t s2;
2945           s1 = -10$tmp_ssuf ;
2946           s2 =  20$tmp_ssuf ;
2947           if(s1 > s2)
2948             return 1;
2949         ]])
2950       ],[
2951         curl_suffix_curl_off_t="$tmp_ssuf"
2952         curl_suffix_curl_off_tu="$tmp_usuf"
2953       ])
2954     fi
2955   done
2956   IFS=$old_IFS
2957   #
2958   if test "x$curl_suffix_curl_off_t" = "xunknown"; then
2959     AC_MSG_ERROR([cannot find constant suffix string for curl_off_t.])
2960   else
2961     AC_MSG_RESULT([$curl_suffix_curl_off_t])
2962     AC_MSG_CHECKING([constant suffix string for unsigned curl_off_t])
2963     AC_MSG_RESULT([$curl_suffix_curl_off_tu])
2964   fi
2965   #
2966 ])
2967
2968
2969 dnl CURL_CONFIGURE_CURL_OFF_T
2970 dnl -------------------------------------------------
2971 dnl Find out suitable curl_off_t data type definition and associated
2972 dnl items, and make the appropriate definitions used in template file
2973 dnl include/curl/curlbuild.h.in to properly configure the library.
2974
2975 AC_DEFUN([CURL_CONFIGURE_CURL_OFF_T], [
2976   AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
2977   #
2978   AC_BEFORE([$0],[AC_SYS_LARGEFILE])dnl
2979   AC_BEFORE([$0],[CURL_CONFIGURE_REENTRANT])dnl
2980   AC_BEFORE([$0],[CURL_CHECK_AIX_ALL_SOURCE])dnl
2981   #
2982   if test -z "$SED"; then
2983     AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
2984   fi
2985   #
2986   AC_CHECK_SIZEOF(long)
2987   AC_CHECK_SIZEOF(void*)
2988   #
2989   if test -z "$ac_cv_sizeof_long" ||
2990     test "$ac_cv_sizeof_long" -eq "0"; then
2991     AC_MSG_ERROR([cannot find out size of long.])
2992   fi
2993   if test -z "$ac_cv_sizeof_voidp" ||
2994      test "$ac_cv_sizeof_voidp" -eq "0"; then
2995     AC_MSG_ERROR([cannot find out size of void*.])
2996   fi
2997   #
2998   x_LP64_long=""
2999   x_LP32_long=""
3000   x_LP16_long=""
3001   #
3002   if test "$ac_cv_sizeof_long" -eq "8" &&
3003      test "$ac_cv_sizeof_voidp" -ge "8"; then
3004     x_LP64_long="long"
3005   elif test "$ac_cv_sizeof_long" -eq "4" &&
3006        test "$ac_cv_sizeof_voidp" -ge "4"; then
3007     x_LP32_long="long"
3008   elif test "$ac_cv_sizeof_long" -eq "2" &&
3009        test "$ac_cv_sizeof_voidp" -ge "2"; then
3010     x_LP16_long="long"
3011   fi
3012   #
3013   dnl DO_CURL_OFF_T_CHECK results are stored in next 3 vars
3014   #
3015   curl_typeof_curl_off_t="unknown"
3016   curl_sizeof_curl_off_t="unknown"
3017   curl_format_curl_off_t="unknown"
3018   curl_format_curl_off_tu="unknown"
3019   #
3020   if test "$curl_typeof_curl_off_t" = "unknown"; then
3021     AC_MSG_CHECKING([for 64-bit curl_off_t data type])
3022     for t8 in          \
3023       "$x_LP64_long"   \
3024       'int64_t'        \
3025       '__int64'        \
3026       'long long'      \
3027       '__longlong'     \
3028       '__longlong_t'   ; do
3029       DO_CURL_OFF_T_CHECK([$t8], [8])
3030     done
3031     AC_MSG_RESULT([$curl_typeof_curl_off_t])
3032   fi
3033   if test "$curl_typeof_curl_off_t" = "unknown"; then
3034     AC_MSG_CHECKING([for 32-bit curl_off_t data type])
3035     for t4 in          \
3036       "$x_LP32_long"   \
3037       'int32_t'        \
3038       '__int32'        \
3039       'int'            ; do
3040       DO_CURL_OFF_T_CHECK([$t4], [4])
3041     done 
3042     AC_MSG_RESULT([$curl_typeof_curl_off_t])
3043   fi
3044   if test "$curl_typeof_curl_off_t" = "unknown"; then
3045     AC_MSG_CHECKING([for 16-bit curl_off_t data type])
3046     for t2 in          \
3047       "$x_LP16_long"   \
3048       'int16_t'        \
3049       '__int16'        \
3050       'int'            ; do
3051       DO_CURL_OFF_T_CHECK([$t2], [2])
3052     done
3053     AC_MSG_RESULT([$curl_typeof_curl_off_t])
3054   fi
3055   if test "$curl_typeof_curl_off_t" = "unknown"; then
3056     AC_MSG_ERROR([cannot find data type for curl_off_t.])
3057   fi
3058   #
3059   AC_MSG_CHECKING([size of curl_off_t])
3060   AC_MSG_RESULT([$curl_sizeof_curl_off_t])
3061   #
3062   AC_MSG_CHECKING([formatting string directive for curl_off_t])
3063   if test "$curl_format_curl_off_t" != "unknown"; then
3064     x_pull_headers="yes"
3065     curl_format_curl_off_t=`echo "$curl_format_curl_off_t" | "$SED" 's/[["]]//g'`
3066     curl_format_curl_off_tu=`echo "$curl_format_curl_off_t" | "$SED" 's/i$/u/'`
3067     curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/d$/u/'`
3068     curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/D$/U/'`
3069   else
3070     x_pull_headers="no"
3071     case AS_TR_SH([$curl_typeof_curl_off_t]) in
3072       long_long | __longlong | __longlong_t)
3073         curl_format_curl_off_t="lld"
3074         curl_format_curl_off_tu="llu"
3075         ;;
3076       long)
3077         curl_format_curl_off_t="ld"
3078         curl_format_curl_off_tu="lu"
3079         ;;
3080       int)
3081         curl_format_curl_off_t="d"
3082         curl_format_curl_off_tu="u"
3083         ;;
3084       __int64)
3085         curl_format_curl_off_t="I64d"
3086         curl_format_curl_off_tu="I64u"
3087         ;;
3088       __int32)
3089         curl_format_curl_off_t="I32d"
3090         curl_format_curl_off_tu="I32u"
3091         ;;
3092       __int16)
3093         curl_format_curl_off_t="I16d"
3094         curl_format_curl_off_tu="I16u"
3095         ;;
3096       *)
3097         AC_MSG_ERROR([cannot find print format string for curl_off_t.])
3098         ;;
3099     esac
3100   fi
3101   AC_MSG_RESULT(["$curl_format_curl_off_t"])
3102   #
3103   AC_MSG_CHECKING([formatting string directive for unsigned curl_off_t])
3104   AC_MSG_RESULT(["$curl_format_curl_off_tu"])
3105   #
3106   DO_CURL_OFF_T_SUFFIX_CHECK([$curl_typeof_curl_off_t])
3107   #
3108   if test "$x_pull_headers" = "yes"; then
3109     if test "x$ac_cv_header_sys_types_h" = "xyes"; then
3110       CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
3111     fi
3112     if test "x$ac_cv_header_stdint_h" = "xyes"; then
3113       CURL_DEFINE_UNQUOTED([CURL_PULL_STDINT_H])
3114     fi
3115     if test "x$ac_cv_header_inttypes_h" = "xyes"; then
3116       CURL_DEFINE_UNQUOTED([CURL_PULL_INTTYPES_H])
3117     fi
3118   fi
3119   #
3120   CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_OFF_T], [$curl_typeof_curl_off_t])
3121   CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_T], ["$curl_format_curl_off_t"])
3122   CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_TU], ["$curl_format_curl_off_tu"])
3123   CURL_DEFINE_UNQUOTED([CURL_FORMAT_OFF_T], ["%$curl_format_curl_off_t"])
3124   CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_OFF_T], [$curl_sizeof_curl_off_t])
3125   CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_T], [$curl_suffix_curl_off_t])
3126   CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_TU], [$curl_suffix_curl_off_tu])
3127   #
3128 ])
3129
3130
3131 dnl CURL_CHECK_WIN32_LARGEFILE
3132 dnl -------------------------------------------------
3133 dnl Check if curl's WIN32 large file will be used
3134
3135 AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
3136   AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
3137   AC_MSG_CHECKING([whether build target supports WIN32 file API])
3138   curl_win32_file_api="no"
3139   if test "$ac_cv_header_windows_h" = "yes"; then
3140     if test x"$enable_largefile" != "xno"; then
3141       AC_COMPILE_IFELSE([
3142         AC_LANG_PROGRAM([[
3143         ]],[[
3144 #if !defined(_WIN32_WCE) && \
3145     (defined(__MINGW32__) || \
3146     (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
3147           int dummy=1;
3148 #else
3149           WIN32 large file API not supported.
3150 #endif
3151         ]])
3152       ],[
3153         curl_win32_file_api="win32_large_files"
3154       ])
3155     fi
3156     if test "$curl_win32_file_api" = "no"; then
3157       AC_COMPILE_IFELSE([
3158         AC_LANG_PROGRAM([[
3159         ]],[[
3160 #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
3161           int dummy=1;
3162 #else
3163           WIN32 small file API not supported.
3164 #endif
3165         ]])
3166       ],[
3167         curl_win32_file_api="win32_small_files"
3168       ])
3169     fi
3170   fi
3171   case "$curl_win32_file_api" in
3172     win32_large_files)
3173       AC_MSG_RESULT([yes (large file enabled)])
3174       AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
3175         [Define to 1 if you are building a Windows target with large file support.])
3176       ;;
3177     win32_small_files)
3178       AC_MSG_RESULT([yes (large file disabled)])
3179       AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
3180         [Define to 1 if you are building a Windows target without large file support.])
3181       ;;
3182     *)
3183       AC_MSG_RESULT([no])
3184       ;;
3185   esac
3186 ])
3187
3188 dnl CURL_CHECK_PKGCONFIG ($module)
3189 dnl ------------------------
3190 dnl search for the pkg-config tool (if not cross-compiling). Set the PKGCONFIG
3191 dnl variable to hold the path to it, or 'no' if not found/present.
3192 dnl
3193 dnl If pkg-config is present, check that it has info about the $module or return
3194 dnl "no" anyway!
3195 dnl
3196
3197 AC_DEFUN([CURL_CHECK_PKGCONFIG], [
3198   if test x$cross_compiling != xyes; then
3199     dnl only do pkg-config magic when not cross-compiling
3200     AC_PATH_PROG( PKGCONFIG, pkg-config, no, $PATH:/usr/bin:/usr/local/bin)
3201
3202     if test x$PKGCONFIG != xno; then
3203       AC_MSG_CHECKING([for $1 options with pkg-config])
3204       dnl ask pkg-config about $1
3205       $PKGCONFIG --exists $1
3206       if test "$?" -ne "0"; then
3207         dnl pkg-config does not have info about the given module! set the
3208         dnl variable to 'no'
3209         PKGCONFIG="no"
3210         AC_MSG_RESULT([no])
3211       else
3212         AC_MSG_RESULT([found])
3213       fi
3214     fi
3215
3216   else
3217     PKGCONFIG="no"
3218   fi
3219 ])