aboutsummaryrefslogtreecommitdiff
path: root/games/egl
diff options
context:
space:
mode:
authorAlejandro Pulver <alepulver@FreeBSD.org>2006-05-25 18:44:00 +0000
committerAlejandro Pulver <alepulver@FreeBSD.org>2006-05-25 18:44:00 +0000
commit9f2d15ac29a5ce7a43b10e74a22a2ef0e8a07d5e (patch)
tree44ba20be327bec2083df89f0d24db58ac94cb024 /games/egl
parent42522c183f4c4d2b6428ace4081be3aa1465017d (diff)
downloadports-9f2d15ac29a5ce7a43b10e74a22a2ef0e8a07d5e.tar.gz
ports-9f2d15ac29a5ce7a43b10e74a22a2ef0e8a07d5e.zip
Notes
Diffstat (limited to 'games/egl')
-rw-r--r--games/egl/Makefile63
-rw-r--r--games/egl/distinfo6
-rw-r--r--games/egl/files/patch-cgame__menu__m_opts_sound.c78
-rw-r--r--games/egl/files/patch-client__snd_main.c129
-rw-r--r--games/egl/files/patch-client__snd_openal.c11
-rw-r--r--games/egl/files/patch-common__common.c10
-rw-r--r--games/egl/files/patch-common__files.c75
-rw-r--r--games/egl/files/patch-include__zlibpng__zconf.h11
-rw-r--r--games/egl/files/patch-linux__glimp_linux.c10
-rw-r--r--games/egl/files/patch-linux__glimp_linux.h14
-rw-r--r--games/egl/files/patch-linux__snd_linux.c109
-rw-r--r--games/egl/files/patch-linux__sys_linux.c58
-rw-r--r--games/egl/files/patch-linux__x11_linux.h11
-rw-r--r--games/egl/files/patch-linux__x11_main.c11
-rw-r--r--games/egl/files/patch-makefile150
-rw-r--r--games/egl/files/patch-renderer__qgl.h20
-rw-r--r--games/egl/files/patch-renderer__r_init.c10
-rw-r--r--games/egl/files/patch-shared__shared.c115
-rw-r--r--games/egl/files/patch-shared__shared.h277
-rw-r--r--games/egl/pkg-descr3
-rw-r--r--games/egl/pkg-plist7
21 files changed, 1178 insertions, 0 deletions
diff --git a/games/egl/Makefile b/games/egl/Makefile
new file mode 100644
index 000000000000..409269c8fd9f
--- /dev/null
+++ b/games/egl/Makefile
@@ -0,0 +1,63 @@
+# New ports collection makefile for: egl
+# Date created: 20 May 2006
+# Whom: alepulver
+#
+# $FreeBSD$
+#
+
+PORTNAME= egl
+PORTVERSION= 0.2.5
+CATEGORIES= games
+MASTER_SITES= http://egl.quakedev.com/files/:src \
+ ftp://ftp.alepulver.com.ar/ports/egl/:data
+DISTNAME= ${PORTNAME}-v${PORTVERSION}-src
+DISTFILES= ${DISTNAME}${EXTRACT_SUFX}:src \
+ egl.pkz:data
+EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX}
+
+MAINTAINER= alepulver@FreeBSD.org
+COMMENT= Enhaced OpenGL only Quake II engine
+
+LIB_DEPENDS= jpeg.9:${PORTSDIR}/graphics/jpeg \
+ png.5:${PORTSDIR}/graphics/png
+
+USE_ZIP= yes
+USE_DOS2UNIX= yes
+USE_GL= yes
+USE_GMAKE= yes
+NO_WRKSUBDIR= yes
+
+OPTIONS= DEDICATED "Build dedicated server" on \
+ OPTIMIZED_CFLAGS "Enable compilation optimizations" on
+
+MAKEFILE= makefile
+
+MAKE_ENV= LIBDIR="${LIBDIR}" PTHREAD_LIBS="${PTHREAD_LIBS}"
+PLIST_SUB= LIBDIR="${LIBDIR:S/${PREFIX}\///}"
+LIBDIR= ${PREFIX}/lib/${PORTNAME}
+
+.include "${.CURDIR}/../quake2-data/Makefile.include"
+
+.include <bsd.port.pre.mk>
+
+.if !defined(WITHOUT_DEDICATED)
+PLIST_SUB+= DEDICATED=""
+.else
+MAKE_ENV+= BUILD_DEDICATED=NO
+PLIST_SUB+= DEDICATED="@comment "
+.endif
+
+.if defined(WITHOUT_OPTIMIZED_CFLAGS)
+MAKE_ENV+= WITH_OPT_CFLAGS=NO
+.endif
+
+do-install:
+ ${INSTALL_PROGRAM} ${WRKSRC}/release/egl ${PREFIX}/bin
+.if !defined(WITHOUT_DEDICATED)
+ ${INSTALL_PROGRAM} ${WRKSRC}/release/eglded ${PREFIX}/bin
+.endif
+ ${MKDIR} ${LIBDIR}/baseq2
+ ${INSTALL_PROGRAM} ${WRKSRC}/release/baseq2/*.so ${LIBDIR}/baseq2
+ ${INSTALL_DATA} ${DISTDIR}/egl.pkz ${LIBDIR}/baseq2
+
+.include <bsd.port.post.mk>
diff --git a/games/egl/distinfo b/games/egl/distinfo
new file mode 100644
index 000000000000..2ec0ef08be5b
--- /dev/null
+++ b/games/egl/distinfo
@@ -0,0 +1,6 @@
+MD5 (egl-v0.2.5-src.zip) = 1026746d24837d585015458c38775d46
+SHA256 (egl-v0.2.5-src.zip) = 3ee9a001cb27b24971221203cc852d5eed8942f70861c0407ca78d5701881c1c
+SIZE (egl-v0.2.5-src.zip) = 2128931
+MD5 (egl.pkz) = 491e4c7c784a29c806e0dfd038eb3ddc
+SHA256 (egl.pkz) = 4b925b38243508aba0c2ecd2a7f9b89ae29e4bfe0c15658295f8313d123341b7
+SIZE (egl.pkz) = 9299043
diff --git a/games/egl/files/patch-cgame__menu__m_opts_sound.c b/games/egl/files/patch-cgame__menu__m_opts_sound.c
new file mode 100644
index 000000000000..fbe2fa3aedd3
--- /dev/null
+++ b/games/egl/files/patch-cgame__menu__m_opts_sound.c
@@ -0,0 +1,78 @@
+--- ./cgame/menu/m_opts_sound.c.orig Tue May 23 20:05:59 2006
++++ ./cgame/menu/m_opts_sound.c Tue May 23 20:06:00 2006
+@@ -60,7 +60,7 @@
+ uiList_t cdtoggle_toggle;
+
+ // openal
+-/* uiAction_t al_header;
++ uiAction_t al_header;
+
+ uiSlider_t dopplerfactor_slider;
+ uiAction_t dopplerfactor_amount;
+@@ -69,7 +69,7 @@
+
+ uiList_t al_extensions_toggle;
+ uiList_t al_ext_eax_toggle;
+-*/
++
+ // software
+ uiAction_t sw_header;
+ uiList_t sw_quality_list;
+@@ -94,14 +94,14 @@
+
+ static void ALDopFactorFunc (void *unused)
+ {
+-// cgi.Cvar_SetValue ("al_dopplerfactor", m_soundMenu.dopplerfactor_slider.curValue * 0.1, qFalse);
+-// m_soundMenu.dopplerfactor_amount.generic.name = cgi.Cvar_GetStringValue ("al_dopplerfactor");
++ cgi.Cvar_SetValue ("al_dopplerfactor", m_soundMenu.dopplerfactor_slider.curValue * 0.1, qFalse);
++ m_soundMenu.dopplerfactor_amount.generic.name = cgi.Cvar_GetStringValue ("al_dopplerfactor");
+ }
+
+ static void ALDopVelocityFunc (void *unused)
+ {
+-// cgi.Cvar_SetValue ("al_dopplervelocity", m_soundMenu.dopplervelocity_slider.curValue * 100, qFalse);
+-// m_soundMenu.dopplervelocity_amount.generic.name = cgi.Cvar_GetStringValue ("al_dopplervelocity");
++ cgi.Cvar_SetValue ("al_dopplervelocity", m_soundMenu.dopplervelocity_slider.curValue * 100, qFalse);
++ m_soundMenu.dopplervelocity_amount.generic.name = cgi.Cvar_GetStringValue ("al_dopplervelocity");
+ }
+
+ static void ALExtensionsFunc (void *unused)
+@@ -152,8 +152,7 @@
+ */
+ static void SoundMenu_SetValues (void)
+ {
+-// cgi.Cvar_SetValue ("s_initSound", clamp (cgi.Cvar_GetIntegerValue ("s_initSound"), 0, 2), qTrue);
+- cgi.Cvar_SetValue ("s_initSound", clamp (cgi.Cvar_GetIntegerValue ("s_initSound"), 0, 1), qTrue);
++ cgi.Cvar_SetValue ("s_initSound", clamp (cgi.Cvar_GetIntegerValue ("s_initSound"), 0, 2), qTrue);
+ m_soundMenu.sound_toggle.curValue = cgi.Cvar_GetIntegerValue ("s_initSound");
+
+ m_soundMenu.sfxvolume_slider.curValue = cgi.Cvar_GetFloatValue ("s_volume") * 20;
+@@ -207,8 +206,8 @@
+
+ static char *soundinit_items[] = {
+ "off",
+- "on",
+-// "OpenAL [ EXPERIMENTAL ]",
++ "OSS",
++ "OpenAL [UNSTABLE]",
+ 0
+ };
+
+@@ -256,7 +255,7 @@
+ m_soundMenu.cdtoggle_toggle.generic.statusBar = "Toggle CD Play";
+
+ // openal
+-/* m_soundMenu.al_header.generic.type = UITYPE_ACTION;
++ m_soundMenu.al_header.generic.type = UITYPE_ACTION;
+ m_soundMenu.al_header.generic.flags = UIF_NOSELECT|UIF_CENTERED|UIF_MEDIUM|UIF_SHADOW;
+ m_soundMenu.al_header.generic.name = "OpenAL Sound Settings";
+
+@@ -289,7 +288,7 @@
+ m_soundMenu.al_ext_eax_toggle.generic.callBack = ALExtEAXFunc;
+ m_soundMenu.al_ext_eax_toggle.itemNames = soundinit_items;
+ m_soundMenu.al_ext_eax_toggle.generic.statusBar = "Toggle the OpenAL extension EAX 2.0";
+-*/
++
+ // software
+ m_soundMenu.sw_header.generic.type = UITYPE_ACTION;
+ m_soundMenu.sw_header.generic.flags = UIF_NOSELECT|UIF_CENTERED|UIF_MEDIUM|UIF_SHADOW;
diff --git a/games/egl/files/patch-client__snd_main.c b/games/egl/files/patch-client__snd_main.c
new file mode 100644
index 000000000000..8e2f91d5408c
--- /dev/null
+++ b/games/egl/files/patch-client__snd_main.c
@@ -0,0 +1,129 @@
+--- ./client/snd_main.c.orig Tue May 23 20:05:59 2006
++++ ./client/snd_main.c Tue May 23 20:06:00 2006
+@@ -25,7 +25,8 @@
+ #include "snd_local.h"
+
+ qBool snd_isActive = qTrue;
+-qBool snd_isInitialized;
++qBool snd_isFirstInit = qTrue;
++qBool snd_isInitialized = qFalse;
+ qBool snd_isDMA;
+ qBool snd_isAL;
+
+@@ -870,7 +871,7 @@
+ int initTime;
+
+ if (snd_isInitialized)
+- Snd_Shutdown ();
++ return;
+
+ Com_Printf (0, "\n--------- Sound Initialization ---------\n");
+
+@@ -892,27 +893,44 @@
+ s_testsound = Cvar_Register ("s_testsound", "0", 0);
+ s_primary = Cvar_Register ("s_primary", "0", CVAR_ARCHIVE|CVAR_LATCH_AUDIO); // win32 specific
+
+- al_allowExtensions = Cvar_Register ("al_allowExtensions", "1", CVAR_ARCHIVE|CVAR_LATCH_AUDIO);
+- al_device = Cvar_Register ("al_device", "", CVAR_ARCHIVE);
+- al_dopplerFactor = Cvar_Register ("al_dopplerFactor", "1", CVAR_ARCHIVE);
+- al_dopplerVelocity = Cvar_Register ("al_dopplerVelocity", "16384", CVAR_ARCHIVE);
+- al_driver = Cvar_Register ("al_driver", AL_DRIVERNAME, CVAR_ARCHIVE|CVAR_LATCH_AUDIO);
+- al_errorCheck = Cvar_Register ("al_errorCheck", "1", CVAR_ARCHIVE);
+- al_ext_eax2 = Cvar_Register ("al_ext_eax2", "1", CVAR_ARCHIVE|CVAR_LATCH_AUDIO);
+- al_gain = Cvar_Register ("al_gain", "5", CVAR_ARCHIVE);
+- al_minDistance = Cvar_Register ("al_minDistance", "100", CVAR_ARCHIVE);
+- al_maxDistance = Cvar_Register ("al_maxDistance", "8192", CVAR_ARCHIVE);
+- al_rollOffFactor = Cvar_Register ("al_rollOffFactor", "0.8", CVAR_ARCHIVE);
++ if (s_initSound->integer == 2) {
++ al_allowExtensions = Cvar_Register ("al_allowExtensions", "1", CVAR_ARCHIVE|CVAR_LATCH_AUDIO);
++ al_device = Cvar_Register ("al_device", "", CVAR_ARCHIVE);
++ al_dopplerFactor = Cvar_Register ("al_dopplerFactor", "1", CVAR_ARCHIVE);
++ al_dopplerVelocity = Cvar_Register ("al_dopplerVelocity", "16384", CVAR_ARCHIVE);
++ al_driver = Cvar_Register ("al_driver", AL_DRIVERNAME, CVAR_ARCHIVE|CVAR_LATCH_AUDIO);
++ al_errorCheck = Cvar_Register ("al_errorCheck", "1", CVAR_ARCHIVE);
++ al_ext_eax2 = Cvar_Register ("al_ext_eax2", "1", CVAR_ARCHIVE|CVAR_LATCH_AUDIO);
++ al_gain = Cvar_Register ("al_gain", "5", CVAR_ARCHIVE);
++ al_minDistance = Cvar_Register ("al_minDistance", "100", CVAR_ARCHIVE);
++ al_maxDistance = Cvar_Register ("al_maxDistance", "8192", CVAR_ARCHIVE);
++ al_rollOffFactor = Cvar_Register ("al_rollOffFactor", "0.8", CVAR_ARCHIVE);
++ }
++
++ /*
++ * We need to keep the snd_restart command even if the sound subsystem
++ * is not started, because there has to be a way to start it.
++ */
++ if (snd_isFirstInit) {
++ cmd_snd_restart = Cmd_AddCommand ("snd_restart", Snd_Restart_f, "Restarts the audio subsystem");
++ snd_isFirstInit = qFalse;
++ }
+
+- cmd_snd_restart = Cmd_AddCommand ("snd_restart", Snd_Restart_f, "Restarts the audio subsystem");
+ cmd_play = Cmd_AddCommand ("play", Snd_Play_f, "Plays a sound");
+ cmd_stopSound = Cmd_AddCommand ("stopsound", Snd_StopAllSounds, "Stops all currently playing sounds");
+ cmd_soundList = Cmd_AddCommand ("soundlist", Snd_SoundList_f, "Prints out a list of loaded sound files");
+ cmd_soundInfo = Cmd_AddCommand ("soundinfo", Snd_SoundInfo_f, "Prints out information on sound subsystem");
+
++ /*
++ * Make Snd_Shutdown() abort the startup if necessary (it quits when
++ * the subsystem is not initialized, so make it think the opposite).
++ */
++ snd_isInitialized = qTrue;
++
+ if (!s_initSound->value) {
+ Com_Printf (0, "...not initializing\n");
+ Com_Printf (0, "----------------------------------------\n");
++ Snd_Shutdown();
+ return;
+ }
+
+@@ -927,13 +945,13 @@
+ }
+ }
+ if (!snd_isAL) {
+- if (!DMASnd_Init())
++ if (!DMASnd_Init()) {
++ Snd_Shutdown();
+ return;
++ }
+ snd_isDMA = qTrue;
+ }
+
+- snd_isInitialized = qTrue;
+-
+ Snd_StopAllSounds ();
+
+ Com_Printf (0, "----------------------------------------\n");
+@@ -955,18 +973,19 @@
+ {
+ int size;
+
+- Cmd_RemoveCommand ("snd_restart", cmd_snd_restart);
++ if (!snd_isInitialized)
++ return;
++
+ Cmd_RemoveCommand ("play", cmd_play);
+ Cmd_RemoveCommand ("stopsound", cmd_stopSound);
+ Cmd_RemoveCommand ("soundlist", cmd_soundList);
+ Cmd_RemoveCommand ("soundinfo", cmd_soundInfo);
+
+- if (!snd_isInitialized)
+- return;
+- snd_isInitialized = qFalse;
+-
+ Com_Printf (0, "\n------------ Sound Shutdown ------------\n");
+
++ // Stop all sounds
++ Snd_StopAllSounds();
++
+ // Free all sounds
+ Snd_FreeSounds ();
+
+@@ -984,6 +1003,8 @@
+ ALSnd_Shutdown ();
+ snd_isAL = qFalse;
+ }
++
++ snd_isInitialized = qFalse;
+
+ Com_Printf (0, "----------------------------------------\n");
+ }
diff --git a/games/egl/files/patch-client__snd_openal.c b/games/egl/files/patch-client__snd_openal.c
new file mode 100644
index 000000000000..545c2128a00f
--- /dev/null
+++ b/games/egl/files/patch-client__snd_openal.c
@@ -0,0 +1,11 @@
+--- ./client/snd_openal.c.orig Tue May 23 20:05:59 2006
++++ ./client/snd_openal.c Tue May 23 20:06:00 2006
+@@ -40,7 +40,7 @@
+ # define AL_FREELIB(a) FreeLibrary (a)
+ #endif
+
+-#if defined(__linux__) || defined(__FreeBSD__)
++#ifdef __unix__
+ # include <dlfcn.h>
+ # include <unistd.h>
+ # include <sys/types.h>
diff --git a/games/egl/files/patch-common__common.c b/games/egl/files/patch-common__common.c
new file mode 100644
index 000000000000..ee0c7cf7389d
--- /dev/null
+++ b/games/egl/files/patch-common__common.c
@@ -0,0 +1,10 @@
+--- ./common/common.c.orig Tue May 23 20:05:59 2006
++++ ./common/common.c Tue May 23 20:06:00 2006
+@@ -645,6 +645,7 @@
+ Com_InitArgv (argc, argv);
+
+ Cmd_Init ();
++ Swap_Init ();
+ Cbuf_Init ();
+ Alias_Init ();
+ Cvar_Init ();
diff --git a/games/egl/files/patch-common__files.c b/games/egl/files/patch-common__files.c
new file mode 100644
index 000000000000..4ecbb4cbf844
--- /dev/null
+++ b/games/egl/files/patch-common__files.c
@@ -0,0 +1,75 @@
+--- ./common/files.c.orig Tue May 23 20:05:59 2006
++++ ./common/files.c Tue May 23 20:06:00 2006
+@@ -1169,6 +1169,23 @@
+ return BASE_MODDIRNAME;
+ }
+
++#ifdef HOMEDIR
++/*
++ * FS_AddHomeAsGameDirectory
++ * Add a game directory in "~/.egl". It can be used to set the last path, so
++ * it will be used for writting.
++ */
++void FS_AddHomeAsGameDirectory(char *dir)
++{
++ char gdir[MAX_OSPATH]; /* Game directory. */
++ char *homedir; /* Home directory. */
++
++ if ((homedir = getenv("HOME")) != NULL) {
++ Q_snprintfz(gdir, sizeof(gdir), "%s/.egl/%s", homedir, dir);
++ FS_AddGameDirectory(gdir, dir);
++ }
++}
++#endif
+
+ /*
+ ================
+@@ -1220,10 +1237,17 @@
+ }
+ else {
+ Cvar_VariableSet (fs_gamedircvar, dir, qTrue);
++#ifdef __FreeBSD__
++ FS_AddGameDirectory (Q_VarArgs ("%s/%s", DATADIR, dir), dir);
++ FS_AddGameDirectory (Q_VarArgs ("%s/%s", LIBDIR, dir), dir);
++#endif
+ if (fs_cddir->string[0])
+ FS_AddGameDirectory (Q_VarArgs ("%s/%s", fs_cddir->string, dir), dir);
+
+ FS_AddGameDirectory (Q_VarArgs ("%s/%s", fs_basedir->string, dir), dir);
++#ifdef HOMEDIR
++ FS_AddHomeAsGameDirectory(dir);
++#endif
+ }
+
+ if (!firstTime) {
+@@ -1573,16 +1597,30 @@
+ fs_defaultPaks = Cvar_Register ("fs_defaultPaks", "1", CVAR_ARCHIVE);
+
+ // Load pak files
++#ifdef __FreeBSD__
++ FS_AddGameDirectory (Q_VarArgs ("%s/"BASE_MODDIRNAME, DATADIR), BASE_MODDIRNAME);
++ FS_AddGameDirectory (Q_VarArgs ("%s/"BASE_MODDIRNAME, LIBDIR), BASE_MODDIRNAME);
++#endif
+ if (fs_cddir->string[0])
+ FS_AddGameDirectory (Q_VarArgs ("%s/"BASE_MODDIRNAME, fs_cddir->string), BASE_MODDIRNAME);
+
+ FS_AddGameDirectory (Q_VarArgs ("%s/"BASE_MODDIRNAME, fs_basedir->string), BASE_MODDIRNAME);
++#ifdef HOMEDIR
++ FS_AddHomeAsGameDirectory(BASE_MODDIRNAME);
++#endif
+
+ // Any set gamedirs will be freed up to here
+ fs_baseSearchPath = fs_searchPaths;
+
+ if (fs_game->string[0])
+ FS_SetGamedir (fs_game->string, qTrue);
++
++#ifdef HOMEDIR
++ /* Create the writable directory if doesn't exist ("~/.egl"). */
++ FS_CreatePath(fs_gameDir);
++ Sys_Mkdir(fs_gameDir);
++ Com_Printf(0, "Using '%s' for writing.\n", fs_gameDir);
++#endif
+
+ // Check memory integrity
+ Mem_CheckPoolIntegrity (MEMPOOL_FILESYS);
diff --git a/games/egl/files/patch-include__zlibpng__zconf.h b/games/egl/files/patch-include__zlibpng__zconf.h
new file mode 100644
index 000000000000..f99643bad20a
--- /dev/null
+++ b/games/egl/files/patch-include__zlibpng__zconf.h
@@ -0,0 +1,11 @@
+--- ./include/zlibpng/zconf.h.orig Tue May 23 20:05:59 2006
++++ ./include/zlibpng/zconf.h Tue May 23 20:06:00 2006
+@@ -254,7 +254,7 @@
+ #if !defined(__MACTYPES__)
+ typedef unsigned char Byte; /* 8 bits */
+ #endif
+-#if !defined(__linux__) && !defined(__FreeBSD__)
++#ifndef __unix__
+ typedef unsigned int uInt; /* 16 bits or more */
+ typedef unsigned long uLong; /* 32 bits or more */
+ #endif
diff --git a/games/egl/files/patch-linux__glimp_linux.c b/games/egl/files/patch-linux__glimp_linux.c
new file mode 100644
index 000000000000..6b03efcd5a12
--- /dev/null
+++ b/games/egl/files/patch-linux__glimp_linux.c
@@ -0,0 +1,10 @@
+--- ./linux/glimp_linux.c.orig Tue May 23 20:05:59 2006
++++ ./linux/glimp_linux.c Tue May 23 20:06:00 2006
+@@ -282,6 +282,7 @@
+ glStatic.cDepthBits = X11_GetGLAttribute(GLX_DEPTH_SIZE);
+ glStatic.cStencilBits = X11_GetGLAttribute(GLX_STENCIL_SIZE);
+
++ X11_SetKMGrab(qFalse, qTrue);
+ return qTrue;
+ }
+
diff --git a/games/egl/files/patch-linux__glimp_linux.h b/games/egl/files/patch-linux__glimp_linux.h
new file mode 100644
index 000000000000..64af66498429
--- /dev/null
+++ b/games/egl/files/patch-linux__glimp_linux.h
@@ -0,0 +1,14 @@
+--- ./linux/glimp_linux.h.orig Tue May 23 20:05:59 2006
++++ ./linux/glimp_linux.h Tue May 23 20:06:00 2006
+@@ -21,9 +21,9 @@
+ // glimp_linux.h
+ //
+
+-#ifndef __linux__
++#ifndef __unix__
+ # error You should not be including this file on this platform
+-#endif // __linux__
++#endif // __unix__
+
+ #ifndef __GLIMP_LINUX_H__
+ #define __GLIMP_LINUX_H__
diff --git a/games/egl/files/patch-linux__snd_linux.c b/games/egl/files/patch-linux__snd_linux.c
new file mode 100644
index 000000000000..1e0f247d2e4a
--- /dev/null
+++ b/games/egl/files/patch-linux__snd_linux.c
@@ -0,0 +1,109 @@
+--- ./linux/snd_linux.c.orig Tue May 23 20:05:59 2006
++++ ./linux/snd_linux.c Tue May 23 20:06:00 2006
+@@ -25,7 +25,11 @@
+ #include <sys/mman.h>
+ #include <sys/shm.h>
+ #include <sys/wait.h>
++#ifdef __linux__
+ #include <linux/soundcard.h>
++#else
++#include <sys/soundcard.h>
++#endif
+ #include <stdio.h>
+
+ #include "../client/snd_local.h"
+@@ -56,7 +60,7 @@
+ extern uid_t saved_euid;
+
+ if (sndInitialized)
+- return;
++ return 1;
+
+ if (!snddevice) {
+ sndbits = Cvar_Register ("sndbits", "16", CVAR_ARCHIVE);
+@@ -101,13 +105,6 @@
+ return 0;
+ }
+
+- if (ioctl (audio_fd, SNDCTL_DSP_GETOSPACE, &info) == -1) {
+- perror ("GETOSPACE");
+- Com_Printf (0, "Um, can't do GETOSPACE?\n");
+- close (audio_fd);
+- return 0;
+- }
+-
+ // set sample bits & speed
+ snd_audioDMA.sampleBits = (int)sndbits->value;
+ if (snd_audioDMA.sampleBits != 16 && snd_audioDMA.sampleBits != 8) {
+@@ -126,21 +123,6 @@
+ snd_audioDMA.channels = (int)sndchannels->value;
+ if ((snd_audioDMA.channels < 1) || (snd_audioDMA.channels > 2))
+ snd_audioDMA.channels = 2;
+-
+- snd_audioDMA.samples = info.fragstotal * info.fragsize / (snd_audioDMA.sampleBits/8);
+- snd_audioDMA.submissionChunk = 1;
+-
+- // memory map the dma buffer
+- if (!snd_audioDMA.buffer)
+- snd_audioDMA.buffer = (unsigned char *) mmap(NULL, info.fragstotal
+- * info.fragsize, PROT_WRITE, MAP_FILE|MAP_SHARED, audio_fd, 0);
+-
+- if (!snd_audioDMA.buffer) {
+- perror (snddevice->string);
+- Com_Printf (0, "Could not mmap %s\n", snddevice->string);
+- close (audio_fd);
+- return 0;
+- }
+
+ tmp = 0;
+ if (snd_audioDMA.channels == 2)
+@@ -157,6 +139,14 @@
+ else
+ snd_audioDMA.channels = 1;
+
++ rc = ioctl (audio_fd, SNDCTL_DSP_SPEED, &snd_audioDMA.speed);
++ if (rc < 0) {
++ perror (snddevice->string);
++ Com_Printf (0, "Could not set %s speed to %d", snddevice->string, snd_audioDMA.speed);
++ close (audio_fd);
++ return 0;
++ }
++
+ if (snd_audioDMA.sampleBits == 16) {
+ rc = AFMT_S16_LE;
+ rc = ioctl (audio_fd, SNDCTL_DSP_SETFMT, &rc);
+@@ -182,13 +172,29 @@
+ return 0;
+ }
+
+- rc = ioctl (audio_fd, SNDCTL_DSP_SPEED, &snd_audioDMA.speed);
+- if (rc < 0) {
+- perror (snddevice->string);
+- Com_Printf (0, "Could not set %s speed to %d", snddevice->string, snd_audioDMA.speed);
++ if (ioctl (audio_fd, SNDCTL_DSP_GETOSPACE, &info) == -1) {
++ perror ("GETOSPACE");
++ Com_Printf (0, "Um, can't do GETOSPACE?\n");
+ close (audio_fd);
+- return 0;
++ return 0;
+ }
++
++ snd_audioDMA.samples = info.fragstotal * info.fragsize / (snd_audioDMA.sampleBits/8);
++ snd_audioDMA.submissionChunk = 1;
++
++ // memory map the dma buffer
++ if (!snd_audioDMA.buffer)
++ snd_audioDMA.buffer = (unsigned char *) mmap(NULL, info.fragstotal
++ * info.fragsize, PROT_WRITE, MAP_FILE|MAP_SHARED, audio_fd, 0);
++
++ if (!snd_audioDMA.buffer) {
++ perror (snddevice->string);
++ Com_Printf (0, "Could not mmap %s\n", snddevice->string);
++ close (audio_fd);
++ return 0;
++ }
++
++
+
+ // toggle the trigger & start her up
+ tmp = 0;
diff --git a/games/egl/files/patch-linux__sys_linux.c b/games/egl/files/patch-linux__sys_linux.c
new file mode 100644
index 000000000000..fa2572fad7fb
--- /dev/null
+++ b/games/egl/files/patch-linux__sys_linux.c
@@ -0,0 +1,58 @@
+--- ./linux/sys_linux.c.orig Tue May 23 20:05:59 2006
++++ ./linux/sys_linux.c Tue May 23 20:06:00 2006
+@@ -43,10 +43,6 @@
+
+ #include "../common/common.h"
+
+-#if defined(__FreeBSD__)
+-#include <machine/param.h>
+-#endif
+-
+ uint32 sys_frameTime;
+ int sys_currTime;
+
+@@ -607,7 +603,6 @@
+ void *Sys_LoadLibrary (libType_t libType, void *parms)
+ {
+ char name[MAX_OSPATH];
+- char cwd[MAX_OSPATH];
+ char *path;
+ void *(*APIfunc) (void *);
+ void **lib;
+@@ -657,13 +652,13 @@
+ switch (libType) {
+ case LIB_CGAME:
+ lib = &cGameLib;
+- libname = "eglcgame" ARCH ".so";
++ libname = "eglcgame.so";
+ apifuncname = "GetCGameAPI";
+ break;
+
+ case LIB_GAME:
+ lib = &gameLib;
+- libname = "game" ARCH ".so";
++ libname = "game.so";
+ apifuncname = "GetGameAPI";
+ break;
+
+@@ -673,8 +668,7 @@
+ }
+
+ // check the current debug directory first for development purposes
+- getcwd (cwd, sizeof(cwd));
+- Q_snprintfz (name, sizeof(name), "%s/%s/%s", cwd, debugdir, libname);
++ Q_snprintfz (name, sizeof(name), "%s/%s", debugdir, libname);
+ *lib = dlopen (name, RTLD_NOW);
+
+ if (*lib) {
+@@ -697,8 +691,10 @@
+ Com_DevPrintf (0, "dlopen (%s)\n", name);
+ break;
+ }
++#if 0
+ if (!*lib && (error = dlerror()))
+ Com_Printf (PRNT_ERROR, "dlopen (%s): %s\n", name, error);
++#endif
+ }
+ }
+
diff --git a/games/egl/files/patch-linux__x11_linux.h b/games/egl/files/patch-linux__x11_linux.h
new file mode 100644
index 000000000000..a00634674628
--- /dev/null
+++ b/games/egl/files/patch-linux__x11_linux.h
@@ -0,0 +1,11 @@
+--- ./linux/x11_linux.h.orig Tue May 23 20:05:59 2006
++++ ./linux/x11_linux.h Tue May 23 20:06:00 2006
+@@ -1,6 +1,6 @@
+-#ifndef __linux__
++#ifndef __unix__
+ # error You should not be including this file on this platform
+-#endif // __linux__
++#endif // __unix__
+
+ #ifndef __X11_LINUX_H__
+ #define __X11_LINUX_H__
diff --git a/games/egl/files/patch-linux__x11_main.c b/games/egl/files/patch-linux__x11_main.c
new file mode 100644
index 000000000000..7a0c54c5f880
--- /dev/null
+++ b/games/egl/files/patch-linux__x11_main.c
@@ -0,0 +1,11 @@
+--- ./linux/x11_main.c.orig Tue May 23 20:05:59 2006
++++ ./linux/x11_main.c Tue May 23 20:06:00 2006
+@@ -147,7 +147,7 @@
+ }
+ }
+
+-static void X11_SetKMGrab (qBool kg, qBool mg)
++void X11_SetKMGrab (qBool kg, qBool mg)
+ {
+ keybd_grabbed = kg;
+ mouse_grabbed = mg;
diff --git a/games/egl/files/patch-makefile b/games/egl/files/patch-makefile
new file mode 100644
index 000000000000..411d76cca0d1
--- /dev/null
+++ b/games/egl/files/patch-makefile
@@ -0,0 +1,150 @@
+--- ./makefile.orig Tue May 23 20:06:00 2006
++++ ./makefile Tue May 23 20:11:46 2006
+@@ -1,37 +1,64 @@
+-BUILD_CLIENT=YES # client executable
+-BUILD_DEDICATED=YES # server executable
+-BUILD_CGAME=YES # cgame dll
+-BUILD_GAME=YES # game dll
++# GNU Makefile for EGL.
++
++# Compilation components and options.
++BUILD_CLIENT?=YES # Client executable.
++BUILD_DEDICATED?=YES # Server executable.
++BUILD_CGAME?=YES # cgame shared library.
++BUILD_GAME?=YES # game shared library.
++WITH_OPT_CFLAGS?=YES # Optimized compiler flags.
++WITH_HOMEDIR?=YES # Write files in "~/.egl".
+
++# Common variables.
++CC?=gcc
+ VERSION=0.0.6
++EGL_MAKEFILE=makefile
+
++# Compiler flags.
++SHARED_FLAGS= $(CFLAGS) -DARCH='\"$(ARCH)\"' \
++ -DGAME_NAME='\"$(GAME_NAME)\"' \
++ -DEGLCGAME_NAME='\"$(EGLCGAME_NAME)\"'
++RELEASE_CFLAGS= -Isource/ -I./ -I../ $(SHARED_FLAGS)
++DEBUG_CFLAGS=- g -Isource/ -I./ -I../ $(SHARED_FLAGS) -DC_ONLY
+
+-CC=gcc
+-EGL_MAKEFILE=makefile
+-SHARED_FLAGS:=
+-RELEASE_CFLAGS=-Isource/ -I./ -I../ $(SHARED_FLAGS) -O2 -fno-strict-aliasing -ffast-math -fexpensive-optimizations
+-DEBUG_CFLAGS=-g -Isource/ -I./ -I../ $(SHARED_FLAGS) -DC_ONLY
+-LDFLAGS=-ldl -lm -lz -ljpeg -lpng
+-DED_LDFLAGS=-ldl -lm -lz
+-MODULE_LDFLAGS=-ldl -lm
+-X11_LDFLAGS=-L/usr/X11R6/lib -lX11 -lXext
++# Linker flags.
++LDFLAGS+=-lm
++DED_LDFLAGS=-lz
++MODULE_LDFLAGS=
++X11_LDFLAGS=-lX11 -lXext -ljpeg -lpng -lz
+
++# Compilation commands.
+
+ SHLIBCFLAGS=-fPIC
+ SHLIBLDFLAGS=-shared
+
+-
+ DO_CC=$(CC) $(CFLAGS) -o $@ -c $<
+ DO_DED_CC=$(CC) $(CFLAGS) -DDEDICATED_ONLY -o $@ -c $<
+ DO_SHLIB_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
+
+-
+-# this nice line comes from the linux kernel makefile
++# This nice line comes from the linux kernel makefile.
+ ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc/ -e s/sparc64/sparc/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/alpha/axp/)
+ SHLIBEXT =so
+
+-BUILD_DEBUG_DIR=debug$(ARCH)
+-BUILD_RELEASE_DIR=release$(ARCH)
++OSTYPE := $(shell uname -s)
++
++BUILD_DEBUG_DIR=debug
++BUILD_RELEASE_DIR=release
++
++ifeq ($(OSTYPE),Linux)
++LDFLAGS+=-ldl
++GAME_NAME= game$(ARCH)
++EGLCGAME_NAME= eglcgame$(ARCH)
++endif
++
++ifeq ($(OSTYPE),FreeBSD)
++# These variables are defined from the port, and passed by the environment.
++SHARED_FLAGS+= -I$(LOCALBASE)/include -I$(X11BASE)/include \
++ -DDATADIR='\"$(Q2DIR)\"' -DLIBDIR='\"$(LIBDIR)\"'
++LDFLAGS+= -L$(LOCALBASE)/lib -L$(X11BASE)/lib
++X11_LDFLAGS+= $(PTHREAD_LIBS)
++GAME_NAME= game
++EGLCGAME_NAME= eglcgame
++endif
+
+ ifeq ($(strip $(BUILD_CLIENT)),YES)
+ TARGETS += $(BUILDDIR)/egl
+@@ -42,20 +69,27 @@
+ endif
+
+ ifeq ($(strip $(BUILD_CGAME)),YES)
+- TARGETS += $(BUILDDIR)/baseq2/eglcgame$(ARCH).$(SHLIBEXT)
++ TARGETS += $(BUILDDIR)/baseq2/$(EGLCGAME_NAME).$(SHLIBEXT)
+ endif
+
+ ifeq ($(strip $(BUILD_GAME)),YES)
+- TARGETS += $(BUILDDIR)/baseq2/game$(ARCH).$(SHLIBEXT)
++ TARGETS += $(BUILDDIR)/baseq2/$(GAME_NAME).$(SHLIBEXT)
+ endif
+
++ifeq ($(strip $(WITH_OPT_CFLAGS)),YES)
++RELEASE_CFLAGS += -O2 -fno-strict-aliasing -ffast-math -fexpensive-optimizations
++endif
+
+-ifeq ($(wildcard /usr/include/X11/extensions/xf86vmode.h),/usr/include/X11/extensions/xf86vmode.h)
++ifeq ($(strip $(WITH_HOMEDIR)),YES)
++SHARED_FLAGS += -DHOMEDIR
++endif
++
++ifeq ($(wildcard $(X11BASE)/include/X11/extensions/xf86vmode.h),$(X11BASE)/include/X11/extensions/xf86vmode.h)
+ SHARED_FLAGS += -DXF86VMODE
+ X11_LDFLAGS += -lXxf86vm
+ endif
+
+-ifeq ($(wildcard /usr/include/X11/extensions/xf86dga.h),/usr/include/X11/extensions/xf86dga.h)
++ifeq ($(wildcard $(X11BASE)/include/X11/extensions/xf86dga.h),$(X11BASE)/include/X11/extensions/xf86dga.h)
+ SHARED_FLAGS += -DXF86DGA
+ X11_LDFLAGS += -lXxf86dga
+ endif
+@@ -527,7 +561,7 @@
+
+ $(BUILDDIR)/eglded: $(OBJS_DEDICATED)
+ @echo Linking eglded;
+- $(CC) $(CFLAGS) -o $@ $(OBJS_DEDICATED) $(DED_LDFLAGS)
++ $(CC) $(CFLAGS) -o $@ $(OBJS_DEDICATED) $(LDFLAGS) $(DED_LDFLAGS)
+
+ $(BUILDDIR)/dedicated/alias.o: $(SOURCEDIR)/common/alias.c
+ $(DO_DED_CC)
+@@ -738,9 +772,9 @@
+ $(BUILDDIR)/baseq2/cgame/m_flash.o \
+
+
+-$(BUILDDIR)/baseq2/eglcgame$(ARCH).$(SHLIBEXT): $(OBJS_CGAME)
++$(BUILDDIR)/baseq2/$(EGLCGAME_NAME).$(SHLIBEXT): $(OBJS_CGAME)
+ @echo Linking cgame dll;
+- $(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(OBJS_CGAME) $(MODULE_LDFLAGS)
++ $(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(OBJS_CGAME) $(LDFLAGS) $(MODULE_LDFLAGS)
+
+ $(BUILDDIR)/baseq2/cgame/cg_api.o: $(SOURCEDIR)/cgame/cg_api.c
+ $(DO_SHLIB_CC)
+@@ -1026,9 +1060,9 @@
+ $(BUILDDIR)/baseq2/game/string.o \
+
+
+-$(BUILDDIR)/baseq2/game$(ARCH).$(SHLIBEXT): $(OBJS_GAME)
++$(BUILDDIR)/baseq2/$(GAME_NAME).$(SHLIBEXT): $(OBJS_GAME)
+ @echo Linking game dll;
+- $(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(OBJS_GAME) $(MODULE_LDFLAGS)
++ $(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(OBJS_GAME) $(LDFLAGS) $(MODULE_LDFLAGS)
+
+ $(BUILDDIR)/baseq2/game/cg_api.o: $(SOURCEDIR)/cgame/cg_api.c
+ $(DO_SHLIB_CC)
diff --git a/games/egl/files/patch-renderer__qgl.h b/games/egl/files/patch-renderer__qgl.h
new file mode 100644
index 000000000000..8ba30f2f935a
--- /dev/null
+++ b/games/egl/files/patch-renderer__qgl.h
@@ -0,0 +1,20 @@
+--- ./renderer/qgl.h.orig Tue May 23 20:05:59 2006
++++ ./renderer/qgl.h Tue May 23 20:06:00 2006
+@@ -30,7 +30,7 @@
+
+ #include <GL/gl.h>
+
+-#if defined(__linux__) || defined(__FreeBSD__)
++#ifdef __unix__
+ # include <GL/glx.h>
+ #endif
+
+@@ -431,7 +431,7 @@
+
+
+
+-#if defined(__linux__) || defined(__FreeBSD__)
++#ifdef __unix__
+
+ //
+ // linux
diff --git a/games/egl/files/patch-renderer__r_init.c b/games/egl/files/patch-renderer__r_init.c
new file mode 100644
index 000000000000..acab148d9f26
--- /dev/null
+++ b/games/egl/files/patch-renderer__r_init.c
@@ -0,0 +1,10 @@
+--- ./renderer/r_init.c.orig Tue May 23 20:05:59 2006
++++ ./renderer/r_init.c Tue May 23 20:06:00 2006
+@@ -1395,6 +1395,7 @@
+ Com_Printf (0, "----------------------------------------\n");
+
+ // Sub-system init
++ Swap_Init();
+ R_ImageInit ();
+ R_ProgramInit ();
+ R_ShaderInit ();
diff --git a/games/egl/files/patch-shared__shared.c b/games/egl/files/patch-shared__shared.c
new file mode 100644
index 000000000000..6f538ea38cac
--- /dev/null
+++ b/games/egl/files/patch-shared__shared.c
@@ -0,0 +1,115 @@
+--- ./shared/shared.c.orig Tue May 23 20:05:59 2006
++++ ./shared/shared.c Tue May 23 20:06:00 2006
+@@ -539,3 +539,112 @@
+ dest--;
+ }
+ }
++
++/*
++==============================================================================
++
++ BYTE ORDER FUNCTIONS
++
++==============================================================================
++*/
++
++qBool bigendien;
++
++/*
++ * Can't just use function pointers, or DLL linkage can mess up when qcommon
++ * is included in multiple places.
++ */
++
++int16 (*_LittleShort) (int16 l);
++int32 (*_LittleLong) (int32 l);
++float (*_LittleFloat) (float l);
++int16 (*_BigShort) (int16 l);
++int32 (*_BigLong) (int32 l);
++float (*_BigFloat) (float l);
++
++int16 LittleShort (int16 l) { return _LittleShort(l); }
++int32 LittleLong (int32 l) { return _LittleLong(l); }
++float LittleFloat (float l) { return _LittleFloat(l); }
++int16 BigShort (int16 l) { return _BigShort(l); }
++int32 BigLong (int32 l) { return _BigLong(l); }
++float BigFloat (float l) { return _BigFloat(l); }
++
++int16 ShortNoSwap (int16 l) { return l; }
++int32 LongNoSwap (int32 l) { return l; }
++float FloatNoSwap (float f) { return f; }
++
++int16 ShortSwap (int16 s)
++{
++ union {
++ byte b[2];
++ int16 s;
++ } in, out;
++
++ in.s = s;
++
++ out.b[0] = in.b[1];
++ out.b[1] = in.b[0];
++
++ return out.s;
++}
++
++int32 LongSwap (int32 l)
++{
++ union {
++ byte b[4];
++ int l;
++ } in, out;
++
++ in.l = l;
++
++ out.b[0] = in.b[3];
++ out.b[1] = in.b[2];
++ out.b[2] = in.b[1];
++ out.b[3] = in.b[0];
++
++ return out.l;
++}
++
++float FloatSwap (float f)
++{
++ union {
++ byte b[4];
++ float f;
++ } in, out;
++
++ in.f = f;
++
++ out.b[0] = in.b[3];
++ out.b[1] = in.b[2];
++ out.b[2] = in.b[1];
++ out.b[3] = in.b[0];
++
++ return out.f;
++}
++
++/*
++ * Swap_Init
++ * Set the byte swapping variables in a portable manner.
++ */
++void Swap_Init (void)
++{
++ byte swaptest[2] = {1, 0};
++
++ if (*(int16 *)swaptest == 1) {
++ bigendien = qFalse;
++ _LittleShort = ShortNoSwap;
++ _LittleLong = LongNoSwap;
++ _LittleFloat = FloatNoSwap;
++ _BigShort = ShortSwap;
++ _BigLong = LongSwap;
++ _BigFloat = FloatSwap;
++ } else {
++ bigendien = qTrue;
++ _LittleShort = ShortSwap;
++ _LittleLong = LongSwap;
++ _LittleFloat = FloatSwap;
++ _BigShort = ShortNoSwap;
++ _BigLong = LongNoSwap;
++ _BigFloat = FloatNoSwap;
++ }
++}
diff --git a/games/egl/files/patch-shared__shared.h b/games/egl/files/patch-shared__shared.h
new file mode 100644
index 000000000000..c80d1af68309
--- /dev/null
+++ b/games/egl/files/patch-shared__shared.h
@@ -0,0 +1,277 @@
+--- ./shared/shared.h.orig Tue May 23 20:05:59 2006
++++ ./shared/shared.h Tue May 23 20:06:00 2006
+@@ -41,6 +41,15 @@
+ //R1Q2 SPECIFC
+
+ // =========================================================================
++// Common
++//
++#ifdef NDEBUG
++# define DEBUG_STR ""
++#else
++# define DEBUG_STR " Debug"
++#endif
++
++// =========================================================================
+ // Windows
+ //
+ #ifdef WIN32
+@@ -68,23 +77,15 @@
+
+ # define BUILDSTRING "Win32"
+
+-# ifdef NDEBUG
+-# ifdef _M_IX86
+-# define CPUSTRING "x86"
+-# elif defined _M_ALPHA
+-# define CPUSTRING "AXP"
+-# endif
+-# else // NDEBUG
+-# ifdef _M_IX86
+-# define CPUSTRING "x86 Debug"
+-# elif defined _M_ALPHA
+-# define CPUSTRING "AXP Debug"
+-# endif
+-# endif // NDEBUG
++# ifdef _M_IX86
++# define CPUSTRING "x86"
++# elif defined _M_ALPHA
++# define CPUSTRING "AXP"
++# endif
+
+-typedef __int16 int16;
+-typedef __int32 int32;
+-typedef __int64 int64;
++typedef __int16 int16;
++typedef __int32 int32;
++typedef __int64 int64;
+ typedef unsigned __int16 uint16;
+ typedef unsigned __int32 uint32;
+ typedef unsigned __int64 uint64;
+@@ -94,49 +95,35 @@
+ # define __declspec_naked __declspec(naked)
+
+ // =========================================================================
+-// Linux
++// Unix in general (Linux, *BSD, etc)
+ //
+-#elif defined __linux__
+-# include <stdint.h>
+-
+-# define GL_DRIVERNAME "libGL.so.1"
+-# define AL_DRIVERNAME "libopenal.so.0"
+-# define GL_FORCEFINISH
++#elif defined __unix__
+
+-# define HAVE_INLINE
+-# define HAVE_STRCASECMP
++// Linux
++# if defined(__linux__)
++# include <stdint.h>
+
+-# define BUILDSTRING "Linux"
++# define BUILDSTRING "Linux"
+
+-# ifdef NDEBUG
+-# ifdef __i386__
+-# define CPUSTRING "i386"
+-# elif defined(__alpha__)
+-# define CPUSTRING "AXP"
+-# endif
+-# else // NDEBUG
+-# ifdef __i386__
+-# define CPUSTRING "i386 Debug"
+-# elif defined(__alpha__)
+-# define CPUSTRING "AXP Debug"
++// FreeBSD
++# elif defined __FreeBSD__
++# include <machine/param.h>
++# if __FreeBSD_version < 500000
++# include <inttypes.h>
++# else
++# include <stdint.h>
+ # endif
+-# endif // NDEBUG
+
+-typedef int16_t int16;
+-typedef int32_t int32;
+-typedef int64_t int64;
+-typedef uint16_t uint16;
+-typedef uint32_t uint32;
+-typedef uint64_t uint64;
++# define BUILDSTRING "FreeBSD"
+
+-# define __declspec
+-# define __declspec_naked
++# else
++# include <stdint.h>
++# endif
+
+-// =========================================================================
+-// FreeBSD
+-//
+-#elif defined __FreeBSD__
+-# include <stdint.h>
++// Common
++# ifdef ARCH
++# define CPUSTRING ARCH
++# endif
+
+ # define GL_DRIVERNAME "libGL.so.1"
+ # define AL_DRIVERNAME "libopenal.so.0"
+@@ -145,22 +132,6 @@
+ # define HAVE_INLINE
+ # define HAVE_STRCASECMP
+
+-# define BUILDSTRING "FreeBSD"
+-
+-# ifdef NDEBUG
+-# ifdef __i386__
+-# define CPUSTRING "i386"
+-# elif defined(__alpha__)
+-# define CPUSTRING "AXP"
+-# endif
+-# else // NDEBUG
+-# ifdef __i386__
+-# define CPUSTRING "i386 Debug"
+-# elif defined(__alpha__)
+-# define CPUSTRING "AXP Debug"
+-# endif
+-# endif // NDEBUG
+-
+ typedef int16_t int16;
+ typedef int32_t int32;
+ typedef int64_t int64;
+@@ -225,7 +196,7 @@
+
+ // =========================================================================
+
+-#if (defined(_M_IX86) || defined(__i386__)) && !defined(C_ONLY) && !defined(__linux__) && !defined(__FreeBSD__) // FIXME: make this work with linux
++#if (defined(_M_IX86) || defined(__i386__)) && !defined(C_ONLY) && !defined(__unix__) // FIXME: make this work with linux
+ # define id386
+ #else
+ # ifdef id386
+@@ -233,14 +204,6 @@
+ # endif
+ #endif
+
+-#if !defined(ENDIAN_LITTLE) && !defined(ENDIAN_BIG)
+-# if defined(__i386__) || defined(__ia64__) || defined(WIN32) || (defined(__alpha__) || defined(__alpha)) || defined(__arm__) || (defined(__mips__) && defined(__MIPSEL__)) || defined(__LITTLE_ENDIAN__)
+-# define ENDIAN_LITTLE
+-# else
+-# define ENDIAN_BIG
+-# endif
+-#endif
+-
+ #ifndef BUILDSTRING
+ # define BUILDSTRING "Unknown"
+ #endif
+@@ -755,100 +718,17 @@
+ ==============================================================================
+
+ BYTE ORDER FUNCTIONS
+-
+-==============================================================================
+-*/
+-
+-#ifdef USE_BYTESWAP
+-
+-/*
+-===============
+-FloatSwap
+-===============
+-*/
+-static inline float FloatSwap (float f)
+-{
+- union {
+- byte b[4];
+- float f;
+- } in, out;
+-
+- in.f = f;
+
+- out.b[0] = in.b[3];
+- out.b[1] = in.b[2];
+- out.b[2] = in.b[1];
+- out.b[3] = in.b[0];
+-
+- return out.f;
+-}
+-
+-
+-/*
+-===============
+-LongSwap
+-===============
+-*/
+-static inline int LongSwap (int l)
+-{
+- union {
+- byte b[4];
+- int l;
+- } in, out;
+-
+- in.l = l;
+-
+- out.b[0] = in.b[3];
+- out.b[1] = in.b[2];
+- out.b[2] = in.b[1];
+- out.b[3] = in.b[0];
+-
+- return out.l;
+-}
+-
+-/*
+-===============
+-ShortSwap
+-===============
++==============================================================================
+ */
+-static inline int16 ShortSwap (int16 s)
+-{
+- union {
+- byte b[2];
+- int16 s;
+- } in, out;
+-
+- in.s = s;
+
+- out.b[0] = in.b[1];
+- out.b[1] = in.b[0];
+-
+- return out.s;
+-}
+-
+-#if defined(WIN32) || defined(__linux__) || defined(__FreeBSD__)
+-
+-#define LittleFloat
+-#define LittleLong
+-#define LittleShort
+-
+-static inline float BigFloat (float f) { return FloatSwap (f); }
+-static inline int BigLong (int l) { return LongSwap (l); }
+-static inline int16 BigShort (int16 s) { return ShortSwap (s); }
+-
+-#elif (defined __MACOS__ || defined MACOS_X)
+-
+-#define BigFloat
+-#define BigLong
+-#define BigShort
+-
+-static inline float LittleFloat (float f) { return FloatSwap (f); }
+-static inline int LittleLong (int l) { return LongSwap (l); }
+-static inline int16 LittleShort (int16 s) { return ShortSwap (s); }
+-
+-#endif
+-
+-#endif // USE_BYTESWAP
++int16 LittleShort (int16 l);
++int32 LittleLong (int32 l);
++float LittleFloat (float l);
++int16 BigShort (int16 l);
++int32 BigLong (int32 l);
++float BigFloat (float l);
++void Swap_Init (void);
+
+ /*
+ ==============================================================================
diff --git a/games/egl/pkg-descr b/games/egl/pkg-descr
new file mode 100644
index 000000000000..d41499954e9d
--- /dev/null
+++ b/games/egl/pkg-descr
@@ -0,0 +1,3 @@
+Enhaced OpenGL only Quake II engine.
+
+WWW: http://egl.quakedev.com/
diff --git a/games/egl/pkg-plist b/games/egl/pkg-plist
new file mode 100644
index 000000000000..93ca6c63923f
--- /dev/null
+++ b/games/egl/pkg-plist
@@ -0,0 +1,7 @@
+bin/egl
+%%DEDICATED%%bin/eglded
+%%LIBDIR%%/baseq2/egl.pkz
+%%LIBDIR%%/baseq2/eglcgame.so
+%%LIBDIR%%/baseq2/game.so
+@dirrm %%LIBDIR%%/baseq2
+@dirrm %%LIBDIR%%