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 fontutils)
31 #:use-module (gnu packages guile)
32 #:use-module (gnu packages image)
33 #:use-module (gnu packages linux)
34 #:use-module (gnu packages mp3)
35 #:use-module (gnu packages pkg-config)
36 #:use-module (gnu packages pulseaudio)
37 #:use-module (gnu packages gl)
38 #:use-module (gnu packages xiph)
39 #:use-module (gnu packages xorg)
57 (string-append "http://libsdl.org/release/SDL-"
61 "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"))
62 (patches (list (search-patch "sdl-libx11-1.6.patch")))))
63 (build-system gnu-build-system)
65 '(;; Explicitly link against shared libraries instead of dlopening them.
66 ;; For X11, ALSA, and PulseAudio.
67 ;; OpenGL library is still dlopened at runtime.
68 #:configure-flags '("--disable-alsa-shared"
69 "--disable-pulseaudio-shared"
70 "--disable-x11-shared"
71 ;; Explicitly link with mesa.
72 ;; This add mesa to libsdl's RUNPATH, to make dlopen
73 ;; finding the libGL from mesa at runtime.
76 #:tests? #f)) ; no check target
78 ;; SDL headers include X11 headers.
80 ("libcap" ,libcap))) ; 'libSDL.la' contain `-lcap'.
81 (native-inputs `(("pkg-config" ,pkg-config)))
82 (inputs `(("libxrandr" ,libxrandr)
85 ("alsa-lib" ,alsa-lib)
86 ("pulseaudio" ,pulseaudio)))
87 (synopsis "Cross platform game development library")
88 (description "Simple DirectMedia Layer is a cross-platform development
89 library designed to provide low level access to audio, keyboard, mouse,
90 joystick, and graphics hardware.")
91 (home-page "http://libsdl.org/")
95 (package (inherit sdl)
101 (string-append "http://libsdl.org/release/SDL2-"
105 "0369ngvb46x6c26h8zva4x22ywgy6mvn0wx87xqwxg40pxm9m9m5"))))
114 (uri (string-append "mirror://sourceforge/mikmod/libmikmod/"
115 version "/libmikmod-" version ".tar.gz"))
118 "18nrkf5l50hfg0y50yxr7bvik9f002lhn8c00nbcp6dgm5011x2c"))))
119 (build-system gnu-build-system)
121 ;; By default, libmikmod tries to dlopen libasound etc., which won't work
122 ;; unless the right libalsa happens to be in $LD_LIBRARY_PATH. Pass
123 ;; '--disable-dl' to avoid that.
124 '(#:configure-flags '("--disable-dl")))
125 (synopsis "Library for module sound formats")
127 "MikMod is able to play a wide range of module formats, as well as
128 digital sound files. It can take advantage of particular features of your
129 system, such as sound redirection over the network.")
131 (home-page "http://mikmod.sourceforge.net/")))
140 (string-append "http://www.ferzkopp.net/Software/SDL_gfx-2.0/SDL_gfx-"
144 "064islldm4r42lgj9fr4kbk66r7jmmakk9745hhyb1kmw71kib9h"))))
145 (build-system gnu-build-system)
146 (propagated-inputs `(("sdl" ,sdl)))
147 (synopsis "SDL graphics primitives library")
148 (description "SDL_gfx provides graphics drawing primitives, rotozoom and
149 other supporting functions for SDL.")
150 (home-page "http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx")
153 ;; The code apparently includes Intel assembly, which fails to build on
155 (supported-systems '("i686-linux" "x86_64-linux"))))
164 (string-append "http://www.libsdl.org/projects/SDL_image/release/SDL_image-"
168 "16an9slbb8ci7d89wakkmyfvp7c0cval8xw4hkg0842nhhlp540b"))))
169 (build-system gnu-build-system)
171 ;; Explicitly link against shared libraries instead of dlopening them.
172 '(#:configure-flags '("--disable-jpg-shared"
173 "--disable-png-shared"
174 "--disable-tif-shared"
175 "--disable-webp-shared")))
176 (native-inputs `(("pkg-config" ,pkg-config)))
177 ;; libjpeg, libpng, and libtiff are propagated inputs because the
178 ;; SDL_image headers include the headers of these libraries. SDL is a
179 ;; propagated input because the pkg-config file refers to SDL's pkg-config
181 (propagated-inputs `(("sdl" ,sdl)
185 ("libwebp" ,libwebp)))
186 (synopsis "SDL image loading library")
187 (description "SDL_image is an image file loading library for SDL that
188 supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF,
189 WEBP, XCF, XPM, and XV.")
190 (home-page "http://www.libsdl.org/projects/SDL_image/")
200 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-"
204 "0alrhqgm40p4c92s26mimg9cm1y7rzr6m0p49687jxd9g6130i0n"))))
205 (build-system gnu-build-system)
207 ;; use libmad instead of smpeg
208 ;; explicitly link against shared libraries instead of dlopening them
209 (arguments `(#:tests? #f
210 #:configure-flags '("--enable-music-mp3-mad-gpl"
211 "--disable-music-mod-shared"
212 "--disable-music-fluidsynth-shared"
213 "--disable-music-ogg-shared"
214 "--disable-music-flac-shared"
215 "--disable-music-mp3-shared")))
216 (inputs `(("libvorbis" ,libvorbis)
219 ("libmikmod" ,libmikmod)))
220 ;; FIXME: Add libfluidsynth
221 (propagated-inputs `(("sdl" ,sdl)))
222 (synopsis "SDL multi-channel audio mixer library")
223 (description "SDL_mixer is a multi-channel audio mixer library for SDL.
224 It supports any number of simultaneously playing channels of 16 bit stereo
225 audio, plus a single channel of music. Supported format include FLAC, MOD,
226 MIDI, Ogg Vorbis, and MP3.")
227 (home-page "http://www.libsdl.org/projects/SDL_mixer/")
237 (string-append "http://www.libsdl.org/projects/SDL_net/release/SDL_net-"
241 "1d5c9xqlf4s1c01gzv6cxmg0r621pq9kfgxcg3197xw4p25pljjz"))))
242 (build-system gnu-build-system)
243 (propagated-inputs `(("sdl" ,sdl)))
244 (native-inputs `(("pkg-config" ,pkg-config)))
245 (synopsis "SDL networking library")
246 (description "SDL_net is a small, cross-platform networking library for
248 (home-page "http://www.libsdl.org/projects/SDL_net/")
258 (string-append "http://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
262 "1dydxd4f5kb1288i5n5568kdk2q7f8mqjr7i7sd33nplxjaxhk3j"))))
263 (build-system gnu-build-system)
264 (propagated-inputs `(("sdl" ,sdl)))
265 (inputs `(("freetype" ,freetype)
267 (native-inputs `(("pkg-config" ,pkg-config)))
268 (synopsis "SDL TrueType font library")
269 (description "SDL_ttf is a TrueType font rendering library for SDL.")
270 (home-page "http://www.libsdl.org/projects/SDL_ttf/")
273 (define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
274 sdl-image sdl-mixer)))
275 "Return 'sdl-union' package which is a union of PACKAGES.
276 If PACKAGES are not specified, all SDL packages are used."
279 (version (package-version sdl))
281 (build-system trivial-build-system)
283 '(#:modules ((guix build union))
285 (use-modules (ice-9 match)
288 (((names . directories) ...)
289 (union-build (assoc-ref %outputs "out")
291 (inputs (map (lambda (package)
292 (list (package-name package) package))
294 (synopsis "Union of SDL libraries")
296 "A union of SDL and its extension libraries. A union is required because
297 sdl-config assumes that all of the headers and libraries are in the same
299 (home-page (package-home-page sdl))
300 (license (package-license sdl))))
302 (define (propagated-inputs-with-sdl2 package)
303 "Replace the \"sdl\" propagated input of PACKAGE with SDL2."
308 (package-propagated-inputs package)))
310 (define-public sdl2-image
311 (package (inherit sdl-image)
317 (string-append "http://www.libsdl.org/projects/SDL_image/release/SDL2_image-"
321 "0d3jlhkmr0j5a2dd5h6y29jfcsj7mkl16wghm6n3nqqp7g3ib65j"))))
323 (propagated-inputs-with-sdl2 sdl-image))))
325 (define-public sdl2-mixer
326 (package (inherit sdl-mixer)
332 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-"
336 "0nvjdxjchrajrn0jag877hdx9zb788hsd315zzg1lyck2wb0xkm8"))))
338 (propagated-inputs-with-sdl2 sdl-mixer))))
340 (define-public sdl2-ttf
341 (package (inherit sdl-ttf)
347 (string-append "http://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-"
351 "0vkg6lyj278mdpd52map3rfi65fbq16w67ahmmfcl77a8da60a47"))))
353 (propagated-inputs-with-sdl2 sdl-ttf))))
355 (define-public guile-sdl
362 (string-append "mirror://gnu/guile-sdl/guile-sdl-"
366 "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
367 (build-system gnu-build-system)
369 `(("pkg-config" ,pkg-config)
370 ;; Required by test suite.
371 ("xorg-server" ,xorg-server)
372 ("libjpeg" ,libjpeg)))
374 `(("guile" ,guile-2.0)
375 ("sdl-union" ,(sdl-union))))
378 (list (string-append "--with-sdl-prefix="
379 (assoc-ref %build-inputs "sdl-union")))
380 #:parallel-build? #f ; parallel build fails
383 'configure 'fix-env-and-patch
384 (lambda* (#:key inputs #:allow-other-keys)
385 (setenv "GUILE_AUTO_COMPILE" "0")
386 ;; SDL_image needs to dlopen libjpeg in the test suite.
387 (setenv "LD_LIBRARY_PATH"
388 (string-append (assoc-ref inputs "libjpeg") "/lib"))
389 ;; Change the site directory /site/2.0 like Guile expects.
390 (substitute* "build-aux/guile-baux/re-prefixed-site-dirs"
391 (("\"/site\"") "\"/site/2.0\""))
393 ;; Skip tests that rely on sound support, which is unavailable in
394 ;; the build environment.
395 (substitute* "test/Makefile.in"
396 (("HAVE_MIXER = .*$")
397 "HAVE_MIXER = 0\n")))
399 'check 'start-xorg-server
400 (lambda* (#:key inputs #:allow-other-keys)
401 ;; The test suite requires a running X server.
402 (system (format #f "~a/bin/Xvfb :1 &"
403 (assoc-ref inputs "xorg-server")))
404 (setenv "DISPLAY" ":1"))
406 (synopsis "Guile interface for SDL (Simple DirectMedia Layer)")
407 (description "Guile-SDL is a set of bindings to the Simple DirectMedia
408 Layer (SDL). With them, Guile programmers can have easy access to graphics,
409 sound and device input (keyboards, joysticks, mice, etc.).")
410 (home-page "http://gnu.org/s/guile-sdl")