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 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 "https://github.com/nanopass/nanopass-framework-scheme/archive"
48 "/v" version ".tar.gz"))
49 (sha256 (base32 "11pwyy4jiwhcl2am3a4ciczacjbjkyvdizqzdglb3l1hj2gj6nv2"))
50 (file-name (string-append "nanopass-" version ".tar.gz")))))
53 (let ((version "1.2.1"))
57 "https://github.com/dybvig/stex/archive"
58 "/v" version ".tar.gz"))
59 (sha256 (base32 "03pl3f668h24dn51vccr1sj5lsba9zq3j37bnxjvdadcdaj4qy5z"))
60 (file-name (string-append "stex-" version ".tar.gz")))))
62 (define-public chez-scheme
69 (uri (string-append "https://github.com/cisco/ChezScheme/archive/"
70 "v" version ".tar.gz"))
72 (base32 "135991hspq0grf26pvl2lkwhp92yz204h6rgiwyym0x6v0xzknd1"))
73 (file-name (string-append "chez-scheme-" version ".tar.gz"))
74 (modules '((guix build utils)))
76 ;; Fix compilation with glibc >= 2.26, which removed xlocale.h.
78 (substitute* "c/expeditor.c"
79 (("xlocale\\.h") "locale.h"))
81 (build-system gnu-build-system)
83 `(("ncurses" ,ncurses)
85 ("xorg-rgb" ,xorg-rgb)
86 ("nanopass" ,nanopass)
88 ("zlib:static" ,zlib "static")
91 `(("texlive" ,texlive)
92 ("ghostscript" ,ghostscript)
95 (list (search-path-specification
96 (variable "CHEZSCHEMELIBDIRS")
97 (files (list (string-append "lib/csv" version "-site"))))))
98 (outputs '("out" "doc"))
100 `(#:modules ((guix build gnu-build-system)
105 (list ,(match (or (%current-target-system) (%current-system))
106 ("x86_64-linux" '(list "--machine=ta6le"))
107 ("i686-linux" '(list "--machine=ti3le"))
108 ;; Let autodetection have its attempt on other architectures.
112 (modify-phases %standard-phases
113 (add-after 'unpack 'patch-processor-detection
114 (lambda _ (substitute* "configure"
115 (("uname -a") "uname -m"))
117 (add-after 'unpack 'patch-broken-documentation
119 ;; Work around an oversight in the 9.5 release tarball that causes
120 ;; building the documentation to fail. This should be fixed in the
121 ;; next one; see <https://github.com/cisco/ChezScheme/issues/209>.
122 (substitute* "csug/copyright.stex"
123 (("\\\\INSERTREVISIONMONTHSPACEYEAR" )
124 "October 2017")))) ; tarball release date
125 ;; Adapt the custom 'configure' script.
127 (lambda* (#:key inputs outputs #:allow-other-keys)
128 (let ((out (assoc-ref outputs "out"))
129 (nanopass (assoc-ref inputs "nanopass"))
130 (stex (assoc-ref inputs "stex"))
131 (zlib (assoc-ref inputs "zlib"))
132 (zlib-static (assoc-ref inputs "zlib:static"))
133 (unpack (assoc-ref %standard-phases 'unpack))
134 (patch-source-shebangs
135 (assoc-ref %standard-phases 'patch-source-shebangs)))
137 ((src orig-name new-name)
138 (with-directory-excursion "."
139 (apply unpack (list #:source src))
140 (apply patch-source-shebangs (list #:source src)))
141 (delete-file-recursively new-name)
142 (system* "mv" orig-name new-name)))
143 `((,nanopass "nanopass-framework-scheme-1.9" "nanopass")
144 (,stex "stex-1.2.1" "stex")))
145 ;; The Makefile wants to download and compile "zlib". We patch
146 ;; it to use the one from our 'zlib' package.
147 (substitute* "configure"
148 (("rmdir zlib .*$") "echo \"using system zlib\"\n"))
149 (substitute* (find-files "./c" "Mf-[a-zA-Z0-9.]+")
150 (("\\$\\{Kernel\\}: \\$\\{kernelobj\\} \\.\\./zlib/libz\\.a")
151 "${Kernel}: ${kernelobj}")
152 (("ld ([-a-zA-Z0-9_${} ]+) \\.\\./zlib/libz\\.a" all args)
153 (string-append "ld " args " " zlib-static "/lib/libz.a"))
154 (("\\(cd \\.\\./zlib; ([-a-zA-Z0-9=./ ]+))")
156 (substitute* (find-files "mats" "Mf-.*")
157 (("^[[:space:]]+(cc ) *") "\tgcc "))
159 (find-files "." (string-append
162 "|Makefile[a-zA-Z0-9.]*"
167 ;;"|[a-zA-Z0-9.]+\\.ms" ; guile can't read
169 (("/bin/rm") (which "rm"))
170 (("/bin/ln") (which "ln"))
171 (("/bin/cp") (which "cp")))
172 (substitute* "makefiles/installsh"
173 (("/bin/true") (which "true")))
174 (substitute* "stex/Makefile"
175 (("PREFIX=/usr") (string-append "PREFIX=" out)))
176 (zero? (system* "./configure" "--threads"
177 (string-append "--installprefix=" out))))))
178 ;; Installation of the documentation requires a running "chez".
179 (add-after 'install 'install-doc
180 (lambda* (#:key inputs outputs #:allow-other-keys)
181 (let ((bin (string-append (assoc-ref outputs "out") "/bin"))
182 (doc (string-append (assoc-ref outputs "doc")
183 "/share/doc/" ,name "-" ,version)))
184 (setenv "HOME" (getcwd))
185 (setenv "PATH" (string-append (getenv "PATH") ":" bin))
186 (with-directory-excursion "stex"
187 (system* "make" (string-append "BIN=" bin)))
188 (system* "make" "docs")
189 (with-directory-excursion "csug"
190 (substitute* "Makefile"
191 (("/tmp/csug9") doc))
192 (system* "make" "install")
193 (install-file "csug.pdf" doc))
194 (with-directory-excursion "release_notes"
195 (install-file "release_notes.pdf" doc))
197 ;; The binary file name is called "scheme" as the one from MIT/GNU
198 ;; Scheme. We add a symlink to use in case both are installed.
199 (add-after 'install 'install-symlink
200 (lambda* (#:key outputs #:allow-other-keys)
201 (let* ((out (assoc-ref outputs "out"))
202 (bin (string-append out "/bin"))
203 (lib (string-append out "/lib"))
204 (name "chez-scheme"))
205 (symlink (string-append bin "/scheme")
206 (string-append bin "/" name))
208 (symlink file (string-append (dirname file)
210 (find-files lib "scheme.boot"))
212 (add-before 'reset-gzip-timestamps 'make-manpages-writable
213 (lambda* (#:key outputs #:allow-other-keys)
215 (make-file-writable file))
216 (find-files (string-append (assoc-ref outputs "out")
220 ;; According to the documentation MIPS is not supported.
221 ;; Cross-compiling for the Raspberry Pi is supported, but not native ARM.
222 (supported-systems (fold delete %supported-systems
223 '("mips64el-linux" "armhf-linux")))
224 (home-page "http://www.scheme.com")
225 (synopsis "R6RS Scheme compiler and run-time")
227 "Chez Scheme is a compiler and run-time system for the language of the
228 Revised^6 Report on Scheme (R6RS), with numerous extensions. The compiler
229 generates native code for each target processor, with support for x86, x86_64,
230 and 32-bit PowerPC architectures.")
233 (define-public chez-srfi
241 "https://github.com/fedeinthemix/chez-srfi/archive"
242 "/v" version ".tar.gz"))
244 (base32 "17i4wly7bcr5kb5hf04ljpbvv4r5hsr9xsmw650fj43z9jr303gs"))
245 (file-name (string-append name "-" version ".tar.gz"))))
246 (build-system gnu-build-system)
248 `(("chez-scheme" ,chez-scheme)))
250 `(#:make-flags (let ((out (assoc-ref %outputs "out")))
251 (list (string-append "PREFIX=" out)))
253 #:phases (modify-phases %standard-phases
254 (delete 'configure))))
255 (home-page "https://github.com/fedeinthemix/chez-srfi")
256 (synopsis "SRFI libraries for Chez Scheme")
258 "This package provides a collection of SRFI libraries for Chez Scheme.")
261 (define-public chez-web
262 (let ((commit "5fd177fe53f31f466bf88720d03c95a3711a8bea")
266 ;; release 2.0 is different and doesn't work.
267 (version (string-append "2.0-" revision "."
268 (string-take commit 7)))
273 (url "https://github.com/arcfide/ChezWEB.git")
275 (file-name (string-append name "-" version "-checkout"))
277 (base32 "1dq25qygyncbfq4kwwqqgyyakfqjwhp5q23vrf3bff1p66nyfl3b"))))
278 (build-system gnu-build-system)
280 `(("chez-scheme" ,chez-scheme)
281 ("texlive" ,texlive)))
283 `(#:make-flags (list (string-append "PREFIX=" %output)
284 (string-append "DOCDIR=" %output "/share/doc/"
286 (string-append "LIBDIR=" %output "/lib/chezweb")
287 (string-append "TEXDIR=" %output "/share/texmf-local"))
288 #:tests? #f ; no tests
290 (modify-phases %standard-phases
293 (copy-file "config.mk.template" "config.mk")
294 (substitute* "tangleit"
295 (("\\./cheztangle\\.ss" all)
296 (string-append "chez-scheme --program " all)))
297 (substitute* "weaveit"
298 (("mpost chezweb\\.mp")
299 "mpost --tex=tex chezweb.mp")
300 (("\\./chezweave" all)
301 (string-append "chez-scheme --program " all)))
302 (substitute* "installit"
303 (("-g \\$GROUP -o \\$OWNER") "")))))))
304 (home-page "https://github.com/arcfide/ChezWEB")
305 (synopsis "Hygienic Literate Programming for Chez Scheme")
306 (description "ChezWEB is a system for doing Knuthian style WEB
307 programming in Scheme.")
310 (define-public chez-sockets
311 (let ((commit "bce96881c06bd69a6757a6bff139744153924140")
314 (name "chez-sockets")
315 (version (string-append "0.0-" revision "."
316 (string-take commit 7)))
321 (url "https://github.com/arcfide/chez-sockets.git")
323 (file-name (string-append name "-" version "-checkout"))
325 (base32 "1n5fbwwz51fdzvjackgmnsgh363g9inyxv7kmzi0469cwavwcx5m"))))
326 (build-system gnu-build-system)
328 `(("chez-scheme" ,chez-scheme)
329 ("chez-web" ,chez-web)
330 ("texlive" ,texlive)))
332 `(#:tests? #f ; no tests
334 (modify-phases %standard-phases
336 (lambda* (#:key outputs inputs #:allow-other-keys)
337 (let* ((out (assoc-ref outputs "out"))
338 (chez-web (assoc-ref inputs "chez-web"))
339 (chez (assoc-ref inputs "chez-scheme"))
340 (chez-h (dirname (car (find-files chez "scheme\\.h")))))
341 (substitute* "Makefile"
342 (("(SCHEMEH=).*$" all var)
343 (string-append var chez-h)))
345 (add-before 'build 'tangle
347 ;; just using "make" tries to build the .c files before
349 (and (zero? (system* "make" "sockets"))
350 (zero? (system* "make")))))
352 (lambda* (#:key outputs inputs #:allow-other-keys)
353 (let* ((out (assoc-ref outputs "out"))
354 (chez-site (string-append out "/lib/csv"
355 ,(package-version chez-scheme)
357 ;; make sure Chez Scheme can find the shared libraries.
358 (substitute* "sockets.ss"
359 (("(load-shared-object) \"(socket-ffi-values\\.[sd][oy].*)\""
361 (string-append cmd " \"" chez-site "/" so "\""))
362 (("sockets-stub\\.[sd][oy].*" all)
363 (string-append chez-site "/" all)))
364 ;; to compile chez-sockets, the .so files must be
365 ;; installed (because of the absolute path we
367 (for-each (lambda (f d) (install-file f d))
368 '("socket-ffi-values.so" "sockets-stub.so")
369 (list chez-site chez-site))
370 (zero? (system "echo '(compile-file \"sockets.sls\")' | scheme -q")))))
372 (lambda* (#:key outputs inputs #:allow-other-keys)
373 (let* ((out (assoc-ref outputs "out"))
374 (lib (string-append out "/lib/chez-sockets"))
375 (doc (string-append out "/share/doc/" ,name "-" ,version))
376 (chez-site (string-append out "/lib/csv"
377 ,(package-version chez-scheme)
379 (for-each (lambda (f d) (install-file f d))
380 '("sockets.pdf" "sockets.so")
381 (list doc chez-site))
383 (home-page "https://github.com/arcfide/chez-sockets")
384 (synopsis "Extensible sockets library for Chez Scheme")
385 (description "Chez-sockets is an extensible sockets library for
389 ;; Help function for Chez Scheme to add the current path to
390 ;; CHEZSCHEMELIBDIRS.
391 (define chez-configure
393 (let ((chez-env (getenv "CHEZSCHEMELIBDIRS")))
394 (setenv "CHEZSCHEMELIBDIRS"
396 (string-append ".:" chez-env)
400 ;; Help function to define make flags for some Chez Scheme custom make
402 (define (chez-make-flags name version)
403 `(let ((out (assoc-ref %outputs "out")))
404 (list (string-append "PREFIX=" out)
405 (string-append "DOCDIR=" out "/share/doc/"
406 ,name "-" ,version))))
408 (define-public chez-matchable
410 (name "chez-matchable")
412 (home-page "https://github.com/fedeinthemix/chez-matchable")
416 (uri (string-append home-page "/archive" "/v" version ".tar.gz"))
418 (base32 "0cl4vc6487pikjq159pj4n5ghyaax31nywb5n4yn1682h3ir1hs0"))
419 (file-name (string-append name "-" version ".tar.gz"))))
420 (build-system gnu-build-system)
422 `(("chez-srfi" ,chez-srfi))) ; for tests
424 `(("chez-scheme" ,chez-scheme)))
426 `(#:make-flags ,(chez-make-flags name version)
428 #:phases (modify-phases %standard-phases
429 (replace 'configure ,chez-configure))))
430 (synopsis "Portable hygienic pattern matcher for Scheme")
431 (description "This package provides a superset of the popular Scheme
432 @code{match} package by Andrew Wright, written in fully portable
433 @code{syntax-rules} and thus preserving hygiene.")
434 (license public-domain)))
436 (define-public chez-irregex
438 (name "chez-irregex")
444 "https://github.com/fedeinthemix/chez-irregex/archive"
445 "/v" version ".tar.gz"))
447 (base32 "0ywy5syaw549a58viz68dmgnv756ic705rcnlqxgjq27lnaim53b"))
448 (file-name (string-append name "-" version ".tar.gz"))))
449 (build-system gnu-build-system)
451 `(("chez-matchable" ,chez-matchable))) ; for tests
453 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
455 `(("chez-scheme" ,chez-scheme)))
457 `(#:make-flags ,(chez-make-flags name version)
459 #:phases (modify-phases %standard-phases
460 (replace 'configure ,chez-configure))))
461 (home-page "https://github.com/fedeinthemix/chez-irregex")
462 (synopsis "Portable regular expression library for Scheme")
463 (description "This package provides a portable and efficient
464 R[4567]RS implementation of regular expressions, supporting both POSIX
465 syntax with various (irregular) PCRE extensions, as well as SCSH's SRE
466 syntax, with various aliases for commonly used patterns.")
469 (define-public chez-fmt
477 "http://synthcode.com/scheme/fmt/fmt-" version ".tar.gz"))
479 (base32 "1zxqlw1jyg85yzclylh8bp2b3fwcy3l3xal68jw837n5illvsjcl"))
480 (file-name (string-append name "-" version ".tar.gz"))))
481 (build-system gnu-build-system)
483 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
485 `(("chez-scheme" ,chez-scheme)))
487 `(#:make-flags ,(chez-make-flags name version)
488 #:test-target "chez-check"
490 (modify-phases %standard-phases
491 (replace 'configure ,chez-configure)
493 (lambda* (#:key (make-flags '()) #:allow-other-keys)
494 (zero? (apply system* "make" "chez-build" make-flags))))
496 (lambda* (#:key (make-flags '()) #:allow-other-keys)
497 (zero? (apply system* "make" "chez-install" make-flags)))))))
498 (home-page "http://synthcode.com/scheme/fmt")
499 (synopsis "Combinator formatting library for Chez Scheme")
500 (description "This package provides a library of procedures for
501 formatting Scheme objects to text in various ways, and for easily
502 concatenating, composing and extending these formatters efficiently
503 without resorting to capturing and manipulating intermediate
507 (define-public chez-mit
511 (home-page "https://github.com/fedeinthemix/chez-mit")
515 (uri (string-append home-page "/archive/v" version ".tar.gz"))
517 (base32 "1p11q061znwxzxrxg3vw4dbsnpv1dav12hjhnkrjnzyyjvvdm2kn"))
518 (file-name (string-append name "-" version ".tar.gz"))))
519 (build-system gnu-build-system)
521 `(("chez-srfi" ,chez-srfi))) ; for tests
523 `(("chez-scheme" ,chez-scheme)))
525 `(#:make-flags ,(chez-make-flags name version)
527 #:phases (modify-phases %standard-phases
528 (replace 'configure ,chez-configure))))
529 (synopsis "MIT/GNU Scheme compatibility library for Chez Scheme")
530 (description "This package provides a set of MIT/GNU Scheme compatibility
531 libraries for Chez Scheme. The main goal was to provide the functionality
532 required to port the program 'Scmutils' to Chez Scheme.")
535 (define-public chez-scmutils
537 (name "chez-scmutils")
539 (home-page "https://github.com/fedeinthemix/chez-scmutils")
543 (uri (string-append home-page "/archive/v" version ".tar.gz"))
545 (base32 "1a5j61pggaiwl1gl6m038rcy5n8r2sj5nyjmz86jydx97mm5i8hj"))
546 (file-name (string-append name "-" version ".tar.gz"))))
547 (build-system gnu-build-system)
549 `(("chez-srfi" ,chez-srfi))) ; for tests
551 `(("chez-scheme" ,chez-scheme)))
553 `(("chez-mit" ,chez-mit)
554 ("chez-srfi" ,chez-srfi)))
556 `(#:make-flags ,(chez-make-flags name version)
557 #:tests? #f ; no test suite
559 (modify-phases %standard-phases
560 (replace 'configure ,chez-configure)
561 ;; Since the documentation is lacking, we install the source
562 ;; code. For things to work correctly we have to replace
563 ;; relative paths by absolute ones in 'include' forms. This
564 ;; in turn requires us to compile the files in the final
567 (add-after 'install 'install-src
568 (lambda* (#:key (make-flags '()) #:allow-other-keys)
569 (zero? (apply system* "make" "install-src" make-flags))))
570 (add-after 'install-src 'absolute-path-in-scm-files
571 (lambda* (#:key outputs #:allow-other-keys)
572 (let ((out (assoc-ref outputs "out")))
573 (for-each (lambda (file)
575 (("include +\"\\./scmutils")
576 (string-append "include \"" (dirname file)))))
577 (find-files out "\\.sls"))
578 (for-each (lambda (file)
580 (("include +\"\\./scmutils/simplify")
581 (string-append "include \"" (dirname file)))))
582 (find-files out "fbe-syntax\\.scm"))
584 (add-after 'absolute-path-in-scm-files 'build
585 (lambda* (#:key outputs (make-flags '()) #:allow-other-keys)
586 (let* ((out (assoc-ref outputs "out"))
587 (mk-file (car (find-files out "Makefile"))))
588 (with-directory-excursion (dirname mk-file)
589 (zero? (apply system* "make" "build" make-flags))))))
590 (add-after 'build 'clean-up
591 (lambda* (#:key outputs #:allow-other-keys)
592 (let* ((out (assoc-ref outputs "out")))
593 (for-each delete-file
594 (find-files out "Makefile|compile-all\\.ss"))))))))
595 (synopsis "Port of MIT/GNU Scheme Scmutils to Chez Scheme")
596 (description "This package provides a port of the MIT/GNU Scheme
597 Scmutils program to Chez Scheme. The port consists of a set of
598 libraries providing most of the functionality of the original.")