| diff --git a/Quake/Makefile b/Quake/Makefile |
| --- a/Quake/Makefile |
| +++ b/Quake/Makefile |
| @@ -14,7 +14,7 @@ USE_CODEC_MP3=1 |
| USE_CODEC_VORBIS=1 |
| |
| # which library to use for mp3 decoding: mad or mpg123 |
| -MP3LIB=mad |
| +MP3LIB=mpg123 |
| # which library to use for ogg decoding: vorbis or tremor |
| VORBISLIB=vorbis |
| |
| @@ -45,11 +45,19 @@ STRIP ?= strip |
| #CPUFLAGS= -mtune=k8 |
| #CPUFLAGS= -march=atom |
| CPUFLAGS= |
| -LDFLAGS = |
| +LDFLAGS ?= |
| DFLAGS ?= |
| -CFLAGS ?= -Wall -Wno-trigraphs |
| +CFLAGS ?= -Wall |
| +CFLAGS += -Wno-unused-result -Wno-trigraphs |
| +CFLAGS += -DREGAL_NO_ENUM_GL_EXT_TEXTURE_FILTER_ANISOTROPIC |
| CFLAGS += $(CPUFLAGS) |
| |
| +ifneq ($(V),1) |
| +RUN_CC = @echo " CC " $@; |
| +RUN_CCLD = @echo " CCLD " $@; |
| +RUN_STRIP = @echo " STRIP " $@; |
| +endif |
| + |
| ifneq ($(DEBUG),0) |
| DFLAGS += -DDEBUG |
| CFLAGS += -g |
| @@ -59,7 +67,7 @@ DFLAGS += -DNDEBUG |
| CFLAGS += -O2 |
| CFLAGS += $(call check_gcc,-fweb,) |
| CFLAGS += $(call check_gcc,-frename-registers,) |
| -cmd_strip=$(STRIP) $(1) |
| +cmd_strip=$(RUN_STRIP)$(STRIP) $(1) |
| define do_strip |
| $(call cmd_strip,$(1)); |
| endef |
| @@ -81,8 +89,8 @@ X11BASE_GUESS := $(shell \ |
| X11BASE ?= $(X11BASE_GUESS) |
| |
| ifneq ($(X11BASE),) |
| -LDFLAGS+= -L$(X11BASE)/lib |
| -CFLAGS += -I$(X11BASE)/include |
| +LDFLAGS += -L$(X11BASE)/lib |
| +CPPFLAGS += -I$(X11BASE)/include |
| endif |
| |
| SDL_CONFIG ?= sdl-config |
| @@ -91,7 +99,7 @@ SDL_LIBS := $(shell $(SDL_CONFIG) --libs) |
| |
| ifeq ($(SDLNET),1) |
| NET_LIBS :=-lSDL_net |
| -CFLAGS +=-D_USE_SDLNET |
| +CPPFLAGS +=-D_USE_SDLNET |
| else |
| ifeq ($(HOST_OS),sunos) |
| NET_LIBS :=-lsocket -lnsl -lresolv |
| @@ -101,7 +109,7 @@ endif |
| endif |
| |
| ifeq ($(USE_QS_CONBACK),1) |
| -CFLAGS+= -DUSE_QS_CONBACK |
| +CPPFLAGS += -DUSE_QS_CONBACK |
| endif |
| |
| ifneq ($(VORBISLIB),vorbis) |
| @@ -133,18 +141,21 @@ endif |
| |
| CODECLIBS := |
| ifeq ($(USE_CODEC_WAVE),1) |
| -CFLAGS+= -DUSE_CODEC_WAVE |
| +CPPFLAGS += -DUSE_CODEC_WAVE |
| endif |
| ifeq ($(USE_CODEC_VORBIS),1) |
| -CFLAGS+= -DUSE_CODEC_VORBIS $(cpp_vorbisdec) |
| +CPPFLAGS += -DUSE_CODEC_VORBIS $(cpp_vorbisdec) |
| CODECLIBS+= $(lib_vorbisdec) |
| endif |
| ifeq ($(USE_CODEC_MP3),1) |
| -CFLAGS+= -DUSE_CODEC_MP3 |
| +CPPFLAGS+= -DUSE_CODEC_MP3 |
| CODECLIBS+= $(lib_mp3dec) |
| endif |
| |
| -COMMON_LIBS:= -lm -lGL |
| +COMMON_LIBS := -lm |
| +ifndef NACL_ARCH |
| +COMMON_LIBS += -lGL |
| +endif |
| |
| LIBS := $(COMMON_LIBS) $(NET_LIBS) $(CODECLIBS) |
| |
| @@ -154,14 +165,14 @@ LIBS := $(COMMON_LIBS) $(NET_LIBS) $(CODECLIBS) |
| |
| .PHONY: clean debug release |
| |
| -DEFAULT_TARGET := quakespasm |
| +DEFAULT_TARGET := quakespasm$(EXEEXT) |
| |
| # --------------------------- |
| # rules |
| # --------------------------- |
| |
| %.o: %.c |
| - $(CC) $(DFLAGS) -c $(CFLAGS) $(SDL_CFLAGS) -o $@ $^ |
| + $(RUN_CC)$(CC) $(DFLAGS) -c $(CPPFLAGS) $(CFLAGS) $(SDL_CFLAGS) -o $@ $^ |
| |
| # ---------------------------------------------------------------------------- |
| # objects |
| @@ -254,11 +265,11 @@ OBJS := strlcat.o \ |
| # Linux build rules |
| # ------------------------ |
| |
| -quakespasm: $(OBJS) |
| - $(LINKER) $(OBJS) $(LDFLAGS) $(LIBS) $(SDL_LIBS) -o $@ |
| +quakespasm$(EXEEXT): $(OBJS) |
| + $(RUN_CCLD)$(LINKER) $(OBJS) $(LDFLAGS) $(LIBS) $(SDL_LIBS) -o $@ |
| $(call do_strip,$@) |
| |
| -release: quakespasm |
| +release: quakespasm$(EXEEXT) |
| debug: |
| $(error Use "make DEBUG=1") |
| |
| diff --git a/Quake/arch_def.h b/Quake/arch_def.h |
| --- a/Quake/arch_def.h |
| +++ b/Quake/arch_def.h |
| @@ -77,6 +77,7 @@ |
| defined(__sun) || defined(sun) || \ |
| defined(__sgi) || defined(sgi) || defined(__sgi__) || \ |
| defined(__GNU__) /* GNU/Hurd */ || \ |
| + defined(__native_client__) || \ |
| defined(__QNX__) || defined(__QNXNTO__) |
| # if !defined(PLATFORM_UNIX) |
| # define PLATFORM_UNIX 1 |
| @@ -108,6 +109,8 @@ |
| # define PLATFORM_STRING "Windows" |
| #elif defined(PLATFORM_DOS) |
| # define PLATFORM_STRING "DOS" |
| +#elif defined(__native_client__) |
| +# define PLATFORM_STRING "NaCl" |
| #elif defined(__linux__) || defined(__linux) |
| # define PLATFORM_STRING "Linux" |
| #elif defined(__DragonFly__) |
| diff --git a/Quake/net_udp.c b/Quake/net_udp.c |
| --- a/Quake/net_udp.c |
| +++ b/Quake/net_udp.c |
| @@ -132,7 +132,9 @@ sys_socket_t UDP_OpenSocket (int port) |
| { |
| sys_socket_t newsocket; |
| struct sockaddr_in address; |
| +#ifdef FIONBIO |
| int _true = 1; |
| +#endif |
| int err; |
| |
| if ((newsocket = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) |
| @@ -142,8 +144,10 @@ sys_socket_t UDP_OpenSocket (int port) |
| return INVALID_SOCKET; |
| } |
| |
| +#ifdef FIONBIO |
| if (ioctlsocket (newsocket, FIONBIO, &_true) == SOCKET_ERROR) |
| goto ErrorReturn; |
| +#endif |
| |
| memset(&address, 0, sizeof(struct sockaddr_in)); |
| address.sin_family = AF_INET; |
| @@ -152,7 +156,9 @@ sys_socket_t UDP_OpenSocket (int port) |
| if (bind (newsocket, (struct sockaddr *)&address, sizeof(address)) == 0) |
| return newsocket; |
| |
| +#ifdef FIONBIO |
| ErrorReturn: |
| +#endif |
| err = SOCKETERRNO; |
| Con_SafePrintf("UDP_OpenSocket: %s\n", socketerror(err)); |
| UDP_CloseSocket (newsocket); |
| @@ -235,7 +241,9 @@ int UDP_Connect (sys_socket_t socketid, struct qsockaddr *addr) |
| |
| sys_socket_t UDP_CheckNewConnections (void) |
| { |
| +#ifdef FIONREAD |
| int available; |
| +#endif |
| struct sockaddr_in from; |
| socklen_t fromlen; |
| char buff[1]; |
| @@ -243,6 +251,7 @@ sys_socket_t UDP_CheckNewConnections (void) |
| if (net_acceptsocket == INVALID_SOCKET) |
| return INVALID_SOCKET; |
| |
| +#ifdef FIONREAD |
| if (ioctl (net_acceptsocket, FIONREAD, &available) == -1) |
| { |
| int err = SOCKETERRNO; |
| @@ -250,6 +259,8 @@ sys_socket_t UDP_CheckNewConnections (void) |
| } |
| if (available) |
| return net_acceptsocket; |
| +#endif |
| + |
| // quietly absorb empty packets |
| recvfrom (net_acceptsocket, buff, 0, 0, (struct sockaddr *) &from, &fromlen); |
| return INVALID_SOCKET; |
| @@ -382,6 +393,7 @@ int UDP_GetSocketAddr (sys_socket_t socketid, struct qsockaddr *addr) |
| |
| int UDP_GetNameFromAddr (struct qsockaddr *addr, char *name) |
| { |
| +#ifndef __native_client__ |
| struct hostent *hostentry; |
| |
| hostentry = gethostbyaddr ((char *)&((struct sockaddr_in *)addr)->sin_addr, |
| @@ -391,6 +403,7 @@ int UDP_GetNameFromAddr (struct qsockaddr *addr, char *name) |
| strncpy (name, (char *)hostentry->h_name, NET_NAMELEN - 1); |
| return 0; |
| } |
| +#endif |
| |
| strcpy (name, UDP_AddrToString (addr)); |
| return 0; |
| diff --git a/Quake/sys_sdl_unix.c b/Quake/sys_sdl_unix.c |
| --- a/Quake/sys_sdl_unix.c |
| +++ b/Quake/sys_sdl_unix.c |
| @@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| #include <unistd.h> |
| #include <sys/stat.h> |
| #include <sys/time.h> |
| +#include <sys/select.h> |
| #include <fcntl.h> |
| #include <time.h> |
| |