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