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