summaryrefslogtreecommitdiff
path: root/Ports
diff options
context:
space:
mode:
authorLuke Wilde <lukew@serenityos.org>2023-02-27 21:26:27 +0000
committerSam Atkins <atkinssj@gmail.com>2023-02-28 08:42:45 +0000
commit57cc2bab4b7d305f0f5f90435c1a08fbe0448eee (patch)
treeaba6b0fab05975bc9322861efff63c4509a29ff0 /Ports
parent3112a6b44f42cb3198cad247c6e3a0dcbd4ba796 (diff)
downloadserenity-57cc2bab4b7d305f0f5f90435c1a08fbe0448eee.zip
Ports: Add Mednafen
Diffstat (limited to 'Ports')
-rw-r--r--Ports/AvailablePorts.md1
-rwxr-xr-xPorts/mednafen/package.sh10
-rw-r--r--Ports/mednafen/patches/0001-Make-mednafen-compile-with-PIC-PIE.patch39
-rw-r--r--Ports/mednafen/patches/0002-Replace-PTHREAD_MUTEX_ERRORCHECK-with-PTHREAD_MUTEX_.patch23
-rw-r--r--Ports/mednafen/patches/ReadMe.md16
5 files changed, 89 insertions, 0 deletions
diff --git a/Ports/AvailablePorts.md b/Ports/AvailablePorts.md
index b52b3af659..689ccd2a7e 100644
--- a/Ports/AvailablePorts.md
+++ b/Ports/AvailablePorts.md
@@ -165,6 +165,7 @@ This list is also available at [ports.serenityos.net](https://ports.serenityos.n
| [`mbedtls`](mbedtls/) | Mbed TLS | 3.1.0 | https://tls.mbed.org/ |
| [`mc`](mc/) | Midnight Commander | 4.8.29 | https://midnight-commander.org/ |
| [`md4c`](md4c/) | Markdown for C | 0.4.8 | https://github.com/mity/md4c |
+| [`mednafen`](mednafen/) | Mednafen (My Emulator Doesn't Need A Frickin' Excellent Name) | 1.31.0-UNSTABLE | https://mednafen.github.io/ |
| [`mgba`](mgba/) | Game Boy, Game Boy Color and Game Boy Advance emulator | 0.9.3 | https://mgba.io/ |
| [`milkytracker`](milkytracker/) | milkytracker | 1.03.00 | https://github.com/milkytracker/MilkyTracker |
| [`mold`](mold/) | A Modern Linker | 1.5.1 | https://github.com/rui314/mold |
diff --git a/Ports/mednafen/package.sh b/Ports/mednafen/package.sh
new file mode 100755
index 0000000000..fc8ac4e403
--- /dev/null
+++ b/Ports/mednafen/package.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env -S bash ../.port_include.sh
+port='mednafen'
+version='1.31.0-UNSTABLE'
+files="https://mednafen.github.io/releases/files/mednafen-${version}.tar.xz mednafen-${version}.tar.xz bfcff72e370e09e12ba3791600782187fbf5e2cc9d6b5fe4f9f3471642046367"
+auth_type='sha256'
+workdir="mednafen"
+useconfigure='true'
+use_fresh_config_sub='true'
+use_fresh_config_guess='true'
+depends=("SDL2" "zlib" "flac")
diff --git a/Ports/mednafen/patches/0001-Make-mednafen-compile-with-PIC-PIE.patch b/Ports/mednafen/patches/0001-Make-mednafen-compile-with-PIC-PIE.patch
new file mode 100644
index 0000000000..6cf55b0b82
--- /dev/null
+++ b/Ports/mednafen/patches/0001-Make-mednafen-compile-with-PIC-PIE.patch
@@ -0,0 +1,39 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Luke Wilde <lukew@serenityos.org>
+Date: Mon, 27 Feb 2023 20:42:52 +0000
+Subject: [PATCH] Make mednafen compile with PIC/PIE
+
+We currently don't support copy relocations and mednafen compiles with
+PIC/PIE disabled for performance reasons. This re-enables it and
+disables the compiler warning it emits for having it enabled.
+---
+ configure | 2 ++
+ src/types.h | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/configure b/configure
+index 01b3122038f5223f3c2fbdefc823b2aeb240515d..2d45a1a179374a9441eaef9f08c841983b70a681 100755
+--- a/configure
++++ b/configure
+@@ -19954,6 +19954,8 @@ cat >>confdefs.h <<_ACEOF
+ #define MEDNAFEN_VERSION_NUMERIC $MEDNAFEN_VERSION_NUMERIC
+ _ACEOF
+
++NOPICPIE_FLAGS=""
++NOPICPIE_LDFLAGS=""
+
+ AM_CFLAGS="$ALTIVEC_FLAGS $OPTIMIZER_FLAGS $WARNING_FLAGS $CODEGEN_FLAGS $CODEGEN_CFLAGS $NOPICPIE_FLAGS"
+
+diff --git a/src/types.h b/src/types.h
+index 86aedf67812c1270d2b55692fb674fa70f66dbc6..41296bbcd01e82bb93b0a66a00349efd8b4fd603 100644
+--- a/src/types.h
++++ b/src/types.h
+@@ -14,6 +14,8 @@
+ #include <config.h>
+ #endif
+
++#define MDFN_DISABLE_PICPIE_ERRWARN 1
++
+ //
+ //
+ //
diff --git a/Ports/mednafen/patches/0002-Replace-PTHREAD_MUTEX_ERRORCHECK-with-PTHREAD_MUTEX_.patch b/Ports/mednafen/patches/0002-Replace-PTHREAD_MUTEX_ERRORCHECK-with-PTHREAD_MUTEX_.patch
new file mode 100644
index 0000000000..9e49246a76
--- /dev/null
+++ b/Ports/mednafen/patches/0002-Replace-PTHREAD_MUTEX_ERRORCHECK-with-PTHREAD_MUTEX_.patch
@@ -0,0 +1,23 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Luke Wilde <lukew@serenityos.org>
+Date: Mon, 27 Feb 2023 20:43:34 +0000
+Subject: [PATCH] Replace PTHREAD_MUTEX_ERRORCHECK with PTHREAD_MUTEX_NORMAL
+
+We currently don't support the PTHREAD_MUTEX_ERRORCHECK mutex type.
+---
+ src/mthreading/MThreading_POSIX.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/mthreading/MThreading_POSIX.cpp b/src/mthreading/MThreading_POSIX.cpp
+index ddebafec32385b98b7e2a0a0a98c3a6558cf069a..1acd8ba3780a9dca435f6596c32e7767720316d5 100644
+--- a/src/mthreading/MThreading_POSIX.cpp
++++ b/src/mthreading/MThreading_POSIX.cpp
+@@ -295,7 +295,7 @@ static void CreateMutex(Mutex* ret)
+ throw MDFN_Error(ene.Errno(), _("%s failed: %s"), "pthread_mutexattr_init()", ene.StrError());
+ }
+
+- if((ptec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK/*PTHREAD_MUTEX_NORMAL*/)))
++ if((ptec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL)))
+ {
+ ErrnoHolder ene(ptec);
+
diff --git a/Ports/mednafen/patches/ReadMe.md b/Ports/mednafen/patches/ReadMe.md
new file mode 100644
index 0000000000..0caecf9911
--- /dev/null
+++ b/Ports/mednafen/patches/ReadMe.md
@@ -0,0 +1,16 @@
+# Patches for mednafen on SerenityOS
+
+## `0001-Make-mednafen-compile-with-PIC-PIE.patch`
+
+Make mednafen compile with PIC/PIE
+
+We currently don't support copy relocations and mednafen compiles with
+PIC/PIE disabled for performance reasons. This re-enables it and
+disables the compiler warning it emits for having it enabled.
+
+## `0002-Replace-PTHREAD_MUTEX_ERRORCHECK-with-PTHREAD_MUTEX_.patch`
+
+Replace PTHREAD_MUTEX_ERRORCHECK with PTHREAD_MUTEX_NORMAL
+
+We currently don't support the PTHREAD_MUTEX_ERRORCHECK mutex type.
+