gnu: Add itpp.
[jackhill/guix/guix.git] / gnu / packages / sdl.scm
index 4e9ebfb..5103aee 100644 (file)
@@ -1,7 +1,9 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013 David Thompson <dthompson2@worcester.edu>
+;;; Copyright © 2013, 2015, 2017 David Thompson <dthompson2@worcester.edu>
 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
-;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
+;;; Copyright © 2015, 2017 Sou Bunnbu <iyzsong@member.fsf.org>
+;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
+;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages sdl)
+  #:use-module (ice-9 match)
   #:use-module (gnu packages)
   #:use-module ((guix licenses) #:hide (freetype))
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system trivial)
+  #:use-module (gnu packages audio)
+  #:use-module (gnu packages fcitx)
   #:use-module (gnu packages fontutils)
+  #:use-module (gnu packages glib)
   #:use-module (gnu packages guile)
+  #:use-module (gnu packages ibus)
   #:use-module (gnu packages image)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages mp3)
   #:use-module (gnu packages gl)
   #:use-module (gnu packages xiph)
   #:use-module (gnu packages xorg)
-  #:export (sdl
-            sdl2
-            libmikmod
-            sdl-gfx
-            sdl-image
-            sdl-mixer
-            sdl-net
-            sdl-ttf))
+  #:export (sdl-union))
 
