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