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