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)
90 `(("texlive" ,texlive)
91 ("ghostscript" ,ghostscript)
94 (list (search-path-specification
95 (variable "CHEZSCHEMELIBDIRS")
96 (files (list (string-append "lib/csv" version "-site"))))))
97 (outputs '("out" "doc"))
99 `(#:modules ((guix build gnu-build-system)
104 (list ,(match (or (%current-target-system) (%current-system))
105 ("x86_64-linux" '(list "--machine=ta6le"))
106 ("i686-linux" '(list "--machine=ti3le"))
107 ;; Let autodetection have its attempt on other architectures.
111 (modify-phases %standard-phases
112 (add-after 'unpack 'patch-processor-detection
113 (lambda _ (substitute* "configure"
114 (("uname -a") "uname -m"))
116 (add-after 'unpack 'patch-broken-documentation
118 ;; Work around an oversight in the 9.5 release tarball that causes
119 ;; building the documentation to fail. This should be fixed in the
120 ;; next one; see <https://github.com/cisco/ChezScheme/issues/209>.
121 (substitute* "csug/copyright.stex"
122 (("\\\\INSERTREVISIONMONTHSPACEYEAR" )
123 "October 2017")))) ; tarball release date
124 ;; Adapt the custom 'configure' script.
126 (lambda* (#:key inputs outputs #:allow-other-keys)
127 (let ((out (assoc-ref outputs "out"))
128 (nanopass (assoc-ref inputs "nanopass"))
129 (stex (assoc-ref inputs "stex"))
130 (zlib (assoc-ref inputs "zlib"))
131 (unpack (assoc-ref %standard-phases 'unpack))
132 (patch-source-shebangs
133 (assoc-ref %standard-phases 'patch-source-shebangs)))
135 ((src orig-name new-name)
136 (with-directory-excursion "."
137 (apply unpack (list #:source src))
138 (apply patch-source-shebangs (list #:source src)))
139 (delete-file-recursively new-name)
140 (system* "mv" orig-name new-name)))
141 `((,nanopass "nanopass-framework-scheme-1.9" "nanopass")
142 (,stex "stex-1.2.1" "stex")))
143 ;; The Makefile wants to download and compile "zlib". We patch
144 ;; it to use the one from our 'zlib' package.
145 (substitute* "configure"
146 (("rmdir zlib .*$") "echo \"using system zlib\"\n"))
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 "/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 (zero? (system* "./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 ((bin (string-append (assoc-ref outputs "out") "/bin"))
180 (doc (string-append (assoc-ref outputs "doc")
181 "/share/doc/" ,name "-" ,version)))
182 (setenv "HOME" (getcwd))
183 (setenv "PATH" (string-append (getenv "PATH") ":" bin))
184 (with-directory-excursion "stex"
185 (system* "make" (string-append "BIN=" bin)))
186 (system* "make" "docs")
187 (with-directory-excursion "csug"
188 (substitute* "Makefile"
189 (("/tmp/csug9") doc))
190 (system* "make" "install")
191 (install-file "csug.pdf" doc))
192 (with-directory-excursion "release_notes"
193 (install-file "release_notes.pdf" doc))
195 ;; The binary file name is called "scheme" as the one from MIT/GNU
196 ;; Scheme. We add a symlink to use in case both are installed.
197 (add-after 'install 'install-symlink
198 (lambda* (#:key outputs #:allow-other-keys)
199 (let* ((out (assoc-ref outputs "out"))
200 (bin (string-append out "/bin"))
201 (lib (string-append out "/lib"))
202 (name "chez-scheme"))
203 (symlink (string-append bin "/scheme")
204 (string-append bin "/" name))
206 (symlink file (string-append (dirname file)
208 (find-files lib "scheme.boot"))
210 (add-before 'reset-gzip-timestamps 'make-manpages-writable
211 (lambda* (#:key outputs #:allow-other-keys)
213 (make-file-writable file))
214 (find-files (string-append (assoc-ref outputs "out")
218 ;; According to the documentation MIPS is not supported.
219 ;; Cross-compiling for the Raspberry Pi is supported, but not native ARM.
220 (supported-systems (fold delete %supported-systems
221 '("mips64el-linux" "armhf-linux")))
222 (home-page "http://www.scheme.com")
223 (synopsis "R6RS Scheme compiler and run-time")
225 "Chez Scheme is a compiler and run-time system for the language of the
226 Revised^6 Report on Scheme (R6RS), with numerous extensions. The compiler
227 generates native code for each target processor, with support for x86, x86_64,
228 and 32-bit PowerPC architectures.")
231 (define-public chez-srfi
239 "https://github.com/fedeinthemix/chez-srfi/archive"
240 "/v" version ".tar.gz"))
242 (base32 "17i4wly7bcr5kb5hf04ljpbvv4r5hsr9xsmw650fj43z9jr303gs"))
243 (file-name (string-append name "-" version ".tar.gz"))))
244 (build-system gnu-build-system)
246 `(("chez-scheme" ,chez-scheme)))
248 `(#:make-flags (let ((out (assoc-ref %outputs "out")))
249 (list (string-append "PREFIX=" out)))
251 #:phases (modify-phases %standard-phases
252 (delete 'configure))))
253 (home-page "https://github.com/fedeinthemix/chez-srfi")
254 (synopsis "SRFI libraries for Chez Scheme")
256 "This package provides a collection of SRFI libraries for Chez Scheme.")
259 (define-public chez-web
260 (let ((commit "5fd177fe53f31f466bf88720d03c95a3711a8bea")
264 ;; release 2.0 is different and doesn't work.
265 (version (string-append "2.0-" revision "."
266 (string-take commit 7)))
271 (url "https://github.com/arcfide/ChezWEB.git")
273 (file-name (string-append name "-" version "-checkout"))
275 (base32 "1dq25qygyncbfq4kwwqqgyyakfqjwhp5q23vrf3bff1p66nyfl3b"))))
276 (build-system gnu-build-system)
278 `(("chez-scheme" ,chez-scheme)
279 ("texlive" ,texlive)))
281 `(#:make-flags (list (string-append "PREFIX=" %output)
282 (string-append "DOCDIR=" %output "/share/doc/"
284 (string-append "LIBDIR=" %output "/lib/chezweb")
285 (string-append "TEXDIR=" %output "/share/texmf-local"))
286 #:tests? #f ; no tests
288 (modify-phases %standard-phases
291 (copy-file "config.mk.template" "config.mk")
292 (substitute* "tangleit"
293 (("\\./cheztangle\\.ss" all)
294 (string-append "chez-scheme --program " all)))
295 (substitute* "weaveit"
296 (("mpost chezweb\\.mp")
297 "mpost --tex=tex chezweb.mp")
298 (("\\./chezweave" all)
299 (string-append "chez-scheme --program " all)))
300 (substitute* "installit"
301 (("-g \\$GROUP -o \\$OWNER") "")))))))
302 (home-page "https://github.com/arcfide/ChezWEB")
303 (synopsis "Hygienic Literate Programming for Chez Scheme")
304 (description "ChezWEB is a system for doing Knuthian style WEB
305 programming in Scheme.")
308 (define-public chez-sockets
309 (let ((commit "bce96881c06bd69a6757a6bff139744153924140")
312 (name "chez-sockets")
313 (version (string-append "0.0-" revision "."
314 (string-take commit 7)))
319 (url "https://github.com/arcfide/chez-sockets.git")
321 (file-name (string-append name "-" version "-checkout"))
323 (base32 "1n5fbwwz51fdzvjackgmnsgh363g9inyxv7kmzi0469cwavwcx5m"))))
324 (build-system gnu-build-system)
326 `(("chez-scheme" ,chez-scheme)
327 ("chez-web" ,chez-web)
328 ("texlive" ,texlive)))
330 `(#:tests? #f ; no tests
332 (modify-phases %standard-phases
334 (lambda* (#:key outputs inputs #:allow-other-keys)
335 (let* ((out (assoc-ref outputs "out"))
336 (chez-web (assoc-ref inputs "chez-web"))
337 (chez (assoc-ref inputs "chez-scheme"))
338 (chez-h (dirname (car (find-files chez "scheme\\.h")))))
339 (substitute* "Makefile"
340 (("(SCHEMEH=).*$" all var)
341 (string-append var chez-h)))
343 (add-before 'build 'tangle
345 ;; just using "make" tries to build the .c files before
347 (and (zero? (system* "make" "sockets"))
348 (zero? (system* "make")))))
350 (lambda* (#:key outputs inputs #:allow-other-keys)
351 (let* ((out (assoc-ref outputs "out"))
352 (chez-site (string-append out "/lib/csv"
353 ,(package-version chez-scheme)
355 ;; make sure Chez Scheme can find the shared libraries.
356 (substitute* "sockets.ss"
357 (("(load-shared-object) \"(socket-ffi-values\\.[sd][oy].*)\""
359 (string-append cmd " \"" chez-site "/" so "\""))
360 (("sockets-stub\\.[sd][oy].*" all)
361 (string-append chez-site "/" all)))
362 ;; to compile chez-sockets, the .so files must be
363 ;; installed (because of the absolute path we
365 (for-each (lambda (f d) (install-file f d))
366 '("socket-ffi-values.so" "sockets-stub.so")
367 (list chez-site chez-site))
368 (zero? (system "echo '(compile-file \"sockets.sls\")' | scheme -q")))))
370 (lambda* (#:key outputs inputs #:allow-other-keys)
371 (let* ((out (assoc-ref outputs "out"))
372 (lib (string-append out "/lib/chez-sockets"))
373 (doc (string-append out "/share/doc/" ,name "-" ,version))
374 (chez-site (string-append out "/lib/csv"
375 ,(package-version chez-scheme)
377 (for-each (lambda (f d) (install-file f d))
378 '("sockets.pdf" "sockets.so")
379 (list doc chez-site))
381 (home-page "https://github.com/arcfide/chez-sockets")
382 (synopsis "Extensible sockets library for Chez Scheme")
383 (description "Chez-sockets is an extensible sockets library for
387 ;; Help function for Chez Scheme to add the current path to
388 ;; CHEZSCHEMELIBDIRS.
389 (define chez-configure
391 (let ((chez-env (getenv "CHEZSCHEMELIBDIRS")))
392 (setenv "CHEZSCHEMELIBDIRS"
394 (string-append ".:" chez-env)
398 ;; Help function to define make flags for some Chez Scheme custom make
400 (define (chez-make-flags name version)
401 `(let ((out (assoc-ref %outputs "out")))
402 (list (string-append "PREFIX=" out)
403 (string-append "DOCDIR=" out "/share/doc/"
404 ,name "-" ,version))))
406 (define-public chez-matchable
408 (name "chez-matchable")
410 (home-page "https://github.com/fedeinthemix/chez-matchable")
414 (uri (string-append home-page "/archive" "/v" version ".tar.gz"))
416 (base32 "0cl4vc6487pikjq159pj4n5ghyaax31nywb5n4yn1682h3ir1hs0"))
417 (file-name (string-append name "-" version ".tar.gz"))))
418 (build-system gnu-build-system)
420 `(("chez-srfi" ,chez-srfi))) ; for tests
422 `(("chez-scheme" ,chez-scheme)))
424 `(#:make-flags ,(chez-make-flags name version)
426 #:phases (modify-phases %standard-phases
427 (replace 'configure ,chez-configure))))
428 (synopsis "Portable hygienic pattern matcher for Scheme")
429 (description "This package provides a superset of the popular Scheme
430 @code{match} package by Andrew Wright, written in fully portable
431 @code{syntax-rules} and thus preserving hygiene.")
432 (license public-domain)))
434 (define-public chez-irregex
436 (name "chez-irregex")
442 "https://github.com/fedeinthemix/chez-irregex/archive"
443 "/v" version ".tar.gz"))
445 (base32 "0ywy5syaw549a58viz68dmgnv756ic705rcnlqxgjq27lnaim53b"))
446 (file-name (string-append name "-" version ".tar.gz"))))
447 (build-system gnu-build-system)
449 `(("chez-matchable" ,chez-matchable))) ; for tests
451 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
453 `(("chez-scheme" ,chez-scheme)))
455 `(#:make-flags ,(chez-make-flags name version)
457 #:phases (modify-phases %standard-phases
458 (replace 'configure ,chez-configure))))
459 (home-page "https://github.com/fedeinthemix/chez-irregex")
460 (synopsis "Portable regular expression library for Scheme")
461 (description "This package provides a portable and efficient
462 R[4567]RS implementation of regular expressions, supporting both POSIX
463 syntax with various (irregular) PCRE extensions, as well as SCSH's SRE
464 syntax, with various aliases for commonly used patterns.")
467 (define-public chez-fmt
475 "http://synthcode.com/scheme/fmt/fmt-" version ".tar.gz"))
477 (base32 "1zxqlw1jyg85yzclylh8bp2b3fwcy3l3xal68jw837n5illvsjcl"))
478 (file-name (string-append name "-" version ".tar.gz"))))
479 (build-system gnu-build-system)
481 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
483 `(("chez-scheme" ,chez-scheme)))
485 `(#:make-flags ,(chez-make-flags name version)
486 #:test-target "chez-check"
488 (modify-phases %standard-phases
489 (replace 'configure ,chez-configure)
491 (lambda* (#:key (make-flags '()) #:allow-other-keys)
492 (zero? (apply system* "make" "chez-build" make-flags))))
494 (lambda* (#:key (make-flags '()) #:allow-other-keys)
495 (zero? (apply system* "make" "chez-install" make-flags)))))))
496 (home-page "http://synthcode.com/scheme/fmt")
497 (synopsis "Combinator formatting library for Chez Scheme")
498 (description "This package provides a library of procedures for
499 formatting Scheme objects to text in various ways, and for easily
500 concatenating, composing and extending these formatters efficiently
501 without resorting to capturing and manipulating intermediate
505 (define-public chez-mit
509 (home-page "https://github.com/fedeinthemix/chez-mit")
513 (uri (string-append home-page "/archive/v" version ".tar.gz"))
515 (base32 "1p11q061znwxzxrxg3vw4dbsnpv1dav12hjhnkrjnzyyjvvdm2kn"))
516 (file-name (string-append name "-" version ".tar.gz"))))
517 (build-system gnu-build-system)
519 `(("chez-srfi" ,chez-srfi))) ; for tests
521 `(("chez-scheme" ,chez-scheme)))
523 `(#:make-flags ,(chez-make-flags name version)
525 #:phases (modify-phases %standard-phases
526 (replace 'configure ,chez-configure))))
527 (synopsis "MIT/GNU Scheme compatibility library for Chez Scheme")
528 (description "This package provides a set of MIT/GNU Scheme compatibility
529 libraries for Chez Scheme. The main goal was to provide the functionality
530 required to port the program 'Scmutils' to Chez Scheme.")
533 (define-public chez-scmutils
535 (name "chez-scmutils")
537 (home-page "https://github.com/fedeinthemix/chez-scmutils")
541 (uri (string-append home-page "/archive/v" version ".tar.gz"))
543 (base32 "1a5j61pggaiwl1gl6m038rcy5n8r2sj5nyjmz86jydx97mm5i8hj"))
544 (file-name (string-append name "-" version ".tar.gz"))))
545 (build-system gnu-build-system)
547 `(("chez-srfi" ,chez-srfi))) ; for tests
549 `(("chez-scheme" ,chez-scheme)))
551 `(("chez-mit" ,chez-mit)
552 ("chez-srfi" ,chez-srfi)))
554 `(#:make-flags ,(chez-make-flags name version)
555 #:tests? #f ; no test suite
557 (modify-phases %standard-phases
558 (replace 'configure ,chez-configure)
559 ;; Since the documentation is lacking, we install the source
560 ;; code. For things to work correctly we have to replace
561 ;; relative paths by absolute ones in 'include' forms. This
562 ;; in turn requires us to compile the files in the final
565 (add-after 'install 'install-src
566 (lambda* (#:key (make-flags '()) #:allow-other-keys)
567 (zero? (apply system* "make" "install-src" make-flags))))
568 (add-after 'install-src 'absolute-path-in-scm-files
569 (lambda* (#:key outputs #:allow-other-keys)
570 (let ((out (assoc-ref outputs "out")))
571 (for-each (lambda (file)
573 (("include +\"\\./scmutils")
574 (string-append "include \"" (dirname file)))))
575 (find-files out "\\.sls"))
576 (for-each (lambda (file)
578 (("include +\"\\./scmutils/simplify")
579 (string-append "include \"" (dirname file)))))
580 (find-files out "fbe-syntax\\.scm"))
582 (add-after 'absolute-path-in-scm-files 'build
583 (lambda* (#:key outputs (make-flags '()) #:allow-other-keys)
584 (let* ((out (assoc-ref outputs "out"))
585 (mk-file (car (find-files out "Makefile"))))
586 (with-directory-excursion (dirname mk-file)
587 (zero? (apply system* "make" "build" make-flags))))))
588 (add-after 'build 'clean-up
589 (lambda* (#:key outputs #:allow-other-keys)
590 (let* ((out (assoc-ref outputs "out")))
591 (for-each delete-file
592 (find-files out "Makefile|compile-all\\.ss"))))))))
593 (synopsis "Port of MIT/GNU Scheme Scmutils to Chez Scheme")
594 (description "This package provides a port of the MIT/GNU Scheme
595 Scmutils program to Chez Scheme. The port consists of a set of
596 libraries providing most of the functionality of the original.")