]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Windows port: configure enhancements on MinGW
authorGuido Serassio <serassio@squid-cache.org>
Tue, 8 Jul 2008 10:21:25 +0000 (12:21 +0200)
committerGuido Serassio <serassio@squid-cache.org>
Tue, 8 Jul 2008 10:21:25 +0000 (12:21 +0200)
- Really detect FD_SETSIZE on MinGW
- Detect real size of TCP and UDP buffers on MinGW
- Check for winsock.h or winsock2.h availability on MinGW

configure.in
src/pinger.cc

index 59dfe4e44253842f41f210607d525e46865dc1a7..7b117588e0aa372e11195dc95d7870a246fd3a30 100755 (executable)
@@ -2200,6 +2200,7 @@ AC_CHECK_TYPE(mtyp_t,AC_DEFINE(HAVE_MTYP_T,1,[mtyp_t is defined by the system he
 dnl Check for needed libraries
 AC_CHECK_LIB(nsl, main)
 AC_CHECK_LIB(socket, main)
+dnl Check for Winsock only on MinGW, on Cygwin we must use emulated BSD socket API
 case "$host_os" in
   mingw|mingw32)
     AC_MSG_CHECKING(for winsock)
@@ -2230,6 +2231,11 @@ case "$host_os" in
        LIBS="$save_LIBS"
     done
     AC_MSG_RESULT($have_winsock)
+    if test $have_winsock = winsock2; then
+       AC_CHECK_HEADERS(winsock2.h)
+    else
+       AC_CHECK_HEADERS(winsock.h)
+    fi
     ;;
 esac
 
@@ -2928,6 +2934,12 @@ AC_TRY_RUN([
 #if HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
+#if HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#if HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
 main() {
        FILE *fp = fopen("conftestval", "w");
        fprintf (fp, "%d\n", FD_SETSIZE);
@@ -3050,14 +3062,31 @@ AC_TRY_RUN([
 #include <stdlib.h>
 #include <stdio.h>
 #include <sys/types.h>
+#if HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
+#if HAVE_NETINET_IN_H
 #include <netinet/in.h>
+#endif
+#if HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#if HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
 main ()
 {
        FILE *fp;
         int fd,val=0,len=sizeof(int);
+#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
+       WSADATA wsaData;
+       WSAStartup(2, &wsaData);
+#endif
        if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) exit(1);
         if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) exit(1);
+#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
+       WSACleanup();
+#endif
        if (val<=0) exit(1);
         fp = fopen("conftestval", "w");
         fprintf (fp, "%d\n", val);
@@ -3076,14 +3105,31 @@ AC_TRY_RUN([
 #include <stdlib.h>
 #include <stdio.h>
 #include <sys/types.h>
+#if HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
+#if HAVE_NETINET_IN_H
 #include <netinet/in.h>
+#endif
+#if HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#if HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
 main ()
 {
        FILE *fp;
         int fd,val=0,len=sizeof(int);
+#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
+       WSADATA wsaData;
+       WSAStartup(2, &wsaData);
+#endif
        if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) exit(1);
         if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) exit(1);
+#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
+       WSACleanup();
+#endif
        if (val <= 0) exit(1);
        fp = fopen("conftestval", "w"); 
        fprintf (fp, "%d\n", val);
@@ -3102,14 +3148,31 @@ AC_TRY_RUN([
 #include <stdlib.h>
 #include <stdio.h>
 #include <sys/types.h>
+#if HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
+#if HAVE_NETINET_IN_H
 #include <netinet/in.h>
+#endif
+#if HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#if HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
 main ()
 {
        FILE *fp;
         int fd,val=0,len=sizeof(int);
+#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
+       WSADATA wsaData;
+       WSAStartup(2, &wsaData);
+#endif
        if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) exit(1);
         if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) exit(1);
+#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
+       WSACleanup();
+#endif
        if (val <= 0) exit(1);
        fp = fopen("conftestval", "w"); 
        fprintf (fp, "%d\n", val);
@@ -3132,14 +3195,31 @@ AC_TRY_RUN([
 #include <stdlib.h>
 #include <stdio.h>
 #include <sys/types.h>
+#if HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
+#if HAVE_NETINET_IN_H
 #include <netinet/in.h>
+#endif
+#if HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#if HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
 main ()
 {
        FILE *fp;
         int fd,val=0,len=sizeof(int);
+#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
+       WSADATA wsaData;
+       WSAStartup(2, &wsaData);
+#endif
        if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) exit(1);
         if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) exit(1);
+#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
+       WSACleanup();
+#endif
        if (val <= 0) exit(1);
        fp = fopen("conftestval", "w"); 
        fprintf (fp, "%d\n", val);
index f906f3fd83f5f868fb585cff7b8695ed5028eda8..b04d6ed5e5d4bcfeae44d11f5edfdbc8a1ebd760 100644 (file)
@@ -63,7 +63,9 @@ static int socket_to_squid = 1;
 
 #ifdef _SQUID_MSWIN_
 
+#if HAVE_WINSOCK2_H
 #include <winsock2.h>
+#endif
 #include <process.h>
 
 #define PINGER_TIMEOUT 5