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