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