gnu: Add cl-tga.
[jackhill/guix/guix.git] / gnu / packages / lisp.scm
index f05ced5..4de4e9f 100644 (file)
@@ -3,18 +3,19 @@
 ;;; Copyright © 2015 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2016 Federico Beffa <beffa@fbengineering.ch>
-;;; Copyright © 2016, 2017 ng0 <ng0@n0.is>
+;;; Copyright © 2016, 2017 Nikita <nikita@n0.is>
 ;;; Copyright © 2016, 2017 Andy Patterson <ajpatter@uwaterloo.ca>
 ;;; Copyright © 2017, 2019 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
-;;; Copyright © 2017, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2017, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2018 Benjamin Slade <slade@jnanam.net>
 ;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
-;;; Copyright © 2018, 2019 Pierre Neidhardt <mail@ambrevar.xyz>
+;;; Copyright © 2018, 2019, 2020 Pierre Neidhardt <mail@ambrevar.xyz>
 ;;; Copyright © 2018, 2019 Pierre Langlois <pierre.langlois@gmx.com>
-;;; Copyright © 2019 Katherine Cox-Buday <cox.katherine.e@gmail.com>
+;;; Copyright © 2019, 2020 Katherine Cox-Buday <cox.katherine.e@gmail.com>
 ;;; Copyright © 2019 Jesse Gildersleve <jessejohngildersleve@protonmail.com>
-;;; Copyright © 2019 Guillaume Le Vaillant <glv@posteo.net>
+;;; Copyright © 2019, 2020 Guillaume Le Vaillant <glv@posteo.net>
+;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -71,6 +72,7 @@
   #:use-module (gnu packages readline)
   #:use-module (gnu packages sdl)
   #:use-module (gnu packages tex)
+  #:use-module (gnu packages tls)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages version-control)
   #:use-module (gnu packages xorg)
               :collect `(:directory (,dir \"systems\"))"
              ,lisp))))
 
+(define-public cl-asdf
+  (package
+    (name "cl-asdf")
+    (version "3.3.3")
+    (source
+     (origin
+       (method url-fetch)
+       (uri
+        (string-append "https://common-lisp.net/project/asdf/archives/asdf-"
+                       version ".lisp"))
+       (sha256
+        (base32 "18lr6kxvzhr79c9rx3sdricz30aby866fj0m24w27zxsqlyvn3rd"))))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils)
+                  (guix build lisp-utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils)
+                      (guix build lisp-utils))
+         (let* ((out (string-append (assoc-ref %outputs "out")))
+                (asdf-install (string-append out %source-install-prefix
+                                             "/source/asdf/"))
+                (asdf (string-append (assoc-ref %build-inputs "source"))))
+           (mkdir-p asdf-install)
+           (copy-file asdf (string-append asdf-install "asdf.lisp"))))))
+    (home-page "https://common-lisp.net/project/asdf/")
+    (synopsis "Another System Definition Facility")
+    (description
+     "ASDF is what Common Lisp hackers use to build and load software.  It is
+the successor of the Lisp DEFSYSTEM of yore.  ASDF stands for Another System
+Definition Facility.")
+    ;; MIT License
+    (license license:expat)))
+
 (define-public gcl
   (let ((commit "d3335e2b3deb63f930eb0328e9b05377744c9512")
         (revision "2")) ;Guix package revision
@@ -186,7 +223,7 @@ interface to the Tk widget system.")
 (define-public ecl
   (package
     (name "ecl")
-    (version "16.1.3")
+    (version "20.4.24")
     (source
      (origin
        (method url-fetch)
@@ -194,28 +231,41 @@ interface to the Tk widget system.")
              "https://common-lisp.net/project/ecl/static/files/release/"
              name "-" version ".tgz"))
        (sha256
-        (base32 "0m0j24w5d5a9dwwqyrg0d35c0nys16ijb4r0nyk87yp82v38b9bn"))
-       (modules '((guix build utils)))
-       (snippet
-        ;; Add ecl-bundle-systems to 'default-system-source-registry'.
-        `(begin
-           (substitute* "contrib/asdf/asdf.lisp"
-             ,@(asdf-substitutions name))
-           #t))))
+        (base32 "01qgdmr54wkj854f69qdm9sybrvd6gd21dpx4askdaaqybnkh237"))))
     (build-system gnu-build-system)
     ;; src/configure uses 'which' to confirm the existence of 'gzip'.
