]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
MinGW: fix winsock dependency issues (#1375)
authorAmos Jeffries <yadij@users.noreply.github.com>
Sun, 2 Jul 2023 09:33:16 +0000 (09:33 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sun, 2 Jul 2023 13:47:44 +0000 (13:47 +0000)
  error: warning: Please include winsock2.h before windows.h

Cleanup these header includes across all Squid code built for
Windows.

Also, detect these headers early to fix autoconf tests relying
on them.

acinclude/lib-checks.m4
configure.ac
src/icmp/Icmp4.h
src/icmp/pinger.cc

index 53847a81612a3f44d4e6e79dc1050e4a78597bb0..26ebb758bd33c62f7fb8776e34fbbe1f7ac2e580 100644 (file)
@@ -10,8 +10,8 @@ AC_DEFUN([SQUID_CHECK_LIBIPHLPAPI],[
     SQUID_STATE_SAVE(iphlpapi)
     LIBS="$LIBS -liphlpapi"
     AC_LINK_IFELSE([AC_LANG_PROGRAM([[
-#include <windows.h>
 #include <winsock2.h>
+#include <windows.h>
 #include <iphlpapi.h>
 ]], [[
   MIB_IPNETTABLE i;
index df97988bab06f433221f2e5715a3347b76c5c86c..0379371c1a9befd5479006c3104f911fe261b4c8 100644 (file)
@@ -189,6 +189,19 @@ AS_CASE(["$squid_host_os"],
   [mingw],[
     CFLAGS="$CFLAGS -mthreads"
     CXXFLAGS="$CXXFLAGS -mthreads -static-libgcc -static-libstdc++"
+    dnl Check for Winsock only on MinGW
+    SQUID_CHECK_WINSOCK_LIB
+    AC_CHECK_HEADERS([ws2tcpip.h winsock2.h windows.h],,,[
+#if HAVE_WS2TCPIP_H
+#include <ws2tcpip.h>
+#endif
+#if HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
+#if HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+    ])
     MINGW_LIBS="-lmingwex"
     AC_SUBST(MINGW_LIBS)
   ],
@@ -2487,24 +2500,6 @@ AC_SEARCH_LIBS([__res_search],[resolv])
 AC_SEARCH_LIBS([bind],[socket])
 AC_SEARCH_LIBS([opcom_stack_trace],[opcom_stack])
 AC_SEARCH_LIBS([yp_match], [nsl nss_nis nss_nisplus])
-dnl Check for Winsock only on MinGW, on Cygwin we must use emulated BSD socket API
-AS_IF([test "x$squid_host_os" = "xmingw"],[
-  SQUID_CHECK_WINSOCK_LIB
-  AC_CHECK_HEADERS( \
-    windows.h \
-    ws2tcpip.h \
-    iphlpapi.h ,,,[
-#if HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
-#if HAVE_WINDOWS_H
-#include <windows.h>
-#endif
-#if HAVE_WS2TCPIP_H
-#include <ws2tcpip.h>
-#endif
-  ])
-])
 
 # check that we have unix sockets
 SQUID_CHECK_UNIX_SOCKET
index 7e8c12be1cc393c931a5bd20c864330052c75174..6214a916cb7da765eecfdba52edfaddfcc6c3830 100644 (file)
 #include "fde.h"
 
 #if _SQUID_WINDOWS_
-
-#if HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
 #include <process.h>
-
 #endif
 
 /* IP Header */
index 98af8a0b89e982300a2611f42e09f16eeff7f4a6..951c1773320803cfb4ac1bf7cb03ca810c076c87 100644 (file)
@@ -57,9 +57,6 @@
 
 #if _SQUID_WINDOWS_
 
-#if HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
 #include <process.h>
 
 #include "fde.h"