(address . guix-patches@gnu.org)(name . Philip McGrath)(address . philip@philipmcgrath.com)
Take advantage of patches that have been accepted upstream.
These changes lay a foundation for reusing more of Chez's
build process for Racket.
* gnu/packages/patches/chez-scheme-build-util-paths-backport.patch:
New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/chez.scm (nanopass): Rename it to ...
(nanopass-framework-scheme): ... this variable. Change it from an origin
to a package. Update to 1.9.2.
(stex): Rename it to ...
(chez-stex): ... this variable. Change it from an origin to a hidden
package. Update to commit 5405149, which helps us install it.
(chez-scheme)[source](patches): Use it.
[source](snippet): Remove bundled libraries here, not during 'configure'
phase. Also remove irrelevant bootfiles.
[inputs]: Organize. Move "nanopass" and "stex" to ...
[native-inputs]: ... this field.
[outputs]: Add "stex".
[arguments]: Remove #:configure-flags which were ignored. Add (ice-9 ftw)
to #:modules. Remove unneeded 'patch-processor-detection' phase.
Add 'link-nanopass+stex' phase (refactored from 'configure').
Simplify 'configure' phase by removing patches that have been upstreamed.
Detect when "--disable-curses" or "--disable-x11" flags are needed.
Add "--nogzip-man-pages" flag so we can remove 'make-manpages-writable'
phase. Refactor 'install-doc' phase into 'build+install-stex' and
'build+install-doc'
---
gnu/local.mk | 1 +
gnu/packages/chez.scm | 370 ++++++---
...hez-scheme-build-util-paths-backport.patch | 780 ++++++++++++++++++
3 files changed, 1030 insertions(+), 121 deletions(-)
create mode 100644 gnu/packages/patches/chez-scheme-build-util-paths-backport.patch
Toggle diff (398 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 0954158d4c..96de2e108e 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -879,6 +879,7 @@ dist_patch_DATA = \
%D%/packages/patches/cdparanoia-fpic.patch \
%D%/packages/patches/cdrtools-3.01-mkisofs-isoinfo.patch \
%D%/packages/patches/ceph-disable-cpu-optimizations.patch \
+ %D%/packages/patches/chez-scheme-build-util-paths-backport.patch \
%D%/packages/patches/chmlib-inttypes.patch \
%D%/packages/patches/cl-asdf-config-directories.patch \
%D%/packages/patches/clamav-config-llvm-libs.patch \
diff --git a/gnu/packages/chez.scm b/gnu/packages/chez.scm
index eac556c4d0..e1e94bc90c 100644
--- a/gnu/packages/chez.scm
+++ b/gnu/packages/chez.scm
@@ -4,6 +4,7 @@
;;; Copyright © 2017, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2019 Brett Gilio <brettg@gnu.org>
;;; Copyright © 2020 Brendan Tildesley <mail@brendan.scot>
+;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -30,6 +31,7 @@
#:use-module (guix git-download)
#:use-module (guix utils)
#:use-module (guix build-system gnu)
+ #:use-module (guix gexp)
#:use-module (gnu packages compression)
#:use-module (gnu packages ncurses)
#:use-module (gnu packages ghostscript)
@@ -42,25 +44,103 @@
#:use-module (ice-9 match)
#:use-module (srfi srfi-1))
-(define nanopass
- (let ((version "1.9.1"))
- (origin
- (method git-fetch)
- (uri (git-reference
- (url "https://github.com/nanopass/nanopass-framework-scheme")
- (commit (string-append "v" version))))
- (sha256 (base32 "1synadgaycca39jfx525975ss9y0lkl516sdrc62wrrllamm8n21"))
- (file-name (git-file-name "nanopass" version)))))
+;; Nanopass will be used by Racket and could be used by
+;; any of the supported Scheme implementations.
+;; Making it a package lets us do the unpacking
+;; and patching steps just once.
+(define-public nanopass-framework-scheme
+ (let ((version "1.9.2"))
+ (package
+ (name "nanopass-framework-scheme")
+ (version version)
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/nanopass/nanopass-framework-scheme")
+ (commit (string-append "v" version))))
+ (sha256 "16vjsik9rrzbabbhbxbaha51ppi3f9n8rk59pc6zdyffs0vziy4i")
+ (file-name (git-file-name "nanopass" version))))
+ (home-page "https://nanopass.org")
+ (synopsis
+ "Embeded domain-specific language for writing compiler passes")
+ (description
+ "The Nanopass Framework is an embedded domain-specific language
+for creating compilers that focuses on creating small passes and many
+intermediate representations. Nanopass reduces the boilerplate required to
+create compilers, making them easier to understand and maintain.
+
+This package contains the R6RS source distribution, which is known to work with
+Chez Scheme, Vicare Scheme, and Ikarus Scheme.")
+ (license (list expat))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (delete 'bootstrap)
+ (delete 'patch-usr-bin-file)
+ (delete 'configure)
+ (delete 'patch-generated-file-shebangs)
+ (delete 'build)
+ (delete 'check)
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ (copy-recursively "." (assoc-ref outputs "out"))
+ #t))
+ (delete 'patch-shebangs)
+ (delete 'strip)
+ (delete 'validate-runpath)
+ (delete 'validate-documentation-location)
+ (delete 'delete-info-dir-file)
+ (delete 'patch-dot-desktop-files)
+ (delete 'install-license-files)
+ (delete 'reset-gzip-timestamps)
+ (delete 'compress-documentation)))))))
+
+
+(define chez-stex
+ ;; Hidden because of a circular dependency issue:
+ ;; stex needs chez-scheme to be used, but chez-scheme uses
+ ;; stex to build its documentation.
+ ;; The chez-scheme package has an stex output that exposes
+ ;; the useful version of this---or maybe there's a more elegant solution?
+ (hidden-package
+ (let ((version "1.2.2")
+ ;; This commit includes a fix for which we would
+ ;; otherwise want to use a snippet.
+ ;; When there's a new tagged release,
+ ;; go back to using (string-append "v" version)
+ (commit "54051494434a197772bf6ca5b4e6cf6be55f39a5")
+ (revision "1")) ;Guix package revision
+ (package
+ (inherit nanopass-framework-scheme)
+ (name "chez-stex")
+ (version (git-version version revision commit))
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/dybvig/stex")
+ (commit commit)))
+ (sha256 "01jnvw8qw33gnpzwrakwhsr05h6b609lm180jnspcrb7lds2p23d")
+ (file-name (git-file-name "stex" version))))
+ (home-page "https://github.com/dybvig/stex")
+ (synopsis
+ "Tools for including Scheme in LaTeX and converting to HTML")
+ (description
+ "The @dfn{stex} package consists of two main programs and some
+supporting items, such as make files, make-file templates, class files,
+and style files. The two main programs are @command{scheme-prep} and
+@command{html-prep}. @command{scheme-prep} performs a conversion from
+stex-formatted files into LaTeX-formatted files, while @command{html-prep}
+converts (some) LaTeX-formatted files into html-formatted files.
+
+An stex file is really just a LaTeX file extended with a handful of commands
+for including Scheme code (or pretty much any other kind of code, as long as
+you don't plan to use the Scheme-specific transcript support) in a document,
+plus a couple of additional features rather arbitrarily thrown in.")
+ (license (list expat))))))
-(define stex
- (let ((version "1.2.2"))
- (origin
- (method git-fetch)
- (uri (git-reference
- (url "https://github.com/dybvig/stex")
- (commit (string-append "v" version))))
- (sha256 (base32 "1q5i8pf4cdfjsj6r2k1rih7ljbfggyxdng2p2fvsgarzihpsin2i"))
- (file-name (git-file-name "stex" version)))))
(define-public chez-scheme
(package
@@ -74,21 +154,49 @@
(commit (string-append "v" version))))
(sha256
(base32 "0prgn2z9l888j93ydxaf04ph424g0fi3a8w7f8m0b2r7fr1v7388"))
- (file-name (git-file-name name version))))
+ (file-name (git-file-name name version))
+ (patches
+ (search-patches
+ ;; backported from upstream: remove on next release
+ "chez-scheme-build-util-paths-backport.patch"))
+ (snippet
+ ;; remove bundled libraries
+ (with-imported-modules '((guix build utils))
+ #~(begin
+ (use-modules (guix build utils))
+ (for-each (lambda (dir)
+ (when (directory-exists? dir)
+ (delete-file-recursively dir)))
+ '("stex"
+ "nanopass"
+ "lz4"
+ "zlib"
+ ;; pre-built bootfiles for unsupported systems:
+ "boot/a6nt"
+ "boot/a6osx"
+ "boot/i3nt"
+ "boot/i3osx"
+ "boot/ta6nt"
+ "boot/ta6osx"
+ "boot/ti3nt"
+ "boot/ti3osx")))))))
(build-system gnu-build-system)
(inputs
- `(("ncurses" ,ncurses)
- ("libuuid" ,util-linux "lib")
- ("libx11" ,libx11)
- ("lz4" ,lz4)
- ("lz4:static" ,lz4 "static")
- ("xorg-rgb" ,xorg-rgb)
- ("nanopass" ,nanopass)
+ `(("libuuid" ,util-linux "lib")
("zlib" ,zlib)
("zlib:static" ,zlib "static")
- ("stex" ,stex)))
+ ("lz4" ,lz4)
+ ("lz4:static" ,lz4 "static")
+ ;; for expeditor:
+ ("ncurses" ,ncurses)
+ ;; for X:
+ ("libx11" ,libx11)
+ ("xorg-rgb" ,xorg-rgb)))
(native-inputs
- `(("texlive" ,(texlive-union (list texlive-latex-oberdiek
+ `(("nanopass" ,nanopass-framework-scheme) ; source-only distribution
+ ;; for docs
+ ("stex" ,chez-stex)
+ ("texlive" ,(texlive-union (list texlive-latex-oberdiek
texlive-generic-epsf)))
("ghostscript" ,ghostscript)
("netpbm" ,netpbm)))
@@ -96,98 +204,63 @@
(list (search-path-specification
(variable "CHEZSCHEMELIBDIRS")
(files (list (string-append "lib/csv" version "-site"))))))
- (outputs '("out" "doc"))
+ (outputs '("out" "stex" "doc"))
(arguments
- `(#:modules ((guix build gnu-build-system)
- (guix build utils)
- (ice-9 match))
+ `(#:modules
+ ((guix build gnu-build-system)
+ (guix build utils)
+ (ice-9 ftw)
+ (ice-9 match))
#:test-target "test"
- #:configure-flags
- (list ,(match (or (%current-target-system) (%current-system))
- ("x86_64-linux" '(list "--machine=ta6le"))
- ("i686-linux" '(list "--machine=ti3le"))
- ;; 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))
- ;; Adapt the custom 'configure' script.
+ ;; put these where configure expects them to be
+ (add-after 'unpack 'link-nanopass+stex
+ (lambda* (#:key native-inputs inputs #:allow-other-keys)
+ (symlink (assoc-ref (or native-inputs inputs) "nanopass")
+ "nanopass")
+ (let ((stex-src (assoc-ref (or native-inputs inputs) "stex")))
+ ;; making stex wants to create a build directory,
+ ;; so the immediate directory must be writable
+ (mkdir "stex")
+ (with-directory-excursion "stex"
+ (for-each (lambda (pth)
+ (unless (member pth '("." ".."))
+ (symlink (string-append stex-src "/" pth)
+ pth)))
+ (scandir stex-src))))
+ #t))
+ ;; NOTE: the custom Chez 'configure' script doesn't allow
+ ;; unrecognized flags, such as those automatically added
+ ;; by `gnu-build-system`.
(replace 'configure
(lambda* (#:key inputs outputs #:allow-other-keys)
- (let ((out (assoc-ref outputs "out"))
- (nanopass (assoc-ref inputs "nanopass"))
- (stex (assoc-ref inputs "stex"))
- (lz4-static (assoc-ref inputs "lz4:static"))
- (zlib-static (assoc-ref inputs "zlib:static"))
- (unpack (assoc-ref %standard-phases 'unpack))
- (patch-source-shebangs
- (assoc-ref %standard-phases 'patch-source-shebangs)))
- (map (match-lambda
- ((src orig-name new-name)
- (with-directory-excursion "."
- (apply unpack (list #:source src))
- (apply patch-source-shebangs (list #:source src)))
- (delete-file-recursively new-name)
- (invoke "mv" orig-name new-name)))
- `((,nanopass "source" "nanopass")
- (,stex "source" "stex")))
- ;; The configure step wants to CURL all submodules as it
- ;; detects a checkout without submodules. Disable curling,
- ;; and manually patch the needed modules for compilation.
- (substitute* "configure"
- (("! -f '") "-d '")) ; working around CURL.
- (substitute* (find-files "mats" "Mf-.*")
- (("^[[:space:]]+(cc ) *") "\tgcc "))
- (substitute*
- (find-files "." (string-append
- "("
- "Mf-[a-zA-Z0-9.]+"
- "|Makefile[a-zA-Z0-9.]*"
- "|checkin"
- "|stex\\.stex"
- "|newrelease"
- "|workarea"
- "|unix\\.ms"
- "|^6\\.ms"
- ;;"|[a-zA-Z0-9.]+\\.ms" ; guile can't read
- ")"))
- (("/bin/rm") (which "rm"))
- (("/bin/ln") (which "ln"))
- (("/bin/cp") (which "cp"))
- (("/bin/echo") (which "echo")))
- (substitute* "makefiles/installsh"
- (("/bin/true") (which "true")))
- (substitute* "stex/Makefile"
- (("PREFIX=/usr") (string-append "PREFIX=" out)))
- (invoke "./configure" "--threads"
- (string-append "ZLIB=" zlib-static "/lib/libz.a")
- (string-append "LZ4=" lz4-static "/lib/liblz4.a")
- (string-append "--installprefix=" out)))))
- ;; Installation of the documentation requires a running "chez".
- (add-after 'install 'install-doc
- (lambda* (#:key inputs outputs #:allow-other-keys)
- (let ((doc (string-append (assoc-ref outputs "doc")
- "/share/doc/" ,name "-" ,version)))
- (invoke "make" "docs")
- (with-directory-excursion "csug"
- (substitute* "Makefile"
- ;; The ‘installdir=’ can't be overruled on the command line.
- (("/tmp/csug9") doc)
- ;; $m is the ‘machine type’, e.g. ‘ta6le’ on x86_64, but is
- ;; set incorrectly for some reason, e.g. to ‘a6le’ on x86_64.
- ;; Avoid the whole mess by running the (machine-independent)
- ;; ‘installsh’ script at its original location.
- (("\\$m/installsh") "makefiles/installsh"))
- (invoke "make" "install")
- (install-file "csug.pdf" doc))
- (with-directory-excursion "release_notes"
- (install-file "release_notes.pdf" doc))
+ (let* ((zlib-static (assoc-ref inputs "zlib:static"))
+ (lz4-static (assoc-ref inputs "lz4:static"))
+ (out (assoc-ref outputs "out"))
+ (flags (list
+ (string-append "--installprefix=" out)
+ (string-append "ZLIB=" zlib-static "/lib/libz.a")
+ (string-append "LZ4=" lz4-static "/lib/liblz4.a")
+ "--nogzip-man-pages" ;; guix will do it
+ "--threads"))
+ (flags (if (assoc-ref inputs "ncurses")
+ flags
+ (cons "--disable-curses"
+ flags)))
+ (flags (if (and (assoc-ref inputs "libx11")
+ (assoc-ref inputs "xorg-rgb"))
+ flags
+ (cons "--disable-x11"
+ flags))))
+ ;; Some makefiles (for tests) don't seem to propagate CC
+ ;; properly, so we take it out of their hands:
+ (setenv "CC" "gcc")
+ (apply invoke
+ "./configure"
+ flags)
#t)))
- ;; The binary file name is called "scheme" as the one from MIT/GNU
+ ;; The binary file name is called "scheme" as is the one from MIT/GNU
;; Scheme. We add a symlink to use in case both are installed.
(add-after 'install 'install-symlink
(lambda* (#:key outputs #:allow-other-keys)
@@ -202,16 +275,70 @@
"/" name ".boot")))
(find-files lib "scheme.boot"))
#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)))))
+ ;; We build & install stex so it can (in principle)
+ ;; be reused for other documents.
+ (add-after 'install-symlink 'build+install-stex
+ (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
+ (let* ((stex+version
+ (strip-store-file-name
+ (assoc-ref (or native-inputs inputs) "stex")))
+ (stex-output (assoc-ref outputs "stex"))
+ (doc-dir (string-append stex-output
+ "/share/doc/"
+ stex+version)))
+ (with-directory-excursion "stex"
+ (invoke "make"
+ "install"
+ (string-append "LIB="
+ stex-output
+ "/lib/"
+ stex+version)
+ (string-append "Scheme="
+ (assoc-ref outputs "out")
+ "/bin/scheme"))
+ (for-each (lambda (pth)
+
This message was truncated. Download the full message here.