Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / chez.scm
index c45306b..929e50e 100644 (file)
@@ -1,5 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016 Federico Beffa <beffa@fbengineering.ch>
+;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,7 +21,7 @@
 (define-module (gnu packages chez)
   #:use-module (gnu packages)
   #:use-module ((guix licenses)
-                #:select (gpl2+ lgpl2.0+ lgpl2.1+ asl2.0 bsd-3 expat
+                #:select (gpl2+ gpl3+ lgpl2.0+ lgpl2.1+ asl2.0 bsd-3 expat
                           public-domain))
   #:use-module (guix packages)
   #:use-module (guix download)
@@ -34,7 +36,8 @@
   #:use-module (gnu packages compression)
   #:use-module (gnu packages image)
   #:use-module (gnu packages xorg)
-  #:use-module (ice-9 match))
+  #:use-module (ice-9 match)
+  #:use-module (srfi srfi-1))
 
 (define nanopass
   (let ((version "1.9"))
 (define-public chez-scheme
   (package
     (name "chez-scheme")
-    (version "9.4")
+    (version "9.5")
     (source
      (origin
        (method url-fetch)
        (uri (string-append "https://github.com/cisco/ChezScheme/archive/"
                            "v" version ".tar.gz"))
        (sha256
-        (base32 "0lprmpsjg2plc6ykgkz482zyvhkzv6gd0vnar71ph21h6zknyklz"))
-       (file-name (string-append "chez-scheme-" version ".tar.gz"))))
+        (base32 "135991hspq0grf26pvl2lkwhp92yz204h6rgiwyym0x6v0xzknd1"))
+       (file-name (string-append "chez-scheme-" version ".tar.gz"))
+       (modules '((guix build utils)))
+       (snippet
+        ;; Fix compilation with glibc >= 2.26, which removed xlocale.h.
+        '(begin
+           (substitute* "c/expeditor.c"
+             (("xlocale\\.h") "locale.h"))
+           #t))))
     (build-system gnu-build-system)
     (inputs
      `(("ncurses" ,ncurses)
@@ -75,6 +85,7 @@
        ("xorg-rgb" ,xorg-rgb)
        ("nanopass" ,nanopass)
        ("zlib" ,zlib)
+       ("zlib:static" ,zlib "static")
        ("stex" ,stex)))
     (native-inputs
      `(("texlive" ,texlive)
        (list ,(match (or (%current-target-system) (%current-system))
                 ("x86_64-linux" '(list "--machine=ta6le"))
                 ("i686-linux" '(list "--machine=ti3le"))
-                ;; FIXME: Some people succeeded in cross-compiling to
-                ;; ARM. https://github.com/cisco/ChezScheme/issues/13
+                ;; Let autodetection have its attempt on other architectures.
                 (_
                  '())))
        #:phases
        (modify-phases %standard-phases
+         (add-after 'unpack 'patch-processor-detection
+           (lambda _ (substitute* "configure"
+                       (("uname -a") "uname -m"))
+                   #t))
+         (add-after 'unpack 'patch-broken-documentation
+           (lambda _
+             ;; Work around an oversight in the 9.5 release tarball that causes
+             ;; building the documentation to fail. This should be fixed in the
+             ;; next one; see <https://github.com/cisco/ChezScheme/issues/209>.
+             (substitute* "csug/copyright.stex"
+               (("\\\\INSERTREVISIONMONTHSPACEYEAR" )
+                "October 2017"))))     ; tarball release date
          ;; Adapt the custom 'configure' script.
          (replace 'configure
            (lambda* (#:key inputs outputs #:allow-other-keys)
                    (nanopass (assoc-ref inputs "nanopass"))
                    (stex (assoc-ref inputs "stex"))
                    (zlib (assoc-ref inputs "zlib"))
+                   (zlib-static (assoc-ref inputs "zlib:static"))
                    (unpack (assoc-ref %standard-phases 'unpack))
                    (patch-source-shebangs
                     (assoc-ref %standard-phases 'patch-source-shebangs)))
                  (("\\$\\{Kernel\\}: \\$\\{kernelobj\\} \\.\\./zlib/libz\\.a")
                   "${Kernel}: ${kernelobj}")
                  (("ld ([-a-zA-Z0-9_${} ]+) \\.\\./zlib/libz\\.a" all args)
-                  (string-append "ld " args " " zlib "/lib/libz.a"))
+                  (string-append "ld " args " " zlib-static "/lib/libz.a"))
                  (("\\(cd \\.\\./zlib; ([-a-zA-Z0-9=./ ]+))")
                   (which "true")))
                (substitute* (find-files "mats" "Mf-.*")
                       (symlink file (string-append (dirname file)
                                                    "/" name ".boot")))
                     (find-files lib "scheme.boot"))
-               #t))))))
+               #t)))
+         (add-before 'reset-gzip-timestamps 'make-manpages-writable
+           (lambda* (#:key outputs #:allow-other-keys)
+             (map (lambda (file)
+                    (make-file-writable file))
+                  (find-files (string-append (assoc-ref outputs "out")
+                                             "/share/man")
+                              ".*\\.gz$"))
+             #t)))))
     ;; According to the documentation MIPS is not supported.
-    (supported-systems (delete "mips64el-linux" %supported-systems))
+    ;; Cross-compiling for the Raspberry Pi is supported, but not native ARM.
+    (supported-systems (fold delete %supported-systems
+                             '("mips64el-linux" "armhf-linux")))
     (home-page "http://www.scheme.com")
     (synopsis "R6RS Scheme compiler and run-time")
     (description
@@ -470,3 +503,97 @@ concatenating, composing and extending these formatters efficiently
 without resorting to capturing and manipulating intermediate
 strings.")
     (license bsd-3)))
+
+(define-public chez-mit
+  (package
+    (name "chez-mit")
+    (version "0.1")
+    (home-page "https://github.com/fedeinthemix/chez-mit")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append home-page "/archive/v" version ".tar.gz"))
+       (sha256
+        (base32 "1p11q061znwxzxrxg3vw4dbsnpv1dav12hjhnkrjnzyyjvvdm2kn"))
+       (file-name (string-append name "-" version ".tar.gz"))))
+    (build-system gnu-build-system)
+    (inputs
+     `(("chez-srfi" ,chez-srfi))) ; for tests
+    (native-inputs
+     `(("chez-scheme" ,chez-scheme)))
+    (arguments
+     `(#:make-flags ,(chez-make-flags name version)
+       #:test-target "test"
+       #:phases (modify-phases %standard-phases
+                  (replace 'configure ,chez-configure))))
+    (synopsis "MIT/GNU Scheme compatibility library for Chez Scheme")
+    (description "This package provides a set of MIT/GNU Scheme compatibility
+libraries for Chez Scheme.  The main goal was to provide the functionality
+required to port the program 'Scmutils' to Chez Scheme.")
+    (license gpl3+)))
+
+(define-public chez-scmutils
+  (package
+    (name "chez-scmutils")
+    (version "0.1")
+    (home-page "https://github.com/fedeinthemix/chez-scmutils")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append home-page "/archive/v" version ".tar.gz"))
+       (sha256
+        (base32 "1a5j61pggaiwl1gl6m038rcy5n8r2sj5nyjmz86jydx97mm5i8hj"))
+       (file-name (string-append name "-" version ".tar.gz"))))
+    (build-system gnu-build-system)
+    (inputs
+     `(("chez-srfi" ,chez-srfi)))      ; for tests
+    (native-inputs
+     `(("chez-scheme" ,chez-scheme)))
+    (propagated-inputs
+     `(("chez-mit" ,chez-mit)
+       ("chez-srfi" ,chez-srfi)))
+    (arguments
+     `(#:make-flags ,(chez-make-flags name version)
+       #:tests? #f ; no test suite
+       #:phases
+       (modify-phases %standard-phases
+         (replace 'configure ,chez-configure)
+         ;; Since the documentation is lacking, we install the source
+         ;; code.  For things to work correctly we have to replace
+         ;; relative paths by absolute ones in 'include' forms.  This
+         ;; in turn requires us to compile the files in the final
+         ;; destination.
+         (delete 'build)
+         (add-after 'install 'install-src
+           (lambda* (#:key (make-flags '()) #:allow-other-keys)
+             (zero? (apply system* "make" "install-src" make-flags))))
+         (add-after 'install-src 'absolute-path-in-scm-files
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (for-each (lambda (file)
+                           (substitute* file
+                             (("include +\"\\./scmutils")
+                              (string-append "include \"" (dirname file)))))
+                         (find-files out "\\.sls"))
+               (for-each (lambda (file)
+                           (substitute* file
+                             (("include +\"\\./scmutils/simplify")
+                              (string-append "include \"" (dirname file)))))
+                         (find-files out "fbe-syntax\\.scm"))
+               #t)))
+         (add-after 'absolute-path-in-scm-files 'build
+           (lambda* (#:key outputs (make-flags '()) #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (mk-file (car (find-files out "Makefile"))))
+               (with-directory-excursion (dirname mk-file)
+                 (zero? (apply system* "make" "build" make-flags))))))
+         (add-after 'build 'clean-up
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out")))
+               (for-each delete-file
+                         (find-files out "Makefile|compile-all\\.ss"))))))))
+    (synopsis "Port of MIT/GNU Scheme Scmutils to Chez Scheme")
+    (description "This package provides a port of the MIT/GNU Scheme
+Scmutils program to Chez Scheme.  The port consists of a set of
+libraries providing most of the functionality of the original.")
+    (license gpl3+)))