Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / lisp.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 John Darrington <jmd@gnu.org>
3 ;;; Copyright © 2015 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
4 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
5 ;;;
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)
23 #:use-module ((guix licenses) #:prefix license:)
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)
31 #:use-module (guix build-system gnu)
32 #:use-module (gnu packages base)
33 #:use-module (gnu packages multiprecision)
34 #:use-module (gnu packages bdw-gc)
35 #:use-module (gnu packages libffi)
36 #:use-module (gnu packages libffcall)
37 #:use-module (gnu packages readline)
38 #:use-module (gnu packages libsigsegv)
39 #:use-module (gnu packages admin)
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))
44
45 (define-public gcl
46 (package
47 (name "gcl")
48 (version "2.6.12")
49 (source
50 (origin
51 (method url-fetch)
52 (uri (string-append "mirror://gnu/" name "/" name "-" version ".tar.gz"))
53 (sha256
54 (base32 "1s4hs2qbjqmn9h88l4xvsifq5c3dlc5s74lyb61rdi5grhdlkf4f"))))
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
62 (lambda _
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"
67 (("rl_attempted_completion_function = \\(CPPFunction \\*\\)rl_completion;")
68 "rl_attempted_completion_function = rl_completion;"))
69 (substitute*
70 (append
71 '("pcl/impl/kcl/makefile.akcl"
72 "add-defs"
73 "unixport/makefile.dos"
74 "add-defs.bat"
75 "gcl-tk/makefile.prev"
76 "add-defs1")
77 (find-files "h" "\\.defs"))
78 (("SHELL=/bin/(ba)?sh")
79 (string-append "SHELL=" (which "bash")))))
80 ;; drop strip phase to make maxima build, see
81 ;; https://www.ma.utexas.edu/pipermail/maxima/2008/009769.html
82 (alist-delete 'strip
83 %standard-phases))))
84 (native-inputs
85 `(("m4" ,m4)
86 ("readline" ,readline)
87 ("texinfo" ,texinfo)
88 ("texlive" ,texlive)))
89 (home-page "http://www.gnu.org/software/gcl")
90 (synopsis "A Common Lisp implementation")
91 (description "GCL is an implementation of the Common Lisp language. It
92 features the ability to compile to native object code and to load native
93 object code modules directly into its lisp core. It also features a
94 stratified garbage collection strategy, a source-level debugger and a built-in
95 interface to the Tk widget system.")
96 (license license:lgpl2.0+)))
97
98 (define-public ecl
99 (package
100 (name "ecl")
101 (version "15.2.21")
102 (source
103 (origin
104 (method url-fetch)
105 (uri (string-append "mirror://sourceforge/ecls/ecls/"
106 (version-major+minor version)
107 "/ecl-" version ".tgz"))
108 (sha256
109 (base32 "05di23v977byf67rq5bdshw8lqbby1ycbscdcl1vca0z6r1s204j"))))
110 (build-system gnu-build-system)
111 ;; src/configure uses 'which' to confirm the existence of 'gzip'.
112 (native-inputs `(("which" ,which)))
113 (inputs `(("gmp" ,gmp)
114 ("libatomic-ops" ,libatomic-ops)
115 ("libgc" ,libgc)
116 ("libffi" ,libffi)))
117 (arguments
118 '(#:tests? #f
119 ;; During 'make check', ECL fails to initialize with "protocol not
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))
142 ))
143 (home-page "http://ecls.sourceforge.net/")
144 (synopsis "Embeddable Common Lisp")
145 (description "ECL is an implementation of the Common Lisp language as
146 defined by the ANSI X3J13 specification. Its most relevant features are: a
147 bytecode compiler and interpreter, being able to compile Common Lisp with any
148 C/C++ compiler, being able to build standalone executables and libraries, and
149 supporting 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+)))
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
171 '(;; XXX The custom configure script does not cope well when passed
172 ;; --build=<triplet>.
173 #:build #f
174 #:phases
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/")
196 (synopsis "A Common Lisp implementation")
197 (description
198 "GNU CLISP is an implementation of ANSI Common Lisp. Common Lisp is a
199 high-level, object-oriented functional programming language. CLISP includes
200 an interpreter, a compiler, a debugger, and much more.")
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+)))
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
226 (alist-delete
227 'configure
228 (alist-cons-before
229 'build 'patch-unix-tool-paths
230 (lambda* (#:key outputs inputs #:allow-other-keys)
231 (let ((out (assoc-ref outputs "out"))
232 (bash (assoc-ref inputs "bash"))
233 (coreutils (assoc-ref inputs "coreutils"))
234 (ed (assoc-ref inputs "ed")))
235 (define (quoted-path input path)
236 (string-append "\"" input path "\""))
237 ;; Patch absolute paths in string literals. Note that this
238 ;; occurs in some .sh files too (which contain Lisp code). Use
239 ;; ISO-8859-1 because some of the files are ISO-8859-1 encoded.
240 (with-fluids ((%default-port-encoding #f))
241 (substitute* (find-files "." "\\.(lisp|sh)$")
242 (("\"/bin/sh\"") (quoted-path bash "/bin/sh"))
243 (("\"/usr/bin/env\"") (quoted-path coreutils "/usr/bin/env"))
244 (("\"/bin/cat\"") (quoted-path coreutils "/bin/cat"))
245 (("\"/bin/ed\"") (quoted-path ed "/bin/ed"))
246 (("\"/bin/echo\"") (quoted-path coreutils "/bin/echo"))
247 (("\"/bin/uname\"") (quoted-path coreutils "/bin/uname"))))
248 ;; This one script has a non-string occurrence of /bin/sh.
249 (substitute* '("tests/foreign.test.sh")
250 ;; Leave whitespace so we don't match the shebang.
251 ((" /bin/sh ") " sh "))
252 ;; This file contains a module that can create executable files
253 ;; which depend on the presence of SBCL. It generates shell
254 ;; scripts doing "exec sbcl ..." to achieve this. We patch both
255 ;; the shebang and the reference to "sbcl", tying the generated
256 ;; executables to the exact SBCL package that generated them.
257 (substitute* '("contrib/sb-executable/sb-executable.lisp")
258 (("/bin/sh") (string-append bash "/bin/sh"))
259 (("exec sbcl") (string-append "exec " out "/bin/sbcl")))
260 ;; Disable some tests that fail in our build environment.
261 (substitute* '("contrib/sb-bsd-sockets/tests.lisp")
262 ;; This requires /etc/protocols.
263 (("\\(deftest get-protocol-by-name/error" all)
264 (string-append "#+nil ;disabled by Guix\n" all)))
265 (substitute* '("contrib/sb-posix/posix-tests.lisp")
266 ;; These assume some users/groups which we don't have.
267 (("\\(deftest pwent\\.[12]" all)
268 (string-append "#+nil ;disabled by Guix\n" all))
269 (("\\(deftest grent\\.[12]" all)
270 (string-append "#+nil ;disabled by Guix\n" all)))))
271 (alist-replace
272 'build
273 (lambda* (#:key outputs #:allow-other-keys)
274 (setenv "CC" "gcc")
275 (zero? (system* "sh" "make.sh" "clisp"
276 (string-append "--prefix="
277 (assoc-ref outputs "out")))))
278 (alist-replace
279 'install
280 (lambda _
281 (zero? (system* "sh" "install.sh")))
282 %standard-phases))))
283 ;; No 'check' target, though "make.sh" (build phase) runs tests.
284 #:tests? #f))
285 (home-page "http://www.sbcl.org/")
286 (synopsis "Common Lisp implementation")
287 (description "Steel Bank Common Lisp (SBCL) is a high performance Common
288 Lisp compiler. In addition to the compiler and runtime system for ANSI Common
289 Lisp, it provides an interactive environment including a debugger, a
290 statistical profiler, a code coverage tool, and many other extensions.")
291 ;; Public domain in jurisdictions that allow it, bsd-2 otherwise. MIT
292 ;; loop macro has its own license. See COPYING file for further notes.
293 (license (list license:public-domain license:bsd-2
294 (license:x11-style "file://src/code/loop.lisp")))))
295
296 (define-public ccl
297 (package
298 (name "ccl")
299 (version "1.10")
300 (source #f)
301 (build-system gnu-build-system)
302 ;; CCL consists of a "lisp kernel" and "heap image", both of which are
303 ;; shipped in precompiled form in source tarballs. The former is a C
304 ;; program which we can rebuild from scratch, but the latter cannot be
305 ;; generated without an already working copy of CCL, and is platform
306 ;; dependent, so we need to fetch the correct tarball for the platform.
307 (inputs
308 `(("ccl"
309 ,(origin
310 (method url-fetch)
311 (uri (string-append
312 "ftp://ftp.clozure.com/pub/release/1.10/ccl-" version "-"
313 (match (%current-system)
314 ((or "i686-linux" "x86_64-linux") "linuxx86")
315 ("armhf-linux" "linuxarm")
316 ;; Prevent errors when querying this package on unsupported
317 ;; platforms, e.g. when running "guix package --search="
318 (_ "UNSUPPORTED"))
319 ".tar.gz"))
320 (sha256
321 (base32
322 (match (%current-system)
323 ((or "i686-linux" "x86_64-linux")
324 "0mr653q5px05lr11z2mk551m5g47b4wq96vbfibpp0qlc9jp58lc")
325 ("armhf-linux"
326 "1py02irpmi2qz5rq3h33wfv6impf15z8i2rign6hvhlqn7s99wwh")
327 (_ ""))))))))
328 (native-inputs
329 `(("m4" ,m4)
330 ("subversion" ,subversion)))
331 (arguments
332 `(#:tests? #f ;no 'check' target
333 #:phases
334 (alist-replace
335 'unpack
336 (lambda* (#:key inputs #:allow-other-keys)
337 (and (zero? (system* "tar" "xzvf" (assoc-ref inputs "ccl")))
338 (begin (chdir "ccl") #t)))
339 (alist-delete
340 'configure
341 (alist-cons-before
342 'build 'pre-build
343 ;; Enter the source directory for the current platform's lisp
344 ;; kernel, and run 'make clean' to remove the precompiled one.
345 (lambda _
346 (chdir (string-append
347 "lisp-kernel/"
348 ,(match (or (%current-target-system) (%current-system))
349 ("i686-linux" "linuxx8632")
350 ("x86_64-linux" "linuxx8664")
351 ("armhf-linux" "linuxarm")
352 ;; Prevent errors when querying this package
353 ;; on unsupported platforms, e.g. when running
354 ;; "guix package --search="
355 (_ "UNSUPPORTED"))))
356 (substitute* '("Makefile")
357 (("/bin/rm") "rm"))
358 (setenv "CC" "gcc")
359 (zero? (system* "make" "clean")))
360 ;; XXX Do we need to recompile the heap image as well for Guix?
361 ;; For now just use the one we already got in the tarball.
362 (alist-replace
363 'install
364 (lambda* (#:key outputs inputs #:allow-other-keys)
365 ;; The lisp kernel built by running 'make' in lisp-kernel/$system
366 ;; is put back into the original directory, so go back. The heap
367 ;; image is there as well.
368 (chdir "../..")
369 (let* ((out (assoc-ref outputs "out"))
370 (libdir (string-append out "/lib/"))
371 (bindir (string-append out "/bin/"))
372 (wrapper (string-append bindir "ccl"))
373 (bash (assoc-ref inputs "bash"))
374 (kernel
375 ,(match (or (%current-target-system) (%current-system))
376 ("i686-linux" "lx86cl")
377 ("x86_64-linux" "lx86cl64")
378 ("armhf-linux" "armcl")
379 ;; Prevent errors when querying this package
380 ;; on unsupported platforms, e.g. when running
381 ;; "guix package --search="
382 (_ "UNSUPPORTED")))
383 (heap (string-append kernel ".image")))
384 (mkdir-p libdir)
385 (mkdir-p bindir)
386 (copy-file kernel (string-append libdir kernel))
387 (copy-file heap (string-append libdir heap))
388 (with-output-to-file wrapper
389 (lambda ()
390 (display
391 (string-append
392 "#!" bash "/bin/sh\n"
393 "if [ -z \"$CCL_DEFAULT_DIRECTORY\" ]; then\n"
394 " CCL_DEFAULT_DIRECTORY=" libdir "\n"
395 "fi\n"
396 "export CCL_DEFAULT_DIRECTORY\n"
397 "exec " libdir kernel "\n"))))
398 (chmod wrapper #o755)))
399 %standard-phases))))))
400 (supported-systems '("i686-linux" "x86_64-linux" "armhf-linux"))
401 (home-page "http://ccl.clozure.com/")
402 (synopsis "Common Lisp implementation")
403 (description "Clozure CL (often called CCL for short) is a Common Lisp
404 implementation featuring fast compilation speed, native threads, a precise,
405 generational, compacting garbage collector, and a convenient foreign-function
406 interface.")
407 ;; See file doc/LICENSE for clarifications it makes regarding how the LGPL
408 ;; applies to Lisp code according to them.
409 (license (list license:lgpl2.1
410 license:clarified-artistic)))) ;TRIVIAL-LDAP package