Merge branch 'master' into core-updates
[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, 2017 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2017, 2018, 2019 Rutger Helling <rhelling@mykolab.com>
8 ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;; Copyright © 2018, 2019, 2020 Ricardo Wurmus <rekado@elephly.net>
10 ;;; Copyright © 2019 Kei Kebreau <kkebreau@posteo.net>
11 ;;; Copyright © 2019, 2020 Nicolas Goaziou <mail@nicolasgoaziou.fr>
12 ;;; Copyright © 2019 Marius Bakke <mbakke@fastmail.com>
13 ;;; Copyright © 2019 Pierre Neidhardt <mail@ambrevar.xyz>
14 ;;; Copyright © 2020 Timotej Lazar <timotej.lazar@araneo.si>
15 ;;; Copyright © 2020 Oleg Pykhalov <go.wigust@gmail.com>
16 ;;;
17 ;;; This file is part of GNU Guix.
18 ;;;
19 ;;; GNU Guix is free software; you can redistribute it and/or modify it
20 ;;; under the terms of the GNU General Public License as published by
21 ;;; the Free Software Foundation; either version 3 of the License, or (at
22 ;;; your option) any later version.
23 ;;;
24 ;;; GNU Guix is distributed in the hope that it will be useful, but
25 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
26 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 ;;; GNU General Public License for more details.
28 ;;;
29 ;;; You should have received a copy of the GNU General Public License
30 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
31
32 (define-module (gnu packages sdl)
33 #:use-module (ice-9 match)
34 #:use-module (srfi srfi-1)
35 #:use-module (srfi srfi-26)
36 #:use-module (gnu packages)
37 #:use-module ((guix licenses) #:hide (freetype))
38 #:use-module (guix packages)
39 #:use-module (guix download)
40 #:use-module (guix git-download)
41 #:use-module (guix utils)
42 #:use-module (guix build-system gnu)
43 #:use-module (guix build-system trivial)
44 #:use-module (gnu packages audio)
45 #:use-module (gnu packages autotools)
46 #:use-module (gnu packages fcitx)
47 #:use-module (gnu packages fontutils)
48 #:use-module (gnu packages freedesktop)
49 #:use-module (gnu packages glib)
50 #:use-module (gnu packages gtk)
51 #:use-module (gnu packages guile)
52 #:use-module (gnu packages ibus)
53 #:use-module (gnu packages image)
54 #:use-module (gnu packages linux)
55 #:use-module (gnu packages mono)
56 #:use-module (gnu packages mp3)
57 #:use-module (gnu packages pkg-config)
58 #:use-module (gnu packages pulseaudio)
59 #:use-module (gnu packages gl)
60 #:use-module (gnu packages xdisorg)
61 #:use-module (gnu packages xiph)
62 #:use-module (gnu packages xorg)
63 #:export (sdl-union))
64
65 (define-public sdl
66 (package
67 (name "sdl")
68 (version "1.2.15")
69 (source (origin
70 (method url-fetch)
71 (uri
72 (string-append "https://libsdl.org/release/SDL-"
73 version ".tar.gz"))
74 (sha256
75 (base32
76 "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"))
77 (patches (search-patches "sdl-libx11-1.6.patch"))))
78 (build-system gnu-build-system)
79 (arguments
80 '(;; Explicitly link against shared libraries instead of dlopening them.
81 ;; For X11, ALSA, and PulseAudio.
82 ;; OpenGL library is still dlopened at runtime.
83 #:configure-flags '("--disable-alsa-shared"
84 "--disable-pulseaudio-shared"
85 "--disable-x11-shared"
86 ;; Explicitly link with mesa.
87 ;; This add mesa to libsdl's RUNPATH, to make dlopen
88 ;; finding the libGL from mesa at runtime.
89 "LDFLAGS=-lGL")
90
91 #:make-flags '("V=1") ;build verbosely
92
93 #:tests? #f)) ; no check target
94 (propagated-inputs
95 ;; SDL headers include X11 headers.
96 `(("libx11" ,libx11)
97 ("libcap" ,libcap) ; 'libSDL.la' contain `-lcap'.
98 ;; TODO: Since building Mesa with Meson it is now necessary that Mesa is
99 ;; a propogated input. We still need to figure out why, possibly due to a
100 ;; change in pkg-config.
101 ("mesa" ,mesa)))
102 (native-inputs `(("pkg-config" ,pkg-config)))
103 (inputs `(("libxrandr" ,libxrandr)
104 ("glu" ,glu)
105 ("alsa-lib" ,alsa-lib)
106 ("pulseaudio" ,pulseaudio)))
107 (outputs '("out" "debug"))
108 (synopsis "Cross platform game development library")
109 (description "Simple DirectMedia Layer is a cross-platform development
110 library designed to provide low level access to audio, keyboard, mouse,
111 joystick, and graphics hardware.")
112 (home-page "https://libsdl.org/")
113 (license lgpl2.1)))
114
115 (define-public sdl2
116 (package (inherit sdl)
117 (name "sdl2")
118 (version "2.0.12")
119 (source (origin
120 (method url-fetch)
121 (uri
122 (string-append "https://libsdl.org/release/SDL2-"
123 version ".tar.gz"))
124 (sha256
125 (base32
126 "0qy8wbqvfkb5ps8kxgaaf2zzpkjqbsw712hlp74znbn0jpv6i4il"))))
127 (arguments
128 (substitute-keyword-arguments (package-arguments sdl)
129 ((#:configure-flags flags)
130 `(append '("--disable-wayland-shared" "--enable-video-kmsdrm"
131 "--disable-kmsdrm-shared")
132 ,flags))
133 ((#:make-flags flags ''())
134 `(cons*
135 ;; SDL dlopens libudev, so make sure it is in rpath. This overrides
136 ;; the LDFLAG set in sdl’s configure-flags, which isn’t necessary
137 ;; as sdl2 includes Mesa by default.
138 (string-append "LDFLAGS=-Wl,-rpath,"
139 (assoc-ref %build-inputs "eudev") "/lib")
140 ,flags))))
141 (inputs
142 ;; SDL2 needs to be built with ibus support otherwise some systems
143 ;; experience a bug where input events are doubled.
144 ;;
145 ;; For more information, see: https://dev.solus-project.com/T1721
146 (append `(("dbus" ,dbus)
147 ("eudev" ,eudev) ; for discovering input devices
148 ("fcitx" ,fcitx) ; helps with CJK input
149 ("glib" ,glib)
150 ("ibus" ,ibus)
151 ("libxkbcommon" ,libxkbcommon)
152 ("libxcursor" ,libxcursor) ; enables X11 cursor support
153 ("wayland" ,wayland)
154 ("wayland-protocols" ,wayland-protocols))
155 (package-inputs sdl)))
156 (license bsd-3)))
157
158 (define-public libmikmod
159 (package
160 (name "libmikmod")
161 (version "3.3.11.1")
162 (source (origin
163 (method url-fetch)
164 (uri (list
165 (string-append "mirror://sourceforge/mikmod/libmikmod/"
166 version "/libmikmod-" version ".tar.gz")
167 ;; Older versions are sometimes moved to:
168 (string-append "mirror://sourceforge/mikmod/"
169 "outdated_versions/libmikmod/"
170 version "/libmikmod-" version ".tar.gz")))
171 (sha256
172 (base32
173 "06bdnhb0l81srdzg6gn2v2ydhhaazza7rshrcj3q8dpqr3gn97dd"))))
174 (build-system gnu-build-system)
175 (arguments
176 ;; By default, libmikmod tries to dlopen libasound etc., which won't work
177 ;; unless the right libalsa happens to be in $LD_LIBRARY_PATH. Pass
178 ;; '--disable-dl' to avoid that.
179 '(#:configure-flags '("--disable-dl")))
180 (synopsis "Library for module sound formats")
181 (description
182 "MikMod is able to play a wide range of module formats, as well as
183 digital sound files. It can take advantage of particular features of your
184 system, such as sound redirection over the network.")
185 (license lgpl2.1)
186 (home-page "http://mikmod.sourceforge.net/")))
187
188 (define-public sdl-gfx
189 (package
190 (name "sdl-gfx")
191 (version "2.0.26")
192 (source (origin
193 (method url-fetch)
194 (uri
195 (string-append "http://www.ferzkopp.net/Software/SDL_gfx-2.0/SDL_gfx-"
196 version ".tar.gz"))
197 (sha256
198 (base32
199 "0ijljhs0v99dj6y27hc10z6qchyp8gdp4199y6jzngy6dzxlzsvw"))))
200 (build-system gnu-build-system)
201 (outputs '("out" "debug"))
202 (arguments
203 `(,@(if (any (cute string-prefix? <> (or (%current-system)
204 (%current-target-system)))
205 '("x86_64" "i686"))
206 ;; mmx is supported only on Intel processors.
207 '()
208 '(#:configure-flags '("--disable-mmx")))))
209 (propagated-inputs `(("sdl" ,sdl)))
210 (synopsis "SDL graphics primitives library")
211 (description "SDL_gfx provides graphics drawing primitives, rotozoom and
212 other supporting functions for SDL.")
213 (home-page "http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx")
214 (license zlib)))
215
216 (define-public sdl-image
217 (package
218 (name "sdl-image")
219 (version "1.2.12")
220 (source (origin
221 (method url-fetch)
222 (uri
223 (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL_image-"
224 version ".tar.gz"))
225 (sha256
226 (base32
227 "16an9slbb8ci7d89wakkmyfvp7c0cval8xw4hkg0842nhhlp540b"))))
228 (build-system gnu-build-system)
229 (outputs '("out" "debug"))
230 (arguments
231 ;; Explicitly link against shared libraries instead of dlopening them.
232 '(#:configure-flags '("--disable-jpg-shared"
233 "--disable-png-shared"
234 "--disable-tif-shared"
235 "--disable-webp-shared")))
236 (native-inputs `(("pkg-config" ,pkg-config)))
237 ;; libjpeg, libpng, and libtiff are propagated inputs because the
238 ;; SDL_image headers include the headers of these libraries. SDL is a
239 ;; propagated input because the pkg-config file refers to SDL's pkg-config
240 ;; file.
241 (propagated-inputs `(("sdl" ,sdl)
242 ("libjpeg" ,libjpeg-turbo)
243 ("libpng" ,libpng)
244 ("libtiff" ,libtiff)
245 ("libwebp" ,libwebp)))
246 (synopsis "SDL image loading library")
247 (description "SDL_image is an image file loading library for SDL that
248 supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF,
249 WEBP, XCF, XPM, and XV.")
250 (home-page "https://www.libsdl.org/projects/SDL_image/")
251 (license zlib)))
252
253 (define-public sdl-mixer
254 (package
255 (name "sdl-mixer")
256 (version "1.2.12")
257 (source (origin
258 (method url-fetch)
259 (uri
260 (string-append "https://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-"
261 version ".tar.gz"))
262 (sha256
263 (base32
264 "0alrhqgm40p4c92s26mimg9cm1y7rzr6m0p49687jxd9g6130i0n"))))
265 (build-system gnu-build-system)
266 (outputs '("out" "debug"))
267 (arguments
268 `(#:tests? #f ; No check target.
269 #:configure-flags
270 '("--enable-music-mp3-mad-gpl" ; Use libmad instead of smpeg.
271 ;; Explicitly link against shared libraries instead of dlopening them.
272 "--disable-music-flac-shared"
273 "--disable-music-fluidsynth-shared"
274 "--disable-music-mod-shared"
275 "--disable-music-ogg-shared")
276 #:phases
277 (modify-phases %standard-phases
278 (add-after 'unpack 'fix-fluidsynth
279 (lambda* (#:key inputs #:allow-other-keys)
280 (substitute* "configure"
281 (("EXTRA_LDFLAGS -lfluidsynth")
282 (string-append "EXTRA_LDFLAGS "
283 "-L"
284 (assoc-ref inputs "fluidsynth")
285 "/lib -lfluidsynth")))
286 #t)))))
287 (inputs
288 `(("fluidsynth" ,fluidsynth)
289 ("libflac" ,flac)
290 ("libmad" ,libmad)
291 ("libmikmod" ,libmikmod)
292 ("libvorbis" ,libvorbis)))
293 (propagated-inputs `(("sdl" ,sdl)))
294 (synopsis "SDL multi-channel audio mixer library")
295 (description "SDL_mixer is a multi-channel audio mixer library for SDL.
296 It supports any number of simultaneously playing channels of 16 bit stereo
297 audio, plus a single channel of music. Supported formats include FLAC, MOD,
298 MIDI, Ogg Vorbis, and MP3.
299
300 This package supports two MIDI backends, selectable at runtime. To use the
301 newer @code{fluidsynth} library, install a soundfont such as @code{fluid-3}
302 and specify it using the @code{SDL_SOUNDFONTS} environment variable. For the
303 legacy @code{timidity} backend, install a patch set such as @code{freepats}
304 and set the path to the configuration file with @code{TIMIDITY_CFG}.")
305 (home-page "https://www.libsdl.org/projects/SDL_mixer/")
306 (license zlib)))
307
308 (define-public sdl-net
309 (package
310 (name "sdl-net")
311 (version "1.2.8")
312 (source (origin
313 (method url-fetch)
314 (uri
315 (string-append "https://www.libsdl.org/projects/SDL_net/release/SDL_net-"
316 version ".tar.gz"))
317 (sha256
318 (base32
319 "1d5c9xqlf4s1c01gzv6cxmg0r621pq9kfgxcg3197xw4p25pljjz"))))
320 (build-system gnu-build-system)
321 (propagated-inputs `(("sdl" ,sdl)))
322 (native-inputs `(("pkg-config" ,pkg-config)))
323 (outputs '("out" "debug"))
324 (synopsis "SDL networking library")
325 (description "SDL_net is a small, cross-platform networking library for
326 SDL.")
327 (home-page "https://www.libsdl.org/projects/SDL_net/")
328 (license zlib)))
329
330 (define-public sdl-pango
331 (package
332 (name "sdl-pango")
333 (version "0.1.2")
334 (source
335 (origin
336 (method url-fetch)
337 (uri (string-append
338 "mirror://sourceforge/sdlpango/SDL_Pango/" version "/"
339 "SDL_Pango-" version ".tar.gz"))
340 (sha256
341 (base32 "197baw1dsg0p4pljs5k0fshbyki00r4l49m1drlpqw6ggawx6xbz"))
342 (patches
343 (search-patches
344 "sdl-pango-api_additions.patch"
345 "sdl-pango-blit_overflow.patch"
346 "sdl-pango-fillrect_crash.patch"
347 "sdl-pango-fix-explicit-SDLPango_CopyFTBitmapTo.patch"
348 "sdl-pango-matrix_declarations.patch"
349 "sdl-pango-sans-serif.patch"))))
350 (build-system gnu-build-system)
351 (arguments
352 `(#:configure-flags (list "--disable-static")
353 #:phases
354 (modify-phases %standard-phases
355 (add-after 'unpack 'autogen
356 ;; Force reconfiguration because the included libtool
357 ;; generates linking errors.
358 (lambda _ (invoke "autoreconf" "-vif"))))))
359 (native-inputs
360 `(("autoconf" ,autoconf)
361 ("automake" ,automake)
362 ("libtool" ,libtool)
363 ("pkg-config" ,pkg-config)))
364 (inputs
365 `(("fontconfig" ,fontconfig)
366 ("freetype" ,freetype)
367 ("glib" ,glib)
368 ("harfbuzz" ,harfbuzz)
369 ("pango" ,pango)
370 ("sdl" ,sdl)))
371 (home-page "http://sdlpango.sourceforge.net")
372 (synopsis "Pango SDL binding")
373 (description "This library is a wrapper around the Pango library.
374 It allows you to use TrueType fonts to render internationalized and
375 tagged text in SDL applications.")
376 (license lgpl2.1)))
377
378 (define-public sdl-ttf
379 (package
380 (name "sdl-ttf")
381 (version "2.0.11")
382 (source (origin
383 (method url-fetch)
384 (uri
385 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
386 version ".tar.gz"))
387 (sha256
388 (base32
389 "1dydxd4f5kb1288i5n5568kdk2q7f8mqjr7i7sd33nplxjaxhk3j"))))
390 (build-system gnu-build-system)
391 (propagated-inputs `(("sdl" ,sdl)))
392 (inputs `(("freetype" ,freetype)
393 ("mesa" ,mesa)))
394 (native-inputs `(("pkg-config" ,pkg-config)))
395 (outputs '("out" "debug"))
396 (synopsis "SDL TrueType font library")
397 (description "SDL_ttf is a TrueType font rendering library for SDL.")
398 (home-page "https://www.libsdl.org/projects/SDL_ttf/")
399 (license zlib)))
400
401 (define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
402 sdl-image sdl-mixer)))
403 "Return 'sdl-union' package which is a union of PACKAGES.
404 If PACKAGES are not specified, all SDL packages are used."
405 (package
406 (name "sdl-union")
407 (version (package-version sdl))
408 (source #f)
409 (build-system trivial-build-system)
410 (arguments
411 '(#:modules ((guix build union))
412 #:builder (begin
413 (use-modules (ice-9 match)
414 (guix build union))
415 (match %build-inputs
416 (((names . directories) ...)
417 (union-build (assoc-ref %outputs "out")
418 directories)
419 #t)))))
420 (inputs (map (lambda (package)
421 (list (package-name package) package))
422 packages))
423 (synopsis "Union of SDL libraries")
424 (description
425 "A union of SDL and its extension libraries. A union is required because
426 sdl-config assumes that all of the headers and libraries are in the same
427 directory.")
428 (home-page (package-home-page sdl))
429 (license (package-license sdl))))
430
431 (define (propagated-inputs-with-sdl2 package)
432 "Replace the \"sdl\" propagated input of PACKAGE with SDL2."
433 (map (match-lambda
434 (("sdl" _)
435 `("sdl2" ,sdl2))
436 (other other))
437 (package-propagated-inputs package)))
438
439 (define-public sdl2-gfx
440 (package (inherit sdl-gfx)
441 (name "sdl2-gfx")
442 (version "1.0.4")
443 (source (origin
444 (method url-fetch)
445 (uri
446 (string-append "https://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-"
447 version ".tar.gz"))
448 (sha256
449 (base32
450 "0qk2ax7f7grlxb13ba0ll3zlm8780s7j8fmrhlpxzjgdvldf1q33"))))
451 (propagated-inputs
452 (propagated-inputs-with-sdl2 sdl-gfx))))
453
454 (define-public sdl2-image
455 (package (inherit sdl-image)
456 (name "sdl2-image")
457 (version "2.0.5")
458 (source
459 (origin
460 (method url-fetch)
461 (uri
462 (string-append "https://www.libsdl.org/projects/SDL_image/release/"
463 "SDL2_image-" version ".tar.gz"))
464 (sha256
465 (base32 "1l0864kas9cwpp2d32yxl81g98lx40dhbdp03dz7sbv84vhgdmdx"))))
466 (propagated-inputs
467 (propagated-inputs-with-sdl2 sdl-image))))
468
469 (define-public sdl2-mixer
470 (package (inherit sdl-mixer)
471 (name "sdl2-mixer")
472 (version "2.0.4")
473 (source
474 (origin
475 (method url-fetch)
476 (uri
477 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/"
478 "SDL2_mixer-" version ".tar.gz"))
479 (modules '((guix build utils)))
480 (snippet '(begin
481 ;; Remove bundled libraries.
482 (delete-file-recursively "external")
483 #t))
484 (sha256
485 (base32 "0694vsz5bjkcdgfdra6x9fq8vpzrl8m6q96gh58df7065hw5mkxl"))))
486 (arguments
487 (substitute-keyword-arguments (package-arguments sdl-mixer)
488 ((#:configure-flags flags)
489 `(cons*
490 "--disable-music-opus-shared"
491 ;; These options were renamed in SDL2 mixer. Keeping the inherited
492 ;; variants produces a harmless warning.
493 "--disable-music-mod-modplug-shared"
494 "--disable-music-midi-fluidsynth-shared"
495 ,flags))))
496 (inputs
497 `(("opusfile" ,opusfile)
498 ;; The default MOD library changed in SDL2 mixer.
499 ("libmodplug" ,libmodplug)
500 ,@(alist-delete "libmikmod" (package-inputs sdl-mixer))))
501 (native-inputs
502 `(("pkgconfig" ,pkg-config))) ; Needed to find the opus library.
503 (propagated-inputs
504 (propagated-inputs-with-sdl2 sdl-mixer))))
505
506 (define-public sdl2-net
507 (package (inherit sdl-net)
508 (name "sdl2-net")
509 (version "2.0.1")
510 (source
511 (origin
512 (method url-fetch)
513 (uri
514 (string-append "http://www.libsdl.org/projects/SDL_net/release/"
515 "SDL2_net-" version ".tar.gz"))
516 (sha256
517 (base32
518 "08cxc1bicmyk89kiks7izw1rlx5ng5n6xpy8fy0zxni3b9z8mkhm"))))
519 (propagated-inputs
520 (propagated-inputs-with-sdl2 sdl-net))))
521
522 (define-public sdl2-ttf
523 (package (inherit sdl-ttf)
524 (name "sdl2-ttf")
525 (version "2.0.15")
526 (source (origin
527 (method url-fetch)
528 (uri
529 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-"
530 version ".tar.gz"))
531 (modules '((guix build utils)))
532 (snippet (begin
533 ;; Remove bundled libraries.
534 '(delete-file-recursively "external")
535 #t))
536 (sha256
537 (base32
538 "0cyd48dipc0m399qy8s03lci8b0bpiy8xlkvrm2ia7wcv0dfpv59"))))
539 (propagated-inputs
540 (propagated-inputs-with-sdl2 sdl-ttf))))
541
542 (define-public guile-sdl
543 (package
544 (name "guile-sdl")
545 (version "0.5.2")
546 (source (origin
547 (method url-fetch)
548 (uri
549 (string-append "mirror://gnu/guile-sdl/guile-sdl-"
550 version ".tar.xz"))
551 (sha256
552 (base32
553 "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
554 (build-system gnu-build-system)
555 (native-inputs
556 `(("pkg-config" ,pkg-config)
557 ;; Required by test suite.
558 ("xorg-server" ,xorg-server)
559 ("libjpeg" ,libjpeg-turbo)))
560 (inputs
561 `(("guile" ,guile-2.2)
562 ("sdl-union" ,(sdl-union))))
563 (arguments
564 '(#:configure-flags
565 (list (string-append "--with-sdl-prefix="
566 (assoc-ref %build-inputs "sdl-union")))
567 #:modules ((ice-9 popen)
568 (guix build utils)
569 (guix build gnu-build-system))
570
571 #:parallel-build? #f ; parallel build fails
572
573 #:phases
574 (modify-phases %standard-phases
575 (add-before 'configure 'fix-env-and-patch
576 (lambda* (#:key inputs #:allow-other-keys)
577 (setenv "GUILE_AUTO_COMPILE" "0")
578 ;; SDL_image needs to dlopen libjpeg in the test suite.
579 (setenv "LD_LIBRARY_PATH"
580 (string-append (assoc-ref inputs "libjpeg") "/lib"))
581
582 ;; Change the site directory /site/X.Y like Guile expects.
583 (substitute* "build-aux/guile-baux/re-prefixed-site-dirs"
584 (("\"/site\"")
585 (let ((effective
586 (read
587 (open-pipe* OPEN_READ
588 "guile" "-c"
589 "(write (effective-version))"))))
590 (string-append "\"/site/" effective "\""))))
591
592 ;; Skip tests that rely on sound support, which is unavailable in
593 ;; the build environment.
594 (substitute* "test/Makefile.in"
595 (("HAVE_MIXER = .*$")
596 "HAVE_MIXER = 0\n"))
597 #t))
598 (add-before 'check 'start-xorg-server
599 (lambda* (#:key inputs #:allow-other-keys)
600 ;; The test suite requires a running X server.
601 (system (format #f "~a/bin/Xvfb :1 &"
602 (assoc-ref inputs "xorg-server")))
603 (setenv "DISPLAY" ":1")
604 #t))
605 (add-before 'check 'skip-cursor-test
606 (lambda _
607 ;; XXX: This test sometimes enters an endless loop, and sometimes
608 ;; crashes with:
609 ;; guile: xcb_io.c:147: append_pending_request: Assertion `!xcb_xlib_unknown_seq_number' failed.
610 ;; Skip it.
611 (substitute* "test/cursor.scm"
612 (("\\(SDL:init .*" all)
613 (string-append "(exit 77) ;" all "\n")))
614 #t)))))
615 (synopsis "Guile interface for SDL (Simple DirectMedia Layer)")
616 (description "Guile-SDL is a set of bindings to the Simple DirectMedia
617 Layer (SDL). With them, Guile programmers can have easy access to graphics,
618 sound and device input (keyboards, joysticks, mice, etc.).")
619 (home-page "https://www.gnu.org/software/guile-sdl/")
620 (license gpl3+)))
621
622 (define-public guile-sdl2
623 (package
624 (name "guile-sdl2")
625 (version "0.4.0")
626 (source (origin
627 (method url-fetch)
628 (uri (string-append "https://files.dthompson.us/guile-sdl2/"
629 "guile-sdl2-" version ".tar.gz"))
630 (sha256
631 (base32
632 "0zcxwgyadwpbhq6h5mv2569c3kalgra26zc186y9fqiyyzmh1v9s"))))
633 (build-system gnu-build-system)
634 (arguments
635 '(#:make-flags '("GUILE_AUTO_COMPILE=0")
636 #:configure-flags
637 (list (string-append "--with-libsdl2-prefix="
638 (assoc-ref %build-inputs "sdl2"))
639 (string-append "--with-libsdl2-image-prefix="
640 (assoc-ref %build-inputs "sdl2-image"))
641 (string-append "--with-libsdl2-ttf-prefix="
642 (assoc-ref %build-inputs "sdl2-ttf"))
643 (string-append "--with-libsdl2-mixer-prefix="
644 (assoc-ref %build-inputs "sdl2-mixer")))))
645 (native-inputs
646 `(("guile" ,guile-2.2)
647 ("pkg-config" ,pkg-config)))
648 (inputs
649 `(("sdl2" ,sdl2)
650 ("sdl2-image" ,sdl2-image)
651 ("sdl2-mixer" ,sdl2-mixer)
652 ("sdl2-ttf" ,sdl2-ttf)))
653 (synopsis "Guile bindings for SDL2")
654 (home-page "https://dthompson.us/projects/guile-sdl2.html")
655 (description
656 "Guile-SDL2 provides Guile Scheme bindings for the SDL2 C shared library.
657 The bindings are written in pure Scheme using Guile's foreign function
658 interface.")
659 (license lgpl3+)))
660
661 (define-public guile3.0-sdl2
662 (package
663 (inherit guile-sdl2)
664 (name "guile3.0-sdl2")
665 (native-inputs
666 `(("guile" ,guile-3.0)
667 ("pkg-config" ,pkg-config)))))
668
669 (define-public sdl2-cs
670 (let ((commit "1a3556441e1394eb0b5d46aeb514b8d1090b93f8"))
671 (package
672 (name "sdl2-cs")
673 (version (git-version "B1" "1" commit))
674 (source (origin
675 (method git-fetch)
676 (uri (git-reference
677 (url "https://github.com/flibitijibibo/SDL2-CS")
678 (commit commit)))
679 (file-name (git-file-name name version))
680 (sha256
681 (base32
682 "007mzkqr9nmvfrvvhs2r6cm36lzgsww24kwshsz9c4fd97f9qk58"))))
683 (build-system gnu-build-system)
684 (arguments
685 '(#:tests? #f ; No tests.
686 #:phases
687 (modify-phases %standard-phases
688 (delete 'configure)
689 (replace 'build
690 (lambda _
691 (invoke "make" "release")))
692 (replace 'install
693 (lambda* (#:key outputs #:allow-other-keys)
694 (let ((out (assoc-ref outputs "out")))
695 (install-file "bin/Release/SDL2-CS.dll" (string-append out "/lib"))
696 #t))))))
697 (native-inputs
698 `(("mono" ,mono)))
699 (inputs
700 `(("sdl2" ,sdl2)
701 ("sdl2-image" ,sdl2-image)
702 ("sdl2-mixer" ,sdl2-mixer)
703 ("sdl2-ttf" ,sdl2-ttf)))
704 (home-page "https://dthompson.us/projects/guile-sdl2.html")
705 (synopsis "C# wrapper for SDL2")
706 (description
707 "SDL2-CS provides C# bindings for the SDL2 C shared library.
708 The C# wrapper was written to be used for FNA's platform support. However, this
709 is written in a way that can be used for any general C# application.")
710 (license zlib))))