gnu: Add xwrits.
[jackhill/guix/guix.git] / gnu / packages / sdl.scm
CommitLineData
c3c516ea 1;;; GNU Guix --- Functional package management for GNU
e0101b54 2;;; Copyright © 2013, 2015, 2017 David Thompson <dthompson2@worcester.edu>
9cb3036f 3;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
df05d80a 4;;; Copyright © 2015, 2017 Sou Bunnbu <iyzsong@member.fsf.org>
40e94665 5;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
8df1ee3f 6;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
abfc114a 7;;; Copyright © 2017, 2018, 2019 Rutger Helling <rhelling@mykolab.com>
ad237c8b 8;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
2ffa842b 9;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
a95b2732 10;;; Copyright © 2019 Kei Kebreau <kkebreau@posteo.net>
1a898453 11;;; Copyright © 2019 Nicolas Goaziou <mail@nicolasgoaziou.fr>
1ea1ce18 12;;; Copyright © 2019 Marius Bakke <mbakke@fastmail.com>
aed6c010 13;;; Copyright © 2019 Pierre Neidhardt <mail@ambrevar.xyz>
5f50c2e6 14;;; Copyright © 2020 Timotej Lazar <timotej.lazar@araneo.si>
8f6b6cb8 15;;; Copyright © 2020 Oleg Pykhalov <go.wigust@gmail.com>
c3c516ea
DT
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)
6813f70a 33 #:use-module (ice-9 match)
8df1ee3f
EF
34 #:use-module (srfi srfi-1)
35 #:use-module (srfi srfi-26)
c3c516ea 36 #:use-module (gnu packages)
890024c5 37 #:use-module ((guix licenses) #:hide (freetype))
c3c516ea
DT
38 #:use-module (guix packages)
39 #:use-module (guix download)
aed6c010 40 #:use-module (guix git-download)
39f2433c 41 #:use-module (guix utils)
c3c516ea 42 #:use-module (guix build-system gnu)
d6f74baf 43 #:use-module (guix build-system trivial)
a313e085 44 #:use-module (gnu packages audio)
543bd0ee 45 #:use-module (gnu packages fcitx)
890024c5 46 #:use-module (gnu packages fontutils)
39f2433c 47 #:use-module (gnu packages freedesktop)
e0101b54 48 #:use-module (gnu packages glib)
bcc046fc 49 #:use-module (gnu packages guile)
e0101b54 50 #:use-module (gnu packages ibus)
e55354b8 51 #:use-module (gnu packages image)
c3c516ea 52 #:use-module (gnu packages linux)
aed6c010 53 #:use-module (gnu packages mono)
5cf3bcd4 54 #:use-module (gnu packages mp3)
8bf8d7c7
DT
55 #:use-module (gnu packages pkg-config)
56 #:use-module (gnu packages pulseaudio)
200726ed 57 #:use-module (gnu packages gl)
39f2433c 58 #:use-module (gnu packages xdisorg)
54ff0b7d 59 #:use-module (gnu packages xiph)
c3c516ea 60 #:use-module (gnu packages xorg)
0160458b 61 #:export (sdl-union))
8bf8d7c7 62
0160458b 63(define-public sdl
8bf8d7c7
DT
64 (package
65 (name "sdl")
66 (version "1.2.15")
67 (source (origin
68 (method url-fetch)
69 (uri
5d5790ce 70 (string-append "https://libsdl.org/release/SDL-"
8bf8d7c7
DT
71 version ".tar.gz"))
72 (sha256
73 (base32
9cb3036f 74 "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"))
fc1adab1 75 (patches (search-patches "sdl-libx11-1.6.patch"))))
8bf8d7c7 76 (build-system gnu-build-system)
22f33e61 77 (arguments
666aa995 78 '(;; Explicitly link against shared libraries instead of dlopening them.
83bb3a3e
SB
79 ;; For X11, ALSA, and PulseAudio.
80 ;; OpenGL library is still dlopened at runtime.
81 #:configure-flags '("--disable-alsa-shared"
82 "--disable-pulseaudio-shared"
07780c71
SB
83 "--disable-x11-shared"
84 ;; Explicitly link with mesa.
85 ;; This add mesa to libsdl's RUNPATH, to make dlopen
86 ;; finding the libGL from mesa at runtime.
87 "LDFLAGS=-lGL")
22f33e61 88
42084536
MB
89 #:make-flags '("V=1") ;build verbosely
90
22f33e61 91 #:tests? #f)) ; no check target
558a5122
LC
92 (propagated-inputs
93 ;; SDL headers include X11 headers.
666aa995 94 `(("libx11" ,libx11)
f6dadee4
RH
95 ("libcap" ,libcap) ; 'libSDL.la' contain `-lcap'.
96 ;; TODO: Since building Mesa with Meson it is now necessary that Mesa is
97 ;; a propogated input. We still need to figure out why, possibly due to a
98 ;; change in pkg-config.
99 ("mesa" ,mesa)))
22f33e61 100 (native-inputs `(("pkg-config" ,pkg-config)))
558a5122 101 (inputs `(("libxrandr" ,libxrandr)
83bb3a3e 102 ("glu" ,glu)
8bf8d7c7 103 ("alsa-lib" ,alsa-lib)
8bf8d7c7 104 ("pulseaudio" ,pulseaudio)))
38033318 105 (outputs '("out" "debug"))
8bf8d7c7
DT
106 (synopsis "Cross platform game development library")
107 (description "Simple DirectMedia Layer is a cross-platform development
108library designed to provide low level access to audio, keyboard, mouse,
109joystick, and graphics hardware.")
5d5790ce 110 (home-page "https://libsdl.org/")
8bf8d7c7
DT
111 (license lgpl2.1)))
112
0160458b 113(define-public sdl2
8bf8d7c7
DT
114 (package (inherit sdl)
115 (name "sdl2")
20269b6e 116 (version "2.0.10")
8bf8d7c7
DT
117 (source (origin
118 (method url-fetch)
119 (uri
5d5790ce 120 (string-append "https://libsdl.org/release/SDL2-"
8bf8d7c7 121 version ".tar.gz"))
c4362613 122 (patches (search-patches "sdl2-mesa-compat.patch"))
8bf8d7c7
DT
123 (sha256
124 (base32
20269b6e 125 "0mqxp6w5jhbq6y1j690g9r3gpzwjxh4czaglw8x05l7hl49nqrdl"))))
39f2433c
RH
126 (arguments
127 (substitute-keyword-arguments (package-arguments sdl)
128 ((#:configure-flags flags)
abfc114a
RH
129 `(append '("--disable-wayland-shared" "--enable-video-kmsdrm"
130 "--disable-kmsdrm-shared")
1ea1ce18
MB
131 ,flags))
132 ((#:make-flags flags ''())
133 ;; Add the Fcitx header files to GCCs "system header" search path
134 ;; in order to suppress compiler warnings induced by those:
135 ;; .../include/fcitx-utils/utarray.h:178:9: error: ISO C90 forbids
136 ;; mixed declarations and code [-Werror=declaration-after-statement]
137 `(append (list (string-append "C_INCLUDE_PATH="
138 (assoc-ref %build-inputs "fcitx")
139 "/include"))
39f2433c 140 ,flags))))
e0101b54
DT
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)
543bd0ee 147 ("fcitx" ,fcitx) ; helps with CJK input
e0101b54 148 ("glib" ,glib)
39f2433c 149 ("ibus" ,ibus)
c695fb76 150 ("libxkbcommon" ,libxkbcommon)
82de17dc 151 ("libxcursor" ,libxcursor) ; enables X11 cursor support
c695fb76
TGR
152 ("wayland" ,wayland)
153 ("wayland-protocols" ,wayland-protocols))
e0101b54 154 (package-inputs sdl)))
8bf8d7c7 155 (license bsd-3)))
c3c516ea 156
0160458b 157(define-public libmikmod
c3c516ea
DT
158 (package
159 (name "libmikmod")
fa3b93d6 160 (version "3.3.11.1")
c3c516ea
DT
161 (source (origin
162 (method url-fetch)
1934769b
MW
163 (uri (list
164 (string-append "mirror://sourceforge/mikmod/libmikmod/"
165 version "/libmikmod-" version ".tar.gz")
166 ;; Older versions are sometimes moved to:
167 (string-append "mirror://sourceforge/mikmod/"
168 "outdated_versions/libmikmod/"
169 version "/libmikmod-" version ".tar.gz")))
c3c516ea
DT
170 (sha256
171 (base32
fa3b93d6 172 "06bdnhb0l81srdzg6gn2v2ydhhaazza7rshrcj3q8dpqr3gn97dd"))))
c3c516ea 173 (build-system gnu-build-system)
03920078
LC
174 (arguments
175 ;; By default, libmikmod tries to dlopen libasound etc., which won't work
176 ;; unless the right libalsa happens to be in $LD_LIBRARY_PATH. Pass
177 ;; '--disable-dl' to avoid that.
178 '(#:configure-flags '("--disable-dl")))
9e771e3b 179 (synopsis "Library for module sound formats")
c3c516ea
DT
180 (description
181 "MikMod is able to play a wide range of module formats, as well as
35b9e423 182digital sound files. It can take advantage of particular features of your
c3c516ea
DT
183system, such as sound redirection over the network.")
184 (license lgpl2.1)
185 (home-page "http://mikmod.sourceforge.net/")))
5cf3bcd4 186
0160458b 187(define-public sdl-gfx
5cf3bcd4
DT
188 (package
189 (name "sdl-gfx")
b5ceea9f 190 (version "2.0.26")
5cf3bcd4
DT
191 (source (origin
192 (method url-fetch)
193 (uri
194 (string-append "http://www.ferzkopp.net/Software/SDL_gfx-2.0/SDL_gfx-"
195 version ".tar.gz"))
196 (sha256
197 (base32
b5ceea9f 198 "0ijljhs0v99dj6y27hc10z6qchyp8gdp4199y6jzngy6dzxlzsvw"))))
5cf3bcd4 199 (build-system gnu-build-system)
38033318 200 (outputs '("out" "debug"))
8df1ee3f
EF
201 (arguments
202 `(,@(if (any (cute string-prefix? <> (or (%current-system)
203 (%current-target-system)))
204 '("x86_64" "i686"))
205 ;; mmx is supported only on Intel processors.
206 '()
207 '(#:configure-flags '("--disable-mmx")))))
5cf3bcd4 208 (propagated-inputs `(("sdl" ,sdl)))
5cf3bcd4
DT
209 (synopsis "SDL graphics primitives library")
210 (description "SDL_gfx provides graphics drawing primitives, rotozoom and
211other supporting functions for SDL.")
212 (home-page "http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx")
8df1ee3f 213 (license zlib)))
5cf3bcd4 214
0160458b 215(define-public sdl-image
5cf3bcd4
DT
216 (package
217 (name "sdl-image")
218 (version "1.2.12")
219 (source (origin
220 (method url-fetch)
221 (uri
5d5790ce 222 (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL_image-"
5cf3bcd4
DT
223 version ".tar.gz"))
224 (sha256
225 (base32
226 "16an9slbb8ci7d89wakkmyfvp7c0cval8xw4hkg0842nhhlp540b"))))
227 (build-system gnu-build-system)
38033318 228 (outputs '("out" "debug"))
7c3e60fb
SB
229 (arguments
230 ;; Explicitly link against shared libraries instead of dlopening them.
231 '(#:configure-flags '("--disable-jpg-shared"
232 "--disable-png-shared"
233 "--disable-tif-shared"
234 "--disable-webp-shared")))
586b6d4d 235 (native-inputs `(("pkg-config" ,pkg-config)))
586b6d4d
DT
236 ;; libjpeg, libpng, and libtiff are propagated inputs because the
237 ;; SDL_image headers include the headers of these libraries. SDL is a
238 ;; propagated input because the pkg-config file refers to SDL's pkg-config
239 ;; file.
240 (propagated-inputs `(("sdl" ,sdl)
241 ("libjpeg" ,libjpeg)
242 ("libpng" ,libpng)
6a51e95b
DT
243 ("libtiff" ,libtiff)
244 ("libwebp" ,libwebp)))
5cf3bcd4
DT
245 (synopsis "SDL image loading library")
246 (description "SDL_image is an image file loading library for SDL that
247supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF,
248WEBP, XCF, XPM, and XV.")
5d5790ce 249 (home-page "https://www.libsdl.org/projects/SDL_image/")
5cf3bcd4
DT
250 (license zlib)))
251
0160458b 252(define-public sdl-mixer
5cf3bcd4
DT
253 (package
254 (name "sdl-mixer")
255 (version "1.2.12")
256 (source (origin
257 (method url-fetch)
258 (uri
5d5790ce 259 (string-append "https://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-"
5cf3bcd4
DT
260 version ".tar.gz"))
261 (sha256
262 (base32
263 "0alrhqgm40p4c92s26mimg9cm1y7rzr6m0p49687jxd9g6130i0n"))))
264 (build-system gnu-build-system)
38033318 265 (outputs '("out" "debug"))
6fbf92ee
TL
266 (arguments
267 `(#:tests? #f ; No check target.
268 #:configure-flags
269 '("--enable-music-mp3-mad-gpl" ; Use libmad instead of smpeg.
270 ;; Explicitly link against shared libraries instead of dlopening them.
271 "--disable-music-flac-shared"
272 "--disable-music-fluidsynth-shared"
273 "--disable-music-mod-shared"
fa0c1a21
DM
274 "--disable-music-ogg-shared")
275 #:phases
276 (modify-phases %standard-phases
277 (add-after 'unpack 'fix-fluidsynth
278 (lambda* (#:key inputs #:allow-other-keys)
279 (substitute* "configure"
280 (("EXTRA_LDFLAGS -lfluidsynth")
281 (string-append "EXTRA_LDFLAGS "
282 "-L"
283 (assoc-ref inputs "fluidsynth")
284 "/lib -lfluidsynth")))
285 #t)))))
6fbf92ee
TL
286 (inputs
287 `(("fluidsynth" ,fluidsynth)
288 ("libflac" ,flac)
289 ("libmad" ,libmad)
290 ("libmikmod" ,libmikmod)
291 ("libvorbis" ,libvorbis)))
5cf3bcd4
DT
292 (propagated-inputs `(("sdl" ,sdl)))
293 (synopsis "SDL multi-channel audio mixer library")
294 (description "SDL_mixer is a multi-channel audio mixer library for SDL.
295It supports any number of simultaneously playing channels of 16 bit stereo
769b96b6
TL
296audio, plus a single channel of music. Supported formats include FLAC, MOD,
297MIDI, Ogg Vorbis, and MP3.
298
299This package supports two MIDI backends, selectable at runtime. To use the
300newer @code{fluidsynth} library, install a soundfont such as @code{fluid-3}
301and specify it using the @code{SDL_SOUNDFONTS} environment variable. For the
302legacy @code{timidity} backend, install a patch set such as @code{freepats}
303and set the path to the configuration file with @code{TIMIDITY_CFG}.")
5d5790ce 304 (home-page "https://www.libsdl.org/projects/SDL_mixer/")
5cf3bcd4
DT
305 (license zlib)))
306
0160458b 307(define-public sdl-net
5cf3bcd4
DT
308 (package
309 (name "sdl-net")
310 (version "1.2.8")
311 (source (origin
312 (method url-fetch)
313 (uri
5d5790ce 314 (string-append "https://www.libsdl.org/projects/SDL_net/release/SDL_net-"
5cf3bcd4
DT
315 version ".tar.gz"))
316 (sha256
317 (base32
318 "1d5c9xqlf4s1c01gzv6cxmg0r621pq9kfgxcg3197xw4p25pljjz"))))
319 (build-system gnu-build-system)
320 (propagated-inputs `(("sdl" ,sdl)))
41eb1198 321 (native-inputs `(("pkg-config" ,pkg-config)))
38033318 322 (outputs '("out" "debug"))
5cf3bcd4
DT
323 (synopsis "SDL networking library")
324 (description "SDL_net is a small, cross-platform networking library for
325SDL.")
5d5790ce 326 (home-page "https://www.libsdl.org/projects/SDL_net/")
5cf3bcd4
DT
327 (license zlib)))
328
0160458b 329(define-public sdl-ttf
5cf3bcd4
DT
330 (package
331 (name "sdl-ttf")
332 (version "2.0.11")
333 (source (origin
334 (method url-fetch)
335 (uri
5d5790ce 336 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
5cf3bcd4
DT
337 version ".tar.gz"))
338 (sha256
339 (base32
340 "1dydxd4f5kb1288i5n5568kdk2q7f8mqjr7i7sd33nplxjaxhk3j"))))
341 (build-system gnu-build-system)
342 (propagated-inputs `(("sdl" ,sdl)))
890024c5 343 (inputs `(("freetype" ,freetype)
41eb1198
LC
344 ("mesa" ,mesa)))
345 (native-inputs `(("pkg-config" ,pkg-config)))
38033318 346 (outputs '("out" "debug"))
5cf3bcd4
DT
347 (synopsis "SDL TrueType font library")
348 (description "SDL_ttf is a TrueType font rendering library for SDL.")
5d5790ce 349 (home-page "https://www.libsdl.org/projects/SDL_ttf/")
5cf3bcd4 350 (license zlib)))
d6f74baf 351
40e94665
AK
352(define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
353 sdl-image sdl-mixer)))
354 "Return 'sdl-union' package which is a union of PACKAGES.
355If PACKAGES are not specified, all SDL packages are used."
d6f74baf
DT
356 (package
357 (name "sdl-union")
358 (version (package-version sdl))
359 (source #f)
360 (build-system trivial-build-system)
361 (arguments
362 '(#:modules ((guix build union))
363 #:builder (begin
364 (use-modules (ice-9 match)
365 (guix build union))
366 (match %build-inputs
367 (((names . directories) ...)
368 (union-build (assoc-ref %outputs "out")
e3cfef22
MW
369 directories)
370 #t)))))
40e94665
AK
371 (inputs (map (lambda (package)
372 (list (package-name package) package))
373 packages))
374 (synopsis "Union of SDL libraries")
d6f74baf
DT
375 (description
376 "A union of SDL and its extension libraries. A union is required because
377sdl-config assumes that all of the headers and libraries are in the same
378directory.")
379 (home-page (package-home-page sdl))
380 (license (package-license sdl))))
bcc046fc 381
6813f70a
DT
382(define (propagated-inputs-with-sdl2 package)
383 "Replace the \"sdl\" propagated input of PACKAGE with SDL2."
384 (map (match-lambda
385 (("sdl" _)
386 `("sdl2" ,sdl2))
387 (other other))
388 (package-propagated-inputs package)))
389
a95b2732
KK
390(define-public sdl2-gfx
391 (package (inherit sdl-gfx)
392 (name "sdl2-gfx")
393 (version "1.0.4")
394 (source (origin
395 (method url-fetch)
396 (uri
397 (string-append "https://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-"
398 version ".tar.gz"))
399 (sha256
400 (base32
401 "0qk2ax7f7grlxb13ba0ll3zlm8780s7j8fmrhlpxzjgdvldf1q33"))))
402 (propagated-inputs
403 (propagated-inputs-with-sdl2 sdl-gfx))))
404
6813f70a
DT
405(define-public sdl2-image
406 (package (inherit sdl-image)
407 (name "sdl2-image")
8f6b6cb8 408 (version "2.0.5")
ad237c8b
TGR
409 (source
410 (origin
411 (method url-fetch)
412 (uri
413 (string-append "https://www.libsdl.org/projects/SDL_image/release/"
414 "SDL2_image-" version ".tar.gz"))
415 (sha256
8f6b6cb8 416 (base32 "1l0864kas9cwpp2d32yxl81g98lx40dhbdp03dz7sbv84vhgdmdx"))))
6813f70a
DT
417 (propagated-inputs
418 (propagated-inputs-with-sdl2 sdl-image))))
419
855e2939
DT
420(define-public sdl2-mixer
421 (package (inherit sdl-mixer)
422 (name "sdl2-mixer")
863ab122
TGR
423 (version "2.0.4")
424 (source
425 (origin
426 (method url-fetch)
427 (uri
428 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/"
429 "SDL2_mixer-" version ".tar.gz"))
430 (modules '((guix build utils)))
431 (snippet '(begin
432 ;; Remove bundled libraries.
433 (delete-file-recursively "external")
434 #t))
435 (sha256
436 (base32 "0694vsz5bjkcdgfdra6x9fq8vpzrl8m6q96gh58df7065hw5mkxl"))))
64941afc
TL
437 (arguments
438 (substitute-keyword-arguments (package-arguments sdl-mixer)
439 ((#:configure-flags flags)
440 `(cons*
ced47faa 441 "--disable-music-opus-shared"
64941afc
TL
442 ;; These options were renamed in SDL2 mixer. Keeping the inherited
443 ;; variants produces a harmless warning.
444 "--disable-music-mod-modplug-shared"
445 "--disable-music-midi-fluidsynth-shared"
446 ,flags))))
5f50c2e6 447 (inputs
ced47faa
TL
448 `(("opusfile" ,opusfile)
449 ;; The default MOD library changed in SDL2 mixer.
450 ("libmodplug" ,libmodplug)
5f50c2e6 451 ,@(alist-delete "libmikmod" (package-inputs sdl-mixer))))
ced47faa
TL
452 (native-inputs
453 `(("pkgconfig" ,pkg-config))) ; Needed to find the opus library.
855e2939
DT
454 (propagated-inputs
455 (propagated-inputs-with-sdl2 sdl-mixer))))
456
1a898453
NG
457(define-public sdl2-net
458 (package (inherit sdl-net)
459 (name "sdl2-net")
460 (version "2.0.1")
461 (source
462 (origin
463 (method url-fetch)
464 (uri
465 (string-append "http://www.libsdl.org/projects/SDL_net/release/"
466 "SDL2_net-" version ".tar.gz"))
467 (sha256
468 (base32
469 "08cxc1bicmyk89kiks7izw1rlx5ng5n6xpy8fy0zxni3b9z8mkhm"))))
470 (propagated-inputs
471 (propagated-inputs-with-sdl2 sdl-net))))
472
d3f6a1de
DT
473(define-public sdl2-ttf
474 (package (inherit sdl-ttf)
475 (name "sdl2-ttf")
c97a1c42 476 (version "2.0.15")
d3f6a1de
DT
477 (source (origin
478 (method url-fetch)
479 (uri
5d5790ce 480 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-"
d3f6a1de 481 version ".tar.gz"))
8d506323 482 (modules '((guix build utils)))
6cbee49d
MW
483 (snippet (begin
484 ;; Remove bundled libraries.
485 '(delete-file-recursively "external")
486 #t))
d3f6a1de
DT
487 (sha256
488 (base32
c97a1c42 489 "0cyd48dipc0m399qy8s03lci8b0bpiy8xlkvrm2ia7wcv0dfpv59"))))
d3f6a1de
DT
490 (propagated-inputs
491 (propagated-inputs-with-sdl2 sdl-ttf))))
492
bcc046fc
DT
493(define-public guile-sdl
494 (package
495 (name "guile-sdl")
af87a551 496 (version "0.5.2")
bcc046fc
DT
497 (source (origin
498 (method url-fetch)
499 (uri
500 (string-append "mirror://gnu/guile-sdl/guile-sdl-"
501 version ".tar.xz"))
502 (sha256
503 (base32
af87a551 504 "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
bcc046fc
DT
505 (build-system gnu-build-system)
506 (native-inputs
507 `(("pkg-config" ,pkg-config)
508 ;; Required by test suite.
509 ("xorg-server" ,xorg-server)
510 ("libjpeg" ,libjpeg)))
511 (inputs
8380a181 512 `(("guile" ,guile-2.2)
40e94665 513 ("sdl-union" ,(sdl-union))))
bcc046fc
DT
514 (arguments
515 '(#:configure-flags
516 (list (string-append "--with-sdl-prefix="
517 (assoc-ref %build-inputs "sdl-union")))
4fa3f796
LC
518 #:modules ((ice-9 popen)
519 (guix build utils)
520 (guix build gnu-build-system))
521
bcc046fc 522 #:parallel-build? #f ; parallel build fails
4fa3f796 523
bcc046fc 524 #:phases
dc1d3cde
KK
525 (modify-phases %standard-phases
526 (add-before 'configure 'fix-env-and-patch
527 (lambda* (#:key inputs #:allow-other-keys)
528 (setenv "GUILE_AUTO_COMPILE" "0")
529 ;; SDL_image needs to dlopen libjpeg in the test suite.
530 (setenv "LD_LIBRARY_PATH"
531 (string-append (assoc-ref inputs "libjpeg") "/lib"))
4fa3f796
LC
532
533 ;; Change the site directory /site/X.Y like Guile expects.
dc1d3cde 534 (substitute* "build-aux/guile-baux/re-prefixed-site-dirs"
4fa3f796
LC
535 (("\"/site\"")
536 (let ((effective
537 (read
538 (open-pipe* OPEN_READ
539 "guile" "-c"
540 "(write (effective-version))"))))
541 (string-append "\"/site/" effective "\""))))
af87a551 542
dc1d3cde
KK
543 ;; Skip tests that rely on sound support, which is unavailable in
544 ;; the build environment.
545 (substitute* "test/Makefile.in"
546 (("HAVE_MIXER = .*$")
547 "HAVE_MIXER = 0\n"))
548 #t))
549 (add-before 'check 'start-xorg-server
550 (lambda* (#:key inputs #:allow-other-keys)
551 ;; The test suite requires a running X server.
552 (system (format #f "~a/bin/Xvfb :1 &"
553 (assoc-ref inputs "xorg-server")))
554 (setenv "DISPLAY" ":1")
8380a181
LC
555 #t))
556 (add-before 'check 'skip-cursor-test
557 (lambda _
558 ;; XXX: This test sometimes enters an endless loop, and sometimes
559 ;; crashes with:
560 ;; guile: xcb_io.c:147: append_pending_request: Assertion `!xcb_xlib_unknown_seq_number' failed.
561 ;; Skip it.
562 (substitute* "test/cursor.scm"
563 (("\\(SDL:init .*" all)
564 (string-append "(exit 77) ;" all "\n")))
dc1d3cde 565 #t)))))
bcc046fc
DT
566 (synopsis "Guile interface for SDL (Simple DirectMedia Layer)")
567 (description "Guile-SDL is a set of bindings to the Simple DirectMedia
568Layer (SDL). With them, Guile programmers can have easy access to graphics,
569sound and device input (keyboards, joysticks, mice, etc.).")
6fd52309 570 (home-page "https://www.gnu.org/software/guile-sdl/")
bcc046fc 571 (license gpl3+)))
df05d80a
SB
572
573(define-public guile-sdl2
574 (package
575 (name "guile-sdl2")
2ffa842b 576 (version "0.4.0")
df05d80a
SB
577 (source (origin
578 (method url-fetch)
2ffa842b
RW
579 (uri (string-append "https://files.dthompson.us/guile-sdl2/"
580 "guile-sdl2-" version ".tar.gz"))
df05d80a
SB
581 (sha256
582 (base32
2ffa842b 583 "0zcxwgyadwpbhq6h5mv2569c3kalgra26zc186y9fqiyyzmh1v9s"))))
df05d80a
SB
584 (build-system gnu-build-system)
585 (arguments
586 '(#:make-flags '("GUILE_AUTO_COMPILE=0")
587 #:configure-flags
588 (list (string-append "--with-libsdl2-prefix="
589 (assoc-ref %build-inputs "sdl2"))
590 (string-append "--with-libsdl2-image-prefix="
591 (assoc-ref %build-inputs "sdl2-image"))
592 (string-append "--with-libsdl2-ttf-prefix="
593 (assoc-ref %build-inputs "sdl2-ttf"))
594 (string-append "--with-libsdl2-mixer-prefix="
22305f85 595 (assoc-ref %build-inputs "sdl2-mixer")))))
df05d80a 596 (native-inputs
37b9be58 597 `(("guile" ,guile-2.2)
df05d80a
SB
598 ("pkg-config" ,pkg-config)))
599 (inputs
600 `(("sdl2" ,sdl2)
601 ("sdl2-image" ,sdl2-image)
602 ("sdl2-mixer" ,sdl2-mixer)
603 ("sdl2-ttf" ,sdl2-ttf)))
604 (synopsis "Guile bindings for SDL2")
605 (home-page "https://dthompson.us/projects/guile-sdl2.html")
606 (description
607 "Guile-SDL2 provides Guile Scheme bindings for the SDL2 C shared library.
608The bindings are written in pure Scheme using Guile's foreign function
609interface.")
610 (license lgpl3+)))
aed6c010
PN
611
612(define-public sdl2-cs
613 (let ((commit "1a3556441e1394eb0b5d46aeb514b8d1090b93f8"))
614 (package
615 (name "sdl2-cs")
616 (version (git-version "B1" "1" commit))
617 (source (origin
618 (method git-fetch)
619 (uri (git-reference
620 (url "https://github.com/flibitijibibo/SDL2-CS")
621 (commit commit)))
622 (file-name (git-file-name name version))
623 (sha256
624 (base32
625 "007mzkqr9nmvfrvvhs2r6cm36lzgsww24kwshsz9c4fd97f9qk58"))))
626 (build-system gnu-build-system)
627 (arguments
628 '(#:tests? #f ; No tests.
629 #:phases
630 (modify-phases %standard-phases
631 (delete 'configure)
632 (replace 'build
633 (lambda _
634 (invoke "make" "release")))
635 (replace 'install
636 (lambda* (#:key outputs #:allow-other-keys)
637 (let ((out (assoc-ref outputs "out")))
638 (install-file "bin/Release/SDL2-CS.dll" (string-append out "/lib"))
639 #t))))))
640 (native-inputs
641 `(("mono" ,mono)))
642 (inputs
643 `(("sdl2" ,sdl2)
644 ("sdl2-image" ,sdl2-image)
645 ("sdl2-mixer" ,sdl2-mixer)
646 ("sdl2-ttf" ,sdl2-ttf)))
647 (home-page "https://dthompson.us/projects/guile-sdl2.html")
648 (synopsis "C# wrapper for SDL2")
649 (description
650 "SDL2-CS provides C# bindings for the SDL2 C shared library.
651The C# wrapper was written to be used for FNA's platform support. However, this
652is written in a way that can be used for any general C# application.")
653 (license zlib))))