gnu: sbcl: Convert to the 'modify-phases' syntax.
[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>
f842bbed
JD
5;;;
6;;; This file is part of GNU Guix.
7;;;
8;;; GNU Guix is free software; you can redistribute it and/or modify it
9;;; under the terms of the GNU General Public License as published by
10;;; the Free Software Foundation; either version 3 of the License, or (at
11;;; your option) any later version.
12;;;
13;;; GNU Guix is distributed in the hope that it will be useful, but
14;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;;; GNU General Public License for more details.
17;;;
18;;; You should have received a copy of the GNU General Public License
19;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21(define-module (gnu packages lisp)
22 #:use-module (gnu packages)
b5b73a82 23 #:use-module ((guix licenses) #:prefix license:)
f842bbed
JD
24 #:use-module (guix packages)
25 #:use-module (gnu packages readline)
26 #:use-module (gnu packages texinfo)
27 #:use-module (gnu packages texlive)
28 #:use-module (gnu packages m4)
29 #:use-module (guix download)
30 #:use-module (guix utils)
00ab9458 31 #:use-module (guix build-system gnu)
ce0614dd 32 #:use-module (gnu packages base)
00ab9458
TUBK
33 #:use-module (gnu packages multiprecision)
34 #:use-module (gnu packages bdw-gc)
560f51d0
TUBK
35 #:use-module (gnu packages libffi)
36 #:use-module (gnu packages libffcall)
37 #:use-module (gnu packages readline)
b702b52d
TUBK
38 #:use-module (gnu packages libsigsegv)
39 #:use-module (gnu packages admin)
531a9aac
TUBK
40 #:use-module (gnu packages ed)
41 #:use-module (gnu packages m4)
42 #:use-module (gnu packages version-control)
43 #:use-module (ice-9 match))
f842bbed
JD
44
45(define-public gcl
46 (package
47 (name "gcl")
e6c1e91d 48 (version "2.6.12")
f842bbed
JD
49 (source
50 (origin
51 (method url-fetch)
52 (uri (string-append "mirror://gnu/" name "/" name "-" version ".tar.gz"))
53 (sha256
e6c1e91d 54 (base32 "1s4hs2qbjqmn9h88l4xvsifq5c3dlc5s74lyb61rdi5grhdlkf4f"))))
f842bbed
JD
55 (build-system gnu-build-system)
56 (arguments
57 `(#:parallel-build? #f ; The build system seems not to be thread safe.
58 #:tests? #f ; There does not seem to be make check or anything similar.
59 #:configure-flags '("--enable-ansi") ; required for use by the maxima package
60 #:phases (alist-cons-before
61 'configure 'pre-conf
a124bbd2 62 (lambda _
f842bbed
JD
63 ;; Patch bug when building readline support. This bug was
64 ;; also observed by Debian
65 ;; https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=741819
66 (substitute* "o/gcl_readline.d"
a124bbd2
SB
67 (("rl_attempted_completion_function = \
68\\(CPPFunction \\*\\)rl_completion;")
f842bbed 69 "rl_attempted_completion_function = rl_completion;"))
a124bbd2
SB
70 (substitute*
71 (append
f842bbed
JD
72 '("pcl/impl/kcl/makefile.akcl"
73 "add-defs"
74 "unixport/makefile.dos"
75 "add-defs.bat"
76 "gcl-tk/makefile.prev"
77 "add-defs1")
78 (find-files "h" "\\.defs"))
79 (("SHELL=/bin/(ba)?sh")
80 (string-append "SHELL=" (which "bash")))))
46251411
AE
81 ;; drop strip phase to make maxima build, see
82 ;; https://www.ma.utexas.edu/pipermail/maxima/2008/009769.html
83 (alist-delete 'strip
84 %standard-phases))))
f842bbed
JD
85 (native-inputs
86 `(("m4" ,m4)
87 ("readline" ,readline)
88 ("texinfo" ,texinfo)
89 ("texlive" ,texlive)))
90 (home-page "http://www.gnu.org/software/gcl")
a2b63d58 91 (synopsis "A Common Lisp implementation")
f842bbed
JD
92 (description "GCL is an implementation of the Common Lisp language. It
93features the ability to compile to native object code and to load native
94object code modules directly into its lisp core. It also features a
95stratified garbage collection strategy, a source-level debugger and a built-in
96interface to the Tk widget system.")
97 (license license:lgpl2.0+)))
98
00ab9458
TUBK
99(define-public ecl
100 (package
101 (name "ecl")
cb03a9b6 102 (version "15.2.21")
00ab9458
TUBK
103 (source
104 (origin
105 (method url-fetch)
106 (uri (string-append "mirror://sourceforge/ecls/ecls/"
107 (version-major+minor version)
108 "/ecl-" version ".tgz"))
109 (sha256
cb03a9b6 110 (base32 "05di23v977byf67rq5bdshw8lqbby1ycbscdcl1vca0z6r1s204j"))))
00ab9458 111 (build-system gnu-build-system)
cb03a9b6 112 ;; src/configure uses 'which' to confirm the existence of 'gzip'.
00ab9458
TUBK
113 (native-inputs `(("which" ,which)))
114 (inputs `(("gmp" ,gmp)
115 ("libatomic-ops" ,libatomic-ops)
116 ("libgc" ,libgc)
117 ("libffi" ,libffi)))
118 (arguments
a124bbd2 119 '(;; During 'make check', ECL fails to initialize with "protocol not
cb03a9b6
TUBK
120 ;; supported", presumably because /etc/protocols is missing in the
121 ;; build environment. See <http://sourceforge.net/p/ecls/bugs/300/>.
122 ;;
123 ;; Should the test suite be re-enabled, it might be necessary to add
124 ;; '#:parallel-tests #f'. See the same bug report as above.
125 ;;
126 ;; The following might also be necessary, due to 'make check' assuming
127 ;; ECL is installed. See <http://sourceforge.net/p/ecls/bugs/299/>.
128 ;;
129 ;; #:phases
130 ;; (let* ((check-phase (assq-ref %standard-phases 'check))
131 ;; (rearranged-phases
132 ;; (alist-cons-after 'install 'check check-phase
133 ;; (alist-delete 'check %standard-phases))))
134 ;; (alist-cons-before
135 ;; 'check 'pre-check
136 ;; (lambda* (#:key outputs #:allow-other-keys)
137 ;; (substitute* '("build/tests/Makefile")
138 ;; (("ECL=ecl")
139 ;; (string-append
140 ;; "ECL=" (assoc-ref outputs "out") "/bin/ecl"))))
141 ;; rearranged-phases))
a124bbd2 142 #:tests? #f))
00ab9458
TUBK
143 (home-page "http://ecls.sourceforge.net/")
144 (synopsis "Embeddable Common Lisp")
145 (description "ECL is an implementation of the Common Lisp language as
146defined by the ANSI X3J13 specification. Its most relevant features are: a
147bytecode compiler and interpreter, being able to compile Common Lisp with any
148C/C++ compiler, being able to build standalone executables and libraries, and
149supporting ASDF, Sockets, Gray streams, MOP, and other useful components.")
150 ;; Note that the file "Copyright" points to some files and directories
151 ;; which aren't under the lgpl2.0+ and instead contain many different,
152 ;; non-copyleft licenses.
153 (license license:lgpl2.0+)))
560f51d0
TUBK
154
155(define-public clisp
156 (package
157 (name "clisp")
158 (version "2.49")
159 (source
160 (origin
161 (method url-fetch)
162 (uri (string-append "mirror://gnu/clisp/release/" version
163 "/clisp-" version ".tar.gz"))
164 (sha256
165 (base32 "0rp82nqp5362isl9i34rwgg04cidz7izljd9d85pqcw1qr964bxx"))))
166 (build-system gnu-build-system)
167 (inputs `(("libffcall" ,libffcall)
168 ("readline" ,readline)
169 ("libsigsegv" ,libsigsegv)))
170 (arguments
f90ef3c3
MW
171 '(;; XXX The custom configure script does not cope well when passed
172 ;; --build=<triplet>.
173 #:build #f
174 #:phases
560f51d0
TUBK
175 (alist-cons-after
176 'unpack 'patch-sh-and-pwd
177 (lambda _
178 ;; The package is very messy with its references to "/bin/sh" and
179 ;; some other absolute paths to traditional tools. These appear in
180 ;; many places where our automatic patching misses them. Therefore
181 ;; we do the following, in this early (post-unpack) phase, to solve
182 ;; the problem from its root.
183 (substitute* (find-files "." "configure|Makefile")
184 (("/bin/sh") "sh"))
185 (substitute* '("src/clisp-link.in")
186 (("/bin/pwd") "pwd")))
187 (alist-cons-before
188 'build 'chdir-to-source
189 (lambda _
190 ;; We are supposed to call make under the src sub-directory.
191 (chdir "src"))
192 %standard-phases))
193 ;; Makefiles seem to have race conditions.
194 #:parallel-build? #f))
195 (home-page "http://www.clisp.org/")
4cc78cb3
LC
196 (synopsis "A Common Lisp implementation")
197 (description
198 "GNU CLISP is an implementation of ANSI Common Lisp. Common Lisp is a
199high-level, object-oriented functional programming language. CLISP includes
200an interpreter, a compiler, a debugger, and much more.")
560f51d0
TUBK
201 ;; Website says gpl2+, COPYRIGHT file says gpl2; actual source files have
202 ;; a lot of gpl3+. (Also some parts are under non-copyleft licenses, such
203 ;; as CLX by Texas Instruments.) In that case gpl3+ wins out.
204 (license license:gpl3+)))
b702b52d
TUBK
205
206(define-public sbcl
207 (package
208 (name "sbcl")
209 (version "1.2.8")
210 (source
211 (origin
212 (method url-fetch)
213 (uri (string-append "mirror://sourceforge/sbcl/sbcl/" version "/sbcl-"
214 version "-source.tar.bz2"))
215 (sha256
216 (base32 "0ab9lw056yf6y0rjmx3iirn5n59pmssqxf00fbmpyl6qsnpaja1d"))))
217 (build-system gnu-build-system)
218 ;; Bootstrap with CLISP.
219 (native-inputs
220 `(("clisp" ,clisp)
221 ("which" ,which)
222 ("inetutils" ,inetutils) ;for hostname(1)
223 ("ed" ,ed)))
224 (arguments
225 '(#:phases
1ee131df
FB
226 (modify-phases %standard-phases
227 (delete 'configure)
228 (add-before 'build 'patch-unix-tool-paths
229 (lambda* (#:key outputs inputs #:allow-other-keys)
230 (let ((out (assoc-ref outputs "out"))
231 (bash (assoc-ref inputs "bash"))
232 (coreutils (assoc-ref inputs "coreutils"))
233 (ed (assoc-ref inputs "ed")))
234 (define (quoted-path input path)
235 (string-append "\"" input path "\""))
236 ;; Patch absolute paths in string literals. Note that this
237 ;; occurs in some .sh files too (which contain Lisp code). Use
238 ;; ISO-8859-1 because some of the files are ISO-8859-1 encoded.
239 (with-fluids ((%default-port-encoding #f))
240 (substitute* (find-files "." "\\.(lisp|sh)$")
241 (("\"/bin/sh\"") (quoted-path bash "/bin/sh"))
242 (("\"/usr/bin/env\"") (quoted-path coreutils "/usr/bin/env"))
243 (("\"/bin/cat\"") (quoted-path coreutils "/bin/cat"))
244 (("\"/bin/ed\"") (quoted-path ed "/bin/ed"))
245 (("\"/bin/echo\"") (quoted-path coreutils "/bin/echo"))
246 (("\"/bin/uname\"") (quoted-path coreutils "/bin/uname"))))
247 ;; This one script has a non-string occurrence of /bin/sh.
248 (substitute* '("tests/foreign.test.sh")
249 ;; Leave whitespace so we don't match the shebang.
250 ((" /bin/sh ") " sh "))
251 ;; This file contains a module that can create executable files
252 ;; which depend on the presence of SBCL. It generates shell
253 ;; scripts doing "exec sbcl ..." to achieve this. We patch both
254 ;; the shebang and the reference to "sbcl", tying the generated
255 ;; executables to the exact SBCL package that generated them.
256 (substitute* '("contrib/sb-executable/sb-executable.lisp")
257 (("/bin/sh") (string-append bash "/bin/sh"))
258 (("exec sbcl") (string-append "exec " out "/bin/sbcl")))
259 ;; Disable some tests that fail in our build environment.
260 (substitute* '("contrib/sb-bsd-sockets/tests.lisp")
261 ;; This requires /etc/protocols.
262 (("\\(deftest get-protocol-by-name/error" all)
263 (string-append "#+nil ;disabled by Guix\n" all)))
264 (substitute* '("contrib/sb-posix/posix-tests.lisp")
265 ;; These assume some users/groups which we don't have.
266 (("\\(deftest pwent\\.[12]" all)
267 (string-append "#+nil ;disabled by Guix\n" all))
268 (("\\(deftest grent\\.[12]" all)
269 (string-append "#+nil ;disabled by Guix\n" all))))))
270 (replace 'build
271 (lambda* (#:key outputs #:allow-other-keys)
272 (setenv "CC" "gcc")
273 (zero? (system* "sh" "make.sh" "clisp"
274 (string-append "--prefix="
275 (assoc-ref outputs "out"))))))
276 (replace 'install
b702b52d 277 (lambda _
1ee131df
FB
278 (zero? (system* "sh" "install.sh")))))
279 ;; No 'check' target, though "make.sh" (build phase) runs tests.
280 #:tests? #f))
b702b52d
TUBK
281 (home-page "http://www.sbcl.org/")
282 (synopsis "Common Lisp implementation")
283 (description "Steel Bank Common Lisp (SBCL) is a high performance Common
284Lisp compiler. In addition to the compiler and runtime system for ANSI Common
285Lisp, it provides an interactive environment including a debugger, a
286statistical profiler, a code coverage tool, and many other extensions.")
287 ;; Public domain in jurisdictions that allow it, bsd-2 otherwise. MIT
288 ;; loop macro has its own license. See COPYING file for further notes.
289 (license (list license:public-domain license:bsd-2
290 (license:x11-style "file://src/code/loop.lisp")))))
531a9aac
TUBK
291
292(define-public ccl
293 (package
294 (name "ccl")
295 (version "1.10")
296 (source #f)
297 (build-system gnu-build-system)
298 ;; CCL consists of a "lisp kernel" and "heap image", both of which are
299 ;; shipped in precompiled form in source tarballs. The former is a C
300 ;; program which we can rebuild from scratch, but the latter cannot be
301 ;; generated without an already working copy of CCL, and is platform
302 ;; dependent, so we need to fetch the correct tarball for the platform.
303 (inputs
304 `(("ccl"
305 ,(origin
306 (method url-fetch)
307 (uri (string-append
308 "ftp://ftp.clozure.com/pub/release/1.10/ccl-" version "-"
309 (match (%current-system)
310 ((or "i686-linux" "x86_64-linux") "linuxx86")
42f11801
MW
311 ("armhf-linux" "linuxarm")
312 ;; Prevent errors when querying this package on unsupported
313 ;; platforms, e.g. when running "guix package --search="
314 (_ "UNSUPPORTED"))
531a9aac
TUBK
315 ".tar.gz"))
316 (sha256
317 (base32
318 (match (%current-system)
319 ((or "i686-linux" "x86_64-linux")
320 "0mr653q5px05lr11z2mk551m5g47b4wq96vbfibpp0qlc9jp58lc")
42f11801
MW
321 ("armhf-linux"
322 "1py02irpmi2qz5rq3h33wfv6impf15z8i2rign6hvhlqn7s99wwh")
323 (_ ""))))))))
531a9aac
TUBK
324 (native-inputs
325 `(("m4" ,m4)
326 ("subversion" ,subversion)))
327 (arguments
328 `(#:tests? #f ;no 'check' target
329 #:phases
330 (alist-replace
331 'unpack
332 (lambda* (#:key inputs #:allow-other-keys)
333 (and (zero? (system* "tar" "xzvf" (assoc-ref inputs "ccl")))
334 (begin (chdir "ccl") #t)))
335 (alist-delete
336 'configure
337 (alist-cons-before
338 'build 'pre-build
339 ;; Enter the source directory for the current platform's lisp
340 ;; kernel, and run 'make clean' to remove the precompiled one.
341 (lambda _
342 (chdir (string-append
343 "lisp-kernel/"
344 ,(match (or (%current-target-system) (%current-system))
76eb7266 345 ("i686-linux" "linuxx8632")
531a9aac 346 ("x86_64-linux" "linuxx8664")
76eb7266
MW
347 ("armhf-linux" "linuxarm")
348 ;; Prevent errors when querying this package
349 ;; on unsupported platforms, e.g. when running
350 ;; "guix package --search="
351 (_ "UNSUPPORTED"))))
531a9aac
TUBK
352 (substitute* '("Makefile")
353 (("/bin/rm") "rm"))
354 (setenv "CC" "gcc")
355 (zero? (system* "make" "clean")))
356 ;; XXX Do we need to recompile the heap image as well for Guix?
357 ;; For now just use the one we already got in the tarball.
358 (alist-replace
359 'install
360 (lambda* (#:key outputs inputs #:allow-other-keys)
361 ;; The lisp kernel built by running 'make' in lisp-kernel/$system
362 ;; is put back into the original directory, so go back. The heap
363 ;; image is there as well.
364 (chdir "../..")
365 (let* ((out (assoc-ref outputs "out"))
366 (libdir (string-append out "/lib/"))
367 (bindir (string-append out "/bin/"))
368 (wrapper (string-append bindir "ccl"))
369 (bash (assoc-ref inputs "bash"))
370 (kernel
371 ,(match (or (%current-target-system) (%current-system))
76eb7266 372 ("i686-linux" "lx86cl")
531a9aac 373 ("x86_64-linux" "lx86cl64")
76eb7266
MW
374 ("armhf-linux" "armcl")
375 ;; Prevent errors when querying this package
376 ;; on unsupported platforms, e.g. when running
377 ;; "guix package --search="
378 (_ "UNSUPPORTED")))
531a9aac
TUBK
379 (heap (string-append kernel ".image")))
380 (mkdir-p libdir)
381 (mkdir-p bindir)
382 (copy-file kernel (string-append libdir kernel))
383 (copy-file heap (string-append libdir heap))
384 (with-output-to-file wrapper
385 (lambda ()
386 (display
387 (string-append
388 "#!" bash "/bin/sh\n"
389 "if [ -z \"$CCL_DEFAULT_DIRECTORY\" ]; then\n"
390 " CCL_DEFAULT_DIRECTORY=" libdir "\n"
391 "fi\n"
392 "export CCL_DEFAULT_DIRECTORY\n"
393 "exec " libdir kernel "\n"))))
394 (chmod wrapper #o755)))
395 %standard-phases))))))
396 (supported-systems '("i686-linux" "x86_64-linux" "armhf-linux"))
397 (home-page "http://ccl.clozure.com/")
398 (synopsis "Common Lisp implementation")
399 (description "Clozure CL (often called CCL for short) is a Common Lisp
400implementation featuring fast compilation speed, native threads, a precise,
401generational, compacting garbage collector, and a convenient foreign-function
402interface.")
403 ;; See file doc/LICENSE for clarifications it makes regarding how the LGPL
404 ;; applies to Lisp code according to them.
405 (license (list license:lgpl2.1
406 license:clarified-artistic)))) ;TRIVIAL-LDAP package