From 7a36701fa83d592f8e7cdf78967c1abaff7ca4b7 Mon Sep 17 00:00:00 2001 From: sezero Date: Mon, 21 Jun 2010 11:10:38 +0000 Subject: [PATCH] * Makefile, Makefile.darwin, Makefile.w32, Makefile.w64: Build changes: The SDL_net driver is now disabled by default and platform-specific network drivers will be used. To compile for SDL_net, a command like "make SDLNET=1" must be used, in which case a new preprocessor macro _USE_SDLNET will be defined in the CFLAGS. For windows targets when not using SDL_net, WINSOCK2 is added as another option: A command line like "make WINSOCK2=1" will enable WinSock2 api and a new preprocessor macro _USE_WINSOCK2 will be defined in the CFLAGS. Or, a command line like "make WINSOCK2=0" will disable WinSock2 api and the old WinSock 1.1 api will be used instead. For Win64, WinSock2 is enabled by default. For Win32, WinSock 1.1 is the default api. * net_bsd.c, net_dgrm.c, net_loop.c, net_main.c, net_sdl.c, net_sdlnet.c, net_udp.c, net_win.c, net_wins.c, net_wipx.c: Use the newly added net_sys.h header. The sys_socket_t type is not in use, yet. git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@215 af15c1b1-3010-417e-b628-4374ebc0bcbd --- quakespasm/Quake/Makefile | 16 +++++++++++++-- quakespasm/Quake/Makefile.darwin | 18 +++++++++++++--- quakespasm/Quake/Makefile.w32 | 29 ++++++++++++++++++++++---- quakespasm/Quake/Makefile.w64 | 29 ++++++++++++++++++++++---- quakespasm/Quake/net_bsd.c | 2 ++ quakespasm/Quake/net_dgrm.c | 35 ++++---------------------------- quakespasm/Quake/net_loop.c | 2 ++ quakespasm/Quake/net_main.c | 2 ++ quakespasm/Quake/net_sdl.c | 2 ++ quakespasm/Quake/net_sdlnet.c | 12 ++--------- quakespasm/Quake/net_udp.c | 19 ++--------------- quakespasm/Quake/net_win.c | 2 ++ quakespasm/Quake/net_wins.c | 6 +++--- quakespasm/Quake/net_wipx.c | 8 ++++---- 14 files changed, 104 insertions(+), 78 deletions(-) diff --git a/quakespasm/Quake/Makefile b/quakespasm/Quake/Makefile index 4ec08711..c645a4d3 100644 --- a/quakespasm/Quake/Makefile +++ b/quakespasm/Quake/Makefile @@ -1,7 +1,9 @@ -# GNU Makefile for QuakeSpasm, Apr. 24, 2010 +# GNU Makefile for QuakeSpasm unix targets, June 21, 2010 # # You need SDL and SDL_net fully installed. # "make DEBUG=1" builds debug client +# "make SDLNET=1" to enable SDL_net. otherwise the socket api will be +# used directly. # "make SDL_CONFIG=/path/to/sdl-config" for unusual SDL installations # # Build objects are separate from those of codeblocks for now @@ -18,6 +20,8 @@ check_gcc = $(shell if echo | $(CC) $(1) -S -o /dev/null -xc - > /dev/null 2>&1; # ============================================================================ DEBUG ?= 0 +SDLNET ?= 0 + BUILDDIR := . SYSNAME := $(shell uname -s) @@ -98,7 +102,12 @@ SDL_CONFIG ?= sdl-config SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags) SDL_LFLAGS := $(shell $(SDL_CONFIG) --libs) +ifeq ($(SDLNET),1) NET_LIBS := SDL_net +CFLAGS +=-D_USE_SDLNET +else +NET_LIBS := +endif COMMON_LIBS:= m GL @@ -128,8 +137,11 @@ SYSOBJ_SND := snd_sdl.o SYSOBJ_CDA := cd_sdl.o SYSOBJ_INPUT := in_sdl.o SYSOBJ_GL_VID:= gl_vidsdl.o -#SYSOBJ_NET := net_bsd.o net_udp.o +ifeq ($(SDLNET),1) SYSOBJ_NET := net_sdl.o net_sdlnet.o +else +SYSOBJ_NET := net_bsd.o net_udp.o +endif SYSOBJ_SYS := pl_linux.o sys_sdl.o SYSOBJ_MAIN:= main_sdl.o SYSOBJ_RES := diff --git a/quakespasm/Quake/Makefile.darwin b/quakespasm/Quake/Makefile.darwin index 9c038633..654877c1 100644 --- a/quakespasm/Quake/Makefile.darwin +++ b/quakespasm/Quake/Makefile.darwin @@ -1,7 +1,9 @@ -# GNU Makefile for QuakeSpasm, Apr. 24, 2010 +# GNU Makefile for QuakeSpasm for Darwin only, June 21, 2010 # # You need SDL and SDL_net fully installed. # "make DEBUG=1" builds debug client +# "make SDLNET=1" to enable SDL_net. otherwise the socket api will be +# used directly. # "make SDL_CONFIG=/path/to/sdl-config" for unusual SDL installations # # Build objects are separate from those of codeblocks for now @@ -18,6 +20,8 @@ check_gcc = $(shell if echo | $(CC) $(1) -S -o /dev/null -xc - > /dev/null 2>&1; # ============================================================================ DEBUG ?= 0 +SDLNET ?= 0 + BUILDDIR := . SYSNAME := $(shell uname -s) @@ -105,7 +109,12 @@ SDL_CONFIG=/usr/local/bin/sdl-config SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags) SDL_LFLAGS := $(shell $(SDL_CONFIG) --libs) -NET_LIBS = -L/usr/local/lib -l SDL_net +ifeq ($(SDLNET),1) +NET_LIBS =-L/usr/local/lib -l SDL_net +CFLAGS +=-D_USE_SDLNET +else +NET_LIBS = +endif COMMON_LIBS = -Wl,-framework,OpenGL @@ -136,8 +145,11 @@ SYSOBJ_SND := snd_sdl.o SYSOBJ_CDA := cd_sdl.o SYSOBJ_INPUT := in_sdl.o SYSOBJ_GL_VID:= gl_vidsdl.o -#SYSOBJ_NET := net_bsd.o net_udp.o +ifeq ($(SDLNET),1) SYSOBJ_NET := net_sdl.o net_sdlnet.o +else +SYSOBJ_NET := net_bsd.o net_udp.o +endif SYSOBJ_SYS := pl_osx.o sys_sdl.o SYSOBJ_MAIN:= main_sdl.o SYSOBJ_RES := diff --git a/quakespasm/Quake/Makefile.w32 b/quakespasm/Quake/Makefile.w32 index 1cfbd006..4132052b 100644 --- a/quakespasm/Quake/Makefile.w32 +++ b/quakespasm/Quake/Makefile.w32 @@ -1,6 +1,10 @@ # GNU Makefile for cross-compiling quakespasm.exe (Win32 : MinGW) -# using cross-toolchains on a linux host / Apr. 24, 2010. +# using cross-toolchains on a linux host / June 21, 2010. # "make DEBUG=1" builds debug client +# "make WINSOCK2=1" to use WinSock2 api when not using SDL_net. otherwise, +# WinSock 1.1 will be used. +# "make SDLNET=1" to enable SDL_net. otherwise, the WinSock api will be +# used directly. # "make SDL_CONFIG=/path/to/sdl-config" for sdl-config from cross-compiled SDL # ============================================================================ @@ -12,6 +16,8 @@ check_gcc = $(shell if echo | $(CC) $(1) -S -o /dev/null -xc - > /dev/null 2>&1; # ============================================================================ DEBUG ?= 0 +WINSOCK2 ?= 0 +SDLNET ?= 0 TOPDIR := $(shell pwd) @@ -50,9 +56,21 @@ SDL_CONFIG ?= sdl-config SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags) SDL_LFLAGS := $(shell $(SDL_CONFIG) --libs) -#NET_LIBS := ws2_32 -#NET_LIBS := wsock32 +ifeq ($(WINSOCK2),1) +DEFWINSOCK :=-D_USE_WINSOCK2 +LIBWINSOCK := ws2_32 +else +DEFWINSOCK := +LIBWINSOCK := wsock32 +endif + +ifeq ($(SDLNET),1) NET_LIBS := SDL_net +CFLAGS +=-D_USE_SDLNET +else +CFLAGS += $(DEFWINSOCK) +NET_LIBS := $(LIBWINSOCK) +endif COMMON_LIBS:= m opengl32 @@ -84,8 +102,11 @@ SYSOBJ_SND := snd_sdl.o SYSOBJ_CDA := cd_sdl.o SYSOBJ_INPUT := in_sdl.o SYSOBJ_GL_VID:= gl_vidsdl.o -#SYSOBJ_NET := net_win.o net_wins.o net_wipx.o +ifeq ($(SDLNET),1) SYSOBJ_NET := net_sdl.o net_sdlnet.o +else +SYSOBJ_NET := net_win.o net_wins.o net_wipx.o +endif SYSOBJ_SYS := pl_win.o sys_sdl.o SYSOBJ_MAIN:= main_sdl.o SYSOBJ_RES := QuakeSpasm.res diff --git a/quakespasm/Quake/Makefile.w64 b/quakespasm/Quake/Makefile.w64 index fc3de4f0..f3ddcd5b 100644 --- a/quakespasm/Quake/Makefile.w64 +++ b/quakespasm/Quake/Makefile.w64 @@ -1,6 +1,10 @@ # GNU Makefile for cross-compiling quakespasm.exe (Win64 : MinGW-w64) -# using cross-toolchains on a linux host / Apr. 24, 2010. +# using cross-toolchains on a linux host / June 21, 2010. # "make DEBUG=1" builds debug client +# "make WINSOCK2=0" to use the old WinSock 1.1 api when not using SDL_net. +# otherwise, WinSock2 api will be used. +# "make SDLNET=1" to enable SDL_net. otherwise, the WinSock api will be +# used directly. # "make SDL_CONFIG=/path/to/sdl-config" for sdl-config from cross-compiled SDL # ============================================================================ @@ -12,6 +16,8 @@ check_gcc = $(shell if echo | $(CC) $(1) -S -o /dev/null -xc - > /dev/null 2>&1; # ============================================================================ DEBUG ?= 0 +WINSOCK2 ?= 1 +SDLNET ?= 0 TOPDIR := $(shell pwd) @@ -50,9 +56,21 @@ SDL_CONFIG ?= sdl-config SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags) SDL_LFLAGS := $(shell $(SDL_CONFIG) --libs) -#NET_LIBS := ws2_32 -#NET_LIBS := wsock32 +ifeq ($(WINSOCK2),1) +DEFWINSOCK :=-D_USE_WINSOCK2 +LIBWINSOCK := ws2_32 +else +DEFWINSOCK := +LIBWINSOCK := wsock32 +endif + +ifeq ($(SDLNET),1) NET_LIBS := SDL_net +CFLAGS +=-D_USE_SDLNET +else +CFLAGS += $(DEFWINSOCK) +NET_LIBS := $(LIBWINSOCK) +endif COMMON_LIBS:= m opengl32 @@ -84,8 +102,11 @@ SYSOBJ_SND := snd_sdl.o SYSOBJ_CDA := cd_sdl.o SYSOBJ_INPUT := in_sdl.o SYSOBJ_GL_VID:= gl_vidsdl.o -#SYSOBJ_NET := net_win.o net_wins.o net_wipx.o +ifeq ($(SDLNET),1) SYSOBJ_NET := net_sdl.o net_sdlnet.o +else +SYSOBJ_NET := net_win.o net_wins.o net_wipx.o +endif SYSOBJ_SYS := pl_win.o sys_sdl.o SYSOBJ_MAIN:= main_sdl.o SYSOBJ_RES := QuakeSpasm.res diff --git a/quakespasm/Quake/net_bsd.c b/quakespasm/Quake/net_bsd.c index e3b6fe9f..cd900682 100644 --- a/quakespasm/Quake/net_bsd.c +++ b/quakespasm/Quake/net_bsd.c @@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "arch_def.h" +#include "net_sys.h" #include "quakedef.h" #include "net_defs.h" diff --git a/quakespasm/Quake/net_dgrm.c b/quakespasm/Quake/net_dgrm.c index 30e4549a..ab92dd5f 100644 --- a/quakespasm/Quake/net_dgrm.c +++ b/quakespasm/Quake/net_dgrm.c @@ -19,41 +19,14 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + // net_dgrm.c // This is enables a simple IP banning mechanism -//#define BAN_TEST disabled --kristian - -#ifdef BAN_TEST -#if defined(_WIN32) -#include -#elif defined (NeXT) -#include -#include -#else -#define AF_INET 2 /* internet */ -struct in_addr -{ - union - { - struct { unsigned char s_b1,s_b2,s_b3,s_b4; } S_un_b; - struct { unsigned short s_w1,s_w2; } S_un_w; - unsigned long S_addr; - } S_un; -}; -#define s_addr S_un.S_addr /* can be used for most tcp & ip code */ -struct sockaddr_in -{ - short sin_family; - unsigned short sin_port; - struct in_addr sin_addr; - char sin_zero[8]; -}; -char *inet_ntoa(struct in_addr in); -unsigned long inet_addr(const char *cp); -#endif -#endif // BAN_TEST +#define BAN_TEST +#include "arch_def.h" +#include "net_sys.h" #include "quakedef.h" #include "net_defs.h" #include "net_dgrm.h" diff --git a/quakespasm/Quake/net_loop.c b/quakespasm/Quake/net_loop.c index 6654c859..951a98d7 100644 --- a/quakespasm/Quake/net_loop.c +++ b/quakespasm/Quake/net_loop.c @@ -20,6 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // net_loop.c +#include "arch_def.h" +#include "net_sys.h" #include "quakedef.h" #include "net_defs.h" #include "net_loop.h" diff --git a/quakespasm/Quake/net_main.c b/quakespasm/Quake/net_main.c index 5a5639d1..3ec3df4e 100644 --- a/quakespasm/Quake/net_main.c +++ b/quakespasm/Quake/net_main.c @@ -20,6 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // net_main.c +#include "arch_def.h" +#include "net_sys.h" #include "quakedef.h" #include "net_defs.h" diff --git a/quakespasm/Quake/net_sdl.c b/quakespasm/Quake/net_sdl.c index 3304b3f8..8f09e07b 100644 --- a/quakespasm/Quake/net_sdl.c +++ b/quakespasm/Quake/net_sdl.c @@ -20,6 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "arch_def.h" +#include "net_sys.h" #include "quakedef.h" #include "net_defs.h" diff --git a/quakespasm/Quake/net_sdlnet.c b/quakespasm/Quake/net_sdlnet.c index 5dc16e99..77a9b8c5 100644 --- a/quakespasm/Quake/net_sdlnet.c +++ b/quakespasm/Quake/net_sdlnet.c @@ -18,22 +18,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "arch_def.h" +#include "net_sys.h" #include "quakedef.h" #include "net_defs.h" #include "net_sdlnet.h" #include "SDL.h" #include "SDL_net.h" -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 255 -#endif -#ifndef AF_INET -#define AF_INET 2 /* internet */ -#endif -#ifndef INADDR_LOOPBACK -#define INADDR_LOOPBACK 0x7f000001 /* 127.0.0.1 */ -#endif - #define MAX_SOCKETS 32 #if 0 /* enable for paranoid debugging purposes */ diff --git a/quakespasm/Quake/net_udp.c b/quakespasm/Quake/net_udp.c index 6e0b0429..0cc9a698 100644 --- a/quakespasm/Quake/net_udp.c +++ b/quakespasm/Quake/net_udp.c @@ -20,26 +20,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "arch_def.h" +#include "net_sys.h" #include "quakedef.h" #include "net_defs.h" -#include -#include - -#include -#include -#include - -#if defined(__sun) || defined(sun) -#include -#endif /* __sunos__ */ - -#include - -#include -#include -#include - static int net_acceptsocket = -1; // socket for fielding new connections static int net_controlsocket; static int net_broadcastsocket = 0; diff --git a/quakespasm/Quake/net_win.c b/quakespasm/Quake/net_win.c index 70d5e37f..9e41f1eb 100644 --- a/quakespasm/Quake/net_win.c +++ b/quakespasm/Quake/net_win.c @@ -19,6 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "arch_def.h" +#include "net_sys.h" #include "quakedef.h" #include "net_defs.h" diff --git a/quakespasm/Quake/net_wins.c b/quakespasm/Quake/net_wins.c index 6eca0511..a359621a 100644 --- a/quakespasm/Quake/net_wins.c +++ b/quakespasm/Quake/net_wins.c @@ -18,14 +18,14 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + // net_wins.c -#include "winsock.h" +#include "arch_def.h" +#include "net_sys.h" #include "quakedef.h" #include "net_defs.h" -#define MAXHOSTNAMELEN 256 - static int net_acceptsocket = -1; // socket for fielding new connections static int net_controlsocket; static int net_broadcastsocket = 0; diff --git a/quakespasm/Quake/net_wipx.c b/quakespasm/Quake/net_wipx.c index ba5d2993..93d681b9 100644 --- a/quakespasm/Quake/net_wipx.c +++ b/quakespasm/Quake/net_wipx.c @@ -18,18 +18,18 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + // net_wipx.c -#include "winsock.h" +#include "arch_def.h" +#include "net_sys.h" +#include #include "quakedef.h" #include "net_defs.h" -#include #include "net_wipx.h" extern cvar_t hostname; -#define MAXHOSTNAMELEN 256 - static int net_acceptsocket = -1; // socket for fielding new connections static int net_controlsocket; static struct sockaddr_ipx broadcastaddr;