1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 Federico Beffa <beffa@fbengineering.ch>
3 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2017, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2019 Brett Gilio <brettg@gnu.org>
6 ;;; Copyright © 2020 Brendan Tildesley <mail@brendan.scot>
7 ;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
9 ;;; This file is part of GNU Guix.
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.
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.
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/>.
24 (define-module (gnu packages chez)
25 #:use-module (gnu packages)
26 #:use-module ((guix licenses)
27 #:select (gpl2+ gpl3+ lgpl2.0+ lgpl2.1+ asl2.0 bsd-3 expat
29 #:use-module (guix packages)
30 #:use-module (guix download)
31 #:use-module (guix git-download)
32 #:use-module (guix utils)
33 #:use-module (guix build-system gnu)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages ncurses)
36 #:use-module (gnu packages ghostscript)
37 #:use-module (gnu packages linux)
38 #:use-module (gnu packages netpbm)
39 #:use-module (gnu packages tex)
40 #:use-module (gnu packages compression)
41 #:use-module (gnu packages image)
42 #:use-module (gnu packages xorg)
43 #:use-module (ice-9 match)
44 #:use-module (srfi srfi-1))
47 (let ((version "1.9.2"))
51 (url "https://github.com/nanopass/nanopass-framework-scheme")
52 (commit (string-append "v" version))))
53 (sha256 (base32 "16vjsik9rrzbabbhbxbaha51ppi3f9n8rk59pc6zdyffs0vziy4i"))
54 (file-name (git-file-name "nanopass" version)))))
57 (let ((version "1.2.2"))
61 (url "https://github.com/dybvig/stex")
62 (commit (string-append "v" version))))
63 (sha256 (base32 "1q5i8pf4cdfjsj6r2k1rih7ljbfggyxdng2p2fvsgarzihpsin2i"))
64 (file-name (git-file-name "stex" version)))))
66 (define-public chez-scheme
74 (url "https://github.com/cisco/ChezScheme")
75 (commit (string-append "v" version))))
77 (base32 "0prgn2z9l888j93ydxaf04ph424g0fi3a8w7f8m0b2r7fr1v7388"))
78 (file-name (git-file-name name version))))
79 (build-system gnu-build-system)
81 `(("ncurses" ,ncurses)
82 ("libuuid" ,util-linux "lib")
85 ("lz4:static" ,lz4 "static")
86 ("xorg-rgb" ,xorg-rgb)
87 ("nanopass" ,nanopass)
89 ("zlib:static" ,zlib "static")
92 `(("texlive" ,(texlive-union (list texlive-latex-oberdiek
93 texlive-generic-epsf)))
94 ("ghostscript" ,ghostscript)
97 (list (search-path-specification
98 (variable "CHEZSCHEMELIBDIRS")
99 (files (list (string-append "lib/csv" version "-site"))))))
100 (outputs '("out" "doc"))
102 `(#:modules ((guix build gnu-build-system)
107 (list ,(match (or (%current-target-system) (%current-system))
108 ("x86_64-linux" '(list "--machine=ta6le"))
109 ("i686-linux" '(list "--machine=ti3le"))
110 ;; Let autodetection have its attempt on other architectures.
114 (modify-phases %standard-phases
115 (add-after 'unpack 'patch-processor-detection
116 (lambda _ (substitute* "configure"
117 (("uname -a") "uname -m"))
119 ;; Adapt the custom 'configure' script.
121 (lambda* (#:key inputs outputs #:allow-other-keys)
122 (let ((out (assoc-ref outputs "out"))
123 (nanopass (assoc-ref inputs "nanopass"))
124 (stex (assoc-ref inputs "stex"))
125 (lz4-static (assoc-ref inputs "lz4:static"))
126 (zlib-static (assoc-ref inputs "zlib:static"))
127 (unpack (assoc-ref %standard-phases 'unpack))
128 (patch-source-shebangs
129 (assoc-ref %standard-phases 'patch-source-shebangs)))
131 ((src orig-name new-name)
132 (with-directory-excursion "."
133 (apply unpack (list #:source src))
134 (apply patch-source-shebangs (list #:source src)))
135 (delete-file-recursively new-name)
136 (invoke "mv" orig-name new-name)))
137 `((,nanopass "source" "nanopass")
138 (,stex "source" "stex")))
139 ;; The configure step wants to CURL all submodules as it
140 ;; detects a checkout without submodules. Disable curling,
141 ;; and manually patch the needed modules for compilation.
142 (substitute* "configure"
143 (("! -f '") "-d '")) ; working around CURL.
144 (substitute* (find-files "mats" "Mf-.*")
145 (("^[[:space:]]+(cc ) *") "\tgcc "))
147 (find-files "." (string-append
150 "|Makefile[a-zA-Z0-9.]*"
157 ;;"|[a-zA-Z0-9.]+\\.ms" ; guile can't read
159 (("/bin/rm") (which "rm"))
160 (("/bin/ln") (which "ln"))
161 (("/bin/cp") (which "cp"))
162 (("/bin/echo") (which "echo")))
163 (substitute* "makefiles/installsh"
164 (("/bin/true") (which "true")))
165 (substitute* "stex/Makefile"
166 (("PREFIX=/usr") (string-append "PREFIX=" out)))
167 (invoke "./configure" "--threads"
168 (string-append "ZLIB=" zlib-static "/lib/libz.a")
169 (string-append "LZ4=" lz4-static "/lib/liblz4.a")
170 (string-append "--installprefix=" out)))))
171 ;; Installation of the documentation requires a running "chez".
172 (add-after 'install 'install-doc
173 (lambda* (#:key inputs outputs #:allow-other-keys)
174 (let ((doc (string-append (assoc-ref outputs "doc")
175 "/share/doc/" ,name "-" ,version)))
176 (invoke "make" "docs")
177 (with-directory-excursion "csug"
178 (substitute* "Makefile"
179 ;; The ‘installdir=’ can't be overruled on the command line.
181 ;; $m is the ‘machine type’, e.g. ‘ta6le’ on x86_64, but is
182 ;; set incorrectly for some reason, e.g. to ‘a6le’ on x86_64.
183 ;; Avoid the whole mess by running the (machine-independent)
184 ;; ‘installsh’ script at its original location.
185 (("\\$m/installsh") "makefiles/installsh"))
186 (invoke "make" "install")
187 (install-file "csug.pdf" doc))
188 (with-directory-excursion "release_notes"
189 (install-file "release_notes.pdf" doc))
191 ;; The binary file name is called "scheme" as the one from MIT/GNU
192 ;; Scheme. We add a symlink to use in case both are installed.
193 (add-after 'install 'install-symlink
194 (lambda* (#:key outputs #:allow-other-keys)
195 (let* ((out (assoc-ref outputs "out"))
196 (bin (string-append out "/bin"))
197 (lib (string-append out "/lib"))
198 (name "chez-scheme"))
199 (symlink (string-append bin "/scheme")
200 (string-append bin "/" name))
202 (symlink file (string-append (dirname file)
204 (find-files lib "scheme.boot"))
206 (add-before 'reset-gzip-timestamps 'make-manpages-writable
207 (lambda* (#:key outputs #:allow-other-keys)
209 (make-file-writable file))
210 (find-files (string-append (assoc-ref outputs "out")
214 ;; According to the documentation MIPS is not supported.
215 ;; Cross-compiling for the Raspberry Pi is supported, but not native ARM.
216 (supported-systems (fold delete %supported-systems
217 '("mips64el-linux" "armhf-linux")))
218 (home-page "https://cisco.github.io/ChezScheme/")
219 (synopsis "R6RS Scheme compiler and run-time")
221 "Chez Scheme is a compiler and run-time system for the language of the
222 Revised^6 Report on Scheme (R6RS), with numerous extensions. The compiler
223 generates native code for each target processor, with support for x86, x86_64,
224 and 32-bit PowerPC architectures.")
227 (define-public chez-srfi
235 (url "https://github.com/fedeinthemix/chez-srfi")
236 (commit (string-append "v" version))))
238 (base32 "1vgn984mj2q4w6r2q66h7qklp2hrh85wwh4k9yisga5fi0ps7myf"))
239 (file-name (git-file-name name version))))
240 (build-system gnu-build-system)
242 `(("chez-scheme" ,chez-scheme)))
244 `(#:make-flags (let ((out (assoc-ref %outputs "out")))
245 (list (string-append "PREFIX=" out)
246 "CHEZ=chez-scheme --libdirs ./"
247 (string-append "chezversion=" ,(package-version chez-scheme))))
249 #:phases (modify-phases %standard-phases
250 (delete 'configure))))
251 (home-page "https://github.com/fedeinthemix/chez-srfi")
252 (synopsis "SRFI libraries for Chez Scheme")
254 "This package provides a collection of SRFI libraries for Chez Scheme.")
257 (define-public chez-web
258 (let ((commit "5fd177fe53f31f466bf88720d03c95a3711a8bea")
262 ;; Release 2.0 is different and doesn't work.
263 (version (git-version "2.0" revision commit))
268 (url "https://github.com/arcfide/ChezWEB")
270 (file-name (git-file-name name version))
272 (base32 "1dq25qygyncbfq4kwwqqgyyakfqjwhp5q23vrf3bff1p66nyfl3b"))))
273 (build-system gnu-build-system)
275 `(("chez-scheme" ,chez-scheme)
276 ("ghostscript" ,ghostscript)
277 ("texlive" ,(texlive-union (list texlive-latex-oberdiek
280 texlive-fonts-charter
281 texlive-generic-pdftex
284 texlive-tex-plain)))))
286 `(#:make-flags (list (string-append "PREFIX=" %output)
287 (string-append "DOCDIR=" %output "/share/doc/"
289 (string-append "LIBDIR=" %output "/lib/chezweb")
290 (string-append "TEXDIR=" %output "/share/texmf-local"))
291 #:tests? #f ; no tests
293 (modify-phases %standard-phases
294 (add-before 'build 'set-HOME
296 ;; FIXME: texlive-union does not find the built
297 ;; metafonts, so it tries to generate them in HOME.
298 (setenv "HOME" "/tmp")
300 ;; This package has a custom "bootstrap" script that
301 ;; is meant to be run from the Makefile.
305 (copy-file "config.mk.template" "config.mk")
306 (substitute* "tangleit"
307 (("\\./cheztangle\\.ss" all)
308 (string-append "chez-scheme --program " all)))
309 (substitute* "weaveit"
310 (("mpost chezweb\\.mp")
311 "mpost --tex=tex chezweb.mp")
312 (("\\./chezweave" all)
313 (string-append "chez-scheme --program " all)))
314 (substitute* "installit"
315 (("-g \\$GROUP -o \\$OWNER") ""))
317 (home-page "https://github.com/arcfide/ChezWEB")
318 (synopsis "Hygienic Literate Programming for Chez Scheme")
319 (description "ChezWEB is a system for doing Knuthian style WEB
320 programming in Scheme.")
323 (define-public chez-sockets
324 (let ((commit "bce96881c06bd69a6757a6bff139744153924140")
327 (name "chez-sockets")
328 (version (git-version "0.0.0" revision commit))
333 (url "https://github.com/arcfide/chez-sockets")
335 (file-name (git-file-name name version))
337 (base32 "1n5fbwwz51fdzvjackgmnsgh363g9inyxv7kmzi0469cwavwcx5m"))))
338 (build-system gnu-build-system)
340 `(("chez-scheme" ,chez-scheme)
341 ("chez-web" ,chez-web)
342 ("texlive" ,(texlive-union (list texlive-generic-pdftex)))))
344 `(#:tests? #f ; no tests
346 (modify-phases %standard-phases
348 (lambda* (#:key outputs inputs #:allow-other-keys)
349 (let* ((out (assoc-ref outputs "out"))
350 (chez-web (assoc-ref inputs "chez-web"))
351 (chez (assoc-ref inputs "chez-scheme"))
352 (chez-h (dirname (car (find-files chez "scheme\\.h")))))
353 (substitute* "Makefile"
354 (("(SCHEMEH=).*$" all var)
355 (string-append var chez-h)))
357 (add-before 'build 'tangle
358 (lambda* (#:key inputs #:allow-other-keys)
362 (assoc-ref inputs "chez-web") "/share/texmf-local/tex/generic:"
364 ;; just using "make" tries to build the .c files before
366 (and (invoke "make" "sockets")
369 (lambda* (#:key outputs inputs #:allow-other-keys)
370 (let* ((out (assoc-ref outputs "out"))
371 (chez-site (string-append out "/lib/csv"
372 ,(package-version chez-scheme)
374 ;; make sure Chez Scheme can find the shared libraries.
375 (substitute* "sockets.ss"
376 (("(load-shared-object) \"(socket-ffi-values\\.[sd][oy].*)\""
378 (string-append cmd " \"" chez-site "/" so "\""))
379 (("sockets-stub\\.[sd][oy].*" all)
380 (string-append chez-site "/" all)))
381 ;; to compile chez-sockets, the .so files must be
382 ;; installed (because of the absolute path we
384 (for-each (lambda (f d) (install-file f d))
385 '("socket-ffi-values.so" "sockets-stub.so")
386 (list chez-site chez-site))
387 (zero? (system "echo '(compile-file \"sockets.sls\")' | scheme -q")))))
389 (lambda* (#:key outputs inputs #:allow-other-keys)
390 (let* ((out (assoc-ref outputs "out"))
391 (lib (string-append out "/lib/chez-sockets"))
392 (doc (string-append out "/share/doc/" ,name "-" ,version))
393 (chez-site (string-append out "/lib/csv"
394 ,(package-version chez-scheme)
396 (for-each (lambda (f d) (install-file f d))
397 '("sockets.pdf" "sockets.so")
398 (list doc chez-site))
400 (home-page "https://github.com/arcfide/chez-sockets")
401 (synopsis "Extensible sockets library for Chez Scheme")
402 (description "Chez-sockets is an extensible sockets library for
406 ;; Help function for Chez Scheme to add the current path to
407 ;; CHEZSCHEMELIBDIRS.
408 (define chez-configure
410 (let ((chez-env (getenv "CHEZSCHEMELIBDIRS")))
411 (setenv "CHEZSCHEMELIBDIRS"
413 (string-append ".:" chez-env)
417 ;; Help function to define make flags for some Chez Scheme custom make
419 (define (chez-make-flags name version)
420 `(let ((out (assoc-ref %outputs "out")))
422 ;; Set 'chezversion' so that libraries are installed in
423 ;; 'lib/csvX.Y.Z-site' like Chez's 'native-search-paths' expects.
424 (string-append "chezversion=" ,(package-version chez-scheme))
425 (string-append "PREFIX=" out)
426 (string-append "DOCDIR=" out "/share/doc/"
427 ,name "-" ,version))))
429 (define-public chez-matchable
431 (name "chez-matchable")
433 (home-page "https://github.com/fedeinthemix/chez-matchable")
439 (commit (string-append "v" version))))
441 (base32 "02qn7x348p23z1x5lwhkyj7i8z6mgwpzpnwr8dyina0yzsdkr71s"))
442 (file-name (git-file-name name version))))
443 (build-system gnu-build-system)
445 `(("chez-srfi" ,chez-srfi))) ; for tests
447 `(("chez-scheme" ,chez-scheme)))
449 `(#:make-flags ,(chez-make-flags name version)
451 #:phases (modify-phases %standard-phases
452 (replace 'configure ,chez-configure))))
453 (synopsis "Portable hygienic pattern matcher for Scheme")
454 (description "This package provides a superset of the popular Scheme
455 @code{match} package by Andrew Wright, written in fully portable
456 @code{syntax-rules} and thus preserving hygiene.")
457 (license public-domain)))
459 (define-public chez-irregex
461 (name "chez-irregex")
467 (url "https://github.com/fedeinthemix/chez-irregex")
468 (commit (string-append "v" version))))
470 (base32 "0jh6piylw545j81llay9wfivgpv6lcnwd81gm4w17lkasslir50q"))
471 (file-name (git-file-name name version))))
472 (build-system gnu-build-system)
474 `(("chez-matchable" ,chez-matchable))) ; for tests
476 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
478 `(("chez-scheme" ,chez-scheme)))
480 `(#:make-flags ,(chez-make-flags name version)
482 #:phases (modify-phases %standard-phases
483 (replace 'configure ,chez-configure))))
484 (home-page "https://github.com/fedeinthemix/chez-irregex")
485 (synopsis "Portable regular expression library for Scheme")
486 (description "This package provides a portable and efficient
487 R[4567]RS implementation of regular expressions, supporting both POSIX
488 syntax with various (irregular) PCRE extensions, as well as SCSH's SRE
489 syntax, with various aliases for commonly used patterns.")
492 (define-public chez-fmt
500 "http://synthcode.com/scheme/fmt/fmt-" version ".tar.gz"))
502 (base32 "1zxqlw1jyg85yzclylh8bp2b3fwcy3l3xal68jw837n5illvsjcl"))
503 (file-name (string-append name "-" version ".tar.gz"))))
504 (build-system gnu-build-system)
506 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
508 `(("chez-scheme" ,chez-scheme)))
510 `(#:make-flags ,(chez-make-flags name version)
511 #:test-target "chez-check"
513 (modify-phases %standard-phases
514 (replace 'configure ,chez-configure)
516 (lambda* (#:key (make-flags '()) #:allow-other-keys)
517 (apply invoke "make" "chez-build" make-flags)))
519 (lambda* (#:key (make-flags '()) #:allow-other-keys)
520 (apply invoke "make" "chez-install" make-flags))))))
521 (home-page "http://synthcode.com/scheme/fmt")
522 (synopsis "Combinator formatting library for Chez Scheme")
523 (description "This package provides a library of procedures for
524 formatting Scheme objects to text in various ways, and for easily
525 concatenating, composing and extending these formatters efficiently
526 without resorting to capturing and manipulating intermediate
530 (define-public chez-mit
534 (home-page "https://github.com/fedeinthemix/chez-mit")
540 (commit (string-append "v" version))))
542 (base32 "0c7i3b6i90xk96nmxn1pc9272a4yal4v40dm1a4ybdi87x53zkk0"))
543 (file-name (git-file-name name version))))
544 (build-system gnu-build-system)
546 `(("chez-srfi" ,chez-srfi))) ; for tests
548 `(("chez-scheme" ,chez-scheme)))
550 `(#:make-flags ,(chez-make-flags name version)
552 #:phases (modify-phases %standard-phases
553 (replace 'configure ,chez-configure))))
554 (synopsis "MIT/GNU Scheme compatibility library for Chez Scheme")
555 (description "This package provides a set of MIT/GNU Scheme compatibility
556 libraries for Chez Scheme. The main goal was to provide the functionality
557 required to port the program @code{Scmutils} to Chez Scheme.")
560 (define-public chez-scmutils
562 (name "chez-scmutils")
564 (home-page "https://github.com/fedeinthemix/chez-scmutils")
570 (commit (string-append "v" version))))
572 (base32 "0lb05wlf8qpgg8y0gdsyaxg1nbfx1qbaqdjvygrp64ndn8fnhq7l"))
573 (file-name (git-file-name name version))))
574 (build-system gnu-build-system)
576 `(("chez-srfi" ,chez-srfi))) ; for tests
578 `(("chez-scheme" ,chez-scheme)))
580 `(("chez-mit" ,chez-mit)
581 ("chez-srfi" ,chez-srfi)))
583 `(#:make-flags ,(chez-make-flags name version)
584 #:tests? #f ; no test suite
586 (modify-phases %standard-phases
587 (replace 'configure ,chez-configure)
588 ;; Since the documentation is lacking, we install the source
589 ;; code. For things to work correctly we have to replace
590 ;; relative paths by absolute ones in 'include' forms. This
591 ;; in turn requires us to compile the files in the final
594 (add-after 'install 'install-src
595 (lambda* (#:key (make-flags '()) #:allow-other-keys)
596 (apply invoke "make" "install-src" make-flags)))
597 (add-after 'install-src 'absolute-path-in-scm-files
598 (lambda* (#:key outputs #:allow-other-keys)
599 (let ((out (assoc-ref outputs "out")))
600 (for-each (lambda (file)
602 (("include +\"\\./scmutils")
603 (string-append "include \"" (dirname file)))))
604 (find-files out "\\.sls"))
605 (for-each (lambda (file)
607 (("include +\"\\./scmutils/simplify")
608 (string-append "include \"" (dirname file)))))
609 (find-files out "fbe-syntax\\.scm"))
611 (add-after 'absolute-path-in-scm-files 'build
612 (lambda* (#:key outputs (make-flags '()) #:allow-other-keys)
613 (let* ((out (assoc-ref outputs "out"))
614 (mk-file (car (find-files out "Makefile"))))
615 (with-directory-excursion (dirname mk-file)
616 (apply invoke "make" "build" make-flags)))))
617 (add-after 'build 'clean-up
618 (lambda* (#:key outputs #:allow-other-keys)
619 (let* ((out (assoc-ref outputs "out")))
620 (for-each delete-file
621 (find-files out "Makefile|compile-all\\.ss"))
623 (synopsis "Port of MIT/GNU Scheme Scmutils to Chez Scheme")
624 (description "This package provides a port of the MIT/GNU Scheme
625 Scmutils program to Chez Scheme. The port consists of a set of
626 libraries providing most of the functionality of the original.")