gnu: iptables: Mention "firewall".
[jackhill/guix/guix.git] / gnu / packages / sdl.scm
CommitLineData
c3c516ea 1;;; GNU Guix --- Functional package management for GNU
6813f70a 2;;; Copyright © 2013, 2015 David Thompson <dthompson2@worcester.edu>
9cb3036f 3;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
666aa995 4;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
40e94665 5;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
c3c516ea
DT
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)
6813f70a 23 #:use-module (ice-9 match)
c3c516ea 24 #:use-module (gnu packages)
890024c5 25 #:use-module ((guix licenses) #:hide (freetype))
c3c516ea
DT
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix build-system gnu)
d6f74baf 29 #:use-module (guix build-system trivial)
a313e085 30 #:use-module (gnu packages audio)
890024c5 31 #:use-module (gnu packages fontutils)
bcc046fc 32 #:use-module (gnu packages guile)
e55354b8 33 #:use-module (gnu packages image)
c3c516ea 34 #:use-module (gnu packages linux)
5cf3bcd4 35 #:use-module (gnu packages mp3)
8bf8d7c7
DT
36 #:use-module (gnu packages pkg-config)
37 #:use-module (gnu packages pulseaudio)
200726ed 38 #:use-module (gnu packages gl)
54ff0b7d 39 #:use-module (gnu packages xiph)
c3c516ea 40 #:use-module (gnu packages xorg)
8bf8d7c7
DT
41 #:export (sdl
42 sdl2
5cf3bcd4
DT
43 libmikmod
44 sdl-gfx
45 sdl-image
46 sdl-mixer
47 sdl-net
40e94665
AK
48 sdl-ttf
49 sdl-union))
8bf8d7c7
DT
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
9cb3036f 62 "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"))
fc1adab1 63 (patches (search-patches "sdl-libx11-1.6.patch"))))
8bf8d7c7 64 (build-system gnu-build-system)
22f33e61 65 (arguments
666aa995 66 '(;; Explicitly link against shared libraries instead of dlopening them.
83bb3a3e
SB
67 ;; For X11, ALSA, and PulseAudio.
68 ;; OpenGL library is still dlopened at runtime.
69 #:configure-flags '("--disable-alsa-shared"
70 "--disable-pulseaudio-shared"
07780c71
SB
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")
22f33e61
LC
76
77 #:tests? #f)) ; no check target
558a5122
LC
78 (propagated-inputs
79 ;; SDL headers include X11 headers.
666aa995
SB
80 `(("libx11" ,libx11)
81 ("libcap" ,libcap))) ; 'libSDL.la' contain `-lcap'.
22f33e61 82 (native-inputs `(("pkg-config" ,pkg-config)))
558a5122 83 (inputs `(("libxrandr" ,libxrandr)
8bf8d7c7 84 ("mesa" ,mesa)
83bb3a3e 85 ("glu" ,glu)
8bf8d7c7 86 ("alsa-lib" ,alsa-lib)
8bf8d7c7
DT
87 ("pulseaudio" ,pulseaudio)))
88 (synopsis "Cross platform game development library")
89 (description "Simple DirectMedia Layer is a cross-platform development
90library designed to provide low level access to audio, keyboard, mouse,
91joystick, and graphics hardware.")
92 (home-page "http://libsdl.org/")
93 (license lgpl2.1)))
94
95(define sdl2
96 (package (inherit sdl)
97 (name "sdl2")
4c0e59d1 98 (version "2.0.4")
8bf8d7c7
DT
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
4c0e59d1 106 "0jqp46mxxbh9lhpx1ih6sp93k752j2smhpc0ad0q4cb3px0famfs"))))
8bf8d7c7 107 (license bsd-3)))
c3c516ea
DT
108
109(define libmikmod
110 (package
111 (name "libmikmod")
1effda8d 112 (version "3.3.7")
c3c516ea
DT
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
1effda8d 119 "18nrkf5l50hfg0y50yxr7bvik9f002lhn8c00nbcp6dgm5011x2c"))))
c3c516ea 120 (build-system gnu-build-system)
03920078
LC
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")))
9e771e3b 126 (synopsis "Library for module sound formats")
c3c516ea
DT
127 (description
128 "MikMod is able to play a wide range of module formats, as well as
35b9e423 129digital sound files. It can take advantage of particular features of your
c3c516ea
DT
130system, such as sound redirection over the network.")
131 (license lgpl2.1)
132 (home-page "http://mikmod.sourceforge.net/")))
5cf3bcd4
DT
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)))
5cf3bcd4
DT
148 (synopsis "SDL graphics primitives library")
149 (description "SDL_gfx provides graphics drawing primitives, rotozoom and
150other supporting functions for SDL.")
151 (home-page "http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx")
1d830bc0
LC
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"))))
5cf3bcd4
DT
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)
7c3e60fb
SB
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")))
586b6d4d 177 (native-inputs `(("pkg-config" ,pkg-config)))
586b6d4d
DT
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)
6a51e95b
DT
185 ("libtiff" ,libtiff)
186 ("libwebp" ,libwebp)))
5cf3bcd4
DT
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.")
6b464e6e 191 (home-page "http://www.libsdl.org/projects/SDL_image/")
5cf3bcd4
DT
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
3ff73390 209 ;; explicitly link against shared libraries instead of dlopening them
5cf3bcd4 210 (arguments `(#:tests? #f
3ff73390
SB
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")))
5cf3bcd4
DT
217 (inputs `(("libvorbis" ,libvorbis)
218 ("libflac" ,flac)
219 ("libmad" ,libmad)
a313e085
DT
220 ("libmikmod" ,libmikmod)
221 ("libmodplug" ,libmodplug)))
5cf3bcd4
DT
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.
226It supports any number of simultaneously playing channels of 16 bit stereo
227audio, plus a single channel of music. Supported format include FLAC, MOD,
228MIDI, Ogg Vorbis, and MP3.")
6b464e6e 229 (home-page "http://www.libsdl.org/projects/SDL_mixer/")
5cf3bcd4
DT
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)))
41eb1198 246 (native-inputs `(("pkg-config" ,pkg-config)))
5cf3bcd4
DT
247 (synopsis "SDL networking library")
248 (description "SDL_net is a small, cross-platform networking library for
249SDL.")
6b464e6e 250 (home-page "http://www.libsdl.org/projects/SDL_net/")
5cf3bcd4
DT
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)))
890024c5 267 (inputs `(("freetype" ,freetype)
41eb1198
LC
268 ("mesa" ,mesa)))
269 (native-inputs `(("pkg-config" ,pkg-config)))
5cf3bcd4
DT
270 (synopsis "SDL TrueType font library")
271 (description "SDL_ttf is a TrueType font rendering library for SDL.")
6b464e6e 272 (home-page "http://www.libsdl.org/projects/SDL_ttf/")
5cf3bcd4 273 (license zlib)))
d6f74baf 274
40e94665
AK
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.
278If PACKAGES are not specified, all SDL packages are used."
d6f74baf
DT
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))))))
40e94665
AK
293 (inputs (map (lambda (package)
294 (list (package-name package) package))
295 packages))
296 (synopsis "Union of SDL libraries")
d6f74baf
DT
297 (description
298 "A union of SDL and its extension libraries. A union is required because
299sdl-config assumes that all of the headers and libraries are in the same
300directory.")
301 (home-page (package-home-page sdl))
302 (license (package-license sdl))))
bcc046fc 303
6813f70a
DT
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")
64ee72e1 315 (version "2.0.1")
6813f70a
DT
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
64ee72e1 323 "0r3z1l7fdn76qkpy7snpkcjqz8dkv2zp6lsqpq25q4m5xsyaygis"))))
6813f70a
DT
324 (propagated-inputs
325 (propagated-inputs-with-sdl2 sdl-image))))
326
855e2939
DT
327(define-public sdl2-mixer
328 (package (inherit sdl-mixer)
329 (name "sdl2-mixer")
efd75ade 330 (version "2.0.1")
855e2939
DT
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"))
efd75ade
DT
336 (modules '((guix build utils)))
337 (snippet
338 ;; Remove bundled libraries.
339 '(delete-file-recursively "external"))
855e2939
DT
340 (sha256
341 (base32
efd75ade 342 "0pv9jzjpcjlbiaybvwrb4avmv46qk7iqxlnqrd2dfj82c4mgc92s"))))
855e2939
DT
343 (propagated-inputs
344 (propagated-inputs-with-sdl2 sdl-mixer))))
345
d3f6a1de
DT
346(define-public sdl2-ttf
347 (package (inherit sdl-ttf)
348 (name "sdl2-ttf")
8d506323 349 (version "2.0.14")
d3f6a1de
DT
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"))
8d506323
DT
355 (modules '((guix build utils)))
356 (snippet
357 ;; Remove bundled libraries.
358 '(delete-file-recursively "external"))
d3f6a1de
DT
359 (sha256
360 (base32
8d506323 361 "0xljwcpvd2knrjdfag5b257xqayplz55mqlszrqp0kpnphh5xnrl"))))
d3f6a1de
DT
362 (propagated-inputs
363 (propagated-inputs-with-sdl2 sdl-ttf))))
364
bcc046fc
DT
365(define-public guile-sdl
366 (package
367 (name "guile-sdl")
af87a551 368 (version "0.5.2")
bcc046fc
DT
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
af87a551 376 "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
bcc046fc
DT
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)
40e94665 385 ("sdl-union" ,(sdl-union))))
bcc046fc
DT
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"
af87a551
LC
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")))
bcc046fc
DT
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
418Layer (SDL). With them, Guile programmers can have easy access to graphics,
419sound and device input (keyboards, joysticks, mice, etc.).")
420 (home-page "http://gnu.org/s/guile-sdl")
421 (license gpl3+)))