1 dnl Check for how to set a socket to non-blocking state. There seems to exist
2 dnl four known different ways, with the one used almost everywhere being POSIX
3 dnl and XPG3, while the other different ways for different systems (old BSD,
4 dnl Windows and Amiga).
6 dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
7 dnl O_NONBLOCK define is found but does not work. This condition is attempted
8 dnl to get caught in this script by using an excessive number of #ifdefs...
10 AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET],
12 AC_MSG_CHECKING([non-blocking sockets style])
15 /* headers for O_NONBLOCK test */
16 #include <sys/types.h>
20 /* try to compile O_NONBLOCK */
22 #if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
23 # if defined(__SVR4) || defined(__srv4__)
24 # define PLATFORM_SOLARIS
26 # define PLATFORM_SUNOS4
29 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX4)
30 # define PLATFORM_AIX_V3
33 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
34 #error "O_NONBLOCK does not work on this platform"
37 int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
39 dnl the O_NONBLOCK test was fine
41 AC_DEFINE(HAVE_O_NONBLOCK, 1, [use O_NONBLOCK for non-blocking sockets])
43 dnl the code was bad, try a different program now, test 2
46 /* headers for FIONBIO test */
50 /* FIONBIO source test (old-style unix) */
52 int flags = ioctl(socket, FIONBIO, &flags);
54 dnl FIONBIO test was good
56 AC_DEFINE(HAVE_FIONBIO, 1, [use FIONBIO for non-blocking sockets])
58 dnl FIONBIO test was also bad
59 dnl the code was bad, try a different program now, test 3
62 /* headers for ioctlsocket test (cygwin?) */
65 /* ioctlsocket source code */
67 unsigned long flags = ioctlsocket(socket, FIONBIO, &flags);
69 dnl ioctlsocket test was good
70 nonblock="ioctlsocket"
71 AC_DEFINE(HAVE_IOCTLSOCKET, 1, [use ioctlsocket() for non-blocking sockets])
73 dnl ioctlsocket didnt compile!, go to test 4
76 /* headers for IoctlSocket test (Amiga?) */
77 #include <sys/ioctl.h>
79 /* IoctlSocket source code */
81 int flags = IoctlSocket(socket, FIONBIO, (long)1);
83 dnl ioctlsocket test was good
84 nonblock="IoctlSocket"
85 AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, [use Ioctlsocket() for non-blocking sockets])
87 dnl Ioctlsocket didnt compile, do test 5!
89 /* headers for SO_NONBLOCK test (BeOS) */
92 /* SO_NONBLOCK source code */
95 int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
97 dnl the SO_NONBLOCK test was good
98 nonblock="SO_NONBLOCK"
99 AC_DEFINE(HAVE_SO_NONBLOCK, 1, [use SO_NONBLOCK for non-blocking sockets])
101 dnl test 5 didnt compile!
103 AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, [disabled non-blocking sockets])
105 dnl end of fifth test
108 dnl end of forth test
111 dnl end of third test
114 dnl end of second test
117 dnl end of non-blocking try-compile test
118 AC_MSG_RESULT($nonblock)
120 if test "$nonblock" = "nada"; then
121 AC_MSG_WARN([non-block sockets disabled])
125 dnl We create a function for detecting which compiler we use and then set as
126 dnl pendantic compiler options as possible for that particular compiler. The
127 dnl options are only used for debug-builds.
129 dnl This is a copy of the original found in curl's configure script. Don't
130 dnl modify this one, edit the one in curl and copy it back here when that one
133 AC_DEFUN([CURL_CC_DEBUG_OPTS],
135 if test "$GCC" = "yes"; then
137 dnl figure out gcc version!
138 AC_MSG_CHECKING([gcc version])
139 gccver=`$CC -dumpversion`
140 num1=`echo $gccver | cut -d . -f1`
141 num2=`echo $gccver | cut -d . -f2`
142 gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
143 AC_MSG_RESULT($gccver)
145 AC_MSG_CHECKING([if this is icc in disguise])
146 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
147 dnl action if the text is found, this it has not been replaced by the
151 dnl the text was not found, it was replaced by the cpp
156 if test "$ICC" = "yes"; then
157 dnl this is icc, not gcc.
159 dnl ICC warnings we ignore:
160 dnl * 279 warns on static conditions in while expressions
161 dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
162 dnl "invalid format string conversion"
166 if test "$gccnum" -gt "600"; then
167 dnl icc 6.0 and older doesn't have the -Wall flag
172 WARN="-W -Wall -Wwrite-strings -pedantic -Wno-long-long -Wundef -Wpointer-arith -Wnested-externs -Winline -Wmissing-declarations -Wmissing-prototypes -Wsign-compare"
174 dnl -Wcast-align is a bit too annoying ;-)
176 if test "$gccnum" -ge "296"; then
177 dnl gcc 2.96 or later
178 WARN="$WARN -Wfloat-equal"
180 if test "$gccnum" -gt "296"; then
181 dnl this option does not exist in 2.96
182 WARN="$WARN -Wno-format-nonliteral"
185 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
186 dnl on i686-Linux as it gives us heaps with false positives
187 if test "$gccnum" -ge "303"; then
188 dnl gcc 3.3 and later
189 WARN="$WARN -Wendif-labels -Wstrict-prototypes"
193 for flag in $CPPFLAGS; do
197 add=`echo $flag | sed 's/^-I/-isystem /g'`
205 CFLAGS="$CFLAGS $WARN"
209 dnl strip off optimizer flags
211 for flag in $CFLAGS; do
214 dnl echo "cut off $flag"
217 NEWFLAGS="$NEWFLAGS $flag"
223 ]) dnl end of AC_DEFUN()
226 dnl This macro determines if the specified struct exists in the specified file
228 dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
230 AC_DEFUN([CARES_CHECK_STRUCT], [
231 AC_MSG_CHECKING([for struct $2])
234 struct $2 struct_instance;
235 ], ac_struct="yes", ac_found="no")
236 if test "$ac_struct" = "yes" ; then
245 dnl This macro determines if the specified constant exists in the specified file
247 dnl CARES_CHECK_CONSTANT(headers, constant name, if found, [if not found])
249 AC_DEFUN([CARES_CHECK_CONSTANT], [
250 AC_MSG_CHECKING([for $2])
251 AC_EGREP_CPP(VARIABLEWASDEFINED,
260 ], ac_constant="yes", ac_constant="no"
262 if test "$ac_constant" = "yes" ; then
272 dnl This macro determines how many parameters getservbyport_r takes
273 AC_DEFUN([CARES_CHECK_GETSERVBYPORT_R], [
274 AC_MSG_CHECKING([how many arguments getservbyport_r takes])
276 [#include <netdb.h>],
280 struct servent *p3, *p6;
281 getservbyport_r(p1, p2, p3, p4, p5, &p6);
282 ], ac_func_getservbyport_r=6,
284 [#include <netdb.h>],
289 getservbyport_r(p1, p2, p3, p4, p5);
290 ], ac_func_getservbyport_r=5,
292 [#include <netdb.h>],
297 struct servent_data p4;
298 getservbyport_r(p1, p2, p3, &p4);
299 ], ac_func_getservbyport_r=4, ac_func_getservbyport_r=0
303 if test $ac_func_getservbyport_r != "0" ; then
304 AC_MSG_RESULT($ac_func_getservbyport_r)
305 AC_DEFINE(HAVE_GETSERVBYPORT_R, 1, [Specifies whether getservbyport_r is present])
306 AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $ac_func_getservbyport_r, [Specifies the number of arguments to
308 if test $ac_func_getservbyport_r = "4" ; then
309 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data), [Specifies the size of the buffer to pass to
312 AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096, [Specifies the size of the buffer to pass to getservbyport_r])
315 AC_MSG_RESULT([not found])