summaryrefslogtreecommitdiff
path: root/Ports/quake3
diff options
context:
space:
mode:
authorJesse Buhagiar <jooster669@gmail.com>2022-03-25 22:37:46 +1100
committerAndreas Kling <kling@serenityos.org>2022-04-09 11:40:33 +0200
commite2f1da8cec15601b16afea9c2f489d5ab044ef6e (patch)
treea6dbdd5107b8b10fb4c822f10d304b60a3f6f365 /Ports/quake3
parentc08dfe063abd30ce2d00042983fa2c3197dc1c8b (diff)
downloadserenity-e2f1da8cec15601b16afea9c2f489d5ab044ef6e.zip
Ports: Add quake3 port :^)
Diffstat (limited to 'Ports/quake3')
-rwxr-xr-xPorts/quake3/package.sh34
-rw-r--r--Ports/quake3/patches/0001-Meta-Refactor-Makefile-to-support-Serenity.patch125
-rw-r--r--Ports/quake3/patches/0002-Engine-Add-Serenity-so-q_platform.h.patch52
-rw-r--r--Ports/quake3/patches/0003-Engine-Add-sys-select.h-include-for-Serenity.patch79
-rw-r--r--Ports/quake3/patches/0004-Meta-Add-ldl-library-for-Serenity-target.patch25
-rw-r--r--Ports/quake3/patches/0005-Engine-Move-ifdef-to-more-sensible-location.patch52
-rw-r--r--Ports/quake3/patches/0006-Meta-Add-ARCH-to-TOOLS_CFLAGS.patch25
-rw-r--r--Ports/quake3/patches/0007-Meta-Remove-extension-from-main-game-exe.patch58
-rw-r--r--Ports/quake3/patches/0008-Engine-Use-Serenity-style-PROT_EXEC-mmap.patch72
-rw-r--r--Ports/quake3/patches/ReadMe.md48
10 files changed, 570 insertions, 0 deletions
diff --git a/Ports/quake3/package.sh b/Ports/quake3/package.sh
new file mode 100755
index 0000000000..0d06356e6d
--- /dev/null
+++ b/Ports/quake3/package.sh
@@ -0,0 +1,34 @@
+#!/usr/bin/env -S bash ../.port_include.sh
+port=quake3
+version=1.34
+commit_hash=6d74896557d8c193a9f19bc6845a47e9d0f77db2
+archive_hash=1db91cfd05170ed5b37c1ab56cdf7bbe6b3c86fc6baee8b68e8e539fddfd88c1
+files="https://github.com/ioquake/ioq3/archive/$commit_hash.tar.gz ioq3.tar.gz $archive_hash"
+auth_type=sha256
+workdir="ioq3-${commit_hash}"
+depends=("SDL2")
+launcher_name="QuakeIII: Arena"
+launcher_category="Games"
+launcher_command=/usr/local/games/quake3/ioquake3
+icon_file="misc/quake3.png"
+
+install() {
+ run make COPYDIR=${SERENITY_INSTALL_ROOT}/usr/local/games/quake3/ copyfiles
+}
+
+post_install() {
+ # Let's create a more Serenity friendly `autoexec.cfg` file :^)
+ cat <<- 'EOF' > ${SERENITY_INSTALL_ROOT}/usr/local/games/quake3/baseq3/autoexec.cfg
+set cl_renderer "opengl1"
+set r_fullscreen "0"
+set cg_drawfps "1"
+EOF
+
+echo ""
+echo ""
+echo "==== Post installation instructions ===="
+echo "Please remember to install baseq3 from your Quake3 install"
+echo "into /usr/local/games/quake3/"
+echo "Don't forget to add the following to Base/etc/fstab/:"
+echo "/usr/local/games/quake3 /usr/local/games/quake3 bind bind,nodev,nosuid,wxallowed"
+}
diff --git a/Ports/quake3/patches/0001-Meta-Refactor-Makefile-to-support-Serenity.patch b/Ports/quake3/patches/0001-Meta-Refactor-Makefile-to-support-Serenity.patch
new file mode 100644
index 0000000000..5ad66b69be
--- /dev/null
+++ b/Ports/quake3/patches/0001-Meta-Refactor-Makefile-to-support-Serenity.patch
@@ -0,0 +1,125 @@
+From 7658f60b1a064ca08da8e71c4f44c4505df6f571 Mon Sep 17 00:00:00 2001
+From: Jesse Buhagiar <jooster669@gmail.com>
+Date: Fri, 25 Mar 2022 09:39:21 +1100
+Subject: [PATCH 1/8] Meta: Refactor Makefile to support Serenity
+
+---
+ Makefile | 36 ++++++++++++++++--------------------
+ 1 file changed, 16 insertions(+), 20 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 9e535559..b26ceb7f 100644
+--- a/Makefile
++++ b/Makefile
+@@ -3,8 +3,8 @@
+ #
+ # GNU Make required
+ #
+-COMPILE_PLATFORM=$(shell uname | sed -e 's/_.*//' | tr '[:upper:]' '[:lower:]' | sed -e 's/\//_/g')
+-COMPILE_ARCH=$(shell uname -m | sed -e 's/i.86/x86/' | sed -e 's/^arm.*/arm/')
++COMPILE_PLATFORM=serenity
++COMPILE_ARCH=${SERENITY_ARCH}
+
+ #arm64 hack!
+ ifeq ($(shell uname -m), arm64)
+@@ -35,13 +35,13 @@ ifndef BUILD_GAME_QVM
+ BUILD_GAME_QVM =
+ endif
+ ifndef BUILD_BASEGAME
+- BUILD_BASEGAME =
++ BUILD_BASEGAME =1
+ endif
+ ifndef BUILD_MISSIONPACK
+- BUILD_MISSIONPACK=
++ BUILD_MISSIONPACK=0
+ endif
+ ifndef BUILD_RENDERER_OPENGL2
+- BUILD_RENDERER_OPENGL2=
++ BUILD_RENDERER_OPENGL2=0
+ endif
+ ifndef BUILD_AUTOUPDATER # DON'T build unless you mean to!
+ BUILD_AUTOUPDATER=0
+@@ -164,39 +164,39 @@ GENERATE_DEPENDENCIES=1
+ endif
+
+ ifndef USE_OPENAL
+-USE_OPENAL=1
++USE_OPENAL=0
+ endif
+
+ ifndef USE_OPENAL_DLOPEN
+-USE_OPENAL_DLOPEN=1
++USE_OPENAL_DLOPEN=0
+ endif
+
+ ifndef USE_CURL
+-USE_CURL=1
++USE_CURL=0
+ endif
+
+ ifndef USE_CURL_DLOPEN
+ ifdef MINGW
+ USE_CURL_DLOPEN=0
+ else
+- USE_CURL_DLOPEN=1
++ USE_CURL_DLOPEN=0
+ endif
+ endif
+
+ ifndef USE_CODEC_VORBIS
+-USE_CODEC_VORBIS=1
++USE_CODEC_VORBIS=0
+ endif
+
+ ifndef USE_CODEC_OPUS
+-USE_CODEC_OPUS=1
++USE_CODEC_OPUS=0
+ endif
+
+ ifndef USE_MUMBLE
+-USE_MUMBLE=1
++USE_MUMBLE=0
+ endif
+
+ ifndef USE_VOIP
+-USE_VOIP=1
++USE_VOIP=0
+ endif
+
+ ifndef USE_FREETYPE
+@@ -505,10 +505,6 @@ ifeq ($(PLATFORM),darwin)
+ ifeq ($(CROSS_COMPILING),1)
+ # If CC is already set to something generic, we probably want to use
+ # something more specific
+- ifneq ($(findstring $(strip $(CC)),cc gcc),)
+- CC=
+- endif
+-
+ ifndef CC
+ ifndef DARWIN
+ # macOS 10.9 SDK
+@@ -817,11 +813,10 @@ ifeq ($(PLATFORM),freebsd)
+ else # ifeq freebsd
+
+ #############################################################################
+-# SETUP AND BUILD -- OPENBSD
++# SETUP AND BUILD -- SERENITY
+ #############################################################################
+
+-ifeq ($(PLATFORM),openbsd)
+-
++ifeq ($(PLATFORM),serenity)
+ BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
+ -pipe -DUSE_ICON -DMAP_ANONYMOUS=MAP_ANON
+ CLIENT_CFLAGS += $(SDL_CFLAGS)
+@@ -1000,6 +995,7 @@ ifeq ($(PLATFORM),sunos)
+
+ else # ifeq sunos
+
++
+ #############################################################################
+ # SETUP AND BUILD -- GENERIC
+ #############################################################################
+--
+2.35.1
+
diff --git a/Ports/quake3/patches/0002-Engine-Add-Serenity-so-q_platform.h.patch b/Ports/quake3/patches/0002-Engine-Add-Serenity-so-q_platform.h.patch
new file mode 100644
index 0000000000..246a50ca54
--- /dev/null
+++ b/Ports/quake3/patches/0002-Engine-Add-Serenity-so-q_platform.h.patch
@@ -0,0 +1,52 @@
+From a5f5bd1db818a315cf7da0211a20718f7879791e Mon Sep 17 00:00:00 2001
+From: Jesse Buhagiar <jooster669@gmail.com>
+Date: Fri, 25 Mar 2022 09:39:42 +1100
+Subject: [PATCH 2/8] Engine: Add Serenity so `q_platform.h`
+
+---
+ code/qcommon/q_platform.h | 29 +++++++++++++++++++++++++++++
+ 1 file changed, 29 insertions(+)
+
+diff --git a/code/qcommon/q_platform.h b/code/qcommon/q_platform.h
+index 72dbfe1d..3bd829d4 100644
+--- a/code/qcommon/q_platform.h
++++ b/code/qcommon/q_platform.h
+@@ -290,6 +290,35 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ #endif
+
++//=================================================================== SERENITY ===
++
++#if defined(__serenity__)
++
++#include <sys/types.h>
++
++#ifndef __serenity__
++ #define __serenity__
++#endif
++
++#define Q3_LITTLE_ENDIAN
++
++#define OS_STRING "serenity"
++
++#define ID_INLINE inline
++#define PATH_SEP '/'
++
++#ifdef __i386__
++#define ARCH_STRING "x86"
++#elif defined __amd64__
++#undef idx64
++#define idx64 1
++#define ARCH_STRING "x86_64"
++#endif
++
++#define DLL_EXT ".so"
++
++#endif
++
+ //================================================================== Q3VM ===
+
+ #ifdef Q3_VM
+--
+2.35.1
+
diff --git a/Ports/quake3/patches/0003-Engine-Add-sys-select.h-include-for-Serenity.patch b/Ports/quake3/patches/0003-Engine-Add-sys-select.h-include-for-Serenity.patch
new file mode 100644
index 0000000000..b0cd841e27
--- /dev/null
+++ b/Ports/quake3/patches/0003-Engine-Add-sys-select.h-include-for-Serenity.patch
@@ -0,0 +1,79 @@
+From c7106223c30a896a576c44ce735d4772c283afac Mon Sep 17 00:00:00 2001
+From: Jesse Buhagiar <jooster669@gmail.com>
+Date: Fri, 25 Mar 2022 09:40:41 +1100
+Subject: [PATCH 3/8] Engine: Add `<sys/select.h>` include for Serenity
+
+QuakeIII makes extensive use of the `select()` syscall for its' netcode.
+It seems that Linux has this in a header that isn't `<sys/select.h>`
+like us, which results in an implicit declaration error.
+---
+ code/qcommon/net_ip.c | 7 +++++++
+ code/sys/con_tty.c | 4 ++++
+ code/sys/sys_unix.c | 4 ++++
+ 3 files changed, 15 insertions(+)
+
+diff --git a/code/qcommon/net_ip.c b/code/qcommon/net_ip.c
+index bcccda20..ea940f59 100644
+--- a/code/qcommon/net_ip.c
++++ b/code/qcommon/net_ip.c
+@@ -81,6 +81,10 @@ static qboolean winsockInitialized = qfalse;
+ # include <sys/filio.h>
+ # endif
+
++#ifdef __serenity__
++#include <sys/select.h>
++#endif
++
+ typedef int SOCKET;
+ # define INVALID_SOCKET -1
+ # define SOCKET_ERROR -1
+@@ -996,6 +1000,7 @@ NET_JoinMulticast
+ Join an ipv6 multicast group
+ ====================
+ */
++#ifndef __serenity__
+ void NET_JoinMulticast6(void)
+ {
+ int err;
+@@ -1059,6 +1064,8 @@ void NET_LeaveMulticast6()
+ }
+ }
+
++#endif
++
+ /*
+ ====================
+ NET_OpenSocks
+diff --git a/code/sys/con_tty.c b/code/sys/con_tty.c
+index 58f178ad..74e1c60d 100644
+--- a/code/sys/con_tty.c
++++ b/code/sys/con_tty.c
+@@ -34,6 +34,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ #include <fcntl.h>
+ #include <sys/time.h>
+
++#ifdef __serenity__
++#include <sys/select.h>
++#endif
++
+ /*
+ =============================================================
+ tty console routines
+diff --git a/code/sys/sys_unix.c b/code/sys/sys_unix.c
+index e0c63238..05f311bb 100644
+--- a/code/sys/sys_unix.c
++++ b/code/sys/sys_unix.c
+@@ -39,6 +39,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ #include <fenv.h>
+ #include <sys/wait.h>
+
++#ifdef __serenity__
++#include <sys/select.h>
++#endif
++
+ qboolean stdinIsATTY;
+
+ // Used to determine where to store user-specific files
+--
+2.35.1
+
diff --git a/Ports/quake3/patches/0004-Meta-Add-ldl-library-for-Serenity-target.patch b/Ports/quake3/patches/0004-Meta-Add-ldl-library-for-Serenity-target.patch
new file mode 100644
index 0000000000..4a34c6536f
--- /dev/null
+++ b/Ports/quake3/patches/0004-Meta-Add-ldl-library-for-Serenity-target.patch
@@ -0,0 +1,25 @@
+From 5efef55d7dc570bcef21533a952267e6b107d495 Mon Sep 17 00:00:00 2001
+From: Jesse Buhagiar <jooster669@gmail.com>
+Date: Fri, 25 Mar 2022 09:45:12 +1100
+Subject: [PATCH 4/8] Meta: Add `-ldl` library for Serenity target
+
+---
+ Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index b26ceb7f..035fea77 100644
+--- a/Makefile
++++ b/Makefile
+@@ -868,7 +868,7 @@ ifeq ($(PLATFORM),serenity)
+ SHLIBLDFLAGS=-shared $(LDFLAGS)
+
+ THREAD_LIBS=-lpthread
+- LIBS=-lm
++ LIBS=-lm -ldl
+
+ CLIENT_LIBS =
+
+--
+2.35.1
+
diff --git a/Ports/quake3/patches/0005-Engine-Move-ifdef-to-more-sensible-location.patch b/Ports/quake3/patches/0005-Engine-Move-ifdef-to-more-sensible-location.patch
new file mode 100644
index 0000000000..f5fd1b47a5
--- /dev/null
+++ b/Ports/quake3/patches/0005-Engine-Move-ifdef-to-more-sensible-location.patch
@@ -0,0 +1,52 @@
+From 1d85a563613d3ea2f6cb03c01a4f4bbda2051e79 Mon Sep 17 00:00:00 2001
+From: Jesse Buhagiar <jooster669@gmail.com>
+Date: Fri, 25 Mar 2022 09:45:32 +1100
+Subject: [PATCH 5/8] Engine: Move `#ifdef` to more sensible location
+
+No linker errors in this dojo!
+---
+ code/qcommon/net_ip.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/code/qcommon/net_ip.c b/code/qcommon/net_ip.c
+index ea940f59..aaba8321 100644
+--- a/code/qcommon/net_ip.c
++++ b/code/qcommon/net_ip.c
+@@ -1000,9 +1000,9 @@ NET_JoinMulticast
+ Join an ipv6 multicast group
+ ====================
+ */
+-#ifndef __serenity__
+ void NET_JoinMulticast6(void)
+ {
++#ifndef __serenity__
+ int err;
+
+ if(ip6_socket == INVALID_SOCKET || multicast6_socket != INVALID_SOCKET || (net_enabled->integer & NET_DISABLEMCAST))
+@@ -1049,10 +1049,12 @@ void NET_JoinMulticast6(void)
+ return;
+ }
+ }
++#endif
+ }
+
+ void NET_LeaveMulticast6()
+ {
++#ifndef __serenity__
+ if(multicast6_socket != INVALID_SOCKET)
+ {
+ if(multicast6_socket != ip6_socket)
+@@ -1062,9 +1064,8 @@ void NET_LeaveMulticast6()
+
+ multicast6_socket = INVALID_SOCKET;
+ }
+-}
+-
+ #endif
++}
+
+ /*
+ ====================
+--
+2.35.1
+
diff --git a/Ports/quake3/patches/0006-Meta-Add-ARCH-to-TOOLS_CFLAGS.patch b/Ports/quake3/patches/0006-Meta-Add-ARCH-to-TOOLS_CFLAGS.patch
new file mode 100644
index 0000000000..42f918f48e
--- /dev/null
+++ b/Ports/quake3/patches/0006-Meta-Add-ARCH-to-TOOLS_CFLAGS.patch
@@ -0,0 +1,25 @@
+From 4c52876ae0217438e97ee9092533bbb29ee1739e Mon Sep 17 00:00:00 2001
+From: Jesse Buhagiar <jooster669@gmail.com>
+Date: Fri, 25 Mar 2022 21:46:14 +1100
+Subject: [PATCH 6/8] Meta: Add ARCH to TOOLS_CFLAGS
+
+---
+ Makefile | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/Makefile b/Makefile
+index 035fea77..c5a27abe 100644
+--- a/Makefile
++++ b/Makefile
+@@ -821,6 +821,8 @@ ifeq ($(PLATFORM),serenity)
+ -pipe -DUSE_ICON -DMAP_ANONYMOUS=MAP_ANON
+ CLIENT_CFLAGS += $(SDL_CFLAGS)
+
++ TOOLS_CFLAGS += -DARCH_STRING=\"$(COMPILE_ARCH)\"
++
+ OPTIMIZEVM = -O3
+ OPTIMIZE = $(OPTIMIZEVM) -ffast-math
+
+--
+2.35.1
+
diff --git a/Ports/quake3/patches/0007-Meta-Remove-extension-from-main-game-exe.patch b/Ports/quake3/patches/0007-Meta-Remove-extension-from-main-game-exe.patch
new file mode 100644
index 0000000000..4d89a27f9b
--- /dev/null
+++ b/Ports/quake3/patches/0007-Meta-Remove-extension-from-main-game-exe.patch
@@ -0,0 +1,58 @@
+From 4d5d4cd86c7e94b3f4b2d8cdaf3909a5016aec23 Mon Sep 17 00:00:00 2001
+From: Jesse Buhagiar <jooster669@gmail.com>
+Date: Fri, 25 Mar 2022 22:04:17 +1100
+Subject: [PATCH 7/8] Meta: Remove extension from main game exe
+
+---
+ Makefile | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index c5a27abe..c0e62001 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1046,12 +1046,12 @@ endif
+
+ ifneq ($(BUILD_CLIENT),0)
+ ifneq ($(USE_RENDERER_DLOPEN),0)
+- TARGETS += $(B)/$(CLIENTBIN)$(FULLBINEXT) $(B)/renderer_opengl1_$(SHLIBNAME)
++ TARGETS += $(B)/$(CLIENTBIN) $(B)/renderer_opengl1_$(SHLIBNAME)
+ ifneq ($(BUILD_RENDERER_OPENGL2),0)
+ TARGETS += $(B)/renderer_opengl2_$(SHLIBNAME)
+ endif
+ else
+- TARGETS += $(B)/$(CLIENTBIN)$(FULLBINEXT)
++ TARGETS += $(B)/$(CLIENTBIN)
+ ifneq ($(BUILD_RENDERER_OPENGL2),0)
+ TARGETS += $(B)/$(CLIENTBIN)_opengl2$(FULLBINEXT)
+ endif
+@@ -2246,7 +2246,7 @@ ifeq ($(USE_MUMBLE),1)
+ endif
+
+ ifneq ($(USE_RENDERER_DLOPEN),0)
+-$(B)/$(CLIENTBIN)$(FULLBINEXT): $(Q3OBJ) $(LIBSDLMAIN)
++$(B)/$(CLIENTBIN): $(Q3OBJ) $(LIBSDLMAIN)
+ $(echo_cmd) "LD $@"
+ $(Q)$(CC) $(CLIENT_CFLAGS) $(CFLAGS) $(CLIENT_LDFLAGS) $(LDFLAGS) $(NOTSHLIBLDFLAGS) \
+ -o $@ $(Q3OBJ) \
+@@ -2262,7 +2262,7 @@ $(B)/renderer_opengl2_$(SHLIBNAME): $(Q3R2OBJ) $(Q3R2STRINGOBJ) $(JPGOBJ)
+ $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(Q3R2OBJ) $(Q3R2STRINGOBJ) $(JPGOBJ) \
+ $(THREAD_LIBS) $(LIBSDLMAIN) $(RENDERER_LIBS) $(LIBS)
+ else
+-$(B)/$(CLIENTBIN)$(FULLBINEXT): $(Q3OBJ) $(Q3ROBJ) $(JPGOBJ) $(LIBSDLMAIN)
++$(B)/$(CLIENTBIN): $(Q3OBJ) $(Q3ROBJ) $(JPGOBJ) $(LIBSDLMAIN)
+ $(echo_cmd) "LD $@"
+ $(Q)$(CC) $(CLIENT_CFLAGS) $(CFLAGS) $(CLIENT_LDFLAGS) $(LDFLAGS) $(NOTSHLIBLDFLAGS) \
+ -o $@ $(Q3OBJ) $(Q3ROBJ) $(JPGOBJ) \
+@@ -2945,7 +2945,7 @@ ifneq ($(BUILD_GAME_SO),0)
+ endif
+
+ ifneq ($(BUILD_CLIENT),0)
+- $(INSTALL) $(STRIP_FLAG) -m 0755 $(BR)/$(CLIENTBIN)$(FULLBINEXT) $(COPYBINDIR)/$(CLIENTBIN)$(FULLBINEXT)
++ $(INSTALL) $(STRIP_FLAG) -m 0755 $(BR)/$(CLIENTBIN) $(COPYBINDIR)/$(CLIENTBIN)
+ ifneq ($(USE_RENDERER_DLOPEN),0)
+ $(INSTALL) $(STRIP_FLAG) -m 0755 $(BR)/renderer_opengl1_$(SHLIBNAME) $(COPYBINDIR)/renderer_opengl1_$(SHLIBNAME)
+ ifneq ($(BUILD_RENDERER_OPENGL2),0)
+--
+2.35.1
+
diff --git a/Ports/quake3/patches/0008-Engine-Use-Serenity-style-PROT_EXEC-mmap.patch b/Ports/quake3/patches/0008-Engine-Use-Serenity-style-PROT_EXEC-mmap.patch
new file mode 100644
index 0000000000..805a2bbf6b
--- /dev/null
+++ b/Ports/quake3/patches/0008-Engine-Use-Serenity-style-PROT_EXEC-mmap.patch
@@ -0,0 +1,72 @@
+From 488dfbc449db59057afabb92d2843a2ae63741ac Mon Sep 17 00:00:00 2001
+From: Jesse Buhagiar <jooster669@gmail.com>
+Date: Sat, 26 Mar 2022 00:08:46 +1100
+Subject: [PATCH 8/8] Engine: Use Serenity style PROT_EXEC mmap
+
+The code for this was really old and crusty, so let's `ifdef` it out and
+use some more friendly Serenity style memory code.
+---
+ code/qcommon/vm_x86.c | 29 +++++++++++++++++++++++++++--
+ 1 file changed, 27 insertions(+), 2 deletions(-)
+
+diff --git a/code/qcommon/vm_x86.c b/code/qcommon/vm_x86.c
+index 8d6321a6..d155efc2 100644
+--- a/code/qcommon/vm_x86.c
++++ b/code/qcommon/vm_x86.c
+@@ -42,6 +42,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ #endif
+ #endif
+
++#ifdef __serenity__
++#include <fcntl.h>
++#include <unistd.h> // for `pledge()`
++#include <serenity.h>
++#endif
++
+ #if defined (__i386__) || defined(__x86_64__)
+ static void VM_Destroy_Compiled(vm_t* self);
+
+@@ -1649,9 +1655,24 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
+ // copy to an exact sized buffer with the appropriate permission bits
+ vm->codeLength = compiledOfs;
+ #ifdef VM_X86_MMAP
++#ifdef __serenity__
++ // Round up by a page for `anon_create` (so we don't blow up in the Kernel)
++ int compiledOfsPageAligned = compiledOfs + (4096u - (compiledOfs % 4096u));
++
++ // Create the fd...
++ int fd = anon_create(compiledOfsPageAligned, O_CLOEXEC);
++ if (fd == -1)
++ Com_Error(ERR_FATAL, "VM_CompileX86: anon_create failed (a very bad thing!)");
++
++ vm->codeBase = mmap_with_name(NULL, compiledOfs, PROT_WRITE|PROT_READ|PROT_EXEC, MAP_SHARED, fd, 0, "Quake3 VM Page");
++ if(vm->codeBase == MAP_FAILED)
++ Com_Error(ERR_FATAL, "VM_CompileX86: can't mmap memory");
++ close(fd);
++#else
+ vm->codeBase = mmap(NULL, compiledOfs, PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
+ if(vm->codeBase == MAP_FAILED)
+ Com_Error(ERR_FATAL, "VM_CompileX86: can't mmap memory");
++#endif
+ #elif _WIN32
+ // allocate memory with EXECUTE permissions under windows.
+ vm->codeBase = VirtualAlloc(NULL, compiledOfs, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+@@ -1665,9 +1686,13 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
+
+ Com_Memcpy( vm->codeBase, buf, compiledOfs );
+
++
+ #ifdef VM_X86_MMAP
+- if(mprotect(vm->codeBase, compiledOfs, PROT_READ|PROT_EXEC))
+- Com_Error(ERR_FATAL, "VM_CompileX86: mprotect failed");
++#ifndef __serenity__
++ int rc = mprotect(vm->codeBase, compiledOfs, PROT_READ|PROT_EXEC);
++ if(rc)
++ Com_Error(ERR_FATAL, "VM_CompileX86: mprotect failed with %d", rc);
++#endif
+ #elif _WIN32
+ {
+ DWORD oldProtect = 0;
+--
+2.35.1
+
diff --git a/Ports/quake3/patches/ReadMe.md b/Ports/quake3/patches/ReadMe.md
new file mode 100644
index 0000000000..6127014155
--- /dev/null
+++ b/Ports/quake3/patches/ReadMe.md
@@ -0,0 +1,48 @@
+# Patches for quake3 on SerenityOS
+
+## `0001-Meta-Refactor-Makefile-to-support-Serenity.patch`
+
+Meta: Refactor Makefile to support Serenity
+
+
+## `0002-Engine-Add-Serenity-so-q_platform.h.patch`
+
+Engine: Add Serenity so `q_platform.h`
+
+
+## `0003-Engine-Add-sys-select.h-include-for-Serenity.patch`
+
+Engine: Add `<sys/select.h>` include for Serenity
+
+QuakeIII makes extensive use of the `select()` syscall for its' netcode.
+It seems that Linux has this in a header that isn't `<sys/select.h>`
+like us, which results in an implicit declaration error.
+
+## `0004-Meta-Add-ldl-library-for-Serenity-target.patch`
+
+Meta: Add `-ldl` library for Serenity target
+
+
+## `0005-Engine-Move-ifdef-to-more-sensible-location.patch`
+
+Engine: Move `#ifdef` to more sensible location
+
+No linker errors in this dojo!
+
+## `0006-Meta-Add-ARCH-to-TOOLS_CFLAGS.patch`
+
+Meta: Add ARCH to TOOLS_CFLAGS
+
+
+## `0007-Meta-Remove-extension-from-main-game-exe.patch`
+
+Meta: Remove extension from main game exe
+
+
+## `0008-Engine-Use-Serenity-style-PROT_EXEC-mmap.patch`
+
+Engine: Use Serenity style PROT_EXEC mmap
+
+The code for this was really old and crusty, so let's `ifdef` it out and
+use some more friendly Serenity style memory code.
+