r97 - in trunk: . code/botlib code/client code/game code/jpeg-6 code/qcommon code/renderer code/unix code/win32

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Sep 21 23:21:38 EDT 2005


Author: tma
Date: 2005-09-21 23:21:33 -0400 (Wed, 21 Sep 2005)
New Revision: 97

Modified:
   trunk/code/botlib/l_utils.h
   trunk/code/client/snd_mix.c
   trunk/code/game/ai_main.c
   trunk/code/game/q_math.c
   trunk/code/game/q_shared.h
   trunk/code/jpeg-6/jinclude.h
   trunk/code/jpeg-6/jmorecfg.h
   trunk/code/qcommon/common.c
   trunk/code/qcommon/md4.c
   trunk/code/qcommon/vm.c
   trunk/code/qcommon/vm_interpreted.c
   trunk/code/qcommon/vm_x86.c
   trunk/code/renderer/qgl.h
   trunk/code/renderer/tr_font.c
   trunk/code/renderer/tr_shade_calc.c
   trunk/code/unix/ChangeLog
   trunk/code/unix/Makefile
   trunk/code/unix/qasm.h
   trunk/code/win32/win_glimp.c
   trunk/code/win32/win_input.c
   trunk/code/win32/win_local.h
   trunk/code/win32/win_main.c
   trunk/code/win32/win_net.c
   trunk/code/win32/win_qgl.c
   trunk/code/win32/win_shared.c
   trunk/code/win32/win_snd.c
   trunk/code/win32/winquake.rc
   trunk/i_o-q3-readme
Log:
* Port to MinGW


Modified: trunk/code/botlib/l_utils.h
===================================================================
--- trunk/code/botlib/l_utils.h	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/botlib/l_utils.h	2005-09-22 03:21:33 UTC (rev 97)
@@ -30,6 +30,8 @@
  *****************************************************************************/
 
 #define Vector2Angles(v,a)		vectoangles(v,a)
+#ifndef MAX_PATH
 #define MAX_PATH				MAX_QPATH
+#endif
 #define Maximum(x,y)			(x > y ? x : y)
 #define Minimum(x,y)			(x < y ? x : y)

Modified: trunk/code/client/snd_mix.c
===================================================================
--- trunk/code/client/snd_mix.c	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/client/snd_mix.c	2005-09-22 03:21:33 UTC (rev 97)
@@ -34,7 +34,7 @@
 int      snd_linear_count;
 short*   snd_out;
 
-#if !( (defined __linux__ || defined __FreeBSD__ ) && (defined __i386__) ) // rb010123
+#if !( (defined __linux__ || defined __FreeBSD__ || defined __MINGW32__ ) && (defined __i386__) ) // rb010123
 #if	!id386
 
 void S_WriteLinearBlastStereo16 (void)

Modified: trunk/code/game/ai_main.c
===================================================================
--- trunk/code/game/ai_main.c	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/game/ai_main.c	2005-09-22 03:21:33 UTC (rev 97)
@@ -55,7 +55,9 @@
 #include "inv.h"
 #include "syn.h"
 
+#ifndef MAX_PATH
 #define MAX_PATH		144
+#endif
 
 
 //bot states

Modified: trunk/code/game/q_math.c
===================================================================
--- trunk/code/game/q_math.c	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/game/q_math.c	2005-09-22 03:21:33 UTC (rev 97)
@@ -740,7 +740,7 @@
 ==================
 */
 
-#if !( (defined __linux__ || __FreeBSD__) && (defined __i386__) && (!defined C_ONLY)) // rb010123
+#if !( (defined __linux__ || __FreeBSD__ || __MINGW32__) && (defined __i386__) && (!defined C_ONLY)) // rb010123
 
 #if defined __LCC__ || defined C_ONLY || !id386 || defined __VECTORC
 

Modified: trunk/code/game/q_shared.h
===================================================================
--- trunk/code/game/q_shared.h	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/game/q_shared.h	2005-09-22 03:21:33 UTC (rev 97)
@@ -31,7 +31,7 @@
 
 #define MAX_TEAMNAME 32
 
-#ifdef _WIN32
+#ifdef _MSC_VER
 
 #pragma warning(disable : 4018)     // signed/unsigned mismatch
 #pragma warning(disable : 4032)
@@ -90,7 +90,7 @@
 
 #endif
 
-#ifdef _WIN32
+#ifdef _MSC_VER
 
 //#pragma intrinsic( memset, memcpy )
 
@@ -134,6 +134,7 @@
 #define	QDECL	__cdecl
 
 // buildstring will be incorporated into the version string
+#ifdef _MSC_VER
 #ifdef NDEBUG
 #ifdef _M_IX86
 #define	CPUSTRING	"win-x86"
@@ -147,14 +148,25 @@
 #define	CPUSTRING	"win-AXP-debug"
 #endif
 #endif
+#elif defined __MINGW32__
+#ifdef NDEBUG
+#ifdef __i386__
+#define	CPUSTRING	"mingw-x86"
+#endif
+#else
+#ifdef __i386__
+#define	CPUSTRING	"mingw-x86-debug"
+#endif
+#endif
+#endif
 
 #define ID_INLINE __inline 
 
 static ID_INLINE short BigShort( short l) { return ShortSwap(l); }
 #define LittleShort
-static ID_INLINE int BigLong(int l) { LongSwap(l); }
+static ID_INLINE int BigLong(int l) { return LongSwap(l); }
 #define LittleLong
-static ID_INLINE float BigFloat(const float l) { FloatSwap(&l); }
+static ID_INLINE float BigFloat(const float l) { return FloatSwap(&l); }
 #define LittleFloat
 
 #define	PATH_SEP '\\'

