Subject: [PATCH] gnu: packages: games: Add meritous v1.2

From: TakeV <[email-masked]>
Date: Thu, 23 Feb 2023 19:47:13 -0800

Fun game from a while back, decided to package it after I saw the source
was gpl3.

---
 gnu/packages/games.scm                        |  84 ++++++----
 .../patches/meritous-fix-sdl-import.patch     | 143 ++++++++++++++++++
 2 files changed, 195 insertions(+), 32 deletions(-)
 create mode 100644 gnu/packages/patches/meritous-fix-sdl-import.patch

diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index a3d093fa5e..93b3d179e9 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -75,6 +75,7 @@
 ;;; Copyright © 2022 Maxim Cournoyer <[email-masked]>
 ;;; Copyright © 2022 Hendursaga <[email-masked]>
 ;;; Copyright © 2022 Parnikkapore <[email-masked]>
+;;; Copyright © 2023 TakeV <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1643,6 +1644,28 @@ (define-public meandmyshadow
 shadow mimic them to reach blocks you couldn't reach alone.")
     (license license:gpl3+)))
 
+(define-public meritous
+  (package
+    (name "meritous")
+    (version "v12")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "http://www.asceai.net/files/meritous_" version "_src.tar.bz2"))
+              (sha256
+               (base32 "07apyzg1ygwlb1kw4qfs8yncpnn9v7wj8jnfs17w046881i0ici0"))
+              (patches (search-patches "meritous-fix-sdl-import.patch"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? `#f
+       #:phases `(modify-phases %standard-phases
+                           (delete `configure))))
+    (inputs `(("sdl" ,(sdl-union (list sdl sdl-image sdl-mixer)))))
+    (native-inputs pkg-config)
+    (home-page "http://www.asceai.net/meritous/")
+    (synopsis "Action Roguelike game")
+    (description "Meritous is an action-adventure dungeon crawl game.")
+    (license license:gpl3)))
+
 (define-public opensurge
   (package
     (name "opensurge")
@@ -8989,40 +9012,37 @@ (define-public meritous
                 "0n5jm4g0arjllgqmd2crv8h02i6hs3hlh1zyc7ng7yfpg1mbd8p8"))))
     (build-system gnu-build-system)
     (arguments
-     `(#:tests? #f                      ;no test
-       #:make-flags
-       (list "CC=gcc"
-             (string-append "prefix=" (assoc-ref %outputs "out")))
-       #:phases
-       (modify-phases %standard-phases
-         (delete 'configure)
-         (add-after 'unpack 'fix-sdl-path
-           ;; XXX: For some reason, `sdl-config' reports stand-alone SDL
-           ;; directory, not SDL-union provided as an input to the package.
-           ;; We force the latter with "--prefix=" option.
-           (lambda* (#:key inputs #:allow-other-keys)
-             (substitute* "Makefile"
-               (("sdl-config" command)
-                (string-append command " --prefix=" (assoc-ref inputs "sdl"))))
-             #t))
-         (add-after 'unpack 'fix-crash
-           ;; XXX: Songs are not present in the repository, due to licensing
-           ;; issues.  Yet, the game tries to load them, and, since it cannot
-           ;; find them, crashes.  Users cannot add them back, the store being
-           ;; read-only, so we turn off background music altogether.
-           (lambda _
-             (substitute* "src/audio.c"
-               (("PlayBackgroundMusic\\(new_track\\);" all)
-                (string-append "// " all)))
-             #t)))))
-    (native-inputs
-     (list intltool))
-    (inputs
-     `(("sdl" ,(sdl-union (list sdl sdl-image sdl-mixer)))
-       ("zlib" ,zlib)))
+     `(#:tests? #f ;no test
+       #:make-flags (list "CC=gcc"
+                          (string-append "prefix="
+                                         (assoc-ref %outputs "out")))
+       #:phases (modify-phases %standard-phases
+                  (delete 'configure)
+                  (add-after 'unpack 'fix-sdl-path
+                    ;; XXX: For some reason, `sdl-config' reports stand-alone SDL
+                    ;; directory, not SDL-union provided as an input to the package.
+                    ;; We force the latter with "--prefix=" option.
+                    (lambda* (#:key inputs #:allow-other-keys)
+                      (substitute* "Makefile"
+                        (("sdl-config" command)
+                         (string-append command " --prefix="
+                                        (assoc-ref inputs "sdl")))) #t))
+                  (add-after 'unpack 'fix-crash
+                    ;; XXX: Songs are not present in the repository, due to licensing
+                    ;; issues.  Yet, the game tries to load them, and, since it cannot
+                    ;; find them, crashes.  Users cannot add them back, the store being
+                    ;; read-only, so we turn off background music altogether.
+                    (lambda _
+                      (substitute* "src/audio.c"
+                        (("PlayBackgroundMusic\\(new_track\\);" all)
+                         (string-append "// " all))) #t)))))
+    (native-inputs (list intltool))
+    (inputs `(("sdl" ,(sdl-union (list sdl sdl-image sdl-mixer)))
+              ("zlib" ,zlib)))
     (home-page "https://gitlab.com/meritous/meritous")
     (synopsis "Action-adventure dungeon crawl game")
-    (description "Far below the surface of the planet is a place of limitless
+    (description
+     "Far below the surface of the planet is a place of limitless
 power.  Those that seek to control such a utopia will soon bring an end to
 themselves.  Seeking an end to the troubles that plague him, PSI user Merit
 journeys into the hallowed Orcus Dome in search of answers.
diff --git a/gnu/packages/patches/meritous-fix-sdl-import.patch b/gnu/packages/patches/meritous-fix-sdl-import.patch
new file mode 100644
index 0000000000..9f47199bd6
--- /dev/null
+++ b/gnu/packages/patches/meritous-fix-sdl-import.patch
@@ -0,0 +1,143 @@
+From 53ce1153924061b52b2892a730e1ffa71b0b6b2b Mon Sep 17 00:00:00 2001
+From: TakeV <disroot.org>
+Date: Thu, 23 Feb 2023 13:53:12 -0800
+Subject: [PATCH] Fix SDL paths for guix build
+
+---
+ Makefile        | 2 +-
+ src/audio.c     | 4 ++--
+ src/boss.c      | 2 +-
+ src/demon.c     | 4 ++--
+ src/ending.c    | 2 +-
+ src/gamemap.c   | 2 +-
+ src/help.c      | 2 +-
+ src/levelblit.c | 4 ++--
+ src/save.c      | 2 +-
+ 9 files changed, 12 insertions(+), 12 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index c48e460..d8f4fcd 100755
+--- a/Makefile
++++ b/Makefile
+@@ -18,7 +18,7 @@
+ #   You should have received a copy of the GNU General Public License
+ #   along with Meritous.  If not, see <http://www.gnu.org/licenses/>.
+ #
+-LDFLAGS = `sdl-config --libs` -lSDL_image -lSDL_mixer -lz
++LDFLAGS = `sdl-config --libs` -lSDL_image -lSDL_mixer -lz -lpthread -lm
+ CCFLAGS = -O2 -Wall `sdl-config --cflags` -g
+ #
+ OBJS = 	src/levelblit.o \
+diff --git a/src/audio.c b/src/audio.c
+index 0e86dd2..d0e8a58 100755
+--- a/src/audio.c
++++ b/src/audio.c
+@@ -23,8 +23,8 @@
+ #include <stdlib.h>
+ #include <math.h>
+ #include <SDL.h>
+-#include <SDL_image.h>
+-#include <SDL_mixer.h>
++#include <SDL/SDL_image.h>
++#include <SDL/SDL_mixer.h>
+ #include <string.h>
+ 
+ #include "levelblit.h"
+diff --git a/src/boss.c b/src/boss.c
+index a1423cd..89e192a 100755
+--- a/src/boss.c
++++ b/src/boss.c
+@@ -25,7 +25,7 @@
+ #include <math.h>
+ #include <time.h>
+ #include <SDL.h>
+-#include <SDL_image.h>
++#include <SDL/SDL_image.h>
+ 
+ #include "levelblit.h"
+ #include "mapgen.h"
+diff --git a/src/demon.c b/src/demon.c
+index e69ea70..8e4fd5e 100755
+--- a/src/demon.c
++++ b/src/demon.c
+@@ -22,8 +22,8 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <math.h>
+-#include <SDL.h>
+-#include <SDL_image.h>
++#include <SDL/SDL.h>
++#include <SDL/SDL_image.h>
+ #include <assert.h>
+ 
+ #include "levelblit.h"
+diff --git a/src/ending.c b/src/ending.c
+index d759ab1..763d3e9 100755
+--- a/src/ending.c
++++ b/src/ending.c
+@@ -23,7 +23,7 @@
+ #include <stdlib.h>
+ #include <math.h>
+ #include <SDL.h>
+-#include <SDL_image.h>
++#include <SDL/SDL_image.h>
+ #include <assert.h>
+ 
+ #include "levelblit.h"
+diff --git a/src/gamemap.c b/src/gamemap.c
+index 7c13bed..59cd47e 100755
+--- a/src/gamemap.c
++++ b/src/gamemap.c
+@@ -23,7 +23,7 @@
+ #include <stdlib.h>
+ #include <math.h>
+ #include <SDL.h>
+-#include <SDL_image.h>
++#include <SDL/SDL_image.h>
+ 
+ #include "levelblit.h"
+ #include "mapgen.h"
+diff --git a/src/help.c b/src/help.c
+index cecc3fd..d47aa5f 100755
+--- a/src/help.c
++++ b/src/help.c
+@@ -23,7 +23,7 @@
+ #include <stdlib.h>
+ #include <math.h>
+ #include <SDL.h>
+-#include <SDL_image.h>
++#include <SDL/SDL_image.h>
+ #include <string.h>
+ 
+ #include "levelblit.h"
+diff --git a/src/levelblit.c b/src/levelblit.c
+index edd3a35..9c43ec6 100755
+--- a/src/levelblit.c
++++ b/src/levelblit.c
+@@ -24,8 +24,8 @@
+ #include <string.h>
+ #include <math.h>
+ #include <time.h>
+-#include <SDL.h>
+-#include <SDL_image.h>
++#include <SDL/SDL.h>
++#include <SDL/SDL_image.h>
+ #include <assert.h>
+ 
+ #include "mapgen.h"
+diff --git a/src/save.c b/src/save.c
+index d7818d9..5b1a881 100755
+--- a/src/save.c
++++ b/src/save.c
+@@ -23,7 +23,7 @@
+ #include <stdlib.h>
+ #include <math.h>
+ #include <SDL.h>
+-#include <SDL_image.h>
++#include <SDL/SDL_image.h>
+ #include <zlib.h>
+ 
+ #include "levelblit.h"
+-- 
+2.39.2
+

base-commit: 5d10644371abd54d0edcd638691113f0a92de743
-- 
2.39.2