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 Ricardo Wurmus <rekado@elephly.net>
10 ;;; Copyright © 2019 Kei Kebreau <kkebreau@posteo.net>
12 ;;; This file is part of GNU Guix.
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27 (define-module (gnu packages sdl)
28 #:use-module (ice-9 match)
29 #:use-module (srfi srfi-1)
30 #:use-module (srfi srfi-26)
31 #:use-module (gnu packages)
32 #:use-module ((guix licenses) #:hide (freetype))
33 #:use-module (guix packages)
34 #:use-module (guix download)
35 #:use-module (guix utils)
36 #:use-module (guix build-system gnu)
37 #:use-module (guix build-system trivial)
38 #:use-module (gnu packages audio)
39 #:use-module (gnu packages fcitx)
40 #:use-module (gnu packages fontutils)
41 #:use-module (gnu packages freedesktop)
42 #:use-module (gnu packages glib)
43 #:use-module (gnu packages guile)
44 #:use-module (gnu packages ibus)
45 #:use-module (gnu packages image)
46 #:use-module (gnu packages linux)
47 #:use-module (gnu packages mp3)
48 #:use-module (gnu packages pkg-config)
49 #:use-module (gnu packages pulseaudio)
50 #:use-module (gnu packages gl)
51 #:use-module (gnu packages xdisorg)
52 #:use-module (gnu packages xiph)
53 #:use-module (gnu packages xorg)
63 (string-append "https://libsdl.org/release/SDL-"
67 "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"))
68 (patches (search-patches "sdl-libx11-1.6.patch"))))
69 (build-system gnu-build-system)
71 '(;; Explicitly link against shared libraries instead of dlopening them.
72 ;; For X11, ALSA, and PulseAudio.
73 ;; OpenGL library is still dlopened at runtime.
74 #:configure-flags '("--disable-alsa-shared"
75 "--disable-pulseaudio-shared"
76 "--disable-x11-shared"
77 ;; Explicitly link with mesa.
78 ;; This add mesa to libsdl's RUNPATH, to make dlopen
79 ;; finding the libGL from mesa at runtime.
82 #:tests? #f)) ; no check target
84 ;; SDL headers include X11 headers.
86 ("libcap" ,libcap))) ; 'libSDL.la' contain `-lcap'.
87 (native-inputs `(("pkg-config" ,pkg-config)))
88 (inputs `(("libxrandr" ,libxrandr)
91 ("alsa-lib" ,alsa-lib)
92 ("pulseaudio" ,pulseaudio)))
93 (outputs '("out" "debug"))
94 (synopsis "Cross platform game development library")
95 (description "Simple DirectMedia Layer is a cross-platform development
96 library designed to provide low level access to audio, keyboard, mouse,
97 joystick, and graphics hardware.")
98 (home-page "https://libsdl.org/")
102 (package (inherit sdl)
108 (string-append "https://libsdl.org/release/SDL2-"
112 "1c94ndagzkdfqaa838yqg589p1nnqln8mv0hpwfhrkbfczf8cl95"))))
114 (substitute-keyword-arguments (package-arguments sdl)
115 ((#:configure-flags flags)
116 `(append '("--disable-wayland-shared" "--enable-video-kmsdrm"
117 "--disable-kmsdrm-shared")
120 ;; SDL2 needs to be built with ibus support otherwise some systems
121 ;; experience a bug where input events are doubled.
123 ;; For more information, see: https://dev.solus-project.com/T1721
124 (append `(("dbus" ,dbus)
125 ("fcitx" ,fcitx) ; helps with CJK input
128 ("libxkbcommon" ,libxkbcommon)
130 ("wayland-protocols" ,wayland-protocols))
131 (package-inputs sdl)))
134 (define-public libmikmod
141 (string-append "mirror://sourceforge/mikmod/libmikmod/"
142 version "/libmikmod-" version ".tar.gz")
143 ;; Older versions are sometimes moved to:
144 (string-append "mirror://sourceforge/mikmod/"
145 "outdated_versions/libmikmod/"
146 version "/libmikmod-" version ".tar.gz")))
149 "06bdnhb0l81srdzg6gn2v2ydhhaazza7rshrcj3q8dpqr3gn97dd"))))
150 (build-system gnu-build-system)
152 ;; By default, libmikmod tries to dlopen libasound etc., which won't work
153 ;; unless the right libalsa happens to be in $LD_LIBRARY_PATH. Pass
154 ;; '--disable-dl' to avoid that.
155 '(#:configure-flags '("--disable-dl")))
156 (synopsis "Library for module sound formats")
158 "MikMod is able to play a wide range of module formats, as well as
159 digital sound files. It can take advantage of particular features of your
160 system, such as sound redirection over the network.")
162 (home-page "http://mikmod.sourceforge.net/")))
164 (define-public sdl-gfx
171 (string-append "http://www.ferzkopp.net/Software/SDL_gfx-2.0/SDL_gfx-"
175 "0ijljhs0v99dj6y27hc10z6qchyp8gdp4199y6jzngy6dzxlzsvw"))))
176 (build-system gnu-build-system)
177 (outputs '("out" "debug"))
179 `(,@(if (any (cute string-prefix? <> (or (%current-system)
180 (%current-target-system)))
182 ;; mmx is supported only on Intel processors.
184 '(#:configure-flags '("--disable-mmx")))))
185 (propagated-inputs `(("sdl" ,sdl)))
186 (synopsis "SDL graphics primitives library")
187 (description "SDL_gfx provides graphics drawing primitives, rotozoom and
188 other supporting functions for SDL.")
189 (home-page "http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx")
192 (define-public sdl-image
199 (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL_image-"
203 "16an9slbb8ci7d89wakkmyfvp7c0cval8xw4hkg0842nhhlp540b"))))
204 (build-system gnu-build-system)
205 (outputs '("out" "debug"))
207 ;; Explicitly link against shared libraries instead of dlopening them.
208 '(#:configure-flags '("--disable-jpg-shared"
209 "--disable-png-shared"
210 "--disable-tif-shared"
211 "--disable-webp-shared")))
212 (native-inputs `(("pkg-config" ,pkg-config)))
213 ;; libjpeg, libpng, and libtiff are propagated inputs because the
214 ;; SDL_image headers include the headers of these libraries. SDL is a
215 ;; propagated input because the pkg-config file refers to SDL's pkg-config
217 (propagated-inputs `(("sdl" ,sdl)
221 ("libwebp" ,libwebp)))
222 (synopsis "SDL image loading library")
223 (description "SDL_image is an image file loading library for SDL that
224 supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF,
225 WEBP, XCF, XPM, and XV.")
226 (home-page "https://www.libsdl.org/projects/SDL_image/")
229 (define-public sdl-mixer
236 (string-append "https://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-"
240 "0alrhqgm40p4c92s26mimg9cm1y7rzr6m0p49687jxd9g6130i0n"))))
241 (build-system gnu-build-system)
242 (outputs '("out" "debug"))
244 ;; use libmad instead of smpeg
245 ;; explicitly link against shared libraries instead of dlopening them
246 (arguments `(#:tests? #f
247 #:configure-flags '("--enable-music-mp3-mad-gpl"
248 "--disable-music-mod-shared"
249 "--disable-music-fluidsynth-shared"
250 "--disable-music-ogg-shared"
251 "--disable-music-flac-shared"
252 "--disable-music-mp3-shared")))
253 (inputs `(("libvorbis" ,libvorbis)
256 ("libmikmod" ,libmikmod)
257 ("libmodplug" ,libmodplug)))
258 ;; FIXME: Add libfluidsynth
259 (propagated-inputs `(("sdl" ,sdl)))
260 (synopsis "SDL multi-channel audio mixer library")
261 (description "SDL_mixer is a multi-channel audio mixer library for SDL.
262 It supports any number of simultaneously playing channels of 16 bit stereo
263 audio, plus a single channel of music. Supported format include FLAC, MOD,
264 MIDI, Ogg Vorbis, and MP3.")
265 (home-page "https://www.libsdl.org/projects/SDL_mixer/")
268 (define-public sdl-net
275 (string-append "https://www.libsdl.org/projects/SDL_net/release/SDL_net-"
279 "1d5c9xqlf4s1c01gzv6cxmg0r621pq9kfgxcg3197xw4p25pljjz"))))
280 (build-system gnu-build-system)
281 (propagated-inputs `(("sdl" ,sdl)))
282 (native-inputs `(("pkg-config" ,pkg-config)))
283 (outputs '("out" "debug"))
284 (synopsis "SDL networking library")
285 (description "SDL_net is a small, cross-platform networking library for
287 (home-page "https://www.libsdl.org/projects/SDL_net/")
290 (define-public sdl-ttf
297 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
301 "1dydxd4f5kb1288i5n5568kdk2q7f8mqjr7i7sd33nplxjaxhk3j"))))
302 (build-system gnu-build-system)
303 (propagated-inputs `(("sdl" ,sdl)))
304 (inputs `(("freetype" ,freetype)
306 (native-inputs `(("pkg-config" ,pkg-config)))
307 (outputs '("out" "debug"))
308 (synopsis "SDL TrueType font library")
309 (description "SDL_ttf is a TrueType font rendering library for SDL.")
310 (home-page "https://www.libsdl.org/projects/SDL_ttf/")
313 (define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
314 sdl-image sdl-mixer)))
315 "Return 'sdl-union' package which is a union of PACKAGES.
316 If PACKAGES are not specified, all SDL packages are used."
319 (version (package-version sdl))
321 (build-system trivial-build-system)
323 '(#:modules ((guix build union))
325 (use-modules (ice-9 match)
328 (((names . directories) ...)
329 (union-build (assoc-ref %outputs "out")
332 (inputs (map (lambda (package)
333 (list (package-name package) package))
335 (synopsis "Union of SDL libraries")
337 "A union of SDL and its extension libraries. A union is required because
338 sdl-config assumes that all of the headers and libraries are in the same
340 (home-page (package-home-page sdl))
341 (license (package-license sdl))))
343 (define (propagated-inputs-with-sdl2 package)
344 "Replace the \"sdl\" propagated input of PACKAGE with SDL2."
349 (package-propagated-inputs package)))
351 (define-public sdl2-gfx
352 (package (inherit sdl-gfx)
358 (string-append "https://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-"
362 "0qk2ax7f7grlxb13ba0ll3zlm8780s7j8fmrhlpxzjgdvldf1q33"))))
364 (propagated-inputs-with-sdl2 sdl-gfx))))
366 (define-public sdl2-image
367 (package (inherit sdl-image)
374 (string-append "https://www.libsdl.org/projects/SDL_image/release/"
375 "SDL2_image-" version ".tar.gz"))
377 (base32 "1b6f7002bm007y3zpyxb5r6ag0lml51jyvx1pwpj9sq24jfc8kp7"))))
379 (propagated-inputs-with-sdl2 sdl-image))))
381 (define-public sdl2-mixer
382 (package (inherit sdl-mixer)
389 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/"
390 "SDL2_mixer-" version ".tar.gz"))
391 (modules '((guix build utils)))
393 ;; Remove bundled libraries.
394 (delete-file-recursively "external")
397 (base32 "0694vsz5bjkcdgfdra6x9fq8vpzrl8m6q96gh58df7065hw5mkxl"))))
399 (propagated-inputs-with-sdl2 sdl-mixer))))
401 (define-public sdl2-ttf
402 (package (inherit sdl-ttf)
408 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-"
410 (modules '((guix build utils)))
412 ;; Remove bundled libraries.
413 '(delete-file-recursively "external")
417 "0cyd48dipc0m399qy8s03lci8b0bpiy8xlkvrm2ia7wcv0dfpv59"))))
419 (propagated-inputs-with-sdl2 sdl-ttf))))
421 (define-public guile-sdl
428 (string-append "mirror://gnu/guile-sdl/guile-sdl-"
432 "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
433 (build-system gnu-build-system)
435 `(("pkg-config" ,pkg-config)
436 ;; Required by test suite.
437 ("xorg-server" ,xorg-server)
438 ("libjpeg" ,libjpeg)))
440 `(("guile" ,guile-2.2)
441 ("sdl-union" ,(sdl-union))))
444 (list (string-append "--with-sdl-prefix="
445 (assoc-ref %build-inputs "sdl-union")))
446 #:modules ((ice-9 popen)
448 (guix build gnu-build-system))
450 #:parallel-build? #f ; parallel build fails
453 (modify-phases %standard-phases
454 (add-before 'configure 'fix-env-and-patch
455 (lambda* (#:key inputs #:allow-other-keys)
456 (setenv "GUILE_AUTO_COMPILE" "0")
457 ;; SDL_image needs to dlopen libjpeg in the test suite.
458 (setenv "LD_LIBRARY_PATH"
459 (string-append (assoc-ref inputs "libjpeg") "/lib"))
461 ;; Change the site directory /site/X.Y like Guile expects.
462 (substitute* "build-aux/guile-baux/re-prefixed-site-dirs"
466 (open-pipe* OPEN_READ
468 "(write (effective-version))"))))
469 (string-append "\"/site/" effective "\""))))
471 ;; Skip tests that rely on sound support, which is unavailable in
472 ;; the build environment.
473 (substitute* "test/Makefile.in"
474 (("HAVE_MIXER = .*$")
477 (add-before 'check 'start-xorg-server
478 (lambda* (#:key inputs #:allow-other-keys)
479 ;; The test suite requires a running X server.
480 (system (format #f "~a/bin/Xvfb :1 &"
481 (assoc-ref inputs "xorg-server")))
482 (setenv "DISPLAY" ":1")
484 (add-before 'check 'skip-cursor-test
486 ;; XXX: This test sometimes enters an endless loop, and sometimes
488 ;; guile: xcb_io.c:147: append_pending_request: Assertion `!xcb_xlib_unknown_seq_number' failed.
490 (substitute* "test/cursor.scm"
491 (("\\(SDL:init .*" all)
492 (string-append "(exit 77) ;" all "\n")))
494 (synopsis "Guile interface for SDL (Simple DirectMedia Layer)")
495 (description "Guile-SDL is a set of bindings to the Simple DirectMedia
496 Layer (SDL). With them, Guile programmers can have easy access to graphics,
497 sound and device input (keyboards, joysticks, mice, etc.).")
498 (home-page "https://www.gnu.org/software/guile-sdl/")
501 (define-public guile-sdl2
508 "https://files.dthompson.us/guile-sdl2/guile-sdl2-"
512 "0bw7x2lx90k4banc5k7yfkn3as93y25gr1xdr225ll7lmij21k64"))))
513 (build-system gnu-build-system)
515 '(#:make-flags '("GUILE_AUTO_COMPILE=0")
517 (list (string-append "--with-libsdl2-prefix="
518 (assoc-ref %build-inputs "sdl2"))
519 (string-append "--with-libsdl2-image-prefix="
520 (assoc-ref %build-inputs "sdl2-image"))
521 (string-append "--with-libsdl2-ttf-prefix="
522 (assoc-ref %build-inputs "sdl2-ttf"))
523 (string-append "--with-libsdl2-mixer-prefix="
524 (assoc-ref %build-inputs "sdl2-mixer")))))
526 `(("guile" ,guile-2.2)
527 ("pkg-config" ,pkg-config)))
530 ("sdl2-image" ,sdl2-image)
531 ("sdl2-mixer" ,sdl2-mixer)
532 ("sdl2-ttf" ,sdl2-ttf)))
533 (synopsis "Guile bindings for SDL2")
534 (home-page "https://dthompson.us/projects/guile-sdl2.html")
536 "Guile-SDL2 provides Guile Scheme bindings for the SDL2 C shared library.
537 The bindings are written in pure Scheme using Guile's foreign function