Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / lisp.scm
index 79721d5..b5d8fd3 100644 (file)
@@ -12,9 +12,9 @@
 ;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
 ;;; Copyright © 2018, 2019 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>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
   #: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)
-  #:use-module (srfi srfi-1)
   #:use-module (ice-9 match))
 
 (define (asdf-substitutions lisp)
               :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
@@ -195,28 +230,36 @@ 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 "0m0j24w5d5a9dwwqyrg0d35c0nys16ijb4r0nyk87yp82v38b9bn"))))
     (build-system gnu-build-system)
     ;; src/configure uses 'which' to confirm the existence of 'gzip'.
-    (native-inputs `(("which" ,which)))
+    (native-inputs `(("cl-asdf" ,cl-asdf)
+                     ("which" ,which)))
     (inputs `(("gmp" ,gmp)
               ("libatomic-ops" ,libatomic-ops)
               ("libgc" ,libgc)
               ("libffi" ,libffi)))
     (arguments
-     '(#:configure-flags '("--without-rt")
+     `(#:configure-flags '("--without-rt")
        #: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"))
@@ -319,24 +362,17 @@ high-level, object-oriented functional programming language.  CLISP includes
 an interpreter, a compiler, a debugger, and much more.")
     (license license:gpl2+)))
 
-(define sbcl-boot0
+(define-public sbcl
   (package
-    (name "sbcl-boot0")
-    (version "1.5.8")
+    (name "sbcl")
+    (version "2.0.2")
     (source
      (origin
        (method url-fetch)
        (uri (string-append "mirror://sourceforge/sbcl/sbcl/" version "/sbcl-"
                            version "-source.tar.bz2"))
        (sha256
-        (base32 "0k7zjrky8r2krkd8780cph214hiihg9nh5rxn4nrhg6i6f8jymw4"))
-       (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 "07pyzdjnhcpqwvr3rrk4i18maqdywbq1qj93fnpx1h4b7dp08r28"))))
     (build-system gnu-build-system)
     (outputs '("out" "doc"))
     (native-inputs
@@ -358,13 +394,19 @@ an interpreter, a compiler, a debugger, and much more.")
      ;; 2019-09-05, ECL was last updated in 2016 while CLISP was last updated
      ;; in 2010.
      ;;
-     ;; For now we stick to CLISP for all systems.
-     `(("clisp" ,clisp)
-       ("which" ,which)
-       ("inetutils" ,inetutils)         ;for hostname(1)
+     ;; 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.
+     `(,@(match (%current-system)
+           ((or "x86_64-linux" "i686-linux")
+            `(("clisp" ,clisp)))
+           (_
+            `(("clisp" ,clisp))))
+       ("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)
@@ -373,6 +415,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"))
@@ -427,7 +487,11 @@ an interpreter, a compiler, a debugger, and much more.")
          (replace 'build
            (lambda* (#:key outputs #:allow-other-keys)
              (setenv "CC" "gcc")
-             (invoke "sh" "make.sh" "clisp"
+             (invoke "sh" "make.sh" ,@(match (%current-system)
+                                        ((or "x86_64-linux" "i686-linux")
+                                         `("clisp"))
+                                        (_
+                                         `("clisp")))
                      (string-append "--prefix="
                                     (assoc-ref outputs "out"))
                      "--with-sb-core-compression"
@@ -468,8 +532,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")
@@ -485,46 +549,6 @@ statistical profiler, a code coverage tool, and many other extensions.")
     (license (list license:public-domain license:bsd-2
                    (license:x11-style "file://src/code/loop.lisp")))))
 
-(define-public sbcl
-  ;; Since 1.5.9, SBCL requires itself to build.
-  ;; See https://bugs.launchpad.net/sbcl/+bug/1855272.
-  (package
-    (inherit sbcl-boot0)
-    (name "sbcl")
-    (version "1.5.9")
-    (source
-     (origin
-       (method url-fetch)
-       (uri (string-append "mirror://sourceforge/sbcl/sbcl/" version "/sbcl-"
-                           version "-source.tar.bz2"))
-       (sha256
-        (base32 "1dmrlklil7x3j68mwmjfpd71vkphr24s4rx6d61jpc54x0jhvnyb"))
-       (modules '((guix build utils)))
-       (snippet
-        ;; Add sbcl-bundle-systems to 'default-system-source-registry'.
-        `(begin
-           (substitute* "contrib/asdf/asdf.lisp"
-             ,@(asdf-substitutions name))
-           #t))))
-    (build-system gnu-build-system)
-    (outputs '("out" "doc"))
-    (native-inputs
-     `(("sbcl" ,sbcl-boot0)
-       ,@(fold alist-delete (package-native-inputs sbcl-boot0)
-               '("clisp"))))
-    (arguments
-     (substitute-keyword-arguments (package-arguments sbcl-boot0)
-       ((#:phases phases)
-        `(modify-phases ,phases
-           (replace 'build
-             (lambda* (#:key outputs #:allow-other-keys)
-               (setenv "CC" "gcc")
-               (invoke "sh" "make.sh" "sbcl"
-                       (string-append "--prefix="
-                                      (assoc-ref outputs "out"))
-                       "--with-sb-core-compression"
-                       "--with-sb-xref-for-internals")))))))))
-
 (define-public ccl
   ;; Warning: according to upstream, CCL is not bootstrappable.
   ;; See https://github.com/Clozure/ccl/issues/222 from 2019-09-02:
@@ -773,7 +797,7 @@ enough to play the original mainframe Zork all the way through.")
 (define-public txr
   (package
     (name "txr")
-    (version "229")
+    (version "232")
     (source
      (origin
        (method git-fetch)
@@ -784,7 +808,7 @@ enough to play the original mainframe Zork all the way through.")
        (patches (search-patches "txr-shell.patch"))
        (sha256
         (base32
-         "070lqckhbcq3wn5ajyaa41hh0gypaa48wnxkk6mc5mxvmv76ml46"))))
+         "1vcnask4a1rxrljp4rcbkfihrndkv25l256l125vv39gjhf315xp"))))
     (build-system gnu-build-system)
     (arguments
      '(#:configure-flags '("cc=gcc")
@@ -815,3 +839,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")))))