Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / sdl.scm
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>
6 ;;;
7 ;;; This file is part of GNU Guix.
8 ;;;
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.
13 ;;;
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.
18 ;;;
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/>.
21
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)
40 #:export (sdl
41 sdl2
42 libmikmod
43 sdl-gfx
44 sdl-image
45 sdl-mixer
46 sdl-net
47 sdl-ttf
48 sdl-union))
49
50 (define sdl
51 (package
52 (name "sdl")
53 (version "1.2.15")
54 (source (origin
55 (method url-fetch)
56 (uri
57 (string-append "http://libsdl.org/release/SDL-"
58 version ".tar.gz"))
59 (sha256
60 (base32
61 "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"))
62 (patches (list (search-patch "sdl-libx11-1.6.patch")))))
63 (build-system gnu-build-system)
64 (arguments
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.
74 "LDFLAGS=-lGL")
75
76 #:tests? #f)) ; no check target
77 (propagated-inputs
78 ;; SDL headers include X11 headers.
79 `(("libx11" ,libx11)
80 ("libcap" ,libcap))) ; 'libSDL.la' contain `-lcap'.
81 (native-inputs `(("pkg-config" ,pkg-config)))
82 (inputs `(("libxrandr" ,libxrandr)
83 ("mesa" ,mesa)
84 ("glu" ,glu)
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/")
92 (license lgpl2.1)))
93
94 (define sdl2
95 (package (inherit sdl)
96 (name "sdl2")
97 (version "2.0.3")
98 (source (origin
99 (method url-fetch)
100 (uri
101 (string-append "http://libsdl.org/release/SDL2-"
102 version ".tar.gz"))
103 (sha256
104 (base32
105 "0369ngvb46x6c26h8zva4x22ywgy6mvn0wx87xqwxg40pxm9m9m5"))))
106 (license bsd-3)))
107
108 (define libmikmod
109 (package
110 (name "libmikmod")
111 (version "3.3.7")
112 (source (origin
113 (method url-fetch)
114 (uri (string-append "mirror://sourceforge/mikmod/libmikmod/"
115 version "/libmikmod-" version ".tar.gz"))
116 (sha256
117 (base32
118 "18nrkf5l50hfg0y50yxr7bvik9f002lhn8c00nbcp6dgm5011x2c"))))
119 (build-system gnu-build-system)
120 (arguments
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")
126 (description
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.")
130 (license lgpl2.1)
131 (home-page "http://mikmod.sourceforge.net/")))
132
133 (define sdl-gfx
134 (package
135 (name "sdl-gfx")
136 (version "2.0.24")
137 (source (origin
138 (method url-fetch)
139 (uri
140 (string-append "http://www.ferzkopp.net/Software/SDL_gfx-2.0/SDL_gfx-"
141 version ".tar.gz"))
142 (sha256
143 (base32
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")
151 (license zlib)
152
153 ;; The code apparently includes Intel assembly, which fails to build on
154 ;; MIPS, at least.
155 (supported-systems '("i686-linux" "x86_64-linux"))))
156
157 (define sdl-image
158 (package
159 (name "sdl-image")
160 (version "1.2.12")
161 (source (origin
162 (method url-fetch)
163 (uri
164 (string-append "http://www.libsdl.org/projects/SDL_image/release/SDL_image-"
165 version ".tar.gz"))
166 (sha256
167 (base32
168 "16an9slbb8ci7d89wakkmyfvp7c0cval8xw4hkg0842nhhlp540b"))))
169 (build-system gnu-build-system)
170 (arguments
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
180 ;; file.
181 (propagated-inputs `(("sdl" ,sdl)
182 ("libjpeg" ,libjpeg)
183 ("libpng" ,libpng)
184 ("libtiff" ,libtiff)
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/")
191 (license zlib)))
192
193 (define sdl-mixer
194 (package
195 (name "sdl-mixer")
196 (version "1.2.12")
197 (source (origin
198 (method url-fetch)
199 (uri
200 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-"
201 version ".tar.gz"))
202 (sha256
203 (base32
204 "0alrhqgm40p4c92s26mimg9cm1y7rzr6m0p49687jxd9g6130i0n"))))
205 (build-system gnu-build-system)
206 ;; no check target
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)
217 ("libflac" ,flac)
218 ("libmad" ,libmad)
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/")
228 (license zlib)))
229
230 (define sdl-net
231 (package
232 (name "sdl-net")
233 (version "1.2.8")
234 (source (origin
235 (method url-fetch)
236 (uri
237 (string-append "http://www.libsdl.org/projects/SDL_net/release/SDL_net-"
238 version ".tar.gz"))
239 (sha256
240 (base32
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
247 SDL.")
248 (home-page "http://www.libsdl.org/projects/SDL_net/")
249 (license zlib)))
250
251 (define sdl-ttf
252 (package
253 (name "sdl-ttf")
254 (version "2.0.11")
255 (source (origin
256 (method url-fetch)
257 (uri
258 (string-append "http://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
259 version ".tar.gz"))
260 (sha256
261 (base32
262 "1dydxd4f5kb1288i5n5568kdk2q7f8mqjr7i7sd33nplxjaxhk3j"))))
263 (build-system gnu-build-system)
264 (propagated-inputs `(("sdl" ,sdl)))
265 (inputs `(("freetype" ,freetype)
266 ("mesa" ,mesa)))
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/")
271 (license zlib)))
272
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."
277 (package
278 (name "sdl-union")
279 (version (package-version sdl))
280 (source #f)
281 (build-system trivial-build-system)
282 (arguments
283 '(#:modules ((guix build union))
284 #:builder (begin
285 (use-modules (ice-9 match)
286 (guix build union))
287 (match %build-inputs
288 (((names . directories) ...)
289 (union-build (assoc-ref %outputs "out")
290 directories))))))
291 (inputs (map (lambda (package)
292 (list (package-name package) package))
293 packages))
294 (synopsis "Union of SDL libraries")
295 (description
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
298 directory.")
299 (home-page (package-home-page sdl))
300 (license (package-license sdl))))
301
302 (define (propagated-inputs-with-sdl2 package)
303 "Replace the \"sdl\" propagated input of PACKAGE with SDL2."
304 (map (match-lambda
305 (("sdl" _)
306 `("sdl2" ,sdl2))
307 (other other))
308 (package-propagated-inputs package)))
309
310 (define-public sdl2-image
311 (package (inherit sdl-image)
312 (name "sdl2-image")
313 (version "2.0.0")
314 (source (origin
315 (method url-fetch)
316 (uri
317 (string-append "http://www.libsdl.org/projects/SDL_image/release/SDL2_image-"
318 version ".tar.gz"))
319 (sha256
320 (base32
321 "0d3jlhkmr0j5a2dd5h6y29jfcsj7mkl16wghm6n3nqqp7g3ib65j"))))
322 (propagated-inputs
323 (propagated-inputs-with-sdl2 sdl-image))))
324
325 (define-public sdl2-mixer
326 (package (inherit sdl-mixer)
327 (name "sdl2-mixer")
328 (version "2.0.0")
329 (source (origin
330 (method url-fetch)
331 (uri
332 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-"
333 version ".tar.gz"))
334 (sha256
335 (base32
336 "0nvjdxjchrajrn0jag877hdx9zb788hsd315zzg1lyck2wb0xkm8"))))
337 (propagated-inputs
338 (propagated-inputs-with-sdl2 sdl-mixer))))
339
340 (define-public sdl2-ttf
341 (package (inherit sdl-ttf)
342 (name "sdl2-ttf")
343 (version "2.0.12")
344 (source (origin
345 (method url-fetch)
346 (uri
347 (string-append "http://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-"
348 version ".tar.gz"))
349 (sha256
350 (base32
351 "0vkg6lyj278mdpd52map3rfi65fbq16w67ahmmfcl77a8da60a47"))))
352 (propagated-inputs
353 (propagated-inputs-with-sdl2 sdl-ttf))))
354
355 (define-public guile-sdl
356 (package
357 (name "guile-sdl")
358 (version "0.5.2")
359 (source (origin
360 (method url-fetch)
361 (uri
362 (string-append "mirror://gnu/guile-sdl/guile-sdl-"
363 version ".tar.xz"))
364 (sha256
365 (base32
366 "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
367 (build-system gnu-build-system)
368 (native-inputs
369 `(("pkg-config" ,pkg-config)
370 ;; Required by test suite.
371 ("xorg-server" ,xorg-server)
372 ("libjpeg" ,libjpeg)))
373 (inputs
374 `(("guile" ,guile-2.0)
375 ("sdl-union" ,(sdl-union))))
376 (arguments
377 '(#:configure-flags
378 (list (string-append "--with-sdl-prefix="
379 (assoc-ref %build-inputs "sdl-union")))
380 #:parallel-build? #f ; parallel build fails
381 #:phases
382 (alist-cons-before
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\""))
392
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")))
398 (alist-cons-before
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"))
405 %standard-phases))))
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")
411 (license gpl3+)))