gnu: Add cl-asdf.
[jackhill/guix/guix.git] / gnu / packages / lisp.scm
CommitLineData
f842bbed
JD
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014 John Darrington <jmd@gnu.org>
00ab9458 3;;; Copyright © 2015 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
e396976b 4;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
05f5ce0c 5;;; Copyright © 2016 Federico Beffa <beffa@fbengineering.ch>
47956fa0 6;;; Copyright © 2016, 2017 ng0 <ng0@n0.is>
14afc7b8 7;;; Copyright © 2016, 2017 Andy Patterson <ajpatter@uwaterloo.ca>
e24ef369 8;;; Copyright © 2017, 2019 Ricardo Wurmus <rekado@elephly.net>
040a7440 9;;; Copyright © 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
46c1c553 10;;; Copyright © 2017, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
56c240ba 11;;; Copyright © 2018 Benjamin Slade <slade@jnanam.net>
28e32b14 12;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
02b63821 13;;; Copyright © 2018, 2019 Pierre Neidhardt <mail@ambrevar.xyz>
c894b803 14;;; Copyright © 2018, 2019 Pierre Langlois <pierre.langlois@gmx.com>
d276ffca 15;;; Copyright © 2019, 2020 Katherine Cox-Buday <cox.katherine.e@gmail.com>
29331827 16;;; Copyright © 2019 Jesse Gildersleve <jessejohngildersleve@protonmail.com>
e4c9ba4d 17;;; Copyright © 2019, 2020 Guillaume Le Vaillant <glv@posteo.net>
f842bbed
JD
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
88f06fd0
PN
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
f842bbed
JD
39(define-module (gnu packages lisp)
40 #:use-module (gnu packages)
b5b73a82 41 #:use-module ((guix licenses) #:prefix license:)
f842bbed 42 #:use-module (guix packages)
f842bbed 43 #:use-module (guix download)
423eef36 44 #:use-module (guix git-download)
f842bbed 45 #:use-module (guix utils)
00ab9458 46 #:use-module (guix build-system gnu)
28e32b14 47 #:use-module (guix build-system ant)
a72debb7 48 #:use-module (guix build-system asdf)
e3e171ee 49 #:use-module (guix build-system trivial)
5ff15b86 50 #:use-module (gnu packages admin)
ce0614dd 51 #:use-module (gnu packages base)
5ff15b86 52 #:use-module (gnu packages bdw-gc)
a0c3a2e3 53 #:use-module (gnu packages bison)
05c63898 54 #:use-module (gnu packages compression)
5ff15b86 55 #:use-module (gnu packages ed)
a0c3a2e3 56 #:use-module (gnu packages flex)
05c63898 57 #:use-module (gnu packages fontutils)
5ff15b86
EF
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)
05c63898 63 #:use-module (gnu packages maths)
00ab9458 64 #:use-module (gnu packages multiprecision)
f473b8f1 65 #:use-module (gnu packages ncurses)
560f51d0 66 #:use-module (gnu packages libffcall)
5ff15b86 67 #:use-module (gnu packages libffi)
b702b52d 68 #:use-module (gnu packages libsigsegv)
05c63898 69 #:use-module (gnu packages linux)
5ff15b86 70 #:use-module (gnu packages perl)
5ff15b86
EF
71 #:use-module (gnu packages readline)
72 #:use-module (gnu packages sdl)
73 #:use-module (gnu packages tex)
e4c9ba4d 74 #:use-module (gnu packages tls)
5ff15b86 75 #:use-module (gnu packages texinfo)
531a9aac 76 #:use-module (gnu packages version-control)
05c63898 77 #:use-module (gnu packages xorg)
88f06fd0 78 #:use-module (ice-9 match))
f842bbed 79
8d0489ae
AP
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
d276ffca
KCB
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
121the successor of the Lisp DEFSYSTEM of yore. ASDF stands for Another System
122Definition Facility.")
123 ;; MIT License
124 (license license:expat)))
125
f842bbed 126(define-public gcl
5a8b00f2
KK
127 (let ((commit "d3335e2b3deb63f930eb0328e9b05377744c9512")
128 (revision "2")) ;Guix package revision
dd0134fc
KK
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
5a8b00f2 141 (base32 "05v86lhvsby05nzvcd3c4k0wljvgdgd0i6arzd2fx1yd67dl6fgj"))))
dd0134fc
KK
142 (build-system gnu-build-system)
143 (arguments
144 `(#:parallel-build? #f ; The build system seems not to be thread safe.
b888396d 145 #:test-target "ansi-tests/test_results"
dd0134fc
KK
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
978154ae 211 `(("m4" ,m4)
27ebd5c4 212 ("texinfo" ,texinfo)))
dd0134fc
KK
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
f842bbed
JD
216features the ability to compile to native object code and to load native
217object code modules directly into its lisp core. It also features a
218stratified garbage collection strategy, a source-level debugger and a built-in
219interface to the Tk widget system.")
dd0134fc 220 (license license:lgpl2.0+))))
f842bbed 221
00ab9458
TUBK
222(define-public ecl
223 (package
224 (name "ecl")
108f69c4 225 (version "16.1.3")
00ab9458
TUBK
226 (source
227 (origin
228 (method url-fetch)
e0524511
AP
229 (uri (string-append
230 "https://common-lisp.net/project/ecl/static/files/release/"
231 name "-" version ".tgz"))
00ab9458 232 (sha256
108f69c4 233 (base32 "0m0j24w5d5a9dwwqyrg0d35c0nys16ijb4r0nyk87yp82v38b9bn"))
fb7dc6d6
AP
234 (modules '((guix build utils)))
235 (snippet
236 ;; Add ecl-bundle-systems to 'default-system-source-registry'.
6cbee49d
MW
237 `(begin
238 (substitute* "contrib/asdf/asdf.lisp"
239 ,@(asdf-substitutions name))
240 #t))))
00ab9458 241 (build-system gnu-build-system)
cb03a9b6 242 ;; src/configure uses 'which' to confirm the existence of 'gzip'.
00ab9458
TUBK
243 (native-inputs `(("which" ,which)))
244 (inputs `(("gmp" ,gmp)
245 ("libatomic-ops" ,libatomic-ops)
246 ("libgc" ,libgc)
247 ("libffi" ,libffi)))
248 (arguments
fd0f8860
GLV
249 '(#:configure-flags '("--without-rt")
250 #:tests? #t
60474cd1
AP
251 #:parallel-tests? #f
252 #:phases
253 (modify-phases %standard-phases
254 (delete 'check)
54a43ff4
AP
255 (add-after 'install 'wrap
256 (lambda* (#:key inputs outputs #:allow-other-keys)
257 (let* ((ecl (assoc-ref outputs "out"))
258 (input-path (lambda (lib path)
259 (string-append
260 (assoc-ref inputs lib) path)))
261 (libraries '("gmp" "libatomic-ops" "libgc" "libffi" "libc"))
262 (binaries '("gcc" "ld-wrapper" "binutils"))
263 (library-directories
264 (map (lambda (lib) (input-path lib "/lib"))
265 libraries)))
266
267 (wrap-program (string-append ecl "/bin/ecl")
268 `("PATH" prefix
269 ,(map (lambda (binary)
270 (input-path binary "/bin"))
271 binaries))
272 `("CPATH" suffix
273 ,(map (lambda (lib)
274 (input-path lib "/include"))
932b2ea2 275 `("kernel-headers" ,@libraries)))
54a43ff4
AP
276 `("LIBRARY_PATH" suffix ,library-directories)
277 `("LD_LIBRARY_PATH" suffix ,library-directories)))))
108f69c4
AP
278 (add-after 'wrap 'check (assoc-ref %standard-phases 'check))
279 (add-before 'check 'fix-path-to-ecl
280 (lambda _
281 (substitute* "build/tests/Makefile"
282 (("\\$\\{exec_prefix\\}/") ""))
283 #t)))))
fb7dc6d6
AP
284 (native-search-paths
285 (list (search-path-specification
286 (variable "XDG_DATA_DIRS")
287 (files '("share")))))
00ab9458
TUBK
288 (home-page "http://ecls.sourceforge.net/")
289 (synopsis "Embeddable Common Lisp")
290 (description "ECL is an implementation of the Common Lisp language as
291defined by the ANSI X3J13 specification. Its most relevant features are: a
292bytecode compiler and interpreter, being able to compile Common Lisp with any
293C/C++ compiler, being able to build standalone executables and libraries, and
294supporting ASDF, Sockets, Gray streams, MOP, and other useful components.")
295 ;; Note that the file "Copyright" points to some files and directories
296 ;; which aren't under the lgpl2.0+ and instead contain many different,
297 ;; non-copyleft licenses.
298 (license license:lgpl2.0+)))
560f51d0
TUBK
299
300(define-public clisp
301 (package
302 (name "clisp")
e4c399fe 303 (version "2.49-92")
560f51d0
TUBK
304 (source
305 (origin
e4c399fe
EF
306 (method git-fetch)
307 (uri (git-reference
308 (url "https://gitlab.com/gnu-clisp/clisp")
309 (commit "clisp-2.49.92-2018-02-18")))
310 (file-name (git-file-name name version))
560f51d0 311 (sha256
e4c399fe
EF
312 (base32 "0k2dmgl0miz3767iks4p0mvp6xw0ysyxhjpklyh11j010rmh6hqb"))
313 (patches (search-patches "clisp-remove-failing-test.patch"))))
560f51d0
TUBK
314 (build-system gnu-build-system)
315 (inputs `(("libffcall" ,libffcall)
f473b8f1
EF
316 ("ncurses" ,ncurses)
317 ("readline" ,readline)
560f51d0
TUBK
318 ("libsigsegv" ,libsigsegv)))
319 (arguments
e4c399fe
EF
320 `(#:configure-flags '(,@(if (string-prefix? "armhf-linux"
321 (or (%current-system)
322 (%current-target-system)))
323 '("CFLAGS=-falign-functions=4")
324 '())
325 "--with-dynamic-ffi"
326 "--with-dynamic-modules"
327 "--with-module=rawsock")
f90ef3c3
MW
328 #:build #f
329 #:phases
636c77d0
RW
330 (modify-phases %standard-phases
331 (add-after 'unpack 'patch-sh-and-pwd
332 (lambda _
333 ;; The package is very messy with its references to "/bin/sh" and
334 ;; some other absolute paths to traditional tools. These appear in
335 ;; many places where our automatic patching misses them. Therefore
336 ;; we do the following, in this early (post-unpack) phase, to solve
337 ;; the problem from its root.
e4c399fe
EF
338 (substitute* '("src/clisp-link.in"
339 "src/unix.d"
340 "src/makemake.in")
341 (("/bin/sh") (which "sh")))
636c77d0
RW
342 (substitute* (find-files "." "configure|Makefile")
343 (("/bin/sh") "sh"))
344 (substitute* '("src/clisp-link.in")
345 (("/bin/pwd") "pwd"))
636c77d0 346 #t)))
560f51d0
TUBK
347 ;; Makefiles seem to have race conditions.
348 #:parallel-build? #f))
e4c399fe 349 (home-page "https://clisp.sourceforge.io/")
4cc78cb3
LC
350 (synopsis "A Common Lisp implementation")
351 (description
352 "GNU CLISP is an implementation of ANSI Common Lisp. Common Lisp is a
353high-level, object-oriented functional programming language. CLISP includes
354an interpreter, a compiler, a debugger, and much more.")
4bd2e2a5 355 (license license:gpl2+)))
b702b52d 356
cfff8ebc 357(define-public sbcl
b702b52d 358 (package
cfff8ebc 359 (name "sbcl")
10a8fb47 360 (version "2.0.0")
b702b52d
TUBK
361 (source
362 (origin
363 (method url-fetch)
364 (uri (string-append "mirror://sourceforge/sbcl/sbcl/" version "/sbcl-"
365 version "-source.tar.bz2"))
366 (sha256
10a8fb47 367 (base32 "1krgd69cirp4ili2pfsh1a0mfvq722jbknlvmf17qhsxh1b94dlh"))
8d0489ae
AP
368 (modules '((guix build utils)))
369 (snippet
370 ;; Add sbcl-bundle-systems to 'default-system-source-registry'.
6cbee49d
MW
371 `(begin
372 (substitute* "contrib/asdf/asdf.lisp"
373 ,@(asdf-substitutions name))
374 #t))))
b702b52d 375 (build-system gnu-build-system)
05f5ce0c 376 (outputs '("out" "doc"))
b702b52d 377 (native-inputs
4bddcae9
PN
378 ;; From INSTALL:
379 ;; Supported build hosts are:
380 ;; SBCL
381 ;; CMUCL
382 ;; CCL (formerly known as OpenMCL)
383 ;; ABCL (recent versions only)
384 ;; CLISP (only some versions: 2.44.1 is OK, 2.47 is not)
385 ;; XCL
a3439b0c
PN
386 ;;
387 ;; From NEWS:
388 ;; * build enhancement: new host quirks mechanism, support for building under
389 ;; ABCL and ECL (as well as CCL, CMUCL, CLISP and SBCL itself)
390 ;;
391 ;; CCL is not bootstrappable so it won't do. CLISP 2.49 seems to work.
392 ;; ECL too. ECL builds SBCL about 20% slower than CLISP. As of
02b63821 393 ;; 2019-09-05, ECL was last updated in 2016 while CLISP was last updated
a3439b0c
PN
394 ;; in 2010.
395 ;;
cfff8ebc
PN
396 ;; For now we stick to CLISP for all systems. We keep the `match' here to
397 ;; make it easier to change the host compiler for various architectures.
398 `(,@(match (%current-system)
399 ((or "x86_64-linux" "i686-linux")
400 `(("clisp" ,clisp)))
401 (_
402 `(("clisp" ,clisp))))
b702b52d
TUBK
403 ("which" ,which)
404 ("inetutils" ,inetutils) ;for hostname(1)
05f5ce0c 405 ("ed" ,ed)
4bddcae9 406 ("texlive" ,(texlive-union (list texlive-tex-texinfo)))
5c8b9a43
PN
407 ("texinfo" ,texinfo)
408 ("zlib" ,zlib)))
b702b52d 409 (arguments
76d520fa 410 `(#:modules ((guix build gnu-build-system)
f0b7dc7e
ST
411 (guix build utils)
412 (srfi srfi-1))
413 #:phases
1ee131df
FB
414 (modify-phases %standard-phases
415 (delete 'configure)
416 (add-before 'build 'patch-unix-tool-paths
417 (lambda* (#:key outputs inputs #:allow-other-keys)
418 (let ((out (assoc-ref outputs "out"))
419 (bash (assoc-ref inputs "bash"))
420 (coreutils (assoc-ref inputs "coreutils"))
421 (ed (assoc-ref inputs "ed")))
422 (define (quoted-path input path)
423 (string-append "\"" input path "\""))
424 ;; Patch absolute paths in string literals. Note that this
425 ;; occurs in some .sh files too (which contain Lisp code). Use
426 ;; ISO-8859-1 because some of the files are ISO-8859-1 encoded.
427 (with-fluids ((%default-port-encoding #f))
1925a879
AP
428 ;; The removed file is utf-16-be encoded, which gives substitute*
429 ;; trouble. It does not contain references to the listed programs.
430 (substitute* (delete
431 "./tests/data/compile-file-pos-utf16be.lisp"
432 (find-files "." "\\.(lisp|sh)$"))
1ee131df
FB
433 (("\"/bin/sh\"") (quoted-path bash "/bin/sh"))
434 (("\"/usr/bin/env\"") (quoted-path coreutils "/usr/bin/env"))
435 (("\"/bin/cat\"") (quoted-path coreutils "/bin/cat"))
436 (("\"/bin/ed\"") (quoted-path ed "/bin/ed"))
437 (("\"/bin/echo\"") (quoted-path coreutils "/bin/echo"))
438 (("\"/bin/uname\"") (quoted-path coreutils "/bin/uname"))))
439 ;; This one script has a non-string occurrence of /bin/sh.
440 (substitute* '("tests/foreign.test.sh")
441 ;; Leave whitespace so we don't match the shebang.
442 ((" /bin/sh ") " sh "))
443 ;; This file contains a module that can create executable files
444 ;; which depend on the presence of SBCL. It generates shell
445 ;; scripts doing "exec sbcl ..." to achieve this. We patch both
446 ;; the shebang and the reference to "sbcl", tying the generated
447 ;; executables to the exact SBCL package that generated them.
448 (substitute* '("contrib/sb-executable/sb-executable.lisp")
449 (("/bin/sh") (string-append bash "/bin/sh"))
450 (("exec sbcl") (string-append "exec " out "/bin/sbcl")))
451 ;; Disable some tests that fail in our build environment.
452 (substitute* '("contrib/sb-bsd-sockets/tests.lisp")
453 ;; This requires /etc/protocols.
454 (("\\(deftest get-protocol-by-name/error" all)
455 (string-append "#+nil ;disabled by Guix\n" all)))
456 (substitute* '("contrib/sb-posix/posix-tests.lisp")
457 ;; These assume some users/groups which we don't have.
458 (("\\(deftest pwent\\.[12]" all)
459 (string-append "#+nil ;disabled by Guix\n" all))
460 (("\\(deftest grent\\.[12]" all)
02b63821
PN
461 (string-append "#+nil ;disabled by Guix\n" all))))
462 #t))
4bddcae9
PN
463 ;; FIXME: the texlive-union insists on regenerating fonts. It stores
464 ;; them in HOME, so it needs to be writeable.
465 (add-before 'build 'set-HOME
466 (lambda _ (setenv "HOME" "/tmp") #t))
1ee131df
FB
467 (replace 'build
468 (lambda* (#:key outputs #:allow-other-keys)
469 (setenv "CC" "gcc")
cfff8ebc
PN
470 (invoke "sh" "make.sh" ,@(match (%current-system)
471 ((or "x86_64-linux" "i686-linux")
472 `("clisp"))
473 (_
474 `("clisp")))
4bddcae9 475 (string-append "--prefix="
5c8b9a43
PN
476 (assoc-ref outputs "out"))
477 "--with-sb-core-compression"
478 "--with-sb-xref-for-internals")))
1ee131df 479 (replace 'install
b702b52d 480 (lambda _
4bddcae9 481 (invoke "sh" "install.sh")))
05f5ce0c
FB
482 (add-after 'build 'build-doc
483 (lambda _
02b63821 484 ;; TODO: Doc is not deterministic, maybe there is a timespamp?
05f5ce0c 485 (with-directory-excursion "doc/manual"
4bddcae9
PN
486 (and (invoke "make" "info")
487 (invoke "make" "dist")))))
d0480ca1
PN
488 (add-after 'build 'build-source
489 (lambda* (#:key outputs #:allow-other-keys)
490 (let* ((out (assoc-ref outputs "out"))
491 (rc (string-append out "/lib/sbcl/sbclrc"))
492 (source-dir (string-append out "/share/sbcl")))
493 (for-each (lambda (p)
494 (copy-recursively p (string-append source-dir "/" p)))
495 '("src" "contrib"))
496 (mkdir-p (dirname rc))
497 (with-output-to-file rc
498 (lambda ()
499 (display
500 (string-append "(sb-ext:set-sbcl-source-location \""
501 source-dir "\")") )))
502 #t)))
05f5ce0c
FB
503 (add-after 'install 'install-doc
504 (lambda* (#:key outputs #:allow-other-keys)
505 (let* ((out (assoc-ref outputs "out"))
506 (doc (assoc-ref outputs "doc"))
507 (old-doc-dir (string-append out "/share/doc"))
508 (new-doc/sbcl-dir (string-append doc "/share/doc/sbcl")))
509 (rmdir (string-append old-doc-dir "/sbcl/html"))
510 (mkdir-p new-doc/sbcl-dir)
511 (copy-recursively (string-append old-doc-dir "/sbcl")
512 new-doc/sbcl-dir)
513 (delete-file-recursively old-doc-dir)
514 #t))))
1ee131df
FB
515 ;; No 'check' target, though "make.sh" (build phase) runs tests.
516 #:tests? #f))
8d0489ae
AP
517 (native-search-paths
518 (list (search-path-specification
519 (variable "XDG_DATA_DIRS")
520 (files '("share")))))
b702b52d
TUBK
521 (home-page "http://www.sbcl.org/")
522 (synopsis "Common Lisp implementation")
523 (description "Steel Bank Common Lisp (SBCL) is a high performance Common
524Lisp compiler. In addition to the compiler and runtime system for ANSI Common
525Lisp, it provides an interactive environment including a debugger, a
526statistical profiler, a code coverage tool, and many other extensions.")
527 ;; Public domain in jurisdictions that allow it, bsd-2 otherwise. MIT
528 ;; loop macro has its own license. See COPYING file for further notes.
529 (license (list license:public-domain license:bsd-2
530 (license:x11-style "file://src/code/loop.lisp")))))
531a9aac
TUBK
531
532(define-public ccl
a3439b0c
PN
533 ;; Warning: according to upstream, CCL is not bootstrappable.
534 ;; See https://github.com/Clozure/ccl/issues/222 from 2019-09-02:
535 ;;
536 ;; "As far as I know, there is no way to build CCL without an existing
537 ;; running CCL image. It was bootstrapped back in 1986 or so as
538 ;; Macintosh Common Lisp, by Gary Byers, I believe, who is no longer on
539 ;; the planet to tell us the story. It SHOULD be possible to port the
540 ;; CCL compiler to portable Common Lisp, so that ANY lisp could build
541 ;; it, as is the case for SBCL, but I know of no attempt to do so."
531a9aac
TUBK
542 (package
543 (name "ccl")
04ab38b7 544 (version "1.11.5")
531a9aac
TUBK
545 (source #f)
546 (build-system gnu-build-system)
547 ;; CCL consists of a "lisp kernel" and "heap image", both of which are
548 ;; shipped in precompiled form in source tarballs. The former is a C
549 ;; program which we can rebuild from scratch, but the latter cannot be
550 ;; generated without an already working copy of CCL, and is platform
551 ;; dependent, so we need to fetch the correct tarball for the platform.
552 (inputs
553 `(("ccl"
554 ,(origin
555 (method url-fetch)
556 (uri (string-append
04ab38b7 557 "https://github.com/Clozure/ccl/releases/download/v" version
3701f014 558 "/ccl-" version "-"
531a9aac
TUBK
559 (match (%current-system)
560 ((or "i686-linux" "x86_64-linux") "linuxx86")
42f11801
MW
561 ("armhf-linux" "linuxarm")
562 ;; Prevent errors when querying this package on unsupported
563 ;; platforms, e.g. when running "guix package --search="
564 (_ "UNSUPPORTED"))
531a9aac
TUBK
565 ".tar.gz"))
566 (sha256
567 (base32
568 (match (%current-system)
569 ((or "i686-linux" "x86_64-linux")
04ab38b7 570 "0hs1f3z7crgzvinpj990kv9gvbsipxvcvwbmk54n51nasvc5025q")
42f11801 571 ("armhf-linux"
04ab38b7 572 "0p0l1dzsygb6i1xxgbipjpxkn46xhq3jm41a34ga1qqp4x8lkr62")
42f11801 573 (_ ""))))))))
531a9aac
TUBK
574 (native-inputs
575 `(("m4" ,m4)
576 ("subversion" ,subversion)))
577 (arguments
578 `(#:tests? #f ;no 'check' target
fc7d5a34
AP
579 #:modules ((srfi srfi-26)
580 (guix build utils)
581 (guix build gnu-build-system))
531a9aac 582 #:phases
dc1d3cde
KK
583 (modify-phases %standard-phases
584 (replace 'unpack
585 (lambda* (#:key inputs #:allow-other-keys)
7d416066
RW
586 (invoke "tar" "xzvf" (assoc-ref inputs "ccl"))
587 (chdir "ccl")
588 #t))
dc1d3cde
KK
589 (delete 'configure)
590 (add-before 'build 'pre-build
591 ;; Enter the source directory for the current platform's lisp
592 ;; kernel, and run 'make clean' to remove the precompiled one.
593 (lambda _
bcc65510
EF
594 (substitute* "lisp-kernel/m4macros.m4"
595 (("/bin/pwd") (which "pwd")))
dc1d3cde
KK
596 (chdir (string-append
597 "lisp-kernel/"
598 ,(match (or (%current-target-system) (%current-system))
599 ("i686-linux" "linuxx8632")
600 ("x86_64-linux" "linuxx8664")
601 ("armhf-linux" "linuxarm")
602 ;; Prevent errors when querying this package
603 ;; on unsupported platforms, e.g. when running
604 ;; "guix package --search="
605 (_ "UNSUPPORTED"))))
606 (substitute* '("Makefile")
607 (("/bin/rm") "rm"))
608 (setenv "CC" "gcc")
7d416066 609 (invoke "make" "clean")))
dc1d3cde
KK
610 ;; XXX Do we need to recompile the heap image as well for Guix?
611 ;; For now just use the one we already got in the tarball.
612 (replace 'install
531a9aac
TUBK
613 (lambda* (#:key outputs inputs #:allow-other-keys)
614 ;; The lisp kernel built by running 'make' in lisp-kernel/$system
615 ;; is put back into the original directory, so go back. The heap
616 ;; image is there as well.
617 (chdir "../..")
618 (let* ((out (assoc-ref outputs "out"))
619 (libdir (string-append out "/lib/"))
620 (bindir (string-append out "/bin/"))
621 (wrapper (string-append bindir "ccl"))
622 (bash (assoc-ref inputs "bash"))
623 (kernel
624 ,(match (or (%current-target-system) (%current-system))
76eb7266 625 ("i686-linux" "lx86cl")
531a9aac 626 ("x86_64-linux" "lx86cl64")
76eb7266
MW
627 ("armhf-linux" "armcl")
628 ;; Prevent errors when querying this package
629 ;; on unsupported platforms, e.g. when running
630 ;; "guix package --search="
631 (_ "UNSUPPORTED")))
531a9aac 632 (heap (string-append kernel ".image")))
fc7d5a34
AP
633 (install-file kernel libdir)
634 (install-file heap libdir)
635
910ac0ef
PN
636 (let ((dirs '("lib" "library" "examples" "tools" "objc-bridge"
637 ,@(match (%current-system)
638 ("x86_64-linux"
639 '("x86-headers64"))
640 ("i686-linux"
641 '("x86-headers"))
642 (_ '())))))
fc7d5a34
AP
643 (for-each copy-recursively
644 dirs
645 (map (cut string-append libdir <>) dirs)))
646
531a9aac 647 (mkdir-p bindir)
531a9aac
TUBK
648 (with-output-to-file wrapper
649 (lambda ()
650 (display
651 (string-append
652 "#!" bash "/bin/sh\n"
eff8e0b4
PN
653 "export CCL_DEFAULT_DIRECTORY=" libdir "\n"
654 "exec -a \"$0\" " libdir kernel " \"$@\"\n"))))
dc1d3cde
KK
655 (chmod wrapper #o755))
656 #t)))))
531a9aac 657 (supported-systems '("i686-linux" "x86_64-linux" "armhf-linux"))
910ac0ef 658 (home-page "https://ccl.clozure.com/")
531a9aac
TUBK
659 (synopsis "Common Lisp implementation")
660 (description "Clozure CL (often called CCL for short) is a Common Lisp
661implementation featuring fast compilation speed, native threads, a precise,
662generational, compacting garbage collector, and a convenient foreign-function
663interface.")
664 ;; See file doc/LICENSE for clarifications it makes regarding how the LGPL
665 ;; applies to Lisp code according to them.
666 (license (list license:lgpl2.1
667 license:clarified-artistic)))) ;TRIVIAL-LDAP package
423eef36 668
05c63898 669(define-public lush2
670 (package
671 (name "lush2")
672 (version "2.0.1")
673 (source
674 (origin
675 (method url-fetch)
676 (uri (string-append "mirror://sourceforge/lush/lush2/lush-"
677 version ".tar.gz"))
678 (modules '((guix build utils)))
679 (snippet
680 '(begin
681 (substitute* "src/unix.c"
6cbee49d
MW
682 (("\\{ \"LUSH_DATE\", __DATE__ \\},") "")
683 (("\\{ \"LUSH_TIME\", __TIME__ \\},") ""))
684 (substitute* "src/main.c"
685 (("\" \\(built \" __DATE__ \"\\)\"") ""))
686 #t))
05c63898 687 (sha256
688 (base32
689 "02pkfn3nqdkm9fm44911dbcz0v3r0l53vygj8xigl6id5g3iwi4k"))))
690 (build-system gnu-build-system)
691 (arguments
692 `(;; We have to add these LIBS so that they are found.
693 #:configure-flags (list "LIBS=-lz"
694 "X_EXTRA_LIBS=-lfontconfig"
695 "--with-x")
696 #:tests? #f)) ; No make check.
697 (native-inputs `(("intltool" ,intltool)))
698 (inputs
699 `(("alsa-lib" ,alsa-lib)
700 ("sdl" ,sdl)
701 ("sdl-image" ,sdl-image)
702 ("sdl-mixer" ,sdl-mixer)
703 ("sdl-net" ,sdl-net)
704 ("sdl-ttf" ,sdl-ttf)
705 ("lapack" ,lapack)
706 ("libxft" ,libxft)
707 ("fontconfig" ,fontconfig)
708 ("gsl" ,gsl)
709 ("openblas" ,openblas)
710 ("glu" ,glu)
711 ("mesa" ,mesa)
712 ("mesa-utils" ,mesa-utils)
713 ("binutils" ,binutils)
714 ("libiberty" ,libiberty)
715 ("readline" ,readline)
716 ("zlib" ,zlib)
717 ("gettext-minimal" ,gettext-minimal)))
718 (synopsis "Lisp Universal Shell")
719 (description
720 "Lush is an object-oriented Lisp interpreter/compiler with features
721designed to please people who want to prototype large numerical
722applications. Lush includes an extensive library of
723vector/matrix/tensor manipulation, numerous numerical libraries
724(including GSL, LAPACK, and BLAS), a set of graphic functions, a
725simple GUI toolkit, and interfaces to various graphic and multimedia
726libraries such as OpenGL, SDL, Video4Linux, and ALSA (video/audio
727grabbing), and others. Lush is an ideal frontend script language for
728programming projects written in C or other languages. Lush also has
729libraries for Machine Learning, Neural Nets and statistical estimation.")
730 (home-page "http://lush.sourceforge.net/")
731 (license license:lgpl2.1+)))
732
56c240ba
LC
733(define-public confusion-mdl
734 (let* ((commit "12a055581fc262225272df43287dae48281900f5"))
735 (package
736 (name "confusion-mdl")
737 (version "0.2")
738 (source (origin
739 (method git-fetch)
740 (uri (git-reference
741 (url (string-append "https://gitlab.com/emacsomancer/" name))
742 (commit commit)))
743 (sha256
744 (base32
745 "1zi8kflzvwqg97ha1sa5xjisbjs5z1mvbpa772vfxiv5ksnpxp0d"))
746 (file-name (git-file-name name version))))
747 (build-system gnu-build-system)
748 (arguments
749 `(#:tests? #f ; there are no tests
750 #:phases
751 (modify-phases %standard-phases
752 (delete 'configure)
753 (replace 'build
754 (lambda* (#:key (make-flags '()) #:allow-other-keys)
755 (apply invoke "make" "CC=gcc" make-flags)))
756 (replace 'install
757 (lambda* (#:key outputs #:allow-other-keys)
758 (let* ((out (assoc-ref outputs "out"))
759 (bin (string-append out "/bin")))
760 (install-file "mdli" bin)
761 #t))))))
762 (native-inputs
763 `(("perl" ,perl)))
764 (inputs
765 `(("libgc" ,libgc)))
766 (synopsis "Interpreter for the MIT Design Language (MDL)")
767 (description "MDL (the MIT Design Language) is a descendant of Lisp. It
768was originally developed in 1971 on the PDP-10 computer under the Incompatible
769Timesharing System (ITS) to provide high level language support for the
770Dynamic Modeling Group at MIT's Project MAC. Infocom built the original
771PDP-10 Zork in MDL and their later ZIL (Zork Implementation Language) was
772based on a subset of MDL. Confusion is a MDL interpreter that works just well
773enough to play the original mainframe Zork all the way through.")
774 (home-page "http://www.russotto.net/git/mrussotto/confusion/src/master/src/README")
775 (license license:gpl3+))))
99c61242 776
88f06fd0 777(define-public txr
d9544d91 778 (package
88f06fd0 779 (name "txr")
92fcf985 780 (version "230")
d9544d91
TGR
781 (source
782 (origin
783 (method git-fetch)
784 (uri (git-reference
88f06fd0
PN
785 (url "http://www.kylheku.com/git/txr/")
786 (commit (string-append "txr-" version))))
d9544d91 787 (file-name (git-file-name name version))
88f06fd0 788 (patches (search-patches "txr-shell.patch"))
ed0ddadc
GLV
789 (sha256
790 (base32
92fcf985 791 "1ma6nbqsnl4f8ndh47zzc8n5vzcny66v0z3ndddgm3g0bqaxzjzm"))))
88f06fd0 792 (build-system gnu-build-system)
d9544d91 793 (arguments
88f06fd0
PN
794 '(#:configure-flags '("cc=gcc")
795 #:phases (modify-phases %standard-phases
796 (add-after 'configure 'fix-tests
797 (lambda _
798 (substitute* "tests/017/realpath.tl"
799 (("/usr/bin") "/"))
800 (substitute* "tests/017/realpath.expected"
801 (("/usr/bin") "/"))
802 #t))
803 (replace 'check
804 (lambda _
805 (invoke "make" "tests"))))))
806 (native-inputs
807 `(("bison" ,bison)
808 ("flex" ,flex)))
d9544d91 809 (inputs
88f06fd0
PN
810 `(("libffi" ,libffi)))
811 (synopsis "General-purpose, multi-paradigm programming language")
d9544d91 812 (description
88f06fd0
PN
813 "TXR is a general-purpose, multi-paradigm programming language. It
814comprises two languages integrated into a single tool: a text scanning and
815extraction language referred to as the TXR Pattern Language (sometimes just
816\"TXR\"), and a general-purpose dialect of Lisp called TXR Lisp. TXR can be
817used for everything from \"one liner\" data transformation tasks at the
818command line, to data scanning and extracting scripts, to full application
819development in a wide-range of areas.")
820 (home-page "https://nongnu.org/txr/")
821 (license license:bsd-2)))
e4c9ba4d
GLV
822
823(define picolisp32
824 (package
825 (name "picolisp32")
826 (version "19.12")
827 (source
828 (origin
829 (method url-fetch)
830 (uri (string-append "https://software-lab.de/picoLisp-" version ".tgz"))
831 (sha256
832 (base32 "10np0mhihr47r3201617zccrvzpkhdl1jwvz7zimk8kxpriydq2j"))
833 (modules '((guix build utils)))
834 (snippet '(begin
835 ;; Delete the pre-compiled jar file.
836 (delete-file "ersatz/picolisp.jar")
837 #t))))
838 (build-system gnu-build-system)
839 (inputs
840 `(("openssl" ,openssl)))
841 (arguments
842 `(#:system ,(match (%current-system)
843 ((or "armhf-linux" "aarch64-linux")
844 "armhf-linux")
845 (_
846 "i686-linux"))
847 #:phases
848 (modify-phases %standard-phases
849 (delete 'configure)
850 (add-after 'unpack 'fix-paths
851 (lambda* (#:key outputs #:allow-other-keys)
852 (let* ((out (assoc-ref outputs "out"))
853 (shebang-line (string-append
854 "#!" out "/bin/picolisp "
855 out "/lib/picolisp/lib.l")))
856 (substitute* '("bin/pil"
857 "bin/pilIndent"
858 "bin/pilPretty"
859 "bin/psh"
860 "bin/replica"
861 "bin/vip"
862 "bin/watchdog"
863 "games/xchess"
864 "misc/bigtest"
865 "misc/calc"
866 "misc/chat"
867 "misc/mailing"
868 "src/mkVers")
869 (("#\\!bin/picolisp lib.l")
870 shebang-line)
871 (("#\\!\\.\\./bin/picolisp \\.\\./lib.l")
872 shebang-line)
873 (("#\\!/usr/bin/picolisp /usr/lib/picolisp/lib.l")
874 shebang-line)))
875 #t))
876 (add-after 'fix-paths 'make-build-reproducible
877 (lambda _
878 (substitute* "src64/lib/asm.l"
879 (("\\(prinl \"/\\* \" \\(datSym \\(date\\)\\) \" \\*/\\)")
880 ""))
881 #t))
882 (add-after 'make-build-reproducible 'fix-permissions
883 (lambda _
884 (for-each make-file-writable
885 '("doc/family.tgz"
886 "doc/family64.tgz"
887 "lib/map"
888 "src64/tags"))
889 #t))
890 (replace 'build
891 (lambda _
892 (invoke "make" "-C" "src" "picolisp" "tools" "gate")))
893 (add-before 'check 'set-home-for-tests
894 (lambda _
895 (setenv "HOME" "/tmp")
896 #t))
897 (replace 'check
898 (lambda _
899 (invoke "./pil" "test/lib.l" "-bye" "+")))
900 (replace 'install
901 (lambda* (#:key outputs #:allow-other-keys)
902 (let* ((out (assoc-ref outputs "out"))
903 (bin (string-append out "/bin"))
904 (man (string-append out "/share/man"))
905 (picolisp (string-append out "/lib/picolisp")))
906 (copy-recursively "man" man)
907 (copy-recursively "." picolisp)
908 (for-each (lambda (name)
909 (let ((path (string-append picolisp "/" name)))
910 (delete-file-recursively path)))
911 '("CHANGES" "COPYING" "CREDITS" "cygwin"
912 "INSTALL" "man" "pil" "README" "src" "src64"
913 "test"))
914 (mkdir-p bin)
915 (symlink (string-append picolisp "/bin/picolisp")
916 (string-append bin "/picolisp"))
917 (symlink (string-append picolisp "/bin/pil")
918 (string-append bin "/pil")))
919 #t)))))
920 (synopsis "Interpreter for the PicoLisp programming language")
921 (description
922 "PicoLisp is a programming language, or really a programming system,
923including a built-in database engine and a GUI system.")
924 (home-page "https://picolisp.com/wiki/?home")
925 (license license:expat)))
926
927(define-public picolisp
928 (match (%current-system)
929 ((or "aarch64-linux" "x86_64-linux")
930 (package
931 ;; Use the 32-bit picolisp to generate the assembly files required by
932 ;; the 64-bit picolisp.
933 (inherit picolisp32)
934 (name "picolisp")
935 (native-inputs
936 `(("picolisp32" ,picolisp32)
937 ("which" ,which)))
938 (arguments
939 (substitute-keyword-arguments (package-arguments picolisp32)
940 ((#:system _ "") (%current-system))
941 ((#:phases phases)
942 `(modify-phases ,phases
943 (delete 'fix-paths)
944 (add-before 'build 'fix-paths
945 ;; This must run after the other shebang-patching phases,
946 ;; or they will override our changes.
947 (lambda* (#:key inputs outputs #:allow-other-keys)
948 (let* ((picolisp32 (assoc-ref inputs "picolisp32"))
949 (out (assoc-ref outputs "out"))
950 (shebang-line (string-append
951 "#!" out "/bin/picolisp "
952 out "/lib/picolisp/lib.l")))
953 (substitute* '("bin/pil"
954 "bin/pilIndent"
955 "bin/pilPretty"
956 "bin/psh"
957 "bin/replica"
958 "bin/vip"
959 "bin/watchdog"
960 "games/xchess"
961 "misc/bigtest"
962 "misc/calc"
963 "misc/chat"
964 "misc/mailing"
965 "src/mkVers")
966 (("#\\!.*picolisp32.*/bin/picolisp .*lib\\.l")
967 shebang-line))
968 (substitute* "src64/mkAsm"
969 (("/usr/bin/")
970 (string-append picolisp32 "/bin/"))))
971 #t))
972 (replace 'build
973 (lambda _
974 (invoke "make" "-C" "src" "tools" "gate")
975 (invoke "make" "-C" "src64" "CC=gcc" "picolisp")))))))))
976 (_
977 (package
978 (inherit picolisp32)
979 (name "picolisp")))))