diff --git a/Ports/AvailablePorts.md b/Ports/AvailablePorts.md index 473337514d..c0d8b8cbb6 100644 --- a/Ports/AvailablePorts.md +++ b/Ports/AvailablePorts.md @@ -254,6 +254,7 @@ This list is also available at [ports.serenityos.net](https://ports.serenityos.n | [`SDLPoP`](SDLPoP/) | Prince of Persia game | | https://github.com/NagyD/SDLPoP | | [`sed`](sed/) | GNU sed | 4.9 | https://www.gnu.org/software/sed/ | | [`serenity-theming`](serenity-theming/) | SerenityOS theming | ba2ddd0 | https://github.com/SerenityOS/theming | +| [`serious-sam-classic`](serious-sam-classic/) | Serious Sam - The First Encounter | 1.10.4 | https://github.com/tx00100xt/SeriousSamClassic | | [`sfinx`](sfinx/) | Sfinx | 1.1 | https://www.scummvm.org/games/#games-sfinx | | [`sl`](sl/) | Steam Locomotive (SL) | | https://github.com/mtoyoda/sl | | [`soltys`](soltys/) | Soltys | 1.0 | https://www.scummvm.org/games/#games-soltys | diff --git a/Ports/serious-sam-classic/package.sh b/Ports/serious-sam-classic/package.sh new file mode 100755 index 0000000000..28e7176419 --- /dev/null +++ b/Ports/serious-sam-classic/package.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env -S bash ../.port_include.sh +port='serious-sam-classic' +useconfigure='false' +version='1.10.4' +files="https://github.com/tx00100xt/SeriousSamClassic/archive/refs/tags/v${version}.tar.gz ${port}.tar.gz c42e1434e03f713ffc60aa627f0a24c64287598bc5ee7cdbd2cbe91aa363ef51" +auth_type='sha256' +depends=( + 'libvorbis' + 'SDL2' + 'zlib' +) +workdir="SeriousSamClassic-${version}" + +launcher_name='Serious Sam - The First Encounter' +launcher_category='Games' +launcher_command="/usr/local/bin/serioussam" +icon_file='SamTFE/Sources/SeriousSam/res/SeriousSam.ico' + +sam_tfe_dir="${workdir}/SamTFE" +sam_tfe_build_dir="${sam_tfe_dir}/Sources/cmake-build" + +# FIXME: SeriousSamClassic includes both TFE and TSE; we should also build and install TSE + +build() { + # Host build: ecc + mkdir -p "${sam_tfe_build_dir}" + cd "${sam_tfe_build_dir}" + if [ ! -x 'ecc' ]; then + host_env + cmake \ + -DTFE=true \ + -DUSE_SYSTEM_SDL2=0 \ + ../ + make "${makeopts[@]}" ecc + fi + + # Target build: SamTFE + cp -vfr ../Entities/PlayerWeapons_old.es ../Entities/PlayerWeapons.es + target_env + cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_TOOLCHAIN_FILE=${SERENITY_BUILD_DIR}/CMakeToolchain.txt \ + -DECC=${PORT_BUILD_DIR}/${sam_tfe_build_dir}/ecc \ + -DINTERNAL_NAME=serioussam \ + -DLINUX=1 \ + -DTFE=true \ + -DUSE_SYSTEM_SDL2=1 \ + ../ + make "${makeopts[@]}" +} + +install() { + cd "${sam_tfe_build_dir}" + make "${installopts[@]}" install +} + +post_install() { + echo + echo 'Serious Sam: The First Encounter is installed!' + echo + echo 'Make sure your game files are present in the following directory:' + echo ' Inside SerenityOS: ~/.local/share/Serious-Engine/serioussam/' + echo " Outside SerenityOS: ${SERENITY_SOURCE_DIR}/Base/home/anon/.local/share/Serious-Engine/serioussam/" + echo + echo 'Copy over all files. The game will be looking for a directory with the `1_00_music.gro` file.' +} diff --git a/Ports/serious-sam-classic/patches/0001-CMake-Remove-march-native.patch b/Ports/serious-sam-classic/patches/0001-CMake-Remove-march-native.patch new file mode 100644 index 0000000000..a53becfe8b --- /dev/null +++ b/Ports/serious-sam-classic/patches/0001-CMake-Remove-march-native.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jelle Raaijmakers +Date: Sun, 30 Apr 2023 17:10:38 +0200 +Subject: [PATCH] CMake: Remove `-march=native` + +The compiler complains about this: + + error: bad value 'native' for '-march=' switch + +However, in the list of supported options, `native` is included - so +there's something funky going on. Leaving this option out lets the game +compile successfully. +--- + SamTFE/Sources/CMakeLists.txt | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/SamTFE/Sources/CMakeLists.txt b/SamTFE/Sources/CMakeLists.txt +index a35b48218f74795d553754ef7e5714d6c8755535..44bf38675ac1e943bd4fb1532d26b713c8f9c9bd 100644 +--- a/SamTFE/Sources/CMakeLists.txt ++++ b/SamTFE/Sources/CMakeLists.txt +@@ -105,7 +105,6 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") + add_compile_options(-pipe) + add_compile_options(-fPIC) + if(NOT PANDORA AND NOT PYRA AND NOT (MACOSX AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")) +- add_compile_options(-march=native) + endif() + if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm.*") + if(PYRA) diff --git a/Ports/serious-sam-classic/patches/0002-CMake-Set-the-install-prefix-to-our-staging-prefix.patch b/Ports/serious-sam-classic/patches/0002-CMake-Set-the-install-prefix-to-our-staging-prefix.patch new file mode 100644 index 0000000000..0d07bd9889 --- /dev/null +++ b/Ports/serious-sam-classic/patches/0002-CMake-Set-the-install-prefix-to-our-staging-prefix.patch @@ -0,0 +1,22 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jelle Raaijmakers +Date: Sat, 29 Apr 2023 15:55:05 +0200 +Subject: [PATCH] CMake: Set the install prefix to our staging prefix + +This makes sure the binaries are installed to `/usr/local`. +--- + SamTFE/Sources/CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/SamTFE/Sources/CMakeLists.txt b/SamTFE/Sources/CMakeLists.txt +index 44bf38675ac1e943bd4fb1532d26b713c8f9c9bd..15922bf2a98fedb843bf83be5d5ddfbdcb7a4fae 100644 +--- a/SamTFE/Sources/CMakeLists.txt ++++ b/SamTFE/Sources/CMakeLists.txt +@@ -61,6 +61,7 @@ if(USE_SYSTEM_ZLIB) + endif() + + # RAKE! Where to install the binaries. ++set(CMAKE_INSTALL_PREFIX "${CMAKE_STAGING_PREFIX}") + if(CMAKE_INSTALL_PREFIX STREQUAL "/usr/local" OR CMAKE_INSTALL_PREFIX STREQUAL "") # Only works for linux since I don't + # know what default is for windows/macos/freebsd. + set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../") # set install path to project root directory since diff --git a/Ports/serious-sam-classic/patches/0003-SamTFE-Force-__linux__-macro-to-be-1.patch b/Ports/serious-sam-classic/patches/0003-SamTFE-Force-__linux__-macro-to-be-1.patch new file mode 100644 index 0000000000..172f6347e9 --- /dev/null +++ b/Ports/serious-sam-classic/patches/0003-SamTFE-Force-__linux__-macro-to-be-1.patch @@ -0,0 +1,23 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jelle Raaijmakers +Date: Mon, 24 Apr 2023 15:41:00 +0200 +Subject: [PATCH] SamTFE: Force __linux__ macro to be 1 + +We are compatible with the Linux version, and setting this macro allows +us to identify as Linux and compile successfully. +--- + SamTFE/Sources/Engine/Base/Base.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/SamTFE/Sources/Engine/Base/Base.h b/SamTFE/Sources/Engine/Base/Base.h +index 0f021cf08cba55b3f9ce8e99e23cba791b81229c..7e7ddc60b1a409aa76deddf491a67a0f35cf6dc0 100644 +--- a/SamTFE/Sources/Engine/Base/Base.h ++++ b/SamTFE/Sources/Engine/Base/Base.h +@@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc., + */ + // be a little more discerning, using these macros will ensure that if someone + // wants to use MINGW then they can ++#define __linux__ 1 + #if (defined _WIN32) || (defined _WIN64) + #ifndef PLATFORM_WIN32 + #define PLATFORM_WIN32 1 diff --git a/Ports/serious-sam-classic/patches/0004-Engine-Remove-malloc.h.patch b/Ports/serious-sam-classic/patches/0004-Engine-Remove-malloc.h.patch new file mode 100644 index 0000000000..78e69660ca --- /dev/null +++ b/Ports/serious-sam-classic/patches/0004-Engine-Remove-malloc.h.patch @@ -0,0 +1,23 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jelle Raaijmakers +Date: Mon, 24 Apr 2023 15:52:50 +0200 +Subject: [PATCH] Engine: Remove malloc.h + +This seems to be a non-standard header. The API used by the game already +finds its way through the inclusion of other headers, so leave this out. +--- + SamTFE/Sources/Engine/Engine.h | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/SamTFE/Sources/Engine/Engine.h b/SamTFE/Sources/Engine/Engine.h +index 7466327d68cb3de4aa86b2f5c0ec67881bf67eb8..fe62f26e60ce33ea31a63cef619097c913dad05f 100644 +--- a/SamTFE/Sources/Engine/Engine.h ++++ b/SamTFE/Sources/Engine/Engine.h +@@ -31,7 +31,6 @@ with this program; if not, write to the Free Software Foundation, Inc., + #endif + + #include +-#include + #include + #include + #include diff --git a/Ports/serious-sam-classic/patches/0005-Engine-Remove-static_assert-on-pthread_t.patch b/Ports/serious-sam-classic/patches/0005-Engine-Remove-static_assert-on-pthread_t.patch new file mode 100644 index 0000000000..013aca6906 --- /dev/null +++ b/Ports/serious-sam-classic/patches/0005-Engine-Remove-static_assert-on-pthread_t.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jelle Raaijmakers +Date: Mon, 24 Apr 2023 17:05:31 +0200 +Subject: [PATCH] Engine: Remove static_assert on pthread_t + +In x86_64 Serenity, `sizeof(size_t) == 8` and `sizeof(pthread_t) == 4`. +The game seems to run just fine without this assertion, and changing +`pthread_t` is quite the yak hole. +--- + SamTFE/Sources/Engine/Base/Unix/UnixSynchronization.cpp | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/SamTFE/Sources/Engine/Base/Unix/UnixSynchronization.cpp b/SamTFE/Sources/Engine/Base/Unix/UnixSynchronization.cpp +index cfa9eda4de2a00e44ec4c8949e718740776656ef..74d1908c3d3dd6264c7c27ce7d7a2c704462b1ed 100644 +--- a/SamTFE/Sources/Engine/Base/Unix/UnixSynchronization.cpp ++++ b/SamTFE/Sources/Engine/Base/Unix/UnixSynchronization.cpp +@@ -58,7 +58,6 @@ LONG InterlockedDecrement(LONG volatile *Addend) { + } + + unsigned long long GetCurrentThreadId() { +- static_assert(sizeof(pthread_t) == sizeof(size_t), ""); + return (unsigned long long) pthread_self(); + } + diff --git a/Ports/serious-sam-classic/patches/0006-Engine-Add-missing-include-for-sys-select.h.patch b/Ports/serious-sam-classic/patches/0006-Engine-Add-missing-include-for-sys-select.h.patch new file mode 100644 index 0000000000..fcd7792561 --- /dev/null +++ b/Ports/serious-sam-classic/patches/0006-Engine-Add-missing-include-for-sys-select.h.patch @@ -0,0 +1,21 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jelle Raaijmakers +Date: Mon, 24 Apr 2023 17:24:51 +0200 +Subject: [PATCH] Engine: Add missing include for + +--- + SamTFE/Sources/Engine/GameAgent/GameAgent.cpp | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/SamTFE/Sources/Engine/GameAgent/GameAgent.cpp b/SamTFE/Sources/Engine/GameAgent/GameAgent.cpp +index fc6c8441188f19c1cd35377643f86b9df5a7cbb6..1c85633a344181f65e2466950ea2313b7a34c6ec 100644 +--- a/SamTFE/Sources/Engine/GameAgent/GameAgent.cpp ++++ b/SamTFE/Sources/Engine/GameAgent/GameAgent.cpp +@@ -35,6 +35,7 @@ typedef int socklen_t; + #include + #include + #include ++#include + #include + #include + #include diff --git a/Ports/serious-sam-classic/patches/0007-Engine-Support-running-from-usr-local.patch b/Ports/serious-sam-classic/patches/0007-Engine-Support-running-from-usr-local.patch new file mode 100644 index 0000000000..aa29862573 --- /dev/null +++ b/Ports/serious-sam-classic/patches/0007-Engine-Support-running-from-usr-local.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jelle Raaijmakers +Date: Sun, 30 Apr 2023 16:53:57 +0200 +Subject: [PATCH] Engine: Support running from `/usr/local` + +A lot of logic is hardcoded to `/usr`, so we push it in the right +direction to allow it to run from `/usr/local` instead. +--- + SamTFE/Sources/Engine/Engine.cpp | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/SamTFE/Sources/Engine/Engine.cpp b/SamTFE/Sources/Engine/Engine.cpp +index f3e2ebe155439cef2a5860201665839fc2cc09c3..0bf86cc57563ef5f44e25d97623194f99484060e 100644 +--- a/SamTFE/Sources/Engine/Engine.cpp ++++ b/SamTFE/Sources/Engine/Engine.cpp +@@ -736,7 +736,7 @@ ENGINE_API void SE_InitEngine(CTString strGameID) + CPrintF(TRANSV("Running %d-bit version\n"), sys_iGameBits); + + #ifdef PLATFORM_UNIX +- int _isystempath = strncmp((const char *)strExePath, (const char *) "/usr/bin/", (size_t) 9 ); ++ int _isystempath = strncmp((const char *)strExePath, (const char *) "/usr/local/bin/", (size_t) 15 ); + if( _isystempath == 0 ) { + sys_iSysPath = 1; // using system path + } else { +@@ -751,8 +751,8 @@ ENGINE_API void SE_InitEngine(CTString strGameID) + _fnmModLibPath = "/usr/lib/i386-linux-gnu/" + strGameID + "/"; + } else if( sys_iSysPath == 1 && sys_iGameBits == 64 && _pFileSystem->IsDirectory((const char *) "/usr/lib64")) { + _fnmModLibPath = "/usr/lib64/" + strGameID + "/"; +- } else if( sys_iSysPath == 1 && sys_iGameBits == 32 && _pFileSystem->IsDirectory((const char *) "/usr/lib")) { +- _fnmModLibPath = "/usr/lib/" + strGameID + "/"; ++ } else if( sys_iSysPath == 1 && _pFileSystem->IsDirectory((const char *) "/usr/local/lib")) { ++ _fnmModLibPath = "/usr/local/lib/" + strGameID + "/"; + } else { + _fnmModLibPath = _fnmApplicationPath; + } diff --git a/Ports/serious-sam-classic/patches/ReadMe.md b/Ports/serious-sam-classic/patches/ReadMe.md new file mode 100644 index 0000000000..8befe1198a --- /dev/null +++ b/Ports/serious-sam-classic/patches/ReadMe.md @@ -0,0 +1,54 @@ +# Patches for serious-sam-classic on SerenityOS + +## `0001-CMake-Remove-march-native.patch` + +CMake: Remove `-march=native` + +The compiler complains about this: + + error: bad value 'native' for '-march=' switch + +However, in the list of supported options, `native` is included - so +there's something funky going on. Leaving this option out lets the game +compile successfully. + +## `0002-CMake-Set-the-install-prefix-to-our-staging-prefix.patch` + +CMake: Set the install prefix to our staging prefix + +This makes sure the binaries are installed to `/usr/local`. + +## `0003-SamTFE-Force-__linux__-macro-to-be-1.patch` + +SamTFE: Force __linux__ macro to be 1 + +We are compatible with the Linux version, and setting this macro allows +us to identify as Linux and compile successfully. + +## `0004-Engine-Remove-malloc.h.patch` + +Engine: Remove malloc.h + +This seems to be a non-standard header. The API used by the game already +finds its way through the inclusion of other headers, so leave this out. + +## `0005-Engine-Remove-static_assert-on-pthread_t.patch` + +Engine: Remove static_assert on pthread_t + +In x86_64 Serenity, `sizeof(size_t) == 8` and `sizeof(pthread_t) == 4`. +The game seems to run just fine without this assertion, and changing +`pthread_t` is quite the yak hole. + +## `0006-Engine-Add-missing-include-for-sys-select.h.patch` + +Engine: Add missing include for + + +## `0007-Engine-Support-running-from-usr-local.patch` + +Engine: Support running from `/usr/local` + +A lot of logic is hardcoded to `/usr`, so we push it in the right +direction to allow it to run from `/usr/local` instead. +