From 795dbf53de16c5618f3ba1ca084cefcb34a928c4 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sat, 17 Apr 2021 05:28:02 +0300
Subject: [PATCH] mingw-w64 doesn't target w95: always use winsock2 with
mingw-w64 builds
Closes: https://github.com/libsdl-org/SDL_net/issues/26
---
SDLnetsys.h | 2 +-
configure | 7 +++++--
configure.ac | 7 +++++--
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/SDLnetsys.h b/SDLnetsys.h
index a36a58a..db92924 100644
--- a/SDLnetsys.h
+++ b/SDLnetsys.h
@@ -33,7 +33,7 @@
/* Include system network headers */
#if defined(__WIN32__) || defined(WIN32)
#define __USE_W32_SOCKETS
-#ifdef _WIN64
+#if defined(_WIN64) || defined(__MINGW64_VERSION_MAJOR)
#include <winsock2.h>
#include <ws2tcpip.h>
#else
diff --git a/configure b/configure
index 0574931..04cd7f6 100755
--- a/configure
+++ b/configure
@@ -1566,7 +1566,7 @@ Optional Features:
--disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors
--disable-sdltest Do not try to compile and run a test SDL program
- --enable-gui Try to build the GUI test programs default=yes
+ --enable-gui Try to build the GUI test programs [default=yes]
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -15254,10 +15254,13 @@ fi
case "$host" in
*mingw32ce*)
INETLIB="-lwinsock -lws2"
- ;;
+ ;;
x86_64-*-mingw*)
INETLIB="-lws2_32 -liphlpapi"
;;
+ *-w64-mingw*)
+ INETLIB="-lws2_32 -liphlpapi"
+ ;;
*-*-cygwin* | *-*-mingw*)
INETLIB="-lwsock32 -liphlpapi"
;;
diff --git a/configure.ac b/configure.ac
index 01c2955..b6f2619 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,10 +83,13 @@ dnl Figure out which networking libraries to use
case "$host" in
*mingw32ce*)
INETLIB="-lwinsock -lws2"
- ;;
+ ;;
x86_64-*-mingw*)
INETLIB="-lws2_32 -liphlpapi"
;;
+ *-w64-mingw*)
+ INETLIB="-lws2_32 -liphlpapi"
+ ;;
*-*-cygwin* | *-*-mingw*)
INETLIB="-lwsock32 -liphlpapi"
;;
@@ -121,7 +124,7 @@ LIBS="$LIBS $SDL_LIBS"
dnl Check for GUI library for the chat client
have_GUI=no
AC_ARG_ENABLE(gui,
-[ --enable-gui Try to build the GUI test programs [default=yes]],
+[AS_HELP_STRING([--enable-gui],[Try to build the GUI test programs [default=yes]])],
, enable_gui=yes)
if test x$enable_gui = xyes; then
AC_LANG_PUSH(C++)