1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2015, 2017 David Thompson <dthompson2@worcester.edu>
3 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015, 2017 Sou Bunnbu <iyzsong@member.fsf.org>
5 ;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
6 ;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2017, 2018, 2019 Rutger Helling <rhelling@mykolab.com>
8 ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
10 ;;; Copyright © 2019 Kei Kebreau <kkebreau@posteo.net>
11 ;;; Copyright © 2019 Nicolas Goaziou <mail@nicolasgoaziou.fr>
13 ;;; This file is part of GNU Guix.
15 ;;; GNU Guix is free software; you can redistribute it and/or modify it
16 ;;; under the terms of the GNU General Public License as published by
17 ;;; the Free Software Foundation; either version 3 of the License, or (at
18 ;;; your option) any later version.
20 ;;; GNU Guix is distributed in the hope that it will be useful, but
21 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;;; GNU General Public License for more details.
25 ;;; You should have received a copy of the GNU General Public License
26 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28 (define-module (gnu packages sdl)
29 #:use-module (ice-9 match)
30 #:use-module (srfi srfi-1)
31 #:use-module (srfi srfi-26)
32 #:use-module (gnu packages)
33 #:use-module ((guix licenses) #:hide (freetype))
34 #:use-module (guix packages)
35 #:use-module (guix download)
36 #:use-module (guix utils)
37 #:use-module (guix build-system gnu)
38 #:use-module (guix build-system trivial)
39 #:use-module (gnu packages audio)
40 #:use-module (gnu packages fcitx)
41 #:use-module (gnu packages fontutils)
42 #:use-module (gnu packages freedesktop)
43 #:use-module (gnu packages glib)
44 #:use-module (gnu packages guile)
45 #:use-module (gnu packages ibus)
46 #:use-module (gnu packages image)
47 #:use-module (gnu packages linux)
48 #:use-module (gnu packages mp3)
49 #:use-module (gnu packages pkg-config)
50 #:use-module (gnu packages pulseaudio)
51 #:use-module (gnu packages gl)
52 #:use-module (gnu packages xdisorg)
53 #:use-module (gnu packages xiph)
54 #:use-module (gnu packages xorg)
64 (string-append "https://libsdl.org/release/SDL-"
68 "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"))
69 (patches (search-patches "sdl-libx11-1.6.patch"))))
70 (build-system gnu-build-system)
72 '(;; Explicitly link against shared libraries instead of dlopening them.
73 ;; For X11, ALSA, and PulseAudio.
74 ;; OpenGL library is still dlopened at runtime.
75 #:configure-flags '("--disable-alsa-shared"
76 "--disable-pulseaudio-shared"
77 "--disable-x11-shared"
78 ;; Explicitly link with mesa.
79 ;; This add mesa to libsdl's RUNPATH, to make dlopen
80 ;; finding the libGL from mesa at runtime.
83 #:make-flags '("V=1") ;build verbosely
85 #:tests? #f)) ; no check target
87 ;; SDL headers include X11 headers.
89 ("libcap" ,libcap) ; 'libSDL.la' contain `-lcap'.
90 ;; TODO: Since building Mesa with Meson it is now necessary that Mesa is
91 ;; a propogated input. We still need to figure out why, possibly due to a
92 ;; change in pkg-config.
94 (native-inputs `(("pkg-config" ,pkg-config)))
95 (inputs `(("libxrandr" ,libxrandr)
97 ("alsa-lib" ,alsa-lib)
98 ("pulseaudio" ,pulseaudio)))
99 (outputs '("out" "debug"))
100 (synopsis "Cross platform game development library")
101 (description "Simple DirectMedia Layer is a cross-platform development
102 library designed to provide low level access to audio, keyboard, mouse,
103 joystick, and graphics hardware.")
104 (home-page "https://libsdl.org/")
108 (package (inherit sdl)
114 (string-append "https://libsdl.org/release/SDL2-"
118 "1c94ndagzkdfqaa838yqg589p1nnqln8mv0hpwfhrkbfczf8cl95"))))
120 (substitute-keyword-arguments (package-arguments sdl)
121 ((#:configure-flags flags)
122 `(append '("--disable-wayland-shared" "--enable-video-kmsdrm"
123 "--disable-kmsdrm-shared")
126 ;; SDL2 needs to be built with ibus support otherwise some systems
127 ;; experience a bug where input events are doubled.
129 ;; For more information, see: https://dev.solus-project.com/T1721
130 (append `(("dbus" ,dbus)
131 ("fcitx" ,fcitx) ; helps with CJK input
134 ("libxkbcommon" ,libxkbcommon)
136 ("wayland-protocols" ,wayland-protocols))
137 (package-inputs sdl)))
140 (define-public libmikmod
147 (string-append "mirror://sourceforge/mikmod/libmikmod/"
148 version "/libmikmod-" version ".tar.gz")
149 ;; Older versions are sometimes moved to:
150 (string-append "mirror://sourceforge/mikmod/"
151 "outdated_versions/libmikmod/"
152 version "/libmikmod-" version ".tar.gz")))
155 "06bdnhb0l81srdzg6gn2v2ydhhaazza7rshrcj3q8dpqr3gn97dd"))))
156 (build-system gnu-build-system)
158 ;; By default, libmikmod tries to dlopen libasound etc., which won't work
159 ;; unless the right libalsa happens to be in $LD_LIBRARY_PATH. Pass
160 ;; '--disable-dl' to avoid that.
161 '(#:configure-flags '("--disable-dl")))
162 (synopsis "Library for module sound formats")
164 "MikMod is able to play a wide range of module formats, as well as
165 digital sound files. It can take advantage of particular features of your
166 system, such as sound redirection over the network.")
168 (home-page "http://mikmod.sourceforge.net/")))
170 (define-public sdl-gfx
177 (string-append "http://www.ferzkopp.net/Software/SDL_gfx-2.0/SDL_gfx-"
181 "0ijljhs0v99dj6y27hc10z6qchyp8gdp4199y6jzngy6dzxlzsvw"))))
182 (build-system gnu-build-system)
183 (outputs '("out" "debug"))
185 `(,@(if (any (cute string-prefix? <> (or (%current-system)
186 (%current-target-system)))
188 ;; mmx is supported only on Intel processors.
190 '(#:configure-flags '("--disable-mmx")))))
191 (propagated-inputs `(("sdl" ,sdl)))
192 (synopsis "SDL graphics primitives library")
193 (description "SDL_gfx provides graphics drawing primitives, rotozoom and
194 other supporting functions for SDL.")
195 (home-page "http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx")
198 (define-public sdl-image
205 (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL_image-"
209 "16an9slbb8ci7d89wakkmyfvp7c0cval8xw4hkg0842nhhlp540b"))))
210 (build-system gnu-build-system)
211 (outputs '("out" "debug"))
213 ;; Explicitly link against shared libraries instead of dlopening them.
214 '(#:configure-flags '("--disable-jpg-shared"
215 "--disable-png-shared"
216 "--disable-tif-shared"
217 "--disable-webp-shared")))
218 (native-inputs `(("pkg-config" ,pkg-config)))
219 ;; libjpeg, libpng, and libtiff are propagated inputs because the
220 ;; SDL_image headers include the headers of these libraries. SDL is a
221 ;; propagated input because the pkg-config file refers to SDL's pkg-config
223 (propagated-inputs `(("sdl" ,sdl)
227 ("libwebp" ,libwebp)))
228 (synopsis "SDL image loading library")
229 (description "SDL_image is an image file loading library for SDL that
230 supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF,
231 WEBP, XCF, XPM, and XV.")
232 (home-page "https://www.libsdl.org/projects/SDL_image/")
235 (define-public sdl-mixer
242 (string-append "https://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-"
246 "0alrhqgm40p4c92s26mimg9cm1y7rzr6m0p49687jxd9g6130i0n"))))
247 (build-system gnu-build-system)
248 (outputs '("out" "debug"))
250 ;; use libmad instead of smpeg
251 ;; explicitly link against shared libraries instead of dlopening them
252 (arguments `(#:tests? #f
253 #:configure-flags '("--enable-music-mp3-mad-gpl"
254 "--disable-music-mod-shared"
255 "--disable-music-fluidsynth-shared"
256 "--disable-music-ogg-shared"
257 "--disable-music-flac-shared"
258 "--disable-music-mp3-shared")))
259 (inputs `(("libvorbis" ,libvorbis)
262 ("libmikmod" ,libmikmod)
263 ("libmodplug" ,libmodplug)))
264 ;; FIXME: Add libfluidsynth
265 (propagated-inputs `(("sdl" ,sdl)))
266 (synopsis "SDL multi-channel audio mixer library")
267 (description "SDL_mixer is a multi-channel audio mixer library for SDL.
268 It supports any number of simultaneously playing channels of 16 bit stereo
269 audio, plus a single channel of music. Supported format include FLAC, MOD,
270 MIDI, Ogg Vorbis, and MP3.")
271 (home-page "https://www.libsdl.org/projects/SDL_mixer/")
274 (define-public sdl-net
281 (string-append "https://www.libsdl.org/projects/SDL_net/release/SDL_net-"
285 "1d5c9xqlf4s1c01gzv6cxmg0r621pq9kfgxcg3197xw4p25pljjz"))))
286 (build-system gnu-build-system)
287 (propagated-inputs `(("sdl" ,sdl)))
288 (native-inputs `(("pkg-config" ,pkg-config)))
289 (outputs '("out" "debug"))
290 (synopsis "SDL networking library")
291 (description "SDL_net is a small, cross-platform networking library for
293 (home-page "https://www.libsdl.org/projects/SDL_net/")
296 (define-public sdl-ttf
303 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
307 "1dydxd4f5kb1288i5n5568kdk2q7f8mqjr7i7sd33nplxjaxhk3j"))))
308 (build-system gnu-build-system)
309 (propagated-inputs `(("sdl" ,sdl)))
310 (inputs `(("freetype" ,freetype)
312 (native-inputs `(("pkg-config" ,pkg-config)))
313 (outputs '("out" "debug"))
314 (synopsis "SDL TrueType font library")
315 (description "SDL_ttf is a TrueType font rendering library for SDL.")
316 (home-page "https://www.libsdl.org/projects/SDL_ttf/")
319 (define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
320 sdl-image sdl-mixer)))
321 "Return 'sdl-union' package which is a union of PACKAGES.
322 If PACKAGES are not specified, all SDL packages are used."
325 (version (package-version sdl))
327 (build-system trivial-build-system)
329 '(#:modules ((guix build union))
331 (use-modules (ice-9 match)
334 (((names . directories) ...)
335 (union-build (assoc-ref %outputs "out")
338 (inputs (map (lambda (package)
339 (list (package-name package) package))
341 (synopsis "Union of SDL libraries")
343 "A union of SDL and its extension libraries. A union is required because
344 sdl-config assumes that all of the headers and libraries are in the same
346 (home-page (package-home-page sdl))
347 (license (package-license sdl))))
349 (define (propagated-inputs-with-sdl2 package)
350 "Replace the \"sdl\" propagated input of PACKAGE with SDL2."
355 (package-propagated-inputs package)))
357 (define-public sdl2-gfx
358 (package (inherit sdl-gfx)
364 (string-append "https://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-"
368 "0qk2ax7f7grlxb13ba0ll3zlm8780s7j8fmrhlpxzjgdvldf1q33"))))
370 (propagated-inputs-with-sdl2 sdl-gfx))))
372 (define-public sdl2-image
373 (package (inherit sdl-image)
380 (string-append "https://www.libsdl.org/projects/SDL_image/release/"
381 "SDL2_image-" version ".tar.gz"))
383 (base32 "1b6f7002bm007y3zpyxb5r6ag0lml51jyvx1pwpj9sq24jfc8kp7"))))
385 (propagated-inputs-with-sdl2 sdl-image))))
387 (define-public sdl2-mixer
388 (package (inherit sdl-mixer)
395 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/"
396 "SDL2_mixer-" version ".tar.gz"))
397 (modules '((guix build utils)))
399 ;; Remove bundled libraries.
400 (delete-file-recursively "external")
403 (base32 "0694vsz5bjkcdgfdra6x9fq8vpzrl8m6q96gh58df7065hw5mkxl"))))
405 (propagated-inputs-with-sdl2 sdl-mixer))))
407 (define-public sdl2-net
408 (package (inherit sdl-net)
415 (string-append "http://www.libsdl.org/projects/SDL_net/release/"
416 "SDL2_net-" version ".tar.gz"))
419 "08cxc1bicmyk89kiks7izw1rlx5ng5n6xpy8fy0zxni3b9z8mkhm"))))
421 (propagated-inputs-with-sdl2 sdl-net))))
423 (define-public sdl2-ttf
424 (package (inherit sdl-ttf)
430 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-"
432 (modules '((guix build utils)))
434 ;; Remove bundled libraries.
435 '(delete-file-recursively "external")
439 "0cyd48dipc0m399qy8s03lci8b0bpiy8xlkvrm2ia7wcv0dfpv59"))))
441 (propagated-inputs-with-sdl2 sdl-ttf))))
443 (define-public guile-sdl
450 (string-append "mirror://gnu/guile-sdl/guile-sdl-"
454 "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
455 (build-system gnu-build-system)
457 `(("pkg-config" ,pkg-config)
458 ;; Required by test suite.
459 ("xorg-server" ,xorg-server)
460 ("libjpeg" ,libjpeg)))
462 `(("guile" ,guile-2.2)
463 ("sdl-union" ,(sdl-union))))
466 (list (string-append "--with-sdl-prefix="
467 (assoc-ref %build-inputs "sdl-union")))
468 #:modules ((ice-9 popen)
470 (guix build gnu-build-system))
472 #:parallel-build? #f ; parallel build fails
475 (modify-phases %standard-phases
476 (add-before 'configure 'fix-env-and-patch
477 (lambda* (#:key inputs #:allow-other-keys)
478 (setenv "GUILE_AUTO_COMPILE" "0")
479 ;; SDL_image needs to dlopen libjpeg in the test suite.
480 (setenv "LD_LIBRARY_PATH"
481 (string-append (assoc-ref inputs "libjpeg") "/lib"))
483 ;; Change the site directory /site/X.Y like Guile expects.
484 (substitute* "build-aux/guile-baux/re-prefixed-site-dirs"
488 (open-pipe* OPEN_READ
490 "(write (effective-version))"))))
491 (string-append "\"/site/" effective "\""))))
493 ;; Skip tests that rely on sound support, which is unavailable in
494 ;; the build environment.
495 (substitute* "test/Makefile.in"
496 (("HAVE_MIXER = .*$")
499 (add-before 'check 'start-xorg-server
500 (lambda* (#:key inputs #:allow-other-keys)
501 ;; The test suite requires a running X server.
502 (system (format #f "~a/bin/Xvfb :1 &"
503 (assoc-ref inputs "xorg-server")))
504 (setenv "DISPLAY" ":1")
506 (add-before 'check 'skip-cursor-test
508 ;; XXX: This test sometimes enters an endless loop, and sometimes
510 ;; guile: xcb_io.c:147: append_pending_request: Assertion `!xcb_xlib_unknown_seq_number' failed.
512 (substitute* "test/cursor.scm"
513 (("\\(SDL:init .*" all)
514 (string-append "(exit 77) ;" all "\n")))
516 (synopsis "Guile interface for SDL (Simple DirectMedia Layer)")
517 (description "Guile-SDL is a set of bindings to the Simple DirectMedia
518 Layer (SDL). With them, Guile programmers can have easy access to graphics,
519 sound and device input (keyboards, joysticks, mice, etc.).")
520 (home-page "https://www.gnu.org/software/guile-sdl/")
523 (define-public guile-sdl2
529 (uri (string-append "https://files.dthompson.us/guile-sdl2/"
530 "guile-sdl2-" version ".tar.gz"))
533 "0zcxwgyadwpbhq6h5mv2569c3kalgra26zc186y9fqiyyzmh1v9s"))))
534 (build-system gnu-build-system)
536 '(#:make-flags '("GUILE_AUTO_COMPILE=0")
538 (list (string-append "--with-libsdl2-prefix="
539 (assoc-ref %build-inputs "sdl2"))
540 (string-append "--with-libsdl2-image-prefix="
541 (assoc-ref %build-inputs "sdl2-image"))
542 (string-append "--with-libsdl2-ttf-prefix="
543 (assoc-ref %build-inputs "sdl2-ttf"))
544 (string-append "--with-libsdl2-mixer-prefix="
545 (assoc-ref %build-inputs "sdl2-mixer")))))
547 `(("guile" ,guile-2.2)
548 ("pkg-config" ,pkg-config)))
551 ("sdl2-image" ,sdl2-image)
552 ("sdl2-mixer" ,sdl2-mixer)
553 ("sdl2-ttf" ,sdl2-ttf)))
554 (synopsis "Guile bindings for SDL2")
555 (home-page "https://dthompson.us/projects/guile-sdl2.html")
557 "Guile-SDL2 provides Guile Scheme bindings for the SDL2 C shared library.
558 The bindings are written in pure Scheme using Guile's foreign function