gnu: python-pandas: Fix build on 32-bit.
[jackhill/guix/guix.git] / gnu / packages / sdl.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2015, 2017 David Thompson <dthompson2@worcester.edu>
3 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015, 2017 Sou Bunnbu <iyzsong@member.fsf.org>
5 ;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
6 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
7 ;;;
8 ;;; This file is part of GNU Guix.
9 ;;;
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
14 ;;;
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
19 ;;;
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22
23 (define-module (gnu packages sdl)
24 #:use-module (ice-9 match)
25 #:use-module (gnu packages)
26 #:use-module ((guix licenses) #:hide (freetype))
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix build-system gnu)
30 #:use-module (guix build-system trivial)
31 #:use-module (gnu packages audio)
32 #:use-module (gnu packages fcitx)
33 #:use-module (gnu packages fontutils)
34 #:use-module (gnu packages glib)
35 #:use-module (gnu packages guile)
36 #:use-module (gnu packages ibus)
37 #:use-module (gnu packages image)
38 #:use-module (gnu packages linux)
39 #:use-module (gnu packages mp3)
40 #:use-module (gnu packages pkg-config)
41 #:use-module (gnu packages pulseaudio)
42 #:use-module (gnu packages gl)
43 #:use-module (gnu packages xiph)
44 #:use-module (gnu packages xorg)
45 #:export (sdl-union))
46
47 (define-public sdl
48 (package
49 (name "sdl")
50 (version "1.2.15")
51 (source (origin
52 (method url-fetch)
53 (uri
54 (string-append "https://libsdl.org/release/SDL-"
55 version ".tar.gz"))
56 (sha256
57 (base32
58 "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"))
59 (patches (search-patches "sdl-libx11-1.6.patch"))))
60 (build-system gnu-build-system)
61 (arguments
62 '(;; Explicitly link against shared libraries instead of dlopening them.
63 ;; For X11, ALSA, and PulseAudio.
64 ;; OpenGL library is still dlopened at runtime.
65 #:configure-flags '("--disable-alsa-shared"
66 "--disable-pulseaudio-shared"
67 "--disable-x11-shared"
68 ;; Explicitly link with mesa.
69 ;; This add mesa to libsdl's RUNPATH, to make dlopen
70 ;; finding the libGL from mesa at runtime.
71 "LDFLAGS=-lGL")
72
73 #:tests? #f)) ; no check target
74 (propagated-inputs
75 ;; SDL headers include X11 headers.
76 `(("libx11" ,libx11)
77 ("libcap" ,libcap))) ; 'libSDL.la' contain `-lcap'.
78 (native-inputs `(("pkg-config" ,pkg-config)))
79 (inputs `(("libxrandr" ,libxrandr)
80 ("mesa" ,mesa)
81 ("glu" ,glu)
82 ("alsa-lib" ,alsa-lib)
83 ("pulseaudio" ,pulseaudio)))
84 (synopsis "Cross platform game development library")
85 (description "Simple DirectMedia Layer is a cross-platform development
86 library designed to provide low level access to audio, keyboard, mouse,
87 joystick, and graphics hardware.")
88 (home-page "https://libsdl.org/")
89 (license lgpl2.1)))
90
91 (define-public sdl2
92 (package (inherit sdl)
93 (name "sdl2")
94 (version "2.0.5")
95 (source (origin
96 (method url-fetch)
97 (uri
98 (string-append "https://libsdl.org/release/SDL2-"
99 version ".tar.gz"))
100 (sha256
101 (base32
102 "11c75qj1qxmx67iwkvf9z4x69phk301pdn86zzr6jncnap7kh824"))))
103 (inputs
104 ;; SDL2 needs to be built with ibus support otherwise some systems
105 ;; experience a bug where input events are doubled.
106 ;;
107 ;; For more information, see: https://dev.solus-project.com/T1721
108 (append `(("dbus" ,dbus)
109 ("fcitx" ,fcitx) ; helps with CJK input
110 ("glib" ,glib)
111 ("ibus" ,ibus))
112 (package-inputs sdl)))
113 (license bsd-3)))
114
115 (define-public libmikmod
116 (package
117 (name "libmikmod")
118 (version "3.3.10")
119 (source (origin
120 (method url-fetch)
121 (uri (string-append "mirror://sourceforge/mikmod/libmikmod/"
122 version "/libmikmod-" version ".tar.gz"))
123 (sha256
124 (base32
125 "0j7g4jpa2zgzw7x6s3rldypa7zlwjvn97rwx0sylx1iihhlzbcq0"))))
126 (build-system gnu-build-system)
127 (arguments
128 ;; By default, libmikmod tries to dlopen libasound etc., which won't work
129 ;; unless the right libalsa happens to be in $LD_LIBRARY_PATH. Pass
130 ;; '--disable-dl' to avoid that.
131 '(#:configure-flags '("--disable-dl")))
132 (synopsis "Library for module sound formats")
133 (description
134 "MikMod is able to play a wide range of module formats, as well as
135 digital sound files. It can take advantage of particular features of your
136 system, such as sound redirection over the network.")
137 (license lgpl2.1)
138 (home-page "http://mikmod.sourceforge.net/")))
139
140 (define-public sdl-gfx
141 (package
142 (name "sdl-gfx")
143 (version "2.0.24")
144 (source (origin
145 (method url-fetch)
146 (uri
147 (string-append "http://www.ferzkopp.net/Software/SDL_gfx-2.0/SDL_gfx-"
148 version ".tar.gz"))
149 (sha256
150 (base32
151 "064islldm4r42lgj9fr4kbk66r7jmmakk9745hhyb1kmw71kib9h"))))
152 (build-system gnu-build-system)
153 (propagated-inputs `(("sdl" ,sdl)))
154 (synopsis "SDL graphics primitives library")
155 (description "SDL_gfx provides graphics drawing primitives, rotozoom and
156 other supporting functions for SDL.")
157 (home-page "http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx")
158 (license zlib)
159
160 ;; The code apparently includes Intel assembly, which fails to build on
161 ;; MIPS, at least.
162 (supported-systems '("i686-linux" "x86_64-linux"))))
163
164 (define-public sdl-image
165 (package
166 (name "sdl-image")
167 (version "1.2.12")
168 (source (origin
169 (method url-fetch)
170 (uri
171 (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL_image-"
172 version ".tar.gz"))
173 (sha256
174 (base32
175 "16an9slbb8ci7d89wakkmyfvp7c0cval8xw4hkg0842nhhlp540b"))))
176 (build-system gnu-build-system)
177 (arguments
178 ;; Explicitly link against shared libraries instead of dlopening them.
179 '(#:configure-flags '("--disable-jpg-shared"
180 "--disable-png-shared"
181 "--disable-tif-shared"
182 "--disable-webp-shared")))
183 (native-inputs `(("pkg-config" ,pkg-config)))
184 ;; libjpeg, libpng, and libtiff are propagated inputs because the
185 ;; SDL_image headers include the headers of these libraries. SDL is a
186 ;; propagated input because the pkg-config file refers to SDL's pkg-config
187 ;; file.
188 (propagated-inputs `(("sdl" ,sdl)
189 ("libjpeg" ,libjpeg)
190 ("libpng" ,libpng)
191 ("libtiff" ,libtiff)
192 ("libwebp" ,libwebp)))
193 (synopsis "SDL image loading library")
194 (description "SDL_image is an image file loading library for SDL that
195 supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF,
196 WEBP, XCF, XPM, and XV.")
197 (home-page "https://www.libsdl.org/projects/SDL_image/")
198 (license zlib)))
199
200 (define-public sdl-mixer
201 (package
202 (name "sdl-mixer")
203 (version "1.2.12")
204 (source (origin
205 (method url-fetch)
206 (uri
207 (string-append "https://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-"
208 version ".tar.gz"))
209 (sha256
210 (base32
211 "0alrhqgm40p4c92s26mimg9cm1y7rzr6m0p49687jxd9g6130i0n"))))
212 (build-system gnu-build-system)
213 ;; no check target
214 ;; use libmad instead of smpeg
215 ;; explicitly link against shared libraries instead of dlopening them
216 (arguments `(#:tests? #f
217 #:configure-flags '("--enable-music-mp3-mad-gpl"
218 "--disable-music-mod-shared"
219 "--disable-music-fluidsynth-shared"
220 "--disable-music-ogg-shared"
221 "--disable-music-flac-shared"
222 "--disable-music-mp3-shared")))
223 (inputs `(("libvorbis" ,libvorbis)
224 ("libflac" ,flac)
225 ("libmad" ,libmad)
226 ("libmikmod" ,libmikmod)
227 ("libmodplug" ,libmodplug)))
228 ;; FIXME: Add libfluidsynth
229 (propagated-inputs `(("sdl" ,sdl)))
230 (synopsis "SDL multi-channel audio mixer library")
231 (description "SDL_mixer is a multi-channel audio mixer library for SDL.
232 It supports any number of simultaneously playing channels of 16 bit stereo
233 audio, plus a single channel of music. Supported format include FLAC, MOD,
234 MIDI, Ogg Vorbis, and MP3.")
235 (home-page "https://www.libsdl.org/projects/SDL_mixer/")
236 (license zlib)))
237
238 (define-public sdl-net
239 (package
240 (name "sdl-net")
241 (version "1.2.8")
242 (source (origin
243 (method url-fetch)
244 (uri
245 (string-append "https://www.libsdl.org/projects/SDL_net/release/SDL_net-"
246 version ".tar.gz"))
247 (sha256
248 (base32
249 "1d5c9xqlf4s1c01gzv6cxmg0r621pq9kfgxcg3197xw4p25pljjz"))))
250 (build-system gnu-build-system)
251 (propagated-inputs `(("sdl" ,sdl)))
252 (native-inputs `(("pkg-config" ,pkg-config)))
253 (synopsis "SDL networking library")
254 (description "SDL_net is a small, cross-platform networking library for
255 SDL.")
256 (home-page "https://www.libsdl.org/projects/SDL_net/")
257 (license zlib)))
258
259 (define-public sdl-ttf
260 (package
261 (name "sdl-ttf")
262 (version "2.0.11")
263 (source (origin
264 (method url-fetch)
265 (uri
266 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
267 version ".tar.gz"))
268 (sha256
269 (base32
270 "1dydxd4f5kb1288i5n5568kdk2q7f8mqjr7i7sd33nplxjaxhk3j"))))
271 (build-system gnu-build-system)
272 (propagated-inputs `(("sdl" ,sdl)))
273 (inputs `(("freetype" ,freetype)
274 ("mesa" ,mesa)))
275 (native-inputs `(("pkg-config" ,pkg-config)))
276 (synopsis "SDL TrueType font library")
277 (description "SDL_ttf is a TrueType font rendering library for SDL.")
278 (home-page "https://www.libsdl.org/projects/SDL_ttf/")
279 (license zlib)))
280
281 (define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
282 sdl-image sdl-mixer)))
283 "Return 'sdl-union' package which is a union of PACKAGES.
284 If PACKAGES are not specified, all SDL packages are used."
285 (package
286 (name "sdl-union")
287 (version (package-version sdl))
288 (source #f)
289 (build-system trivial-build-system)
290 (arguments
291 '(#:modules ((guix build union))
292 #:builder (begin
293 (use-modules (ice-9 match)
294 (guix build union))
295 (match %build-inputs
296 (((names . directories) ...)
297 (union-build (assoc-ref %outputs "out")
298 directories))))))
299 (inputs (map (lambda (package)
300 (list (package-name package) package))
301 packages))
302 (synopsis "Union of SDL libraries")
303 (description
304 "A union of SDL and its extension libraries. A union is required because
305 sdl-config assumes that all of the headers and libraries are in the same
306 directory.")
307 (home-page (package-home-page sdl))
308 (license (package-license sdl))))
309
310 (define (propagated-inputs-with-sdl2 package)
311 "Replace the \"sdl\" propagated input of PACKAGE with SDL2."
312 (map (match-lambda
313 (("sdl" _)
314 `("sdl2" ,sdl2))
315 (other other))
316 (package-propagated-inputs package)))
317
318 (define-public sdl2-image
319 (package (inherit sdl-image)
320 (name "sdl2-image")
321 (version "2.0.1")
322 (source (origin
323 (method url-fetch)
324 (uri
325 (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL2_image-"
326 version ".tar.gz"))
327 (sha256
328 (base32
329 "0r3z1l7fdn76qkpy7snpkcjqz8dkv2zp6lsqpq25q4m5xsyaygis"))))
330 (propagated-inputs
331 (propagated-inputs-with-sdl2 sdl-image))))
332
333 (define-public sdl2-mixer
334 (package (inherit sdl-mixer)
335 (name "sdl2-mixer")
336 (version "2.0.1")
337 (source (origin
338 (method url-fetch)
339 (uri
340 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-"
341 version ".tar.gz"))
342 (modules '((guix build utils)))
343 (snippet
344 ;; Remove bundled libraries.
345 '(delete-file-recursively "external"))
346 (sha256
347 (base32
348 "0pv9jzjpcjlbiaybvwrb4avmv46qk7iqxlnqrd2dfj82c4mgc92s"))))
349 (propagated-inputs
350 (propagated-inputs-with-sdl2 sdl-mixer))))
351
352 (define-public sdl2-ttf
353 (package (inherit sdl-ttf)
354 (name "sdl2-ttf")
355 (version "2.0.14")
356 (source (origin
357 (method url-fetch)
358 (uri
359 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-"
360 version ".tar.gz"))
361 (modules '((guix build utils)))
362 (snippet
363 ;; Remove bundled libraries.
364 '(delete-file-recursively "external"))
365 (sha256
366 (base32
367 "0xljwcpvd2knrjdfag5b257xqayplz55mqlszrqp0kpnphh5xnrl"))))
368 (propagated-inputs
369 (propagated-inputs-with-sdl2 sdl-ttf))))
370
371 (define-public guile-sdl
372 (package
373 (name "guile-sdl")
374 (version "0.5.2")
375 (source (origin
376 (method url-fetch)
377 (uri
378 (string-append "mirror://gnu/guile-sdl/guile-sdl-"
379 version ".tar.xz"))
380 (sha256
381 (base32
382 "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
383 (build-system gnu-build-system)
384 (native-inputs
385 `(("pkg-config" ,pkg-config)
386 ;; Required by test suite.
387 ("xorg-server" ,xorg-server)
388 ("libjpeg" ,libjpeg)))
389 (inputs
390 `(("guile" ,guile-2.0)
391 ("sdl-union" ,(sdl-union))))
392 (arguments
393 '(#:configure-flags
394 (list (string-append "--with-sdl-prefix="
395 (assoc-ref %build-inputs "sdl-union")))
396 #:parallel-build? #f ; parallel build fails
397 #:phases
398 (alist-cons-before
399 'configure 'fix-env-and-patch
400 (lambda* (#:key inputs #:allow-other-keys)
401 (setenv "GUILE_AUTO_COMPILE" "0")
402 ;; SDL_image needs to dlopen libjpeg in the test suite.
403 (setenv "LD_LIBRARY_PATH"
404 (string-append (assoc-ref inputs "libjpeg") "/lib"))
405 ;; Change the site directory /site/2.0 like Guile expects.
406 (substitute* "build-aux/guile-baux/re-prefixed-site-dirs"
407 (("\"/site\"") "\"/site/2.0\""))
408
409 ;; Skip tests that rely on sound support, which is unavailable in
410 ;; the build environment.
411 (substitute* "test/Makefile.in"
412 (("HAVE_MIXER = .*$")
413 "HAVE_MIXER = 0\n")))
414 (alist-cons-before
415 'check 'start-xorg-server
416 (lambda* (#:key inputs #:allow-other-keys)
417 ;; The test suite requires a running X server.
418 (system (format #f "~a/bin/Xvfb :1 &"
419 (assoc-ref inputs "xorg-server")))
420 (setenv "DISPLAY" ":1"))
421 %standard-phases))))
422 (synopsis "Guile interface for SDL (Simple DirectMedia Layer)")
423 (description "Guile-SDL is a set of bindings to the Simple DirectMedia
424 Layer (SDL). With them, Guile programmers can have easy access to graphics,
425 sound and device input (keyboards, joysticks, mice, etc.).")
426 (home-page "http://gnu.org/s/guile-sdl")
427 (license gpl3+)))
428
429 (define-public guile-sdl2
430 (package
431 (name "guile-sdl2")
432 (version "0.2.0")
433 (source (origin
434 (method url-fetch)
435 (uri (string-append
436 "https://files.dthompson.us/guile-sdl2/guile-sdl2-"
437 version ".tar.gz"))
438 (sha256
439 (base32
440 "0yq9lsl17cdvj77padvpk3jcw2g6g0pck9jrchc7n2767rrc012b"))))
441 (build-system gnu-build-system)
442 (arguments
443 '(#:make-flags '("GUILE_AUTO_COMPILE=0")
444 #:configure-flags
445 (list (string-append "--with-libsdl2-prefix="
446 (assoc-ref %build-inputs "sdl2"))
447 (string-append "--with-libsdl2-image-prefix="
448 (assoc-ref %build-inputs "sdl2-image"))
449 (string-append "--with-libsdl2-ttf-prefix="
450 (assoc-ref %build-inputs "sdl2-ttf"))
451 (string-append "--with-libsdl2-mixer-prefix="
452 (assoc-ref %build-inputs "sdl2-mixer")))))
453 (native-inputs
454 `(("guile" ,guile-2.0)
455 ("pkg-config" ,pkg-config)))
456 (inputs
457 `(("sdl2" ,sdl2)
458 ("sdl2-image" ,sdl2-image)
459 ("sdl2-mixer" ,sdl2-mixer)
460 ("sdl2-ttf" ,sdl2-ttf)))
461 (synopsis "Guile bindings for SDL2")
462 (home-page "https://dthompson.us/projects/guile-sdl2.html")
463 (description
464 "Guile-SDL2 provides Guile Scheme bindings for the SDL2 C shared library.
465 The bindings are written in pure Scheme using Guile's foreign function
466 interface.")
467 (license lgpl3+)))