]> Savannah Git Hosting - gnulib.git/commitdiff
poll: Avoid link errors on MSVC.
authorBruno Haible <bruno@clisp.org>
Tue, 4 Oct 2011 01:33:21 +0000 (03:33 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 4 Oct 2011 01:33:21 +0000 (03:33 +0200)
* m4/poll.m4 (gl_FUNC_POLL): Determine LIB_POLL.
* modules/poll (Depends-on): Add sockets.
(Link): New section.
* NEWS: Mention the change.
* modules/poll-tests (Makefile.am): Link test-poll against $(LIB_POLL).
* modules/poll-h-c++-tests (Makefile.am): Link test-poll-h-c++ against
$(LIB_POLL) instead of $(LIBSOCKET).

ChangeLog
NEWS
m4/poll.m4
modules/poll
modules/poll-h-c++-tests
modules/poll-tests

index 28a18112db6cc1bd978d117223c476f5e8feec0c..7906531a1d39132a923141d4843237719c56df93 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-10-03  Bruno Haible  <bruno@clisp.org>
+
+       poll: Avoid link errors on MSVC.
+       * m4/poll.m4 (gl_FUNC_POLL): Determine LIB_POLL.
+       * modules/poll (Depends-on): Add sockets.
+       (Link): New section.
+       * NEWS: Mention the change.
+       * modules/poll-tests (Makefile.am): Link test-poll against $(LIB_POLL).
+       * modules/poll-h-c++-tests (Makefile.am): Link test-poll-h-c++ against
+       $(LIB_POLL) instead of $(LIBSOCKET).
+
 2011-10-03  Bruno Haible  <bruno@clisp.org>
 
        sys_select tests: Fix link error on MSVC 9.
diff --git a/NEWS b/NEWS
index 85d3d43b5f466a677a8ea80e8b486fb9b5d4ff1f..2e98e61b9703c323307d21016f6a578f982dca76 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,9 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2011-10-03  poll            The link requirements of this module are changed
+                            from empty to $(LIB_POLL).
+
 2011-09-25  sys_stat        This module no longer provides the fstat()
                             function. If you need this function, you now need
                             to request the 'fstat' module.
index e489df7a00899fb2bdc38f26c19993cf228c96c3..0cf3183d14a4f8f09bae8da15b0db0b0b9e5ff20 100644 (file)
@@ -1,4 +1,4 @@
-# poll.m4 serial 14
+# poll.m4 serial 15
 dnl Copyright (c) 2003, 2005-2007, 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,
@@ -7,6 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_FUNC_POLL],
 [
   AC_REQUIRE([gl_POLL_H])
+  AC_REQUIRE([gl_SOCKETS])
   if test "$ac_cv_header_poll_h" = no; then
     ac_cv_func_poll=no
     gl_cv_func_poll=no
@@ -68,6 +69,31 @@ This is MacOSX or AIX
     AC_DEFINE([HAVE_POLL], [1],
       [Define to 1 if you have the 'poll' function and it works.])
   fi
+
+  dnl Determine the needed libraries.
+  LIB_POLL="$LIBSOCKET"
+  if test $HAVE_POLL = 0 || test $REPLACE_POLL = 1; then
+    case "$host_os" in
+      mingw*)
+        dnl On the MSVC platform, the function MsgWaitForMultipleObjects
+        dnl (used in lib/poll.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_POLL="$LIB_POLL -luser32"])
+        ;;
+    esac
+  fi
+  AC_SUBST([LIB_POLL])
 ])
 
 # Prerequisites of lib/poll.c.
index 37143320ea32ce3d5322d77d54344299e2b627d3..8fa88fd4d1248e9ceacaf20e3b7cd4ee5d4103ef 100644 (file)
@@ -9,6 +9,7 @@ Depends-on:
 poll-h
 alloca          [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]
 select          [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]
+sockets         [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]
 sys_select      [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]
 sys_time        [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]
 errno           [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]
@@ -27,6 +28,9 @@ Makefile.am:
 Include:
 <poll.h>
 
+Link:
+$(LIB_POLL)
+
 License:
 LGPLv2+
 
index 7ca908c71d715856957fd1efdb177590305de55e..8dd6262babe8aa6cb7b3adc4e96fd771403f345e 100644 (file)
@@ -15,5 +15,5 @@ if ANSICXX
 TESTS += test-poll-h-c++
 check_PROGRAMS += test-poll-h-c++
 test_poll_h_c___SOURCES = test-poll-h-c++.cc
-test_poll_h_c___LDADD = $(LDADD) @LIBSOCKET@
+test_poll_h_c___LDADD = $(LDADD) $(LIB_POLL)
 endif
index d34107ee8ab3f3b438833b19806cb19e9e4527d7..ab291a090df1303a31797a3edb968668d7925413 100644 (file)
@@ -28,4 +28,4 @@ AC_CHECK_HEADERS_ONCE([unistd.h sys/wait.h])
 Makefile.am:
 TESTS += test-poll
 check_PROGRAMS += test-poll
-test_poll_LDADD = $(LDADD) @LIBSOCKET@ $(INET_PTON_LIB)
+test_poll_LDADD = $(LDADD) $(LIB_POLL) @LIBSOCKET@ $(INET_PTON_LIB)