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)
58 (string-append "http://libsdl.org/release/SDL-"
62 "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"))
63 (patches (search-patches "sdl-libx11-1.6.patch"))))
64 (build-system gnu-build-system)
66 '(;; Explicitly link against shared libraries instead of dlopening them.
67 ;; For X11, ALSA, and PulseAudio.
68 ;; OpenGL library is still dlopened at runtime.
69 #:configure-flags '("--disable-alsa-shared"
70 "--disable-pulseaudio-shared"
71 "--disable-x11-shared"
72 ;; Explicitly link with mesa.
73 ;; This add mesa to libsdl's RUNPATH, to make dlopen
74 ;; finding the libGL from mesa at runtime.
77 #:tests? #f)) ; no check target
79 ;; SDL headers include X11 headers.
81 ("libcap" ,libcap))) ; 'libSDL.la' contain `-lcap'.
82 (native-inputs `(("pkg-config" ,pkg-config)))
83 (inputs `(("libxrandr" ,libxrandr)
86 ("alsa-lib" ,alsa-lib)
87 ("pulseaudio" ,pulseaudio)))
88 (synopsis "Cross platform game development library")
89 (description "Simple DirectMedia Layer is a cross-platform development
90 library designed to provide low level access to audio, keyboard, mouse,
91 joystick, and graphics hardware.")
92 (home-page "http://libsdl.org/")
96 (package (inherit sdl)
102 (string-append "http://libsdl.org/release/SDL2-"
106 "0jqp46mxxbh9lhpx1ih6sp93k752j2smhpc0ad0q4cb3px0famfs"))))
115 (uri (string-append "mirror://sourceforge/mikmod/libmikmod/"
116 version "/libmikmod-" version ".tar.gz"))
119 "18nrkf5l50hfg0y50yxr7bvik9f002lhn8c00nbcp6dgm5011x2c"))))
120 (build-system gnu-build-system)
122 ;; By default, libmikmod tries to dlopen libasound etc., which won't work
123 ;; unless the right libalsa happens to be in $LD_LIBRARY_PATH. Pass
124 ;; '--disable-dl' to avoid that.
125 '(#:configure-flags '("--disable-dl")))
126 (synopsis "Library for module sound formats")
128 "MikMod is able to play a wide range of module formats, as well as
129 digital sound files. It can take advantage of particular features of your
130 system, such as sound redirection over the network.")
132 (home-page "http://mikmod.sourceforge.net/")))
141 (string-append "http://www.ferzkopp.net/Software/SDL_gfx-2.0/SDL_gfx-"
145 "064islldm4r42lgj9fr4kbk66r7jmmakk9745hhyb1kmw71kib9h"))))
146 (build-system gnu-build-system)
147 (propagated-inputs `(("sdl" ,sdl)))
148 (synopsis "SDL graphics primitives library")
149 (description "SDL_gfx provides graphics drawing primitives, rotozoom and
150 other supporting functions for SDL.")
151 (home-page "http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx")
154 ;; The code apparently includes Intel assembly, which fails to build on
156 (supported-systems '("i686-linux" "x86_64-linux"))))
165 (string-append "http://www.libsdl.org/projects/SDL_image/release/SDL_image-"
169 "16an9slbb8ci7d89wakkmyfvp7c0cval8xw4hkg0842nhhlp540b"))))
170 (build-system gnu-build-system)
172 ;; Explicitly link against shared libraries instead of dlopening them.
173 '(#:configure-flags '("--disable-jpg-shared"
174 "--disable-png-shared"
175 "--disable-tif-shared"
176 "--disable-webp-shared")))
177 (native-inputs `(("pkg-config" ,pkg-config)))
178 ;; libjpeg, libpng, and libtiff are propagated inputs because the
179 ;; SDL_image headers include the headers of these libraries. SDL is a
180 ;; propagated input because the pkg-config file refers to SDL's pkg-config
182 (propagated-inputs `(("sdl" ,sdl)
186 ("libwebp" ,libwebp)))
187 (synopsis "SDL image loading library")
188 (description "SDL_image is an image file loading library for SDL that
189 supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF,
190 WEBP, XCF, XPM, and XV.")
191 (home-page "http://www.libsdl.org/projects/SDL_image/")
201 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-"
205 "0alrhqgm40p4c92s26mimg9cm1y7rzr6m0p49687jxd9g6130i0n"))))
206 (build-system gnu-build-system)
208 ;; use libmad instead of smpeg
209 ;; explicitly link against shared libraries instead of dlopening them
210 (arguments `(#:tests? #f
211 #:configure-flags '("--enable-music-mp3-mad-gpl"
212 "--disable-music-mod-shared"
213 "--disable-music-fluidsynth-shared"
214 "--disable-music-ogg-shared"
215 "--disable-music-flac-shared"
216 "--disable-music-mp3-shared")))
217 (inputs `(("libvorbis" ,libvorbis)
220 ("libmikmod" ,libmikmod)
221 ("libmodplug" ,libmodplug)))
222 ;; FIXME: Add libfluidsynth
223 (propagated-inputs `(("sdl" ,sdl)))
224 (synopsis "SDL multi-channel audio mixer library")
225 (description "SDL_mixer is a multi-channel audio mixer library for SDL.
226 It supports any number of simultaneously playing channels of 16 bit stereo
227 audio, plus a single channel of music. Supported format include FLAC, MOD,
228 MIDI, Ogg Vorbis, and MP3.")
229 (home-page "http://www.libsdl.org/projects/SDL_mixer/")
239 (string-append "http://www.libsdl.org/projects/SDL_net/release/SDL_net-"
243 "1d5c9xqlf4s1c01gzv6cxmg0r621pq9kfgxcg3197xw4p25pljjz"))))
244 (build-system gnu-build-system)
245 (propagated-inputs `(("sdl" ,sdl)))
246 (native-inputs `(("pkg-config" ,pkg-config)))
247 (synopsis "SDL networking library")
248 (description "SDL_net is a small, cross-platform networking library for
250 (home-page "http://www.libsdl.org/projects/SDL_net/")
260 (string-append "http://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
264 "1dydxd4f5kb1288i5n5568kdk2q7f8mqjr7i7sd33nplxjaxhk3j"))))
265 (build-system gnu-build-system)
266 (propagated-inputs `(("sdl" ,sdl)))
267 (inputs `(("freetype" ,freetype)
269 (native-inputs `(("pkg-config" ,pkg-config)))
270 (synopsis "SDL TrueType font library")
271 (description "SDL_ttf is a TrueType font rendering library for SDL.")
272 (home-page "http://www.libsdl.org/projects/SDL_ttf/")
275 (define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
276 sdl-image sdl-mixer)))
277 "Return 'sdl-union' package which is a union of PACKAGES.
278 If PACKAGES are not specified, all SDL packages are used."
281 (version (package-version sdl))
283 (build-system trivial-build-system)
285 '(#:modules ((guix build union))
287 (use-modules (ice-9 match)
290 (((names . directories) ...)
291 (union-build (assoc-ref %outputs "out")
293 (inputs (map (lambda (package)
294 (list (package-name package) package))
296 (synopsis "Union of SDL libraries")
298 "A union of SDL and its extension libraries. A union is required because
299 sdl-config assumes that all of the headers and libraries are in the same
301 (home-page (package-home-page sdl))
302 (license (package-license sdl))))
304 (define (propagated-inputs-with-sdl2 package)
305 "Replace the \"sdl\" propagated input of PACKAGE with SDL2."
310 (package-propagated-inputs package)))
312 (define-public sdl2-image
313 (package (inherit sdl-image)
319 (string-append "http://www.libsdl.org/projects/SDL_image/release/SDL2_image-"
323 "0r3z1l7fdn76qkpy7snpkcjqz8dkv2zp6lsqpq25q4m5xsyaygis"))))
325 (propagated-inputs-with-sdl2 sdl-image))))
327 (define-public sdl2-mixer
328 (package (inherit sdl-mixer)
334 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-"
336 (modules '((guix build utils)))
338 ;; Remove bundled libraries.
339 '(delete-file-recursively "external"))
342 "0pv9jzjpcjlbiaybvwrb4avmv46qk7iqxlnqrd2dfj82c4mgc92s"))))
344 (propagated-inputs-with-sdl2 sdl-mixer))))
346 (define-public sdl2-ttf
347 (package (inherit sdl-ttf)
353 (string-append "http://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-"
355 (modules '((guix build utils)))
357 ;; Remove bundled libraries.
358 '(delete-file-recursively "external"))
361 "0xljwcpvd2knrjdfag5b257xqayplz55mqlszrqp0kpnphh5xnrl"))))
363 (propagated-inputs-with-sdl2 sdl-ttf))))
365 (define-public guile-sdl
372 (string-append "mirror://gnu/guile-sdl/guile-sdl-"
376 "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
377 (build-system gnu-build-system)
379 `(("pkg-config" ,pkg-config)
380 ;; Required by test suite.
381 ("xorg-server" ,xorg-server)
382 ("libjpeg" ,libjpeg)))
384 `(("guile" ,guile-2.0)
385 ("sdl-union" ,(sdl-union))))
388 (list (string-append "--with-sdl-prefix="
389 (assoc-ref %build-inputs "sdl-union")))
390 #:parallel-build? #f ; parallel build fails
393 'configure 'fix-env-and-patch
394 (lambda* (#:key inputs #:allow-other-keys)
395 (setenv "GUILE_AUTO_COMPILE" "0")
396 ;; SDL_image needs to dlopen libjpeg in the test suite.
397 (setenv "LD_LIBRARY_PATH"
398 (string-append (assoc-ref inputs "libjpeg") "/lib"))
399 ;; Change the site directory /site/2.0 like Guile expects.
400 (substitute* "build-aux/guile-baux/re-prefixed-site-dirs"
401 (("\"/site\"") "\"/site/2.0\""))
403 ;; Skip tests that rely on sound support, which is unavailable in
404 ;; the build environment.
405 (substitute* "test/Makefile.in"
406 (("HAVE_MIXER = .*$")
407 "HAVE_MIXER = 0\n")))
409 'check 'start-xorg-server
410 (lambda* (#:key inputs #:allow-other-keys)
411 ;; The test suite requires a running X server.
412 (system (format #f "~a/bin/Xvfb :1 &"
413 (assoc-ref inputs "xorg-server")))
414 (setenv "DISPLAY" ":1"))
416 (synopsis "Guile interface for SDL (Simple DirectMedia Layer)")
417 (description "Guile-SDL is a set of bindings to the Simple DirectMedia
418 Layer (SDL). With them, Guile programmers can have easy access to graphics,
419 sound and device input (keyboards, joysticks, mice, etc.).")
420 (home-page "http://gnu.org/s/guile-sdl")