gnu: Add gambit-c.
[jackhill/guix/guix.git] / gnu / packages / scheme.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
4 ;;;
5 ;;; This file is part of GNU Guix.
6 ;;;
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
11 ;;;
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
16 ;;;
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20 (define-module (gnu packages scheme)
21 #:use-module (gnu packages)
22 #:use-module (guix licenses)
23 #:use-module (guix packages)
24 #:use-module (guix download)
25 #:use-module (guix utils)
26 #:use-module (guix build-system gnu)
27 #:use-module (gnu packages m4)
28 #:use-module (gnu packages multiprecision)
29 #:use-module (gnu packages databases)
30 #:use-module (gnu packages emacs)
31 #:use-module (gnu packages texinfo)
32 #:use-module (gnu packages elf)
33 #:use-module (gnu packages which)
34 #:use-module (gnu packages pkg-config)
35 #:use-module (gnu packages avahi)
36 #:use-module (gnu packages libphidget)
37 #:use-module (gnu packages glib)
38 #:use-module (gnu packages gtk)
39 #:use-module (gnu packages libffi)
40 #:use-module (gnu packages fontutils)
41 #:use-module (gnu packages image)
42 #:use-module (ice-9 match))
43
44 (define (mit-scheme-source-directory system version)
45 (string-append "mit-scheme-"
46 (if (or (string-prefix? "x86_64" system)
47 (string-prefix? "i686" system))
48 ""
49 "c-")
50 version))
51
52 (define-public mit-scheme
53 (package
54 (name "mit-scheme")
55 (version "9.2")
56 (source #f) ; see below
57 (build-system gnu-build-system)
58 (arguments
59 `(#:tests? #f ; no "check" target
60 #:phases
61 (alist-replace
62 'unpack
63 (lambda* (#:key inputs #:allow-other-keys)
64 (and (zero? (system* "tar" "xzvf"
65 (assoc-ref inputs "source")))
66 (chdir ,(mit-scheme-source-directory (%current-system)
67 version))
68 (begin
69 ;; Delete these dangling symlinks since they break
70 ;; `patch-shebangs'.
71 (for-each delete-file
72 (append '("src/lib/shim-config.scm")
73 (find-files "src/lib/lib" "\\.so$")
74 (find-files "src/lib" "^liarc-")
75 (find-files "src/compiler" "^make\\.")))
76 (chdir "src")
77 #t)))
78 (alist-replace
79 'build
80 (lambda* (#:key system outputs #:allow-other-keys)
81 (let ((out (assoc-ref outputs "out")))
82 (if (or (string-prefix? "x86_64" system)
83 (string-prefix? "i686" system))
84 (zero? (system* "make" "compile-microcode"))
85 (zero? (system* "./etc/make-liarc.sh"
86 (string-append "--prefix=" out))))))
87 %standard-phases))))
88 (inputs
89 `(;; TODO: Build doc when TeX Live is available.
90 ;; ("automake" ,automake)
91 ;; ("texlive-core" ,texlive-core)
92 ("texinfo" ,texinfo)
93 ("m4" ,m4)
94
95 ("source"
96
97 ;; MIT/GNU Scheme is not bootstrappable, so it's recommended to
98 ;; compile from the architecture-specific tarballs, which contain
99 ;; pre-built binaries. It leads to more efficient code than when
100 ;; building the tarball that contains generated C code instead of
101 ;; those binaries.
102 ,(origin
103 (method url-fetch)
104 (uri (string-append "mirror://gnu/mit-scheme/stable.pkg/"
105 version "/mit-scheme-"
106 (match (%current-system)
107 ("x86_64-linux"
108 (string-append version "-x86-64"))
109 ("i686-linux"
110 (string-append version "-i386"))
111 (_
112 (string-append "c-" version)))
113 ".tar.gz"))
114 (sha256
115 (match (%current-system)
116 ("x86_64-linux"
117 (base32
118 "1skzxxhr0iq96bf0j5m7mvf3i4sppfyfa6gpqn34mwgkw1fx8274"))
119 ("i686-linux"
120 (base32
121 "1fmlpnhf5a75db93phajh4ysbdgrgl72v45lk3kznriprl0a7jc6"))
122 (_
123 (base32
124 "0w5ib5vsidihb4hb6fma3sp596ykr8izagm57axvgd6lqzwicsjg"))))))))
125
126 ;; Fails to build on MIPS, see <http://bugs.gnu.org/18221>.
127 (supported-systems (delete "mips64el-linux" %supported-systems))
128
129 (home-page "http://www.gnu.org/software/mit-scheme/")
130 (synopsis "A Scheme implementation with integrated editor and debugger")
131 (description
132 "GNU/MIT Scheme is an implementation of the Scheme programming
133 language. It provides an interpreter, a compiler and a debugger. It also
134 features an integrated Emacs-like editor and a large runtime library.")
135 (license gpl2+)))
136
137 (define-public bigloo
138 (package
139 (name "bigloo")
140 (version "4.1a")
141 (source (origin
142 (method url-fetch)
143 (uri (string-append "ftp://ftp-sop.inria.fr/indes/fp/Bigloo/bigloo"
144 version ".tar.gz"))
145 (sha256
146 (base32
147 "170q7nh08n4v20xl81fxb0xcdxphqqacfa643hsa8i2ar6pki04c"))
148 (patches (list (search-patch "bigloo-gc-shebangs.patch")))))
149 (build-system gnu-build-system)
150 (arguments
151 `(#:test-target "test"
152 #:phases (alist-replace
153 'configure
154 (lambda* (#:key outputs #:allow-other-keys)
155
156 (substitute* "configure"
157 (("^shell=.*$")
158 (string-append "shell=" (which "bash") "\n")))
159
160 ;; Since libgc's pthread redirects are used, we end up
161 ;; using libgc symbols, so we must link against it.
162 ;; Reported on 2013-06-25.
163 (substitute* "api/pthread/src/Makefile"
164 (("^EXTRALIBS[[:blank:]]*=(.*)$" _ value)
165 (string-append "EXTRALIBS = "
166 (string-trim-right value)
167 " -l$(GCLIB)_fth-$(RELEASE)"
168 " -Wl,-rpath=" (assoc-ref outputs "out")
169 "/lib/bigloo/" ,version)))
170
171 ;; Those variables are used by libgc's `configure'.
172 (setenv "SHELL" (which "sh"))
173 (setenv "CONFIG_SHELL" (which "sh"))
174
175 ;; ... but they turned out to be overridden later, so work
176 ;; around that.
177 (substitute* (find-files "gc" "^configure-gc")
178 (("sh=/bin/sh")
179 (string-append "sh=" (which "sh"))))
180
181 ;; The `configure' script doesn't understand options
182 ;; of those of Autoconf.
183 (let ((out (assoc-ref outputs "out")))
184 (zero?
185 (system* "./configure"
186 (string-append "--prefix=" out)
187 ;; FIXME: Currently fails, see
188 ;; <http://article.gmane.org/gmane.lisp.scheme.bigloo/6126>.
189 ;; "--customgc=no" ; use our libgc
190 (string-append"--mv=" (which "mv"))
191 (string-append "--rm=" (which "rm"))))))
192 (alist-cons-after
193 'install 'install-emacs-modes
194 (lambda* (#:key outputs #:allow-other-keys)
195 (let* ((out (assoc-ref outputs "out"))
196 (dir (string-append out "/share/emacs/site-lisp")))
197 (zero? (system* "make" "-C" "bmacs" "all" "install"
198 (string-append "EMACSBRAND=emacs24")
199 (string-append "EMACSDIR=" dir)))))
200 %standard-phases))))
201 (inputs
202 `(("emacs" ,emacs)
203
204 ;; Optional APIs for which Bigloo has bindings.
205 ("avahi" ,avahi)
206 ("libphidget" ,libphidget)))
207 (native-inputs
208 `(("pkg-config" ,pkg-config)))
209 (propagated-inputs
210 `(("gmp" ,gmp))) ; bigloo.h refers to gmp.h
211 (home-page "http://www-sop.inria.fr/indes/fp/Bigloo/")
212 (synopsis "Efficient Scheme compiler")
213 (description
214 "Bigloo is a Scheme implementation devoted to one goal: enabling
215 Scheme based programming style where C(++) is usually
216 required. Bigloo attempts to make Scheme practical by offering
217 features usually presented by traditional programming languages
218 but not offered by Scheme and functional programming. Bigloo
219 compiles Scheme modules. It delivers small and fast stand alone
220 binary executables. Bigloo enables full connections between
221 Scheme and C programs and between Scheme and Java programs.")
222 (license gpl2+)))
223
224 (define-public hop
225 (package
226 (name "hop")
227 (version "2.4.0")
228 (source (origin
229 (method url-fetch)
230 (uri (string-append "ftp://ftp-sop.inria.fr/indes/fp/Hop/hop-"
231 version ".tar.gz"))
232 (sha256
233 (base32
234 "1v2r4ga58kk1sx0frn8qa8ccmjpic9csqzpk499wc95y9c4b1wy3"))
235 (patches (list (search-patch "hop-bigloo-4.0b.patch")))))
236 (build-system gnu-build-system)
237 (arguments
238 '(#:phases
239 (alist-replace
240 'configure
241 (lambda* (#:key inputs outputs #:allow-other-keys)
242 (let ((out (assoc-ref outputs "out")))
243 (zero?
244 (system* "./configure"
245 (string-append "--prefix=" out)))))
246 (alist-cons-after
247 'strip 'patch-rpath
248 (lambda* (#:key outputs #:allow-other-keys)
249 ;; Patch the RPATH of every installed library to point to $out/lib
250 ;; instead of $TMPDIR. Note that "patchelf --set-rpath" produces
251 ;; invalid binaries when used before stripping.
252 (let ((out (assoc-ref outputs "out"))
253 (tmpdir (getcwd)))
254 (every (lambda (lib)
255 (let* ((in (open-pipe* OPEN_READ "patchelf"
256 "--print-rpath" lib))
257 (rpath (read-line in)))
258 (and (zero? (close-pipe in))
259 (let ((rpath* (regexp-substitute/global
260 #f (regexp-quote tmpdir) rpath
261 'pre out 'post)))
262 (or (equal? rpath rpath*)
263 (begin
264 (format #t "~a: changing RPATH from `~a' to `~a'~%"
265 lib rpath rpath*)
266 (zero?
267 (system* "patchelf" "--set-rpath"
268 rpath* lib))))))))
269 (append (find-files (string-append out "/bin")
270 ".*")
271 (find-files (string-append out "/lib")
272 "\\.so$")))))
273 %standard-phases))
274 #:tests? #f ; no test suite
275 #:modules ((guix build gnu-build-system)
276 (guix build utils)
277 (ice-9 popen)
278 (ice-9 regex)
279 (ice-9 rdelim)
280 (srfi srfi-1))))
281 (inputs `(("bigloo" ,bigloo)
282 ("which" ,which)
283 ("patchelf" ,patchelf)))
284 (home-page "http://hop.inria.fr/")
285 (synopsis "Multi-tier programming language for the Web 2.0")
286 (description
287 "HOP is a multi-tier programming language for the Web 2.0 and the
288 so-called diffuse Web. It is designed for programming interactive web
289 applications in many fields such as multimedia (web galleries, music players,
290 ...), ubiquitous and house automation (SmartPhones, personal appliance),
291 mashups, office (web agendas, mail clients, ...), etc.")
292 (license gpl2+)))
293
294 (define-public chicken
295 (package
296 (name "chicken")
297 (version "4.9.0.1")
298 (source (origin
299 (method url-fetch)
300 (uri (string-append "http://code.call-cc.org/releases/4.9.0/chicken-"
301 version ".tar.gz"))
302 (sha256
303 (base32
304 "0598mar1qswfd8hva9nqs88zjn02lzkqd8fzdd21dz1nki1prpq4"))))
305 (build-system gnu-build-system)
306 (arguments
307 `(#:modules ((guix build gnu-build-system)
308 (guix build utils)
309 (srfi srfi-1))
310
311 ;; No `configure' script; run "make check" after "make install" as
312 ;; prescribed by README.
313 #:phases (alist-cons-after
314 'install 'check
315 (assoc-ref %standard-phases 'check)
316 (fold alist-delete %standard-phases
317 '(configure check)))
318
319 #:make-flags (let ((out (assoc-ref %outputs "out")))
320 (list "PLATFORM=linux"
321 (string-append "PREFIX=" out)
322 (string-append "VARDIR=" out "/var/lib")))
323
324 ;; Parallel builds are not supported, as noted in README.
325 #:parallel-build? #f))
326 (home-page "http://www.call-cc.org/")
327 (synopsis "R5RS Scheme implementation that compiles native code via C")
328 (description
329 "CHICKEN is a compiler for the Scheme programming language. CHICKEN
330 produces portable and efficient C, supports almost all of the R5RS Scheme
331 language standard, and includes many enhancements and extensions.")
332 (license bsd-3)))
333
334 (define-public scheme48
335 (package
336 (name "scheme48")
337 (version "1.9")
338 (source (origin
339 (method url-fetch)
340 (uri (string-append "http://s48.org/" version
341 "/scheme48-" version ".tgz"))
342 (sha256
343 (base32
344 "0rw2lz5xgld0klvld292ds6hvfk5l12vskzgf1hhwjdpa38r3fnw"))
345 (patches (list (search-patch "scheme48-tests.patch")))))
346 (build-system gnu-build-system)
347 (home-page "http://s48.org/")
348 (synopsis "Scheme implementation using a bytecode interpreter")
349 (description
350 "Scheme 48 is an implementation of Scheme based on a byte-code
351 interpreter and is designed to be used as a testbed for experiments in
352 implementation techniques and as an expository tool.")
353
354 ;; Most files are BSD-3; see COPYING for the few exceptions.
355 (license bsd-3)))
356
357 (define-public racket
358 (package
359 (name "racket")
360 (version "6.1.1")
361 (source (origin
362 (method url-fetch)
363 (uri (list (string-append "http://mirror.racket-lang.org/installers/"
364 version "/racket-" version "-src.tgz")
365 (string-append
366 "http://mirror.informatik.uni-tuebingen.de/mirror/racket/"
367 version "/racket/racket-" version "-src-unix.tgz")))
368 (sha256
369 (base32
370 "0xfsfdqkngz0xw2lqmc7bsznwx25cw91l9fjhp7abrr05m96j0h9"))))
371 (build-system gnu-build-system)
372 (arguments
373 '(#:phases
374 (let* ((gui-libs
375 (lambda (inputs)
376 (define (lib input)
377 (string-append (assoc-ref inputs input) "/lib"))
378
379 (list (lib "glib")
380 (lib "cairo")
381 (lib "pango")
382 (lib "libjpeg")
383 (lib "gtk")
384 (lib "gdk-pixbuf")
385 (lib "fontconfig")
386 (lib "sqlite"))))) ;to build the doc
387 (alist-cons-before
388 'configure 'pre-configure
389 (lambda* (#:key inputs #:allow-other-keys)
390 (chdir "src")
391
392 ;; The GUI libs are dynamically opened through the FFI, so they
393 ;; must be in the loader's search path.
394 (setenv "LD_LIBRARY_PATH" (string-join (gui-libs inputs) ":")))
395 (alist-cons-after
396 'unpack 'patch-/bin/sh
397 (lambda _
398 (substitute* "collects/racket/system.rkt"
399 (("/bin/sh") (which "sh"))))
400 (alist-cons-after
401 'install 'wrap-programs
402 (lambda* (#:key inputs outputs #:allow-other-keys)
403 (let ((out (assoc-ref outputs "out")))
404 (define (wrap prog)
405 (wrap-program prog
406 `("LD_LIBRARY_PATH" ":" prefix
407 ,(gui-libs inputs))))
408
409 (with-directory-excursion (string-append out "/bin")
410 (for-each wrap
411 (list "gracket" "drracket" "slideshow" "mred"))
412 #t)))
413 %standard-phases))))
414 #:tests? #f ; XXX: how to run them?
415 ))
416 (inputs `(("libffi" ,libffi)
417 ("glib" ,glib) ; for DrRacket
418 ("cairo" ,cairo)
419 ("pango" ,pango)
420 ("libjpeg" ,libjpeg-8)
421 ("fontconfig" ,fontconfig)
422 ("gdk-pixbuf" ,gdk-pixbuf)
423 ("gtk" ,gtk+-2)
424 ("sqlite" ,sqlite))) ;needed to build the doc
425 (home-page "http://racket-lang.org")
426 (synopsis "Implementation of Scheme and related languages")
427 (description
428 "Racket is an implementation of the Scheme programming language (R5RS and
429 R6RS) and related languages, such as Typed Racket. It features a compiler and
430 a virtual machine with just-in-time native compilation, as well as a large set
431 of libraries.")
432 (license lgpl2.0+)))
433
434 (define-public gambit-c
435 (package
436 (name "gambit-c")
437 (version "4.7.4")
438 (source
439 (origin
440 (method url-fetch)
441 (uri (string-append
442 "http://www.iro.umontreal.ca/~gambit/download/gambit/v"
443 (version-major+minor version) "/source/gambc-v"
444 (string-map (lambda (c) (if (char=? c #\.) #\_ c)) version)
445 ".tgz"))
446 (sha256
447 (base32 "0y2pklh4k65yrmxv63ass76xckrk9wqimbdad2gha35v2mi7blhs"))))
448 (build-system gnu-build-system)
449 (arguments
450 '(#:configure-flags
451 ;; According to the ./configure script, this makes the build slower and
452 ;; use >= 1 GB memory, but makes Gambit much faster.
453 '("--enable-single-host")
454 #:phases
455 (alist-cons-before
456 'check 'fix-tests
457 (lambda _
458 (substitute* '("tests/makefile")
459 ;; '-:' is how run-time options are set. 'tl' sets some terminal
460 ;; option, which makes it fail in our build environment. It
461 ;; recommends using 'd-' as a solution, which sets the REPL
462 ;; interaction channel to stdin/stdout.
463 (("gsi -:tl") "gsi -:d-,tl")))
464 %standard-phases)))
465 (home-page "http://www.iro.umontreal.ca/~gambit/")
466 (synopsis "Efficient Scheme interpreter and compiler")
467 (description
468 "Gambit consists of two main programs: gsi, the Gambit Scheme
469 interpreter, and gsc, the Gambit Scheme compiler. The interpreter contains
470 the complete execution and debugging environment. The compiler is the
471 interpreter extended with the capability of generating executable files. The
472 compiler can produce standalone executables or compiled modules which can be
473 loaded at run time. Interpreted code and compiled code can be freely
474 mixed.")
475 ;; Dual license.
476 (license (list lgpl2.1+ asl2.0))))