gnu: python-file: Don't create a compressed egg.
[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 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)
41 #:export (sdl-union))
42
43 (define-public sdl
44 (package
45 (name "sdl")
46 (version "1.2.15")
47 (source (origin
48 (method url-fetch)
49 (uri
50 (string-append "http://libsdl.org/release/SDL-"
51 version ".tar.gz"))
52 (sha256
53 (base32
54 "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"))
55 (patches (search-patches "sdl-libx11-1.6.patch"))))
56 (build-system gnu-build-system)
57 (arguments
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.
67 "LDFLAGS=-lGL")
68
69 #:tests? #f)) ; no check target
70 (propagated-inputs
71 ;; SDL headers include X11 headers.
72 `(("libx11" ,libx11)
73 ("libcap" ,libcap))) ; 'libSDL.la' contain `-lcap'.
74 (native-inputs `(("pkg-config" ,pkg-config)))
75 (inputs `(("libxrandr" ,libxrandr)
76 ("mesa" ,mesa)
77 ("glu" ,glu)
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/")
85 (license lgpl2.1)))
86
87 (define-public sdl2
88 (package (inherit sdl)
89 (name "sdl2")
90 (version "2.0.4")
91 (source (origin
92 (method url-fetch)
93 (uri
94 (string-append "http://libsdl.org/release/SDL2-"
95 version ".tar.gz"))
96 (sha256
97 (base32
98 "0jqp46mxxbh9lhpx1ih6sp93k752j2smhpc0ad0q4cb3px0famfs"))))
99 (license bsd-3)))
100
101 (define-public libmikmod
102 (package
103 (name "libmikmod")
104 (version "3.3.7")
105 (source (origin
106 (method url-fetch)
107 (uri (string-append "mirror://sourceforge/mikmod/libmikmod/"
108 version "/libmikmod-" version ".tar.gz"))
109 (sha256
110 (base32
111 "18nrkf5l50hfg0y50yxr7bvik9f002lhn8c00nbcp6dgm5011x2c"))))
112 (build-system gnu-build-system)
113 (arguments
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")
119 (description
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.")
123 (license lgpl2.1)
124 (home-page "http://mikmod.sourceforge.net/")))
125
126 (define-public sdl-gfx
127 (package
128 (name "sdl-gfx")
129 (version "2.0.24")
130 (source (origin
131 (method url-fetch)
132 (uri
133 (string-append "http://www.ferzkopp.net/Software/SDL_gfx-2.0/SDL_gfx-"
134 version ".tar.gz"))
135 (sha256
136 (base32
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")
144 (license zlib)
145
146 ;; The code apparently includes Intel assembly, which fails to build on
147 ;; MIPS, at least.
148 (supported-systems '("i686-linux" "x86_64-linux"))))
149
150 (define-public sdl-image
151 (package
152 (name "sdl-image")
153 (version "1.2.12")
154 (source (origin
155 (method url-fetch)
156 (uri
157 (string-append "http://www.libsdl.org/projects/SDL_image/release/SDL_image-"
158 version ".tar.gz"))
159 (sha256
160 (base32
161 "16an9slbb8ci7d89wakkmyfvp7c0cval8xw4hkg0842nhhlp540b"))))
162 (build-system gnu-build-system)
163 (arguments
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
173 ;; file.
174 (propagated-inputs `(("sdl" ,sdl)
175 ("libjpeg" ,libjpeg)
176 ("libpng" ,libpng)
177 ("libtiff" ,libtiff)
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/")
184 (license zlib)))
185
186 (define-public sdl-mixer
187 (package
188 (name "sdl-mixer")
189 (version "1.2.12")
190 (source (origin
191 (method url-fetch)
192 (uri
193 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-"
194 version ".tar.gz"))
195 (sha256
196 (base32
197 "0alrhqgm40p4c92s26mimg9cm1y7rzr6m0p49687jxd9g6130i0n"))))
198 (build-system gnu-build-system)
199 ;; no check target
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)
210 ("libflac" ,flac)
211 ("libmad" ,libmad)
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/")
222 (license zlib)))
223
224 (define-public sdl-net
225 (package
226 (name "sdl-net")
227 (version "1.2.8")
228 (source (origin
229 (method url-fetch)
230 (uri
231 (string-append "http://www.libsdl.org/projects/SDL_net/release/SDL_net-"
232 version ".tar.gz"))
233 (sha256
234 (base32
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
241 SDL.")
242 (home-page "http://www.libsdl.org/projects/SDL_net/")
243 (license zlib)))
244
245 (define-public sdl-ttf
246 (package
247 (name "sdl-ttf")
248 (version "2.0.11")
249 (source (origin
250 (method url-fetch)
251 (uri
252 (string-append "http://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
253 version ".tar.gz"))
254 (sha256
255 (base32
256 "1dydxd4f5kb1288i5n5568kdk2q7f8mqjr7i7sd33nplxjaxhk3j"))))
257 (build-system gnu-build-system)
258 (propagated-inputs `(("sdl" ,sdl)))
259 (inputs `(("freetype" ,freetype)
260 ("mesa" ,mesa)))
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/")
265 (license zlib)))
266
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."
271 (package
272 (name "sdl-union")
273 (version (package-version sdl))
274 (source #f)
275 (build-system trivial-build-system)
276 (arguments
277 '(#:modules ((guix build union))
278 #:builder (begin
279 (use-modules (ice-9 match)
280 (guix build union))
281 (match %build-inputs
282 (((names . directories) ...)
283 (union-build (assoc-ref %outputs "out")
284 directories))))))
285 (inputs (map (lambda (package)
286 (list (package-name package) package))
287 packages))
288 (synopsis "Union of SDL libraries")
289 (description
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
292 directory.")
293 (home-page (package-home-page sdl))
294 (license (package-license sdl))))
295
296 (define (propagated-inputs-with-sdl2 package)
297 "Replace the \"sdl\" propagated input of PACKAGE with SDL2."
298 (map (match-lambda
299 (("sdl" _)
300 `("sdl2" ,sdl2))
301 (other other))
302 (package-propagated-inputs package)))
303
304 (define-public sdl2-image
305 (package (inherit sdl-image)
306 (name "sdl2-image")
307 (version "2.0.1")
308 (source (origin
309 (method url-fetch)
310 (uri
311 (string-append "http://www.libsdl.org/projects/SDL_image/release/SDL2_image-"
312 version ".tar.gz"))
313 (sha256
314 (base32
315 "0r3z1l7fdn76qkpy7snpkcjqz8dkv2zp6lsqpq25q4m5xsyaygis"))))
316 (propagated-inputs
317 (propagated-inputs-with-sdl2 sdl-image))))
318
319 (define-public sdl2-mixer
320 (package (inherit sdl-mixer)
321 (name "sdl2-mixer")
322 (version "2.0.1")
323 (source (origin
324 (method url-fetch)
325 (uri
326 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-"
327 version ".tar.gz"))
328 (modules '((guix build utils)))
329 (snippet
330 ;; Remove bundled libraries.
331 '(delete-file-recursively "external"))
332 (sha256
333 (base32
334 "0pv9jzjpcjlbiaybvwrb4avmv46qk7iqxlnqrd2dfj82c4mgc92s"))))
335 (propagated-inputs
336 (propagated-inputs-with-sdl2 sdl-mixer))))
337
338 (define-public sdl2-ttf
339 (package (inherit sdl-ttf)
340 (name "sdl2-ttf")
341 (version "2.0.14")
342 (source (origin
343 (method url-fetch)
344 (uri
345 (string-append "http://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-"
346 version ".tar.gz"))
347 (modules '((guix build utils)))
348 (snippet
349 ;; Remove bundled libraries.
350 '(delete-file-recursively "external"))
351 (sha256
352 (base32
353 "0xljwcpvd2knrjdfag5b257xqayplz55mqlszrqp0kpnphh5xnrl"))))
354 (propagated-inputs
355 (propagated-inputs-with-sdl2 sdl-ttf))))
356
357 (define-public guile-sdl
358 (package
359 (name "guile-sdl")
360 (version "0.5.2")
361 (source (origin
362 (method url-fetch)
363 (uri
364 (string-append "mirror://gnu/guile-sdl/guile-sdl-"
365 version ".tar.xz"))
366 (sha256
367 (base32
368 "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
369 (build-system gnu-build-system)
370 (native-inputs
371 `(("pkg-config" ,pkg-config)
372 ;; Required by test suite.
373 ("xorg-server" ,xorg-server)
374 ("libjpeg" ,libjpeg)))
375 (inputs
376 `(("guile" ,guile-2.0)
377 ("sdl-union" ,(sdl-union))))
378 (arguments
379 '(#:configure-flags
380 (list (string-append "--with-sdl-prefix="
381 (assoc-ref %build-inputs "sdl-union")))
382 #:parallel-build? #f ; parallel build fails
383 #:phases
384 (alist-cons-before
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\""))
394
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")))
400 (alist-cons-before
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"))
407 %standard-phases))))
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")
413 (license gpl3+)))