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 #:make-flags '("V=1") ;build verbosely
84 #:tests? #f)) ; no check target
86 ;; SDL headers include X11 headers.
88 ("libcap" ,libcap) ; 'libSDL.la' contain `-lcap'.
89 ;; TODO: Since building Mesa with Meson it is now necessary that Mesa is
90 ;; a propogated input. We still need to figure out why, possibly due to a
91 ;; change in pkg-config.
93 (native-inputs `(("pkg-config" ,pkg-config)))
94 (inputs `(("libxrandr" ,libxrandr)
96 ("alsa-lib" ,alsa-lib)
97 ("pulseaudio" ,pulseaudio)))
98 (outputs '("out" "debug"))
99 (synopsis "Cross platform game development library")
100 (description "Simple DirectMedia Layer is a cross-platform development
101 library designed to provide low level access to audio, keyboard, mouse,
102 joystick, and graphics hardware.")
103 (home-page "https://libsdl.org/")
107 (package (inherit sdl)
113 (string-append "https://libsdl.org/release/SDL2-"
117 "1c94ndagzkdfqaa838yqg589p1nnqln8mv0hpwfhrkbfczf8cl95"))))
119 (substitute-keyword-arguments (package-arguments sdl)
120 ((#:configure-flags flags)
121 `(append '("--disable-wayland-shared" "--enable-video-kmsdrm"
122 "--disable-kmsdrm-shared")
125 ;; SDL2 needs to be built with ibus support otherwise some systems
126 ;; experience a bug where input events are doubled.
128 ;; For more information, see: https://dev.solus-project.com/T1721
129 (append `(("dbus" ,dbus)
130 ("fcitx" ,fcitx) ; helps with CJK input
133 ("libxkbcommon" ,libxkbcommon)
135 ("wayland-protocols" ,wayland-protocols))
136 (package-inputs sdl)))
139 (define-public libmikmod
146 (string-append "mirror://sourceforge/mikmod/libmikmod/"
147 version "/libmikmod-" version ".tar.gz")
148 ;; Older versions are sometimes moved to:
149 (string-append "mirror://sourceforge/mikmod/"
150 "outdated_versions/libmikmod/"
151 version "/libmikmod-" version ".tar.gz")))
154 "06bdnhb0l81srdzg6gn2v2ydhhaazza7rshrcj3q8dpqr3gn97dd"))))
155 (build-system gnu-build-system)
157 ;; By default, libmikmod tries to dlopen libasound etc., which won't work
158 ;; unless the right libalsa happens to be in $LD_LIBRARY_PATH. Pass
159 ;; '--disable-dl' to avoid that.
160 '(#:configure-flags '("--disable-dl")))
161 (synopsis "Library for module sound formats")
163 "MikMod is able to play a wide range of module formats, as well as
164 digital sound files. It can take advantage of particular features of your
165 system, such as sound redirection over the network.")
167 (home-page "http://mikmod.sourceforge.net/")))
169 (define-public sdl-gfx
176 (string-append "http://www.ferzkopp.net/Software/SDL_gfx-2.0/SDL_gfx-"
180 "0ijljhs0v99dj6y27hc10z6qchyp8gdp4199y6jzngy6dzxlzsvw"))))
181 (build-system gnu-build-system)
182 (outputs '("out" "debug"))
184 `(,@(if (any (cute string-prefix? <> (or (%current-system)
185 (%current-target-system)))
187 ;; mmx is supported only on Intel processors.
189 '(#:configure-flags '("--disable-mmx")))))
190 (propagated-inputs `(("sdl" ,sdl)))
191 (synopsis "SDL graphics primitives library")
192 (description "SDL_gfx provides graphics drawing primitives, rotozoom and
193 other supporting functions for SDL.")
194 (home-page "http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx")
197 (define-public sdl-image
204 (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL_image-"
208 "16an9slbb8ci7d89wakkmyfvp7c0cval8xw4hkg0842nhhlp540b"))))
209 (build-system gnu-build-system)
210 (outputs '("out" "debug"))
212 ;; Explicitly link against shared libraries instead of dlopening them.
213 '(#:configure-flags '("--disable-jpg-shared"
214 "--disable-png-shared"
215 "--disable-tif-shared"
216 "--disable-webp-shared")))
217 (native-inputs `(("pkg-config" ,pkg-config)))
218 ;; libjpeg, libpng, and libtiff are propagated inputs because the
219 ;; SDL_image headers include the headers of these libraries. SDL is a
220 ;; propagated input because the pkg-config file refers to SDL's pkg-config
222 (propagated-inputs `(("sdl" ,sdl)
226 ("libwebp" ,libwebp)))
227 (synopsis "SDL image loading library")
228 (description "SDL_image is an image file loading library for SDL that
229 supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF,
230 WEBP, XCF, XPM, and XV.")
231 (home-page "https://www.libsdl.org/projects/SDL_image/")
234 (define-public sdl-mixer
241 (string-append "https://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-"
245 "0alrhqgm40p4c92s26mimg9cm1y7rzr6m0p49687jxd9g6130i0n"))))
246 (build-system gnu-build-system)
247 (outputs '("out" "debug"))
249 ;; use libmad instead of smpeg
250 ;; explicitly link against shared libraries instead of dlopening them
251 (arguments `(#:tests? #f
252 #:configure-flags '("--enable-music-mp3-mad-gpl"
253 "--disable-music-mod-shared"
254 "--disable-music-fluidsynth-shared"
255 "--disable-music-ogg-shared"
256 "--disable-music-flac-shared"
257 "--disable-music-mp3-shared")))
258 (inputs `(("libvorbis" ,libvorbis)
261 ("libmikmod" ,libmikmod)
262 ("libmodplug" ,libmodplug)))
263 ;; FIXME: Add libfluidsynth
264 (propagated-inputs `(("sdl" ,sdl)))
265 (synopsis "SDL multi-channel audio mixer library")
266 (description "SDL_mixer is a multi-channel audio mixer library for SDL.
267 It supports any number of simultaneously playing channels of 16 bit stereo
268 audio, plus a single channel of music. Supported format include FLAC, MOD,
269 MIDI, Ogg Vorbis, and MP3.")
270 (home-page "https://www.libsdl.org/projects/SDL_mixer/")
273 (define-public sdl-net
280 (string-append "https://www.libsdl.org/projects/SDL_net/release/SDL_net-"
284 "1d5c9xqlf4s1c01gzv6cxmg0r621pq9kfgxcg3197xw4p25pljjz"))))
285 (build-system gnu-build-system)
286 (propagated-inputs `(("sdl" ,sdl)))
287 (native-inputs `(("pkg-config" ,pkg-config)))
288 (outputs '("out" "debug"))
289 (synopsis "SDL networking library")
290 (description "SDL_net is a small, cross-platform networking library for
292 (home-page "https://www.libsdl.org/projects/SDL_net/")
295 (define-public sdl-ttf
302 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
306 "1dydxd4f5kb1288i5n5568kdk2q7f8mqjr7i7sd33nplxjaxhk3j"))))
307 (build-system gnu-build-system)
308 (propagated-inputs `(("sdl" ,sdl)))
309 (inputs `(("freetype" ,freetype)
311 (native-inputs `(("pkg-config" ,pkg-config)))
312 (outputs '("out" "debug"))
313 (synopsis "SDL TrueType font library")
314 (description "SDL_ttf is a TrueType font rendering library for SDL.")
315 (home-page "https://www.libsdl.org/projects/SDL_ttf/")
318 (define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
319 sdl-image sdl-mixer)))
320 "Return 'sdl-union' package which is a union of PACKAGES.
321 If PACKAGES are not specified, all SDL packages are used."
324 (version (package-version sdl))
326 (build-system trivial-build-system)
328 '(#:modules ((guix build union))
330 (use-modules (ice-9 match)
333 (((names . directories) ...)
334 (union-build (assoc-ref %outputs "out")
337 (inputs (map (lambda (package)
338 (list (package-name package) package))
340 (synopsis "Union of SDL libraries")
342 "A union of SDL and its extension libraries. A union is required because
343 sdl-config assumes that all of the headers and libraries are in the same
345 (home-page (package-home-page sdl))
346 (license (package-license sdl))))
348 (define (propagated-inputs-with-sdl2 package)
349 "Replace the \"sdl\" propagated input of PACKAGE with SDL2."
354 (package-propagated-inputs package)))
356 (define-public sdl2-gfx
357 (package (inherit sdl-gfx)
363 (string-append "https://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-"
367 "0qk2ax7f7grlxb13ba0ll3zlm8780s7j8fmrhlpxzjgdvldf1q33"))))
369 (propagated-inputs-with-sdl2 sdl-gfx))))
371 (define-public sdl2-image
372 (package (inherit sdl-image)
379 (string-append "https://www.libsdl.org/projects/SDL_image/release/"
380 "SDL2_image-" version ".tar.gz"))
382 (base32 "1b6f7002bm007y3zpyxb5r6ag0lml51jyvx1pwpj9sq24jfc8kp7"))))
384 (propagated-inputs-with-sdl2 sdl-image))))
386 (define-public sdl2-mixer
387 (package (inherit sdl-mixer)
394 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/"
395 "SDL2_mixer-" version ".tar.gz"))
396 (modules '((guix build utils)))
398 ;; Remove bundled libraries.
399 (delete-file-recursively "external")
402 (base32 "0694vsz5bjkcdgfdra6x9fq8vpzrl8m6q96gh58df7065hw5mkxl"))))
404 (propagated-inputs-with-sdl2 sdl-mixer))))
406 (define-public sdl2-ttf
407 (package (inherit sdl-ttf)
413 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-"
415 (modules '((guix build utils)))
417 ;; Remove bundled libraries.
418 '(delete-file-recursively "external")
422 "0cyd48dipc0m399qy8s03lci8b0bpiy8xlkvrm2ia7wcv0dfpv59"))))
424 (propagated-inputs-with-sdl2 sdl-ttf))))
426 (define-public guile-sdl
433 (string-append "mirror://gnu/guile-sdl/guile-sdl-"
437 "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
438 (build-system gnu-build-system)
440 `(("pkg-config" ,pkg-config)
441 ;; Required by test suite.
442 ("xorg-server" ,xorg-server)
443 ("libjpeg" ,libjpeg)))
445 `(("guile" ,guile-2.2)
446 ("sdl-union" ,(sdl-union))))
449 (list (string-append "--with-sdl-prefix="
450 (assoc-ref %build-inputs "sdl-union")))
451 #:modules ((ice-9 popen)
453 (guix build gnu-build-system))
455 #:parallel-build? #f ; parallel build fails
458 (modify-phases %standard-phases
459 (add-before 'configure 'fix-env-and-patch
460 (lambda* (#:key inputs #:allow-other-keys)
461 (setenv "GUILE_AUTO_COMPILE" "0")
462 ;; SDL_image needs to dlopen libjpeg in the test suite.
463 (setenv "LD_LIBRARY_PATH"
464 (string-append (assoc-ref inputs "libjpeg") "/lib"))
466 ;; Change the site directory /site/X.Y like Guile expects.
467 (substitute* "build-aux/guile-baux/re-prefixed-site-dirs"
471 (open-pipe* OPEN_READ
473 "(write (effective-version))"))))
474 (string-append "\"/site/" effective "\""))))
476 ;; Skip tests that rely on sound support, which is unavailable in
477 ;; the build environment.
478 (substitute* "test/Makefile.in"
479 (("HAVE_MIXER = .*$")
482 (add-before 'check 'start-xorg-server
483 (lambda* (#:key inputs #:allow-other-keys)
484 ;; The test suite requires a running X server.
485 (system (format #f "~a/bin/Xvfb :1 &"
486 (assoc-ref inputs "xorg-server")))
487 (setenv "DISPLAY" ":1")
489 (add-before 'check 'skip-cursor-test
491 ;; XXX: This test sometimes enters an endless loop, and sometimes
493 ;; guile: xcb_io.c:147: append_pending_request: Assertion `!xcb_xlib_unknown_seq_number' failed.
495 (substitute* "test/cursor.scm"
496 (("\\(SDL:init .*" all)
497 (string-append "(exit 77) ;" all "\n")))
499 (synopsis "Guile interface for SDL (Simple DirectMedia Layer)")
500 (description "Guile-SDL is a set of bindings to the Simple DirectMedia
501 Layer (SDL). With them, Guile programmers can have easy access to graphics,
502 sound and device input (keyboards, joysticks, mice, etc.).")
503 (home-page "https://www.gnu.org/software/guile-sdl/")
506 (define-public guile-sdl2
513 "https://files.dthompson.us/guile-sdl2/guile-sdl2-"
517 "0bw7x2lx90k4banc5k7yfkn3as93y25gr1xdr225ll7lmij21k64"))))
518 (build-system gnu-build-system)
520 '(#:make-flags '("GUILE_AUTO_COMPILE=0")
522 (list (string-append "--with-libsdl2-prefix="
523 (assoc-ref %build-inputs "sdl2"))
524 (string-append "--with-libsdl2-image-prefix="
525 (assoc-ref %build-inputs "sdl2-image"))
526 (string-append "--with-libsdl2-ttf-prefix="
527 (assoc-ref %build-inputs "sdl2-ttf"))
528 (string-append "--with-libsdl2-mixer-prefix="
529 (assoc-ref %build-inputs "sdl2-mixer")))))
531 `(("guile" ,guile-2.2)
532 ("pkg-config" ,pkg-config)))
535 ("sdl2-image" ,sdl2-image)
536 ("sdl2-mixer" ,sdl2-mixer)
537 ("sdl2-ttf" ,sdl2-ttf)))
538 (synopsis "Guile bindings for SDL2")
539 (home-page "https://dthompson.us/projects/guile-sdl2.html")
541 "Guile-SDL2 provides Guile Scheme bindings for the SDL2 C shared library.
542 The bindings are written in pure Scheme using Guile's foreign function