1
0
Fork 0

Make it possible to disable alsa. Fix various compiler and configure related bugs. Hopefully fixes 1677839, 1678736, 1693635,1697017 and the various email reports

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2855
This commit is contained in:
Peter Veenstra 2007-05-15 15:51:30 +00:00
parent 481d37adf6
commit 0911359ee9
4 changed files with 92 additions and 44 deletions

View file

@ -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 <stdio.h>
#ifdef STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#else
# ifdef HAVE_STDLIB_H
# include <stdlib.h>
# endif
#endif
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
])
dnl check for the socklen_t (darwin doesn't always have it)
AC_COMPILE_IFELSE([
#include <stdio.h>
#ifdef STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#else
# ifdef HAVE_STDLIB_H
# include <stdlib.h>
# endif
#endif
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#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 <unistd.h>
@ -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*)

View file

@ -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 <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define SOCKET int
#elif defined WIN32
#define CAPWORD (NETWRAPPER_TCP|NETWRAPPER_TCP_NATIVESOCKET)
#include <winsock.h>
typedef int socklen_t;
#elif defined __APPLE__
#define CAPWORD (NETWRAPPER_TCP|NETWRAPPER_TCP_NATIVESOCKET)
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#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<char*>(destination),port)) {
listensocketset = SDLNet_AllocSocketSet(1);
if(!listensocketset) return;
mysock = SDLNet_TCP_Open(&openip);

View file

@ -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 <winsock2.h>
#include <ws2tcpip.h> //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 <stdio.h> //darwin
#include <stdlib.h> //darwin
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
//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

View file

@ -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;