packages: Add 'search-patches'.
[jackhill/guix/guix.git] / gnu / packages / scheme.scm
CommitLineData
e117772d 1;;; GNU Guix --- Functional package management for GNU
d3206af6 2;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
07f4aef0 3;;; Copyright © 2015 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
c093f9f6 4;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
d0d94110 5;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
5c4d98ab 6;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
e117772d
LC
7;;;
8;;; This file is part of GNU Guix.
9;;;
10;;; GNU Guix is free software; you can redistribute it and/or modify it
11;;; under the terms of the GNU General Public License as published by
12;;; the Free Software Foundation; either version 3 of the License, or (at
13;;; your option) any later version.
14;;;
15;;; GNU Guix is distributed in the hope that it will be useful, but
16;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;;; GNU General Public License for more details.
19;;;
20;;; You should have received a copy of the GNU General Public License
21;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22
1ffa7090 23(define-module (gnu packages scheme)
59a43334 24 #:use-module (gnu packages)
e117772d
LC
25 #:use-module (guix licenses)
26 #:use-module (guix packages)
27 #:use-module (guix download)
07f4aef0 28 #:use-module (guix utils)
e117772d 29 #:use-module (guix build-system gnu)
1ffa7090
LC
30 #:use-module (gnu packages m4)
31 #:use-module (gnu packages multiprecision)
d3206af6 32 #:use-module (gnu packages databases)
1ffa7090
LC
33 #:use-module (gnu packages emacs)
34 #:use-module (gnu packages texinfo)
f163c290 35 #:use-module (gnu packages texlive)
ce0614dd 36 #:use-module (gnu packages base)
cf53ecf5
LC
37 #:use-module (gnu packages pkg-config)
38 #:use-module (gnu packages avahi)
39 #:use-module (gnu packages libphidget)
ffc13e75 40 #:use-module (gnu packages gcc)
30645251 41 #:use-module (gnu packages glib)
9d3c4dae 42 #:use-module (gnu packages gtk)
30645251 43 #:use-module (gnu packages libffi)
d3206af6 44 #:use-module (gnu packages fontutils)
e55354b8 45 #:use-module (gnu packages image)
bc11c72c 46 #:use-module (gnu packages xorg)
e117772d
LC
47 #:use-module (ice-9 match))
48
a0efb39a 49(define (mit-scheme-source-directory system version)
ecb26c10
AE
50 (string-append "mit-scheme-"
51 (if (or (string-prefix? "x86_64" system)
a0efb39a 52 (string-prefix? "i686" system))
ecb26c10
AE
53 ""
54 "c-")
55 version))
56
e117772d
LC
57(define-public mit-scheme
58 (package
59 (name "mit-scheme")
6c4a2884 60 (version "9.2")
e117772d 61 (source #f) ; see below
f163c290 62 (outputs '("out" "doc"))
e117772d
LC
63 (build-system gnu-build-system)
64 (arguments
65 `(#:tests? #f ; no "check" target
f163c290
FB
66 #:modules ((guix build gnu-build-system)
67 (guix build utils)
68 (srfi srfi-1))
e117772d 69 #:phases
af00e633
FB
70 (modify-phases %standard-phases
71 (replace 'unpack
72 (lambda* (#:key inputs #:allow-other-keys)
73 (and (zero? (system* "tar" "xzvf"
74 (assoc-ref inputs "source")))
75 (chdir ,(mit-scheme-source-directory (%current-system)
76 version))
77 (begin
78 ;; Delete these dangling symlinks since they break
79 ;; `patch-shebangs'.
80 (for-each delete-file
81 (append '("src/lib/shim-config.scm")
82 (find-files "src/lib/lib" "\\.so$")
83 (find-files "src/lib" "^liarc-")
84 (find-files "src/compiler" "^make\\.")))
85 (chdir "src")
86 #t))))
87 (replace 'build
88 (lambda* (#:key system outputs #:allow-other-keys)
89 (let ((out (assoc-ref outputs "out")))
90 (if (or (string-prefix? "x86_64" system)
91 (string-prefix? "i686" system))
92 (zero? (system* "make" "compile-microcode"))
93 (zero? (system* "./etc/make-liarc.sh"
f163c290
FB
94 (string-append "--prefix=" out)))))))
95 (add-after 'configure 'configure-doc
96 (lambda* (#:key outputs inputs #:allow-other-keys)
97 (with-directory-excursion "../doc"
98 (let* ((out (assoc-ref outputs "out"))
99 (bash (assoc-ref inputs "bash"))
100 (bin/sh (string-append bash "/bin/sh")))
101 (system* bin/sh "./configure"
102 (string-append "--prefix=" out)
103 (string-append "SHELL=" bin/sh))
104 (substitute* '("Makefile" "make-common")
105 (("/lib/mit-scheme/doc")
106 (string-append "/share/doc/" ,name "-" ,version)))
107 #t))))
108 (add-after 'build 'build-doc
109 (lambda* _
110 (with-directory-excursion "../doc"
111 (zero? (system* "make")))))
112 (add-after 'install 'install-doc
113 (lambda* (#:key outputs #:allow-other-keys)
114 (let* ((out (assoc-ref outputs "out"))
115 (doc (assoc-ref outputs "doc"))
116 (old-doc-dir (string-append out "/share/doc"))
117 (new-doc/mit-scheme-dir
118 (string-append doc "/share/doc/" ,name "-" ,version)))
119 (with-directory-excursion "../doc"
120 (for-each (lambda (target)
121 (system* "make" target))
122 '("install-config" "install-info-gz" "install-man"
123 "install-html" "install-pdf")))
124 (mkdir-p new-doc/mit-scheme-dir)
125 (copy-recursively
126 (string-append old-doc-dir "/" ,name "-" ,version)
127 new-doc/mit-scheme-dir)
128 (delete-file-recursively old-doc-dir)
129 #t))))))
130 (native-inputs
131 `(("texlive" ,texlive)
132 ("texinfo" ,texinfo)
133 ("m4" ,m4)))
e117772d 134 (inputs
f163c290 135 `(("libx11" ,libx11)
e117772d
LC
136
137 ("source"
dd6b9a37
LC
138
139 ;; MIT/GNU Scheme is not bootstrappable, so it's recommended to
140 ;; compile from the architecture-specific tarballs, which contain
141 ;; pre-built binaries. It leads to more efficient code than when
142 ;; building the tarball that contains generated C code instead of
143 ;; those binaries.
144 ,(origin
145 (method url-fetch)
146 (uri (string-append "mirror://gnu/mit-scheme/stable.pkg/"
147 version "/mit-scheme-"
dd6b9a37 148 (match (%current-system)
ecb26c10
AE
149 ("x86_64-linux"
150 (string-append version "-x86-64"))
151 ("i686-linux"
152 (string-append version "-i386"))
153 (_
154 (string-append "c-" version)))
dd6b9a37
LC
155 ".tar.gz"))
156 (sha256
157 (match (%current-system)
158 ("x86_64-linux"
159 (base32
6c4a2884 160 "1skzxxhr0iq96bf0j5m7mvf3i4sppfyfa6gpqn34mwgkw1fx8274"))
dd6b9a37
LC
161 ("i686-linux"
162 (base32
6c4a2884 163 "1fmlpnhf5a75db93phajh4ysbdgrgl72v45lk3kznriprl0a7jc6"))
dd6b9a37
LC
164 (_
165 (base32
6c4a2884 166 "0w5ib5vsidihb4hb6fma3sp596ykr8izagm57axvgd6lqzwicsjg"))))))))
75af27f7
LC
167
168 ;; Fails to build on MIPS, see <http://bugs.gnu.org/18221>.
7491edaf 169 (supported-systems (delete "mips64el-linux" %supported-systems))
75af27f7 170
e117772d 171 (home-page "http://www.gnu.org/software/mit-scheme/")
a2b63d58 172 (synopsis "A Scheme implementation with integrated editor and debugger")
e117772d 173 (description
79c311b8 174 "GNU/MIT Scheme is an implementation of the Scheme programming
a22dc0c4
LC
175language. It provides an interpreter, a compiler and a debugger. It also
176features an integrated Emacs-like editor and a large runtime library.")
e117772d
LC
177 (license gpl2+)))
178
179(define-public bigloo
180 (package
181 (name "bigloo")
7fe492e8 182 (version "4.1a")
e117772d
LC
183 (source (origin
184 (method url-fetch)
185 (uri (string-append "ftp://ftp-sop.inria.fr/indes/fp/Bigloo/bigloo"
186 version ".tar.gz"))
187 (sha256
188 (base32
7fe492e8 189 "170q7nh08n4v20xl81fxb0xcdxphqqacfa643hsa8i2ar6pki04c"))
01eafd38 190 (patches (list (search-patch "bigloo-gc-shebangs.patch")))))
e117772d
LC
191 (build-system gnu-build-system)
192 (arguments
01eafd38 193 `(#:test-target "test"
e117772d
LC
194 #:phases (alist-replace
195 'configure
196 (lambda* (#:key outputs #:allow-other-keys)
197
198 (substitute* "configure"
199 (("^shell=.*$")
200 (string-append "shell=" (which "bash") "\n")))
201
6e1c4093
LC
202 ;; Since libgc's pthread redirects are used, we end up
203 ;; using libgc symbols, so we must link against it.
204 ;; Reported on 2013-06-25.
205 (substitute* "api/pthread/src/Makefile"
206 (("^EXTRALIBS[[:blank:]]*=(.*)$" _ value)
207 (string-append "EXTRALIBS = "
208 (string-trim-right value)
209 " -l$(GCLIB)_fth-$(RELEASE)"
210 " -Wl,-rpath=" (assoc-ref outputs "out")
211 "/lib/bigloo/" ,version)))
212
e117772d 213 ;; Those variables are used by libgc's `configure'.
e858326a
LC
214 (setenv "SHELL" (which "sh"))
215 (setenv "CONFIG_SHELL" (which "sh"))
216
217 ;; ... but they turned out to be overridden later, so work
218 ;; around that.
219 (substitute* (find-files "gc" "^configure-gc")
220 (("sh=/bin/sh")
221 (string-append "sh=" (which "sh"))))
e117772d
LC
222
223 ;; The `configure' script doesn't understand options
224 ;; of those of Autoconf.
225 (let ((out (assoc-ref outputs "out")))
226 (zero?
227 (system* "./configure"
228 (string-append "--prefix=" out)
7fe492e8
LC
229 ;; FIXME: Currently fails, see
230 ;; <http://article.gmane.org/gmane.lisp.scheme.bigloo/6126>.
231 ;; "--customgc=no" ; use our libgc
e117772d 232 (string-append"--mv=" (which "mv"))
f0ad3c76
LC
233 (string-append "--rm=" (which "rm"))
234 (string-append "--ldflags=-Wl,-rpath="
235 (assoc-ref outputs "out")
236 "/lib/bigloo/" ,version)))))
e117772d 237 (alist-cons-after
e858326a
LC
238 'install 'install-emacs-modes
239 (lambda* (#:key outputs #:allow-other-keys)
240 (let* ((out (assoc-ref outputs "out"))
241 (dir (string-append out "/share/emacs/site-lisp")))
242 (zero? (system* "make" "-C" "bmacs" "all" "install"
243 (string-append "EMACSBRAND=emacs24")
244 (string-append "EMACSDIR=" dir)))))
245 %standard-phases))))
e117772d 246 (inputs
69383a47 247 `(("emacs" ,emacs) ;UDE needs the X version of Emacs
cf53ecf5
LC
248
249 ;; Optional APIs for which Bigloo has bindings.
250 ("avahi" ,avahi)
251 ("libphidget" ,libphidget)))
252 (native-inputs
253 `(("pkg-config" ,pkg-config)))
10879c4e
LC
254 (propagated-inputs
255 `(("gmp" ,gmp))) ; bigloo.h refers to gmp.h
e117772d 256 (home-page "http://www-sop.inria.fr/indes/fp/Bigloo/")
35b9e423 257 (synopsis "Efficient Scheme compiler")
e117772d
LC
258 (description
259 "Bigloo is a Scheme implementation devoted to one goal: enabling
260Scheme based programming style where C(++) is usually
261required. Bigloo attempts to make Scheme practical by offering
262features usually presented by traditional programming languages
263but not offered by Scheme and functional programming. Bigloo
264compiles Scheme modules. It delivers small and fast stand alone
265binary executables. Bigloo enables full connections between
14e72a18 266Scheme and C programs and between Scheme and Java programs.")
e117772d 267 (license gpl2+)))
e6e82f62
LC
268
269(define-public hop
270 (package
271 (name "hop")
272 (version "2.4.0")
273 (source (origin
274 (method url-fetch)
275 (uri (string-append "ftp://ftp-sop.inria.fr/indes/fp/Hop/hop-"
276 version ".tar.gz"))
277 (sha256
278 (base32
01eafd38 279 "1v2r4ga58kk1sx0frn8qa8ccmjpic9csqzpk499wc95y9c4b1wy3"))
76071c70
EB
280 (patches (list (search-patch "hop-bigloo-4.0b.patch")
281 (search-patch "hop-linker-flags.patch")))))
e6e82f62
LC
282 (build-system gnu-build-system)
283 (arguments
8a629613 284 `(#:phases
d8707db0
LC
285 (alist-replace
286 'configure
76071c70 287 (lambda* (#:key outputs #:allow-other-keys)
d8707db0
LC
288 (let ((out (assoc-ref outputs "out")))
289 (zero?
290 (system* "./configure"
76071c70
EB
291 (string-append "--prefix=" out)
292 (string-append "--blflags="
293 ;; user flags completely override useful
294 ;; default flags, so repeat them here.
295 "-copt \\$(CPICFLAGS) -L\\$(BUILDLIBDIR) "
296 "-ldopt -Wl,-rpath," out "/lib")))))
297 %standard-phases)
298 #:tests? #f)) ; no test suite
a394c60a
AE
299 (inputs `(("avahi" ,avahi)
300 ("bigloo" ,bigloo)
8a629613 301 ("which" ,which)))
e6e82f62 302 (home-page "http://hop.inria.fr/")
9e771e3b 303 (synopsis "Multi-tier programming language for the Web 2.0")
e6e82f62
LC
304 (description
305 "HOP is a multi-tier programming language for the Web 2.0 and the
306so-called diffuse Web. It is designed for programming interactive web
307applications in many fields such as multimedia (web galleries, music players,
308...), ubiquitous and house automation (SmartPhones, personal appliance),
309mashups, office (web agendas, mail clients, ...), etc.")
310 (license gpl2+)))
8cc9e7f9
LC
311
312(define-public chicken
313 (package
314 (name "chicken")
d0d94110 315 (version "4.10.0")
8cc9e7f9
LC
316 (source (origin
317 (method url-fetch)
d0d94110
RW
318 (uri (string-append "http://code.call-cc.org/releases/"
319 version "/chicken-" version ".tar.gz"))
8cc9e7f9
LC
320 (sha256
321 (base32
d0d94110 322 "16w96jrhb6qf62fgznk53f55yhfv81damghdjn31k5hirnmza1qf"))))
8cc9e7f9
LC
323 (build-system gnu-build-system)
324 (arguments
325 `(#:modules ((guix build gnu-build-system)
326 (guix build utils)
327 (srfi srfi-1))
328
329 ;; No `configure' script; run "make check" after "make install" as
330 ;; prescribed by README.
acb38070
RW
331 #:phases
332 (modify-phases %standard-phases
333 (delete 'configure)
334 (delete 'check)
335 (add-after 'install 'check
416a5a9a
RW
336 (assoc-ref %standard-phases 'check))
337 (add-after 'unpack 'disable-broken-tests
338 (lambda _
339 ;; The port tests fail with this error:
340 ;; Error: (line 294) invalid escape-sequence '\x o'
341 (substitute* "tests/runtests.sh"
342 (("\\$interpret -s port-tests\\.scm") ""))
343 #t)))
8cc9e7f9
LC
344
345 #:make-flags (let ((out (assoc-ref %outputs "out")))
346 (list "PLATFORM=linux"
347 (string-append "PREFIX=" out)
348 (string-append "VARDIR=" out "/var/lib")))
349
350 ;; Parallel builds are not supported, as noted in README.
351 #:parallel-build? #f))
ffc13e75
RW
352 ;; One of the tests ("testing direct invocation can detect calls of too
353 ;; many arguments...") times out when building with a more recent GCC.
354 ;; The problem was reported here:
355 ;; https://lists.gnu.org/archive/html/chicken-hackers/2015-04/msg00059.html
356 (native-inputs
357 `(("gcc" ,gcc-4.8)))
8cc9e7f9
LC
358 (home-page "http://www.call-cc.org/")
359 (synopsis "R5RS Scheme implementation that compiles native code via C")
360 (description
361 "CHICKEN is a compiler for the Scheme programming language. CHICKEN
362produces portable and efficient C, supports almost all of the R5RS Scheme
2c4b49ed 363language standard, and includes many enhancements and extensions.")
8cc9e7f9 364 (license bsd-3)))
f7ce90e7
LC
365
366(define-public scheme48
367 (package
368 (name "scheme48")
5c4d98ab 369 (version "1.9.2")
f7ce90e7
LC
370 (source (origin
371 (method url-fetch)
372 (uri (string-append "http://s48.org/" version
373 "/scheme48-" version ".tgz"))
374 (sha256
375 (base32
5c4d98ab 376 "1x4xfm3lyz2piqcw1h01vbs1iq89zq7wrsfjgh3fxnlm1slj2jcw"))
01eafd38 377 (patches (list (search-patch "scheme48-tests.patch")))))
f7ce90e7 378 (build-system gnu-build-system)
f7ce90e7
LC
379 (home-page "http://s48.org/")
380 (synopsis "Scheme implementation using a bytecode interpreter")
381 (description
382 "Scheme 48 is an implementation of Scheme based on a byte-code
383interpreter and is designed to be used as a testbed for experiments in
384implementation techniques and as an expository tool.")
385
386 ;; Most files are BSD-3; see COPYING for the few exceptions.
387 (license bsd-3)))
30645251
LC
388
389(define-public racket
390 (package
391 (name "racket")
64a71920 392 (version "6.2.1")
30645251
LC
393 (source (origin
394 (method url-fetch)
d3206af6
LC
395 (uri (list (string-append "http://mirror.racket-lang.org/installers/"
396 version "/racket-" version "-src.tgz")
30645251
LC
397 (string-append
398 "http://mirror.informatik.uni-tuebingen.de/mirror/racket/"
399 version "/racket/racket-" version "-src-unix.tgz")))
400 (sha256
d3206af6 401 (base32
64a71920 402 "0555j63k7fs10iv0icmivlxpzgp6s7gwcbfddmbwxlf2rk80qhq0"))))
30645251
LC
403 (build-system gnu-build-system)
404 (arguments
405 '(#:phases
406 (let* ((gui-libs
407 (lambda (inputs)
9d3c4dae
LC
408 (define (lib input)
409 (string-append (assoc-ref inputs input) "/lib"))
410
411 (list (lib "glib")
412 (lib "cairo")
413 (lib "pango")
414 (lib "libjpeg")
415 (lib "gtk")
d3206af6
LC
416 (lib "gdk-pixbuf")
417 (lib "fontconfig")
418 (lib "sqlite"))))) ;to build the doc
30645251
LC
419 (alist-cons-before
420 'configure 'pre-configure
421 (lambda* (#:key inputs #:allow-other-keys)
422 (chdir "src")
423
424 ;; The GUI libs are dynamically opened through the FFI, so they
425 ;; must be in the loader's search path.
426 (setenv "LD_LIBRARY_PATH" (string-join (gui-libs inputs) ":")))
427 (alist-cons-after
428 'unpack 'patch-/bin/sh
429 (lambda _
430 (substitute* "collects/racket/system.rkt"
431 (("/bin/sh") (which "sh"))))
432 (alist-cons-after
433 'install 'wrap-programs
434 (lambda* (#:key inputs outputs #:allow-other-keys)
435 (let ((out (assoc-ref outputs "out")))
436 (define (wrap prog)
437 (wrap-program prog
438 `("LD_LIBRARY_PATH" ":" prefix
439 ,(gui-libs inputs))))
440
441 (with-directory-excursion (string-append out "/bin")
442 (for-each wrap
443 (list "gracket" "drracket" "slideshow" "mred"))
444 #t)))
445 %standard-phases))))
446 #:tests? #f ; XXX: how to run them?
447 ))
448 (inputs `(("libffi" ,libffi)
449 ("glib" ,glib) ; for DrRacket
450 ("cairo" ,cairo)
451 ("pango" ,pango)
9d3c4dae 452 ("libjpeg" ,libjpeg-8)
d3206af6 453 ("fontconfig" ,fontconfig)
9d3c4dae 454 ("gdk-pixbuf" ,gdk-pixbuf)
d3206af6
LC
455 ("gtk" ,gtk+-2)
456 ("sqlite" ,sqlite))) ;needed to build the doc
30645251
LC
457 (home-page "http://racket-lang.org")
458 (synopsis "Implementation of Scheme and related languages")
459 (description
460 "Racket is an implementation of the Scheme programming language (R5RS and
461R6RS) and related languages, such as Typed Racket. It features a compiler and
462a virtual machine with just-in-time native compilation, as well as a large set
463of libraries.")
39d0ce93 464 (license lgpl2.0+)))
07f4aef0
TUBK
465
466(define-public gambit-c
467 (package
468 (name "gambit-c")
469 (version "4.7.4")
470 (source
471 (origin
472 (method url-fetch)
473 (uri (string-append
474 "http://www.iro.umontreal.ca/~gambit/download/gambit/v"
475 (version-major+minor version) "/source/gambc-v"
476 (string-map (lambda (c) (if (char=? c #\.) #\_ c)) version)
477 ".tgz"))
478 (sha256
479 (base32 "0y2pklh4k65yrmxv63ass76xckrk9wqimbdad2gha35v2mi7blhs"))))
480 (build-system gnu-build-system)
481 (arguments
482 '(#:configure-flags
483 ;; According to the ./configure script, this makes the build slower and
484 ;; use >= 1 GB memory, but makes Gambit much faster.
485 '("--enable-single-host")
486 #:phases
487 (alist-cons-before
488 'check 'fix-tests
489 (lambda _
490 (substitute* '("tests/makefile")
491 ;; '-:' is how run-time options are set. 'tl' sets some terminal
492 ;; option, which makes it fail in our build environment. It
493 ;; recommends using 'd-' as a solution, which sets the REPL
494 ;; interaction channel to stdin/stdout.
495 (("gsi -:tl") "gsi -:d-,tl")))
496 %standard-phases)))
497 (home-page "http://www.iro.umontreal.ca/~gambit/")
498 (synopsis "Efficient Scheme interpreter and compiler")
499 (description
500 "Gambit consists of two main programs: gsi, the Gambit Scheme
501interpreter, and gsc, the Gambit Scheme compiler. The interpreter contains
502the complete execution and debugging environment. The compiler is the
503interpreter extended with the capability of generating executable files. The
504compiler can produce standalone executables or compiled modules which can be
505loaded at run time. Interpreted code and compiled code can be freely
506mixed.")
507 ;; Dual license.
508 (license (list lgpl2.1+ asl2.0))))
3e92f4f9
TUBK
509
510(define-public chibi-scheme
511 (package
512 (name "chibi-scheme")
51960939 513 (version "0.7.3")
3e92f4f9
TUBK
514 (source
515 (origin
516 (method url-fetch)
51960939
TUBK
517 (uri (string-append "https://github.com/ashinn/chibi-scheme/archive/"
518 version ".tar.gz"))
3e92f4f9 519 (sha256
51960939
TUBK
520 (base32 "16wppf4qzr0748iyp0m89gidsfgq9s6x3gw4xggym91waw4fh742"))
521 (file-name (string-append "chibi-scheme-" version ".tar.gz"))))
3e92f4f9
TUBK
522 (build-system gnu-build-system)
523 (arguments
524 `(#:phases
525 (alist-delete
526 'configure
527 (alist-cons-before
528 'build 'set-cc
529 (lambda _
530 (setenv "CC" "gcc"))
531 %standard-phases))
532 #:make-flags (let ((out (assoc-ref %outputs "out")))
533 (list (string-append "PREFIX=" out)
534 (string-append "LDFLAGS=-Wl,-rpath=" out "/lib")))
535 #:test-target "test"))
536 (home-page "https://code.google.com/p/chibi-scheme/")
537 (synopsis "Small embeddable Scheme implementation")
538 (description
539 "Chibi-Scheme is a very small library with no external dependencies
540intended for use as an extension and scripting language in C programs. In
541addition to support for lightweight VM-based threads, each VM itself runs in
542an isolated heap allowing multiple VMs to run simultaneously in different OS
543threads.")
544 (license bsd-3)))
c093f9f6 545
c093f9f6
FB
546(define-public scmutils
547 (let ()
548 (define (system-suffix)
549 (cond
550 ((string-prefix? "x86_64" (or (%current-target-system)
551 (%current-system)))
552 "x86-64")
553 (else "i386")))
554
555 (package
556 (name "scmutils")
557 (version "20140302")
558 (source
559 (origin
95001d4b 560 (method url-fetch/tarbomb)
c093f9f6
FB
561 (modules '((guix build utils)))
562 (snippet
563 ;; Remove binary code
564 '(delete-file-recursively "scmutils/mit-scheme"))
565 (file-name (string-append name "-" version ".tar.gz"))
566 (uri (string-append "http://groups.csail.mit.edu/mac/users/gjs/6946"
567 "/scmutils-tarballs/" name "-" version
568 "-x86-64-gnu-linux.tar.gz"))
569 (sha256
570 (base32 "10cnbm7nh78m5mrl1di85s29gny81jb1am9zd9f9yx725xb6dnfg"))))
571 (build-system gnu-build-system)
572 (inputs
573 `(("mit-scheme" ,mit-scheme)
574 ("emacs" ,emacs-no-x)))
575 (arguments
576 `(#:tests? #f ;; no tests-suite
577 #:modules ((guix build gnu-build-system)
578 (guix build utils)
579 (guix build emacs-utils))
580 #:imported-modules (,@%gnu-build-system-modules
581 (guix build emacs-utils))
582 #:phases
583 (modify-phases %standard-phases
584 (replace 'configure
585 ;; No standard build procedure is used. We set the correct
586 ;; runtime path in the custom build system.
587 (lambda* (#:key outputs #:allow-other-keys)
588 (let ((out (assoc-ref outputs "out")))
589 ;; Required to find .bci files at runtime.
590 (with-directory-excursion "scmutils"
591 (rename-file "src" "scmutils"))
592 (substitute* "scmutils/scmutils/load.scm"
593 (("/usr/local/scmutils/")
594 (string-append out "/lib/mit-scheme-"
595 ,(system-suffix) "/")))
596 #t)))
597 (replace 'build
598 ;; Compile the code and build a band.
599 (lambda* (#:key outputs #:allow-other-keys)
600 (let* ((out (assoc-ref outputs "out"))
601 (make-img (string-append
602 "echo '(load \"load\") "
603 "(disk-save \"edwin-mechanics.com\")'"
604 "| mit-scheme")))
605 (with-directory-excursion "scmutils/scmutils"
606 (and (zero? (system "mit-scheme < compile.scm"))
607 (zero? (system make-img)))))))
608 (add-before 'install 'fix-directory-names
609 ;; Correct directory names in the startup script.
610 (lambda* (#:key inputs outputs #:allow-other-keys)
611 (let* ((out (assoc-ref outputs "out"))
612 (scm-root (assoc-ref inputs "mit-scheme")))
613 (substitute* "bin/mechanics"
614 (("ROOT=\"\\$\\{SCMUTILS_ROOT:-/.*\\}\"")
615 (string-append
616 "ROOT=\"${SCMUTILS_ROOT:-" scm-root "}\"\n"
617 "LIB=\"${ROOT}/lib/mit-scheme-"
618 ,(system-suffix) ":"
619 out "/lib/mit-scheme-" ,(system-suffix) "\""))
620 (("EDWIN_INFO_DIRECTORY=.*\n") "")
621 (("SCHEME=.*\n")
622 (string-append "SCHEME=\"${ROOT}/bin/scheme "
623 "--library ${LIB}\"\n"))
624 (("export EDWIN_INFO_DIRECTORY") ""))
625 #t)))
626 (add-before 'install 'emacs-tags
627 ;; Generate Emacs's tags for easy reference to source
628 ;; code.
629 (lambda* (#:key inputs outputs #:allow-other-keys)
630 (with-directory-excursion "scmutils/scmutils"
631 (zero? (apply system* "etags"
632 (find-files "." "\\.scm"))))))
633 (replace 'install
634 ;; Copy files to the store.
635 (lambda* (#:key outputs #:allow-other-keys)
636 (define* (copy-files-to-directory files dir
637 #:optional (delete? #f))
638 (for-each (lambda (f)
639 (copy-file f (string-append dir "/" f))
640 (when delete? (delete-file f)))
641 files))
642
643 (let* ((out (assoc-ref outputs "out"))
644 (bin (string-append out "/bin"))
645 (doc (string-append out "/share/doc/"
646 ,name "-" ,version))
647 (lib (string-append out "/lib/mit-scheme-"
648 ,(system-suffix)
649 "/scmutils")))
650 (for-each mkdir-p (list lib doc bin))
651 (with-directory-excursion "scmutils/scmutils"
652 (copy-files-to-directory '("COPYING" "LICENSE")
653 doc #t)
654 (for-each delete-file (find-files "." "\\.bin"))
655 (copy-files-to-directory '("edwin-mechanics.com")
656 (string-append lib "/..") #t)
657 (copy-recursively "." lib))
658 (with-directory-excursion "bin"
659 (copy-files-to-directory (find-files ".") bin))
660 (with-directory-excursion "scmutils/manual"
661 (copy-files-to-directory (find-files ".") doc))
662 #t)))
663 (add-after 'install 'emacs-helpers
664 ;; Add convenience Emacs commands to easily load the
665 ;; Scmutils band in an MIT-Scheme buffer inside of Emacs
666 ;; and to easily load code tags.
667 (lambda* (#:key inputs outputs #:allow-other-keys)
668 (let* ((out (assoc-ref outputs "out"))
669 (mit-root (assoc-ref inputs "mit-scheme"))
670 (emacs-lisp-dir
671 (string-append out "/share/emacs/site-lisp"
672 "/guix.d/" ,name "-" ,version))
673 (el-file (string-append emacs-lisp-dir
674 "/scmutils.el"))
675 (lib-relative-path
676 (string-append "/lib/mit-scheme-"
677 ,(system-suffix))))
678 (mkdir-p emacs-lisp-dir)
679 (call-with-output-file el-file
680 (lambda (p)
681 (format p
682 ";;;###autoload
683(defun scmutils-load ()
684 (interactive)
685 (require 'xscheme)
686 (let ((mit-root \"~a\")
687 (scmutils \"~a\"))
688 (run-scheme
689 (concat mit-root \"/bin/scheme --library \"
690 mit-root \"~a:\" scmutils \"~a\"
691 \" --band edwin-mechanics.com\"
692 \" --emacs\"))))
693
694;;;###autoload
695(defun scmutils-load-tags ()
696 (interactive)
697 (let ((scmutils \"~a\"))
698 (visit-tags-table (concat scmutils \"/TAGS\"))))
699"
700 mit-root out
701 lib-relative-path
702 lib-relative-path
703 (string-append out lib-relative-path
704 "/scmutils"))))
aad4a48a
FB
705 (emacs-generate-autoloads ,name emacs-lisp-dir)
706 (emacs-byte-compile-directory emacs-lisp-dir)
c093f9f6
FB
707 #t))))))
708 (home-page
709 "http://groups.csail.mit.edu/mac/users/gjs/6946/linux-install.htm")
710 (synopsis "Scmutils library for MIT Scheme")
711 (description "The Scmutils system is an integrated library of
712procedures, embedded in the programming language Scheme, and intended to
713support teaching and research in mathematical physics and electrical
714engineering.")
715 (license gpl2+))))