diff options
author | tma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2005-09-22 03:21:33 +0000 |
---|---|---|
committer | tma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2005-09-22 03:21:33 +0000 |
commit | df30c9d13185a525d2c45de3becd39c4a178f484 (patch) | |
tree | 3cf10550bfe1d9473252bfc3ad56b8007652e622 | |
parent | 3873056dc5e0a7c314fa42dd70c072027ccccec0 (diff) | |
download | ioquake3-aero-df30c9d13185a525d2c45de3becd39c4a178f484.tar.gz ioquake3-aero-df30c9d13185a525d2c45de3becd39c4a178f484.zip |
* Port to MinGW
git-svn-id: svn://svn.icculus.org/quake3/trunk@97 edf5b092-35ff-0310-97b2-ce42778d08ea
-rw-r--r-- | code/botlib/l_utils.h | 2 | ||||
-rw-r--r-- | code/client/snd_mix.c | 2 | ||||
-rw-r--r-- | code/game/ai_main.c | 2 | ||||
-rw-r--r-- | code/game/q_math.c | 2 | ||||
-rw-r--r-- | code/game/q_shared.h | 20 | ||||
-rw-r--r-- | code/jpeg-6/jinclude.h | 2 | ||||
-rw-r--r-- | code/jpeg-6/jmorecfg.h | 2 | ||||
-rw-r--r-- | code/qcommon/common.c | 2 | ||||
-rw-r--r-- | code/qcommon/md4.c | 2 | ||||
-rw-r--r-- | code/qcommon/vm.c | 2 | ||||
-rw-r--r-- | code/qcommon/vm_interpreted.c | 2 | ||||
-rw-r--r-- | code/qcommon/vm_x86.c | 50 | ||||
-rw-r--r-- | code/renderer/qgl.h | 3 | ||||
-rw-r--r-- | code/renderer/tr_font.c | 4 | ||||
-rw-r--r-- | code/renderer/tr_shade_calc.c | 4 | ||||
-rw-r--r-- | code/unix/ChangeLog | 54 | ||||
-rw-r--r-- | code/unix/Makefile | 152 | ||||
-rw-r--r-- | code/unix/qasm.h | 4 | ||||
-rw-r--r-- | code/win32/win_glimp.c | 2 | ||||
-rw-r--r-- | code/win32/win_input.c | 7 | ||||
-rw-r--r-- | code/win32/win_local.h | 2 | ||||
-rw-r--r-- | code/win32/win_main.c | 8 | ||||
-rw-r--r-- | code/win32/win_net.c | 4 | ||||
-rw-r--r-- | code/win32/win_qgl.c | 6 | ||||
-rw-r--r-- | code/win32/win_shared.c | 18 | ||||
-rw-r--r-- | code/win32/win_snd.c | 6 | ||||
-rw-r--r-- | code/win32/winquake.rc | 8 | ||||
-rw-r--r-- | i_o-q3-readme | 39 |
28 files changed, 347 insertions, 64 deletions
diff --git a/code/botlib/l_utils.h b/code/botlib/l_utils.h index a784d7a..cef85ba 100644 --- a/code/botlib/l_utils.h +++ b/code/botlib/l_utils.h @@ -30,6 +30,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************/ #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) diff --git a/code/client/snd_mix.c b/code/client/snd_mix.c index 2915b43..8426b60 100644 --- a/code/client/snd_mix.c +++ b/code/client/snd_mix.c @@ -34,7 +34,7 @@ int* snd_p; 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) diff --git a/code/game/ai_main.c b/code/game/ai_main.c index cd6dbc9..63de0ce 100644 --- a/code/game/ai_main.c +++ b/code/game/ai_main.c @@ -55,7 +55,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "inv.h" #include "syn.h" +#ifndef MAX_PATH #define MAX_PATH 144 +#endif //bot states diff --git a/code/game/q_math.c b/code/game/q_math.c index 53412e1..aeed2ab 100644 --- a/code/game/q_math.c +++ b/code/game/q_math.c @@ -740,7 +740,7 @@ int BoxOnPlaneSide2 (vec3_t emins, vec3_t emaxs, struct cplane_s *p) ================== */ -#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 diff --git a/code/game/q_shared.h b/code/game/q_shared.h index d16bb1d..4b4fa31 100644 --- a/code/game/q_shared.h +++ b/code/game/q_shared.h @@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define MAX_TEAMNAME 32 -#ifdef _WIN32 +#ifdef _MSC_VER #pragma warning(disable : 4018) // signed/unsigned mismatch #pragma warning(disable : 4032) @@ -90,7 +90,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #endif -#ifdef _WIN32 +#ifdef _MSC_VER //#pragma intrinsic( memset, memcpy ) @@ -134,6 +134,7 @@ float FloatSwap (const float *f); #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 @@ float FloatSwap (const float *f); #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 '\\' diff --git a/code/jpeg-6/jinclude.h b/code/jpeg-6/jinclude.h index eadcd19..aede8ec 100644 --- a/code/jpeg-6/jinclude.h +++ b/code/jpeg-6/jinclude.h @@ -15,7 +15,7 @@ */ -#ifdef _WIN32 +#ifdef _MSC_VER #pragma warning(disable : 4018) // signed/unsigned mismatch #pragma warning(disable : 4032) diff --git a/code/jpeg-6/jmorecfg.h b/code/jpeg-6/jmorecfg.h index 1fc0a19..a2fea83 100644 --- a/code/jpeg-6/jmorecfg.h +++ b/code/jpeg-6/jmorecfg.h @@ -149,7 +149,9 @@ typedef unsigned short UINT16; 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. */ diff --git a/code/qcommon/common.c b/code/qcommon/common.c index 49f3721..1f7a9ab 100644 --- a/code/qcommon/common.c +++ b/code/qcommon/common.c @@ -2817,7 +2817,7 @@ void Com_Shutdown (void) { } #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) diff --git a/code/qcommon/md4.c b/code/qcommon/md4.c index e530b07..5f96838 100644 --- a/code/qcommon/md4.c +++ b/code/qcommon/md4.c @@ -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 diff --git a/code/qcommon/vm.c b/code/qcommon/vm.c index 87f0795..3f7a182 100644 --- a/code/qcommon/vm.c +++ b/code/qcommon/vm.c @@ -858,7 +858,7 @@ void VM_LogSyscalls( int *args ) { -#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); } diff --git a/code/qcommon/vm_interpreted.c b/code/qcommon/vm_interpreted.c index fb28011..0d0d90f 100644 --- a/code/qcommon/vm_interpreted.c +++ b/code/qcommon/vm_interpreted.c @@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "vm_local.h" +//#define DEBUG_VM #ifdef DEBUG_VM // bk001204 static char *opnames[256] = { "OP_UNDEF", @@ -306,7 +307,6 @@ locals from sp */ #define MAX_STACK 256 #define STACK_MASK (MAX_STACK-1) -//#define DEBUG_VM #define DEBUGSTR va("%s%i", VM_Indent(vm), opStack-stack ) diff --git a/code/qcommon/vm_x86.c b/code/qcommon/vm_x86.c index 04abce9..7858616 100644 --- a/code/qcommon/vm_x86.c +++ b/code/qcommon/vm_x86.c @@ -60,8 +60,13 @@ int _ftol( float ); 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 @@ static ELastCommand LastCommand; AsmCall ================= */ -#ifdef _WIN32 +#ifdef _MSC_VER __declspec( naked ) void AsmCall( void ) { int programStack; int *opStack; @@ -168,7 +173,7 @@ _asm { } -#else //!_WIN32 +#else //!_MSC_VER static int callProgramStack; static int *callOpStack; @@ -185,13 +190,14 @@ void callAsmCall(void) // 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 @@ void AsmCall( void ) { : "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 @@ int VM_CallCompiled( vm_t *vm, int *args ) { entryPoint = vm->codeBase; opStack = &stack; -#ifdef _WIN32 +#ifdef _MSC_VER __asm { pushad mov esi, programStack; diff --git a/code/renderer/qgl.h b/code/renderer/qgl.h index 3aa111a..e92b3d3 100644 --- a/code/renderer/qgl.h +++ b/code/renderer/qgl.h @@ -32,12 +32,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #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> diff --git a/code/renderer/tr_font.c b/code/renderer/tr_font.c index 5a0c839..1878025 100644 --- a/code/renderer/tr_font.c +++ b/code/renderer/tr_font.c @@ -311,12 +311,12 @@ typedef union { 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]; diff --git a/code/renderer/tr_shade_calc.c b/code/renderer/tr_shade_calc.c index b97f674..ca6f07c 100644 --- a/code/renderer/tr_shade_calc.c +++ b/code/renderer/tr_shade_calc.c @@ -1025,10 +1025,14 @@ void RB_CalcRotateTexCoords( float degsPerSecond, float *st ) #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 diff --git a/code/unix/ChangeLog b/code/unix/ChangeLog index 48ce2f8..ca41f9a 100644 --- a/code/unix/ChangeLog +++ b/code/unix/ChangeLog @@ -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@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@idsoftware.com> + + updated the xcode project from Apple's version + now with the latest vm_ppc code + 2004-05-21 Timothee Besset <ttimo@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@idsoftware.com> -- import Q3 java master code, cleanups on monster + + import Q3 java master code, cleanups on monster 2003-08-31 Timothee Besset <ttimo@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@idsoftware.com> + new cvsreport, testing per-module config diff --git a/code/unix/Makefile b/code/unix/Makefile index a8ca1eb..a8e43b7 100644 --- a/code/unix/Makefile +++ b/code/unix/Makefile @@ -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_NAME=quake3 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 @@ SDIR=$(MOUNT_DIR)/server 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 @@ ifeq ($(PLATFORM),linux) 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 @@ TARGETS=\ $(B)/$(PLATFORM)q3ded endif #Linux +endif #mingw32 endif #FreeBSD endif #IRIX @@ -351,6 +434,7 @@ DO_SHLIB_DEBUG_CC=$(CC) $(DEBUG_CFLAGS) $(SHLIBCFLAGS) -o $@ -c $< 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 @@ Q3OBJ = \ $(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 @@ Q3OBJ = \ #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 @@ ifeq ($(PLATFORM),freebsd) 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 @@ else $(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 @@ else Q3POBJ_SMP += $(B)/client/ftol.o $(B)/client/snapvector.o endif -endif +endif #Linux-axp endif #Linux -endif #FreeBSD +endif #mingw32 endif #IRIX +endif #FreeBSD $(B)/$(PLATFORM)quake3 : $(Q3OBJ) $(Q3POBJ) $(CC) -o $@ $(Q3OBJ) $(Q3POBJ) $(GLLDFLAGS) $(LDFLAGS) @@ -719,10 +834,10 @@ $(B)/client/jdmaster.o : $(JPDIR)/jdmaster.c; $(DO_CC) $(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_cmds.o : $(RDIR)/tr_cmds.c; $(DO_CC) $(GL_CFLAGS) $(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/sdl_snd.o : $(UDIR)/sdl_snd.c; $(DO_CC) $(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/linux_common.o : $(UDIR)/linux_common.c; $(DO_DED_CC) $(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) diff --git a/code/unix/qasm.h b/code/unix/qasm.h index f6d16d6..b560095 100644 --- a/code/unix/qasm.h +++ b/code/unix/qasm.h @@ -22,6 +22,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifndef __ASM_I386__ #define __ASM_I386__ +#ifdef __MINGW32__ +#undef ELF +#endif + #ifdef ELF #define C(label) label #else diff --git a/code/win32/win_glimp.c b/code/win32/win_glimp.c index acb14ad..3a05109 100644 --- a/code/win32/win_glimp.c +++ b/code/win32/win_glimp.c @@ -1592,7 +1592,7 @@ qboolean GLimp_SpawnRenderThread( void (*function)( void ) ) { (LPTHREAD_START_ROUTINE)GLimp_RenderThreadWrapper, // LPTHREAD_START_ROUTINE lpStartAddr, 0, // LPVOID lpvThreadParm, 0, // DWORD fdwCreate, - &renderThreadId ); + (long *)&renderThreadId ); if ( !renderThreadHandle ) { return qfalse; diff --git a/code/win32/win_input.c b/code/win32/win_input.c index a5ec47a..bf312f2 100644 --- a/code/win32/win_input.c +++ b/code/win32/win_input.c @@ -195,7 +195,7 @@ DIRECT INPUT MOUSE CONTROL #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 @@ qboolean IN_InitDIMouse( void ) { } 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 @@ void IN_DIMouse( int *mx, int *my ) { DWORD dwElements; HRESULT hr; int value; - static float oldSysTime; if ( !g_pMouse ) { return; @@ -929,7 +928,7 @@ void IN_JoyMove( void ) { 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; diff --git a/code/win32/win_local.h b/code/win32/win_local.h index 86d512b..9a4183c 100644 --- a/code/win32/win_local.h +++ b/code/win32/win_local.h @@ -73,7 +73,7 @@ LONG WINAPI MainWndProc ( void Conbuf_AppendText( const char *msg ); void SNDDMA_Activate( void ); -int SNDDMA_InitDS (); +int SNDDMA_InitDS (void); typedef struct { diff --git a/code/win32/win_main.c b/code/win32/win_main.c index ff079e5..a66f712 100644 --- a/code/win32/win_main.c +++ b/code/win32/win_main.c @@ -56,7 +56,7 @@ void Spk_Open(char *name) 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 @@ extern char *FS_BuildOSPath( const char *base, const char *game, const char *qp // 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 @@ void Sys_Init( void ) { { Com_Printf( "...detecting CPU, found " ); +#ifndef __MINGW32__ cpuid = Sys_GetProcessorId(); +#else // See comments in win_shared.c + cpuid = CPUID_GENERIC; +#endif switch ( cpuid ) { diff --git a/code/win32/win_net.c b/code/win32/win_net.c index 42c08ee..deadbbf 100644 --- a/code/win32/win_net.c +++ b/code/win32/win_net.c @@ -488,7 +488,7 @@ int NET_IPSocket( char *net_interface, int port ) { } // 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 @@ int NET_IPXSocket( int port ) { } // 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; } diff --git a/code/win32/win_qgl.c b/code/win32/win_qgl.c index 57277a4..0656006 100644 --- a/code/win32/win_qgl.c +++ b/code/win32/win_qgl.c @@ -3220,8 +3220,12 @@ static qboolean GlideIsValid( void ) 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 @@ void QGL_EnableLogging( qboolean enable ) } } +#ifdef _MSC_VER #pragma warning (default : 4113 4133 4047 ) +#endif diff --git a/code/win32/win_shared.c b/code/win32/win_shared.c index 012a291..0179edc 100644 --- a/code/win32/win_shared.c +++ b/code/win32/win_shared.c @@ -59,14 +59,19 @@ Sys_SnapVector ================ */ 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 @@ void Sys_SnapVector( float *v ) 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 @@ void Sys_SnapVector( float *v ) ** 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 @@ int Sys_GetProcessorId( void ) #endif } +#endif /* ** ** Re-enable optimizations back to what they were ** */ +#ifdef _MSC_VER #pragma optimize( "", on ) +#endif //============================================ diff --git a/code/win32/win_snd.c b/code/win32/win_snd.c index 084ed44..f3f7c50 100644 --- a/code/win32/win_snd.c +++ b/code/win32/win_snd.c @@ -135,7 +135,7 @@ qboolean SNDDMA_Init(void) { #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 @@ void SNDDMA_BeginPainting( void ) { 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) { diff --git a/code/win32/winquake.rc b/code/win32/winquake.rc index c99e257..0d78b89 100644 --- a/code/win32/winquake.rc +++ b/code/win32/winquake.rc @@ -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 @@ END // 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 ///////////////////////////////////////////////////////////////////////////// // diff --git a/i_o-q3-readme b/i_o-q3-readme index aa5bbea..fb38c35 100644 --- a/i_o-q3-readme +++ b/i_o-q3-readme @@ -52,3 +52,42 @@ To compile working(!) shared libraries for 64bit mods the vmMain and 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. |