aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2006-07-05 23:10:37 +0000
committerYang Tse <yangsita@gmail.com>2006-07-05 23:10:37 +0000
commitbc2f0c7dcbd22ab52971df4a419933e70f263a3f (patch)
treef0691aecd2dab76f769aa04ad94c18a8fa4ed6aa
parentc6ae0ebcbf3c7b47ab444195613c6e14843fa248 (diff)
Prevent definition of HAVE_WINxxx_H symbols and avoid inclusion of Windows headers when compiled with Cygwin in POSIX emulation mode.
-rw-r--r--acinclude.m4100
-rw-r--r--ares/acinclude.m499
-rw-r--r--ares/ares.h2
-rw-r--r--ares/nameser.h2
-rw-r--r--ares/setup.h6
-rw-r--r--docs/examples/synctime.c2
-rw-r--r--include/curl/multi.h4
-rw-r--r--lib/setup.h2
-rw-r--r--src/setup.h2
9 files changed, 208 insertions, 11 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index adfce1a91..e13d7cfe4 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -21,6 +21,26 @@
# $Id$
###########################################################################
+
+dnl CURL_CHECK_HEADERS_ONCE
+dnl -------------------------------------------------
+dnl Check for headers if check not already done.
+
+AC_DEFUN(CURL_CHECK_HEADERS_ONCE, [
+ for i in $1; do
+ eval prev_check_res=\$ac_cv_header_$i
+ case "$prev_check_res" in
+ yes | no)
+ ;;
+ *)
+ AC_CHECK_HEADERS($i)
+ ;;
+ esac
+
+ done
+])
+
+
dnl CURL_CHECK_HEADER_WINDOWS
dnl -------------------------------------------------
dnl Check for compilable and valid windows.h header
@@ -35,7 +55,11 @@ AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
#endif
#include <windows.h>
],[
+#ifdef __CYGWIN__
+ HAVE_WINDOWS_H shall not be defined.
+#else
int dummy=2*WINVER;
+#endif
])
],[
ac_cv_header_windows_h="yes"
@@ -68,7 +92,11 @@ AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
#include <windows.h>
#include <winsock.h>
],[
+#ifdef __CYGWIN__
+ HAVE_WINSOCK_H shall not be defined.
+#else
int dummy=WSACleanup();
+#endif
])
],[
ac_cv_header_winsock_h="yes"
@@ -99,7 +127,11 @@ AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
#include <windows.h>
#include <winsock2.h>
],[
+#ifdef __CYGWIN__
+ HAVE_WINSOCK2_H shall not be defined.
+#else
int dummy=2*IPPROTO_ESP;
+#endif
])
],[
ac_cv_header_winsock2_h="yes"
@@ -131,7 +163,11 @@ AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
#include <winsock2.h>
#include <ws2tcpip.h>
],[
+#ifdef __CYGWIN__
+ HAVE_WS2TCPIP_H shall not be defined.
+#else
int dummy=2*IP_PKTINFO;
+#endif
])
],[
ac_cv_header_ws2tcpip_h="yes"
@@ -566,17 +602,33 @@ dnl and RECV_TYPE_ARG4, defining the type of the function
dnl return value in RECV_TYPE_RETV.
AC_DEFUN([CURL_CHECK_FUNC_RECV], [
+ AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
+ AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
AC_CHECK_HEADERS(sys/types.h sys/socket.h)
#
AC_MSG_CHECKING([for recv])
AC_TRY_LINK([
-#undef inline
+#undef inline
+#ifdef HAVE_WINDOWS_H
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#else
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#endif
+#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
+#endif
],[
recv(0, 0, 0, 0);
],[
@@ -599,12 +651,26 @@ AC_DEFUN([CURL_CHECK_FUNC_RECV], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#undef inline
+#ifdef HAVE_WINDOWS_H
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#else
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#endif
+#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
+#endif
extern $recv_retv recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
],[
$recv_arg1 s=0;
@@ -663,17 +729,33 @@ dnl return value in SEND_TYPE_RETV, and also defining the
dnl type qualifier of second argument in SEND_QUAL_ARG2.
AC_DEFUN([CURL_CHECK_FUNC_SEND], [
+ AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
+ AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
AC_CHECK_HEADERS(sys/types.h sys/socket.h)
#
AC_MSG_CHECKING([for send])
AC_TRY_LINK([
-#undef inline
+#undef inline
+#ifdef HAVE_WINDOWS_H
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#else
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#endif
+#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
+#endif
],[
send(0, 0, 0, 0);
],[
@@ -696,12 +778,26 @@ AC_DEFUN([CURL_CHECK_FUNC_SEND], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#undef inline
+#ifdef HAVE_WINDOWS_H
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#else
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#endif
+#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
+#endif
extern $send_retv send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
],[
$send_arg1 s=0;
diff --git a/ares/acinclude.m4 b/ares/acinclude.m4
index b86e2a8a5..bf3cf04a4 100644
--- a/ares/acinclude.m4
+++ b/ares/acinclude.m4
@@ -1,5 +1,24 @@
+dnl CURL_CHECK_HEADERS_ONCE
+dnl -------------------------------------------------
+dnl Check for headers if check not already done.
+
+AC_DEFUN(CURL_CHECK_HEADERS_ONCE, [
+ for i in $1; do
+ eval prev_check_res=\$ac_cv_header_$i
+ case "$prev_check_res" in
+ yes | no)
+ ;;
+ *)
+ AC_CHECK_HEADERS($i)
+ ;;
+ esac
+
+ done
+])
+
+
dnl CURL_CHECK_HEADER_WINDOWS
dnl -------------------------------------------------
dnl Check for compilable and valid windows.h header
@@ -14,7 +33,11 @@ AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
#endif
#include <windows.h>
],[
+#ifdef __CYGWIN__
+ HAVE_WINDOWS_H shall not be defined.
+#else
int dummy=2*WINVER;
+#endif
])
],[
ac_cv_header_windows_h="yes"
@@ -47,7 +70,11 @@ AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
#include <windows.h>
#include <winsock.h>
],[
+#ifdef __CYGWIN__
+ HAVE_WINSOCK_H shall not be defined.
+#else
int dummy=WSACleanup();
+#endif
])
],[
ac_cv_header_winsock_h="yes"
@@ -78,7 +105,11 @@ AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
#include <windows.h>
#include <winsock2.h>
],[
+#ifdef __CYGWIN__
+ HAVE_WINSOCK2_H shall not be defined.
+#else
int dummy=2*IPPROTO_ESP;
+#endif
])
],[
ac_cv_header_winsock2_h="yes"
@@ -110,7 +141,11 @@ AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
#include <winsock2.h>
#include <ws2tcpip.h>
],[
+#ifdef __CYGWIN__
+ HAVE_WS2TCPIP_H shall not be defined.
+#else
int dummy=2*IP_PKTINFO;
+#endif
])
],[
ac_cv_header_ws2tcpip_h="yes"
@@ -545,17 +580,33 @@ dnl and RECV_TYPE_ARG4, defining the type of the function
dnl return value in RECV_TYPE_RETV.
AC_DEFUN([CURL_CHECK_FUNC_RECV], [
+ AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
+ AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
AC_CHECK_HEADERS(sys/types.h sys/socket.h)
#
AC_MSG_CHECKING([for recv])
AC_TRY_LINK([
-#undef inline
+#undef inline
+#ifdef HAVE_WINDOWS_H
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#else
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#endif
+#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
+#endif
],[
recv(0, 0, 0, 0);
],[
@@ -578,12 +629,26 @@ AC_DEFUN([CURL_CHECK_FUNC_RECV], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#undef inline
+#ifdef HAVE_WINDOWS_H
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#else
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#endif
+#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
+#endif
extern $recv_retv recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
],[
$recv_arg1 s=0;
@@ -642,17 +707,33 @@ dnl return value in SEND_TYPE_RETV, and also defining the
dnl type qualifier of second argument in SEND_QUAL_ARG2.
AC_DEFUN([CURL_CHECK_FUNC_SEND], [
+ AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
+ AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
AC_CHECK_HEADERS(sys/types.h sys/socket.h)
#
AC_MSG_CHECKING([for send])
AC_TRY_LINK([
-#undef inline
+#undef inline
+#ifdef HAVE_WINDOWS_H
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#else
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#endif
+#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
+#endif
],[
send(0, 0, 0, 0);
],[
@@ -675,12 +756,26 @@ AC_DEFUN([CURL_CHECK_FUNC_SEND], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#undef inline
+#ifdef HAVE_WINDOWS_H
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#else
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#endif
+#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
+#endif
extern $send_retv send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
],[
$send_arg1 s=0;
diff --git a/ares/ares.h b/ares/ares.h
index 9414f9b78..f4d98c87d 100644
--- a/ares/ares.h
+++ b/ares/ares.h
@@ -31,7 +31,7 @@
#include <netinet/in.h>
#include <sys/socket.h>
#include <tcp.h>
-#elif defined(WIN32)
+#elif defined(WIN32) && !defined(__CYGWIN__)
#include <winsock2.h>
#include <windows.h>
#else
diff --git a/ares/nameser.h b/ares/nameser.h
index 7127c2640..1faeb6ff8 100644
--- a/ares/nameser.h
+++ b/ares/nameser.h
@@ -7,7 +7,9 @@
port build */
#ifndef NETWARE
+#ifndef __CYGWIN__
#include <windows.h>
+#endif
#include <process.h> /* for the _getpid() proto */
#endif /* !NETWARE */
#include <sys/types.h>
diff --git a/ares/setup.h b/ares/setup.h
index 44261411b..c6ec2618e 100644
--- a/ares/setup.h
+++ b/ares/setup.h
@@ -43,10 +43,12 @@
* Include header files for windows builds before redefining anything.
* Use this preproessor block only to include or exclude windows.h,
* winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs
- * to any other further and independant block.
+ * to any other further and independant block. Under Cygwin things work
+ * just as under linux (e.g. <sys/socket.h>) and the winsock headers should
+ * never be included when __CYGWIN__ is defined.
*/
-#ifdef HAVE_WINDOWS_H
+#if defined(HAVE_WINDOWS_H) && !defined(__CYGWIN__)
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
diff --git a/docs/examples/synctime.c b/docs/examples/synctime.c
index 9f3bba0e9..fc629ee33 100644
--- a/docs/examples/synctime.c
+++ b/docs/examples/synctime.c
@@ -59,7 +59,9 @@
#include <stdio.h>
#include <time.h>
+#ifndef __CYGWIN__
#include <windows.h>
+#endif
#include <curl/curl.h>
diff --git a/include/curl/multi.h b/include/curl/multi.h
index 6ce682690..4fc70640a 100644
--- a/include/curl/multi.h
+++ b/include/curl/multi.h
@@ -43,8 +43,8 @@
#define WIN32 1
#endif
-#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__GNUC__) || \
- defined(__MINGW32__)
+#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__GNUC__) && \
+ !defined(__CYGWIN__) || defined(__MINGW32__)
#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H))
/* The check above prevents the winsock2 inclusion if winsock.h already was
included, since they can't co-exist without problems */
diff --git a/lib/setup.h b/lib/setup.h
index cef40288e..57ac87d5b 100644
--- a/lib/setup.h
+++ b/lib/setup.h
@@ -81,7 +81,7 @@
* winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs
* to any other further and independant block. Under Cygwin things work
* just as under linux (e.g. <sys/socket.h>) and the winsock headers should
- * never be included.
+ * never be included when __CYGWIN__ is defined.
*/
#if defined(HAVE_WINDOWS_H) && !defined(__CYGWIN__)
diff --git a/src/setup.h b/src/setup.h
index f07b3a7b7..d3814fef4 100644
--- a/src/setup.h
+++ b/src/setup.h
@@ -83,7 +83,7 @@
* winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs
* to any other further and independant block. Under Cygwin things work
* just as under linux (e.g. <sys/socket.h>) and the winsock headers should
- * never be included.
+ * never be included when __CYGWIN__ is defined.
*/
#if defined(HAVE_WINDOWS_H) && !defined(__CYGWIN__)