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>
7 ;;; This file is part of GNU Guix.
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22 (define-module (gnu packages chez)
23 #:use-module (gnu packages)
24 #:use-module ((guix licenses)
25 #:select (gpl2+ gpl3+ lgpl2.0+ lgpl2.1+ asl2.0 bsd-3 expat
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix git-download)
30 #:use-module (guix utils)
31 #:use-module (guix build-system gnu)
32 #:use-module (gnu packages compression)
33 #:use-module (gnu packages ncurses)
34 #:use-module (gnu packages ghostscript)
35 #:use-module (gnu packages linux)
36 #:use-module (gnu packages netpbm)
37 #:use-module (gnu packages tex)
38 #:use-module (gnu packages compression)
39 #:use-module (gnu packages image)
40 #:use-module (gnu packages xorg)
41 #:use-module (ice-9 match)
42 #:use-module (srfi srfi-1))
45 (let ((version "1.9"))
49 (url "https://github.com/nanopass/nanopass-framework-scheme")
50 (commit (string-append "v" version))))
51 (sha256 (base32 "0lrngdna6w7v9vlp1a873hgwrwsz2p0pgkccswa4smzvdyhgfsri"))
52 (file-name (git-file-name "nanopass" version)))))
55 (let ((version "1.2.1"))
59 (url "https://github.com/dybvig/stex")
60 (commit (string-append "v" version))))
61 (sha256 (base32 "1jiawhhqnsj42hzmlbq5xby3iarhf8vhiqs0kg1a0zg5jsn6cf8n"))
62 (file-name (git-file-name "stex" version)))))
64 (define-public chez-scheme
72 (url "https://github.com/cisco/ChezScheme")
73 (commit (string-append "v" version))))
75 (base32 "1hagrqdp649n2g0wq2a9gfnz7mjcjakkw7ziplbj3db412bb7kx5"))
76 (file-name (git-file-name name version))))
77 (build-system gnu-build-system)
79 `(("ncurses" ,ncurses)
80 ("libuuid" ,util-linux "lib")
82 ("xorg-rgb" ,xorg-rgb)
83 ("nanopass" ,nanopass)
85 ("zlib:static" ,zlib "static")
88 `(("texlive" ,(texlive-union (list texlive-latex-oberdiek
89 texlive-generic-epsf)))
90 ("ghostscript" ,ghostscript)
93 (list (search-path-specification
94 (variable "CHEZSCHEMELIBDIRS")
95 (files (list (string-append "lib/csv" version "-site"))))))
96 (outputs '("out" "doc"))
98 `(#:modules ((guix build gnu-build-system)
103 (list ,(match (or (%current-target-system) (%current-system))
104 ("x86_64-linux" '(list "--machine=ta6le"))
105 ("i686-linux" '(list "--machine=ti3le"))
106 ;; Let autodetection have its attempt on other architectures.
110 (modify-phases %standard-phases
111 (add-after 'unpack 'patch-processor-detection
112 (lambda _ (substitute* "configure"
113 (("uname -a") "uname -m"))
115 ;; Adapt the custom 'configure' script.
117 (lambda* (#:key inputs outputs #:allow-other-keys)
118 (let ((out (assoc-ref outputs "out"))
119 (nanopass (assoc-ref inputs "nanopass"))
120 (stex (assoc-ref inputs "stex"))
121 (zlib (assoc-ref inputs "zlib"))
122 (zlib-static (assoc-ref inputs "zlib:static"))
123 (unpack (assoc-ref %standard-phases 'unpack))
124 (patch-source-shebangs
125 (assoc-ref %standard-phases 'patch-source-shebangs)))
127 ((src orig-name new-name)
128 (with-directory-excursion "."
129 (apply unpack (list #:source src))
130 (apply patch-source-shebangs (list #:source src)))
131 (delete-file-recursively new-name)
132 (invoke "mv" orig-name new-name)))
133 `((,nanopass "source" "nanopass")
134 (,stex "source" "stex")))
135 ;; The configure step wants to CURL all submodules as it
136 ;; detects a checkout without submodules. Disable curling,
137 ;; and manually patch the needed modules for compilation.
138 (substitute* "configure"
139 (("! -f '") "-d '")) ; working around CURL.
140 (substitute* (find-files "./c" "Mf-[a-zA-Z0-9.]+")
141 (("\\$\\{Kernel\\}: \\$\\{kernelobj\\} \\.\\./zlib/libz\\.a")
142 "${Kernel}: ${kernelobj}")
143 (("ld ([-a-zA-Z0-9_${} ]+) \\.\\./zlib/libz\\.a" all args)
144 (string-append "ld " args " " zlib-static "/lib/libz.a"))
145 (("\\(cd \\.\\./zlib; ([-a-zA-Z0-9=./ ]+))")
147 (substitute* (find-files "mats" "Mf-.*")
148 (("^[[:space:]]+(cc ) *") "\tgcc "))
150 (find-files "." (string-append
153 "|Makefile[a-zA-Z0-9.]*"
158 ;;"|[a-zA-Z0-9.]+\\.ms" ; guile can't read
160 (("/bin/rm") (which "rm"))
161 (("/bin/ln") (which "ln"))
162 (("/bin/cp") (which "cp")))
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 "--installprefix=" out)))))
169 ;; Installation of the documentation requires a running "chez".
170 (add-after 'install 'install-doc
171 (lambda* (#:key inputs outputs #:allow-other-keys)
172 (let ((doc (string-append (assoc-ref outputs "doc")
173 "/share/doc/" ,name "-" ,version)))
174 (invoke "make" "docs")
175 (with-directory-excursion "csug"
176 (substitute* "Makefile"
177 ;; The ‘installdir=’ can't be overruled on the command line.
179 ;; $m is the ‘machine type’, e.g. ‘ta6le’ on x86_64, but is
180 ;; set incorrectly for some reason, e.g. to ‘a6le’ on x86_64.
181 ;; Avoid the whole mess by running the (machine-independent)
182 ;; ‘installsh’ script at its original location.
183 (("\\$m/installsh") "makefiles/installsh"))
184 (invoke "make" "install")
185 (install-file "csug.pdf" doc))
186 (with-directory-excursion "release_notes"
187 (install-file "release_notes.pdf" doc))
189 ;; The binary file name is called "scheme" as the one from MIT/GNU
190 ;; Scheme. We add a symlink to use in case both are installed.
191 (add-after 'install 'install-symlink
192 (lambda* (#:key outputs #:allow-other-keys)
193 (let* ((out (assoc-ref outputs "out"))
194 (bin (string-append out "/bin"))
195 (lib (string-append out "/lib"))
196 (name "chez-scheme"))
197 (symlink (string-append bin "/scheme")
198 (string-append bin "/" name))
200 (symlink file (string-append (dirname file)
202 (find-files lib "scheme.boot"))
204 (add-before 'reset-gzip-timestamps 'make-manpages-writable
205 (lambda* (#:key outputs #:allow-other-keys)
207 (make-file-writable file))
208 (find-files (string-append (assoc-ref outputs "out")
212 ;; According to the documentation MIPS is not supported.
213 ;; Cross-compiling for the Raspberry Pi is supported, but not native ARM.
214 (supported-systems (fold delete %supported-systems
215 '("mips64el-linux" "armhf-linux")))
216 (home-page "https://cisco.github.io/ChezScheme/")
217 (synopsis "R6RS Scheme compiler and run-time")
219 "Chez Scheme is a compiler and run-time system for the language of the
220 Revised^6 Report on Scheme (R6RS), with numerous extensions. The compiler
221 generates native code for each target processor, with support for x86, x86_64,
222 and 32-bit PowerPC architectures.")
225 (define-public chez-srfi
233 (url "https://github.com/fedeinthemix/chez-srfi")
234 (commit (string-append "v" version))))
236 (base32 "1vgn984mj2q4w6r2q66h7qklp2hrh85wwh4k9yisga5fi0ps7myf"))
237 (file-name (git-file-name name version))))
238 (build-system gnu-build-system)
240 `(("chez-scheme" ,chez-scheme)))
242 `(#:make-flags (let ((out (assoc-ref %outputs "out")))
243 (list (string-append "PREFIX=" out)
244 "CHEZ=chez-scheme --libdirs ./"
245 (string-append "chezversion=" ,(package-version chez-scheme))))
247 #:phases (modify-phases %standard-phases
248 (delete 'configure))))
249 (home-page "https://github.com/fedeinthemix/chez-srfi")
250 (synopsis "SRFI libraries for Chez Scheme")
252 "This package provides a collection of SRFI libraries for Chez Scheme.")
255 (define-public chez-web
256 (let ((commit "5fd177fe53f31f466bf88720d03c95a3711a8bea")
260 ;; Release 2.0 is different and doesn't work.
261 (version (git-version "2.0" revision commit))
266 (url "https://github.com/arcfide/ChezWEB")
268 (file-name (git-file-name name version))
270 (base32 "1dq25qygyncbfq4kwwqqgyyakfqjwhp5q23vrf3bff1p66nyfl3b"))))
271 (build-system gnu-build-system)
273 `(("chez-scheme" ,chez-scheme)
274 ("ghostscript" ,ghostscript)
275 ("texlive" ,(texlive-union (list texlive-latex-oberdiek
278 texlive-fonts-charter
279 texlive-generic-pdftex
282 texlive-tex-plain)))))
284 `(#:make-flags (list (string-append "PREFIX=" %output)
285 (string-append "DOCDIR=" %output "/share/doc/"
287 (string-append "LIBDIR=" %output "/lib/chezweb")
288 (string-append "TEXDIR=" %output "/share/texmf-local"))
289 #:tests? #f ; no tests
291 (modify-phases %standard-phases
292 (add-before 'build 'set-HOME
294 ;; FIXME: texlive-union does not find the built
295 ;; metafonts, so it tries to generate them in HOME.
296 (setenv "HOME" "/tmp")
298 ;; This package has a custom "bootstrap" script that
299 ;; is meant to be run from the Makefile.
303 (copy-file "config.mk.template" "config.mk")
304 (substitute* "tangleit"
305 (("\\./cheztangle\\.ss" all)
306 (string-append "chez-scheme --program " all)))
307 (substitute* "weaveit"
308 (("mpost chezweb\\.mp")
309 "mpost --tex=tex chezweb.mp")
310 (("\\./chezweave" all)
311 (string-append "chez-scheme --program " all)))
312 (substitute* "installit"
313 (("-g \\$GROUP -o \\$OWNER") ""))
315 (home-page "https://github.com/arcfide/ChezWEB")
316 (synopsis "Hygienic Literate Programming for Chez Scheme")
317 (description "ChezWEB is a system for doing Knuthian style WEB
318 programming in Scheme.")
321 (define-public chez-sockets
322 (let ((commit "bce96881c06bd69a6757a6bff139744153924140")
325 (name "chez-sockets")
326 (version (git-version "0.0.0" revision commit))
331 (url "https://github.com/arcfide/chez-sockets")
333 (file-name (git-file-name name version))
335 (base32 "1n5fbwwz51fdzvjackgmnsgh363g9inyxv7kmzi0469cwavwcx5m"))))
336 (build-system gnu-build-system)
338 `(("chez-scheme" ,chez-scheme)
339 ("chez-web" ,chez-web)
340 ("texlive" ,(texlive-union (list texlive-generic-pdftex)))))
342 `(#:tests? #f ; no tests
344 (modify-phases %standard-phases
346 (lambda* (#:key outputs inputs #:allow-other-keys)
347 (let* ((out (assoc-ref outputs "out"))
348 (chez-web (assoc-ref inputs "chez-web"))
349 (chez (assoc-ref inputs "chez-scheme"))
350 (chez-h (dirname (car (find-files chez "scheme\\.h")))))
351 (substitute* "Makefile"
352 (("(SCHEMEH=).*$" all var)
353 (string-append var chez-h)))
355 (add-before 'build 'tangle
356 (lambda* (#:key inputs #:allow-other-keys)
360 (assoc-ref inputs "chez-web") "/share/texmf-local/tex/generic:"
362 ;; just using "make" tries to build the .c files before
364 (and (invoke "make" "sockets")
367 (lambda* (#:key outputs inputs #:allow-other-keys)
368 (let* ((out (assoc-ref outputs "out"))
369 (chez-site (string-append out "/lib/csv"
370 ,(package-version chez-scheme)
372 ;; make sure Chez Scheme can find the shared libraries.
373 (substitute* "sockets.ss"
374 (("(load-shared-object) \"(socket-ffi-values\\.[sd][oy].*)\""
376 (string-append cmd " \"" chez-site "/" so "\""))
377 (("sockets-stub\\.[sd][oy].*" all)
378 (string-append chez-site "/" all)))
379 ;; to compile chez-sockets, the .so files must be
380 ;; installed (because of the absolute path we
382 (for-each (lambda (f d) (install-file f d))
383 '("socket-ffi-values.so" "sockets-stub.so")
384 (list chez-site chez-site))
385 (zero? (system "echo '(compile-file \"sockets.sls\")' | scheme -q")))))
387 (lambda* (#:key outputs inputs #:allow-other-keys)
388 (let* ((out (assoc-ref outputs "out"))
389 (lib (string-append out "/lib/chez-sockets"))
390 (doc (string-append out "/share/doc/" ,name "-" ,version))
391 (chez-site (string-append out "/lib/csv"
392 ,(package-version chez-scheme)
394 (for-each (lambda (f d) (install-file f d))
395 '("sockets.pdf" "sockets.so")
396 (list doc chez-site))
398 (home-page "https://github.com/arcfide/chez-sockets")
399 (synopsis "Extensible sockets library for Chez Scheme")
400 (description "Chez-sockets is an extensible sockets library for
404 ;; Help function for Chez Scheme to add the current path to
405 ;; CHEZSCHEMELIBDIRS.
406 (define chez-configure
408 (let ((chez-env (getenv "CHEZSCHEMELIBDIRS")))
409 (setenv "CHEZSCHEMELIBDIRS"
411 (string-append ".:" chez-env)
415 ;; Help function to define make flags for some Chez Scheme custom make
417 (define (chez-make-flags name version)
418 `(let ((out (assoc-ref %outputs "out")))
420 ;; Set 'chezversion' so that libraries are installed in
421 ;; 'lib/csvX.Y.Z-site' like Chez's 'native-search-paths' expects.
422 (string-append "chezversion=" ,(package-version chez-scheme))
423 (string-append "PREFIX=" out)
424 (string-append "DOCDIR=" out "/share/doc/"
425 ,name "-" ,version))))
427 (define-public chez-matchable
429 (name "chez-matchable")
431 (home-page "https://github.com/fedeinthemix/chez-matchable")
437 (commit (string-append "v" version))))
439 (base32 "02qn7x348p23z1x5lwhkyj7i8z6mgwpzpnwr8dyina0yzsdkr71s"))
440 (file-name (git-file-name name version))))
441 (build-system gnu-build-system)
443 `(("chez-srfi" ,chez-srfi))) ; for tests
445 `(("chez-scheme" ,chez-scheme)))
447 `(#:make-flags ,(chez-make-flags name version)
449 #:phases (modify-phases %standard-phases
450 (replace 'configure ,chez-configure))))
451 (synopsis "Portable hygienic pattern matcher for Scheme")
452 (description "This package provides a superset of the popular Scheme
453 @code{match} package by Andrew Wright, written in fully portable
454 @code{syntax-rules} and thus preserving hygiene.")
455 (license public-domain)))
457 (define-public chez-irregex
459 (name "chez-irregex")
465 (url "https://github.com/fedeinthemix/chez-irregex")
466 (commit (string-append "v" version))))
468 (base32 "0jh6piylw545j81llay9wfivgpv6lcnwd81gm4w17lkasslir50q"))
469 (file-name (git-file-name name version))))
470 (build-system gnu-build-system)
472 `(("chez-matchable" ,chez-matchable))) ; for tests
474 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
476 `(("chez-scheme" ,chez-scheme)))
478 `(#:make-flags ,(chez-make-flags name version)
480 #:phases (modify-phases %standard-phases
481 (replace 'configure ,chez-configure))))
482 (home-page "https://github.com/fedeinthemix/chez-irregex")
483 (synopsis "Portable regular expression library for Scheme")
484 (description "This package provides a portable and efficient
485 R[4567]RS implementation of regular expressions, supporting both POSIX
486 syntax with various (irregular) PCRE extensions, as well as SCSH's SRE
487 syntax, with various aliases for commonly used patterns.")
490 (define-public chez-fmt
498 "http://synthcode.com/scheme/fmt/fmt-" version ".tar.gz"))
500 (base32 "1zxqlw1jyg85yzclylh8bp2b3fwcy3l3xal68jw837n5illvsjcl"))
501 (file-name (string-append name "-" version ".tar.gz"))))
502 (build-system gnu-build-system)
504 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
506 `(("chez-scheme" ,chez-scheme)))
508 `(#:make-flags ,(chez-make-flags name version)
509 #:test-target "chez-check"
511 (modify-phases %standard-phases
512 (replace 'configure ,chez-configure)
514 (lambda* (#:key (make-flags '()) #:allow-other-keys)
515 (apply invoke "make" "chez-build" make-flags)))
517 (lambda* (#:key (make-flags '()) #:allow-other-keys)
518 (apply invoke "make" "chez-install" make-flags))))))
519 (home-page "http://synthcode.com/scheme/fmt")
520 (synopsis "Combinator formatting library for Chez Scheme")
521 (description "This package provides a library of procedures for
522 formatting Scheme objects to text in various ways, and for easily
523 concatenating, composing and extending these formatters efficiently
524 without resorting to capturing and manipulating intermediate
528 (define-public chez-mit
532 (home-page "https://github.com/fedeinthemix/chez-mit")
538 (commit (string-append "v" version))))
540 (base32 "0c7i3b6i90xk96nmxn1pc9272a4yal4v40dm1a4ybdi87x53zkk0"))
541 (file-name (git-file-name name version))))
542 (build-system gnu-build-system)
544 `(("chez-srfi" ,chez-srfi))) ; for tests
546 `(("chez-scheme" ,chez-scheme)))
548 `(#:make-flags ,(chez-make-flags name version)
550 #:phases (modify-phases %standard-phases
551 (replace 'configure ,chez-configure))))
552 (synopsis "MIT/GNU Scheme compatibility library for Chez Scheme")
553 (description "This package provides a set of MIT/GNU Scheme compatibility
554 libraries for Chez Scheme. The main goal was to provide the functionality
555 required to port the program @code{Scmutils} to Chez Scheme.")
558 (define-public chez-scmutils
560 (name "chez-scmutils")
562 (home-page "https://github.com/fedeinthemix/chez-scmutils")
568 (commit (string-append "v" version))))
570 (base32 "0lb05wlf8qpgg8y0gdsyaxg1nbfx1qbaqdjvygrp64ndn8fnhq7l"))
571 (file-name (git-file-name name version))))
572 (build-system gnu-build-system)
574 `(("chez-srfi" ,chez-srfi))) ; for tests
576 `(("chez-scheme" ,chez-scheme)))
578 `(("chez-mit" ,chez-mit)
579 ("chez-srfi" ,chez-srfi)))
581 `(#:make-flags ,(chez-make-flags name version)
582 #:tests? #f ; no test suite
584 (modify-phases %standard-phases
585 (replace 'configure ,chez-configure)
586 ;; Since the documentation is lacking, we install the source
587 ;; code. For things to work correctly we have to replace
588 ;; relative paths by absolute ones in 'include' forms. This
589 ;; in turn requires us to compile the files in the final
592 (add-after 'install 'install-src
593 (lambda* (#:key (make-flags '()) #:allow-other-keys)
594 (apply invoke "make" "install-src" make-flags)))
595 (add-after 'install-src 'absolute-path-in-scm-files
596 (lambda* (#:key outputs #:allow-other-keys)
597 (let ((out (assoc-ref outputs "out")))
598 (for-each (lambda (file)
600 (("include +\"\\./scmutils")
601 (string-append "include \"" (dirname file)))))
602 (find-files out "\\.sls"))
603 (for-each (lambda (file)
605 (("include +\"\\./scmutils/simplify")
606 (string-append "include \"" (dirname file)))))
607 (find-files out "fbe-syntax\\.scm"))
609 (add-after 'absolute-path-in-scm-files 'build
610 (lambda* (#:key outputs (make-flags '()) #:allow-other-keys)
611 (let* ((out (assoc-ref outputs "out"))
612 (mk-file (car (find-files out "Makefile"))))
613 (with-directory-excursion (dirname mk-file)
614 (apply invoke "make" "build" make-flags)))))
615 (add-after 'build 'clean-up
616 (lambda* (#:key outputs #:allow-other-keys)
617 (let* ((out (assoc-ref outputs "out")))
618 (for-each delete-file
619 (find-files out "Makefile|compile-all\\.ss"))
621 (synopsis "Port of MIT/GNU Scheme Scmutils to Chez Scheme")
622 (description "This package provides a port of the MIT/GNU Scheme
623 Scmutils program to Chez Scheme. The port consists of a set of
624 libraries providing most of the functionality of the original.")