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