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