gnu: sdl2: Update to 2.0.12.
[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>
59d10c31 9;;; Copyright © 2018, 2019, 2020 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")
43b176f3 118 (version "2.0.12")
8bf8d7c7
DT
119 (source (origin
120 (method url-fetch)
121 (uri
5d5790ce 122 (string-append "https://libsdl.org/release/SDL2-"
8bf8d7c7
DT
123 version ".tar.gz"))
124 (sha256
125 (base32
43b176f3 126 "0qy8wbqvfkb5ps8kxgaaf2zzpkjqbsw712hlp74znbn0jpv6i4il"))))
39f2433c
RH
127 (arguments
128 (substitute-keyword-arguments (package-arguments sdl)
129 ((#:configure-flags flags)
abfc114a
RH
130 `(append '("--disable-wayland-shared" "--enable-video-kmsdrm"
131 "--disable-kmsdrm-shared")
1ea1ce18
MB
132 ,flags))
133 ((#:make-flags flags ''())
9d4ed357
TL
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))))
e0101b54
DT
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)
9d4ed357 153 ("eudev" ,eudev) ; for discovering input devices
543bd0ee 154 ("fcitx" ,fcitx) ; helps with CJK input
e0101b54 155 ("glib" ,glib)
39f2433c 156 ("ibus" ,ibus)
c695fb76 157 ("libxkbcommon" ,libxkbcommon)
82de17dc 158 ("libxcursor" ,libxcursor) ; enables X11 cursor support
c695fb76
TGR
159 ("wayland" ,wayland)
160 ("wayland-protocols" ,wayland-protocols))
e0101b54 161 (package-inputs sdl)))
8bf8d7c7 162 (license bsd-3)))
c3c516ea 163
0160458b 164(define-public libmikmod
c3c516ea
DT
165 (package
166 (name "libmikmod")
fa3b93d6 167 (version "3.3.11.1")
c3c516ea
DT
168 (source (origin
169 (method url-fetch)
1934769b
MW
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")))
c3c516ea
DT
177 (sha256
178 (base32
fa3b93d6 179 "06bdnhb0l81srdzg6gn2v2ydhhaazza7rshrcj3q8dpqr3gn97dd"))))
c3c516ea 180 (build-system gnu-build-system)
03920078
LC
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")))
9e771e3b 186 (synopsis "Library for module sound formats")
c3c516ea
DT
187 (description
188 "MikMod is able to play a wide range of module formats, as well as
35b9e423 189digital sound files. It can take advantage of particular features of your
c3c516ea
DT
190system, such as sound redirection over the network.")
191 (license lgpl2.1)
192 (home-page "http://mikmod.sourceforge.net/")))
5cf3bcd4 193
0160458b 194(define-public sdl-gfx
5cf3bcd4
DT
195 (package
196 (name "sdl-gfx")
b5ceea9f 197 (version "2.0.26")
5cf3bcd4
DT
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
b5ceea9f 205 "0ijljhs0v99dj6y27hc10z6qchyp8gdp4199y6jzngy6dzxlzsvw"))))
5cf3bcd4 206 (build-system gnu-build-system)
38033318 207 (outputs '("out" "debug"))
8df1ee3f
EF
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")))))
5cf3bcd4 215 (propagated-inputs `(("sdl" ,sdl)))
5cf3bcd4
DT
216 (synopsis "SDL graphics primitives library")
217 (description "SDL_gfx provides graphics drawing primitives, rotozoom and
218other supporting functions for SDL.")
219 (home-page "http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx")
8df1ee3f 220 (license zlib)))
5cf3bcd4 221
0160458b 222(define-public sdl-image
5cf3bcd4
DT
223 (package
224 (name "sdl-image")
225 (version "1.2.12")
226 (source (origin
227 (method url-fetch)
228 (uri
5d5790ce 229 (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL_image-"
5cf3bcd4
DT
230 version ".tar.gz"))
231 (sha256
232 (base32
233 "16an9slbb8ci7d89wakkmyfvp7c0cval8xw4hkg0842nhhlp540b"))))
234 (build-system gnu-build-system)
38033318 235 (outputs '("out" "debug"))
7c3e60fb
SB
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")))
586b6d4d 242 (native-inputs `(("pkg-config" ,pkg-config)))
586b6d4d
DT
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)
6a51e95b
DT
250 ("libtiff" ,libtiff)
251 ("libwebp" ,libwebp)))
5cf3bcd4
DT
252 (synopsis "SDL image loading library")
253 (description "SDL_image is an image file loading library for SDL that
254supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF,
255WEBP, XCF, XPM, and XV.")
5d5790ce 256 (home-page "https://www.libsdl.org/projects/SDL_image/")
5cf3bcd4
DT
257 (license zlib)))
258
0160458b 259(define-public sdl-mixer
5cf3bcd4
DT
260 (package
261 (name "sdl-mixer")
262 (version "1.2.12")
263 (source (origin
264 (method url-fetch)
265 (uri
5d5790ce 266 (string-append "https://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-"
5cf3bcd4
DT
267 version ".tar.gz"))
268 (sha256
269 (base32
270 "0alrhqgm40p4c92s26mimg9cm1y7rzr6m0p49687jxd9g6130i0n"))))
271 (build-system gnu-build-system)
38033318 272 (outputs '("out" "debug"))
6fbf92ee
TL
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"
fa0c1a21
DM
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)))))
6fbf92ee
TL
293 (inputs
294 `(("fluidsynth" ,fluidsynth)
295 ("libflac" ,flac)
296 ("libmad" ,libmad)
297 ("libmikmod" ,libmikmod)
298 ("libvorbis" ,libvorbis)))
5cf3bcd4
DT
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.
302It supports any number of simultaneously playing channels of 16 bit stereo
769b96b6
TL
303audio, plus a single channel of music. Supported formats include FLAC, MOD,
304MIDI, Ogg Vorbis, and MP3.
305
306This package supports two MIDI backends, selectable at runtime. To use the
307newer @code{fluidsynth} library, install a soundfont such as @code{fluid-3}
308and specify it using the @code{SDL_SOUNDFONTS} environment variable. For the
309legacy @code{timidity} backend, install a patch set such as @code{freepats}
310and set the path to the configuration file with @code{TIMIDITY_CFG}.")
5d5790ce 311 (home-page "https://www.libsdl.org/projects/SDL_mixer/")
5cf3bcd4
DT
312 (license zlib)))
313
0160458b 314(define-public sdl-net
5cf3bcd4
DT
315 (package
316 (name "sdl-net")
317 (version "1.2.8")
318 (source (origin
319 (method url-fetch)
320 (uri
5d5790ce 321 (string-append "https://www.libsdl.org/projects/SDL_net/release/SDL_net-"
5cf3bcd4
DT
322 version ".tar.gz"))
323 (sha256
324 (base32
325 "1d5c9xqlf4s1c01gzv6cxmg0r621pq9kfgxcg3197xw4p25pljjz"))))
326 (build-system gnu-build-system)
327 (propagated-inputs `(("sdl" ,sdl)))
41eb1198 328 (native-inputs `(("pkg-config" ,pkg-config)))
38033318 329 (outputs '("out" "debug"))
5cf3bcd4
DT
330 (synopsis "SDL networking library")
331 (description "SDL_net is a small, cross-platform networking library for
332SDL.")
5d5790ce 333 (home-page "https://www.libsdl.org/projects/SDL_net/")
5cf3bcd4
DT
334 (license zlib)))
335
f389c65d
NG
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
349 (search-patches
350 "sdl-pango-api_additions.patch"
351 "sdl-pango-blit_overflow.patch"
352 "sdl-pango-fillrect_crash.patch"
374540ff 353 "sdl-pango-fix-explicit-SDLPango_CopyFTBitmapTo.patch"
f389c65d
NG
354 "sdl-pango-matrix_declarations.patch"
355 "sdl-pango-sans-serif.patch"))))
356 (build-system gnu-build-system)
357 (arguments
358 `(#:configure-flags (list "--disable-static")
359 #:phases
360 (modify-phases %standard-phases
361 (add-after 'unpack 'autogen
362 ;; Force reconfiguration because the included libtool
363 ;; generates linking errors.
364 (lambda _ (invoke "autoreconf" "-vif"))))))
365 (native-inputs
366 `(("autoconf" ,autoconf)
367 ("automake" ,automake)
368 ("libtool" ,libtool)
369 ("pkg-config" ,pkg-config)))
370 (inputs
371 `(("fontconfig" ,fontconfig)
372 ("freetype" ,freetype)
373 ("glib" ,glib)
374 ("harfbuzz" ,harfbuzz)
375 ("pango" ,pango)
376 ("sdl" ,sdl)))
377 (home-page "http://sdlpango.sourceforge.net")
378 (synopsis "Pango SDL binding")
379 (description "This library is a wrapper around the Pango library.
380It allows you to use TrueType fonts to render internationalized and
381tagged text in SDL applications.")
382 (license lgpl2.1)))
383
0160458b 384(define-public sdl-ttf
5cf3bcd4
DT
385 (package
386 (name "sdl-ttf")
387 (version "2.0.11")
388 (source (origin
389 (method url-fetch)
390 (uri
5d5790ce 391 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
5cf3bcd4
DT
392 version ".tar.gz"))
393 (sha256
394 (base32
395 "1dydxd4f5kb1288i5n5568kdk2q7f8mqjr7i7sd33nplxjaxhk3j"))))
396 (build-system gnu-build-system)
397 (propagated-inputs `(("sdl" ,sdl)))
890024c5 398 (inputs `(("freetype" ,freetype)
41eb1198
LC
399 ("mesa" ,mesa)))
400 (native-inputs `(("pkg-config" ,pkg-config)))
38033318 401 (outputs '("out" "debug"))
5cf3bcd4
DT
402 (synopsis "SDL TrueType font library")
403 (description "SDL_ttf is a TrueType font rendering library for SDL.")
5d5790ce 404 (home-page "https://www.libsdl.org/projects/SDL_ttf/")
5cf3bcd4 405 (license zlib)))
d6f74baf 406
40e94665
AK
407(define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
408 sdl-image sdl-mixer)))
409 "Return 'sdl-union' package which is a union of PACKAGES.
410If PACKAGES are not specified, all SDL packages are used."
d6f74baf
DT
411 (package
412 (name "sdl-union")
413 (version (package-version sdl))
414 (source #f)
415 (build-system trivial-build-system)
416 (arguments
417 '(#:modules ((guix build union))
418 #:builder (begin
419 (use-modules (ice-9 match)
420 (guix build union))
421 (match %build-inputs
422 (((names . directories) ...)
423 (union-build (assoc-ref %outputs "out")
e3cfef22
MW
424 directories)
425 #t)))))
40e94665
AK
426 (inputs (map (lambda (package)
427 (list (package-name package) package))
428 packages))
429 (synopsis "Union of SDL libraries")
d6f74baf
DT
430 (description
431 "A union of SDL and its extension libraries. A union is required because
432sdl-config assumes that all of the headers and libraries are in the same
433directory.")
434 (home-page (package-home-page sdl))
435 (license (package-license sdl))))
bcc046fc 436
6813f70a
DT
437(define (propagated-inputs-with-sdl2 package)
438 "Replace the \"sdl\" propagated input of PACKAGE with SDL2."
439 (map (match-lambda
440 (("sdl" _)
441 `("sdl2" ,sdl2))
442 (other other))
443 (package-propagated-inputs package)))
444
a95b2732
KK
445(define-public sdl2-gfx
446 (package (inherit sdl-gfx)
447 (name "sdl2-gfx")
448 (version "1.0.4")
449 (source (origin
450 (method url-fetch)
451 (uri
452 (string-append "https://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-"
453 version ".tar.gz"))
454 (sha256
455 (base32
456 "0qk2ax7f7grlxb13ba0ll3zlm8780s7j8fmrhlpxzjgdvldf1q33"))))
457 (propagated-inputs
458 (propagated-inputs-with-sdl2 sdl-gfx))))
459
6813f70a
DT
460(define-public sdl2-image
461 (package (inherit sdl-image)
462 (name "sdl2-image")
8f6b6cb8 463 (version "2.0.5")
ad237c8b
TGR
464 (source
465 (origin
466 (method url-fetch)
467 (uri
468 (string-append "https://www.libsdl.org/projects/SDL_image/release/"
469 "SDL2_image-" version ".tar.gz"))
470 (sha256
8f6b6cb8 471 (base32 "1l0864kas9cwpp2d32yxl81g98lx40dhbdp03dz7sbv84vhgdmdx"))))
6813f70a
DT
472 (propagated-inputs
473 (propagated-inputs-with-sdl2 sdl-image))))
474
855e2939
DT
475(define-public sdl2-mixer
476 (package (inherit sdl-mixer)
477 (name "sdl2-mixer")
863ab122
TGR
478 (version "2.0.4")
479 (source
480 (origin
481 (method url-fetch)
482 (uri
483 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/"
484 "SDL2_mixer-" version ".tar.gz"))
485 (modules '((guix build utils)))
486 (snippet '(begin
487 ;; Remove bundled libraries.
488 (delete-file-recursively "external")
489 #t))
490 (sha256
491 (base32 "0694vsz5bjkcdgfdra6x9fq8vpzrl8m6q96gh58df7065hw5mkxl"))))
64941afc
TL
492 (arguments
493 (substitute-keyword-arguments (package-arguments sdl-mixer)
494 ((#:configure-flags flags)
495 `(cons*
ced47faa 496 "--disable-music-opus-shared"
64941afc
TL
497 ;; These options were renamed in SDL2 mixer. Keeping the inherited
498 ;; variants produces a harmless warning.
499 "--disable-music-mod-modplug-shared"
500 "--disable-music-midi-fluidsynth-shared"
501 ,flags))))
5f50c2e6 502 (inputs
ced47faa
TL
503 `(("opusfile" ,opusfile)
504 ;; The default MOD library changed in SDL2 mixer.
505 ("libmodplug" ,libmodplug)
5f50c2e6 506 ,@(alist-delete "libmikmod" (package-inputs sdl-mixer))))
ced47faa
TL
507 (native-inputs
508 `(("pkgconfig" ,pkg-config))) ; Needed to find the opus library.
855e2939
DT
509 (propagated-inputs
510 (propagated-inputs-with-sdl2 sdl-mixer))))
511
1a898453
NG
512(define-public sdl2-net
513 (package (inherit sdl-net)
514 (name "sdl2-net")
515 (version "2.0.1")
516 (source
517 (origin
518 (method url-fetch)
519 (uri
520 (string-append "http://www.libsdl.org/projects/SDL_net/release/"
521 "SDL2_net-" version ".tar.gz"))
522 (sha256
523 (base32
524 "08cxc1bicmyk89kiks7izw1rlx5ng5n6xpy8fy0zxni3b9z8mkhm"))))
525 (propagated-inputs
526 (propagated-inputs-with-sdl2 sdl-net))))
527
d3f6a1de
DT
528(define-public sdl2-ttf
529 (package (inherit sdl-ttf)
530 (name "sdl2-ttf")
c97a1c42 531 (version "2.0.15")
d3f6a1de
DT
532 (source (origin
533 (method url-fetch)
534 (uri
5d5790ce 535 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-"
d3f6a1de 536 version ".tar.gz"))
8d506323 537 (modules '((guix build utils)))
6cbee49d
MW
538 (snippet (begin
539 ;; Remove bundled libraries.
540 '(delete-file-recursively "external")
541 #t))
d3f6a1de
DT
542 (sha256
543 (base32
c97a1c42 544 "0cyd48dipc0m399qy8s03lci8b0bpiy8xlkvrm2ia7wcv0dfpv59"))))
d3f6a1de
DT
545 (propagated-inputs
546 (propagated-inputs-with-sdl2 sdl-ttf))))
547
bcc046fc
DT
548(define-public guile-sdl
549 (package
550 (name "guile-sdl")
af87a551 551 (version "0.5.2")
bcc046fc
DT
552 (source (origin
553 (method url-fetch)
554 (uri
555 (string-append "mirror://gnu/guile-sdl/guile-sdl-"
556 version ".tar.xz"))
557 (sha256
558 (base32
af87a551 559 "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
bcc046fc
DT
560 (build-system gnu-build-system)
561 (native-inputs
562 `(("pkg-config" ,pkg-config)
563 ;; Required by test suite.
564 ("xorg-server" ,xorg-server)
565 ("libjpeg" ,libjpeg)))
566 (inputs
8380a181 567 `(("guile" ,guile-2.2)
40e94665 568 ("sdl-union" ,(sdl-union))))
bcc046fc
DT
569 (arguments
570 '(#:configure-flags
571 (list (string-append "--with-sdl-prefix="
572 (assoc-ref %build-inputs "sdl-union")))
4fa3f796
LC
573 #:modules ((ice-9 popen)
574 (guix build utils)
575 (guix build gnu-build-system))
576
bcc046fc 577 #:parallel-build? #f ; parallel build fails
4fa3f796 578
bcc046fc 579 #:phases
dc1d3cde
KK
580 (modify-phases %standard-phases
581 (add-before 'configure 'fix-env-and-patch
582 (lambda* (#:key inputs #:allow-other-keys)
583 (setenv "GUILE_AUTO_COMPILE" "0")
584 ;; SDL_image needs to dlopen libjpeg in the test suite.
585 (setenv "LD_LIBRARY_PATH"
586 (string-append (assoc-ref inputs "libjpeg") "/lib"))
4fa3f796
LC
587
588 ;; Change the site directory /site/X.Y like Guile expects.
dc1d3cde 589 (substitute* "build-aux/guile-baux/re-prefixed-site-dirs"
4fa3f796
LC
590 (("\"/site\"")
591 (let ((effective
592 (read
593 (open-pipe* OPEN_READ
594 "guile" "-c"
595 "(write (effective-version))"))))
596 (string-append "\"/site/" effective "\""))))
af87a551 597
dc1d3cde
KK
598 ;; Skip tests that rely on sound support, which is unavailable in
599 ;; the build environment.
600 (substitute* "test/Makefile.in"
601 (("HAVE_MIXER = .*$")
602 "HAVE_MIXER = 0\n"))
603 #t))
604 (add-before 'check 'start-xorg-server
605 (lambda* (#:key inputs #:allow-other-keys)
606 ;; The test suite requires a running X server.
607 (system (format #f "~a/bin/Xvfb :1 &"
608 (assoc-ref inputs "xorg-server")))
609 (setenv "DISPLAY" ":1")
8380a181
LC
610 #t))
611 (add-before 'check 'skip-cursor-test
612 (lambda _
613 ;; XXX: This test sometimes enters an endless loop, and sometimes
614 ;; crashes with:
615 ;; guile: xcb_io.c:147: append_pending_request: Assertion `!xcb_xlib_unknown_seq_number' failed.
616 ;; Skip it.
617 (substitute* "test/cursor.scm"
618 (("\\(SDL:init .*" all)
619 (string-append "(exit 77) ;" all "\n")))
dc1d3cde 620 #t)))))
bcc046fc
DT
621 (synopsis "Guile interface for SDL (Simple DirectMedia Layer)")
622 (description "Guile-SDL is a set of bindings to the Simple DirectMedia
623Layer (SDL). With them, Guile programmers can have easy access to graphics,
624sound and device input (keyboards, joysticks, mice, etc.).")
6fd52309 625 (home-page "https://www.gnu.org/software/guile-sdl/")
bcc046fc 626 (license gpl3+)))
df05d80a
SB
627
628(define-public guile-sdl2
629 (package
630 (name "guile-sdl2")
2ffa842b 631 (version "0.4.0")
df05d80a
SB
632 (source (origin
633 (method url-fetch)
2ffa842b
RW
634 (uri (string-append "https://files.dthompson.us/guile-sdl2/"
635 "guile-sdl2-" version ".tar.gz"))
df05d80a
SB
636 (sha256
637 (base32
2ffa842b 638 "0zcxwgyadwpbhq6h5mv2569c3kalgra26zc186y9fqiyyzmh1v9s"))))
df05d80a
SB
639 (build-system gnu-build-system)
640 (arguments
641 '(#:make-flags '("GUILE_AUTO_COMPILE=0")
642 #:configure-flags
643 (list (string-append "--with-libsdl2-prefix="
644 (assoc-ref %build-inputs "sdl2"))
645 (string-append "--with-libsdl2-image-prefix="
646 (assoc-ref %build-inputs "sdl2-image"))
647 (string-append "--with-libsdl2-ttf-prefix="
648 (assoc-ref %build-inputs "sdl2-ttf"))
649 (string-append "--with-libsdl2-mixer-prefix="
22305f85 650 (assoc-ref %build-inputs "sdl2-mixer")))))
df05d80a 651 (native-inputs
37b9be58 652 `(("guile" ,guile-2.2)
df05d80a
SB
653 ("pkg-config" ,pkg-config)))
654 (inputs
655 `(("sdl2" ,sdl2)
656 ("sdl2-image" ,sdl2-image)
657 ("sdl2-mixer" ,sdl2-mixer)
658 ("sdl2-ttf" ,sdl2-ttf)))
659 (synopsis "Guile bindings for SDL2")
660 (home-page "https://dthompson.us/projects/guile-sdl2.html")
661 (description
662 "Guile-SDL2 provides Guile Scheme bindings for the SDL2 C shared library.
663The bindings are written in pure Scheme using Guile's foreign function
664interface.")
665 (license lgpl3+)))
aed6c010 666
59d10c31
RW
667(define-public guile3.0-sdl2
668 (package
669 (inherit guile-sdl2)
670 (name "guile3.0-sdl2")
671 (native-inputs
672 `(("guile" ,guile-3.0)
673 ("pkg-config" ,pkg-config)))))
674
aed6c010
PN
675(define-public sdl2-cs
676 (let ((commit "1a3556441e1394eb0b5d46aeb514b8d1090b93f8"))
677 (package
678 (name "sdl2-cs")
679 (version (git-version "B1" "1" commit))
680 (source (origin
681 (method git-fetch)
682 (uri (git-reference
683 (url "https://github.com/flibitijibibo/SDL2-CS")
684 (commit commit)))
685 (file-name (git-file-name name version))
686 (sha256
687 (base32
688 "007mzkqr9nmvfrvvhs2r6cm36lzgsww24kwshsz9c4fd97f9qk58"))))
689 (build-system gnu-build-system)
690 (arguments
691 '(#:tests? #f ; No tests.
692 #:phases
693 (modify-phases %standard-phases
694 (delete 'configure)
695 (replace 'build
696 (lambda _
697 (invoke "make" "release")))
698 (replace 'install
699 (lambda* (#:key outputs #:allow-other-keys)
700 (let ((out (assoc-ref outputs "out")))
701 (install-file "bin/Release/SDL2-CS.dll" (string-append out "/lib"))
702 #t))))))
703 (native-inputs
704 `(("mono" ,mono)))
705 (inputs
706 `(("sdl2" ,sdl2)
707 ("sdl2-image" ,sdl2-image)
708 ("sdl2-mixer" ,sdl2-mixer)
709 ("sdl2-ttf" ,sdl2-ttf)))
710 (home-page "https://dthompson.us/projects/guile-sdl2.html")
711 (synopsis "C# wrapper for SDL2")
712 (description
713 "SDL2-CS provides C# bindings for the SDL2 C shared library.
714The C# wrapper was written to be used for FNA's platform support. However, this
715is written in a way that can be used for any general C# application.")
716 (license zlib))))