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 (modules '((guix build utils)))
79 ;; Fix compilation with glibc >= 2.26, which removed xlocale.h.
81 (substitute* "c/expeditor.c"
82 (("xlocale\\.h") "locale.h"))
84 (build-system gnu-build-system)
86 `(("ncurses" ,ncurses)
88 ("xorg-rgb" ,xorg-rgb)
89 ("nanopass" ,nanopass)
91 ("zlib:static" ,zlib "static")
94 `(("texlive" ,(texlive-union (list texlive-latex-oberdiek
95 texlive-generic-epsf)))
96 ("ghostscript" ,ghostscript)
98 ("util-linux" ,util-linux)))
100 (list (search-path-specification
101 (variable "CHEZSCHEMELIBDIRS")
102 (files (list (string-append "lib/csv" version "-site"))))))
103 (outputs '("out" "doc"))
105 `(#:modules ((guix build gnu-build-system)
110 (list ,(match (or (%current-target-system) (%current-system))
111 ("x86_64-linux" '(list "--machine=ta6le"))
112 ("i686-linux" '(list "--machine=ti3le"))
113 ;; Let autodetection have its attempt on other architectures.
117 (modify-phases %standard-phases
118 (add-after 'unpack 'patch-processor-detection
119 (lambda _ (substitute* "configure"
120 (("uname -a") "uname -m"))
122 ;; Adapt the custom 'configure' script.
124 (lambda* (#:key inputs outputs #:allow-other-keys)
125 (let ((out (assoc-ref outputs "out"))
126 (nanopass (assoc-ref inputs "nanopass"))
127 (stex (assoc-ref inputs "stex"))
128 (zlib (assoc-ref inputs "zlib"))
129 (zlib-static (assoc-ref inputs "zlib:static"))
130 (unpack (assoc-ref %standard-phases 'unpack))
131 (patch-source-shebangs
132 (assoc-ref %standard-phases 'patch-source-shebangs)))
134 ((src orig-name new-name)
135 (with-directory-excursion "."
136 (apply unpack (list #:source src))
137 (apply patch-source-shebangs (list #:source src)))
138 (delete-file-recursively new-name)
139 (invoke "mv" orig-name new-name)))
140 `((,nanopass "source" "nanopass")
141 (,stex "source" "stex")))
142 ;; The configure step wants to CURL all submodules as it
143 ;; detects a checkout without submodules. Disable curling,
144 ;; and manually patch the needed modules for compilation.
145 (substitute* "configure"
146 (("! -f '") "-d '")) ; working around CURL.
147 (substitute* (find-files "./c" "Mf-[a-zA-Z0-9.]+")
148 (("\\$\\{Kernel\\}: \\$\\{kernelobj\\} \\.\\./zlib/libz\\.a")
149 "${Kernel}: ${kernelobj}")
150 (("ld ([-a-zA-Z0-9_${} ]+) \\.\\./zlib/libz\\.a" all args)
151 (string-append "ld " args " " zlib-static "/lib/libz.a"))
152 (("\\(cd \\.\\./zlib; ([-a-zA-Z0-9=./ ]+))")
154 (substitute* (find-files "mats" "Mf-.*")
155 (("^[[:space:]]+(cc ) *") "\tgcc "))
157 (find-files "." (string-append
160 "|Makefile[a-zA-Z0-9.]*"
165 ;;"|[a-zA-Z0-9.]+\\.ms" ; guile can't read
167 (("/bin/rm") (which "rm"))
168 (("/bin/ln") (which "ln"))
169 (("/bin/cp") (which "cp")))
170 (substitute* "makefiles/installsh"
171 (("/bin/true") (which "true")))
172 (substitute* "stex/Makefile"
173 (("PREFIX=/usr") (string-append "PREFIX=" out)))
174 (invoke "./configure" "--threads"
175 (string-append "--installprefix=" out)))))
176 ;; Installation of the documentation requires a running "chez".
177 (add-after 'install 'install-doc
178 (lambda* (#:key inputs outputs #:allow-other-keys)
179 (let ((doc (string-append (assoc-ref outputs "doc")
180 "/share/doc/" ,name "-" ,version)))
181 (invoke "make" "docs")
182 (with-directory-excursion "csug"
183 (substitute* "Makefile"
184 ;; The ‘installdir=’ can't be overruled on the command line.
186 ;; $m is the ‘machine type’, e.g. ‘ta6le’ on x86_64, but is
187 ;; set incorrectly for some reason, e.g. to ‘a6le’ on x86_64.
188 ;; Avoid the whole mess by running the (machine-independent)
189 ;; ‘installsh’ script at its original location.
190 (("\\$m/installsh") "makefiles/installsh"))
191 (invoke "make" "install")
192 (install-file "csug.pdf" doc))
193 (with-directory-excursion "release_notes"
194 (install-file "release_notes.pdf" doc))
196 ;; The binary file name is called "scheme" as the one from MIT/GNU
197 ;; Scheme. We add a symlink to use in case both are installed.
198 (add-after 'install 'install-symlink
199 (lambda* (#:key outputs #:allow-other-keys)
200 (let* ((out (assoc-ref outputs "out"))
201 (bin (string-append out "/bin"))
202 (lib (string-append out "/lib"))
203 (name "chez-scheme"))
204 (symlink (string-append bin "/scheme")
205 (string-append bin "/" name))
207 (symlink file (string-append (dirname file)
209 (find-files lib "scheme.boot"))
211 (add-before 'reset-gzip-timestamps 'make-manpages-writable
212 (lambda* (#:key outputs #:allow-other-keys)
214 (make-file-writable file))
215 (find-files (string-append (assoc-ref outputs "out")
219 ;; According to the documentation MIPS is not supported.
220 ;; Cross-compiling for the Raspberry Pi is supported, but not native ARM.
221 (supported-systems (fold delete %supported-systems
222 '("mips64el-linux" "armhf-linux")))
223 (home-page "https://cisco.github.io/ChezScheme/")
224 (synopsis "R6RS Scheme compiler and run-time")
226 "Chez Scheme is a compiler and run-time system for the language of the
227 Revised^6 Report on Scheme (R6RS), with numerous extensions. The compiler
228 generates native code for each target processor, with support for x86, x86_64,
229 and 32-bit PowerPC architectures.")
232 (define-public chez-srfi
240 (url "https://github.com/fedeinthemix/chez-srfi.git")
241 (commit (string-append "v" version))))
243 (base32 "1vgn984mj2q4w6r2q66h7qklp2hrh85wwh4k9yisga5fi0ps7myf"))
244 (file-name (git-file-name name version))))
245 (build-system gnu-build-system)
247 `(("chez-scheme" ,chez-scheme)))
249 `(#:make-flags (let ((out (assoc-ref %outputs "out")))
250 (list (string-append "PREFIX=" out)))
252 #:phases (modify-phases %standard-phases
253 (delete 'configure))))
254 (home-page "https://github.com/fedeinthemix/chez-srfi")
255 (synopsis "SRFI libraries for Chez Scheme")
257 "This package provides a collection of SRFI libraries for Chez Scheme.")
260 (define-public chez-web
261 (let ((commit "5fd177fe53f31f466bf88720d03c95a3711a8bea")
265 ;; Release 2.0 is different and doesn't work.
266 (version (git-version "2.0" revision commit))
271 (url "https://github.com/arcfide/ChezWEB.git")
273 (file-name (git-file-name name version))
275 (base32 "1dq25qygyncbfq4kwwqqgyyakfqjwhp5q23vrf3bff1p66nyfl3b"))))
276 (build-system gnu-build-system)
278 `(("chez-scheme" ,chez-scheme)
279 ("ghostscript" ,ghostscript)
280 ("texlive" ,(texlive-union (list texlive-latex-oberdiek
283 texlive-fonts-charter
284 texlive-generic-pdftex
287 texlive-tex-plain)))))
289 `(#:make-flags (list (string-append "PREFIX=" %output)
290 (string-append "DOCDIR=" %output "/share/doc/"
292 (string-append "LIBDIR=" %output "/lib/chezweb")
293 (string-append "TEXDIR=" %output "/share/texmf-local"))
294 #:tests? #f ; no tests
296 (modify-phases %standard-phases
297 (add-before 'build 'set-HOME
299 ;; FIXME: texlive-union does not find the built
300 ;; metafonts, so it tries to generate them in HOME.
301 (setenv "HOME" "/tmp")
303 ;; This package has a custom "bootstrap" script that
304 ;; is meant to be run from the Makefile.
308 (copy-file "config.mk.template" "config.mk")
309 (substitute* "tangleit"
310 (("\\./cheztangle\\.ss" all)
311 (string-append "chez-scheme --program " all)))
312 (substitute* "weaveit"
313 (("mpost chezweb\\.mp")
314 "mpost --tex=tex chezweb.mp")
315 (("\\./chezweave" all)
316 (string-append "chez-scheme --program " all)))
317 (substitute* "installit"
318 (("-g \\$GROUP -o \\$OWNER") ""))
320 (home-page "https://github.com/arcfide/ChezWEB")
321 (synopsis "Hygienic Literate Programming for Chez Scheme")
322 (description "ChezWEB is a system for doing Knuthian style WEB
323 programming in Scheme.")
326 (define-public chez-sockets
327 (let ((commit "bce96881c06bd69a6757a6bff139744153924140")
330 (name "chez-sockets")
331 (version (git-version "0.0.0" revision commit))
336 (url "https://github.com/arcfide/chez-sockets.git")
338 (file-name (git-file-name name version))
340 (base32 "1n5fbwwz51fdzvjackgmnsgh363g9inyxv7kmzi0469cwavwcx5m"))))
341 (build-system gnu-build-system)
343 `(("chez-scheme" ,chez-scheme)
344 ("chez-web" ,chez-web)
345 ("texlive" ,(texlive-union (list texlive-generic-pdftex)))))
347 `(#:tests? #f ; no tests
349 (modify-phases %standard-phases
351 (lambda* (#:key outputs inputs #:allow-other-keys)
352 (let* ((out (assoc-ref outputs "out"))
353 (chez-web (assoc-ref inputs "chez-web"))
354 (chez (assoc-ref inputs "chez-scheme"))
355 (chez-h (dirname (car (find-files chez "scheme\\.h")))))
356 (substitute* "Makefile"
357 (("(SCHEMEH=).*$" all var)
358 (string-append var chez-h)))
360 (add-before 'build 'tangle
361 (lambda* (#:key inputs #:allow-other-keys)
365 (assoc-ref inputs "chez-web") "/share/texmf-local/tex/generic:"
367 ;; just using "make" tries to build the .c files before
369 (and (invoke "make" "sockets")
372 (lambda* (#:key outputs inputs #:allow-other-keys)
373 (let* ((out (assoc-ref outputs "out"))
374 (chez-site (string-append out "/lib/csv"
375 ,(package-version chez-scheme)
377 ;; make sure Chez Scheme can find the shared libraries.
378 (substitute* "sockets.ss"
379 (("(load-shared-object) \"(socket-ffi-values\\.[sd][oy].*)\""
381 (string-append cmd " \"" chez-site "/" so "\""))
382 (("sockets-stub\\.[sd][oy].*" all)
383 (string-append chez-site "/" all)))
384 ;; to compile chez-sockets, the .so files must be
385 ;; installed (because of the absolute path we
387 (for-each (lambda (f d) (install-file f d))
388 '("socket-ffi-values.so" "sockets-stub.so")
389 (list chez-site chez-site))
390 (zero? (system "echo '(compile-file \"sockets.sls\")' | scheme -q")))))
392 (lambda* (#:key outputs inputs #:allow-other-keys)
393 (let* ((out (assoc-ref outputs "out"))
394 (lib (string-append out "/lib/chez-sockets"))
395 (doc (string-append out "/share/doc/" ,name "-" ,version))
396 (chez-site (string-append out "/lib/csv"
397 ,(package-version chez-scheme)
399 (for-each (lambda (f d) (install-file f d))
400 '("sockets.pdf" "sockets.so")
401 (list doc chez-site))
403 (home-page "https://github.com/arcfide/chez-sockets")
404 (synopsis "Extensible sockets library for Chez Scheme")
405 (description "Chez-sockets is an extensible sockets library for
409 ;; Help function for Chez Scheme to add the current path to
410 ;; CHEZSCHEMELIBDIRS.
411 (define chez-configure
413 (let ((chez-env (getenv "CHEZSCHEMELIBDIRS")))
414 (setenv "CHEZSCHEMELIBDIRS"
416 (string-append ".:" chez-env)
420 ;; Help function to define make flags for some Chez Scheme custom make
422 (define (chez-make-flags name version)
423 `(let ((out (assoc-ref %outputs "out")))
424 (list (string-append "PREFIX=" out)
425 (string-append "DOCDIR=" out "/share/doc/"
426 ,name "-" ,version))))
428 (define-public chez-matchable
430 (name "chez-matchable")
432 (home-page "https://github.com/fedeinthemix/chez-matchable")
438 (commit (string-append "v" version))))
440 (base32 "02qn7x348p23z1x5lwhkyj7i8z6mgwpzpnwr8dyina0yzsdkr71s"))
441 (file-name (git-file-name name version))))
442 (build-system gnu-build-system)
444 `(("chez-srfi" ,chez-srfi))) ; for tests
446 `(("chez-scheme" ,chez-scheme)))
448 `(#:make-flags ,(chez-make-flags name version)
450 #:phases (modify-phases %standard-phases
451 (replace 'configure ,chez-configure))))
452 (synopsis "Portable hygienic pattern matcher for Scheme")
453 (description "This package provides a superset of the popular Scheme
454 @code{match} package by Andrew Wright, written in fully portable
455 @code{syntax-rules} and thus preserving hygiene.")
456 (license public-domain)))
458 (define-public chez-irregex
460 (name "chez-irregex")
466 (url "https://github.com/fedeinthemix/chez-irregex.git")
467 (commit (string-append "v" version))))
469 (base32 "0jh6piylw545j81llay9wfivgpv6lcnwd81gm4w17lkasslir50q"))
470 (file-name (git-file-name name version))))
471 (build-system gnu-build-system)
473 `(("chez-matchable" ,chez-matchable))) ; for tests
475 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
477 `(("chez-scheme" ,chez-scheme)))
479 `(#:make-flags ,(chez-make-flags name version)
481 #:phases (modify-phases %standard-phases
482 (replace 'configure ,chez-configure))))
483 (home-page "https://github.com/fedeinthemix/chez-irregex")
484 (synopsis "Portable regular expression library for Scheme")
485 (description "This package provides a portable and efficient
486 R[4567]RS implementation of regular expressions, supporting both POSIX
487 syntax with various (irregular) PCRE extensions, as well as SCSH's SRE
488 syntax, with various aliases for commonly used patterns.")
491 (define-public chez-fmt
499 "http://synthcode.com/scheme/fmt/fmt-" version ".tar.gz"))
501 (base32 "1zxqlw1jyg85yzclylh8bp2b3fwcy3l3xal68jw837n5illvsjcl"))
502 (file-name (string-append name "-" version ".tar.gz"))))
503 (build-system gnu-build-system)
505 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
507 `(("chez-scheme" ,chez-scheme)))
509 `(#:make-flags ,(chez-make-flags name version)
510 #:test-target "chez-check"
512 (modify-phases %standard-phases
513 (replace 'configure ,chez-configure)
515 (lambda* (#:key (make-flags '()) #:allow-other-keys)
516 (apply invoke "make" "chez-build" make-flags)))
518 (lambda* (#:key (make-flags '()) #:allow-other-keys)
519 (apply invoke "make" "chez-install" make-flags))))))
520 (home-page "http://synthcode.com/scheme/fmt")
521 (synopsis "Combinator formatting library for Chez Scheme")
522 (description "This package provides a library of procedures for
523 formatting Scheme objects to text in various ways, and for easily
524 concatenating, composing and extending these formatters efficiently
525 without resorting to capturing and manipulating intermediate
529 (define-public chez-mit
533 (home-page "https://github.com/fedeinthemix/chez-mit")
539 (commit (string-append "v" version))))
541 (base32 "0c7i3b6i90xk96nmxn1pc9272a4yal4v40dm1a4ybdi87x53zkk0"))
542 (file-name (git-file-name name version))))
543 (build-system gnu-build-system)
545 `(("chez-srfi" ,chez-srfi))) ; for tests
547 `(("chez-scheme" ,chez-scheme)))
549 `(#:make-flags ,(chez-make-flags name version)
551 #:phases (modify-phases %standard-phases
552 (replace 'configure ,chez-configure))))
553 (synopsis "MIT/GNU Scheme compatibility library for Chez Scheme")
554 (description "This package provides a set of MIT/GNU Scheme compatibility
555 libraries for Chez Scheme. The main goal was to provide the functionality
556 required to port the program @code{Scmutils} to Chez Scheme.")
559 (define-public chez-scmutils
561 (name "chez-scmutils")
563 (home-page "https://github.com/fedeinthemix/chez-scmutils")
569 (commit (string-append "v" version))))
571 (base32 "0lb05wlf8qpgg8y0gdsyaxg1nbfx1qbaqdjvygrp64ndn8fnhq7l"))
572 (file-name (git-file-name name version))))
573 (build-system gnu-build-system)
575 `(("chez-srfi" ,chez-srfi))) ; for tests
577 `(("chez-scheme" ,chez-scheme)))
579 `(("chez-mit" ,chez-mit)
580 ("chez-srfi" ,chez-srfi)))
582 `(#:make-flags ,(chez-make-flags name version)
583 #:tests? #f ; no test suite
585 (modify-phases %standard-phases
586 (replace 'configure ,chez-configure)
587 ;; Since the documentation is lacking, we install the source
588 ;; code. For things to work correctly we have to replace
589 ;; relative paths by absolute ones in 'include' forms. This
590 ;; in turn requires us to compile the files in the final
593 (add-after 'install 'install-src
594 (lambda* (#:key (make-flags '()) #:allow-other-keys)
595 (apply invoke "make" "install-src" make-flags)))
596 (add-after 'install-src 'absolute-path-in-scm-files
597 (lambda* (#:key outputs #:allow-other-keys)
598 (let ((out (assoc-ref outputs "out")))
599 (for-each (lambda (file)
601 (("include +\"\\./scmutils")
602 (string-append "include \"" (dirname file)))))
603 (find-files out "\\.sls"))
604 (for-each (lambda (file)
606 (("include +\"\\./scmutils/simplify")
607 (string-append "include \"" (dirname file)))))
608 (find-files out "fbe-syntax\\.scm"))
610 (add-after 'absolute-path-in-scm-files 'build
611 (lambda* (#:key outputs (make-flags '()) #:allow-other-keys)
612 (let* ((out (assoc-ref outputs "out"))
613 (mk-file (car (find-files out "Makefile"))))
614 (with-directory-excursion (dirname mk-file)
615 (apply invoke "make" "build" make-flags)))))
616 (add-after 'build 'clean-up
617 (lambda* (#:key outputs #:allow-other-keys)
618 (let* ((out (assoc-ref outputs "out")))
619 (for-each delete-file
620 (find-files out "Makefile|compile-all\\.ss"))
622 (synopsis "Port of MIT/GNU Scheme Scmutils to Chez Scheme")
623 (description "This package provides a port of the MIT/GNU Scheme
624 Scmutils program to Chez Scheme. The port consists of a set of
625 libraries providing most of the functionality of the original.")