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
AC_CHECK_LIB([cunit], [CU_run_test], [CUNIT_LIBS=-lcunit])
# WinSock
AC_CHECK_LIB([wsock32], [main])
AC_SUBST(DL_LIBS)
AC_SUBST(MATH_LIBS)
AC_SUBST(PNG_LIBS)
@ -295,6 +292,30 @@ fi
AM_CONDITIONAL([ENABLE_SSL], [test "x${have_ssl}" = "xyes"])
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
@ -1234,6 +1255,7 @@ $PACKAGE_NAME version $PACKAGE_VERSION
libvorbis ........... ${have_vorbis}
libpulse ............ ${have_pulse}
libwebp ............. ${have_webp}
wsock32 ............. ${have_winsock}
Protocol support:

View File

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

View File

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

View File

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