Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Sep 2009 16:43:07 GMT
From:      Dominic Fandrey <kamikaze@bsdforen.de>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/138535: takeover - games/ioquake3
Message-ID:  <200909041643.n84Gh71w089501@www.freebsd.org>
Resent-Message-ID: <200909041650.n84Go36g064751@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         138535
>Category:       ports
>Synopsis:       takeover - games/ioquake3
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Fri Sep 04 16:50:02 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Dominic Fandrey
>Release:        RELENG_7
>Organization:
private
>Environment:
FreeBSD mobileKamikaze.norad 7.2-STABLE FreeBSD 7.2-STABLE #0: Fri Jul  3 10:26:33 CEST 2009     root@mobileKamikaze.norad:/usr/obj/HP6510b/amd64/usr/src/sys/HP6510b  amd64
>Description:
The games/ioquake3 port is years outdated. I intend to take the maintainership (with Ale's permission).

I'll attach 2 files, a patch to games/ioquake3, updating it to the latest release 1.36 (tested on amd64 and i386) and a shar archive with games/ioquake3-devel (which depends on the patch).
>How-To-Repeat:

>Fix:
diff -Nur ports/games/ioquake3.orig/Makefile ports/games/ioquake3/Makefile
--- ports/games/ioquake3.orig/Makefile	2009-08-31 08:51:16.000000000 +0200
+++ ports/games/ioquake3/Makefile	2009-09-03 22:56:24.000000000 +0200
@@ -5,38 +5,45 @@
 # $FreeBSD: ports/games/ioquake3/Makefile,v 1.14 2009/07/06 21:25:46 naddy Exp $
 #
 
-PORTNAME=	ioquake3
-DISTVERSION=	1.34-rc3
-PORTREVISION=	7
+PORTNAME?=	ioquake3
+DISTVERSION?=	1.36
 CATEGORIES=	games
-MASTER_SITES=	http://ioquake3.org/files/
-DISTNAME=	${PORTNAME}_${DISTVERSION}
+MASTER_SITES?=	http://ioquake3.org/files/${DISTVERSION}/
 
-MAINTAINER=	alepulver@FreeBSD.org
-COMMENT=	Cleaned-up and enhaced version of Quake 3
+MAINTAINER?=	kamikaze@bsdforen.de
+COMMENT?=	Cleaned-up and enhaced version of Quake 3
 
-USE_BZIP2=	yes
+USE_ZIP?=	yes
+# Allow slave ports to turn off zip.
+.if ${USE_ZIP} == "no"
+.undef USE_ZIP
+.endif
 USE_GMAKE=	yes
 
 OPTIONS=	CLIENT "Build client" on \
-		CELLSHADING "Enable Cell Shading effect" off \
-		GAMELIBS "Build game libraries (when not mandatory)" off \
+		GAMELIBS "Build game libraries (when not mandatory)" on \
 		DEDICATED "Build dedicated server" on \
-		MP3 "Enable MP3 support" off \
-		OPENAL "Enable OpenAL (3D sound) support" off \
-		OPENAL_DLOPEN "Enable dynamic loading of OpenAL" off \
-		OPTIMIZED_CFLAGS "Enable compilation optimizations" on \
-		SDL_AUDIO "Use SDL for audio" off \
-		SDL_VIDEO "Use SDL for video" off \
 		SMP "Build SMP (threaded) client" on \
-		VORBIS "Enable Ogg Vorbis codec support" off
+		VORBIS "Enable Ogg Vorbis support" on
 
-MAKE_ENV=	DEFAULT_BASEDIR="${Q3DIR}" LIBDIR="${LIBDIR}" \
-		PTHREAD_LIBS="${PTHREAD_LIBS}"
-PLIST_SUB=	LIBDIR="${LIBDIR:S/${PREFIX}\///}"
+MAKE_ARGS+=	DEFAULT_BASEDIR="${Q3DIR}" \
+		DEFAULT_LIBDIR="${LIBDIR}" \
+		HOMEPATH="/.${PORTNAME}" \
+		ARCH="${LINUX_ARCH}"
+PLIST_SUB=	LIBDIR="${LIBDIR:S/${PREFIX}\///}" \
+		ARCH="${LINUX_ARCH}" \
+		BINSUFFIX="${BINSUFFIX}"
+ALL_TARGET=	release
+MAKE_JOBS_SAFE=	yes
 
 LIBDIR=		${PREFIX}/lib/${PORTNAME}
-VM_ARCHS=	amd64 i386 powerpc
+BUILDDIR=	${WRKSRC}/build/release-${OPSYS:L}-${LINUX_ARCH}
+LINUX_ARCH=	${ARCH:C/amd64/x86_64/:C/i386/x86/}
+BINSUFFIX?=
+
+# Make sure TARGET and CFLAGS fit together.
+MACHINE_ARCH=	${ARCH}
+.include <bsd.cpu.mk>
 
 .include <bsd.port.pre.mk>
 
@@ -45,102 +52,59 @@
 IGNORE=		needs at least one of CLIENT, DEDICATED and SMP options
 .endif
 
-.for i in ${ARCH}
-.   if ${VM_ARCHS:M${i}} != ""
-HAVE_VM_COMPILED=	yes
-.   endif
-.endfor
-
-.if defined(HAVE_VM_COMPILED)
-MAKE_ENV+=	HAVE_VM_COMPILED=true
-.endif
-
-.if defined(WITH_CELLSHADING)
-EXTRA_PATCHES+=	${FILESDIR}/extra-patch-cellshading
-.endif
-
-.if !defined(WITHOUT_CLIENT) || !defined(WITHOUT_SMP)
+.if defined(WITH_CLIENT) || defined(WITH_SMP)
 # OpenAL
-.   if defined(WITH_OPENAL)
 LIB_DEPENDS+=	openal.0:${PORTSDIR}/audio/openal
-MAKE_ENV+=	USE_OPENAL=1
-.       if defined(WITH_OPENAL_DLOPEN)
-MAKE_ENV+=	USE_OPENAL_DLOPEN=1
-.       endif
-.   endif
 # SDL
-.   if defined(WITH_SDL_AUDIO)
 USE_SDL=	sdl
-MAKE_ENV+=	USE_SDL_AUDIO=1
-.   endif
-.   if defined(WITH_SDL_VIDEO)
-USE_SDL=	sdl
-MAKE_ENV+=	USE_SDL_VIDEO=1
-.   else
-USE_GL=		yes
-USE_XORG=	xxf86dga
-.   endif
 # Vorbis
-.   if defined(WITH_VORBIS)
+.if defined(WITH_VORBIS)
 LIB_DEPENDS+=	vorbis.4:${PORTSDIR}/audio/libvorbis
-MAKE_ENV+=	USE_CODEC_VORBIS=1
-.   endif
+MAKE_ARGS+=	USE_CODEC_VORBIS=1
+.endif
 .endif
 
-.if !defined(WITHOUT_CLIENT)
-MAKE_ENV+=	BUILD_CLIENT=1
+# SMP is only built with CLIENT.
+.if defined(WITH_CLIENT) || defined(WITH_SMP)
+MAKE_ARGS+=	BUILD_CLIENT=1
 PLIST_SUB+=	CLIENT=""
 Q3BIN+=		ioquake3
 .else
 PLIST_SUB+=	CLIENT="@comment "
 .endif
 
-.if !defined(WITHOUT_DEDICATED)
-MAKE_ENV+=	BUILD_SERVER=1
+.if defined(WITH_DEDICATED)
+MAKE_ARGS+=	BUILD_SERVER=1
 PLIST_SUB+=	DEDICATED=""
 Q3BIN+=		ioq3ded
 .else
 PLIST_SUB+=	DEDICATED="@comment "
 .endif
 
-.if defined(WITH_GAMELIBS) || !defined(HAVE_VM_COMPILED)
-MAKE_ENV+=	BUILD_GAME_SO=1
+.if defined(WITH_GAMELIBS)
+MAKE_ARGS+=	BUILD_GAME_SO=1
 PLIST_SUB+=	GAMELIBS=""
 .else
 PLIST_SUB+=	GAMELIBS="@comment "
 .endif
 
-.if defined(WITH_MP3)
-EXTRA_PATCHES+=	${FILESDIR}/extra-patch-mp3
-LIB_DEPENDS+=	mad.2:${PORTSDIR}/audio/libmad
-MAKE_ENV+=	USE_CODEC_MP3=1
-.endif
-
-.if !defined(WITHOUT_OPTIMIZED_CFLAGS)
-MAKE_ENV+=	USE_OPTIMIZED_CFLAGS=1
-.endif
-
-.if !defined(WITHOUT_SMP)
-MAKE_ENV+=	BUILD_CLIENT_SMP=1
+.if defined(WITH_SMP)
+MAKE_ARGS+=	BUILD_CLIENT_SMP=1
 PLIST_SUB+=	SMP=""
 Q3BIN+=		ioquake3-smp
 .else
 PLIST_SUB+=	SMP="@comment "
 .endif
 
-post-patch:
-# There are new variables in the config files, so keep them in another dir.
-	@${REINPLACE_CMD} -E 's|/\.q3a|/.${PORTNAME}|' \
-		${WRKSRC}/code/unix/unix_shared.c
-
 do-install:
 .for bin in ${Q3BIN}
-	${INSTALL_PROGRAM} ${WRKSRC}/build/release/${bin} ${PREFIX}/bin
+	${INSTALL_PROGRAM} ${BUILDDIR}/${bin}.${LINUX_ARCH} \
+		${PREFIX}/bin/${bin}${BINSUFFIX}
 .endfor
-.if defined(WITH_GAMELIBS) || !defined(HAVE_VM_COMPILED)
+.if defined(WITH_GAMELIBS)
 .for dir in baseq3 missionpack
 	${MKDIR} ${LIBDIR}/${dir}
-	${INSTALL_PROGRAM} ${WRKSRC}/build/release/${dir}/*.so ${LIBDIR}/${dir}
+	${INSTALL_PROGRAM} ${BUILDDIR}/${dir}/*.so ${LIBDIR}/${dir}
 .endfor
 .endif
 .if !defined(NOPORTDOCS)
diff -Nur ports/games/ioquake3.orig/distinfo ports/games/ioquake3/distinfo
--- ports/games/ioquake3.orig/distinfo	2009-08-31 08:51:16.000000000 +0200
+++ ports/games/ioquake3/distinfo	2009-08-31 09:59:56.000000000 +0200
@@ -1,3 +1,3 @@
-MD5 (ioquake3_1.34-rc3.tar.bz2) = ed06d79afcb026f58763a89483733823
-SHA256 (ioquake3_1.34-rc3.tar.bz2) = fb43f63178c6700f20b83634b816f77e390e375e7d9c717180c9820f0c541b01
-SIZE (ioquake3_1.34-rc3.tar.bz2) = 3147694
+MD5 (ioquake3-1.36.zip) = 8e48a3957b3e70601d0ea0a450dc6359
+SHA256 (ioquake3-1.36.zip) = 3f8fecd81f9af484b9215df4cf58bcc6a378adb6f1504b0bba169c3dbadb4c94
+SIZE (ioquake3-1.36.zip) = 4583577
diff -Nur ports/games/ioquake3.orig/files/extra-patch-cellshading ports/games/ioquake3/files/extra-patch-cellshading
--- ports/games/ioquake3.orig/files/extra-patch-cellshading	2009-08-31 08:51:16.000000000 +0200
+++ ports/games/ioquake3/files/extra-patch-cellshading	1970-01-01 01:00:00.000000000 +0100
@@ -1,933 +0,0 @@
-Index: code/renderer/tr_image.c
-===================================================================
---- code/renderer/tr_image.c	(revision 933)
-+++ code/renderer/tr_image.c	(working copy)
-@@ -34,7 +34,24 @@
- #define JPEG_INTERNALS
- #include "../jpeg-6/jpeglib.h"
- 
-+/**
-+ * Headers for cell shading
-+ * @author Jordi Prats Catala
-+ * @author Guillermo Miranda Alamo
-+ */
-+/*
-+byte getImageR(byte *targa_rgba, int x, int y, int columns, int rows);
-+byte getImageG(byte *targa_rgba, int x, int y, int columns, int rows);
-+byte getImageB(byte *targa_rgba, int x, int y, int columns, int rows);
-+byte getImageA(byte *targa_rgba, int x, int y, int columns, int rows);
-+void setImageR(byte *targa_rgba, int x, int y, int columns, int rows, byte value);
-+void setImageG(byte *targa_rgba, int x, int y, int columns, int rows, byte value);
-+void setImageB(byte *targa_rgba, int x, int y, int columns, int rows, byte value);
-+void setImageA(byte *targa_rgba, int x, int y, int columns, int rows, byte value);
-+*/
-+//void kuwahara(int columns, int rows, byte *targa_rgba);
- 
-+
- static void LoadBMP( const char *name, byte **pic, int *width, int *height );
- static void LoadTGA( const char *name, byte **pic, int *width, int *height );
- static void LoadJPG( const char *name, byte **pic, int *width, int *height );
-@@ -799,7 +816,643 @@
- 	return image;
- }
- 
-+/****************************
-+RGB GET/SET
-+****************************/
- 
-+//RED
-+static byte getImageR(byte *targa_rgba, int x, int y, int columns, int rows)
-+{
-+	byte	*pixbuf;
-+	
-+	x*=((x<0)?-1:1);
-+	y*=((y<0)?-1:1);
-+  if(rows<=y)
-+		y=y%rows;
-+  if(columns<=x)
-+		x=x%columns;
-+	x*=((x<0)?-1:1);
-+	y*=((y<0)?-1:1);
-+  
-+	
-+	pixbuf = targa_rgba + y*columns*4;
-+	
-+	pixbuf+=(x*4);
-+	
-+	return *pixbuf;
-+}
-+
-+static void setImageR(byte *targa_rgba, int x, int y, int columns, int rows, byte value)
-+{
-+	byte	*pixbuf;
-+	
-+	x*=((x<0)?-1:1);
-+	y*=((y<0)?-1:1);
-+	
-+	pixbuf = targa_rgba + y*columns*4;
-+	
-+	pixbuf+=(x*4);
-+	
-+	*pixbuf=value;
-+}
-+//GREEN
-+static byte getImageG(byte *targa_rgba, int x, int y, int columns, int rows)
-+{
-+	byte	*pixbuf;
-+	
-+	x*=((x<0)?-1:1);
-+	y*=((y<0)?-1:1);
-+  if(rows<=y)
-+		y=y%rows;
-+  if(columns<=x)
-+		x=x%columns;
-+	x*=((x<0)?-1:1);
-+	y*=((y<0)?-1:1);
-+	
-+	pixbuf = targa_rgba + y*columns*4;
-+	
-+	pixbuf+=(x*4);
-+	
-+	pixbuf++;
-+	return *pixbuf;
-+}
-+
-+static void setImageG(byte *targa_rgba, int x, int y, int columns, int rows, byte value)
-+{
-+	byte	*pixbuf;
-+
-+	x*=((x<0)?-1:1);
-+	y*=((y<0)?-1:1);
-+
-+	pixbuf = targa_rgba + y*columns*4;
-+	
-+	pixbuf+=(x*4);
-+	pixbuf++;
-+	*pixbuf=value;
-+}
-+//BLUE
-+static byte getImageB(byte *targa_rgba, int x, int y, int columns, int rows)
-+{
-+	byte	*pixbuf;
-+	
-+	x*=((x<0)?-1:1);
-+	y*=((y<0)?-1:1);
-+  if(rows<=y)
-+		y=y%rows;
-+  if(columns<=x)
-+		x=x%columns;
-+	x*=((x<0)?-1:1);
-+	y*=((y<0)?-1:1);
-+	
-+	pixbuf = targa_rgba + y*columns*4;
-+	
-+	pixbuf+=(x*4);
-+	pixbuf+=2;
-+	return *pixbuf;
-+}
-+
-+static void setImageB(byte *targa_rgba, int x, int y, int columns, int rows, byte value)
-+{
-+	byte	*pixbuf;
-+	
-+	x*=((x<0)?-1:1);
-+	y*=((y<0)?-1:1);
-+	
-+	pixbuf = targa_rgba + y*columns*4;
-+	
-+	pixbuf+=(x*4);
-+	pixbuf+=2;
-+	*pixbuf=value;
-+}
-+//ALPHA
-+static byte getImageA(byte *targa_rgba, int x, int y, int columns, int rows)
-+{
-+	byte	*pixbuf;
-+	
-+	x*=((x<0)?-1:1);
-+	y*=((y<0)?-1:1);
-+	
-+	pixbuf = targa_rgba + y*columns*4;
-+	
-+	pixbuf+=(x*4);
-+	pixbuf+=3;
-+	return *pixbuf;
-+}
-+
-+static void setImageA(byte *targa_rgba, int x, int y, int columns, int rows, byte value)
-+{
-+	byte	*pixbuf;
-+	
-+	x*=((x<0)?-1:1);
-+	y*=((y<0)?-1:1);
-+	
-+	pixbuf = targa_rgba + y*columns*4;
-+	
-+	pixbuf+=(x*4);
-+	pixbuf+=3;
-+	*pixbuf=value;
-+}
-+
-+//RGB
-+static void getImageRGB(byte *targa_rgba, int x, int y, int columns, int rows, vec3_t rgb)
-+{
-+	byte	*pixbuf;
-+	
-+	x*=((x<0)?-1:1);
-+	y*=((y<0)?-1:1);
-+  //if(rows<=y)
-+	y=y%rows;
-+  //if(columns<=x)
-+	x=x%columns;
-+	//x*=((x<0)?-1:1);
-+	//y*=((y<0)?-1:1);
-+	
-+	pixbuf = targa_rgba + y*columns*4 + x*4;
-+	
-+	rgb[0]=*pixbuf;
-+	rgb[1]=*(pixbuf+1);
-+	rgb[2]=*(pixbuf+2);
-+}
-+
-+static void setImageRGB(byte *targa_rgba, int x, int y, int columns, int rows, vec3_t rgb)
-+{
-+	byte	*pixbuf;
-+	
-+	//x*=((x<0)?-1:1);
-+	//y*=((y<0)?-1:1);
-+	
-+	pixbuf = targa_rgba + y*columns*4 + (x*4);
-+	
-+	*pixbuf=(byte)(rgb[0]);
-+	*(pixbuf+1)=(byte)(rgb[1]);
-+	*(pixbuf+2)=(byte)(rgb[2]);
-+}
-+
-+/****************************
-+NO BRAINER'S BLUR
-+****************************/
-+static void blur(int columns, int rows, byte *targa_rgba)
-+{
-+	int		row, column;
-+	float sum;
-+	
-+	
-+		for(row=0; row<rows; row++) 
-+		{
-+			//pixbuf = targa_rgba + row*columns*4;
-+			for(column=0; column<columns; column++) 
-+			{
-+				sum=0;
-+				sum+=getImageR(targa_rgba,column-1,row-1,columns,rows);
-+				sum+=getImageR(targa_rgba,column,row-1,columns,rows);
-+				sum+=getImageR(targa_rgba,column+1,row-1,columns,rows);
-+				sum+=getImageR(targa_rgba,column-1,row,columns,rows);
-+				sum+=getImageR(targa_rgba,column,row,columns,rows);
-+				sum+=getImageR(targa_rgba,column+1,row,columns,rows);
-+				sum+=getImageR(targa_rgba,column-1,row+1,columns,rows);
-+				sum+=getImageR(targa_rgba,column,row+1,columns,rows);
-+				sum+=getImageR(targa_rgba,column+1,row+1,columns,rows);
-+				
-+				sum/=9.0f;
-+				
-+				setImageR(targa_rgba, column, row, columns, rows, (byte)sum);
-+				////////////////////
-+				sum=0;
-+				sum+=getImageG(targa_rgba,column-1,row-1,columns,rows);
-+				sum+=getImageG(targa_rgba,column,row-1,columns,rows);
-+				sum+=getImageG(targa_rgba,column+1,row-1,columns,rows);
-+				sum+=getImageG(targa_rgba,column-1,row,columns,rows);
-+				sum+=getImageG(targa_rgba,column,row,columns,rows);
-+				sum+=getImageG(targa_rgba,column+1,row,columns,rows);
-+				sum+=getImageG(targa_rgba,column-1,row+1,columns,rows);
-+				sum+=getImageG(targa_rgba,column,row+1,columns,rows);
-+				sum+=getImageG(targa_rgba,column+1,row+1,columns,rows);
-+				
-+				sum/=9.0f;
-+				
-+				setImageG(targa_rgba, column, row, columns, rows, (byte)sum);
-+				////////////////////////
-+				sum=0;
-+				sum+=getImageB(targa_rgba,column-1,row-1,columns,rows);
-+				sum+=getImageB(targa_rgba,column,row-1,columns,rows);
-+				sum+=getImageB(targa_rgba,column+1,row-1,columns,rows);
-+				sum+=getImageB(targa_rgba,column-1,row,columns,rows);
-+				sum+=getImageB(targa_rgba,column,row,columns,rows);
-+				sum+=getImageB(targa_rgba,column+1,row,columns,rows);
-+				sum+=getImageB(targa_rgba,column-1,row+1,columns,rows);
-+				sum+=getImageB(targa_rgba,column,row+1,columns,rows);
-+				sum+=getImageB(targa_rgba,column+1,row+1,columns,rows);
-+				
-+				sum/=9.0f;
-+				
-+				setImageB(targa_rgba, column, row, columns, rows, (byte)sum);
-+				
-+				// "halftoning"
-+				/*if((row%5==0)&&(column%5==1))
-+				{
-+					gris=0;
-+					gris+=red;
-+					gris+=green;
-+					gris+=blue;
-+					gris/=3;
-+					
-+					gris=255-gris;
-+					if(gris<0)
-+						gris=0;
-+						
-+						setImageR(targa_rgba, column, row, columns, rows, (byte)gris);
-+						setImageG(targa_rgba, column, row, columns, rows, (byte)gris);
-+						setImageB(targa_rgba, column, row, columns, rows, (byte)gris);
-+					
-+				}*/
-+			
-+			}
-+		}
-+
-+}
-+
-+
-+/****************************
-+COLORED LIGHTMAP
-+****************************/
-+void whiteTextureOne(int columns, int rows, byte *targa_rgba){
-+	//byte	*pixbyf;
-+	int		row, column;
-+	long	rMean=0, gMean=0, bMean=0;
-+	int		pixels=0;
-+
-+	for(row=0;row<rows;row++){
-+		for(column=0;column<columns;column++){
-+			// Don't count fully transparent pixels
-+			if(getImageA(targa_rgba,column,row,columns,rows)==0)
-+				continue;
-+			// Sum pixels values
-+			rMean+=getImageR(targa_rgba,column,row,columns,rows);
-+			gMean+=getImageG(targa_rgba,column,row,columns,rows);
-+			bMean+=getImageB(targa_rgba,column,row,columns,rows);
-+			pixels++;
-+		}
-+	}
-+
-+	// Calculate average
-+	if(pixels>0){
-+		rMean=((float)rMean/(float)pixels);
-+		gMean=((float)gMean/(float)pixels);
-+		bMean=((float)bMean/(float)pixels);
-+	}
-+	else{
-+		return;
-+	}
-+
-+	for(row=0;row<rows;row++){
-+		for(column=0;column<columns;column++){
-+			if(getImageA(targa_rgba,column,row,columns,rows)<32)
-+				continue;
-+			setImageR(targa_rgba,column,row,columns,rows,rMean);
-+			setImageG(targa_rgba,column,row,columns,rows,gMean);
-+			setImageB(targa_rgba,column,row,columns,rows,bMean);
-+		}
-+	}
-+}
-+
-+int diffSquare(int mean, int val){
-+	float variance = (val-mean)/255.0f;
-+	float radius = mean<128?mean:255-mean;
-+	return mean+(radius*variance);
-+}
-+
-+/****************************
-+DECONTRAST
-+****************************/
-+void whiteTextureTwo(int columns, int rows, byte *targa_rgba){
-+	int		row, column;
-+	long	rMean=0, gMean=0, bMean=0;
-+	int r=0, g=0, b=0;
-+	int		pixels=0;
-+
-+	
-+	for(row=0;row<rows;row++){
-+		for(column=0;column<columns;column++){
-+			// Don't count fully transparent pixels
-+			if(getImageA(targa_rgba,column,row,columns,rows)<32)
-+				continue;
-+			// Sum pixels values
-+			rMean+=getImageR(targa_rgba,column,row,columns,rows);
-+			gMean+=getImageG(targa_rgba,column,row,columns,rows);
-+			bMean+=getImageB(targa_rgba,column,row,columns,rows);
-+			pixels++;
-+		}
-+	}
-+
-+	// Calculate average
-+	if(pixels>0){
-+		rMean=rMean/pixels;
-+		gMean=gMean/pixels;
-+		bMean=bMean/pixels;
-+	}
-+	else{
-+		return;
-+	}
-+	
-+
-+	for(row=0;row<rows;row++){
-+		for(column=0;column<columns;column++){
-+			if(getImageA(targa_rgba,column,row,columns,rows)<32)
-+				continue;
-+			r=getImageR(targa_rgba,column,row,columns,rows);
-+			g=getImageG(targa_rgba,column,row,columns,rows);
-+			b=getImageB(targa_rgba,column,row,columns,rows);
-+			
-+			setImageR(targa_rgba,column,row,columns,rows,diffSquare(rMean,r));
-+			setImageG(targa_rgba,column,row,columns,rows,diffSquare(gMean,g));
-+			setImageB(targa_rgba,column,row,columns,rows,diffSquare(bMean,b));
-+			
-+		}
-+	}
-+}
-+
-+/****************************
-+KUWAHARA ,FAILS SOMEWHERE
-+****************************/
-+#define KWH_RADIUS 2
-+static void mean_variance(int x0, int y0, int x1, int y1, int columns, int rows, byte *targa_rgba, vec4_t mv )
-+{
-+	short min=255*3, max=0;
-+	unsigned short count= 0;
-+	short row, column;
-+	unsigned short value;
-+	vec3_t rgb;
-+	
-+	mv[0]=mv[1]=mv[2]=mv[3]=0;
-+
-+	for(row=y0;row<=y1;row++)
-+	{
-+		for(column=x0;column<=x1;column++)
-+		{
-+			getImageRGB(targa_rgba,column,row,columns,rows,rgb);
-+			
-+			VectorAdd(mv,rgb,mv);
-+			
-+			count++;
-+			value=rgb[0]+rgb[1]+rgb[2];
-+			if(value<min) min=value;
-+			if(value>max) max=value;
-+		}
-+	}
-+
-+	mv[0]/=count;
-+	mv[1]/=count;
-+	mv[2]/=count;
-+	mv[3]= (max-min)/3.0f;
-+}
-+
-+
-+static void rgb_kuwahara(int x, int y, int columns, int rows, byte *targa_rgba, vec4_t bmv)
-+{
-+  vec4_t mv;
-+	bmv[0]=bmv[1]=bmv[2]=bmv[3]=255;
-+	
-+	mean_variance(x-KWH_RADIUS, y-KWH_RADIUS, x, y, columns, rows, targa_rgba, mv);
-+	if( mv[3] < bmv[3] )
-+	{
-+		Vector4Copy(mv,bmv);
-+	}
-+	
-+	mean_variance(x, y-KWH_RADIUS, x+KWH_RADIUS, y, columns, rows, targa_rgba, mv);
-+	if( mv[3] < bmv[3] )
-+	{
-+		Vector4Copy(mv,bmv);
-+	}
-+	
-+	mean_variance(x, y, x+KWH_RADIUS, y+KWH_RADIUS, columns, rows, targa_rgba, mv);
-+	if( mv[3] < bmv[3] )
-+	{
-+		Vector4Copy(mv,bmv);
-+	}
-+	
-+	mean_variance(x-KWH_RADIUS, y, x, y+KWH_RADIUS, columns, rows, targa_rgba, mv);
-+	if( mv[3] < bmv[3] )
-+	{
-+		Vector4Copy(mv,bmv);
-+	}
-+}
-+
-+static void kuwahara(int columns, int rows, byte *targa_rgba){
-+	int		row, column;
-+	vec4_t rgbv;
-+	
-+	for(row=0;row<rows;row++){
-+		for(column=0;column<columns;column++){
-+			rgb_kuwahara(column, row, columns, rows, targa_rgba, rgbv);
-+			setImageRGB(targa_rgba,column,row,columns,rows,rgbv);
-+		}
-+	}
-+}
-+
-+
-+#define FLT_MAX		3.40282346638528860000e+38
-+static void kuwahara3(int columns, int rows, byte *targa_rgba)
-+{
-+	byte channel;
-+	int size = 10;
-+	int index1,index2;
-+	int width = columns-4;
-+	int height = rows-4;
-+	int size2 = (size+1)/2;
-+	int offset = (size-1)/2;
-+	const int width2 = columns + offset;
-+	const int height2 = rows + offset;
-+	int x1start = 4;
-+	int y1start = 4;
-+	int x2, y2;
-+	int sum, sum2, n, v=0, xbase, ybase;
-+	int y1,x1;
-+	int xbase2=0, ybase2=0;
-+	float var, min;
-+	float** mean, **variance;
-+
-+	//blur(columns, rows, targa_rgba);
-+
-+	// I hate malloc I hate malloc I hate malloc I hate malloc I hate malloc I hate malloc 
-+	mean = (float**)malloc(sizeof(float*)*width2);
-+	for(index1=0;index1<width2;index1++)
-+		mean[index1] = (float*)malloc(sizeof(float)*height2);
-+
-+	variance = (float**)malloc(sizeof(float*)*width2);
-+	for(index2=0;index2<width2;index2++)
-+		variance[index2] = (float*)malloc(sizeof(float)*height2);
-+
-+	// For each channel (R,G,B)
-+	// for(channel=0;channel<2;channel++)
-+	// FTL
-+	for(channel=0;channel<3;channel++){
-+		for (y1=y1start-offset; y1<y1start+height; y1++) {
-+
-+			for (x1=x1start-offset; x1<x1start+width; x1++) {
-+				sum=0; sum2=0; n=0;
-+				for (x2=x1; x2<x1+size2; x2++) {
-+					for (y2=y1; y2<y1+size2; y2++) {
-+						//v = i(x2, y2);
-+						switch(channel){
-+							case 0:
-+								v = getImageR(targa_rgba,x2,y2,columns,rows);
-+								break;
-+							case 1:
-+								v = getImageG(targa_rgba,x2,y2,columns,rows);
-+								break;
-+							case 2:
-+								v = getImageB(targa_rgba,x2,y2,columns,rows);
-+								break;
-+						}
-+						//v = *targa_rgba + y2*columns*4+x2*4;
-+						v/=10;
-+						v*=10;
-+						sum += v;
-+						sum2 += v*v;
-+						n++;
-+					}
-+				}
-+				//cerr << "Accedo" << endl;
-+				mean[x1+offset][y1+offset] = (float)(sum/n);
-+				variance[x1+offset][y1+offset] = (float)((n*sum2-sum*sum)/n);
-+			}
-+		}
-+
-+		for (y1=y1start; y1<y1start+height; y1++) {
-+			/*if ((y1%20)==0)
-+				cout << (0.7+0.3*(y1-y1start)/height);*/
-+			for (x1=x1start; x1<x1start+width; x1++) {
-+				min =  FLT_MAX;
-+				xbase = x1; ybase=y1;
-+				var = variance[xbase][ybase];
-+				if (var<min){
-+					min= var;
-+					xbase2=xbase;
-+					ybase2=ybase;
-+				}
-+				xbase = x1+offset;
-+				var = variance[xbase][ybase];
-+				if (var<min){
-+					min= var;
-+					xbase2=xbase;
-+					ybase2=ybase;
-+				}
-+				ybase = y1+offset;
-+				var = variance[xbase][ybase];
-+				if (var<min){
-+					min= var;
-+					xbase2=xbase;
-+					ybase2=ybase;
-+				}
-+				xbase = x1;
-+				var = variance[xbase][ybase];
-+				if (var<min){
-+					min= var;
-+					xbase2=xbase;
-+					ybase2=ybase;
-+				}
-+				//i(x1, y1)=(int)(mean[xbase2][ybase2]+0.5);
-+				switch(channel){
-+					case 0:
-+						setImageR(targa_rgba,x1,y1,columns,rows,(byte)(mean[xbase2][ybase2]+0.5));
-+						break;
-+					case 1:
-+						setImageG(targa_rgba,x1,y1,columns,rows,(byte)(mean[xbase2][ybase2]+0.5));
-+						break;
-+					case 2:
-+						setImageB(targa_rgba,x1,y1,columns,rows,(byte)(mean[xbase2][ybase2]+0.5));
-+						break;
-+				}
-+			}
-+		}
-+	}
-+	// Fuck mean & variance, this is hell (!+) Bad Religion
-+	for(index1=0;index1<width2;index1++)
-+		free(mean[index1]);
-+	free(mean);
-+
-+	for(index2=0;index2<width2;index2++)
-+		free(variance[index2]);
-+	free(variance);
-+	
-+	//blur(columns, rows, targa_rgba);  
-+}
-+
-+/****************************
-+Symmetric Nearest Neighbour
-+****************************/
-+
-+#define SNN_RADIUS 3
-+
-+static int deltaE(int l1,int a1,int b1,int l2,int a2,int b2)
-+{
-+	return (l1-l2)*(l1-l2) + (a1-a2)*(a1-a2) + (b1-b2)*(b1-b2);
-+}
-+
-+static void snn(int columns, int rows, byte *targa_rgba)
-+{
-+	
-+	int row, column;
-+	unsigned short sumR, sumG, sumB;
-+	unsigned short count;
-+	short u, v;
-+	byte r, g, b;
-+	byte r1, g1, b1;
-+	byte r2, g2, b2;
-+	for(row=0;row<rows;row++){
-+		for(column=0;column<columns;column++){
-+			sumR=0;
-+			sumG=0;
-+			sumB=0;
-+			count=0;
-+			
-+			r=getImageR(targa_rgba,column,row,columns,rows);
-+			g=getImageG(targa_rgba,column,row,columns,rows);
-+			b=getImageB(targa_rgba,column,row,columns,rows);
-+			
-+			for(v=-SNN_RADIUS;v<=0;v++)
-+			{
-+				for(u=-SNN_RADIUS;u<=SNN_RADIUS;u++)
-+				{
-+					if(v==0&&u>=0) break;
-+					// Sum pixels values
-+					r1=getImageR(targa_rgba,column+u,row+v,columns,rows);
-+					g1=getImageG(targa_rgba,column+u,row+v,columns,rows);
-+					b1=getImageB(targa_rgba,column+u,row+v,columns,rows);
-+					
-+					r2=getImageR(targa_rgba,column-u,row-v,columns,rows);
-+					g2=getImageG(targa_rgba,column-u,row-v,columns,rows);
-+					b2=getImageB(targa_rgba,column-u,row-v,columns,rows);
-+					
-+					if ( deltaE(r,g,b,r1,g1,b1) < deltaE(r,g,b,r2,g2,b2))
-+					{
-+						sumR += r1;
-+						sumG += g1;
-+						sumB += b1;
-+					}
-+					else
-+					{
-+						sumR += r2;
-+						sumG += g2;
-+						sumB += b2;
-+					}
-+					count++;
-+				}
-+			}
-+			
-+			r=(byte)((int)(2*sumR+r)/(int)(2*count+1));
-+			g=(byte)((int)(2*sumG+g)/(int)(2*count+1));
-+			b=(byte)((int)(2*sumB+b)/(int)(2*count+1));
-+			
-+			setImageR(targa_rgba,column,row,columns,rows,r);
-+			setImageG(targa_rgba,column,row,columns,rows,g);
-+			setImageB(targa_rgba,column,row,columns,rows,b);
-+		}
-+	}
-+}
-+
-+
-+
- /*
- =========================================================
- 
-@@ -1968,6 +2621,50 @@
- 	} else if ( !Q_stricmp( name+len-4, ".jpg" ) ) {
- 		LoadJPG( name, pic, width, height );
- 	}
-+
-+	switch(r_celshadalgo->integer)
-+	{
-+		case 1:
-+			whiteTextureOne(*width,*height,*pic);
-+			break;
-+		case 2:
-+			whiteTextureTwo(*width,*height,*pic);
-+			break;
-+		case 10:
-+			kuwahara(*width,*height,*pic);
-+			break;
-+		case 11:
-+			blur(*width,*height,*pic);
-+			kuwahara(*width,*height,*pic);
-+			break;
-+		case 12:
-+			kuwahara(*width,*height,*pic);
-+			blur(*width,*height,*pic);
-+			break;
-+		case 13:
-+			blur(*width,*height,*pic);
-+			kuwahara(*width,*height,*pic);
-+			blur(*width,*height,*pic);
-+			break;
-+		case 20:
-+			snn(*width,*height,*pic);
-+			break;
-+		case 21:
-+			blur(*width,*height,*pic);
-+			snn(*width,*height,*pic);
-+			break;
-+		case 22:
-+			snn(*width,*height,*pic);
-+			blur(*width,*height,*pic);
-+			break;
-+		case 23:
-+			blur(*width,*height,*pic);
-+			snn(*width,*height,*pic);
-+			blur(*width,*height,*pic);
-+			break;
-+		default:
-+			break;
-+	}
- }
- 
- 
-Index: code/renderer/tr_init.c
-===================================================================
---- code/renderer/tr_init.c	(revision 933)
-+++ code/renderer/tr_init.c	(working copy)
-@@ -111,6 +111,10 @@
- cvar_t	*r_roundImagesDown;
- cvar_t	*r_colorMipLevels;
- cvar_t	*r_picmip;
-+// Next one added for cell shading algorithm selection
-+cvar_t	*r_celshadalgo;
-+//. next one for enable/disable cel bordering all together.
-+cvar_t	*r_celoutline;
- cvar_t	*r_showtris;
- cvar_t	*r_showsky;
- cvar_t	*r_shownormals;
-@@ -1110,6 +1114,10 @@
- 	r_debugSurface = ri.Cvar_Get ("r_debugSurface", "0", CVAR_CHEAT);
- 	r_nobind = ri.Cvar_Get ("r_nobind", "0", CVAR_CHEAT);
- 	r_showtris = ri.Cvar_Get ("r_showtris", "0", CVAR_CHEAT);
-+	// for cell shading algorithm selection
-+	r_celshadalgo = ri.Cvar_Get ("r_celshadalgo", "1", CVAR_LATCH);
-+	// cel outline option
-+	r_celoutline = ri.Cvar_Get("r_celoutline","1", CVAR_ARCHIVE);
- 	r_showsky = ri.Cvar_Get ("r_showsky", "0", CVAR_CHEAT);
- 	r_shownormals = ri.Cvar_Get ("r_shownormals", "0", CVAR_CHEAT);
- 	r_clear = ri.Cvar_Get ("r_clear", "0", CVAR_CHEAT);
-Index: code/renderer/tr_local.h
-===================================================================
---- code/renderer/tr_local.h	(revision 933)
-+++ code/renderer/tr_local.h	(working copy)
-@@ -1063,6 +1063,8 @@
- extern	cvar_t	*r_uiFullScreen;				// ui is running fullscreen
- 
- extern	cvar_t	*r_logFile;						// number of frames to emit GL logs
-+extern	cvar_t	*r_celshadalgo;					// Cell shading, chooses method: 0 = disabled, 1 = kuwahara, 2 = whiteTexture
-+extern	cvar_t	*r_celoutline;						//. cel outline. 1 on, 0 off. (maybe other options later)
- extern	cvar_t	*r_showtris;					// enables wireframe rendering of the world
- extern	cvar_t	*r_showsky;						// forces sky in front of all surfaces
- extern	cvar_t	*r_shownormals;					// draws wireframe normals
-Index: code/renderer/tr_shade.c
-===================================================================
---- code/renderer/tr_shade.c	(revision 933)
-+++ code/renderer/tr_shade.c	(working copy)
-@@ -201,6 +201,86 @@
- }
- 
- 
-+//R_DRAWCEL
-+static void R_DrawCel( int numIndexes, const glIndex_t *indexes ) {
-+	int		primitives;
-+	
-+	if(
-+		//. ignore the 2d projection. do i smell the HUD?
-+		(backEnd.projection2D == qtrue) ||
-+		//. ignore general entitites that are sprites. SEE NOTE #3.
-+		(backEnd.currentEntity->e.reType == RT_SPRITE) ||
-+		//. ignore these liquids. why? ever see liquid with tris on the surface? exactly. SEE NOTE #4.
-+		(tess.shader->contentFlags & (CONTENTS_WATER | CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_FOG)) ||
-+		//. ignore things that are two sided, meaning mostly things that have transparency. SEE NOTE #1.		
-+		(tess.shader->cullType == CT_TWO_SIDED)
-+		
-+		) {
-+		return;
-+	}
-+
-+	primitives = r_primitives->integer;
-+
-+	// default is to use triangles if compiled vertex arrays are present
-+	if ( primitives == 0 ) {
-+		if ( qglLockArraysEXT ) {
-+			primitives = 2;
-+		} else {
-+			primitives = 1;
-+		}
-+	}
-+
-+	//. correction for mirrors. SEE NOTE #2.
-+	if(backEnd.viewParms.isMirror == qtrue) { qglCullFace (GL_FRONT); }
-+	else { qglCullFace (GL_BACK); }	
-+
-+	qglEnable (GL_BLEND);
-+	qglBlendFunc (GL_SRC_ALPHA ,GL_ONE_MINUS_SRC_ALPHA);
-+	qglColor3f (0.0f,0.0f,0.0f);
-+	qglLineWidth( (float) r_celoutline->integer );	
-+
-+	if(primitives == 2) {
-+		qglDrawElements( GL_TRIANGLES, numIndexes, GL_INDEX_TYPE, indexes );
-+	} else if(primitives == 1) {
-+		R_DrawStripElements( numIndexes,  indexes, qglArrayElement );
-+	} else if(primitives == 3) {
-+		R_DrawStripElements( numIndexes,  indexes, R_ArrayElementDiscrete );
-+	}
-+
-+	//. correction for mirrors. SEE NOTE #2.
-+	if(backEnd.viewParms.isMirror == qtrue) { qglCullFace (GL_BACK); }
-+	else { qglCullFace (GL_FRONT); }
-+	
-+	qglDisable (GL_BLEND);
-+	
-+	return;
-+
-+/* Notes
-+
-+1. this is going to be a pain in the arse. it fixes things like light `beams` from being cel'd but it
-+also will ignore any other shader set with no culling. this usually is everything that is translucent.
-+but this is a good hack to clean up the screen untill something more selective comes along. or who knows
-+group desision might actually be that this is liked. if so i take back calling it a `hack`, lol.
-+	= bob.
-+
-+2. mirrors display correctly because the normals of the displayed are inverted of normal space. so to
-+continue to have them display correctly, we must invert them inversely from a normal inversion.
-+	= bob.
-+	
-+3. this turns off a lot of space hogging sprite cel outlines. picture if you will five people in a small
-+room all shooting rockets. each smoke puff gets a big black square around it, each explosion gets a big
-+black square around it, and now nobody can see eachother because everyones screen is solid black.
-+	= bob.
-+
-+4. ignoring liquids means you will not get black tris lines all over the top of your liquid. i put this in
-+after seeing the lava on q3dm7 and water on q3ctf2 that had black lines all over the top, making the
-+liquids look solid instead of... liquid.
-+	= bob.
-+
-+*/
-+}
-+
-+
- /*
- =============================================================
- 
-@@ -245,6 +325,33 @@
- 	GL_Bind( bundle->image[ index ] );
- }
- 
-+//DRAWCEL
-+static void DrawCel (shaderCommands_t *input) {
-+
-+	GL_Bind( tr.whiteImage );
-+	qglColor3f (1,1,1);
-+
-+	GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE );
-+
-+	qglDisableClientState (GL_COLOR_ARRAY);
-+	qglDisableClientState (GL_TEXTURE_COORD_ARRAY);
-+
-+	qglVertexPointer (3, GL_FLOAT, 16, input->xyz);	// padded for SIMD
-+
-+	if (qglLockArraysEXT) {
-+		qglLockArraysEXT(0, input->numVertexes);
-+		GLimp_LogComment( "glLockArraysEXT\n" );
-+	}
-+
-+	R_DrawCel( input->numIndexes, input->indexes );
-+
-+	if (qglUnlockArraysEXT) {
-+		qglUnlockArraysEXT();
-+		GLimp_LogComment( "glUnlockArraysEXT\n" );
-+	}
-+
-+}
-+
- /*
- ================
- DrawTris
-@@ -1140,6 +1247,12 @@
- 		qglPolygonOffset( r_offsetFactor->value, r_offsetUnits->value );
- 	}
- 
-+	//. show me cel outlines.
-+	//. there has to be a better place to put this.
-+	if(r_celoutline->integer > 0) {
-+		DrawCel(&tess);
-+	}
-+
- 	//
- 	// if there is only a single pass then we can enable color
- 	// and texture arrays before we compile, otherwise we need
-Index: code/renderer/tr_shader.c
-===================================================================
---- code/renderer/tr_shader.c	(revision 933)
-+++ code/renderer/tr_shader.c	(working copy)
-@@ -2744,7 +2744,17 @@
- */
- qhandle_t RE_RegisterShaderNoMip( const char *name ) {
- 	shader_t	*sh;
-+	// Remember previous value
-+	int			old_r_celshadalgo;
- 
-+	/*
-+	 * This will prevent sprites, like buttons, go through
-+	 * cel shading filters, like kuwahara.
-+	 * @author gmiranda
-+	 */
-+	old_r_celshadalgo = r_celshadalgo->integer;
-+	r_celshadalgo->integer=0;
-+
- 	if ( strlen( name ) >= MAX_QPATH ) {
- 		Com_Printf( "Shader name exceeds MAX_QPATH\n" );
- 		return 0;
-@@ -2752,6 +2762,9 @@
- 
- 	sh = R_FindShader( name, LIGHTMAP_2D, qfalse );
- 
-+	// Restore value
-+	r_celshadalgo->integer=old_r_celshadalgo;
-+
- 	// we want to return 0 if the shader failed to
- 	// load for some reason, but R_FindShader should
- 	// still keep a name allocated for it, so if
diff -Nur ports/games/ioquake3.orig/files/extra-patch-mp3 ports/games/ioquake3/files/extra-patch-mp3
--- ports/games/ioquake3.orig/files/extra-patch-mp3	2009-08-31 08:51:16.000000000 +0200
+++ ports/games/ioquake3/files/extra-patch-mp3	1970-01-01 01:00:00.000000000 +0100
@@ -1,753 +0,0 @@
-Index: code/client/snd_codec.c
-===================================================================
---- code/client/snd_codec.c	(revision 917)
-+++ code/client/snd_codec.c	(working copy)
-@@ -105,6 +105,9 @@
- #if USE_CODEC_VORBIS
- 	S_CodecRegister(&ogg_codec);
- #endif
-+#if USE_CODEC_MP3
-+	S_CodecRegister(&mp3_codec);
-+#endif
- }
- 
- /*
-Index: code/client/snd_codec.h
-===================================================================
---- code/client/snd_codec.h	(revision 917)
-+++ code/client/snd_codec.h	(working copy)
-@@ -95,4 +95,13 @@
- int S_OGG_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer);
- #endif // USE_CODEC_VORBIS
- 
-+// MP3 codec
-+#ifdef USE_CODEC_MP3
-+extern snd_codec_t mp3_codec;
-+void *S_MP3_CodecLoad(const char *filename, snd_info_t *info);
-+snd_stream_t *S_MP3_CodecOpenStream(const char *filename);
-+void S_MP3_CodecCloseStream(snd_stream_t *stream);
-+int S_MP3_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer);
-+#endif // USE_CODEC_MP3
-+
- #endif // !_SND_CODEC_H_
-Index: code/client/snd_codec_mp3.c
-===================================================================
---- code/client/snd_codec_mp3.c	(revision 0)
-+++ code/client/snd_codec_mp3.c	(revision 0)
-@@ -0,0 +1,716 @@
-+/*
-+===========================================================================
-+Copyright (C) 1999-2005 Id Software, Inc.
-+Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com)
-+Copyright (C) 2005-2006 Joerg Dietrich <dietrich_joerg@gmx.de>
-+Copyright (C) 2006 Thilo Schulz <arny@ats.s.bawue.de>
-+
-+This file is part of Quake III Arena source code.
-+
-+Quake III Arena source code is free software; you can redistribute it
-+and/or modify it under the terms of the GNU General Public License as
-+published by the Free Software Foundation; either version 2 of the License,
-+or (at your option) any later version.
-+
-+Quake III Arena source code is distributed in the hope that it will be
-+useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-+GNU General Public License for more details.
-+
-+You should have received a copy of the GNU General Public License
-+along with Quake III Arena source code; if not, write to the Free Software
-+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-+===========================================================================
-+*/
-+
-+// MP3 support is enabled by this define
-+#if USE_CODEC_MP3
-+
-+// includes for the Q3 sound system
-+#include "client.h"
-+#include "snd_codec.h"
-+
-+// includes for the MP3 codec
-+#include <mad.h>
-+
-+#define MP3_SAMPLE_WIDTH		2
-+#define MP3_PCMSAMPLES_PERSLICE		32
-+
-+// buffer size used when reading through the mp3
-+#define MP3_DATA_BUFSIZ			128*1024
-+
-+// undefine this if you don't want any dithering.
-+#define MP3_DITHERING
-+
-+// Q3 MP3 codec
-+snd_codec_t mp3_codec =
-+{
-+	".mp3",
-+	S_MP3_CodecLoad,
-+	S_MP3_CodecOpenStream,
-+	S_MP3_CodecReadStream,
-+	S_MP3_CodecCloseStream,
-+	NULL
-+};
-+
-+// structure used for info purposes
-+struct snd_codec_mp3_info
-+{
-+	byte encbuf[MP3_DATA_BUFSIZ];	// left over bytes not consumed
-+					// by the decoder.
-+	struct mad_stream madstream;	// uses encbuf as buffer.
-+	struct mad_frame madframe;	// control structures for libmad.
-+	struct mad_synth madsynth;
-+
-+	byte *pcmbuf;			// buffer for not-used samples.
-+	int buflen;			// length of buffer data.
-+	int pcmbufsize;			// amount of allocated memory for
-+					// pcmbuf. This should have at least
-+					// the size of a decoded mp3 frame.	
-+
-+	byte *dest;			// copy decoded data here.
-+	int destlen;			// amount of already copied data.
-+	int destsize;			// amount of bytes we must decode.
-+};
-+
-+/*************** MP3 utility functions ***************/
-+
-+/*
-+=================
-+S_MP3_ReadData
-+=================
-+*/
-+
-+// feed libmad with data
-+int S_MP3_ReadData(snd_stream_t *stream, struct mad_stream *madstream, byte *encbuf, int encbufsize)
-+{
-+	int retval;
-+	int leftover;
-+	
-+	if(!stream)
-+		return -1;
-+	
-+	leftover =  madstream->bufend - madstream->next_frame;
-+	if(leftover > 0)
-+		memmove(encbuf, madstream->this_frame, leftover);
-+
-+
-+	// Fill the buffer right to the end
-+	
-+	retval = FS_Read(&encbuf[leftover], encbufsize - leftover, stream->file);
-+
-+	if(retval <= 0)
-+	{
-+		// EOF reached, that's ok.
-+		return 0;
-+	}
-+	
-+	mad_stream_buffer(madstream, encbuf, retval + leftover);
-+	
-+	return retval;
-+}
-+
-+
-+/*
-+=================
-+S_MP3_Scanfile
-+
-+to determine the samplecount, we apparently must get *all* headers :(
-+I basically used the xmms-mad plugin source to see how this stuff works.
-+
-+returns a value < 0 on error.
-+=================
-+*/
-+
-+int S_MP3_Scanfile(snd_stream_t *stream)
-+{
-+	struct mad_stream madstream;
-+	struct mad_header madheader;
-+	int retval;
-+	int samplecount;
-+	byte encbuf[MP3_DATA_BUFSIZ];
-+
-+	// error out on invalid input.
-+	if(!stream)
-+		return -1;
-+
-+	mad_stream_init(&madstream);
-+	mad_header_init(&madheader);
-+	
-+	while(1)
-+	{
-+		retval = S_MP3_ReadData(stream, &madstream, encbuf, sizeof(encbuf));
-+		if(retval < 0)
-+			return -1;
-+		else if(retval == 0)
-+			break;
-+		
-+		// Start decoding the headers.
-+		while(1)
-+		{
-+			if((retval = mad_header_decode(&madheader, &madstream)) < 0)
-+			{
-+				if(madstream.error == MAD_ERROR_BUFLEN)
-+				{
-+					// We need to read more data
-+					break;
-+				}
-+
-+				if(!MAD_RECOVERABLE (madstream.error))
-+				{
-+					// unrecoverable error... we must bail out.
-+					return retval;
-+				}
-+
-+				mad_stream_skip(&madstream, madstream.skiplen);
-+				continue;
-+			}
-+			
-+			// we got a valid header.
-+			
-+			if(madheader.layer != MAD_LAYER_III)
-+			{
-+				// we don't support non-mp3s
-+				return -1;
-+			}
-+
-+			if(!stream->info.samples)
-+			{
-+				// This here is the very first frame. Set initial values now,
-+				// that we expect to stay constant throughout the whole mp3.
-+				
-+				stream->info.rate = madheader.samplerate;
-+				stream->info.width = MP3_SAMPLE_WIDTH;
-+				stream->info.channels = MAD_NCHANNELS(&madheader);
-+				stream->info.samples = 0;
-+				stream->info.size = 0;				// same here.
-+				stream->info.dataofs = 0;
-+			}
-+			else
-+			{
-+				// Check whether something changed that shouldn't.
-+				
-+				if(stream->info.rate != madheader.samplerate ||
-+				   stream->info.channels != MAD_NCHANNELS(&madheader))
-+					return -1;
-+			}
-+
-+			// Update the counters
-+			samplecount = MAD_NSBSAMPLES(&madheader) * MP3_PCMSAMPLES_PERSLICE;
-+			stream->info.samples += samplecount;
-+			stream->info.size += samplecount * stream->info.channels * stream->info.width;			
-+		}
-+	}
-+	
-+	// Reset the file pointer so we can do the real decoding.
-+	FS_Seek(stream->file, 0, FS_SEEK_SET);
-+	
-+	return 0;
-+}
-+
-+/************************ dithering functions ***************************/
-+
-+#ifdef MP3_DITHERING
-+
-+// All dithering done here is taken from the GPL'ed xmms-mad plugin.
-+
-+/* Copyright (C) 1997 Makoto Matsumoto and Takuji Nishimura.       */
-+/* Any feedback is very welcome. For any question, comments,       */
-+/* see http://www.math.keio.ac.jp/matumoto/emt.html or email       */
-+/* matumoto@math.keio.ac.jp                                        */
-+
-+/* Period parameters */
-+#define MP3_DITH_N 624
-+#define MP3_DITH_M 397
-+#define MATRIX_A 0x9908b0df   /* constant vector a */
-+#define UPPER_MASK 0x80000000 /* most significant w-r bits */
-+#define LOWER_MASK 0x7fffffff /* least significant r bits */
-+
-+/* Tempering parameters */
-+#define TEMPERING_MASK_B 0x9d2c5680
-+#define TEMPERING_MASK_C 0xefc60000
-+#define TEMPERING_SHIFT_U(y)  (y >> 11)
-+#define TEMPERING_SHIFT_S(y)  (y << 7)
-+#define TEMPERING_SHIFT_T(y)  (y << 15)
-+#define TEMPERING_SHIFT_L(y)  (y >> 18)
-+
-+static unsigned long mt[MP3_DITH_N]; /* the array for the state vector  */
-+static int mti=MP3_DITH_N+1; /* mti==MP3_DITH_N+1 means mt[MP3_DITH_N] is not initialized */
-+
-+/* initializing the array with a NONZERO seed */
-+void sgenrand(unsigned long seed)
-+{
-+    /* setting initial seeds to mt[MP3_DITH_N] using         */
-+    /* the generator Line 25 of Table 1 in          */
-+    /* [KNUTH 1981, The Art of Computer Programming */
-+    /*    Vol. 2 (2nd Ed.), pp102]                  */
-+    mt[0]= seed & 0xffffffff;
-+    for (mti=1; mti<MP3_DITH_N; mti++)
-+        mt[mti] = (69069 * mt[mti-1]) & 0xffffffff;
-+}
-+
-+unsigned long genrand(void)
-+{
-+    unsigned long y;
-+    static unsigned long mag01[2]={0x0, MATRIX_A};
-+    /* mag01[x] = x * MATRIX_A  for x=0,1 */
-+
-+    if (mti >= MP3_DITH_N) { /* generate MP3_DITH_N words at one time */
-+        int kk;
-+
-+        if (mti == MP3_DITH_N+1)   /* if sgenrand() has not been called, */
-+            sgenrand(4357); /* a default initial seed is used   */
-+
-+        for (kk=0;kk<MP3_DITH_N-MP3_DITH_M;kk++) {
-+            y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
-+            mt[kk] = mt[kk+MP3_DITH_M] ^ (y >> 1) ^ mag01[y & 0x1];
-+        }
-+        for (;kk<MP3_DITH_N-1;kk++) {
-+            y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
-+            mt[kk] = mt[kk+(MP3_DITH_M-MP3_DITH_N)] ^ (y >> 1) ^ mag01[y & 0x1];
-+        }
-+        y = (mt[MP3_DITH_N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK);
-+        mt[MP3_DITH_N-1] = mt[MP3_DITH_M-1] ^ (y >> 1) ^ mag01[y & 0x1];
-+
-+        mti = 0;
-+    }
-+
-+    y = mt[mti++];
-+    y ^= TEMPERING_SHIFT_U(y);
-+    y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B;
-+    y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C;
-+    y ^= TEMPERING_SHIFT_L(y);
-+
-+    return y;
-+}
-+
-+long triangular_dither_noise(int nbits) {
-+    // parameter nbits : the peak-to-peak amplitude desired (in bits)
-+    //  use with nbits set to    2 + nber of bits to be trimmed.
-+    // (because triangular is made from two uniformly distributed processes,
-+    // it starts at 2 bits peak-to-peak amplitude)
-+    // see The Theory of Dithered Quantization by Robert Alexander Wannamaker
-+    // for complete proof of why that's optimal
-+
-+    long v = (genrand()/2 - genrand()/2); // in ]-2^31, 2^31[
-+    //int signe = (v>0) ? 1 : -1;
-+    long P = 1 << (32 - nbits); // the power of 2
-+    v /= P;
-+    // now v in ]-2^(nbits-1), 2^(nbits-1) [
-+
-+    return v;
-+}
-+
-+#endif // MP3_DITHERING
-+
-+/************************ decoder functions ***************************/
-+
-+/*
-+=================
-+S_MP3_Scale
-+
-+Converts the signal to 16 bit LE-PCM data and does dithering.
-+
-+- borrowed from xmms-mad plugin source.
-+=================
-+*/
-+
-+/*
-+ * xmms-mad - mp3 plugin for xmms
-+ * Copyright (C) 2001-2002 Sam Clegg
-+ */
-+
-+signed int S_MP3_Scale(mad_fixed_t sample)
-+{
-+	int n_bits_to_loose = MAD_F_FRACBITS + 1 - 16;
-+#ifdef MP3_DITHERING
-+	int dither;
-+#endif
-+	
-+	// round
-+	sample += (1L << (n_bits_to_loose - 1));
-+
-+#ifdef MP3_DITHERING
-+	dither = triangular_dither_noise(n_bits_to_loose + 1);
-+	sample += dither;
-+#endif
-+
-+	/* clip */
-+	if (sample >= MAD_F_ONE)
-+		sample = MAD_F_ONE - 1;
-+	else if (sample < -MAD_F_ONE)
-+		sample = -MAD_F_ONE;
-+
-+	/* quantize */
-+	return sample >> n_bits_to_loose;
-+}
-+
-+
-+
-+/*
-+=================
-+S_MP3_PCMCopy
-+
-+Copy and convert pcm data until bytecount bytes have been written.
-+return the position in pcm->samples.
-+indicate the amount of actually written bytes in wrotecnt.
-+=================
-+*/
-+
-+int S_MP3_PCMCopy(byte *buf, struct mad_pcm *pcm, int bufofs,
-+			 int sampleofs, int bytecount, int *wrotecnt)
-+{
-+	int written = 0;
-+	signed int sample;
-+	int framesize = pcm->channels * MP3_SAMPLE_WIDTH;
-+
-+	// add new pcm data.
-+	while(written < bytecount && sampleofs < pcm->length)
-+	{
-+		sample = S_MP3_Scale(pcm->samples[0][sampleofs]);
-+
-+#ifdef Q3_BIG_ENDIAN
-+		// output to 16 bit big endian PCM
-+		buf[bufofs++] = (sample >> 8) & 0xff;
-+		buf[bufofs++] = sample & 0xff;
-+#else
-+		// output to 16 bit little endian PCM
-+		buf[bufofs++] = sample & 0xff;
-+		buf[bufofs++] = (sample >> 8) & 0xff;
-+#endif
-+		
-+		if(pcm->channels == 2)
-+		{
-+			sample = S_MP3_Scale(pcm->samples[1][sampleofs]);
-+
-+#ifdef Q3_BIG_ENDIAN
-+			buf[bufofs++] = (sample >> 8) & 0xff;
-+			buf[bufofs++] = sample & 0xff;
-+#else
-+			buf[bufofs++] = sample & 0xff;
-+			buf[bufofs++] = (sample >> 8) & 0xff;
-+#endif
-+		}
-+		
-+		sampleofs++;
-+		written += framesize;
-+	}	
-+
-+	if(wrotecnt)
-+		*wrotecnt = written;
-+
-+	return sampleofs;
-+}
-+
-+
-+/*
-+=================
-+S_MP3_Decode
-+=================
-+*/
-+
-+// gets executed for every decoded frame.
-+int S_MP3_Decode(snd_stream_t *stream)
-+{
-+	struct snd_codec_mp3_info *mp3info;
-+	struct mad_stream *madstream;
-+	struct mad_frame *madframe;
-+	struct mad_synth *madsynth;
-+	struct mad_pcm *pcm;
-+	int cursize;
-+	int samplecount;
-+	int needcount;
-+	int wrote;
-+	int retval;
-+
-+	if(!stream)
-+		return -1;
-+
-+	mp3info = stream->ptr;
-+	madstream = &mp3info->madstream;
-+	madframe = &mp3info->madframe;
-+
-+	if(mad_frame_decode(madframe, madstream))
-+	{
-+		if(madstream->error == MAD_ERROR_BUFLEN)
-+		{
-+			// we need more data. Read another chunk.
-+			retval = S_MP3_ReadData(stream, madstream, mp3info->encbuf, sizeof(mp3info->encbuf));
-+
-+			// call myself again now that buffer is full.
-+			if(retval > 0)
-+				retval = S_MP3_Decode(stream);
-+		}
-+		else if(MAD_RECOVERABLE(madstream->error))
-+		{
-+			mad_stream_skip(madstream, madstream->skiplen);
-+			return S_MP3_Decode(stream);
-+		}
-+		else
-+			retval = -1;
-+
-+		return retval;
-+	}
-+
-+	// check whether this really is an mp3
-+	if(madframe->header.layer != MAD_LAYER_III)
-+		return -1;
-+
-+	// generate pcm data
-+	madsynth = &mp3info->madsynth;
-+	mad_synth_frame(madsynth, madframe);
-+
-+	pcm = &madsynth->pcm;
-+
-+	// perform a few checks to see whether something changed that shouldn't.
-+		
-+	if(stream->info.rate != pcm->samplerate ||
-+	   stream->info.channels != pcm->channels)
-+	{
-+		return -1;
-+	}
-+	// see whether we have got enough data now.
-+	cursize = pcm->length * pcm->channels * stream->info.width;
-+	needcount = mp3info->destsize - mp3info->destlen;
-+
-+	// Copy exactly as many samples as required.
-+	samplecount = S_MP3_PCMCopy(mp3info->dest, pcm,
-+				    mp3info->destlen, 0, needcount, &wrote);
-+	mp3info->destlen += wrote;
-+	
-+	if(samplecount < pcm->length)
-+	{
-+		// Not all samples got copied. Copy the rest into the pcm buffer.
-+		samplecount = S_MP3_PCMCopy(mp3info->pcmbuf, pcm,
-+					    mp3info->buflen,
-+					    samplecount,
-+					    mp3info->pcmbufsize - mp3info->buflen,
-+					    &wrote);
-+		mp3info->buflen += wrote;
-+		
-+
-+		if(samplecount < pcm->length)
-+		{
-+			// The pcm buffer was not large enough. Make it bigger.
-+			byte *newbuf = Z_Malloc(cursize);
-+			
-+			if(mp3info->pcmbuf)
-+			{
-+				memcpy(newbuf, mp3info->pcmbuf, mp3info->buflen);
-+				Z_Free(mp3info->pcmbuf);
-+			}
-+			
-+			mp3info->pcmbuf = newbuf;
-+			mp3info->pcmbufsize = cursize;
-+			
-+			samplecount = S_MP3_PCMCopy(mp3info->pcmbuf, pcm,
-+						    mp3info->buflen,
-+						    samplecount,
-+						    mp3info->pcmbufsize - mp3info->buflen,
-+						    &wrote);
-+			mp3info->buflen += wrote;		
-+		}		
-+		
-+		// we're definitely done.
-+		retval = 0;
-+	}
-+	else if(mp3info->destlen >= mp3info->destsize)
-+		retval = 0;
-+	else
-+		retval = 1;
-+
-+	return retval;
-+}
-+
-+/*************** Callback functions for quake3 ***************/
-+
-+/*
-+=================
-+S_MP3_CodecOpenStream
-+=================
-+*/
-+
-+snd_stream_t *S_MP3_CodecOpenStream(const char *filename)
-+{
-+	snd_stream_t *stream;
-+	struct snd_codec_mp3_info *mp3info;
-+
-+	// Open the stream
-+	stream = S_CodecUtilOpen(filename, &mp3_codec);
-+	if(!stream || stream->length <= 0)
-+		return NULL;
-+
-+	// We have to scan through the MP3 to determine the important mp3 info.
-+	if(S_MP3_Scanfile(stream) < 0)
-+	{
-+		// scanning didn't work out...
-+		S_CodecUtilClose(stream);
-+		return NULL;
-+	}
-+
-+	// Initialize the mp3 info structure we need for streaming
-+	mp3info = Z_Malloc(sizeof(*mp3info));
-+	if(!mp3info)
-+	{
-+		S_CodecUtilClose(stream);
-+		return NULL;
-+	}
-+
-+	stream->ptr = mp3info;
-+
-+	// initialize the libmad control structures.
-+	mad_stream_init(&mp3info->madstream);
-+	mad_frame_init(&mp3info->madframe);
-+	mad_synth_init(&mp3info->madsynth);
-+
-+	if(S_MP3_ReadData(stream, &mp3info->madstream, mp3info->encbuf, sizeof(mp3info->encbuf)) <= 0)
-+	{
-+		// we didnt read anything, that's bad.
-+		S_MP3_CodecCloseStream(stream);
-+		return NULL;
-+	}
-+
-+	return stream;
-+}
-+
-+/*
-+=================
-+S_MP3_CodecCloseStream
-+=================
-+*/
-+
-+// free all memory we allocated.
-+void S_MP3_CodecCloseStream(snd_stream_t *stream)
-+{
-+	struct snd_codec_mp3_info *mp3info;
-+	
-+	if(!stream)
-+		return;
-+		
-+	// free all data in our mp3info tree
-+
-+	if(stream->ptr)
-+	{
-+		mp3info = stream->ptr;
-+
-+		if(mp3info->pcmbuf)
-+			Z_Free(mp3info->pcmbuf);
-+
-+		mad_synth_finish(&mp3info->madsynth);
-+		mad_frame_finish(&mp3info->madframe);
-+		mad_stream_finish(&mp3info->madstream);
-+	
-+		Z_Free(stream->ptr);
-+	}
-+
-+	S_CodecUtilClose(stream);
-+}
-+
-+/*
-+=================
-+S_MP3_CodecReadStream
-+=================
-+*/
-+int S_MP3_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer)
-+{
-+	struct snd_codec_mp3_info *mp3info;
-+	int retval;
-+	
-+	if(!stream)
-+		return -1;
-+		
-+	mp3info = stream->ptr;
-+
-+	// Make sure we get complete frames all the way through.
-+	bytes -= bytes % (stream->info.channels * stream->info.width);
-+
-+	if(mp3info->buflen)
-+	{
-+		if(bytes < mp3info->buflen)
-+		{
-+			// we still have enough bytes in our decoded pcm buffer
-+			memcpy(buffer, mp3info->pcmbuf, bytes);
-+		
-+			// remove the portion from our buffer.
-+			mp3info->buflen -= bytes;
-+			memmove(mp3info->pcmbuf, &mp3info->pcmbuf[bytes], mp3info->buflen);
-+			return bytes;
-+		}
-+		else
-+		{
-+			// copy over the samples we already have.
-+			memcpy(buffer, mp3info->pcmbuf, mp3info->buflen);
-+			mp3info->destlen = mp3info->buflen;
-+			mp3info->buflen = 0;
-+		}
-+	}
-+	else
-+		mp3info->destlen = 0;
-+	
-+	mp3info->dest = buffer;
-+	mp3info->destsize = bytes;
-+
-+	do
-+	{
-+		retval = S_MP3_Decode(stream);
-+	} while(retval > 0);
-+	
-+	// if there was an error return nothing.
-+	if(retval < 0)
-+		return 0;
-+	
-+	return mp3info->destlen;
-+}
-+
-+/*
-+=====================================================================
-+S_MP3_CodecLoad
-+
-+We handle S_MP3_CodecLoad as a special case of the streaming functions 
-+where we read the whole stream at once.
-+======================================================================
-+*/
-+void *S_MP3_CodecLoad(const char *filename, snd_info_t *info)
-+{
-+	snd_stream_t *stream;
-+	byte *pcmbuffer;
-+
-+	// check if input is valid
-+	if(!filename)
-+		return NULL;
-+
-+	stream = S_MP3_CodecOpenStream(filename);
-+	
-+	if(!stream)
-+		return NULL;
-+		
-+        // copy over the info
-+        info->rate = stream->info.rate;
-+        info->width = stream->info.width;
-+        info->channels = stream->info.channels;
-+        info->samples = stream->info.samples;
-+        info->dataofs = stream->info.dataofs;
-+	
-+	// allocate enough buffer for all pcm data
-+	pcmbuffer = Z_Malloc(stream->info.size);
-+	if(!pcmbuffer)
-+	{
-+		S_MP3_CodecCloseStream(stream);
-+		return NULL;
-+	}
-+
-+	info->size = S_MP3_CodecReadStream(stream, stream->info.size, pcmbuffer);
-+
-+	if(info->size <= 0)
-+	{
-+		// we didn't read anything at all. darn.
-+		Z_Free(pcmbuffer);
-+		pcmbuffer = NULL;
-+	}
-+
-+	S_MP3_CodecCloseStream(stream);
-+
-+	return pcmbuffer;
-+}
-+
-+#endif // USE_CODEC_MP3
diff -Nur ports/games/ioquake3.orig/files/patch-Makefile ports/games/ioquake3/files/patch-Makefile
--- ports/games/ioquake3.orig/files/patch-Makefile	2009-08-31 08:51:16.000000000 +0200
+++ ports/games/ioquake3/files/patch-Makefile	2009-09-01 23:30:53.000000000 +0200
@@ -1,98 +1,22 @@
---- Makefile.orig	Tue Nov 28 19:05:39 2006
-+++ Makefile	Fri Sep 28 22:39:49 2007
-@@ -26,11 +26,20 @@
-   endif
- endif
- 
--BUILD_CLIENT     =
--BUILD_CLIENT_SMP =
--BUILD_SERVER     =
--BUILD_GAME_SO    =
--BUILD_GAME_QVM   =
-+BUILD_CLIENT?=0
-+BUILD_CLIENT_SMP?=0
-+BUILD_GAME_QVM?=0
-+BUILD_GAME_SO?=0
-+BUILD_SERVER?=0
-+HAVE_VM_COMPILED?=false
-+USE_CODEC_MP3?=0
-+USE_CODEC_VORBIS?=0
-+USE_LOCAL_HEADERS?=0
-+USE_OPENAL?=0
-+USE_OPENAL_DLOPEN?=0
-+USE_OPTIMIZED_CFLAGS?=0
-+USE_SDL_AUDIO?=0
-+USE_SDL_VIDEO?=0
- 
- #############################################################################
- #
-@@ -88,30 +97,10 @@
+--- Makefile.orig	2009-08-30 19:33:49.000000000 +0200
++++ Makefile	2009-09-01 23:28:34.000000000 +0200
+@@ -17,6 +17,15 @@
+   COMPILE_ARCH=$(shell uname -p | sed -e s/i.86/i386/)
  endif
- export USE_CCACHE
- 
--ifndef USE_SDL
--USE_SDL=1
--endif
--
--ifndef USE_OPENAL
--USE_OPENAL=1
--endif
--
--ifndef USE_OPENAL_DLOPEN
--USE_OPENAL_DLOPEN=0
--endif
--
--ifndef USE_CODEC_VORBIS
--USE_CODEC_VORBIS=0
--endif
--
--ifndef USE_LOCAL_HEADERS
--USE_LOCAL_HEADERS=1
--endif
--
- #############################################################################
- 
- BD=$(BUILD_DIR)/debug-$(PLATFORM)-$(ARCH)
--BR=$(BUILD_DIR)/release-$(PLATFORM)-$(ARCH)
-+BR=$(BUILD_DIR)/release
- CDIR=$(MOUNT_DIR)/client
- SDIR=$(MOUNT_DIR)/server
- RDIR=$(MOUNT_DIR)/renderer
-@@ -185,6 +174,10 @@
-     BASE_CFLAGS += -DUSE_CODEC_VORBIS=1
-   endif
  
-+  ifeq ($(USE_CODEC_MP3),1)
-+    BASE_CFLAGS += -DUSE_CODEC_MP3=1
++ifeq ($(COMPILE_PLATFORM),freebsd)
++  ifeq ($(COMPILE_ARCH),amd64)
++    COMPILE_ARCH=x86_64
 +  endif
-+
-   ifeq ($(USE_SDL),1)
-     BASE_CFLAGS += -DUSE_SDL_VIDEO=1 -DUSE_SDL_SOUND=1 $(shell sdl-config --cflags)
-     GL_CFLAGS =
-@@ -243,6 +236,10 @@
-     endif
-   endif
- 
-+  ifeq ($(USE_CODEC_MP3),1)
-+    CLIENT_LDFLAGS += -lmad
-+  endif
-+
-   ifeq ($(USE_CODEC_VORBIS),1)
-     CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg
-   endif
-@@ -342,6 +339,11 @@
-     endif
-   endif
- 
-+  ifeq ($(USE_CODEC_MP3),1)
-+    BASE_CFLAGS += -DUSE_CODEC_MP3=1
-+    CLIENT_LDFLAGS += -lmad
++  ifeq ($(COMPILE_ARCH),i386)
++    COMPILE_ARCH=x86
 +  endif
++endif
 +
-   ifeq ($(USE_CODEC_VORBIS),1)
-     BASE_CFLAGS += -DUSE_CODEC_VORBIS=1
-     CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg
-@@ -444,18 +446,12 @@
+ ifeq ($(COMPILE_PLATFORM),mingw32)
+   ifeq ($(COMPILE_ARCH),i386)
+     COMPILE_ARCH=x86
+@@ -521,15 +530,35 @@
  
  ifeq ($(PLATFORM),freebsd)
  
@@ -101,289 +25,70 @@
 -  else #default to i386
 -    ARCH=i386
 -  endif #alpha test
--
--
--  BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes
-+  BASE_CFLAGS = -DARCH='\"$(ARCH)\"' -DLIBDIR='\"$(LIBDIR)\"' -I$(LOCALBASE)/include -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes
++  FREEBSD_ARCH = $(ARCH)
++  ifeq ($(ARCH),amd64)
++    ARCH = x86_64
++  endif
++  ifeq ($(ARCH),i386)
++    ARCH = x86
++  endif
++
++  ifeq ($(FREEBSD_ARCH),x86_64)
++    FREEBSD_ARCH = amd64
++  endif
++  ifeq ($(FREEBSD_ARCH),x86)
++    FREEBSD_ARCH = i386
++  endif
  
--  GL_CFLAGS = -I/usr/X11R6/include
-+  GL_CFLAGS = -I$(LOCALBASE)/include
++  ifndef HOMEPATH
++    HOMEPATH = /.ioquake3
++  endif
++
++  ifndef DEFAULT_LIBDIR
++    DEFAULT_LIBDIR = /usr/local/lib/ioquake3
++  endif
  
-   DEBUG_CFLAGS=$(BASE_CFLAGS) -g
-+  RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -pipe
+   BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
+-    -DUSE_ICON $(shell sdl-config --cflags)
++    -DUSE_ICON $(shell sdl-config --cflags) -DMAP_ANONYMOUS=MAP_ANON \
++    -DHOMEPATH=\\\"$(HOMEPATH)\\\" \
++    -DDEFAULT_LIBDIR=\\\"$(DEFAULT_LIBDIR)\\\" \
++    $(shell make -f /dev/null -VCFLAGS MACHINE_ARCH=$(FREEBSD_ARCH))
++    
  
    ifeq ($(USE_OPENAL),1)
-     BASE_CFLAGS += -DUSE_OPENAL=1
-@@ -468,47 +464,61 @@
-     BASE_CFLAGS += -DUSE_CODEC_VORBIS=1
-   endif
- 
--  ifeq ($(USE_SDL),1)
--    BASE_CFLAGS += $(shell sdl-config --cflags) -DUSE_SDL_VIDEO=1 -DUSE_SDL_SOUND=1
-+  ifeq ($(USE_SDL_AUDIO),1)
-+    BASE_CFLAGS += $(shell $(SDL_CONFIG) --cflags)
-+  else
-+    ifeq ($(USE_SDL_VIDEO),1)
-+      BASE_CFLAGS += $(shell $(SDL_CONFIG) --cflags)
-+    endif
-   endif
- 
--  ifeq ($(ARCH),axp)
--    CC=gcc
--    BASE_CFLAGS += -DNO_VM_COMPILED
--    RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 -ffast-math -funroll-loops \
--      -fomit-frame-pointer -fexpensive-optimizations
--  else
+     BASE_CFLAGS += -DUSE_OPENAL
+@@ -547,9 +576,22 @@
+     RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 -ffast-math -funroll-loops \
+       -fomit-frame-pointer -fexpensive-optimizations
+   else
 -  ifeq ($(ARCH),i386)
--    CC=gcc
 -    RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 -mtune=pentiumpro \
 -      -march=pentium -fomit-frame-pointer -pipe -ffast-math \
--      -falign-loops=2 -falign-jumps=2 -falign-functions=2 \
--      -funroll-loops -fstrength-reduce
--    HAVE_VM_COMPILED=true
--  else
--    BASE_CFLAGS += -DNO_VM_COMPILED
-+  ifeq ($(USE_SDL_AUDIO),1)
-+    BASE_CFLAGS += -DUSE_SDL_SOUND=1
-+  endif
-+
-+  ifeq ($(USE_SDL_VIDEO),1)
-+    BASE_CFLAGS += -DUSE_SDL_VIDEO=1
-+  endif
-+
-+  ifeq ($(USE_OPTIMIZED_CFLAGS),1)
-+    RELEASE_CFLAGS+=-O3 -ffast-math -funroll-loops -fomit-frame-pointer \
-+       -fexpensive-optimizations
-+    ifeq ($(ARCH),i386)
-+      RELEASE_CFLAGS+=-falign-loops=2 -falign-jumps=2 -falign-functions=2 \
-+         -fstrength-reduce
++  ifeq ($(ARCH),x86)
++    ifeq ($(CROSS_COMPILING),1)
++      BASE_CFLAGS += -m32
 +    endif
-   endif
-+
-+  ifneq ($(HAVE_VM_COMPILED),true)
-+    BASE_CFLAGS += -DNO_VM_COMPILED
-   endif
- 
-   SHLIBEXT=so
-   SHLIBCFLAGS=-fPIC
-   SHLIBLDFLAGS=-shared $(LDFLAGS)
- 
--  THREAD_LDFLAGS=-lpthread
-+  THREAD_LDFLAGS=$(PTHREAD_LIBS)
-   # don't need -ldl (FreeBSD)
-   LDFLAGS=-lm
- 
--  CLIENT_LDFLAGS =
-+  CLIENT_LDFLAGS = -L$(LOCALBASE)/lib
- 
--  ifeq ($(USE_SDL),1)
--    CLIENT_LDFLAGS += $(shell sdl-config --libs)
-+  ifeq ($(USE_SDL_AUDIO),1)
-+    CLIENT_LDFLAGS += $(shell $(SDL_CONFIG) --libs)
-   else
--    CLIENT_LDFLAGS += -L/usr/X11R6/$(LIB) -lGL -lX11 -lXext -lXxf86dga -lXxf86vm
-+    ifeq ($(USE_SDL_VIDEO),1)
-+      CLIENT_LDFLAGS += $(shell $(SDL_CONFIG) --libs)
++    RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 \
++      -fomit-frame-pointer -pipe -ffast-math \
++      -falign-loops=2 -falign-jumps=2 -falign-functions=2 \
++      -funroll-loops -fstrength-reduce
++    HAVE_VM_COMPILED=true
++  else
++  ifeq ($(ARCH),x86_64)
++    ifeq ($(CROSS_COMPILING),1)
++      BASE_CFLAGS += -m64
 +    endif
-+  endif
-+
-+  ifneq ($(USE_SDL_VIDEO),1)
-+    CLIENT_LDFLAGS += -L$(LOCALBASE)/lib -lGL -lX11 -lXext -lXxf86dga -lXxf86vm
++    RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 \
++      -fomit-frame-pointer -pipe -ffast-math \
+       -falign-loops=2 -falign-jumps=2 -falign-functions=2 \
+       -funroll-loops -fstrength-reduce
+     HAVE_VM_COMPILED=true
+@@ -557,6 +599,7 @@
+     BASE_CFLAGS += -DNO_VM_COMPILED
    endif
- 
-   ifeq ($(USE_OPENAL),1)
-+    CLIENT_LDFLAGS += $(THREAD_LDFLAGS)
-     ifneq ($(USE_OPENAL_DLOPEN),1)
--      CLIENT_LDFLAGS += $(THREAD_LDFLAGS) -lopenal
-+      CLIENT_LDFLAGS += -lopenal
-     endif
    endif
++  endif
  
-@@ -516,7 +526,6 @@
-     CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg
-   endif
- 
--
- else # ifeq freebsd
- 
- #############################################################################
-@@ -670,24 +679,25 @@
- TARGETS =
- 
- ifneq ($(BUILD_SERVER),0)
--  TARGETS += $(B)/ioq3ded.$(ARCH)$(BINEXT)
-+  TARGETS += $(B)/ioq3ded$(BINEXT)
- endif
- 
- ifneq ($(BUILD_CLIENT),0)
--  TARGETS += $(B)/ioquake3.$(ARCH)$(BINEXT)
--  ifneq ($(BUILD_CLIENT_SMP),0)
--    TARGETS += $(B)/ioquake3-smp.$(ARCH)$(BINEXT)
--  endif
-+  TARGETS += $(B)/ioquake3$(BINEXT)
-+endif
-+
-+ifneq ($(BUILD_CLIENT_SMP),0)
-+  TARGETS += $(B)/ioquake3-smp$(BINEXT)
- endif
- 
- ifneq ($(BUILD_GAME_SO),0)
-   TARGETS += \
--    $(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/cgame.$(SHLIBEXT) \
-+    $(B)/baseq3/qagame.$(SHLIBEXT) \
-+    $(B)/baseq3/ui.$(SHLIBEXT)     \
-+    $(B)/missionpack/cgame.$(SHLIBEXT) \
-+    $(B)/missionpack/qagame.$(SHLIBEXT) \
-+    $(B)/missionpack/ui.$(SHLIBEXT)
- endif
- 
- ifneq ($(BUILD_GAME_QVM),0)
-@@ -749,11 +759,11 @@
- 	$(MAKE)  targets B=$(BD) CFLAGS="$(CFLAGS) $(DEBUG_CFLAGS) $(DEPEND_CFLAGS)"
- 
- build_release: B=$(BR)
--build_release: makedirs tools
-+build_release: makedirs
- 	$(MAKE)  targets B=$(BR) CFLAGS="$(CFLAGS) $(RELEASE_CFLAGS) $(DEPEND_CFLAGS)"
- 
- #Build both debug and release builds
--all:build_debug build_release
-+all:build_release
- 
- targets: $(TARGETS)
- 
-@@ -835,8 +845,13 @@
-   $(B)/client/snd_main.o \
-   $(B)/client/snd_codec.o \
-   $(B)/client/snd_codec_wav.o \
--  $(B)/client/snd_codec_ogg.o \
--  \
-+  $(B)/client/snd_codec_ogg.o
-+
-+ifeq ($(USE_CODEC_MP3),1)
-+  Q3OBJ += $(B)/client/snd_codec_mp3.o
-+endif
-+
-+Q3OBJ += \
-   $(B)/client/qal.o \
-   $(B)/client/snd_openal.o \
-   \
-@@ -964,13 +979,10 @@
-   ifeq ($(ARCH),i386)
-     Q3OBJ += $(B)/client/vm_x86.o
-   endif
--  ifeq ($(ARCH),x86)
--    Q3OBJ += $(B)/client/vm_x86.o
--  endif
--  ifeq ($(ARCH),x86_64)
-+  ifeq ($(ARCH),amd64)
-     Q3OBJ += $(B)/client/vm_x86_64.o
-   endif
--  ifeq ($(ARCH),ppc)
-+  ifeq ($(ARCH),powerpc)
-     Q3OBJ += $(B)/client/$(VM_PPC).o
-   endif
- endif
-@@ -1017,10 +1029,10 @@
-     $(B)/client/sdl_glimp_smp.o
- endif
- 
--$(B)/ioquake3.$(ARCH)$(BINEXT): $(Q3OBJ) $(Q3POBJ) $(LIBSDLMAIN)
-+$(B)/ioquake3$(BINEXT): $(Q3OBJ) $(Q3POBJ) $(LIBSDLMAIN)
- 	$(CC)  -o $@ $(Q3OBJ) $(Q3POBJ) $(CLIENT_LDFLAGS) $(LDFLAGS) $(LIBSDLMAIN)
- 
--$(B)/ioquake3-smp.$(ARCH)$(BINEXT): $(Q3OBJ) $(Q3POBJ_SMP) $(LIBSDLMAIN)
-+$(B)/ioquake3-smp$(BINEXT): $(Q3OBJ) $(Q3POBJ_SMP) $(LIBSDLMAIN)
- 	$(CC)  -o $@ $(Q3OBJ) $(Q3POBJ_SMP) $(CLIENT_LDFLAGS) \
- 		$(THREAD_LDFLAGS) $(LDFLAGS) $(LIBSDLMAIN)
- 
-@@ -1056,6 +1068,7 @@
- $(B)/client/snd_codec.o : $(CDIR)/snd_codec.c; $(DO_CC)
- $(B)/client/snd_codec_wav.o : $(CDIR)/snd_codec_wav.c; $(DO_CC)
- $(B)/client/snd_codec_ogg.o : $(CDIR)/snd_codec_ogg.c; $(DO_CC)
-+$(B)/client/snd_codec_mp3.o : $(CDIR)/snd_codec_mp3.c; $(DO_CC)
- 
- $(B)/client/qal.o : $(CDIR)/qal.c; $(DO_CC)
- $(B)/client/snd_openal.o : $(CDIR)/snd_openal.c; $(DO_CC)
-@@ -1317,18 +1330,15 @@
-   ifeq ($(ARCH),i386)
-     Q3DOBJ += $(B)/ded/vm_x86.o
-   endif
--  ifeq ($(ARCH),x86)
--    Q3DOBJ += $(B)/ded/vm_x86.o
--  endif
--  ifeq ($(ARCH),x86_64)
-+  ifeq ($(ARCH),amd64)
-     Q3DOBJ += $(B)/ded/vm_x86_64.o
-   endif
--  ifeq ($(ARCH),ppc)
-+  ifeq ($(ARCH),powerpc)
-     Q3DOBJ += $(B)/ded/$(VM_PPC).o
-   endif
- endif
- 
--$(B)/ioq3ded.$(ARCH)$(BINEXT): $(Q3DOBJ)
-+$(B)/ioq3ded$(BINEXT): $(Q3DOBJ)
- 	$(CC) -o $@ $(Q3DOBJ) $(LDFLAGS)
- 
- $(B)/ded/sv_bot.o : $(SDIR)/sv_bot.c; $(DO_DED_CC)
-@@ -1445,7 +1455,7 @@
- Q3CGOBJ = $(Q3CGOBJ_) $(B)/baseq3/cgame/cg_syscalls.o
- Q3CGVMOBJ = $(Q3CGOBJ_:%.o=%.asm) $(B)/baseq3/game/bg_lib.asm
- 
--$(B)/baseq3/cgame$(ARCH).$(SHLIBEXT) : $(Q3CGOBJ)
-+$(B)/baseq3/cgame.$(SHLIBEXT) : $(Q3CGOBJ)
- 	$(CC) $(SHLIBLDFLAGS) -o $@ $(Q3CGOBJ)
- 
- $(B)/baseq3/vm/cgame.qvm: $(Q3CGVMOBJ) $(CGDIR)/cg_syscalls.asm
-@@ -1486,7 +1496,7 @@
- MPCGOBJ = $(MPCGOBJ_) $(B)/missionpack/cgame/cg_syscalls.o
- MPCGVMOBJ = $(MPCGOBJ_:%.o=%.asm) $(B)/missionpack/game/bg_lib.asm
- 
--$(B)/missionpack/cgame$(ARCH).$(SHLIBEXT) : $(MPCGOBJ)
-+$(B)/missionpack/cgame.$(SHLIBEXT) : $(MPCGOBJ)
- 	$(CC) $(SHLIBLDFLAGS) -o $@ $(MPCGOBJ)
- 
- $(B)/missionpack/vm/cgame.qvm: $(MPCGVMOBJ) $(CGDIR)/cg_syscalls.asm
-@@ -1536,7 +1546,7 @@
- Q3GOBJ = $(Q3GOBJ_) $(B)/baseq3/game/g_syscalls.o
- Q3GVMOBJ = $(Q3GOBJ_:%.o=%.asm) $(B)/baseq3/game/bg_lib.asm
- 
--$(B)/baseq3/qagame$(ARCH).$(SHLIBEXT) : $(Q3GOBJ)
-+$(B)/baseq3/qagame.$(SHLIBEXT) : $(Q3GOBJ)
- 	$(CC) $(SHLIBLDFLAGS) -o $@ $(Q3GOBJ)
- 
- $(B)/baseq3/vm/qagame.qvm: $(Q3GVMOBJ) $(GDIR)/g_syscalls.asm
-@@ -1584,7 +1594,7 @@
- MPGOBJ = $(MPGOBJ_) $(B)/missionpack/game/g_syscalls.o
- MPGVMOBJ = $(MPGOBJ_:%.o=%.asm) $(B)/missionpack/game/bg_lib.asm
- 
--$(B)/missionpack/qagame$(ARCH).$(SHLIBEXT) : $(MPGOBJ)
-+$(B)/missionpack/qagame.$(SHLIBEXT) : $(MPGOBJ)
- 	$(CC) $(SHLIBLDFLAGS) -o $@ $(MPGOBJ)
- 
- $(B)/missionpack/vm/qagame.qvm: $(MPGVMOBJ) $(GDIR)/g_syscalls.asm
-@@ -1644,7 +1654,7 @@
- Q3UIOBJ = $(Q3UIOBJ_) $(B)/missionpack/ui/ui_syscalls.o
- Q3UIVMOBJ = $(Q3UIOBJ_:%.o=%.asm) $(B)/baseq3/game/bg_lib.asm
- 
--$(B)/baseq3/ui$(ARCH).$(SHLIBEXT) : $(Q3UIOBJ)
-+$(B)/baseq3/ui.$(SHLIBEXT) : $(Q3UIOBJ)
- 	$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(Q3UIOBJ)
- 
- $(B)/baseq3/vm/ui.qvm: $(Q3UIVMOBJ) $(UIDIR)/ui_syscalls.asm
-@@ -1669,7 +1679,7 @@
- MPUIOBJ = $(MPUIOBJ_) $(B)/missionpack/ui/ui_syscalls.o
- MPUIVMOBJ = $(MPUIOBJ_:%.o=%.asm) $(B)/baseq3/game/bg_lib.asm
- 
--$(B)/missionpack/ui$(ARCH).$(SHLIBEXT) : $(MPUIOBJ)
-+$(B)/missionpack/ui.$(SHLIBEXT) : $(MPUIOBJ)
- 	$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(MPUIOBJ)
+   DEBUG_CFLAGS=$(BASE_CFLAGS) -g
  
- $(B)/missionpack/vm/ui.qvm: $(MPUIVMOBJ) $(UIDIR)/ui_syscalls.asm
diff -Nur ports/games/ioquake3.orig/files/patch-README ports/games/ioquake3/files/patch-README
--- ports/games/ioquake3.orig/files/patch-README	1970-01-01 01:00:00.000000000 +0100
+++ ports/games/ioquake3/files/patch-README	2009-08-31 10:01:50.000000000 +0200
@@ -0,0 +1,11 @@
+--- README.orig	2009-08-30 23:34:03.000000000 +0200
++++ README	2009-08-31 00:05:03.000000000 +0200
+@@ -79,6 +79,8 @@
+   CFLAGS            - use this for custom CFLAGS
+   V                 - set to show cc command line when building
+   DEFAULT_BASEDIR   - extra path to search for baseq3 and such
++  DEFAULT_LIBDIR    - extra path to search for libraries (FreeBSD only)
++  HOMEPATH          - alternative home directory (FreeBSD only)
+   BUILD_SERVER      - build the 'ioq3ded' server binary
+   BUILD_CLIENT      - build the 'ioquake3' client binary
+   BUILD_CLIENT_SMP  - build the 'ioquake3-smp' client binary
diff -Nur ports/games/ioquake3.orig/files/patch-code-qcommon-files.c ports/games/ioquake3/files/patch-code-qcommon-files.c
--- ports/games/ioquake3.orig/files/patch-code-qcommon-files.c	1970-01-01 01:00:00.000000000 +0100
+++ ports/games/ioquake3/files/patch-code-qcommon-files.c	2009-08-31 10:01:50.000000000 +0200
@@ -0,0 +1,23 @@
+--- code/qcommon/files.c.orig	2009-08-30 22:58:50.000000000 +0200
++++ code/qcommon/files.c	2009-08-30 23:10:53.000000000 +0200
+@@ -241,6 +241,9 @@
+ #endif
+ 
+ static	cvar_t		*fs_basepath;
++#ifdef __FreeBSD__
++static	cvar_t		*fs_libpath;
++#endif
+ static	cvar_t		*fs_basegame;
+ static	cvar_t		*fs_gamedirvar;
+ static	searchpath_t	*fs_searchpaths;
+@@ -2761,6 +2764,10 @@
+ 	fs_debug = Cvar_Get( "fs_debug", "0", 0 );
+ 	fs_basepath = Cvar_Get ("fs_basepath", Sys_DefaultInstallPath(), CVAR_INIT );
+ 	fs_basegame = Cvar_Get ("fs_basegame", "", CVAR_INIT );
++	#ifdef __FreeBSD__
++	fs_libpath = Cvar_Get ("fs_libpath", Sys_DefaultLibPath(), CVAR_INIT );
++	#endif
++	
+ 	homePath = Sys_DefaultHomePath();
+ 	if (!homePath || !homePath[0]) {
+ 		homePath = fs_basepath->string;
diff -Nur ports/games/ioquake3.orig/files/patch-code-qcommon-q_platform.h ports/games/ioquake3/files/patch-code-qcommon-q_platform.h
--- ports/games/ioquake3.orig/files/patch-code-qcommon-q_platform.h	1970-01-01 01:00:00.000000000 +0100
+++ ports/games/ioquake3/files/patch-code-qcommon-q_platform.h	2009-08-31 10:01:50.000000000 +0200
@@ -0,0 +1,11 @@
+--- code/qcommon/q_platform.h.orig	2009-08-30 19:30:01.000000000 +0200
++++ code/qcommon/q_platform.h	2009-08-30 19:28:38.000000000 +0200
+@@ -199,6 +199,8 @@
+ 
+ #ifdef __i386__
+ #define ARCH_STRING "i386"
++#elif defined __amd64__
++#define ARCH_STRING "x86_64"
+ #elif defined __axp__
+ #define ARCH_STRING "alpha"
+ #endif
diff -Nur ports/games/ioquake3.orig/files/patch-code-qcommon-qcommon.h ports/games/ioquake3/files/patch-code-qcommon-qcommon.h
--- ports/games/ioquake3.orig/files/patch-code-qcommon-qcommon.h	1970-01-01 01:00:00.000000000 +0100
+++ ports/games/ioquake3/files/patch-code-qcommon-qcommon.h	2009-08-31 10:01:50.000000000 +0200
@@ -0,0 +1,13 @@
+--- code/qcommon/qcommon.h.orig	2009-08-30 23:12:19.000000000 +0200
++++ code/qcommon/qcommon.h	2009-08-30 23:26:12.000000000 +0200
+@@ -1068,6 +1068,10 @@
+ #ifdef MACOS_X
+ char    *Sys_DefaultAppPath(void);
+ #endif
++#ifdef __FreeBSD__
++void	Sys_SetDefaultLibPath(const char *path);
++char	*Sys_DefaultLibPath(void);
++#endif
+ 
+ void  Sys_SetDefaultHomePath(const char *path);
+ char	*Sys_DefaultHomePath(void);
diff -Nur ports/games/ioquake3.orig/files/patch-code-qcommon-vm_x86_64.c ports/games/ioquake3/files/patch-code-qcommon-vm_x86_64.c
--- ports/games/ioquake3.orig/files/patch-code-qcommon-vm_x86_64.c	1970-01-01 01:00:00.000000000 +0100
+++ ports/games/ioquake3/files/patch-code-qcommon-vm_x86_64.c	2009-08-31 10:01:50.000000000 +0200
@@ -0,0 +1,11 @@
+--- code/qcommon/vm_x86_64.c.orig	2009-08-30 20:50:41.000000000 +0200
++++ code/qcommon/vm_x86_64.c	2009-08-30 20:51:43.000000000 +0200
+@@ -246,7 +246,7 @@
+ #else
+ #define JMPIARG \
+ 	emit("movq $%lu, %%rax", vm->codeBase+vm->instructionPointers[iarg]); \
+-	emit("jmpq *%rax");
++	emit("jmpq *%%rax");
+ #endif
+  
+ // integer compare and jump
diff -Nur ports/games/ioquake3.orig/files/patch-code-sys-sys_main.c ports/games/ioquake3/files/patch-code-sys-sys_main.c
--- ports/games/ioquake3.orig/files/patch-code-sys-sys_main.c	1970-01-01 01:00:00.000000000 +0100
+++ ports/games/ioquake3/files/patch-code-sys-sys_main.c	2009-08-31 10:01:50.000000000 +0200
@@ -0,0 +1,111 @@
+--- code/sys/sys_main.c.orig	2009-08-30 22:32:59.000000000 +0200
++++ code/sys/sys_main.c	2009-08-30 23:21:12.000000000 +0200
+@@ -49,6 +49,9 @@
+ 
+ static char binaryPath[ MAX_OSPATH ] = { 0 };
+ static char installPath[ MAX_OSPATH ] = { 0 };
++#ifdef __FreeBSD__
++static char libPath[ MAX_OSPATH ] = { 0 };
++#endif
+ 
+ /*
+ =================
+@@ -93,6 +96,31 @@
+ 		return Sys_Cwd();
+ }
+ 
++#ifdef __FreeBSD__
++/*
++=================
++Sys_SetDefaultLibPath
++=================
++*/
++void Sys_SetDefaultLibPath(const char *path)
++{
++	Q_strncpyz(libPath, path, sizeof(libPath));
++}
++
++/*
++=================
++Sys_DefaultLibPath
++=================
++*/
++char *Sys_DefaultLibPath(void)
++{
++	if (*libPath)
++		return libPath;
++	else
++		return Sys_Cwd();
++}
++#endif
++
+ /*
+ =================
+ Sys_DefaultAppPath
+@@ -384,6 +412,7 @@
+ #1 look down current path
+ #2 look in fs_homepath
+ #3 look in fs_basepath
++#4 look in fs_libpath under FreeBSD
+ =================
+ */
+ void *Sys_LoadDll( const char *name, char *fqpath ,
+@@ -394,6 +423,9 @@
+ 	void  (*dllEntry)( intptr_t (*syscallptr)(intptr_t, ...) );
+ 	char  fname[MAX_OSPATH];
+ 	char  *basepath;
++	#ifdef __FreeBSD__
++	char  *libpath;
++	#endif
+ 	char  *homepath;
+ 	char  *pwdpath;
+ 	char  *gamedir;
+@@ -405,6 +437,9 @@
+ 	// TODO: use fs_searchpaths from files.c
+ 	pwdpath = Sys_Cwd();
+ 	basepath = Cvar_VariableString( "fs_basepath" );
++	#ifdef __FreeBSD__
++	libpath = Cvar_VariableString( "fs_libpath" );
++	#endif
+ 	homepath = Cvar_VariableString( "fs_homepath" );
+ 	gamedir = Cvar_VariableString( "fs_game" );
+ 
+@@ -416,6 +451,11 @@
+ 	if(!libHandle && basepath)
+ 		libHandle = Sys_TryLibraryLoad(basepath, gamedir, fname, fqpath);
+ 
++	#ifdef __FreeBSD__
++	if(!libHandle && libpath)
++		libHandle = Sys_TryLibraryLoad(libpath, gamedir, fname, fqpath);
++	#endif
++
+ 	if(!libHandle) {
+ 		Com_Printf ( "Sys_LoadDll(%s) failed to load library\n", name );
+ 		return NULL;
+@@ -469,6 +509,16 @@
+ #	endif
+ #endif
+ 
++#ifdef __FreeBSD__
++#ifndef DEFAULT_LIBDIR
++#	ifdef MACOS_X
++#		define DEFAULT_LIBDIR Sys_StripAppBundle(Sys_BinaryPath())
++#	else
++#		define DEFAULT_LIBDIR Sys_BinaryPath()
++#	endif
++#endif
++#endif
++
+ /*
+ =================
+ Sys_SigHandler
+@@ -540,6 +590,9 @@
+ 	Sys_ParseArgs( argc, argv );
+ 	Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) );
+ 	Sys_SetDefaultInstallPath( DEFAULT_BASEDIR );
++	#ifdef __FreeBSD__
++	Sys_SetDefaultLibPath( DEFAULT_LIBDIR );
++	#endif
+ 
+ 	// Concatenate the command line for passing to Com_Init
+ 	for( i = 1; i < argc; i++ )
diff -Nur ports/games/ioquake3.orig/files/patch-code-sys-sys_unix.c ports/games/ioquake3/files/patch-code-sys-sys_unix.c
--- ports/games/ioquake3.orig/files/patch-code-sys-sys_unix.c	1970-01-01 01:00:00.000000000 +0100
+++ ports/games/ioquake3/files/patch-code-sys-sys_unix.c	2009-08-31 10:01:50.000000000 +0200
@@ -0,0 +1,15 @@
+--- code/sys/sys_unix.c.orig	2009-08-30 21:54:20.000000000 +0200
++++ code/sys/sys_unix.c	2009-08-30 22:10:31.000000000 +0200
+@@ -56,8 +56,12 @@
+ #ifdef MACOS_X
+ 			Q_strcat( homePath, sizeof( homePath ), "/Library/Application Support/Quake3" );
+ #else
++#ifdef __FreeBSD__
++			Q_strcat( homePath, sizeof( homePath ), HOMEPATH );
++#else
+ 			Q_strcat( homePath, sizeof( homePath ), "/.q3a" );
+ #endif
++#endif
+ 			if( mkdir( homePath, 0777 ) )
+ 			{
+ 				if( errno != EEXIST )
diff -Nur ports/games/ioquake3.orig/files/patch-code__qcommon__common.c ports/games/ioquake3/files/patch-code__qcommon__common.c
--- ports/games/ioquake3.orig/files/patch-code__qcommon__common.c	2009-08-31 08:51:16.000000000 +0200
+++ ports/games/ioquake3/files/patch-code__qcommon__common.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,10 +0,0 @@
---- ./code/qcommon/common.c.orig	Wed Apr 26 08:27:12 2006
-+++ ./code/qcommon/common.c	Sun Jun 11 17:26:26 2006
-@@ -25,6 +25,7 @@
- #include "qcommon.h"
- #include <setjmp.h>
- #ifndef _WIN32
-+#include <sys/types.h>
- #include <netinet/in.h>
- #include <sys/stat.h> // umask
- #else
diff -Nur ports/games/ioquake3.orig/files/patch-code__qcommon__q_platform.h ports/games/ioquake3/files/patch-code__qcommon__q_platform.h
--- ports/games/ioquake3.orig/files/patch-code__qcommon__q_platform.h	2009-08-31 08:51:16.000000000 +0200
+++ ports/games/ioquake3/files/patch-code__qcommon__q_platform.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,15 +0,0 @@
---- ./code/qcommon/q_platform.h.orig	Tue Dec 27 16:46:01 2005
-+++ ./code/qcommon/q_platform.h	Sun Jun 11 17:26:26 2006
-@@ -176,11 +176,7 @@
- #define ID_INLINE inline
- #define PATH_SEP '/'
- 
--#ifdef __i386__
--#define ARCH_STRING "i386"
--#elif defined __axp__
--#define ARCH_STRING "alpha"
--#endif
-+#define ARCH_STRING ARCH
- 
- #if BYTE_ORDER == BIG_ENDIAN
- #define Q3_BIG_ENDIAN
diff -Nur ports/games/ioquake3.orig/files/patch-code__unix__linux_glimp.c ports/games/ioquake3/files/patch-code__unix__linux_glimp.c
--- ports/games/ioquake3.orig/files/patch-code__unix__linux_glimp.c	2009-08-31 08:51:16.000000000 +0200
+++ ports/games/ioquake3/files/patch-code__unix__linux_glimp.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,19 +0,0 @@
---- ./code/unix/linux_glimp.c.orig	Sun Apr 30 11:32:56 2006
-+++ ./code/unix/linux_glimp.c	Sun Jun 11 17:26:26 2006
-@@ -631,8 +631,14 @@
- 
-           dx = ((int)event.xmotion.x - mwx);
-           dy = ((int)event.xmotion.y - mwy);
--					mx += dx;
--					my += dy;
-+          if (abs(dx) > 1)
-+            mx += dx * 2;
-+          else
-+            mx += dx;
-+          if (abs(dy) > 1)
-+            my += dy * 2;
-+          else
-+            my += dy;
- 
-           mwx = event.xmotion.x;
-           mwy = event.xmotion.y;
diff -Nur ports/games/ioquake3.orig/files/patch-code__unix__unix_main.c ports/games/ioquake3/files/patch-code__unix__unix_main.c
--- ports/games/ioquake3.orig/files/patch-code__unix__unix_main.c	2009-08-31 08:51:16.000000000 +0200
+++ ports/games/ioquake3/files/patch-code__unix__unix_main.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,31 +0,0 @@
---- ./code/unix/unix_main.c.orig	Sun Feb 26 18:22:12 2006
-+++ ./code/unix/unix_main.c	Sun Jun 11 17:26:26 2006
-@@ -774,6 +774,7 @@
-   char  curpath[MAX_OSPATH];
-   char  fname[MAX_OSPATH];
-   char  *basepath;
-+  char  *libpath;
-   char  *homepath;
-   char  *pwdpath;
-   char  *cdpath;
-@@ -789,14 +790,19 @@
-   // TODO: use fs_searchpaths from files.c
-   pwdpath = Sys_Cwd();
-   basepath = Cvar_VariableString( "fs_basepath" );
-+  libpath = LIBDIR;
-   homepath = Cvar_VariableString( "fs_homepath" );
-   cdpath = Cvar_VariableString( "fs_cdpath" );
-   gamedir = Cvar_VariableString( "fs_game" );
- 
--  libHandle = try_dlopen(pwdpath, gamedir, fname, fqpath);
-+  if(!libHandle && homepath)
-+    libHandle = try_dlopen(pwdpath, gamedir, fname, fqpath);
- 
-   if(!libHandle && homepath)
-     libHandle = try_dlopen(homepath, gamedir, fname, fqpath);
-+
-+  if(!libHandle && basepath)
-+    libHandle = try_dlopen(libpath, gamedir, fname, fqpath);
- 
-   if(!libHandle && basepath)
-     libHandle = try_dlopen(basepath, gamedir, fname, fqpath);
diff -Nur ports/games/ioquake3.orig/pkg-message ports/games/ioquake3/pkg-message
--- ports/games/ioquake3.orig/pkg-message	2009-08-31 08:51:16.000000000 +0200
+++ ports/games/ioquake3/pkg-message	2009-08-31 17:13:19.000000000 +0200
@@ -1,17 +1,11 @@
 ==============================================================================
 
-If you have sound problems with SDL try setting the variable "s_sdlSpeed" to
-"44100". It will be saved to the configuration file.
-
-If you have sound problems with OpenAL recompile without it. Also the OPENAL
-option causes the program to omit restoring gamma and mouse sensivity after
-exitting.
+The input devices are now handled by SDL. Some mouse buttons will have
+different aliases and the mouse speed needs to be readjusted.
 
 The configuration files are saved to ~/.ioquake3 instead of ~/.q3a because
 they have additional variables which would be removed if other engines
 overwrite them. But you can safely copy the original directory to the new one
 for the first time.
 
-If you enabled CELLSHADING, check files/extra-patch-cellshading for variables.
-
 ==============================================================================
diff -Nur ports/games/ioquake3.orig/pkg-plist ports/games/ioquake3/pkg-plist
--- ports/games/ioquake3.orig/pkg-plist	2009-08-31 08:51:16.000000000 +0200
+++ ports/games/ioquake3/pkg-plist	2009-08-31 17:33:10.000000000 +0200
@@ -1,12 +1,12 @@
-%%DEDICATED%%bin/ioq3ded
-%%CLIENT%%bin/ioquake3
-%%SMP%%bin/ioquake3-smp
-%%GAMELIBS%%%%LIBDIR%%/baseq3/cgame.so
-%%GAMELIBS%%%%LIBDIR%%/baseq3/qagame.so
-%%GAMELIBS%%%%LIBDIR%%/baseq3/ui.so
-%%GAMELIBS%%%%LIBDIR%%/missionpack/cgame.so
-%%GAMELIBS%%%%LIBDIR%%/missionpack/qagame.so
-%%GAMELIBS%%%%LIBDIR%%/missionpack/ui.so
+%%DEDICATED%%bin/ioq3ded%%BINSUFFIX%%
+%%CLIENT%%bin/ioquake3%%BINSUFFIX%%
+%%SMP%%bin/ioquake3-smp%%BINSUFFIX%%
+%%GAMELIBS%%%%LIBDIR%%/baseq3/cgame%%ARCH%%.so
+%%GAMELIBS%%%%LIBDIR%%/baseq3/qagame%%ARCH%%.so
+%%GAMELIBS%%%%LIBDIR%%/baseq3/ui%%ARCH%%.so
+%%GAMELIBS%%%%LIBDIR%%/missionpack/cgame%%ARCH%%.so
+%%GAMELIBS%%%%LIBDIR%%/missionpack/qagame%%ARCH%%.so
+%%GAMELIBS%%%%LIBDIR%%/missionpack/ui%%ARCH%%.so
 %%PORTDOCS%%%%DOCSDIR%%/README
 %%GAMELIBS%%@dirrm %%LIBDIR%%/missionpack
 %%GAMELIBS%%@dirrm %%LIBDIR%%/baseq3


Patch attached with submission follows:

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	ports/games/ioquake3-devel
#	ports/games/ioquake3-devel/Makefile
#	ports/games/ioquake3-devel/pkg-message
#	ports/games/ioquake3-devel/pkg-descr
#	ports/games/ioquake3-devel/files
#	ports/games/ioquake3-devel/files/patch-code-sys-sys_unix.c
#	ports/games/ioquake3-devel/files/patch-code-sys-sys_main.c
#	ports/games/ioquake3-devel/files/patch-code-qcommon-vm_x86_64.c
#	ports/games/ioquake3-devel/files/patch-code-qcommon-qcommon.h
#	ports/games/ioquake3-devel/files/patch-code-qcommon-q_platform.h
#	ports/games/ioquake3-devel/files/patch-code-qcommon-files.c
#	ports/games/ioquake3-devel/files/patch-README
#	ports/games/ioquake3-devel/files/patch-Makefile
#
echo c - ports/games/ioquake3-devel
mkdir -p ports/games/ioquake3-devel > /dev/null 2>&1
echo x - ports/games/ioquake3-devel/Makefile
sed 's/^X//' >ports/games/ioquake3-devel/Makefile << '2ae32169a817b0a0a93abbf7fba92741'
X# New ports collection makefile for:	ioquake3-devel
X# Date created:				31 Aug 2009
X# Whom:					Dominic Fandrey
X#
X# $FreeBSD$
X#
X
XPORTNAME=	ioquake3-devel
XDISTVERSION=	1.36_SVN${SVNREVISION}
XDISTFILES=
XEXTRACT_ONLY=
X
XMAINTAINER=	kamikaze@bsdforen.de
XCOMMENT=	Development SVN snapshots of ioquake3
X
XUSE_ZIP=	no
XPLIST=		${.CURDIR}/../ioquake3/pkg-plist
X
XFETCH_DEPENDS+=	svn:${PORTSDIR}/devel/subversion
X
XSVNREVISION=	1582
XBINSUFFIX=	-devel
X
Xdo-fetch:
X	@${MKDIR} ${WRKDIR}
X	@(cd ${WRKDIR} && svn checkout -r ${SVNREVISION} \
X		svn://svn.icculus.org/quake3/trunk ${DISTNAME})
X
Xdo-extract:
X	@${DO_NADA}
X
X.include "${.CURDIR}/../ioquake3/Makefile"
2ae32169a817b0a0a93abbf7fba92741
echo x - ports/games/ioquake3-devel/pkg-message
sed 's/^X//' >ports/games/ioquake3-devel/pkg-message << '0429fae03848f7efc77aa092bf6cadda'
X==============================================================================
X
XThe input devices are now handled by SDL. Some mouse buttons will have
Xdifferent aliases and the mouse speed needs to be readjusted.
X
XThe configuration files are saved to ~/.ioquake3-devel instead of ~/.ioquake3
Xif you prefer both versions to share the configurations files create a
Xsymlink.
X
X==============================================================================
0429fae03848f7efc77aa092bf6cadda
echo x - ports/games/ioquake3-devel/pkg-descr
sed 's/^X//' >ports/games/ioquake3-devel/pkg-descr << 'd528b08280fbd956e88574dc714d2554'
XThis project, icculus.org/quake3 (sometimes referred to ioquake3, or ioq3 for
Xshort) aims to build upon id Software's Quake 3 source code release. The
Xsource code was released on August 20, 2005 under the GPL. Since then, we have
Xbeen cleaning up, fixing bugs, and adding features. Our permanent goal is to
Xcreate the open source Quake 3 distribution upon which people base their games
Xand projects. We also seek to have the perfect version of the engine for
Xplaying Quake 3: Arena, Team Arena, and all popular mods. This distribution of
Xthe engine has been ported to many new platforms and has had a slew of new
Xfeatures added, along with massive bug extermination.
X
XWWW: http://ioquake3.org/
d528b08280fbd956e88574dc714d2554
echo c - ports/games/ioquake3-devel/files
mkdir -p ports/games/ioquake3-devel/files > /dev/null 2>&1
echo x - ports/games/ioquake3-devel/files/patch-code-sys-sys_unix.c
sed 's/^X//' >ports/games/ioquake3-devel/files/patch-code-sys-sys_unix.c << 'a7e5b5e1f9121249b5e8d080e0b3f05c'
X--- code/sys/sys_unix.c.orig	2009-08-30 21:54:20.000000000 +0200
X+++ code/sys/sys_unix.c	2009-08-30 22:10:31.000000000 +0200
X@@ -56,8 +56,12 @@
X #ifdef MACOS_X
X 			Q_strcat( homePath, sizeof( homePath ), "/Library/Application Support/Quake3" );
X #else
X+#ifdef __FreeBSD__
X+			Q_strcat( homePath, sizeof( homePath ), HOMEPATH );
X+#else
X 			Q_strcat( homePath, sizeof( homePath ), "/.q3a" );
X #endif
X+#endif
X 			if( mkdir( homePath, 0777 ) )
X 			{
X 				if( errno != EEXIST )
a7e5b5e1f9121249b5e8d080e0b3f05c
echo x - ports/games/ioquake3-devel/files/patch-code-sys-sys_main.c
sed 's/^X//' >ports/games/ioquake3-devel/files/patch-code-sys-sys_main.c << 'c428aee8797322460cc86821d8e3bd7f'
X--- code/sys/sys_main.c.orig	2009-08-30 22:32:59.000000000 +0200
X+++ code/sys/sys_main.c	2009-08-30 23:21:12.000000000 +0200
X@@ -49,6 +49,9 @@
X 
X static char binaryPath[ MAX_OSPATH ] = { 0 };
X static char installPath[ MAX_OSPATH ] = { 0 };
X+#ifdef __FreeBSD__
X+static char libPath[ MAX_OSPATH ] = { 0 };
X+#endif
X 
X /*
X =================
X@@ -93,6 +96,31 @@
X 		return Sys_Cwd();
X }
X 
X+#ifdef __FreeBSD__
X+/*
X+=================
X+Sys_SetDefaultLibPath
X+=================
X+*/
X+void Sys_SetDefaultLibPath(const char *path)
X+{
X+	Q_strncpyz(libPath, path, sizeof(libPath));
X+}
X+
X+/*
X+=================
X+Sys_DefaultLibPath
X+=================
X+*/
X+char *Sys_DefaultLibPath(void)
X+{
X+	if (*libPath)
X+		return libPath;
X+	else
X+		return Sys_Cwd();
X+}
X+#endif
X+
X /*
X =================
X Sys_DefaultAppPath
X@@ -384,6 +412,7 @@
X #1 look down current path
X #2 look in fs_homepath
X #3 look in fs_basepath
X+#4 look in fs_libpath under FreeBSD
X =================
X */
X void *Sys_LoadDll( const char *name, char *fqpath ,
X@@ -394,6 +423,9 @@
X 	void  (*dllEntry)( intptr_t (*syscallptr)(intptr_t, ...) );
X 	char  fname[MAX_OSPATH];
X 	char  *basepath;
X+	#ifdef __FreeBSD__
X+	char  *libpath;
X+	#endif
X 	char  *homepath;
X 	char  *pwdpath;
X 	char  *gamedir;
X@@ -405,6 +437,9 @@
X 	// TODO: use fs_searchpaths from files.c
X 	pwdpath = Sys_Cwd();
X 	basepath = Cvar_VariableString( "fs_basepath" );
X+	#ifdef __FreeBSD__
X+	libpath = Cvar_VariableString( "fs_libpath" );
X+	#endif
X 	homepath = Cvar_VariableString( "fs_homepath" );
X 	gamedir = Cvar_VariableString( "fs_game" );
X 
X@@ -416,6 +451,11 @@
X 	if(!libHandle && basepath)
X 		libHandle = Sys_TryLibraryLoad(basepath, gamedir, fname, fqpath);
X 
X+	#ifdef __FreeBSD__
X+	if(!libHandle && libpath)
X+		libHandle = Sys_TryLibraryLoad(libpath, gamedir, fname, fqpath);
X+	#endif
X+
X 	if(!libHandle) {
X 		Com_Printf ( "Sys_LoadDll(%s) failed to load library\n", name );
X 		return NULL;
X@@ -469,6 +509,16 @@
X #	endif
X #endif
X 
X+#ifdef __FreeBSD__
X+#ifndef DEFAULT_LIBDIR
X+#	ifdef MACOS_X
X+#		define DEFAULT_LIBDIR Sys_StripAppBundle(Sys_BinaryPath())
X+#	else
X+#		define DEFAULT_LIBDIR Sys_BinaryPath()
X+#	endif
X+#endif
X+#endif
X+
X /*
X =================
X Sys_SigHandler
X@@ -540,6 +590,9 @@
X 	Sys_ParseArgs( argc, argv );
X 	Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) );
X 	Sys_SetDefaultInstallPath( DEFAULT_BASEDIR );
X+	#ifdef __FreeBSD__
X+	Sys_SetDefaultLibPath( DEFAULT_LIBDIR );
X+	#endif
X 
X 	// Concatenate the command line for passing to Com_Init
X 	for( i = 1; i < argc; i++ )
c428aee8797322460cc86821d8e3bd7f
echo x - ports/games/ioquake3-devel/files/patch-code-qcommon-vm_x86_64.c
sed 's/^X//' >ports/games/ioquake3-devel/files/patch-code-qcommon-vm_x86_64.c << '24f936a72eb74f1d2d6a298d04a49426'
X--- code/qcommon/vm_x86_64.c.orig	2009-08-30 20:50:41.000000000 +0200
X+++ code/qcommon/vm_x86_64.c	2009-08-30 20:51:43.000000000 +0200
X@@ -246,7 +246,7 @@
X #else
X #define JMPIARG \
X 	emit("movq $%lu, %%rax", vm->codeBase+vm->instructionPointers[iarg]); \
X-	emit("jmpq *%rax");
X+	emit("jmpq *%%rax");
X #endif
X  
X // integer compare and jump
24f936a72eb74f1d2d6a298d04a49426
echo x - ports/games/ioquake3-devel/files/patch-code-qcommon-qcommon.h
sed 's/^X//' >ports/games/ioquake3-devel/files/patch-code-qcommon-qcommon.h << '6e8887129cbf10cf05963f1e3fdb282c'
X--- code/qcommon/qcommon.h.orig	2009-08-30 23:12:19.000000000 +0200
X+++ code/qcommon/qcommon.h	2009-08-30 23:26:12.000000000 +0200
X@@ -1068,6 +1068,10 @@
X #ifdef MACOS_X
X char    *Sys_DefaultAppPath(void);
X #endif
X+#ifdef __FreeBSD__
X+void	Sys_SetDefaultLibPath(const char *path);
X+char	*Sys_DefaultLibPath(void);
X+#endif
X 
X void  Sys_SetDefaultHomePath(const char *path);
X char	*Sys_DefaultHomePath(void);
6e8887129cbf10cf05963f1e3fdb282c
echo x - ports/games/ioquake3-devel/files/patch-code-qcommon-q_platform.h
sed 's/^X//' >ports/games/ioquake3-devel/files/patch-code-qcommon-q_platform.h << '95adf37e630535fdeaa30505192cb473'
X--- code/qcommon/q_platform.h.orig	2009-08-30 19:30:01.000000000 +0200
X+++ code/qcommon/q_platform.h	2009-08-30 19:28:38.000000000 +0200
X@@ -199,6 +199,8 @@
X 
X #ifdef __i386__
X #define ARCH_STRING "i386"
X+#elif defined __amd64__
X+#define ARCH_STRING "x86_64"
X #elif defined __axp__
X #define ARCH_STRING "alpha"
X #endif
95adf37e630535fdeaa30505192cb473
echo x - ports/games/ioquake3-devel/files/patch-code-qcommon-files.c
sed 's/^X//' >ports/games/ioquake3-devel/files/patch-code-qcommon-files.c << '38ebd6632f942028f93b13bfe8aadafb'
X--- code/qcommon/files.c.orig	2009-08-30 22:58:50.000000000 +0200
X+++ code/qcommon/files.c	2009-08-30 23:10:53.000000000 +0200
X@@ -241,6 +241,9 @@
X #endif
X 
X static	cvar_t		*fs_basepath;
X+#ifdef __FreeBSD__
X+static	cvar_t		*fs_libpath;
X+#endif
X static	cvar_t		*fs_basegame;
X static	cvar_t		*fs_gamedirvar;
X static	searchpath_t	*fs_searchpaths;
X@@ -2761,6 +2764,10 @@
X 	fs_debug = Cvar_Get( "fs_debug", "0", 0 );
X 	fs_basepath = Cvar_Get ("fs_basepath", Sys_DefaultInstallPath(), CVAR_INIT );
X 	fs_basegame = Cvar_Get ("fs_basegame", "", CVAR_INIT );
X+	#ifdef __FreeBSD__
X+	fs_libpath = Cvar_Get ("fs_libpath", Sys_DefaultLibPath(), CVAR_INIT );
X+	#endif
X+	
X 	homePath = Sys_DefaultHomePath();
X 	if (!homePath || !homePath[0]) {
X 		homePath = fs_basepath->string;
38ebd6632f942028f93b13bfe8aadafb
echo x - ports/games/ioquake3-devel/files/patch-README
sed 's/^X//' >ports/games/ioquake3-devel/files/patch-README << '891cd52adc73e0d249a2a3063222495b'
X--- README.orig	2009-08-30 23:34:03.000000000 +0200
X+++ README	2009-08-31 00:05:03.000000000 +0200
X@@ -79,6 +79,8 @@
X   CFLAGS            - use this for custom CFLAGS
X   V                 - set to show cc command line when building
X   DEFAULT_BASEDIR   - extra path to search for baseq3 and such
X+  DEFAULT_LIBDIR    - extra path to search for libraries (FreeBSD only)
X+  HOMEPATH          - alternative home directory (FreeBSD only)
X   BUILD_SERVER      - build the 'ioq3ded' server binary
X   BUILD_CLIENT      - build the 'ioquake3' client binary
X   BUILD_CLIENT_SMP  - build the 'ioquake3-smp' client binary
891cd52adc73e0d249a2a3063222495b
echo x - ports/games/ioquake3-devel/files/patch-Makefile
sed 's/^X//' >ports/games/ioquake3-devel/files/patch-Makefile << 'a6bad1cd6ad7ac897f46aaeac9e96e43'
X--- Makefile.orig	2009-09-01 23:31:56.000000000 +0200
X+++ Makefile	2009-09-01 23:37:01.000000000 +0200
X@@ -17,6 +17,15 @@
X   COMPILE_ARCH=$(shell uname -p | sed -e s/i.86/i386/)
X endif
X 
X+ifeq ($(COMPILE_PLATFORM),freebsd)
X+  ifeq ($(COMPILE_ARCH),amd64)
X+    COMPILE_ARCH=x86_64
X+  endif
X+  ifeq ($(COMPILE_ARCH),i386)
X+    COMPILE_ARCH=x86
X+  endif
X+endif
X+
X ifeq ($(COMPILE_PLATFORM),mingw32)
X   ifeq ($(COMPILE_ARCH),i386)
X     COMPILE_ARCH=x86
X@@ -528,15 +537,34 @@
X 
X ifeq ($(PLATFORM),freebsd)
X 
X-  ifneq (,$(findstring alpha,$(shell uname -m)))
X-    ARCH=axp
X-  else #default to i386
X-    ARCH=i386
X-  endif #alpha test
X+  FREEBSD_ARCH = $(ARCH)
X+  ifeq ($(ARCH),amd64)
X+    ARCH = x86_64
X+  endif
X+  ifeq ($(ARCH),i386)
X+    ARCH = x86
X+  endif
X+
X+  ifeq ($(FREEBSD_ARCH),x86_64)
X+    FREEBSD_ARCH = amd64
X+  endif
X+  ifeq ($(FREEBSD_ARCH),x86)
X+    FREEBSD_ARCH = i386
X+  endif
X+
X+  ifndef HOMEPATH
X+    HOMEPATH = /.ioquake3
X+  endif
X 
X+  ifndef DEFAULT_LIBDIR
X+    DEFAULT_LIBDIR = /usr/local/lib/ioquake3
X+  endif
X 
X   BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
X-    -DUSE_ICON $(SDL_CFLAGS)
X+    -DUSE_ICON $(SDL_CFLAGS) -DMAP_ANONYMOUS=MAP_ANON \
X+    -DHOMEPATH=\\\"$(HOMEPATH)\\\" \
X+    -DDEFAULT_LIBDIR=\\\"$(DEFAULT_LIBDIR)\\\" \
X+    $(shell make -f /dev/null -VCFLAGS MACHINE_ARCH=$(FREEBSD_ARCH))
X 
X   ifeq ($(USE_OPENAL),1)
X     BASE_CFLAGS += -DUSE_OPENAL
X@@ -555,8 +583,21 @@
X       -fomit-frame-pointer -fexpensive-optimizations
X   else
X   ifeq ($(ARCH),i386)
X-    RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 -mtune=pentiumpro \
X-      -march=pentium -fomit-frame-pointer -pipe -ffast-math \
X+    ifeq ($(CROSS_COMPILING),1)
X+      BASE_CFLAGS += -m32
X+    endif
X+    RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 \
X+      -fomit-frame-pointer -pipe -ffast-math \
X+      -falign-loops=2 -falign-jumps=2 -falign-functions=2 \
X+      -funroll-loops -fstrength-reduce
X+    HAVE_VM_COMPILED=true
X+  else
X+  ifeq ($(ARCH),x86_64)
X+    ifeq ($(CROSS_COMPILING),1)
X+      BASE_CFLAGS += -m64
X+    endif
X+    RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 \
X+      -fomit-frame-pointer -pipe -ffast-math \
X       -falign-loops=2 -falign-jumps=2 -falign-functions=2 \
X       -funroll-loops -fstrength-reduce
X     HAVE_VM_COMPILED=true
X@@ -564,6 +605,7 @@
X     BASE_CFLAGS += -DNO_VM_COMPILED
X   endif
X   endif
X+  endif
X 
X   DEBUG_CFLAGS=$(BASE_CFLAGS) -g
X 
a6bad1cd6ad7ac897f46aaeac9e96e43
exit



>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200909041643.n84Gh71w089501>