gnu: libdrm: Switch to meson-build-system.
[jackhill/guix/guix.git] / gnu / packages / sdl.scm
index af598ec..8d2a024 100644 (file)
@@ -4,6 +4,10 @@
 ;;; Copyright © 2015, 2017 Sou Bunnbu <iyzsong@member.fsf.org>
 ;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
 ;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2017, 2018, 2019 Rutger Helling <rhelling@mykolab.com>
+;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2019 Kei Kebreau <kkebreau@posteo.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
   #:use-module ((guix licenses) #:hide (freetype))
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix utils)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system haskell)
   #: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 freedesktop)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages guile)
+  #:use-module (gnu packages haskell)
   #:use-module (gnu packages ibus)
   #:use-module (gnu packages image)
   #:use-module (gnu packages linux)
@@ -42,6 +50,7 @@
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages pulseaudio)
   #:use-module (gnu packages gl)
+  #:use-module (gnu packages xdisorg)
   #:use-module (gnu packages xiph)
   #:use-module (gnu packages xorg)
   #:export (sdl-union))
@@ -72,6 +81,8 @@
                            ;; finding the libGL from mesa at runtime.
                            "LDFLAGS=-lGL")
 
+       #:make-flags '("V=1")            ;build verbosely
+
        #:tests? #f)) ; no check target
     (propagated-inputs
      ;; SDL headers include X11 headers.
@@ -83,6 +94,7 @@
               ("glu" ,glu)
               ("alsa-lib" ,alsa-lib)
               ("pulseaudio" ,pulseaudio)))
+    (outputs '("out" "debug"))
     (synopsis "Cross platform game development library")
     (description "Simple DirectMedia Layer is a cross-platform development
 library designed to provide low level access to audio, keyboard, mouse,
@@ -93,7 +105,7 @@ joystick, and graphics hardware.")
 (define-public sdl2
   (package (inherit sdl)
     (name "sdl2")
-    (version "2.0.5")
+    (version "2.0.9")
     (source (origin
              (method url-fetch)
              (uri
@@ -101,7 +113,13 @@ joystick, and graphics hardware.")
                              version ".tar.gz"))
              (sha256
               (base32
-               "11c75qj1qxmx67iwkvf9z4x69phk301pdn86zzr6jncnap7kh824"))))
+               "1c94ndagzkdfqaa838yqg589p1nnqln8mv0hpwfhrkbfczf8cl95"))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments sdl)
+       ((#:configure-flags flags)
+        `(append '("--disable-wayland-shared" "--enable-video-kmsdrm"
+                   "--disable-kmsdrm-shared")
+                 ,flags))))
     (inputs
      ;; SDL2 needs to be built with ibus support otherwise some systems
      ;; experience a bug where input events are doubled.
@@ -110,14 +128,17 @@ joystick, and graphics hardware.")
      (append `(("dbus" ,dbus)
                ("fcitx" ,fcitx) ; helps with CJK input
                ("glib" ,glib)
-               ("ibus" ,ibus))
+               ("ibus" ,ibus)
+               ("libxkbcommon" ,libxkbcommon)
+               ("wayland" ,wayland)
+               ("wayland-protocols" ,wayland-protocols))
              (package-inputs sdl)))
     (license bsd-3)))
 
 (define-public libmikmod
   (package
     (name "libmikmod")
-    (version "3.3.10")
+    (version "3.3.11.1")
     (source (origin
              (method url-fetch)
              (uri (list
@@ -129,7 +150,7 @@ joystick, and graphics hardware.")
                                   version "/libmikmod-" version ".tar.gz")))
              (sha256
               (base32
-               "0j7g4jpa2zgzw7x6s3rldypa7zlwjvn97rwx0sylx1iihhlzbcq0"))))
+               "06bdnhb0l81srdzg6gn2v2ydhhaazza7rshrcj3q8dpqr3gn97dd"))))
     (build-system gnu-build-system)
     (arguments
      ;; By default, libmikmod tries to dlopen libasound etc., which won't work
@@ -157,6 +178,7 @@ system, such as sound redirection over the network.")
                (base32
                 "0ijljhs0v99dj6y27hc10z6qchyp8gdp4199y6jzngy6dzxlzsvw"))))
     (build-system gnu-build-system)
