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>
6 ;;; This file is part of GNU Guix.
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21 (define-module (gnu packages chez)
22 #:use-module (gnu packages)
23 #:use-module ((guix licenses)
24 #:select (gpl2+ gpl3+ lgpl2.0+ lgpl2.1+ asl2.0 bsd-3 expat
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix git-download)
29 #:use-module (guix utils)
30 #:use-module (guix build-system gnu)
31 #:use-module (gnu packages compression)
32 #:use-module (gnu packages ncurses)
33 #:use-module (gnu packages ghostscript)
34 #:use-module (gnu packages netpbm)
35 #:use-module (gnu packages tex)
36 #:use-module (gnu packages compression)
37 #:use-module (gnu packages image)
38 #:use-module (gnu packages xorg)
39 #:use-module (ice-9 match)
40 #:use-module (srfi srfi-1))
43 (let ((version "1.9"))
47 (url "https://github.com/nanopass/nanopass-framework-scheme.git")
48 (commit (string-append "v" version))))
49 (sha256 (base32 "0lrngdna6w7v9vlp1a873hgwrwsz2p0pgkccswa4smzvdyhgfsri"))
50 (file-name (git-file-name "nanopass" version)))))
53 (let ((version "1.2.1"))
57 (url "https://github.com/dybvig/stex.git")
58 (commit (string-append "v" version))))
59 (sha256 (base32 "1jiawhhqnsj42hzmlbq5xby3iarhf8vhiqs0kg1a0zg5jsn6cf8n"))
60 (file-name (git-file-name "stex" version)))))
62 (define-public chez-scheme
70 (url "https://github.com/cisco/ChezScheme.git")
71 (commit (string-append "v" version))))
73 (base32 "132fal5hwiq0bqzvfhjsqr4d11cfdh1670f6286ks29xxj1c04zq"))
74 (file-name (git-file-name name version))
75 (modules '((guix build utils)))
77 ;; Fix compilation with glibc >= 2.26, which removed xlocale.h.
79 (substitute* "c/expeditor.c"
80 (("xlocale\\.h") "locale.h"))
82 (build-system gnu-build-system)
84 `(("ncurses" ,ncurses)
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 (add-after 'unpack 'patch-broken-documentation
121 ;; Work around an oversight in the 9.5 release tarball that causes
122 ;; building the documentation to fail. This should be fixed in the
123 ;; next one; see <https://github.com/cisco/ChezScheme/issues/209>.
124 (substitute* "csug/copyright.stex"
125 (("\\\\INSERTREVISIONMONTHSPACEYEAR" )
126 "October 2017")) ; tarball release date
128 ;; Adapt the custom 'configure' script.
130 (lambda* (#:key inputs outputs #:allow-other-keys)
131 (let ((out (assoc-ref outputs "out"))
132 (nanopass (assoc-ref inputs "nanopass"))
133 (stex (assoc-ref inputs "stex"))
134 (zlib (assoc-ref inputs "zlib"))
135 (zlib-static (assoc-ref inputs "zlib:static"))
136 (unpack (assoc-ref %standard-phases 'unpack))
137 (patch-source-shebangs
138 (assoc-ref %standard-phases 'patch-source-shebangs)))
140 ((src orig-name new-name)
141 (with-directory-excursion "."
142 (apply unpack (list #:source src))
143 (apply patch-source-shebangs (list #:source src)))
144 (delete-file-recursively new-name)
145 (invoke "mv" orig-name new-name)))
146 `((,nanopass "source" "nanopass")
147 (,stex "source" "stex")))
148 ;; The Makefile wants to download and compile "zlib". We patch
149 ;; it to use the one from our 'zlib' package.
150 (substitute* "configure"
151 (("rmdir zlib .*$") "echo \"using system zlib\"\n"))
152 (substitute* (find-files "./c" "Mf-[a-zA-Z0-9.]+")
153 (("\\$\\{Kernel\\}: \\$\\{kernelobj\\} \\.\\./zlib/libz\\.a")
154 "${Kernel}: ${kernelobj}")
155 (("ld ([-a-zA-Z0-9_${} ]+) \\.\\./zlib/libz\\.a" all args)
156 (string-append "ld " args " " zlib-static "/lib/libz.a"))
157 (("\\(cd \\.\\./zlib; ([-a-zA-Z0-9=./ ]+))")
159 (substitute* (find-files "mats" "Mf-.*")
160 (("^[[:space:]]+(cc ) *") "\tgcc "))
162 (find-files "." (string-append
165 "|Makefile[a-zA-Z0-9.]*"
170 ;;"|[a-zA-Z0-9.]+\\.ms" ; guile can't read
172 (("/bin/rm") (which "rm"))
173 (("/bin/ln") (which "ln"))
174 (("/bin/cp") (which "cp")))
175 (substitute* "makefiles/installsh"
176 (("/bin/true") (which "true")))
177 (substitute* "stex/Makefile"
178 (("PREFIX=/usr") (string-append "PREFIX=" out)))
179 (invoke "./configure" "--threads"
180 (string-append "--installprefix=" out)))))
181 ;; Installation of the documentation requires a running "chez".
182 (add-after 'install 'install-doc
183 (lambda* (#:key inputs outputs #:allow-other-keys)
184 (let ((doc (string-append (assoc-ref outputs "doc")
185 "/share/doc/" ,name "-" ,version)))
186 (invoke "make" "docs")
187 (with-directory-excursion "csug"
188 (substitute* "Makefile"
189 ;; The ‘installdir=’ can't be overruled on the command line.
191 ;; $m is the ‘machine type’, e.g. ‘ta6le’ on x86_64, but is
192 ;; set incorrectly for some reason, e.g. to ‘a6le’ on x86_64.
193 ;; Avoid the whole mess by running the (machine-independent)
194 ;; ‘installsh’ script at its original location.
195 (("\\$m/installsh") "makefiles/installsh"))
196 (invoke "make" "install")
197 (install-file "csug.pdf" doc))
198 (with-directory-excursion "release_notes"
199 (install-file "release_notes.pdf" doc))
201 ;; The binary file name is called "scheme" as the one from MIT/GNU
202 ;; Scheme. We add a symlink to use in case both are installed.
203 (add-after 'install 'install-symlink
204 (lambda* (#:key outputs #:allow-other-keys)
205 (let* ((out (assoc-ref outputs "out"))
206 (bin (string-append out "/bin"))
207 (lib (string-append out "/lib"))
208 (name "chez-scheme"))
209 (symlink (string-append bin "/scheme")
210 (string-append bin "/" name))
212 (symlink file (string-append (dirname file)
214 (find-files lib "scheme.boot"))
216 (add-before 'reset-gzip-timestamps 'make-manpages-writable
217 (lambda* (#:key outputs #:allow-other-keys)
219 (make-file-writable file))
220 (find-files (string-append (assoc-ref outputs "out")
224 ;; According to the documentation MIPS is not supported.
225 ;; Cross-compiling for the Raspberry Pi is supported, but not native ARM.
226 (supported-systems (fold delete %supported-systems
227 '("mips64el-linux" "armhf-linux")))
228 (home-page "http://www.scheme.com")
229 (synopsis "R6RS Scheme compiler and run-time")
231 "Chez Scheme is a compiler and run-time system for the language of the
232 Revised^6 Report on Scheme (R6RS), with numerous extensions. The compiler
233 generates native code for each target processor, with support for x86, x86_64,
234 and 32-bit PowerPC architectures.")
237 (define-public chez-srfi
245 (url "https://github.com/fedeinthemix/chez-srfi.git")
246 (commit (string-append "v" version))))
248 (base32 "1vgn984mj2q4w6r2q66h7qklp2hrh85wwh4k9yisga5fi0ps7myf"))
249 (file-name (git-file-name name version))))
250 (build-system gnu-build-system)
252 `(("chez-scheme" ,chez-scheme)))
254 `(#:make-flags (let ((out (assoc-ref %outputs "out")))
255 (list (string-append "PREFIX=" out)))
257 #:phases (modify-phases %standard-phases
258 (delete 'configure))))
259 (home-page "https://github.com/fedeinthemix/chez-srfi")
260 (synopsis "SRFI libraries for Chez Scheme")
262 "This package provides a collection of SRFI libraries for Chez Scheme.")
265 (define-public chez-web
266 (let ((commit "5fd177fe53f31f466bf88720d03c95a3711a8bea")
270 ;; Release 2.0 is different and doesn't work.
271 (version (git-version "2.0" revision commit))
276 (url "https://github.com/arcfide/ChezWEB.git")
278 (file-name (git-file-name name version))
280 (base32 "1dq25qygyncbfq4kwwqqgyyakfqjwhp5q23vrf3bff1p66nyfl3b"))))
281 (build-system gnu-build-system)
283 `(("chez-scheme" ,chez-scheme)
284 ("ghostscript" ,ghostscript)
285 ("texlive" ,(texlive-union (list texlive-latex-oberdiek
288 texlive-fonts-charter
289 texlive-generic-pdftex
292 texlive-tex-plain)))))
294 `(#:make-flags (list (string-append "PREFIX=" %output)
295 (string-append "DOCDIR=" %output "/share/doc/"
297 (string-append "LIBDIR=" %output "/lib/chezweb")
298 (string-append "TEXDIR=" %output "/share/texmf-local"))
299 #:tests? #f ; no tests
301 (modify-phases %standard-phases
302 (add-before 'build 'set-HOME
304 ;; FIXME: texlive-union does not find the built
305 ;; metafonts, so it tries to generate them in HOME.
306 (setenv "HOME" "/tmp")
308 ;; This package has a custom "bootstrap" script that
309 ;; is meant to be run from the Makefile.
313 (copy-file "config.mk.template" "config.mk")
314 (substitute* "tangleit"
315 (("\\./cheztangle\\.ss" all)
316 (string-append "chez-scheme --program " all)))
317 (substitute* "weaveit"
318 (("mpost chezweb\\.mp")
319 "mpost --tex=tex chezweb.mp")
320 (("\\./chezweave" all)
321 (string-append "chez-scheme --program " all)))
322 (substitute* "installit"
323 (("-g \\$GROUP -o \\$OWNER") ""))
325 (home-page "https://github.com/arcfide/ChezWEB")
326 (synopsis "Hygienic Literate Programming for Chez Scheme")
327 (description "ChezWEB is a system for doing Knuthian style WEB
328 programming in Scheme.")
331 (define-public chez-sockets
332 (let ((commit "bce96881c06bd69a6757a6bff139744153924140")
335 (name "chez-sockets")
336 (version (git-version "0.0.0" revision commit))
341 (url "https://github.com/arcfide/chez-sockets.git")
343 (file-name (git-file-name name version))
345 (base32 "1n5fbwwz51fdzvjackgmnsgh363g9inyxv7kmzi0469cwavwcx5m"))))
346 (build-system gnu-build-system)
348 `(("chez-scheme" ,chez-scheme)
349 ("chez-web" ,chez-web)
350 ("texlive" ,(texlive-union (list texlive-generic-pdftex)))))
352 `(#:tests? #f ; no tests
354 (modify-phases %standard-phases
356 (lambda* (#:key outputs inputs #:allow-other-keys)
357 (let* ((out (assoc-ref outputs "out"))
358 (chez-web (assoc-ref inputs "chez-web"))
359 (chez (assoc-ref inputs "chez-scheme"))
360 (chez-h (dirname (car (find-files chez "scheme\\.h")))))
361 (substitute* "Makefile"
362 (("(SCHEMEH=).*$" all var)
363 (string-append var chez-h)))
365 (add-before 'build 'tangle
366 (lambda* (#:key inputs #:allow-other-keys)
370 (assoc-ref inputs "chez-web") "/share/texmf-local/tex/generic:"
372 ;; just using "make" tries to build the .c files before
374 (and (invoke "make" "sockets")
377 (lambda* (#:key outputs inputs #:allow-other-keys)
378 (let* ((out (assoc-ref outputs "out"))
379 (chez-site (string-append out "/lib/csv"
380 ,(package-version chez-scheme)
382 ;; make sure Chez Scheme can find the shared libraries.
383 (substitute* "sockets.ss"
384 (("(load-shared-object) \"(socket-ffi-values\\.[sd][oy].*)\""
386 (string-append cmd " \"" chez-site "/" so "\""))
387 (("sockets-stub\\.[sd][oy].*" all)
388 (string-append chez-site "/" all)))
389 ;; to compile chez-sockets, the .so files must be
390 ;; installed (because of the absolute path we
392 (for-each (lambda (f d) (install-file f d))
393 '("socket-ffi-values.so" "sockets-stub.so")
394 (list chez-site chez-site))
395 (zero? (system "echo '(compile-file \"sockets.sls\")' | scheme -q")))))
397 (lambda* (#:key outputs inputs #:allow-other-keys)
398 (let* ((out (assoc-ref outputs "out"))
399 (lib (string-append out "/lib/chez-sockets"))
400 (doc (string-append out "/share/doc/" ,name "-" ,version))
401 (chez-site (string-append out "/lib/csv"
402 ,(package-version chez-scheme)
404 (for-each (lambda (f d) (install-file f d))
405 '("sockets.pdf" "sockets.so")
406 (list doc chez-site))
408 (home-page "https://github.com/arcfide/chez-sockets")
409 (synopsis "Extensible sockets library for Chez Scheme")
410 (description "Chez-sockets is an extensible sockets library for
414 ;; Help function for Chez Scheme to add the current path to
415 ;; CHEZSCHEMELIBDIRS.
416 (define chez-configure
418 (let ((chez-env (getenv "CHEZSCHEMELIBDIRS")))
419 (setenv "CHEZSCHEMELIBDIRS"
421 (string-append ".:" chez-env)
425 ;; Help function to define make flags for some Chez Scheme custom make
427 (define (chez-make-flags name version)
428 `(let ((out (assoc-ref %outputs "out")))
429 (list (string-append "PREFIX=" out)
430 (string-append "DOCDIR=" out "/share/doc/"
431 ,name "-" ,version))))
433 (define-public chez-matchable
435 (name "chez-matchable")
437 (home-page "https://github.com/fedeinthemix/chez-matchable")
443 (commit (string-append "v" version))))
445 (base32 "02qn7x348p23z1x5lwhkyj7i8z6mgwpzpnwr8dyina0yzsdkr71s"))
446 (file-name (git-file-name name version))))
447 (build-system gnu-build-system)
449 `(("chez-srfi" ,chez-srfi))) ; for tests
451 `(("chez-scheme" ,chez-scheme)))
453 `(#:make-flags ,(chez-make-flags name version)
455 #:phases (modify-phases %standard-phases
456 (replace 'configure ,chez-configure))))
457 (synopsis "Portable hygienic pattern matcher for Scheme")
458 (description "This package provides a superset of the popular Scheme
459 @code{match} package by Andrew Wright, written in fully portable
460 @code{syntax-rules} and thus preserving hygiene.")
461 (license public-domain)))
463 (define-public chez-irregex
465 (name "chez-irregex")
471 (url "https://github.com/fedeinthemix/chez-irregex.git")
472 (commit (string-append "v" version))))
474 (base32 "0jh6piylw545j81llay9wfivgpv6lcnwd81gm4w17lkasslir50q"))
475 (file-name (git-file-name name version))))
476 (build-system gnu-build-system)
478 `(("chez-matchable" ,chez-matchable))) ; for tests
480 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
482 `(("chez-scheme" ,chez-scheme)))
484 `(#:make-flags ,(chez-make-flags name version)
486 #:phases (modify-phases %standard-phases
487 (replace 'configure ,chez-configure))))
488 (home-page "https://github.com/fedeinthemix/chez-irregex")
489 (synopsis "Portable regular expression library for Scheme")
490 (description "This package provides a portable and efficient
491 R[4567]RS implementation of regular expressions, supporting both POSIX
492 syntax with various (irregular) PCRE extensions, as well as SCSH's SRE
493 syntax, with various aliases for commonly used patterns.")
496 (define-public chez-fmt
504 "http://synthcode.com/scheme/fmt/fmt-" version ".tar.gz"))
506 (base32 "1zxqlw1jyg85yzclylh8bp2b3fwcy3l3xal68jw837n5illvsjcl"))
507 (file-name (string-append name "-" version ".tar.gz"))))
508 (build-system gnu-build-system)
510 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
512 `(("chez-scheme" ,chez-scheme)))
514 `(#:make-flags ,(chez-make-flags name version)
515 #:test-target "chez-check"
517 (modify-phases %standard-phases
518 (replace 'configure ,chez-configure)
520 (lambda* (#:key (make-flags '()) #:allow-other-keys)
521 (apply invoke "make" "chez-build" make-flags)))
523 (lambda* (#:key (make-flags '()) #:allow-other-keys)
524 (apply invoke "make" "chez-install" make-flags))))))
525 (home-page "http://synthcode.com/scheme/fmt")
526 (synopsis "Combinator formatting library for Chez Scheme")
527 (description "This package provides a library of procedures for
528 formatting Scheme objects to text in various ways, and for easily
529 concatenating, composing and extending these formatters efficiently
530 without resorting to capturing and manipulating intermediate
534 (define-public chez-mit
538 (home-page "https://github.com/fedeinthemix/chez-mit")
544 (commit (string-append "v" version))))
546 (base32 "0c7i3b6i90xk96nmxn1pc9272a4yal4v40dm1a4ybdi87x53zkk0"))
547 (file-name (git-file-name name version))))
548 (build-system gnu-build-system)
550 `(("chez-srfi" ,chez-srfi))) ; for tests
552 `(("chez-scheme" ,chez-scheme)))
554 `(#:make-flags ,(chez-make-flags name version)
556 #:phases (modify-phases %standard-phases
557 (replace 'configure ,chez-configure))))
558 (synopsis "MIT/GNU Scheme compatibility library for Chez Scheme")
559 (description "This package provides a set of MIT/GNU Scheme compatibility
560 libraries for Chez Scheme. The main goal was to provide the functionality
561 required to port the program @code{Scmutils} to Chez Scheme.")
564 (define-public chez-scmutils
566 (name "chez-scmutils")
568 (home-page "https://github.com/fedeinthemix/chez-scmutils")
574 (commit (string-append "v" version))))
576 (base32 "0lb05wlf8qpgg8y0gdsyaxg1nbfx1qbaqdjvygrp64ndn8fnhq7l"))
577 (file-name (git-file-name name version))))
578 (build-system gnu-build-system)
580 `(("chez-srfi" ,chez-srfi))) ; for tests
582 `(("chez-scheme" ,chez-scheme)))
584 `(("chez-mit" ,chez-mit)
585 ("chez-srfi" ,chez-srfi)))
587 `(#:make-flags ,(chez-make-flags name version)
588 #:tests? #f ; no test suite
590 (modify-phases %standard-phases
591 (replace 'configure ,chez-configure)
592 ;; Since the documentation is lacking, we install the source
593 ;; code. For things to work correctly we have to replace
594 ;; relative paths by absolute ones in 'include' forms. This
595 ;; in turn requires us to compile the files in the final
598 (add-after 'install 'install-src
599 (lambda* (#:key (make-flags '()) #:allow-other-keys)
600 (apply invoke "make" "install-src" make-flags)))
601 (add-after 'install-src 'absolute-path-in-scm-files
602 (lambda* (#:key outputs #:allow-other-keys)
603 (let ((out (assoc-ref outputs "out")))
604 (for-each (lambda (file)
606 (("include +\"\\./scmutils")
607 (string-append "include \"" (dirname file)))))
608 (find-files out "\\.sls"))
609 (for-each (lambda (file)
611 (("include +\"\\./scmutils/simplify")
612 (string-append "include \"" (dirname file)))))
613 (find-files out "fbe-syntax\\.scm"))
615 (add-after 'absolute-path-in-scm-files 'build
616 (lambda* (#:key outputs (make-flags '()) #:allow-other-keys)
617 (let* ((out (assoc-ref outputs "out"))
618 (mk-file (car (find-files out "Makefile"))))
619 (with-directory-excursion (dirname mk-file)
620 (apply invoke "make" "build" make-flags)))))
621 (add-after 'build 'clean-up
622 (lambda* (#:key outputs #:allow-other-keys)
623 (let* ((out (assoc-ref outputs "out")))
624 (for-each delete-file
625 (find-files out "Makefile|compile-all\\.ss"))
627 (synopsis "Port of MIT/GNU Scheme Scmutils to Chez Scheme")
628 (description "This package provides a port of the MIT/GNU Scheme
629 Scmutils program to Chez Scheme. The port consists of a set of
630 libraries providing most of the functionality of the original.")