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