+    (outputs '("out" "debug"))
     (arguments
      `(,@(if (any (cute string-prefix? <> (or (%current-system)
                                               (%current-target-system)))
@@ -184,6 +206,7 @@ other supporting functions for SDL.")
               (base32
                "16an9slbb8ci7d89wakkmyfvp7c0cval8xw4hkg0842nhhlp540b"))))
     (build-system gnu-build-system)
+    (outputs '("out" "debug"))
     (arguments
      ;; Explicitly link against shared libraries instead of dlopening them.
      '(#:configure-flags '("--disable-jpg-shared"
@@ -220,6 +243,7 @@ WEBP, XCF, XPM, and XV.")
                (base32
                 "0alrhqgm40p4c92s26mimg9cm1y7rzr6m0p49687jxd9g6130i0n"))))
     (build-system gnu-build-system)
+    (outputs '("out" "debug"))
     ;; no check target
     ;; use libmad instead of smpeg
     ;; explicitly link against shared libraries instead of dlopening them
@@ -260,6 +284,7 @@ MIDI, Ogg Vorbis, and MP3.")
     (build-system gnu-build-system)
     (propagated-inputs `(("sdl" ,sdl)))
     (native-inputs `(("pkg-config" ,pkg-config)))
+    (outputs '("out" "debug"))
     (synopsis "SDL networking library")
     (description "SDL_net is a small, cross-platform networking library for
 SDL.")
@@ -283,6 +308,7 @@ SDL.")
     (inputs `(("freetype" ,freetype)
               ("mesa" ,mesa)))
     (native-inputs `(("pkg-config" ,pkg-config)))
+    (outputs '("out" "debug"))
     (synopsis "SDL TrueType font library")
     (description "SDL_ttf is a TrueType font rendering library for SDL.")
     (home-page "https://www.libsdl.org/projects/SDL_ttf/")
@@ -305,7 +331,8 @@ If PACKAGES are not specified, all SDL packages are used."
                    (match %build-inputs
                      (((names . directories) ...)
                       (union-build (assoc-ref %outputs "out")
-                                   directories))))))
+                                   directories)
+                      #t)))))
     (inputs (map (lambda (package)
                    (list (package-name package) package))
                  packages))
@@ -325,56 +352,73 @@ directory.")
          (other other))
        (package-propagated-inputs package)))
 
-(define-public sdl2-image
-  (package (inherit sdl-image)
-    (name "sdl2-image")
-    (version "2.0.1")
+(define-public sdl2-gfx
+  (package (inherit sdl-gfx)
+    (name "sdl2-gfx")
+    (version "1.0.4")
     (source (origin
               (method url-fetch)
               (uri
-               (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL2_image-"
+               (string-append "https://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-"
                               version ".tar.gz"))
               (sha256
                (base32
-                "0r3z1l7fdn76qkpy7snpkcjqz8dkv2zp6lsqpq25q4m5xsyaygis"))))
+                "0qk2ax7f7grlxb13ba0ll3zlm8780s7j8fmrhlpxzjgdvldf1q33"))))
+    (propagated-inputs
+     (propagated-inputs-with-sdl2 sdl-gfx))))
+
+(define-public sdl2-image
+  (package (inherit sdl-image)
+    (name "sdl2-image")
+    (version "2.0.4")
+    (source
+     (origin
+       (method url-fetch)
+       (uri
+        (string-append "https://www.libsdl.org/projects/SDL_image/release/"
+                       "SDL2_image-" version ".tar.gz"))
+       (sha256
+        (base32 "1b6f7002bm007y3zpyxb5r6ag0lml51jyvx1pwpj9sq24jfc8kp7"))))
     (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"))))
+    (version "2.0.4")
+    (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 '(begin
+                   ;; Remove bundled libraries.
+                   (delete-file-recursively "external")
+                   #t))
+       (sha256
+        (base32 "0694vsz5bjkcdgfdra6x9fq8vpzrl8m6q96gh58df7065hw5mkxl"))))
     (propagated-inputs
      (propagated-inputs-with-sdl2 sdl-mixer))))
 
 (define-public sdl2-ttf
   (package (inherit sdl-ttf)
     (name "sdl2-ttf")
-    (version "2.0.14")
+    (version "2.0.15")
     (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"))
+             (snippet (begin
+                        ;; Remove bundled libraries.
+                        '(delete-file-recursively "external")
+                        #t))
              (sha256
               (base32
-               "0xljwcpvd2knrjdfag5b257xqayplz55mqlszrqp0kpnphh5xnrl"))))
+               "0cyd48dipc0m399qy8s03lci8b0bpiy8xlkvrm2ia7wcv0dfpv59"))))
     (propagated-inputs
      (propagated-inputs-with-sdl2 sdl-ttf))))
 
@@ -397,38 +441,60 @@ directory.")
        ("xorg-server" ,xorg-server)
        ("libjpeg" ,libjpeg)))
     (inputs
-     `(("guile" ,guile-2.0)
+     `(("guile" ,guile-2.2)
        ("sdl-union" ,(sdl-union))))
     (arguments
      '(#:configure-flags
        (list (string-append "--with-sdl-prefix="
                             (assoc-ref %build-inputs "sdl-union")))
+       #:modules ((ice-9 popen)
+                  (guix build utils)
+                  (guix build gnu-build-system))
+
        #:parallel-build? #f ; parallel build fails
+
        #:phases
-       (alist-cons-before
-        'configure 'fix-env-and-patch
-        (lambda* (#:key inputs #:allow-other-keys)
-          (setenv "GUILE_AUTO_COMPILE" "0")
-          ;; SDL_image needs to dlopen libjpeg in the test suite.
-          (setenv "LD_LIBRARY_PATH"
-                  (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\""))
+       (modify-phases %standard-phases
+         (add-before 'configure 'fix-env-and-patch
+           (lambda* (#:key inputs #:allow-other-keys)
+             (setenv "GUILE_AUTO_COMPILE" "0")
+             ;; SDL_image needs to dlopen libjpeg in the test suite.
+             (setenv "LD_LIBRARY_PATH"
+                     (string-append (assoc-ref inputs "libjpeg") "/lib"))
 
-          ;; 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)
-           ;; The test suite requires a running X server.
-           (system (format #f "~a/bin/Xvfb :1 &"
-                           (assoc-ref inputs "xorg-server")))
-           (setenv "DISPLAY" ":1"))
-         %standard-phases))))
+             ;; Change the site directory /site/X.Y like Guile expects.
+             (substitute* "build-aux/guile-baux/re-prefixed-site-dirs"
+               (("\"/site\"")
+                (let ((effective
+                       (read
+                        (open-pipe* OPEN_READ
+                                    "guile" "-c"
+                                    "(write (effective-version))"))))
+                  (string-append "\"/site/" effective "\""))))
+
+             ;; Skip tests that rely on sound support, which is unavailable in
+             ;; the build environment.
+             (substitute* "test/Makefile.in"
+               (("HAVE_MIXER = .*$")
+                "HAVE_MIXER = 0\n"))
+             #t))
+         (add-before 'check 'start-xorg-server
+           (lambda* (#:key inputs #:allow-other-keys)
+             ;; The test suite requires a running X server.
+             (system (format #f "~a/bin/Xvfb :1 &"
+                             (assoc-ref inputs "xorg-server")))
+             (setenv "DISPLAY" ":1")
+             #t))
+         (add-before 'check 'skip-cursor-test
+           (lambda _
+             ;; XXX: This test sometimes enters an endless loop, and sometimes
+             ;; crashes with:
+             ;;   guile: xcb_io.c:147: append_pending_request: Assertion `!xcb_xlib_unknown_seq_number' failed.
+             ;; Skip it.
+             (substitute* "test/cursor.scm"
+               (("\\(SDL:init .*" all)
+                (string-append "(exit 77)  ;" all "\n")))
+             #t)))))
     (synopsis "Guile interface for SDL (Simple DirectMedia Layer)")
     (description "Guile-SDL is a set of bindings to the Simple DirectMedia
 Layer (SDL).  With them, Guile programmers can have easy access to graphics,
@@ -439,7 +505,7 @@ sound and device input (keyboards, joysticks, mice, etc.).")
 (define-public guile-sdl2
   (package
     (name "guile-sdl2")
-    (version "0.2.0")
+    (version "0.3.1")
     (source (origin
               (method url-fetch)
               (uri (string-append
@@ -447,7 +513,7 @@ sound and device input (keyboards, joysticks, mice, etc.).")
                     version ".tar.gz"))
               (sha256
                (base32
-                "0yq9lsl17cdvj77padvpk3jcw2g6g0pck9jrchc7n2767rrc012b"))))
+                "0bw7x2lx90k4banc5k7yfkn3as93y25gr1xdr225ll7lmij21k64"))))
     (build-system gnu-build-system)
     (arguments
      '(#:make-flags '("GUILE_AUTO_COMPILE=0")
@@ -461,7 +527,7 @@ sound and device input (keyboards, joysticks, mice, etc.).")
              (string-append "--with-libsdl2-mixer-prefix="
                             (assoc-ref %build-inputs "sdl2-mixer")))))
     (native-inputs
-     `(("guile" ,guile-2.0)
+     `(("guile" ,guile-2.2)
        ("pkg-config" ,pkg-config)))
     (inputs
      `(("sdl2" ,sdl2)
@@ -475,3 +541,93 @@ sound and device input (keyboards, joysticks, mice, etc.).")
 The bindings are written in pure Scheme using Guile's foreign function
 interface.")
     (license lgpl3+)))
+
+(define-public ghc-sdl2
+  (package
+    (name "ghc-sdl2")
+    (version "2.4.1.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://hackage.haskell.org/package/"
+                           "sdl2/sdl2-" version ".tar.gz"))
+       (sha256
+        (base32
+         "0p4b12fmxps0sbnkqdfy0qw19s355yrkw7fgw6xz53wzq706k991"))))
+    (build-system haskell-build-system)
+    (arguments '(#:tests? #f)) ; tests require graphical environment
+    (inputs
+     `(("ghc-exceptions" ,ghc-exceptions)
+       ("ghc-linear" ,ghc-linear)
+       ("ghc-statevar" ,ghc-statevar)
+       ("ghc-text" ,ghc-text)
+       ("ghc-vector" ,ghc-vector)
+       ("sdl2" ,sdl2)))
+    (native-inputs
+     `(("ghc-weigh" ,ghc-weigh)
+       ("pkg-config" ,pkg-config)))
+    (home-page "http://hackage.haskell.org/package/sdl2")
+    (synopsis "High- and low-level bindings to the SDL library")
+    (description
+     "This package contains bindings to the SDL 2 library, in both high- and
+low-level forms.  The @code{SDL} namespace contains high-level bindings, where
+enumerations are split into sum types, and we perform automatic
+error-checking.  The @code{SDL.Raw} namespace contains an almost 1-1
+translation of the C API into Haskell FFI calls.  As such, this does not
+contain sum types nor error checking.  Thus this namespace is suitable for
+building your own abstraction over SDL, but is not recommended for day-to-day
+programming.")
+    (license bsd-3)))
+
+(define-public ghc-sdl2-mixer
+  (package
+    (name "ghc-sdl2-mixer")
+    (version "1.1.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://hackage.haskell.org/package/sdl2-mixer/"
+                           "sdl2-mixer-" version ".tar.gz"))
+       (sha256
+        (base32
+         "1k8avyccq5l9z7bwxigim312yaancxl1sr3q6a96bcm7pnhiak0g"))))
+    (build-system haskell-build-system)
+    (inputs
+     `(("ghc-data-default-class" ,ghc-data-default-class)
+       ("ghc-lifted-base" ,ghc-lifted-base)
+       ("ghc-monad-control" ,ghc-monad-control)
+       ("ghc-sdl2" ,ghc-sdl2)
+       ("ghc-vector" ,ghc-vector)
+       ("sdl2-mixer" ,sdl2-mixer)))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)))
+    (home-page "http://hackage.haskell.org/package/sdl2-mixer")
+    (synopsis "Bindings to SDL2 mixer")
+    (description "This package provides Haskell bindings to
+@code{SDL2_mixer}.")
+    (license bsd-3)))
+
+(define-public ghc-sdl2-image
+  (package
+    (name "ghc-sdl2-image")
+    (version "2.0.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://hackage.haskell.org/package/sdl2-image/"
+                           "sdl2-image-" version ".tar.gz"))
+       (sha256
+        (base32
+         "1pr6dkg73cy9z0w54lrkj9c5bhxj56nl92lxikjy8kz6nyr455rr"))))
+    (build-system haskell-build-system)
+    (inputs
+     `(("ghc-sdl2" ,ghc-sdl2)
+       ("ghc-text" ,ghc-text)
+       ("sdl2-image" ,sdl2-image)))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)))
+    (home-page "http://hackage.haskell.org/package/sdl2-image")
+    (synopsis "Bindings to SDL2_image")
+    (description "This package provides Haskell bindings to
+@code{SDL2_image}.")
+    (license expat)))