3 dnl CURL_CHECK_COMPILER_HALT_ON_ERROR
4 dnl -------------------------------------------------
5 dnl Verifies if the compiler actually halts after the
6 dnl compilation phase without generating any object
7 dnl code file, when the source compiles with errors.
9 AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [
10 AC_MSG_CHECKING([if compiler halts on compilation errors])
14 force compilation error
18 AC_MSG_ERROR([compiler does not halt on compilation errors.])
25 dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
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 code tries to define a
30 dnl type for a constant array with negative dimension.
32 AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
33 AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
34 AC_MSG_CHECKING([if compiler halts on negative sized arrays])
37 typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
43 AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
50 dnl CURL_CHECK_DEF(SYMBOL, [INCLUDES], [SILENT])
51 dnl -------------------------------------------------
52 dnl Use the C preprocessor to find out if the given object-style symbol
53 dnl is defined and get its expansion. This macro will not use default
54 dnl includes even if no INCLUDES argument is given. This macro will run
55 dnl silently when invoked with three arguments.
57 AC_DEFUN([CURL_CHECK_DEF], [
58 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
59 AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
60 ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
70 tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
71 "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
72 "$SED" 's/.*CURL_DEF_TOKEN[[ ]]//' 2>/dev/null | \
73 "$SED" 'q' 2>/dev/null`
74 if test "$tmp_exp" = "$1"; then
78 if test -z "$tmp_exp"; then
79 AS_VAR_SET([ac_HaveDef], [no])
80 ifelse($3,,[AC_MSG_RESULT([no])])
82 AS_VAR_SET([ac_HaveDef], [yes])
83 AS_VAR_SET([ac_Def], [$tmp_exp])
84 ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
86 AS_VAR_POPDEF([ac_Def])dnl
87 AS_VAR_POPDEF([ac_HaveDef])dnl
91 dnl CURL_CHECK_HEADER_WINDOWS
92 dnl -------------------------------------------------
93 dnl Check for compilable and valid windows.h header
95 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
96 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
100 #ifndef WIN32_LEAN_AND_MEAN
101 #define WIN32_LEAN_AND_MEAN
105 #if defined(__CYGWIN__) || defined(__CEGCC__)
106 HAVE_WINDOWS_H shall not be defined.
112 ac_cv_header_windows_h="yes"
114 ac_cv_header_windows_h="no"
117 case "$ac_cv_header_windows_h" in
119 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
120 [Define to 1 if you have the windows.h header file.])
121 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
122 [Define to avoid automatic inclusion of winsock.h])
128 dnl CURL_CHECK_NATIVE_WINDOWS
129 dnl -------------------------------------------------
130 dnl Check if building a native Windows target
132 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
133 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
134 AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
135 if test "$ac_cv_header_windows_h" = "no"; then
136 ac_cv_native_windows="no"
141 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
142 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
145 Not a native Windows build target.
149 ac_cv_native_windows="yes"
151 ac_cv_native_windows="no"
155 case "$ac_cv_native_windows" in
157 AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
158 [Define to 1 if you are building a native Windows target.])
164 dnl CURL_CHECK_HEADER_WINSOCK
165 dnl -------------------------------------------------
166 dnl Check for compilable and valid winsock.h header
168 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
169 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
170 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
174 #ifndef WIN32_LEAN_AND_MEAN
175 #define WIN32_LEAN_AND_MEAN
180 #if defined(__CYGWIN__) || defined(__CEGCC__)
181 HAVE_WINSOCK_H shall not be defined.
183 int dummy=WSACleanup();
187 ac_cv_header_winsock_h="yes"
189 ac_cv_header_winsock_h="no"
192 case "$ac_cv_header_winsock_h" in
194 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
195 [Define to 1 if you have the winsock.h header file.])
201 dnl CURL_CHECK_HEADER_WINSOCK2
202 dnl -------------------------------------------------
203 dnl Check for compilable and valid winsock2.h header
205 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
206 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
207 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
211 #ifndef WIN32_LEAN_AND_MEAN
212 #define WIN32_LEAN_AND_MEAN
215 #include <winsock2.h>
217 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
218 HAVE_WINSOCK2_H shall not be defined.
220 int dummy=2*IPPROTO_ESP;
224 ac_cv_header_winsock2_h="yes"
226 ac_cv_header_winsock2_h="no"
229 case "$ac_cv_header_winsock2_h" in
231 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
232 [Define to 1 if you have the winsock2.h header file.])
238 dnl CURL_CHECK_HEADER_WS2TCPIP
239 dnl -------------------------------------------------
240 dnl Check for compilable and valid ws2tcpip.h header
242 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
243 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
244 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
248 #ifndef WIN32_LEAN_AND_MEAN
249 #define WIN32_LEAN_AND_MEAN
252 #include <winsock2.h>
253 #include <ws2tcpip.h>
255 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
256 HAVE_WS2TCPIP_H shall not be defined.
258 int dummy=2*IP_PKTINFO;
262 ac_cv_header_ws2tcpip_h="yes"
264 ac_cv_header_ws2tcpip_h="no"
267 case "$ac_cv_header_ws2tcpip_h" in
269 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
270 [Define to 1 if you have the ws2tcpip.h header file.])
276 dnl CURL_CHECK_HEADER_MALLOC
277 dnl -------------------------------------------------
278 dnl Check for compilable and valid malloc.h header,
279 dnl and check if it is needed even with stdlib.h
281 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
282 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
287 void *p = malloc(10);
288 void *q = calloc(10,10);
293 ac_cv_header_malloc_h="yes"
295 ac_cv_header_malloc_h="no"
298 if test "$ac_cv_header_malloc_h" = "yes"; then
299 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
300 [Define to 1 if you have the malloc.h header file.])
306 void *p = malloc(10);
307 void *q = calloc(10,10);
312 curl_cv_need_header_malloc_h="no"
314 curl_cv_need_header_malloc_h="yes"
317 case "$curl_cv_need_header_malloc_h" in
319 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
320 [Define to 1 if you need the malloc.h header file even with stdlib.h])
327 dnl CURL_CHECK_TYPE_SOCKLEN_T
328 dnl -------------------------------------------------
329 dnl Check for existing socklen_t type, and provide
330 dnl an equivalent type if socklen_t not available
332 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
333 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
334 AC_CHECK_TYPE([socklen_t], ,[
335 dnl socklen_t not available
336 AC_CACHE_CHECK([for socklen_t equivalent],
337 [curl_cv_socklen_t_equiv], [
338 curl_cv_socklen_t_equiv="unknown"
339 for arg1 in 'int' 'SOCKET'; do
340 for arg2 in "struct sockaddr" void; do
341 for t in int size_t unsigned long "unsigned long"; do
342 if test "$curl_cv_socklen_t_equiv" = "unknown"; then
346 #ifdef HAVE_WINDOWS_H
347 #ifndef WIN32_LEAN_AND_MEAN
348 #define WIN32_LEAN_AND_MEAN
351 #ifdef HAVE_WINSOCK2_H
352 #include <winsock2.h>
354 #ifdef HAVE_WINSOCK_H
358 #define GETPEERNCALLCONV PASCAL
360 #ifdef HAVE_SYS_TYPES_H
361 #include <sys/types.h>
363 #ifdef HAVE_SYS_SOCKET_H
364 #include <sys/socket.h>
366 #define GETPEERNCALLCONV
368 extern int GETPEERNCALLCONV getpeername($arg1, $arg2 *, $t *);
371 getpeername(0,0,&len);
374 curl_cv_socklen_t_equiv="$t"
381 case "$curl_cv_socklen_t_equiv" in
383 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
386 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
387 [Type to use in place of socklen_t when system does not provide it.])
392 #ifdef HAVE_WINDOWS_H
393 #ifndef WIN32_LEAN_AND_MEAN
394 #define WIN32_LEAN_AND_MEAN
397 #ifdef HAVE_WINSOCK2_H
398 #include <winsock2.h>
399 #ifdef HAVE_WS2TCPIP_H
400 #include <ws2tcpip.h>
404 #ifdef HAVE_SYS_TYPES_H
405 #include <sys/types.h>
407 #ifdef HAVE_SYS_SOCKET_H
408 #include <sys/socket.h>
415 dnl CURL_CHECK_FUNC_GETNAMEINFO
416 dnl -------------------------------------------------
417 dnl Test if the getnameinfo function is available,
418 dnl and check the types of five of its arguments.
419 dnl If the function succeeds HAVE_GETNAMEINFO will be
420 dnl defined, defining the types of the arguments in
421 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
422 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
423 dnl and also defining the type qualifier of first
424 dnl argument in GETNAMEINFO_QUAL_ARG1.
426 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
427 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
428 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
429 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
431 AC_MSG_CHECKING([for getnameinfo])
433 AC_LANG_FUNC_LINK_TRY([getnameinfo])
436 curl_cv_getnameinfo="yes"
439 curl_cv_getnameinfo="no"
442 if test "$curl_cv_getnameinfo" != "yes"; then
443 AC_MSG_CHECKING([deeper for getnameinfo])
451 curl_cv_getnameinfo="yes"
453 AC_MSG_RESULT([but still no])
454 curl_cv_getnameinfo="no"
458 if test "$curl_cv_getnameinfo" != "yes"; then
459 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
463 #ifdef HAVE_WINDOWS_H
464 #ifndef WIN32_LEAN_AND_MEAN
465 #define WIN32_LEAN_AND_MEAN
468 #ifdef HAVE_WINSOCK2_H
469 #include <winsock2.h>
470 #ifdef HAVE_WS2TCPIP_H
471 #include <ws2tcpip.h>
475 #ifdef HAVE_SYS_TYPES_H
476 #include <sys/types.h>
478 #ifdef HAVE_SYS_SOCKET_H
479 #include <sys/socket.h>
486 getnameinfo(0, 0, 0, 0, 0, 0, 0);
490 curl_cv_getnameinfo="yes"
492 AC_MSG_RESULT([but still no])
493 curl_cv_getnameinfo="no"
497 if test "$curl_cv_getnameinfo" = "yes"; then
498 AC_CACHE_CHECK([types of arguments for getnameinfo],
499 [curl_cv_func_getnameinfo_args], [
500 curl_cv_func_getnameinfo_args="unknown"
501 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
502 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
503 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
504 for gni_arg7 in 'int' 'unsigned int'; do
505 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
509 #ifdef HAVE_WINDOWS_H
510 #ifndef WIN32_LEAN_AND_MEAN
511 #define WIN32_LEAN_AND_MEAN
513 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
515 #define _WIN32_WINNT 0x0501
518 #ifdef HAVE_WINSOCK2_H
519 #include <winsock2.h>
520 #ifdef HAVE_WS2TCPIP_H
521 #include <ws2tcpip.h>
524 #define GNICALLCONV WSAAPI
526 #ifdef HAVE_SYS_TYPES_H
527 #include <sys/types.h>
529 #ifdef HAVE_SYS_SOCKET_H
530 #include <sys/socket.h>
537 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
543 $gni_arg46 hostlen=0;
544 $gni_arg46 servlen=0;
546 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
549 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
557 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
558 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
559 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
561 gni_prev_IFS=$IFS; IFS=','
562 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
566 gni_qual_type_arg1=$[1]
568 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
569 [Define to the type of arg 2 for getnameinfo.])
570 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
571 [Define to the type of args 4 and 6 for getnameinfo.])
572 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
573 [Define to the type of arg 7 for getnameinfo.])
577 case $prev_sh_opts in
585 case "$gni_qual_type_arg1" in
588 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
592 gni_type_arg1=$gni_qual_type_arg1
596 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
597 [Define to the type qualifier of arg 1 for getnameinfo.])
598 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
599 [Define to the type of arg 1 for getnameinfo.])
601 case $prev_sh_opts in
609 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
610 [Define to 1 if you have the getnameinfo function.])
611 ac_cv_func_getnameinfo="yes"
617 dnl TYPE_SOCKADDR_STORAGE
618 dnl -------------------------------------------------
619 dnl Check for struct sockaddr_storage. Most IPv6-enabled
620 dnl hosts have it, but AIX 4.3 is one known exception.
622 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
624 AC_CHECK_TYPE([struct sockaddr_storage],
625 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
626 [if struct sockaddr_storage is defined]), ,
629 #ifdef HAVE_WINDOWS_H
630 #ifndef WIN32_LEAN_AND_MEAN
631 #define WIN32_LEAN_AND_MEAN
634 #ifdef HAVE_WINSOCK2_H
635 #include <winsock2.h>
638 #ifdef HAVE_SYS_TYPES_H
639 #include <sys/types.h>
641 #ifdef HAVE_SYS_SOCKET_H
642 #include <sys/socket.h>
644 #ifdef HAVE_NETINET_IN_H
645 #include <netinet/in.h>
647 #ifdef HAVE_ARPA_INET_H
648 #include <arpa/inet.h>
655 dnl CURL_CHECK_NI_WITHSCOPEID
656 dnl -------------------------------------------------
657 dnl Check for working NI_WITHSCOPEID in getnameinfo()
659 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
660 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
661 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
662 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
663 netdb.h netinet/in.h arpa/inet.h)
665 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
666 [ac_cv_working_ni_withscopeid], [
672 #ifdef HAVE_SYS_TYPES_H
673 #include <sys/types.h>
675 #ifdef HAVE_SYS_SOCKET_H
676 #include <sys/socket.h>
681 #ifdef HAVE_NETINET_IN_H
682 #include <netinet/in.h>
684 #ifdef HAVE_ARPA_INET_H
685 #include <arpa/inet.h>
688 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
689 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
690 struct sockaddr_storage sa;
692 unsigned char sa[256];
694 char hostbuf[NI_MAXHOST];
696 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
697 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
698 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
699 int fd = socket(AF_INET6, SOCK_STREAM, 0);
702 return 1; /* Error creating socket */
704 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
706 perror("getsockname()");
707 return 2; /* Error retrieving socket name */
709 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
711 printf("rc = %s\n", gai_strerror(rc));
712 return 3; /* Error translating socket address */
714 return 0; /* Ok, NI_WITHSCOPEID works */
716 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
718 ]]) # AC_LANG_PROGRAM
720 # Exit code == 0. Program worked.
721 ac_cv_working_ni_withscopeid="yes"
723 # Exit code != 0. Program failed.
724 ac_cv_working_ni_withscopeid="no"
726 # Program is not run when cross-compiling. So we assume
727 # NI_WITHSCOPEID will work if we are able to compile it.
730 #include <sys/types.h>
731 #include <sys/socket.h>
734 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
737 ac_cv_working_ni_withscopeid="yes"
739 ac_cv_working_ni_withscopeid="no"
740 ]) # AC_COMPILE_IFELSE
743 case "$ac_cv_working_ni_withscopeid" in
745 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
746 [Define to 1 if NI_WITHSCOPEID exists and works.])
752 dnl CURL_CHECK_FUNC_RECV
753 dnl -------------------------------------------------
754 dnl Test if the socket recv() function is available,
755 dnl and check its return type and the types of its
756 dnl arguments. If the function succeeds HAVE_RECV
757 dnl will be defined, defining the types of the arguments
758 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
759 dnl and RECV_TYPE_ARG4, defining the type of the function
760 dnl return value in RECV_TYPE_RETV.
762 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
763 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
764 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
765 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
767 AC_MSG_CHECKING([for recv])
771 #ifdef HAVE_WINDOWS_H
772 #ifndef WIN32_LEAN_AND_MEAN
773 #define WIN32_LEAN_AND_MEAN
776 #ifdef HAVE_WINSOCK2_H
777 #include <winsock2.h>
779 #ifdef HAVE_WINSOCK_H
784 #ifdef HAVE_SYS_TYPES_H
785 #include <sys/types.h>
787 #ifdef HAVE_SYS_SOCKET_H
788 #include <sys/socket.h>
802 if test "$curl_cv_recv" = "yes"; then
803 AC_CACHE_CHECK([types of args and return type for recv],
804 [curl_cv_func_recv_args], [
805 curl_cv_func_recv_args="unknown"
806 for recv_retv in 'int' 'ssize_t'; do
807 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
808 for recv_arg2 in 'char *' 'void *'; do
809 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
810 for recv_arg4 in 'int' 'unsigned int'; do
811 if test "$curl_cv_func_recv_args" = "unknown"; then
815 #ifdef HAVE_WINDOWS_H
816 #ifndef WIN32_LEAN_AND_MEAN
817 #define WIN32_LEAN_AND_MEAN
820 #ifdef HAVE_WINSOCK2_H
821 #include <winsock2.h>
823 #ifdef HAVE_WINSOCK_H
827 #define RECVCALLCONV PASCAL
829 #ifdef HAVE_SYS_TYPES_H
830 #include <sys/types.h>
832 #ifdef HAVE_SYS_SOCKET_H
833 #include <sys/socket.h>
837 extern $recv_retv RECVCALLCONV
838 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
844 $recv_retv res = recv(s, buf, len, flags);
847 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
856 if test "$curl_cv_func_recv_args" = "unknown"; then
857 AC_MSG_ERROR([Cannot find proper types to use for recv args])
859 recv_prev_IFS=$IFS; IFS=','
860 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
864 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
865 [Define to the type of arg 1 for recv.])
866 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
867 [Define to the type of arg 2 for recv.])
868 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
869 [Define to the type of arg 3 for recv.])
870 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
871 [Define to the type of arg 4 for recv.])
872 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
873 [Define to the function return type for recv.])
875 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
876 [Define to 1 if you have the recv function.])
877 ac_cv_func_recv="yes"
880 AC_MSG_ERROR([Unable to link function recv])
885 dnl CURL_CHECK_FUNC_SEND
886 dnl -------------------------------------------------
887 dnl Test if the socket send() function is available,
888 dnl and check its return type and the types of its
889 dnl arguments. If the function succeeds HAVE_SEND
890 dnl will be defined, defining the types of the arguments
891 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
892 dnl and SEND_TYPE_ARG4, defining the type of the function
893 dnl return value in SEND_TYPE_RETV, and also defining the
894 dnl type qualifier of second argument in SEND_QUAL_ARG2.
896 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
897 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
898 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
899 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
901 AC_MSG_CHECKING([for send])
905 #ifdef HAVE_WINDOWS_H
906 #ifndef WIN32_LEAN_AND_MEAN
907 #define WIN32_LEAN_AND_MEAN
910 #ifdef HAVE_WINSOCK2_H
911 #include <winsock2.h>
913 #ifdef HAVE_WINSOCK_H
918 #ifdef HAVE_SYS_TYPES_H
919 #include <sys/types.h>
921 #ifdef HAVE_SYS_SOCKET_H
922 #include <sys/socket.h>
936 if test "$curl_cv_send" = "yes"; then
937 AC_CACHE_CHECK([types of args and return type for send],
938 [curl_cv_func_send_args], [
939 curl_cv_func_send_args="unknown"
940 for send_retv in 'int' 'ssize_t'; do
941 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
942 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
943 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
944 for send_arg4 in 'int' 'unsigned int'; do
945 if test "$curl_cv_func_send_args" = "unknown"; then
949 #ifdef HAVE_WINDOWS_H
950 #ifndef WIN32_LEAN_AND_MEAN
951 #define WIN32_LEAN_AND_MEAN
954 #ifdef HAVE_WINSOCK2_H
955 #include <winsock2.h>
957 #ifdef HAVE_WINSOCK_H
961 #define SENDCALLCONV PASCAL
963 #ifdef HAVE_SYS_TYPES_H
964 #include <sys/types.h>
966 #ifdef HAVE_SYS_SOCKET_H
967 #include <sys/socket.h>
971 extern $send_retv SENDCALLCONV
972 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
977 $send_retv res = send(s, 0, len, flags);
980 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
989 if test "$curl_cv_func_send_args" = "unknown"; then
990 AC_MSG_ERROR([Cannot find proper types to use for send args])
992 send_prev_IFS=$IFS; IFS=','
993 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
997 send_qual_type_arg2=$[2]
999 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1000 [Define to the type of arg 1 for send.])
1001 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1002 [Define to the type of arg 3 for send.])
1003 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1004 [Define to the type of arg 4 for send.])
1005 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1006 [Define to the function return type for send.])
1010 case $prev_sh_opts in
1018 case "$send_qual_type_arg2" in
1020 send_qual_arg2=const
1021 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1025 send_type_arg2=$send_qual_type_arg2
1029 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1030 [Define to the type qualifier of arg 2 for send.])
1031 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1032 [Define to the type of arg 2 for send.])
1034 case $prev_sh_opts in
1042 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1043 [Define to 1 if you have the send function.])
1044 ac_cv_func_send="yes"
1047 AC_MSG_ERROR([Unable to link function send])
1052 dnl CURL_CHECK_MSG_NOSIGNAL
1053 dnl -------------------------------------------------
1054 dnl Check for MSG_NOSIGNAL
1056 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1057 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1058 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1062 #ifdef HAVE_WINDOWS_H
1063 #ifndef WIN32_LEAN_AND_MEAN
1064 #define WIN32_LEAN_AND_MEAN
1066 #include <windows.h>
1067 #ifdef HAVE_WINSOCK2_H
1068 #include <winsock2.h>
1070 #ifdef HAVE_WINSOCK_H
1071 #include <winsock.h>
1075 #ifdef HAVE_SYS_TYPES_H
1076 #include <sys/types.h>
1078 #ifdef HAVE_SYS_SOCKET_H
1079 #include <sys/socket.h>
1083 int flag=MSG_NOSIGNAL;
1086 ac_cv_msg_nosignal="yes"
1088 ac_cv_msg_nosignal="no"
1091 case "$ac_cv_msg_nosignal" in
1093 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1094 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1100 dnl CURL_CHECK_STRUCT_TIMEVAL
1101 dnl -------------------------------------------------
1102 dnl Check for timeval struct
1104 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1105 AC_REQUIRE([AC_HEADER_TIME])dnl
1106 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1107 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1108 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1109 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1113 #ifdef HAVE_WINDOWS_H
1114 #ifndef WIN32_LEAN_AND_MEAN
1115 #define WIN32_LEAN_AND_MEAN
1117 #include <windows.h>
1118 #ifdef HAVE_WINSOCK2_H
1119 #include <winsock2.h>
1121 #ifdef HAVE_WINSOCK_H
1122 #include <winsock.h>
1126 #ifdef HAVE_SYS_TYPES_H
1127 #include <sys/types.h>
1129 #ifdef HAVE_SYS_TIME_H
1130 #include <sys/time.h>
1131 #ifdef TIME_WITH_SYS_TIME
1145 ac_cv_struct_timeval="yes"
1147 ac_cv_struct_timeval="no"
1150 case "$ac_cv_struct_timeval" in
1152 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1153 [Define to 1 if you have the timeval struct.])
1159 dnl TYPE_SIG_ATOMIC_T
1160 dnl -------------------------------------------------
1161 dnl Check if the sig_atomic_t type is available, and
1162 dnl verify if it is already defined as volatile.
1164 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1165 AC_CHECK_HEADERS(signal.h)
1166 AC_CHECK_TYPE([sig_atomic_t],[
1167 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1168 [Define to 1 if sig_atomic_t is an available typedef.])
1170 #ifdef HAVE_SIGNAL_H
1174 case "$ac_cv_type_sig_atomic_t" in
1177 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1180 #ifdef HAVE_SIGNAL_H
1184 static volatile sig_atomic_t dummy = 0;
1188 ac_cv_sig_atomic_t_volatile="no"
1190 AC_MSG_RESULT([yes])
1191 ac_cv_sig_atomic_t_volatile="yes"
1194 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1195 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1196 [Define to 1 if sig_atomic_t is already defined as volatile.])
1203 dnl CURL_CHECK_NONBLOCKING_SOCKET
1204 dnl -------------------------------------------------
1205 dnl Check for how to set a socket to non-blocking state. There seems to exist
1206 dnl four known different ways, with the one used almost everywhere being POSIX
1207 dnl and XPG3, while the other different ways for different systems (old BSD,
1208 dnl Windows and Amiga).
1210 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
1211 dnl O_NONBLOCK define is found but does not work. This condition is attempted
1212 dnl to get caught in this script by using an excessive number of #ifdefs...
1214 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [
1215 AC_MSG_CHECKING([non-blocking sockets style])
1220 /* headers for O_NONBLOCK test */
1221 #include <sys/types.h>
1225 #if defined(sun) || defined(__sun__) || \
1226 defined(__SUNPRO_C) || defined(__SUNPRO_CC)
1227 # if defined(__SVR4) || defined(__srv4__)
1228 # define PLATFORM_SOLARIS
1230 # define PLATFORM_SUNOS4
1233 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
1234 # define PLATFORM_AIX_V3
1237 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
1238 #error "O_NONBLOCK does not work on this platform"
1241 /* O_NONBLOCK source test */
1243 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
1246 dnl the O_NONBLOCK test was fine
1247 nonblock="O_NONBLOCK"
1248 AC_DEFINE(HAVE_O_NONBLOCK, 1,
1249 [use O_NONBLOCK for non-blocking sockets])
1252 if test "$nonblock" = "unknown"; then
1255 /* headers for FIONBIO test */
1257 #include <stropts.h>
1259 /* FIONBIO source test (old-style unix) */
1261 int flags = ioctl(socket, FIONBIO, &flags);
1264 dnl FIONBIO test was good
1266 AC_DEFINE(HAVE_FIONBIO, 1,
1267 [use FIONBIO for non-blocking sockets])
1271 if test "$nonblock" = "unknown"; then
1274 /* headers for ioctlsocket test (Windows) */
1276 #ifdef HAVE_WINDOWS_H
1277 #ifndef WIN32_LEAN_AND_MEAN
1278 #define WIN32_LEAN_AND_MEAN
1280 #include <windows.h>
1281 #ifdef HAVE_WINSOCK2_H
1282 #include <winsock2.h>
1284 #ifdef HAVE_WINSOCK_H
1285 #include <winsock.h>
1290 /* ioctlsocket source code (Windows) */
1292 unsigned long flags = 0;
1293 sd = socket(0, 0, 0);
1294 ioctlsocket(sd, FIONBIO, &flags);
1297 dnl ioctlsocket test was good
1298 nonblock="ioctlsocket"
1299 AC_DEFINE(HAVE_IOCTLSOCKET, 1,
1300 [use ioctlsocket() for non-blocking sockets])
1304 if test "$nonblock" = "unknown"; then
1307 /* headers for IoctlSocket test (Amiga?) */
1308 #include <sys/ioctl.h>
1310 /* IoctlSocket source code (Amiga?) */
1312 int flags = IoctlSocket(socket, FIONBIO, (long)1);
1315 dnl Ioctlsocket test was good
1316 nonblock="IoctlSocket"
1317 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1,
1318 [use Ioctlsocket() for non-blocking sockets])
1322 if test "$nonblock" = "unknown"; then
1325 /* headers for SO_NONBLOCK test (BeOS) */
1328 /* SO_NONBLOCK source code (BeOS) */
1331 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
1334 dnl the SO_NONBLOCK test was good
1335 nonblock="SO_NONBLOCK"
1336 AC_DEFINE(HAVE_SO_NONBLOCK, 1,
1337 [use SO_NONBLOCK for non-blocking sockets])
1341 AC_MSG_RESULT($nonblock)
1343 if test "$nonblock" = "unknown"; then
1344 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1,
1345 [disabled non-blocking sockets])
1346 AC_MSG_WARN([non-block sockets disabled])
1352 dnl -------------------------------------------------
1353 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1354 dnl and a few other things.
1356 AC_DEFUN([TYPE_IN_ADDR_T], [
1357 AC_CHECK_TYPE([in_addr_t], ,[
1358 dnl in_addr_t not available
1359 AC_CACHE_CHECK([for in_addr_t equivalent],
1360 [curl_cv_in_addr_t_equiv], [
1361 curl_cv_in_addr_t_equiv="unknown"
1362 for t in "unsigned long" int size_t unsigned long; do
1363 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
1367 #ifdef HAVE_WINDOWS_H
1368 #ifndef WIN32_LEAN_AND_MEAN
1369 #define WIN32_LEAN_AND_MEAN
1371 #include <windows.h>
1372 #ifdef HAVE_WINSOCK2_H
1373 #include <winsock2.h>
1375 #ifdef HAVE_WINSOCK_H
1376 #include <winsock.h>
1380 #ifdef HAVE_SYS_TYPES_H
1381 #include <sys/types.h>
1383 #ifdef HAVE_SYS_SOCKET_H
1384 #include <sys/socket.h>
1386 #ifdef HAVE_NETINET_IN_H
1387 #include <netinet/in.h>
1389 #ifdef HAVE_ARPA_INET_H
1390 #include <arpa/inet.h>
1394 $t data = inet_addr ("1.2.3.4");
1397 curl_cv_in_addr_t_equiv="$t"
1402 case "$curl_cv_in_addr_t_equiv" in
1404 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1407 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1408 [Type to use in place of in_addr_t when system does not provide it.])
1413 #ifdef HAVE_WINDOWS_H
1414 #ifndef WIN32_LEAN_AND_MEAN
1415 #define WIN32_LEAN_AND_MEAN
1417 #include <windows.h>
1418 #ifdef HAVE_WINSOCK2_H
1419 #include <winsock2.h>
1421 #ifdef HAVE_WINSOCK_H
1422 #include <winsock.h>
1426 #ifdef HAVE_SYS_TYPES_H
1427 #include <sys/types.h>
1429 #ifdef HAVE_SYS_SOCKET_H
1430 #include <sys/socket.h>
1432 #ifdef HAVE_NETINET_IN_H
1433 #include <netinet/in.h>
1435 #ifdef HAVE_ARPA_INET_H
1436 #include <arpa/inet.h>
1439 ]) dnl AC_CHECK_TYPE
1443 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1444 dnl -------------------------------------------------
1445 dnl Check if monotonic clock_gettime is available.
1447 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1448 AC_REQUIRE([AC_HEADER_TIME])dnl
1449 AC_CHECK_HEADERS(sys/types.h unistd.h sys/time.h time.h)
1450 AC_MSG_CHECKING([for monotonic clock_gettime])
1453 #ifdef HAVE_SYS_TYPES_H
1454 #include <sys/types.h>
1456 #ifdef HAVE_UNISTD_H
1459 #ifdef HAVE_SYS_TIME_H
1460 #include <sys/time.h>
1461 #ifdef TIME_WITH_SYS_TIME
1470 #if defined(_POSIX_MONOTONIC_CLOCK) && (_POSIX_MONOTONIC_CLOCK > 0)
1472 The monotonic clock will not be used unless the feature test macro is
1473 defined with a value greater than zero indicating _always_ supported.
1476 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1478 HAVE_CLOCK_GETTIME_MONOTONIC shall not be defined.
1482 AC_MSG_RESULT([yes])
1483 ac_cv_func_clock_gettime="yes"
1486 ac_cv_func_clock_gettime="no"
1488 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally
1489 dnl postponed until library linking checks for clock_gettime pass.
1493 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1494 dnl -------------------------------------------------
1495 dnl If monotonic clock_gettime is available then,
1496 dnl check and prepended to LIBS any needed libraries.
1498 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
1499 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
1501 if test "$ac_cv_func_clock_gettime" = "yes"; then
1503 AC_MSG_CHECKING([for clock_gettime in libraries])
1505 curl_cv_save_LIBS="$LIBS"
1506 curl_cv_gclk_LIBS="unknown"
1508 for x_xlibs in '' '-lrt' '-lposix4' ; do
1509 if test "$curl_cv_gclk_LIBS" = "unknown"; then
1510 if test -z "$x_xlibs"; then
1511 LIBS="$curl_cv_save_LIBS"
1513 LIBS="$x_xlibs $curl_cv_save_LIBS"
1517 #ifdef HAVE_SYS_TYPES_H
1518 #include <sys/types.h>
1520 #ifdef HAVE_UNISTD_H
1523 #ifdef HAVE_SYS_TIME_H
1524 #include <sys/time.h>
1525 #ifdef TIME_WITH_SYS_TIME
1535 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1538 curl_cv_gclk_LIBS="$x_xlibs"
1543 LIBS="$curl_cv_save_LIBS"
1545 case X-"$curl_cv_gclk_LIBS" in
1547 AC_MSG_RESULT([cannot find clock_gettime])
1548 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1549 ac_cv_func_clock_gettime="no"
1552 AC_MSG_RESULT([no additional lib required])
1553 ac_cv_func_clock_gettime="yes"
1556 if test -z "$curl_cv_save_LIBS"; then
1557 LIBS="$curl_cv_gclk_LIBS"
1559 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
1561 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
1562 ac_cv_func_clock_gettime="yes"
1566 dnl only do runtime verification when not cross-compiling
1567 if test "x$cross_compiling" != "xyes" &&
1568 test "$ac_cv_func_clock_gettime" = "yes"; then
1569 AC_MSG_CHECKING([if monotonic clock_gettime works])
1572 #ifdef HAVE_SYS_TYPES_H
1573 #include <sys/types.h>
1575 #ifdef HAVE_UNISTD_H
1578 #ifdef HAVE_SYS_TIME_H
1579 #include <sys/time.h>
1580 #ifdef TIME_WITH_SYS_TIME
1589 #if defined(_POSIX_MONOTONIC_CLOCK) && (_POSIX_MONOTONIC_CLOCK > 0)
1591 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
1597 AC_MSG_RESULT([yes])
1600 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1601 ac_cv_func_clock_gettime="no"
1602 LIBS="$curl_cv_save_LIBS"
1606 case "$ac_cv_func_clock_gettime" in
1608 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
1609 [Define to 1 if you have the clock_gettime function and monotonic timer.])
1618 dnl **********************************************************************
1619 dnl CURL_DETECT_ICC ([ACTION-IF-YES])
1621 dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
1622 dnl sets the $ICC variable to "yes" or "no"
1623 dnl **********************************************************************
1624 AC_DEFUN([CURL_DETECT_ICC],
1627 AC_MSG_CHECKING([for icc in use])
1628 if test "$GCC" = "yes"; then
1629 dnl check if this is icc acting as gcc in disguise
1630 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
1631 dnl action if the text is found, this it has not been replaced by the
1634 dnl the text was not found, it was replaced by the cpp
1636 AC_MSG_RESULT([yes])
1640 if test "$ICC" = "no"; then
1646 dnl We create a function for detecting which compiler we use and then set as
1647 dnl pendantic compiler options as possible for that particular compiler. The
1648 dnl options are only used for debug-builds.
1650 dnl This is a copy of the original found in curl's configure script. Don't
1651 dnl modify this one, edit the one in curl and copy it back here when that one
1654 AC_DEFUN([CURL_CC_DEBUG_OPTS],
1656 if test "z$ICC" = "z"; then
1660 if test "$GCC" = "yes"; then
1662 dnl figure out gcc version!
1663 AC_MSG_CHECKING([gcc version])
1664 gccver=`$CC -dumpversion`
1665 num1=`echo $gccver | cut -d . -f1`
1666 num2=`echo $gccver | cut -d . -f2`
1667 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
1668 AC_MSG_RESULT($gccver)
1670 if test "$ICC" = "yes"; then
1671 dnl this is icc, not gcc.
1673 dnl ICC warnings we ignore:
1674 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
1675 dnl "invalid format string conversion"
1676 dnl * 279 warns on static conditions in while expressions
1677 dnl * 981 warns on "operands are evaluated in unspecified order"
1678 dnl * 1418 "external definition with no prior declaration"
1679 dnl * 1419 warns on "external declaration in primary source file"
1680 dnl which we know and do on purpose.
1682 WARN="-wd279,269,981,1418,1419"
1684 if test "$gccnum" -gt "600"; then
1685 dnl icc 6.0 and older doesn't have the -Wall flag
1689 dnl this is a set of options we believe *ALL* gcc versions support:
1690 WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
1692 dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
1694 if test "$gccnum" -ge "207"; then
1695 dnl gcc 2.7 or later
1696 WARN="$WARN -Wmissing-declarations"
1699 if test "$gccnum" -gt "295"; then
1700 dnl only if the compiler is newer than 2.95 since we got lots of
1701 dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
1702 dnl gcc 2.95.4 on FreeBSD 4.9!
1703 WARN="$WARN -Wundef -Wno-long-long -Wsign-compare -Wshadow -Wno-multichar"
1706 if test "$gccnum" -ge "296"; then
1707 dnl gcc 2.96 or later
1708 WARN="$WARN -Wfloat-equal"
1711 if test "$gccnum" -gt "296"; then
1712 dnl this option does not exist in 2.96
1713 WARN="$WARN -Wno-format-nonliteral"
1716 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
1717 dnl on i686-Linux as it gives us heaps with false positives.
1718 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
1719 dnl over making it unusable for generic purposes. Let's not use it.
1721 if test "$gccnum" -ge "303"; then
1722 dnl gcc 3.3 and later
1723 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
1726 if test "$gccnum" -ge "304"; then
1727 # try these on gcc 3.4
1728 WARN="$WARN -Wdeclaration-after-statement"
1731 for flag in $CPPFLAGS; do
1734 dnl Include path, provide a -isystem option for the same dir
1735 dnl to prevent warnings in those dirs. The -isystem was not very
1736 dnl reliable on earlier gcc versions.
1737 add=`echo $flag | sed 's/^-I/-isystem /g'`
1745 CFLAGS="$CFLAGS $WARN"
1747 AC_MSG_NOTICE([Added this set of compiler options: $WARN])
1751 AC_MSG_NOTICE([Added no extra compiler options])
1755 dnl strip off optimizer flags
1757 for flag in $CFLAGS; do
1760 dnl echo "cut off $flag"
1763 NEWFLAGS="$NEWFLAGS $flag"
1769 ]) dnl end of AC_DEFUN()
1772 dnl This macro determines if the specified struct exists in the specified file
1774 dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
1776 AC_DEFUN([CARES_CHECK_STRUCT], [
1777 AC_MSG_CHECKING([for struct $2])
1778 AC_TRY_COMPILE([$1],
1780 struct $2 struct_instance;
1781 ], ac_struct="yes", ac_found="no")
1782 if test "$ac_struct" = "yes" ; then
1791 dnl This macro determines if the specified constant exists in the specified file
1793 dnl CARES_CHECK_CONSTANT(headers, constant name, if found, [if not found])
1795 AC_DEFUN([CARES_CHECK_CONSTANT], [
1796 AC_MSG_CHECKING([for $2])
1797 AC_EGREP_CPP(VARIABLEWASDEFINED,
1806 ], ac_constant="yes", ac_constant="no"
1808 if test "$ac_constant" = "yes" ; then
1818 dnl CARES_CHECK_GETSERVBYPORT_R
1819 dnl -------------------------------------------------
1820 dnl Test if the getservbyport_r function is available,
1821 dnl and find out how many parameters it takes.
1823 AC_DEFUN([CARES_CHECK_GETSERVBYPORT_R], [
1824 AC_MSG_CHECKING([how many arguments getservbyport_r takes])
1825 ac_func_getservbyport_r="unknown"
1833 struct servent *p3, *p6;
1834 getservbyport_r(p1, p2, p3, p4, p5, &p6);
1837 ac_func_getservbyport_r="6"
1840 if test "$ac_func_getservbyport_r" = "unknown"; then
1848 getservbyport_r(p1, p2, p3, p4, p5);
1851 ac_func_getservbyport_r="5"
1855 if test "$ac_func_getservbyport_r" = "unknown"; then
1863 struct servent_data p4;
1864 getservbyport_r(p1, p2, p3, &p4);
1867 ac_func_getservbyport_r="4"
1871 if test "$ac_func_getservbyport_r" = "unknown"; then
1872 AC_MSG_RESULT([not found])
1874 AC_MSG_RESULT($ac_func_getservbyport_r)
1875 AC_DEFINE(HAVE_GETSERVBYPORT_R, 1,
1876 [Specifies whether getservbyport_r is present])
1877 AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $ac_func_getservbyport_r,
1878 [Specifies the number of arguments to getservbyport_r])
1879 if test "$ac_func_getservbyport_r" = "4" ; then
1880 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data),
1881 [Specifies the size of the buffer to pass to getservbyport_r])
1883 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096,
1884 [Specifies the size of the buffer to pass to getservbyport_r])