-(define sdl
+(define-public sdl
   (package
     (name "sdl")
     (version "1.2.15")
     (source (origin
              (method url-fetch)
              (uri
-              (string-append "http://libsdl.org/release/SDL-"
+              (string-append "https://libsdl.org/release/SDL-"
                              version ".tar.gz"))
              (sha256
               (base32
                "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"))
-             (patches (list (search-patch "sdl-libx11-1.6.patch")))))
+             (patches (search-patches "sdl-libx11-1.6.patch"))))
     (build-system gnu-build-system)
     (arguments
      '(;; Explicitly link against shared libraries instead of dlopening them.
     (description "Simple DirectMedia Layer is a cross-platform development
 library designed to provide low level access to audio, keyboard, mouse,
 joystick, and graphics hardware.")
-    (home-page "http://libsdl.org/")
+    (home-page "https://libsdl.org/")
     (license lgpl2.1)))
 
-(define sdl2
+(define-public sdl2
   (package (inherit sdl)
     (name "sdl2")
-    (version "2.0.3")
+    (version "2.0.5")
     (source (origin
              (method url-fetch)
              (uri
-              (string-append "http://libsdl.org/release/SDL2-"
+              (string-append "https://libsdl.org/release/SDL2-"
                              version ".tar.gz"))
              (sha256
               (base32
-               "0369ngvb46x6c26h8zva4x22ywgy6mvn0wx87xqwxg40pxm9m9m5"))))
+               "11c75qj1qxmx67iwkvf9z4x69phk301pdn86zzr6jncnap7kh824"))))
+    (inputs
+     ;; SDL2 needs to be built with ibus support otherwise some systems
+     ;; experience a bug where input events are doubled.
+     ;;
+     ;; For more information, see: https://dev.solus-project.com/T1721
+     (append `(("dbus" ,dbus)
+               ("fcitx" ,fcitx) ; helps with CJK input
+               ("glib" ,glib)
+               ("ibus" ,ibus))
+             (package-inputs sdl)))
     (license bsd-3)))
 
-(define libmikmod
+(define-public libmikmod
   (package
     (name "libmikmod")
-    (version "3.3.7")
+    (version "3.3.10")
     (source (origin
              (method url-fetch)
              (uri (string-append "mirror://sourceforge/mikmod/libmikmod/"
                                  version "/libmikmod-" version ".tar.gz"))
              (sha256
               (base32
-               "18nrkf5l50hfg0y50yxr7bvik9f002lhn8c00nbcp6dgm5011x2c"))))
+               "0j7g4jpa2zgzw7x6s3rldypa7zlwjvn97rwx0sylx1iihhlzbcq0"))))
     (build-system gnu-build-system)
     (arguments
      ;; By default, libmikmod tries to dlopen libasound etc., which won't work
@@ -127,7 +137,7 @@ system, such as sound redirection over the network.")
     (license lgpl2.1)
     (home-page "http://mikmod.sourceforge.net/")))
 
-(define sdl-gfx
+(define-public sdl-gfx
   (package
     (name "sdl-gfx")
     (version "2.0.24")
@@ -151,14 +161,14 @@ other supporting functions for SDL.")
     ;; MIPS, at least.
     (supported-systems '("i686-linux" "x86_64-linux"))))
 
-(define sdl-image
+(define-public sdl-image
   (package
     (name "sdl-image")
     (version "1.2.12")
     (source (origin
              (method url-fetch)
              (uri
-              (string-append "http://www.libsdl.org/projects/SDL_image/release/SDL_image-"
+              (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL_image-"
                              version ".tar.gz"))
              (sha256
               (base32
@@ -171,8 +181,6 @@ other supporting functions for SDL.")
                            "--disable-tif-shared"
                            "--disable-webp-shared")))
     (native-inputs `(("pkg-config" ,pkg-config)))
-    ;; FIXME: Add webp
-    ;;
     ;; libjpeg, libpng, and libtiff are propagated inputs because the
     ;; SDL_image headers include the headers of these libraries.  SDL is a
     ;; propagated input because the pkg-config file refers to SDL's pkg-config
@@ -180,22 +188,23 @@ other supporting functions for SDL.")
     (propagated-inputs `(("sdl" ,sdl)
                          ("libjpeg" ,libjpeg)
                          ("libpng" ,libpng)
-                         ("libtiff" ,libtiff)))
+                         ("libtiff" ,libtiff)
+                         ("libwebp" ,libwebp)))
     (synopsis "SDL image loading library")
     (description "SDL_image is an image file loading library for SDL that
 supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF,
 WEBP, XCF, XPM, and XV.")
-    (home-page "http://www.libsdl.org/projects/SDL_image/")
+    (home-page "https://www.libsdl.org/projects/SDL_image/")
     (license zlib)))
 
-(define sdl-mixer
+(define-public sdl-mixer
   (package
     (name "sdl-mixer")
     (version "1.2.12")
     (source (origin
               (method url-fetch)
               (uri
-               (string-append "http://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-"
+               (string-append "https://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-"
                               version ".tar.gz"))
               (sha256
                (base32
@@ -214,7 +223,8 @@ WEBP, XCF, XPM, and XV.")
     (inputs `(("libvorbis" ,libvorbis)
               ("libflac" ,flac)
               ("libmad" ,libmad)
-              ("libmikmod" ,libmikmod)))
+              ("libmikmod" ,libmikmod)
+              ("libmodplug" ,libmodplug)))
     ;; FIXME: Add libfluidsynth
     (propagated-inputs `(("sdl" ,sdl)))
     (synopsis "SDL multi-channel audio mixer library")
@@ -222,17 +232,17 @@ WEBP, XCF, XPM, and XV.")
 It supports any number of simultaneously playing channels of 16 bit stereo
 audio, plus a single channel of music.  Supported format include FLAC, MOD,
 MIDI, Ogg Vorbis, and MP3.")
-    (home-page "http://www.libsdl.org/projects/SDL_mixer/")
+    (home-page "https://www.libsdl.org/projects/SDL_mixer/")
     (license zlib)))
 
-(define sdl-net
+(define-public sdl-net
   (package
     (name "sdl-net")
     (version "1.2.8")
     (source (origin
               (method url-fetch)
               (uri
-               (string-append "http://www.libsdl.org/projects/SDL_net/release/SDL_net-"
+               (string-append "https://www.libsdl.org/projects/SDL_net/release/SDL_net-"
                               version ".tar.gz"))
               (sha256
                (base32
@@ -243,17 +253,17 @@ MIDI, Ogg Vorbis, and MP3.")
     (synopsis "SDL networking library")
     (description "SDL_net is a small, cross-platform networking library for
 SDL.")
-    (home-page "http://www.libsdl.org/projects/SDL_net/")
+    (home-page "https://www.libsdl.org/projects/SDL_net/")
     (license zlib)))
 
-(define sdl-ttf
+(define-public sdl-ttf
   (package
     (name "sdl-ttf")
     (version "2.0.11")
     (source (origin
              (method url-fetch)
              (uri
-              (string-append "http://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
+              (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
                              version ".tar.gz"))
              (sha256
               (base32
@@ -265,10 +275,13 @@ SDL.")
     (native-inputs `(("pkg-config" ,pkg-config)))
     (synopsis "SDL TrueType font library")
     (description "SDL_ttf is a TrueType font rendering library for SDL.")
-    (home-page "http://www.libsdl.org/projects/SDL_ttf/")
+    (home-page "https://www.libsdl.org/projects/SDL_ttf/")
     (license zlib)))
 
