diff --git a/configure.in b/configure.in index c2fd3576..13fea9ce 100644 --- a/configure.in +++ b/configure.in @@ -50,6 +50,42 @@ AC_CHECK_SIZEOF(unsigned long) AC_CHECK_SIZEOF(unsigned long long) AC_CHECK_SIZEOF(int *) +dnl some semi complex check for sys/socket so it works on darwin as well +AC_CHECK_HEADERS([stdlib.h sys/types.h]) +AC_CHECK_HEADERS([sys/socket.h netinet/in.h], [], [], +[#include +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_SYS_TYPES_H +# include +#endif +]) + +dnl check for the socklen_t (darwin doesn't always have it) +AC_COMPILE_IFELSE([ +#include +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +],[],[AC_DEFINE([socklen_t],[int],[Define to `int` if you don't have socklen_t])]) + AC_MSG_CHECKING(if environ can be included) AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include @@ -93,7 +129,18 @@ int x=10;if( __builtin_expect ((x==1),0) ) ; #switch language back AC_LANG_POP(C++) -AM_PATH_ALSA(0.9.0, AC_DEFINE(HAVE_ALSA,1,[Define to 1 to use ALSA for MIDI]) , : ) +dnl enable disable alsa and pass it's cflags to CXXFLAGS +AC_ARG_ENABLE(alsa-midi, +AC_HELP_STRING([--enable-alsa-midi],[compile with alsa midi support (default yes)]), +[ case "${enableval}" in + yes) alsa_midi=true;; + no) alsa_midi=false;; +esac], +[alsa_midi=true]) +if test x$alsa_midi = xtrue ; then + AM_PATH_ALSA(0.9.0, AC_DEFINE(HAVE_ALSA,1,[Define to 1 to use ALSA for MIDI]) , : ) + CXXFLAGS="$CXXFLAGS $ALSA_CFLAGS" +fi #Check for big endian machine, should #define WORDS_BIGENDIAN if so AC_C_BIGENDIAN @@ -327,8 +374,8 @@ case "$target" in AC_DEFINE(MACOSX, 1, [Compiling on Mac OS X]) LIBS="$LIBS -framework AudioUnit" ;; - *-*-linux-gnu*) - AC_DEFINE(LINUX, 1, [Compiling on GNU/Linux]) + *-*-freebsd* | *-*-linux*) + AC_DEFINE(LINUX, 1, [Compiling on GNU/Linux or *BSD]) AC_DEFINE(C_DIRECTSERIAL, 1, [ Define to 1 if you want serial passthrough support (Win32, Posix and OS/2).]) ;; *-*-os2-emx*) diff --git a/src/hardware/serialport/misc_util.cpp b/src/hardware/serialport/misc_util.cpp index 5b999719..97379094 100644 --- a/src/hardware/serialport/misc_util.cpp +++ b/src/hardware/serialport/misc_util.cpp @@ -5,39 +5,13 @@ /*****************************************************************************/ // C++ SDLnet wrapper -// Socket inheritance -#if defined LINUX || defined OS2 -#define CAPWORD (NETWRAPPER_TCP|NETWRAPPER_TCP_NATIVESOCKET) -#ifdef OS2 -typedef int socklen_t; -#endif -#include -#include -#include -#define SOCKET int - -#elif defined WIN32 -#define CAPWORD (NETWRAPPER_TCP|NETWRAPPER_TCP_NATIVESOCKET) -#include -typedef int socklen_t; - -#elif defined __APPLE__ -#define CAPWORD (NETWRAPPER_TCP|NETWRAPPER_TCP_NATIVESOCKET) -#include -#include -#include -#define SOCKET socklen_t - -#else -#define CAPWORD NETWRAPPER_TCP -#endif - #include "misc_util.h" - struct _TCPsocketX { int ready; +#ifdef NATIVESOCKETS SOCKET channel; +#endif IPaddress remoteAddress; IPaddress localAddress; int sflag; @@ -67,7 +41,7 @@ TCPClientSocket::TCPClientSocket(int platformsocket) { // fill the SDL socket manually ((struct _TCPsocketX*)nativetcpstruct)->ready=0; ((struct _TCPsocketX*)nativetcpstruct)->sflag=0; - ((struct _TCPsocketX*)nativetcpstruct)->channel=platformsocket; + ((struct _TCPsocketX*)nativetcpstruct)->channel=(SOCKET) platformsocket; sockaddr_in sa; socklen_t sz; sz=sizeof(sa); @@ -146,7 +120,8 @@ TCPClientSocket::TCPClientSocket(const char* destination, Bit16u port) { listensocketset=0; IPaddress openip; - if (!SDLNet_ResolveHost(&openip,destination,port)) { + //Ancient versions of SDL_net had this as char*. People still appear to be using this one. + if (!SDLNet_ResolveHost(&openip,const_cast(destination),port)) { listensocketset = SDLNet_AllocSocketSet(1); if(!listensocketset) return; mysock = SDLNet_TCP_Open(&openip); diff --git a/src/hardware/serialport/misc_util.h b/src/hardware/serialport/misc_util.h index 9b89ac18..08a36123 100644 --- a/src/hardware/serialport/misc_util.h +++ b/src/hardware/serialport/misc_util.h @@ -1,24 +1,48 @@ #ifndef SDLNETWRAPPER_H #define SDLNETWRAPPER_H +#ifndef DOSBOX_DOSBOX_H +#include "dosbox.h" +#endif + #if C_MODEM -#include "SDL_net.h" +# ifndef DOSBOX_SUPPORT_H #include "support.h" - -#if defined LINUX || defined OS2 -#define NATIVESOCKETS - -#elif defined WIN32 -#define NATIVESOCKETS - -#else #endif // Netwrapper Capabilities #define NETWRAPPER_TCP 1 #define NETWRAPPER_TCP_NATIVESOCKET 2 +#if defined WIN32 + #define NATIVESOCKETS + #include + #include //for socklen_t + //typedef int socklen_t; + +//Tests for BSD/OS2/LINUX +#elif defined HAVE_STDLIB_H && defined HAVE_SYS_TYPES_H && defined HAVE_SYS_SOCKET_H && defined HAVE_NETINET_IN_H + #define NATIVESOCKETS + #define SOCKET int + #include //darwin + #include //darwin + #include + #include + #include + //socklen_t should be handled by configure +#endif + +#ifdef NATIVESOCKETS + #define CAPWORD (NETWRAPPER_TCP|NETWRAPPER_TCP_NATIVESOCKET) +#else + #define CAPWORD NETWRAPPER_TCP +#endif + +#include "SDL_net.h" + + + Bit32u Netwrapper_GetCapabilities(); @@ -74,6 +98,6 @@ class TCPServerSocket { }; -#endif +#endif //C_MODEM -#endif //#if C_MODEM +#endif //# SDLNETWRAPPER_H diff --git a/src/hardware/serialport/nullmodem.cpp b/src/hardware/serialport/nullmodem.cpp index c0ca3f35..f0853c17 100644 --- a/src/hardware/serialport/nullmodem.cpp +++ b/src/hardware/serialport/nullmodem.cpp @@ -90,6 +90,7 @@ CNullModem::CNullModem(Bitu id, CommandLine* cmd):CSerial (id, cmd) { } // socket inheritance if(getBituSubstring("inhsocket:", &bool_temp, cmd)) { +#ifdef NATIVESOCKETS if(Netwrapper_GetCapabilities()&NETWRAPPER_TCP_NATIVESOCKET) { if(bool_temp==1) { int sock; @@ -128,6 +129,7 @@ CNullModem::CNullModem(Bitu id, CommandLine* cmd):CSerial (id, cmd) { } } } else { +#endif LOG_MSG("Serial%d: socket inheritance not supported on this platform.", COMNUMBER); return;