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>
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 (srfi srfi-1)
26 #:use-module (srfi srfi-26)
27 #:use-module (gnu packages)
28 #:use-module ((guix licenses) #:hide (freetype))
29 #:use-module (guix packages)
30 #:use-module (guix download)
31 #:use-module (guix build-system gnu)
32 #:use-module (guix build-system trivial)
33 #:use-module (gnu packages audio)
34 #:use-module (gnu packages fcitx)
35 #:use-module (gnu packages fontutils)
36 #:use-module (gnu packages glib)
37 #:use-module (gnu packages guile)
38 #:use-module (gnu packages ibus)
39 #:use-module (gnu packages image)
40 #:use-module (gnu packages linux)
41 #:use-module (gnu packages mp3)
42 #:use-module (gnu packages pkg-config)
43 #:use-module (gnu packages pulseaudio)
44 #:use-module (gnu packages gl)
45 #:use-module (gnu packages xiph)
46 #:use-module (gnu packages xorg)
56 (string-append "https://libsdl.org/release/SDL-"
60 "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"))
61 (patches (search-patches "sdl-libx11-1.6.patch"))))
62 (build-system gnu-build-system)
64 '(;; Explicitly link against shared libraries instead of dlopening them.
65 ;; For X11, ALSA, and PulseAudio.
66 ;; OpenGL library is still dlopened at runtime.
67 #:configure-flags '("--disable-alsa-shared"
68 "--disable-pulseaudio-shared"
69 "--disable-x11-shared"
70 ;; Explicitly link with mesa.
71 ;; This add mesa to libsdl's RUNPATH, to make dlopen
72 ;; finding the libGL from mesa at runtime.
75 #:tests? #f)) ; no check target
77 ;; SDL headers include X11 headers.
79 ("libcap" ,libcap))) ; 'libSDL.la' contain `-lcap'.
80 (native-inputs `(("pkg-config" ,pkg-config)))
81 (inputs `(("libxrandr" ,libxrandr)
84 ("alsa-lib" ,alsa-lib)
85 ("pulseaudio" ,pulseaudio)))
86 (synopsis "Cross platform game development library")
87 (description "Simple DirectMedia Layer is a cross-platform development
88 library designed to provide low level access to audio, keyboard, mouse,
89 joystick, and graphics hardware.")
90 (home-page "https://libsdl.org/")
94 (package (inherit sdl)
100 (string-append "https://libsdl.org/release/SDL2-"
104 "11c75qj1qxmx67iwkvf9z4x69phk301pdn86zzr6jncnap7kh824"))))
106 ;; SDL2 needs to be built with ibus support otherwise some systems
107 ;; experience a bug where input events are doubled.
109 ;; For more information, see: https://dev.solus-project.com/T1721
110 (append `(("dbus" ,dbus)
111 ("fcitx" ,fcitx) ; helps with CJK input
114 (package-inputs sdl)))
117 (define-public libmikmod
124 (string-append "mirror://sourceforge/mikmod/libmikmod/"
125 version "/libmikmod-" version ".tar.gz")
126 ;; Older versions are sometimes moved to:
127 (string-append "mirror://sourceforge/mikmod/"
128 "outdated_versions/libmikmod/"
129 version "/libmikmod-" version ".tar.gz")))
132 "0j7g4jpa2zgzw7x6s3rldypa7zlwjvn97rwx0sylx1iihhlzbcq0"))))
133 (build-system gnu-build-system)
135 ;; By default, libmikmod tries to dlopen libasound etc., which won't work
136 ;; unless the right libalsa happens to be in $LD_LIBRARY_PATH. Pass
137 ;; '--disable-dl' to avoid that.
138 '(#:configure-flags '("--disable-dl")))
139 (synopsis "Library for module sound formats")
141 "MikMod is able to play a wide range of module formats, as well as
142 digital sound files. It can take advantage of particular features of your
143 system, such as sound redirection over the network.")
145 (home-page "http://mikmod.sourceforge.net/")))
147 (define-public sdl-gfx
154 (string-append "http://www.ferzkopp.net/Software/SDL_gfx-2.0/SDL_gfx-"
158 "0ijljhs0v99dj6y27hc10z6qchyp8gdp4199y6jzngy6dzxlzsvw"))))
159 (build-system gnu-build-system)
161 `(,@(if (any (cute string-prefix? <> (or (%current-system)
162 (%current-target-system)))
164 ;; mmx is supported only on Intel processors.
166 '(#:configure-flags '("--disable-mmx")))))
167 (propagated-inputs `(("sdl" ,sdl)))
168 (synopsis "SDL graphics primitives library")
169 (description "SDL_gfx provides graphics drawing primitives, rotozoom and
170 other supporting functions for SDL.")
171 (home-page "http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx")
174 (define-public sdl-image
181 (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL_image-"
185 "16an9slbb8ci7d89wakkmyfvp7c0cval8xw4hkg0842nhhlp540b"))))
186 (build-system gnu-build-system)
188 ;; Explicitly link against shared libraries instead of dlopening them.
189 '(#:configure-flags '("--disable-jpg-shared"
190 "--disable-png-shared"
191 "--disable-tif-shared"
192 "--disable-webp-shared")))
193 (native-inputs `(("pkg-config" ,pkg-config)))
194 ;; libjpeg, libpng, and libtiff are propagated inputs because the
195 ;; SDL_image headers include the headers of these libraries. SDL is a
196 ;; propagated input because the pkg-config file refers to SDL's pkg-config
198 (propagated-inputs `(("sdl" ,sdl)
202 ("libwebp" ,libwebp)))
203 (synopsis "SDL image loading library")
204 (description "SDL_image is an image file loading library for SDL that
205 supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF,
206 WEBP, XCF, XPM, and XV.")
207 (home-page "https://www.libsdl.org/projects/SDL_image/")
210 (define-public sdl-mixer
217 (string-append "https://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-"
221 "0alrhqgm40p4c92s26mimg9cm1y7rzr6m0p49687jxd9g6130i0n"))))
222 (build-system gnu-build-system)
224 ;; use libmad instead of smpeg
225 ;; explicitly link against shared libraries instead of dlopening them
226 (arguments `(#:tests? #f
227 #:configure-flags '("--enable-music-mp3-mad-gpl"
228 "--disable-music-mod-shared"
229 "--disable-music-fluidsynth-shared"
230 "--disable-music-ogg-shared"
231 "--disable-music-flac-shared"
232 "--disable-music-mp3-shared")))
233 (inputs `(("libvorbis" ,libvorbis)
236 ("libmikmod" ,libmikmod)
237 ("libmodplug" ,libmodplug)))
238 ;; FIXME: Add libfluidsynth
239 (propagated-inputs `(("sdl" ,sdl)))
240 (synopsis "SDL multi-channel audio mixer library")
241 (description "SDL_mixer is a multi-channel audio mixer library for SDL.
242 It supports any number of simultaneously playing channels of 16 bit stereo
243 audio, plus a single channel of music. Supported format include FLAC, MOD,
244 MIDI, Ogg Vorbis, and MP3.")
245 (home-page "https://www.libsdl.org/projects/SDL_mixer/")
248 (define-public sdl-net
255 (string-append "https://www.libsdl.org/projects/SDL_net/release/SDL_net-"
259 "1d5c9xqlf4s1c01gzv6cxmg0r621pq9kfgxcg3197xw4p25pljjz"))))
260 (build-system gnu-build-system)
261 (propagated-inputs `(("sdl" ,sdl)))
262 (native-inputs `(("pkg-config" ,pkg-config)))
263 (synopsis "SDL networking library")
264 (description "SDL_net is a small, cross-platform networking library for
266 (home-page "https://www.libsdl.org/projects/SDL_net/")
269 (define-public sdl-ttf
276 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
280 "1dydxd4f5kb1288i5n5568kdk2q7f8mqjr7i7sd33nplxjaxhk3j"))))
281 (build-system gnu-build-system)
282 (propagated-inputs `(("sdl" ,sdl)))
283 (inputs `(("freetype" ,freetype)
285 (native-inputs `(("pkg-config" ,pkg-config)))
286 (synopsis "SDL TrueType font library")
287 (description "SDL_ttf is a TrueType font rendering library for SDL.")
288 (home-page "https://www.libsdl.org/projects/SDL_ttf/")
291 (define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
292 sdl-image sdl-mixer)))
293 "Return 'sdl-union' package which is a union of PACKAGES.
294 If PACKAGES are not specified, all SDL packages are used."
297 (version (package-version sdl))
299 (build-system trivial-build-system)
301 '(#:modules ((guix build union))
303 (use-modules (ice-9 match)
306 (((names . directories) ...)
307 (union-build (assoc-ref %outputs "out")
309 (inputs (map (lambda (package)
310 (list (package-name package) package))
312 (synopsis "Union of SDL libraries")
314 "A union of SDL and its extension libraries. A union is required because
315 sdl-config assumes that all of the headers and libraries are in the same
317 (home-page (package-home-page sdl))
318 (license (package-license sdl))))
320 (define (propagated-inputs-with-sdl2 package)
321 "Replace the \"sdl\" propagated input of PACKAGE with SDL2."
326 (package-propagated-inputs package)))
328 (define-public sdl2-image
329 (package (inherit sdl-image)
335 (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL2_image-"
339 "0r3z1l7fdn76qkpy7snpkcjqz8dkv2zp6lsqpq25q4m5xsyaygis"))))
341 (propagated-inputs-with-sdl2 sdl-image))))
343 (define-public sdl2-mixer
344 (package (inherit sdl-mixer)
350 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-"
352 (modules '((guix build utils)))
354 ;; Remove bundled libraries.
355 '(delete-file-recursively "external"))
358 "0pv9jzjpcjlbiaybvwrb4avmv46qk7iqxlnqrd2dfj82c4mgc92s"))))
360 (propagated-inputs-with-sdl2 sdl-mixer))))
362 (define-public sdl2-ttf
363 (package (inherit sdl-ttf)
369 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-"
371 (modules '((guix build utils)))
373 ;; Remove bundled libraries.
374 '(delete-file-recursively "external"))
377 "0xljwcpvd2knrjdfag5b257xqayplz55mqlszrqp0kpnphh5xnrl"))))
379 (propagated-inputs-with-sdl2 sdl-ttf))))
381 (define-public guile-sdl
388 (string-append "mirror://gnu/guile-sdl/guile-sdl-"
392 "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
393 (build-system gnu-build-system)
395 `(("pkg-config" ,pkg-config)
396 ;; Required by test suite.
397 ("xorg-server" ,xorg-server)
398 ("libjpeg" ,libjpeg)))
400 `(("guile" ,guile-2.0)
401 ("sdl-union" ,(sdl-union))))
404 (list (string-append "--with-sdl-prefix="
405 (assoc-ref %build-inputs "sdl-union")))
406 #:parallel-build? #f ; parallel build fails
408 (modify-phases %standard-phases
409 (add-before 'configure 'fix-env-and-patch
410 (lambda* (#:key inputs #:allow-other-keys)
411 (setenv "GUILE_AUTO_COMPILE" "0")
412 ;; SDL_image needs to dlopen libjpeg in the test suite.
413 (setenv "LD_LIBRARY_PATH"
414 (string-append (assoc-ref inputs "libjpeg") "/lib"))
415 ;; Change the site directory /site/2.0 like Guile expects.
416 (substitute* "build-aux/guile-baux/re-prefixed-site-dirs"
417 (("\"/site\"") "\"/site/2.0\""))
419 ;; Skip tests that rely on sound support, which is unavailable in
420 ;; the build environment.
421 (substitute* "test/Makefile.in"
422 (("HAVE_MIXER = .*$")
425 (add-before 'check 'start-xorg-server
426 (lambda* (#:key inputs #:allow-other-keys)
427 ;; The test suite requires a running X server.
428 (system (format #f "~a/bin/Xvfb :1 &"
429 (assoc-ref inputs "xorg-server")))
430 (setenv "DISPLAY" ":1")
432 (synopsis "Guile interface for SDL (Simple DirectMedia Layer)")
433 (description "Guile-SDL is a set of bindings to the Simple DirectMedia
434 Layer (SDL). With them, Guile programmers can have easy access to graphics,
435 sound and device input (keyboards, joysticks, mice, etc.).")
436 (home-page "https://www.gnu.org/software/guile-sdl/")
439 (define-public guile-sdl2
446 "https://files.dthompson.us/guile-sdl2/guile-sdl2-"
450 "0yq9lsl17cdvj77padvpk3jcw2g6g0pck9jrchc7n2767rrc012b"))))
451 (build-system gnu-build-system)
453 '(#:make-flags '("GUILE_AUTO_COMPILE=0")
455 (list (string-append "--with-libsdl2-prefix="
456 (assoc-ref %build-inputs "sdl2"))
457 (string-append "--with-libsdl2-image-prefix="
458 (assoc-ref %build-inputs "sdl2-image"))
459 (string-append "--with-libsdl2-ttf-prefix="
460 (assoc-ref %build-inputs "sdl2-ttf"))
461 (string-append "--with-libsdl2-mixer-prefix="
462 (assoc-ref %build-inputs "sdl2-mixer")))))
464 `(("guile" ,guile-2.0)
465 ("pkg-config" ,pkg-config)))
468 ("sdl2-image" ,sdl2-image)
469 ("sdl2-mixer" ,sdl2-mixer)
470 ("sdl2-ttf" ,sdl2-ttf)))
471 (synopsis "Guile bindings for SDL2")
472 (home-page "https://dthompson.us/projects/guile-sdl2.html")
474 "Guile-SDL2 provides Guile Scheme bindings for the SDL2 C shared library.
475 The bindings are written in pure Scheme using Guile's foreign function