Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / scheme.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
4 ;;; Copyright © 2015, 2016 Federico Beffa <beffa@fbengineering.ch>
5 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
6 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
8 ;;;
9 ;;; This file is part of GNU Guix.
10 ;;;
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
15 ;;;
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
20 ;;;
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24 (define-module (gnu packages scheme)
25 #:use-module (gnu packages)
26 #:use-module ((guix licenses)
27 #:select (gpl2+ lgpl2.0+ lgpl2.1+ asl2.0 bsd-3
28 cc-by-sa4.0))
29 #:use-module (guix packages)
30 #:use-module (guix download)
31 #:use-module (guix git-download)
32 #:use-module (guix utils)
33 #:use-module (guix build-system gnu)
34 #:use-module (guix build-system trivial)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages m4)
37 #:use-module (gnu packages multiprecision)
38 #:use-module (gnu packages ncurses)
39 #:use-module (gnu packages databases)
40 #:use-module (gnu packages emacs)
41 #:use-module (gnu packages ghostscript)
42 #:use-module (gnu packages netpbm)
43 #:use-module (gnu packages texinfo)
44 #:use-module (gnu packages tex)
45 #:use-module (gnu packages base)
46 #:use-module (gnu packages compression)
47 #:use-module (gnu packages pkg-config)
48 #:use-module (gnu packages avahi)
49 #:use-module (gnu packages libphidget)
50 #:use-module (gnu packages gcc)
51 #:use-module (gnu packages glib)
52 #:use-module (gnu packages gtk)
53 #:use-module (gnu packages libffi)
54 #:use-module (gnu packages fontutils)
55 #:use-module (gnu packages image)
56 #:use-module (gnu packages xorg)
57 #:use-module (gnu packages tls)
58 #:use-module (gnu packages gl)
59 #:use-module (ice-9 match))
60
61 (define (mit-scheme-source-directory system version)
62 (string-append "mit-scheme-"
63 (if (or (string-prefix? "x86_64" system)
64 (string-prefix? "i686" system))
65 ""
66 "c-")
67 version))
68
69 (define-public mit-scheme
70 (package
71 (name "mit-scheme")
72 (version "9.2")
73 (source #f) ; see below
74 (outputs '("out" "doc"))
75 (build-system gnu-build-system)
76 (arguments
77 `(#:tests? #f ; no "check" target
78 #:modules ((guix build gnu-build-system)
79 (guix build utils)
80 (srfi srfi-1))
81 #:phases
82 (modify-phases %standard-phases
83 (replace 'unpack
84 (lambda* (#:key inputs #:allow-other-keys)
85 (and (zero? (system* "tar" "xzvf"
86 (assoc-ref inputs "source")))
87 (chdir ,(mit-scheme-source-directory (%current-system)
88 version))
89 (begin
90 ;; Delete these dangling symlinks since they break
91 ;; `patch-shebangs'.
92 (for-each delete-file
93 (append '("src/lib/shim-config.scm")
94 (find-files "src/lib/lib" "\\.so$")
95 (find-files "src/lib" "^liarc-")
96 (find-files "src/compiler" "^make\\.")))
97 (chdir "src")
98 #t))))
99 (replace 'build
100 (lambda* (#:key system outputs #:allow-other-keys)
101 (let ((out (assoc-ref outputs "out")))
102 (if (or (string-prefix? "x86_64" system)
103 (string-prefix? "i686" system))
104 (zero? (system* "make" "compile-microcode"))
105 (zero? (system* "./etc/make-liarc.sh"
106 (string-append "--prefix=" out)))))))
107 (add-after 'configure 'configure-doc
108 (lambda* (#:key outputs inputs #:allow-other-keys)
109 (with-directory-excursion "../doc"
110 (let* ((out (assoc-ref outputs "out"))
111 (bash (assoc-ref inputs "bash"))
112 (bin/sh (string-append bash "/bin/sh")))
113 (system* bin/sh "./configure"
114 (string-append "--prefix=" out)
115 (string-append "SHELL=" bin/sh))
116 (substitute* '("Makefile" "make-common")
117 (("/lib/mit-scheme/doc")
118 (string-append "/share/doc/" ,name "-" ,version)))
119 #t))))
120 (add-after 'build 'build-doc
121 (lambda* _
122 (with-directory-excursion "../doc"
123 (zero? (system* "make")))))
124 (add-after 'install 'install-doc
125 (lambda* (#:key outputs #:allow-other-keys)
126 (let* ((out (assoc-ref outputs "out"))
127 (doc (assoc-ref outputs "doc"))
128 (old-doc-dir (string-append out "/share/doc"))
129 (new-doc/mit-scheme-dir
130 (string-append doc "/share/doc/" ,name "-" ,version)))
131 (with-directory-excursion "../doc"
132 (for-each (lambda (target)
133 (system* "make" target))
134 '("install-config" "install-info-gz" "install-man"
135 "install-html" "install-pdf")))
136 (mkdir-p new-doc/mit-scheme-dir)
137 (copy-recursively
138 (string-append old-doc-dir "/" ,name "-" ,version)
139 new-doc/mit-scheme-dir)
140 (delete-file-recursively old-doc-dir)
141 #t))))))
142 (native-inputs
143 `(("texlive" ,texlive)
144 ("texinfo" ,texinfo)
145 ("m4" ,m4)))
146 (inputs
147 `(("libx11" ,libx11)
148
149 ("source"
150
151 ;; MIT/GNU Scheme is not bootstrappable, so it's recommended to
152 ;; compile from the architecture-specific tarballs, which contain
153 ;; pre-built binaries. It leads to more efficient code than when
154 ;; building the tarball that contains generated C code instead of
155 ;; those binaries.
156 ,(origin
157 (method url-fetch)
158 (uri (string-append "mirror://gnu/mit-scheme/stable.pkg/"
159 version "/mit-scheme-"
160 (match (%current-system)
161 ("x86_64-linux"
162 (string-append version "-x86-64"))
163 ("i686-linux"
164 (string-append version "-i386"))
165 (_
166 (string-append "c-" version)))
167 ".tar.gz"))
168 (sha256
169 (match (%current-system)
170 ("x86_64-linux"
171 (base32
172 "1skzxxhr0iq96bf0j5m7mvf3i4sppfyfa6gpqn34mwgkw1fx8274"))
173 ("i686-linux"
174 (base32
175 "1fmlpnhf5a75db93phajh4ysbdgrgl72v45lk3kznriprl0a7jc6"))
176 (_
177 (base32
178 "0w5ib5vsidihb4hb6fma3sp596ykr8izagm57axvgd6lqzwicsjg"))))))))
179
180 ;; Fails to build on MIPS, see <http://bugs.gnu.org/18221>.
181 (supported-systems (delete "mips64el-linux" %supported-systems))
182
183 (home-page "http://www.gnu.org/software/mit-scheme/")
184 (synopsis "A Scheme implementation with integrated editor and debugger")
185 (description
186 "GNU/MIT Scheme is an implementation of the Scheme programming
187 language. It provides an interpreter, a compiler and a debugger. It also
188 features an integrated Emacs-like editor and a large runtime library.")
189 (license gpl2+)
190 (properties '((ftp-directory . "/gnu/mit-scheme/stable.pkg")))))
191
192 (define-public bigloo
193 (package
194 (name "bigloo")
195 (version "4.1a")
196 (source (origin
197 (method url-fetch)
198 (uri (string-append "ftp://ftp-sop.inria.fr/indes/fp/Bigloo/bigloo"
199 version ".tar.gz"))
200 (sha256
201 (base32
202 "170q7nh08n4v20xl81fxb0xcdxphqqacfa643hsa8i2ar6pki04c"))
203 (patches (search-patches "bigloo-gc-shebangs.patch"))))
204 (build-system gnu-build-system)
205 (arguments
206 `(#:test-target "test"
207 #:phases (alist-replace
208 'configure
209 (lambda* (#:key outputs #:allow-other-keys)
210
211 (substitute* "configure"
212 (("^shell=.*$")
213 (string-append "shell=" (which "bash") "\n")))
214
215 ;; Since libgc's pthread redirects are used, we end up
216 ;; using libgc symbols, so we must link against it.
217 ;; Reported on 2013-06-25.
218 (substitute* "api/pthread/src/Makefile"
219 (("^EXTRALIBS[[:blank:]]*=(.*)$" _ value)
220 (string-append "EXTRALIBS = "
221 (string-trim-right value)
222 " -l$(GCLIB)_fth-$(RELEASE)"
223 " -Wl,-rpath=" (assoc-ref outputs "out")
224 "/lib/bigloo/" ,version)))
225
226 ;; Those variables are used by libgc's `configure'.
227 (setenv "SHELL" (which "sh"))
228 (setenv "CONFIG_SHELL" (which "sh"))
229
230 ;; ... but they turned out to be overridden later, so work
231 ;; around that.
232 (substitute* (find-files "gc" "^configure-gc")
233 (("sh=/bin/sh")
234 (string-append "sh=" (which "sh"))))
235
236 ;; The `configure' script doesn't understand options
237 ;; of those of Autoconf.
238 (let ((out (assoc-ref outputs "out")))
239 (zero?
240 (system* "./configure"
241 (string-append "--prefix=" out)
242 ;; FIXME: Currently fails, see
243 ;; <http://article.gmane.org/gmane.lisp.scheme.bigloo/6126>.
244 ;; "--customgc=no" ; use our libgc
245 (string-append"--mv=" (which "mv"))
246 (string-append "--rm=" (which "rm"))
247 (string-append "--ldflags=-Wl,-rpath="
248 (assoc-ref outputs "out")
249 "/lib/bigloo/" ,version)))))
250 (alist-cons-after
251 'install 'install-emacs-modes
252 (lambda* (#:key outputs #:allow-other-keys)
253 (let* ((out (assoc-ref outputs "out"))
254 (dir (string-append out "/share/emacs/site-lisp")))
255 (zero? (system* "make" "-C" "bmacs" "all" "install"
256 (string-append "EMACSBRAND=emacs24")
257 (string-append "EMACSDIR=" dir)))))
258 %standard-phases))))
259 (inputs
260 `(("emacs" ,emacs) ;UDE needs the X version of Emacs
261
262 ;; Optional APIs for which Bigloo has bindings.
263 ("avahi" ,avahi)
264 ("libphidget" ,libphidget)))
265 (native-inputs
266 `(("pkg-config" ,pkg-config)))
267 (propagated-inputs
268 `(("gmp" ,gmp))) ; bigloo.h refers to gmp.h
269 (home-page "http://www-sop.inria.fr/indes/fp/Bigloo/")
270 (synopsis "Efficient Scheme compiler")
271 (description
272 "Bigloo is a Scheme implementation devoted to one goal: enabling
273 Scheme based programming style where C(++) is usually
274 required. Bigloo attempts to make Scheme practical by offering
275 features usually presented by traditional programming languages
276 but not offered by Scheme and functional programming. Bigloo
277 compiles Scheme modules. It delivers small and fast stand alone
278 binary executables. Bigloo enables full connections between
279 Scheme and C programs and between Scheme and Java programs.")
280 (license gpl2+)))
281
282 (define-public hop
283 (package
284 (name "hop")
285 (version "2.4.0")
286 (source (origin
287 (method url-fetch)
288 (uri (string-append "ftp://ftp-sop.inria.fr/indes/fp/Hop/hop-"
289 version ".tar.gz"))
290 (sha256
291 (base32
292 "1v2r4ga58kk1sx0frn8qa8ccmjpic9csqzpk499wc95y9c4b1wy3"))
293 (patches (search-patches "hop-bigloo-4.0b.patch"
294 "hop-linker-flags.patch"))))
295 (build-system gnu-build-system)
296 (arguments
297 `(#:phases
298 (alist-replace
299 'configure
300 (lambda* (#:key outputs #:allow-other-keys)
301 (let ((out (assoc-ref outputs "out")))
302 (zero?
303 (system* "./configure"
304 (string-append "--prefix=" out)
305 (string-append "--blflags="
306 ;; user flags completely override useful
307 ;; default flags, so repeat them here.
308 "-copt \\$(CPICFLAGS) -L\\$(BUILDLIBDIR) "
309 "-ldopt -Wl,-rpath," out "/lib")))))
310 %standard-phases)
311 #:tests? #f)) ; no test suite
312 (inputs `(("avahi" ,avahi)
313 ("bigloo" ,bigloo)
314 ("which" ,which)))
315 (home-page "http://hop.inria.fr/")
316 (synopsis "Multi-tier programming language for the Web 2.0")
317 (description
318 "HOP is a multi-tier programming language for the Web 2.0 and the
319 so-called diffuse Web. It is designed for programming interactive web
320 applications in many fields such as multimedia (web galleries, music players,
321 ...), ubiquitous and house automation (SmartPhones, personal appliance),
322 mashups, office (web agendas, mail clients, ...), etc.")
323 (license gpl2+)))
324
325 (define-public chicken
326 (package
327 (name "chicken")
328 (version "4.11.0")
329 (source (origin
330 (method url-fetch)
331 (uri (string-append "http://code.call-cc.org/releases/"
332 version "/chicken-" version ".tar.gz"))
333 (sha256
334 (base32
335 "12ddyiikqknpr8h6llsxbg2fz75xnayvcnsvr1cwv8xnjn7jpp73"))))
336 (build-system gnu-build-system)
337 (arguments
338 `(#:modules ((guix build gnu-build-system)
339 (guix build utils)
340 (srfi srfi-1))
341
342 ;; No `configure' script; run "make check" after "make install" as
343 ;; prescribed by README.
344 #:phases
345 (modify-phases %standard-phases
346 (delete 'configure)
347 (delete 'check)
348 (add-after 'install 'check
349 (assoc-ref %standard-phases 'check))
350 (add-after 'unpack 'disable-broken-tests
351 (lambda _
352 ;; The port tests fail with this error:
353 ;; Error: (line 294) invalid escape-sequence '\x o'
354 (substitute* "tests/runtests.sh"
355 (("\\$interpret -s port-tests\\.scm") ""))
356 #t)))
357
358 #:make-flags (let ((out (assoc-ref %outputs "out")))
359 (list "PLATFORM=linux"
360 (string-append "PREFIX=" out)
361 (string-append "VARDIR=" out "/var/lib")))
362
363 ;; Parallel builds are not supported, as noted in README.
364 #:parallel-build? #f))
365 ;; One of the tests ("testing direct invocation can detect calls of too
366 ;; many arguments...") times out when building with a more recent GCC.
367 ;; The problem was reported here:
368 ;; https://lists.gnu.org/archive/html/chicken-hackers/2015-04/msg00059.html
369 (native-inputs
370 `(("gcc" ,gcc-4.8)))
371 (home-page "http://www.call-cc.org/")
372 (synopsis "R5RS Scheme implementation that compiles native code via C")
373 (description
374 "CHICKEN is a compiler for the Scheme programming language. CHICKEN
375 produces portable and efficient C, supports almost all of the R5RS Scheme
376 language standard, and includes many enhancements and extensions.")
377 (license bsd-3)))
378
379 (define-public scheme48
380 (package
381 (name "scheme48")
382 (version "1.9.2")
383 (source (origin
384 (method url-fetch)
385 (uri (string-append "http://s48.org/" version
386 "/scheme48-" version ".tgz"))
387 (sha256
388 (base32
389 "1x4xfm3lyz2piqcw1h01vbs1iq89zq7wrsfjgh3fxnlm1slj2jcw"))
390 (patches (search-patches "scheme48-tests.patch"))))
391 (build-system gnu-build-system)
392 (home-page "http://s48.org/")
393 (synopsis "Scheme implementation using a bytecode interpreter")
394 (description
395 "Scheme 48 is an implementation of Scheme based on a byte-code
396 interpreter and is designed to be used as a testbed for experiments in
397 implementation techniques and as an expository tool.")
398
399 ;; Most files are BSD-3; see COPYING for the few exceptions.
400 (license bsd-3)))
401
402 (define-public racket
403 (package
404 (name "racket")
405 (version "6.5")
406 (source (origin
407 (method url-fetch)
408 (uri (list (string-append "http://mirror.racket-lang.org/installers/"
409 version "/racket-" version "-src.tgz")
410 (string-append
411 "http://mirror.informatik.uni-tuebingen.de/mirror/racket/"
412 version "/racket/racket-" version "-src-unix.tgz")))
413 (sha256
414 (base32
415 "0gvh7i5k87mg1gpqk8gaq50ja9ksbhnvdqn7qqh0n17byidd6999"))))
416 (build-system gnu-build-system)
417 (arguments
418 '(#:phases
419 (alist-cons-before
420 'configure 'pre-configure
421 (lambda* (#:key inputs #:allow-other-keys)
422 ;; Patch dynamically loaded libraries with their absolute paths.
423 (let* ((library-path (search-path-as-string->list
424 (getenv "LIBRARY_PATH")))
425 (find-so (lambda (soname)
426 (search-path
427 library-path
428 (format #f "~a.so" soname))))
429 (patch-ffi-libs (lambda (file libs)
430 (for-each
431 (lambda (lib)
432 (substitute* file
433 (((format #f "\"~a\"" lib))
434 (format #f "\"~a\"" (find-so lib)))))
435 libs))))
436 (substitute* "collects/db/private/sqlite3/ffi.rkt"
437 (("ffi-lib sqlite-so")
438 (format #f "ffi-lib \"~a\"" (find-so "libsqlite3"))))
439 (substitute* "collects/openssl/libssl.rkt"
440 (("ffi-lib libssl-so")
441 (format #f "ffi-lib \"~a\"" (find-so "libssl"))))
442 (substitute* "collects/openssl/libcrypto.rkt"
443 (("ffi-lib libcrypto-so")
444 (format #f "ffi-lib \"~a\"" (find-so "libcrypto"))))
445 (substitute* "share/pkgs/math-lib/math/private/bigfloat/gmp.rkt"
446 (("ffi-lib libgmp-so")
447 (format #f "ffi-lib \"~a\"" (find-so "libgmp"))))
448 (substitute* "share/pkgs/math-lib/math/private/bigfloat/mpfr.rkt"
449 (("ffi-lib libmpfr-so")
450 (format #f "ffi-lib \"~a\"" (find-so "libmpfr"))))
451 (for-each
452 (lambda (x) (apply patch-ffi-libs x))
453 '(("share/pkgs/draw-lib/racket/draw/unsafe/cairo-lib.rkt"
454 ("libfontconfig" "libcairo"))
455 ("share/pkgs/draw-lib/racket/draw/unsafe/glib.rkt"
456 ("libglib-2.0" "libgmodule-2.0" "libgobject-2.0"))
457 ("share/pkgs/draw-lib/racket/draw/unsafe/jpeg.rkt"
458 ("libjpeg"))
459 ("share/pkgs/draw-lib/racket/draw/unsafe/pango.rkt"
460 ("libpango-1.0" "libpangocairo-1.0"))
461 ("share/pkgs/draw-lib/racket/draw/unsafe/png.rkt"
462 ("libpng"))
463 ("share/pkgs/db-lib/db/private/odbc/ffi.rkt"
464 ("libodbc"))
465 ("share/pkgs/gui-lib/mred/private/wx/gtk/x11.rkt"
466 ("libX11"))
467 ("share/pkgs/gui-lib/mred/private/wx/gtk/gsettings.rkt"
468 ("libgio-2.0"))
469 ("share/pkgs/gui-lib/mred/private/wx/gtk/gtk3.rkt"
470 ("libgdk-3" "libgtk-3"))
471 ("share/pkgs/gui-lib/mred/private/wx/gtk/unique.rkt"
472 ("libunique-1.0"))
473 ("share/pkgs/gui-lib/mred/private/wx/gtk/utils.rkt"
474 ("libgdk-x11-2.0" "libgdk_pixbuf-2.0" "libgtk-x11-2.0"))
475 ("share/pkgs/gui-lib/mred/private/wx/gtk/gl-context.rkt"
476 ("libGL"))
477 ("share/pkgs/sgl/gl.rkt"
478 ("libGL" "libGLU")))))
479 (chdir "src"))
480 (alist-cons-after
481 'unpack 'patch-/bin/sh
482 (lambda _
483 (substitute* "collects/racket/system.rkt"
484 (("/bin/sh") (which "sh"))))
485 %standard-phases))
486 #:tests? #f ; XXX: how to run them?
487 ))
488 (inputs
489 `(("libffi" ,libffi)
490 ;; Hardcode dynamically loaded libraries for better functionality.
491 ;; sqlite and libraries for `racket/draw' are needed to build the doc.
492 ("cairo" ,cairo)
493 ("fontconfig" ,fontconfig)
494 ("glib" ,glib)
495 ("glu" ,glu)
496 ("gmp" ,gmp)
497 ("gtk+" ,gtk+) ; propagates gdk-pixbuf+svg
498 ("libjpeg" ,libjpeg)
499 ("libpng" ,libpng)
500 ("libx11" ,libx11)
501 ("mesa" ,mesa)
502 ("mpfr" ,mpfr)
503 ("openssl" ,openssl)
504 ("pango" ,pango)
505 ("sqlite" ,sqlite)
506 ("unixodbc" ,unixodbc)))
507 (home-page "http://racket-lang.org")
508 (synopsis "Implementation of Scheme and related languages")
509 (description
510 "Racket is an implementation of the Scheme programming language (R5RS and
511 R6RS) and related languages, such as Typed Racket. It features a compiler and
512 a virtual machine with just-in-time native compilation, as well as a large set
513 of libraries.")
514 (license lgpl2.0+)))
515
516 (define-public gambit-c
517 (package
518 (name "gambit-c")
519 (version "4.7.4")
520 (source
521 (origin
522 (method url-fetch)
523 (uri (string-append
524 "http://www.iro.umontreal.ca/~gambit/download/gambit/v"
525 (version-major+minor version) "/source/gambc-v"
526 (string-map (lambda (c) (if (char=? c #\.) #\_ c)) version)
527 ".tgz"))
528 (sha256
529 (base32 "0y2pklh4k65yrmxv63ass76xckrk9wqimbdad2gha35v2mi7blhs"))))
530 (build-system gnu-build-system)
531 (arguments
532 '(#:configure-flags
533 ;; According to the ./configure script, this makes the build slower and
534 ;; use >= 1 GB memory, but makes Gambit much faster.
535 '("--enable-single-host")
536 #:phases
537 (alist-cons-before
538 'check 'fix-tests
539 (lambda _
540 (substitute* '("tests/makefile")
541 ;; '-:' is how run-time options are set. 'tl' sets some terminal
542 ;; option, which makes it fail in our build environment. It
543 ;; recommends using 'd-' as a solution, which sets the REPL
544 ;; interaction channel to stdin/stdout.
545 (("gsi -:tl") "gsi -:d-,tl")))
546 %standard-phases)))
547 (home-page "http://www.iro.umontreal.ca/~gambit/")
548 (synopsis "Efficient Scheme interpreter and compiler")
549 (description
550 "Gambit consists of two main programs: gsi, the Gambit Scheme
551 interpreter, and gsc, the Gambit Scheme compiler. The interpreter contains
552 the complete execution and debugging environment. The compiler is the
553 interpreter extended with the capability of generating executable files. The
554 compiler can produce standalone executables or compiled modules which can be
555 loaded at run time. Interpreted code and compiled code can be freely
556 mixed.")
557 ;; Dual license.
558 (license (list lgpl2.1+ asl2.0))))
559
560 (define-public chibi-scheme
561 (package
562 (name "chibi-scheme")
563 (version "0.7.3")
564 (source
565 (origin
566 (method url-fetch)
567 (uri (string-append "https://github.com/ashinn/chibi-scheme/archive/"
568 version ".tar.gz"))
569 (sha256
570 (base32 "16wppf4qzr0748iyp0m89gidsfgq9s6x3gw4xggym91waw4fh742"))
571 (file-name (string-append "chibi-scheme-" version ".tar.gz"))))
572 (build-system gnu-build-system)
573 (arguments
574 `(#:phases
575 (alist-delete
576 'configure
577 (alist-cons-before
578 'build 'set-cc
579 (lambda _
580 (setenv "CC" "gcc"))
581 %standard-phases))
582 #:make-flags (let ((out (assoc-ref %outputs "out")))
583 (list (string-append "PREFIX=" out)
584 (string-append "LDFLAGS=-Wl,-rpath=" out "/lib")))
585 #:test-target "test"))
586 (home-page "https://code.google.com/p/chibi-scheme/")
587 (synopsis "Small embeddable Scheme implementation")
588 (description
589 "Chibi-Scheme is a very small library with no external dependencies
590 intended for use as an extension and scripting language in C programs. In
591 addition to support for lightweight VM-based threads, each VM itself runs in
592 an isolated heap allowing multiple VMs to run simultaneously in different OS
593 threads.")
594 (license bsd-3)))
595
596 (define nanopass
597 (let ((version "1.9"))
598 (origin
599 (method url-fetch)
600 (uri (string-append
601 "https://github.com/nanopass/nanopass-framework-scheme/archive"
602 "/v" version ".tar.gz"))
603 (sha256 (base32 "11pwyy4jiwhcl2am3a4ciczacjbjkyvdizqzdglb3l1hj2gj6nv2"))
604 (file-name (string-append "nanopass-" version ".tar.gz")))))
605
606 (define stex
607 (let ((version "1.2.1"))
608 (origin
609 (method url-fetch)
610 (uri (string-append
611 "https://github.com/dybvig/stex/archive"
612 "/v" version ".tar.gz"))
613 (sha256 (base32 "03pl3f668h24dn51vccr1sj5lsba9zq3j37bnxjvdadcdaj4qy5z"))
614 (file-name (string-append "stex-" version ".tar.gz")))))
615
616 (define-public chez-scheme
617 (package
618 (name "chez-scheme")
619 (version "9.4")
620 (source
621 (origin
622 (method url-fetch)
623 (uri (string-append "https://github.com/cisco/ChezScheme/archive/"
624 "v" version ".tar.gz"))
625 (sha256
626 (base32 "0lprmpsjg2plc6ykgkz482zyvhkzv6gd0vnar71ph21h6zknyklz"))
627 (file-name (string-append "chez-scheme-" version ".tar.gz"))))
628 (build-system gnu-build-system)
629 (inputs
630 `(("ncurses" ,ncurses)
631 ("libx11" ,libx11)
632 ("xorg-rgb" ,xorg-rgb)
633 ("nanopass" ,nanopass)
634 ("zlib" ,zlib)
635 ("stex" ,stex)))
636 (native-inputs
637 `(("texlive" ,texlive)
638 ("ghostscript" ,ghostscript-gs)
639 ("netpbm" ,netpbm)))
640 (outputs '("out" "doc"))
641 (arguments
642 `(#:modules ((guix build gnu-build-system)
643 (guix build utils)
644 (ice-9 match))
645 #:test-target "test"
646 #:phases
647 (modify-phases %standard-phases
648 ;; Adapt the custom 'configure' script.
649 (replace 'configure
650 (lambda* (#:key inputs outputs #:allow-other-keys)
651 (let ((out (assoc-ref outputs "out"))
652 (nanopass (assoc-ref inputs "nanopass"))
653 (stex (assoc-ref inputs "stex"))
654 (zlib (assoc-ref inputs "zlib"))
655 (unpack (assoc-ref %standard-phases 'unpack))
656 (patch-source-shebangs
657 (assoc-ref %standard-phases 'patch-source-shebangs)))
658 (map (match-lambda
659 ((src orig-name new-name)
660 (with-directory-excursion "."
661 (apply unpack (list #:source src))
662 (apply patch-source-shebangs (list #:source src)))
663 (delete-file-recursively new-name)
664 (system* "mv" orig-name new-name)))
665 `((,nanopass "nanopass-framework-scheme-1.9" "nanopass")
666 (,stex "stex-1.2.1" "stex")))
667 ;; The Makefile wants to download and compile "zlib". We patch
668 ;; it to use the one from our 'zlib' package.
669 (substitute* "configure"
670 (("rmdir zlib .*$") "echo \"using system zlib\"\n"))
671 (substitute* (find-files "./c" "Mf-[a-zA-Z0-9.]+")
672 (("\\$\\{Kernel\\}: \\$\\{kernelobj\\} \\.\\./zlib/libz\\.a")
673 "${Kernel}: ${kernelobj}")
674 (("ld -melf_x86_64 -r -X -o \\$\\{Kernel\\} \\$\\{kernelobj\\} \\.\\./zlib/libz\\.a")
675 (string-append "ld -melf_x86_64 -r -X -o ${Kernel} ${kernelobj} "
676 zlib "/lib/libz.a"))
677 (("\\(cd \\.\\./zlib; CFLAGS=-m64 \\./configure --64)")
678 (which "true"))
679 (("(cd \\.\\./zlib; make)")
680 (which "true")))
681 (substitute* (find-files "mats" "Mf-.*")
682 (("^[[:space:]]+(cc ) *") "\tgcc "))
683 (substitute*
684 (find-files "." (string-append
685 "("
686 "Mf-[a-zA-Z0-9.]+"
687 "|Makefile[a-zA-Z0-9.]*"
688 "|checkin"
689 "|stex\\.stex"
690 "|newrelease"
691 "|workarea"
692 ;;"|[a-zA-Z0-9.]+\\.ms" ; guile can't read
693 ")"))
694 (("/bin/rm") (which "rm"))
695 (("/bin/ln") (which "ln"))
696 (("/bin/cp") (which "cp")))
697 (substitute* "makefiles/installsh"
698 (("/bin/true") (which "true")))
699 (substitute* "stex/Makefile"
700 (("PREFIX=/usr") (string-append "PREFIX=" out)))
701 (zero? (system* "./configure" "--threads"
702 (string-append "--installprefix=" out))))))
703 ;; Installation of the documentation requires a running "chez".
704 (add-after 'install 'install-doc
705 (lambda* (#:key inputs outputs #:allow-other-keys)
706 (let ((bin (string-append (assoc-ref outputs "out") "/bin"))
707 (doc (string-append (assoc-ref outputs "doc")
708 "/share/doc/" ,name "-" ,version)))
709 (setenv "HOME" (getcwd))
710 (setenv "PATH" (string-append (getenv "PATH") ":" bin))
711 (with-directory-excursion "stex"
712 (system* "make" (string-append "BIN=" bin)))
713 (system* "make" "docs")
714 (with-directory-excursion "csug"
715 (substitute* "Makefile"
716 (("/tmp/csug9") doc)
717 (("^m = a6le")
718 "m := $(shell echo '(machine-type)' | scheme -q)"))
719 (system* "make" "install")
720 (install-file "csug.pdf" doc))
721 (with-directory-excursion "release_notes"
722 (install-file "release_notes.pdf" doc))
723 #t)))
724 ;; The binary file name is called "scheme" as the one from MIT/GNU
725 ;; Scheme. We add a symlink to use in case both are installed.
726 (add-after 'install 'install-symlink
727 (lambda* (#:key outputs #:allow-other-keys)
728 (let* ((out (assoc-ref outputs "out"))
729 (bin (string-append out "/bin"))
730 (lib (string-append out "/lib"))
731 (name "chez-scheme"))
732 (symlink (string-append bin "/scheme")
733 (string-append bin "/" name))
734 (map (lambda (file)
735 (symlink file (string-append (dirname file)
736 "/" name ".boot")))
737 (find-files lib "scheme.boot"))
738 #t))))))
739 ;; According to the documentation MIPS is not supported.
740 (supported-systems (delete "mips64el-linux" %supported-systems))
741 (home-page "http://www.scheme.com")
742 (synopsis "R6RS Scheme compiler and run-time")
743 (description
744 "Chez Scheme is a compiler and run-time system for the language of the
745 Revised^6 Report on Scheme (R6RS), with numerous extensions. The compiler
746 generates native code for each target processor, with support for x86, x86_64,
747 and 32-bit PowerPC architectures.")
748 (license asl2.0)))
749
750 (define-public scmutils
751 (let ()
752 (define (system-suffix)
753 (cond
754 ((string-prefix? "x86_64" (or (%current-target-system)
755 (%current-system)))
756 "x86-64")
757 (else "i386")))
758
759 (package
760 (name "scmutils")
761 (version "20140302")
762 (source
763 (origin
764 (method url-fetch/tarbomb)
765 (modules '((guix build utils)))
766 (snippet
767 ;; Remove binary code
768 '(delete-file-recursively "scmutils/mit-scheme"))
769 (file-name (string-append name "-" version ".tar.gz"))
770 (uri (string-append "http://groups.csail.mit.edu/mac/users/gjs/6946"
771 "/scmutils-tarballs/" name "-" version
772 "-x86-64-gnu-linux.tar.gz"))
773 (sha256
774 (base32 "10cnbm7nh78m5mrl1di85s29gny81jb1am9zd9f9yx725xb6dnfg"))))
775 (build-system gnu-build-system)
776 (inputs
777 `(("mit-scheme" ,mit-scheme)
778 ("emacs" ,emacs-minimal)))
779 (arguments
780 `(#:tests? #f ;; no tests-suite
781 #:modules ((guix build gnu-build-system)
782 (guix build utils)
783 (guix build emacs-utils))
784 #:imported-modules (,@%gnu-build-system-modules
785 (guix build emacs-utils))
786 #:phases
787 (modify-phases %standard-phases
788 (replace 'configure
789 ;; No standard build procedure is used. We set the correct
790 ;; runtime path in the custom build system.
791 (lambda* (#:key outputs #:allow-other-keys)
792 (let ((out (assoc-ref outputs "out")))
793 ;; Required to find .bci files at runtime.
794 (with-directory-excursion "scmutils"
795 (rename-file "src" "scmutils"))
796 (substitute* "scmutils/scmutils/load.scm"
797 (("/usr/local/scmutils/")
798 (string-append out "/lib/mit-scheme-"
799 ,(system-suffix) "/")))
800 #t)))
801 (replace 'build
802 ;; Compile the code and build a band.
803 (lambda* (#:key outputs #:allow-other-keys)
804 (let* ((out (assoc-ref outputs "out"))
805 (make-img (string-append
806 "echo '(load \"load\") "
807 "(disk-save \"edwin-mechanics.com\")'"
808 "| mit-scheme")))
809 (with-directory-excursion "scmutils/scmutils"
810 (and (zero? (system "mit-scheme < compile.scm"))
811 (zero? (system make-img)))))))
812 (add-before 'install 'fix-directory-names
813 ;; Correct directory names in the startup script.
814 (lambda* (#:key inputs outputs #:allow-other-keys)
815 (let* ((out (assoc-ref outputs "out"))
816 (scm-root (assoc-ref inputs "mit-scheme")))
817 (substitute* "bin/mechanics"
818 (("ROOT=\"\\$\\{SCMUTILS_ROOT:-/.*\\}\"")
819 (string-append
820 "ROOT=\"${SCMUTILS_ROOT:-" scm-root "}\"\n"
821 "LIB=\"${ROOT}/lib/mit-scheme-"
822 ,(system-suffix) ":"
823 out "/lib/mit-scheme-" ,(system-suffix) "\""))
824 (("EDWIN_INFO_DIRECTORY=.*\n") "")
825 (("SCHEME=.*\n")
826 (string-append "SCHEME=\"${ROOT}/bin/scheme "
827 "--library ${LIB}\"\n"))
828 (("export EDWIN_INFO_DIRECTORY") ""))
829 #t)))
830 (add-before 'install 'emacs-tags
831 ;; Generate Emacs's tags for easy reference to source
832 ;; code.
833 (lambda* (#:key inputs outputs #:allow-other-keys)
834 (with-directory-excursion "scmutils/scmutils"
835 (zero? (apply system* "etags"
836 (find-files "." "\\.scm"))))))
837 (replace 'install
838 ;; Copy files to the store.
839 (lambda* (#:key outputs #:allow-other-keys)
840 (define* (copy-files-to-directory files dir
841 #:optional (delete? #f))
842 (for-each (lambda (f)
843 (copy-file f (string-append dir "/" f))
844 (when delete? (delete-file f)))
845 files))
846
847 (let* ((out (assoc-ref outputs "out"))
848 (bin (string-append out "/bin"))
849 (doc (string-append out "/share/doc/"
850 ,name "-" ,version))
851 (lib (string-append out "/lib/mit-scheme-"
852 ,(system-suffix)
853 "/scmutils")))
854 (for-each mkdir-p (list lib doc bin))
855 (with-directory-excursion "scmutils/scmutils"
856 (copy-files-to-directory '("COPYING" "LICENSE")
857 doc #t)
858 (for-each delete-file (find-files "." "\\.bin"))
859 (copy-files-to-directory '("edwin-mechanics.com")
860 (string-append lib "/..") #t)
861 (copy-recursively "." lib))
862 (with-directory-excursion "bin"
863 (copy-files-to-directory (find-files ".") bin))
864 (with-directory-excursion "scmutils/manual"
865 (copy-files-to-directory (find-files ".") doc))
866 #t)))
867 (add-after 'install 'emacs-helpers
868 ;; Add convenience Emacs commands to easily load the
869 ;; Scmutils band in an MIT-Scheme buffer inside of Emacs
870 ;; and to easily load code tags.
871 (lambda* (#:key inputs outputs #:allow-other-keys)
872 (let* ((out (assoc-ref outputs "out"))
873 (mit-root (assoc-ref inputs "mit-scheme"))
874 (emacs-lisp-dir
875 (string-append out "/share/emacs/site-lisp"
876 "/guix.d/" ,name "-" ,version))
877 (el-file (string-append emacs-lisp-dir
878 "/scmutils.el"))
879 (lib-relative-path
880 (string-append "/lib/mit-scheme-"
881 ,(system-suffix))))
882 (mkdir-p emacs-lisp-dir)
883 (call-with-output-file el-file
884 (lambda (p)
885 (format p
886 ";;;###autoload
887 (defun scmutils-load ()
888 (interactive)
889 (require 'xscheme)
890 (let ((mit-root \"~a\")
891 (scmutils \"~a\"))
892 (run-scheme
893 (concat mit-root \"/bin/scheme --library \"
894 mit-root \"~a:\" scmutils \"~a\"
895 \" --band edwin-mechanics.com\"
896 \" --emacs\"))))
897
898 ;;;###autoload
899 (defun scmutils-load-tags ()
900 (interactive)
901 (let ((scmutils \"~a\"))
902 (visit-tags-table (concat scmutils \"/TAGS\"))))
903 "
904 mit-root out
905 lib-relative-path
906 lib-relative-path
907 (string-append out lib-relative-path
908 "/scmutils"))))
909 (emacs-generate-autoloads ,name emacs-lisp-dir)
910 (emacs-byte-compile-directory emacs-lisp-dir)
911 #t))))))
912 (home-page
913 "http://groups.csail.mit.edu/mac/users/gjs/6946/linux-install.htm")
914 (synopsis "Scmutils library for MIT Scheme")
915 (description "The Scmutils system is an integrated library of
916 procedures, embedded in the programming language Scheme, and intended to
917 support teaching and research in mathematical physics and electrical
918 engineering.")
919 (license gpl2+))))
920
921 (define-public sicp
922 (let ((commit "5b52db566968d28a89fbbaf338d207f01cc81cac"))
923 (package
924 (name "sicp")
925 (version (string-append "20160220-1." (string-take commit 7)))
926 (source (origin
927 (method git-fetch)
928 (uri (git-reference
929 (url "https://github.com/sarabander/sicp")
930 (commit commit)))
931 (sha256
932 (base32
933 "10h6h7szwlfbshwh18bnl2hvyddj5i7106l79s145l0sjjv15cxb"))
934 (file-name (string-append name "-" version "-checkout"))))
935 (build-system trivial-build-system)
936 (native-inputs `(("gzip" ,gzip)
937 ("source" ,source)
938 ("texinfo" ,texinfo)))
939 (arguments
940 `(#:modules ((guix build utils)
941 (srfi srfi-1)
942 (srfi srfi-26))
943 #:builder
944 (begin
945 (use-modules (guix build utils)
946 (srfi srfi-1)
947 (srfi srfi-26))
948 (let ((gzip (assoc-ref %build-inputs "gzip"))
949 (source (assoc-ref %build-inputs "source"))
950 (texinfo (assoc-ref %build-inputs "texinfo"))
951 (info-dir (string-append %output "/share/info")))
952 (setenv "PATH" (string-append gzip "/bin"
953 ":" texinfo "/bin"))
954 (mkdir-p info-dir)
955 (and (zero?
956 (system* "makeinfo" "--output"
957 (string-append info-dir "/sicp.info")
958 (string-append source "/sicp-pocket.texi")))
959 (every zero?
960 (map (cut system* "gzip" "-9n" <>)
961 (find-files info-dir))))))))
962 (home-page "http://sarabander.github.io/sicp")
963 (synopsis "Structure and Interpretation of Computer Programs")
964 (description "Structure and Interpretation of Computer Programs (SICP) is
965 a textbook aiming to teach the principles of computer programming.
966
967 Using Scheme, a dialect of the Lisp programming language, the book explains
968 core computer science concepts such as abstraction in programming,
969 metalinguistic abstraction, recursion, interpreters, and modular programming.")
970 (license cc-by-sa4.0))))