Modified: trunk/code/jpeg-6/jinclude.h
===================================================================
--- trunk/code/jpeg-6/jinclude.h	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/jpeg-6/jinclude.h	2005-09-22 03:21:33 UTC (rev 97)
@@ -15,7 +15,7 @@
  */
 
 
-#ifdef _WIN32
+#ifdef _MSC_VER
 
 #pragma warning(disable : 4018)     // signed/unsigned mismatch
 #pragma warning(disable : 4032)

Modified: trunk/code/jpeg-6/jmorecfg.h
===================================================================
--- trunk/code/jpeg-6/jmorecfg.h	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/jpeg-6/jmorecfg.h	2005-09-22 03:21:33 UTC (rev 97)
@@ -149,7 +149,9 @@
 typedef unsigned int UINT16;
 #endif /* HAVE_UNSIGNED_SHORT */
 
+#ifndef DONT_TYPEDEF_INT32
 typedef long INT32;
+#endif
 
 /* INT16 must hold at least the values -32768..32767. */
 

Modified: trunk/code/qcommon/common.c
===================================================================
--- trunk/code/qcommon/common.c	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/qcommon/common.c	2005-09-22 03:21:33 UTC (rev 97)
@@ -2817,7 +2817,7 @@
 }
 
 #if !( defined __VECTORC )
-#if !( defined __linux__ || defined __FreeBSD__ )  // r010123 - include FreeBSD 
+#if !( defined __linux__ || defined __FreeBSD__ || defined __MINGW32__ )  // r010123 - include FreeBSD 
 #if ((!id386) && (!defined __i386__)) // rcg010212 - for PPC
 
 void Com_Memcpy (void* dest, const void* src, const size_t count)

Modified: trunk/code/qcommon/md4.c
===================================================================
--- trunk/code/qcommon/md4.c	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/qcommon/md4.c	2005-09-22 03:21:33 UTC (rev 97)
@@ -1,7 +1,7 @@
 /* GLOBAL.H - RSAREF types and constants */
 
 #include <string.h>
-#if defined(_WIN32)
+#ifdef _MSC_VER
 #pragma warning(disable : 4711)		// selected for automatic inline expansion
 #endif
 

Modified: trunk/code/qcommon/vm.c
===================================================================
--- trunk/code/qcommon/vm.c	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/qcommon/vm.c	2005-09-22 03:21:33 UTC (rev 97)
@@ -858,7 +858,7 @@
 
 
 
-#ifdef oDLL_ONLY // bk010215 - for DLL_ONLY dedicated servers/builds w/o VM
+#ifdef DLL_ONLY // bk010215 - for DLL_ONLY dedicated servers/builds w/o VM
 int	VM_CallCompiled( vm_t *vm, int *args ) {
   return(0); 
 }

Modified: trunk/code/qcommon/vm_interpreted.c
===================================================================
--- trunk/code/qcommon/vm_interpreted.c	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/qcommon/vm_interpreted.c	2005-09-22 03:21:33 UTC (rev 97)
@@ -21,6 +21,7 @@
 */
 #include "vm_local.h"
 
+//#define	DEBUG_VM
 #ifdef DEBUG_VM // bk001204
 static char	*opnames[256] = {
 	"OP_UNDEF", 
@@ -306,7 +307,6 @@
 */
 #define	MAX_STACK	256
 #define	STACK_MASK	(MAX_STACK-1)
-//#define	DEBUG_VM
 
 #define	DEBUGSTR va("%s%i", VM_Indent(vm), opStack-stack )
 

Modified: trunk/code/qcommon/vm_x86.c
===================================================================
--- trunk/code/qcommon/vm_x86.c	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/qcommon/vm_x86.c	2005-09-22 03:21:33 UTC (rev 97)
@@ -60,8 +60,13 @@
 static	int		ftolPtr = (int)_ftol;
 #endif
 
+#ifndef __MINGW32__
 void AsmCall( void );
 static	int		asmCallPtr = (int)AsmCall;
+#else
+void doAsmCall( void );
+static	int		asmCallPtr = (int)doAsmCall;
+#endif
 
 #else // _WIN32
 
@@ -105,7 +110,7 @@
 AsmCall
 =================
 */
-#ifdef _WIN32
+#ifdef _MSC_VER
 __declspec( naked ) void AsmCall( void ) {
 int		programStack;
 int		*opStack;
@@ -168,7 +173,7 @@
 
 }
 
-#else //!_WIN32
+#else //!_MSC_VER
 
 static	int		callProgramStack;
 static	int		*callOpStack;
@@ -185,13 +190,14 @@
 	// save the stack to allow recursive VM entry
 	currentVM->programStack = callProgramStack - 4;
 	*(int *)((byte *)currentVM->dataBase + callProgramStack + 4) = callSyscallNum;
-//VM_LogSyscalls(  (int *)((byte *)currentVM->dataBase + programStack + 4) );
+	//VM_LogSyscalls((int *)((byte *)currentVM->dataBase + callProgramStack + 4) );
 	*(callOpStack2+1) = currentVM->systemCall( (int *)((byte *)currentVM->dataBase + callProgramStack + 4) );
 
  	currentVM = savedVM;
 }
 
 void AsmCall( void ) {
+#ifndef __MINGW32__
 	__asm__("doAsmCall:      			\n\t" \
 			"	movl (%%edi),%%eax			\n\t" \
 			"	subl $4,%%edi				\n\t" \
@@ -223,6 +229,42 @@
 			: "rm" (instructionPointers) \
 			: "ax", "di", "si", "cx" \
 	);
+#else
+	// The only difference is _ added to the C symbols. It seems mingw
+	// mangles all symbols this way, like linux gcc does when producing
+	// a.out instead of elf
+	__asm__("_doAsmCall:      			\n\t" \
+			"	movl (%%edi),%%eax			\n\t" \
+			"	subl $4,%%edi				\n\t" \
+			"   orl %%eax,%%eax				\n\t" \
+			"	jl systemCall				\n\t" \
+			"	shll $2,%%eax				\n\t" \
+			"	addl %3,%%eax				\n\t" \
+			"	call *(%%eax)				\n\t" \
+		  " movl (%%edi),%%eax   \n\t" \
+	    " andl _callMask, %%eax \n\t" \
+			"	jmp doret					   \n\t" \
+			"systemCall:					\n\t" \
+			"	negl %%eax					\n\t" \
+			"	decl %%eax					\n\t" \
+			"	movl %%eax,%0				\n\t" \
+			"	movl %%esi,%1				\n\t" \
+			"	movl %%edi,%2				\n\t" \
+			"	pushl %%ecx					\n\t" \
+			"	pushl %%esi					\n\t" \
+			"	pushl %%edi					\n\t" \
+			"	call _callAsmCall			\n\t" \
+			"	popl %%edi					\n\t" \
+			"	popl %%esi					\n\t" \
+			"	popl %%ecx					\n\t" \
+			"	addl $4,%%edi				\n\t" \
+			"doret:							\n\t" \
+			"	ret							\n\t" \
+			: "=rm" (callSyscallNum), "=rm" (callProgramStack), "=rm" (callOpStack) \
+			: "rm" (instructionPointers) \
+			: "ax", "di", "si", "cx" \
+	);
+#endif
 }
 #endif
 
