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