2
dnl **********************************************************************
3
dnl CURL_DETECT_ICC ([ACTION-IF-YES])
5
dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
6
dnl sets the $ICC variable to "yes" or "no"
7
dnl **********************************************************************
8
AC_DEFUN([CURL_DETECT_ICC],
11
AC_MSG_CHECKING([for icc in use])
12
if test "$GCC" = "yes"; then
13
dnl check if this is icc acting as gcc in disguise
14
AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
15
dnl action if the text is found, this it has not been replaced by the
18
dnl the text was not found, it was replaced by the cpp
24
if test "$ICC" = "no"; then
30
dnl We create a function for detecting which compiler we use and then set as
31
dnl pendantic compiler options as possible for that particular compiler. The
32
dnl options are only used for debug-builds.
34
AC_DEFUN([CURL_CC_DEBUG_OPTS],
36
if test "z$ICC" = "z"; then
40
if test "$GCC" = "yes"; then
42
dnl figure out gcc version!
43
AC_MSG_CHECKING([gcc version])
44
gccver=`$CC -dumpversion`
45
num1=`echo $gccver | cut -d . -f1`
46
num2=`echo $gccver | cut -d . -f2`
47
gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
48
AC_MSG_RESULT($gccver)
50
if test "$ICC" = "yes"; then
51
dnl this is icc, not gcc.
53
dnl ICC warnings we ignore:
54
dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
55
dnl "invalid format string conversion"
56
dnl * 279 warns on static conditions in while expressions
57
dnl * 981 warns on "operands are evaluated in unspecified order"
58
dnl * 1418 "external definition with no prior declaration"
59
dnl * 1419 warns on "external declaration in primary source file"
60
dnl which we know and do on purpose.
62
WARN="-wd279,269,981,1418,1419"
64
if test "$gccnum" -gt "600"; then
65
dnl icc 6.0 and older doesn't have the -Wall flag
69
dnl this is a set of options we believe *ALL* gcc versions support:
70
WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
72
dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
74
if test "$gccnum" -ge "207"; then
76
WARN="$WARN -Wmissing-declarations"
79
if test "$gccnum" -gt "295"; then
80
dnl only if the compiler is newer than 2.95 since we got lots of
81
dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
82
dnl gcc 2.95.4 on FreeBSD 4.9!
83
WARN="$WARN -Wundef -Wno-long-long -Wsign-compare"
86
if test "$gccnum" -ge "296"; then
88
WARN="$WARN -Wfloat-equal"
91
if test "$gccnum" -gt "296"; then
92
dnl this option does not exist in 2.96
93
WARN="$WARN -Wno-format-nonliteral"
96
dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
97
dnl on i686-Linux as it gives us heaps with false positives.
98
dnl Also, on gcc 4.0.X it is totally unbearable and complains all
99
dnl over making it unusable for generic purposes. Let's not use it.
101
if test "$gccnum" -ge "303"; then
102
dnl gcc 3.3 and later
103
WARN="$WARN -Wendif-labels -Wstrict-prototypes"
106
if test "$gccnum" -ge "304"; then
107
# try these on gcc 3.4
108
WARN="$WARN -Wdeclaration-after-statement"
111
for flag in $CPPFLAGS; do
114
dnl Include path, provide a -isystem option for the same dir
115
dnl to prevent warnings in those dirs. The -isystem was not very
116
dnl reliable on earlier gcc versions.
117
add=`echo $flag | sed 's/^-I/-isystem /g'`
125
CFLAGS="$CFLAGS $WARN"
127
AC_MSG_NOTICE([Added this set of compiler options: $WARN])
131
AC_MSG_NOTICE([Added no extra compiler options])
135
dnl strip off optimizer flags
137
for flag in $CFLAGS; do
140
dnl echo "cut off $flag"
143
NEWFLAGS="$NEWFLAGS $flag"
149
]) dnl end of AC_DEFUN()
151
dnl CURL_CHECK_NONBLOCKING_SOCKET
152
dnl -------------------------------------------------
153
dnl Check for how to set a socket to non-blocking state. There seems to exist
154
dnl four known different ways, with the one used almost everywhere being POSIX
155
dnl and XPG3, while the other different ways for different systems (old BSD,
156
dnl Windows and Amiga).
158
dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
159
dnl O_NONBLOCK define is found but does not work. This condition is attempted
160
dnl to get caught in this script by using an excessive number of #ifdefs...
162
AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET],
164
AC_MSG_CHECKING([non-blocking sockets style])
167
/* headers for O_NONBLOCK test */
168
#include <sys/types.h>
172
/* try to compile O_NONBLOCK */
174
#if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
175
# if defined(__SVR4) || defined(__srv4__)
176
# define PLATFORM_SOLARIS
178
# define PLATFORM_SUNOS4
181
#if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
182
# define PLATFORM_AIX_V3
185
#if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
186
#error "O_NONBLOCK does not work on this platform"
189
int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
191
dnl the O_NONBLOCK test was fine
192
nonblock="O_NONBLOCK"
193
AC_DEFINE(HAVE_O_NONBLOCK, 1, [use O_NONBLOCK for non-blocking sockets])
195
dnl the code was bad, try a different program now, test 2
198
/* headers for FIONBIO test */
202
/* FIONBIO source test (old-style unix) */
204
int flags = ioctl(socket, FIONBIO, &flags);
206
dnl FIONBIO test was good
208
AC_DEFINE(HAVE_FIONBIO, 1, [use FIONBIO for non-blocking sockets])
210
dnl FIONBIO test was also bad
211
dnl the code was bad, try a different program now, test 3
214
/* headers for ioctlsocket test (Windows) */
216
#ifdef HAVE_WINDOWS_H
217
#ifndef WIN32_LEAN_AND_MEAN
218
#define WIN32_LEAN_AND_MEAN
221
#ifdef HAVE_WINSOCK2_H
222
#include <winsock2.h>
224
#ifdef HAVE_WINSOCK_H
230
/* ioctlsocket source code */
232
unsigned long flags = 0;
233
sd = socket(0, 0, 0);
234
ioctlsocket(sd, FIONBIO, &flags);
236
dnl ioctlsocket test was good
237
nonblock="ioctlsocket"
238
AC_DEFINE(HAVE_IOCTLSOCKET, 1, [use ioctlsocket() for non-blocking sockets])
240
dnl ioctlsocket didnt compile!, go to test 4
243
/* headers for IoctlSocket test (Amiga?) */
244
#include <sys/ioctl.h>
246
/* IoctlSocket source code */
248
int flags = IoctlSocket(socket, FIONBIO, (long)1);
250
dnl ioctlsocket test was good
251
nonblock="IoctlSocket"
252
AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, [use Ioctlsocket() for non-blocking sockets])
254
dnl Ioctlsocket didnt compile, do test 5!
256
/* headers for SO_NONBLOCK test (BeOS) */
259
/* SO_NONBLOCK source code */
262
int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
264
dnl the SO_NONBLOCK test was good
265
nonblock="SO_NONBLOCK"
266
AC_DEFINE(HAVE_SO_NONBLOCK, 1, [use SO_NONBLOCK for non-blocking sockets])
268
dnl test 5 didnt compile!
270
AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, [disabled non-blocking sockets])
272
dnl end of fifth test
275
dnl end of forth test
278
dnl end of third test
281
dnl end of second test
284
dnl end of non-blocking try-compile test
285
AC_MSG_RESULT($nonblock)
287
if test "$nonblock" = "nada"; then
288
AC_MSG_WARN([non-block sockets disabled])
292
dnl CURL_CHECK_NEED_REENTRANT_SYSTEM
293
dnl -------------------------------------------------
294
dnl Checks if the preprocessor _REENTRANT definition
295
dnl must be unconditionally done for this platform.
296
dnl Internal macro for CURL_CONFIGURE_REENTRANT.
298
AC_DEFUN([CURL_CHECK_NEED_REENTRANT_SYSTEM], [
300
*-*-solaris* | *-*-hpux*)
301
tmp_need_reentrant="yes"
304
tmp_need_reentrant="no"
310
dnl CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT
311
dnl -------------------------------------------------
312
dnl This macro ensures that configuration tests done
313
dnl after this will execute with preprocessor symbol
314
dnl _REENTRANT defined. This macro also ensures that
315
dnl the generated config file defines NEED_REENTRANT
316
dnl and that in turn setup.h will define _REENTRANT.
317
dnl Internal macro for CURL_CONFIGURE_REENTRANT.
319
AC_DEFUN([CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT], [
320
AC_DEFINE(NEED_REENTRANT, 1,
321
[Define to 1 if _REENTRANT preprocessor symbol must be defined.])
322
cat >>confdefs.h <<_EOF
330
dnl CURL_CONFIGURE_REENTRANT
331
dnl -------------------------------------------------
332
dnl This first checks if the preprocessor _REENTRANT
333
dnl symbol is already defined. If it isn't currently
334
dnl defined a set of checks are performed to verify
335
dnl if its definition is required to make visible to
336
dnl the compiler a set of *_r functions. Finally, if
337
dnl _REENTRANT is already defined or needed it takes
338
dnl care of making adjustments necessary to ensure
339
dnl that it is defined equally for further configure
340
dnl tests and generated config file.
342
AC_DEFUN([CURL_CONFIGURE_REENTRANT], [
345
AC_MSG_CHECKING([if _REENTRANT is already defined])
352
force compilation error
357
tmp_reentrant_initially_defined="yes"
360
tmp_reentrant_initially_defined="no"
363
if test "$tmp_reentrant_initially_defined" = "no"; then
364
AC_MSG_CHECKING([if _REENTRANT is actually needed])
365
CURL_CHECK_NEED_REENTRANT_SYSTEM
367
if test "$tmp_need_reentrant" = "yes"; then
374
AC_MSG_CHECKING([if _REENTRANT is onwards defined])
375
if test "$tmp_reentrant_initially_defined" = "yes" ||
376
test "$tmp_need_reentrant" = "yes"; then
377
CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT