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>
5 ;;; This file is part of GNU Guix.
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 (define-module (gnu packages chez)
21 #:use-module (gnu packages)
22 #:use-module ((guix licenses)
23 #:select (gpl2+ gpl3+ lgpl2.0+ lgpl2.1+ asl2.0 bsd-3 expat
25 #:use-module (guix packages)
26 #:use-module (guix download)
27 #:use-module (guix git-download)
28 #:use-module (guix utils)
29 #:use-module (guix build-system gnu)
30 #:use-module (gnu packages compression)
31 #:use-module (gnu packages ncurses)
32 #:use-module (gnu packages ghostscript)
33 #:use-module (gnu packages netpbm)
34 #:use-module (gnu packages tex)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages image)
37 #:use-module (gnu packages xorg)
38 #:use-module (ice-9 match)
39 #:use-module (srfi srfi-1))
42 (let ((version "1.9"))
46 "https://github.com/nanopass/nanopass-framework-scheme/archive"
47 "/v" version ".tar.gz"))
48 (sha256 (base32 "11pwyy4jiwhcl2am3a4ciczacjbjkyvdizqzdglb3l1hj2gj6nv2"))
49 (file-name (string-append "nanopass-" version ".tar.gz")))))
52 (let ((version "1.2.1"))
56 "https://github.com/dybvig/stex/archive"
57 "/v" version ".tar.gz"))
58 (sha256 (base32 "03pl3f668h24dn51vccr1sj5lsba9zq3j37bnxjvdadcdaj4qy5z"))
59 (file-name (string-append "stex-" version ".tar.gz")))))
61 (define-public chez-scheme
68 (uri (string-append "https://github.com/cisco/ChezScheme/archive/"
69 "v" version ".tar.gz"))
71 (base32 "0lprmpsjg2plc6ykgkz482zyvhkzv6gd0vnar71ph21h6zknyklz"))
72 (file-name (string-append "chez-scheme-" version ".tar.gz"))))
73 (build-system gnu-build-system)
75 `(("ncurses" ,ncurses)
77 ("xorg-rgb" ,xorg-rgb)
78 ("nanopass" ,nanopass)
82 `(("texlive" ,texlive)
83 ("ghostscript" ,ghostscript)
86 (list (search-path-specification
87 (variable "CHEZSCHEMELIBDIRS")
88 (files (list (string-append "lib/csv" version "-site"))))))
89 (outputs '("out" "doc"))
91 `(#:modules ((guix build gnu-build-system)
96 (list ,(match (or (%current-target-system) (%current-system))
97 ("x86_64-linux" '(list "--machine=ta6le"))
98 ("i686-linux" '(list "--machine=ti3le"))
99 ;; Let autodetection have its attempt on other architectures.
103 (modify-phases %standard-phases
104 (add-after 'unpack 'patch-processor-detection
105 (lambda _ (substitute* "configure"
106 (("uname -a") "uname -m"))
108 ;; Adapt the custom 'configure' script.
110 (lambda* (#:key inputs outputs #:allow-other-keys)
111 (let ((out (assoc-ref outputs "out"))
112 (nanopass (assoc-ref inputs "nanopass"))
113 (stex (assoc-ref inputs "stex"))
114 (zlib (assoc-ref inputs "zlib"))
115 (unpack (assoc-ref %standard-phases 'unpack))
116 (patch-source-shebangs
117 (assoc-ref %standard-phases 'patch-source-shebangs)))
119 ((src orig-name new-name)
120 (with-directory-excursion "."
121 (apply unpack (list #:source src))
122 (apply patch-source-shebangs (list #:source src)))
123 (delete-file-recursively new-name)
124 (system* "mv" orig-name new-name)))
125 `((,nanopass "nanopass-framework-scheme-1.9" "nanopass")
126 (,stex "stex-1.2.1" "stex")))
127 ;; The Makefile wants to download and compile "zlib". We patch
128 ;; it to use the one from our 'zlib' package.
129 (substitute* "configure"
130 (("rmdir zlib .*$") "echo \"using system zlib\"\n"))
131 (substitute* (find-files "./c" "Mf-[a-zA-Z0-9.]+")
132 (("\\$\\{Kernel\\}: \\$\\{kernelobj\\} \\.\\./zlib/libz\\.a")
133 "${Kernel}: ${kernelobj}")
134 (("ld ([-a-zA-Z0-9_${} ]+) \\.\\./zlib/libz\\.a" all args)
135 (string-append "ld " args " " zlib "/lib/libz.a"))
136 (("\\(cd \\.\\./zlib; ([-a-zA-Z0-9=./ ]+))")
138 (substitute* (find-files "mats" "Mf-.*")
139 (("^[[:space:]]+(cc ) *") "\tgcc "))
141 (find-files "." (string-append
144 "|Makefile[a-zA-Z0-9.]*"
149 ;;"|[a-zA-Z0-9.]+\\.ms" ; guile can't read
151 (("/bin/rm") (which "rm"))
152 (("/bin/ln") (which "ln"))
153 (("/bin/cp") (which "cp")))
154 (substitute* "makefiles/installsh"
155 (("/bin/true") (which "true")))
156 (substitute* "stex/Makefile"
157 (("PREFIX=/usr") (string-append "PREFIX=" out)))
158 (zero? (system* "./configure" "--threads"
159 (string-append "--installprefix=" out))))))
160 ;; Installation of the documentation requires a running "chez".
161 (add-after 'install 'install-doc
162 (lambda* (#:key inputs outputs #:allow-other-keys)
163 (let ((bin (string-append (assoc-ref outputs "out") "/bin"))
164 (doc (string-append (assoc-ref outputs "doc")
165 "/share/doc/" ,name "-" ,version)))
166 (setenv "HOME" (getcwd))
167 (setenv "PATH" (string-append (getenv "PATH") ":" bin))
168 (with-directory-excursion "stex"
169 (system* "make" (string-append "BIN=" bin)))
170 (system* "make" "docs")
171 (with-directory-excursion "csug"
172 (substitute* "Makefile"
173 (("/tmp/csug9") doc))
174 (system* "make" "install")
175 (install-file "csug.pdf" doc))
176 (with-directory-excursion "release_notes"
177 (install-file "release_notes.pdf" doc))
179 ;; The binary file name is called "scheme" as the one from MIT/GNU
180 ;; Scheme. We add a symlink to use in case both are installed.
181 (add-after 'install 'install-symlink
182 (lambda* (#:key outputs #:allow-other-keys)
183 (let* ((out (assoc-ref outputs "out"))
184 (bin (string-append out "/bin"))
185 (lib (string-append out "/lib"))
186 (name "chez-scheme"))
187 (symlink (string-append bin "/scheme")
188 (string-append bin "/" name))
190 (symlink file (string-append (dirname file)
192 (find-files lib "scheme.boot"))
194 (add-before 'reset-gzip-timestamps 'make-manpages-writable
195 (lambda* (#:key outputs #:allow-other-keys)
197 (make-file-writable file))
198 (find-files (string-append (assoc-ref outputs "out")
202 ;; According to the documentation MIPS is not supported.
203 ;; Cross-compiling for the Raspberry Pi is supported, but not native ARM.
204 (supported-systems (fold delete %supported-systems
205 '("mips64el-linux" "armhf-linux")))
206 (home-page "http://www.scheme.com")
207 (synopsis "R6RS Scheme compiler and run-time")
209 "Chez Scheme is a compiler and run-time system for the language of the
210 Revised^6 Report on Scheme (R6RS), with numerous extensions. The compiler
211 generates native code for each target processor, with support for x86, x86_64,
212 and 32-bit PowerPC architectures.")
215 (define-public chez-srfi
223 "https://github.com/fedeinthemix/chez-srfi/archive"
224 "/v" version ".tar.gz"))
226 (base32 "17i4wly7bcr5kb5hf04ljpbvv4r5hsr9xsmw650fj43z9jr303gs"))
227 (file-name (string-append name "-" version ".tar.gz"))))
228 (build-system gnu-build-system)
230 `(("chez-scheme" ,chez-scheme)))
232 `(#:make-flags (let ((out (assoc-ref %outputs "out")))
233 (list (string-append "PREFIX=" out)))
235 #:phases (modify-phases %standard-phases
236 (delete 'configure))))
237 (home-page "https://github.com/fedeinthemix/chez-srfi")
238 (synopsis "SRFI libraries for Chez Scheme")
240 "This package provides a collection of SRFI libraries for Chez Scheme.")
243 (define-public chez-web
244 (let ((commit "5fd177fe53f31f466bf88720d03c95a3711a8bea")
248 ;; release 2.0 is different and doesn't work.
249 (version (string-append "2.0-" revision "."
250 (string-take commit 7)))
255 (url "https://github.com/arcfide/ChezWEB.git")
257 (file-name (string-append name "-" version "-checkout"))
259 (base32 "1dq25qygyncbfq4kwwqqgyyakfqjwhp5q23vrf3bff1p66nyfl3b"))))
260 (build-system gnu-build-system)
262 `(("chez-scheme" ,chez-scheme)
263 ("texlive" ,texlive)))
265 `(#:make-flags (list (string-append "PREFIX=" %output)
266 (string-append "DOCDIR=" %output "/share/doc/"
268 (string-append "LIBDIR=" %output "/lib/chezweb")
269 (string-append "TEXDIR=" %output "/share/texmf-local"))
270 #:tests? #f ; no tests
272 (modify-phases %standard-phases
275 (copy-file "config.mk.template" "config.mk")
276 (substitute* "tangleit"
277 (("\\./cheztangle\\.ss" all)
278 (string-append "chez-scheme --program " all)))
279 (substitute* "weaveit"
280 (("mpost chezweb\\.mp")
281 "mpost --tex=tex chezweb.mp")
282 (("\\./chezweave" all)
283 (string-append "chez-scheme --program " all)))
284 (substitute* "installit"
285 (("-g \\$GROUP -o \\$OWNER") "")))))))
286 (home-page "https://github.com/arcfide/ChezWEB")
287 (synopsis "Hygienic Literate Programming for Chez Scheme")
288 (description "ChezWEB is a system for doing Knuthian style WEB
289 programming in Scheme.")
292 (define-public chez-sockets
293 (let ((commit "bce96881c06bd69a6757a6bff139744153924140")
296 (name "chez-sockets")
297 (version (string-append "0.0-" revision "."
298 (string-take commit 7)))
303 (url "https://github.com/arcfide/chez-sockets.git")
305 (file-name (string-append name "-" version "-checkout"))
307 (base32 "1n5fbwwz51fdzvjackgmnsgh363g9inyxv7kmzi0469cwavwcx5m"))))
308 (build-system gnu-build-system)
310 `(("chez-scheme" ,chez-scheme)
311 ("chez-web" ,chez-web)
312 ("texlive" ,texlive)))
314 `(#:tests? #f ; no tests
316 (modify-phases %standard-phases
318 (lambda* (#:key outputs inputs #:allow-other-keys)
319 (let* ((out (assoc-ref outputs "out"))
320 (chez-web (assoc-ref inputs "chez-web"))
321 (chez (assoc-ref inputs "chez-scheme"))
322 (chez-h (dirname (car (find-files chez "scheme\\.h")))))
323 (substitute* "Makefile"
324 (("(SCHEMEH=).*$" all var)
325 (string-append var chez-h)))
327 (add-before 'build 'tangle
329 ;; just using "make" tries to build the .c files before
331 (and (zero? (system* "make" "sockets"))
332 (zero? (system* "make")))))
334 (lambda* (#:key outputs inputs #:allow-other-keys)
335 (let* ((out (assoc-ref outputs "out"))
336 (chez-site (string-append out "/lib/csv"
337 ,(package-version chez-scheme)
339 ;; make sure Chez Scheme can find the shared libraries.
340 (substitute* "sockets.ss"
341 (("(load-shared-object) \"(socket-ffi-values\\.[sd][oy].*)\""
343 (string-append cmd " \"" chez-site "/" so "\""))
344 (("sockets-stub\\.[sd][oy].*" all)
345 (string-append chez-site "/" all)))
346 ;; to compile chez-sockets, the .so files must be
347 ;; installed (because of the absolute path we
349 (for-each (lambda (f d) (install-file f d))
350 '("socket-ffi-values.so" "sockets-stub.so")
351 (list chez-site chez-site))
352 (zero? (system "echo '(compile-file \"sockets.sls\")' | scheme -q")))))
354 (lambda* (#:key outputs inputs #:allow-other-keys)
355 (let* ((out (assoc-ref outputs "out"))
356 (lib (string-append out "/lib/chez-sockets"))
357 (doc (string-append out "/share/doc/" ,name "-" ,version))
358 (chez-site (string-append out "/lib/csv"
359 ,(package-version chez-scheme)
361 (for-each (lambda (f d) (install-file f d))
362 '("sockets.pdf" "sockets.so")
363 (list doc chez-site))
365 (home-page "https://github.com/arcfide/chez-sockets")
366 (synopsis "Extensible sockets library for Chez Scheme")
367 (description "Chez-sockets is an extensible sockets library for
371 ;; Help function for Chez Scheme to add the current path to
372 ;; CHEZSCHEMELIBDIRS.
373 (define chez-configure
375 (let ((chez-env (getenv "CHEZSCHEMELIBDIRS")))
376 (setenv "CHEZSCHEMELIBDIRS"
378 (string-append ".:" chez-env)
382 ;; Help function to define make flags for some Chez Scheme custom make
384 (define (chez-make-flags name version)
385 `(let ((out (assoc-ref %outputs "out")))
386 (list (string-append "PREFIX=" out)
387 (string-append "DOCDIR=" out "/share/doc/"
388 ,name "-" ,version))))
390 (define-public chez-matchable
392 (name "chez-matchable")
394 (home-page "https://github.com/fedeinthemix/chez-matchable")
398 (uri (string-append home-page "/archive" "/v" version ".tar.gz"))
400 (base32 "0cl4vc6487pikjq159pj4n5ghyaax31nywb5n4yn1682h3ir1hs0"))
401 (file-name (string-append name "-" version ".tar.gz"))))
402 (build-system gnu-build-system)
404 `(("chez-srfi" ,chez-srfi))) ; for tests
406 `(("chez-scheme" ,chez-scheme)))
408 `(#:make-flags ,(chez-make-flags name version)
410 #:phases (modify-phases %standard-phases
411 (replace 'configure ,chez-configure))))
412 (synopsis "Portable hygienic pattern matcher for Scheme")
413 (description "This package provides a superset of the popular Scheme
414 @code{match} package by Andrew Wright, written in fully portable
415 @code{syntax-rules} and thus preserving hygiene.")
416 (license public-domain)))
418 (define-public chez-irregex
420 (name "chez-irregex")
426 "https://github.com/fedeinthemix/chez-irregex/archive"
427 "/v" version ".tar.gz"))
429 (base32 "0ywy5syaw549a58viz68dmgnv756ic705rcnlqxgjq27lnaim53b"))
430 (file-name (string-append name "-" version ".tar.gz"))))
431 (build-system gnu-build-system)
433 `(("chez-matchable" ,chez-matchable))) ; for tests
435 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
437 `(("chez-scheme" ,chez-scheme)))
439 `(#:make-flags ,(chez-make-flags name version)
441 #:phases (modify-phases %standard-phases
442 (replace 'configure ,chez-configure))))
443 (home-page "https://github.com/fedeinthemix/chez-irregex")
444 (synopsis "Portable regular expression library for Scheme")
445 (description "This package provides a portable and efficient
446 R[4567]RS implementation of regular expressions, supporting both POSIX
447 syntax with various (irregular) PCRE extensions, as well as SCSH's SRE
448 syntax, with various aliases for commonly used patterns.")
451 (define-public chez-fmt
459 "http://synthcode.com/scheme/fmt/fmt-" version ".tar.gz"))
461 (base32 "1zxqlw1jyg85yzclylh8bp2b3fwcy3l3xal68jw837n5illvsjcl"))
462 (file-name (string-append name "-" version ".tar.gz"))))
463 (build-system gnu-build-system)
465 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
467 `(("chez-scheme" ,chez-scheme)))
469 `(#:make-flags ,(chez-make-flags name version)
470 #:test-target "chez-check"
472 (modify-phases %standard-phases
473 (replace 'configure ,chez-configure)
475 (lambda* (#:key (make-flags '()) #:allow-other-keys)
476 (zero? (apply system* "make" "chez-build" make-flags))))
478 (lambda* (#:key (make-flags '()) #:allow-other-keys)
479 (zero? (apply system* "make" "chez-install" make-flags)))))))
480 (home-page "http://synthcode.com/scheme/fmt")
481 (synopsis "Combinator formatting library for Chez Scheme")
482 (description "This package provides a library of procedures for
483 formatting Scheme objects to text in various ways, and for easily
484 concatenating, composing and extending these formatters efficiently
485 without resorting to capturing and manipulating intermediate
489 (define-public chez-mit
493 (home-page "https://github.com/fedeinthemix/chez-mit")
497 (uri (string-append home-page "/archive/v" version ".tar.gz"))
499 (base32 "1p11q061znwxzxrxg3vw4dbsnpv1dav12hjhnkrjnzyyjvvdm2kn"))
500 (file-name (string-append name "-" version ".tar.gz"))))
501 (build-system gnu-build-system)
503 `(("chez-srfi" ,chez-srfi))) ; for tests
505 `(("chez-scheme" ,chez-scheme)))
507 `(#:make-flags ,(chez-make-flags name version)
509 #:phases (modify-phases %standard-phases
510 (replace 'configure ,chez-configure))))
511 (synopsis "MIT/GNU Scheme compatibility library for Chez Scheme")
512 (description "This package provides a set of MIT/GNU Scheme compatibility
513 libraries for Chez Scheme. The main goal was to provide the functionality
514 required to port the program 'Scmutils' to Chez Scheme.")
517 (define-public chez-scmutils
519 (name "chez-scmutils")
521 (home-page "https://github.com/fedeinthemix/chez-scmutils")
525 (uri (string-append home-page "/archive/v" version ".tar.gz"))
527 (base32 "1a5j61pggaiwl1gl6m038rcy5n8r2sj5nyjmz86jydx97mm5i8hj"))
528 (file-name (string-append name "-" version ".tar.gz"))))
529 (build-system gnu-build-system)
531 `(("chez-srfi" ,chez-srfi))) ; for tests
533 `(("chez-scheme" ,chez-scheme)))
535 `(("chez-mit" ,chez-mit)
536 ("chez-srfi" ,chez-srfi)))
538 `(#:make-flags ,(chez-make-flags name version)
539 #:tests? #f ; no test suite
541 (modify-phases %standard-phases
542 (replace 'configure ,chez-configure)
543 ;; Since the documentation is lacking, we install the source
544 ;; code. For things to work correctly we have to replace
545 ;; relative paths by absolute ones in 'include' forms. This
546 ;; in turn requires us to compile the files in the final
549 (add-after 'install 'install-src
550 (lambda* (#:key (make-flags '()) #:allow-other-keys)
551 (zero? (apply system* "make" "install-src" make-flags))))
552 (add-after 'install-src 'absolute-path-in-scm-files
553 (lambda* (#:key outputs #:allow-other-keys)
554 (let ((out (assoc-ref outputs "out")))
555 (for-each (lambda (file)
557 (("include +\"\\./scmutils")
558 (string-append "include \"" (dirname file)))))
559 (find-files out "\\.sls"))
560 (for-each (lambda (file)
562 (("include +\"\\./scmutils/simplify")
563 (string-append "include \"" (dirname file)))))
564 (find-files out "fbe-syntax\\.scm"))
566 (add-after 'absolute-path-in-scm-files 'build
567 (lambda* (#:key outputs (make-flags '()) #:allow-other-keys)
568 (let* ((out (assoc-ref outputs "out"))
569 (mk-file (car (find-files out "Makefile"))))
570 (with-directory-excursion (dirname mk-file)
571 (zero? (apply system* "make" "build" make-flags))))))
572 (add-after 'build 'clean-up
573 (lambda* (#:key outputs #:allow-other-keys)
574 (let* ((out (assoc-ref outputs "out")))
575 (for-each delete-file
576 (find-files out "Makefile|compile-all\\.ss"))))))))
577 (synopsis "Port of MIT/GNU Scheme Scmutils to Chez Scheme")
578 (description "This package provides a port of the MIT/GNU Scheme
579 Scmutils program to Chez Scheme. The port consists of a set of
580 libraries providing most of the functionality of the original.")