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 Rutger Helling <rhelling@mykolab.com>
8 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
10 ;;; This file is part of GNU Guix.
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25 (define-module (gnu packages sdl)
26 #:use-module (ice-9 match)
27 #:use-module (srfi srfi-1)
28 #:use-module (srfi srfi-26)
29 #:use-module (gnu packages)
30 #:use-module ((guix licenses) #:hide (freetype))
31 #:use-module (guix packages)
32 #:use-module (guix download)
33 #:use-module (guix utils)
34 #:use-module (guix build-system gnu)
35 #:use-module (guix build-system trivial)
36 #:use-module (gnu packages audio)
37 #:use-module (gnu packages fcitx)
38 #:use-module (gnu packages fontutils)
39 #:use-module (gnu packages freedesktop)
40 #:use-module (gnu packages glib)
41 #:use-module (gnu packages guile)
42 #:use-module (gnu packages ibus)
43 #:use-module (gnu packages image)
44 #:use-module (gnu packages linux)
45 #:use-module (gnu packages mp3)
46 #:use-module (gnu packages pkg-config)
47 #:use-module (gnu packages pulseaudio)
48 #:use-module (gnu packages gl)
49 #:use-module (gnu packages xdisorg)
50 #:use-module (gnu packages xiph)
51 #:use-module (gnu packages xorg)
61 (string-append "https://libsdl.org/release/SDL-"
65 "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"))
66 (patches (search-patches "sdl-libx11-1.6.patch"))))
67 (build-system gnu-build-system)
69 '(;; Explicitly link against shared libraries instead of dlopening them.
70 ;; For X11, ALSA, and PulseAudio.
71 ;; OpenGL library is still dlopened at runtime.
72 #:configure-flags '("--disable-alsa-shared"
73 "--disable-pulseaudio-shared"
74 "--disable-x11-shared"
75 ;; Explicitly link with mesa.
76 ;; This add mesa to libsdl's RUNPATH, to make dlopen
77 ;; finding the libGL from mesa at runtime.
80 #:tests? #f)) ; no check target
82 ;; SDL headers include X11 headers.
84 ("libcap" ,libcap))) ; 'libSDL.la' contain `-lcap'.
85 (native-inputs `(("pkg-config" ,pkg-config)))
86 (inputs `(("libxrandr" ,libxrandr)
89 ("alsa-lib" ,alsa-lib)
90 ("pulseaudio" ,pulseaudio)))
91 (outputs '("out" "debug"))
92 (synopsis "Cross platform game development library")
93 (description "Simple DirectMedia Layer is a cross-platform development
94 library designed to provide low level access to audio, keyboard, mouse,
95 joystick, and graphics hardware.")
96 (home-page "https://libsdl.org/")
100 (package (inherit sdl)
106 (string-append "https://libsdl.org/release/SDL2-"
110 "1v4js1gkr75hzbxzhwzzif0sf9g07234sd23x1vdaqc661bprizd"))))
112 (substitute-keyword-arguments (package-arguments sdl)
113 ((#:configure-flags flags)
114 `(append '("--disable-wayland-shared")
117 ;; SDL2 needs to be built with ibus support otherwise some systems
118 ;; experience a bug where input events are doubled.
120 ;; For more information, see: https://dev.solus-project.com/T1721
121 (append `(("dbus" ,dbus)
122 ("fcitx" ,fcitx) ; helps with CJK input
125 ("libxkbcommon", libxkbcommon)
127 ("wayland-protocols", wayland-protocols))
128 (package-inputs sdl)))
131 (define-public libmikmod
138 (string-append "mirror://sourceforge/mikmod/libmikmod/"
139 version "/libmikmod-" version ".tar.gz")
140 ;; Older versions are sometimes moved to:
141 (string-append "mirror://sourceforge/mikmod/"
142 "outdated_versions/libmikmod/"
143 version "/libmikmod-" version ".tar.gz")))
146 "0j7g4jpa2zgzw7x6s3rldypa7zlwjvn97rwx0sylx1iihhlzbcq0"))))
147 (build-system gnu-build-system)
149 ;; By default, libmikmod tries to dlopen libasound etc., which won't work
150 ;; unless the right libalsa happens to be in $LD_LIBRARY_PATH. Pass
151 ;; '--disable-dl' to avoid that.
152 '(#:configure-flags '("--disable-dl")))
153 (synopsis "Library for module sound formats")
155 "MikMod is able to play a wide range of module formats, as well as
156 digital sound files. It can take advantage of particular features of your
157 system, such as sound redirection over the network.")
159 (home-page "http://mikmod.sourceforge.net/")))
161 (define-public sdl-gfx
168 (string-append "http://www.ferzkopp.net/Software/SDL_gfx-2.0/SDL_gfx-"
172 "0ijljhs0v99dj6y27hc10z6qchyp8gdp4199y6jzngy6dzxlzsvw"))))
173 (build-system gnu-build-system)
174 (outputs '("out" "debug"))
176 `(,@(if (any (cute string-prefix? <> (or (%current-system)
177 (%current-target-system)))
179 ;; mmx is supported only on Intel processors.
181 '(#:configure-flags '("--disable-mmx")))))
182 (propagated-inputs `(("sdl" ,sdl)))
183 (synopsis "SDL graphics primitives library")
184 (description "SDL_gfx provides graphics drawing primitives, rotozoom and
185 other supporting functions for SDL.")
186 (home-page "http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx")
189 (define-public sdl-image
196 (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL_image-"
200 "16an9slbb8ci7d89wakkmyfvp7c0cval8xw4hkg0842nhhlp540b"))))
201 (build-system gnu-build-system)
202 (outputs '("out" "debug"))
204 ;; Explicitly link against shared libraries instead of dlopening them.
205 '(#:configure-flags '("--disable-jpg-shared"
206 "--disable-png-shared"
207 "--disable-tif-shared"
208 "--disable-webp-shared")))
209 (native-inputs `(("pkg-config" ,pkg-config)))
210 ;; libjpeg, libpng, and libtiff are propagated inputs because the
211 ;; SDL_image headers include the headers of these libraries. SDL is a
212 ;; propagated input because the pkg-config file refers to SDL's pkg-config
214 (propagated-inputs `(("sdl" ,sdl)
218 ("libwebp" ,libwebp)))
219 (synopsis "SDL image loading library")
220 (description "SDL_image is an image file loading library for SDL that
221 supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF,
222 WEBP, XCF, XPM, and XV.")
223 (home-page "https://www.libsdl.org/projects/SDL_image/")
226 (define-public sdl-mixer
233 (string-append "https://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-"
237 "0alrhqgm40p4c92s26mimg9cm1y7rzr6m0p49687jxd9g6130i0n"))))
238 (build-system gnu-build-system)
239 (outputs '("out" "debug"))
241 ;; use libmad instead of smpeg
242 ;; explicitly link against shared libraries instead of dlopening them
243 (arguments `(#:tests? #f
244 #:configure-flags '("--enable-music-mp3-mad-gpl"
245 "--disable-music-mod-shared"
246 "--disable-music-fluidsynth-shared"
247 "--disable-music-ogg-shared"
248 "--disable-music-flac-shared"
249 "--disable-music-mp3-shared")))
250 (inputs `(("libvorbis" ,libvorbis)
253 ("libmikmod" ,libmikmod)
254 ("libmodplug" ,libmodplug)))
255 ;; FIXME: Add libfluidsynth
256 (propagated-inputs `(("sdl" ,sdl)))
257 (synopsis "SDL multi-channel audio mixer library")
258 (description "SDL_mixer is a multi-channel audio mixer library for SDL.
259 It supports any number of simultaneously playing channels of 16 bit stereo
260 audio, plus a single channel of music. Supported format include FLAC, MOD,
261 MIDI, Ogg Vorbis, and MP3.")
262 (home-page "https://www.libsdl.org/projects/SDL_mixer/")
265 (define-public sdl-net
272 (string-append "https://www.libsdl.org/projects/SDL_net/release/SDL_net-"
276 "1d5c9xqlf4s1c01gzv6cxmg0r621pq9kfgxcg3197xw4p25pljjz"))))
277 (build-system gnu-build-system)
278 (propagated-inputs `(("sdl" ,sdl)))
279 (native-inputs `(("pkg-config" ,pkg-config)))
280 (outputs '("out" "debug"))
281 (synopsis "SDL networking library")
282 (description "SDL_net is a small, cross-platform networking library for
284 (home-page "https://www.libsdl.org/projects/SDL_net/")
287 (define-public sdl-ttf
294 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
298 "1dydxd4f5kb1288i5n5568kdk2q7f8mqjr7i7sd33nplxjaxhk3j"))))
299 (build-system gnu-build-system)
300 (propagated-inputs `(("sdl" ,sdl)))
301 (inputs `(("freetype" ,freetype)
303 (native-inputs `(("pkg-config" ,pkg-config)))
304 (outputs '("out" "debug"))
305 (synopsis "SDL TrueType font library")
306 (description "SDL_ttf is a TrueType font rendering library for SDL.")
307 (home-page "https://www.libsdl.org/projects/SDL_ttf/")
310 (define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
311 sdl-image sdl-mixer)))
312 "Return 'sdl-union' package which is a union of PACKAGES.
313 If PACKAGES are not specified, all SDL packages are used."
316 (version (package-version sdl))
318 (build-system trivial-build-system)
320 '(#:modules ((guix build union))
322 (use-modules (ice-9 match)
325 (((names . directories) ...)
326 (union-build (assoc-ref %outputs "out")
328 (inputs (map (lambda (package)
329 (list (package-name package) package))
331 (synopsis "Union of SDL libraries")
333 "A union of SDL and its extension libraries. A union is required because
334 sdl-config assumes that all of the headers and libraries are in the same
336 (home-page (package-home-page sdl))
337 (license (package-license sdl))))
339 (define (propagated-inputs-with-sdl2 package)
340 "Replace the \"sdl\" propagated input of PACKAGE with SDL2."
345 (package-propagated-inputs package)))
347 (define-public sdl2-image
348 (package (inherit sdl-image)
354 (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL2_image-"
358 "1s3ciydixrgv34vlf45ak5syq5nlfaqf19wf162lbz4ixxd0gpvj"))))
360 (propagated-inputs-with-sdl2 sdl-image))))
362 (define-public sdl2-mixer
363 (package (inherit sdl-mixer)
369 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-"
371 (modules '((guix build utils)))
373 ;; Remove bundled libraries.
374 (delete-file-recursively "external")
378 "1fw3kkqi5346ai5if4pxrcbhs5c4vv3a4smgz6fl6kyaxwkmwqaf"))))
380 (propagated-inputs-with-sdl2 sdl-mixer))))
382 (define-public sdl2-ttf
383 (package (inherit sdl-ttf)
389 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-"
391 (modules '((guix build utils)))
393 ;; Remove bundled libraries.
394 '(delete-file-recursively "external")
398 "0xljwcpvd2knrjdfag5b257xqayplz55mqlszrqp0kpnphh5xnrl"))))
400 (propagated-inputs-with-sdl2 sdl-ttf))))
402 (define-public guile-sdl
409 (string-append "mirror://gnu/guile-sdl/guile-sdl-"
413 "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
414 (build-system gnu-build-system)
416 `(("pkg-config" ,pkg-config)
417 ;; Required by test suite.
418 ("xorg-server" ,xorg-server)
419 ("libjpeg" ,libjpeg)))
421 `(("guile" ,guile-2.2)
422 ("sdl-union" ,(sdl-union))))
425 (list (string-append "--with-sdl-prefix="
426 (assoc-ref %build-inputs "sdl-union")))
427 #:modules ((ice-9 popen)
429 (guix build gnu-build-system))
431 #:parallel-build? #f ; parallel build fails
434 (modify-phases %standard-phases
435 (add-before 'configure 'fix-env-and-patch
436 (lambda* (#:key inputs #:allow-other-keys)
437 (setenv "GUILE_AUTO_COMPILE" "0")
438 ;; SDL_image needs to dlopen libjpeg in the test suite.
439 (setenv "LD_LIBRARY_PATH"
440 (string-append (assoc-ref inputs "libjpeg") "/lib"))
442 ;; Change the site directory /site/X.Y like Guile expects.
443 (substitute* "build-aux/guile-baux/re-prefixed-site-dirs"
447 (open-pipe* OPEN_READ
449 "(write (effective-version))"))))
450 (string-append "\"/site/" effective "\""))))
452 ;; Skip tests that rely on sound support, which is unavailable in
453 ;; the build environment.
454 (substitute* "test/Makefile.in"
455 (("HAVE_MIXER = .*$")
458 (add-before 'check 'start-xorg-server
459 (lambda* (#:key inputs #:allow-other-keys)
460 ;; The test suite requires a running X server.
461 (system (format #f "~a/bin/Xvfb :1 &"
462 (assoc-ref inputs "xorg-server")))
463 (setenv "DISPLAY" ":1")
465 (add-before 'check 'skip-cursor-test
467 ;; XXX: This test sometimes enters an endless loop, and sometimes
469 ;; guile: xcb_io.c:147: append_pending_request: Assertion `!xcb_xlib_unknown_seq_number' failed.
471 (substitute* "test/cursor.scm"
472 (("\\(SDL:init .*" all)
473 (string-append "(exit 77) ;" all "\n")))
475 (synopsis "Guile interface for SDL (Simple DirectMedia Layer)")
476 (description "Guile-SDL is a set of bindings to the Simple DirectMedia
477 Layer (SDL). With them, Guile programmers can have easy access to graphics,
478 sound and device input (keyboards, joysticks, mice, etc.).")
479 (home-page "https://www.gnu.org/software/guile-sdl/")
482 (define-public guile-sdl2
489 "https://files.dthompson.us/guile-sdl2/guile-sdl2-"
493 "0yq9lsl17cdvj77padvpk3jcw2g6g0pck9jrchc7n2767rrc012b"))))
494 (build-system gnu-build-system)
496 '(#:make-flags '("GUILE_AUTO_COMPILE=0")
498 (list (string-append "--with-libsdl2-prefix="
499 (assoc-ref %build-inputs "sdl2"))
500 (string-append "--with-libsdl2-image-prefix="
501 (assoc-ref %build-inputs "sdl2-image"))
502 (string-append "--with-libsdl2-ttf-prefix="
503 (assoc-ref %build-inputs "sdl2-ttf"))
504 (string-append "--with-libsdl2-mixer-prefix="
505 (assoc-ref %build-inputs "sdl2-mixer")))))
507 `(("guile" ,guile-2.0)
508 ("pkg-config" ,pkg-config)))
511 ("sdl2-image" ,sdl2-image)
512 ("sdl2-mixer" ,sdl2-mixer)
513 ("sdl2-ttf" ,sdl2-ttf)))
514 (synopsis "Guile bindings for SDL2")
515 (home-page "https://dthompson.us/projects/guile-sdl2.html")
517 "Guile-SDL2 provides Guile Scheme bindings for the SDL2 C shared library.
518 The bindings are written in pure Scheme using Guile's foreign function