From a83c6a6471b0f1950ab5c53acb278e1b88d51c11 Mon Sep 17 00:00:00 2001
From: Eric Bavier <bavier@member.fsf.org>
Date: Thu, 12 Jun 2014 23:54:44 -0500
Subject: [PATCH] gnu: Add pingus.

* gnu/packages/games.scm (pingus): New variable.
* gnu/packages/patches/pingus-sdl-libs-config.patch: New patch.
* gnu-system.am (dist_patch_DATA): Add it.
---
 gnu-system.am                                 |  1 +
 gnu/packages/games.scm                        | 50 +++++++++++++++++++
 .../patches/pingus-sdl-libs-config.patch      | 21 ++++++++
 3 files changed, 72 insertions(+)
 create mode 100644 gnu/packages/patches/pingus-sdl-libs-config.patch

diff --git a/gnu-system.am b/gnu-system.am
index fbe031a7ea4..653b99a93de 100644
--- a/gnu-system.am
+++ b/gnu-system.am
@@ -338,6 +338,7 @@ dist_patch_DATA =						\
   gnu/packages/patches/perl-no-sys-dirs.patch			\
   gnu/packages/patches/perl-tk-x11-discover.patch		\
   gnu/packages/patches/petsc-fix-threadcomm.patch		\
+  gnu/packages/patches/pingus-sdl-libs-config.patch		\
   gnu/packages/patches/plotutils-libpng-jmpbuf.patch		\
   gnu/packages/patches/procps-make-3.82.patch			\
   gnu/packages/patches/pybugz-encode-error.patch		\
diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index 0e5616cd59b..ce75e6d17c4 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2013 John Darrington <jmd@gnu.org>
 ;;; Copyright © 2014 David Thompson <dthompson2@worcester.edu>
+;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -21,6 +22,8 @@ (define-module (gnu packages games)
   #:use-module (guix licenses)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages boost)
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages gl)
   #:use-module (gnu packages glib)
@@ -28,6 +31,7 @@ (define-module (gnu packages games)
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages guile)
   #:use-module (gnu packages libcanberra)
+  #:use-module (gnu packages libpng)
   #:use-module (gnu packages python)
   #:use-module (gnu packages readline)
   #:use-module (gnu packages xorg)
@@ -158,3 +162,49 @@ (define input-directories
 them, called Jean Raymond, found an old church in which to hide, not knowing
 that beneath its ruins lay buried an ancient evil.")
     (license gpl3+)))
+
+(define-public pingus
+  (package
+    (name "pingus")
+    (version "0.7.6")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "http://pingus.googlecode.com/files/pingus-"
+                           version ".tar.bz2"))
+       (sha256
+        (base32
+         "0q34d2k6anzqvb0mf67x85q92lfx9jr71ry13dlp47jx0x9i573m"))
+       (patches (list (search-patch "pingus-sdl-libs-config.patch")))))
+    (build-system gnu-build-system)
+    (native-inputs `(("pkg-config" ,pkg-config)
+                     ("scons" ,scons)))
+    (inputs `(("sdl" ,sdl)
+              ("sdl-image" ,sdl-image)
+              ("sdl-mixer" ,sdl-mixer)
+              ("mesa" ,mesa)
+              ("libpng" ,libpng)
+              ("boost" ,boost)))
+    (arguments
+     '(#:tests? #f                      ;no check target
+       #:phases
+       (alist-delete
+        'configure
+        (alist-replace
+         'install
+         (lambda* (#:key outputs #:allow-other-keys)
+           (zero? (system* "make" "install"
+                           (string-append "PREFIX="
+                                          (assoc-ref outputs "out")))))
+         %standard-phases))))
+    (home-page "http://pingus.seul.org/welcome.html")
+    (synopsis "Lemmings clone")
+    (description
+     "Pingus is a free Lemmings-like puzzle game in which the player takes
+command of a bunch of small animals and has to guide them through levels.
+Since the animals walk on their own, the player can only influence them by
+giving them commands, like build a bridge, dig a hole, or redirect all animals
+in the other direction.  Multiple such commands are necessary to reach the
+level's exit.  The game is presented in a 2D side view.")
+    ;; Some source files are under bsd-3 and gpl2+ licenses.
+    (license gpl3+)))
diff --git a/gnu/packages/patches/pingus-sdl-libs-config.patch b/gnu/packages/patches/pingus-sdl-libs-config.patch
new file mode 100644
index 00000000000..4d695c40db3
--- /dev/null
+++ b/gnu/packages/patches/pingus-sdl-libs-config.patch
@@ -0,0 +1,21 @@
+Do not assume the SDL_image and SLD_mixer libraries are installed at the same
+prefix reported by sdl-config, but instead get flags from the pkg-config files
+installed with these libraries.
+
+--- a/SConscript	2011-12-24 15:46:47.000000000 -0600
++++ b/SConscript	2014-06-12 21:20:45.702668330 -0500
+@@ -199,7 +199,13 @@
+                 self.fatal_error += "  * library 'png' not found\n"
+ 
+     def configure_sdl(self):
+-        if self.conf.CheckMyProgram('sdl-config'):
++        if self.conf.CheckMyProgram('pkg-config'):
++            self.conf.env.ParseConfig("pkg-config --cflags --libs sdl")
++            for sdllib in ['image', 'mixer']:
++                self.conf.env.ParseConfig("pkg-config --cflags --libs SDL_%s" % sdllib)
++                if not self.conf.CheckSDLLib(sdllib):
++                    self.fatal_error += "  * SDL library '%s' not found\n" % sdllib
++        elif self.conf.CheckMyProgram('sdl-config'):
+             self.conf.env.ParseConfig("sdl-config  --cflags --libs | sed 's/-I/-isystem/g'")
+             for sdllib in ['image', 'mixer']:
+                 if not self.conf.CheckSDLLib(sdllib):
-- 
GitLab