gnu: Add sdl2-ttf.
[jackhill/guix/guix.git] / gnu / packages / sdl.scm
... / ...
CommitLineData
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
89library designed to provide low level access to audio, keyboard, mouse,
90joystick, 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
128digital sound files. It can take advantage of particular features of your
129system, 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
149other 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 ;; FIXME: Add webp
178 ;;
179 ;; libjpeg, libpng, and libtiff are propagated inputs because the
180 ;; SDL_image headers include the headers of these libraries. SDL is a
181 ;; propagated input because the pkg-config file refers to SDL's pkg-config
182 ;; file.
183 (propagated-inputs `(("sdl" ,sdl)
184 ("libjpeg" ,libjpeg)
185 ("libpng" ,libpng)
186 ("libtiff" ,libtiff)))
187 (synopsis "SDL image loading library")
188 (description "SDL_image is an image file loading library for SDL that
189supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF,
190WEBP, 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 ;; FIXME: Add libfluidsynth
222 (propagated-inputs `(("sdl" ,sdl)))
223 (synopsis "SDL multi-channel audio mixer library")
224 (description "SDL_mixer is a multi-channel audio mixer library for SDL.
225It supports any number of simultaneously playing channels of 16 bit stereo
226audio, plus a single channel of music. Supported format include FLAC, MOD,
227MIDI, Ogg Vorbis, and MP3.")
228 (home-page "http://www.libsdl.org/projects/SDL_mixer/")
229 (license zlib)))
230
231(define sdl-net
232 (package
233 (name "sdl-net")
234 (version "1.2.8")
235 (source (origin
236 (method url-fetch)
237 (uri
238 (string-append "http://www.libsdl.org/projects/SDL_net/release/SDL_net-"
239 version ".tar.gz"))
240 (sha256
241 (base32
242 "1d5c9xqlf4s1c01gzv6cxmg0r621pq9kfgxcg3197xw4p25pljjz"))))
243 (build-system gnu-build-system)
244 (propagated-inputs `(("sdl" ,sdl)))
245 (native-inputs `(("pkg-config" ,pkg-config)))
246 (synopsis "SDL networking library")
247 (description "SDL_net is a small, cross-platform networking library for
248SDL.")
249 (home-page "http://www.libsdl.org/projects/SDL_net/")
250 (license zlib)))
251
252(define sdl-ttf
253 (package
254 (name "sdl-ttf")
255 (version "2.0.11")
256 (source (origin
257 (method url-fetch)
258 (uri
259 (string-append "http://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
260 version ".tar.gz"))
261 (sha256
262 (base32
263 "1dydxd4f5kb1288i5n5568kdk2q7f8mqjr7i7sd33nplxjaxhk3j"))))
264 (build-system gnu-build-system)
265 (propagated-inputs `(("sdl" ,sdl)))
266 (inputs `(("freetype" ,freetype)
267 ("mesa" ,mesa)))
268 (native-inputs `(("pkg-config" ,pkg-config)))
269 (synopsis "SDL TrueType font library")
270 (description "SDL_ttf is a TrueType font rendering library for SDL.")
271 (home-page "http://www.libsdl.org/projects/SDL_ttf/")
272 (license zlib)))
273
274(define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
275 sdl-image sdl-mixer)))
276 "Return 'sdl-union' package which is a union of PACKAGES.
277If PACKAGES are not specified, all SDL packages are used."
278 (package
279 (name "sdl-union")
280 (version (package-version sdl))
281 (source #f)
282 (build-system trivial-build-system)
283 (arguments
284 '(#:modules ((guix build union))
285 #:builder (begin
286 (use-modules (ice-9 match)
287 (guix build union))
288 (match %build-inputs
289 (((names . directories) ...)
290 (union-build (assoc-ref %outputs "out")
291 directories))))))
292 (inputs (map (lambda (package)
293 (list (package-name package) package))
294 packages))
295 (synopsis "Union of SDL libraries")
296 (description
297 "A union of SDL and its extension libraries. A union is required because
298sdl-config assumes that all of the headers and libraries are in the same
299directory.")
300 (home-page (package-home-page sdl))
301 (license (package-license sdl))))
302
303(define (propagated-inputs-with-sdl2 package)
304 "Replace the \"sdl\" propagated input of PACKAGE with SDL2."
305 (map (match-lambda
306 (("sdl" _)
307 `("sdl2" ,sdl2))
308 (other other))
309 (package-propagated-inputs package)))
310
311(define-public sdl2-image
312 (package (inherit sdl-image)
313 (name "sdl2-image")
314 (version "2.0.0")
315 (source (origin
316 (method url-fetch)
317 (uri
318 (string-append "http://www.libsdl.org/projects/SDL_image/release/SDL2_image-"
319 version ".tar.gz"))
320 (sha256
321 (base32
322 "0d3jlhkmr0j5a2dd5h6y29jfcsj7mkl16wghm6n3nqqp7g3ib65j"))))
323 (propagated-inputs
324 (propagated-inputs-with-sdl2 sdl-image))))
325
326(define-public sdl2-mixer
327 (package (inherit sdl-mixer)
328 (name "sdl2-mixer")
329 (version "2.0.0")
330 (source (origin
331 (method url-fetch)
332 (uri
333 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-"
334 version ".tar.gz"))
335 (sha256
336 (base32
337 "0nvjdxjchrajrn0jag877hdx9zb788hsd315zzg1lyck2wb0xkm8"))))
338 (propagated-inputs
339 (propagated-inputs-with-sdl2 sdl-mixer))))
340
341(define-public sdl2-ttf
342 (package (inherit sdl-ttf)
343 (name "sdl2-ttf")
344 (version "2.0.12")
345 (source (origin
346 (method url-fetch)
347 (uri
348 (string-append "http://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-"
349 version ".tar.gz"))
350 (sha256
351 (base32
352 "0vkg6lyj278mdpd52map3rfi65fbq16w67ahmmfcl77a8da60a47"))))
353 (propagated-inputs
354 (propagated-inputs-with-sdl2 sdl-ttf))))
355
356(define-public guile-sdl
357 (package
358 (name "guile-sdl")
359 (version "0.5.2")
360 (source (origin
361 (method url-fetch)
362 (uri
363 (string-append "mirror://gnu/guile-sdl/guile-sdl-"
364 version ".tar.xz"))
365 (sha256
366 (base32
367 "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
368 (build-system gnu-build-system)
369 (native-inputs
370 `(("pkg-config" ,pkg-config)
371 ;; Required by test suite.
372 ("xorg-server" ,xorg-server)
373 ("libjpeg" ,libjpeg)))
374 (inputs
375 `(("guile" ,guile-2.0)
376 ("sdl-union" ,(sdl-union))))
377 (arguments
378 '(#:configure-flags
379 (list (string-append "--with-sdl-prefix="
380 (assoc-ref %build-inputs "sdl-union")))
381 #:parallel-build? #f ; parallel build fails
382 #:phases
383 (alist-cons-before
384 'configure 'fix-env-and-patch
385 (lambda* (#:key inputs #:allow-other-keys)
386 (setenv "GUILE_AUTO_COMPILE" "0")
387 ;; SDL_image needs to dlopen libjpeg in the test suite.
388 (setenv "LD_LIBRARY_PATH"
389 (string-append (assoc-ref inputs "libjpeg") "/lib"))
390 ;; Change the site directory /site/2.0 like Guile expects.
391 (substitute* "build-aux/guile-baux/re-prefixed-site-dirs"
392 (("\"/site\"") "\"/site/2.0\""))
393
394 ;; Skip tests that rely on sound support, which is unavailable in
395 ;; the build environment.
396 (substitute* "test/Makefile.in"
397 (("HAVE_MIXER = .*$")
398 "HAVE_MIXER = 0\n")))
399 (alist-cons-before
400 'check 'start-xorg-server
401 (lambda* (#:key inputs #:allow-other-keys)
402 ;; The test suite requires a running X server.
403 (system (format #f "~a/bin/Xvfb :1 &"
404 (assoc-ref inputs "xorg-server")))
405 (setenv "DISPLAY" ":1"))
406 %standard-phases))))
407 (synopsis "Guile interface for SDL (Simple DirectMedia Layer)")
408 (description "Guile-SDL is a set of bindings to the Simple DirectMedia
409Layer (SDL). With them, Guile programmers can have easy access to graphics,
410sound and device input (keyboards, joysticks, mice, etc.).")
411 (home-page "http://gnu.org/s/guile-sdl")
412 (license gpl3+)))