1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1998 - 2006, 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_HEADER_WINDOWS
26 dnl -------------------------------------------------
27 dnl Check for compilable and valid windows.h header
29 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
30 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
34 #ifndef WIN32_LEAN_AND_MEAN
35 #define WIN32_LEAN_AND_MEAN
40 HAVE_WINDOWS_H shall not be defined.
46 ac_cv_header_windows_h="yes"
48 ac_cv_header_windows_h="no"
51 case "$ac_cv_header_windows_h" in
53 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
54 [Define to 1 if you have the windows.h header file.])
55 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
56 [Define to avoid automatic inclusion of winsock.h])
62 dnl CURL_CHECK_HEADER_WINSOCK
63 dnl -------------------------------------------------
64 dnl Check for compilable and valid winsock.h header
66 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
67 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
68 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
72 #ifndef WIN32_LEAN_AND_MEAN
73 #define WIN32_LEAN_AND_MEAN
79 HAVE_WINSOCK_H shall not be defined.
81 int dummy=WSACleanup();
85 ac_cv_header_winsock_h="yes"
87 ac_cv_header_winsock_h="no"
90 case "$ac_cv_header_winsock_h" in
92 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
93 [Define to 1 if you have the winsock.h header file.])
99 dnl CURL_CHECK_HEADER_WINSOCK2
100 dnl -------------------------------------------------
101 dnl Check for compilable and valid winsock2.h header
103 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
104 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
105 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
109 #ifndef WIN32_LEAN_AND_MEAN
110 #define WIN32_LEAN_AND_MEAN
113 #include <winsock2.h>
116 HAVE_WINSOCK2_H shall not be defined.
118 int dummy=2*IPPROTO_ESP;
122 ac_cv_header_winsock2_h="yes"
124 ac_cv_header_winsock2_h="no"
127 case "$ac_cv_header_winsock2_h" in
129 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
130 [Define to 1 if you have the winsock2.h header file.])
136 dnl CURL_CHECK_HEADER_WS2TCPIP
137 dnl -------------------------------------------------
138 dnl Check for compilable and valid ws2tcpip.h header
140 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
141 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
142 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
146 #ifndef WIN32_LEAN_AND_MEAN
147 #define WIN32_LEAN_AND_MEAN
150 #include <winsock2.h>
151 #include <ws2tcpip.h>
154 HAVE_WS2TCPIP_H shall not be defined.
156 int dummy=2*IP_PKTINFO;
160 ac_cv_header_ws2tcpip_h="yes"
162 ac_cv_header_ws2tcpip_h="no"
165 case "$ac_cv_header_ws2tcpip_h" in
167 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
168 [Define to 1 if you have the ws2tcpip.h header file.])
174 dnl CURL_CHECK_HEADER_MALLOC
175 dnl -------------------------------------------------
176 dnl Check for compilable and valid malloc.h header,
177 dnl and check if it is needed even with stdlib.h
179 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
180 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
185 void *p = malloc(10);
186 void *q = calloc(10,10);
191 ac_cv_header_malloc_h="yes"
193 ac_cv_header_malloc_h="no"
196 if test "$ac_cv_header_malloc_h" = "yes"; then
197 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
198 [Define to 1 if you have the malloc.h header file.])
204 void *p = malloc(10);
205 void *q = calloc(10,10);
210 curl_cv_need_header_malloc_h="no"
212 curl_cv_need_header_malloc_h="yes"
215 case "$curl_cv_need_header_malloc_h" in
217 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
218 [Define to 1 if you need the malloc.h header file even with stdlib.h])
225 dnl CURL_CHECK_TYPE_SOCKLEN_T
226 dnl -------------------------------------------------
227 dnl Check for existing socklen_t type, and provide
228 dnl an equivalent type if socklen_t not available
230 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
231 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
232 AC_CHECK_TYPE([socklen_t], ,[
233 AC_CACHE_CHECK([for socklen_t equivalent],
234 [curl_cv_socklen_t_equiv], [
235 curl_cv_socklen_t_equiv="unknown"
236 for arg2 in "struct sockaddr" void; do
237 for t in int size_t unsigned long "unsigned long"; do
241 #ifdef HAVE_WINDOWS_H
242 #ifndef WIN32_LEAN_AND_MEAN
243 #define WIN32_LEAN_AND_MEAN
246 #ifdef HAVE_WINSOCK2_H
247 #include <winsock2.h>
249 #ifdef HAVE_WINSOCK_H
254 #ifdef HAVE_SYS_TYPES_H
255 #include <sys/types.h>
257 #ifdef HAVE_SYS_SOCKET_H
258 #include <sys/socket.h>
261 int getpeername (int, $arg2 *, $t *);
264 getpeername(0,0,&len);
267 curl_cv_socklen_t_equiv="$t"
273 case "$curl_cv_socklen_t_equiv" in
275 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
278 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
279 [type to use in place of socklen_t if not defined])
284 #ifdef HAVE_WINDOWS_H
285 #ifndef WIN32_LEAN_AND_MEAN
286 #define WIN32_LEAN_AND_MEAN
289 #ifdef HAVE_WINSOCK2_H
290 #include <winsock2.h>
291 #ifdef HAVE_WS2TCPIP_H
292 #include <ws2tcpip.h>
296 #ifdef HAVE_SYS_TYPES_H
297 #include <sys/types.h>
299 #ifdef HAVE_SYS_SOCKET_H
300 #include <sys/socket.h>
307 dnl CURL_CHECK_FUNC_GETNAMEINFO
308 dnl -------------------------------------------------
309 dnl Test if the getnameinfo function is available,
310 dnl and check the types of five of its arguments.
311 dnl If the function succeeds HAVE_GETNAMEINFO will be
312 dnl defined, defining the types of the arguments in
313 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
314 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
315 dnl and also defining the type qualifier of first
316 dnl argument in GETNAMEINFO_QUAL_ARG1.
318 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
319 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
320 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
321 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
323 AC_MSG_CHECKING([for getnameinfo])
325 AC_LANG_FUNC_LINK_TRY([getnameinfo])
328 curl_cv_getnameinfo="yes"
331 curl_cv_getnameinfo="no"
334 if test "$curl_cv_getnameinfo" != "yes"; then
335 AC_MSG_CHECKING([deeper for getnameinfo])
341 curl_cv_getnameinfo="yes"
343 AC_MSG_RESULT([but still no])
344 curl_cv_getnameinfo="no"
348 if test "$curl_cv_getnameinfo" != "yes"; then
349 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
352 #ifdef HAVE_WINDOWS_H
353 #ifndef WIN32_LEAN_AND_MEAN
354 #define WIN32_LEAN_AND_MEAN
357 #ifdef HAVE_WINSOCK2_H
358 #include <winsock2.h>
359 #ifdef HAVE_WS2TCPIP_H
360 #include <ws2tcpip.h>
364 #ifdef HAVE_SYS_TYPES_H
365 #include <sys/types.h>
367 #ifdef HAVE_SYS_SOCKET_H
368 #include <sys/socket.h>
375 getnameinfo(0, 0, 0, 0, 0, 0, 0);
378 curl_cv_getnameinfo="yes"
380 AC_MSG_RESULT([but still no])
381 curl_cv_getnameinfo="no"
385 if test "$curl_cv_getnameinfo" = "yes"; then
386 AC_CACHE_CHECK([types of arguments for getnameinfo],
387 [curl_cv_func_getnameinfo_args], [
388 curl_cv_func_getnameinfo_args="unknown"
389 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
390 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
391 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
392 for gni_arg7 in 'int' 'unsigned int'; do
396 #ifdef HAVE_WINDOWS_H
397 #ifndef WIN32_LEAN_AND_MEAN
398 #define WIN32_LEAN_AND_MEAN
400 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
402 #define _WIN32_WINNT 0x0501
405 #ifdef HAVE_WINSOCK2_H
406 #include <winsock2.h>
407 #ifdef HAVE_WS2TCPIP_H
408 #include <ws2tcpip.h>
411 #define GNICALLCONV WSAAPI
413 #ifdef HAVE_SYS_TYPES_H
414 #include <sys/types.h>
416 #ifdef HAVE_SYS_SOCKET_H
417 #include <sys/socket.h>
424 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
430 $gni_arg46 hostlen=0;
431 $gni_arg46 servlen=0;
433 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
436 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
444 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
445 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
446 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
448 gni_prev_IFS=$IFS; IFS=','
449 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
453 gni_qual_type_arg1=$[1]
455 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
456 [Define to the type of arg 2 for getnameinfo.])
457 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
458 [Define to the type of args 4 and 6 for getnameinfo.])
459 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
460 [Define to the type of arg 7 for getnameinfo.])
464 case $prev_sh_opts in
472 case "$gni_qual_type_arg1" in
475 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
479 gni_type_arg1=$gni_qual_type_arg1
483 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
484 [Define to the type qualifier of arg 1 for getnameinfo.])
485 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
486 [Define to the type of arg 1 for getnameinfo.])
488 case $prev_sh_opts in
496 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
497 [Define to 1 if you have the getnameinfo function.])
498 ac_cv_func_getnameinfo="yes"
504 dnl TYPE_SOCKADDR_STORAGE
505 dnl -------------------------------------------------
506 dnl Check for struct sockaddr_storage. Most IPv6-enabled
507 dnl hosts have it, but AIX 4.3 is one known exception.
509 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
511 AC_CHECK_TYPE([struct sockaddr_storage],
512 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
513 [if struct sockaddr_storage is defined]), ,
516 #ifdef HAVE_WINDOWS_H
517 #ifndef WIN32_LEAN_AND_MEAN
518 #define WIN32_LEAN_AND_MEAN
521 #ifdef HAVE_WINSOCK2_H
522 #include <winsock2.h>
525 #ifdef HAVE_SYS_TYPES_H
526 #include <sys/types.h>
528 #ifdef HAVE_SYS_SOCKET_H
529 #include <sys/socket.h>
531 #ifdef HAVE_NETINET_IN_H
532 #include <netinet/in.h>
534 #ifdef HAVE_ARPA_INET_H
535 #include <arpa/inet.h>
542 dnl CURL_CHECK_NI_WITHSCOPEID
543 dnl -------------------------------------------------
544 dnl Check for working NI_WITHSCOPEID in getnameinfo()
546 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
547 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
548 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
549 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
550 netdb.h netinet/in.h arpa/inet.h)
552 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
553 [ac_cv_working_ni_withscopeid], [
559 #ifdef HAVE_SYS_TYPES_H
560 #include <sys/types.h>
562 #ifdef HAVE_SYS_SOCKET_H
563 #include <sys/socket.h>
568 #ifdef HAVE_NETINET_IN_H
569 #include <netinet/in.h>
571 #ifdef HAVE_ARPA_INET_H
572 #include <arpa/inet.h>
575 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
576 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
577 struct sockaddr_storage sa;
579 unsigned char sa[256];
581 char hostbuf[NI_MAXHOST];
583 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
584 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
585 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
586 int fd = socket(AF_INET6, SOCK_STREAM, 0);
589 return 1; /* Error creating socket */
591 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
593 perror("getsockname()");
594 return 2; /* Error retrieving socket name */
596 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
598 printf("rc = %s\n", gai_strerror(rc));
599 return 3; /* Error translating socket address */
601 return 0; /* Ok, NI_WITHSCOPEID works */
603 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
607 # Exit code == 0. Program worked.
608 ac_cv_working_ni_withscopeid="yes"
610 # Exit code != 0. Program failed.
611 ac_cv_working_ni_withscopeid="no"
613 # Program is not run when cross-compiling. So we assume
614 # NI_WITHSCOPEID will work if we are able to compile it.
617 #include <sys/types.h>
618 #include <sys/socket.h>
621 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
624 ac_cv_working_ni_withscopeid="yes"
626 ac_cv_working_ni_withscopeid="no"
627 ]) # AC_COMPILE_IFELSE
630 case "$ac_cv_working_ni_withscopeid" in
632 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
633 [Define to 1 if NI_WITHSCOPEID exists and works.])
639 dnl CURL_CHECK_FUNC_RECV
640 dnl -------------------------------------------------
641 dnl Test if the socket recv() function is available,
642 dnl and check its return type and the types of its
643 dnl arguments. If the function succeeds HAVE_RECV
644 dnl will be defined, defining the types of the arguments
645 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
646 dnl and RECV_TYPE_ARG4, defining the type of the function
647 dnl return value in RECV_TYPE_RETV.
649 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
650 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
651 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
652 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
654 AC_MSG_CHECKING([for recv])
657 #ifdef HAVE_WINDOWS_H
658 #ifndef WIN32_LEAN_AND_MEAN
659 #define WIN32_LEAN_AND_MEAN
662 #ifdef HAVE_WINSOCK2_H
663 #include <winsock2.h>
665 #ifdef HAVE_WINSOCK_H
670 #ifdef HAVE_SYS_TYPES_H
671 #include <sys/types.h>
673 #ifdef HAVE_SYS_SOCKET_H
674 #include <sys/socket.h>
687 if test "$curl_cv_recv" = "yes"; then
688 AC_CACHE_CHECK([types of arguments and return type for recv],
689 [curl_cv_func_recv_args], [
690 curl_cv_func_recv_args="unknown"
691 for recv_retv in 'int' 'ssize_t'; do
692 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
693 for recv_arg2 in 'char *' 'void *'; do
694 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
695 for recv_arg4 in 'int' 'unsigned int'; do
699 #ifdef HAVE_WINDOWS_H
700 #ifndef WIN32_LEAN_AND_MEAN
701 #define WIN32_LEAN_AND_MEAN
704 #ifdef HAVE_WINSOCK2_H
705 #include <winsock2.h>
707 #ifdef HAVE_WINSOCK_H
711 #define RECVCALLCONV PASCAL
713 #ifdef HAVE_SYS_TYPES_H
714 #include <sys/types.h>
716 #ifdef HAVE_SYS_SOCKET_H
717 #include <sys/socket.h>
721 extern $recv_retv RECVCALLCONV recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
727 $recv_retv res = recv(s, buf, len, flags);
730 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
739 if test "$curl_cv_func_recv_args" = "unknown"; then
740 AC_MSG_WARN([Cannot find proper types to use for recv args])
741 AC_MSG_WARN([HAVE_RECV will not be defined])
743 recv_prev_IFS=$IFS; IFS=','
744 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
748 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
749 [Define to the type of arg 1 for recv.])
750 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
751 [Define to the type of arg 2 for recv.])
752 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
753 [Define to the type of arg 3 for recv.])
754 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
755 [Define to the type of arg 4 for recv.])
756 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
757 [Define to the function return type for recv.])
759 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
760 [Define to 1 if you have the recv function.])
761 ac_cv_func_recv="yes"
767 dnl CURL_CHECK_FUNC_SEND
768 dnl -------------------------------------------------
769 dnl Test if the socket send() function is available,
770 dnl and check its return type and the types of its
771 dnl arguments. If the function succeeds HAVE_SEND
772 dnl will be defined, defining the types of the arguments
773 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
774 dnl and SEND_TYPE_ARG4, defining the type of the function
775 dnl return value in SEND_TYPE_RETV, and also defining the
776 dnl type qualifier of second argument in SEND_QUAL_ARG2.
778 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
779 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
780 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
781 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
783 AC_MSG_CHECKING([for send])
786 #ifdef HAVE_WINDOWS_H
787 #ifndef WIN32_LEAN_AND_MEAN
788 #define WIN32_LEAN_AND_MEAN
791 #ifdef HAVE_WINSOCK2_H
792 #include <winsock2.h>
794 #ifdef HAVE_WINSOCK_H
799 #ifdef HAVE_SYS_TYPES_H
800 #include <sys/types.h>
802 #ifdef HAVE_SYS_SOCKET_H
803 #include <sys/socket.h>
816 if test "$curl_cv_send" = "yes"; then
817 AC_CACHE_CHECK([types of arguments and return type for send],
818 [curl_cv_func_send_args], [
819 curl_cv_func_send_args="unknown"
820 for send_retv in 'int' 'ssize_t'; do
821 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
822 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
823 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
824 for send_arg4 in 'int' 'unsigned int'; do
828 #ifdef HAVE_WINDOWS_H
829 #ifndef WIN32_LEAN_AND_MEAN
830 #define WIN32_LEAN_AND_MEAN
833 #ifdef HAVE_WINSOCK2_H
834 #include <winsock2.h>
836 #ifdef HAVE_WINSOCK_H
840 #define SENDCALLCONV PASCAL
842 #ifdef HAVE_SYS_TYPES_H
843 #include <sys/types.h>
845 #ifdef HAVE_SYS_SOCKET_H
846 #include <sys/socket.h>
850 extern $send_retv SENDCALLCONV send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
855 $send_retv res = send(s, 0, len, flags);
858 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
867 if test "$curl_cv_func_send_args" = "unknown"; then
868 AC_MSG_WARN([Cannot find proper types to use for send args])
869 AC_MSG_WARN([HAVE_SEND will not be defined])
871 send_prev_IFS=$IFS; IFS=','
872 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
876 send_qual_type_arg2=$[2]
878 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
879 [Define to the type of arg 1 for send.])
880 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
881 [Define to the type of arg 3 for send.])
882 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
883 [Define to the type of arg 4 for send.])
884 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
885 [Define to the function return type for send.])
889 case $prev_sh_opts in
897 case "$send_qual_type_arg2" in
900 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
904 send_type_arg2=$send_qual_type_arg2
908 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
909 [Define to the type qualifier of arg 2 for send.])
910 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
911 [Define to the type of arg 2 for send.])
913 case $prev_sh_opts in
921 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
922 [Define to 1 if you have the send function.])
923 ac_cv_func_send="yes"
929 dnl CURL_CHECK_MSG_NOSIGNAL
930 dnl -------------------------------------------------
931 dnl Check for MSG_NOSIGNAL
933 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
934 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
935 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
939 #ifdef HAVE_WINDOWS_H
940 #ifndef WIN32_LEAN_AND_MEAN
941 #define WIN32_LEAN_AND_MEAN
944 #ifdef HAVE_WINSOCK2_H
945 #include <winsock2.h>
947 #ifdef HAVE_WINSOCK_H
952 #ifdef HAVE_SYS_TYPES_H
953 #include <sys/types.h>
955 #ifdef HAVE_SYS_SOCKET_H
956 #include <sys/socket.h>
960 int flag=MSG_NOSIGNAL;
963 ac_cv_msg_nosignal="yes"
965 ac_cv_msg_nosignal="no"
968 case "$ac_cv_msg_nosignal" in
970 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
971 [Define to 1 if you have the MSG_NOSIGNAL flag.])
977 dnl CURL_CHECK_NONBLOCKING_SOCKET
978 dnl -------------------------------------------------
979 dnl Check for how to set a socket to non-blocking state. There seems to exist
980 dnl four known different ways, with the one used almost everywhere being POSIX
981 dnl and XPG3, while the other different ways for different systems (old BSD,
982 dnl Windows and Amiga).
984 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
985 dnl O_NONBLOCK define is found but does not work. This condition is attempted
986 dnl to get caught in this script by using an excessive number of #ifdefs...
988 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET],
990 AC_MSG_CHECKING([non-blocking sockets style])
993 /* headers for O_NONBLOCK test */
994 #include <sys/types.h>
998 /* try to compile O_NONBLOCK */
1000 #if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
1001 # if defined(__SVR4) || defined(__srv4__)
1002 # define PLATFORM_SOLARIS
1004 # define PLATFORM_SUNOS4
1007 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX4)
1008 # define PLATFORM_AIX_V3
1011 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
1012 #error "O_NONBLOCK does not work on this platform"
1015 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
1017 dnl the O_NONBLOCK test was fine
1018 nonblock="O_NONBLOCK"
1019 AC_DEFINE(HAVE_O_NONBLOCK, 1, [use O_NONBLOCK for non-blocking sockets])
1021 dnl the code was bad, try a different program now, test 2
1024 /* headers for FIONBIO test */
1026 #include <stropts.h>
1028 /* FIONBIO source test (old-style unix) */
1030 int flags = ioctl(socket, FIONBIO, &flags);
1032 dnl FIONBIO test was good
1034 AC_DEFINE(HAVE_FIONBIO, 1, [use FIONBIO for non-blocking sockets])
1036 dnl FIONBIO test was also bad
1037 dnl the code was bad, try a different program now, test 3
1040 /* headers for ioctlsocket test (Windows) */
1042 #ifdef HAVE_WINDOWS_H
1043 #ifndef WIN32_LEAN_AND_MEAN
1044 #define WIN32_LEAN_AND_MEAN
1046 #include <windows.h>
1047 #ifdef HAVE_WINSOCK2_H
1048 #include <winsock2.h>
1050 #ifdef HAVE_WINSOCK_H
1051 #include <winsock.h>
1056 /* ioctlsocket source code */
1058 unsigned long flags = 0;
1059 sd = socket(0, 0, 0);
1060 ioctlsocket(sd, FIONBIO, &flags);
1062 dnl ioctlsocket test was good
1063 nonblock="ioctlsocket"
1064 AC_DEFINE(HAVE_IOCTLSOCKET, 1, [use ioctlsocket() for non-blocking sockets])
1066 dnl ioctlsocket didnt compile!, go to test 4
1069 /* headers for IoctlSocket test (Amiga?) */
1070 #include <sys/ioctl.h>
1072 /* IoctlSocket source code */
1074 int flags = IoctlSocket(socket, FIONBIO, (long)1);
1076 dnl ioctlsocket test was good
1077 nonblock="IoctlSocket"
1078 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, [use Ioctlsocket() for non-blocking sockets])
1080 dnl Ioctlsocket didnt compile, do test 5!
1082 /* headers for SO_NONBLOCK test (BeOS) */
1085 /* SO_NONBLOCK source code */
1088 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
1090 dnl the SO_NONBLOCK test was good
1091 nonblock="SO_NONBLOCK"
1092 AC_DEFINE(HAVE_SO_NONBLOCK, 1, [use SO_NONBLOCK for non-blocking sockets])
1094 dnl test 5 didnt compile!
1096 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, [disabled non-blocking sockets])
1098 dnl end of fifth test
1101 dnl end of forth test
1104 dnl end of third test
1107 dnl end of second test
1110 dnl end of non-blocking try-compile test
1111 AC_MSG_RESULT($nonblock)
1113 if test "$nonblock" = "nada"; then
1114 AC_MSG_WARN([non-block sockets disabled])
1120 dnl -------------------------------------------------
1121 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1122 dnl and a few other things.
1123 AC_DEFUN([TYPE_IN_ADDR_T],
1125 AC_CHECK_TYPE([in_addr_t], ,[
1126 AC_MSG_CHECKING([for in_addr_t equivalent])
1127 AC_CACHE_VAL([curl_cv_in_addr_t_equiv],
1129 curl_cv_in_addr_t_equiv=
1130 for t in "unsigned long" int size_t unsigned long; do
1133 #ifdef HAVE_WINDOWS_H
1134 #ifndef WIN32_LEAN_AND_MEAN
1135 #define WIN32_LEAN_AND_MEAN
1137 #include <windows.h>
1138 #ifdef HAVE_WINSOCK2_H
1139 #include <winsock2.h>
1141 #ifdef HAVE_WINSOCK_H
1142 #include <winsock.h>
1146 #ifdef HAVE_SYS_TYPES_H
1147 #include <sys/types.h>
1149 #ifdef HAVE_SYS_SOCKET_H
1150 #include <sys/socket.h>
1152 #ifdef HAVE_NETINET_IN_H
1153 #include <netinet/in.h>
1155 #ifdef HAVE_ARPA_INET_H
1156 #include <arpa/inet.h>
1160 $t data = inet_addr ("1.2.3.4");
1162 curl_cv_in_addr_t_equiv="$t"
1167 if test "x$curl_cv_in_addr_t_equiv" = x; then
1168 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1171 AC_MSG_RESULT($curl_cv_in_addr_t_equiv)
1172 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1173 [type to use in place of in_addr_t if not defined])],
1176 #ifdef HAVE_WINDOWS_H
1177 #ifndef WIN32_LEAN_AND_MEAN
1178 #define WIN32_LEAN_AND_MEAN
1180 #include <windows.h>
1181 #ifdef HAVE_WINSOCK2_H
1182 #include <winsock2.h>
1184 #ifdef HAVE_WINSOCK_H
1185 #include <winsock.h>
1189 #ifdef HAVE_SYS_TYPES_H
1190 #include <sys/types.h>
1192 #ifdef HAVE_SYS_SOCKET_H
1193 #include <sys/socket.h>
1195 #ifdef HAVE_NETINET_IN_H
1196 #include <netinet/in.h>
1198 #ifdef HAVE_ARPA_INET_H
1199 #include <arpa/inet.h>
1202 ]) dnl AC_CHECK_TYPE
1205 dnl ************************************************************
1206 dnl check for "localhost", if it doesn't exist, we can't do the
1207 dnl gethostbyname_r tests!
1210 AC_DEFUN([CURL_CHECK_WORKING_RESOLVER],[
1211 AC_MSG_CHECKING([if "localhost" resolves])
1214 #include <sys/types.h>
1220 h = gethostbyname("localhost");
1221 exit (h == NULL ? 1 : 0); }],[
1222 AC_MSG_RESULT(yes)],[
1224 AC_MSG_ERROR([can't figure out gethostbyname_r() since localhost doesn't resolve])
1230 dnl ************************************************************
1231 dnl check for working getaddrinfo() that works with AI_NUMERICHOST
1233 AC_DEFUN([CURL_CHECK_WORKING_GETADDRINFO],[
1234 AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
1237 #include <sys/types.h>
1238 #include <sys/socket.h>
1242 struct addrinfo hints, *ai;
1245 memset(&hints, 0, sizeof(hints));
1246 hints.ai_flags = AI_NUMERICHOST;
1247 hints.ai_family = AF_UNSPEC;
1248 hints.ai_socktype = SOCK_STREAM;
1249 error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
1256 ac_cv_working_getaddrinfo="yes"
1258 ac_cv_working_getaddrinfo="no"
1260 ac_cv_working_getaddrinfo="yes"
1262 if test "$ac_cv_working_getaddrinfo" = "yes"; then
1263 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
1264 AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
1267 AC_SUBST(IPV6_ENABLED)
1272 AC_DEFUN([CURL_CHECK_LOCALTIME_R],
1274 dnl check for localtime_r
1275 AC_CHECK_FUNCS(localtime_r,[
1276 AC_MSG_CHECKING(whether localtime_r is declared)
1277 AC_EGREP_CPP(localtime_r,[
1278 #include <time.h>],[
1279 AC_MSG_RESULT(yes)],[
1281 AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
1282 AC_EGREP_CPP(localtime_r,[
1284 #include <time.h>],[
1285 AC_DEFINE(NEED_REENTRANT)
1286 AC_MSG_RESULT(yes)],
1287 AC_MSG_RESULT(no))])])
1291 dnl This function checks for strerror_r(). If it isn't found at first, it
1292 dnl retries with _THREAD_SAFE defined, as that is what AIX seems to require
1293 dnl in order to find this function.
1295 dnl If the function is found, it will then proceed to check how the function
1296 dnl actually works: glibc-style or POSIX-style.
1299 dnl char *strerror_r(int errnum, char *buf, size_t n);
1301 dnl What this one does is to return the error string (no surprises there),
1302 dnl but it doesn't usually copy anything into buf! The 'buf' and 'n'
1303 dnl parameters are only meant as an optional working area, in case strerror_r
1304 dnl needs it. A quick test on a few systems shows that it's generally not
1308 dnl int strerror_r(int errnum, char *buf, size_t n);
1310 AC_DEFUN([CURL_CHECK_STRERROR_R],
1312 AC_CHECK_FUNCS(strerror_r)
1314 if test "x$ac_cv_func_strerror_r" = "xyes"; then
1316 AC_MSG_CHECKING(whether strerror_r is declared)
1317 AC_EGREP_CPP(strerror_r,[
1318 #include <string.h>],[
1319 AC_MSG_RESULT(yes)],[
1321 AC_MSG_CHECKING(whether strerror_r with -D_REENTRANT is declared)
1322 AC_EGREP_CPP(strerror_r,[
1324 #include <string.h>],[
1325 CPPFLAGS="-D_REENTRANT $CPPFLAGS"
1326 AC_MSG_RESULT(yes)],
1328 AC_DEFINE(HAVE_NO_STRERROR_R_DECL, 1, [we have no strerror_r() proto])
1329 ) dnl with _THREAD_SAFE
1330 ]) dnl plain cpp for it
1332 dnl determine if this strerror_r() is glibc or POSIX
1333 AC_MSG_CHECKING([for a glibc strerror_r API])
1339 char buffer[1024]; /* big enough to play with */
1341 strerror_r(EACCES, buffer, sizeof(buffer));
1342 /* this should've returned a string */
1343 if(!string || !string[0])
1348 GLIBC_STRERROR_R="1"
1349 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
1350 AC_MSG_RESULT([yes]),
1351 AC_MSG_RESULT([no]),
1353 dnl Use an inferior method of strerror_r detection while cross-compiling
1355 #include <features.h>
1360 dnl looks like glibc, so assume a glibc-style strerror_r()
1361 GLIBC_STRERROR_R="1"
1362 AC_DEFINE(HAVE_GLIBC_STRERROR_R, 1, [we have a glibc-style strerror_r()])
1363 AC_MSG_RESULT([yes]),
1364 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
1365 ) dnl while cross-compiling
1368 if test -z "$GLIBC_STRERROR_R"; then
1370 AC_MSG_CHECKING([for a POSIX strerror_r API])
1376 char buffer[1024]; /* big enough to play with */
1378 strerror_r(EACCES, buffer, sizeof(buffer));
1379 /* This should've returned zero, and written an error string in the
1381 if(!buffer[0] || error)
1386 AC_DEFINE(HAVE_POSIX_STRERROR_R, 1, [we have a POSIX-style strerror_r()])
1387 AC_MSG_RESULT([yes]),
1388 AC_MSG_RESULT([no]) ,
1389 dnl cross-compiling!
1390 AC_MSG_NOTICE([cannot determine strerror_r() style: edit lib/config.h manually!])
1393 fi dnl if not using glibc API
1395 fi dnl we have a strerror_r
1399 AC_DEFUN([CURL_CHECK_INET_NTOA_R],
1401 dnl determine if function definition for inet_ntoa_r exists.
1402 AC_CHECK_FUNCS(inet_ntoa_r,[
1403 AC_MSG_CHECKING(whether inet_ntoa_r is declared)
1404 AC_EGREP_CPP(inet_ntoa_r,[
1405 #include <arpa/inet.h>],[
1406 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
1407 AC_MSG_RESULT(yes)],[
1409 AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
1410 AC_EGREP_CPP(inet_ntoa_r,[
1412 #include <arpa/inet.h>],[
1413 AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
1414 AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT defined])
1415 AC_MSG_RESULT(yes)],
1416 AC_MSG_RESULT(no))])])
1419 AC_DEFUN([CURL_CHECK_GETHOSTBYADDR_R],
1421 dnl check for number of arguments to gethostbyaddr_r. it might take
1422 dnl either 5, 7, or 8 arguments.
1423 AC_CHECK_FUNCS(gethostbyaddr_r,[
1424 AC_MSG_CHECKING(if gethostbyaddr_r takes 5 arguments)
1426 #include <sys/types.h>
1427 #include <netdb.h>],[
1432 struct hostent_data hdata;
1434 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
1436 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
1437 ac_cv_gethostbyaddr_args=5],[
1439 AC_MSG_CHECKING(if gethostbyaddr_r with -D_REENTRANT takes 5 arguments)
1442 #include <sys/types.h>
1443 #include <netdb.h>],[
1448 struct hostent_data hdata;
1450 rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
1452 AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
1453 AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT])
1454 ac_cv_gethostbyaddr_args=5],[
1456 AC_MSG_CHECKING(if gethostbyaddr_r takes 7 arguments)
1458 #include <sys/types.h>
1459 #include <netdb.h>],[
1466 struct hostent * hp;
1468 hp = gethostbyaddr_r(address, length, type, &h,
1469 buffer, 8192, &h_errnop);],[
1471 AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args] )
1472 ac_cv_gethostbyaddr_args=7],[
1474 AC_MSG_CHECKING(if gethostbyaddr_r takes 8 arguments)
1476 #include <sys/types.h>
1477 #include <netdb.h>],[
1484 struct hostent * hp;
1487 rc = gethostbyaddr_r(address, length, type, &h,
1488 buffer, 8192, &hp, &h_errnop);],[
1490 AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
1491 ac_cv_gethostbyaddr_args=8],[
1493 have_missing_r_funcs="$have_missing_r_funcs gethostbyaddr_r"])])])])])
1496 AC_DEFUN([CURL_CHECK_GETHOSTBYNAME_R],
1498 dnl check for number of arguments to gethostbyname_r. it might take
1499 dnl either 3, 5, or 6 arguments.
1500 AC_CHECK_FUNCS(gethostbyname_r,[
1501 AC_MSG_CHECKING([if gethostbyname_r takes 3 arguments])
1504 #include <sys/types.h>
1507 #define NULL (void *)0
1510 gethostbyname_r(const char *, struct hostent *, struct hostent_data *);],[
1511 struct hostent_data data;
1512 gethostbyname_r(NULL, NULL, NULL);],[
1514 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
1515 ac_cv_gethostbyname_args=3],[
1517 AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 3 arguments])
1522 #include <sys/types.h>
1525 #define NULL (void *)0
1528 gethostbyname_r(const char *,struct hostent *, struct hostent_data *);],[
1529 struct hostent_data data;
1530 gethostbyname_r(NULL, NULL, NULL);],[
1532 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
1533 AC_DEFINE(NEED_REENTRANT, 1, [needs REENTRANT])
1534 ac_cv_gethostbyname_args=3],[
1536 AC_MSG_CHECKING([if gethostbyname_r takes 5 arguments])
1538 #include <sys/types.h>
1541 #define NULL (void *)0
1544 gethostbyname_r(const char *, struct hostent *, char *, int, int *);],[
1545 gethostbyname_r(NULL, NULL, NULL, 0, NULL);],[
1547 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
1548 ac_cv_gethostbyname_args=5],[
1550 AC_MSG_CHECKING([if gethostbyname_r takes 6 arguments])
1552 #include <sys/types.h>
1555 #define NULL (void *)0
1558 gethostbyname_r(const char *, struct hostent *, char *, size_t,
1559 struct hostent **, int *);],[
1560 gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);],[
1562 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
1563 ac_cv_gethostbyname_args=6],[
1565 have_missing_r_funcs="$have_missing_r_funcs gethostbyname_r"],
1566 [ac_cv_gethostbyname_args=0])],
1567 [ac_cv_gethostbyname_args=0])],
1568 [ac_cv_gethostbyname_args=0])],
1569 [ac_cv_gethostbyname_args=0])])
1571 if test "$ac_cv_func_gethostbyname_r" = "yes"; then
1572 if test "$ac_cv_gethostbyname_args" = "0"; then
1573 dnl there's a gethostbyname_r() function, but we don't know how
1574 dnl many arguments it wants!
1575 AC_MSG_ERROR([couldn't figure out how to use gethostbyname_r()])
1581 dnl **********************************************************************
1582 dnl CURL_DETECT_ICC ([ACTION-IF-YES])
1584 dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
1585 dnl sets the $ICC variable to "yes" or "no"
1586 dnl **********************************************************************
1587 AC_DEFUN([CURL_DETECT_ICC],
1590 AC_MSG_CHECKING([for icc in use])
1591 if test "$GCC" = "yes"; then
1592 dnl check if this is icc acting as gcc in disguise
1593 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
1594 dnl action if the text is found, this it has not been replaced by the
1597 dnl the text was not found, it was replaced by the cpp
1599 AC_MSG_RESULT([yes])
1603 if test "$ICC" = "no"; then
1609 dnl We create a function for detecting which compiler we use and then set as
1610 dnl pendantic compiler options as possible for that particular compiler. The
1611 dnl options are only used for debug-builds.
1613 AC_DEFUN([CURL_CC_DEBUG_OPTS],
1615 if test "z$ICC" = "z"; then
1619 if test "$GCC" = "yes"; then
1621 dnl figure out gcc version!
1622 AC_MSG_CHECKING([gcc version])
1623 gccver=`$CC -dumpversion`
1624 num1=`echo $gccver | cut -d . -f1`
1625 num2=`echo $gccver | cut -d . -f2`
1626 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
1627 AC_MSG_RESULT($gccver)
1629 if test "$ICC" = "yes"; then
1630 dnl this is icc, not gcc.
1632 dnl ICC warnings we ignore:
1633 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
1634 dnl "invalid format string conversion"
1635 dnl * 279 warns on static conditions in while expressions
1636 dnl * 981 warns on "operands are evaluated in unspecified order"
1637 dnl * 1418 "external definition with no prior declaration"
1638 dnl * 1419 warns on "external declaration in primary source file"
1639 dnl which we know and do on purpose.
1641 WARN="-wd279,269,981,1418,1419"
1643 if test "$gccnum" -gt "600"; then
1644 dnl icc 6.0 and older doesn't have the -Wall flag
1648 dnl this is a set of options we believe *ALL* gcc versions support:
1649 WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
1651 dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
1653 if test "$gccnum" -ge "207"; then
1654 dnl gcc 2.7 or later
1655 WARN="$WARN -Wmissing-declarations"
1658 if test "$gccnum" -gt "295"; then
1659 dnl only if the compiler is newer than 2.95 since we got lots of
1660 dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
1661 dnl gcc 2.95.4 on FreeBSD 4.9!
1662 WARN="$WARN -Wundef -Wno-long-long -Wsign-compare"
1665 if test "$gccnum" -ge "296"; then
1666 dnl gcc 2.96 or later
1667 WARN="$WARN -Wfloat-equal"
1670 if test "$gccnum" -gt "296"; then
1671 dnl this option does not exist in 2.96
1672 WARN="$WARN -Wno-format-nonliteral"
1675 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
1676 dnl on i686-Linux as it gives us heaps with false positives.
1677 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
1678 dnl over making it unusable for generic purposes. Let's not use it.
1680 if test "$gccnum" -ge "303"; then
1681 dnl gcc 3.3 and later
1682 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
1685 if test "$gccnum" -ge "304"; then
1686 # try these on gcc 3.4
1687 WARN="$WARN -Wdeclaration-after-statement"
1690 for flag in $CPPFLAGS; do
1693 dnl Include path, provide a -isystem option for the same dir
1694 dnl to prevent warnings in those dirs. The -isystem was not very
1695 dnl reliable on earlier gcc versions.
1696 add=`echo $flag | sed 's/^-I/-isystem /g'`
1704 CFLAGS="$CFLAGS $WARN"
1706 AC_MSG_NOTICE([Added this set of compiler options: $WARN])
1710 AC_MSG_NOTICE([Added no extra compiler options])
1714 dnl strip off optimizer flags
1716 for flag in $CFLAGS; do
1719 dnl echo "cut off $flag"
1722 NEWFLAGS="$NEWFLAGS $flag"
1728 ]) dnl end of AC_DEFUN()
1731 dnl Determine the name of the library to pass to dlopen() based on the name
1732 dnl that would normally be given to AC_CHECK_LIB. The preprocessor symbol
1733 dnl given is set to the quoted library file name.
1734 dnl The standard dynamic library file name is first generated, based on the
1735 dnl current system type, then a search is performed for that file on the
1736 dnl standard dynamic library path. If it is a symbolic link, the destination
1737 dnl of the link is used as the file name, after stripping off any minor
1738 dnl version numbers. If a library file can't be found, a guess is made.
1739 dnl This macro assumes AC_PROG_LIBTOOL has been called and requires perl
1740 dnl to be available in the PATH, or $PERL to be set to its location.
1742 dnl CURL_DLLIB_NAME(VARIABLE, library_name)
1743 dnl e.g. CURL_DLLIB_NAME(LDAP_NAME, ldap) on a Linux system might result
1744 dnl in LDAP_NAME holding the string "libldap.so.2".
1746 AC_DEFUN([CURL_DLLIB_NAME],
1748 AC_MSG_CHECKING([name of dynamic library $2])
1749 dnl The shared library extension variable name changes from version to
1750 dnl version of libtool. Try a few names then just set one statically.
1751 test -z "$shared_ext" && shared_ext="$shrext_cmds"
1752 test -z "$shared_ext" && shared_ext="$shrext"
1753 test -z "$shared_ext" && shared_ext=".so"
1755 dnl Create the library link name of the correct form for this platform
1756 LIBNAME_LINK_SPEC=`echo "$library_names_spec" | $SED 's/^.* //'`
1757 DLGUESSLIB=`name=$2 eval echo "$libname_spec"`
1758 DLGUESSFILE=`libname="$DLGUESSLIB" release="" major="" versuffix="" eval echo "$LIBNAME_LINK_SPEC"`
1760 dnl Synthesize a likely dynamic library name in case we can't find an actual one
1761 SO_NAME_SPEC="$soname_spec"
1762 dnl soname_spec undefined when identical to the 1st entry in library_names_spec
1763 test -z "$SO_NAME_SPEC" && SO_NAME_SPEC=`echo "$library_names_spec" | $SED 's/ .*$//'`
1764 DLGUESSSOFILE=`libname="$DLGUESSLIB" release="" major="" versuffix="" eval echo "$SO_NAME_SPEC"`
1766 if test "$cross_compiling" = yes; then
1767 dnl Can't look at filesystem when cross-compiling
1768 AC_DEFINE_UNQUOTED($1, "$DLGUESSSOFILE", [$2 dynamic library file])
1769 AC_MSG_RESULT([$DLGUESSSOFILE (guess while cross-compiling)])
1773 if test "$sys_lib_dlsearch_path_spec" ; then
1774 dnl Search for the link library name and see what it points to.
1775 for direc in $sys_lib_dlsearch_path_spec ; do
1776 DLTRYFILE="$direc/$DLGUESSFILE"
1777 dnl Find where the symbolic link for this name points
1778 changequote(<<, >>)dnl
1780 DLFOUNDFILE=`${PERL:-perl} -e 'use File::Basename; (basename(readlink($ARGV[0])) =~ /^(.*[^\d]\.\d+)[\d\.]*$/ && print ${1}) || exit 1;' "$DLTRYFILE" 2>&5`
1782 changequote([, ])dnl
1783 if test "$?" -eq "0"; then
1784 dnl Found the file link
1790 if test -z "$DLFOUNDFILE" ; then
1791 dnl Couldn't find a link library, so guess at a name.
1792 DLFOUNDFILE="$DLGUESSSOFILE"
1795 AC_DEFINE_UNQUOTED($1, "$DLFOUNDFILE", [$2 dynamic library file])
1796 AC_MSG_RESULT($DLFOUNDFILE)
1800 # This is only a temporary fix. This macro is here to replace the broken one
1801 # delivered by the automake project (including the 1.9.6 release). As soon as
1802 # they ship a working version we SHOULD remove this work-around.
1804 AC_DEFUN([AM_MISSING_HAS_RUN],
1805 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
1806 test x"${MISSING+set}" = xset || MISSING="\${SHELL} \"$am_aux_dir/missing\""
1807 # Use eval to expand $SHELL
1808 if eval "$MISSING --run true"; then
1809 am_missing_run="$MISSING --run "
1812 AC_MSG_WARN([`missing' script is too old or missing])