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