]> Savannah Git Hosting - gnulib.git/commitdiff
select: Avoid link errors on MSVC.
authorBruno Haible <bruno@clisp.org>
Thu, 22 Sep 2011 21:45:06 +0000 (23:45 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 22 Sep 2011 21:45:06 +0000 (23:45 +0200)
* m4/select.m4 (gl_FUNC_SELECT): Determine LIB_SELECT.
* modules/select (Link): Replace $(LIBSOCKET) with $(LIB_SELECT).
* modules/pselect (Link): Likewise.
* NEWS: Mention the change.
* modules/select-tests (Makefile.am): Link test-select, test-select-fd,
test-select-stdin against $(LIB_SELECT).
* modules/pselect-tests (Makefile.am): Link test-pselect against
$(LIB_SELECT).

ChangeLog
NEWS
m4/select.m4
modules/pselect
modules/pselect-tests
modules/select
modules/select-tests

index aca9b43d805a85c170bcd2eea9f2209b65c074e5..3af8904e0f551dc3de7c2c207f98e39b428e6902 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2011-09-22  Bruno Haible  <bruno@clisp.org>
+
+       select: Avoid link errors on MSVC.
+       * m4/select.m4 (gl_FUNC_SELECT): Determine LIB_SELECT.
+       * modules/select (Link): Replace $(LIBSOCKET) with $(LIB_SELECT).
+       * modules/pselect (Link): Likewise.
+       * NEWS: Mention the change.
+       * modules/select-tests (Makefile.am): Link test-select, test-select-fd,
+       test-select-stdin against $(LIB_SELECT).
+       * modules/pselect-tests (Makefile.am): Link test-pselect against
+       $(LIB_SELECT).
+
 2011-09-22  Bruno Haible  <bruno@clisp.org>
 
        select: Avoid compilation error on MSVC.
diff --git a/NEWS b/NEWS
index 16c5a3528fd1586568f0453534a17c812fb0c5ad..d7d9acd9cef26947890b9e7bfa398a1419d64405 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,9 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2011-09-22  select          The link requirements of this module are changed
+                            from $(LIBSOCKET) to $(LIB_SELECT).
+
 2011-09-12  fchdir          This module no longer overrides the functions
                             opendir() and closedir(), unless the modules
                             'opendir' and 'closedir' are in use, respectively.
index d9c3465b12889e9923385039de2045c7d60b39ac..a58f0ac3a1d179d26fc9f8158da7c92a8966a413 100644 (file)
@@ -1,4 +1,4 @@
-# select.m4 serial 5
+# select.m4 serial 6
 dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -47,4 +47,29 @@ changequote([,])dnl
       *) REPLACE_SELECT=1 ;;
     esac
   fi
+
+  dnl Determine the needed libraries.
+  LIB_SELECT="$LIBSOCKET"
+  if test $REPLACE_SELECT = 1; then
+    case "$host_os" in
+      mingw*)
+        dnl On the MSVC platform, the function MsgWaitForMultipleObjects
+        dnl (used in lib/select.c) requires linking with -luser32. On mingw,
+        dnl it is implicit.
+        AC_LINK_IFELSE(
+          [AC_LANG_SOURCE([[
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+int
+main ()
+{
+  MsgWaitForMultipleObjects (0, NULL, 0, 0, 0);
+  return 0;
+}]])],
+          [],
+          [LIB_SELECT="$LIB_SELECT -luser32"])
+        ;;
+    esac
+  fi
+  AC_SUBST([LIB_SELECT])
 ])
index fa69c5369be48f063ee9a5f2195dcfc4280d55ae..1ca08edea9cd5090d23c24865c82e95cffdd6d83 100644 (file)
@@ -23,7 +23,7 @@ Include:
 <sys/select.h>
 
 Link:
-$(LIBSOCKET) $(LIB_PTHREAD_SIGMASK)
+$(LIB_SELECT) $(LIB_PTHREAD_SIGMASK)
 
 License:
 LGPLv2+
index 0dccb3634df36080a35a6d5e61e5a78ceca91d59..0c37ff6abf6a45e641452914c6ac4518f0c2e7a5 100644 (file)
@@ -30,4 +30,4 @@ AC_CHECK_HEADERS_ONCE([sys/wait.h])
 Makefile.am:
 TESTS += test-pselect
 check_PROGRAMS += test-pselect
-test_pselect_LDADD = $(LDADD) @LIBSOCKET@ @LIB_PTHREAD_SIGMASK@ $(INET_PTON_LIB)
+test_pselect_LDADD = $(LDADD) @LIB_SELECT@ @LIBSOCKET@ @LIB_PTHREAD_SIGMASK@ $(INET_PTON_LIB)
index 5969a4eaf20680b05b86d719b5f31418912e2255..f665740b0319fdd1fec64099b06ed31537c1b08c 100644 (file)
@@ -23,7 +23,7 @@ Include:
 <sys/select.h>
 
 Link:
-$(LIBSOCKET)
+$(LIB_SELECT)
 
 License:
 LGPLv2+
index a3b13db2d5982fc0e0bed03efb94e7233d54c41f..bd7b7313712eba813fc483b3ab62a182e670e9e7 100644 (file)
@@ -36,6 +36,6 @@ Makefile.am:
 TESTS += test-select test-select-in.sh test-select-out.sh
 # test-select-stdin has to be run by hand.
 check_PROGRAMS += test-select test-select-fd test-select-stdin
-test_select_LDADD = $(LDADD) @LIBSOCKET@ $(INET_PTON_LIB)
-test_select_fd_LDADD = $(LDADD) @LIBSOCKET@
-test_select_stdin_LDADD = $(LDADD) @LIBSOCKET@
+test_select_LDADD = $(LDADD) @LIB_SELECT@ @LIBSOCKET@ $(INET_PTON_LIB)
+test_select_fd_LDADD = $(LDADD) @LIB_SELECT@
+test_select_stdin_LDADD = $(LDADD) @LIB_SELECT@