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