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.git")
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.git")
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.git")
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)
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.git")
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)))
245 #:phases (modify-phases %standard-phases
246 (delete 'configure))))
247 (home-page "https://github.com/fedeinthemix/chez-srfi")
248 (synopsis "SRFI libraries for Chez Scheme")
250 "This package provides a collection of SRFI libraries for Chez Scheme.")
253 (define-public chez-web
254 (let ((commit "5fd177fe53f31f466bf88720d03c95a3711a8bea")
258 ;; Release 2.0 is different and doesn't work.
259 (version (git-version "2.0" revision commit))
264 (url "https://github.com/arcfide/ChezWEB.git")
266 (file-name (git-file-name name version))
268 (base32 "1dq25qygyncbfq4kwwqqgyyakfqjwhp5q23vrf3bff1p66nyfl3b"))))
269 (build-system gnu-build-system)
271 `(("chez-scheme" ,chez-scheme)
272 ("ghostscript" ,ghostscript)
273 ("texlive" ,(texlive-union (list texlive-latex-oberdiek
276 texlive-fonts-charter
277 texlive-generic-pdftex
280 texlive-tex-plain)))))
282 `(#:make-flags (list (string-append "PREFIX=" %output)
283 (string-append "DOCDIR=" %output "/share/doc/"
285 (string-append "LIBDIR=" %output "/lib/chezweb")
286 (string-append "TEXDIR=" %output "/share/texmf-local"))
287 #:tests? #f ; no tests
289 (modify-phases %standard-phases
290 (add-before 'build 'set-HOME
292 ;; FIXME: texlive-union does not find the built
293 ;; metafonts, so it tries to generate them in HOME.
294 (setenv "HOME" "/tmp")
296 ;; This package has a custom "bootstrap" script that
297 ;; is meant to be run from the Makefile.
301 (copy-file "config.mk.template" "config.mk")
302 (substitute* "tangleit"
303 (("\\./cheztangle\\.ss" all)
304 (string-append "chez-scheme --program " all)))
305 (substitute* "weaveit"
306 (("mpost chezweb\\.mp")
307 "mpost --tex=tex chezweb.mp")
308 (("\\./chezweave" all)
309 (string-append "chez-scheme --program " all)))
310 (substitute* "installit"
311 (("-g \\$GROUP -o \\$OWNER") ""))
313 (home-page "https://github.com/arcfide/ChezWEB")
314 (synopsis "Hygienic Literate Programming for Chez Scheme")
315 (description "ChezWEB is a system for doing Knuthian style WEB
316 programming in Scheme.")
319 (define-public chez-sockets
320 (let ((commit "bce96881c06bd69a6757a6bff139744153924140")
323 (name "chez-sockets")
324 (version (git-version "0.0.0" revision commit))
329 (url "https://github.com/arcfide/chez-sockets.git")
331 (file-name (git-file-name name version))
333 (base32 "1n5fbwwz51fdzvjackgmnsgh363g9inyxv7kmzi0469cwavwcx5m"))))
334 (build-system gnu-build-system)
336 `(("chez-scheme" ,chez-scheme)
337 ("chez-web" ,chez-web)
338 ("texlive" ,(texlive-union (list texlive-generic-pdftex)))))
340 `(#:tests? #f ; no tests
342 (modify-phases %standard-phases
344 (lambda* (#:key outputs inputs #:allow-other-keys)
345 (let* ((out (assoc-ref outputs "out"))
346 (chez-web (assoc-ref inputs "chez-web"))
347 (chez (assoc-ref inputs "chez-scheme"))
348 (chez-h (dirname (car (find-files chez "scheme\\.h")))))
349 (substitute* "Makefile"
350 (("(SCHEMEH=).*$" all var)
351 (string-append var chez-h)))
353 (add-before 'build 'tangle
354 (lambda* (#:key inputs #:allow-other-keys)
358 (assoc-ref inputs "chez-web") "/share/texmf-local/tex/generic:"
360 ;; just using "make" tries to build the .c files before
362 (and (invoke "make" "sockets")
365 (lambda* (#:key outputs inputs #:allow-other-keys)
366 (let* ((out (assoc-ref outputs "out"))
367 (chez-site (string-append out "/lib/csv"
368 ,(package-version chez-scheme)
370 ;; make sure Chez Scheme can find the shared libraries.
371 (substitute* "sockets.ss"
372 (("(load-shared-object) \"(socket-ffi-values\\.[sd][oy].*)\""
374 (string-append cmd " \"" chez-site "/" so "\""))
375 (("sockets-stub\\.[sd][oy].*" all)
376 (string-append chez-site "/" all)))
377 ;; to compile chez-sockets, the .so files must be
378 ;; installed (because of the absolute path we
380 (for-each (lambda (f d) (install-file f d))
381 '("socket-ffi-values.so" "sockets-stub.so")
382 (list chez-site chez-site))
383 (zero? (system "echo '(compile-file \"sockets.sls\")' | scheme -q")))))
385 (lambda* (#:key outputs inputs #:allow-other-keys)
386 (let* ((out (assoc-ref outputs "out"))
387 (lib (string-append out "/lib/chez-sockets"))
388 (doc (string-append out "/share/doc/" ,name "-" ,version))
389 (chez-site (string-append out "/lib/csv"
390 ,(package-version chez-scheme)
392 (for-each (lambda (f d) (install-file f d))
393 '("sockets.pdf" "sockets.so")
394 (list doc chez-site))
396 (home-page "https://github.com/arcfide/chez-sockets")
397 (synopsis "Extensible sockets library for Chez Scheme")
398 (description "Chez-sockets is an extensible sockets library for
402 ;; Help function for Chez Scheme to add the current path to
403 ;; CHEZSCHEMELIBDIRS.
404 (define chez-configure
406 (let ((chez-env (getenv "CHEZSCHEMELIBDIRS")))
407 (setenv "CHEZSCHEMELIBDIRS"
409 (string-append ".:" chez-env)
413 ;; Help function to define make flags for some Chez Scheme custom make
415 (define (chez-make-flags name version)
416 `(let ((out (assoc-ref %outputs "out")))
417 (list (string-append "PREFIX=" out)
418 (string-append "DOCDIR=" out "/share/doc/"
419 ,name "-" ,version))))
421 (define-public chez-matchable
423 (name "chez-matchable")
425 (home-page "https://github.com/fedeinthemix/chez-matchable")
431 (commit (string-append "v" version))))
433 (base32 "02qn7x348p23z1x5lwhkyj7i8z6mgwpzpnwr8dyina0yzsdkr71s"))
434 (file-name (git-file-name name version))))
435 (build-system gnu-build-system)
437 `(("chez-srfi" ,chez-srfi))) ; for tests
439 `(("chez-scheme" ,chez-scheme)))
441 `(#:make-flags ,(chez-make-flags name version)
443 #:phases (modify-phases %standard-phases
444 (replace 'configure ,chez-configure))))
445 (synopsis "Portable hygienic pattern matcher for Scheme")
446 (description "This package provides a superset of the popular Scheme
447 @code{match} package by Andrew Wright, written in fully portable
448 @code{syntax-rules} and thus preserving hygiene.")
449 (license public-domain)))
451 (define-public chez-irregex
453 (name "chez-irregex")
459 (url "https://github.com/fedeinthemix/chez-irregex.git")
460 (commit (string-append "v" version))))
462 (base32 "0jh6piylw545j81llay9wfivgpv6lcnwd81gm4w17lkasslir50q"))
463 (file-name (git-file-name name version))))
464 (build-system gnu-build-system)
466 `(("chez-matchable" ,chez-matchable))) ; for tests
468 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
470 `(("chez-scheme" ,chez-scheme)))
472 `(#:make-flags ,(chez-make-flags name version)
474 #:phases (modify-phases %standard-phases
475 (replace 'configure ,chez-configure))))
476 (home-page "https://github.com/fedeinthemix/chez-irregex")
477 (synopsis "Portable regular expression library for Scheme")
478 (description "This package provides a portable and efficient
479 R[4567]RS implementation of regular expressions, supporting both POSIX
480 syntax with various (irregular) PCRE extensions, as well as SCSH's SRE
481 syntax, with various aliases for commonly used patterns.")
484 (define-public chez-fmt
492 "http://synthcode.com/scheme/fmt/fmt-" version ".tar.gz"))
494 (base32 "1zxqlw1jyg85yzclylh8bp2b3fwcy3l3xal68jw837n5illvsjcl"))
495 (file-name (string-append name "-" version ".tar.gz"))))
496 (build-system gnu-build-system)
498 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
500 `(("chez-scheme" ,chez-scheme)))
502 `(#:make-flags ,(chez-make-flags name version)
503 #:test-target "chez-check"
505 (modify-phases %standard-phases
506 (replace 'configure ,chez-configure)
508 (lambda* (#:key (make-flags '()) #:allow-other-keys)
509 (apply invoke "make" "chez-build" make-flags)))
511 (lambda* (#:key (make-flags '()) #:allow-other-keys)
512 (apply invoke "make" "chez-install" make-flags))))))
513 (home-page "http://synthcode.com/scheme/fmt")
514 (synopsis "Combinator formatting library for Chez Scheme")
515 (description "This package provides a library of procedures for
516 formatting Scheme objects to text in various ways, and for easily
517 concatenating, composing and extending these formatters efficiently
518 without resorting to capturing and manipulating intermediate
522 (define-public chez-mit
526 (home-page "https://github.com/fedeinthemix/chez-mit")
532 (commit (string-append "v" version))))
534 (base32 "0c7i3b6i90xk96nmxn1pc9272a4yal4v40dm1a4ybdi87x53zkk0"))
535 (file-name (git-file-name name version))))
536 (build-system gnu-build-system)
538 `(("chez-srfi" ,chez-srfi))) ; for tests
540 `(("chez-scheme" ,chez-scheme)))
542 `(#:make-flags ,(chez-make-flags name version)
544 #:phases (modify-phases %standard-phases
545 (replace 'configure ,chez-configure))))
546 (synopsis "MIT/GNU Scheme compatibility library for Chez Scheme")
547 (description "This package provides a set of MIT/GNU Scheme compatibility
548 libraries for Chez Scheme. The main goal was to provide the functionality
549 required to port the program @code{Scmutils} to Chez Scheme.")
552 (define-public chez-scmutils
554 (name "chez-scmutils")
556 (home-page "https://github.com/fedeinthemix/chez-scmutils")
562 (commit (string-append "v" version))))
564 (base32 "0lb05wlf8qpgg8y0gdsyaxg1nbfx1qbaqdjvygrp64ndn8fnhq7l"))
565 (file-name (git-file-name name version))))
566 (build-system gnu-build-system)
568 `(("chez-srfi" ,chez-srfi))) ; for tests
570 `(("chez-scheme" ,chez-scheme)))
572 `(("chez-mit" ,chez-mit)
573 ("chez-srfi" ,chez-srfi)))
575 `(#:make-flags ,(chez-make-flags name version)
576 #:tests? #f ; no test suite
578 (modify-phases %standard-phases
579 (replace 'configure ,chez-configure)
580 ;; Since the documentation is lacking, we install the source
581 ;; code. For things to work correctly we have to replace
582 ;; relative paths by absolute ones in 'include' forms. This
583 ;; in turn requires us to compile the files in the final
586 (add-after 'install 'install-src
587 (lambda* (#:key (make-flags '()) #:allow-other-keys)
588 (apply invoke "make" "install-src" make-flags)))
589 (add-after 'install-src 'absolute-path-in-scm-files
590 (lambda* (#:key outputs #:allow-other-keys)
591 (let ((out (assoc-ref outputs "out")))
592 (for-each (lambda (file)
594 (("include +\"\\./scmutils")
595 (string-append "include \"" (dirname file)))))
596 (find-files out "\\.sls"))
597 (for-each (lambda (file)
599 (("include +\"\\./scmutils/simplify")
600 (string-append "include \"" (dirname file)))))
601 (find-files out "fbe-syntax\\.scm"))
603 (add-after 'absolute-path-in-scm-files 'build
604 (lambda* (#:key outputs (make-flags '()) #:allow-other-keys)
605 (let* ((out (assoc-ref outputs "out"))
606 (mk-file (car (find-files out "Makefile"))))
607 (with-directory-excursion (dirname mk-file)
608 (apply invoke "make" "build" make-flags)))))
609 (add-after 'build 'clean-up
610 (lambda* (#:key outputs #:allow-other-keys)
611 (let* ((out (assoc-ref outputs "out")))
612 (for-each delete-file
613 (find-files out "Makefile|compile-all\\.ss"))
615 (synopsis "Port of MIT/GNU Scheme Scmutils to Chez Scheme")
616 (description "This package provides a port of the MIT/GNU Scheme
617 Scmutils program to Chez Scheme. The port consists of a set of
618 libraries providing most of the functionality of the original.")