1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2015 David Thompson <dthompson2@worcester.edu>
3 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
5 ;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
7 ;;; This file is part of GNU Guix.
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22 (define-module (gnu packages sdl)
23 #:use-module (ice-9 match)
24 #:use-module (gnu packages)
25 #:use-module ((guix licenses) #:hide (freetype))
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix build-system trivial)
30 #:use-module (gnu packages audio)
31 #:use-module (gnu packages fontutils)
32 #:use-module (gnu packages guile)
33 #:use-module (gnu packages image)
34 #:use-module (gnu packages linux)
35 #:use-module (gnu packages mp3)
36 #:use-module (gnu packages pkg-config)
37 #:use-module (gnu packages pulseaudio)
38 #:use-module (gnu packages gl)
39 #:use-module (gnu packages xiph)
40 #:use-module (gnu packages xorg)
50 (string-append "http://libsdl.org/release/SDL-"
54 "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"))
55 (patches (search-patches "sdl-libx11-1.6.patch"))))
56 (build-system gnu-build-system)
58 '(;; Explicitly link against shared libraries instead of dlopening them.
59 ;; For X11, ALSA, and PulseAudio.
60 ;; OpenGL library is still dlopened at runtime.
61 #:configure-flags '("--disable-alsa-shared"
62 "--disable-pulseaudio-shared"
63 "--disable-x11-shared"
64 ;; Explicitly link with mesa.
65 ;; This add mesa to libsdl's RUNPATH, to make dlopen
66 ;; finding the libGL from mesa at runtime.
69 #:tests? #f)) ; no check target
71 ;; SDL headers include X11 headers.
73 ("libcap" ,libcap))) ; 'libSDL.la' contain `-lcap'.
74 (native-inputs `(("pkg-config" ,pkg-config)))
75 (inputs `(("libxrandr" ,libxrandr)
78 ("alsa-lib" ,alsa-lib)
79 ("pulseaudio" ,pulseaudio)))
80 (synopsis "Cross platform game development library")
81 (description "Simple DirectMedia Layer is a cross-platform development
82 library designed to provide low level access to audio, keyboard, mouse,
83 joystick, and graphics hardware.")
84 (home-page "http://libsdl.org/")
88 (package (inherit sdl)
94 (string-append "http://libsdl.org/release/SDL2-"
98 "0jqp46mxxbh9lhpx1ih6sp93k752j2smhpc0ad0q4cb3px0famfs"))))
101 (define-public libmikmod
107 (uri (string-append "mirror://sourceforge/mikmod/libmikmod/"
108 version "/libmikmod-" version ".tar.gz"))
111 "18nrkf5l50hfg0y50yxr7bvik9f002lhn8c00nbcp6dgm5011x2c"))))
112 (build-system gnu-build-system)
114 ;; By default, libmikmod tries to dlopen libasound etc., which won't work
115 ;; unless the right libalsa happens to be in $LD_LIBRARY_PATH. Pass
116 ;; '--disable-dl' to avoid that.
117 '(#:configure-flags '("--disable-dl")))
118 (synopsis "Library for module sound formats")
120 "MikMod is able to play a wide range of module formats, as well as
121 digital sound files. It can take advantage of particular features of your
122 system, such as sound redirection over the network.")
124 (home-page "http://mikmod.sourceforge.net/")))
126 (define-public sdl-gfx
133 (string-append "http://www.ferzkopp.net/Software/SDL_gfx-2.0/SDL_gfx-"
137 "064islldm4r42lgj9fr4kbk66r7jmmakk9745hhyb1kmw71kib9h"))))
138 (build-system gnu-build-system)
139 (propagated-inputs `(("sdl" ,sdl)))
140 (synopsis "SDL graphics primitives library")
141 (description "SDL_gfx provides graphics drawing primitives, rotozoom and
142 other supporting functions for SDL.")
143 (home-page "http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx")
146 ;; The code apparently includes Intel assembly, which fails to build on
148 (supported-systems '("i686-linux" "x86_64-linux"))))
150 (define-public sdl-image
157 (string-append "http://www.libsdl.org/projects/SDL_image/release/SDL_image-"
161 "16an9slbb8ci7d89wakkmyfvp7c0cval8xw4hkg0842nhhlp540b"))))
162 (build-system gnu-build-system)
164 ;; Explicitly link against shared libraries instead of dlopening them.
165 '(#:configure-flags '("--disable-jpg-shared"
166 "--disable-png-shared"
167 "--disable-tif-shared"
168 "--disable-webp-shared")))
169 (native-inputs `(("pkg-config" ,pkg-config)))
170 ;; libjpeg, libpng, and libtiff are propagated inputs because the
171 ;; SDL_image headers include the headers of these libraries. SDL is a
172 ;; propagated input because the pkg-config file refers to SDL's pkg-config
174 (propagated-inputs `(("sdl" ,sdl)
178 ("libwebp" ,libwebp)))
179 (synopsis "SDL image loading library")
180 (description "SDL_image is an image file loading library for SDL that
181 supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF,
182 WEBP, XCF, XPM, and XV.")
183 (home-page "http://www.libsdl.org/projects/SDL_image/")
186 (define-public sdl-mixer
193 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-"
197 "0alrhqgm40p4c92s26mimg9cm1y7rzr6m0p49687jxd9g6130i0n"))))
198 (build-system gnu-build-system)
200 ;; use libmad instead of smpeg
201 ;; explicitly link against shared libraries instead of dlopening them
202 (arguments `(#:tests? #f
203 #:configure-flags '("--enable-music-mp3-mad-gpl"
204 "--disable-music-mod-shared"
205 "--disable-music-fluidsynth-shared"
206 "--disable-music-ogg-shared"
207 "--disable-music-flac-shared"
208 "--disable-music-mp3-shared")))
209 (inputs `(("libvorbis" ,libvorbis)
212 ("libmikmod" ,libmikmod)
213 ("libmodplug" ,libmodplug)))
214 ;; FIXME: Add libfluidsynth
215 (propagated-inputs `(("sdl" ,sdl)))
216 (synopsis "SDL multi-channel audio mixer library")
217 (description "SDL_mixer is a multi-channel audio mixer library for SDL.
218 It supports any number of simultaneously playing channels of 16 bit stereo
219 audio, plus a single channel of music. Supported format include FLAC, MOD,
220 MIDI, Ogg Vorbis, and MP3.")
221 (home-page "http://www.libsdl.org/projects/SDL_mixer/")
224 (define-public sdl-net
231 (string-append "http://www.libsdl.org/projects/SDL_net/release/SDL_net-"
235 "1d5c9xqlf4s1c01gzv6cxmg0r621pq9kfgxcg3197xw4p25pljjz"))))
236 (build-system gnu-build-system)
237 (propagated-inputs `(("sdl" ,sdl)))
238 (native-inputs `(("pkg-config" ,pkg-config)))
239 (synopsis "SDL networking library")
240 (description "SDL_net is a small, cross-platform networking library for
242 (home-page "http://www.libsdl.org/projects/SDL_net/")
245 (define-public sdl-ttf
252 (string-append "http://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
256 "1dydxd4f5kb1288i5n5568kdk2q7f8mqjr7i7sd33nplxjaxhk3j"))))
257 (build-system gnu-build-system)
258 (propagated-inputs `(("sdl" ,sdl)))
259 (inputs `(("freetype" ,freetype)
261 (native-inputs `(("pkg-config" ,pkg-config)))
262 (synopsis "SDL TrueType font library")
263 (description "SDL_ttf is a TrueType font rendering library for SDL.")
264 (home-page "http://www.libsdl.org/projects/SDL_ttf/")
267 (define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
268 sdl-image sdl-mixer)))
269 "Return 'sdl-union' package which is a union of PACKAGES.
270 If PACKAGES are not specified, all SDL packages are used."
273 (version (package-version sdl))
275 (build-system trivial-build-system)
277 '(#:modules ((guix build union))
279 (use-modules (ice-9 match)
282 (((names . directories) ...)
283 (union-build (assoc-ref %outputs "out")
285 (inputs (map (lambda (package)
286 (list (package-name package) package))
288 (synopsis "Union of SDL libraries")
290 "A union of SDL and its extension libraries. A union is required because
291 sdl-config assumes that all of the headers and libraries are in the same
293 (home-page (package-home-page sdl))
294 (license (package-license sdl))))
296 (define (propagated-inputs-with-sdl2 package)
297 "Replace the \"sdl\" propagated input of PACKAGE with SDL2."
302 (package-propagated-inputs package)))
304 (define-public sdl2-image
305 (package (inherit sdl-image)
311 (string-append "http://www.libsdl.org/projects/SDL_image/release/SDL2_image-"
315 "0r3z1l7fdn76qkpy7snpkcjqz8dkv2zp6lsqpq25q4m5xsyaygis"))))
317 (propagated-inputs-with-sdl2 sdl-image))))
319 (define-public sdl2-mixer
320 (package (inherit sdl-mixer)
326 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-"
328 (modules '((guix build utils)))
330 ;; Remove bundled libraries.
331 '(delete-file-recursively "external"))
334 "0pv9jzjpcjlbiaybvwrb4avmv46qk7iqxlnqrd2dfj82c4mgc92s"))))
336 (propagated-inputs-with-sdl2 sdl-mixer))))
338 (define-public sdl2-ttf
339 (package (inherit sdl-ttf)
345 (string-append "http://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-"
347 (modules '((guix build utils)))
349 ;; Remove bundled libraries.
350 '(delete-file-recursively "external"))
353 "0xljwcpvd2knrjdfag5b257xqayplz55mqlszrqp0kpnphh5xnrl"))))
355 (propagated-inputs-with-sdl2 sdl-ttf))))
357 (define-public guile-sdl
364 (string-append "mirror://gnu/guile-sdl/guile-sdl-"
368 "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
369 (build-system gnu-build-system)
371 `(("pkg-config" ,pkg-config)
372 ;; Required by test suite.
373 ("xorg-server" ,xorg-server)
374 ("libjpeg" ,libjpeg)))
376 `(("guile" ,guile-2.0)
377 ("sdl-union" ,(sdl-union))))
380 (list (string-append "--with-sdl-prefix="
381 (assoc-ref %build-inputs "sdl-union")))
382 #:parallel-build? #f ; parallel build fails
385 'configure 'fix-env-and-patch
386 (lambda* (#:key inputs #:allow-other-keys)
387 (setenv "GUILE_AUTO_COMPILE" "0")
388 ;; SDL_image needs to dlopen libjpeg in the test suite.
389 (setenv "LD_LIBRARY_PATH"
390 (string-append (assoc-ref inputs "libjpeg") "/lib"))
391 ;; Change the site directory /site/2.0 like Guile expects.
392 (substitute* "build-aux/guile-baux/re-prefixed-site-dirs"
393 (("\"/site\"") "\"/site/2.0\""))
395 ;; Skip tests that rely on sound support, which is unavailable in
396 ;; the build environment.
397 (substitute* "test/Makefile.in"
398 (("HAVE_MIXER = .*$")
399 "HAVE_MIXER = 0\n")))
401 'check 'start-xorg-server
402 (lambda* (#:key inputs #:allow-other-keys)
403 ;; The test suite requires a running X server.
404 (system (format #f "~a/bin/Xvfb :1 &"
405 (assoc-ref inputs "xorg-server")))
406 (setenv "DISPLAY" ":1"))
408 (synopsis "Guile interface for SDL (Simple DirectMedia Layer)")
409 (description "Guile-SDL is a set of bindings to the Simple DirectMedia
410 Layer (SDL). With them, Guile programmers can have easy access to graphics,
411 sound and device input (keyboards, joysticks, mice, etc.).")
412 (home-page "http://gnu.org/s/guile-sdl")