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