GUACAMOLE-325: Explicitly check for Winsock.

This commit is contained in:
Michael Jumper 2017-06-12 14:27:22 -07:00
parent d85f61deaf
commit eb73563445
4 changed files with 33 additions and 10 deletions

View File

@ -89,9 +89,6 @@ AC_CHECK_DECL([uuid_make],,
# cunit # cunit
AC_CHECK_LIB([cunit], [CU_run_test], [CUNIT_LIBS=-lcunit]) AC_CHECK_LIB([cunit], [CU_run_test], [CUNIT_LIBS=-lcunit])
# WinSock
AC_CHECK_LIB([wsock32], [main])
AC_SUBST(DL_LIBS) AC_SUBST(DL_LIBS)
AC_SUBST(MATH_LIBS) AC_SUBST(MATH_LIBS)
AC_SUBST(PNG_LIBS) AC_SUBST(PNG_LIBS)
@ -295,6 +292,30 @@ fi
AM_CONDITIONAL([ENABLE_SSL], [test "x${have_ssl}" = "xyes"]) AM_CONDITIONAL([ENABLE_SSL], [test "x${have_ssl}" = "xyes"])
AC_SUBST(SSL_LIBS) AC_SUBST(SSL_LIBS)
#
# Winsock
#
have_winsock=disabled
WINSOCK_LIBS=
AC_ARG_WITH([winsock],
[AS_HELP_STRING([--with-winsock],
[support Windows Sockets API @<:@default=check@:>@])],
[],
[with_winsock=check])
if test "x$with_winsock" != "xno"
then
have_winsock=yes
AC_CHECK_LIB([wsock32], [main],
[WINSOCK_LIBS="-lwsock32"]
[AC_DEFINE([ENABLE_WINSOCK],,
[Whether Windows Socket API support is enabled])],
[have_winsock=no])
fi
AM_CONDITIONAL([ENABLE_WINSOCK], [test "x${have_winsock}" = "xyes"])
AC_SUBST(WINSOCK_LIBS)
# #
# Ogg Vorbis # Ogg Vorbis
@ -1234,6 +1255,7 @@ $PACKAGE_NAME version $PACKAGE_VERSION
libvorbis ........... ${have_vorbis} libvorbis ........... ${have_vorbis}
libpulse ............ ${have_pulse} libpulse ............ ${have_pulse}
libwebp ............. ${have_webp} libwebp ............. ${have_webp}
wsock32 ............. ${have_winsock}
Protocol support: Protocol support:

View File

@ -122,5 +122,6 @@ libguac_la_LDFLAGS = \
@SSL_LIBS@ \ @SSL_LIBS@ \
@UUID_LIBS@ \ @UUID_LIBS@ \
@VORBIS_LIBS@ \ @VORBIS_LIBS@ \
@WEBP_LIBS@ @WEBP_LIBS@ \
@WINSOCK_LIBS@

View File

@ -31,7 +31,7 @@
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h> #include <unistd.h>
#ifdef __MINGW32__ #ifdef ENABLE_WINSOCK
#include <winsock2.h> #include <winsock2.h>
#endif #endif
@ -100,8 +100,8 @@ ssize_t guac_socket_fd_write(guac_socket* socket,
int retval; int retval;
#ifdef __MINGW32__ #ifdef ENABLE_WINSOCK
/* MINGW32 WINSOCK only works with send() */ /* WSA only works with send() */
retval = send(data->fd, buf, count, 0); retval = send(data->fd, buf, count, 0);
#else #else
/* Use write() for all other platforms */ /* Use write() for all other platforms */
@ -148,8 +148,8 @@ static ssize_t guac_socket_fd_read_handler(guac_socket* socket,
int retval; int retval;
#ifdef __MINGW32__ #ifdef ENABLE_WINSOCK
/* MINGW32 WINSOCK only works with recv() */ /* Winsock only works with recv() */
retval = recv(data->fd, buf, count, 0); retval = recv(data->fd, buf, count, 0);
#else #else
/* Use read() for all other platforms */ /* Use read() for all other platforms */

View File

@ -19,7 +19,7 @@
#include "config.h" #include "config.h"
#ifdef __MINGW32__ #ifdef ENABLE_WINSOCK
# include <winsock2.h> # include <winsock2.h>
#else #else
# ifdef HAVE_POLL # ifdef HAVE_POLL