-(define sdl-union
+(define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
+                                               sdl-image sdl-mixer)))
+  "Return 'sdl-union' package which is a union of PACKAGES.
+If PACKAGES are not specified, all SDL packages are used."
   (package
     (name "sdl-union")
     (version (package-version sdl))
@@ -283,12 +296,10 @@ SDL.")
                      (((names . directories) ...)
                       (union-build (assoc-ref %outputs "out")
                                    directories))))))
-    (inputs `(("sdl" ,sdl)
-              ("sdl-gfx" ,sdl-gfx)
-              ("sdl-image" ,sdl-image)
-              ("sdl-mixer" ,sdl-mixer)
-              ("sdl-ttf" ,sdl-ttf)))
-    (synopsis "Union of all SDL libraries")
+    (inputs (map (lambda (package)
+                   (list (package-name package) package))
+                 packages))
+    (synopsis "Union of SDL libraries")
     (description
      "A union of SDL and its extension libraries.  A union is required because
 sdl-config assumes that all of the headers and libraries are in the same
@@ -296,10 +307,71 @@ directory.")
     (home-page (package-home-page sdl))
     (license (package-license sdl))))
 
+(define (propagated-inputs-with-sdl2 package)
+  "Replace the \"sdl\" propagated input of PACKAGE with SDL2."
+  (map (match-lambda
+         (("sdl" _)
+          `("sdl2" ,sdl2))
+         (other other))
+       (package-propagated-inputs package)))
+
+(define-public sdl2-image
+  (package (inherit sdl-image)
+    (name "sdl2-image")
+    (version "2.0.1")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL2_image-"
+                              version ".tar.gz"))
+              (sha256
+               (base32
+                "0r3z1l7fdn76qkpy7snpkcjqz8dkv2zp6lsqpq25q4m5xsyaygis"))))
+    (propagated-inputs
+     (propagated-inputs-with-sdl2 sdl-image))))
+
+(define-public sdl2-mixer
+  (package (inherit sdl-mixer)
+    (name "sdl2-mixer")
+    (version "2.0.1")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append "http://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-"
+                              version ".tar.gz"))
+              (modules '((guix build utils)))
+              (snippet
+               ;; Remove bundled libraries.
+               '(delete-file-recursively "external"))
+              (sha256
+               (base32
+                "0pv9jzjpcjlbiaybvwrb4avmv46qk7iqxlnqrd2dfj82c4mgc92s"))))
+    (propagated-inputs
+     (propagated-inputs-with-sdl2 sdl-mixer))))
+
+(define-public sdl2-ttf
+  (package (inherit sdl-ttf)
+    (name "sdl2-ttf")
+    (version "2.0.14")
+    (source (origin
+             (method url-fetch)
+             (uri
+              (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-"
+                             version ".tar.gz"))
+             (modules '((guix build utils)))
+             (snippet
+              ;; Remove bundled libraries.
+              '(delete-file-recursively "external"))
+             (sha256
+              (base32
+               "0xljwcpvd2knrjdfag5b257xqayplz55mqlszrqp0kpnphh5xnrl"))))
+    (propagated-inputs
+     (propagated-inputs-with-sdl2 sdl-ttf))))
+
 (define-public guile-sdl
   (package
     (name "guile-sdl")
-    (version "0.5.1")
+    (version "0.5.2")
     (source (origin
               (method url-fetch)
               (uri
@@ -307,7 +379,7 @@ directory.")
                               version ".tar.xz"))
               (sha256
                (base32
-                "126n4rd0ydh6i2s11ari5k85iivradlf12zq13b34shf9k1wn5am"))))
+                "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
     (build-system gnu-build-system)
     (native-inputs
      `(("pkg-config" ,pkg-config)
@@ -316,7 +388,7 @@ directory.")
        ("libjpeg" ,libjpeg)))
     (inputs
      `(("guile" ,guile-2.0)
-       ("sdl-union" ,sdl-union)))
+       ("sdl-union" ,(sdl-union))))
     (arguments
      '(#:configure-flags
        (list (string-append "--with-sdl-prefix="
@@ -332,7 +404,13 @@ directory.")
                   (string-append (assoc-ref inputs "libjpeg") "/lib"))
           ;; Change the site directory /site/2.0 like Guile expects.
           (substitute* "build-aux/guile-baux/re-prefixed-site-dirs"
-            (("\"/site\"") "\"/site/2.0\"")))
+            (("\"/site\"") "\"/site/2.0\""))
+
+          ;; Skip tests that rely on sound support, which is unavailable in
+          ;; the build environment.
+          (substitute* "test/Makefile.in"
+            (("HAVE_MIXER = .*$")
+             "HAVE_MIXER = 0\n")))
         (alist-cons-before
          'check 'start-xorg-server
          (lambda* (#:key inputs #:allow-other-keys)
@@ -347,3 +425,43 @@ Layer (SDL).  With them, Guile programmers can have easy access to graphics,
 sound and device input (keyboards, joysticks, mice, etc.).")
     (home-page "http://gnu.org/s/guile-sdl")
     (license gpl3+)))
+
+(define-public guile-sdl2
+  (package
+    (name "guile-sdl2")
+    (version "0.2.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "https://files.dthompson.us/guile-sdl2/guile-sdl2-"
+                    version ".tar.gz"))
+              (sha256
+               (base32
+                "0yq9lsl17cdvj77padvpk3jcw2g6g0pck9jrchc7n2767rrc012b"))))
+    (build-system gnu-build-system)
+    (arguments
+     '(#:make-flags '("GUILE_AUTO_COMPILE=0")
+       #:configure-flags
+       (list (string-append "--with-libsdl2-prefix="
+                            (assoc-ref %build-inputs "sdl2"))
+             (string-append "--with-libsdl2-image-prefix="
+                            (assoc-ref %build-inputs "sdl2-image"))
+             (string-append "--with-libsdl2-ttf-prefix="
+                            (assoc-ref %build-inputs "sdl2-ttf"))
+             (string-append "--with-libsdl2-mixer-prefix="
+                            (assoc-ref %build-inputs "sdl2-mixer")))))
+    (native-inputs
+     `(("guile" ,guile-2.0)
+       ("pkg-config" ,pkg-config)))
+    (inputs
+     `(("sdl2" ,sdl2)
+       ("sdl2-image" ,sdl2-image)
+       ("sdl2-mixer" ,sdl2-mixer)
+       ("sdl2-ttf" ,sdl2-ttf)))
+    (synopsis "Guile bindings for SDL2")
+    (home-page "https://dthompson.us/projects/guile-sdl2.html")
+    (description
+     "Guile-SDL2 provides Guile Scheme bindings for the SDL2 C shared library.
+The bindings are written in pure Scheme using Guile's foreign function
+interface.")
+    (license lgpl3+)))