@@ -1140,7 +1182,7 @@
 	entryPoint = vm->codeBase;
 	opStack = &stack;
 
-#ifdef _WIN32
+#ifdef _MSC_VER
 	__asm  {
 		pushad
 		mov		esi, programStack;

Modified: trunk/code/renderer/qgl.h
===================================================================
--- trunk/code/renderer/qgl.h	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/renderer/qgl.h	2005-09-22 03:21:33 UTC (rev 97)
@@ -32,12 +32,15 @@
 
 #elif defined( _WIN32 )
 
+#if _MSC_VER
 #pragma warning (disable: 4201)
 #pragma warning (disable: 4214)
 #pragma warning (disable: 4514)
 #pragma warning (disable: 4032)
 #pragma warning (disable: 4201)
 #pragma warning (disable: 4214)
+#endif
+
 #include <windows.h>
 #include <gl/gl.h>
 

Modified: trunk/code/renderer/tr_font.c
===================================================================
--- trunk/code/renderer/tr_font.c	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/renderer/tr_font.c	2005-09-22 03:21:33 UTC (rev 97)
@@ -311,12 +311,12 @@
 
 float readFloat( void ) {
 	poor	me;
-#if __WORD_ORDER == __BIG_ENDIAN
+#if defined BigFloat
 	me.fred[0] = fdFile[fdOffset+3];
 	me.fred[1] = fdFile[fdOffset+2];
 	me.fred[2] = fdFile[fdOffset+1];
 	me.fred[3] = fdFile[fdOffset+0];
-#else
+#elif defined LittleFloat
 	me.fred[0] = fdFile[fdOffset+0];
 	me.fred[1] = fdFile[fdOffset+1];
 	me.fred[2] = fdFile[fdOffset+2];

Modified: trunk/code/renderer/tr_shade_calc.c
===================================================================
--- trunk/code/renderer/tr_shade_calc.c	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/renderer/tr_shade_calc.c	2005-09-22 03:21:33 UTC (rev 97)
@@ -1025,10 +1025,14 @@
 #if id386 && !( (defined __linux__ || defined __FreeBSD__ ) && (defined __i386__ ) ) // rb010123
 
 long myftol( float f ) {
+#ifndef __MINGW32__
 	static int tmp;
 	__asm fld f
 	__asm fistp tmp
 	__asm mov eax, tmp
+#else
+	return (long)f;
+#endif
 }
 
 #endif

Modified: trunk/code/unix/ChangeLog
===================================================================
--- trunk/code/unix/ChangeLog	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/unix/ChangeLog	2005-09-22 03:21:33 UTC (rev 97)
@@ -1,32 +1,38 @@
 TODO: the Mac port seems stable, but outputs a bunch of warnings..
-2005-09-?? 
-- SDL Stuff (icculus)
-- x86_64 (ludwig von angstenheimer)
-- patches from a casth of thousands
-	
-2004-05-22
-- updated the xcode project from Apple's version
-  now with the latest vm_ppc code
-	
+2005-09-22 Tim Angus <tim at ngus.net>
+	+ MinGW port
+
+2005-09-??
+	+ SDL Stuff (icculus)
+	+ x86_64 (ludwig von angstenheimer)
+	+ patches from a cast of thousands
+
+2004-05-22 Timothee Besset <ttimo at idsoftware.com>
+	+ updated the xcode project from Apple's version
+		now with the latest vm_ppc code
+
 2004-05-21 Timothee Besset <ttimo at idsoftware.com>
-- fixed the Linux build to compile again on sid (glext.h and gcc3 warnings)
-- 2 weeks ago, hacked up the source to compile on panther / xcode 1.1
-  several cleanups were needed, and VM support seems broke (hangs or crashes)
-- got altivec optimisations from Apple (Kenneth Dyke)
-  merged back in
-- looks like with the new code merge the VM support is back in and working
-	
+	+ fixed the Linux build to compile again on sid (glext.h and gcc3 warnings)
+	+ 2 weeks ago, hacked up the source to compile on panther / xcode 1.1
+		several cleanups were needed, and VM support seems broke (hangs or crashes)
+	+ got altivec optimisations from Apple (Kenneth Dyke)
+		merged back in
+	+ looks like with the new code merge the VM support is back in and working
+
 2003-09-15 Timothee Besset <ttimo at idsoftware.com>
-- import Q3 java master code, cleanups on monster
+	+ import Q3 java master code, cleanups on monster
 
 2003-08-31 Timothee Besset <ttimo at idsoftware.com>
-+ loki_setup hell
-  https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=626
-  http://zerowing.idsoftware.com/linux/q3a/index.html#glibc
-  text mode installer in loki_setup image built on Mandrake 7.2 crashes on some glibc 2.3 systems such as RH9 etc.
-  need to move to a different version of the installer, and update old installers to keep them still 'installing'
-  moving to build the setup binaries on Debian Woody systems (glibc 2.2, text mode installer will no longer work on 2.1 systems)
-  hacked together a new setup, using setup tree from RTCW. would need a complete revamp if a new full setup with new binaries is needed
+	+ loki_setup hell
+		https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=626
+		http://zerowing.idsoftware.com/linux/q3a/index.html#glibc
+		text mode installer in loki_setup image built on Mandrake 7.2 crashes on
+		some glibc 2.3 systems such as RH9 etc.  need to move to a different
+		version of the installer, and update old installers to keep them still
+		'installing' moving to build the setup binaries on Debian Woody systems
+		(glibc 2.2, text mode installer will no longer work on 2.1 systems) hacked
+		together a new setup, using setup tree from RTCW. would need a complete
+		revamp if a new full setup with new binaries is needed
 
 2003-07-17 Timothee Besset <ttimo at idsoftware.com>
 	+ new cvsreport, testing per-module config

Modified: trunk/code/unix/Makefile
===================================================================
--- trunk/code/unix/Makefile	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/unix/Makefile	2005-09-22 03:21:33 UTC (rev 97)
@@ -17,7 +17,7 @@
 # GNU Make required
 #
 
-PLATFORM=$(shell uname|tr A-Z a-z)
+PLATFORM=$(shell uname|sed -e s/_.*//|tr A-Z a-z)
 PLATFORM_RELEASE=$(shell uname -r)
 ARCH:=$(shell uname -m | sed -e s/i.86/i386/)
 ifndef COPYDIR
@@ -42,6 +42,9 @@
 
 BUILD_FREETYPE=0
 
+# Used for building with mingw
+DXSDK_DIR=C:/DXSDK
+
 #############################################################################
 ##
 ## You shouldn't have to touch anything below here
@@ -55,6 +58,7 @@
 RDIR=$(MOUNT_DIR)/renderer
 CMDIR=$(MOUNT_DIR)/qcommon
 UDIR=$(MOUNT_DIR)/unix
+W32DIR=$(MOUNT_DIR)/win32
 GDIR=$(MOUNT_DIR)/game
 CGDIR=$(MOUNT_DIR)/cgame
 BAIDIR=$(GDIR)
@@ -210,6 +214,84 @@
 else # ifeq Linux
 
 #############################################################################
+# SETUP AND BUILD -- MINGW32
+#############################################################################
+
+ifeq ($(PLATFORM),mingw32)
+
+  GLIBC=-mingw
+  CC=gcc
+  CXX=g++
+  WINDRES=windres
+
+ifeq ($(ARCH),i386)
+  ARCH=x86
+endif
+
+  RPMARCH=$(ARCH)
+
+  BASE_CFLAGS =  -pipe -Wall -Wimplicit -Wstrict-prototypes
+  
+  ifeq ($(strip $(DLL_ONLY)),true)
+    BASE_CFLAGS += -DDLL_ONLY
+  endif
+
+  DX_CFLAGS = -I$(DXSDK_DIR)/Include
+
+  GL_CFLAGS =
+  MINGW_CFLAGS = -DDONT_TYPEDEF_INT32
+
+  OPTIMIZE = -O3 -march=i686 -fomit-frame-pointer -ffast-math -falign-loops=2 -falign-jumps=2 -falign-functions=2 -fno-strict-aliasing -fstrength-reduce
+  BASE_CFLAGS += -DHAVE_VM_NATIVE -DHAVE_VM_COMPILED
+
+  DEBUG_CFLAGS=$(BASE_CFLAGS) -g -O0
+
+  RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE)
+
+  LIBEXT=lib
+
+  SHLIBEXT=dll
+  SHLIBCFLAGS=
+  SHLIBLDFLAGS=-shared $(LDFLAGS)
+
+  AR=ar
+  ARFLAGS=rv
+  RANLIB=ranlib
+
+  THREAD_LDFLAGS=-lpthread
+  LDFLAGS= -mwindows -lwsock32 -lgdi32 -lwinmm -lole32
+  GLLDFLAGS=
+
+  ifeq ($(BUILD_FREETYPE),1)
+    RELEASE_CFLAGS += $(shell pkg-config --cflags freetype2) -DBUILD_FREETYPE
+    DEBUG_CFLAGS += $(shell pkg-config --cflags freetype2) -DBUILD_FREETYPE
+    LDFLAGS += $(shell pkg-config --libs freetype2)
+  endif
+
+  ifeq ($(ARCH),x86)
+    # build 32bit
+    BASE_CFLAGS += -m32
+    LDFLAGS+=-m32
+  endif
+
+  TARGETS=\
+	$(B)/$(PLATFORM)quake3 \
+	$(B)/baseq3/cgame$(ARCH).$(SHLIBEXT) \
+	$(B)/baseq3/qagame$(ARCH).$(SHLIBEXT) \
+	$(B)/baseq3/ui$(ARCH).$(SHLIBEXT)     \
+	$(B)/missionpack/cgame$(ARCH).$(SHLIBEXT) \
+	$(B)/missionpack/qagame$(ARCH).$(SHLIBEXT) \
+	$(B)/missionpack/ui$(ARCH).$(SHLIBEXT)
+#	$(B)/baseq3/vm/qagame.qvm \
+#	$(B)/baseq3/vm/cgame.qvm \
+#	$(B)/baseq3/vm/ui.qvm \
+#	$(B)/missionpack/vm/qagame.qvm \
+#	$(B)/missionpack/vm/cgame.qvm \
+#	$(B)/missionpack/vm/ui.qvm
+
+else # ifeq mingw32
+
+#############################################################################
 # SETUP AND BUILD -- FREEBSD
 #############################################################################
 
@@ -334,6 +416,7 @@
 	$(B)/$(PLATFORM)q3ded
 
 endif #Linux
+endif #mingw32
 endif #FreeBSD
 endif #IRIX
 
@@ -351,6 +434,7 @@
 DO_AS=$(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $<
 DO_NASM=nasm -f elf -o $@  $<
 DO_DED_CC=$(CC) -DDEDICATED -DC_ONLY $(CFLAGS) -o $@ -c $<
+DO_WINDRES=$(WINDRES) -i $< -o $@ 
 
 #DO_LCC=$(LCC) -o $@ -S -Wf-target=bytecode -Wf-g -DQ3_VM -I$(CGDIR) -I$(GDIR)  -I$(UIDIR)  $< 
 
@@ -532,15 +616,16 @@
 	$(B)/client/tr_sky.o \
 	$(B)/client/tr_surface.o \
 	$(B)/client/tr_world.o \
-	\
-	$(B)/client/unix_main.o \
-	$(B)/client/unix_net.o \
-	$(B)/client/unix_shared.o \
 
+
     ifeq ($(ARCH),i386)
 	  Q3OBJ += $(B)/client/vm_x86.o
     endif
 
+    ifeq ($(ARCH),x86)
+	  Q3OBJ += $(B)/client/vm_x86.o
+    endif
+
     ifeq ($(ARCH),x86_64)
 	  Q3OBJ += $(B)/client/vm_none.o
     endif
@@ -556,6 +641,9 @@
 #platform specific objects
 ifeq ($(PLATFORM),freebsd)
 	Q3POBJ=\
+		$(B)/client/unix_main.o \
+		$(B)/client/unix_net.o \
+		$(B)/client/unix_shared.o \
 		$(B)/client/linux_signals.o \
 		$(B)/client/linux_common.o \
 		$(B)/client/linux_qgl.o \
@@ -570,15 +658,38 @@
 else
 ifeq ($(PLATFORM),irix)
 	Q3POBJ=\
+		$(B)/client/unix_main.o \
+		$(B)/client/unix_net.o \
+		$(B)/client/unix_shared.o \
 		$(B)/client/irix_qgl.o \
 		$(B)/client/irix_glimp.o \
 		$(B)/client/irix_snd.o
 else
+ifeq ($(PLATFORM),mingw32)
+	Q3POBJ=\
+		$(B)/client/linux_common.o \
+		$(B)/client/snd_mixa.o \
+		$(B)/client/matha.o \
+		$(B)/client/win_gamma.o \
+		$(B)/client/win_glimp.o \
+		$(B)/client/win_input.o \
+		$(B)/client/win_main.o \
+		$(B)/client/win_net.o \
+		$(B)/client/win_qgl.o \
+		$(B)/client/win_shared.o \
+		$(B)/client/win_snd.o \
+		$(B)/client/win_syscon.o \
+		$(B)/client/win_wndproc.o \
+		$(B)/client/win_resource.o
+else
 ifeq ($(PLATFORM),linux)
 ifeq ($(ARCH),axp)
 	Q3POBJ=
 else
 	Q3POBJ=\
+		$(B)/client/unix_main.o \
+		$(B)/client/unix_net.o \
+		$(B)/client/unix_shared.o \
 		$(B)/client/linux_signals.o \
 		$(B)/client/linux_common.o \
 		$(B)/client/linux_qgl.o \
@@ -591,6 +702,9 @@
 		$(B)/client/matha.o \
 
 	Q3POBJ_SMP=\
+		$(B)/client/unix_main.o \
+		$(B)/client/unix_net.o \
+		$(B)/client/unix_shared.o \
 		$(B)/client/linux_signals.o \
 		$(B)/client/linux_common.o \
 		$(B)/client/linux_qgl.o \
@@ -606,10 +720,11 @@
 		Q3POBJ_SMP += $(B)/client/ftol.o $(B)/client/snapvector.o
     endif
 
-endif
+endif #Linux-axp
 endif #Linux
+endif #mingw32
+endif #IRIX
 endif #FreeBSD
-endif #IRIX
 
 $(B)/$(PLATFORM)quake3 : $(Q3OBJ) $(Q3POBJ)
 	$(CC)  -o $@ $(Q3OBJ) $(Q3POBJ) $(GLLDFLAGS) $(LDFLAGS) 
@@ -719,10 +834,10 @@
 $(B)/client/jdpostct.o : $(JPDIR)/jdpostct.c; $(DO_CC) 
 $(B)/client/jdsample.o : $(JPDIR)/jdsample.c; $(DO_CC) 
 $(B)/client/jdtrans.o : $(JPDIR)/jdtrans.c; $(DO_CC) 
-$(B)/client/jerror.o : $(JPDIR)/jerror.c; $(DO_CC) $(GL_CFLAGS) 
+$(B)/client/jerror.o : $(JPDIR)/jerror.c; $(DO_CC) $(GL_CFLAGS) $(MINGW_CFLAGS)
 $(B)/client/jidctflt.o : $(JPDIR)/jidctflt.c; $(DO_CC) 
 $(B)/client/jmemmgr.o : $(JPDIR)/jmemmgr.c; $(DO_CC) 
-$(B)/client/jmemnobs.o : $(JPDIR)/jmemnobs.c; $(DO_CC)  $(GL_CFLAGS) 
+$(B)/client/jmemnobs.o : $(JPDIR)/jmemnobs.c; $(DO_CC)  $(GL_CFLAGS) $(MINGW_CFLAGS)
 $(B)/client/jutils.o : $(JPDIR)/jutils.c; $(DO_CC) 
 
 $(B)/client/tr_bsp.o : $(RDIR)/tr_bsp.c; $(DO_CC)  $(GL_CFLAGS) 
@@ -732,7 +847,7 @@
 $(B)/client/tr_curve.o : $(RDIR)/tr_curve.c; $(DO_CC)  $(GL_CFLAGS) 
 $(B)/client/tr_flares.o : $(RDIR)/tr_flares.c; $(DO_CC)  $(GL_CFLAGS) 
 $(B)/client/tr_font.o : $(RDIR)/tr_font.c; $(DO_CC)   $(GL_CFLAGS) 
-$(B)/client/tr_image.o : $(RDIR)/tr_image.c; $(DO_CC)   $(GL_CFLAGS) 
+$(B)/client/tr_image.o : $(RDIR)/tr_image.c; $(DO_CC)   $(GL_CFLAGS) $(MINGW_CFLAGS) 
 $(B)/client/tr_init.o : $(RDIR)/tr_init.c; $(DO_CC)    $(GL_CFLAGS) 
 $(B)/client/tr_light.o : $(RDIR)/tr_light.c; $(DO_CC)  $(GL_CFLAGS) 
 $(B)/client/tr_main.o : $(RDIR)/tr_main.c; $(DO_CC)   $(GL_CFLAGS) 
@@ -773,12 +888,28 @@
 $(B)/client/snd_mixa.o : $(UDIR)/snd_mixa.s; $(DO_AS) 
 $(B)/client/matha.o : $(UDIR)/matha.s; $(DO_AS) 
 
+$(B)/client/win_gamma.o : $(W32DIR)/win_gamma.c; $(DO_CC) $(DX_CFLAGS)
+$(B)/client/win_glimp.o : $(W32DIR)/win_glimp.c; $(DO_CC) $(DX_CFLAGS)
+$(B)/client/win_input.o : $(W32DIR)/win_input.c; $(DO_CC) $(DX_CFLAGS)
+$(B)/client/win_main.o : $(W32DIR)/win_main.c; $(DO_CC) $(DX_CFLAGS)
+$(B)/client/win_net.o : $(W32DIR)/win_net.c; $(DO_CC) $(DX_CFLAGS)
+$(B)/client/win_qgl.o : $(W32DIR)/win_qgl.c; $(DO_CC) $(DX_CFLAGS)
+$(B)/client/win_shared.o : $(W32DIR)/win_shared.c; $(DO_CC) $(DX_CFLAGS)
+$(B)/client/win_snd.o : $(W32DIR)/win_snd.c; $(DO_CC) $(DX_CFLAGS)
+$(B)/client/win_syscon.o : $(W32DIR)/win_syscon.c; $(DO_CC) $(DX_CFLAGS)
+$(B)/client/win_wndproc.o : $(W32DIR)/win_wndproc.c; $(DO_CC) $(DX_CFLAGS)
+$(B)/client/win_resource.o : $(W32DIR)/winquake.rc; $(DO_WINDRES)
+
 ifeq ($(ARCH),i386)
 $(B)/client/ftol.o : $(UDIR)/ftol.nasm; $(DO_NASM)
 $(B)/client/snapvector.o : $(UDIR)/snapvector.nasm; $(DO_NASM)
 $(B)/client/vm_x86.o : $(CMDIR)/vm_x86.c; $(DO_CC) 
 endif
 
+ifeq ($(ARCH),x86)
+$(B)/client/vm_x86.o : $(CMDIR)/vm_x86.c; $(DO_CC) 
+endif
+
 ifeq ($(ARCH),x86_64)
 $(B)/client/vm_none.o : $(CMDIR)/vm_none.c; $(DO_CC) 
 endif
@@ -944,6 +1075,7 @@
 $(B)/ded/unix_main.o : $(UDIR)/unix_main.c; $(DO_DED_CC) 
 $(B)/ded/unix_net.o : $(UDIR)/unix_net.c; $(DO_DED_CC) 
 $(B)/ded/unix_shared.o : $(UDIR)/unix_shared.c; $(DO_DED_CC) 
+
 $(B)/ded/null_client.o : $(NDIR)/null_client.c; $(DO_DED_CC) 
 $(B)/ded/null_input.o : $(NDIR)/null_input.c; $(DO_DED_CC) 
 $(B)/ded/null_snddma.o : $(NDIR)/null_snddma.c; $(DO_DED_CC) 

Modified: trunk/code/unix/qasm.h
===================================================================
--- trunk/code/unix/qasm.h	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/unix/qasm.h	2005-09-22 03:21:33 UTC (rev 97)
@@ -22,6 +22,10 @@
 #ifndef __ASM_I386__
 #define __ASM_I386__
 
+#ifdef __MINGW32__
+#undef ELF
+#endif
+
 #ifdef ELF
 #define C(label) label
 #else

Modified: trunk/code/win32/win_glimp.c
===================================================================
--- trunk/code/win32/win_glimp.c	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/win32/win_glimp.c	2005-09-22 03:21:33 UTC (rev 97)
@@ -1592,7 +1592,7 @@
 	   (LPTHREAD_START_ROUTINE)GLimp_RenderThreadWrapper,	// LPTHREAD_START_ROUTINE lpStartAddr,
 	   0,			// LPVOID lpvThreadParm,
 	   0,			//   DWORD fdwCreate,
-	   &renderThreadId );
+	   (long *)&renderThreadId );
 
 	if ( !renderThreadHandle ) {
 		return qfalse;

Modified: trunk/code/win32/win_input.c
===================================================================
--- trunk/code/win32/win_input.c	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/win32/win_input.c	2005-09-22 03:21:33 UTC (rev 97)
@@ -195,7 +195,7 @@
 #undef DEFINE_GUID
 
 #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
-        EXTERN_C const GUID name \
+        const GUID name \
                 = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }
 
 DEFINE_GUID(GUID_SysMouse,   0x6F1D2B60,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
@@ -279,7 +279,7 @@
 	}
 
 	if (!pDirectInputCreate) {
-		pDirectInputCreate = (long (__stdcall *)(void *,unsigned long ,struct IDirectInputA ** ,struct IUnknown *))
+		pDirectInputCreate = (HRESULT (WINAPI *)(HINSTANCE, DWORD, LPDIRECTINPUT *, LPUNKNOWN))
 			GetProcAddress(hInstDI,"DirectInputCreateA");
 
 		if (!pDirectInputCreate) {
@@ -403,7 +403,6 @@
 	DWORD				dwElements;
 	HRESULT				hr;
   int value;
-	static float		oldSysTime;
 
 	if ( !g_pMouse ) {
 		return;
@@ -929,7 +928,7 @@
 
 	if ( joyGetPosEx (joy.id, &joy.ji) != JOYERR_NOERROR ) {
 		// read error occurred
-		// turning off the joystick seems too harsh for 1 read error,\
+		// turning off the joystick seems too harsh for 1 read error,
 		// but what should be done?
 		// Com_Printf ("IN_ReadJoystick: no response\n");
 		// joy.avail = false;

Modified: trunk/code/win32/win_local.h
===================================================================
--- trunk/code/win32/win_local.h	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/win32/win_local.h	2005-09-22 03:21:33 UTC (rev 97)
@@ -73,7 +73,7 @@
 void Conbuf_AppendText( const char *msg );
 
 void SNDDMA_Activate( void );
-int  SNDDMA_InitDS ();
+int  SNDDMA_InitDS (void);
 
 typedef struct
 {

Modified: trunk/code/win32/win_main.c
===================================================================
--- trunk/code/win32/win_main.c	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/win32/win_main.c	2005-09-22 03:21:33 UTC (rev 97)
@@ -56,7 +56,7 @@
   fh = open( name, O_TRUNC | O_CREAT | O_WRONLY, S_IREAD | S_IWRITE );
 };
 
-void Spk_Close()
+void Spk_Close(void)
 {
   if (!fh)
     return;
@@ -526,7 +526,7 @@
 // fqpath param added 7/20/02 by T.Ray - Sys_LoadDll is only called in vm.c at this time
 // fqpath will be empty if dll not loaded, otherwise will hold fully qualified path of dll module loaded
 // fqpath buffersize must be at least MAX_QPATH+1 bytes long
-void * QDECL Sys_LoadDll( const char *name, char *fqpath , int (QDECL **entryPoint)(int, ...),
+void * QDECL Sys_LoadDll( const char *name, char *fqpath , long (QDECL **entryPoint)(long, ...),
 				  long (QDECL *systemcalls)(long, ...) ) {
 	static int	lastWarning = 0;
 	HINSTANCE	libHandle;
@@ -1100,7 +1100,11 @@
 	{
 		Com_Printf( "...detecting CPU, found " );
 
+#ifndef __MINGW32__
 		cpuid = Sys_GetProcessorId();
+#else // See comments in win_shared.c
+		cpuid = CPUID_GENERIC;
+#endif
 
 		switch ( cpuid )
 		{

Modified: trunk/code/win32/win_net.c
===================================================================
--- trunk/code/win32/win_net.c	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/win32/win_net.c	2005-09-22 03:21:33 UTC (rev 97)
@@ -488,7 +488,7 @@
 	}
 
 	// make it non-blocking
-	if( ioctlsocket( newsocket, FIONBIO, &_true ) == SOCKET_ERROR ) {
+	if( ioctlsocket( newsocket, FIONBIO, (u_long *)&_true ) == SOCKET_ERROR ) {
 		Com_Printf( "WARNING: UDP_OpenSocket: ioctl FIONBIO: %s\n", NET_ErrorString() );
 		return 0;
 	}
@@ -799,7 +799,7 @@
 	}
 
 	// make it non-blocking
-	if( ioctlsocket( newsocket, FIONBIO, &_true ) == SOCKET_ERROR ) {
+	if( ioctlsocket( newsocket, FIONBIO, (u_long *)&_true ) == SOCKET_ERROR ) {
 		Com_Printf( "WARNING: IPX_Socket: ioctl FIONBIO: %s\n", NET_ErrorString() );
 		return 0;
 	}

Modified: trunk/code/win32/win_qgl.c
===================================================================
--- trunk/code/win32/win_qgl.c	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/win32/win_qgl.c	2005-09-22 03:21:33 UTC (rev 97)
@@ -3220,8 +3220,12 @@
 	return qfalse;
 } 
 
+#ifdef _MSC_VER
 #	pragma warning (disable : 4113 4133 4047 )
 #	define GPA( a ) GetProcAddress( glw_state.hinstOpenGL, a )
+#else
+#	define GPA( a ) (void *)GetProcAddress( glw_state.hinstOpenGL, a )
+#endif
 
 /*
 ** QGL_Init
@@ -4368,7 +4372,9 @@
 	}
 }
 
+#ifdef _MSC_VER
 #pragma warning (default : 4113 4133 4047 )
+#endif
 
 
 

Modified: trunk/code/win32/win_shared.c
===================================================================
--- trunk/code/win32/win_shared.c	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/win32/win_shared.c	2005-09-22 03:21:33 UTC (rev 97)
@@ -59,14 +59,19 @@
 ================
 */
 long fastftol( float f ) {
+#ifndef __MINGW32__
 	static int tmp;
 	__asm fld f
 	__asm fistp tmp
 	__asm mov eax, tmp
+#else
+	return (long)f;
+#endif
 }
 
 void Sys_SnapVector( float *v )
 {
+#ifndef __MINGW32__
 	int i;
 	float f;
 
@@ -91,6 +96,11 @@
 	v++;
 	*v = fastftol(*v);
 	*/
+#else
+	v[0] = rint(v[0]);
+	v[1] = rint(v[1]);
+	v[2] = rint(v[2]);
+#endif
 }
 
 
@@ -99,8 +109,13 @@
 ** Disable all optimizations temporarily so this code works correctly!
 **
 */
+#ifdef _MSC_VER
 #pragma optimize( "", off )
+#endif
 
+// If you fancy porting this stuff to AT&T then feel free... :)
+// It's not actually used functionally though, so it may be a waste of effort
+#ifndef __MINGW32__
 /*
 ** --------------------------------------------------------------------------------
 **
@@ -268,13 +283,16 @@
 
 #endif
 }
+#endif
 
 /*
 **
 ** Re-enable optimizations back to what they were
 **
 */
+#ifdef _MSC_VER
 #pragma optimize( "", on )
+#endif
 
 //============================================
 

Modified: trunk/code/win32/win_snd.c
===================================================================
--- trunk/code/win32/win_snd.c	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/win32/win_snd.c	2005-09-22 03:21:33 UTC (rev 97)
@@ -135,7 +135,7 @@
 #undef DEFINE_GUID
 
 #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
-        EXTERN_C const GUID name \
+        const GUID name \
                 = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }
 
 // DirectSound Component GUID {47D4D946-62E8-11CF-93BC-444553540000}
@@ -331,8 +331,8 @@
 	reps = 0;
 	dma.buffer = NULL;
 
-	while ((hresult = pDSBuf->lpVtbl->Lock(pDSBuf, 0, gSndBufSize, &pbuf, &locksize, 
-								   &pbuf2, &dwSize2, 0)) != DS_OK)
+	while ((hresult = pDSBuf->lpVtbl->Lock(pDSBuf, 0, gSndBufSize, (LPVOID)&pbuf, &locksize, 
+								   (LPVOID)&pbuf2, &dwSize2, 0)) != DS_OK)
 	{
 		if (hresult != DSERR_BUFFERLOST)
 		{

Modified: trunk/code/win32/winquake.rc
===================================================================
--- trunk/code/win32/winquake.rc	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/code/win32/winquake.rc	2005-09-22 03:21:33 UTC (rev 97)
@@ -7,7 +7,11 @@
 //
 // Generated from the TEXTINCLUDE 2 resource.
 //
+#ifndef __MINGW32__
 #include "winres.h"
+#else
+#include <winresrc.h>
+#endif
 
 /////////////////////////////////////////////////////////////////////////////
 #undef APSTUDIO_READONLY_SYMBOLS
@@ -53,7 +57,11 @@
 
 // Icon with lowest ID value placed first to ensure application icon
 // remains consistent on all systems.
+#ifndef __MINGW32__
 IDI_ICON1               ICON    DISCARDABLE     "qe3.ico"
+#else
+IDI_ICON1               ICON    DISCARDABLE     "../win32/qe3.ico"
+#endif
 
 /////////////////////////////////////////////////////////////////////////////
 //

Modified: trunk/i_o-q3-readme
===================================================================
--- trunk/i_o-q3-readme	2005-09-19 20:43:35 UTC (rev 96)
+++ trunk/i_o-q3-readme	2005-09-22 03:21:33 UTC (rev 97)
@@ -52,3 +52,42 @@
 dllEntry functions as well as the syscall pointer have to be changed
 to accept and return long instead of int.
 
+Compiling under windows using MinGW
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+It is possible to compile ioQ3 using the MinGW (Minimalist GNU for Windows)
+toolset. It's a little more involved than compiling for linux; steps are as
+follows:
+
+1. Download and install MinGW and MSys from http://www.mingw.org/.
+2. Download and install the DirectX 9 SDK from
+   http://msdn.microsoft.com/directx/. Previous versions of the SDK will
+   probably work, but they have not been tested.
+3. Find the following in DXSDK/Include/dinput.h...
+
+      } DIDEVICEINSTANCEW, *LPDIDEVICEINSTANCEW;
+      #ifdef UNICODE
+      typedef DIDEVICEINSTANCEW DIDEVICEINSTANCE;
+      typedef LPDIDEVICEINSTANCEW LPDIDEVICEINSTANCE;
+      #else
+      typedef DIDEVICEINSTANCEA DIDEVICEINSTANCE;
+      typedef LPDIDEVICEINSTANCEA LPDIDEVICEINSTANCE;
+      #endif // UNICODE
+
+      typedef const DIDEVICEINSTANCEA *LPCDIDEVICEINSTANCEA;
+      typedef const DIDEVICEINSTANCEW *LPCDIDEVICEINSTANCEW;
+   >  #ifdef UNICODE
+   >  typedef DIDEVICEINSTANCEW DIDEVICEINSTANCE;
+   >  typedef LPCDIDEVICEINSTANCEW LPCDIDEVICEINSTANCE;
+   >  #else
+   >  typedef DIDEVICEINSTANCEA DIDEVICEINSTANCE;
+   >  typedef LPCDIDEVICEINSTANCEA LPCDIDEVICEINSTANCE;
+   >  #endif // UNICODE
+      typedef const DIDEVICEINSTANCE  *LPCDIDEVICEINSTANCE;
+
+   ...and comment out/remove the duplicated code (go Microsoft!) marked by '>'.
+
+4. If you didn't install the DirectX SDK in C:\DXSDK\, edit DXSDK_DIR in
+   code/unix/Makefile to reflect the new location.
+5. Perform the usual precompilation sacrificial ritual.
+6. Open an MSys terminal, and follow the instructions for compiling on Linux.




More information about the quake3-commits mailing list