From ae32abffe9c75c130951b8b81097b56c3821ffdd Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sat, 17 Apr 2021 15:40:17 +0200 Subject: Ports: Add openttd --- Ports/AvailablePorts.md | 3 + Ports/openttd-opengfx/package.sh | 16 +++++ Ports/openttd-opensfx/package.sh | 16 +++++ Ports/openttd/package.sh | 47 +++++++++++++ Ports/openttd/patches/build-fixes.patch | 116 ++++++++++++++++++++++++++++++++ Ports/openttd/patches/memory.patch | 22 ++++++ Ports/openttd/patches/rdtsc.patch | 12 ++++ Ports/openttd/patches/sighandler.patch | 12 ++++ 8 files changed, 244 insertions(+) create mode 100755 Ports/openttd-opengfx/package.sh create mode 100755 Ports/openttd-opensfx/package.sh create mode 100755 Ports/openttd/package.sh create mode 100644 Ports/openttd/patches/build-fixes.patch create mode 100644 Ports/openttd/patches/memory.patch create mode 100644 Ports/openttd/patches/rdtsc.patch create mode 100644 Ports/openttd/patches/sighandler.patch (limited to 'Ports') diff --git a/Ports/AvailablePorts.md b/Ports/AvailablePorts.md index 3b5e442826..24e34adc34 100644 --- a/Ports/AvailablePorts.md +++ b/Ports/AvailablePorts.md @@ -81,6 +81,9 @@ Please make sure to keep this list up to date when adding and updating ports. :^ | [`nyancat`](nyancat/) | Nyancat | | https://github.com/klange/nyancat | | [`openssh`](openssh/) | OpenSSH | 8.3-9ca7e9c | https://github.com/openssh/openssh-portable | | [`openssl`](openssl/) | OpenSSL | 1.0.2t | https://www.openssl.org/ | +| [`openttd`](openttd/) | OpenTTD | 1.11.0 | https://www.openttd.org/ | +| [`openttd-opengfx`](openttd-opengfx/) | OpenGFX graphics for OpenTTD | 0.6.1 | https://www.openttd.org/ | +| [`openttd-opensfx`](openttd-opensfx/) | OpenSFX audio files for OpenTTD | 1.0.1 | https://www.openttd.org/ | | [`oksh`](oksh/) | oksh | 6.8.1 | https://github.com/ibara/oksh | | [`patch`](patch/) | patch (OpenBSD) | 6.6 | https://github.com/ibara/libpuffy | | [`pcre`](pcre/) | Perl-compatible Regular Expressions (PCRE) | 8.44 | https://www.pcre.org/ | diff --git a/Ports/openttd-opengfx/package.sh b/Ports/openttd-opengfx/package.sh new file mode 100755 index 0000000000..5a31b90612 --- /dev/null +++ b/Ports/openttd-opengfx/package.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env -S bash ../.port_include.sh +port=openttd-opengfx +version=0.6.1 +workdir=. +files="https://cdn.openttd.org/opengfx-releases/${version}/opengfx-${version}-all.zip opengfx-${version}-all.zip c694a112cd508d9c8fdad1b92bde05e7c48b14d66bad0c3999e443367437e37e" +auth_type=sha256 + +build() { + # The ZIP file we downloaded contains a tarball. + run_nocd tar xf opengfx-${version}.tar +} + +install() { + run_nocd mkdir -p ${SERENITY_INSTALL_ROOT}/usr/local/share/games/openttd/baseset/ + run_nocd cp -a opengfx-${version}/* ${SERENITY_INSTALL_ROOT}/usr/local/share/games/openttd/baseset/ +} diff --git a/Ports/openttd-opensfx/package.sh b/Ports/openttd-opensfx/package.sh new file mode 100755 index 0000000000..0d4e0c4a5d --- /dev/null +++ b/Ports/openttd-opensfx/package.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env -S bash ../.port_include.sh +port=openttd-opensfx +version=1.0.1 +workdir=. +files="https://cdn.openttd.org/opensfx-releases/${version}/opensfx-${version}-all.zip opensfx-${version}-all.zip 37b825426f1d690960313414423342733520d08916f512f30f7aaf30910a36c5" +auth_type=sha256 + +build() { + # The ZIP file we downloaded contains a tarball. + run_nocd tar xf opensfx-${version}.tar +} + +install() { + run_nocd mkdir -p ${SERENITY_INSTALL_ROOT}/usr/local/share/games/openttd/baseset/ + run_nocd cp -a opensfx-${version}/* ${SERENITY_INSTALL_ROOT}/usr/local/share/games/openttd/baseset/ +} diff --git a/Ports/openttd/package.sh b/Ports/openttd/package.sh new file mode 100755 index 0000000000..73cc6e9f12 --- /dev/null +++ b/Ports/openttd/package.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env -S bash ../.port_include.sh +port=openttd +version=1.11.0 +auth_type=sha256 +depends="SDL2 libpng zlib xz" +files="https://cdn.openttd.org/openttd-releases/${version}/openttd-${version}-source.tar.xz openttd-${version}.tar.xz 5e65184e07368ba1afa62dbb3e35abaee6c4da6730ff4bc9eb4447d53363c7a8" +useconfigure=true +configopts="-DCMAKE_TOOLCHAIN_FILE=$SERENITY_ROOT/Toolchain/CMake/CMakeToolchain.txt" + +configure() { + host_env + mkdir -p $workdir/host-build + ( + cd $workdir/host-build + cmake .. -DOPTION_TOOLS_ONLY=1 + ) + + target_env + mkdir -p $workdir/build + ( + cd $workdir/build + cmake .. $configopts -DHOST_BINARY_DIR=$(pwd)/../host-build + ) +} + +build() { + host_env + ( + cd $workdir/host-build + make $makeopts + ) + + target_env + ( + cd $workdir/build + make $makeopts + ) +} + +install() { + ( + cd $workdir/build + make install + ) + + ln -sf /usr/local/games/openttd $DESTDIR/usr/local/bin/openttd +} diff --git a/Ports/openttd/patches/build-fixes.patch b/Ports/openttd/patches/build-fixes.patch new file mode 100644 index 0000000000..f8a1e91e73 --- /dev/null +++ b/Ports/openttd/patches/build-fixes.patch @@ -0,0 +1,116 @@ +diff -Naur openttd-1.11.0/cmake/CompileFlags.cmake openttd-1.11.0.serenity/cmake/CompileFlags.cmake +--- openttd-1.11.0/cmake/CompileFlags.cmake 2021-04-01 14:33:44.000000000 +0200 ++++ openttd-1.11.0.serenity/cmake/CompileFlags.cmake 2021-04-19 19:30:33.457232215 +0200 +@@ -154,7 +154,7 @@ + message(FATAL_ERROR "No warning flags are set for this compiler yet; please consider creating a Pull Request to add support for this compiler.") + endif() + +- if(NOT WIN32) ++ if(NOT WIN32 AND NOT SERENITYOS) + # rdynamic is used to get useful stack traces from crash reports. + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic") + endif() +diff -Naur openttd-1.11.0/src/network/core/address.cpp openttd-1.11.0.serenity/src/network/core/address.cpp +--- openttd-1.11.0/src/network/core/address.cpp 2021-04-01 14:33:44.000000000 +0200 ++++ openttd-1.11.0.serenity/src/network/core/address.cpp 2021-04-19 19:30:33.457232215 +0200 +@@ -372,7 +372,7 @@ + DEBUG(net, 3, "[%s] could not set reusable %s sockets for port %s: %s", type, family, address, strerror(errno)); + } + +-#ifndef __OS2__ ++#if !defined(__OS2__) && !defined(__serenity__) + if (runp->ai_family == AF_INET6 && + setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&on, sizeof(on)) == -1) { + DEBUG(net, 3, "[%s] could not disable IPv4 over IPv6 on port %s: %s", type, address, strerror(errno)); +diff -Naur openttd-1.11.0/src/network/core/host.cpp openttd-1.11.0.serenity/src/network/core/host.cpp +--- openttd-1.11.0/src/network/core/host.cpp 2021-04-01 14:33:44.000000000 +0200 ++++ openttd-1.11.0.serenity/src/network/core/host.cpp 2021-04-19 19:30:33.457232215 +0200 +@@ -147,6 +147,7 @@ + + static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // !GETIFADDRS implementation + { ++#ifndef __serenity__ + SOCKET sock = socket(AF_INET, SOCK_DGRAM, 0); + if (sock == INVALID_SOCKET) return; + +@@ -183,6 +184,7 @@ + } + + closesocket(sock); ++#endif + } + #endif /* all NetworkFindBroadcastIPsInternals */ + +diff -Naur openttd-1.11.0/src/network/core/os_abstraction.h openttd-1.11.0.serenity/src/network/core/os_abstraction.h +--- openttd-1.11.0/src/network/core/os_abstraction.h 2021-04-01 14:33:44.000000000 +0200 ++++ openttd-1.11.0.serenity/src/network/core/os_abstraction.h 2021-04-19 19:30:33.457232215 +0200 +@@ -59,13 +59,14 @@ + # include + # include + # include ++# include + # include + # include + # include + # include + /* According to glibc/NEWS, appeared in glibc-2.3. */ + # if !defined(__sgi__) && !defined(SUNOS) && !defined(__INNOTEK_LIBC__) \ +- && !(defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)) && !defined(__dietlibc__) && !defined(HPUX) ++ && !(defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)) && !defined(__dietlibc__) && !defined(HPUX) && !defined(__serenity__) + /* If for any reason ifaddrs.h does not exist on your system, comment out + * the following two lines and an alternative way will be used to fetch + * the list of IPs from the system. */ +diff -Naur openttd-1.11.0/src/os/unix/unix.cpp openttd-1.11.0.serenity/src/os/unix/unix.cpp +--- openttd-1.11.0/src/os/unix/unix.cpp 2021-04-01 14:33:44.000000000 +0200 ++++ openttd-1.11.0.serenity/src/os/unix/unix.cpp 2021-04-19 19:30:33.457232215 +0200 +@@ -42,9 +42,11 @@ + # define HAS_SYSCTL + #endif + ++#ifndef __serenity__ + #ifdef HAS_STATVFS + #include + #endif ++#endif + + #ifdef HAS_SYSCTL + #include +@@ -84,7 +86,7 @@ + + if (statfs(path, &s) != 0) return false; + free = (uint64)s.f_bsize * s.f_bavail; +-#elif defined(HAS_STATVFS) ++#elif defined(HAS_STATVFS) && !defined(__serenity__) + struct statvfs s; + + if (statvfs(path, &s) != 0) return false; +diff -Naur openttd-1.11.0/src/stdafx.h openttd-1.11.0.serenity/src/stdafx.h +--- openttd-1.11.0/src/stdafx.h 2021-04-01 14:33:44.000000000 +0200 ++++ openttd-1.11.0.serenity/src/stdafx.h 2021-04-19 20:08:30.758187723 +0200 +@@ -28,7 +28,7 @@ + # define TROUBLED_INTS + #endif + +-#if defined(__HAIKU__) || defined(__CYGWIN__) ++#if defined(__HAIKU__) || defined(__CYGWIN__) || defined(__serenity__) + # include /* strncasecmp */ + #endif + +@@ -107,7 +107,7 @@ + # define strcasecmp stricmp + #endif + +-#if defined(SUNOS) || defined(HPUX) || defined(__CYGWIN__) ++#if defined(SUNOS) || defined(HPUX) || defined(__CYGWIN__) || defined(__serenity__) + # include + #endif + +@@ -307,7 +307,7 @@ + typedef unsigned char byte; + + /* This is already defined in unix, but not in QNX Neutrino (6.x) or Cygwin. */ +-#if (!defined(UNIX) && !defined(__HAIKU__)) || defined(__QNXNTO__) || defined(__CYGWIN__) ++#if (!defined(UNIX) && !defined(__HAIKU__)) || defined(__QNXNTO__) || defined(__CYGWIN__) || defined(__serenity__) + typedef unsigned int uint; + #endif + diff --git a/Ports/openttd/patches/memory.patch b/Ports/openttd/patches/memory.patch new file mode 100644 index 0000000000..68729bd13a --- /dev/null +++ b/Ports/openttd/patches/memory.patch @@ -0,0 +1,22 @@ +diff -Naur openttd-1.11.0/src/spritecache.cpp openttd-1.11.0.serenity/src/spritecache.cpp +--- openttd-1.11.0/src/spritecache.cpp 2021-04-01 14:33:44.000000000 +0200 ++++ openttd-1.11.0.serenity/src/spritecache.cpp 2021-04-18 21:03:15.916430052 +0200 +@@ -915,6 +915,7 @@ + /* Remember 'target_size' from the previous allocation attempt, so we do not try to reach the target_size multiple times in case of failure. */ + static uint last_alloc_attempt = 0; + ++#ifndef __serenity__ + if (_spritecache_ptr == nullptr || (_allocated_sprite_cache_size != target_size && target_size != last_alloc_attempt)) { + delete[] reinterpret_cast(_spritecache_ptr); + +@@ -950,6 +951,10 @@ + ScheduleErrorMessage(msg); + } + } ++#else ++ _allocated_sprite_cache_size = target_size / 5; ++ _spritecache_ptr = reinterpret_cast(new byte[_allocated_sprite_cache_size]); ++#endif + + /* A big free block */ + _spritecache_ptr->size = (_allocated_sprite_cache_size - sizeof(MemBlock)) | S_FREE_MASK; diff --git a/Ports/openttd/patches/rdtsc.patch b/Ports/openttd/patches/rdtsc.patch new file mode 100644 index 0000000000..24f85448f0 --- /dev/null +++ b/Ports/openttd/patches/rdtsc.patch @@ -0,0 +1,12 @@ +diff -Naur openttd-1.11.0/src/cpu.cpp openttd-1.11.0.serenity/src/cpu.cpp +--- openttd-1.11.0/src/cpu.cpp 2021-04-22 01:14:21.038920133 +0200 ++++ openttd-1.11.0.serenity/src/cpu.cpp 2021-04-22 01:13:56.638440518 +0200 +@@ -40,7 +40,7 @@ + #endif + + /* rdtsc for all other *nix-en (hopefully). Use GCC syntax */ +-#if (defined(__i386__) || defined(__x86_64__)) && !defined(RDTSC_AVAILABLE) ++#if (defined(__i386__) || defined(__x86_64__)) && !defined(__serenity__) && !defined(RDTSC_AVAILABLE) + uint64 ottd_rdtsc() + { + uint32 high, low; diff --git a/Ports/openttd/patches/sighandler.patch b/Ports/openttd/patches/sighandler.patch new file mode 100644 index 0000000000..b9a2c3d38e --- /dev/null +++ b/Ports/openttd/patches/sighandler.patch @@ -0,0 +1,12 @@ +diff -Naur openttd-1.11.0/src/os/unix/crashlog_unix.cpp openttd-1.11.0.serenity/src/os/unix/crashlog_unix.cpp +--- openttd-1.11.0/src/os/unix/crashlog_unix.cpp 2021-04-01 14:33:44.000000000 +0200 ++++ openttd-1.11.0.serenity/src/os/unix/crashlog_unix.cpp 2021-04-18 21:40:06.426298674 +0200 +@@ -178,7 +178,7 @@ + /* static */ void CrashLog::InitialiseCrashLog() + { + for (const int *i = _signals_to_handle; i != endof(_signals_to_handle); i++) { +- signal(*i, HandleCrash); ++ //signal(*i, HandleCrash); + } + } + -- cgit v1.2.3