[libxml2] autotools: Fix winsock detection



commit f597eff8ddc7a867ed40b388a76484a8c91f793b
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Wed Sep 7 18:18:06 2022 +0200

    autotools: Fix winsock detection
    
    Hardcode the required library on MinGW because winsock uses non-standard
    calling conventions on 32-bit Windows which makes AC_SEARCH_LIBS fail.
    
    Should fix #406.

 .gitlab-ci.yml | 10 ++++++++--
 configure.ac   | 29 +++++++++++++++++++----------
 2 files changed, 27 insertions(+), 12 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1c8cc5a6..d95bf7f8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -74,6 +74,14 @@ mingw:w64-x86_64:shared:
     CFLAGS: "-O2"
     MSYSTEM: MINGW64
 
+mingw:w64-i686:shared:
+  extends: .mingw
+  only:
+    - schedules
+  variables:
+    CFLAGS: "-O2"
+    MSYSTEM: MINGW32
+
 # Disabled, GCC missing?
 .mingw:msys:shared:
   extends: .mingw
@@ -96,8 +104,6 @@ mingw:w64-x86_64:shared:
 
 cmake:linux:gcc:shared:
   extends: .cmake:linux
-#  only:
-#    - schedules
   variables:
     BUILD_SHARED_LIBS: "ON"
     CC: gcc
diff --git a/configure.ac b/configure.ac
index 5df1e7bb..b6255f91 100644
--- a/configure.ac
+++ b/configure.ac
@@ -349,16 +349,25 @@ dnl
 dnl Checks for inet libraries
 dnl
 if test "$with_http" != "no" || test "with_ftp" = "yes"; then
-    _libs=$LIBS
-    AC_SEARCH_LIBS(gethostbyname, [nsl ws2_32], [
-        if test "$ac_cv_search_gethostbyname" != "none required"; then
-            NET_LIBS="$NET_LIBS $ac_cv_search_gethostbyname"
-        fi], [:], [$NET_LIBS])
-    AC_SEARCH_LIBS(connect, [bsd socket inet ws2_32], [
-        if test "$ac_cv_search_connect" != "none required"; then
-            NET_LIBS="$NET_LIBS $ac_cv_search_connect"
-        fi], [:], [$NET_LIBS])
-    LIBS=$_libs
+    case "$host" in
+        *-*-mingw*)
+            dnl AC_SEARCH_LIBS doesn't work because of non-standard calling
+            dnl conventions on 32-bit Windows.
+            NET_LIBS="$NET_LIBS -lws2_32"
+            ;;
+        *)
+            _libs=$LIBS
+            AC_SEARCH_LIBS(gethostbyname, [nsl], [
+                if test "$ac_cv_search_gethostbyname" != "none required"; then
+                    NET_LIBS="$NET_LIBS $ac_cv_search_gethostbyname"
+                fi], [:], [$NET_LIBS])
+            AC_SEARCH_LIBS(connect, [bsd socket inet], [
+                if test "$ac_cv_search_connect" != "none required"; then
+                    NET_LIBS="$NET_LIBS $ac_cv_search_connect"
+                fi], [:], [$NET_LIBS])
+            LIBS=$_libs
+            ;;
+    esac
 
     dnl Determine what socket length (socklen_t) data type is
     AC_MSG_CHECKING([for type of socket length (socklen_t)])


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]