3 dnl CURL_CHECK_HEADER_WINDOWS
4 dnl -------------------------------------------------
5 dnl Check for compilable and valid windows.h header
7 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
8 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
12 #define WIN32_LEAN_AND_MEAN
18 ac_cv_header_windows_h="yes"
20 ac_cv_header_windows_h="no"
23 if test "x$ac_cv_header_windows_h" = "xyes"; then
24 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
25 [Define to 1 if you have the windows.h header file.])
26 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
27 [Define to avoid automatic inclusion of winsock.h])
32 dnl CURL_CHECK_HEADER_WINSOCK
33 dnl -------------------------------------------------
34 dnl Check for compilable and valid winsock.h header
36 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
37 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
38 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
42 #define WIN32_LEAN_AND_MEAN
46 int dummy=WSACleanup();
49 ac_cv_header_winsock_h="yes"
51 ac_cv_header_winsock_h="no"
54 if test "x$ac_cv_header_winsock_h" = "xyes"; then
55 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
56 [Define to 1 if you have the winsock.h header file.])
61 dnl CURL_CHECK_HEADER_WINSOCK2
62 dnl -------------------------------------------------
63 dnl Check for compilable and valid winsock2.h header
65 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
66 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
67 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
71 #define WIN32_LEAN_AND_MEAN
75 int dummy=2*IPPROTO_ESP;
78 ac_cv_header_winsock2_h="yes"
80 ac_cv_header_winsock2_h="no"
83 if test "x$ac_cv_header_winsock2_h" = "xyes"; then
84 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
85 [Define to 1 if you have the winsock2.h header file.])
90 dnl CURL_CHECK_HEADER_WS2TCPIP
91 dnl -------------------------------------------------
92 dnl Check for compilable and valid ws2tcpip.h header
94 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
95 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
96 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
100 #define WIN32_LEAN_AND_MEAN
102 #include <winsock2.h>
103 #include <ws2tcpip.h>
105 int dummy=2*IP_PKTINFO;
108 ac_cv_header_ws2tcpip_h="yes"
110 ac_cv_header_ws2tcpip_h="no"
113 if test "x$ac_cv_header_ws2tcpip_h" = "xyes"; then
114 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
115 [Define to 1 if you have the ws2tcpip.h header file.])
120 dnl CURL_CHECK_TYPE_SOCKLEN_T
121 dnl -------------------------------------------------
122 dnl Check for existing socklen_t type, and provide
123 dnl an equivalent type if socklen_t not available
125 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
126 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
127 AC_CHECK_TYPE([socklen_t], ,[
128 AC_CACHE_CHECK([for socklen_t equivalent],
129 [curl_cv_socklen_t_equiv], [
130 curl_cv_socklen_t_equiv="unknown"
131 for arg2 in "struct sockaddr" void; do
132 for t in int size_t unsigned long "unsigned long"; do
136 #ifdef HAVE_WINDOWS_H
137 #define WIN32_LEAN_AND_MEAN
139 #ifdef HAVE_WINSOCK2_H
140 #include <winsock2.h>
142 #ifdef HAVE_WINSOCK_H
147 #ifdef HAVE_SYS_TYPES_H
148 #include <sys/types.h>
150 #ifdef HAVE_SYS_SOCKET_H
151 #include <sys/socket.h>
154 int getpeername (int, $arg2 *, $t *);
157 getpeername(0,0,&len);
160 curl_cv_socklen_t_equiv="$t"
166 if test "$curl_cv_socklen_t_equiv" = "unknown"; then
167 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
169 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
170 [type to use in place of socklen_t if not defined])
173 #ifdef HAVE_WINDOWS_H
174 #ifdef HAVE_WS2TCPIP_H
175 #include <ws2tcpip.h>
178 #ifdef HAVE_SYS_TYPES_H
179 #include <sys/types.h>
181 #ifdef HAVE_SYS_SOCKET_H
182 #include <sys/socket.h>
189 dnl CURL_FUNC_GETNAMEINFO_ARGTYPES
190 dnl -------------------------------------------------
191 dnl Check the type to be passed to five of the arguments
192 dnl of getnameinfo function, and define those types in
193 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
194 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7.
195 dnl This function is experimental and its results shall
196 dnl not be trusted while this notice is in place ------
198 AC_DEFUN([CURL_FUNC_GETNAMEINFO_ARGTYPES], [
199 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
200 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
201 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
202 AC_CACHE_CHECK([types of arguments for getnameinfo],
203 [curl_cv_func_getnameinfo_args], [
204 curl_cv_func_getnameinfo_args="unknown"
205 for gni_arg1 in 'struct sockaddr *' 'void *'; do
206 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
207 for gni_arg46 in 'size_t' 'int' 'socklen_t'; do
208 for gni_arg7 in 'int' 'unsigned int'; do
212 #ifdef HAVE_WINDOWS_H
213 #define WIN32_LEAN_AND_MEAN
215 #ifdef HAVE_WINSOCK2_H
216 #include <winsock2.h>
218 #ifdef HAVE_WS2TCPIP_H
219 #include <ws2tcpip.h>
222 #ifdef HAVE_SYS_TYPES_H
223 #include <sys/types.h>
225 #ifdef HAVE_SYS_SOCKET_H
226 #include <sys/socket.h>
232 extern int getnameinfo($gni_arg1, $gni_arg2,
240 $gni_arg46 hostlen=0;
242 $gni_arg46 servlen=0;
244 getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
247 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
255 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
256 AC_MSG_ERROR([Cannot find proper types to use for getnameinfo args])
258 gni_prev_IFS=$IFS; IFS=','
259 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
262 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $[1],
263 [Define to the type of arg 1 for `getnameinfo'.])
264 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
265 [Define to the type of arg 2 for `getnameinfo'.])
266 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
267 [Define to the type of args 4 and 6 for `getnameinfo'.])
268 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
269 [Define to the type of arg 7 for `getnameinfo'.])
274 dnl Check for how to set a socket to non-blocking state. There seems to exist
275 dnl four known different ways, with the one used almost everywhere being POSIX
276 dnl and XPG3, while the other different ways for different systems (old BSD,
277 dnl Windows and Amiga).
279 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
280 dnl O_NONBLOCK define is found but does not work. This condition is attempted
281 dnl to get caught in this script by using an excessive number of #ifdefs...
283 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET],
285 AC_MSG_CHECKING([non-blocking sockets style])
288 /* headers for O_NONBLOCK test */
289 #include <sys/types.h>
293 /* try to compile O_NONBLOCK */
295 #if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
296 # if defined(__SVR4) || defined(__srv4__)
297 # define PLATFORM_SOLARIS
299 # define PLATFORM_SUNOS4
302 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX4)
303 # define PLATFORM_AIX_V3
306 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
307 #error "O_NONBLOCK does not work on this platform"
310 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
312 dnl the O_NONBLOCK test was fine
313 nonblock="O_NONBLOCK"
314 AC_DEFINE(HAVE_O_NONBLOCK, 1, [use O_NONBLOCK for non-blocking sockets])
316 dnl the code was bad, try a different program now, test 2
319 /* headers for FIONBIO test */
323 /* FIONBIO source test (old-style unix) */
325 int flags = ioctl(socket, FIONBIO, &flags);
327 dnl FIONBIO test was good
329 AC_DEFINE(HAVE_FIONBIO, 1, [use FIONBIO for non-blocking sockets])
331 dnl FIONBIO test was also bad
332 dnl the code was bad, try a different program now, test 3
335 /* headers for ioctlsocket test (cygwin?) */
338 /* ioctlsocket source code */
340 unsigned long flags = ioctlsocket(socket, FIONBIO, &flags);
342 dnl ioctlsocket test was good
343 nonblock="ioctlsocket"
344 AC_DEFINE(HAVE_IOCTLSOCKET, 1, [use ioctlsocket() for non-blocking sockets])
346 dnl ioctlsocket didnt compile!, go to test 4
349 /* headers for IoctlSocket test (Amiga?) */
350 #include <sys/ioctl.h>
352 /* IoctlSocket source code */
354 int flags = IoctlSocket(socket, FIONBIO, (long)1);
356 dnl ioctlsocket test was good
357 nonblock="IoctlSocket"
358 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, [use Ioctlsocket() for non-blocking sockets])
360 dnl Ioctlsocket didnt compile, do test 5!
362 /* headers for SO_NONBLOCK test (BeOS) */
365 /* SO_NONBLOCK source code */
368 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
370 dnl the SO_NONBLOCK test was good
371 nonblock="SO_NONBLOCK"
372 AC_DEFINE(HAVE_SO_NONBLOCK, 1, [use SO_NONBLOCK for non-blocking sockets])
374 dnl test 5 didnt compile!
376 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, [disabled non-blocking sockets])
378 dnl end of fifth test
381 dnl end of forth test
384 dnl end of third test
387 dnl end of second test
390 dnl end of non-blocking try-compile test
391 AC_MSG_RESULT($nonblock)
393 if test "$nonblock" = "nada"; then
394 AC_MSG_WARN([non-block sockets disabled])
398 dnl We create a function for detecting which compiler we use and then set as
399 dnl pendantic compiler options as possible for that particular compiler. The
400 dnl options are only used for debug-builds.
402 dnl This is a copy of the original found in curl's configure script. Don't
403 dnl modify this one, edit the one in curl and copy it back here when that one
406 AC_DEFUN([CURL_CC_DEBUG_OPTS],
408 if test "$GCC" = "yes"; then
410 dnl figure out gcc version!
411 AC_MSG_CHECKING([gcc version])
412 gccver=`$CC -dumpversion`
413 num1=`echo $gccver | cut -d . -f1`
414 num2=`echo $gccver | cut -d . -f2`
415 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
416 AC_MSG_RESULT($gccver)
418 AC_MSG_CHECKING([if this is icc in disguise])
419 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
420 dnl action if the text is found, this it has not been replaced by the
424 dnl the text was not found, it was replaced by the cpp
429 if test "$ICC" = "yes"; then
430 dnl this is icc, not gcc.
432 dnl ICC warnings we ignore:
433 dnl * 279 warns on static conditions in while expressions
434 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
435 dnl "invalid format string conversion"
439 if test "$gccnum" -gt "600"; then
440 dnl icc 6.0 and older doesn't have the -Wall flag
445 WARN="-W -Wall -Wwrite-strings -pedantic -Wno-long-long -Wundef -Wpointer-arith -Wnested-externs -Winline -Wmissing-declarations -Wmissing-prototypes -Wsign-compare"
447 dnl -Wcast-align is a bit too annoying ;-)
449 if test "$gccnum" -ge "296"; then
450 dnl gcc 2.96 or later
451 WARN="$WARN -Wfloat-equal"
453 if test "$gccnum" -gt "296"; then
454 dnl this option does not exist in 2.96
455 WARN="$WARN -Wno-format-nonliteral"
458 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
459 dnl on i686-Linux as it gives us heaps with false positives
460 if test "$gccnum" -ge "303"; then
461 dnl gcc 3.3 and later
462 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
466 for flag in $CPPFLAGS; do
470 add=`echo $flag | sed 's/^-I/-isystem /g'`
478 CFLAGS="$CFLAGS $WARN"
482 dnl strip off optimizer flags
484 for flag in $CFLAGS; do
487 dnl echo "cut off $flag"
490 NEWFLAGS="$NEWFLAGS $flag"
496 ]) dnl end of AC_DEFUN()
499 dnl This macro determines if the specified struct exists in the specified file
501 dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
503 AC_DEFUN([CARES_CHECK_STRUCT], [
504 AC_MSG_CHECKING([for struct $2])
507 struct $2 struct_instance;
508 ], ac_struct="yes", ac_found="no")
509 if test "$ac_struct" = "yes" ; then
518 dnl This macro determines if the specified constant exists in the specified file
520 dnl CARES_CHECK_CONSTANT(headers, constant name, if found, [if not found])
522 AC_DEFUN([CARES_CHECK_CONSTANT], [
523 AC_MSG_CHECKING([for $2])
524 AC_EGREP_CPP(VARIABLEWASDEFINED,
533 ], ac_constant="yes", ac_constant="no"
535 if test "$ac_constant" = "yes" ; then
545 dnl This macro determines how many parameters getservbyport_r takes
546 AC_DEFUN([CARES_CHECK_GETSERVBYPORT_R], [
547 AC_MSG_CHECKING([how many arguments getservbyport_r takes])
549 [#include <netdb.h>],
553 struct servent *p3, *p6;
554 getservbyport_r(p1, p2, p3, p4, p5, &p6);
555 ], ac_func_getservbyport_r=6,
557 [#include <netdb.h>],
562 getservbyport_r(p1, p2, p3, p4, p5);
563 ], ac_func_getservbyport_r=5,
565 [#include <netdb.h>],
570 struct servent_data p4;
571 getservbyport_r(p1, p2, p3, &p4);
572 ], ac_func_getservbyport_r=4, ac_func_getservbyport_r=0
576 if test $ac_func_getservbyport_r != "0" ; then
577 AC_MSG_RESULT($ac_func_getservbyport_r)
578 AC_DEFINE(HAVE_GETSERVBYPORT_R, 1, [Specifies whether getservbyport_r is present])
579 AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $ac_func_getservbyport_r, [Specifies the number of arguments to
581 if test $ac_func_getservbyport_r = "4" ; then
582 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data), [Specifies the size of the buffer to pass to
585 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096, [Specifies the size of the buffer to pass to getservbyport_r])
588 AC_MSG_RESULT([not found])