gnu: libsmpeg: Set source file-name.
[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>
5d5790ce 6;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
c3c516ea
DT
7;;;
8;;; This file is part of GNU Guix.
9;;;
10;;; GNU Guix is free software; you can redistribute it and/or modify it
11;;; under the terms of the GNU General Public License as published by
12;;; the Free Software Foundation; either version 3 of the License, or (at
13;;; your option) any later version.
14;;;
15;;; GNU Guix is distributed in the hope that it will be useful, but
16;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;;; GNU General Public License for more details.
19;;;
20;;; You should have received a copy of the GNU General Public License
21;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22
23(define-module (gnu packages sdl)
6813f70a 24 #:use-module (ice-9 match)
c3c516ea 25 #:use-module (gnu packages)
890024c5 26 #:use-module ((guix licenses) #:hide (freetype))
c3c516ea
DT
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix build-system gnu)
d6f74baf 30 #:use-module (guix build-system trivial)
a313e085 31 #:use-module (gnu packages audio)
543bd0ee 32 #:use-module (gnu packages fcitx)
890024c5 33 #:use-module (gnu packages fontutils)
e0101b54 34 #:use-module (gnu packages glib)
bcc046fc 35 #:use-module (gnu packages guile)
e0101b54 36 #:use-module (gnu packages ibus)
e55354b8 37 #:use-module (gnu packages image)
c3c516ea 38 #:use-module (gnu packages linux)
5cf3bcd4 39 #:use-module (gnu packages mp3)
8bf8d7c7
DT
40 #:use-module (gnu packages pkg-config)
41 #:use-module (gnu packages pulseaudio)
200726ed 42 #:use-module (gnu packages gl)
54ff0b7d 43 #:use-module (gnu packages xiph)
c3c516ea 44 #:use-module (gnu packages xorg)
0160458b 45 #:export (sdl-union))
8bf8d7c7 46
0160458b 47(define-public sdl
8bf8d7c7
DT
48 (package
49 (name "sdl")
50 (version "1.2.15")
51 (source (origin
52 (method url-fetch)
53 (uri
5d5790ce 54 (string-append "https://libsdl.org/release/SDL-"
8bf8d7c7
DT
55 version ".tar.gz"))
56 (sha256
57 (base32
9cb3036f 58 "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"))
fc1adab1 59 (patches (search-patches "sdl-libx11-1.6.patch"))))
8bf8d7c7 60 (build-system gnu-build-system)
22f33e61 61 (arguments
666aa995 62 '(;; Explicitly link against shared libraries instead of dlopening them.
83bb3a3e
SB
63 ;; For X11, ALSA, and PulseAudio.
64 ;; OpenGL library is still dlopened at runtime.
65 #:configure-flags '("--disable-alsa-shared"
66 "--disable-pulseaudio-shared"
07780c71
SB
67 "--disable-x11-shared"
68 ;; Explicitly link with mesa.
69 ;; This add mesa to libsdl's RUNPATH, to make dlopen
70 ;; finding the libGL from mesa at runtime.
71 "LDFLAGS=-lGL")
22f33e61
LC
72
73 #:tests? #f)) ; no check target
558a5122
LC
74 (propagated-inputs
75 ;; SDL headers include X11 headers.
666aa995
SB
76 `(("libx11" ,libx11)
77 ("libcap" ,libcap))) ; 'libSDL.la' contain `-lcap'.
22f33e61 78 (native-inputs `(("pkg-config" ,pkg-config)))
558a5122 79 (inputs `(("libxrandr" ,libxrandr)
8bf8d7c7 80 ("mesa" ,mesa)
83bb3a3e 81 ("glu" ,glu)
8bf8d7c7 82 ("alsa-lib" ,alsa-lib)
8bf8d7c7
DT
83 ("pulseaudio" ,pulseaudio)))
84 (synopsis "Cross platform game development library")
85 (description "Simple DirectMedia Layer is a cross-platform development
86library designed to provide low level access to audio, keyboard, mouse,
87joystick, and graphics hardware.")
5d5790ce 88 (home-page "https://libsdl.org/")
8bf8d7c7
DT
89 (license lgpl2.1)))
90
0160458b 91(define-public sdl2
8bf8d7c7
DT
92 (package (inherit sdl)
93 (name "sdl2")
355d8e87 94 (version "2.0.5")
8bf8d7c7
DT
95 (source (origin
96 (method url-fetch)
97 (uri
5d5790ce 98 (string-append "https://libsdl.org/release/SDL2-"
8bf8d7c7
DT
99 version ".tar.gz"))
100 (sha256
101 (base32
355d8e87 102 "11c75qj1qxmx67iwkvf9z4x69phk301pdn86zzr6jncnap7kh824"))))
e0101b54
DT
103 (inputs
104 ;; SDL2 needs to be built with ibus support otherwise some systems
105 ;; experience a bug where input events are doubled.
106 ;;
107 ;; For more information, see: https://dev.solus-project.com/T1721
108 (append `(("dbus" ,dbus)
543bd0ee 109 ("fcitx" ,fcitx) ; helps with CJK input
e0101b54
DT
110 ("glib" ,glib)
111 ("ibus" ,ibus))
112 (package-inputs sdl)))
8bf8d7c7 113 (license bsd-3)))
c3c516ea 114
0160458b 115(define-public libmikmod
c3c516ea
DT
116 (package
117 (name "libmikmod")
7d876afd 118 (version "3.3.10")
c3c516ea
DT
119 (source (origin
120 (method url-fetch)
121 (uri (string-append "mirror://sourceforge/mikmod/libmikmod/"
122 version "/libmikmod-" version ".tar.gz"))
123 (sha256
124 (base32
7d876afd 125 "0j7g4jpa2zgzw7x6s3rldypa7zlwjvn97rwx0sylx1iihhlzbcq0"))))
c3c516ea 126 (build-system gnu-build-system)
03920078
LC
127 (arguments
128 ;; By default, libmikmod tries to dlopen libasound etc., which won't work
129 ;; unless the right libalsa happens to be in $LD_LIBRARY_PATH. Pass
130 ;; '--disable-dl' to avoid that.
131 '(#:configure-flags '("--disable-dl")))
9e771e3b 132 (synopsis "Library for module sound formats")
c3c516ea
DT
133 (description
134 "MikMod is able to play a wide range of module formats, as well as
35b9e423 135digital sound files. It can take advantage of particular features of your
c3c516ea
DT
136system, such as sound redirection over the network.")
137 (license lgpl2.1)
138 (home-page "http://mikmod.sourceforge.net/")))
5cf3bcd4 139
0160458b 140(define-public sdl-gfx
5cf3bcd4
DT
141 (package
142 (name "sdl-gfx")
b5ceea9f 143 (version "2.0.26")
5cf3bcd4
DT
144 (source (origin
145 (method url-fetch)
146 (uri
147 (string-append "http://www.ferzkopp.net/Software/SDL_gfx-2.0/SDL_gfx-"
148 version ".tar.gz"))
149 (sha256
150 (base32
b5ceea9f 151 "0ijljhs0v99dj6y27hc10z6qchyp8gdp4199y6jzngy6dzxlzsvw"))))
5cf3bcd4
DT
152 (build-system gnu-build-system)
153 (propagated-inputs `(("sdl" ,sdl)))
5cf3bcd4
DT
154 (synopsis "SDL graphics primitives library")
155 (description "SDL_gfx provides graphics drawing primitives, rotozoom and
156other supporting functions for SDL.")
157 (home-page "http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx")
1d830bc0
LC
158 (license zlib)
159
160 ;; The code apparently includes Intel assembly, which fails to build on
161 ;; MIPS, at least.
162 (supported-systems '("i686-linux" "x86_64-linux"))))
5cf3bcd4 163
0160458b 164(define-public sdl-image
5cf3bcd4
DT
165 (package
166 (name "sdl-image")
167 (version "1.2.12")
168 (source (origin
169 (method url-fetch)
170 (uri
5d5790ce 171 (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL_image-"
5cf3bcd4
DT
172 version ".tar.gz"))
173 (sha256
174 (base32
175 "16an9slbb8ci7d89wakkmyfvp7c0cval8xw4hkg0842nhhlp540b"))))
176 (build-system gnu-build-system)
7c3e60fb
SB
177 (arguments
178 ;; Explicitly link against shared libraries instead of dlopening them.
179 '(#:configure-flags '("--disable-jpg-shared"
180 "--disable-png-shared"
181 "--disable-tif-shared"
182 "--disable-webp-shared")))
586b6d4d 183 (native-inputs `(("pkg-config" ,pkg-config)))
586b6d4d
DT
184 ;; libjpeg, libpng, and libtiff are propagated inputs because the
185 ;; SDL_image headers include the headers of these libraries. SDL is a
186 ;; propagated input because the pkg-config file refers to SDL's pkg-config
187 ;; file.
188 (propagated-inputs `(("sdl" ,sdl)
189 ("libjpeg" ,libjpeg)
190 ("libpng" ,libpng)
6a51e95b
DT
191 ("libtiff" ,libtiff)
192 ("libwebp" ,libwebp)))
5cf3bcd4
DT
193 (synopsis "SDL image loading library")
194 (description "SDL_image is an image file loading library for SDL that
195supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF,
196WEBP, XCF, XPM, and XV.")
5d5790ce 197 (home-page "https://www.libsdl.org/projects/SDL_image/")
5cf3bcd4
DT
198 (license zlib)))
199
0160458b 200(define-public sdl-mixer
5cf3bcd4
DT
201 (package
202 (name "sdl-mixer")
203 (version "1.2.12")
204 (source (origin
205 (method url-fetch)
206 (uri
5d5790ce 207 (string-append "https://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-"
5cf3bcd4
DT
208 version ".tar.gz"))
209 (sha256
210 (base32
211 "0alrhqgm40p4c92s26mimg9cm1y7rzr6m0p49687jxd9g6130i0n"))))
212 (build-system gnu-build-system)
213 ;; no check target
214 ;; use libmad instead of smpeg
3ff73390 215 ;; explicitly link against shared libraries instead of dlopening them
5cf3bcd4 216 (arguments `(#:tests? #f
3ff73390
SB
217 #:configure-flags '("--enable-music-mp3-mad-gpl"
218 "--disable-music-mod-shared"
219 "--disable-music-fluidsynth-shared"
220 "--disable-music-ogg-shared"
221 "--disable-music-flac-shared"
222 "--disable-music-mp3-shared")))
5cf3bcd4
DT
223 (inputs `(("libvorbis" ,libvorbis)
224 ("libflac" ,flac)
225 ("libmad" ,libmad)
a313e085
DT
226 ("libmikmod" ,libmikmod)
227 ("libmodplug" ,libmodplug)))
5cf3bcd4
DT
228 ;; FIXME: Add libfluidsynth
229 (propagated-inputs `(("sdl" ,sdl)))
230 (synopsis "SDL multi-channel audio mixer library")
231 (description "SDL_mixer is a multi-channel audio mixer library for SDL.
232It supports any number of simultaneously playing channels of 16 bit stereo
233audio, plus a single channel of music. Supported format include FLAC, MOD,
234MIDI, Ogg Vorbis, and MP3.")
5d5790ce 235 (home-page "https://www.libsdl.org/projects/SDL_mixer/")
5cf3bcd4
DT
236 (license zlib)))
237
0160458b 238(define-public sdl-net
5cf3bcd4
DT
239 (package
240 (name "sdl-net")
241 (version "1.2.8")
242 (source (origin
243 (method url-fetch)
244 (uri
5d5790ce 245 (string-append "https://www.libsdl.org/projects/SDL_net/release/SDL_net-"
5cf3bcd4
DT
246 version ".tar.gz"))
247 (sha256
248 (base32
249 "1d5c9xqlf4s1c01gzv6cxmg0r621pq9kfgxcg3197xw4p25pljjz"))))
250 (build-system gnu-build-system)
251 (propagated-inputs `(("sdl" ,sdl)))
41eb1198 252 (native-inputs `(("pkg-config" ,pkg-config)))
5cf3bcd4
DT
253 (synopsis "SDL networking library")
254 (description "SDL_net is a small, cross-platform networking library for
255SDL.")
5d5790ce 256 (home-page "https://www.libsdl.org/projects/SDL_net/")
5cf3bcd4
DT
257 (license zlib)))
258
0160458b 259(define-public sdl-ttf
5cf3bcd4
DT
260 (package
261 (name "sdl-ttf")
262 (version "2.0.11")
263 (source (origin
264 (method url-fetch)
265 (uri
5d5790ce 266 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-"
5cf3bcd4
DT
267 version ".tar.gz"))
268 (sha256
269 (base32
270 "1dydxd4f5kb1288i5n5568kdk2q7f8mqjr7i7sd33nplxjaxhk3j"))))
271 (build-system gnu-build-system)
272 (propagated-inputs `(("sdl" ,sdl)))
890024c5 273 (inputs `(("freetype" ,freetype)
41eb1198
LC
274 ("mesa" ,mesa)))
275 (native-inputs `(("pkg-config" ,pkg-config)))
5cf3bcd4
DT
276 (synopsis "SDL TrueType font library")
277 (description "SDL_ttf is a TrueType font rendering library for SDL.")
5d5790ce 278 (home-page "https://www.libsdl.org/projects/SDL_ttf/")
5cf3bcd4 279 (license zlib)))
d6f74baf 280
40e94665
AK
281(define* (sdl-union #:optional (packages (list sdl sdl-gfx sdl-net sdl-ttf
282 sdl-image sdl-mixer)))
283 "Return 'sdl-union' package which is a union of PACKAGES.
284If PACKAGES are not specified, all SDL packages are used."
d6f74baf
DT
285 (package
286 (name "sdl-union")
287 (version (package-version sdl))
288 (source #f)
289 (build-system trivial-build-system)
290 (arguments
291 '(#:modules ((guix build union))
292 #:builder (begin
293 (use-modules (ice-9 match)
294 (guix build union))
295 (match %build-inputs
296 (((names . directories) ...)
297 (union-build (assoc-ref %outputs "out")
298 directories))))))
40e94665
AK
299 (inputs (map (lambda (package)
300 (list (package-name package) package))
301 packages))
302 (synopsis "Union of SDL libraries")
d6f74baf
DT
303 (description
304 "A union of SDL and its extension libraries. A union is required because
305sdl-config assumes that all of the headers and libraries are in the same
306directory.")
307 (home-page (package-home-page sdl))
308 (license (package-license sdl))))
bcc046fc 309
6813f70a
DT
310(define (propagated-inputs-with-sdl2 package)
311 "Replace the \"sdl\" propagated input of PACKAGE with SDL2."
312 (map (match-lambda
313 (("sdl" _)
314 `("sdl2" ,sdl2))
315 (other other))
316 (package-propagated-inputs package)))
317
318(define-public sdl2-image
319 (package (inherit sdl-image)
320 (name "sdl2-image")
64ee72e1 321 (version "2.0.1")
6813f70a
DT
322 (source (origin
323 (method url-fetch)
324 (uri
5d5790ce 325 (string-append "https://www.libsdl.org/projects/SDL_image/release/SDL2_image-"
6813f70a
DT
326 version ".tar.gz"))
327 (sha256
328 (base32
64ee72e1 329 "0r3z1l7fdn76qkpy7snpkcjqz8dkv2zp6lsqpq25q4m5xsyaygis"))))
6813f70a
DT
330 (propagated-inputs
331 (propagated-inputs-with-sdl2 sdl-image))))
332
855e2939
DT
333(define-public sdl2-mixer
334 (package (inherit sdl-mixer)
335 (name "sdl2-mixer")
efd75ade 336 (version "2.0.1")
855e2939
DT
337 (source (origin
338 (method url-fetch)
339 (uri
340 (string-append "http://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-"
341 version ".tar.gz"))
efd75ade
DT
342 (modules '((guix build utils)))
343 (snippet
344 ;; Remove bundled libraries.
345 '(delete-file-recursively "external"))
855e2939
DT
346 (sha256
347 (base32
efd75ade 348 "0pv9jzjpcjlbiaybvwrb4avmv46qk7iqxlnqrd2dfj82c4mgc92s"))))
855e2939
DT
349 (propagated-inputs
350 (propagated-inputs-with-sdl2 sdl-mixer))))
351
d3f6a1de
DT
352(define-public sdl2-ttf
353 (package (inherit sdl-ttf)
354 (name "sdl2-ttf")
8d506323 355 (version "2.0.14")
d3f6a1de
DT
356 (source (origin
357 (method url-fetch)
358 (uri
5d5790ce 359 (string-append "https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-"
d3f6a1de 360 version ".tar.gz"))
8d506323
DT
361 (modules '((guix build utils)))
362 (snippet
363 ;; Remove bundled libraries.
364 '(delete-file-recursively "external"))
d3f6a1de
DT
365 (sha256
366 (base32
8d506323 367 "0xljwcpvd2knrjdfag5b257xqayplz55mqlszrqp0kpnphh5xnrl"))))
d3f6a1de
DT
368 (propagated-inputs
369 (propagated-inputs-with-sdl2 sdl-ttf))))
370
bcc046fc
DT
371(define-public guile-sdl
372 (package
373 (name "guile-sdl")
af87a551 374 (version "0.5.2")
bcc046fc
DT
375 (source (origin
376 (method url-fetch)
377 (uri
378 (string-append "mirror://gnu/guile-sdl/guile-sdl-"
379 version ".tar.xz"))
380 (sha256
381 (base32
af87a551 382 "0cjgs012a9922hn6xqwj66w6qmfs3nycnm56hyykx5n3g5p7ag01"))))
bcc046fc
DT
383 (build-system gnu-build-system)
384 (native-inputs
385 `(("pkg-config" ,pkg-config)
386 ;; Required by test suite.
387 ("xorg-server" ,xorg-server)
388 ("libjpeg" ,libjpeg)))
389 (inputs
390 `(("guile" ,guile-2.0)
40e94665 391 ("sdl-union" ,(sdl-union))))
bcc046fc
DT
392 (arguments
393 '(#:configure-flags
394 (list (string-append "--with-sdl-prefix="
395 (assoc-ref %build-inputs "sdl-union")))
396 #:parallel-build? #f ; parallel build fails
397 #:phases
398 (alist-cons-before
399 'configure 'fix-env-and-patch
400 (lambda* (#:key inputs #:allow-other-keys)
401 (setenv "GUILE_AUTO_COMPILE" "0")
402 ;; SDL_image needs to dlopen libjpeg in the test suite.
403 (setenv "LD_LIBRARY_PATH"
404 (string-append (assoc-ref inputs "libjpeg") "/lib"))
405 ;; Change the site directory /site/2.0 like Guile expects.
406 (substitute* "build-aux/guile-baux/re-prefixed-site-dirs"
af87a551
LC
407 (("\"/site\"") "\"/site/2.0\""))
408
409 ;; Skip tests that rely on sound support, which is unavailable in
410 ;; the build environment.
411 (substitute* "test/Makefile.in"
412 (("HAVE_MIXER = .*$")
413 "HAVE_MIXER = 0\n")))
bcc046fc
DT
414 (alist-cons-before
415 'check 'start-xorg-server
416 (lambda* (#:key inputs #:allow-other-keys)
417 ;; The test suite requires a running X server.
418 (system (format #f "~a/bin/Xvfb :1 &"
419 (assoc-ref inputs "xorg-server")))
420 (setenv "DISPLAY" ":1"))
421 %standard-phases))))
422 (synopsis "Guile interface for SDL (Simple DirectMedia Layer)")
423 (description "Guile-SDL is a set of bindings to the Simple DirectMedia
424Layer (SDL). With them, Guile programmers can have easy access to graphics,
425sound and device input (keyboards, joysticks, mice, etc.).")
6fd52309 426 (home-page "https://www.gnu.org/software/guile-sdl/")
bcc046fc 427 (license gpl3+)))
df05d80a
SB
428
429(define-public guile-sdl2
430 (package
431 (name "guile-sdl2")
432 (version "0.2.0")
433 (source (origin
434 (method url-fetch)
435 (uri (string-append
436 "https://files.dthompson.us/guile-sdl2/guile-sdl2-"
437 version ".tar.gz"))
438 (sha256
439 (base32
440 "0yq9lsl17cdvj77padvpk3jcw2g6g0pck9jrchc7n2767rrc012b"))))
441 (build-system gnu-build-system)
442 (arguments
443 '(#:make-flags '("GUILE_AUTO_COMPILE=0")
444 #:configure-flags
445 (list (string-append "--with-libsdl2-prefix="
446 (assoc-ref %build-inputs "sdl2"))
447 (string-append "--with-libsdl2-image-prefix="
448 (assoc-ref %build-inputs "sdl2-image"))
449 (string-append "--with-libsdl2-ttf-prefix="
450 (assoc-ref %build-inputs "sdl2-ttf"))
451 (string-append "--with-libsdl2-mixer-prefix="
452 (assoc-ref %build-inputs "sdl2-mixer")))))
453 (native-inputs
454 `(("guile" ,guile-2.0)
455 ("pkg-config" ,pkg-config)))
456 (inputs
457 `(("sdl2" ,sdl2)
458 ("sdl2-image" ,sdl2-image)
459 ("sdl2-mixer" ,sdl2-mixer)
460 ("sdl2-ttf" ,sdl2-ttf)))
461 (synopsis "Guile bindings for SDL2")
462 (home-page "https://dthompson.us/projects/guile-sdl2.html")
463 (description
464 "Guile-SDL2 provides Guile Scheme bindings for the SDL2 C shared library.
465The bindings are written in pure Scheme using Guile's foreign function
466interface.")
467 (license lgpl3+)))