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-union (list texlive-latex-oberdiek
92 texlive-generic-epsf)))
93 ("ghostscript" ,ghostscript)
96 (list (search-path-specification
97 (variable "CHEZSCHEMELIBDIRS")
98 (files (list (string-append "lib/csv" version "-site"))))))
99 (outputs '("out" "doc"))
101 `(#:modules ((guix build gnu-build-system)
106 (list ,(match (or (%current-target-system) (%current-system))
107 ("x86_64-linux" '(list "--machine=ta6le"))
108 ("i686-linux" '(list "--machine=ti3le"))
109 ;; Let autodetection have its attempt on other architectures.
113 (modify-phases %standard-phases
114 (add-after 'unpack 'patch-processor-detection
115 (lambda _ (substitute* "configure"
116 (("uname -a") "uname -m"))
118 (add-after 'unpack 'patch-broken-documentation
120 ;; Work around an oversight in the 9.5 release tarball that causes
121 ;; building the documentation to fail. This should be fixed in the
122 ;; next one; see <https://github.com/cisco/ChezScheme/issues/209>.
123 (substitute* "csug/copyright.stex"
124 (("\\\\INSERTREVISIONMONTHSPACEYEAR" )
125 "October 2017")))) ; tarball release date
126 ;; Adapt the custom 'configure' script.
128 (lambda* (#:key inputs outputs #:allow-other-keys)
129 (let ((out (assoc-ref outputs "out"))
130 (nanopass (assoc-ref inputs "nanopass"))
131 (stex (assoc-ref inputs "stex"))
132 (zlib (assoc-ref inputs "zlib"))
133 (zlib-static (assoc-ref inputs "zlib:static"))
134 (unpack (assoc-ref %standard-phases 'unpack))
135 (patch-source-shebangs
136 (assoc-ref %standard-phases 'patch-source-shebangs)))
138 ((src orig-name new-name)
139 (with-directory-excursion "."
140 (apply unpack (list #:source src))
141 (apply patch-source-shebangs (list #:source src)))
142 (delete-file-recursively new-name)
143 (system* "mv" orig-name new-name)))
144 `((,nanopass "nanopass-framework-scheme-1.9" "nanopass")
145 (,stex "stex-1.2.1" "stex")))
146 ;; The Makefile wants to download and compile "zlib". We patch
147 ;; it to use the one from our 'zlib' package.
148 (substitute* "configure"
149 (("rmdir zlib .*$") "echo \"using system zlib\"\n"))
150 (substitute* (find-files "./c" "Mf-[a-zA-Z0-9.]+")
151 (("\\$\\{Kernel\\}: \\$\\{kernelobj\\} \\.\\./zlib/libz\\.a")
152 "${Kernel}: ${kernelobj}")
153 (("ld ([-a-zA-Z0-9_${} ]+) \\.\\./zlib/libz\\.a" all args)
154 (string-append "ld " args " " zlib-static "/lib/libz.a"))
155 (("\\(cd \\.\\./zlib; ([-a-zA-Z0-9=./ ]+))")
157 (substitute* (find-files "mats" "Mf-.*")
158 (("^[[:space:]]+(cc ) *") "\tgcc "))
160 (find-files "." (string-append
163 "|Makefile[a-zA-Z0-9.]*"
168 ;;"|[a-zA-Z0-9.]+\\.ms" ; guile can't read
170 (("/bin/rm") (which "rm"))
171 (("/bin/ln") (which "ln"))
172 (("/bin/cp") (which "cp")))
173 (substitute* "makefiles/installsh"
174 (("/bin/true") (which "true")))
175 (substitute* "stex/Makefile"
176 (("PREFIX=/usr") (string-append "PREFIX=" out)))
177 (zero? (system* "./configure" "--threads"
178 (string-append "--installprefix=" out))))))
179 ;; Installation of the documentation requires a running "chez".
180 (add-after 'install 'install-doc
181 (lambda* (#:key inputs outputs #:allow-other-keys)
182 (let ((bin (string-append (assoc-ref outputs "out") "/bin"))
183 (doc (string-append (assoc-ref outputs "doc")
184 "/share/doc/" ,name "-" ,version)))
185 (setenv "HOME" (getcwd))
186 (setenv "PATH" (string-append (getenv "PATH") ":" bin))
187 (with-directory-excursion "stex"
188 (system* "make" (string-append "BIN=" bin)))
189 (system* "make" "docs")
190 (with-directory-excursion "csug"
191 (substitute* "Makefile"
192 (("/tmp/csug9") doc))
193 (system* "make" "install")
194 (install-file "csug.pdf" doc))
195 (with-directory-excursion "release_notes"
196 (install-file "release_notes.pdf" doc))
198 ;; The binary file name is called "scheme" as the one from MIT/GNU
199 ;; Scheme. We add a symlink to use in case both are installed.
200 (add-after 'install 'install-symlink
201 (lambda* (#:key outputs #:allow-other-keys)
202 (let* ((out (assoc-ref outputs "out"))
203 (bin (string-append out "/bin"))
204 (lib (string-append out "/lib"))
205 (name "chez-scheme"))
206 (symlink (string-append bin "/scheme")
207 (string-append bin "/" name))
209 (symlink file (string-append (dirname file)
211 (find-files lib "scheme.boot"))
213 (add-before 'reset-gzip-timestamps 'make-manpages-writable
214 (lambda* (#:key outputs #:allow-other-keys)
216 (make-file-writable file))
217 (find-files (string-append (assoc-ref outputs "out")
221 ;; According to the documentation MIPS is not supported.
222 ;; Cross-compiling for the Raspberry Pi is supported, but not native ARM.
223 (supported-systems (fold delete %supported-systems
224 '("mips64el-linux" "armhf-linux")))
225 (home-page "http://www.scheme.com")
226 (synopsis "R6RS Scheme compiler and run-time")
228 "Chez Scheme is a compiler and run-time system for the language of the
229 Revised^6 Report on Scheme (R6RS), with numerous extensions. The compiler
230 generates native code for each target processor, with support for x86, x86_64,
231 and 32-bit PowerPC architectures.")
234 (define-public chez-srfi
242 "https://github.com/fedeinthemix/chez-srfi/archive"
243 "/v" version ".tar.gz"))
245 (base32 "17i4wly7bcr5kb5hf04ljpbvv4r5hsr9xsmw650fj43z9jr303gs"))
246 (file-name (string-append name "-" version ".tar.gz"))))
247 (build-system gnu-build-system)
249 `(("chez-scheme" ,chez-scheme)))
251 `(#:make-flags (let ((out (assoc-ref %outputs "out")))
252 (list (string-append "PREFIX=" out)))
254 #:phases (modify-phases %standard-phases
255 (delete 'configure))))
256 (home-page "https://github.com/fedeinthemix/chez-srfi")
257 (synopsis "SRFI libraries for Chez Scheme")
259 "This package provides a collection of SRFI libraries for Chez Scheme.")
262 (define-public chez-web
263 (let ((commit "5fd177fe53f31f466bf88720d03c95a3711a8bea")
267 ;; release 2.0 is different and doesn't work.
268 (version (string-append "2.0-" revision "."
269 (string-take commit 7)))
274 (url "https://github.com/arcfide/ChezWEB.git")
276 (file-name (string-append name "-" version "-checkout"))
278 (base32 "1dq25qygyncbfq4kwwqqgyyakfqjwhp5q23vrf3bff1p66nyfl3b"))))
279 (build-system gnu-build-system)
281 `(("chez-scheme" ,chez-scheme)
282 ("texlive" ,texlive)))
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
294 (copy-file "config.mk.template" "config.mk")
295 (substitute* "tangleit"
296 (("\\./cheztangle\\.ss" all)
297 (string-append "chez-scheme --program " all)))
298 (substitute* "weaveit"
299 (("mpost chezweb\\.mp")
300 "mpost --tex=tex chezweb.mp")
301 (("\\./chezweave" all)
302 (string-append "chez-scheme --program " all)))
303 (substitute* "installit"
304 (("-g \\$GROUP -o \\$OWNER") "")))))))
305 (home-page "https://github.com/arcfide/ChezWEB")
306 (synopsis "Hygienic Literate Programming for Chez Scheme")
307 (description "ChezWEB is a system for doing Knuthian style WEB
308 programming in Scheme.")
311 (define-public chez-sockets
312 (let ((commit "bce96881c06bd69a6757a6bff139744153924140")
315 (name "chez-sockets")
316 (version (string-append "0.0-" revision "."
317 (string-take commit 7)))
322 (url "https://github.com/arcfide/chez-sockets.git")
324 (file-name (string-append name "-" version "-checkout"))
326 (base32 "1n5fbwwz51fdzvjackgmnsgh363g9inyxv7kmzi0469cwavwcx5m"))))
327 (build-system gnu-build-system)
329 `(("chez-scheme" ,chez-scheme)
330 ("chez-web" ,chez-web)
331 ("texlive" ,texlive)))
333 `(#:tests? #f ; no tests
335 (modify-phases %standard-phases
337 (lambda* (#:key outputs inputs #:allow-other-keys)
338 (let* ((out (assoc-ref outputs "out"))
339 (chez-web (assoc-ref inputs "chez-web"))
340 (chez (assoc-ref inputs "chez-scheme"))
341 (chez-h (dirname (car (find-files chez "scheme\\.h")))))
342 (substitute* "Makefile"
343 (("(SCHEMEH=).*$" all var)
344 (string-append var chez-h)))
346 (add-before 'build 'tangle
348 ;; just using "make" tries to build the .c files before
350 (and (zero? (system* "make" "sockets"))
351 (zero? (system* "make")))))
353 (lambda* (#:key outputs inputs #:allow-other-keys)
354 (let* ((out (assoc-ref outputs "out"))
355 (chez-site (string-append out "/lib/csv"
356 ,(package-version chez-scheme)
358 ;; make sure Chez Scheme can find the shared libraries.
359 (substitute* "sockets.ss"
360 (("(load-shared-object) \"(socket-ffi-values\\.[sd][oy].*)\""
362 (string-append cmd " \"" chez-site "/" so "\""))
363 (("sockets-stub\\.[sd][oy].*" all)
364 (string-append chez-site "/" all)))
365 ;; to compile chez-sockets, the .so files must be
366 ;; installed (because of the absolute path we
368 (for-each (lambda (f d) (install-file f d))
369 '("socket-ffi-values.so" "sockets-stub.so")
370 (list chez-site chez-site))
371 (zero? (system "echo '(compile-file \"sockets.sls\")' | scheme -q")))))
373 (lambda* (#:key outputs inputs #:allow-other-keys)
374 (let* ((out (assoc-ref outputs "out"))
375 (lib (string-append out "/lib/chez-sockets"))
376 (doc (string-append out "/share/doc/" ,name "-" ,version))
377 (chez-site (string-append out "/lib/csv"
378 ,(package-version chez-scheme)
380 (for-each (lambda (f d) (install-file f d))
381 '("sockets.pdf" "sockets.so")
382 (list doc chez-site))
384 (home-page "https://github.com/arcfide/chez-sockets")
385 (synopsis "Extensible sockets library for Chez Scheme")
386 (description "Chez-sockets is an extensible sockets library for
390 ;; Help function for Chez Scheme to add the current path to
391 ;; CHEZSCHEMELIBDIRS.
392 (define chez-configure
394 (let ((chez-env (getenv "CHEZSCHEMELIBDIRS")))
395 (setenv "CHEZSCHEMELIBDIRS"
397 (string-append ".:" chez-env)
401 ;; Help function to define make flags for some Chez Scheme custom make
403 (define (chez-make-flags name version)
404 `(let ((out (assoc-ref %outputs "out")))
405 (list (string-append "PREFIX=" out)
406 (string-append "DOCDIR=" out "/share/doc/"
407 ,name "-" ,version))))
409 (define-public chez-matchable
411 (name "chez-matchable")
413 (home-page "https://github.com/fedeinthemix/chez-matchable")
417 (uri (string-append home-page "/archive" "/v" version ".tar.gz"))
419 (base32 "0cl4vc6487pikjq159pj4n5ghyaax31nywb5n4yn1682h3ir1hs0"))
420 (file-name (string-append name "-" version ".tar.gz"))))
421 (build-system gnu-build-system)
423 `(("chez-srfi" ,chez-srfi))) ; for tests
425 `(("chez-scheme" ,chez-scheme)))
427 `(#:make-flags ,(chez-make-flags name version)
429 #:phases (modify-phases %standard-phases
430 (replace 'configure ,chez-configure))))
431 (synopsis "Portable hygienic pattern matcher for Scheme")
432 (description "This package provides a superset of the popular Scheme
433 @code{match} package by Andrew Wright, written in fully portable
434 @code{syntax-rules} and thus preserving hygiene.")
435 (license public-domain)))
437 (define-public chez-irregex
439 (name "chez-irregex")
445 "https://github.com/fedeinthemix/chez-irregex/archive"
446 "/v" version ".tar.gz"))
448 (base32 "0ywy5syaw549a58viz68dmgnv756ic705rcnlqxgjq27lnaim53b"))
449 (file-name (string-append name "-" version ".tar.gz"))))
450 (build-system gnu-build-system)
452 `(("chez-matchable" ,chez-matchable))) ; for tests
454 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
456 `(("chez-scheme" ,chez-scheme)))
458 `(#:make-flags ,(chez-make-flags name version)
460 #:phases (modify-phases %standard-phases
461 (replace 'configure ,chez-configure))))
462 (home-page "https://github.com/fedeinthemix/chez-irregex")
463 (synopsis "Portable regular expression library for Scheme")
464 (description "This package provides a portable and efficient
465 R[4567]RS implementation of regular expressions, supporting both POSIX
466 syntax with various (irregular) PCRE extensions, as well as SCSH's SRE
467 syntax, with various aliases for commonly used patterns.")
470 (define-public chez-fmt
478 "http://synthcode.com/scheme/fmt/fmt-" version ".tar.gz"))
480 (base32 "1zxqlw1jyg85yzclylh8bp2b3fwcy3l3xal68jw837n5illvsjcl"))
481 (file-name (string-append name "-" version ".tar.gz"))))
482 (build-system gnu-build-system)
484 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
486 `(("chez-scheme" ,chez-scheme)))
488 `(#:make-flags ,(chez-make-flags name version)
489 #:test-target "chez-check"
491 (modify-phases %standard-phases
492 (replace 'configure ,chez-configure)
494 (lambda* (#:key (make-flags '()) #:allow-other-keys)
495 (zero? (apply system* "make" "chez-build" make-flags))))
497 (lambda* (#:key (make-flags '()) #:allow-other-keys)
498 (zero? (apply system* "make" "chez-install" make-flags)))))))
499 (home-page "http://synthcode.com/scheme/fmt")
500 (synopsis "Combinator formatting library for Chez Scheme")
501 (description "This package provides a library of procedures for
502 formatting Scheme objects to text in various ways, and for easily
503 concatenating, composing and extending these formatters efficiently
504 without resorting to capturing and manipulating intermediate
508 (define-public chez-mit
512 (home-page "https://github.com/fedeinthemix/chez-mit")
516 (uri (string-append home-page "/archive/v" version ".tar.gz"))
518 (base32 "1p11q061znwxzxrxg3vw4dbsnpv1dav12hjhnkrjnzyyjvvdm2kn"))
519 (file-name (string-append name "-" version ".tar.gz"))))
520 (build-system gnu-build-system)
522 `(("chez-srfi" ,chez-srfi))) ; for tests
524 `(("chez-scheme" ,chez-scheme)))
526 `(#:make-flags ,(chez-make-flags name version)
528 #:phases (modify-phases %standard-phases
529 (replace 'configure ,chez-configure))))
530 (synopsis "MIT/GNU Scheme compatibility library for Chez Scheme")
531 (description "This package provides a set of MIT/GNU Scheme compatibility
532 libraries for Chez Scheme. The main goal was to provide the functionality
533 required to port the program 'Scmutils' to Chez Scheme.")
536 (define-public chez-scmutils
538 (name "chez-scmutils")
540 (home-page "https://github.com/fedeinthemix/chez-scmutils")
544 (uri (string-append home-page "/archive/v" version ".tar.gz"))
546 (base32 "1a5j61pggaiwl1gl6m038rcy5n8r2sj5nyjmz86jydx97mm5i8hj"))
547 (file-name (string-append name "-" version ".tar.gz"))))
548 (build-system gnu-build-system)
550 `(("chez-srfi" ,chez-srfi))) ; for tests
552 `(("chez-scheme" ,chez-scheme)))
554 `(("chez-mit" ,chez-mit)
555 ("chez-srfi" ,chez-srfi)))
557 `(#:make-flags ,(chez-make-flags name version)
558 #:tests? #f ; no test suite
560 (modify-phases %standard-phases
561 (replace 'configure ,chez-configure)
562 ;; Since the documentation is lacking, we install the source
563 ;; code. For things to work correctly we have to replace
564 ;; relative paths by absolute ones in 'include' forms. This
565 ;; in turn requires us to compile the files in the final
568 (add-after 'install 'install-src
569 (lambda* (#:key (make-flags '()) #:allow-other-keys)
570 (zero? (apply system* "make" "install-src" make-flags))))
571 (add-after 'install-src 'absolute-path-in-scm-files
572 (lambda* (#:key outputs #:allow-other-keys)
573 (let ((out (assoc-ref outputs "out")))
574 (for-each (lambda (file)
576 (("include +\"\\./scmutils")
577 (string-append "include \"" (dirname file)))))
578 (find-files out "\\.sls"))
579 (for-each (lambda (file)
581 (("include +\"\\./scmutils/simplify")
582 (string-append "include \"" (dirname file)))))
583 (find-files out "fbe-syntax\\.scm"))
585 (add-after 'absolute-path-in-scm-files 'build
586 (lambda* (#:key outputs (make-flags '()) #:allow-other-keys)
587 (let* ((out (assoc-ref outputs "out"))
588 (mk-file (car (find-files out "Makefile"))))
589 (with-directory-excursion (dirname mk-file)
590 (zero? (apply system* "make" "build" make-flags))))))
591 (add-after 'build 'clean-up
592 (lambda* (#:key outputs #:allow-other-keys)
593 (let* ((out (assoc-ref outputs "out")))
594 (for-each delete-file
595 (find-files out "Makefile|compile-all\\.ss"))))))))
596 (synopsis "Port of MIT/GNU Scheme Scmutils to Chez Scheme")
597 (description "This package provides a port of the MIT/GNU Scheme
598 Scmutils program to Chez Scheme. The port consists of a set of
599 libraries providing most of the functionality of the original.")