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])])
100 tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
101 "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
102 "$SED" 's/.*CURL_DEF_TOKEN[[ ]]//' 2>/dev/null | \
103 "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
104 if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
108 if test -z "$tmp_exp"; then
109 AS_VAR_SET(ac_HaveDef, no)
110 ifelse($3,,[AC_MSG_RESULT([no])])
112 AS_VAR_SET(ac_HaveDef, yes)
113 AS_VAR_SET(ac_Def, $tmp_exp)
114 ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
116 AS_VAR_POPDEF([ac_Def])dnl
117 AS_VAR_POPDEF([ac_HaveDef])dnl
121 dnl CURL_CHECK_AIX_ALL_SOURCE
122 dnl -------------------------------------------------
123 dnl Provides a replacement of traditional AC_AIX with
124 dnl an uniform behaviour across all autoconf versions,
125 dnl and with our own placement rules.
127 AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
128 AH_VERBATIM([_ALL_SOURCE],
129 [/* Define to 1 if OS is AIX. */
133 AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
134 AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
135 AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
136 AC_EGREP_CPP([yes_this_is_aix],[
142 AC_DEFINE(_ALL_SOURCE)
149 dnl CURL_CHECK_HEADER_WINDOWS
150 dnl -------------------------------------------------
151 dnl Check for compilable and valid windows.h header
153 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
154 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
158 #ifndef WIN32_LEAN_AND_MEAN
159 #define WIN32_LEAN_AND_MEAN
163 #if defined(__CYGWIN__) || defined(__CEGCC__)
164 HAVE_WINDOWS_H shall not be defined.
170 ac_cv_header_windows_h="yes"
172 ac_cv_header_windows_h="no"
175 case "$ac_cv_header_windows_h" in
177 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
178 [Define to 1 if you have the windows.h header file.])
179 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
180 [Define to avoid automatic inclusion of winsock.h])
186 dnl CURL_CHECK_NATIVE_WINDOWS
187 dnl -------------------------------------------------
188 dnl Check if building a native Windows target
190 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
191 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
192 AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
193 if test "$ac_cv_header_windows_h" = "no"; then
194 ac_cv_native_windows="no"
199 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
200 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
203 Not a native Windows build target.
207 ac_cv_native_windows="yes"
209 ac_cv_native_windows="no"
213 case "$ac_cv_native_windows" in
215 AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
216 [Define to 1 if you are building a native Windows target.])
222 dnl CURL_CHECK_HEADER_WINSOCK
223 dnl -------------------------------------------------
224 dnl Check for compilable and valid winsock.h header
226 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
227 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
228 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
232 #ifndef WIN32_LEAN_AND_MEAN
233 #define WIN32_LEAN_AND_MEAN
238 #if defined(__CYGWIN__) || defined(__CEGCC__)
239 HAVE_WINSOCK_H shall not be defined.
241 int dummy=WSACleanup();
245 ac_cv_header_winsock_h="yes"
247 ac_cv_header_winsock_h="no"
250 case "$ac_cv_header_winsock_h" in
252 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
253 [Define to 1 if you have the winsock.h header file.])
259 dnl CURL_CHECK_HEADER_WINSOCK2
260 dnl -------------------------------------------------
261 dnl Check for compilable and valid winsock2.h header
263 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
264 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
265 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
269 #ifndef WIN32_LEAN_AND_MEAN
270 #define WIN32_LEAN_AND_MEAN
273 #include <winsock2.h>
275 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
276 HAVE_WINSOCK2_H shall not be defined.
278 int dummy=2*IPPROTO_ESP;
282 ac_cv_header_winsock2_h="yes"
284 ac_cv_header_winsock2_h="no"
287 case "$ac_cv_header_winsock2_h" in
289 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
290 [Define to 1 if you have the winsock2.h header file.])
296 dnl CURL_CHECK_HEADER_WS2TCPIP
297 dnl -------------------------------------------------
298 dnl Check for compilable and valid ws2tcpip.h header
300 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
301 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
302 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
306 #ifndef WIN32_LEAN_AND_MEAN
307 #define WIN32_LEAN_AND_MEAN
310 #include <winsock2.h>
311 #include <ws2tcpip.h>
313 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
314 HAVE_WS2TCPIP_H shall not be defined.
316 int dummy=2*IP_PKTINFO;
320 ac_cv_header_ws2tcpip_h="yes"
322 ac_cv_header_ws2tcpip_h="no"
325 case "$ac_cv_header_ws2tcpip_h" in
327 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
328 [Define to 1 if you have the ws2tcpip.h header file.])
334 dnl CURL_CHECK_HEADER_WINLDAP
335 dnl -------------------------------------------------
336 dnl Check for compilable and valid winldap.h header
338 AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
339 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
340 AC_CACHE_CHECK([for winldap.h], [ac_cv_header_winldap_h], [
344 #ifdef HAVE_WINDOWS_H
345 #ifndef WIN32_LEAN_AND_MEAN
346 #define WIN32_LEAN_AND_MEAN
352 #if defined(__CYGWIN__) || defined(__CEGCC__)
353 HAVE_WINLDAP_H shall not be defined.
355 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
356 ULONG res = ldap_unbind(ldp);
360 ac_cv_header_winldap_h="yes"
362 ac_cv_header_winldap_h="no"
365 case "$ac_cv_header_winldap_h" in
367 AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
368 [Define to 1 if you have the winldap.h header file.])
374 dnl CURL_CHECK_HEADER_WINBER
375 dnl -------------------------------------------------
376 dnl Check for compilable and valid winber.h header
378 AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
379 AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
380 AC_CACHE_CHECK([for winber.h], [ac_cv_header_winber_h], [
384 #ifdef HAVE_WINDOWS_H
385 #ifndef WIN32_LEAN_AND_MEAN
386 #define WIN32_LEAN_AND_MEAN
393 #if defined(__CYGWIN__) || defined(__CEGCC__)
394 HAVE_WINBER_H shall not be defined.
397 BerElement *bep = ber_init(bvp);
402 ac_cv_header_winber_h="yes"
404 ac_cv_header_winber_h="no"
407 case "$ac_cv_header_winber_h" in
409 AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
410 [Define to 1 if you have the winber.h header file.])
416 dnl CURL_CHECK_HEADER_LBER
417 dnl -------------------------------------------------
418 dnl Check for compilable and valid lber.h header,
419 dnl and check if it is needed even with ldap.h
421 AC_DEFUN([CURL_CHECK_HEADER_LBER], [
422 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
423 AC_CACHE_CHECK([for lber.h], [ac_cv_header_lber_h], [
427 #ifdef HAVE_WINDOWS_H
428 #ifndef WIN32_LEAN_AND_MEAN
429 #define WIN32_LEAN_AND_MEAN
433 #ifdef HAVE_SYS_TYPES_H
434 #include <sys/types.h>
438 #define NULL (void *)0
442 BerValue *bvp = NULL;
443 BerElement *bep = ber_init(bvp);
447 ac_cv_header_lber_h="yes"
449 ac_cv_header_lber_h="no"
452 if test "$ac_cv_header_lber_h" = "yes"; then
453 AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
454 [Define to 1 if you have the lber.h header file.])
459 #ifdef HAVE_WINDOWS_H
460 #ifndef WIN32_LEAN_AND_MEAN
461 #define WIN32_LEAN_AND_MEAN
465 #ifdef HAVE_SYS_TYPES_H
466 #include <sys/types.h>
470 #define NULL (void *)0
472 #ifndef LDAP_DEPRECATED
473 #define LDAP_DEPRECATED 1
477 BerValue *bvp = NULL;
478 BerElement *bep = ber_init(bvp);
482 curl_cv_need_header_lber_h="no"
484 curl_cv_need_header_lber_h="yes"
487 case "$curl_cv_need_header_lber_h" in
489 AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
490 [Define to 1 if you need the lber.h header file even with ldap.h])
497 dnl CURL_CHECK_HEADER_LDAP
498 dnl -------------------------------------------------
499 dnl Check for compilable and valid ldap.h header
501 AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
502 AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
503 AC_CACHE_CHECK([for ldap.h], [ac_cv_header_ldap_h], [
507 #ifdef HAVE_WINDOWS_H
508 #ifndef WIN32_LEAN_AND_MEAN
509 #define WIN32_LEAN_AND_MEAN
513 #ifdef HAVE_SYS_TYPES_H
514 #include <sys/types.h>
517 #ifndef LDAP_DEPRECATED
518 #define LDAP_DEPRECATED 1
525 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
526 int res = ldap_unbind(ldp);
529 ac_cv_header_ldap_h="yes"
531 ac_cv_header_ldap_h="no"
534 case "$ac_cv_header_ldap_h" in
536 AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
537 [Define to 1 if you have the ldap.h header file.])
543 dnl CURL_CHECK_HEADER_LDAP_SSL
544 dnl -------------------------------------------------
545 dnl Check for compilable and valid ldap_ssl.h header
547 AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
548 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
549 AC_CACHE_CHECK([for ldap_ssl.h], [ac_cv_header_ldap_ssl_h], [
553 #ifdef HAVE_WINDOWS_H
554 #ifndef WIN32_LEAN_AND_MEAN
555 #define WIN32_LEAN_AND_MEAN
559 #ifdef HAVE_SYS_TYPES_H
560 #include <sys/types.h>
563 #ifndef LDAP_DEPRECATED
564 #define LDAP_DEPRECATED 1
572 #include <ldap_ssl.h>
574 LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
577 ac_cv_header_ldap_ssl_h="yes"
579 ac_cv_header_ldap_ssl_h="no"
582 case "$ac_cv_header_ldap_ssl_h" in
584 AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
585 [Define to 1 if you have the ldap_ssl.h header file.])
591 dnl CURL_CHECK_HEADER_LDAPSSL
592 dnl -------------------------------------------------
593 dnl Check for compilable and valid ldapssl.h header
595 AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
596 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
597 AC_CACHE_CHECK([for ldapssl.h], [ac_cv_header_ldapssl_h], [
601 #ifdef HAVE_WINDOWS_H
602 #ifndef WIN32_LEAN_AND_MEAN
603 #define WIN32_LEAN_AND_MEAN
607 #ifdef HAVE_SYS_TYPES_H
608 #include <sys/types.h>
612 #define NULL (void *)0
614 #ifndef LDAP_DEPRECATED
615 #define LDAP_DEPRECATED 1
625 char *cert_label = NULL;
626 LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
629 ac_cv_header_ldapssl_h="yes"
631 ac_cv_header_ldapssl_h="no"
634 case "$ac_cv_header_ldapssl_h" in
636 AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
637 [Define to 1 if you have the ldapssl.h header file.])
643 dnl CURL_CHECK_LIBS_WINLDAP
644 dnl -------------------------------------------------
645 dnl Check for libraries needed for WINLDAP support,
646 dnl and prepended to LIBS any needed libraries.
647 dnl This macro can take an optional parameter with a
648 dnl white space separated list of libraries to check
649 dnl before the WINLDAP default ones.
651 AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
652 AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
654 AC_MSG_CHECKING([for WINLDAP libraries])
668 if test -z "$u_libs"; then
671 u_libs="$u_libs $l_lib"
676 curl_cv_save_LIBS="$LIBS"
677 curl_cv_ldap_LIBS="unknown"
679 for x_nlibs in '' "$u_libs" \
681 if test "$curl_cv_ldap_LIBS" = "unknown"; then
682 if test -z "$x_nlibs"; then
683 LIBS="$curl_cv_save_LIBS"
685 LIBS="$x_nlibs $curl_cv_save_LIBS"
690 #ifdef HAVE_WINDOWS_H
691 #ifndef WIN32_LEAN_AND_MEAN
692 #define WIN32_LEAN_AND_MEAN
695 #ifdef HAVE_WINLDAP_H
704 BerElement *bep = ber_init(bvp);
705 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
706 ULONG res = ldap_unbind(ldp);
710 curl_cv_ldap_LIBS="$x_nlibs"
715 LIBS="$curl_cv_save_LIBS"
717 case X-"$curl_cv_ldap_LIBS" in
719 AC_MSG_RESULT([cannot find WINLDAP libraries])
722 AC_MSG_RESULT([no additional lib required])
725 if test -z "$curl_cv_save_LIBS"; then
726 LIBS="$curl_cv_ldap_LIBS"
728 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
730 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
737 dnl CURL_CHECK_LIBS_LDAP
738 dnl -------------------------------------------------
739 dnl Check for libraries needed for LDAP support,
740 dnl and prepended to LIBS any needed libraries.
741 dnl This macro can take an optional parameter with a
742 dnl white space separated list of libraries to check
743 dnl before the default ones.
745 AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
746 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
748 AC_MSG_CHECKING([for LDAP libraries])
762 if test -z "$u_libs"; then
765 u_libs="$u_libs $l_lib"
770 curl_cv_save_LIBS="$LIBS"
771 curl_cv_ldap_LIBS="unknown"
773 for x_nlibs in '' "$u_libs" \
777 '-lldapssl -lldapx -lldapsdk' \
778 '-lldapsdk -lldapx -lldapssl' ; do
779 if test "$curl_cv_ldap_LIBS" = "unknown"; then
780 if test -z "$x_nlibs"; then
781 LIBS="$curl_cv_save_LIBS"
783 LIBS="$x_nlibs $curl_cv_save_LIBS"
788 #ifdef HAVE_WINDOWS_H
789 #ifndef WIN32_LEAN_AND_MEAN
790 #define WIN32_LEAN_AND_MEAN
794 #ifdef HAVE_SYS_TYPES_H
795 #include <sys/types.h>
799 #define NULL (void *)0
801 #ifndef LDAP_DEPRECATED
802 #define LDAP_DEPRECATED 1
811 BerValue *bvp = NULL;
812 BerElement *bep = ber_init(bvp);
813 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
814 int res = ldap_unbind(ldp);
818 curl_cv_ldap_LIBS="$x_nlibs"
823 LIBS="$curl_cv_save_LIBS"
825 case X-"$curl_cv_ldap_LIBS" in
827 AC_MSG_RESULT([cannot find LDAP libraries])
830 AC_MSG_RESULT([no additional lib required])
833 if test -z "$curl_cv_save_LIBS"; then
834 LIBS="$curl_cv_ldap_LIBS"
836 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
838 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
845 dnl CURL_CHECK_HEADER_MALLOC
846 dnl -------------------------------------------------
847 dnl Check for compilable and valid malloc.h header,
848 dnl and check if it is needed even with stdlib.h
850 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
851 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
856 void *p = malloc(10);
857 void *q = calloc(10,10);
862 ac_cv_header_malloc_h="yes"
864 ac_cv_header_malloc_h="no"
867 if test "$ac_cv_header_malloc_h" = "yes"; then
868 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
869 [Define to 1 if you have the malloc.h header file.])
875 void *p = malloc(10);
876 void *q = calloc(10,10);
881 curl_cv_need_header_malloc_h="no"
883 curl_cv_need_header_malloc_h="yes"
886 case "$curl_cv_need_header_malloc_h" in
888 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
889 [Define to 1 if you need the malloc.h header file even with stdlib.h])
896 dnl CURL_CHECK_TYPE_SOCKLEN_T
897 dnl -------------------------------------------------
898 dnl Check for existing socklen_t type, and provide
899 dnl an equivalent type if socklen_t not available
901 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
902 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
903 AC_CHECK_TYPE([socklen_t], ,[
904 dnl socklen_t not available
905 AC_CACHE_CHECK([for socklen_t equivalent],
906 [curl_cv_socklen_t_equiv], [
907 curl_cv_socklen_t_equiv="unknown"
908 for arg1 in 'int' 'SOCKET'; do
909 for arg2 in "struct sockaddr" void; do
910 for t in int size_t unsigned long "unsigned long"; do
911 if test "$curl_cv_socklen_t_equiv" = "unknown"; then
915 #ifdef HAVE_WINDOWS_H
916 #ifndef WIN32_LEAN_AND_MEAN
917 #define WIN32_LEAN_AND_MEAN
920 #ifdef HAVE_WINSOCK2_H
921 #include <winsock2.h>
923 #ifdef HAVE_WINSOCK_H
927 #define GETPEERNCALLCONV PASCAL
929 #ifdef HAVE_SYS_TYPES_H
930 #include <sys/types.h>
932 #ifdef HAVE_SYS_SOCKET_H
933 #include <sys/socket.h>
935 #define GETPEERNCALLCONV
937 extern int GETPEERNCALLCONV getpeername($arg1, $arg2 *, $t *);
940 getpeername(0,0,&len);
943 curl_cv_socklen_t_equiv="$t"
950 case "$curl_cv_socklen_t_equiv" in
952 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
955 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
956 [Type to use in place of socklen_t when system does not provide it.])
961 #ifdef HAVE_WINDOWS_H
962 #ifndef WIN32_LEAN_AND_MEAN
963 #define WIN32_LEAN_AND_MEAN
966 #ifdef HAVE_WINSOCK2_H
967 #include <winsock2.h>
968 #ifdef HAVE_WS2TCPIP_H
969 #include <ws2tcpip.h>
973 #ifdef HAVE_SYS_TYPES_H
974 #include <sys/types.h>
976 #ifdef HAVE_SYS_SOCKET_H
977 #include <sys/socket.h>
984 dnl CURL_CHECK_FUNC_GETNAMEINFO
985 dnl -------------------------------------------------
986 dnl Test if the getnameinfo function is available,
987 dnl and check the types of five of its arguments.
988 dnl If the function succeeds HAVE_GETNAMEINFO will be
989 dnl defined, defining the types of the arguments in
990 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
991 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
992 dnl and also defining the type qualifier of first
993 dnl argument in GETNAMEINFO_QUAL_ARG1.
995 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
996 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
997 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
998 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
1000 AC_MSG_CHECKING([for getnameinfo])
1002 AC_LANG_FUNC_LINK_TRY([getnameinfo])
1004 AC_MSG_RESULT([yes])
1005 curl_cv_getnameinfo="yes"
1008 curl_cv_getnameinfo="no"
1011 if test "$curl_cv_getnameinfo" != "yes"; then
1012 AC_MSG_CHECKING([deeper for getnameinfo])
1019 AC_MSG_RESULT([yes])
1020 curl_cv_getnameinfo="yes"
1022 AC_MSG_RESULT([but still no])
1023 curl_cv_getnameinfo="no"
1027 if test "$curl_cv_getnameinfo" != "yes"; then
1028 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
1032 #ifdef HAVE_WINDOWS_H
1033 #ifndef WIN32_LEAN_AND_MEAN
1034 #define WIN32_LEAN_AND_MEAN
1036 #include <windows.h>
1037 #ifdef HAVE_WINSOCK2_H
1038 #include <winsock2.h>
1039 #ifdef HAVE_WS2TCPIP_H
1040 #include <ws2tcpip.h>
1044 #ifdef HAVE_SYS_TYPES_H
1045 #include <sys/types.h>
1047 #ifdef HAVE_SYS_SOCKET_H
1048 #include <sys/socket.h>
1055 getnameinfo(0, 0, 0, 0, 0, 0, 0);
1058 AC_MSG_RESULT([yes])
1059 curl_cv_getnameinfo="yes"
1061 AC_MSG_RESULT([but still no])
1062 curl_cv_getnameinfo="no"
1066 if test "$curl_cv_getnameinfo" = "yes"; then
1067 AC_CACHE_CHECK([types of arguments for getnameinfo],
1068 [curl_cv_func_getnameinfo_args], [
1069 curl_cv_func_getnameinfo_args="unknown"
1070 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
1071 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
1072 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
1073 for gni_arg7 in 'int' 'unsigned int'; do
1074 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1078 #ifdef HAVE_WINDOWS_H
1079 #ifndef WIN32_LEAN_AND_MEAN
1080 #define WIN32_LEAN_AND_MEAN
1082 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
1084 #define _WIN32_WINNT 0x0501
1086 #include <windows.h>
1087 #ifdef HAVE_WINSOCK2_H
1088 #include <winsock2.h>
1089 #ifdef HAVE_WS2TCPIP_H
1090 #include <ws2tcpip.h>
1093 #define GNICALLCONV WSAAPI
1095 #ifdef HAVE_SYS_TYPES_H
1096 #include <sys/types.h>
1098 #ifdef HAVE_SYS_SOCKET_H
1099 #include <sys/socket.h>
1106 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
1112 $gni_arg46 hostlen=0;
1113 $gni_arg46 servlen=0;
1115 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
1118 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
1126 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1127 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
1128 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
1130 gni_prev_IFS=$IFS; IFS=','
1131 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
1135 gni_qual_type_arg1=$[1]
1137 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
1138 [Define to the type of arg 2 for getnameinfo.])
1139 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
1140 [Define to the type of args 4 and 6 for getnameinfo.])
1141 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
1142 [Define to the type of arg 7 for getnameinfo.])
1146 case $prev_sh_opts in
1154 case "$gni_qual_type_arg1" in
1157 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
1161 gni_type_arg1=$gni_qual_type_arg1
1165 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
1166 [Define to the type qualifier of arg 1 for getnameinfo.])
1167 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
1168 [Define to the type of arg 1 for getnameinfo.])
1170 case $prev_sh_opts in
1178 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
1179 [Define to 1 if you have the getnameinfo function.])
1180 ac_cv_func_getnameinfo="yes"
1186 dnl TYPE_SOCKADDR_STORAGE
1187 dnl -------------------------------------------------
1188 dnl Check for struct sockaddr_storage. Most IPv6-enabled
1189 dnl hosts have it, but AIX 4.3 is one known exception.
1191 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
1193 AC_CHECK_TYPE([struct sockaddr_storage],
1194 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
1195 [if struct sockaddr_storage is defined]), ,
1198 #ifdef HAVE_WINDOWS_H
1199 #ifndef WIN32_LEAN_AND_MEAN
1200 #define WIN32_LEAN_AND_MEAN
1202 #include <windows.h>
1203 #ifdef HAVE_WINSOCK2_H
1204 #include <winsock2.h>
1207 #ifdef HAVE_SYS_TYPES_H
1208 #include <sys/types.h>
1210 #ifdef HAVE_SYS_SOCKET_H
1211 #include <sys/socket.h>
1213 #ifdef HAVE_NETINET_IN_H
1214 #include <netinet/in.h>
1216 #ifdef HAVE_ARPA_INET_H
1217 #include <arpa/inet.h>
1224 dnl CURL_CHECK_NI_WITHSCOPEID
1225 dnl -------------------------------------------------
1226 dnl Check for working NI_WITHSCOPEID in getnameinfo()
1228 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
1229 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
1230 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
1231 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
1232 netdb.h netinet/in.h arpa/inet.h)
1234 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
1235 [ac_cv_working_ni_withscopeid], [
1238 #ifdef HAVE_STDLIB_H
1244 #ifdef HAVE_SYS_TYPES_H
1245 #include <sys/types.h>
1247 #ifdef HAVE_SYS_SOCKET_H
1248 #include <sys/socket.h>
1253 #ifdef HAVE_NETINET_IN_H
1254 #include <netinet/in.h>
1256 #ifdef HAVE_ARPA_INET_H
1257 #include <arpa/inet.h>
1260 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
1261 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
1262 struct sockaddr_storage sa;
1264 unsigned char sa[256];
1266 char hostbuf[NI_MAXHOST];
1268 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
1269 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
1270 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1271 int fd = socket(AF_INET6, SOCK_STREAM, 0);
1274 return 1; /* Error creating socket */
1276 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
1278 perror("getsockname()");
1279 return 2; /* Error retrieving socket name */
1281 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
1283 printf("rc = %s\n", gai_strerror(rc));
1284 return 3; /* Error translating socket address */
1286 return 0; /* Ok, NI_WITHSCOPEID works */
1288 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
1290 ]]) # AC-LANG-PROGRAM
1292 # Exit code == 0. Program worked.
1293 ac_cv_working_ni_withscopeid="yes"
1295 # Exit code != 0. Program failed.
1296 ac_cv_working_ni_withscopeid="no"
1298 # Program is not run when cross-compiling. So we assume
1299 # NI_WITHSCOPEID will work if we are able to compile it.
1302 #include <sys/types.h>
1303 #include <sys/socket.h>
1306 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1309 ac_cv_working_ni_withscopeid="yes"
1311 ac_cv_working_ni_withscopeid="no"
1312 ]) # AC-COMPILE-IFELSE
1315 case "$ac_cv_working_ni_withscopeid" in
1317 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
1318 [Define to 1 if NI_WITHSCOPEID exists and works.])
1324 dnl CURL_CHECK_FUNC_RECV
1325 dnl -------------------------------------------------
1326 dnl Test if the socket recv() function is available,
1327 dnl and check its return type and the types of its
1328 dnl arguments. If the function succeeds HAVE_RECV
1329 dnl will be defined, defining the types of the arguments
1330 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
1331 dnl and RECV_TYPE_ARG4, defining the type of the function
1332 dnl return value in RECV_TYPE_RETV.
1334 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
1335 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1336 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1337 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1339 AC_MSG_CHECKING([for recv])
1343 #ifdef HAVE_WINDOWS_H
1344 #ifndef WIN32_LEAN_AND_MEAN
1345 #define WIN32_LEAN_AND_MEAN
1347 #include <windows.h>
1348 #ifdef HAVE_WINSOCK2_H
1349 #include <winsock2.h>
1351 #ifdef HAVE_WINSOCK_H
1352 #include <winsock.h>
1356 #ifdef HAVE_SYS_TYPES_H
1357 #include <sys/types.h>
1359 #ifdef HAVE_SYS_SOCKET_H
1360 #include <sys/socket.h>
1367 AC_MSG_RESULT([yes])
1374 if test "$curl_cv_recv" = "yes"; then
1375 AC_CACHE_CHECK([types of args and return type for recv],
1376 [curl_cv_func_recv_args], [
1377 curl_cv_func_recv_args="unknown"
1378 for recv_retv in 'int' 'ssize_t'; do
1379 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1380 for recv_arg2 in 'char *' 'void *'; do
1381 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1382 for recv_arg4 in 'int' 'unsigned int'; do
1383 if test "$curl_cv_func_recv_args" = "unknown"; then
1387 #ifdef HAVE_WINDOWS_H
1388 #ifndef WIN32_LEAN_AND_MEAN
1389 #define WIN32_LEAN_AND_MEAN
1391 #include <windows.h>
1392 #ifdef HAVE_WINSOCK2_H
1393 #include <winsock2.h>
1395 #ifdef HAVE_WINSOCK_H
1396 #include <winsock.h>
1399 #define RECVCALLCONV PASCAL
1401 #ifdef HAVE_SYS_TYPES_H
1402 #include <sys/types.h>
1404 #ifdef HAVE_SYS_SOCKET_H
1405 #include <sys/socket.h>
1407 #define RECVCALLCONV
1409 extern $recv_retv RECVCALLCONV
1410 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
1416 $recv_retv res = recv(s, buf, len, flags);
1419 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
1428 if test "$curl_cv_func_recv_args" = "unknown"; then
1429 AC_MSG_ERROR([Cannot find proper types to use for recv args])
1431 recv_prev_IFS=$IFS; IFS=','
1432 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
1436 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
1437 [Define to the type of arg 1 for recv.])
1438 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
1439 [Define to the type of arg 2 for recv.])
1440 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
1441 [Define to the type of arg 3 for recv.])
1442 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
1443 [Define to the type of arg 4 for recv.])
1444 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
1445 [Define to the function return type for recv.])
1447 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
1448 [Define to 1 if you have the recv function.])
1449 ac_cv_func_recv="yes"
1452 AC_MSG_ERROR([Unable to link function recv])
1457 dnl CURL_CHECK_FUNC_SEND
1458 dnl -------------------------------------------------
1459 dnl Test if the socket send() function is available,
1460 dnl and check its return type and the types of its
1461 dnl arguments. If the function succeeds HAVE_SEND
1462 dnl will be defined, defining the types of the arguments
1463 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
1464 dnl and SEND_TYPE_ARG4, defining the type of the function
1465 dnl return value in SEND_TYPE_RETV, and also defining the
1466 dnl type qualifier of second argument in SEND_QUAL_ARG2.
1468 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
1469 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1470 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1471 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1473 AC_MSG_CHECKING([for send])
1477 #ifdef HAVE_WINDOWS_H
1478 #ifndef WIN32_LEAN_AND_MEAN
1479 #define WIN32_LEAN_AND_MEAN
1481 #include <windows.h>
1482 #ifdef HAVE_WINSOCK2_H
1483 #include <winsock2.h>
1485 #ifdef HAVE_WINSOCK_H
1486 #include <winsock.h>
1490 #ifdef HAVE_SYS_TYPES_H
1491 #include <sys/types.h>
1493 #ifdef HAVE_SYS_SOCKET_H
1494 #include <sys/socket.h>
1501 AC_MSG_RESULT([yes])
1508 if test "$curl_cv_send" = "yes"; then
1509 AC_CACHE_CHECK([types of args and return type for send],
1510 [curl_cv_func_send_args], [
1511 curl_cv_func_send_args="unknown"
1512 for send_retv in 'int' 'ssize_t'; do
1513 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1514 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
1515 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1516 for send_arg4 in 'int' 'unsigned int'; do
1517 if test "$curl_cv_func_send_args" = "unknown"; then
1521 #ifdef HAVE_WINDOWS_H
1522 #ifndef WIN32_LEAN_AND_MEAN
1523 #define WIN32_LEAN_AND_MEAN
1525 #include <windows.h>
1526 #ifdef HAVE_WINSOCK2_H
1527 #include <winsock2.h>
1529 #ifdef HAVE_WINSOCK_H
1530 #include <winsock.h>
1533 #define SENDCALLCONV PASCAL
1535 #ifdef HAVE_SYS_TYPES_H
1536 #include <sys/types.h>
1538 #ifdef HAVE_SYS_SOCKET_H
1539 #include <sys/socket.h>
1541 #define SENDCALLCONV
1543 extern $send_retv SENDCALLCONV
1544 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1549 $send_retv res = send(s, 0, len, flags);
1552 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1561 if test "$curl_cv_func_send_args" = "unknown"; then
1562 AC_MSG_ERROR([Cannot find proper types to use for send args])
1564 send_prev_IFS=$IFS; IFS=','
1565 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1569 send_qual_type_arg2=$[2]
1571 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1572 [Define to the type of arg 1 for send.])
1573 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1574 [Define to the type of arg 3 for send.])
1575 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1576 [Define to the type of arg 4 for send.])
1577 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1578 [Define to the function return type for send.])
1582 case $prev_sh_opts in
1590 case "$send_qual_type_arg2" in
1592 send_qual_arg2=const
1593 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1597 send_type_arg2=$send_qual_type_arg2
1601 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1602 [Define to the type qualifier of arg 2 for send.])
1603 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1604 [Define to the type of arg 2 for send.])
1606 case $prev_sh_opts in
1614 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1615 [Define to 1 if you have the send function.])
1616 ac_cv_func_send="yes"
1619 AC_MSG_ERROR([Unable to link function send])
1624 dnl CURL_CHECK_FUNC_RECVFROM
1625 dnl -------------------------------------------------
1626 dnl Test if the socket recvfrom() function is available,
1627 dnl and check its return type and the types of its
1628 dnl arguments. If the function succeeds HAVE_RECVFROM
1629 dnl will be defined, defining the types of the arguments
1630 dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
1631 dnl to RECVFROM_TYPE_ARG6, defining also the type of the
1632 dnl function return value in RECVFROM_TYPE_RETV.
1633 dnl Notice that the types returned for pointer arguments
1634 dnl will actually be the type pointed by the pointer.
1636 AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
1637 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1638 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1639 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1641 AC_MSG_CHECKING([for recvfrom])
1645 #ifdef HAVE_WINDOWS_H
1646 #ifndef WIN32_LEAN_AND_MEAN
1647 #define WIN32_LEAN_AND_MEAN
1649 #include <windows.h>
1650 #ifdef HAVE_WINSOCK2_H
1651 #include <winsock2.h>
1653 #ifdef HAVE_WINSOCK_H
1654 #include <winsock.h>
1658 #ifdef HAVE_SYS_TYPES_H
1659 #include <sys/types.h>
1661 #ifdef HAVE_SYS_SOCKET_H
1662 #include <sys/socket.h>
1666 recvfrom(0, 0, 0, 0, 0, 0);
1669 AC_MSG_RESULT([yes])
1670 curl_cv_recvfrom="yes"
1673 curl_cv_recvfrom="no"
1676 if test "$curl_cv_recvfrom" = "yes"; then
1677 AC_CACHE_CHECK([types of args and return type for recvfrom],
1678 [curl_cv_func_recvfrom_args], [
1679 curl_cv_func_recvfrom_args="unknown"
1680 for recvfrom_retv in 'int' 'ssize_t'; do
1681 for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1682 for recvfrom_arg2 in 'char *' 'void *'; do
1683 for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1684 for recvfrom_arg4 in 'int' 'unsigned int'; do
1685 for recvfrom_arg5 in 'struct sockaddr *' 'void *'; do
1686 for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
1687 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1691 #ifdef HAVE_WINDOWS_H
1692 #ifndef WIN32_LEAN_AND_MEAN
1693 #define WIN32_LEAN_AND_MEAN
1695 #include <windows.h>
1696 #ifdef HAVE_WINSOCK2_H
1697 #include <winsock2.h>
1699 #ifdef HAVE_WINSOCK_H
1700 #include <winsock.h>
1703 #define RECVFROMCALLCONV PASCAL
1705 #ifdef HAVE_SYS_TYPES_H
1706 #include <sys/types.h>
1708 #ifdef HAVE_SYS_SOCKET_H
1709 #include <sys/socket.h>
1711 #define RECVFROMCALLCONV
1713 extern $recvfrom_retv RECVFROMCALLCONV
1714 recvfrom($recvfrom_arg1, $recvfrom_arg2,
1715 $recvfrom_arg3, $recvfrom_arg4,
1716 $recvfrom_arg5, $recvfrom_arg6);
1719 $recvfrom_arg2 buf=0;
1720 $recvfrom_arg3 len=0;
1721 $recvfrom_arg4 flags=0;
1722 $recvfrom_arg5 addr=0;
1723 $recvfrom_arg6 addrlen=0;
1724 $recvfrom_retv res=0;
1725 res = recvfrom(s, buf, len, flags, addr, addrlen);
1728 curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
1739 # Nearly last minute change for this release starts here
1740 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1741 [Define to 1 if you have the recvfrom function.])
1742 ac_cv_func_recvfrom="yes"
1743 # Nearly last minute change for this release ends here
1744 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1745 AC_MSG_WARN([Cannot find proper types to use for recvfrom args])
1747 recvfrom_prev_IFS=$IFS; IFS=','
1748 set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
1749 IFS=$recvfrom_prev_IFS
1752 recvfrom_ptrt_arg2=$[2]
1753 recvfrom_ptrt_arg5=$[5]
1754 recvfrom_ptrt_arg6=$[6]
1756 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
1757 [Define to the type of arg 1 for recvfrom.])
1758 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
1759 [Define to the type of arg 3 for recvfrom.])
1760 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
1761 [Define to the type of arg 4 for recvfrom.])
1762 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
1763 [Define to the function return type for recvfrom.])
1767 case $prev_sh_opts in
1775 recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
1776 recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
1777 recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
1779 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
1780 [Define to the type pointed by arg 2 for recvfrom.])
1781 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
1782 [Define to the type pointed by arg 5 for recvfrom.])
1783 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
1784 [Define to the type pointed by arg 6 for recvfrom.])
1786 if test "$recvfrom_type_arg2" = "void"; then
1787 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2_IS_VOID, 1,
1788 [Define to 1 if the type pointed by arg 2 for recvfrom is void.])
1790 if test "$recvfrom_type_arg5" = "void"; then
1791 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5_IS_VOID, 1,
1792 [Define to 1 if the type pointed by arg 5 for recvfrom is void.])
1794 if test "$recvfrom_type_arg6" = "void"; then
1795 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6_IS_VOID, 1,
1796 [Define to 1 if the type pointed by arg 6 for recvfrom is void.])
1799 case $prev_sh_opts in
1807 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1808 [Define to 1 if you have the recvfrom function.])
1809 ac_cv_func_recvfrom="yes"
1812 AC_MSG_WARN([Unable to link function recvfrom])
1817 dnl CURL_CHECK_MSG_NOSIGNAL
1818 dnl -------------------------------------------------
1819 dnl Check for MSG_NOSIGNAL
1821 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1822 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1823 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1827 #ifdef HAVE_WINDOWS_H
1828 #ifndef WIN32_LEAN_AND_MEAN
1829 #define WIN32_LEAN_AND_MEAN
1831 #include <windows.h>
1832 #ifdef HAVE_WINSOCK2_H
1833 #include <winsock2.h>
1835 #ifdef HAVE_WINSOCK_H
1836 #include <winsock.h>
1840 #ifdef HAVE_SYS_TYPES_H
1841 #include <sys/types.h>
1843 #ifdef HAVE_SYS_SOCKET_H
1844 #include <sys/socket.h>
1848 int flag=MSG_NOSIGNAL;
1851 ac_cv_msg_nosignal="yes"
1853 ac_cv_msg_nosignal="no"
1856 case "$ac_cv_msg_nosignal" in
1858 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1859 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1865 dnl CURL_CHECK_STRUCT_TIMEVAL
1866 dnl -------------------------------------------------
1867 dnl Check for timeval struct
1869 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1870 AC_REQUIRE([AC_HEADER_TIME])dnl
1871 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1872 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1873 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1874 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1878 #ifdef HAVE_WINDOWS_H
1879 #ifndef WIN32_LEAN_AND_MEAN
1880 #define WIN32_LEAN_AND_MEAN
1882 #include <windows.h>
1883 #ifdef HAVE_WINSOCK2_H
1884 #include <winsock2.h>
1886 #ifdef HAVE_WINSOCK_H
1887 #include <winsock.h>
1891 #ifdef HAVE_SYS_TYPES_H
1892 #include <sys/types.h>
1894 #ifdef HAVE_SYS_TIME_H
1895 #include <sys/time.h>
1896 #ifdef TIME_WITH_SYS_TIME
1910 ac_cv_struct_timeval="yes"
1912 ac_cv_struct_timeval="no"
1915 case "$ac_cv_struct_timeval" in
1917 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1918 [Define to 1 if you have the timeval struct.])
1924 dnl TYPE_SIG_ATOMIC_T
1925 dnl -------------------------------------------------
1926 dnl Check if the sig_atomic_t type is available, and
1927 dnl verify if it is already defined as volatile.
1929 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1930 AC_CHECK_HEADERS(signal.h)
1931 AC_CHECK_TYPE([sig_atomic_t],[
1932 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1933 [Define to 1 if sig_atomic_t is an available typedef.])
1935 #ifdef HAVE_SIGNAL_H
1939 case "$ac_cv_type_sig_atomic_t" in
1942 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1945 #ifdef HAVE_SIGNAL_H
1949 static volatile sig_atomic_t dummy = 0;
1953 ac_cv_sig_atomic_t_volatile="no"
1955 AC_MSG_RESULT([yes])
1956 ac_cv_sig_atomic_t_volatile="yes"
1959 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1960 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1961 [Define to 1 if sig_atomic_t is already defined as volatile.])
1969 dnl -------------------------------------------------
1970 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1971 dnl and a few other things.
1973 AC_DEFUN([TYPE_IN_ADDR_T], [
1974 AC_CHECK_TYPE([in_addr_t], ,[
1975 dnl in_addr_t not available
1976 AC_CACHE_CHECK([for in_addr_t equivalent],
1977 [curl_cv_in_addr_t_equiv], [
1978 curl_cv_in_addr_t_equiv="unknown"
1979 for t in "unsigned long" int size_t unsigned long; do
1980 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
1984 #ifdef HAVE_WINDOWS_H
1985 #ifndef WIN32_LEAN_AND_MEAN
1986 #define WIN32_LEAN_AND_MEAN
1988 #include <windows.h>
1989 #ifdef HAVE_WINSOCK2_H
1990 #include <winsock2.h>
1992 #ifdef HAVE_WINSOCK_H
1993 #include <winsock.h>
1997 #ifdef HAVE_SYS_TYPES_H
1998 #include <sys/types.h>
2000 #ifdef HAVE_SYS_SOCKET_H
2001 #include <sys/socket.h>
2003 #ifdef HAVE_NETINET_IN_H
2004 #include <netinet/in.h>
2006 #ifdef HAVE_ARPA_INET_H
2007 #include <arpa/inet.h>
2011 $t data = inet_addr ("1.2.3.4");
2014 curl_cv_in_addr_t_equiv="$t"
2019 case "$curl_cv_in_addr_t_equiv" in
2021 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
2024 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
2025 [Type to use in place of in_addr_t when system does not provide it.])
2030 #ifdef HAVE_WINDOWS_H
2031 #ifndef WIN32_LEAN_AND_MEAN
2032 #define WIN32_LEAN_AND_MEAN
2034 #include <windows.h>
2035 #ifdef HAVE_WINSOCK2_H
2036 #include <winsock2.h>
2038 #ifdef HAVE_WINSOCK_H
2039 #include <winsock.h>
2043 #ifdef HAVE_SYS_TYPES_H
2044 #include <sys/types.h>
2046 #ifdef HAVE_SYS_SOCKET_H
2047 #include <sys/socket.h>
2049 #ifdef HAVE_NETINET_IN_H
2050 #include <netinet/in.h>
2052 #ifdef HAVE_ARPA_INET_H
2053 #include <arpa/inet.h>
2060 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
2061 dnl -------------------------------------------------
2062 dnl Check if monotonic clock_gettime is available.
2064 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
2065 AC_REQUIRE([AC_HEADER_TIME])dnl
2066 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
2067 AC_MSG_CHECKING([for monotonic clock_gettime])
2070 #ifdef HAVE_SYS_TYPES_H
2071 #include <sys/types.h>
2073 #ifdef HAVE_SYS_TIME_H
2074 #include <sys/time.h>
2075 #ifdef TIME_WITH_SYS_TIME
2085 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
2088 AC_MSG_RESULT([yes])
2089 ac_cv_func_clock_gettime="yes"
2092 ac_cv_func_clock_gettime="no"
2094 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
2095 dnl until library linking and run-time checks for clock_gettime succeed.
2099 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
2100 dnl -------------------------------------------------
2101 dnl If monotonic clock_gettime is available then,
2102 dnl check and prepended to LIBS any needed libraries.
2104 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
2105 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
2107 if test "$ac_cv_func_clock_gettime" = "yes"; then
2109 AC_MSG_CHECKING([for clock_gettime in libraries])
2111 curl_cv_save_LIBS="$LIBS"
2112 curl_cv_gclk_LIBS="unknown"
2114 for x_xlibs in '' '-lrt' '-lposix4' ; do
2115 if test "$curl_cv_gclk_LIBS" = "unknown"; then
2116 if test -z "$x_xlibs"; then
2117 LIBS="$curl_cv_save_LIBS"
2119 LIBS="$x_xlibs $curl_cv_save_LIBS"
2123 #ifdef HAVE_SYS_TYPES_H
2124 #include <sys/types.h>
2126 #ifdef HAVE_SYS_TIME_H
2127 #include <sys/time.h>
2128 #ifdef TIME_WITH_SYS_TIME
2138 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
2141 curl_cv_gclk_LIBS="$x_xlibs"
2146 LIBS="$curl_cv_save_LIBS"
2148 case X-"$curl_cv_gclk_LIBS" in
2150 AC_MSG_RESULT([cannot find clock_gettime])
2151 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
2152 ac_cv_func_clock_gettime="no"
2155 AC_MSG_RESULT([no additional lib required])
2156 ac_cv_func_clock_gettime="yes"
2159 if test -z "$curl_cv_save_LIBS"; then
2160 LIBS="$curl_cv_gclk_LIBS"
2162 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
2164 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
2165 ac_cv_func_clock_gettime="yes"
2169 dnl only do runtime verification when not cross-compiling
2170 if test "x$cross_compiling" != "xyes" &&
2171 test "$ac_cv_func_clock_gettime" = "yes"; then
2172 AC_MSG_CHECKING([if monotonic clock_gettime works])
2175 #ifdef HAVE_STDLIB_H
2178 #ifdef HAVE_SYS_TYPES_H
2179 #include <sys/types.h>
2181 #ifdef HAVE_SYS_TIME_H
2182 #include <sys/time.h>
2183 #ifdef TIME_WITH_SYS_TIME
2193 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
2199 AC_MSG_RESULT([yes])
2202 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
2203 ac_cv_func_clock_gettime="no"
2204 LIBS="$curl_cv_save_LIBS"
2208 case "$ac_cv_func_clock_gettime" in
2210 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
2211 [Define to 1 if you have the clock_gettime function and monotonic timer.])
2220 dnl CURL_CHECK_FUNC_SELECT
2221 dnl -------------------------------------------------
2222 dnl Test if the socket select() function is available,
2223 dnl and check its return type and the types of its
2224 dnl arguments. If the function succeeds HAVE_SELECT
2225 dnl will be defined, defining the types of the
2226 dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
2227 dnl and SELECT_TYPE_ARG5, defining the type of the
2228 dnl function return value in SELECT_TYPE_RETV, and
2229 dnl also defining the type qualifier of fifth argument
2230 dnl in SELECT_QUAL_ARG5.
2232 AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
2233 AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
2234 AC_CHECK_HEADERS(sys/select.h sys/socket.h)
2236 AC_MSG_CHECKING([for select])
2240 #ifdef HAVE_WINDOWS_H
2241 #ifndef WIN32_LEAN_AND_MEAN
2242 #define WIN32_LEAN_AND_MEAN
2244 #include <windows.h>
2245 #ifdef HAVE_WINSOCK2_H
2246 #include <winsock2.h>
2248 #ifdef HAVE_WINSOCK_H
2249 #include <winsock.h>
2253 #ifdef HAVE_SYS_TYPES_H
2254 #include <sys/types.h>
2256 #ifdef HAVE_SYS_TIME_H
2257 #include <sys/time.h>
2258 #ifdef TIME_WITH_SYS_TIME
2266 #ifndef HAVE_WINDOWS_H
2267 #ifdef HAVE_SYS_SELECT_H
2268 #include <sys/select.h>
2270 #ifdef HAVE_SYS_SOCKET_H
2271 #include <sys/socket.h>
2275 select(0, 0, 0, 0, 0);
2278 AC_MSG_RESULT([yes])
2279 curl_cv_select="yes"
2285 if test "$curl_cv_select" = "yes"; then
2286 AC_CACHE_CHECK([types of args and return type for select],
2287 [curl_cv_func_select_args], [
2288 curl_cv_func_select_args="unknown"
2289 for sel_retv in 'int' 'ssize_t'; do
2290 for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
2291 for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
2292 for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
2293 if test "$curl_cv_func_select_args" = "unknown"; then
2297 #ifdef HAVE_WINDOWS_H
2298 #ifndef WIN32_LEAN_AND_MEAN
2299 #define WIN32_LEAN_AND_MEAN
2301 #include <windows.h>
2302 #ifdef HAVE_WINSOCK2_H
2303 #include <winsock2.h>
2305 #ifdef HAVE_WINSOCK_H
2306 #include <winsock.h>
2309 #define SELECTCALLCONV PASCAL
2311 #ifdef HAVE_SYS_TYPES_H
2312 #include <sys/types.h>
2314 #ifdef HAVE_SYS_TIME_H
2315 #include <sys/time.h>
2316 #ifdef TIME_WITH_SYS_TIME
2324 #ifndef HAVE_WINDOWS_H
2325 #ifdef HAVE_SYS_SELECT_H
2326 #include <sys/select.h>
2328 #ifdef HAVE_SYS_SOCKET_H
2329 #include <sys/socket.h>
2331 #define SELECTCALLCONV
2333 #ifndef HAVE_STRUCT_TIMEVAL
2339 extern $sel_retv SELECTCALLCONV select($sel_arg1,
2349 $sel_retv res = select(nfds, rfds, wfds, efds, 0);
2352 curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
2360 if test "$curl_cv_func_select_args" = "unknown"; then
2361 AC_MSG_WARN([Cannot find proper types to use for select args])
2362 AC_MSG_WARN([HAVE_SELECT will not be defined])
2364 select_prev_IFS=$IFS; IFS=','
2365 set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
2366 IFS=$select_prev_IFS
2369 sel_qual_type_arg5=$[3]
2371 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
2372 [Define to the type of arg 1 for select.])
2373 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
2374 [Define to the type of args 2, 3 and 4 for select.])
2375 AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
2376 [Define to the function return type for select.])
2380 case $prev_sh_opts in
2388 case "$sel_qual_type_arg5" in
2391 sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
2395 sel_type_arg5=$sel_qual_type_arg5
2399 AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
2400 [Define to the type qualifier of arg 5 for select.])
2401 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
2402 [Define to the type of arg 5 for select.])
2404 case $prev_sh_opts in
2412 AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
2413 [Define to 1 if you have the select function.])
2414 ac_cv_func_select="yes"
2420 # This is only a temporary fix. This macro is here to replace the broken one
2421 # delivered by the automake project (including the 1.9.6 release). As soon as
2422 # they ship a working version we SHOULD remove this work-around.
2424 AC_DEFUN([AM_MISSING_HAS_RUN],
2425 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
2426 test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\""
2427 # Use eval to expand $SHELL
2428 if eval "$MISSING --run true"; then
2429 am_missing_run="$MISSING --run "
2432 AC_MSG_WARN([`missing' script is too old or missing])
2437 dnl CURL_VERIFY_RUNTIMELIBS
2438 dnl -------------------------------------------------
2439 dnl Verify that the shared libs found so far can be used when running
2440 dnl programs, since otherwise the situation will create odd configure errors
2441 dnl that are misleading people.
2443 dnl Make sure this test is run BEFORE the first test in the script that
2444 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
2445 dnl macro. It must also run AFTER all lib-checking macros are complete.
2447 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
2449 dnl this test is of course not sensible if we are cross-compiling!
2450 if test "x$cross_compiling" != xyes; then
2452 dnl just run a program to verify that the libs checked for previous to this
2453 dnl point also is available run-time!
2454 AC_MSG_CHECKING([run-time libs availability])
2461 AC_MSG_RESULT([fine]),
2462 AC_MSG_RESULT([failed])
2463 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
2466 dnl if this test fails, configure has already stopped
2471 dnl CURL_CHECK_VARIADIC_MACROS
2472 dnl -------------------------------------------------
2473 dnl Check compiler support of variadic macros
2475 AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
2476 AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
2477 [curl_cv_variadic_macros_c99], [
2480 #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
2481 #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
2482 int fun3(int arg1, int arg2, int arg3);
2483 int fun2(int arg1, int arg2);
2484 int fun3(int arg1, int arg2, int arg3)
2485 { return arg1 + arg2 + arg3; }
2486 int fun2(int arg1, int arg2)
2487 { return arg1 + arg2; }
2489 int res3 = c99_vmacro3(1, 2, 3);
2490 int res2 = c99_vmacro2(1, 2);
2493 curl_cv_variadic_macros_c99="yes"
2495 curl_cv_variadic_macros_c99="no"
2498 case "$curl_cv_variadic_macros_c99" in
2500 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
2501 [Define to 1 if compiler supports C99 variadic macro style.])
2504 AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
2505 [curl_cv_variadic_macros_gcc], [
2508 #define gcc_vmacro3(first, args...) fun3(first, args)
2509 #define gcc_vmacro2(first, args...) fun2(first, args)
2510 int fun3(int arg1, int arg2, int arg3);
2511 int fun2(int arg1, int arg2);
2512 int fun3(int arg1, int arg2, int arg3)
2513 { return arg1 + arg2 + arg3; }
2514 int fun2(int arg1, int arg2)
2515 { return arg1 + arg2; }
2517 int res3 = gcc_vmacro3(1, 2, 3);
2518 int res2 = gcc_vmacro2(1, 2);
2521 curl_cv_variadic_macros_gcc="yes"
2523 curl_cv_variadic_macros_gcc="no"
2526 case "$curl_cv_variadic_macros_gcc" in
2528 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
2529 [Define to 1 if compiler supports old gcc variadic macro style.])
2535 dnl CURL_CHECK_CA_BUNDLE
2536 dnl -------------------------------------------------
2537 dnl Check if a default ca-bundle should be used
2539 dnl regarding the paths this will scan:
2540 dnl /etc/ssl/certs/ca-certificates.crt Debian systems
2541 dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
2542 dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
2543 dnl /usr/local/share/certs/ca-root.crt FreeBSD
2544 dnl /etc/ssl/certs/ (ca path) SUSE
2546 AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
2548 AC_MSG_CHECKING([default CA cert bundle/path])
2550 AC_ARG_WITH(ca-bundle,
2551 AC_HELP_STRING([--with-ca-bundle=FILE], [File name to use as CA bundle])
2552 AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
2555 if test "x$want_ca" = "xyes"; then
2556 AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
2559 [ want_ca="unset" ])
2560 AC_ARG_WITH(ca-path,
2561 AC_HELP_STRING([--with-ca-path=DIRECTORY], [Directory to use as CA path])
2562 AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
2564 want_capath="$withval"
2565 if test "x$want_capath" = "xyes"; then
2566 AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
2569 [ want_capath="unset"])
2571 if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
2572 "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2574 AC_MSG_ERROR([Can't specify both --with-ca-bundle and --with-ca-path.])
2575 elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
2576 dnl --with-ca-bundle given
2579 elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
2580 dnl --with-ca-path given
2581 if test "x$OPENSSL_ENABLED" != "x1"; then
2582 AC_MSG_ERROR([--with-ca-path only works with openSSL])
2584 capath="$want_capath"
2587 dnl neither of --with-ca-* given
2588 dnl first try autodetecting a CA bundle , then a CA path
2589 dnl both autodetections can be skipped by --without-ca-*
2592 if test "x$want_ca" = "xunset"; then
2593 dnl the path we previously would have installed the curl ca bundle
2594 dnl to, and thus we now check for an already existing cert in that place
2595 dnl in case we find no other
2596 if test "x$prefix" != xNONE; then
2597 cac="${prefix}/share/curl/curl-ca-bundle.crt"
2599 cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
2602 for a in /etc/ssl/certs/ca-certificates.crt \
2603 /etc/pki/tls/certs/ca-bundle.crt \
2604 /usr/share/ssl/certs/ca-bundle.crt \
2605 /usr/local/share/certs/ca-root.crt \
2607 if test -f "$a"; then
2613 if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
2614 "x$OPENSSL_ENABLED" = "x1"; then
2615 for a in /etc/ssl/certs/; do
2616 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
2626 if test "x$ca" != "xno"; then
2627 CURL_CA_BUNDLE='"'$ca'"'
2628 AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
2629 AC_SUBST(CURL_CA_BUNDLE)
2630 AC_MSG_RESULT([$ca])
2631 elif test "x$capath" != "xno"; then
2632 CURL_CA_PATH="\"$capath\""
2633 AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
2634 AC_MSG_RESULT([$capath (capath)])
2641 dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
2642 dnl -------------------------------------------------
2643 dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
2644 dnl symbol that can be further used in custom template configuration
2645 dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
2646 dnl argument for the description. Symbol definitions done with this
2647 dnl macro are intended to be exclusively used in handcrafted *.h.in
2648 dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
2649 dnl prevents autoheader generation and insertion of symbol template
2650 dnl stub and definition into the first configuration header file. Do
2651 dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
2652 dnl one serves different functional needs.
2654 AC_DEFUN([CURL_DEFINE_UNQUOTED], [
2655 cat >>confdefs.h <<_EOF
2656 [@%:@define] $1 ifelse($#, 2, [$2], 1)
2661 dnl CURL_INCLUDES_INTTYPES
2662 dnl -------------------------------------------------
2663 dnl Set up variable with list of headers that must be
2664 dnl included when inttypes.h is to be included.
2666 AC_DEFUN([CURL_INCLUDES_INTTYPES], [
2667 curl_includes_inttypes="\
2668 /* includes start */
2669 #ifdef HAVE_SYS_TYPES_H
2670 # include <sys/types.h>
2672 #ifdef HAVE_STDINT_H
2673 # include <stdint.h>
2675 #ifdef HAVE_INTTYPES_H
2676 # include <inttypes.h>
2680 sys/types.h stdint.h inttypes.h,
2681 [], [], [$curl_includes_inttypes])
2685 dnl CURL_CONFIGURE_LONG
2686 dnl -------------------------------------------------
2687 dnl Find out the size of long as reported by sizeof() and define
2688 dnl CURL_SIZEOF_LONG as appropriate to be used in template file
2689 dnl include/curl/curlbuild.h.in to properly configure the library.
2690 dnl The size of long is a build time characteristic and as such
2691 dnl must be recorded in curlbuild.h
2693 AC_DEFUN([CURL_CONFIGURE_LONG], [
2694 if test -z "$ac_cv_sizeof_long" ||
2695 test "$ac_cv_sizeof_long" -eq "0"; then
2696 AC_MSG_ERROR([cannot find out size of long.])
2698 CURL_DEFINE_UNQUOTED([CURL_SIZEOF_LONG], [$ac_cv_sizeof_long])
2702 dnl DO_CURL_OFF_T_CHECK (TYPE, SIZE)
2703 dnl -------------------------------------------------
2704 dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
2706 AC_DEFUN([DO_CURL_OFF_T_CHECK], [
2707 AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
2708 if test "$curl_typeof_curl_off_t" = "unknown" && test ! -z "$1"; then
2712 case AS_TR_SH([$1]) in
2714 tmp_includes="$curl_includes_inttypes"
2715 tmp_source="char f@<:@@:>@ = PRId64;"
2719 tmp_includes="$curl_includes_inttypes"
2720 tmp_source="char f@<:@@:>@ = PRId32;"
2724 tmp_includes="$curl_includes_inttypes"
2725 tmp_source="char f@<:@@:>@ = PRId16;"
2732 typedef $1 curl_off_t;
2733 typedef char dummy_arr[sizeof(curl_off_t) == $2 ? 1 : -1];
2739 if test -z "$tmp_fmt"; then
2740 curl_typeof_curl_off_t="$1"
2741 curl_sizeof_curl_off_t="$2"
2743 CURL_CHECK_DEF([$tmp_fmt], [$curl_includes_inttypes], [silent])
2744 AS_VAR_PUSHDEF([tmp_HaveFmtDef], [curl_cv_have_def_$tmp_fmt])dnl
2745 AS_VAR_PUSHDEF([tmp_FmtDef], [curl_cv_def_$tmp_fmt])dnl
2746 if test AS_VAR_GET(tmp_HaveFmtDef) = "yes"; then
2747 curl_format_curl_off_t=AS_VAR_GET(tmp_FmtDef)
2748 curl_typeof_curl_off_t="$1"
2749 curl_sizeof_curl_off_t="$2"
2751 AS_VAR_POPDEF([tmp_FmtDef])dnl
2752 AS_VAR_POPDEF([tmp_HaveFmtDef])dnl
2759 dnl DO_CURL_OFF_T_SUFFIX_CHECK (TYPE)
2760 dnl -------------------------------------------------
2761 dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
2763 AC_DEFUN([DO_CURL_OFF_T_SUFFIX_CHECK], [
2764 AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
2765 AC_MSG_CHECKING([constant suffix string for curl_off_t])
2767 curl_suffix_curl_off_t="unknown"
2768 curl_suffix_curl_off_tu="unknown"
2770 case AS_TR_SH([$1]) in
2771 long_long | __longlong | __longlong_t)
2781 tst_suffixes="LL:i64::"
2784 tst_suffixes="L:i32::"
2787 tst_suffixes="L:i16::"
2790 AC_MSG_ERROR([unexpected data type $1])
2794 old_IFS=$IFS; IFS=':'
2795 for tmp_ssuf in $tst_suffixes ; do
2797 if test "x$curl_suffix_curl_off_t" = "xunknown"; then
2800 tmp_usuf="u$tmp_ssuf"
2803 tmp_usuf="U$tmp_ssuf"
2811 $curl_includes_inttypes
2822 curl_suffix_curl_off_t="$tmp_ssuf"
2823 curl_suffix_curl_off_tu="$tmp_usuf"
2829 if test "x$curl_suffix_curl_off_t" = "xunknown"; then
2830 AC_MSG_ERROR([cannot find constant suffix string for curl_off_t.])
2832 AC_MSG_RESULT([$curl_suffix_curl_off_t])
2833 AC_MSG_CHECKING([constant suffix string for unsigned curl_off_t])
2834 AC_MSG_RESULT([$curl_suffix_curl_off_tu])
2840 dnl CURL_CONFIGURE_CURL_OFF_T
2841 dnl -------------------------------------------------
2842 dnl Find out suitable curl_off_t data type definition and associated
2843 dnl items, and make the appropriate definitions used in template file
2844 dnl include/curl/curlbuild.h.in to properly configure the library.
2846 AC_DEFUN([CURL_CONFIGURE_CURL_OFF_T], [
2847 AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
2849 AC_BEFORE([$0],[AC_SYS_LARGEFILE])dnl
2850 AC_BEFORE([$0],[CURL_CONFIGURE_REENTRANT])dnl
2851 AC_BEFORE([$0],[CURL_CHECK_AIX_ALL_SOURCE])dnl
2853 if test -z "$SED"; then
2854 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
2857 AC_CHECK_SIZEOF(long)
2858 AC_CHECK_SIZEOF(void*)
2860 if test -z "$ac_cv_sizeof_long" ||
2861 test "$ac_cv_sizeof_long" -eq "0"; then
2862 AC_MSG_ERROR([cannot find out size of long.])
2864 if test -z "$ac_cv_sizeof_voidp" ||
2865 test "$ac_cv_sizeof_voidp" -eq "0"; then
2866 AC_MSG_ERROR([cannot find out size of void*.])
2873 if test "$ac_cv_sizeof_long" -eq "8" &&
2874 test "$ac_cv_sizeof_voidp" -ge "8"; then
2876 elif test "$ac_cv_sizeof_long" -eq "4" &&
2877 test "$ac_cv_sizeof_voidp" -ge "4"; then
2879 elif test "$ac_cv_sizeof_long" -eq "2" &&
2880 test "$ac_cv_sizeof_voidp" -ge "2"; then
2884 dnl DO_CURL_OFF_T_CHECK results are stored in next 3 vars
2886 curl_typeof_curl_off_t="unknown"
2887 curl_sizeof_curl_off_t="unknown"
2888 curl_format_curl_off_t="unknown"
2889 curl_format_curl_off_tu="unknown"
2891 if test "$curl_typeof_curl_off_t" = "unknown"; then
2892 AC_MSG_CHECKING([for 64-bit curl_off_t data type])
2900 DO_CURL_OFF_T_CHECK([$t8], [8])
2902 AC_MSG_RESULT([$curl_typeof_curl_off_t])
2904 if test "$curl_typeof_curl_off_t" = "unknown"; then
2905 AC_MSG_CHECKING([for 32-bit curl_off_t data type])
2911 DO_CURL_OFF_T_CHECK([$t4], [4])
2913 AC_MSG_RESULT([$curl_typeof_curl_off_t])
2915 if test "$curl_typeof_curl_off_t" = "unknown"; then
2916 AC_MSG_CHECKING([for 16-bit curl_off_t data type])
2922 DO_CURL_OFF_T_CHECK([$t2], [2])
2924 AC_MSG_RESULT([$curl_typeof_curl_off_t])
2926 if test "$curl_typeof_curl_off_t" = "unknown"; then
2927 AC_MSG_ERROR([cannot find data type for curl_off_t.])
2930 AC_MSG_CHECKING([size of curl_off_t])
2931 AC_MSG_RESULT([$curl_sizeof_curl_off_t])
2933 AC_MSG_CHECKING([formatting string directive for curl_off_t])
2934 if test "$curl_format_curl_off_t" != "unknown"; then
2935 x_pull_headers="yes"
2936 curl_format_curl_off_t=`echo "$curl_format_curl_off_t" | "$SED" 's/[["]]//g'`
2937 curl_format_curl_off_tu=`echo "$curl_format_curl_off_t" | "$SED" 's/i$/u/'`
2938 curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/d$/u/'`
2939 curl_format_curl_off_tu=`echo "$curl_format_curl_off_tu" | "$SED" 's/D$/U/'`
2942 case AS_TR_SH([$curl_typeof_curl_off_t]) in
2943 long_long | __longlong | __longlong_t)
2944 curl_format_curl_off_t="lld"
2945 curl_format_curl_off_tu="llu"
2948 curl_format_curl_off_t="ld"
2949 curl_format_curl_off_tu="lu"
2952 curl_format_curl_off_t="d"
2953 curl_format_curl_off_tu="u"
2956 curl_format_curl_off_t="I64d"
2957 curl_format_curl_off_tu="I64u"
2960 curl_format_curl_off_t="I32d"
2961 curl_format_curl_off_tu="I32u"
2964 curl_format_curl_off_t="I16d"
2965 curl_format_curl_off_tu="I16u"
2968 AC_MSG_ERROR([cannot find print format string for curl_off_t.])
2972 AC_MSG_RESULT(["$curl_format_curl_off_t"])
2974 AC_MSG_CHECKING([formatting string directive for unsigned curl_off_t])
2975 AC_MSG_RESULT(["$curl_format_curl_off_tu"])
2977 DO_CURL_OFF_T_SUFFIX_CHECK([$curl_typeof_curl_off_t])
2979 if test "$x_pull_headers" = "yes"; then
2980 if test "x$ac_cv_header_sys_types_h" = "xyes"; then
2981 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
2983 if test "x$ac_cv_header_stdint_h" = "xyes"; then
2984 CURL_DEFINE_UNQUOTED([CURL_PULL_STDINT_H])
2986 if test "x$ac_cv_header_inttypes_h" = "xyes"; then
2987 CURL_DEFINE_UNQUOTED([CURL_PULL_INTTYPES_H])
2991 CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_OFF_T], [$curl_typeof_curl_off_t])
2992 CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_T], ["$curl_format_curl_off_t"])
2993 CURL_DEFINE_UNQUOTED([CURL_FORMAT_CURL_OFF_TU], ["$curl_format_curl_off_tu"])
2994 CURL_DEFINE_UNQUOTED([CURL_FORMAT_OFF_T], ["%$curl_format_curl_off_t"])
2995 CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_OFF_T], [$curl_sizeof_curl_off_t])
2996 CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_T], [$curl_suffix_curl_off_t])
2997 CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_TU], [$curl_suffix_curl_off_tu])
3002 dnl CURL_CHECK_WIN32_LARGEFILE
3003 dnl -------------------------------------------------
3004 dnl Check if curl's WIN32 large file will be used
3006 AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [
3007 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
3008 AC_MSG_CHECKING([whether build target supports WIN32 file API])
3009 curl_win32_file_api="no"
3010 if test "$ac_cv_header_windows_h" = "yes"; then
3011 if test x"$enable_largefile" != "xno"; then
3015 #if !defined(_WIN32_WCE) && \
3016 (defined(__MINGW32__) || \
3017 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))))
3020 WIN32 large file API not supported.
3024 curl_win32_file_api="win32_large_files"
3027 if test "$curl_win32_file_api" = "no"; then
3031 #if defined(_WIN32_WCE) || defined(__MINGW32__) || defined(_MSC_VER)
3034 WIN32 small file API not supported.
3038 curl_win32_file_api="win32_small_files"
3042 case "$curl_win32_file_api" in
3044 AC_MSG_RESULT([yes (large file enabled)])
3045 AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
3046 [Define to 1 if you are building a Windows target with large file support.])
3049 AC_MSG_RESULT([yes (large file disabled)])
3050 AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1,
3051 [Define to 1 if you are building a Windows target without large file support.])