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