Merge branch 'master' into staging
[jackhill/guix/guix.git] / gnu / packages / lisp.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 John Darrington <jmd@gnu.org>
3 ;;; Copyright © 2015 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
4 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
5 ;;; Copyright © 2016 Federico Beffa <beffa@fbengineering.ch>
6 ;;; Copyright © 2016, 2017 Nikita <nikita@n0.is>
7 ;;; Copyright © 2016, 2017 Andy Patterson <ajpatter@uwaterloo.ca>
8 ;;; Copyright © 2017, 2019 Ricardo Wurmus <rekado@elephly.net>
9 ;;; Copyright © 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
10 ;;; Copyright © 2017, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
11 ;;; Copyright © 2018 Benjamin Slade <slade@jnanam.net>
12 ;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
13 ;;; Copyright © 2018, 2019, 2020 Pierre Neidhardt <mail@ambrevar.xyz>
14 ;;; Copyright © 2018, 2019 Pierre Langlois <pierre.langlois@gmx.com>
15 ;;; Copyright © 2019, 2020 Katherine Cox-Buday <cox.katherine.e@gmail.com>
16 ;;; Copyright © 2019 Jesse Gildersleve <jessejohngildersleve@protonmail.com>
17 ;;; Copyright © 2019, 2020 Guillaume Le Vaillant <glv@posteo.net>
18 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
19 ;;;
20 ;;; This file is part of GNU Guix.
21 ;;;
22 ;;; GNU Guix is free software; you can redistribute it and/or modify it
23 ;;; under the terms of the GNU General Public License as published by
24 ;;; the Free Software Foundation; either version 3 of the License, or (at
25 ;;; your option) any later version.
26 ;;;
27 ;;; GNU Guix is distributed in the hope that it will be useful, but
28 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
29 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 ;;; GNU General Public License for more details.
31 ;;;
32 ;;; You should have received a copy of the GNU General Public License
33 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
34
35 ;;; This file only contains Common Lisp compilers and tooling.
36 ;;; Common Lisp libraries go to lisp-xyz.scm.
37 ;;; Common Lisp applications should go to the most appropriate file,
38 ;;; e.g. StumpWM is in wm.scm.
39
40 (define-module (gnu packages lisp)
41 #:use-module (gnu packages)
42 #:use-module ((guix licenses) #:prefix license:)
43 #:use-module (guix packages)
44 #:use-module (guix download)
45 #:use-module (guix git-download)
46 #:use-module (guix utils)
47 #:use-module (guix build-system gnu)
48 #:use-module (guix build-system ant)
49 #:use-module (guix build-system asdf)
50 #:use-module (guix build-system trivial)
51 #:use-module (gnu packages admin)
52 #:use-module (gnu packages base)
53 #:use-module (gnu packages bdw-gc)
54 #:use-module (gnu packages compression)
55 #:use-module (gnu packages ed)
56 #:use-module (gnu packages fontutils)
57 #:use-module (gnu packages gcc)
58 #:use-module (gnu packages gettext)
59 #:use-module (gnu packages gl)
60 #:use-module (gnu packages glib)
61 #:use-module (gnu packages m4)
62 #:use-module (gnu packages maths)
63 #:use-module (gnu packages multiprecision)
64 #:use-module (gnu packages ncurses)
65 #:use-module (gnu packages libffcall)
66 #:use-module (gnu packages libffi)
67 #:use-module (gnu packages libsigsegv)
68 #:use-module (gnu packages linux)
69 #:use-module (gnu packages perl)
70 #:use-module (gnu packages readline)
71 #:use-module (gnu packages sdl)
72 #:use-module (gnu packages tex)
73 #:use-module (gnu packages tls)
74 #:use-module (gnu packages texinfo)
75 #:use-module (gnu packages version-control)
76 #:use-module (gnu packages xorg)
77 #:use-module (ice-9 match))
78
79 (define-public cl-asdf
80 (package
81 (name "cl-asdf")
82 (version "3.3.4")
83 (source
84 (origin
85 (method url-fetch)
86 (uri
87 (string-append "https://common-lisp.net/project/asdf/archives/asdf-"
88 version ".lisp"))
89 (sha256
90 (base32 "1hpx30f6yrak15nw992k7x3pn75ahvjs04n4f134k68mhgs62km2"))))
91 (build-system trivial-build-system)
92 (arguments
93 `(#:modules ((guix build utils)
94 (guix build lisp-utils))
95 #:builder
96 (begin
97 (use-modules (guix build utils)
98 (guix build lisp-utils))
99 (let* ((out (string-append (assoc-ref %outputs "out")))
100 (asdf-install (string-append out %source-install-prefix
101 "/source/asdf/"))
102 (src-asdf (string-append (assoc-ref %build-inputs "source")))
103 (dst-asdf (string-append asdf-install "asdf.lisp")))
104 (mkdir-p asdf-install)
105 (copy-file src-asdf dst-asdf)
106 ;; Patch ASDF to make it read the configuration files in all
107 ;; the direcories listed in '$XDG_CONFIG_DIRS' instead of just
108 ;; the first.
109 (substitute* dst-asdf
110 (("\\(xdg-config-pathname \\*source-registry-directory\\* direction\\)")
111 "`(:source-registry
112 ,@(loop
113 for dir in (xdg-config-dirs
114 \"common-lisp/source-registry.conf.d/\")
115 collect `(:include ,dir))
116 :inherit-configuration)")
117 (("\\(xdg-config-pathname \\*output-translations-directory\\* direction\\)")
118 "`(:output-translations
119 ,@(loop
120 for dir in (xdg-config-dirs
121 \"common-lisp/asdf-output-translations.conf.d/\")
122 collect `(:include ,dir))
123 :inherit-configuration)")))
124 #t)))
125 (home-page "https://common-lisp.net/project/asdf/")
126 (synopsis "Another System Definition Facility")
127 (description
128 "ASDF is what Common Lisp hackers use to build and load software. It is
129 the successor of the Lisp DEFSYSTEM of yore. ASDF stands for Another System
130 Definition Facility.")
131 ;; MIT License
132 (license license:expat)))
133
134 (define-public gcl
135 (let ((commit "d3335e2b3deb63f930eb0328e9b05377744c9512")
136 (revision "2")) ;Guix package revision
137 (package
138 (name "gcl")
139 (version (string-append "2.6.12-" revision "."
140 (string-take commit 7)))
141 (source
142 (origin
143 (method git-fetch)
144 (uri (git-reference
145 (url "https://git.savannah.gnu.org/r/gcl.git")
146 (commit commit)))
147 (file-name (string-append "gcl-" version "-checkout"))
148 (sha256
149 (base32 "05v86lhvsby05nzvcd3c4k0wljvgdgd0i6arzd2fx1yd67dl6fgj"))))
150 (build-system gnu-build-system)
151 (arguments
152 `(#:parallel-build? #f ; The build system seems not to be thread safe.
153 #:test-target "ansi-tests/test_results"
154 #:configure-flags '("--enable-ansi") ; required for use by the maxima package
155 #:make-flags (list
156 (string-append "GCL_CC=" (assoc-ref %build-inputs "gcc")
157 "/bin/gcc")
158 (string-append "CC=" (assoc-ref %build-inputs "gcc")
159 "/bin/gcc"))
160 #:phases
161 (modify-phases %standard-phases
162 (add-before 'configure 'pre-conf
163 (lambda* (#:key inputs #:allow-other-keys)
164 (chdir "gcl")
165 (substitute*
166 (append
167 '("pcl/impl/kcl/makefile.akcl"
168 "add-defs"
169 "unixport/makefile.dos"
170 "add-defs.bat"
171 "gcl-tk/makefile.prev"
172 "add-defs1")
173 (find-files "h" "\\.defs"))
174 (("SHELL=/bin/bash")
175 (string-append "SHELL=" (which "bash")))
176 (("SHELL=/bin/sh")
177 (string-append "SHELL=" (which "sh"))))
178 (substitute* "h/linux.defs"
179 (("#CC") "CC")
180 (("-fwritable-strings") "")
181 (("-Werror") ""))
182 (substitute* "lsp/gcl_top.lsp"
183 (("\"cc\"")
184 (string-append "\"" (assoc-ref %build-inputs "gcc")
185 "/bin/gcc\""))
186 (("\\(or \\(get-path \\*cc\\*\\) \\*cc\\*\\)") "*cc*")
187 (("\"ld\"")
188 (string-append "\"" (assoc-ref %build-inputs "binutils")
189 "/bin/ld\""))
190 (("\\(or \\(get-path \\*ld\\*\\) \\*ld\\*\\)") "*ld*")
191 (("\\(get-path \"objdump --source \"\\)")
192 (string-append "\"" (assoc-ref %build-inputs "binutils")
193 "/bin/objdump --source \"")))
194 #t))
195 (add-after 'install 'wrap
196 (lambda* (#:key inputs outputs #:allow-other-keys)
197 (let* ((gcl (assoc-ref outputs "out"))
198 (input-path (lambda (lib path)
199 (string-append
200 (assoc-ref inputs lib) path)))
201 (binaries '("binutils")))
202 ;; GCC and the GNU binutils are necessary for GCL to be
203 ;; able to compile Lisp functions and programs (this is
204 ;; a standard feature in Common Lisp). While the
205 ;; the location of GCC is specified in the make-flags,
206 ;; the GNU binutils must be available in GCL's $PATH.
207 (wrap-program (string-append gcl "/bin/gcl")
208 `("PATH" prefix ,(map (lambda (binary)
209 (input-path binary "/bin"))
210 binaries))))
211 #t))
212 ;; drop strip phase to make maxima build, see
213 ;; https://www.ma.utexas.edu/pipermail/maxima/2008/009769.html
214 (delete 'strip))))
215 (inputs
216 `(("gmp" ,gmp)
217 ("readline" ,readline)))
218 (native-inputs
219 `(("m4" ,m4)
220 ("texinfo" ,texinfo)))
221 (home-page "https://www.gnu.org/software/gcl/")
222 (synopsis "A Common Lisp implementation")
223 (description "GCL is an implementation of the Common Lisp language. It
224 features the ability to compile to native object code and to load native
225 object code modules directly into its lisp core. It also features a
226 stratified garbage collection strategy, a source-level debugger and a built-in
227 interface to the Tk widget system.")
228 (license license:lgpl2.0+))))
229
230 (define-public ecl
231 (package
232 (name "ecl")
233 (version "20.4.24")
234 (source
235 (origin
236 (method url-fetch)
237 (uri (string-append
238 "https://common-lisp.net/project/ecl/static/files/release/"
239 name "-" version ".tgz"))
240 (sha256
241 (base32 "01qgdmr54wkj854f69qdm9sybrvd6gd21dpx4askdaaqybnkh237"))))
242 (build-system gnu-build-system)
243 ;; src/configure uses 'which' to confirm the existence of 'gzip'.
244 (native-inputs
245 `(("cl-asdf" ,cl-asdf)
246 ("which" ,which)
247 ("texinfo" ,texinfo)))
248 (inputs
249 `(("gmp" ,gmp)
250 ("libatomic-ops" ,libatomic-ops)
251 ("libgc" ,libgc)
252 ("libffi" ,libffi)))
253 (arguments
254 `(#:configure-flags '("--without-rt")
255 ;; FIXME: As of version 20.4.24, we pass 17995 tests and fail 7.
256 ;; 2-3 tests may be due to FHS assumptions.
257 #:tests? #t
258 #:parallel-tests? #f
259 #:phases
260 (modify-phases %standard-phases
261 (delete 'check)
262 (add-after 'unpack 'replace-asdf
263 ;; Use system ASDF instead of bundled one.
264 (lambda* (#:key inputs outputs #:allow-other-keys)
265 (let* ((cl-asdf (assoc-ref inputs "cl-asdf"))
266 (guix-asdf (string-append
267 cl-asdf
268 "/share/common-lisp/source/asdf/asdf.lisp"))
269 (out (string-append (assoc-ref outputs "out")))
270 (contrib-asdf "contrib/asdf/asdf.lisp"))
271 (copy-file guix-asdf contrib-asdf))
272 #t))
273 (add-after 'install 'wrap
274 (lambda* (#:key inputs outputs #:allow-other-keys)
275 (let* ((ecl (assoc-ref outputs "out"))
276 (input-path (lambda (lib path)
277 (string-append
278 (assoc-ref inputs lib) path)))
279 (libraries '("gmp" "libatomic-ops" "libgc" "libffi" "libc"))
280 (binaries '("gcc" "ld-wrapper" "binutils"))
281 (library-directories
282 (map (lambda (lib) (input-path lib "/lib"))
283 libraries)))
284
285 (wrap-program (string-append ecl "/bin/ecl")
286 `("PATH" prefix
287 ,(map (lambda (binary)
288 (input-path binary "/bin"))
289 binaries))
290 `("CPATH" suffix
291 ,(map (lambda (lib)
292 (input-path lib "/include"))
293 `("kernel-headers" ,@libraries)))
294 `("LIBRARY_PATH" suffix ,library-directories)
295 `("LD_LIBRARY_PATH" suffix ,library-directories)))))
296 (add-after 'wrap 'check (assoc-ref %standard-phases 'check))
297 (add-before 'check 'fix-path-to-ecl
298 (lambda _
299 (substitute* "build/tests/Makefile"
300 (("\\$\\{exec_prefix\\}/") ""))
301 #t)))))
302 (native-search-paths
303 (list (search-path-specification
304 (variable "XDG_DATA_DIRS")
305 (files '("share")))
306 (search-path-specification
307 (variable "XDG_CONFIG_DIRS")
308 (files '("etc")))))
309 (home-page "http://ecls.sourceforge.net/")
310 (synopsis "Embeddable Common Lisp")
311 (description "ECL is an implementation of the Common Lisp language as
312 defined by the ANSI X3J13 specification. Its most relevant features are: a
313 bytecode compiler and interpreter, being able to compile Common Lisp with any
314 C/C++ compiler, being able to build standalone executables and libraries, and
315 supporting ASDF, Sockets, Gray streams, MOP, and other useful components.")
316 ;; Note that the file "Copyright" points to some files and directories
317 ;; which aren't under the lgpl2.1+ and instead contain many different,
318 ;; non-copyleft licenses.
319 ;; See https://common-lisp.net/project/ecl/posts/ECL-license.html.
320 (license license:lgpl2.1+)))
321
322 (define-public clisp
323 (package
324 (name "clisp")
325 (version "2.49-92")
326 (source
327 (origin
328 (method git-fetch)
329 (uri (git-reference
330 (url "https://gitlab.com/gnu-clisp/clisp")
331 (commit "clisp-2.49.92-2018-02-18")))
332 (file-name (git-file-name name version))
333 (sha256
334 (base32 "0k2dmgl0miz3767iks4p0mvp6xw0ysyxhjpklyh11j010rmh6hqb"))
335 (patches (search-patches "clisp-remove-failing-test.patch"))))
336 (build-system gnu-build-system)
337 (inputs `(("libffcall" ,libffcall)
338 ("ncurses" ,ncurses)
339 ("readline" ,readline)
340 ("libsigsegv" ,libsigsegv)))
341 (arguments
342 `(#:configure-flags '(,@(if (string-prefix? "armhf-linux"
343 (or (%current-system)
344 (%current-target-system)))
345 '("CFLAGS=-falign-functions=4")
346 '())
347 "--with-dynamic-ffi"
348 "--with-dynamic-modules"
349 "--with-module=rawsock")
350 #:build #f
351 #:phases
352 (modify-phases %standard-phases
353 (add-after 'unpack 'patch-sh-and-pwd
354 (lambda _
355 ;; The package is very messy with its references to "/bin/sh" and
356 ;; some other absolute paths to traditional tools. These appear in
357 ;; many places where our automatic patching misses them. Therefore
358 ;; we do the following, in this early (post-unpack) phase, to solve
359 ;; the problem from its root.
360 (substitute* '("src/clisp-link.in"
361 "src/unix.d"
362 "src/makemake.in")
363 (("/bin/sh") (which "sh")))
364 (substitute* (find-files "." "configure|Makefile")
365 (("/bin/sh") "sh"))
366 (substitute* '("src/clisp-link.in")
367 (("/bin/pwd") "pwd"))
368 #t)))
369 ;; Makefiles seem to have race conditions.
370 #:parallel-build? #f))
371 (home-page "https://clisp.sourceforge.io/")
372 (synopsis "A Common Lisp implementation")
373 (description
374 "GNU CLISP is an implementation of ANSI Common Lisp. Common Lisp is a
375 high-level, object-oriented functional programming language. CLISP includes
376 an interpreter, a compiler, a debugger, and much more.")
377 (license license:gpl2+)))
378
379 (define-public sbcl
380 (package
381 (name "sbcl")
382 (version "2.0.10")
383 (source
384 (origin
385 (method url-fetch)
386 (uri (string-append "mirror://sourceforge/sbcl/sbcl/" version "/sbcl-"
387 version "-source.tar.bz2"))
388 (sha256
389 (base32 "0mq5ga977hzsq4wgv31l8d6rpa186q8xc4x2awwcskf5nq842xai"))))
390 (build-system gnu-build-system)
391 (outputs '("out" "doc"))
392 (native-inputs
393 ;; From INSTALL:
394 ;; Supported build hosts are:
395 ;; SBCL
396 ;; CMUCL
397 ;; CCL (formerly known as OpenMCL)
398 ;; ABCL (recent versions only)
399 ;; CLISP (only some versions: 2.44.1 is OK, 2.47 is not)
400 ;; XCL
401 ;;
402 ;; From NEWS:
403 ;; * build enhancement: new host quirks mechanism, support for building under
404 ;; ABCL and ECL (as well as CCL, CMUCL, CLISP and SBCL itself)
405 ;;
406 ;; CCL is not bootstrappable so it won't do. CLISP 2.49 seems to work.
407 ;; ECL too. As of 2020-07-01, ECL was last updated in 2020 while CLISP
408 ;; was last updated in 2010, and both take about the same time to build SBCL.
409 ;;
410 ;; For now we stick to CLISP for all systems. We keep the `match' here
411 ;; to make it easier to change the host compiler for various
412 ;; architectures. Consider switching to ECL if it gets faster than CLISP
413 ;; (maybe post 2020 release).
414 `(,@(match (%current-system)
415 ((or "x86_64-linux" "i686-linux")
416 `(("clisp" ,clisp)))
417 (_
418 `(("clisp" ,clisp))))
419 ("cl-asdf" ,cl-asdf)
420 ("ed" ,ed)
421 ("inetutils" ,inetutils) ;for hostname(1)
422 ("texinfo" ,texinfo)
423 ("texlive" ,(texlive-union (list texlive-tex-texinfo)))
424 ("which" ,which)
425 ("zlib" ,zlib)))
426 (arguments
427 `(#:modules ((guix build gnu-build-system)
428 (guix build utils)
429 (srfi srfi-1))
430 #:phases
431 (modify-phases %standard-phases
432 (delete 'configure)
433 (add-after 'unpack 'replace-asdf
434 ;; SBCL developers have not committed to keeping ASDF up to date
435 ;; due to breaking changes [1]. Guix can handle this situation
436 ;; easily, and it behooves us to have more control over what version
437 ;; of ASDF we use to build software; therefore, replace the contrib
438 ;; ASDF with the version packaged into Guix.
439 ;; [1] - https://bugs.launchpad.net/sbcl/+bug/1823442
440 (lambda* (#:key inputs outputs #:allow-other-keys)
441 (let* ((cl-asdf (assoc-ref inputs "cl-asdf"))
442 (guix-asdf (string-append
443 cl-asdf
444 "/share/common-lisp/source/asdf/asdf.lisp"))
445 (out (string-append (assoc-ref outputs "out")))
446 (contrib-asdf "contrib/asdf/asdf.lisp"))
447 (copy-file guix-asdf contrib-asdf))
448 #t))
449 (add-before 'build 'patch-unix-tool-paths
450 (lambda* (#:key outputs inputs #:allow-other-keys)
451 (let ((out (assoc-ref outputs "out"))
452 (bash (assoc-ref inputs "bash"))
453 (coreutils (assoc-ref inputs "coreutils"))
454 (ed (assoc-ref inputs "ed")))
455 (define (quoted-path input path)
456 (string-append "\"" input path "\""))
457 ;; Patch absolute paths in string literals. Note that this
458 ;; occurs in some .sh files too (which contain Lisp code). Use
459 ;; ISO-8859-1 because some of the files are ISO-8859-1 encoded.
460 (with-fluids ((%default-port-encoding #f))
461 ;; The removed file is utf-16-be encoded, which gives substitute*
462 ;; trouble. It does not contain references to the listed programs.
463 (substitute* (delete
464 "./tests/data/compile-file-pos-utf16be.lisp"
465 (find-files "." "\\.(lisp|sh)$"))
466 (("\"/bin/sh\"") (quoted-path bash "/bin/sh"))
467 (("\"/usr/bin/env\"") (quoted-path coreutils "/usr/bin/env"))
468 (("\"/bin/cat\"") (quoted-path coreutils "/bin/cat"))
469 (("\"/bin/ed\"") (quoted-path ed "/bin/ed"))
470 (("\"/bin/echo\"") (quoted-path coreutils "/bin/echo"))
471 (("\"/bin/uname\"") (quoted-path coreutils "/bin/uname"))))
472 ;; This one script has a non-string occurrence of /bin/sh.
473 (substitute* '("tests/foreign.test.sh")
474 ;; Leave whitespace so we don't match the shebang.
475 ((" /bin/sh ") " sh "))
476 ;; This file contains a module that can create executable files
477 ;; which depend on the presence of SBCL. It generates shell
478 ;; scripts doing "exec sbcl ..." to achieve this. We patch both
479 ;; the shebang and the reference to "sbcl", tying the generated
480 ;; executables to the exact SBCL package that generated them.
481 (substitute* '("contrib/sb-executable/sb-executable.lisp")
482 (("/bin/sh") (string-append bash "/bin/sh"))
483 (("exec sbcl") (string-append "exec " out "/bin/sbcl")))
484 ;; Disable some tests that fail in our build environment.
485 (substitute* '("contrib/sb-bsd-sockets/tests.lisp")
486 ;; This requires /etc/protocols.
487 (("\\(deftest get-protocol-by-name/error" all)
488 (string-append "#+nil ;disabled by Guix\n" all)))
489 (substitute* '("contrib/sb-posix/posix-tests.lisp")
490 ;; These assume some users/groups which we don't have.
491 (("\\(deftest pwent\\.[12]" all)
492 (string-append "#+nil ;disabled by Guix\n" all))
493 (("\\(deftest grent\\.[12]" all)
494 (string-append "#+nil ;disabled by Guix\n" all))))
495 #t))
496 ;; FIXME: the texlive-union insists on regenerating fonts. It stores
497 ;; them in HOME, so it needs to be writeable.
498 (add-before 'build 'set-HOME
499 (lambda _ (setenv "HOME" "/tmp") #t))
500 (replace 'build
501 (lambda* (#:key outputs #:allow-other-keys)
502 (setenv "CC" "gcc")
503 (invoke "sh" "make.sh" ,@(match (%current-system)
504 ((or "x86_64-linux" "i686-linux")
505 `("clisp"))
506 (_
507 `("clisp")))
508 (string-append "--prefix="
509 (assoc-ref outputs "out"))
510 "--dynamic-space-size=2Gb"
511 "--with-sb-core-compression"
512 "--with-sb-xref-for-internals")))
513 (replace 'install
514 (lambda _
515 (invoke "sh" "install.sh")))
516 (add-after 'build 'build-doc
517 (lambda _
518 ;; TODO: Doc is not deterministic, maybe there is a timespamp?
519 (with-directory-excursion "doc/manual"
520 (and (invoke "make" "info")
521 (invoke "make" "dist")))))
522 (add-after 'build 'build-source
523 (lambda* (#:key outputs #:allow-other-keys)
524 (let* ((out (assoc-ref outputs "out"))
525 (rc (string-append out "/lib/sbcl/sbclrc"))
526 (source-dir (string-append out "/share/sbcl")))
527 (for-each (lambda (p)
528 (copy-recursively p (string-append source-dir "/" p)))
529 '("src" "contrib"))
530 (mkdir-p (dirname rc))
531 (with-output-to-file rc
532 (lambda ()
533 (display
534 (string-append "(sb-ext:set-sbcl-source-location \""
535 source-dir "\")") )))
536 #t)))
537 (add-after 'install 'install-doc
538 (lambda* (#:key outputs #:allow-other-keys)
539 (let* ((out (assoc-ref outputs "out"))
540 (doc (assoc-ref outputs "doc"))
541 (old-doc-dir (string-append out "/share/doc"))
542 (new-doc/sbcl-dir (string-append doc "/share/doc/sbcl")))
543 (rmdir (string-append old-doc-dir "/sbcl/html"))
544 (mkdir-p new-doc/sbcl-dir)
545 (copy-recursively (string-append old-doc-dir "/sbcl")
546 new-doc/sbcl-dir)
547 (delete-file-recursively old-doc-dir)
548 #t))))
549 ;; No 'check' target, though "make.sh" (build phase) runs tests.
550 #:tests? #f))
551 (native-search-paths
552 (list (search-path-specification
553 (variable "XDG_DATA_DIRS")
554 (files '("share")))
555 (search-path-specification
556 (variable "XDG_CONFIG_DIRS")
557 (files '("etc")))))
558 (home-page "http://www.sbcl.org/")
559 (synopsis "Common Lisp implementation")
560 (description "Steel Bank Common Lisp (SBCL) is a high performance Common
561 Lisp compiler. In addition to the compiler and runtime system for ANSI Common
562 Lisp, it provides an interactive environment including a debugger, a
563 statistical profiler, a code coverage tool, and many other extensions.")
564 ;; Public domain in jurisdictions that allow it, bsd-2 otherwise. MIT
565 ;; loop macro has its own license. See COPYING file for further notes.
566 (license (list license:public-domain license:bsd-2
567 (license:x11-style "file://src/code/loop.lisp")))))
568
569 (define-public ccl
570 ;; Warning: according to upstream, CCL is not bootstrappable.
571 ;; See https://github.com/Clozure/ccl/issues/222 from 2019-09-02:
572 ;;
573 ;; "As far as I know, there is no way to build CCL without an existing
574 ;; running CCL image. It was bootstrapped back in 1986 or so as
575 ;; Macintosh Common Lisp, by Gary Byers, I believe, who is no longer on
576 ;; the planet to tell us the story. It SHOULD be possible to port the
577 ;; CCL compiler to portable Common Lisp, so that ANY lisp could build
578 ;; it, as is the case for SBCL, but I know of no attempt to do so."
579 (package
580 (name "ccl")
581 (version "1.12")
582 (source (origin
583 (method git-fetch)
584 (uri (git-reference
585 (url "https://github.com/Clozure/ccl/")
586 (commit (string-append "v" version))))
587 (file-name (git-file-name "ccl" version))
588 (sha256
589 (base32
590 "0kxr24d2fzsmpsilijpwwfl6g89y7fcrwb80kai5nx9pwgxmjbp3"))))
591 (build-system gnu-build-system)
592 ;; CCL consists of a "lisp kernel" and "heap image", both of which are
593 ;; shipped in precompiled form in source tarballs. The former is a C
594 ;; program which we can rebuild from scratch, but the latter cannot be
595 ;; generated without an already working copy of CCL, and is platform
596 ;; dependent, so we need to fetch the correct tarball for the platform.
597 (inputs
598 `(("ccl-bootstrap"
599 ,(origin
600 (method url-fetch)
601 (uri (string-append
602 "https://github.com/Clozure/ccl/releases/download/v" version "/"
603 (match (%current-system)
604 ("armhf-linux" "linuxarm")
605 ;; XXX: This source only works on x86, but provide it as a
606 ;; catch-all to prevent errors when querying this package
607 ;; on unsupported platforms.
608 (_ "linuxx86"))
609 ".tar.gz"))
610 (sha256
611 (base32
612 (match (%current-system)
613 ("armhf-linux"
614 "0x4bjx6cxsjvxyagijhlvmc7jkyxifdvz5q5zvz37028va65243c")
615 (_ "15l7cfa4a7jkfwdzsfm4q3n22jnb57imxahpql3h77xin57v1gbz"))))))))
616 (native-inputs
617 `(("m4" ,m4)))
618 (arguments
619 `(#:tests? #f ;no 'check' target
620 #:modules ((ice-9 match)
621 (srfi srfi-26)
622 (guix build utils)
623 (guix build gnu-build-system))
624 #:phases
625 (modify-phases %standard-phases
626 (add-after 'unpack 'unpack-image
627 (lambda* (#:key inputs #:allow-other-keys)
628 (invoke "tar" "xzvf" (assoc-ref inputs "ccl-bootstrap"))))
629 (delete 'configure)
630 (add-before 'build 'pre-build
631 ;; Enter the source directory for the current platform's lisp
632 ;; kernel, and run 'make clean' to remove the precompiled one.
633 (lambda* (#:key system #:allow-other-keys)
634 (substitute* "lisp-kernel/m4macros.m4"
635 (("/bin/pwd") (which "pwd")))
636 (chdir (string-append
637 "lisp-kernel/"
638 (match system
639 ("i686-linux" "linuxx8632")
640 ("x86_64-linux" "linuxx8664")
641 ("armhf-linux" "linuxarm")
642 (_ (string-append "unknown system: " system)))))
643 (substitute* '("Makefile")
644 (("/bin/rm") "rm"))
645 (setenv "CC" "gcc")
646 (invoke "make" "clean")))
647 ;; XXX Do we need to recompile the heap image as well for Guix?
648 ;; For now just use the one we already got in the tarball.
649 (replace 'install
650 (lambda* (#:key outputs inputs system #:allow-other-keys)
651 ;; The lisp kernel built by running 'make' in lisp-kernel/$system
652 ;; is put back into the original directory, so go back. The heap
653 ;; image is there as well.
654 (chdir "../..")
655 (let* ((out (assoc-ref outputs "out"))
656 (libdir (string-append out "/lib/"))
657 (bindir (string-append out "/bin/"))
658 (wrapper (string-append bindir "ccl"))
659 (bash (assoc-ref inputs "bash"))
660 (kernel
661 (match system
662 ("i686-linux" "lx86cl")
663 ("x86_64-linux" "lx86cl64")
664 ("armhf-linux" "armcl")
665 ;; Unlikely to work, but try it anyway...
666 (_ system)))
667 (heap (string-append kernel ".image")))
668 (install-file kernel libdir)
669 (install-file heap libdir)
670
671 (let ((dirs `("lib" "library" "examples" "tools" "objc-bridge"
672 ,@(match system
673 ("x86_64-linux"
674 '("x86-headers64"))
675 ("i686-linux"
676 '("x86-headers"))
677 (_ '())))))
678 (for-each copy-recursively
679 dirs
680 (map (cut string-append libdir <>) dirs)))
681
682 (mkdir-p bindir)
683 (with-output-to-file wrapper
684 (lambda ()
685 (display
686 (string-append
687 "#!" bash "/bin/sh\n"
688 "export CCL_DEFAULT_DIRECTORY=" libdir "\n"
689 "exec -a \"$0\" " libdir kernel " \"$@\"\n"))))
690 (chmod wrapper #o755))
691 #t)))))
692 (supported-systems '("i686-linux" "x86_64-linux" "armhf-linux"))
693 (home-page "https://ccl.clozure.com/")
694 (synopsis "Common Lisp implementation")
695 (description "Clozure CL (often called CCL for short) is a Common Lisp
696 implementation featuring fast compilation speed, native threads, a precise,
697 generational, compacting garbage collector, and a convenient foreign-function
698 interface.")
699 (license license:asl2.0)))
700
701 (define-public lush2
702 (package
703 (name "lush2")
704 (version "2.0.1")
705 (source
706 (origin
707 (method url-fetch)
708 (uri (string-append "mirror://sourceforge/lush/lush2/lush-"
709 version ".tar.gz"))
710 (modules '((guix build utils)))
711 (snippet
712 '(begin
713 (substitute* "src/unix.c"
714 (("\\{ \"LUSH_DATE\", __DATE__ \\},") "")
715 (("\\{ \"LUSH_TIME\", __TIME__ \\},") ""))
716 (substitute* "src/main.c"
717 (("\" \\(built \" __DATE__ \"\\)\"") ""))
718 #t))
719 (sha256
720 (base32
721 "02pkfn3nqdkm9fm44911dbcz0v3r0l53vygj8xigl6id5g3iwi4k"))))
722 (build-system gnu-build-system)
723 (arguments
724 `(;; We have to add these LIBS so that they are found.
725 #:configure-flags (list "LIBS=-lz"
726 "X_EXTRA_LIBS=-lfontconfig"
727 "--with-x")
728 #:tests? #f)) ; No make check.
729 (native-inputs `(("intltool" ,intltool)))
730 (inputs
731 `(("alsa-lib" ,alsa-lib)
732 ("sdl" ,sdl)
733 ("sdl-image" ,sdl-image)
734 ("sdl-mixer" ,sdl-mixer)
735 ("sdl-net" ,sdl-net)
736 ("sdl-ttf" ,sdl-ttf)
737 ("lapack" ,lapack)
738 ("libxft" ,libxft)
739 ("fontconfig" ,fontconfig)
740 ("gsl" ,gsl)
741 ("openblas" ,openblas)
742 ("glu" ,glu)
743 ("mesa" ,mesa)
744 ("mesa-utils" ,mesa-utils)
745 ("binutils" ,binutils)
746 ("libiberty" ,libiberty)
747 ("readline" ,readline)
748 ("zlib" ,zlib)
749 ("gettext-minimal" ,gettext-minimal)))
750 (synopsis "Lisp Universal Shell")
751 (description
752 "Lush is an object-oriented Lisp interpreter/compiler with features
753 designed to please people who want to prototype large numerical
754 applications. Lush includes an extensive library of
755 vector/matrix/tensor manipulation, numerous numerical libraries
756 (including GSL, LAPACK, and BLAS), a set of graphic functions, a
757 simple GUI toolkit, and interfaces to various graphic and multimedia
758 libraries such as OpenGL, SDL, Video4Linux, and ALSA (video/audio
759 grabbing), and others. Lush is an ideal frontend script language for
760 programming projects written in C or other languages. Lush also has
761 libraries for Machine Learning, Neural Nets and statistical estimation.")
762 (home-page "http://lush.sourceforge.net/")
763 (license license:lgpl2.1+)))
764
765 (define-public confusion-mdl
766 (let* ((commit "12a055581fc262225272df43287dae48281900f5"))
767 (package
768 (name "confusion-mdl")
769 (version "0.2")
770 (source (origin
771 (method git-fetch)
772 (uri (git-reference
773 (url (string-append "https://gitlab.com/emacsomancer/" name))
774 (commit commit)))
775 (sha256
776 (base32
777 "1zi8kflzvwqg97ha1sa5xjisbjs5z1mvbpa772vfxiv5ksnpxp0d"))
778 (file-name (git-file-name name version))))
779 (build-system gnu-build-system)
780 (arguments
781 `(#:tests? #f ; there are no tests
782 #:phases
783 (modify-phases %standard-phases
784 (delete 'configure)
785 (replace 'build
786 (lambda* (#:key (make-flags '()) #:allow-other-keys)
787 (apply invoke "make" "CC=gcc" make-flags)))
788 (replace 'install
789 (lambda* (#:key outputs #:allow-other-keys)
790 (let* ((out (assoc-ref outputs "out"))
791 (bin (string-append out "/bin")))
792 (install-file "mdli" bin)
793 #t))))))
794 (native-inputs
795 `(("perl" ,perl)))
796 (inputs
797 `(("libgc" ,libgc)))
798 (synopsis "Interpreter for the MIT Design Language (MDL)")
799 (description "MDL (the MIT Design Language) is a descendant of Lisp. It
800 was originally developed in 1971 on the PDP-10 computer under the Incompatible
801 Timesharing System (ITS) to provide high level language support for the
802 Dynamic Modeling Group at MIT's Project MAC. Infocom built the original
803 PDP-10 Zork in MDL and their later ZIL (Zork Implementation Language) was
804 based on a subset of MDL. Confusion is a MDL interpreter that works just well
805 enough to play the original mainframe Zork all the way through.")
806 (home-page "http://www.russotto.net/git/mrussotto/confusion/src/master/src/README")
807 (license license:gpl3+))))
808
809 (define-public txr
810 (package
811 (name "txr")
812 (version "244")
813 (source
814 (origin
815 (method git-fetch)
816 (uri (git-reference
817 (url "http://www.kylheku.com/git/txr/")
818 (commit (string-append "txr-" version))))
819 (file-name (git-file-name name version))
820 (sha256
821 (base32 "1bzhb1pms6gjzphbsimhwdyq46ik1m7sgldigg5l1q7bppg9r3i0"))))
822 (build-system gnu-build-system)
823 (arguments
824 `(#:configure-flags
825 (list ,(string-append "cc=" (cc-for-target))
826 (string-append "--prefix=" (assoc-ref %outputs "out")))
827 #:test-target "tests"
828 #:phases
829 (modify-phases %standard-phases
830 (replace 'configure
831 ;; ./configure is a hand-written script that can't handle standard
832 ;; autotools arguments like CONFIG_SHELL.
833 (lambda* (#:key configure-flags #:allow-other-keys)
834 (setenv "txr_shell" (which "bash"))
835 (apply invoke "./configure" configure-flags)
836 #t))
837 (add-after 'configure 'fix-tests
838 (lambda _
839 (substitute* (list "tests/017/realpath.tl"
840 "tests/017/realpath.expected")
841 (("/usr/bin") "/"))
842 #t)))))
843 (inputs
844 `(("libffi" ,libffi)))
845 (synopsis "General-purpose, multi-paradigm programming language")
846 (description
847 "TXR is a general-purpose, multi-paradigm programming language. It
848 comprises two languages integrated into a single tool: a text scanning and
849 extraction language referred to as the TXR Pattern Language (sometimes just
850 \"TXR\"), and a general-purpose dialect of Lisp called TXR Lisp. TXR can be
851 used for everything from \"one liner\" data transformation tasks at the
852 command line, to data scanning and extracting scripts, to full application
853 development in a wide-range of areas.")
854 (home-page "https://nongnu.org/txr/")
855 (license license:bsd-2)))
856
857 (define picolisp32
858 (package
859 (name "picolisp32")
860 (version "19.12")
861 (source
862 (origin
863 (method url-fetch)
864 (uri (string-append "https://software-lab.de/picoLisp-" version ".tgz"))
865 (sha256
866 (base32 "10np0mhihr47r3201617zccrvzpkhdl1jwvz7zimk8kxpriydq2j"))
867 (modules '((guix build utils)))
868 (snippet '(begin
869 ;; Delete the pre-compiled jar file.
870 (delete-file "ersatz/picolisp.jar")
871 #t))))
872 (build-system gnu-build-system)
873 (inputs
874 `(("openssl" ,openssl)))
875 (arguments
876 `(#:system ,(match (%current-system)
877 ((or "armhf-linux" "aarch64-linux")
878 "armhf-linux")
879 (_
880 "i686-linux"))
881 #:phases
882 (modify-phases %standard-phases
883 (delete 'configure)
884 (add-after 'unpack 'fix-paths
885 (lambda* (#:key outputs #:allow-other-keys)
886 (let* ((out (assoc-ref outputs "out"))
887 (shebang-line (string-append
888 "#!" out "/bin/picolisp "
889 out "/lib/picolisp/lib.l")))
890 (substitute* '("bin/pil"
891 "bin/pilIndent"
892 "bin/pilPretty"
893 "bin/psh"
894 "bin/replica"
895 "bin/vip"
896 "bin/watchdog"
897 "games/xchess"
898 "misc/bigtest"
899 "misc/calc"
900 "misc/chat"
901 "misc/mailing"
902 "src/mkVers")
903 (("#\\!bin/picolisp lib.l")
904 shebang-line)
905 (("#\\!\\.\\./bin/picolisp \\.\\./lib.l")
906 shebang-line)
907 (("#\\!/usr/bin/picolisp /usr/lib/picolisp/lib.l")
908 shebang-line)))
909 #t))
910 (add-after 'fix-paths 'make-build-reproducible
911 (lambda _
912 (substitute* "src64/lib/asm.l"
913 (("\\(prinl \"/\\* \" \\(datSym \\(date\\)\\) \" \\*/\\)")
914 ""))
915 #t))
916 (add-after 'make-build-reproducible 'fix-permissions
917 (lambda _
918 (for-each make-file-writable
919 '("doc/family.tgz"
920 "doc/family64.tgz"
921 "lib/map"
922 "src64/tags"))
923 #t))
924 (replace 'build
925 (lambda _
926 (invoke "make" "-C" "src" "picolisp" "tools" "gate")))
927 (add-before 'check 'set-home-for-tests
928 (lambda _
929 (setenv "HOME" "/tmp")
930 #t))
931 (replace 'check
932 (lambda _
933 (invoke "./pil" "test/lib.l" "-bye" "+")))
934 (replace 'install
935 (lambda* (#:key outputs #:allow-other-keys)
936 (let* ((out (assoc-ref outputs "out"))
937 (bin (string-append out "/bin"))
938 (man (string-append out "/share/man"))
939 (picolisp (string-append out "/lib/picolisp")))
940 (copy-recursively "man" man)
941 (copy-recursively "." picolisp)
942 (for-each (lambda (name)
943 (let ((path (string-append picolisp "/" name)))
944 (delete-file-recursively path)))
945 '("CHANGES" "COPYING" "CREDITS" "cygwin"
946 "INSTALL" "man" "pil" "README" "src" "src64"
947 "test"))
948 (mkdir-p bin)
949 (symlink (string-append picolisp "/bin/picolisp")
950 (string-append bin "/picolisp"))
951 (symlink (string-append picolisp "/bin/pil")
952 (string-append bin "/pil")))
953 #t)))))
954 (synopsis "Interpreter for the PicoLisp programming language")
955 (description
956 "PicoLisp is a programming language, or really a programming system,
957 including a built-in database engine and a GUI system.")
958 (home-page "https://picolisp.com/wiki/?home")
959 (license license:expat)))
960
961 (define-public picolisp
962 (match (%current-system)
963 ((or "aarch64-linux" "x86_64-linux")
964 (package
965 ;; Use the 32-bit picolisp to generate the assembly files required by
966 ;; the 64-bit picolisp.
967 (inherit picolisp32)
968 (name "picolisp")
969 (native-inputs
970 `(("picolisp32" ,picolisp32)
971 ("which" ,which)))
972 (arguments
973 (substitute-keyword-arguments (package-arguments picolisp32)
974 ((#:system _ "") (%current-system))
975 ((#:phases phases)
976 `(modify-phases ,phases
977 (delete 'fix-paths)
978 (add-before 'build 'fix-paths
979 ;; This must run after the other shebang-patching phases,
980 ;; or they will override our changes.
981 (lambda* (#:key inputs outputs #:allow-other-keys)
982 (let* ((picolisp32 (assoc-ref inputs "picolisp32"))
983 (out (assoc-ref outputs "out"))
984 (shebang-line (string-append
985 "#!" out "/bin/picolisp "
986 out "/lib/picolisp/lib.l")))
987 (substitute* '("bin/pil"
988 "bin/pilIndent"
989 "bin/pilPretty"
990 "bin/psh"
991 "bin/replica"
992 "bin/vip"
993 "bin/watchdog"
994 "games/xchess"
995 "misc/bigtest"
996 "misc/calc"
997 "misc/chat"
998 "misc/mailing"
999 "src/mkVers")
1000 (("#\\!.*picolisp32.*/bin/picolisp .*lib\\.l")
1001 shebang-line))
1002 (substitute* "src64/mkAsm"
1003 (("/usr/bin/")
1004 (string-append picolisp32 "/bin/"))))
1005 #t))
1006 (replace 'build
1007 (lambda _
1008 (invoke "make" "-C" "src" "tools" "gate")
1009 (invoke "make" "-C" "src64" "CC=gcc" "picolisp")))))))))
1010 (_
1011 (package
1012 (inherit picolisp32)
1013 (name "picolisp")))))
1014
1015 (define-public janet
1016 (package
1017 (name "janet")
1018 (version "1.12.2")
1019 (source
1020 (origin
1021 (method git-fetch)
1022 (uri (git-reference
1023 (url "https://github.com/janet-lang/janet")
1024 (commit (string-append "v" version))))
1025 (file-name (git-file-name name version))
1026 (sha256
1027 (base32 "0if514zdmbjvvrsa9x5yfvg2b14sz53yaka12g3yhwkq8ls3qk0c"))))
1028 (build-system gnu-build-system)
1029 (arguments
1030 `(#:make-flags (list
1031 (string-append "DESTDIR=" (assoc-ref %outputs "out"))
1032 (string-append "PREFIX=")
1033 (string-append "CC=" (assoc-ref %build-inputs "gcc")
1034 "/bin/gcc"))
1035 #:phases
1036 (modify-phases %standard-phases
1037 (delete 'configure)
1038 (replace 'check
1039 (lambda _
1040 (invoke "make" "test"))))))
1041 (home-page "https://janet-lang.org/")
1042 (synopsis "Functional, imperative and embeddable programming language")
1043 (description
1044 "Janet is a functional and imperative programming language. It can be
1045 used for rapid prototyping, dynamic systems, and other domains where dynamic
1046 languages shine. You can also add Janet scripting to an application by
1047 embedding a single C file and two headers. It can be easily ported to new
1048 platforms. The entire language (core library, interpreter, compiler,
1049 assembler, PEG) is less than 1MB.")
1050 (license license:expat)))