From 78f5dc4e7a40eb48410a102aef159a003619bbd0 Mon Sep 17 00:00:00 2001 From: Matteo Pacini Date: Sat, 22 Jun 2024 10:51:40 +0100 Subject: [PATCH] tinyfugue: darwin support --- pkgs/games/tinyfugue/001-darwin-fixes.patch | 27 +++++++++++++++++++++ pkgs/games/tinyfugue/default.nix | 24 ++++++++++++------ 2 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 pkgs/games/tinyfugue/001-darwin-fixes.patch diff --git a/pkgs/games/tinyfugue/001-darwin-fixes.patch b/pkgs/games/tinyfugue/001-darwin-fixes.patch new file mode 100644 index 000000000000..4a65f274f98d --- /dev/null +++ b/pkgs/games/tinyfugue/001-darwin-fixes.patch @@ -0,0 +1,27 @@ +diff --git a/src/malloc.h b/src/malloc.h +index cc4d3bf..bbf78cd 100644 +--- a/src/malloc.h ++++ b/src/malloc.h +@@ -34,6 +34,10 @@ extern int low_memory_warning; + # define realloc(ptr, size) mrealloc(NULL, ptr, size) + # define free(ptr) mfree(NULL, ptr) + #else ++#ifdef __APPLE__ ++ #include ++ #include ++#endif + # define mmalloc(md, size) malloc(size) + # define mcalloc(md, size) calloc(size) + # define mrealloc(md, ptr, size) realloc(ptr, size) +diff --git a/src/tfio.c b/src/tfio.c +index 2cd2103..8640f2b 100644 +--- a/src/tfio.c ++++ b/src/tfio.c +@@ -70,6 +70,7 @@ static void fileputs(const char *str, FILE *fp); + static void filenputs(const char *str, int n, FILE *fp); + static void queueputline(conString *line, TFILE *file); + ++extern void main_loop(void); + + void init_tfio(void) + { diff --git a/pkgs/games/tinyfugue/default.nix b/pkgs/games/tinyfugue/default.nix index 6cb80663bdb7..a10c35f96796 100644 --- a/pkgs/games/tinyfugue/default.nix +++ b/pkgs/games/tinyfugue/default.nix @@ -1,6 +1,11 @@ -{ lib, stdenv, fetchurl, ncurses, zlib -, openssl ? null -, sslSupport ? true +{ + lib, + stdenv, + fetchurl, + ncurses, + zlib, + openssl, + sslSupport ? true, }: assert sslSupport -> openssl != null; @@ -24,11 +29,16 @@ stdenv.mkDerivation rec { sha256 = "12fra2fdwqj6ilv9wdkc33rkj343rdcf5jyff4yiwywlrwaa2l1p"; }; + patches = [ + ./001-darwin-fixes.patch + ]; + configureFlags = optional (!sslSupport) "--disable-ssl"; - buildInputs = - [ ncurses zlib ] - ++ optional sslSupport openssl; + buildInputs = [ + ncurses + zlib + ] ++ optional sslSupport openssl; # Workaround build failure on -fno-common toolchains like upstream # gcc-10. Otherwise build fails as: @@ -45,7 +55,7 @@ stdenv.mkDerivation rec { with any type of text MUD. ''; license = licenses.gpl2; - platforms = platforms.linux; + platforms = platforms.linux ++ platforms.darwin; maintainers = [ maintainers.KibaFox ]; }; }