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 Efraim Flashner <efraim@flashner.co.il>
8 ;;; This file is part of GNU Guix.
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23 (define-module (gnu packages sdl)
24 #:use-module (ice-9 match)
25 #:use-module (gnu packages)
26 #:use-module ((guix licenses) #:hide (freetype))
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix build-system gnu)
30 #:use-module (guix build-system trivial)
31 #:use-module (gnu packages audio)
32 #:use-module (gnu packages fcitx)
33 #:use-module (gnu packages fontutils)
34 #:use-module (gnu packages glib)
35 #:use-module (gnu packages guile)
36 #:use-module (gnu packages ibus)
37 #:use-module (gnu packages image)
38 #:use-module (gnu packages linux)
39 #:use-module (gnu packages mp3)
40 #:use-module (gnu packages pkg-config)
41 #:use-module (gnu packages pulseaudio)
42 #:use-module (gnu packages gl)
43 #:use-module (gnu packages xiph)
44 #:use-module (gnu packages xorg)
54 (string-append "https://libsdl.org/release/SDL-"
58 "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"))
59 (patches (search-patches "sdl-libx11-1.6.patch"))))
60 (build-system gnu-build-system)
62 '(;; Explicitly link against shared libraries instead of dlopening them.
63 ;; For X11, ALSA, and PulseAudio.
64 ;; OpenGL library is still dlopened at runtime.
65 #:configure-flags '("--disable-alsa-shared"
66 "--disable-pulseaudio-shared"
67 "--disable-x11-shared"
68 ;; Explicitly link with mesa.
69 ;; This add mesa to libsdl's RUNPATH, to make dlopen
70 ;; finding the libGL from mesa at runtime.
73 #:tests? #f)) ; no check target
75 ;; SDL headers include X11 headers.
77 ("libcap" ,libcap))) ; 'libSDL.la' contain `-lcap'.
78 (native-inputs `(("pkg-config" ,pkg-config)))
79 (inputs `(("libxrandr" ,libxrandr)
82 ("alsa-lib" ,alsa-lib)
83 ("pulseaudio" ,pulseaudio)))
84 (synopsis "Cross platform game development library")
85 (description "Simple DirectMedia Layer is a cross-platform development
86 library designed to provide low level access to audio, keyboard, mouse,
87 joystick, and graphics hardware.")
88 (home-page "https://libsdl.org/")
92 (package (inherit sdl)
98 (string-append "https://libsdl.org/release/SDL2-"
102 "11c75qj1qxmx67iwkvf9z4x69phk301pdn86zzr6jncnap7kh824"))))
104 ;; SDL2 needs to be built with ibus support otherwise some systems
105 ;; experience a bug where input events are doubled.
107 ;; For more information, see: https://dev.solus-project.com/T1721
108 (append `(("dbus" ,dbus)
109 ("fcitx" ,fcitx) ; helps with CJK input
112 (package-inputs sdl)))
115 (define-public libmikmod
121 (uri (string-append "mirror://sourceforge/mikmod/libmikmod/"
122 version "/libmikmod-" version ".tar.gz"))
125 "0j7g4jpa2zgzw7x6s3rldypa7zlwjvn97rwx0sylx1iihhlzbcq0"))))
126 (build-system gnu-build-system)
128 ;; By default, libmikmod tries to dlopen libasound etc., which won't work
129 ;; unless the right libalsa happens to be in $LD_LIBRARY_PATH. Pass
130 ;; '--disable-dl' to avoid that.
131 '(#:configure-flags '("--disable-dl")))
132 (synopsis "Library for module sound formats")
134 "MikMod is able to play a wide range of module formats, as well as
135 digital sound files. It can take advantage of particular features of your
136 system, such as sound redirection over the network.")
138 (home-page "http://mikmod.sourceforge.net/")))
140 (define-public sdl-gfx
147 (string-append "http://www.ferzkopp.net/Software/SDL_gfx-2.0/SDL_gfx-"
151 "0ijljhs0v99dj6y27hc10z6qchyp8gdp4199y6jzngy6dzxlzsvw"))))
152 (build-system gnu-build-system)
153 (propagated-inputs `(("sdl" ,sdl)))
154 (synopsis "SDL graphics primitives library")
155 (description "SDL_gfx provides graphics drawing primitives, rotozoom and
156 other supporting functions for SDL.")
157 (home-page "http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx")
160 ;; The code apparently includes Intel assembly, which fails to build on
162 (supported-systems '("i686-linux" "x86_64-linux"))))
164 (define-public sdl-image
171 (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL_image-"
175 "16an9slbb8ci7d89wakkmyfvp7c0cval8xw4hkg0842nhhlp540b"))))
176 (build-system gnu-build-system)
178 ;; Explicitly link against shared libraries instead of dlopening them.
179 '(#:configure-flags '("--disable-jpg-shared"
180 "--disable-png-shared"
181 "--disable-tif-shared"
182 "--disable-webp-shared")))
183 (native-inputs `(("pkg-config" ,pkg-config)))
184 ;; libjpeg, libpng, and libtiff are propagated inputs because the
185 ;; SDL_image headers include the headers of these libraries. SDL is a
186 ;; propagated input because the pkg-config file refers to SDL's pkg-config
188 (propagated-inputs `(("sdl" ,sdl)
192 ("libwebp" ,libwebp)))
193 (synopsis "SDL image loading library")
194 (description "SDL_image is an image file loading library for SDL that
195 supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF,
196 WEBP, XCF, XPM, and XV.")
197 (home-page "https://www.libsdl.org/projects/SDL_image/")
200 (define-public sdl-mixer
207 (string-append "https://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-"
211 "0alrhqgm40p4c92s26mimg9cm1y7rzr6m0p49687jxd9g6130i0n"))))
212 (build-system gnu-build-system)
214 ;; use libmad instead of smpeg
215 ;; explicitly link against shared libraries instead of dlopening them
216 (arguments `(#:tests? #f
217 #:configure-flags '("--enable-music-mp3-mad-gpl"
218 "--disable-music-mod-shared"
219 "--disable-music-fluidsynth-shared"
220 "--disable-music-ogg-shared"
221 "--disable-music-flac-shared"
222 "--disable-music-mp3-shared")))
223 (inputs `(("libvorbis" ,libvorbis)
226 ("libmikmod" ,libmikmod)
227 ("libmodplug" ,libmodplug)))
228 ;; FIXME: Add libfluidsynth
229 (propagated-inputs `(("sdl" ,sdl)))
230 (synopsis "SDL multi-channel audio mixer library")
231 (description "SDL_mixer is a multi-channel audio mixer library for SDL.
232 It supports any number of simultaneously playing channels of 16 bit stereo
233 audio, plus a single channel of music. Supported format include FLAC, MOD,
234 MIDI, Ogg Vorbis, and MP3.")
235 (home-page "https://www.libsdl.org/projects/SDL_mixer/")
238 (define-public sdl-net
245 (string-append "https://www.libsdl.org/projects/SDL_net/release/SDL_net-"
249 "1d5c9xqlf4s1c01gzv6cxmg0r621pq9kfgxcg3197xw4p25pljjz"))))
250 (build-system gnu-build-system)
251 (propagated-inputs `(("sdl" ,sdl)))
252 (native-inputs `(("pkg-config" ,pkg-config)))
253 (synopsis "SDL networking library")
254 (description "SDL_net is a small, cross-platform networking library for
256 (home-page "https://www.libsdl.org/projects/SDL_net/")
259 (define-public sdl-ttf
266 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
270 "1dydxd4f5kb1288i5n5568kdk2q7f8mqjr7i7sd33nplxjaxhk3j"))))
271 (build-system gnu-build-system)
272 (propagated-inputs `(("sdl" ,sdl)))
273 (inputs `(("freetype" ,freetype)
275 (native-inputs `(("pkg-config" ,pkg-config)))
276 (synopsis "SDL TrueType font library")
277 (description "SDL_ttf is a TrueType font rendering library for SDL.")
278 (home-page "https://www.libsdl.org/projects/SDL_ttf/")
281 (define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
282 sdl-image sdl-mixer)))
283 "Return 'sdl-union' package which is a union of PACKAGES.
284 If PACKAGES are not specified, all SDL packages are used."
287 (version (package-version sdl))
289 (build-system trivial-build-system)
291 '(#:modules ((guix build union))
293 (use-modules (ice-9 match)
296 (((names . directories) ...)
297 (union-build (assoc-ref %outputs "out")
299 (inputs (map (lambda (package)
300 (list (package-name package) package))
302 (synopsis "Union of SDL libraries")
304 "A union of SDL and its extension libraries. A union is required because
305 sdl-config assumes that all of the headers and libraries are in the same
307 (home-page (package-home-page sdl))
308 (license (package-license sdl))))
310 (define (propagated-inputs-with-sdl2 package)
311 "Replace the \"sdl\" propagated input of PACKAGE with SDL2."
316 (package-propagated-inputs package)))
318 (define-public sdl2-image
319 (package (inherit sdl-image)
325 (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL2_image-"
329 "0r3z1l7fdn76qkpy7snpkcjqz8dkv2zp6lsqpq25q4m5xsyaygis"))))
331 (propagated-inputs-with-sdl2 sdl-image))))
333 (define-public sdl2-mixer
334 (package (inherit sdl-mixer)
340 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-"
342 (modules '((guix build utils)))
344 ;; Remove bundled libraries.
345 '(delete-file-recursively "external"))
348 "0pv9jzjpcjlbiaybvwrb4avmv46qk7iqxlnqrd2dfj82c4mgc92s"))))
350 (propagated-inputs-with-sdl2 sdl-mixer))))
352 (define-public sdl2-ttf
353 (package (inherit sdl-ttf)
359 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-"
361 (modules '((guix build utils)))
363 ;; Remove bundled libraries.
364 '(delete-file-recursively "external"))
367 "0xljwcpvd2knrjdfag5b257xqayplz55mqlszrqp0kpnphh5xnrl"))))
369 (propagated-inputs-with-sdl2 sdl-ttf))))
371 (define-public guile-sdl
378 (string-append "mirror://gnu/guile-sdl/guile-sdl-"
382 "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
383 (build-system gnu-build-system)
385 `(("pkg-config" ,pkg-config)
386 ;; Required by test suite.
387 ("xorg-server" ,xorg-server)
388 ("libjpeg" ,libjpeg)))
390 `(("guile" ,guile-2.0)
391 ("sdl-union" ,(sdl-union))))
394 (list (string-append "--with-sdl-prefix="
395 (assoc-ref %build-inputs "sdl-union")))
396 #:parallel-build? #f ; parallel build fails
399 'configure 'fix-env-and-patch
400 (lambda* (#:key inputs #:allow-other-keys)
401 (setenv "GUILE_AUTO_COMPILE" "0")
402 ;; SDL_image needs to dlopen libjpeg in the test suite.
403 (setenv "LD_LIBRARY_PATH"
404 (string-append (assoc-ref inputs "libjpeg") "/lib"))
405 ;; Change the site directory /site/2.0 like Guile expects.
406 (substitute* "build-aux/guile-baux/re-prefixed-site-dirs"
407 (("\"/site\"") "\"/site/2.0\""))
409 ;; Skip tests that rely on sound support, which is unavailable in
410 ;; the build environment.
411 (substitute* "test/Makefile.in"
412 (("HAVE_MIXER = .*$")
413 "HAVE_MIXER = 0\n")))
415 'check 'start-xorg-server
416 (lambda* (#:key inputs #:allow-other-keys)
417 ;; The test suite requires a running X server.
418 (system (format #f "~a/bin/Xvfb :1 &"
419 (assoc-ref inputs "xorg-server")))
420 (setenv "DISPLAY" ":1"))
422 (synopsis "Guile interface for SDL (Simple DirectMedia Layer)")
423 (description "Guile-SDL is a set of bindings to the Simple DirectMedia
424 Layer (SDL). With them, Guile programmers can have easy access to graphics,
425 sound and device input (keyboards, joysticks, mice, etc.).")
426 (home-page "https://www.gnu.org/software/guile-sdl/")
429 (define-public guile-sdl2
436 "https://files.dthompson.us/guile-sdl2/guile-sdl2-"
440 "0yq9lsl17cdvj77padvpk3jcw2g6g0pck9jrchc7n2767rrc012b"))))
441 (build-system gnu-build-system)
443 '(#:make-flags '("GUILE_AUTO_COMPILE=0")
445 (list (string-append "--with-libsdl2-prefix="
446 (assoc-ref %build-inputs "sdl2"))
447 (string-append "--with-libsdl2-image-prefix="
448 (assoc-ref %build-inputs "sdl2-image"))
449 (string-append "--with-libsdl2-ttf-prefix="
450 (assoc-ref %build-inputs "sdl2-ttf"))
451 (string-append "--with-libsdl2-mixer-prefix="
452 (assoc-ref %build-inputs "sdl2-mixer")))))
454 `(("guile" ,guile-2.0)
455 ("pkg-config" ,pkg-config)))
458 ("sdl2-image" ,sdl2-image)
459 ("sdl2-mixer" ,sdl2-mixer)
460 ("sdl2-ttf" ,sdl2-ttf)))
461 (synopsis "Guile bindings for SDL2")
462 (home-page "https://dthompson.us/projects/guile-sdl2.html")
464 "Guile-SDL2 provides Guile Scheme bindings for the SDL2 C shared library.
465 The bindings are written in pure Scheme using Guile's foreign function