gnu: Add gom.
[jackhill/guix/guix.git] / gnu / packages / gl.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2015 Andreas Enge <andreas@enge.fr>
3 ;;; Copyright © 2013 Joshua Grant <tadni@riseup.net>
4 ;;; Copyright © 2014 David Thompson <davet@gnu.org>
5 ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
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 gl)
23 #:use-module (ice-9 match)
24 #:use-module (guix build utils)
25 #:use-module ((guix licenses) #:prefix l:)
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix packages)
30 #:use-module (guix utils)
31 #:use-module (gnu packages autotools)
32 #:use-module (gnu packages bison)
33 #:use-module (gnu packages flex)
34 #:use-module (gnu packages pkg-config)
35 #:use-module (gnu packages gettext)
36 #:use-module (gnu packages linux)
37 #:use-module (gnu packages python)
38 #:use-module (gnu packages xorg)
39 #:use-module (gnu packages xml)
40 #:use-module (gnu packages fontutils)
41 #:use-module (gnu packages guile)
42 #:use-module (gnu packages video)
43 #:use-module (gnu packages xdisorg)
44 #:use-module (gnu packages zip))
45
46 (define-public glu
47 (package
48 (name "glu")
49 (version "9.0.0")
50 (source (origin
51 (method url-fetch)
52 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/glu/glu-"
53 version ".tar.gz"))
54 (sha256
55 (base32 "0r72yyhj09x3krn3kn629jqbwyq50ji8w5ri2pn6zwrk35m4g1s3"))))
56 (build-system gnu-build-system)
57 (propagated-inputs
58 `(("mesa" ,mesa))) ; according to glu.pc
59 (home-page "http://www.opengl.org/archives/resources/faq/technical/glu.htm")
60 (synopsis "Mesa OpenGL Utility library")
61 (description
62 "GLU, or OpenGL Utility Library provides some higher-level functionality
63 not provided by just OpenGL itself. Some of GLU's Features
64 include: Scaling of 2D images and creation of mipmap pyramids,
65 Transformation of object coordinates into device coordinates and
66 vice versa, Support for NURBS surfaces, Support for tessellation
67 of concave or bow tie polygonal primitives, Specialty transformation
68 matrices for creating perspective and orthographic projections,
69 positioning a camera, and selection/picking, Rendering of disk,
70 cylinder, and sphere primitives, Interpreting OpenGL error values
71 as ASCII text.")
72 (license (l:x11-style "http://directory.fsf.org/wiki/License:SGIFreeBv2"))))
73
74 (define-public freeglut
75 (package
76 (name "freeglut")
77 (version "2.8.1")
78 (source (origin
79 (method url-fetch)
80 (uri (string-append "mirror://sourceforge/project/freeglut/freeglut/"
81 version "/freeglut-" version ".tar.gz"))
82 (sha256
83 (base32 "16lrxxxd9ps9l69y3zsw6iy0drwjsp6m26d1937xj71alqk6dr6x"))))
84 (build-system gnu-build-system)
85 (inputs `(("mesa" ,mesa)
86 ("libx11" ,libx11)
87 ("libxi" ,libxi)
88 ("libxrandr" ,libxrandr)
89 ("libxxf86vm" ,libxxf86vm)
90 ("inputproto" ,inputproto)
91 ("xinput" ,xinput)))
92 (propagated-inputs
93 ;; Headers from Mesa and GLU are needed.
94 `(("glu" ,glu)
95 ("mesa" ,mesa)))
96 (home-page "http://freeglut.sourceforge.net/")
97 (synopsis "Alternative to the OpenGL Utility Toolkit (GLUT)")
98 (description
99 "Freeglut is a completely Free/OpenSourced alternative to
100 the OpenGL Utility Toolkit (GLUT) library. GLUT was originally
101 written by Mark Kilgard to support the sample programs in the
102 second edition OpenGL 'RedBook'. Since then, GLUT has been used
103 in a wide variety of practical applications because it is simple,
104 widely available and highly portable.
105
106 GLUT (and hence freeglut) allows the user to create and manage windows
107 containing OpenGL contexts on a wide range of platforms and also read
108 the mouse, keyboard and joystick functions. Freeglut is released under
109 the X-Consortium license.")
110 (license l:x11)))
111
112 (define-public ftgl
113 (package
114 (name "ftgl")
115 (version "2.1.3-rc5")
116 (source (origin
117 (method url-fetch)
118 (uri (string-append "mirror://sourceforge/project/ftgl/FTGL%20Source/2.1.3~rc5/ftgl-"
119 version ".tar.gz"))
120 (sha256
121 (base32 "0nsn4s6vnv5xcgxcw6q031amvh2zfj2smy1r5mbnjj2548hxcn2l"))))
122 (build-system gnu-build-system)
123 (inputs `(("freetype" ,freetype)
124 ("libx11" ,libx11)
125 ("mesa" ,mesa)
126 ("glu" ,glu)))
127 (home-page "http://ftgl.sourceforge.net")
128 (synopsis "Font rendering library for OpenGL applications")
129 (description
130 "FTGL is a font rendering library for OpenGL applications. Supported
131 rendering modes are: Bitmaps, Anti-aliased pixmaps, Texture maps, Outlines,
132 Polygon meshes, and Extruded polygon meshes")
133 (license l:x11)))
134
135 (define-public s2tc
136 (package
137 (name "s2tc")
138 (version "1.0")
139 (source
140 (origin
141 (method url-fetch)
142 (uri (string-append
143 "https://github.com/divVerent/s2tc/archive/v" version ".tar.gz"))
144 (sha256
145 (base32 "0ibfdib277fhbqvxzan0bmglwnsl1y1rw2g8skvz82l1sfmmn752"))
146 (file-name (string-append name "-" version ".tar.gz"))))
147 (build-system gnu-build-system)
148 (native-inputs
149 `(("autoconf" ,autoconf)
150 ("automake" ,automake)
151 ("libtool" ,libtool)))
152 (inputs
153 `(("mesa-headers" ,mesa-headers)))
154 (arguments
155 '(#:phases
156 (modify-phases %standard-phases
157 (add-after 'unpack 'autogen
158 (lambda _
159 (zero? (system* "sh" "autogen.sh")))))))
160 (home-page "https://github.com/divVerent/s2tc")
161 (synopsis "S3 Texture Compression implementation")
162 (description
163 "S2TC is a patent-free implementation of S3 Texture Compression (S3TC,
164 also known as DXTn or DXTC) for Mesa.")
165 (license l:expat)))
166
167 ;;; Mesa needs LibVA headers to build its Gallium-based VA API implementation;
168 ;;; LibVA itself depends on Mesa. We use the following to solve the circular
169 ;;; dependency.
170 (define libva-without-mesa
171 ;; Delay to work around circular import problem.
172 (delay
173 (package
174 (inherit libva)
175 (name "libva-without-mesa")
176 (inputs (alist-delete "mesa" (package-inputs libva)))
177 (arguments
178 (strip-keyword-arguments
179 '(#:make-flags)
180 (substitute-keyword-arguments (package-arguments libva)
181 ((#:configure-flags flags)
182 '(list "--disable-glx" "--disable-egl"))))))))
183
184 (define-public mesa
185 (package
186 (name "mesa")
187 (version "10.5.4")
188 (source
189 (origin
190 (method url-fetch)
191 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/"
192 version "/mesa-" version ".tar.xz"))
193 (sha256
194 (base32
195 "00v89jna7m6r2w1yrnx09isc97r2bd1hkn4jib445n1078zp47mm"))))
196 (build-system gnu-build-system)
197 (propagated-inputs
198 `(("glproto" ,glproto)
199 ;; The following are in the Requires.private field of gl.pc.
200 ("libdrm" ,libdrm)
201 ("libx11" ,libx11)
202 ("libxdamage" ,libxdamage)
203 ("libxfixes" ,libxfixes)
204 ("libxshmfence" ,libxshmfence)
205 ("libxxf86vm" ,libxxf86vm)))
206 ;; TODO: Add vdpau.
207 (inputs
208 `(("udev" ,eudev)
209 ("dri2proto" ,dri2proto)
210 ("dri3proto" ,dri3proto)
211 ("presentproto" ,presentproto)
212 ("expat" ,expat)
213 ("libva" ,(force libva-without-mesa))
214 ("libxml2" ,libxml2)
215 ;; TODO: Add 'libxml2-python' for OpenGL ES 1.1 and 2.0 support
216 ("libxvmc" ,libxvmc)
217 ("makedepend" ,makedepend)
218 ("s2tc" ,s2tc)))
219 (native-inputs
220 `(("pkg-config" ,pkg-config)))
221 (arguments
222 `(#:configure-flags
223 '(;; drop r300 from default gallium drivers, as it requires llvm
224 "--with-gallium-drivers=r600,svga,swrast,nouveau"
225 ;; Enable various optional features. TODO: opencl requires libclc,
226 ;; omx requires libomxil-bellagio
227 "--with-egl-platforms=x11,drm"
228 "--enable-glx-tls" ;Thread Local Storage, improves performance
229 ;; "--enable-opencl"
230 ;; "--enable-omx"
231 "--enable-osmesa"
232 "--enable-xa"
233
234 ;; on non-intel systems, drop i915 and i965
235 ;; from the default dri drivers
236 ,@(match (%current-system)
237 ((or "x86_64-linux" "i686-linux")
238 '())
239 (_
240 '("--with-dri-drivers=nouveau,r200,radeon,swrast"))))
241 #:phases (alist-cons-after
242 'unpack 'patch-create_test_cases
243 (lambda _
244 (substitute* "src/glsl/tests/lower_jumps/create_test_cases.py"
245 (("/usr/bin/env bash") (which "bash"))))
246 (alist-cons-before
247 'build 'fix-dlopen-libnames
248 (lambda* (#:key inputs outputs #:allow-other-keys)
249 (let ((s2tc (assoc-ref inputs "s2tc"))
250 (udev (assoc-ref inputs "udev"))
251 (out (assoc-ref outputs "out")))
252 ;; Remain agnostic to .so.X.Y.Z versions while doing
253 ;; the substitutions so we're future-safe.
254 (substitute*
255 '("src/gallium/auxiliary/util/u_format_s3tc.c"
256 "src/mesa/main/texcompress_s3tc.c")
257 (("\"libtxc_dxtn\\.so")
258 (string-append "\"" s2tc "/lib/libtxc_dxtn.so")))
259 (substitute* "src/gallium/targets/egl-static/egl_st.c"
260 (("\"libglapi\"")
261 (string-append "\"" out "/lib/libglapi\"")))
262 (substitute* "src/loader/loader.c"
263 (("dlopen\\(\"libudev\\.so")
264 (string-append "dlopen(\"" udev "/lib/libudev.so")))
265 (substitute* "src/glx/dri_common.c"
266 (("dlopen\\(\"libGL\\.so")
267 (string-append "dlopen(\"" out "/lib/libGL.so")))
268 (substitute* "src/egl/drivers/dri2/egl_dri2.c"
269 (("\"libglapi\\.so")
270 (string-append "\"" out "/lib/libglapi.so")))
271 (substitute* "src/gbm/main/backend.c"
272 ;; No need to patch the gbm_gallium_drm.so reference;
273 ;; it's never installed since Mesa removed its
274 ;; egl_gallium support.
275 (("\"gbm_dri\\.so")
276 (string-append "\"" out "/lib/dri/gbm_dri.so")))))
277 %standard-phases))))
278 (home-page "http://mesa3d.org/")
279 (synopsis "OpenGL implementation")
280 (description "Mesa is a free implementation of the OpenGL specification -
281 a system for rendering interactive 3D graphics. A variety of device drivers
282 allows Mesa to be used in many different environments ranging from software
283 emulation to complete hardware acceleration for modern GPUs.")
284 (license l:x11)))
285
286 (define-public mesa-headers
287 (package
288 (inherit mesa)
289 (name "mesa-headers")
290 (propagated-inputs '())
291 (inputs '())
292 (native-inputs '())
293 (arguments
294 '(#:phases
295 (modify-phases %standard-phases
296 (delete 'configure)
297 (delete 'build)
298 (delete 'check)
299 (replace 'install
300 (lambda* (#:key outputs #:allow-other-keys)
301 (copy-recursively "include" (string-append
302 (assoc-ref outputs "out")
303 "/include")))))))))
304
305 ;;; The mesa-demos distribution contains non-free files, many files with no
306 ;;; clear license information, and many demos that aren't useful for most
307 ;;; people, so we just use this for the mesa-utils package below, and possibly
308 ;;; other packages in the future. This is modeled after Debian's solution.
309 (define (mesa-demos-source version)
310 (origin
311 (method url-fetch)
312 (uri (string-append "ftp://ftp.freedesktop.org/pub/mesa/demos/" version
313 "/mesa-demos-" version ".tar.bz2"))
314 (sha256 (base32 "14msj0prbl3ljwd24yaqv9pz1xzicdmqgg616xxlppbdh6syrgz4"))))
315
316 (define-public mesa-utils
317 (package
318 (name "mesa-utils")
319 (version "8.2.0")
320 (source (mesa-demos-source version))
321 (build-system gnu-build-system)
322 (inputs
323 `(("mesa" ,mesa)
324 ("glut" ,freeglut)
325 ("glew" ,glew)))
326 (native-inputs
327 `(("pkg-config" ,pkg-config)))
328 (arguments
329 '(#:phases
330 (modify-phases %standard-phases
331 (replace
332 'install
333 (lambda* (#:key outputs #:allow-other-keys)
334 (let ((out (assoc-ref outputs "out")))
335 (mkdir-p (string-append out "/bin"))
336 (for-each
337 (lambda (file)
338 (copy-file file (string-append out "/bin/" (basename file))))
339 '("src/xdemos/glxdemo" "src/xdemos/glxgears"
340 "src/xdemos/glxinfo" "src/xdemos/glxheads"))))))))
341 (home-page "http://mesa3d.org/")
342 (synopsis "Utility tools for Mesa")
343 (description
344 "The mesa-utils package contains several utility tools for Mesa: glxdemo,
345 glxgears, glxheads, and glxinfo.")
346 ;; glxdemo is public domain; others expat.
347 (license (list l:expat l:public-domain))))
348
349 (define-public glew
350 (package
351 (name "glew")
352 (version "1.11.0")
353 (source (origin
354 (method url-fetch)
355 (uri (string-append
356 "mirror://sourceforge/glew/glew-"
357 version
358 ".tgz"))
359 (sha256
360 (base32
361 "1mhkllxz49l1x680dmzrv2i82qjrq017sykah3xc90f2d8qcxfv9"))
362 (modules '((guix build utils)))
363 (snippet
364 '(substitute* "config/Makefile.linux"
365 (("= cc") "= gcc")
366 (("/lib64") "/lib")))))
367 (build-system gnu-build-system)
368 (arguments
369 '(#:phases (alist-delete 'configure %standard-phases)
370 #:make-flags (list (string-append "GLEW_PREFIX="
371 (assoc-ref %outputs "out"))
372 (string-append "GLEW_DEST="
373 (assoc-ref %outputs "out")))
374 #:tests? #f)) ;no 'check' target
375 (inputs
376 `(("libxi" ,libxi)
377 ("libxmu" ,libxmu)
378 ("libx11" ,libx11)
379 ("mesa" ,mesa)))
380
381 ;; <GL/glew.h> includes <GL/glu.h>.
382 (propagated-inputs `(("glu" ,glu)))
383
384 (home-page "http://glew.sourceforge.net/")
385 (synopsis "OpenGL extension loading library for C and C++")
386 (description
387 "The OpenGL Extension Wrangler Library (GLEW) is a C/C++ extension
388 loading library. GLEW provides efficient run-time mechanisms for determining
389 which OpenGL extensions are supported on the target platform. OpenGL core and
390 extension functionality is exposed in a single header file.")
391 (license l:bsd-3)))
392
393 (define-public guile-opengl
394 (package
395 (name "guile-opengl")
396 (version "0.1.0")
397 (source (origin
398 (method url-fetch)
399 (uri (string-append "mirror://gnu/guile-opengl/guile-opengl-"
400 version ".tar.gz"))
401 (sha256
402 (base32
403 "13qfx4xh8baryxqrv986l848ygd0piqwm6s2s90pxk9c0m9vklim"))))
404 (build-system gnu-build-system)
405 (native-inputs `(("pkg-config" ,pkg-config)))
406 (inputs `(("guile" ,guile-2.0)
407 ("mesa" ,mesa)
408 ("glu" ,glu)
409 ("freeglut" ,freeglut)))
410 (arguments
411 '(#:phases (alist-cons-before
412 'build 'patch-dynamic-link
413 (lambda* (#:key inputs outputs #:allow-other-keys)
414 (define (dynamic-link-substitute file lib input)
415 (substitute* file
416 (("dynamic-link \"lib([a-zA-Z]+)\"" _ lib)
417 (string-append "dynamic-link \""
418 (assoc-ref inputs input)
419 "/lib/lib" lib "\""))))
420 ;; Replace dynamic-link calls for libGL, libGLU, and
421 ;; libglut with absolute paths to the store.
422 (dynamic-link-substitute "glx/runtime.scm" "GL" "mesa")
423 (dynamic-link-substitute "glu/runtime.scm" "GLU" "glu")
424 (dynamic-link-substitute "glut/runtime.scm" "glut"
425 "freeglut"))
426 %standard-phases)))
427 (home-page "http://gnu.org/s/guile-opengl")
428 (synopsis "Guile binding for the OpenGL graphics API")
429 (description
430 "Guile-OpenGL is a library for Guile that provides bindings to the
431 OpenGL graphics API.")
432 (license l:lgpl3+)))
433
434 (define-public libepoxy
435 (package
436 (name "libepoxy")
437 (version "1.2")
438 (source (origin
439 (method url-fetch)
440 (uri (string-append
441 "https://github.com/anholt/libepoxy/archive/v"
442 version
443 ".tar.gz"))
444 (file-name (string-append name "-" version ".tar.gz"))
445 (sha256
446 (base32
447 "1xp8g6b7xlbym2rj4vkbl6xpb7ijq7glpv656mc7k9b01x22ihs2"))))
448 (arguments
449 `(#:phases
450 (alist-cons-after
451 'unpack 'autoreconf
452 (lambda _
453 (zero? (system* "autoreconf" "-vif")))
454 (alist-cons-before
455 'configure 'patch-paths
456 (lambda* (#:key inputs #:allow-other-keys)
457 (let ((python (assoc-ref inputs "python"))
458 (mesa (assoc-ref inputs "mesa")))
459 (substitute* "src/gen_dispatch.py"
460 (("/usr/bin/env python") python))
461 (substitute* (find-files "." "\\.[ch]$")
462 (("libGL.so.1") (string-append mesa "/lib/libGL.so.1"))
463 (("libEGL.so.1") (string-append mesa "/lib/libEGL.so.1")))
464
465 ;; XXX On armhf systems, we must add "GLIBC_2.4" to the list of
466 ;; versions in test/dlwrap.c:dlwrap_real_dlsym. It would be
467 ;; better to make this a normal patch, but for now we do it here
468 ;; to prevent rebuilding on other platforms.
469 ,@(if (string-prefix? "arm" (or (%current-target-system)
470 (%current-system)))
471 '((substitute* '"test/dlwrap.c"
472 (("\"GLIBC_2\\.0\"") "\"GLIBC_2.0\", \"GLIBC_2.4\"")))
473 '())
474 #t))
475 %standard-phases))))
476 (build-system gnu-build-system)
477 (native-inputs
478 `(("autoconf" ,autoconf)
479 ("automake" ,automake)
480 ("libtool" ,libtool)
481 ("pkg-config" ,pkg-config)
482 ("python" ,python)))
483 (inputs
484 `(("mesa" ,mesa)))
485 (home-page "http://github.com/anholt/libepoxy/")
486 (synopsis "A library for handling OpenGL function pointer management")
487 (description
488 "A library for handling OpenGL function pointer management.")
489 (license l:x11)))
490
491 (define-public soil
492 (package
493 (name "soil")
494 (version "1.0.7")
495 (source (origin
496 (method url-fetch)
497 ;; No versioned archive available.
498 (uri "http://www.lonesock.net/files/soil.zip")
499 (sha256
500 (base32
501 "00gpwp9dldzhsdhksjvmbhsd2ialraqbv6v6dpikdmpncj6mnc52"))))
502 (build-system gnu-build-system)
503 (arguments
504 '(#:tests? #f ; no tests
505 #:phases (modify-phases %standard-phases
506 (delete 'configure)
507 (add-before 'build 'init-build
508 (lambda* (#:key outputs #:allow-other-keys)
509 (let ((out (assoc-ref outputs "out")))
510 (setenv "CFLAGS" "-fPIC") ; needed for shared library
511 ;; Use alternate Makefile
512 (copy-file "projects/makefile/alternate Makefile.txt"
513 "src/Makefile")
514 (chdir "src")
515 (substitute* '("Makefile")
516 (("INCLUDEDIR = /usr/include/SOIL")
517 (string-append "INCLUDEDIR = " out "/include/SOIL"))
518 (("LIBDIR = /usr/lib")
519 (string-append "LIBDIR = " out "/lib"))
520 ;; Remove these flags from 'install' commands.
521 (("-o root -g root") ""))))))))
522 (native-inputs
523 `(("unzip" ,unzip)))
524 (inputs
525 `(("mesa" ,mesa)))
526 (home-page "http://www.lonesock.net/soil.html")
527 (synopsis "OpenGL texture loading library")
528 (description
529 "SOIL is a tiny C library used primarily for uploading textures into
530 OpenGL.")
531 (license l:public-domain)))