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_SETUP_VARS_ALPHA_SETS
122 dnl -------------------------------------------------
123 dnl Set up variables with sets of several letters.
125 AC_DEFUN([CURL_SETUP_VARS_ALPHA_SETS], [
126 curl_cv_letters='abcdefghijklmnopqrstuvwxyz'
127 curl_cv_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
128 curl_cv_Letters=$curl_cv_letters$curl_cv_LETTERS
129 curl_cv_digits='0123456789'
130 curl_cv_alnum=$curl_cv_Letters$curl_cv_digits
134 dnl CURL_CHECK_DEF_INTXX_C (INTXX_C, [INCLUDES])
135 dnl -------------------------------------------------
136 dnl Use the C preprocessor to find out if the given INTXX_C function-style
137 dnl macro is defined and get the suffix part of its expansion. This macro
138 dnl will not use default includes even if no INCLUDES argument is given.
140 AC_DEFUN([CURL_CHECK_DEF_INTXX_C], [
141 AC_REQUIRE([CURL_SETUP_VARS_ALPHA_SETS])dnl
142 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
143 AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
144 if test -z "$SED"; then
145 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
147 if test -z "$GREP"; then
148 AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
161 echo "DEBUG: preproc IF-ACTION branch for $1 -----" >&6
162 echo "DEBUG: ------- preproc source follows: " >&6
163 sed 's/^/cpp-src> /' conftest.$ac_ext >&6
164 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.yang2 1>conftest.yang1
165 echo "DEBUG: ------- preproc STDOUT follows: " >&6
166 sed 's/^/cpp-out> /' conftest.yang1 >&6
167 echo "DEBUG: ------- preproc STDERR follows: " >&6
168 sed 's/^/cpp-err> /' conftest.yang2 >&6
169 echo "DEBUG: ------- preproc STDERR ends in above line. " >&6
170 echo "DEBUG: ------- shell tmp_suf follows: " >&6
172 tmp_suf=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
173 "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
174 "$SED" 's/.*CURL_DEF_TOKEN//' 2>/dev/null | \
175 "$SED" 's/[[^'"$curl_cv_alnum"']]//g' 2>/dev/null`
177 echo "DEBUG: $tmp_suf" >&6
178 echo "DEBUG: ------- shell tmp_suf ends in above line. " >&6
180 if test -z "$tmp_suf"; then
187 echo "DEBUG: preproc ELSE-ACTION branch for $1 -----" >&6
188 echo "DEBUG: ------- preproc source follows: " >&6
189 sed 's/^/cpp-src> /' conftest.$ac_ext >&6
190 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.yang2 1>conftest.yang1
191 echo "DEBUG: ------- preproc STDOUT follows: " >&6
192 sed 's/^/cpp-out> /' conftest.yang1 >&6
193 echo "DEBUG: ------- preproc STDERR follows: " >&6
194 sed 's/^/cpp-err> /' conftest.yang2 >&6
195 echo "DEBUG: ------- preproc STDERR ends in above line. " >&6
202 if test -z "$tmp_suf"; then
203 AS_VAR_SET(ac_HaveDef, no)
205 AS_VAR_SET(ac_HaveDef, yes)
206 AS_VAR_SET(ac_Def, $tmp_suf)
208 AS_VAR_POPDEF([ac_Def])dnl
209 AS_VAR_POPDEF([ac_HaveDef])dnl
213 dnl CURL_CHECK_AIX_ALL_SOURCE
214 dnl -------------------------------------------------
215 dnl Provides a replacement of traditional AC_AIX with
216 dnl an uniform behaviour across all autoconf versions,
217 dnl and with our own placement rules.
219 AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [
220 AH_VERBATIM([_ALL_SOURCE],
221 [/* Define to 1 if OS is AIX. */
225 AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
226 AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl
227 AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
228 AC_EGREP_CPP([yes_this_is_aix],[
234 AC_DEFINE(_ALL_SOURCE)
241 dnl CURL_CHECK_HEADER_WINDOWS
242 dnl -------------------------------------------------
243 dnl Check for compilable and valid windows.h header
245 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
246 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
250 #ifndef WIN32_LEAN_AND_MEAN
251 #define WIN32_LEAN_AND_MEAN
255 #if defined(__CYGWIN__) || defined(__CEGCC__)
256 HAVE_WINDOWS_H shall not be defined.
262 ac_cv_header_windows_h="yes"
264 ac_cv_header_windows_h="no"
267 case "$ac_cv_header_windows_h" in
269 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
270 [Define to 1 if you have the windows.h header file.])
271 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
272 [Define to avoid automatic inclusion of winsock.h])
278 dnl CURL_CHECK_NATIVE_WINDOWS
279 dnl -------------------------------------------------
280 dnl Check if building a native Windows target
282 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
283 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
284 AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
285 if test "$ac_cv_header_windows_h" = "no"; then
286 ac_cv_native_windows="no"
291 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
292 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
295 Not a native Windows build target.
299 ac_cv_native_windows="yes"
301 ac_cv_native_windows="no"
305 case "$ac_cv_native_windows" in
307 AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
308 [Define to 1 if you are building a native Windows target.])
314 dnl CURL_CHECK_HEADER_WINSOCK
315 dnl -------------------------------------------------
316 dnl Check for compilable and valid winsock.h header
318 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
319 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
320 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
324 #ifndef WIN32_LEAN_AND_MEAN
325 #define WIN32_LEAN_AND_MEAN
330 #if defined(__CYGWIN__) || defined(__CEGCC__)
331 HAVE_WINSOCK_H shall not be defined.
333 int dummy=WSACleanup();
337 ac_cv_header_winsock_h="yes"
339 ac_cv_header_winsock_h="no"
342 case "$ac_cv_header_winsock_h" in
344 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
345 [Define to 1 if you have the winsock.h header file.])
351 dnl CURL_CHECK_HEADER_WINSOCK2
352 dnl -------------------------------------------------
353 dnl Check for compilable and valid winsock2.h header
355 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
356 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
357 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
361 #ifndef WIN32_LEAN_AND_MEAN
362 #define WIN32_LEAN_AND_MEAN
365 #include <winsock2.h>
367 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
368 HAVE_WINSOCK2_H shall not be defined.
370 int dummy=2*IPPROTO_ESP;
374 ac_cv_header_winsock2_h="yes"
376 ac_cv_header_winsock2_h="no"
379 case "$ac_cv_header_winsock2_h" in
381 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
382 [Define to 1 if you have the winsock2.h header file.])
388 dnl CURL_CHECK_HEADER_WS2TCPIP
389 dnl -------------------------------------------------
390 dnl Check for compilable and valid ws2tcpip.h header
392 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
393 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
394 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
398 #ifndef WIN32_LEAN_AND_MEAN
399 #define WIN32_LEAN_AND_MEAN
402 #include <winsock2.h>
403 #include <ws2tcpip.h>
405 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
406 HAVE_WS2TCPIP_H shall not be defined.
408 int dummy=2*IP_PKTINFO;
412 ac_cv_header_ws2tcpip_h="yes"
414 ac_cv_header_ws2tcpip_h="no"
417 case "$ac_cv_header_ws2tcpip_h" in
419 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
420 [Define to 1 if you have the ws2tcpip.h header file.])
426 dnl CURL_CHECK_HEADER_WINLDAP
427 dnl -------------------------------------------------
428 dnl Check for compilable and valid winldap.h header
430 AC_DEFUN([CURL_CHECK_HEADER_WINLDAP], [
431 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
432 AC_CACHE_CHECK([for winldap.h], [ac_cv_header_winldap_h], [
436 #ifdef HAVE_WINDOWS_H
437 #ifndef WIN32_LEAN_AND_MEAN
438 #define WIN32_LEAN_AND_MEAN
444 #if defined(__CYGWIN__) || defined(__CEGCC__)
445 HAVE_WINLDAP_H shall not be defined.
447 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
448 ULONG res = ldap_unbind(ldp);
452 ac_cv_header_winldap_h="yes"
454 ac_cv_header_winldap_h="no"
457 case "$ac_cv_header_winldap_h" in
459 AC_DEFINE_UNQUOTED(HAVE_WINLDAP_H, 1,
460 [Define to 1 if you have the winldap.h header file.])
466 dnl CURL_CHECK_HEADER_WINBER
467 dnl -------------------------------------------------
468 dnl Check for compilable and valid winber.h header
470 AC_DEFUN([CURL_CHECK_HEADER_WINBER], [
471 AC_REQUIRE([CURL_CHECK_HEADER_WINLDAP])dnl
472 AC_CACHE_CHECK([for winber.h], [ac_cv_header_winber_h], [
476 #ifdef HAVE_WINDOWS_H
477 #ifndef WIN32_LEAN_AND_MEAN
478 #define WIN32_LEAN_AND_MEAN
485 #if defined(__CYGWIN__) || defined(__CEGCC__)
486 HAVE_WINBER_H shall not be defined.
489 BerElement *bep = ber_init(bvp);
494 ac_cv_header_winber_h="yes"
496 ac_cv_header_winber_h="no"
499 case "$ac_cv_header_winber_h" in
501 AC_DEFINE_UNQUOTED(HAVE_WINBER_H, 1,
502 [Define to 1 if you have the winber.h header file.])
508 dnl CURL_CHECK_HEADER_LBER
509 dnl -------------------------------------------------
510 dnl Check for compilable and valid lber.h header,
511 dnl and check if it is needed even with ldap.h
513 AC_DEFUN([CURL_CHECK_HEADER_LBER], [
514 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
515 AC_CACHE_CHECK([for lber.h], [ac_cv_header_lber_h], [
519 #ifdef HAVE_WINDOWS_H
520 #ifndef WIN32_LEAN_AND_MEAN
521 #define WIN32_LEAN_AND_MEAN
525 #ifdef HAVE_SYS_TYPES_H
526 #include <sys/types.h>
530 #define NULL (void *)0
534 BerValue *bvp = NULL;
535 BerElement *bep = ber_init(bvp);
539 ac_cv_header_lber_h="yes"
541 ac_cv_header_lber_h="no"
544 if test "$ac_cv_header_lber_h" = "yes"; then
545 AC_DEFINE_UNQUOTED(HAVE_LBER_H, 1,
546 [Define to 1 if you have the lber.h header file.])
551 #ifdef HAVE_WINDOWS_H
552 #ifndef WIN32_LEAN_AND_MEAN
553 #define WIN32_LEAN_AND_MEAN
557 #ifdef HAVE_SYS_TYPES_H
558 #include <sys/types.h>
562 #define NULL (void *)0
564 #ifndef LDAP_DEPRECATED
565 #define LDAP_DEPRECATED 1
569 BerValue *bvp = NULL;
570 BerElement *bep = ber_init(bvp);
574 curl_cv_need_header_lber_h="no"
576 curl_cv_need_header_lber_h="yes"
579 case "$curl_cv_need_header_lber_h" in
581 AC_DEFINE_UNQUOTED(NEED_LBER_H, 1,
582 [Define to 1 if you need the lber.h header file even with ldap.h])
589 dnl CURL_CHECK_HEADER_LDAP
590 dnl -------------------------------------------------
591 dnl Check for compilable and valid ldap.h header
593 AC_DEFUN([CURL_CHECK_HEADER_LDAP], [
594 AC_REQUIRE([CURL_CHECK_HEADER_LBER])dnl
595 AC_CACHE_CHECK([for ldap.h], [ac_cv_header_ldap_h], [
599 #ifdef HAVE_WINDOWS_H
600 #ifndef WIN32_LEAN_AND_MEAN
601 #define WIN32_LEAN_AND_MEAN
605 #ifdef HAVE_SYS_TYPES_H
606 #include <sys/types.h>
609 #ifndef LDAP_DEPRECATED
610 #define LDAP_DEPRECATED 1
617 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
618 int res = ldap_unbind(ldp);
621 ac_cv_header_ldap_h="yes"
623 ac_cv_header_ldap_h="no"
626 case "$ac_cv_header_ldap_h" in
628 AC_DEFINE_UNQUOTED(HAVE_LDAP_H, 1,
629 [Define to 1 if you have the ldap.h header file.])
635 dnl CURL_CHECK_HEADER_LDAP_SSL
636 dnl -------------------------------------------------
637 dnl Check for compilable and valid ldap_ssl.h header
639 AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [
640 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
641 AC_CACHE_CHECK([for ldap_ssl.h], [ac_cv_header_ldap_ssl_h], [
645 #ifdef HAVE_WINDOWS_H
646 #ifndef WIN32_LEAN_AND_MEAN
647 #define WIN32_LEAN_AND_MEAN
651 #ifdef HAVE_SYS_TYPES_H
652 #include <sys/types.h>
655 #ifndef LDAP_DEPRECATED
656 #define LDAP_DEPRECATED 1
664 #include <ldap_ssl.h>
666 LDAP *ldp = ldapssl_init("dummy", LDAPS_PORT, 1);
669 ac_cv_header_ldap_ssl_h="yes"
671 ac_cv_header_ldap_ssl_h="no"
674 case "$ac_cv_header_ldap_ssl_h" in
676 AC_DEFINE_UNQUOTED(HAVE_LDAP_SSL_H, 1,
677 [Define to 1 if you have the ldap_ssl.h header file.])
683 dnl CURL_CHECK_HEADER_LDAPSSL
684 dnl -------------------------------------------------
685 dnl Check for compilable and valid ldapssl.h header
687 AC_DEFUN([CURL_CHECK_HEADER_LDAPSSL], [
688 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
689 AC_CACHE_CHECK([for ldapssl.h], [ac_cv_header_ldapssl_h], [
693 #ifdef HAVE_WINDOWS_H
694 #ifndef WIN32_LEAN_AND_MEAN
695 #define WIN32_LEAN_AND_MEAN
699 #ifdef HAVE_SYS_TYPES_H
700 #include <sys/types.h>
704 #define NULL (void *)0
706 #ifndef LDAP_DEPRECATED
707 #define LDAP_DEPRECATED 1
717 char *cert_label = NULL;
718 LDAP *ldp = ldap_ssl_init("dummy", LDAPS_PORT, cert_label);
721 ac_cv_header_ldapssl_h="yes"
723 ac_cv_header_ldapssl_h="no"
726 case "$ac_cv_header_ldapssl_h" in
728 AC_DEFINE_UNQUOTED(HAVE_LDAPSSL_H, 1,
729 [Define to 1 if you have the ldapssl.h header file.])
735 dnl CURL_CHECK_LIBS_WINLDAP
736 dnl -------------------------------------------------
737 dnl Check for libraries needed for WINLDAP support,
738 dnl and prepended to LIBS any needed libraries.
739 dnl This macro can take an optional parameter with a
740 dnl white space separated list of libraries to check
741 dnl before the WINLDAP default ones.
743 AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [
744 AC_REQUIRE([CURL_CHECK_HEADER_WINBER])dnl
746 AC_MSG_CHECKING([for WINLDAP libraries])
760 if test -z "$u_libs"; then
763 u_libs="$u_libs $l_lib"
768 curl_cv_save_LIBS="$LIBS"
769 curl_cv_ldap_LIBS="unknown"
771 for x_nlibs in '' "$u_libs" \
773 if test "$curl_cv_ldap_LIBS" = "unknown"; then
774 if test -z "$x_nlibs"; then
775 LIBS="$curl_cv_save_LIBS"
777 LIBS="$x_nlibs $curl_cv_save_LIBS"
782 #ifdef HAVE_WINDOWS_H
783 #ifndef WIN32_LEAN_AND_MEAN
784 #define WIN32_LEAN_AND_MEAN
787 #ifdef HAVE_WINLDAP_H
796 BerElement *bep = ber_init(bvp);
797 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
798 ULONG res = ldap_unbind(ldp);
802 curl_cv_ldap_LIBS="$x_nlibs"
807 LIBS="$curl_cv_save_LIBS"
809 case X-"$curl_cv_ldap_LIBS" in
811 AC_MSG_RESULT([cannot find WINLDAP libraries])
814 AC_MSG_RESULT([no additional lib required])
817 if test -z "$curl_cv_save_LIBS"; then
818 LIBS="$curl_cv_ldap_LIBS"
820 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
822 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
829 dnl CURL_CHECK_LIBS_LDAP
830 dnl -------------------------------------------------
831 dnl Check for libraries needed for LDAP support,
832 dnl and prepended to LIBS any needed libraries.
833 dnl This macro can take an optional parameter with a
834 dnl white space separated list of libraries to check
835 dnl before the default ones.
837 AC_DEFUN([CURL_CHECK_LIBS_LDAP], [
838 AC_REQUIRE([CURL_CHECK_HEADER_LDAP])dnl
840 AC_MSG_CHECKING([for LDAP libraries])
854 if test -z "$u_libs"; then
857 u_libs="$u_libs $l_lib"
862 curl_cv_save_LIBS="$LIBS"
863 curl_cv_ldap_LIBS="unknown"
865 for x_nlibs in '' "$u_libs" \
869 '-lldapssl -lldapx -lldapsdk' \
870 '-lldapsdk -lldapx -lldapssl' ; do
871 if test "$curl_cv_ldap_LIBS" = "unknown"; then
872 if test -z "$x_nlibs"; then
873 LIBS="$curl_cv_save_LIBS"
875 LIBS="$x_nlibs $curl_cv_save_LIBS"
880 #ifdef HAVE_WINDOWS_H
881 #ifndef WIN32_LEAN_AND_MEAN
882 #define WIN32_LEAN_AND_MEAN
886 #ifdef HAVE_SYS_TYPES_H
887 #include <sys/types.h>
891 #define NULL (void *)0
893 #ifndef LDAP_DEPRECATED
894 #define LDAP_DEPRECATED 1
903 BerValue *bvp = NULL;
904 BerElement *bep = ber_init(bvp);
905 LDAP *ldp = ldap_init("dummy", LDAP_PORT);
906 int res = ldap_unbind(ldp);
910 curl_cv_ldap_LIBS="$x_nlibs"
915 LIBS="$curl_cv_save_LIBS"
917 case X-"$curl_cv_ldap_LIBS" in
919 AC_MSG_RESULT([cannot find LDAP libraries])
922 AC_MSG_RESULT([no additional lib required])
925 if test -z "$curl_cv_save_LIBS"; then
926 LIBS="$curl_cv_ldap_LIBS"
928 LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS"
930 AC_MSG_RESULT([$curl_cv_ldap_LIBS])
937 dnl CURL_CHECK_HEADER_MALLOC
938 dnl -------------------------------------------------
939 dnl Check for compilable and valid malloc.h header,
940 dnl and check if it is needed even with stdlib.h
942 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
943 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
948 void *p = malloc(10);
949 void *q = calloc(10,10);
954 ac_cv_header_malloc_h="yes"
956 ac_cv_header_malloc_h="no"
959 if test "$ac_cv_header_malloc_h" = "yes"; then
960 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
961 [Define to 1 if you have the malloc.h header file.])
967 void *p = malloc(10);
968 void *q = calloc(10,10);
973 curl_cv_need_header_malloc_h="no"
975 curl_cv_need_header_malloc_h="yes"
978 case "$curl_cv_need_header_malloc_h" in
980 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
981 [Define to 1 if you need the malloc.h header file even with stdlib.h])
988 dnl CURL_CHECK_TYPE_SOCKLEN_T
989 dnl -------------------------------------------------
990 dnl Check for existing socklen_t type, and provide
991 dnl an equivalent type if socklen_t not available
993 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
994 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
995 AC_CHECK_TYPE([socklen_t], ,[
996 dnl socklen_t not available
997 AC_CACHE_CHECK([for socklen_t equivalent],
998 [curl_cv_socklen_t_equiv], [
999 curl_cv_socklen_t_equiv="unknown"
1000 for arg1 in 'int' 'SOCKET'; do
1001 for arg2 in "struct sockaddr" void; do
1002 for t in int size_t unsigned long "unsigned long"; do
1003 if test "$curl_cv_socklen_t_equiv" = "unknown"; then
1007 #ifdef HAVE_WINDOWS_H
1008 #ifndef WIN32_LEAN_AND_MEAN
1009 #define WIN32_LEAN_AND_MEAN
1011 #include <windows.h>
1012 #ifdef HAVE_WINSOCK2_H
1013 #include <winsock2.h>
1015 #ifdef HAVE_WINSOCK_H
1016 #include <winsock.h>
1019 #define GETPEERNCALLCONV PASCAL
1021 #ifdef HAVE_SYS_TYPES_H
1022 #include <sys/types.h>
1024 #ifdef HAVE_SYS_SOCKET_H
1025 #include <sys/socket.h>
1027 #define GETPEERNCALLCONV
1029 extern int GETPEERNCALLCONV getpeername($arg1, $arg2 *, $t *);
1032 getpeername(0,0,&len);
1035 curl_cv_socklen_t_equiv="$t"
1042 case "$curl_cv_socklen_t_equiv" in
1044 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
1047 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
1048 [Type to use in place of socklen_t when system does not provide it.])
1053 #ifdef HAVE_WINDOWS_H
1054 #ifndef WIN32_LEAN_AND_MEAN
1055 #define WIN32_LEAN_AND_MEAN
1057 #include <windows.h>
1058 #ifdef HAVE_WINSOCK2_H
1059 #include <winsock2.h>
1060 #ifdef HAVE_WS2TCPIP_H
1061 #include <ws2tcpip.h>
1065 #ifdef HAVE_SYS_TYPES_H
1066 #include <sys/types.h>
1068 #ifdef HAVE_SYS_SOCKET_H
1069 #include <sys/socket.h>
1076 dnl CURL_CHECK_FUNC_GETNAMEINFO
1077 dnl -------------------------------------------------
1078 dnl Test if the getnameinfo function is available,
1079 dnl and check the types of five of its arguments.
1080 dnl If the function succeeds HAVE_GETNAMEINFO will be
1081 dnl defined, defining the types of the arguments in
1082 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
1083 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
1084 dnl and also defining the type qualifier of first
1085 dnl argument in GETNAMEINFO_QUAL_ARG1.
1087 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
1088 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
1089 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
1090 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
1092 AC_MSG_CHECKING([for getnameinfo])
1094 AC_LANG_FUNC_LINK_TRY([getnameinfo])
1096 AC_MSG_RESULT([yes])
1097 curl_cv_getnameinfo="yes"
1100 curl_cv_getnameinfo="no"
1103 if test "$curl_cv_getnameinfo" != "yes"; then
1104 AC_MSG_CHECKING([deeper for getnameinfo])
1111 AC_MSG_RESULT([yes])
1112 curl_cv_getnameinfo="yes"
1114 AC_MSG_RESULT([but still no])
1115 curl_cv_getnameinfo="no"
1119 if test "$curl_cv_getnameinfo" != "yes"; then
1120 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
1124 #ifdef HAVE_WINDOWS_H
1125 #ifndef WIN32_LEAN_AND_MEAN
1126 #define WIN32_LEAN_AND_MEAN
1128 #include <windows.h>
1129 #ifdef HAVE_WINSOCK2_H
1130 #include <winsock2.h>
1131 #ifdef HAVE_WS2TCPIP_H
1132 #include <ws2tcpip.h>
1136 #ifdef HAVE_SYS_TYPES_H
1137 #include <sys/types.h>
1139 #ifdef HAVE_SYS_SOCKET_H
1140 #include <sys/socket.h>
1147 getnameinfo(0, 0, 0, 0, 0, 0, 0);
1150 AC_MSG_RESULT([yes])
1151 curl_cv_getnameinfo="yes"
1153 AC_MSG_RESULT([but still no])
1154 curl_cv_getnameinfo="no"
1158 if test "$curl_cv_getnameinfo" = "yes"; then
1159 AC_CACHE_CHECK([types of arguments for getnameinfo],
1160 [curl_cv_func_getnameinfo_args], [
1161 curl_cv_func_getnameinfo_args="unknown"
1162 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
1163 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
1164 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
1165 for gni_arg7 in 'int' 'unsigned int'; do
1166 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1170 #ifdef HAVE_WINDOWS_H
1171 #ifndef WIN32_LEAN_AND_MEAN
1172 #define WIN32_LEAN_AND_MEAN
1174 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
1176 #define _WIN32_WINNT 0x0501
1178 #include <windows.h>
1179 #ifdef HAVE_WINSOCK2_H
1180 #include <winsock2.h>
1181 #ifdef HAVE_WS2TCPIP_H
1182 #include <ws2tcpip.h>
1185 #define GNICALLCONV WSAAPI
1187 #ifdef HAVE_SYS_TYPES_H
1188 #include <sys/types.h>
1190 #ifdef HAVE_SYS_SOCKET_H
1191 #include <sys/socket.h>
1198 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
1204 $gni_arg46 hostlen=0;
1205 $gni_arg46 servlen=0;
1207 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
1210 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
1218 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
1219 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
1220 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
1222 gni_prev_IFS=$IFS; IFS=','
1223 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
1227 gni_qual_type_arg1=$[1]
1229 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
1230 [Define to the type of arg 2 for getnameinfo.])
1231 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
1232 [Define to the type of args 4 and 6 for getnameinfo.])
1233 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
1234 [Define to the type of arg 7 for getnameinfo.])
1238 case $prev_sh_opts in
1246 case "$gni_qual_type_arg1" in
1249 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
1253 gni_type_arg1=$gni_qual_type_arg1
1257 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
1258 [Define to the type qualifier of arg 1 for getnameinfo.])
1259 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
1260 [Define to the type of arg 1 for getnameinfo.])
1262 case $prev_sh_opts in
1270 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
1271 [Define to 1 if you have the getnameinfo function.])
1272 ac_cv_func_getnameinfo="yes"
1278 dnl TYPE_SOCKADDR_STORAGE
1279 dnl -------------------------------------------------
1280 dnl Check for struct sockaddr_storage. Most IPv6-enabled
1281 dnl hosts have it, but AIX 4.3 is one known exception.
1283 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
1285 AC_CHECK_TYPE([struct sockaddr_storage],
1286 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
1287 [if struct sockaddr_storage is defined]), ,
1290 #ifdef HAVE_WINDOWS_H
1291 #ifndef WIN32_LEAN_AND_MEAN
1292 #define WIN32_LEAN_AND_MEAN
1294 #include <windows.h>
1295 #ifdef HAVE_WINSOCK2_H
1296 #include <winsock2.h>
1299 #ifdef HAVE_SYS_TYPES_H
1300 #include <sys/types.h>
1302 #ifdef HAVE_SYS_SOCKET_H
1303 #include <sys/socket.h>
1305 #ifdef HAVE_NETINET_IN_H
1306 #include <netinet/in.h>
1308 #ifdef HAVE_ARPA_INET_H
1309 #include <arpa/inet.h>
1316 dnl CURL_CHECK_NI_WITHSCOPEID
1317 dnl -------------------------------------------------
1318 dnl Check for working NI_WITHSCOPEID in getnameinfo()
1320 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
1321 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
1322 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
1323 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
1324 netdb.h netinet/in.h arpa/inet.h)
1326 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
1327 [ac_cv_working_ni_withscopeid], [
1333 #ifdef HAVE_SYS_TYPES_H
1334 #include <sys/types.h>
1336 #ifdef HAVE_SYS_SOCKET_H
1337 #include <sys/socket.h>
1342 #ifdef HAVE_NETINET_IN_H
1343 #include <netinet/in.h>
1345 #ifdef HAVE_ARPA_INET_H
1346 #include <arpa/inet.h>
1349 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
1350 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
1351 struct sockaddr_storage sa;
1353 unsigned char sa[256];
1355 char hostbuf[NI_MAXHOST];
1357 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
1358 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
1359 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1360 int fd = socket(AF_INET6, SOCK_STREAM, 0);
1363 return 1; /* Error creating socket */
1365 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
1367 perror("getsockname()");
1368 return 2; /* Error retrieving socket name */
1370 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
1372 printf("rc = %s\n", gai_strerror(rc));
1373 return 3; /* Error translating socket address */
1375 return 0; /* Ok, NI_WITHSCOPEID works */
1377 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
1379 ]]) # AC-LANG-PROGRAM
1381 # Exit code == 0. Program worked.
1382 ac_cv_working_ni_withscopeid="yes"
1384 # Exit code != 0. Program failed.
1385 ac_cv_working_ni_withscopeid="no"
1387 # Program is not run when cross-compiling. So we assume
1388 # NI_WITHSCOPEID will work if we are able to compile it.
1391 #include <sys/types.h>
1392 #include <sys/socket.h>
1395 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
1398 ac_cv_working_ni_withscopeid="yes"
1400 ac_cv_working_ni_withscopeid="no"
1401 ]) # AC-COMPILE-IFELSE
1404 case "$ac_cv_working_ni_withscopeid" in
1406 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
1407 [Define to 1 if NI_WITHSCOPEID exists and works.])
1413 dnl CURL_CHECK_FUNC_RECV
1414 dnl -------------------------------------------------
1415 dnl Test if the socket recv() function is available,
1416 dnl and check its return type and the types of its
1417 dnl arguments. If the function succeeds HAVE_RECV
1418 dnl will be defined, defining the types of the arguments
1419 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
1420 dnl and RECV_TYPE_ARG4, defining the type of the function
1421 dnl return value in RECV_TYPE_RETV.
1423 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
1424 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1425 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1426 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1428 AC_MSG_CHECKING([for recv])
1432 #ifdef HAVE_WINDOWS_H
1433 #ifndef WIN32_LEAN_AND_MEAN
1434 #define WIN32_LEAN_AND_MEAN
1436 #include <windows.h>
1437 #ifdef HAVE_WINSOCK2_H
1438 #include <winsock2.h>
1440 #ifdef HAVE_WINSOCK_H
1441 #include <winsock.h>
1445 #ifdef HAVE_SYS_TYPES_H
1446 #include <sys/types.h>
1448 #ifdef HAVE_SYS_SOCKET_H
1449 #include <sys/socket.h>
1456 AC_MSG_RESULT([yes])
1463 if test "$curl_cv_recv" = "yes"; then
1464 AC_CACHE_CHECK([types of args and return type for recv],
1465 [curl_cv_func_recv_args], [
1466 curl_cv_func_recv_args="unknown"
1467 for recv_retv in 'int' 'ssize_t'; do
1468 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1469 for recv_arg2 in 'char *' 'void *'; do
1470 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1471 for recv_arg4 in 'int' 'unsigned int'; do
1472 if test "$curl_cv_func_recv_args" = "unknown"; then
1476 #ifdef HAVE_WINDOWS_H
1477 #ifndef WIN32_LEAN_AND_MEAN
1478 #define WIN32_LEAN_AND_MEAN
1480 #include <windows.h>
1481 #ifdef HAVE_WINSOCK2_H
1482 #include <winsock2.h>
1484 #ifdef HAVE_WINSOCK_H
1485 #include <winsock.h>
1488 #define RECVCALLCONV PASCAL
1490 #ifdef HAVE_SYS_TYPES_H
1491 #include <sys/types.h>
1493 #ifdef HAVE_SYS_SOCKET_H
1494 #include <sys/socket.h>
1496 #define RECVCALLCONV
1498 extern $recv_retv RECVCALLCONV
1499 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
1505 $recv_retv res = recv(s, buf, len, flags);
1508 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
1517 if test "$curl_cv_func_recv_args" = "unknown"; then
1518 AC_MSG_ERROR([Cannot find proper types to use for recv args])
1520 recv_prev_IFS=$IFS; IFS=','
1521 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
1525 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
1526 [Define to the type of arg 1 for recv.])
1527 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
1528 [Define to the type of arg 2 for recv.])
1529 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
1530 [Define to the type of arg 3 for recv.])
1531 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
1532 [Define to the type of arg 4 for recv.])
1533 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
1534 [Define to the function return type for recv.])
1536 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
1537 [Define to 1 if you have the recv function.])
1538 ac_cv_func_recv="yes"
1541 AC_MSG_ERROR([Unable to link function recv])
1546 dnl CURL_CHECK_FUNC_SEND
1547 dnl -------------------------------------------------
1548 dnl Test if the socket send() function is available,
1549 dnl and check its return type and the types of its
1550 dnl arguments. If the function succeeds HAVE_SEND
1551 dnl will be defined, defining the types of the arguments
1552 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
1553 dnl and SEND_TYPE_ARG4, defining the type of the function
1554 dnl return value in SEND_TYPE_RETV, and also defining the
1555 dnl type qualifier of second argument in SEND_QUAL_ARG2.
1557 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
1558 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1559 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1560 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1562 AC_MSG_CHECKING([for send])
1566 #ifdef HAVE_WINDOWS_H
1567 #ifndef WIN32_LEAN_AND_MEAN
1568 #define WIN32_LEAN_AND_MEAN
1570 #include <windows.h>
1571 #ifdef HAVE_WINSOCK2_H
1572 #include <winsock2.h>
1574 #ifdef HAVE_WINSOCK_H
1575 #include <winsock.h>
1579 #ifdef HAVE_SYS_TYPES_H
1580 #include <sys/types.h>
1582 #ifdef HAVE_SYS_SOCKET_H
1583 #include <sys/socket.h>
1590 AC_MSG_RESULT([yes])
1597 if test "$curl_cv_send" = "yes"; then
1598 AC_CACHE_CHECK([types of args and return type for send],
1599 [curl_cv_func_send_args], [
1600 curl_cv_func_send_args="unknown"
1601 for send_retv in 'int' 'ssize_t'; do
1602 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1603 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
1604 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1605 for send_arg4 in 'int' 'unsigned int'; do
1606 if test "$curl_cv_func_send_args" = "unknown"; then
1610 #ifdef HAVE_WINDOWS_H
1611 #ifndef WIN32_LEAN_AND_MEAN
1612 #define WIN32_LEAN_AND_MEAN
1614 #include <windows.h>
1615 #ifdef HAVE_WINSOCK2_H
1616 #include <winsock2.h>
1618 #ifdef HAVE_WINSOCK_H
1619 #include <winsock.h>
1622 #define SENDCALLCONV PASCAL
1624 #ifdef HAVE_SYS_TYPES_H
1625 #include <sys/types.h>
1627 #ifdef HAVE_SYS_SOCKET_H
1628 #include <sys/socket.h>
1630 #define SENDCALLCONV
1632 extern $send_retv SENDCALLCONV
1633 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1638 $send_retv res = send(s, 0, len, flags);
1641 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1650 if test "$curl_cv_func_send_args" = "unknown"; then
1651 AC_MSG_ERROR([Cannot find proper types to use for send args])
1653 send_prev_IFS=$IFS; IFS=','
1654 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1658 send_qual_type_arg2=$[2]
1660 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1661 [Define to the type of arg 1 for send.])
1662 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1663 [Define to the type of arg 3 for send.])
1664 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1665 [Define to the type of arg 4 for send.])
1666 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1667 [Define to the function return type for send.])
1671 case $prev_sh_opts in
1679 case "$send_qual_type_arg2" in
1681 send_qual_arg2=const
1682 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1686 send_type_arg2=$send_qual_type_arg2
1690 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1691 [Define to the type qualifier of arg 2 for send.])
1692 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1693 [Define to the type of arg 2 for send.])
1695 case $prev_sh_opts in
1703 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1704 [Define to 1 if you have the send function.])
1705 ac_cv_func_send="yes"
1708 AC_MSG_ERROR([Unable to link function send])
1713 dnl CURL_CHECK_FUNC_RECVFROM
1714 dnl -------------------------------------------------
1715 dnl Test if the socket recvfrom() function is available,
1716 dnl and check its return type and the types of its
1717 dnl arguments. If the function succeeds HAVE_RECVFROM
1718 dnl will be defined, defining the types of the arguments
1719 dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
1720 dnl to RECVFROM_TYPE_ARG6, defining also the type of the
1721 dnl function return value in RECVFROM_TYPE_RETV.
1722 dnl Notice that the types returned for pointer arguments
1723 dnl will actually be the type pointed by the pointer.
1725 AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
1726 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1727 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1728 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1730 AC_MSG_CHECKING([for recvfrom])
1734 #ifdef HAVE_WINDOWS_H
1735 #ifndef WIN32_LEAN_AND_MEAN
1736 #define WIN32_LEAN_AND_MEAN
1738 #include <windows.h>
1739 #ifdef HAVE_WINSOCK2_H
1740 #include <winsock2.h>
1742 #ifdef HAVE_WINSOCK_H
1743 #include <winsock.h>
1747 #ifdef HAVE_SYS_TYPES_H
1748 #include <sys/types.h>
1750 #ifdef HAVE_SYS_SOCKET_H
1751 #include <sys/socket.h>
1755 recvfrom(0, 0, 0, 0, 0, 0);
1758 AC_MSG_RESULT([yes])
1759 curl_cv_recvfrom="yes"
1762 curl_cv_recvfrom="no"
1765 if test "$curl_cv_recvfrom" = "yes"; then
1766 AC_CACHE_CHECK([types of args and return type for recvfrom],
1767 [curl_cv_func_recvfrom_args], [
1768 curl_cv_func_recvfrom_args="unknown"
1769 for recvfrom_retv in 'int' 'ssize_t'; do
1770 for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1771 for recvfrom_arg2 in 'char *' 'void *'; do
1772 for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1773 for recvfrom_arg4 in 'int' 'unsigned int'; do
1774 for recvfrom_arg5 in 'struct sockaddr *' 'void *'; do
1775 for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
1776 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1780 #ifdef HAVE_WINDOWS_H
1781 #ifndef WIN32_LEAN_AND_MEAN
1782 #define WIN32_LEAN_AND_MEAN
1784 #include <windows.h>
1785 #ifdef HAVE_WINSOCK2_H
1786 #include <winsock2.h>
1788 #ifdef HAVE_WINSOCK_H
1789 #include <winsock.h>
1792 #define RECVFROMCALLCONV PASCAL
1794 #ifdef HAVE_SYS_TYPES_H
1795 #include <sys/types.h>
1797 #ifdef HAVE_SYS_SOCKET_H
1798 #include <sys/socket.h>
1800 #define RECVFROMCALLCONV
1802 extern $recvfrom_retv RECVFROMCALLCONV
1803 recvfrom($recvfrom_arg1, $recvfrom_arg2,
1804 $recvfrom_arg3, $recvfrom_arg4,
1805 $recvfrom_arg5, $recvfrom_arg6);
1808 $recvfrom_arg2 buf=0;
1809 $recvfrom_arg3 len=0;
1810 $recvfrom_arg4 flags=0;
1811 $recvfrom_arg5 addr=0;
1812 $recvfrom_arg6 addrlen=0;
1813 $recvfrom_retv res=0;
1814 res = recvfrom(s, buf, len, flags, addr, addrlen);
1817 curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
1828 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1829 AC_MSG_ERROR([Cannot find proper types to use for recvfrom args])
1831 recvfrom_prev_IFS=$IFS; IFS=','
1832 set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
1833 IFS=$recvfrom_prev_IFS
1836 recvfrom_ptrt_arg2=$[2]
1837 recvfrom_ptrt_arg5=$[5]
1838 recvfrom_ptrt_arg6=$[6]
1840 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
1841 [Define to the type of arg 1 for recvfrom.])
1842 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
1843 [Define to the type of arg 3 for recvfrom.])
1844 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
1845 [Define to the type of arg 4 for recvfrom.])
1846 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
1847 [Define to the function return type for recvfrom.])
1851 case $prev_sh_opts in
1859 recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
1860 recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
1861 recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
1863 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
1864 [Define to the type pointed by arg 2 for recvfrom.])
1865 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
1866 [Define to the type pointed by arg 5 for recvfrom.])
1867 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
1868 [Define to the type pointed by arg 6 for recvfrom.])
1870 if test "$recvfrom_type_arg2" = "void"; then
1871 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2_IS_VOID, 1,
1872 [Define to 1 if the type pointed by arg 2 for recvfrom is void.])
1874 if test "$recvfrom_type_arg5" = "void"; then
1875 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5_IS_VOID, 1,
1876 [Define to 1 if the type pointed by arg 5 for recvfrom is void.])
1878 if test "$recvfrom_type_arg6" = "void"; then
1879 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6_IS_VOID, 1,
1880 [Define to 1 if the type pointed by arg 6 for recvfrom is void.])
1883 case $prev_sh_opts in
1891 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1892 [Define to 1 if you have the recvfrom function.])
1893 ac_cv_func_recvfrom="yes"
1896 AC_MSG_ERROR([Unable to link function recvfrom])
1901 dnl CURL_CHECK_MSG_NOSIGNAL
1902 dnl -------------------------------------------------
1903 dnl Check for MSG_NOSIGNAL
1905 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1906 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1907 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1911 #ifdef HAVE_WINDOWS_H
1912 #ifndef WIN32_LEAN_AND_MEAN
1913 #define WIN32_LEAN_AND_MEAN
1915 #include <windows.h>
1916 #ifdef HAVE_WINSOCK2_H
1917 #include <winsock2.h>
1919 #ifdef HAVE_WINSOCK_H
1920 #include <winsock.h>
1924 #ifdef HAVE_SYS_TYPES_H
1925 #include <sys/types.h>
1927 #ifdef HAVE_SYS_SOCKET_H
1928 #include <sys/socket.h>
1932 int flag=MSG_NOSIGNAL;
1935 ac_cv_msg_nosignal="yes"
1937 ac_cv_msg_nosignal="no"
1940 case "$ac_cv_msg_nosignal" in
1942 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1943 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1949 dnl CURL_CHECK_STRUCT_TIMEVAL
1950 dnl -------------------------------------------------
1951 dnl Check for timeval struct
1953 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1954 AC_REQUIRE([AC_HEADER_TIME])dnl
1955 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1956 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1957 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1958 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1962 #ifdef HAVE_WINDOWS_H
1963 #ifndef WIN32_LEAN_AND_MEAN
1964 #define WIN32_LEAN_AND_MEAN
1966 #include <windows.h>
1967 #ifdef HAVE_WINSOCK2_H
1968 #include <winsock2.h>
1970 #ifdef HAVE_WINSOCK_H
1971 #include <winsock.h>
1975 #ifdef HAVE_SYS_TYPES_H
1976 #include <sys/types.h>
1978 #ifdef HAVE_SYS_TIME_H
1979 #include <sys/time.h>
1980 #ifdef TIME_WITH_SYS_TIME
1994 ac_cv_struct_timeval="yes"
1996 ac_cv_struct_timeval="no"
1999 case "$ac_cv_struct_timeval" in
2001 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
2002 [Define to 1 if you have the timeval struct.])
2008 dnl TYPE_SIG_ATOMIC_T
2009 dnl -------------------------------------------------
2010 dnl Check if the sig_atomic_t type is available, and
2011 dnl verify if it is already defined as volatile.
2013 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
2014 AC_CHECK_HEADERS(signal.h)
2015 AC_CHECK_TYPE([sig_atomic_t],[
2016 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
2017 [Define to 1 if sig_atomic_t is an available typedef.])
2019 #ifdef HAVE_SIGNAL_H
2023 case "$ac_cv_type_sig_atomic_t" in
2026 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
2029 #ifdef HAVE_SIGNAL_H
2033 static volatile sig_atomic_t dummy = 0;
2037 ac_cv_sig_atomic_t_volatile="no"
2039 AC_MSG_RESULT([yes])
2040 ac_cv_sig_atomic_t_volatile="yes"
2043 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
2044 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
2045 [Define to 1 if sig_atomic_t is already defined as volatile.])
2052 dnl CURL_CHECK_NONBLOCKING_SOCKET
2053 dnl -------------------------------------------------
2054 dnl Check for how to set a socket to non-blocking state. There seems to exist
2055 dnl four known different ways, with the one used almost everywhere being POSIX
2056 dnl and XPG3, while the other different ways for different systems (old BSD,
2057 dnl Windows and Amiga).
2059 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
2060 dnl O_NONBLOCK define is found but does not work. This condition is attempted
2061 dnl to get caught in this script by using an excessive number of #ifdefs...
2063 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [
2064 AC_MSG_CHECKING([non-blocking sockets style])
2069 /* headers for O_NONBLOCK test */
2070 #include <sys/types.h>
2074 #if defined(sun) || defined(__sun__) || \
2075 defined(__SUNPRO_C) || defined(__SUNPRO_CC)
2076 # if defined(__SVR4) || defined(__srv4__)
2077 # define PLATFORM_SOLARIS
2079 # define PLATFORM_SUNOS4
2082 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
2083 # define PLATFORM_AIX_V3
2086 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
2087 #error "O_NONBLOCK does not work on this platform"
2090 /* O_NONBLOCK source test */
2092 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
2095 dnl the O_NONBLOCK test was fine
2096 nonblock="O_NONBLOCK"
2097 AC_DEFINE(HAVE_O_NONBLOCK, 1,
2098 [use O_NONBLOCK for non-blocking sockets])
2101 if test "$nonblock" = "unknown"; then
2104 /* headers for FIONBIO test */
2106 #include <stropts.h>
2108 /* FIONBIO source test (old-style unix) */
2110 int flags = ioctl(socket, FIONBIO, &flags);
2113 dnl FIONBIO test was good
2115 AC_DEFINE(HAVE_FIONBIO, 1,
2116 [use FIONBIO for non-blocking sockets])
2120 if test "$nonblock" = "unknown"; then
2123 /* headers for ioctlsocket test (Windows) */
2125 #ifdef HAVE_WINDOWS_H
2126 #ifndef WIN32_LEAN_AND_MEAN
2127 #define WIN32_LEAN_AND_MEAN
2129 #include <windows.h>
2130 #ifdef HAVE_WINSOCK2_H
2131 #include <winsock2.h>
2133 #ifdef HAVE_WINSOCK_H
2134 #include <winsock.h>
2139 /* ioctlsocket source code (Windows) */
2141 unsigned long flags = 0;
2142 sd = socket(0, 0, 0);
2143 ioctlsocket(sd, FIONBIO, &flags);
2146 dnl ioctlsocket test was good
2147 nonblock="ioctlsocket"
2148 AC_DEFINE(HAVE_IOCTLSOCKET, 1,
2149 [use ioctlsocket() for non-blocking sockets])
2153 if test "$nonblock" = "unknown"; then
2156 /* headers for IoctlSocket test (Amiga?) */
2157 #include <sys/ioctl.h>
2159 /* IoctlSocket source code (Amiga?) */
2161 int flags = IoctlSocket(socket, FIONBIO, (long)1);
2164 dnl Ioctlsocket test was good
2165 nonblock="IoctlSocket"
2166 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1,
2167 [use Ioctlsocket() for non-blocking sockets])
2171 if test "$nonblock" = "unknown"; then
2174 /* headers for SO_NONBLOCK test (BeOS) */
2177 /* SO_NONBLOCK source code (BeOS) */
2180 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
2183 dnl the SO_NONBLOCK test was good
2184 nonblock="SO_NONBLOCK"
2185 AC_DEFINE(HAVE_SO_NONBLOCK, 1,
2186 [use SO_NONBLOCK for non-blocking sockets])
2190 AC_MSG_RESULT($nonblock)
2192 if test "$nonblock" = "unknown"; then
2193 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1,
2194 [disabled non-blocking sockets])
2195 AC_MSG_WARN([non-block sockets disabled])
2201 dnl -------------------------------------------------
2202 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
2203 dnl and a few other things.
2205 AC_DEFUN([TYPE_IN_ADDR_T], [
2206 AC_CHECK_TYPE([in_addr_t], ,[
2207 dnl in_addr_t not available
2208 AC_CACHE_CHECK([for in_addr_t equivalent],
2209 [curl_cv_in_addr_t_equiv], [
2210 curl_cv_in_addr_t_equiv="unknown"
2211 for t in "unsigned long" int size_t unsigned long; do
2212 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
2216 #ifdef HAVE_WINDOWS_H
2217 #ifndef WIN32_LEAN_AND_MEAN
2218 #define WIN32_LEAN_AND_MEAN
2220 #include <windows.h>
2221 #ifdef HAVE_WINSOCK2_H
2222 #include <winsock2.h>
2224 #ifdef HAVE_WINSOCK_H
2225 #include <winsock.h>
2229 #ifdef HAVE_SYS_TYPES_H
2230 #include <sys/types.h>
2232 #ifdef HAVE_SYS_SOCKET_H
2233 #include <sys/socket.h>
2235 #ifdef HAVE_NETINET_IN_H
2236 #include <netinet/in.h>
2238 #ifdef HAVE_ARPA_INET_H
2239 #include <arpa/inet.h>
2243 $t data = inet_addr ("1.2.3.4");
2246 curl_cv_in_addr_t_equiv="$t"
2251 case "$curl_cv_in_addr_t_equiv" in
2253 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
2256 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
2257 [Type to use in place of in_addr_t when system does not provide it.])
2262 #ifdef HAVE_WINDOWS_H
2263 #ifndef WIN32_LEAN_AND_MEAN
2264 #define WIN32_LEAN_AND_MEAN
2266 #include <windows.h>
2267 #ifdef HAVE_WINSOCK2_H
2268 #include <winsock2.h>
2270 #ifdef HAVE_WINSOCK_H
2271 #include <winsock.h>
2275 #ifdef HAVE_SYS_TYPES_H
2276 #include <sys/types.h>
2278 #ifdef HAVE_SYS_SOCKET_H
2279 #include <sys/socket.h>
2281 #ifdef HAVE_NETINET_IN_H
2282 #include <netinet/in.h>
2284 #ifdef HAVE_ARPA_INET_H
2285 #include <arpa/inet.h>
2292 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
2293 dnl -------------------------------------------------
2294 dnl Check if monotonic clock_gettime is available.
2296 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
2297 AC_REQUIRE([AC_HEADER_TIME])dnl
2298 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
2299 AC_MSG_CHECKING([for monotonic clock_gettime])
2302 #ifdef HAVE_SYS_TYPES_H
2303 #include <sys/types.h>
2305 #ifdef HAVE_SYS_TIME_H
2306 #include <sys/time.h>
2307 #ifdef TIME_WITH_SYS_TIME
2317 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
2320 AC_MSG_RESULT([yes])
2321 ac_cv_func_clock_gettime="yes"
2324 ac_cv_func_clock_gettime="no"
2326 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
2327 dnl until library linking and run-time checks for clock_gettime succeed.
2331 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
2332 dnl -------------------------------------------------
2333 dnl If monotonic clock_gettime is available then,
2334 dnl check and prepended to LIBS any needed libraries.
2336 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
2337 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
2339 if test "$ac_cv_func_clock_gettime" = "yes"; then
2341 AC_MSG_CHECKING([for clock_gettime in libraries])
2343 curl_cv_save_LIBS="$LIBS"
2344 curl_cv_gclk_LIBS="unknown"
2346 for x_xlibs in '' '-lrt' '-lposix4' ; do
2347 if test "$curl_cv_gclk_LIBS" = "unknown"; then
2348 if test -z "$x_xlibs"; then
2349 LIBS="$curl_cv_save_LIBS"
2351 LIBS="$x_xlibs $curl_cv_save_LIBS"
2355 #ifdef HAVE_SYS_TYPES_H
2356 #include <sys/types.h>
2358 #ifdef HAVE_SYS_TIME_H
2359 #include <sys/time.h>
2360 #ifdef TIME_WITH_SYS_TIME
2370 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
2373 curl_cv_gclk_LIBS="$x_xlibs"
2378 LIBS="$curl_cv_save_LIBS"
2380 case X-"$curl_cv_gclk_LIBS" in
2382 AC_MSG_RESULT([cannot find clock_gettime])
2383 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
2384 ac_cv_func_clock_gettime="no"
2387 AC_MSG_RESULT([no additional lib required])
2388 ac_cv_func_clock_gettime="yes"
2391 if test -z "$curl_cv_save_LIBS"; then
2392 LIBS="$curl_cv_gclk_LIBS"
2394 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
2396 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
2397 ac_cv_func_clock_gettime="yes"
2401 dnl only do runtime verification when not cross-compiling
2402 if test "x$cross_compiling" != "xyes" &&
2403 test "$ac_cv_func_clock_gettime" = "yes"; then
2404 AC_MSG_CHECKING([if monotonic clock_gettime works])
2407 #ifdef HAVE_SYS_TYPES_H
2408 #include <sys/types.h>
2410 #ifdef HAVE_SYS_TIME_H
2411 #include <sys/time.h>
2412 #ifdef TIME_WITH_SYS_TIME
2422 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
2428 AC_MSG_RESULT([yes])
2431 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
2432 ac_cv_func_clock_gettime="no"
2433 LIBS="$curl_cv_save_LIBS"
2437 case "$ac_cv_func_clock_gettime" in
2439 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
2440 [Define to 1 if you have the clock_gettime function and monotonic timer.])
2449 dnl CURL_CHECK_FUNC_SELECT
2450 dnl -------------------------------------------------
2451 dnl Test if the socket select() function is available,
2452 dnl and check its return type and the types of its
2453 dnl arguments. If the function succeeds HAVE_SELECT
2454 dnl will be defined, defining the types of the
2455 dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
2456 dnl and SELECT_TYPE_ARG5, defining the type of the
2457 dnl function return value in SELECT_TYPE_RETV, and
2458 dnl also defining the type qualifier of fifth argument
2459 dnl in SELECT_QUAL_ARG5.
2461 AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
2462 AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
2463 AC_CHECK_HEADERS(sys/select.h sys/socket.h)
2465 AC_MSG_CHECKING([for select])
2469 #ifdef HAVE_WINDOWS_H
2470 #ifndef WIN32_LEAN_AND_MEAN
2471 #define WIN32_LEAN_AND_MEAN
2473 #include <windows.h>
2474 #ifdef HAVE_WINSOCK2_H
2475 #include <winsock2.h>
2477 #ifdef HAVE_WINSOCK_H
2478 #include <winsock.h>
2482 #ifdef HAVE_SYS_TYPES_H
2483 #include <sys/types.h>
2485 #ifdef HAVE_SYS_TIME_H
2486 #include <sys/time.h>
2487 #ifdef TIME_WITH_SYS_TIME
2495 #ifndef HAVE_WINDOWS_H
2496 #ifdef HAVE_SYS_SELECT_H
2497 #include <sys/select.h>
2499 #ifdef HAVE_SYS_SOCKET_H
2500 #include <sys/socket.h>
2504 select(0, 0, 0, 0, 0);
2507 AC_MSG_RESULT([yes])
2508 curl_cv_select="yes"
2514 if test "$curl_cv_select" = "yes"; then
2515 AC_CACHE_CHECK([types of args and return type for select],
2516 [curl_cv_func_select_args], [
2517 curl_cv_func_select_args="unknown"
2518 for sel_retv in 'int' 'ssize_t'; do
2519 for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
2520 for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
2521 for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
2522 if test "$curl_cv_func_select_args" = "unknown"; then
2526 #ifdef HAVE_WINDOWS_H
2527 #ifndef WIN32_LEAN_AND_MEAN
2528 #define WIN32_LEAN_AND_MEAN
2530 #include <windows.h>
2531 #ifdef HAVE_WINSOCK2_H
2532 #include <winsock2.h>
2534 #ifdef HAVE_WINSOCK_H
2535 #include <winsock.h>
2538 #define SELECTCALLCONV PASCAL
2540 #ifdef HAVE_SYS_TYPES_H
2541 #include <sys/types.h>
2543 #ifdef HAVE_SYS_TIME_H
2544 #include <sys/time.h>
2545 #ifdef TIME_WITH_SYS_TIME
2553 #ifndef HAVE_WINDOWS_H
2554 #ifdef HAVE_SYS_SELECT_H
2555 #include <sys/select.h>
2557 #ifdef HAVE_SYS_SOCKET_H
2558 #include <sys/socket.h>
2560 #define SELECTCALLCONV
2562 #ifndef HAVE_STRUCT_TIMEVAL
2568 extern $sel_retv SELECTCALLCONV select($sel_arg1,
2578 $sel_retv res = select(nfds, rfds, wfds, efds, 0);
2581 curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
2589 if test "$curl_cv_func_select_args" = "unknown"; then
2590 AC_MSG_WARN([Cannot find proper types to use for select args])
2591 AC_MSG_WARN([HAVE_SELECT will not be defined])
2593 select_prev_IFS=$IFS; IFS=','
2594 set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
2595 IFS=$select_prev_IFS
2598 sel_qual_type_arg5=$[3]
2600 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
2601 [Define to the type of arg 1 for select.])
2602 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
2603 [Define to the type of args 2, 3 and 4 for select.])
2604 AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
2605 [Define to the function return type for select.])
2609 case $prev_sh_opts in
2617 case "$sel_qual_type_arg5" in
2620 sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
2624 sel_type_arg5=$sel_qual_type_arg5
2628 AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
2629 [Define to the type qualifier of arg 5 for select.])
2630 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
2631 [Define to the type of arg 5 for select.])
2633 case $prev_sh_opts in
2641 AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
2642 [Define to 1 if you have the select function.])
2643 ac_cv_func_select="yes"
2649 dnl ************************************************************
2650 dnl check for working getaddrinfo() that works with AI_NUMERICHOST
2652 AC_DEFUN([CURL_CHECK_WORKING_GETADDRINFO],[
2653 AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
2656 #include <sys/types.h>
2657 #include <sys/socket.h>
2661 struct addrinfo hints, *ai;
2664 memset(&hints, 0, sizeof(hints));
2665 hints.ai_flags = AI_NUMERICHOST;
2666 hints.ai_family = AF_UNSPEC;
2667 hints.ai_socktype = SOCK_STREAM;
2668 error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
2675 ac_cv_working_getaddrinfo="yes"
2677 ac_cv_working_getaddrinfo="no"
2679 ac_cv_working_getaddrinfo="yes"
2681 if test "$ac_cv_working_getaddrinfo" = "yes"; then
2682 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
2683 AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
2686 AC_SUBST(IPV6_ENABLED)
2691 AC_DEFUN([CURL_CHECK_LOCALTIME_R],
2693 dnl check for localtime_r
2694 AC_CHECK_FUNCS(localtime_r,[
2695 AC_MSG_CHECKING(whether localtime_r is declared)
2696 AC_EGREP_CPP(localtime_r,[
2698 #include <time.h>],[
2699 AC_MSG_RESULT(yes)],[
2701 AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
2702 AC_EGREP_CPP(localtime_r,[
2705 #include <time.h>],[
2706 AC_MSG_RESULT(yes)],
2707 AC_MSG_RESULT(no))])])
2711 dnl This function checks for strerror_r(). If it isn't found at first, it
2712 dnl retries with _THREAD_SAFE defined, as that is what AIX seems to require
2713 dnl in order to find this function.
2715 dnl If the function is found, it will then proceed to check how the function
2716 dnl actually works: glibc-style or POSIX-style.
2719 dnl char *strerror_r(int errnum, char *buf, size_t n);
2721 dnl What this one does is to return the error string (no surprises there),
2722 dnl but it doesn't usually copy anything into buf! The 'buf' and 'n'
2723 dnl parameters are only meant as an optional working area, in case strerror_r
2724 dnl needs it. A quick test on a few systems shows that it's generally not
2728 dnl int strerror_r(int errnum, char *buf, size_t n);
2730 AC_DEFUN([CURL_CHECK_STRERROR_R],
2732 AC_CHECK_FUNCS(strerror_r)
2734 if test "x$ac_cv_func_strerror_r" = "xyes"; then
2736 AC_MSG_CHECKING(whether strerror_r is declared)
2737 AC_EGREP_CPP(strerror_r,[
2739 #include <string.h>],[
2740 AC_MSG_RESULT(yes)],[
2742 AC_MSG_CHECKING(whether strerror_r with -D_REENTRANT is declared)
2743 AC_EGREP_CPP(strerror_r,[
2746 #include <string.h>],[
2747 AC_MSG_RESULT(yes)],
2749 AC_DEFINE(HAVE_NO_STRERROR_R_DECL, 1, [we have no strerror_r() proto])
2750 ) dnl with _THREAD_SAFE
2751 ]) dnl plain cpp for it
2753 dnl determine if this strerror_r() is glibc or POSIX
2754 AC_MSG_CHECKING([for a glibc strerror_r API])
2760 char buffer[1024]; /* big enough to play with */
2762 strerror_r(EACCES, buffer, sizeof(buffer));
2763 /* this should've returned a string */
2764 if(!string || !string[0])
2769 GLIBC_STRERROR_R="1"
2770 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
2771 AC_MSG_RESULT([yes]),
2772 AC_MSG_RESULT([no]),
2774 dnl Use an inferior method of strerror_r detection while cross-compiling
2776 #include <features.h>
2781 dnl looks like glibc, so assume a glibc-style strerror_r()
2782 GLIBC_STRERROR_R="1"
2783 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
2784 AC_MSG_RESULT([yes]),
2785 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
2786 ) dnl while cross-compiling
2789 if test -z "$GLIBC_STRERROR_R"; then
2791 AC_MSG_CHECKING([for a POSIX strerror_r API])
2797 char buffer[1024]; /* big enough to play with */
2799 strerror_r(EACCES, buffer, sizeof(buffer));
2800 /* This should've returned zero, and written an error string in the
2802 if(!buffer[0] || error)
2807 AC_DEFINE(HAVE_POSIX_STRERROR_R, 1, [we have a POSIX-style strerror_r()])
2808 AC_MSG_RESULT([yes]),
2809 AC_MSG_RESULT([no]) ,
2810 dnl cross-compiling!
2811 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
2814 fi dnl if not using glibc API
2816 fi dnl we have a strerror_r
2820 AC_DEFUN([CURL_CHECK_INET_NTOA_R],
2822 dnl determine if function definition for inet_ntoa_r exists.
2823 AC_CHECK_FUNCS(inet_ntoa_r,[
2824 AC_MSG_CHECKING(whether inet_ntoa_r is declared)
2825 AC_EGREP_CPP(inet_ntoa_r,[
2827 #include <arpa/inet.h>],[
2828 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
2829 AC_MSG_RESULT(yes)],[
2831 AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
2832 AC_EGREP_CPP(inet_ntoa_r,[
2835 #include <arpa/inet.h>],[
2836 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
2837 AC_MSG_RESULT(yes)],
2838 AC_MSG_RESULT(no))])])
2842 dnl CURL_CHECK_GETHOSTBYADDR_R
2843 dnl -------------------------------------------------
2844 dnl check number of arguments for gethostbyaddr_r, it
2845 dnl might take either 5, 7, or 8 arguments.
2847 AC_DEFUN([CURL_CHECK_GETHOSTBYADDR_R], [
2849 AC_MSG_CHECKING([for gethostbyaddr_r])
2851 AC_LANG_FUNC_LINK_TRY([gethostbyaddr_r])
2853 AC_MSG_RESULT([yes])
2854 tmp_cv_gethostbyaddr_r="yes"
2857 tmp_cv_gethostbyaddr_r="no"
2860 if test "$tmp_cv_gethostbyaddr_r" != "yes"; then
2861 AC_MSG_CHECKING([deeper for gethostbyaddr_r])
2868 AC_MSG_RESULT([yes])
2869 tmp_cv_gethostbyaddr_r="yes"
2871 AC_MSG_RESULT([but still no])
2872 tmp_cv_gethostbyaddr_r="no"
2876 if test "$tmp_cv_gethostbyaddr_r" = "yes"; then
2878 ac_cv_gethostbyaddr_r_args="unknown"
2880 AC_MSG_CHECKING([if gethostbyaddr_r takes 5 arguments])
2884 #include <sys/types.h>
2891 struct hostent_data hdata;
2893 rc = gethostbyaddr_r(address, length, type, &h, &hdata);
2896 AC_MSG_RESULT([yes])
2897 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
2898 ac_cv_gethostbyaddr_r_args="5"
2903 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2904 AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 5 arguments])
2909 #include <sys/types.h>
2916 struct hostent_data hdata;
2918 rc = gethostbyaddr_r(address, length, type, &h, &hdata);
2921 AC_MSG_RESULT([yes])
2922 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
2923 ac_cv_gethostbyaddr_r_args="5"
2929 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2930 AC_MSG_CHECKING([if gethostbyaddr_r takes 7 arguments])
2934 #include <sys/types.h>
2943 struct hostent * hp;
2944 hp = gethostbyaddr_r(address, length, type, &h,
2945 buffer, 8192, &h_errnop);
2948 AC_MSG_RESULT([yes])
2949 AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
2950 ac_cv_gethostbyaddr_r_args="7"
2956 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2957 AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 7 arguments])
2962 #include <sys/types.h>
2971 struct hostent * hp;
2972 hp = gethostbyaddr_r(address, length, type, &h,
2973 buffer, 8192, &h_errnop);
2976 AC_MSG_RESULT([yes])
2977 AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args])
2978 ac_cv_gethostbyaddr_r_args="7"
2984 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
2985 AC_MSG_CHECKING([if gethostbyaddr_r takes 8 arguments])
2989 #include <sys/types.h>
2998 struct hostent * hp;
3000 rc = gethostbyaddr_r(address, length, type, &h,
3001 buffer, 8192, &hp, &h_errnop);
3004 AC_MSG_RESULT([yes])
3005 AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
3006 ac_cv_gethostbyaddr_r_args="8"
3012 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
3013 AC_MSG_CHECKING([if gethostbyaddr_r with -D_REENTRANT takes 8 arguments])
3018 #include <sys/types.h>
3027 struct hostent * hp;
3029 rc = gethostbyaddr_r(address, length, type, &h,
3030 buffer, 8192, &hp, &h_errnop);
3033 AC_MSG_RESULT([yes])
3034 AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
3035 ac_cv_gethostbyaddr_r_args="8"
3041 if test "$ac_cv_gethostbyaddr_r_args" = "unknown"; then
3042 AC_MSG_WARN([Cannot find out how to use gethostbyaddr_r])
3043 AC_MSG_WARN([HAVE_GETHOSTBYADDR_R will not be defined])
3044 ac_cv_func_gethostbyaddr_r="no"
3046 AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR_R, 1,
3047 [Define to 1 if you have the gethostbyaddr_r function.])
3048 ac_cv_func_gethostbyaddr_r="yes"
3052 ac_cv_func_gethostbyaddr_r="no"
3057 dnl CURL_CHECK_GETHOSTBYNAME_R
3058 dnl -------------------------------------------------
3059 dnl check number of arguments for gethostbyname_r, it
3060 dnl might take either 3, 5, or 6 arguments.
3062 AC_DEFUN([CURL_CHECK_GETHOSTBYNAME_R], [
3064 AC_MSG_CHECKING([for gethostbyname_r])
3066 AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
3068 AC_MSG_RESULT([yes])
3069 tmp_cv_gethostbyname_r="yes"
3072 tmp_cv_gethostbyname_r="no"
3075 if test "$tmp_cv_gethostbyname_r" != "yes"; then
3076 AC_MSG_CHECKING([deeper for gethostbyname_r])
3083 AC_MSG_RESULT([yes])
3084 tmp_cv_gethostbyname_r="yes"
3086 AC_MSG_RESULT([but still no])
3087 tmp_cv_gethostbyname_r="no"
3091 if test "$tmp_cv_gethostbyname_r" = "yes"; then
3093 ac_cv_gethostbyname_r_args="unknown"
3095 AC_MSG_CHECKING([if gethostbyname_r takes 3 arguments])
3100 #include <sys/types.h>
3103 #define NULL (void *)0
3105 gethostbyname_r(const char *, struct hostent *,
3106 struct hostent_data *);
3108 struct hostent_data data;
3109 gethostbyname_r(NULL, NULL, NULL);
3112 AC_MSG_RESULT([yes])
3113 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
3114 ac_cv_gethostbyname_r_args="3"
3119 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
3120 AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 3 arguments])
3126 #include <sys/types.h>
3129 #define NULL (void *)0
3131 gethostbyname_r(const char *, struct hostent *,
3132 struct hostent_data *);
3134 struct hostent_data data;
3135 gethostbyname_r(NULL, NULL, NULL);
3138 AC_MSG_RESULT([yes])
3139 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
3140 ac_cv_gethostbyname_r_args="3"
3146 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
3147 AC_MSG_CHECKING([if gethostbyname_r takes 5 arguments])
3151 #include <sys/types.h>
3154 #define NULL (void *)0
3156 gethostbyname_r(const char *, struct hostent *,
3157 char *, int, int *);
3159 gethostbyname_r(NULL, NULL, NULL, 0, NULL);
3162 AC_MSG_RESULT([yes])
3163 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
3164 ac_cv_gethostbyname_r_args="5"
3170 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
3171 AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 5 arguments])
3176 #include <sys/types.h>
3179 #define NULL (void *)0
3181 gethostbyname_r(const char *, struct hostent *,
3182 char *, int, int *);
3184 gethostbyname_r(NULL, NULL, NULL, 0, NULL);
3187 AC_MSG_RESULT([yes])
3188 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
3189 ac_cv_gethostbyname_r_args="5"
3195 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
3196 AC_MSG_CHECKING([if gethostbyname_r takes 6 arguments])
3200 #include <sys/types.h>
3203 #define NULL (void *)0
3205 gethostbyname_r(const char *, struct hostent *,
3206 char *, size_t, struct hostent **, int *);
3208 gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
3211 AC_MSG_RESULT([yes])
3212 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
3213 ac_cv_gethostbyname_r_args="6"
3219 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
3220 AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 6 arguments])
3225 #include <sys/types.h>
3228 #define NULL (void *)0
3230 gethostbyname_r(const char *, struct hostent *,
3231 char *, size_t, struct hostent **, int *);
3233 gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
3236 AC_MSG_RESULT([yes])
3237 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
3238 ac_cv_gethostbyname_r_args="6"
3244 if test "$ac_cv_gethostbyname_r_args" = "unknown"; then
3245 AC_MSG_WARN([Cannot find out how to use gethostbyname_r])
3246 AC_MSG_WARN([HAVE_GETHOSTBYNAME_R will not be defined])
3247 ac_cv_func_gethostbyname_r="no"
3249 AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME_R, 1,
3250 [Define to 1 if you have the gethostbyname_r function.])
3251 ac_cv_func_gethostbyname_r="yes"
3255 ac_cv_func_gethostbyname_r="no"
3260 dnl **********************************************************************
3261 dnl CURL_DETECT_ICC ([ACTION-IF-YES])
3263 dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
3264 dnl sets the $ICC variable to "yes" or "no"
3265 dnl **********************************************************************
3266 AC_DEFUN([CURL_DETECT_ICC],
3269 AC_MSG_CHECKING([for icc in use])
3270 if test "$GCC" = "yes"; then
3271 dnl check if this is icc acting as gcc in disguise
3272 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
3273 dnl action if the text is found, this it has not been replaced by the
3276 dnl the text was not found, it was replaced by the cpp
3278 AC_MSG_RESULT([yes])
3282 if test "$ICC" = "no"; then
3288 dnl We create a function for detecting which compiler we use and then set as
3289 dnl pendantic compiler options as possible for that particular compiler. The
3290 dnl options are only used for debug-builds.
3292 AC_DEFUN([CURL_CC_DEBUG_OPTS],
3294 if test "z$ICC" = "z"; then
3298 if test "$GCC" = "yes"; then
3300 dnl figure out gcc version!
3301 AC_MSG_CHECKING([gcc version])
3302 gccver=`$CC -dumpversion`
3303 num1=`echo $gccver | cut -d . -f1`
3304 num2=`echo $gccver | cut -d . -f2`
3305 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
3306 AC_MSG_RESULT($gccver)
3308 if test "$ICC" = "yes"; then
3309 dnl this is icc, not gcc.
3311 dnl ICC warnings we ignore:
3312 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
3313 dnl "invalid format string conversion"
3314 dnl * 279 warns on static conditions in while expressions
3315 dnl * 981 warns on "operands are evaluated in unspecified order"
3316 dnl * 1418 "external definition with no prior declaration"
3317 dnl * 1419 warns on "external declaration in primary source file"
3318 dnl which we know and do on purpose.
3320 WARN="-wd279,269,981,1418,1419"
3322 if test "$gccnum" -gt "600"; then
3323 dnl icc 6.0 and older doesn't have the -Wall flag
3327 dnl this is a set of options we believe *ALL* gcc versions support:
3328 WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
3330 dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
3332 if test "$gccnum" -ge "207"; then
3333 dnl gcc 2.7 or later
3334 WARN="$WARN -Wmissing-declarations"
3337 if test "$gccnum" -gt "295"; then
3338 dnl only if the compiler is newer than 2.95 since we got lots of
3339 dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
3340 dnl gcc 2.95.4 on FreeBSD 4.9!
3341 WARN="$WARN -Wundef -Wno-long-long -Wsign-compare -Wshadow -Wno-multichar"
3344 if test "$gccnum" -ge "296"; then
3345 dnl gcc 2.96 or later
3346 WARN="$WARN -Wfloat-equal"
3349 if test "$gccnum" -gt "296"; then
3350 dnl this option does not exist in 2.96
3351 WARN="$WARN -Wno-format-nonliteral"
3354 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
3355 dnl on i686-Linux as it gives us heaps with false positives.
3356 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
3357 dnl over making it unusable for generic purposes. Let's not use it.
3359 if test "$gccnum" -ge "303"; then
3360 dnl gcc 3.3 and later
3361 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
3364 if test "$gccnum" -ge "304"; then
3365 # try these on gcc 3.4
3366 WARN="$WARN -Wdeclaration-after-statement"
3369 for flag in $CPPFLAGS; do
3372 dnl Include path, provide a -isystem option for the same dir
3373 dnl to prevent warnings in those dirs. The -isystem was not very
3374 dnl reliable on earlier gcc versions.
3375 add=`echo $flag | sed 's/^-I/-isystem /g'`
3383 CFLAGS="$CFLAGS $WARN"
3385 AC_MSG_NOTICE([Added this set of compiler options: $WARN])
3389 AC_MSG_NOTICE([Added no extra compiler options])
3393 dnl strip off optimizer flags
3395 for flag in $CFLAGS; do
3398 dnl echo "cut off $flag"
3401 NEWFLAGS="$NEWFLAGS $flag"
3411 # This is only a temporary fix. This macro is here to replace the broken one
3412 # delivered by the automake project (including the 1.9.6 release). As soon as
3413 # they ship a working version we SHOULD remove this work-around.
3415 AC_DEFUN([AM_MISSING_HAS_RUN],
3416 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
3417 test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\""
3418 # Use eval to expand $SHELL
3419 if eval "$MISSING --run true"; then
3420 am_missing_run="$MISSING --run "
3423 AC_MSG_WARN([`missing' script is too old or missing])
3428 dnl CURL_VERIFY_RUNTIMELIBS
3429 dnl -------------------------------------------------
3430 dnl Verify that the shared libs found so far can be used when running
3431 dnl programs, since otherwise the situation will create odd configure errors
3432 dnl that are misleading people.
3434 dnl Make sure this test is run BEFORE the first test in the script that
3435 dnl runs anything, which at the time of this writing is the AC_CHECK_SIZEOF
3436 dnl macro. It must also run AFTER all lib-checking macros are complete.
3438 AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [
3440 dnl this test is of course not sensible if we are cross-compiling!
3441 if test "x$cross_compiling" != xyes; then
3443 dnl just run a program to verify that the libs checked for previous to this
3444 dnl point also is available run-time!
3445 AC_MSG_CHECKING([run-time libs availability])
3452 AC_MSG_RESULT([fine]),
3453 AC_MSG_RESULT([failed])
3454 AC_MSG_ERROR([one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS])
3457 dnl if this test fails, configure has already stopped
3462 dnl CURL_CHECK_VARIADIC_MACROS
3463 dnl -------------------------------------------------
3464 dnl Check compiler support of variadic macros
3466 AC_DEFUN([CURL_CHECK_VARIADIC_MACROS], [
3467 AC_CACHE_CHECK([for compiler support of C99 variadic macro style],
3468 [curl_cv_variadic_macros_c99], [
3471 #define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
3472 #define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
3473 int fun3(int arg1, int arg2, int arg3);
3474 int fun2(int arg1, int arg2);
3475 int fun3(int arg1, int arg2, int arg3)
3476 { return arg1 + arg2 + arg3; }
3477 int fun2(int arg1, int arg2)
3478 { return arg1 + arg2; }
3480 int res3 = c99_vmacro3(1, 2, 3);
3481 int res2 = c99_vmacro2(1, 2);
3484 curl_cv_variadic_macros_c99="yes"
3486 curl_cv_variadic_macros_c99="no"
3489 case "$curl_cv_variadic_macros_c99" in
3491 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_C99, 1,
3492 [Define to 1 if compiler supports C99 variadic macro style.])
3495 AC_CACHE_CHECK([for compiler support of old gcc variadic macro style],
3496 [curl_cv_variadic_macros_gcc], [
3499 #define gcc_vmacro3(first, args...) fun3(first, args)
3500 #define gcc_vmacro2(first, args...) fun2(first, args)
3501 int fun3(int arg1, int arg2, int arg3);
3502 int fun2(int arg1, int arg2);
3503 int fun3(int arg1, int arg2, int arg3)
3504 { return arg1 + arg2 + arg3; }
3505 int fun2(int arg1, int arg2)
3506 { return arg1 + arg2; }
3508 int res3 = gcc_vmacro3(1, 2, 3);
3509 int res2 = gcc_vmacro2(1, 2);
3512 curl_cv_variadic_macros_gcc="yes"
3514 curl_cv_variadic_macros_gcc="no"
3517 case "$curl_cv_variadic_macros_gcc" in
3519 AC_DEFINE_UNQUOTED(HAVE_VARIADIC_MACROS_GCC, 1,
3520 [Define to 1 if compiler supports old gcc variadic macro style.])
3526 dnl CURL_CHECK_CA_BUNDLE
3527 dnl -------------------------------------------------
3528 dnl Check if a default ca-bundle should be used
3530 dnl regarding the paths this will scan:
3531 dnl /etc/ssl/certs/ca-certificates.crt Debian systems
3532 dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
3533 dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
3534 dnl /etc/ssl/certs/ (ca path) SUSE
3536 AC_DEFUN([CURL_CHECK_CA_BUNDLE], [
3538 AC_MSG_CHECKING([default CA cert bundle/path])
3540 AC_ARG_WITH(ca-bundle,
3541 AC_HELP_STRING([--with-ca-bundle=FILE], [File name to use as CA bundle])
3542 AC_HELP_STRING([--without-ca-bundle], [Don't use a default CA bundle]),
3545 if test "x$want_ca" = "xyes"; then
3546 AC_MSG_ERROR([--with-ca-bundle=FILE requires a path to the CA bundle])
3549 [ want_ca="unset" ])
3550 AC_ARG_WITH(ca-path,
3551 AC_HELP_STRING([--with-ca-path=DIRECTORY], [Directory to use as CA path])
3552 AC_HELP_STRING([--without-ca-path], [Don't use a default CA path]),
3554 want_capath="$withval"
3555 if test "x$want_capath" = "xyes"; then
3556 AC_MSG_ERROR([--with-ca-path=DIRECTORY requires a path to the CA path directory])
3559 [ want_capath="unset"])
3561 if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \
3562 "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
3564 AC_MSG_ERROR([Can't specify both --with-ca-bundle and --with-ca-path.])
3565 elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then
3566 dnl --with-ca-bundle given
3569 elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then
3570 dnl --with-ca-path given
3571 if test "x$OPENSSL_ENABLED" != "x1"; then
3572 AC_MSG_ERROR([--with-ca-path only works with openSSL])
3574 capath="$want_capath"
3577 dnl neither of --with-ca-* given
3578 dnl first try autodetecting a CA bundle , then a CA path
3579 dnl both autodetections can be skipped by --without-ca-*
3582 if test "x$want_ca" = "xunset"; then
3583 dnl the path we previously would have installed the curl ca bundle
3584 dnl to, and thus we now check for an already existing cert in that place
3585 dnl in case we find no other
3586 if test "x$prefix" != xNONE; then
3587 cac="${prefix}/share/curl/curl-ca-bundle.crt"
3589 cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt"
3592 for a in /etc/ssl/certs/ca-certificates.crt \
3593 /etc/pki/tls/certs/ca-bundle.crt \
3594 /usr/share/ssl/certs/ca-bundle.crt \
3596 if test -f "$a"; then
3602 if test "x$want_capath" = "xunset" -a "x$ca" = "xno" -a \
3603 "x$OPENSSL_ENABLED" = "x1"; then
3604 for a in /etc/ssl/certs/; do
3605 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
3615 if test "x$ca" != "xno"; then
3616 CURL_CA_BUNDLE='"'$ca'"'
3617 AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
3618 AC_SUBST(CURL_CA_BUNDLE)
3619 AC_MSG_RESULT([$ca])
3620 elif test "x$capath" != "xno"; then
3621 CURL_CA_PATH="\"$capath\""
3622 AC_DEFINE_UNQUOTED(CURL_CA_PATH, "$capath", [Location of default ca path])
3623 AC_MSG_RESULT([$capath (capath)])
3630 dnl CURL_DEFINE_UNQUOTED (VARIABLE, [VALUE])
3631 dnl -------------------------------------------------
3632 dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
3633 dnl symbol that can be further used in custom template configuration
3634 dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
3635 dnl argument for the description. Symbol definitions done with this
3636 dnl macro are intended to be exclusively used in handcrafted *.h.in
3637 dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
3638 dnl prevents autoheader generation and insertion of symbol template
3639 dnl stub and definition into the first configuration header file. Do
3640 dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
3641 dnl one serves different functional needs.
3643 AC_DEFUN([CURL_DEFINE_UNQUOTED], [
3644 cat >>confdefs.h <<_EOF
3645 [@%:@define] $1 ifelse($#, 2, [$2], 1)
3650 dnl CURL_INCLUDES_INTTYPES
3651 dnl -------------------------------------------------
3652 dnl Set up variable with list of headers that must be
3653 dnl included when inttypes.h is to be included.
3655 AC_DEFUN([CURL_INCLUDES_INTTYPES], [
3656 curl_includes_inttypes="\
3657 /* includes start */
3658 #ifdef HAVE_SYS_TYPES_H
3659 # include <sys/types.h>
3661 #ifdef HAVE_STDINT_H
3662 # include <stdint.h>
3664 #ifdef HAVE_INTTYPES_H
3665 # include <inttypes.h>
3669 sys/types.h stdint.h inttypes.h,
3670 [], [], [$curl_includes_inttypes])
3674 dnl CURL_CONFIGURE_LONG
3675 dnl -------------------------------------------------
3676 dnl Find out the size of long as reported by sizeof() and define
3677 dnl CURL_SIZEOF_LONG as appropriate to be used in template file
3678 dnl include/curl/curlbuild.h.in to properly configure the library.
3679 dnl The size of long is a build time characteristic and as such
3680 dnl must be recorded in curlbuild.h
3682 AC_DEFUN([CURL_CONFIGURE_LONG], [
3683 if test -z "$ac_cv_sizeof_long" ||
3684 test "$ac_cv_sizeof_long" -eq "0"; then
3685 AC_MSG_ERROR([cannot find out size of long.])
3687 CURL_DEFINE_UNQUOTED([CURL_SIZEOF_LONG], [$ac_cv_sizeof_long])
3691 dnl DO_CURL_OFF_T_CHECK (TYPE, SIZE)
3692 dnl -------------------------------------------------
3693 dnl Internal macro for CURL_CONFIGURE_CURL_OFF_T
3695 AC_DEFUN([DO_CURL_OFF_T_CHECK], [
3696 AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
3697 if test "$x_typeof" = "unknown" && test ! -z "$1"; then
3702 case AS_TR_SH([$1]) in
3704 tmp_includes="$curl_includes_inttypes"
3705 tmp_source="char f@<:@@:>@ = PRId64;"
3710 tmp_includes="$curl_includes_inttypes"
3711 tmp_source="char f@<:@@:>@ = PRId32;"
3716 tmp_includes="$curl_includes_inttypes"
3717 tmp_source="char f@<:@@:>@ = PRId16;"
3725 typedef $1 curl_off_t;
3726 typedef char dummy_arr[sizeof(curl_off_t) == $2 ? 1 : -1];
3732 if test -z "$tmp_fmt"; then
3736 CURL_CHECK_DEF([$tmp_fmt], [$curl_includes_inttypes], [silent])
3737 CURL_CHECK_DEF_INTXX_C([$tmp_intxx], [$curl_includes_inttypes])
3738 AS_VAR_PUSHDEF([tmp_HaveFmtDef], [curl_cv_have_def_$tmp_fmt])dnl
3739 AS_VAR_PUSHDEF([tmp_FmtDef], [curl_cv_def_$tmp_fmt])dnl
3740 AS_VAR_PUSHDEF([tmp_HaveSufDef], [curl_cv_have_def_$tmp_intxx])dnl
3741 AS_VAR_PUSHDEF([tmp_SufDef], [curl_cv_def_$tmp_intxx])dnl
3742 if test AS_VAR_GET(tmp_HaveFmtDef) = "yes" &&
3743 test AS_VAR_GET(tmp_HaveSufDef) = "yes"; then
3744 x_format=AS_VAR_GET(tmp_FmtDef)
3745 x_suffix=AS_VAR_GET(tmp_SufDef)
3749 AS_VAR_POPDEF([tmp_SufDef])dnl
3750 AS_VAR_POPDEF([tmp_HaveSufDef])dnl
3751 AS_VAR_POPDEF([tmp_FmtDef])dnl
3752 AS_VAR_POPDEF([tmp_HaveFmtDef])dnl
3759 dnl CURL_CONFIGURE_CURL_OFF_T
3760 dnl -------------------------------------------------
3761 dnl Find out suitable curl_off_t data type definition and associated
3762 dnl items, and make the appropriate definitions used in template file
3763 dnl include/curl/curlbuild.h.in to properly configure the library.
3765 AC_DEFUN([CURL_CONFIGURE_CURL_OFF_T], [
3766 AC_REQUIRE([CURL_INCLUDES_INTTYPES])dnl
3768 AC_BEFORE([$0],[AC_SYS_LARGEFILE])dnl
3769 AC_BEFORE([$0],[CURL_CONFIGURE_REENTRANT])dnl
3770 AC_BEFORE([$0],[CURL_CHECK_AIX_ALL_SOURCE])dnl
3772 if test -z "$SED"; then
3773 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
3776 AC_CHECK_SIZEOF(long)
3777 AC_CHECK_SIZEOF(void*)
3779 if test -z "$ac_cv_sizeof_long" ||
3780 test "$ac_cv_sizeof_long" -eq "0"; then
3781 AC_MSG_ERROR([cannot find out size of long.])
3783 if test -z "$ac_cv_sizeof_voidp" ||
3784 test "$ac_cv_sizeof_voidp" -eq "0"; then
3785 AC_MSG_ERROR([cannot find out size of void*.])
3792 if test "$ac_cv_sizeof_long" -eq "8" &&
3793 test "$ac_cv_sizeof_voidp" -ge "8"; then
3795 elif test "$ac_cv_sizeof_long" -eq "4" &&
3796 test "$ac_cv_sizeof_voidp" -ge "4"; then
3798 elif test "$ac_cv_sizeof_long" -eq "2" &&
3799 test "$ac_cv_sizeof_voidp" -ge "2"; then
3803 dnl DO_CURL_OFF_T_CHECK results are stored in next 3 vars
3812 if test "$x_typeof" = "unknown"; then
3813 AC_MSG_CHECKING([for 64-bit curl_off_t data type])
3821 DO_CURL_OFF_T_CHECK([$t8], [8])
3823 AC_MSG_RESULT([$x_typeof])
3825 if test "$x_typeof" = "unknown"; then
3826 AC_MSG_CHECKING([for 32-bit curl_off_t data type])
3832 DO_CURL_OFF_T_CHECK([$t4], [4])
3834 AC_MSG_RESULT([$x_typeof])
3836 if test "$x_typeof" = "unknown"; then
3837 AC_MSG_CHECKING([for 16-bit curl_off_t data type])
3843 DO_CURL_OFF_T_CHECK([$t2], [2])
3845 AC_MSG_RESULT([$x_typeof])
3847 if test "$x_typeof" = "unknown"; then
3848 AC_MSG_ERROR([cannot find data type for curl_off_t.])
3851 AC_MSG_CHECKING([size of curl_off_t])
3852 AC_MSG_RESULT([$x_sizeof])
3854 AC_MSG_CHECKING([formatting string directive for curl_off_t])
3855 if test "$x_format" != "unknown"; then
3856 x_pull_headers="yes"
3857 x_format=`echo "$x_format" | "$SED" 's/[["]]//g'`
3858 u_format=`echo "$x_format" | "$SED" 's/i$/u/'`
3859 u_format=`echo "$u_format" | "$SED" 's/d$/u/'`
3860 u_format=`echo "$u_format" | "$SED" 's/D$/U/'`
3861 u_suffix=`echo "$x_suffix" | "$SED" 's/^/U/'`
3864 case AS_TR_SH([$x_typeof]) in
3865 long_long | __longlong | __longlong_t)
3902 AC_MSG_ERROR([cannot find print format string for curl_off_t.])
3906 AC_MSG_RESULT(["$x_format"])
3908 AC_MSG_CHECKING([formatting string directive for unsigned curl_off_t])
3909 AC_MSG_RESULT(["$u_format"])
3910 AC_MSG_CHECKING([constant suffix string for curl_off_t])
3911 AC_MSG_RESULT([$x_suffix])
3912 AC_MSG_CHECKING([constant suffix string for unsigned curl_off_t])
3913 AC_MSG_RESULT([$u_suffix])
3915 if test "$x_pull_headers" = "yes"; then
3916 if test "x$ac_cv_header_sys_types_h" = "xyes"; then
3917 CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
3919 if test "x$ac_cv_header_stdint_h" = "xyes"; then
3920 CURL_DEFINE_UNQUOTED([CURL_PULL_STDINT_H])
3922 if test "x$ac_cv_header_inttypes_h" = "xyes"; then
3923 CURL_DEFINE_UNQUOTED([CURL_PULL_INTTYPES_H])
3927 CURL_DEFINE_UNQUOTED([CURL_OFF_T], [$x_typeof])
3928 CURL_DEFINE_UNQUOTED([CURL_FMT_OFF_T], ["$x_format"])
3929 CURL_DEFINE_UNQUOTED([CURL_FMT_OFF_TU], ["$u_format"])
3930 CURL_DEFINE_UNQUOTED([CURL_FORMAT_OFF_T], ["%$x_format"])
3931 CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_OFF_T], [$x_sizeof])
3932 CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_T], [$x_suffix])
3933 CURL_DEFINE_UNQUOTED([CURL_SUFFIX_CURL_OFF_TU], [$u_suffix])