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>
9 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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
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))
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))
69 (define-public mit-scheme
73 (source #f) ; see below
74 (outputs '("out" "doc"))
75 (build-system gnu-build-system)
77 `(#:tests? #f ; no "check" target
78 #:modules ((guix build gnu-build-system)
82 (modify-phases %standard-phases
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)
90 ;; Delete these dangling symlinks since they break
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\\.")))
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)))
120 (add-after 'build 'build-doc
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)
138 (string-append old-doc-dir "/" ,name "-" ,version)
139 new-doc/mit-scheme-dir)
140 (delete-file-recursively old-doc-dir)
143 `(("texlive" ,texlive)
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
158 (uri (string-append "mirror://gnu/mit-scheme/stable.pkg/"
159 version "/mit-scheme-"
160 (match (%current-system)
162 (string-append version "-x86-64"))
164 (string-append version "-i386"))
166 (string-append "c-" version)))
169 (match (%current-system)
172 "1skzxxhr0iq96bf0j5m7mvf3i4sppfyfa6gpqn34mwgkw1fx8274"))
175 "1fmlpnhf5a75db93phajh4ysbdgrgl72v45lk3kznriprl0a7jc6"))
178 "0w5ib5vsidihb4hb6fma3sp596ykr8izagm57axvgd6lqzwicsjg"))))))))
180 ;; Fails to build on MIPS, see <http://bugs.gnu.org/18221>.
181 (supported-systems (delete "mips64el-linux" %supported-systems))
183 (home-page "http://www.gnu.org/software/mit-scheme/")
184 (synopsis "A Scheme implementation with integrated editor and debugger")
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.")
190 (properties '((ftp-directory . "/gnu/mit-scheme/stable.pkg")))))
192 (define-public bigloo
198 (uri (string-append "ftp://ftp-sop.inria.fr/indes/fp/Bigloo/bigloo"
202 "170q7nh08n4v20xl81fxb0xcdxphqqacfa643hsa8i2ar6pki04c"))
203 (patches (search-patches "bigloo-gc-shebangs.patch"))))
204 (build-system gnu-build-system)
206 `(#:test-target "test"
207 #:phases (alist-replace
209 (lambda* (#:key outputs #:allow-other-keys)
211 (substitute* "configure"
213 (string-append "shell=" (which "bash") "\n")))
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)))
226 ;; Those variables are used by libgc's `configure'.
227 (setenv "SHELL" (which "sh"))
228 (setenv "CONFIG_SHELL" (which "sh"))
230 ;; ... but they turned out to be overridden later, so work
232 (substitute* (find-files "gc" "^configure-gc")
234 (string-append "sh=" (which "sh"))))
236 ;; The `configure' script doesn't understand options
237 ;; of those of Autoconf.
238 (let ((out (assoc-ref outputs "out")))
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)))))
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)))))
260 `(("emacs" ,emacs) ;UDE needs the X version of Emacs
262 ;; Optional APIs for which Bigloo has bindings.
264 ("libphidget" ,libphidget)))
266 `(("pkg-config" ,pkg-config)))
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")
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.")
288 (uri (string-append "ftp://ftp-sop.inria.fr/indes/fp/Hop/hop-"
292 "1v2r4ga58kk1sx0frn8qa8ccmjpic9csqzpk499wc95y9c4b1wy3"))
293 (patches (search-patches "hop-bigloo-4.0b.patch"
294 "hop-linker-flags.patch"))))
295 (build-system gnu-build-system)
300 (lambda* (#:key outputs #:allow-other-keys)
301 (let ((out (assoc-ref outputs "out")))
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")))))
311 #:tests? #f)) ; no test suite
312 (inputs `(("avahi" ,avahi)
315 (home-page "http://hop.inria.fr/")
316 (synopsis "Multi-tier programming language for the Web 2.0")
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.")
325 (define-public chicken
331 (uri (string-append "http://code.call-cc.org/releases/"
332 version "/chicken-" version ".tar.gz"))
335 "12ddyiikqknpr8h6llsxbg2fz75xnayvcnsvr1cwv8xnjn7jpp73"))))
336 (build-system gnu-build-system)
338 `(#:modules ((guix build gnu-build-system)
342 ;; No `configure' script; run "make check" after "make install" as
343 ;; prescribed by README.
345 (modify-phases %standard-phases
348 (add-after 'install 'check
349 (assoc-ref %standard-phases 'check))
350 (add-after 'unpack 'disable-broken-tests
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") ""))
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")))
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
371 (home-page "http://www.call-cc.org/")
372 (synopsis "R5RS Scheme implementation that compiles native code via C")
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.")
379 (define-public scheme48
385 (uri (string-append "http://s48.org/" version
386 "/scheme48-" version ".tgz"))
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")
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.")
399 ;; Most files are BSD-3; see COPYING for the few exceptions.
402 (define-public racket
408 (uri (list (string-append "http://mirror.racket-lang.org/installers/"
409 version "/racket-" version "-src.tgz")
411 "http://mirror.informatik.uni-tuebingen.de/mirror/racket/"
412 version "/racket/racket-" version "-src-unix.tgz")))
415 "0gvh7i5k87mg1gpqk8gaq50ja9ksbhnvdqn7qqh0n17byidd6999"))))
416 (build-system gnu-build-system)
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)
428 (format #f "~a.so" soname))))
429 (patch-ffi-libs (lambda (file libs)
433 (((format #f "\"~a\"" lib))
434 (format #f "\"~a\"" (find-so lib)))))
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"))))
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"
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"
463 ("share/pkgs/db-lib/db/private/odbc/ffi.rkt"
465 ("share/pkgs/gui-lib/mred/private/wx/gtk/x11.rkt"
467 ("share/pkgs/gui-lib/mred/private/wx/gtk/gsettings.rkt"
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"
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"
477 ("share/pkgs/sgl/gl.rkt"
478 ("libGL" "libGLU")))))
481 'unpack 'patch-/bin/sh
483 (substitute* "collects/racket/system.rkt"
484 (("/bin/sh") (which "sh"))))
486 #:tests? #f ; XXX: how to run them?
490 ;; Hardcode dynamically loaded libraries for better functionality.
491 ;; sqlite and libraries for `racket/draw' are needed to build the doc.
493 ("fontconfig" ,fontconfig)
497 ("gtk+" ,gtk+) ; propagates gdk-pixbuf+svg
506 ("unixodbc" ,unixodbc)))
507 (home-page "http://racket-lang.org")
508 (synopsis "Implementation of Scheme and related languages")
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
516 (define-public gambit-c
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)
529 (base32 "0y2pklh4k65yrmxv63ass76xckrk9wqimbdad2gha35v2mi7blhs"))))
530 (build-system gnu-build-system)
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")
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")))
547 (home-page "http://www.iro.umontreal.ca/~gambit/")
548 (synopsis "Efficient Scheme interpreter and compiler")
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
558 (license (list lgpl2.1+ asl2.0))))
560 (define-public chibi-scheme
562 (name "chibi-scheme")
567 (uri (string-append "https://github.com/ashinn/chibi-scheme/archive/"
570 (base32 "16wppf4qzr0748iyp0m89gidsfgq9s6x3gw4xggym91waw4fh742"))
571 (file-name (string-append "chibi-scheme-" version ".tar.gz"))))
572 (build-system gnu-build-system)
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")
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
597 (let ((version "1.9"))
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")))))
607 (let ((version "1.2.1"))
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")))))
616 (define-public chez-scheme
623 (uri (string-append "https://github.com/cisco/ChezScheme/archive/"
624 "v" version ".tar.gz"))
626 (base32 "0lprmpsjg2plc6ykgkz482zyvhkzv6gd0vnar71ph21h6zknyklz"))
627 (file-name (string-append "chez-scheme-" version ".tar.gz"))))
628 (build-system gnu-build-system)
630 `(("ncurses" ,ncurses)
632 ("xorg-rgb" ,xorg-rgb)
633 ("nanopass" ,nanopass)
637 `(("texlive" ,texlive)
638 ("ghostscript" ,ghostscript-gs)
640 (outputs '("out" "doc"))
642 `(#:modules ((guix build gnu-build-system)
647 (modify-phases %standard-phases
648 ;; Adapt the custom 'configure' script.
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)))
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} "
677 (("\\(cd \\.\\./zlib; CFLAGS=-m64 \\./configure --64)")
679 (("(cd \\.\\./zlib; make)")
681 (substitute* (find-files "mats" "Mf-.*")
682 (("^[[:space:]]+(cc ) *") "\tgcc "))
684 (find-files "." (string-append
687 "|Makefile[a-zA-Z0-9.]*"
692 ;;"|[a-zA-Z0-9.]+\\.ms" ; guile can't read
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"
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))
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))
735 (symlink file (string-append (dirname file)
737 (find-files lib "scheme.boot"))
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")
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.")
750 (define-public scmutils
752 (define (system-suffix)
754 ((string-prefix? "x86_64" (or (%current-target-system)
764 (method url-fetch/tarbomb)
765 (modules '((guix build utils)))
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"))
774 (base32 "10cnbm7nh78m5mrl1di85s29gny81jb1am9zd9f9yx725xb6dnfg"))))
775 (build-system gnu-build-system)
777 `(("mit-scheme" ,mit-scheme)
778 ("emacs" ,emacs-minimal)))
780 `(#:tests? #f ;; no tests-suite
781 #:modules ((guix build gnu-build-system)
783 (guix build emacs-utils))
784 #:imported-modules (,@%gnu-build-system-modules
785 (guix build emacs-utils))
787 (modify-phases %standard-phases
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) "/")))
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\")'"
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:-/.*\\}\"")
820 "ROOT=\"${SCMUTILS_ROOT:-" scm-root "}\"\n"
821 "LIB=\"${ROOT}/lib/mit-scheme-"
823 out "/lib/mit-scheme-" ,(system-suffix) "\""))
824 (("EDWIN_INFO_DIRECTORY=.*\n") "")
826 (string-append "SCHEME=\"${ROOT}/bin/scheme "
827 "--library ${LIB}\"\n"))
828 (("export EDWIN_INFO_DIRECTORY") ""))
830 (add-before 'install 'emacs-tags
831 ;; Generate Emacs's tags for easy reference to source
833 (lambda* (#:key inputs outputs #:allow-other-keys)
834 (with-directory-excursion "scmutils/scmutils"
835 (zero? (apply system* "etags"
836 (find-files "." "\\.scm"))))))
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)))
847 (let* ((out (assoc-ref outputs "out"))
848 (bin (string-append out "/bin"))
849 (doc (string-append out "/share/doc/"
851 (lib (string-append out "/lib/mit-scheme-"
854 (for-each mkdir-p (list lib doc bin))
855 (with-directory-excursion "scmutils/scmutils"
856 (copy-files-to-directory '("COPYING" "LICENSE")
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))
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"))
875 (string-append out "/share/emacs/site-lisp"
876 "/guix.d/" ,name "-" ,version))
877 (el-file (string-append emacs-lisp-dir
880 (string-append "/lib/mit-scheme-"
882 (mkdir-p emacs-lisp-dir)
883 (call-with-output-file el-file
887 (defun scmutils-load ()
890 (let ((mit-root \"~a\")
893 (concat mit-root \"/bin/scheme --library \"
894 mit-root \"~a:\" scmutils \"~a\"
895 \" --band edwin-mechanics.com\"
899 (defun scmutils-load-tags ()
901 (let ((scmutils \"~a\"))
902 (visit-tags-table (concat scmutils \"/TAGS\"))))
907 (string-append out lib-relative-path
909 (emacs-generate-autoloads ,name emacs-lisp-dir)
910 (emacs-byte-compile-directory emacs-lisp-dir)
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
922 (let ((commit "5b52db566968d28a89fbbaf338d207f01cc81cac"))
925 (version (string-append "20160220-1." (string-take commit 7)))
929 (url "https://github.com/sarabander/sicp")
933 "10h6h7szwlfbshwh18bnl2hvyddj5i7106l79s145l0sjjv15cxb"))
934 (file-name (string-append name "-" version "-checkout"))))
935 (build-system trivial-build-system)
936 (native-inputs `(("gzip" ,gzip)
938 ("texinfo" ,texinfo)))
940 `(#:modules ((guix build utils)
945 (use-modules (guix build utils)
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"
956 (system* "makeinfo" "--output"
957 (string-append info-dir "/sicp.info")
958 (string-append source "/sicp-pocket.texi")))
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.
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))))