gnu: sdl-pango: Shorten file name of patch.
[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 ;; Add the Fcitx header files to GCCs "system header" search path
136 ;; in order to suppress compiler warnings induced by those:
137 ;; .../include/fcitx-utils/utarray.h:178:9: error: ISO C90 forbids
138 ;; mixed declarations and code [-Werror=declaration-after-statement]
139 (string-append "C_INCLUDE_PATH="
140 (assoc-ref %build-inputs "fcitx") "/include")
141 ;; SDL dlopens libudev, so make sure it is in rpath. This overrides
142 ;; the LDFLAG set in sdl’s configure-flags, which isn’t necessary
143 ;; as sdl2 includes Mesa by default.
144 (string-append "LDFLAGS=-Wl,-rpath,"
145 (assoc-ref %build-inputs "eudev") "/lib")
146 ,flags))))
147 (inputs
148 ;; SDL2 needs to be built with ibus support otherwise some systems
149 ;; experience a bug where input events are doubled.
150 ;;
151 ;; For more information, see: https://dev.solus-project.com/T1721
152 (append `(("dbus" ,dbus)
153 ("eudev" ,eudev) ; for discovering input devices
154 ("fcitx" ,fcitx) ; helps with CJK input
155 ("glib" ,glib)
156 ("ibus" ,ibus)
157 ("libxkbcommon" ,libxkbcommon)
158 ("libxcursor" ,libxcursor) ; enables X11 cursor support
159 ("wayland" ,wayland)
160 ("wayland-protocols" ,wayland-protocols))
161 (package-inputs sdl)))
162 (license bsd-3)))
163
164 (define-public libmikmod
165 (package
166 (name "libmikmod")
167 (version "3.3.11.1")
168 (source (origin
169 (method url-fetch)
170 (uri (list
171 (string-append "mirror://sourceforge/mikmod/libmikmod/"
172 version "/libmikmod-" version ".tar.gz")
173 ;; Older versions are sometimes moved to:
174 (string-append "mirror://sourceforge/mikmod/"
175 "outdated_versions/libmikmod/"
176 version "/libmikmod-" version ".tar.gz")))
177 (sha256
178 (base32
179 "06bdnhb0l81srdzg6gn2v2ydhhaazza7rshrcj3q8dpqr3gn97dd"))))
180 (build-system gnu-build-system)
181 (arguments
182 ;; By default, libmikmod tries to dlopen libasound etc., which won't work
183 ;; unless the right libalsa happens to be in $LD_LIBRARY_PATH. Pass
184 ;; '--disable-dl' to avoid that.
185 '(#:configure-flags '("--disable-dl")))
186 (synopsis "Library for module sound formats")
187 (description
188 "MikMod is able to play a wide range of module formats, as well as
189 digital sound files. It can take advantage of particular features of your
190 system, such as sound redirection over the network.")
191 (license lgpl2.1)
192 (home-page "http://mikmod.sourceforge.net/")))
193
194 (define-public sdl-gfx
195 (package
196 (name "sdl-gfx")
197 (version "2.0.26")
198 (source (origin
199 (method url-fetch)
200 (uri
201 (string-append "http://www.ferzkopp.net/Software/SDL_gfx-2.0/SDL_gfx-"
202 version ".tar.gz"))
203 (sha256
204 (base32
205 "0ijljhs0v99dj6y27hc10z6qchyp8gdp4199y6jzngy6dzxlzsvw"))))
206 (build-system gnu-build-system)
207 (outputs '("out" "debug"))
208 (arguments
209 `(,@(if (any (cute string-prefix? <> (or (%current-system)
210 (%current-target-system)))
211 '("x86_64" "i686"))
212 ;; mmx is supported only on Intel processors.
213 '()
214 '(#:configure-flags '("--disable-mmx")))))
215 (propagated-inputs `(("sdl" ,sdl)))
216 (synopsis "SDL graphics primitives library")
217 (description "SDL_gfx provides graphics drawing primitives, rotozoom and
218 other supporting functions for SDL.")
219 (home-page "http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx")
220 (license zlib)))
221
222 (define-public sdl-image
223 (package
224 (name "sdl-image")
225 (version "1.2.12")
226 (source (origin
227 (method url-fetch)
228 (uri
229 (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL_image-"
230 version ".tar.gz"))
231 (sha256
232 (base32
233 "16an9slbb8ci7d89wakkmyfvp7c0cval8xw4hkg0842nhhlp540b"))))
234 (build-system gnu-build-system)
235 (outputs '("out" "debug"))
236 (arguments
237 ;; Explicitly link against shared libraries instead of dlopening them.
238 '(#:configure-flags '("--disable-jpg-shared"
239 "--disable-png-shared"
240 "--disable-tif-shared"
241 "--disable-webp-shared")))
242 (native-inputs `(("pkg-config" ,pkg-config)))
243 ;; libjpeg, libpng, and libtiff are propagated inputs because the
244 ;; SDL_image headers include the headers of these libraries. SDL is a
245 ;; propagated input because the pkg-config file refers to SDL's pkg-config
246 ;; file.
247 (propagated-inputs `(("sdl" ,sdl)
248 ("libjpeg" ,libjpeg)
249 ("libpng" ,libpng)
250 ("libtiff" ,libtiff)
251 ("libwebp" ,libwebp)))
252 (synopsis "SDL image loading library")
253 (description "SDL_image is an image file loading library for SDL that
254 supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF,
255 WEBP, XCF, XPM, and XV.")
256 (home-page "https://www.libsdl.org/projects/SDL_image/")
257 (license zlib)))
258
259 (define-public sdl-mixer
260 (package
261 (name "sdl-mixer")
262 (version "1.2.12")
263 (source (origin
264 (method url-fetch)
265 (uri
266 (string-append "https://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-"
267 version ".tar.gz"))
268 (sha256
269 (base32
270 "0alrhqgm40p4c92s26mimg9cm1y7rzr6m0p49687jxd9g6130i0n"))))
271 (build-system gnu-build-system)
272 (outputs '("out" "debug"))
273 (arguments
274 `(#:tests? #f ; No check target.
275 #:configure-flags
276 '("--enable-music-mp3-mad-gpl" ; Use libmad instead of smpeg.
277 ;; Explicitly link against shared libraries instead of dlopening them.
278 "--disable-music-flac-shared"
279 "--disable-music-fluidsynth-shared"
280 "--disable-music-mod-shared"
281 "--disable-music-ogg-shared")
282 #:phases
283 (modify-phases %standard-phases
284 (add-after 'unpack 'fix-fluidsynth
285 (lambda* (#:key inputs #:allow-other-keys)
286 (substitute* "configure"
287 (("EXTRA_LDFLAGS -lfluidsynth")
288 (string-append "EXTRA_LDFLAGS "
289 "-L"
290 (assoc-ref inputs "fluidsynth")
291 "/lib -lfluidsynth")))
292 #t)))))
293 (inputs
294 `(("fluidsynth" ,fluidsynth)
295 ("libflac" ,flac)
296 ("libmad" ,libmad)
297 ("libmikmod" ,libmikmod)
298 ("libvorbis" ,libvorbis)))
299 (propagated-inputs `(("sdl" ,sdl)))
300 (synopsis "SDL multi-channel audio mixer library")
301 (description "SDL_mixer is a multi-channel audio mixer library for SDL.
302 It supports any number of simultaneously playing channels of 16 bit stereo
303 audio, plus a single channel of music. Supported formats include FLAC, MOD,
304 MIDI, Ogg Vorbis, and MP3.
305
306 This package supports two MIDI backends, selectable at runtime. To use the
307 newer @code{fluidsynth} library, install a soundfont such as @code{fluid-3}
308 and specify it using the @code{SDL_SOUNDFONTS} environment variable. For the
309 legacy @code{timidity} backend, install a patch set such as @code{freepats}
310 and set the path to the configuration file with @code{TIMIDITY_CFG}.")
311 (home-page "https://www.libsdl.org/projects/SDL_mixer/")
312 (license zlib)))
313
314 (define-public sdl-net
315 (package
316 (name "sdl-net")
317 (version "1.2.8")
318 (source (origin
319 (method url-fetch)
320 (uri
321 (string-append "https://www.libsdl.org/projects/SDL_net/release/SDL_net-"
322 version ".tar.gz"))
323 (sha256
324 (base32
325 "1d5c9xqlf4s1c01gzv6cxmg0r621pq9kfgxcg3197xw4p25pljjz"))))
326 (build-system gnu-build-system)
327 (propagated-inputs `(("sdl" ,sdl)))
328 (native-inputs `(("pkg-config" ,pkg-config)))
329 (outputs '("out" "debug"))
330 (synopsis "SDL networking library")
331 (description "SDL_net is a small, cross-platform networking library for
332 SDL.")
333 (home-page "https://www.libsdl.org/projects/SDL_net/")
334 (license zlib)))
335
336 (define-public sdl-pango
337 (package
338 (name "sdl-pango")
339 (version "0.1.2")
340 (source
341 (origin
342 (method url-fetch)
343 (uri (string-append
344 "mirror://sourceforge/sdlpango/SDL_Pango/" version "/"
345 "SDL_Pango-" version ".tar.gz"))
346 (sha256
347 (base32 "197baw1dsg0p4pljs5k0fshbyki00r4l49m1drlpqw6ggawx6xbz"))
348 (patches (search-patches "sdl-pango-api_additions.patch"
349 "sdl-pango-blit_overflow.patch"
350 "sdl-pango-fillrect_crash.patch"
351 "sdl-pango-header-guard.patch"
352 "sdl-pango-matrix_declarations.patch"
353 "sdl-pango-sans-serif.patch"))))
354 (build-system gnu-build-system)
355 (arguments
356 `(#:configure-flags (list "--disable-static")
357 #:phases
358 (modify-phases %standard-phases
359 (add-after 'unpack 'autogen
360 ;; Force reconfiguration because the included libtool
361 ;; generates linking errors.
362 (lambda _ (invoke "autoreconf" "-vif"))))))
363 (native-inputs
364 `(("autoconf" ,autoconf)
365 ("automake" ,automake)
366 ("libtool" ,libtool)
367 ("pkg-config" ,pkg-config)))
368 (inputs
369 `(("fontconfig" ,fontconfig)
370 ("freetype" ,freetype)
371 ("glib" ,glib)
372 ("harfbuzz" ,harfbuzz)
373 ("pango" ,pango)
374 ("sdl" ,sdl)))
375 (home-page "http://sdlpango.sourceforge.net")
376 (synopsis "Pango SDL binding")
377 (description "This library is a wrapper around the Pango library.
378 It allows you to use TrueType fonts to render internationalized and
379 tagged text in SDL applications.")
380 (license lgpl2.1)))
381
382 (define-public sdl-ttf
383 (package
384 (name "sdl-ttf")
385 (version "2.0.11")
386 (source (origin
387 (method url-fetch)
388 (uri
389 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
390 version ".tar.gz"))
391 (sha256
392 (base32
393 "1dydxd4f5kb1288i5n5568kdk2q7f8mqjr7i7sd33nplxjaxhk3j"))))
394 (build-system gnu-build-system)
395 (propagated-inputs `(("sdl" ,sdl)))
396 (inputs `(("freetype" ,freetype)
397 ("mesa" ,mesa)))
398 (native-inputs `(("pkg-config" ,pkg-config)))
399 (outputs '("out" "debug"))
400 (synopsis "SDL TrueType font library")
401 (description "SDL_ttf is a TrueType font rendering library for SDL.")
402 (home-page "https://www.libsdl.org/projects/SDL_ttf/")
403 (license zlib)))
404
405 (define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
406 sdl-image sdl-mixer)))
407 "Return 'sdl-union' package which is a union of PACKAGES.
408 If PACKAGES are not specified, all SDL packages are used."
409 (package
410 (name "sdl-union")
411 (version (package-version sdl))
412 (source #f)
413 (build-system trivial-build-system)
414 (arguments
415 '(#:modules ((guix build union))
416 #:builder (begin
417 (use-modules (ice-9 match)
418 (guix build union))
419 (match %build-inputs
420 (((names . directories) ...)
421 (union-build (assoc-ref %outputs "out")
422 directories)
423 #t)))))
424 (inputs (map (lambda (package)
425 (list (package-name package) package))
426 packages))
427 (synopsis "Union of SDL libraries")
428 (description
429 "A union of SDL and its extension libraries. A union is required because
430 sdl-config assumes that all of the headers and libraries are in the same
431 directory.")
432 (home-page (package-home-page sdl))
433 (license (package-license sdl))))
434
435 (define (propagated-inputs-with-sdl2 package)
436 "Replace the \"sdl\" propagated input of PACKAGE with SDL2."
437 (map (match-lambda
438 (("sdl" _)
439 `("sdl2" ,sdl2))
440 (other other))
441 (package-propagated-inputs package)))
442
443 (define-public sdl2-gfx
444 (package (inherit sdl-gfx)
445 (name "sdl2-gfx")
446 (version "1.0.4")
447 (source (origin
448 (method url-fetch)
449 (uri
450 (string-append "https://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-"
451 version ".tar.gz"))
452 (sha256
453 (base32
454 "0qk2ax7f7grlxb13ba0ll3zlm8780s7j8fmrhlpxzjgdvldf1q33"))))
455 (propagated-inputs
456 (propagated-inputs-with-sdl2 sdl-gfx))))
457
458 (define-public sdl2-image
459 (package (inherit sdl-image)
460 (name "sdl2-image")
461 (version "2.0.5")
462 (source
463 (origin
464 (method url-fetch)
465 (uri
466 (string-append "https://www.libsdl.org/projects/SDL_image/release/"
467 "SDL2_image-" version ".tar.gz"))
468 (sha256
469 (base32 "1l0864kas9cwpp2d32yxl81g98lx40dhbdp03dz7sbv84vhgdmdx"))))
470 (propagated-inputs
471 (propagated-inputs-with-sdl2 sdl-image))))
472
473 (define-public sdl2-mixer
474 (package (inherit sdl-mixer)
475 (name "sdl2-mixer")
476 (version "2.0.4")
477 (source
478 (origin
479 (method url-fetch)
480 (uri
481 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/"
482 "SDL2_mixer-" version ".tar.gz"))
483 (modules '((guix build utils)))
484 (snippet '(begin
485 ;; Remove bundled libraries.
486 (delete-file-recursively "external")
487 #t))
488 (sha256
489 (base32 "0694vsz5bjkcdgfdra6x9fq8vpzrl8m6q96gh58df7065hw5mkxl"))))
490 (arguments
491 (substitute-keyword-arguments (package-arguments sdl-mixer)
492 ((#:configure-flags flags)
493 `(cons*
494 "--disable-music-opus-shared"
495 ;; These options were renamed in SDL2 mixer. Keeping the inherited
496 ;; variants produces a harmless warning.
497 "--disable-music-mod-modplug-shared"
498 "--disable-music-midi-fluidsynth-shared"
499 ,flags))))
500 (inputs
501 `(("opusfile" ,opusfile)
502 ;; The default MOD library changed in SDL2 mixer.
503 ("libmodplug" ,libmodplug)
504 ,@(alist-delete "libmikmod" (package-inputs sdl-mixer))))
505 (native-inputs
506 `(("pkgconfig" ,pkg-config))) ; Needed to find the opus library.
507 (propagated-inputs
508 (propagated-inputs-with-sdl2 sdl-mixer))))
509
510 (define-public sdl2-net
511 (package (inherit sdl-net)
512 (name "sdl2-net")
513 (version "2.0.1")
514 (source
515 (origin
516 (method url-fetch)
517 (uri
518 (string-append "http://www.libsdl.org/projects/SDL_net/release/"
519 "SDL2_net-" version ".tar.gz"))
520 (sha256
521 (base32
522 "08cxc1bicmyk89kiks7izw1rlx5ng5n6xpy8fy0zxni3b9z8mkhm"))))
523 (propagated-inputs
524 (propagated-inputs-with-sdl2 sdl-net))))
525
526 (define-public sdl2-ttf
527 (package (inherit sdl-ttf)
528 (name "sdl2-ttf")
529 (version "2.0.15")
530 (source (origin
531 (method url-fetch)
532 (uri
533 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-"
534 version ".tar.gz"))
535 (modules '((guix build utils)))
536 (snippet (begin
537 ;; Remove bundled libraries.
538 '(delete-file-recursively "external")
539 #t))
540 (sha256
541 (base32
542 "0cyd48dipc0m399qy8s03lci8b0bpiy8xlkvrm2ia7wcv0dfpv59"))))
543 (propagated-inputs
544 (propagated-inputs-with-sdl2 sdl-ttf))))
545
546 (define-public guile-sdl
547 (package
548 (name "guile-sdl")
549 (version "0.5.2")
550 (source (origin
551 (method url-fetch)
552 (uri
553 (string-append "mirror://gnu/guile-sdl/guile-sdl-"
554 version ".tar.xz"))
555 (sha256
556 (base32
557 "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
558 (build-system gnu-build-system)
559 (native-inputs
560 `(("pkg-config" ,pkg-config)
561 ;; Required by test suite.
562 ("xorg-server" ,xorg-server)
563 ("libjpeg" ,libjpeg)))
564 (inputs
565 `(("guile" ,guile-2.2)
566 ("sdl-union" ,(sdl-union))))
567 (arguments
568 '(#:configure-flags
569 (list (string-append "--with-sdl-prefix="
570 (assoc-ref %build-inputs "sdl-union")))
571 #:modules ((ice-9 popen)
572 (guix build utils)
573 (guix build gnu-build-system))
574
575 #:parallel-build? #f ; parallel build fails
576
577 #:phases
578 (modify-phases %standard-phases
579 (add-before 'configure 'fix-env-and-patch
580 (lambda* (#:key inputs #:allow-other-keys)
581 (setenv "GUILE_AUTO_COMPILE" "0")
582 ;; SDL_image needs to dlopen libjpeg in the test suite.
583 (setenv "LD_LIBRARY_PATH"
584 (string-append (assoc-ref inputs "libjpeg") "/lib"))
585
586 ;; Change the site directory /site/X.Y like Guile expects.
587 (substitute* "build-aux/guile-baux/re-prefixed-site-dirs"
588 (("\"/site\"")
589 (let ((effective
590 (read
591 (open-pipe* OPEN_READ
592 "guile" "-c"
593 "(write (effective-version))"))))
594 (string-append "\"/site/" effective "\""))))
595
596 ;; Skip tests that rely on sound support, which is unavailable in
597 ;; the build environment.
598 (substitute* "test/Makefile.in"
599 (("HAVE_MIXER = .*$")
600 "HAVE_MIXER = 0\n"))
601 #t))
602 (add-before 'check 'start-xorg-server
603 (lambda* (#:key inputs #:allow-other-keys)
604 ;; The test suite requires a running X server.
605 (system (format #f "~a/bin/Xvfb :1 &"
606 (assoc-ref inputs "xorg-server")))
607 (setenv "DISPLAY" ":1")
608 #t))
609 (add-before 'check 'skip-cursor-test
610 (lambda _
611 ;; XXX: This test sometimes enters an endless loop, and sometimes
612 ;; crashes with:
613 ;; guile: xcb_io.c:147: append_pending_request: Assertion `!xcb_xlib_unknown_seq_number' failed.
614 ;; Skip it.
615 (substitute* "test/cursor.scm"
616 (("\\(SDL:init .*" all)
617 (string-append "(exit 77) ;" all "\n")))
618 #t)))))
619 (synopsis "Guile interface for SDL (Simple DirectMedia Layer)")
620 (description "Guile-SDL is a set of bindings to the Simple DirectMedia
621 Layer (SDL). With them, Guile programmers can have easy access to graphics,
622 sound and device input (keyboards, joysticks, mice, etc.).")
623 (home-page "https://www.gnu.org/software/guile-sdl/")
624 (license gpl3+)))
625
626 (define-public guile-sdl2
627 (package
628 (name "guile-sdl2")
629 (version "0.4.0")
630 (source (origin
631 (method url-fetch)
632 (uri (string-append "https://files.dthompson.us/guile-sdl2/"
633 "guile-sdl2-" version ".tar.gz"))
634 (sha256
635 (base32
636 "0zcxwgyadwpbhq6h5mv2569c3kalgra26zc186y9fqiyyzmh1v9s"))))
637 (build-system gnu-build-system)
638 (arguments
639 '(#:make-flags '("GUILE_AUTO_COMPILE=0")
640 #:configure-flags
641 (list (string-append "--with-libsdl2-prefix="
642 (assoc-ref %build-inputs "sdl2"))
643 (string-append "--with-libsdl2-image-prefix="
644 (assoc-ref %build-inputs "sdl2-image"))
645 (string-append "--with-libsdl2-ttf-prefix="
646 (assoc-ref %build-inputs "sdl2-ttf"))
647 (string-append "--with-libsdl2-mixer-prefix="
648 (assoc-ref %build-inputs "sdl2-mixer")))))
649 (native-inputs
650 `(("guile" ,guile-2.2)
651 ("pkg-config" ,pkg-config)))
652 (inputs
653 `(("sdl2" ,sdl2)
654 ("sdl2-image" ,sdl2-image)
655 ("sdl2-mixer" ,sdl2-mixer)
656 ("sdl2-ttf" ,sdl2-ttf)))
657 (synopsis "Guile bindings for SDL2")
658 (home-page "https://dthompson.us/projects/guile-sdl2.html")
659 (description
660 "Guile-SDL2 provides Guile Scheme bindings for the SDL2 C shared library.
661 The bindings are written in pure Scheme using Guile's foreign function
662 interface.")
663 (license lgpl3+)))
664
665 (define-public guile3.0-sdl2
666 (package
667 (inherit guile-sdl2)
668 (name "guile3.0-sdl2")
669 (native-inputs
670 `(("guile" ,guile-3.0)
671 ("pkg-config" ,pkg-config)))))
672
673 (define-public sdl2-cs
674 (let ((commit "1a3556441e1394eb0b5d46aeb514b8d1090b93f8"))
675 (package
676 (name "sdl2-cs")
677 (version (git-version "B1" "1" commit))
678 (source (origin
679 (method git-fetch)
680 (uri (git-reference
681 (url "https://github.com/flibitijibibo/SDL2-CS")
682 (commit commit)))
683 (file-name (git-file-name name version))
684 (sha256
685 (base32
686 "007mzkqr9nmvfrvvhs2r6cm36lzgsww24kwshsz9c4fd97f9qk58"))))
687 (build-system gnu-build-system)
688 (arguments
689 '(#:tests? #f ; No tests.
690 #:phases
691 (modify-phases %standard-phases
692 (delete 'configure)
693 (replace 'build
694 (lambda _
695 (invoke "make" "release")))
696 (replace 'install
697 (lambda* (#:key outputs #:allow-other-keys)
698 (let ((out (assoc-ref outputs "out")))
699 (install-file "bin/Release/SDL2-CS.dll" (string-append out "/lib"))
700 #t))))))
701 (native-inputs
702 `(("mono" ,mono)))
703 (inputs
704 `(("sdl2" ,sdl2)
705 ("sdl2-image" ,sdl2-image)
706 ("sdl2-mixer" ,sdl2-mixer)
707 ("sdl2-ttf" ,sdl2-ttf)))
708 (home-page "https://dthompson.us/projects/guile-sdl2.html")
709 (synopsis "C# wrapper for SDL2")
710 (description
711 "SDL2-CS provides C# bindings for the SDL2 C shared library.
712 The C# wrapper was written to be used for FNA's platform support. However, this
713 is written in a way that can be used for any general C# application.")
714 (license zlib))))