From: Bruno Haible Date: Tue, 4 Oct 2011 01:33:21 +0000 (+0200) Subject: poll: Avoid link errors on MSVC. X-Git-Tag: v0.1~1702 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=996ce97a8f8572ae9bade6c7df1aa364bd0e259f;p=gnulib.git 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). --- diff --git a/ChangeLog b/ChangeLog index 28a18112d..7906531a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2011-10-03 Bruno Haible + 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 + sys_select tests: Fix link error on MSVC 9. * modules/sys_select-c++-tests (Makefile.am): Link test-sys_select-c++ with $(LIB_SELECT) instead of $(LIBSOCKET). diff --git a/NEWS b/NEWS index 85d3d43b5..2e98e61b9 100644 --- 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. diff --git a/m4/poll.m4 b/m4/poll.m4 index e489df7a0..0cf3183d1 100644 --- a/m4/poll.m4 +++ b/m4/poll.m4 @@ -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 +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. diff --git a/modules/poll b/modules/poll index 37143320e..8fa88fd4d 100644 --- a/modules/poll +++ b/modules/poll @@ -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: +Link: +$(LIB_POLL) + License: LGPLv2+ diff --git a/modules/poll-h-c++-tests b/modules/poll-h-c++-tests index 7ca908c71..8dd6262ba 100644 --- a/modules/poll-h-c++-tests +++ b/modules/poll-h-c++-tests @@ -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 diff --git a/modules/poll-tests b/modules/poll-tests index d34107ee8..ab291a090 100644 --- a/modules/poll-tests +++ b/modules/poll-tests @@ -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)