1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
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.
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.
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
22 #***************************************************************************
25 dnl CURL_CHECK_COMPILER_HALT_ON_ERROR
26 dnl -------------------------------------------------
27 dnl Verifies if the compiler actually halts after the
28 dnl compilation phase without generating any object
29 dnl code file, when the source compiles with errors.
31 AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [
32 AC_MSG_CHECKING([if compiler halts on compilation errors])
36 force compilation error
40 AC_MSG_ERROR([compiler does not halt on compilation errors.])
47 dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
48 dnl -------------------------------------------------
49 dnl Verifies if the compiler actually halts after the
50 dnl compilation phase without generating any object
51 dnl code file, when the source code tries to define a
52 dnl type for a constant array with negative dimension.
54 AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
55 AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
56 AC_MSG_CHECKING([if compiler halts on negative sized arrays])
59 typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
65 AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
72 dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
73 dnl -------------------------------------------------
74 dnl Use the C preprocessor to find out if the given object-style symbol
75 dnl is defined and get its expansion. This macro will not use default
76 dnl includes even if no INCLUDES argument is given. This macro will run
77 dnl silently when invoked with three arguments. If the expansion would
78 dnl result in a set of double-quoted strings the returned expansion will
79 dnl actually be a single double-quoted string concatenating all them.
81 AC_DEFUN([CURL_CHECK_DEF], [
82 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
83 AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
84 if test -z "$SED"; then
85 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
87 if test -z "$GREP"; then
88 AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
90 ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
102 echo "DEBUG: preproc IF-ACTION branch for $1 -----" >&6
103 echo "DEBUG: ------- preproc source follows: " >&6
104 sed 's/^/cpp-src> /' conftest.$ac_ext >&6
105 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.yang2 1>conftest.yang1
106 echo "DEBUG: ------- preproc STDOUT follows: " >&6
107 sed 's/^/cpp-out> /' conftest.yang1 >&6
108 echo "DEBUG: ------- preproc STDERR follows: " >&6
109 sed 's/^/cpp-err> /' conftest.yang2 >&6
110 echo "DEBUG: ------- preproc STDERR ends in above line. " >&6
111 echo "DEBUG: ------- shell tmp_exp follows: " >&6
113 tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
114 "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
115 "$SED" 's/.*CURL_DEF_TOKEN[[ ]]//' 2>/dev/null | \
116 "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
118 echo "DEBUG: $tmp_exp" >&6
120 if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
122 echo "DEBUG: $tmp_exp" >&6
125 echo "DEBUG: ------- shell tmp_exp ends in above line. " >&6
130 echo "DEBUG: preproc ELSE-ACTION branch for $1 -----" >&6
131 echo "DEBUG: ------- preproc source follows: " >&6
132 sed 's/^/cpp-src> /' conftest.$ac_ext >&6
133 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.yang2 1>conftest.yang1
134 echo "DEBUG: ------- preproc STDOUT follows: " >&6
135 sed 's/^/cpp-out> /' conftest.yang1 >&6
136 echo "DEBUG: ------- preproc STDERR follows: " >&6
137 sed 's/^/cpp-err> /' conftest.yang2 >&6
138 echo "DEBUG: ------- preproc STDERR ends in above line. " >&6
145 if test -z "$tmp_exp"; then
146 AS_VAR_SET(ac_HaveDef, no)
147 ifelse($3,,[AC_MSG_RESULT([no])])
149 AS_VAR_SET(ac_HaveDef, yes)
150 AS_VAR_SET(ac_Def, $tmp_exp)
151 ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
153 AS_VAR_POPDEF([ac_Def])dnl
154 AS_VAR_POPDEF([ac_HaveDef])dnl
158 dnl CURL_CHECK_AIX_ALL_SOURCE
159 dnl -------------------------------------------------
160 dnl Provides a replacement of traditional AC_AIX with
161 dnl an uniform behaviour across all autoconf versions,
162 dnl and with our own placement rules.
164 AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
165 AH_VERBATIM([_ALL_SOURCE],
166 [/* Define to 1 if OS is AIX. */
170 AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
171 AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
172 AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
173 AC_EGREP_CPP([yes_this_is_aix],[
179 AC_DEFINE(_ALL_SOURCE)
186 dnl CURL_CHECK_HEADER_WINDOWS
187 dnl -------------------------------------------------
188 dnl Check for compilable and valid windows.h header
190 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
191 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
195 #ifndef WIN32_LEAN_AND_MEAN
196 #define WIN32_LEAN_AND_MEAN
200 #if defined(__CYGWIN__) || defined(__CEGCC__)
201 HAVE_WINDOWS_H shall not be defined.
207 ac_cv_header_windows_h="yes"
209 ac_cv_header_windows_h="no"
212 case "$ac_cv_header_windows_h" in
214 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
215 [Define to 1 if you have the windows.h header file.])
216 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
217 [Define to avoid automatic inclusion of winsock.h])
223 dnl CURL_CHECK_NATIVE_WINDOWS
224 dnl -------------------------------------------------
225 dnl Check if building a native Windows target
227 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
228 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
229 AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
230 if test "$ac_cv_header_windows_h" = "no"; then
231 ac_cv_native_windows="no"
236 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
237 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
240 Not a native Windows build target.
244 ac_cv_native_windows="yes"
246 ac_cv_native_windows="no"
250 case "$ac_cv_native_windows" in
252 AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
253 [Define to 1 if you are building a native Windows target.])
259 dnl CURL_CHECK_HEADER_WINSOCK
260 dnl -------------------------------------------------
261 dnl Check for compilable and valid winsock.h header
263 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
264 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
265 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
269 #ifndef WIN32_LEAN_AND_MEAN
270 #define WIN32_LEAN_AND_MEAN
275 #if defined(__CYGWIN__) || defined(__CEGCC__)
276 HAVE_WINSOCK_H shall not be defined.
278 int dummy=WSACleanup();
282 ac_cv_header_winsock_h="yes"
284 ac_cv_header_winsock_h="no"
287 case "$ac_cv_header_winsock_h" in
289 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
290 [Define to 1 if you have the winsock.h header file.])
296 dnl CURL_CHECK_HEADER_WINSOCK2
297 dnl -------------------------------------------------
298 dnl Check for compilable and valid winsock2.h header
300 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
301 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
302 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
306 #ifndef WIN32_LEAN_AND_MEAN
307 #define WIN32_LEAN_AND_MEAN
310 #include <winsock2.h>
312 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
313 HAVE_WINSOCK2_H shall not be defined.
315 int dummy=2*IPPROTO_ESP;
319 ac_cv_header_winsock2_h="yes"
321 ac_cv_header_winsock2_h="no"
324 case "$ac_cv_header_winsock2_h" in
326 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
327 [Define to 1 if you have the winsock2.h header file.])
333 dnl CURL_CHECK_HEADER_WS2TCPIP
334 dnl -------------------------------------------------
335 dnl Check for compilable and valid ws2tcpip.h header
337 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
338 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
339 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
343 #ifndef WIN32_LEAN_AND_MEAN
344 #define WIN32_LEAN_AND_MEAN
347 #include <winsock2.h>
348 #include <ws2tcpip.h>
350 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
351 HAVE_WS2TCPIP_H shall not be defined.
353 int dummy=2*IP_PKTINFO;
357 ac_cv_header_ws2tcpip_h="yes"
359 ac_cv_header_ws2tcpip_h="no"
362 case "$ac_cv_header_ws2tcpip_h" in
364 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
365 [Define to 1 if you have the ws2tcpip.h header file.])
371 dnl CURL_CHECK_HEADER_WINLDAP
372 dnl -------------------------------------------------
373 dnl Check for compilable and valid winldap.h header
375 AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
376 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
377 AC_CACHE_CHECK([for winldap.h], [ac_cv_header_winldap_h], [
381 #ifdef HAVE_WINDOWS_H
382 #ifndef WIN32_LEAN_AND_MEAN
383 #define WIN32_LEAN_AND_MEAN
389 #if defined(__CYGWIN__) || defined(__CEGCC__)
390 HAVE_WINLDAP_H shall not be defined.
392 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
393 ULONG res = ldap_unbind(ldp);
397 ac_cv_header_winldap_h="yes"
399 ac_cv_header_winldap_h="no"
402 case "$ac_cv_header_winldap_h" in
404 AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
405 [Define to 1 if you have the winldap.h header file.])
411 dnl CURL_CHECK_HEADER_WINBER
412 dnl -------------------------------------------------
413 dnl Check for compilable and valid winber.h header
415 AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
416 AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
417 AC_CACHE_CHECK([for winber.h], [ac_cv_header_winber_h], [
421 #ifdef HAVE_WINDOWS_H
422 #ifndef WIN32_LEAN_AND_MEAN
423 #define WIN32_LEAN_AND_MEAN
430 #if defined(__CYGWIN__) || defined(__CEGCC__)
431 HAVE_WINBER_H shall not be defined.
434 BerElement *bep = ber_init(bvp);
439 ac_cv_header_winber_h="yes"
441 ac_cv_header_winber_h="no"
444 case "$ac_cv_header_winber_h" in
446 AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
447 [Define to 1 if you have the winber.h header file.])
453 dnl CURL_CHECK_HEADER_LBER
454 dnl -------------------------------------------------
455 dnl Check for compilable and valid lber.h header,
456 dnl and check if it is needed even with ldap.h
458 AC_DEFUN([CURL_CHECK_HEADER_LBER], [
459 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
460 AC_CACHE_CHECK([for lber.h], [ac_cv_header_lber_h], [
464 #ifdef HAVE_WINDOWS_H
465 #ifndef WIN32_LEAN_AND_MEAN
466 #define WIN32_LEAN_AND_MEAN
470 #ifdef HAVE_SYS_TYPES_H
471 #include <sys/types.h>
475 #define NULL (void *)0
479 BerValue *bvp = NULL;
480 BerElement *bep = ber_init(bvp);
484 ac_cv_header_lber_h="yes"
486 ac_cv_header_lber_h="no"
489 if test "$ac_cv_header_lber_h" = "yes"; then
490 AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
491 [Define to 1 if you have the lber.h header file.])
496 #ifdef HAVE_WINDOWS_H
497 #ifndef WIN32_LEAN_AND_MEAN
498 #define WIN32_LEAN_AND_MEAN
502 #ifdef HAVE_SYS_TYPES_H
503 #include <sys/types.h>
507 #define NULL (void *)0
509 #ifndef LDAP_DEPRECATED
510 #define LDAP_DEPRECATED 1
514 BerValue *bvp = NULL;
515 BerElement *bep = ber_init(bvp);
519 curl_cv_need_header_lber_h="no"
521 curl_cv_need_header_lber_h="yes"
524 case "$curl_cv_need_header_lber_h" in
526 AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
527 [Define to 1 if you need the lber.h header file even with ldap.h])
534 dnl CURL_CHECK_HEADER_LDAP
535 dnl -------------------------------------------------
536 dnl Check for compilable and valid ldap.h header
538 AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
539 AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
540 AC_CACHE_CHECK([for ldap.h], [ac_cv_header_ldap_h], [
544 #ifdef HAVE_WINDOWS_H
545 #ifndef WIN32_LEAN_AND_MEAN
546 #define WIN32_LEAN_AND_MEAN
550 #ifdef HAVE_SYS_TYPES_H
551 #include <sys/types.h>
554 #ifndef LDAP_DEPRECATED
555 #define LDAP_DEPRECATED 1
562 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
563 int res = ldap_unbind(ldp);
566 ac_cv_header_ldap_h="yes"
568 ac_cv_header_ldap_h="no"
571 case "$ac_cv_header_ldap_h" in
573 AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
574 [Define to 1 if you have the ldap.h header file.])
580 dnl CURL_CHECK_HEADER_LDAP_SSL
581 dnl -------------------------------------------------
582 dnl Check for compilable and valid ldap_ssl.h header
584 AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
585 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
586 AC_CACHE_CHECK([for ldap_ssl.h], [ac_cv_header_ldap_ssl_h], [
590 #ifdef HAVE_WINDOWS_H
591 #ifndef WIN32_LEAN_AND_MEAN
592 #define WIN32_LEAN_AND_MEAN
596 #ifdef HAVE_SYS_TYPES_H
597 #include <sys/types.h>
600 #ifndef LDAP_DEPRECATED
601 #define LDAP_DEPRECATED 1
609 #include <ldap_ssl.h>
611 LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
614 ac_cv_header_ldap_ssl_h="yes"
616 ac_cv_header_ldap_ssl_h="no"
619 case "$ac_cv_header_ldap_ssl_h" in
621 AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
622 [Define to 1 if you have the ldap_ssl.h header file.])
628 dnl CURL_CHECK_HEADER_LDAPSSL
629 dnl -------------------------------------------------
630 dnl Check for compilable and valid ldapssl.h header
632 AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
633 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
634 AC_CACHE_CHECK([for ldapssl.h], [ac_cv_header_ldapssl_h], [
638 #ifdef HAVE_WINDOWS_H
639 #ifndef WIN32_LEAN_AND_MEAN
640 #define WIN32_LEAN_AND_MEAN
644 #ifdef HAVE_SYS_TYPES_H
645 #include <sys/types.h>
649 #define NULL (void *)0
651 #ifndef LDAP_DEPRECATED
652 #define LDAP_DEPRECATED 1
662 char *cert_label = NULL;
663 LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
666 ac_cv_header_ldapssl_h="yes"
668 ac_cv_header_ldapssl_h="no"
671 case "$ac_cv_header_ldapssl_h" in
673 AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
674 [Define to 1 if you have the ldapssl.h header file.])
680 dnl CURL_CHECK_LIBS_WINLDAP
681 dnl -------------------------------------------------
682 dnl Check for libraries needed for WINLDAP support,
683 dnl and prepended to LIBS any needed libraries.
684 dnl This macro can take an optional parameter with a
685 dnl white space separated list of libraries to check
686 dnl before the WINLDAP default ones.
688 AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
689 AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
691 AC_MSG_CHECKING([for WINLDAP libraries])
705 if test -z "$u_libs"; then
708 u_libs="$u_libs $l_lib"
713 curl_cv_save_LIBS="$LIBS"
714 curl_cv_ldap_LIBS="unknown"
716 for x_nlibs in '' "$u_libs" \
718 if test "$curl_cv_ldap_LIBS" = "unknown"; then
719 if test -z "$x_nlibs"; then
720 LIBS="$curl_cv_save_LIBS"
722 LIBS="$x_nlibs $curl_cv_save_LIBS"
727 #ifdef HAVE_WINDOWS_H
728 #ifndef WIN32_LEAN_AND_MEAN
729 #define WIN32_LEAN_AND_MEAN
732 #ifdef HAVE_WINLDAP_H
741 BerElement *bep = ber_init(bvp);
742 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
743 ULONG res = ldap_unbind(ldp);
747 curl_cv_ldap_LIBS="$x_nlibs"
752 LIBS="$curl_cv_save_LIBS"
754 case X-"$curl_cv_ldap_LIBS" in
756 AC_MSG_RESULT([cannot find WINLDAP libraries])
759 AC_MSG_RESULT([no additional lib required])
762 if test -z "$curl_cv_save_LIBS"; then
763 LIBS="$curl_cv_ldap_LIBS"
765 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
767 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
774 dnl CURL_CHECK_LIBS_LDAP
775 dnl -------------------------------------------------
776 dnl Check for libraries needed for LDAP support,
777 dnl and prepended to LIBS any needed libraries.
778 dnl This macro can take an optional parameter with a
779 dnl white space separated list of libraries to check
780 dnl before the default ones.
782 AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
783 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
785 AC_MSG_CHECKING([for LDAP libraries])
799 if test -z "$u_libs"; then
802 u_libs="$u_libs $l_lib"
807 curl_cv_save_LIBS="$LIBS"
808 curl_cv_ldap_LIBS="unknown"
810 for x_nlibs in '' "$u_libs" \
814 '-lldapssl -lldapx -lldapsdk' \
815 '-lldapsdk -lldapx -lldapssl' ; do
816 if test "$curl_cv_ldap_LIBS" = "unknown"; then
817 if test -z "$x_nlibs"; then
818 LIBS="$curl_cv_save_LIBS"
820 LIBS="$x_nlibs $curl_cv_save_LIBS"
825 #ifdef HAVE_WINDOWS_H
826 #ifndef WIN32_LEAN_AND_MEAN
827 #define WIN32_LEAN_AND_MEAN
831 #ifdef HAVE_SYS_TYPES_H
832 #include <sys/types.h>
836 #define NULL (void *)0
838 #ifndef LDAP_DEPRECATED
839 #define LDAP_DEPRECATED 1
848 BerValue *bvp = NULL;
849 BerElement *bep = ber_init(bvp);
850 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
851 int res = ldap_unbind(ldp);
855 curl_cv_ldap_LIBS="$x_nlibs"
860 LIBS="$curl_cv_save_LIBS"
862 case X-"$curl_cv_ldap_LIBS" in
864 AC_MSG_RESULT([cannot find LDAP libraries])
867 AC_MSG_RESULT([no additional lib required])
870 if test -z "$curl_cv_save_LIBS"; then
871 LIBS="$curl_cv_ldap_LIBS"
873 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
875 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
882 dnl CURL_CHECK_HEADER_MALLOC
883 dnl -------------------------------------------------
884 dnl Check for compilable and valid malloc.h header,
885 dnl and check if it is needed even with stdlib.h
887 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
888 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
893 void *p = malloc(10);
894 void *q = calloc(10,10);
899 ac_cv_header_malloc_h="yes"
901 ac_cv_header_malloc_h="no"
904 if test "$ac_cv_header_malloc_h" = "yes"; then
905 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
906 [Define to 1 if you have the malloc.h header file.])
912 void *p = malloc(10);
913 void *q = calloc(10,10);
918 curl_cv_need_header_malloc_h="no"
920 curl_cv_need_header_malloc_h="yes"
923 case "$curl_cv_need_header_malloc_h" in
925 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
926 [Define to 1 if you need the malloc.h header file even with stdlib.h])
933 dnl CURL_CHECK_TYPE_SOCKLEN_T
934 dnl -------------------------------------------------
935 dnl Check for existing socklen_t type, and provide
936 dnl an equivalent type if socklen_t not available
938 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
939 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
940 AC_CHECK_TYPE([socklen_t], ,[
941 dnl socklen_t not available
942 AC_CACHE_CHECK([for socklen_t equivalent],
943 [curl_cv_socklen_t_equiv], [
944 curl_cv_socklen_t_equiv="unknown"
945 for arg1 in 'int' 'SOCKET'; do
946 for arg2 in "struct sockaddr" void; do
947 for t in int size_t unsigned long "unsigned long"; do
948 if test "$curl_cv_socklen_t_equiv" = "unknown"; then
952 #ifdef HAVE_WINDOWS_H
953 #ifndef WIN32_LEAN_AND_MEAN
954 #define WIN32_LEAN_AND_MEAN
957 #ifdef HAVE_WINSOCK2_H
958 #include <winsock2.h>
960 #ifdef HAVE_WINSOCK_H
964 #define GETPEERNCALLCONV PASCAL
966 #ifdef HAVE_SYS_TYPES_H
967 #include <sys/types.h>
969 #ifdef HAVE_SYS_SOCKET_H
970 #include <sys/socket.h>
972 #define GETPEERNCALLCONV
974 extern int GETPEERNCALLCONV getpeername($arg1, $arg2 *, $t *);
977 getpeername(0,0,&len);
980 curl_cv_socklen_t_equiv="$t"
987 case "$curl_cv_socklen_t_equiv" in
989 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
992 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
993 [Type to use in place of socklen_t when system does not provide it.])
998 #ifdef HAVE_WINDOWS_H
999 #ifndef WIN32_LEAN_AND_MEAN
1000 #define WIN32_LEAN_AND_MEAN
1002 #include <windows.h>
1003 #ifdef HAVE_WINSOCK2_H
1004 #include <winsock2.h>
1005 #ifdef HAVE_WS2TCPIP_H
1006 #include <ws2tcpip.h>
1010 #ifdef HAVE_SYS_TYPES_H
1011 #include <sys/types.h>
1013 #ifdef HAVE_SYS_SOCKET_H
1014 #include <sys/socket.h>
1021 dnl CURL_CHECK_FUNC_GETNAMEINFO
1022 dnl -------------------------------------------------
1023 dnl Test if the getnameinfo function is available,
1024 dnl and check the types of five of its arguments.
1025 dnl If the function succeeds HAVE_GETNAMEINFO will be
1026 dnl defined, defining the types of the arguments in
1027 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
1028 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
1029 dnl and also defining the type qualifier of first
1030 dnl argument in GETNAMEINFO_QUAL_ARG1.
1032 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
1033 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
1034 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
1035 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
1037 AC_MSG_CHECKING([for getnameinfo])
1039 AC_LANG_FUNC_LINK_TRY([getnameinfo])
1041 AC_MSG_RESULT([yes])
1042 curl_cv_getnameinfo="yes"
1045 curl_cv_getnameinfo="no"
1048 if test "$curl_cv_getnameinfo" != "yes"; then
1049 AC_MSG_CHECKING([deeper for getnameinfo])
1056 AC_MSG_RESULT([yes])
1057 curl_cv_getnameinfo="yes"
1059 AC_MSG_RESULT([but still no])
1060 curl_cv_getnameinfo="no"
1064 if test "$curl_cv_getnameinfo" != "yes"; then
1065 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
1069 #ifdef HAVE_WINDOWS_H
1070 #ifndef WIN32_LEAN_AND_MEAN
1071 #define WIN32_LEAN_AND_MEAN
1073 #include <windows.h>
1074 #ifdef HAVE_WINSOCK2_H
1075 #include <winsock2.h>
1076 #ifdef HAVE_WS2TCPIP_H
1077 #include <ws2tcpip.h>
1081 #ifdef HAVE_SYS_TYPES_H
1082 #include <sys/types.h>
1084 #ifdef HAVE_SYS_SOCKET_H
1085 #include <sys/socket.h>
1092 getnameinfo(0, 0, 0, 0, 0, 0, 0);
1095 AC_MSG_RESULT([yes])
1096 curl_cv_getnameinfo="yes"
1098 AC_MSG_RESULT([but still no])
1099 curl_cv_getnameinfo="no"
1103 if test "$curl_cv_getnameinfo" = "yes"; then
1104 AC_CACHE_CHECK([types of arguments for getnameinfo],
1105 [curl_cv_func_getnameinfo_args], [
1106 curl_cv_func_getnameinfo_args="unknown"
1107 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
1108 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
1109 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
1110 for gni_arg7 in 'int' 'unsigned int'; do
1111 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1115 #ifdef HAVE_WINDOWS_H
1116 #ifndef WIN32_LEAN_AND_MEAN
1117 #define WIN32_LEAN_AND_MEAN
1119 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
1121 #define _WIN32_WINNT 0x0501
1123 #include <windows.h>
1124 #ifdef HAVE_WINSOCK2_H
1125 #include <winsock2.h>
1126 #ifdef HAVE_WS2TCPIP_H
1127 #include <ws2tcpip.h>
1130 #define GNICALLCONV WSAAPI
1132 #ifdef HAVE_SYS_TYPES_H
1133 #include <sys/types.h>
1135 #ifdef HAVE_SYS_SOCKET_H
1136 #include <sys/socket.h>
1143 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
1149 $gni_arg46 hostlen=0;
1150 $gni_arg46 servlen=0;
1152 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
1155 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
1163 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1164 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
1165 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
1167 gni_prev_IFS=$IFS; IFS=','
1168 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
1172 gni_qual_type_arg1=$[1]
1174 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
1175 [Define to the type of arg 2 for getnameinfo.])
1176 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
1177 [Define to the type of args 4 and 6 for getnameinfo.])
1178 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
1179 [Define to the type of arg 7 for getnameinfo.])
1183 case $prev_sh_opts in
1191 case "$gni_qual_type_arg1" in
1194 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
1198 gni_type_arg1=$gni_qual_type_arg1
1202 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
1203 [Define to the type qualifier of arg 1 for getnameinfo.])
1204 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
1205 [Define to the type of arg 1 for getnameinfo.])
1207 case $prev_sh_opts in
1215 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
1216 [Define to 1 if you have the getnameinfo function.])
1217 ac_cv_func_getnameinfo="yes"
1223 dnl TYPE_SOCKADDR_STORAGE
1224 dnl -------------------------------------------------
1225 dnl Check for struct sockaddr_storage. Most IPv6-enabled
1226 dnl hosts have it, but AIX 4.3 is one known exception.
1228 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
1230 AC_CHECK_TYPE([struct sockaddr_storage],
1231 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
1232 [if struct sockaddr_storage is defined]), ,
1235 #ifdef HAVE_WINDOWS_H
1236 #ifndef WIN32_LEAN_AND_MEAN
1237 #define WIN32_LEAN_AND_MEAN
1239 #include <windows.h>
1240 #ifdef HAVE_WINSOCK2_H
1241 #include <winsock2.h>
1244 #ifdef HAVE_SYS_TYPES_H
1245 #include <sys/types.h>
1247 #ifdef HAVE_SYS_SOCKET_H
1248 #include <sys/socket.h>
1250 #ifdef HAVE_NETINET_IN_H
1251 #include <netinet/in.h>
1253 #ifdef HAVE_ARPA_INET_H
1254 #include <arpa/inet.h>
1261 dnl CURL_CHECK_NI_WITHSCOPEID
1262 dnl -------------------------------------------------
1263 dnl Check for working NI_WITHSCOPEID in getnameinfo()
1265 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
1266 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
1267 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
1268 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
1269 netdb.h netinet/in.h arpa/inet.h)
1271 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
1272 [ac_cv_working_ni_withscopeid], [
1278 #ifdef HAVE_SYS_TYPES_H
1279 #include <sys/types.h>
1281 #ifdef HAVE_SYS_SOCKET_H
1282 #include <sys/socket.h>
1287 #ifdef HAVE_NETINET_IN_H
1288 #include <netinet/in.h>
1290 #ifdef HAVE_ARPA_INET_H
1291 #include <arpa/inet.h>
1294 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
1295 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
1296 struct sockaddr_storage sa;
1298 unsigned char sa[256];
1300 char hostbuf[NI_MAXHOST];
1302 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
1303 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
1304 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1305 int fd = socket(AF_INET6, SOCK_STREAM, 0);
1308 return 1; /* Error creating socket */
1310 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
1312 perror("getsockname()");
1313 return 2; /* Error retrieving socket name */
1315 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
1317 printf("rc = %s\n", gai_strerror(rc));
1318 return 3; /* Error translating socket address */
1320 return 0; /* Ok, NI_WITHSCOPEID works */
1322 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
1324 ]]) # AC-LANG-PROGRAM
1326 # Exit code == 0. Program worked.
1327 ac_cv_working_ni_withscopeid="yes"
1329 # Exit code != 0. Program failed.
1330 ac_cv_working_ni_withscopeid="no"
1332 # Program is not run when cross-compiling. So we assume
1333 # NI_WITHSCOPEID will work if we are able to compile it.
1336 #include <sys/types.h>
1337 #include <sys/socket.h>
1340 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1343 ac_cv_working_ni_withscopeid="yes"
1345 ac_cv_working_ni_withscopeid="no"
1346 ]) # AC-COMPILE-IFELSE
1349 case "$ac_cv_working_ni_withscopeid" in
1351 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
1352 [Define to 1 if NI_WITHSCOPEID exists and works.])
1358 dnl CURL_CHECK_FUNC_RECV
1359 dnl -------------------------------------------------
1360 dnl Test if the socket recv() function is available,
1361 dnl and check its return type and the types of its
1362 dnl arguments. If the function succeeds HAVE_RECV
1363 dnl will be defined, defining the types of the arguments
1364 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
1365 dnl and RECV_TYPE_ARG4, defining the type of the function
1366 dnl return value in RECV_TYPE_RETV.
1368 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
1369 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1370 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1371 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1373 AC_MSG_CHECKING([for recv])
1377 #ifdef HAVE_WINDOWS_H
1378 #ifndef WIN32_LEAN_AND_MEAN
1379 #define WIN32_LEAN_AND_MEAN
1381 #include <windows.h>
1382 #ifdef HAVE_WINSOCK2_H
1383 #include <winsock2.h>
1385 #ifdef HAVE_WINSOCK_H
1386 #include <winsock.h>
1390 #ifdef HAVE_SYS_TYPES_H
1391 #include <sys/types.h>
1393 #ifdef HAVE_SYS_SOCKET_H
1394 #include <sys/socket.h>
1401 AC_MSG_RESULT([yes])
1408 if test "$curl_cv_recv" = "yes"; then
1409 AC_CACHE_CHECK([types of args and return type for recv],
1410 [curl_cv_func_recv_args], [
1411 curl_cv_func_recv_args="unknown"
1412 for recv_retv in 'int' 'ssize_t'; do
1413 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1414 for recv_arg2 in 'char *' 'void *'; do
1415 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1416 for recv_arg4 in 'int' 'unsigned int'; do
1417 if test "$curl_cv_func_recv_args" = "unknown"; then
1421 #ifdef HAVE_WINDOWS_H
1422 #ifndef WIN32_LEAN_AND_MEAN
1423 #define WIN32_LEAN_AND_MEAN
1425 #include <windows.h>
1426 #ifdef HAVE_WINSOCK2_H
1427 #include <winsock2.h>
1429 #ifdef HAVE_WINSOCK_H
1430 #include <winsock.h>
1433 #define RECVCALLCONV PASCAL
1435 #ifdef HAVE_SYS_TYPES_H
1436 #include <sys/types.h>
1438 #ifdef HAVE_SYS_SOCKET_H
1439 #include <sys/socket.h>
1441 #define RECVCALLCONV
1443 extern $recv_retv RECVCALLCONV
1444 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
1450 $recv_retv res = recv(s, buf, len, flags);
1453 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
1462 if test "$curl_cv_func_recv_args" = "unknown"; then
1463 AC_MSG_ERROR([Cannot find proper types to use for recv args])
1465 recv_prev_IFS=$IFS; IFS=','
1466 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
1470 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
1471 [Define to the type of arg 1 for recv.])
1472 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
1473 [Define to the type of arg 2 for recv.])
1474 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
1475 [Define to the type of arg 3 for recv.])
1476 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
1477 [Define to the type of arg 4 for recv.])
1478 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
1479 [Define to the function return type for recv.])
1481 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
1482 [Define to 1 if you have the recv function.])
1483 ac_cv_func_recv="yes"
1486 AC_MSG_ERROR([Unable to link function recv])
1491 dnl CURL_CHECK_FUNC_SEND
1492 dnl -------------------------------------------------
1493 dnl Test if the socket send() function is available,
1494 dnl and check its return type and the types of its
1495 dnl arguments. If the function succeeds HAVE_SEND
1496 dnl will be defined, defining the types of the arguments
1497 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
1498 dnl and SEND_TYPE_ARG4, defining the type of the function
1499 dnl return value in SEND_TYPE_RETV, and also defining the
1500 dnl type qualifier of second argument in SEND_QUAL_ARG2.
1502 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
1503 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1504 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1505 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1507 AC_MSG_CHECKING([for send])
1511 #ifdef HAVE_WINDOWS_H
1512 #ifndef WIN32_LEAN_AND_MEAN
1513 #define WIN32_LEAN_AND_MEAN
1515 #include <windows.h>
1516 #ifdef HAVE_WINSOCK2_H
1517 #include <winsock2.h>
1519 #ifdef HAVE_WINSOCK_H
1520 #include <winsock.h>
1524 #ifdef HAVE_SYS_TYPES_H
1525 #include <sys/types.h>
1527 #ifdef HAVE_SYS_SOCKET_H
1528 #include <sys/socket.h>
1535 AC_MSG_RESULT([yes])
1542 if test "$curl_cv_send" = "yes"; then
1543 AC_CACHE_CHECK([types of args and return type for send],
1544 [curl_cv_func_send_args], [
1545 curl_cv_func_send_args="unknown"
1546 for send_retv in 'int' 'ssize_t'; do
1547 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1548 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
1549 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1550 for send_arg4 in 'int' 'unsigned int'; do
1551 if test "$curl_cv_func_send_args" = "unknown"; then
1555 #ifdef HAVE_WINDOWS_H
1556 #ifndef WIN32_LEAN_AND_MEAN
1557 #define WIN32_LEAN_AND_MEAN
1559 #include <windows.h>
1560 #ifdef HAVE_WINSOCK2_H
1561 #include <winsock2.h>
1563 #ifdef HAVE_WINSOCK_H
1564 #include <winsock.h>
1567 #define SENDCALLCONV PASCAL
1569 #ifdef HAVE_SYS_TYPES_H
1570 #include <sys/types.h>
1572 #ifdef HAVE_SYS_SOCKET_H
1573 #include <sys/socket.h>
1575 #define SENDCALLCONV
1577 extern $send_retv SENDCALLCONV
1578 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1583 $send_retv res = send(s, 0, len, flags);
1586 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1595 if test "$curl_cv_func_send_args" = "unknown"; then
1596 AC_MSG_ERROR([Cannot find proper types to use for send args])
1598 send_prev_IFS=$IFS; IFS=','
1599 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1603 send_qual_type_arg2=$[2]
1605 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1606 [Define to the type of arg 1 for send.])
1607 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1608 [Define to the type of arg 3 for send.])
1609 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1610 [Define to the type of arg 4 for send.])
1611 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1612 [Define to the function return type for send.])
1616 case $prev_sh_opts in
1624 case "$send_qual_type_arg2" in
1626 send_qual_arg2=const
1627 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1631 send_type_arg2=$send_qual_type_arg2
1635 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1636 [Define to the type qualifier of arg 2 for send.])
1637 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1638 [Define to the type of arg 2 for send.])
1640 case $prev_sh_opts in
1648 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1649 [Define to 1 if you have the send function.])
1650 ac_cv_func_send="yes"
1653 AC_MSG_ERROR([Unable to link function send])
1658 dnl CURL_CHECK_FUNC_RECVFROM
1659 dnl -------------------------------------------------
1660 dnl Test if the socket recvfrom() function is available,
1661 dnl and check its return type and the types of its
1662 dnl arguments. If the function succeeds HAVE_RECVFROM
1663 dnl will be defined, defining the types of the arguments
1664 dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
1665 dnl to RECVFROM_TYPE_ARG6, defining also the type of the
1666 dnl function return value in RECVFROM_TYPE_RETV.
1667 dnl Notice that the types returned for pointer arguments
1668 dnl will actually be the type pointed by the pointer.
1670 AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
1671 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1672 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1673 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1675 AC_MSG_CHECKING([for recvfrom])
1679 #ifdef HAVE_WINDOWS_H
1680 #ifndef WIN32_LEAN_AND_MEAN
1681 #define WIN32_LEAN_AND_MEAN
1683 #include <windows.h>
1684 #ifdef HAVE_WINSOCK2_H
1685 #include <winsock2.h>
1687 #ifdef HAVE_WINSOCK_H
1688 #include <winsock.h>
1692 #ifdef HAVE_SYS_TYPES_H
1693 #include <sys/types.h>
1695 #ifdef HAVE_SYS_SOCKET_H
1696 #include <sys/socket.h>
1700 recvfrom(0, 0, 0, 0, 0, 0);
1703 AC_MSG_RESULT([yes])
1704 curl_cv_recvfrom="yes"
1707 curl_cv_recvfrom="no"
1710 if test "$curl_cv_recvfrom" = "yes"; then
1711 AC_CACHE_CHECK([types of args and return type for recvfrom],
1712 [curl_cv_func_recvfrom_args], [
1713 curl_cv_func_recvfrom_args="unknown"
1714 for recvfrom_retv in 'int' 'ssize_t'; do
1715 for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1716 for recvfrom_arg2 in 'char *' 'void *'; do
1717 for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1718 for recvfrom_arg4 in 'int' 'unsigned int'; do
1719 for recvfrom_arg5 in 'struct sockaddr *' 'void *'; do
1720 for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
1721 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1725 #ifdef HAVE_WINDOWS_H
1726 #ifndef WIN32_LEAN_AND_MEAN
1727 #define WIN32_LEAN_AND_MEAN
1729 #include <windows.h>
1730 #ifdef HAVE_WINSOCK2_H
1731 #include <winsock2.h>
1733 #ifdef HAVE_WINSOCK_H
1734 #include <winsock.h>
1737 #define RECVFROMCALLCONV PASCAL
1739 #ifdef HAVE_SYS_TYPES_H
1740 #include <sys/types.h>
1742 #ifdef HAVE_SYS_SOCKET_H
1743 #include <sys/socket.h>
1745 #define RECVFROMCALLCONV
1747 extern $recvfrom_retv RECVFROMCALLCONV
1748 recvfrom($recvfrom_arg1, $recvfrom_arg2,
1749 $recvfrom_arg3, $recvfrom_arg4,
1750 $recvfrom_arg5, $recvfrom_arg6);
1753 $recvfrom_arg2 buf=0;
1754 $recvfrom_arg3 len=0;
1755 $recvfrom_arg4 flags=0;
1756 $recvfrom_arg5 addr=0;
1757 $recvfrom_arg6 addrlen=0;
1758 $recvfrom_retv res=0;
1759 res = recvfrom(s, buf, len, flags, addr, addrlen);
1762 curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
1773 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1774 AC_MSG_ERROR([Cannot find proper types to use for recvfrom args])
1776 recvfrom_prev_IFS=$IFS; IFS=','
1777 set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
1778 IFS=$recvfrom_prev_IFS
1781 recvfrom_ptrt_arg2=$[2]
1782 recvfrom_ptrt_arg5=$[5]
1783 recvfrom_ptrt_arg6=$[6]
1785 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
1786 [Define to the type of arg 1 for recvfrom.])
1787 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
1788 [Define to the type of arg 3 for recvfrom.])
1789 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
1790 [Define to the type of arg 4 for recvfrom.])
1791 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
1792 [Define to the function return type for recvfrom.])
1796 case $prev_sh_opts in
1804 recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
1805 recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
1806 recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
1808 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
1809 [Define to the type pointed by arg 2 for recvfrom.])
1810 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
1811 [Define to the type pointed by arg 5 for recvfrom.])
1812 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
1813 [Define to the type pointed by arg 6 for recvfrom.])
1815 if test "$recvfrom_type_arg2" = "void"; then
1816 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2_IS_VOID, 1,
1817 [Define to 1 if the type pointed by arg 2 for recvfrom is void.])
1819 if test "$recvfrom_type_arg5" = "void"; then
1820 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5_IS_VOID, 1,
1821 [Define to 1 if the type pointed by arg 5 for recvfrom is void.])
1823 if test "$recvfrom_type_arg6" = "void"; then
1824 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6_IS_VOID, 1,
1825 [Define to 1 if the type pointed by arg 6 for recvfrom is void.])
1828 case $prev_sh_opts in
1836 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1837 [Define to 1 if you have the recvfrom function.])
1838 ac_cv_func_recvfrom="yes"
1841 AC_MSG_ERROR([Unable to link function recvfrom])
1846 dnl CURL_CHECK_MSG_NOSIGNAL
1847 dnl -------------------------------------------------
1848 dnl Check for MSG_NOSIGNAL
1850 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1851 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1852 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1856 #ifdef HAVE_WINDOWS_H
1857 #ifndef WIN32_LEAN_AND_MEAN
1858 #define WIN32_LEAN_AND_MEAN
1860 #include <windows.h>
1861 #ifdef HAVE_WINSOCK2_H
1862 #include <winsock2.h>
1864 #ifdef HAVE_WINSOCK_H
1865 #include <winsock.h>
1869 #ifdef HAVE_SYS_TYPES_H
1870 #include <sys/types.h>
1872 #ifdef HAVE_SYS_SOCKET_H
1873 #include <sys/socket.h>
1877 int flag=MSG_NOSIGNAL;
1880 ac_cv_msg_nosignal="yes"
1882 ac_cv_msg_nosignal="no"
1885 case "$ac_cv_msg_nosignal" in
1887 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1888 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1894 dnl CURL_CHECK_STRUCT_TIMEVAL
1895 dnl -------------------------------------------------
1896 dnl Check for timeval struct
1898 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1899 AC_REQUIRE([AC_HEADER_TIME])dnl
1900 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1901 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1902 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1903 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1907 #ifdef HAVE_WINDOWS_H
1908 #ifndef WIN32_LEAN_AND_MEAN
1909 #define WIN32_LEAN_AND_MEAN
1911 #include <windows.h>
1912 #ifdef HAVE_WINSOCK2_H
1913 #include <winsock2.h>
1915 #ifdef HAVE_WINSOCK_H
1916 #include <winsock.h>
1920 #ifdef HAVE_SYS_TYPES_H
1921 #include <sys/types.h>
1923 #ifdef HAVE_SYS_TIME_H
1924 #include <sys/time.h>
1925 #ifdef TIME_WITH_SYS_TIME
1939 ac_cv_struct_timeval="yes"
1941 ac_cv_struct_timeval="no"
1944 case "$ac_cv_struct_timeval" in
1946 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1947 [Define to 1 if you have the timeval struct.])
1953 dnl TYPE_SIG_ATOMIC_T
1954 dnl -------------------------------------------------
1955 dnl Check if the sig_atomic_t type is available, and
1956 dnl verify if it is already defined as volatile.
1958 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1959 AC_CHECK_HEADERS(signal.h)
1960 AC_CHECK_TYPE([sig_atomic_t],[
1961 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1962 [Define to 1 if sig_atomic_t is an available typedef.])
1964 #ifdef HAVE_SIGNAL_H
1968 case "$ac_cv_type_sig_atomic_t" in
1971 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1974 #ifdef HAVE_SIGNAL_H
1978 static volatile sig_atomic_t dummy = 0;
1982 ac_cv_sig_atomic_t_volatile="no"
1984 AC_MSG_RESULT([yes])
1985 ac_cv_sig_atomic_t_volatile="yes"
1988 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1989 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1990 [Define to 1 if sig_atomic_t is already defined as volatile.])
1997 dnl CURL_CHECK_NONBLOCKING_SOCKET
1998 dnl -------------------------------------------------
1999 dnl Check for how to set a socket to non-blocking state. There seems to exist
2000 dnl four known different ways, with the one used almost everywhere being POSIX
2001 dnl and XPG3, while the other different ways for different systems (old BSD,
2002 dnl Windows and Amiga).
2004 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
2005 dnl O_NONBLOCK define is found but does not work. This condition is attempted
2006 dnl to get caught in this script by using an excessive number of #ifdefs...
2008 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [
2009 AC_MSG_CHECKING([non-blocking sockets style])
2014 /* headers for O_NONBLOCK test */
2015 #include <sys/types.h>
2019 #if defined(sun) || defined(__sun__) || \
2020 defined(__SUNPRO_C) || defined(__SUNPRO_CC)
2021 # if defined(__SVR4) || defined(__srv4__)
2022 # define PLATFORM_SOLARIS
2024 # define PLATFORM_SUNOS4
2027 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
2028 # define PLATFORM_AIX_V3
2031 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
2032 #error "O_NONBLOCK does not work on this platform"
2035 /* O_NONBLOCK source test */
2037 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
2040 dnl the O_NONBLOCK test was fine
2041 nonblock="O_NONBLOCK"
2042 AC_DEFINE(HAVE_O_NONBLOCK, 1,
2043 [use O_NONBLOCK for non-blocking sockets])
2046 if test "$nonblock" = "unknown"; then
2049 /* headers for FIONBIO test */
2051 #include <stropts.h>
2053 /* FIONBIO source test (old-style unix) */
2055 int flags = ioctl(socket, FIONBIO, &flags);
2058 dnl FIONBIO test was good
2060 AC_DEFINE(HAVE_FIONBIO, 1,
2061 [use FIONBIO for non-blocking sockets])
2065 if test "$nonblock" = "unknown"; then
2068 /* headers for ioctlsocket test (Windows) */
2070 #ifdef HAVE_WINDOWS_H
2071 #ifndef WIN32_LEAN_AND_MEAN
2072 #define WIN32_LEAN_AND_MEAN
2074 #include <windows.h>
2075 #ifdef HAVE_WINSOCK2_H
2076 #include <winsock2.h>
2078 #ifdef HAVE_WINSOCK_H
2079 #include <winsock.h>
2084 /* ioctlsocket source code (Windows) */
2086 unsigned long flags = 0;
2087 sd = socket(0, 0, 0);
2088 ioctlsocket(sd, FIONBIO, &flags);
2091 dnl ioctlsocket test was good
2092 nonblock="ioctlsocket"
2093 AC_DEFINE(HAVE_IOCTLSOCKET, 1,
2094 [use ioctlsocket() for non-blocking sockets])
2098 if test "$nonblock" = "unknown"; then
2101 /* headers for IoctlSocket test (Amiga?) */
2102 #include <sys/ioctl.h>
2104 /* IoctlSocket source code (Amiga?) */
2106 int flags = IoctlSocket(socket, FIONBIO, (long)1);
2109 dnl Ioctlsocket test was good
2110 nonblock="IoctlSocket"
2111 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1,
2112 [use Ioctlsocket() for non-blocking sockets])
2116 if test "$nonblock" = "unknown"; then
2119 /* headers for SO_NONBLOCK test (BeOS) */
2122 /* SO_NONBLOCK source code (BeOS) */
2125 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
2128 dnl the SO_NONBLOCK test was good
2129 nonblock="SO_NONBLOCK"
2130 AC_DEFINE(HAVE_SO_NONBLOCK, 1,
2131 [use SO_NONBLOCK for non-blocking sockets])
2135 AC_MSG_RESULT($nonblock)
2137 if test "$nonblock" = "unknown"; then
2138 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1,
2139 [disabled non-blocking sockets])
2140 AC_MSG_WARN([non-block sockets disabled])
2146 dnl -------------------------------------------------
2147 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
2148 dnl and a few other things.
2150 AC_DEFUN([TYPE_IN_ADDR_T], [
2151 AC_CHECK_TYPE([in_addr_t], ,[
2152 dnl in_addr_t not available
2153 AC_CACHE_CHECK([for in_addr_t equivalent],
2154 [curl_cv_in_addr_t_equiv], [
2155 curl_cv_in_addr_t_equiv="unknown"
2156 for t in "unsigned long" int size_t unsigned long; do
2157 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
2161 #ifdef HAVE_WINDOWS_H
2162 #ifndef WIN32_LEAN_AND_MEAN
2163 #define WIN32_LEAN_AND_MEAN
2165 #include <windows.h>
2166 #ifdef HAVE_WINSOCK2_H
2167 #include <winsock2.h>
2169 #ifdef HAVE_WINSOCK_H
2170 #include <winsock.h>
2174 #ifdef HAVE_SYS_TYPES_H
2175 #include <sys/types.h>
2177 #ifdef HAVE_SYS_SOCKET_H
2178 #include <sys/socket.h>
2180 #ifdef HAVE_NETINET_IN_H
2181 #include <netinet/in.h>
2183 #ifdef HAVE_ARPA_INET_H
2184 #include <arpa/inet.h>
2188 $t data = inet_addr ("1.2.3.4");
2191 curl_cv_in_addr_t_equiv="$t"
2196 case "$curl_cv_in_addr_t_equiv" in
2198 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
2201 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
2202 [Type to use in place of in_addr_t when system does not provide it.])
2207 #ifdef HAVE_WINDOWS_H
2208 #ifndef WIN32_LEAN_AND_MEAN
2209 #define WIN32_LEAN_AND_MEAN
2211 #include <windows.h>
2212 #ifdef HAVE_WINSOCK2_H
2213 #include <winsock2.h>
2215 #ifdef HAVE_WINSOCK_H
2216 #include <winsock.h>
2220 #ifdef HAVE_SYS_TYPES_H
2221 #include <sys/types.h>
2223 #ifdef HAVE_SYS_SOCKET_H
2224 #include <sys/socket.h>
2226 #ifdef HAVE_NETINET_IN_H
2227 #include <netinet/in.h>
2229 #ifdef HAVE_ARPA_INET_H
2230 #include <arpa/inet.h>
2237 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
2238 dnl -------------------------------------------------
2239 dnl Check if monotonic clock_gettime is available.
2241 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
2242 AC_REQUIRE([AC_HEADER_TIME])dnl
2243 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
2244 AC_MSG_CHECKING([for monotonic clock_gettime])
2247 #ifdef HAVE_SYS_TYPES_H
2248 #include <sys/types.h>
2250 #ifdef HAVE_SYS_TIME_H
2251 #include <sys/time.h>
2252 #ifdef TIME_WITH_SYS_TIME
2262 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
2265 AC_MSG_RESULT([yes])
2266 ac_cv_func_clock_gettime="yes"
2269 ac_cv_func_clock_gettime="no"
2271 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
2272 dnl until library linking and run-time checks for clock_gettime succeed.
2276 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
2277 dnl -------------------------------------------------
2278 dnl If monotonic clock_gettime is available then,
2279 dnl check and prepended to LIBS any needed libraries.
2281 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
2282 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
2284 if test "$ac_cv_func_clock_gettime" = "yes"; then
2286 AC_MSG_CHECKING([for clock_gettime in libraries])
2288 curl_cv_save_LIBS="$LIBS"
2289 curl_cv_gclk_LIBS="unknown"
2291 for x_xlibs in '' '-lrt' '-lposix4' ; do
2292 if test "$curl_cv_gclk_LIBS" = "unknown"; then
2293 if test -z "$x_xlibs"; then
2294 LIBS="$curl_cv_save_LIBS"
2296 LIBS="$x_xlibs $curl_cv_save_LIBS"
2300 #ifdef HAVE_SYS_TYPES_H
2301 #include <sys/types.h>
2303 #ifdef HAVE_SYS_TIME_H
2304 #include <sys/time.h>
2305 #ifdef TIME_WITH_SYS_TIME
2315 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
2318 curl_cv_gclk_LIBS="$x_xlibs"
2323 LIBS="$curl_cv_save_LIBS"
2325 case X-"$curl_cv_gclk_LIBS" in
2327 AC_MSG_RESULT([cannot find clock_gettime])
2328 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
2329 ac_cv_func_clock_gettime="no"
2332 AC_MSG_RESULT([no additional lib required])
2333 ac_cv_func_clock_gettime="yes"
2336 if test -z "$curl_cv_save_LIBS"; then
2337 LIBS="$curl_cv_gclk_LIBS"
2339 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
2341 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
2342 ac_cv_func_clock_gettime="yes"
2346 dnl only do runtime verification when not cross-compiling
2347 if test "x$cross_compiling" != "xyes" &&
2348 test "$ac_cv_func_clock_gettime" = "yes"; then
2349 AC_MSG_CHECKING([if monotonic clock_gettime works])
2352 #ifdef HAVE_SYS_TYPES_H
2353 #include <sys/types.h>
2355 #ifdef HAVE_SYS_TIME_H
2356 #include <sys/time.h>
2357 #ifdef TIME_WITH_SYS_TIME
2367 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
2373 AC_MSG_RESULT([yes])
2376 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
2377 ac_cv_func_clock_gettime="no"
2378 LIBS="$curl_cv_save_LIBS"
2382 case "$ac_cv_func_clock_gettime" in
2384 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
2385 [Define to 1 if you have the clock_gettime function and monotonic timer.])
2394 dnl CURL_CHECK_FUNC_SELECT
2395 dnl -------------------------------------------------
2396 dnl Test if the socket select() function is available,
2397 dnl and check its return type and the types of its
2398 dnl arguments. If the function succeeds HAVE_SELECT
2399 dnl will be defined, defining the types of the
2400 dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
2401 dnl and SELECT_TYPE_ARG5, defining the type of the
2402 dnl function return value in SELECT_TYPE_RETV, and
2403 dnl also defining the type qualifier of fifth argument
2404 dnl in SELECT_QUAL_ARG5.
2406 AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
2407 AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
2408 AC_CHECK_HEADERS(sys/select.h sys/socket.h)
2410 AC_MSG_CHECKING([for select])
2414 #ifdef HAVE_WINDOWS_H
2415 #ifndef WIN32_LEAN_AND_MEAN
2416 #define WIN32_LEAN_AND_MEAN
2418 #include <windows.h>
2419 #ifdef HAVE_WINSOCK2_H
2420 #include <winsock2.h>
2422 #ifdef HAVE_WINSOCK_H
2423 #include <winsock.h>
2427 #ifdef HAVE_SYS_TYPES_H
2428 #include <sys/types.h>
2430 #ifdef HAVE_SYS_TIME_H
2431 #include <sys/time.h>
2432 #ifdef TIME_WITH_SYS_TIME
2440 #ifndef HAVE_WINDOWS_H
2441 #ifdef HAVE_SYS_SELECT_H
2442 #include <sys/select.h>
2444 #ifdef HAVE_SYS_SOCKET_H
2445 #include <sys/socket.h>
2449 select(0, 0, 0, 0, 0);
2452 AC_MSG_RESULT([yes])
2453 curl_cv_select="yes"
2459 if test "$curl_cv_select" = "yes"; then
2460 AC_CACHE_CHECK([types of args and return type for select],
2461 [curl_cv_func_select_args], [
2462 curl_cv_func_select_args="unknown"
2463 for sel_retv in 'int' 'ssize_t'; do
2464 for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
2465 for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
2466 for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
2467 if test "$curl_cv_func_select_args" = "unknown"; then
2471 #ifdef HAVE_WINDOWS_H
2472 #ifndef WIN32_LEAN_AND_MEAN
2473 #define WIN32_LEAN_AND_MEAN
2475 #include <windows.h>
2476 #ifdef HAVE_WINSOCK2_H
2477 #include <winsock2.h>
2479 #ifdef HAVE_WINSOCK_H
2480 #include <winsock.h>
2483 #define SELECTCALLCONV PASCAL
2485 #ifdef HAVE_SYS_TYPES_H
2486 #include <sys/types.h>
2488 #ifdef HAVE_SYS_TIME_H
2489 #include <sys/time.h>
2490 #ifdef TIME_WITH_SYS_TIME
2498 #ifndef HAVE_WINDOWS_H
2499 #ifdef HAVE_SYS_SELECT_H
2500 #include <sys/select.h>
2502 #ifdef HAVE_SYS_SOCKET_H
2503 #include <sys/socket.h>
2505 #define SELECTCALLCONV
2507 #ifndef HAVE_STRUCT_TIMEVAL
2513 extern $sel_retv SELECTCALLCONV select($sel_arg1,
2523 $sel_retv res = select(nfds, rfds, wfds, efds, 0);
2526 curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
2534 if test "$curl_cv_func_select_args" = "unknown"; then
2535 AC_MSG_WARN([Cannot find proper types to use for select args])
2536 AC_MSG_WARN([HAVE_SELECT will not be defined])
2538 select_prev_IFS=$IFS; IFS=','
2539 set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
2540 IFS=$select_prev_IFS
2543 sel_qual_type_arg5=$[3]
2545 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
2546 [Define to the type of arg 1 for select.])
2547 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
2548 [Define to the type of args 2, 3 and 4 for select.])
2549 AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
2550 [Define to the function return type for select.])
2554 case $prev_sh_opts in
2562 case "$sel_qual_type_arg5" in
2565 sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
2569 sel_type_arg5=$sel_qual_type_arg5
2573 AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
2574 [Define to the type qualifier of arg 5 for select.])
2575 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
2576 [Define to the type of arg 5 for select.])
2578 case $prev_sh_opts in
2586 AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
2587 [Define to 1 if you have the select function.])
2588 ac_cv_func_select="yes"
2594 dnl ************************************************************
2595 dnl check for working getaddrinfo() that works with AI_NUMERICHOST
2597 AC_DEFUN([CURL_CHECK_WORKING_GETADDRINFO],[
2598 AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
2601 #include <sys/types.h>
2602 #include <sys/socket.h>
2606 struct addrinfo hints, *ai;
2609 memset(&hints, 0, sizeof(hints));
2610 hints.ai_flags = AI_NUMERICHOST;
2611 hints.ai_family = AF_UNSPEC;
2612 hints.ai_socktype = SOCK_STREAM;
2613 error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
2620 ac_cv_working_getaddrinfo="yes"
2622 ac_cv_working_getaddrinfo="no"
2624 ac_cv_working_getaddrinfo="yes"
2626 if test "$ac_cv_working_getaddrinfo" = "yes"; then
2627 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
2628 AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
2631 AC_SUBST(IPV6_ENABLED)
2636 AC_DEFUN([CURL_CHECK_LOCALTIME_R],
2638 dnl check for localtime_r
2639 AC_CHECK_FUNCS(localtime_r,[
2640 AC_MSG_CHECKING(whether localtime_r is declared)
2641 AC_EGREP_CPP(localtime_r,[
2643 #include <time.h>],[
2644 AC_MSG_RESULT(yes)],[
2646 AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
2647 AC_EGREP_CPP(localtime_r,[
2650 #include <time.h>],[
2651 AC_MSG_RESULT(yes)],
2652 AC_MSG_RESULT(no))])])
2656 dnl This function checks for strerror_r(). If it isn't found at first, it
2657 dnl retries with _THREAD_SAFE defined, as that is what AIX seems to require
2658 dnl in order to find this function.
2660 dnl If the function is found, it will then proceed to check how the function
2661 dnl actually works: glibc-style or POSIX-style.
2664 dnl char *strerror_r(int errnum, char *buf, size_t n);
2666 dnl What this one does is to return the error string (no surprises there),
2667 dnl but it doesn't usually copy anything into buf! The 'buf' and 'n'
2668 dnl parameters are only meant as an optional working area, in case strerror_r
2669 dnl needs it. A quick test on a few systems shows that it's generally not
2673 dnl int strerror_r(int errnum, char *buf, size_t n);
2675 AC_DEFUN([CURL_CHECK_STRERROR_R],
2677 AC_CHECK_FUNCS(strerror_r)
2679 if test "x$ac_cv_func_strerror_r" = "xyes"; then
2681 AC_MSG_CHECKING(whether strerror_r is declared)
2682 AC_EGREP_CPP(strerror_r,[
2684 #include <string.h>],[
2685 AC_MSG_RESULT(yes)],[
2687 AC_MSG_CHECKING(whether strerror_r with -D_REENTRANT is declared)
2688 AC_EGREP_CPP(strerror_r,[
2691 #include <string.h>],[
2692 AC_MSG_RESULT(yes)],
2694 AC_DEFINE(HAVE_NO_STRERROR_R_DECL, 1, [we have no strerror_r() proto])
2695 ) dnl with _THREAD_SAFE
2696 ]) dnl plain cpp for it
2698 dnl determine if this strerror_r() is glibc or POSIX
2699 AC_MSG_CHECKING([for a glibc strerror_r API])
2705 char buffer[1024]; /* big enough to play with */
2707 strerror_r(EACCES, buffer, sizeof(buffer));
2708 /* this should've returned a string */
2709 if(!string || !string[0])
2714 GLIBC_STRERROR_R="1"
2715 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
2716 AC_MSG_RESULT([yes]),
2717 AC_MSG_RESULT([no]),
2719 dnl Use an inferior method of strerror_r detection while cross-compiling
2721 #include <features.h>
2726 dnl looks like glibc, so assume a glibc-style strerror_r()
2727 GLIBC_STRERROR_R="1"
2728 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
2729 AC_MSG_RESULT([yes]),
2730 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
2731 ) dnl while cross-compiling
2734 if test -z "$GLIBC_STRERROR_R"; then
2736 AC_MSG_CHECKING([for a POSIX strerror_r API])
2742 char buffer[1024]; /* big enough to play with */
2744 strerror_r(EACCES, buffer, sizeof(buffer));
2745 /* This should've returned zero, and written an error string in the
2747 if(!buffer[0] || error)
2752 AC_DEFINE(HAVE_POSIX_STRERROR_R, 1, [we have a POSIX-style strerror_r()])
2753 AC_MSG_RESULT([yes]),
2754 AC_MSG_RESULT([no]) ,
2755 dnl cross-compiling!
2756 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
2759 fi dnl if not using glibc API
2761 fi dnl we have a strerror_r
2765 AC_DEFUN([CURL_CHECK_INET_NTOA_R],
2767 dnl determine if function definition for inet_ntoa_r exists.
2768 AC_CHECK_FUNCS(inet_ntoa_r,[
2769 AC_MSG_CHECKING(whether inet_ntoa_r is declared)
2770 AC_EGREP_CPP(inet_ntoa_r,[
2772 #include <arpa/inet.h>],[
2773 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
2774 AC_MSG_RESULT(yes)],[
2776 AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
2777 AC_EGREP_CPP(inet_ntoa_r,[
2780 #include <arpa/inet.h>],[
2781 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
2782 AC_MSG_RESULT(yes)],
2783 AC_MSG_RESULT(no))])])
2787 dnl CURL_CHECK_GETHOSTBYADDR_R
2788 dnl -------------------------------------------------
2789 dnl check number of arguments for gethostbyaddr_r, it
2790 dnl might take either 5, 7, or 8 arguments.
2792 AC_DEFUN([CURL_CHECK_GETHOSTBYADDR_R], [
2794 AC_MSG_CHECKING([for gethostbyaddr_r])
2796 AC_LANG_FUNC_LINK_TRY([gethostbyaddr_r])
2798 AC_MSG_RESULT([yes])
2799 tmp_cv_gethostbyaddr_r="yes"
2802 tmp_cv_gethostbyaddr_r="no"
2805 if test "$tmp_cv_gethostbyaddr_r" != "yes"; then
2806 AC_MSG_CHECKING([deeper for gethostbyaddr_r])
2813 AC_MSG_RESULT([yes])
2814 tmp_cv_gethostbyaddr_r="yes"
2816 AC_MSG_RESULT([but still no])
2817 tmp_cv_gethostbyaddr_r="no"
2821 if test "$tmp_cv_gethostbyaddr_r" = "yes"; then
2823 ac_cv_gethostbyaddr_r_args="unknown"
2825 AC_MSG_CHECKING([if gethostbyaddr_r takes 5 arguments])
2829 #include <sys/types.h>
2836 struct hostent_data hdata;
2838 rc = gethostbyaddr_r(address, length, type, &h, &hdata);
2841 AC_MSG_RESULT([yes])
2842 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
2843 ac_cv_gethostbyaddr_r_args="5"
2848 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2849 AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 5 arguments])
2854 #include <sys/types.h>
2861 struct hostent_data hdata;
2863 rc = gethostbyaddr_r(address, length, type, &h, &hdata);
2866 AC_MSG_RESULT([yes])
2867 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
2868 ac_cv_gethostbyaddr_r_args="5"
2874 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2875 AC_MSG_CHECKING([if gethostbyaddr_r takes 7 arguments])
2879 #include <sys/types.h>
2888 struct hostent * hp;
2889 hp = gethostbyaddr_r(address, length, type, &h,
2890 buffer, 8192, &h_errnop);
2893 AC_MSG_RESULT([yes])
2894 AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
2895 ac_cv_gethostbyaddr_r_args="7"
2901 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2902 AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 7 arguments])
2907 #include <sys/types.h>
2916 struct hostent * hp;
2917 hp = gethostbyaddr_r(address, length, type, &h,
2918 buffer, 8192, &h_errnop);
2921 AC_MSG_RESULT([yes])
2922 AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
2923 ac_cv_gethostbyaddr_r_args="7"
2929 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2930 AC_MSG_CHECKING([if gethostbyaddr_r takes 8 arguments])
2934 #include <sys/types.h>
2943 struct hostent * hp;
2945 rc = gethostbyaddr_r(address, length, type, &h,
2946 buffer, 8192, &hp, &h_errnop);
2949 AC_MSG_RESULT([yes])
2950 AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
2951 ac_cv_gethostbyaddr_r_args="8"
2957 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2958 AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 8 arguments])
2963 #include <sys/types.h>
2972 struct hostent * hp;
2974 rc = gethostbyaddr_r(address, length, type, &h,
2975 buffer, 8192, &hp, &h_errnop);
2978 AC_MSG_RESULT([yes])
2979 AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
2980 ac_cv_gethostbyaddr_r_args="8"
2986 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2987 AC_MSG_WARN([Cannot find out how to use gethostbyaddr_r])
2988 AC_MSG_WARN([HAVE_GETHOSTBYADDR_R will not be defined])
2989 ac_cv_func_gethostbyaddr_r="no"
2991 AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR_R, 1,
2992 [Define to 1 if you have the gethostbyaddr_r function.])
2993 ac_cv_func_gethostbyaddr_r="yes"
2997 ac_cv_func_gethostbyaddr_r="no"
3002 dnl CURL_CHECK_GETHOSTBYNAME_R
3003 dnl -------------------------------------------------
3004 dnl check number of arguments for gethostbyname_r, it
3005 dnl might take either 3, 5, or 6 arguments.
3007 AC_DEFUN([CURL_CHECK_GETHOSTBYNAME_R], [
3009 AC_MSG_CHECKING([for gethostbyname_r])
3011 AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
3013 AC_MSG_RESULT([yes])
3014 tmp_cv_gethostbyname_r="yes"
3017 tmp_cv_gethostbyname_r="no"
3020 if test "$tmp_cv_gethostbyname_r" != "yes"; then
3021 AC_MSG_CHECKING([deeper for gethostbyname_r])
3028 AC_MSG_RESULT([yes])
3029 tmp_cv_gethostbyname_r="yes"
3031 AC_MSG_RESULT([but still no])
3032 tmp_cv_gethostbyname_r="no"
3036 if test "$tmp_cv_gethostbyname_r" = "yes"; then
3038 ac_cv_gethostbyname_r_args="unknown"
3040 AC_MSG_CHECKING([if gethostbyname_r takes 3 arguments])
3045 #include <sys/types.h>
3048 #define NULL (void *)0
3050 gethostbyname_r(const char *, struct hostent *,
3051 struct hostent_data *);
3053 struct hostent_data data;
3054 gethostbyname_r(NULL, NULL, NULL);
3057 AC_MSG_RESULT([yes])
3058 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
3059 ac_cv_gethostbyname_r_args="3"
3064 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
3065 AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 3 arguments])
3071 #include <sys/types.h>
3074 #define NULL (void *)0
3076 gethostbyname_r(const char *, struct hostent *,
3077 struct hostent_data *);
3079 struct hostent_data data;
3080 gethostbyname_r(NULL, NULL, NULL);
3083 AC_MSG_RESULT([yes])
3084 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
3085 ac_cv_gethostbyname_r_args="3"
3091 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
3092 AC_MSG_CHECKING([if gethostbyname_r takes 5 arguments])
3096 #include <sys/types.h>
3099 #define NULL (void *)0
3101 gethostbyname_r(const char *, struct hostent *,
3102 char *, int, int *);
3104 gethostbyname_r(NULL, NULL, NULL, 0, NULL);
3107 AC_MSG_RESULT([yes])
3108 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
3109 ac_cv_gethostbyname_r_args="5"
3115 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
3116 AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 5 arguments])
3121 #include <sys/types.h>
3124 #define NULL (void *)0
3126 gethostbyname_r(const char *, struct hostent *,
3127 char *, int, int *);
3129 gethostbyname_r(NULL, NULL, NULL, 0, NULL);
3132 AC_MSG_RESULT([yes])
3133 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
3134 ac_cv_gethostbyname_r_args="5"
3140 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
3141 AC_MSG_CHECKING([if gethostbyname_r takes 6 arguments])
3145 #include <sys/types.h>
3148 #define NULL (void *)0
3150 gethostbyname_r(const char *, struct hostent *,
3151 char *, size_t, struct hostent **, int *);
3153 gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
3156 AC_MSG_RESULT([yes])
3157 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
3158 ac_cv_gethostbyname_r_args="6"
3164 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
3165 AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 6 arguments])
3170 #include <sys/types.h>
3173 #define NULL (void *)0
3175 gethostbyname_r(const char *, struct hostent *,
3176 char *, size_t, struct hostent **, int *);
3178 gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
3181 AC_MSG_RESULT([yes])
3182 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
3183 ac_cv_gethostbyname_r_args="6"
3189 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
3190 AC_MSG_WARN([Cannot find out how to use gethostbyname_r])
3191 AC_MSG_WARN([HAVE_GETHOSTBYNAME_R will not be defined])
3192 ac_cv_func_gethostbyname_r="no"
3194 AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME_R, 1,
3195 [Define to 1 if you have the gethostbyname_r function.])
3196 ac_cv_func_gethostbyname_r="yes"
3200 ac_cv_func_gethostbyname_r="no"
3205 dnl **********************************************************************
3206 dnl CURL_DETECT_ICC ([ACTION-IF-YES])
3208 dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
3209 dnl sets the $ICC variable to "yes" or "no"
3210 dnl **********************************************************************
3211 AC_DEFUN([CURL_DETECT_ICC],
3214 AC_MSG_CHECKING([for icc in use])
3215 if test "$GCC" = "yes"; then
3216 dnl check if this is icc acting as gcc in disguise
3217 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
3218 dnl action if the text is found, this it has not been replaced by the
3221 dnl the text was not found, it was replaced by the cpp
3223 AC_MSG_RESULT([yes])
3227 if test "$ICC" = "no"; then
3233 dnl We create a function for detecting which compiler we use and then set as
3234 dnl pendantic compiler options as possible for that particular compiler. The
3235 dnl options are only used for debug-builds.
3237 AC_DEFUN([CURL_CC_DEBUG_OPTS],
3239 if test "z$ICC" = "z"; then
3243 if test "$GCC" = "yes"; then
3245 dnl figure out gcc version!
3246 AC_MSG_CHECKING([gcc version])
3247 gccver=`$CC -dumpversion`
3248 num1=`echo $gccver | cut -d . -f1`
3249 num2=`echo $gccver | cut -d . -f2`
3250 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
3251 AC_MSG_RESULT($gccver)
3253 if test "$ICC" = "yes"; then
3254 dnl this is icc, not gcc.
3256 dnl ICC warnings we ignore:
3257 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
3258 dnl "invalid format string conversion"
3259 dnl * 279 warns on static conditions in while expressions
3260 dnl * 981 warns on "operands are evaluated in unspecified order"
3261 dnl * 1418 "external definition with no prior declaration"
3262 dnl * 1419 warns on "external declaration in primary source file"
3263 dnl which we know and do on purpose.
3265 WARN="-wd279,269,981,1418,1419"
3267 if test "$gccnum" -gt "600"; then
3268 dnl icc 6.0 and older doesn't have the -Wall flag
3272 dnl this is a set of options we believe *ALL* gcc versions support:
3273 WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
3275 dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
3277 if test "$gccnum" -ge "207"; then
3278 dnl gcc 2.7 or later
3279 WARN="$WARN -Wmissing-declarations"
3282 if test "$gccnum" -gt "295"; then
3283 dnl only if the compiler is newer than 2.95 since we got lots of
3284 dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
3285 dnl gcc 2.95.4 on FreeBSD 4.9!
3286 WARN="$WARN -Wundef -Wno-long-long -Wsign-compare -Wshadow -Wno-multichar"
3289 if test "$gccnum" -ge "296"; then
3290 dnl gcc 2.96 or later
3291 WARN="$WARN -Wfloat-equal"
3294 if test "$gccnum" -gt "296"; then
3295 dnl this option does not exist in 2.96
3296 WARN="$WARN -Wno-format-nonliteral"
3299 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
3300 dnl on i686-Linux as it gives us heaps with false positives.
3301 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
3302 dnl over making it unusable for generic purposes. Let's not use it.
3304 if test "$gccnum" -ge "303"; then
3305 dnl gcc 3.3 and later
3306 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
3309 if test "$gccnum" -ge "304"; then
3310 # try these on gcc 3.4
3311 WARN="$WARN -Wdeclaration-after-statement"
3314 for flag in $CPPFLAGS; do
3317 dnl Include path, provide a -isystem option for the same dir
3318 dnl to prevent warnings in those dirs. The -isystem was not very
3319 dnl reliable on earlier gcc versions.
3320 add=`echo $flag | sed 's/^-I/-isystem /g'`
3328 CFLAGS="$CFLAGS $WARN"
3330 AC_MSG_NOTICE([Added this set of compiler options: $WARN])
3334 AC_MSG_NOTICE([Added no extra compiler options])
3338 dnl strip off optimizer flags
3340 for flag in $CFLAGS; do
3343 dnl echo "cut off $flag"
3346 NEWFLAGS="$NEWFLAGS $flag"
3356 # This is only a temporary fix. This macro is here to replace the broken one
3357 # delivered by the automake project (including the 1.9.6 release). As soon as
3358 # they ship a working version we SHOULD remove this work-around.
3360 AC_DEFUN([AM_MISSING_HAS_RUN],
3361 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
3362 test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\""
3363 # Use eval to expand $SHELL
3364 if eval "$MISSING --run true"; then
3365 am_missing_run="$MISSING --run "
3368 AC_MSG_WARN([`missing' script is too old or missing])
3373 dnl CURL_VERIFY_RUNTIMELIBS
3374 dnl -------------------------------------------------
3375 dnl Verify that the shared libs found so far can be used when running
3376 dnl programs, since otherwise the situation will create odd configure errors
3377 dnl that are misleading people.
3379 dnl Make sure this test is run BEFORE the first test in the script that
3380 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
3381 dnl macro. It must also run AFTER all lib-checking macros are complete.
3383 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
3385 dnl this test is of course not sensible if we are cross-compiling!
3386 if test "x$cross_compiling" != xyes; then
3388 dnl just run a program to verify that the libs checked for previous to this
3389 dnl point also is available run-time!
3390 AC_MSG_CHECKING([run-time libs availability])
3397 AC_MSG_RESULT([fine]),
3398 AC_MSG_RESULT([failed])
3399 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
3402 dnl if this test fails, configure has already stopped
3407 dnl CURL_CHECK_VARIADIC_MACROS
3408 dnl -------------------------------------------------
3409 dnl Check compiler support of variadic macros
3411 AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
3412 AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
3413 [curl_cv_variadic_macros_c99], [
3416 #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
3417 #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
3418 int fun3(int arg1, int arg2, int arg3);
3419 int fun2(int arg1, int arg2);
3420 int fun3(int arg1, int arg2, int arg3)
3421 { return arg1 + arg2 + arg3; }
3422 int fun2(int arg1, int arg2)
3423 { return arg1 + arg2; }
3425 int res3 = c99_vmacro3(1, 2, 3);
3426 int res2 = c99_vmacro2(1, 2);
3429 curl_cv_variadic_macros_c99="yes"
3431 curl_cv_variadic_macros_c99="no"
3434 case "$curl_cv_variadic_macros_c99" in
3436 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
3437 [Define to 1 if compiler supports C99 variadic macro style.])
3440 AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
3441 [curl_cv_variadic_macros_gcc], [
3444 #define gcc_vmacro3(first, args...) fun3(first, args)
3445 #define gcc_vmacro2(first, args...) fun2(first, args)
3446 int fun3(int arg1, int arg2, int arg3);
3447 int fun2(int arg1, int arg2);
3448 int fun3(int arg1, int arg2, int arg3)
3449 { return arg1 + arg2 + arg3; }
3450 int fun2(int arg1, int arg2)
3451 { return arg1 + arg2; }
3453 int res3 = gcc_vmacro3(1, 2, 3);
3454 int res2 = gcc_vmacro2(1, 2);
3457 curl_cv_variadic_macros_gcc="yes"
3459 curl_cv_variadic_macros_gcc="no"
3462 case "$curl_cv_variadic_macros_gcc" in
3464 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
3465 [Define to 1 if compiler supports old gcc variadic macro style.])
3471 dnl CURL_CHECK_CA_BUNDLE
3472 dnl -------------------------------------------------
3473 dnl Check if a default ca-bundle should be used
3475 dnl regarding the paths this will scan:
3476 dnl /etc/ssl/certs/ca-certificates.crt Debian systems
3477 dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
3478 dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
3479 dnl /etc/ssl/certs/ (ca path) SUSE
3481 AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
3483 AC_MSG_CHECKING([default CA cert bundle/path])
3485 AC_ARG_WITH(ca-bundle,
3486 AC_HELP_STRING([--with-ca-bundle=FILE], [File name to use as CA bundle])
3487 AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
3490 if test "x$want_ca" = "xyes"; then
3491 AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
3494 [ want_ca="unset" ])
3495 AC_ARG_WITH(ca-path,
3496 AC_HELP_STRING([--with-ca-path=DIRECTORY], [Directory to use as CA path])
3497 AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
3499 want_capath="$withval"
3500 if test "x$want_capath" = "xyes"; then
3501 AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
3504 [ want_capath="unset"])
3506 if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
3507 "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
3509 AC_MSG_ERROR([Can't specify both --with-ca-bundle and --with-ca-path.])
3510 elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
3511 dnl --with-ca-bundle given
3514 elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
3515 dnl --with-ca-path given
3516 if test "x$OPENSSL_ENABLED" != "x1"; then
3517 AC_MSG_ERROR([--with-ca-path only works with openSSL])
3519 capath="$want_capath"
3522 dnl neither of --with-ca-* given
3523 dnl first try autodetecting a CA bundle , then a CA path
3524 dnl both autodetections can be skipped by --without-ca-*
3527 if test "x$want_ca" = "xunset"; then
3528 dnl the path we previously would have installed the curl ca bundle
3529 dnl to, and thus we now check for an already existing cert in that place
3530 dnl in case we find no other
3531 if test "x$prefix" != xNONE; then
3532 cac="${prefix}/share/curl/curl-ca-bundle.crt"
3534 cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
3537 for a in /etc/ssl/certs/ca-certificates.crt \
3538 /etc/pki/tls/certs/ca-bundle.crt \
3539 /usr/share/ssl/certs/ca-bundle.crt \
3541 if test -f "$a"; then
3547 if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
3548 "x$OPENSSL_ENABLED" = "x1"; then
3549 for a in /etc/ssl/certs/; do
3550 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
3560 if test "x$ca" != "xno"; then
3561 CURL_CA_BUNDLE='"'$ca'"'
3562 AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
3563 AC_SUBST(CURL_CA_BUNDLE)
3564 AC_MSG_RESULT([$ca])
3565 elif test "x$capath" != "xno"; then
3566 CURL_CA_PATH="\"$capath\""
3567 AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
3568 AC_MSG_RESULT([$capath (capath)])
3575 dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
3576 dnl -------------------------------------------------
3577 dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
3578 dnl symbol that can be further used in custom template configuration
3579 dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
3580 dnl argument for the description. Symbol definitions done with this
3581 dnl macro are intended to be exclusively used in handcrafted *.h.in
3582 dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
3583 dnl prevents autoheader generation and insertion of symbol template
3584 dnl stub and definition into the first configuration header file. Do
3585 dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
3586 dnl one serves different functional needs.
3588 AC_DEFUN([CURL_DEFINE_UNQUOTED], [
3589 cat >>confdefs.h <<_EOF
3590 [@%:@define] $1 ifelse($#, 2, [$2], 1)
3595 dnl CURL_INCLUDES_INTTYPES
3596 dnl -------------------------------------------------
3597 dnl Set up variable with list of headers that must be
3598 dnl included when inttypes.h is to be included.
3600 AC_DEFUN([CURL_INCLUDES_INTTYPES], [
3601 curl_includes_inttypes="\
3602 /* includes start */
3603 #ifdef HAVE_SYS_TYPES_H
3604 # include <sys/types.h>
3606 #ifdef HAVE_STDINT_H
3607 # include <stdint.h>
3609 #ifdef HAVE_INTTYPES_H
3610 # include <inttypes.h>
3614 sys/types.h stdint.h inttypes.h,
3615 [], [], [$curl_includes_inttypes])
3619 dnl DO_CURL_OFF_T_CHECK (TYPE, SIZE)
3620 dnl -------------------------------------------------
3621 dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
3623 AC_DEFUN([DO_CURL_OFF_T_CHECK], [
3624 AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
3625 if test "$x_typeof" = "unknown" && test ! -z "$1"; then
3628 echo "DEBUG: ===== doing DO-CURL-OFF-T-CHECK for $1 with size $2 =====" >&6
3633 case AS_TR_SH([$1]) in
3635 tmp_includes="$curl_includes_inttypes"
3636 tmp_source="char f@<:@@:>@ = PRId64;"
3640 tmp_includes="$curl_includes_inttypes"
3641 tmp_source="char f@<:@@:>@ = PRId32;"
3645 tmp_includes="$curl_includes_inttypes"
3646 tmp_source="char f@<:@@:>@ = PRId16;"
3653 typedef $1 curl_off_t;
3654 typedef char dummy_arr[sizeof(curl_off_t) == $2 ? 1 : -1];
3660 echo "DEBUG: ===== generated source which compiled OK follows: " >&6
3661 sed 's/^/cc-ok> /' conftest.$ac_ext >&6
3663 if test -z "$tmp_fmt"; then
3667 CURL_CHECK_DEF([$tmp_fmt], [$curl_includes_inttypes], [silent])
3668 AS_VAR_PUSHDEF([tmp_HaveDef], [curl_cv_have_def_$tmp_fmt])dnl
3669 AS_VAR_PUSHDEF([tmp_Def], [curl_cv_def_$tmp_fmt])dnl
3670 if test AS_VAR_GET(tmp_HaveDef) = "yes"; then
3671 x_format=AS_VAR_GET(tmp_Def)
3675 AS_VAR_POPDEF([tmp_Def])dnl
3676 AS_VAR_POPDEF([tmp_HaveDef])dnl
3679 echo "DEBUG: ===== generated source which failed compilation follows:" >&6
3680 sed 's/^/cc-fail> /' conftest.$ac_ext >&6
3687 dnl CURL_CONFIGURE_CURL_OFF_T
3688 dnl -------------------------------------------------
3689 dnl Find out suitable curl_off_t data type definition and associated
3690 dnl items, and make the appropriate definitions used in template file
3691 dnl include/curl/curlbuild.h.in to properly configure the library.
3693 AC_DEFUN([CURL_CONFIGURE_CURL_OFF_T], [
3694 AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
3696 AC_BEFORE([$0],[AC_SYS_LARGEFILE])dnl
3697 AC_BEFORE([$0],[CURL_CONFIGURE_REENTRANT])dnl
3698 AC_BEFORE([$0],[CURL_CHECK_AIX_ALL_SOURCE])dnl
3700 if test -z "$SED"; then
3701 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
3704 AC_CHECK_SIZEOF(long)
3705 AC_CHECK_SIZEOF(void*)
3707 if test -z "$ac_cv_sizeof_long" ||
3708 test "$ac_cv_sizeof_long" -eq "0"; then
3709 AC_MSG_ERROR([cannot find out size of long.])
3711 if test -z "$ac_cv_sizeof_voidp" ||
3712 test "$ac_cv_sizeof_voidp" -eq "0"; then
3713 AC_MSG_ERROR([cannot find out size of void*.])
3720 if test "$ac_cv_sizeof_long" -eq "8" &&
3721 test "$ac_cv_sizeof_voidp" -ge "8"; then
3723 elif test "$ac_cv_sizeof_long" -eq "4" &&
3724 test "$ac_cv_sizeof_voidp" -ge "4"; then
3726 elif test "$ac_cv_sizeof_long" -eq "2" &&
3727 test "$ac_cv_sizeof_voidp" -ge "2"; then
3731 dnl DO_CURL_OFF_T_CHECK results are stored in next 3 vars
3738 if test "$x_typeof" = "unknown"; then
3739 AC_MSG_CHECKING([for 64-bit curl_off_t data type])
3747 DO_CURL_OFF_T_CHECK([$t8], [8])
3749 AC_MSG_RESULT([$x_typeof])
3751 if test "$x_typeof" = "unknown"; then
3752 AC_MSG_CHECKING([for 32-bit curl_off_t data type])
3758 DO_CURL_OFF_T_CHECK([$t4], [4])
3760 AC_MSG_RESULT([$x_typeof])
3762 if test "$x_typeof" = "unknown"; then
3763 AC_MSG_CHECKING([for 16-bit curl_off_t data type])
3769 DO_CURL_OFF_T_CHECK([$t2], [2])
3771 AC_MSG_RESULT([$x_typeof])
3773 if test "$x_typeof" = "unknown"; then
3774 AC_MSG_ERROR([cannot find data type for curl_off_t.])
3777 AC_MSG_CHECKING([size of curl_off_t])
3778 AC_MSG_RESULT([$x_sizeof])
3780 AC_MSG_CHECKING([formatting string directive for curl_off_t])
3781 if test "$x_format" != "unknown"; then
3782 x_pull_headers="yes"
3783 x_format=`echo "$x_format" | "$SED" 's/[["]]//g'`
3784 u_format=`echo "$x_format" | "$SED" 's/i$/u/'`
3785 u_format=`echo "$u_format" | "$SED" 's/d$/u/'`
3786 u_format=`echo "$u_format" | "$SED" 's/D$/U/'`
3789 case AS_TR_SH([$x_typeof]) in
3790 long_long | __longlong | __longlong_t)
3815 AC_MSG_ERROR([cannot find print format string for curl_off_t.])
3819 AC_MSG_RESULT(["$x_format"])
3821 AC_MSG_CHECKING([formatting string directive for unsigned curl_off_t])
3822 AC_MSG_RESULT(["$u_format"])
3824 if test "$x_pull_headers" = "yes"; then
3825 if test "x$ac_cv_header_sys_types_h" = "xyes"; then
3826 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
3828 if test "x$ac_cv_header_stdint_h" = "xyes"; then
3829 CURL_DEFINE_UNQUOTED([CURL_PULL_STDINT_H])
3831 if test "x$ac_cv_header_inttypes_h" = "xyes"; then
3832 CURL_DEFINE_UNQUOTED([CURL_PULL_INTTYPES_H])
3836 CURL_DEFINE_UNQUOTED([CURL_OFF_T], [$x_typeof])
3837 CURL_DEFINE_UNQUOTED([CURL_FMT_OFF_T], ["$x_format"])
3838 CURL_DEFINE_UNQUOTED([CURL_FMT_OFF_TU], ["$u_format"])
3839 CURL_DEFINE_UNQUOTED([CURL_FORMAT_OFF_T], ["%$x_format"])
3840 CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_OFF_T], [$x_sizeof])