-    (native-inputs `(("which" ,which)))
-    (inputs `(("gmp" ,gmp)
-              ("libatomic-ops" ,libatomic-ops)
-              ("libgc" ,libgc)
-              ("libffi" ,libffi)))
+    (native-inputs
+     `(("cl-asdf" ,cl-asdf)
+       ("which" ,which)
+       ("texinfo" ,texinfo)))
+    (inputs
+     `(("gmp" ,gmp)
+       ("libatomic-ops" ,libatomic-ops)
+       ("libgc" ,libgc)
+       ("libffi" ,libffi)))
     (arguments
-     '(#:configure-flags '("--without-rt")
+     `(#:configure-flags '("--without-rt")
+       ;; FIXME: As of version 20.4.24, we pass 17995 tests and fail 7.
+       ;; 2-3 tests may be due to FHS assumptions.
        #:tests? #t
        #:parallel-tests? #f
        #:phases
        (modify-phases %standard-phases
          (delete 'check)
+         (add-after 'unpack 'replace-asdf
+           ;; Use system ASDF instead of bundled one.
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((cl-asdf (assoc-ref inputs "cl-asdf"))
+                    (guix-asdf (string-append
+                                cl-asdf
+                                "/share/common-lisp/source/asdf/asdf.lisp"))
+                    (out (string-append (assoc-ref outputs "out")))
+                    (contrib-asdf "contrib/asdf/asdf.lisp"))
+               (copy-file guix-asdf contrib-asdf)
+               ;; Add ecl-bundle-systems to 'default-system-source-registry'.
+               (substitute* contrib-asdf
+                 ,@(asdf-substitutions name)))
+             #t))
          (add-after 'install 'wrap
            (lambda* (#:key inputs outputs #:allow-other-keys)
              (let* ((ecl (assoc-ref outputs "out"))
@@ -257,9 +307,10 @@ bytecode compiler and interpreter, being able to compile Common Lisp with any
 C/C++ compiler, being able to build standalone executables and libraries, and
 supporting ASDF, Sockets, Gray streams, MOP, and other useful components.")
     ;; Note that the file "Copyright" points to some files and directories
-    ;; which aren't under the lgpl2.0+ and instead contain many different,
+    ;; which aren't under the lgpl2.1+ and instead contain many different,
     ;; non-copyleft licenses.
-    (license license:lgpl2.0+)))
+    ;; See https://common-lisp.net/project/ecl/posts/ECL-license.html.
+    (license license:lgpl2.1+)))
 
 (define-public clisp
   (package
@@ -318,24 +369,19 @@ high-level, object-oriented functional programming language.  CLISP includes
 an interpreter, a compiler, a debugger, and much more.")
     (license license:gpl2+)))
 
+;; NOTE: SBCL 2.0.6 breaks named-readtables and consequently many Common Lisp packages.
+;; See https://github.com/melisgl/named-readtables/issues/19.
 (define-public sbcl
   (package
     (name "sbcl")
-    (version "2.0.0")
+    (version "2.0.5")
     (source
      (origin
        (method url-fetch)
        (uri (string-append "mirror://sourceforge/sbcl/sbcl/" version "/sbcl-"
                            version "-source.tar.bz2"))
        (sha256
-        (base32 "1krgd69cirp4ili2pfsh1a0mfvq722jbknlvmf17qhsxh1b94dlh"))
-       (modules '((guix build utils)))
-       (snippet
-        ;; Add sbcl-bundle-systems to 'default-system-source-registry'.
-        `(begin
-           (substitute* "contrib/asdf/asdf.lisp"
-             ,@(asdf-substitutions name))
-           #t))))
+        (base32 "1jz26w1i3riv032aa35vww4cv7cjk2ww7dp70c7wk4r8s66zhl00"))))
     (build-system gnu-build-system)
     (outputs '("out" "doc"))
     (native-inputs
@@ -353,22 +399,24 @@ an interpreter, a compiler, a debugger, and much more.")
      ;;     ABCL and ECL (as well as CCL, CMUCL, CLISP and SBCL itself)
      ;;
      ;; CCL is not bootstrappable so it won't do.  CLISP 2.49 seems to work.
-     ;; ECL too.  ECL builds SBCL about 20% slower than CLISP.  As of
-     ;; 2019-09-05, ECL was last updated in 2016 while CLISP was last updated
-     ;; in 2010.
+     ;; ECL too.  As of 2020-07-01, ECL was last updated in 2020 while CLISP
+     ;; was last updated in 2010, and both take about the same time to build SBCL.
      ;;
-     ;; For now we stick to CLISP for all systems.  We keep the `match' here to
-     ;; make it easier to change the host compiler for various architectures.
+     ;; For now we stick to CLISP for all systems.  We keep the `match' here
+     ;; to make it easier to change the host compiler for various
+     ;; architectures.  Consider switching to ECL if it gets faster than CLISP
+     ;; (maybe post 2020 release).
      `(,@(match (%current-system)
            ((or "x86_64-linux" "i686-linux")
             `(("clisp" ,clisp)))
            (_
             `(("clisp" ,clisp))))
-       ("which" ,which)
-       ("inetutils" ,inetutils)         ;for hostname(1)
+       ("cl-asdf" ,cl-asdf)
        ("ed" ,ed)
-       ("texlive" ,(texlive-union (list texlive-tex-texinfo)))
+       ("inetutils" ,inetutils)         ;for hostname(1)
        ("texinfo" ,texinfo)
+       ("texlive" ,(texlive-union (list texlive-tex-texinfo)))
+       ("which" ,which)
        ("zlib" ,zlib)))
     (arguments
      `(#:modules ((guix build gnu-build-system)
@@ -377,6 +425,24 @@ an interpreter, a compiler, a debugger, and much more.")
        #:phases
        (modify-phases %standard-phases
          (delete 'configure)
+         (add-after 'unpack 'replace-asdf
+           ;; SBCL developers have not committed to keeping ASDF up to date
+           ;; due to breaking changes [1]. Guix can handle this situation
+           ;; easily, and it behooves us to have more control over what version
+           ;; of ASDF we use to build software; therefore, replace the contrib
+           ;; ASDF with the version packaged into Guix.
+           ;; [1] - https://bugs.launchpad.net/sbcl/+bug/1823442
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((cl-asdf (assoc-ref inputs "cl-asdf"))
+                    (guix-asdf (string-append
+                                cl-asdf
+                                "/share/common-lisp/source/asdf/asdf.lisp"))
+                    (out (string-append (assoc-ref outputs "out")))
+                    (contrib-asdf "contrib/asdf/asdf.lisp"))
+               (copy-file guix-asdf contrib-asdf)
+               (substitute* contrib-asdf
+                 ,@(asdf-substitutions name)))
+             #t))
          (add-before 'build 'patch-unix-tool-paths
            (lambda* (#:key outputs inputs #:allow-other-keys)
              (let ((out (assoc-ref outputs "out"))
@@ -438,6 +504,7 @@ an interpreter, a compiler, a debugger, and much more.")
                                          `("clisp")))
                      (string-append "--prefix="
                                     (assoc-ref outputs "out"))
+                     "--dynamic-space-size=2Gb"
                      "--with-sb-core-compression"
                      "--with-sb-xref-for-internals")))
          (replace 'install
@@ -476,8 +543,8 @@ an interpreter, a compiler, a debugger, and much more.")
                                  new-doc/sbcl-dir)
                (delete-file-recursively old-doc-dir)
                #t))))
-         ;; No 'check' target, though "make.sh" (build phase) runs tests.
-         #:tests? #f))
+       ;; No 'check' target, though "make.sh" (build phase) runs tests.
+       #:tests? #f))
     (native-search-paths
      (list (search-path-specification
             (variable "XDG_DATA_DIRS")
@@ -505,8 +572,16 @@ statistical profiler, a code coverage tool, and many other extensions.")
   ;;     it, as is the case for SBCL, but I know of no attempt to do so."
   (package
     (name "ccl")
-    (version "1.11.5")
-    (source #f)
+    (version "1.12")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/Clozure/ccl/")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name "ccl" version))
+              (sha256
+               (base32
+                "0kxr24d2fzsmpsilijpwwfl6g89y7fcrwb80kai5nx9pwgxmjbp3"))))
     (build-system gnu-build-system)
     ;; CCL consists of a "lisp kernel" and "heap image", both of which are
     ;; shipped in precompiled form in source tarballs.  The former is a C
@@ -514,59 +589,51 @@ statistical profiler, a code coverage tool, and many other extensions.")
     ;; generated without an already working copy of CCL, and is platform
     ;; dependent, so we need to fetch the correct tarball for the platform.
     (inputs
-     `(("ccl"
+     `(("ccl-bootstrap"
         ,(origin
            (method url-fetch)
            (uri (string-append
-                 "https://github.com/Clozure/ccl/releases/download/v" version
-                 "/ccl-" version "-"
+                 "https://github.com/Clozure/ccl/releases/download/v" version "/"
                  (match (%current-system)
-                   ((or "i686-linux" "x86_64-linux") "linuxx86")
                    ("armhf-linux" "linuxarm")
-                   ;; Prevent errors when querying this package on unsupported
-                   ;; platforms, e.g. when running "guix package --search="
-                   (_ "UNSUPPORTED"))
+                   ;; XXX: This source only works on x86, but provide it as a
+                   ;; catch-all to prevent errors when querying this package
+                   ;; on unsupported platforms.
+                   (_ "linuxx86"))
                  ".tar.gz"))
            (sha256
             (base32
              (match (%current-system)
-               ((or "i686-linux" "x86_64-linux")
-                "0hs1f3z7crgzvinpj990kv9gvbsipxvcvwbmk54n51nasvc5025q")
                ("armhf-linux"
-                "0p0l1dzsygb6i1xxgbipjpxkn46xhq3jm41a34ga1qqp4x8lkr62")
-               (_ ""))))))))
+                "0x4bjx6cxsjvxyagijhlvmc7jkyxifdvz5q5zvz37028va65243c")
+               (_ "15l7cfa4a7jkfwdzsfm4q3n22jnb57imxahpql3h77xin57v1gbz"))))))))
     (native-inputs
-     `(("m4" ,m4)
-       ("subversion" ,subversion)))
+     `(("m4" ,m4)))
     (arguments
      `(#:tests? #f                      ;no 'check' target
-       #:modules ((srfi srfi-26)
+       #:modules ((ice-9 match)
+                  (srfi srfi-26)
                   (guix build utils)
                   (guix build gnu-build-system))
        #:phases
        (modify-phases %standard-phases
-         (replace 'unpack
+         (add-after 'unpack 'unpack-image
            (lambda* (#:key inputs #:allow-other-keys)
-             (invoke "tar" "xzvf" (assoc-ref inputs "ccl"))
-             (chdir "ccl")
-             #t))
+             (invoke "tar" "xzvf" (assoc-ref inputs "ccl-bootstrap"))))
          (delete 'configure)
          (add-before 'build 'pre-build
            ;; Enter the source directory for the current platform's lisp
            ;; kernel, and run 'make clean' to remove the precompiled one.
-           (lambda _
+           (lambda* (#:key system #:allow-other-keys)
              (substitute* "lisp-kernel/m4macros.m4"
                (("/bin/pwd") (which "pwd")))
              (chdir (string-append
                      "lisp-kernel/"
-                     ,(match (or (%current-target-system) (%current-system))
-                        ("i686-linux"   "linuxx8632")
-                        ("x86_64-linux" "linuxx8664")
-                        ("armhf-linux"  "linuxarm")
-                        ;; Prevent errors when querying this package
-                        ;; on unsupported platforms, e.g. when running
-                        ;; "guix package --search="
-                        (_              "UNSUPPORTED"))))
+                     (match system
+                       ("i686-linux" "linuxx8632")
+                       ("x86_64-linux" "linuxx8664")
+                       ("armhf-linux" "linuxarm")
+                       (_ (string-append "unknown system: " system)))))
              (substitute* '("Makefile")
                (("/bin/rm") "rm"))
              (setenv "CC" "gcc")
@@ -574,7 +641,7 @@ statistical profiler, a code coverage tool, and many other extensions.")
          ;; XXX Do we need to recompile the heap image as well for Guix?
          ;; For now just use the one we already got in the tarball.
          (replace 'install
-           (lambda* (#:key outputs inputs #:allow-other-keys)
+           (lambda* (#:key outputs inputs system #:allow-other-keys)
              ;; The lisp kernel built by running 'make' in lisp-kernel/$system
              ;; is put back into the original directory, so go back.  The heap
              ;; image is there as well.
@@ -585,25 +652,23 @@ statistical profiler, a code coverage tool, and many other extensions.")
                     (wrapper (string-append bindir "ccl"))
                     (bash (assoc-ref inputs "bash"))
                     (kernel
-                     ,(match (or (%current-target-system) (%current-system))
-                        ("i686-linux"   "lx86cl")
-                        ("x86_64-linux" "lx86cl64")
-                        ("armhf-linux"  "armcl")
-                        ;; Prevent errors when querying this package
-                        ;; on unsupported platforms, e.g. when running
-                        ;; "guix package --search="
-                        (_              "UNSUPPORTED")))
+                     (match system
+                       ("i686-linux" "lx86cl")
+                       ("x86_64-linux" "lx86cl64")
+                       ("armhf-linux" "armcl")
+                       ;; Unlikely to work, but try it anyway...
+                       (_ system)))
                     (heap (string-append kernel ".image")))
                (install-file kernel libdir)
                (install-file heap libdir)
 
-               (let ((dirs '("lib" "library" "examples" "tools" "objc-bridge"
-                             ,@(match (%current-system)
-                                ("x86_64-linux"
-                                 '("x86-headers64"))
-                                ("i686-linux"
-                                 '("x86-headers"))
-                                (_ '())))))
+               (let ((dirs `("lib" "library" "examples" "tools" "objc-bridge"
+                             ,@(match system
+                                 ("x86_64-linux"
+                                  '("x86-headers64"))
+                                 ("i686-linux"
+                                  '("x86-headers"))
+                                 (_ '())))))
                  (for-each copy-recursively
                            dirs
                            (map (cut string-append libdir <>) dirs)))
@@ -625,10 +690,7 @@ statistical profiler, a code coverage tool, and many other extensions.")
 implementation featuring fast compilation speed, native threads, a precise,
 generational, compacting garbage collector, and a convenient foreign-function
 interface.")
-    ;; See file doc/LICENSE for clarifications it makes regarding how the LGPL
-    ;; applies to Lisp code according to them.
-    (license (list license:lgpl2.1
-                   license:clarified-artistic)))) ;TRIVIAL-LDAP package
+    (license license:asl2.0)))
 
 (define-public lush2
   (package
@@ -741,7 +803,7 @@ enough to play the original mainframe Zork all the way through.")
 (define-public txr
   (package
     (name "txr")
-    (version "230")
+    (version "239")
     (source
      (origin
        (method git-fetch)
@@ -749,24 +811,29 @@ enough to play the original mainframe Zork all the way through.")
              (url "http://www.kylheku.com/git/txr/")
              (commit (string-append "txr-" version))))
        (file-name (git-file-name name version))
-       (patches (search-patches "txr-shell.patch"))
        (sha256
-        (base32
-         "1ma6nbqsnl4f8ndh47zzc8n5vzcny66v0z3ndddgm3g0bqaxzjzm"))))
+        (base32 "1jldpkd5f855m3z4zjpd1ha64f405pcdwwrnr8jnk66v22dsvdwx"))))
     (build-system gnu-build-system)
     (arguments
-     '(#:configure-flags '("cc=gcc")
-       #:phases (modify-phases %standard-phases
-                  (add-after 'configure 'fix-tests
-                    (lambda _
-                      (substitute* "tests/017/realpath.tl"
-                        (("/usr/bin") "/"))
-                      (substitute* "tests/017/realpath.expected"
-                        (("/usr/bin") "/"))
-                      #t))
-                  (replace 'check
-                    (lambda _
-                      (invoke "make" "tests"))))))
+     `(#:configure-flags
+       (list ,(string-append "cc=" (cc-for-target))
+             (string-append "--prefix=" (assoc-ref %outputs "out")))
+       #:test-target "tests"
+       #:phases
+       (modify-phases %standard-phases
+         (replace 'configure
+           ;; ./configure is a hand-written script that can't handle standard
+           ;; autotools arguments like CONFIG_SHELL.
+           (lambda* (#:key configure-flags #:allow-other-keys)
+             (setenv "txr_shell" (which "bash"))
+             (apply invoke "./configure" configure-flags)
+             #t))
+         (add-after 'configure 'fix-tests
+           (lambda _
+             (substitute* (list "tests/017/realpath.tl"
+                                "tests/017/realpath.expected")
+               (("/usr/bin") "/"))
+             #t)))))
     (native-inputs
      `(("bison" ,bison)
        ("flex" ,flex)))
@@ -783,3 +850,161 @@ command line, to data scanning and extracting scripts, to full application
 development in a wide-range of areas.")
     (home-page "https://nongnu.org/txr/")
     (license license:bsd-2)))
+
+(define picolisp32
+  (package
+    (name "picolisp32")
+    (version "19.12")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://software-lab.de/picoLisp-" version ".tgz"))
+       (sha256
+        (base32 "10np0mhihr47r3201617zccrvzpkhdl1jwvz7zimk8kxpriydq2j"))
+       (modules '((guix build utils)))
+       (snippet '(begin
+                   ;; Delete the pre-compiled jar file.
+                   (delete-file "ersatz/picolisp.jar")
+                   #t))))
+    (build-system gnu-build-system)
+    (inputs
+     `(("openssl" ,openssl)))
+    (arguments
+     `(#:system ,(match (%current-system)
+                   ((or "armhf-linux" "aarch64-linux")
+                    "armhf-linux")
+                   (_
+                    "i686-linux"))
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure)
+         (add-after 'unpack 'fix-paths
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (shebang-line (string-append
+                                   "#!" out "/bin/picolisp "
+                                   out "/lib/picolisp/lib.l")))
+               (substitute* '("bin/pil"
+                              "bin/pilIndent"
+                              "bin/pilPretty"
+                              "bin/psh"
+                              "bin/replica"
+                              "bin/vip"
+                              "bin/watchdog"
+                              "games/xchess"
+                              "misc/bigtest"
+                              "misc/calc"
+                              "misc/chat"
+                              "misc/mailing"
+                              "src/mkVers")
+                 (("#\\!bin/picolisp lib.l")
+                  shebang-line)
+                 (("#\\!\\.\\./bin/picolisp \\.\\./lib.l")
+                  shebang-line)
+                 (("#\\!/usr/bin/picolisp /usr/lib/picolisp/lib.l")
+                  shebang-line)))
+             #t))
+         (add-after 'fix-paths 'make-build-reproducible
+           (lambda _
+             (substitute* "src64/lib/asm.l"
+               (("\\(prinl \"/\\* \" \\(datSym \\(date\\)\\) \" \\*/\\)")
+                ""))
+             #t))
+         (add-after 'make-build-reproducible 'fix-permissions
+           (lambda _
+             (for-each make-file-writable
+                       '("doc/family.tgz"
+                         "doc/family64.tgz"
+                         "lib/map"
+                         "src64/tags"))
+             #t))
+         (replace 'build
+           (lambda _
+             (invoke "make" "-C" "src" "picolisp" "tools" "gate")))
+         (add-before 'check 'set-home-for-tests
+           (lambda _
+             (setenv "HOME" "/tmp")
+             #t))
+         (replace 'check
+           (lambda _
+             (invoke "./pil" "test/lib.l" "-bye" "+")))
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (bin (string-append out "/bin"))
+                    (man (string-append out "/share/man"))
+                    (picolisp (string-append out "/lib/picolisp")))
+               (copy-recursively "man" man)
+               (copy-recursively "." picolisp)
+               (for-each (lambda (name)
+                           (let ((path (string-append picolisp "/" name)))
+                             (delete-file-recursively path)))
+                         '("CHANGES" "COPYING" "CREDITS" "cygwin"
+                           "INSTALL" "man" "pil" "README" "src" "src64"
+                           "test"))
+               (mkdir-p bin)
+               (symlink (string-append picolisp "/bin/picolisp")
+                        (string-append bin "/picolisp"))
+               (symlink (string-append picolisp "/bin/pil")
+                        (string-append bin "/pil")))
+             #t)))))
+    (synopsis "Interpreter for the PicoLisp programming language")
+    (description
+     "PicoLisp is a programming language, or really a programming system,
+including a built-in database engine and a GUI system.")
+    (home-page "https://picolisp.com/wiki/?home")
+    (license license:expat)))
+
+(define-public picolisp
+  (match (%current-system)
+    ((or "aarch64-linux" "x86_64-linux")
+     (package
+       ;; Use the 32-bit picolisp to generate the assembly files required by
+       ;; the 64-bit picolisp.
+       (inherit picolisp32)
+       (name "picolisp")
+       (native-inputs
+        `(("picolisp32" ,picolisp32)
+          ("which" ,which)))
+       (arguments
+        (substitute-keyword-arguments (package-arguments picolisp32)
+          ((#:system _ "") (%current-system))
+          ((#:phases phases)
+           `(modify-phases ,phases
+              (delete 'fix-paths)
+              (add-before 'build 'fix-paths
+                ;; This must run after the other shebang-patching phases,
+                ;; or they will override our changes.
+                (lambda* (#:key inputs outputs #:allow-other-keys)
+                  (let* ((picolisp32 (assoc-ref inputs "picolisp32"))
+                         (out (assoc-ref outputs "out"))
+                         (shebang-line (string-append
+                                        "#!" out "/bin/picolisp "
+                                        out "/lib/picolisp/lib.l")))
+                    (substitute* '("bin/pil"
+                                   "bin/pilIndent"
+                                   "bin/pilPretty"
+                                   "bin/psh"
+                                   "bin/replica"
+                                   "bin/vip"
+                                   "bin/watchdog"
+                                   "games/xchess"
+                                   "misc/bigtest"
+                                   "misc/calc"
+                                   "misc/chat"
+                                   "misc/mailing"
+                                   "src/mkVers")
+                      (("#\\!.*picolisp32.*/bin/picolisp .*lib\\.l")
+                       shebang-line))
+                    (substitute* "src64/mkAsm"
+                      (("/usr/bin/")
+                       (string-append picolisp32 "/bin/"))))
+                  #t))
+              (replace 'build
+                (lambda _
+                  (invoke "make" "-C" "src" "tools" "gate")
+                  (invoke "make" "-C" "src64" "CC=gcc" "picolisp")))))))))
+    (_
+     (package
+       (inherit picolisp32)
+       (name "picolisp")))))