1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 Federico Beffa <beffa@fbengineering.ch>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (gnu packages chez)
20 #:use-module (gnu packages)
21 #:use-module ((guix licenses)
22 #:select (gpl2+ lgpl2.0+ lgpl2.1+ asl2.0 bsd-3 expat
24 #:use-module (guix packages)
25 #:use-module (guix download)
26 #:use-module (guix git-download)
27 #:use-module (guix utils)
28 #:use-module (guix build-system gnu)
29 #:use-module (gnu packages compression)
30 #:use-module (gnu packages ncurses)
31 #:use-module (gnu packages ghostscript)
32 #:use-module (gnu packages netpbm)
33 #:use-module (gnu packages tex)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages image)
36 #:use-module (gnu packages xorg)
37 #:use-module (ice-9 match))
40 (let ((version "1.9"))
44 "https://github.com/nanopass/nanopass-framework-scheme/archive"
45 "/v" version ".tar.gz"))
46 (sha256 (base32 "11pwyy4jiwhcl2am3a4ciczacjbjkyvdizqzdglb3l1hj2gj6nv2"))
47 (file-name (string-append "nanopass-" version ".tar.gz")))))
50 (let ((version "1.2.1"))
54 "https://github.com/dybvig/stex/archive"
55 "/v" version ".tar.gz"))
56 (sha256 (base32 "03pl3f668h24dn51vccr1sj5lsba9zq3j37bnxjvdadcdaj4qy5z"))
57 (file-name (string-append "stex-" version ".tar.gz")))))
59 (define-public chez-scheme
66 (uri (string-append "https://github.com/cisco/ChezScheme/archive/"
67 "v" version ".tar.gz"))
69 (base32 "0lprmpsjg2plc6ykgkz482zyvhkzv6gd0vnar71ph21h6zknyklz"))
70 (file-name (string-append "chez-scheme-" version ".tar.gz"))))
71 (build-system gnu-build-system)
73 `(("ncurses" ,ncurses)
75 ("xorg-rgb" ,xorg-rgb)
76 ("nanopass" ,nanopass)
80 `(("texlive" ,texlive)
81 ("ghostscript" ,ghostscript)
84 (list (search-path-specification
85 (variable "CHEZSCHEMELIBDIRS")
86 (files (list (string-append "lib/csv" version "-site"))))))
87 (outputs '("out" "doc"))
89 `(#:modules ((guix build gnu-build-system)
94 (list ,(match (or (%current-target-system) (%current-system))
95 ("x86_64-linux" '(list "--machine=ta6le"))
96 ("i686-linux" '(list "--machine=ti3le"))
97 ;; FIXME: Some people succeeded in cross-compiling to
98 ;; ARM. https://github.com/cisco/ChezScheme/issues/13
102 (modify-phases %standard-phases
103 ;; Adapt the custom 'configure' script.
105 (lambda* (#:key inputs outputs #:allow-other-keys)
106 (let ((out (assoc-ref outputs "out"))
107 (nanopass (assoc-ref inputs "nanopass"))
108 (stex (assoc-ref inputs "stex"))
109 (zlib (assoc-ref inputs "zlib"))
110 (unpack (assoc-ref %standard-phases 'unpack))
111 (patch-source-shebangs
112 (assoc-ref %standard-phases 'patch-source-shebangs)))
114 ((src orig-name new-name)
115 (with-directory-excursion "."
116 (apply unpack (list #:source src))
117 (apply patch-source-shebangs (list #:source src)))
118 (delete-file-recursively new-name)
119 (system* "mv" orig-name new-name)))
120 `((,nanopass "nanopass-framework-scheme-1.9" "nanopass")
121 (,stex "stex-1.2.1" "stex")))
122 ;; The Makefile wants to download and compile "zlib". We patch
123 ;; it to use the one from our 'zlib' package.
124 (substitute* "configure"
125 (("rmdir zlib .*$") "echo \"using system zlib\"\n"))
126 (substitute* (find-files "./c" "Mf-[a-zA-Z0-9.]+")
127 (("\\$\\{Kernel\\}: \\$\\{kernelobj\\} \\.\\./zlib/libz\\.a")
128 "${Kernel}: ${kernelobj}")
129 (("ld ([-a-zA-Z0-9_${} ]+) \\.\\./zlib/libz\\.a" all args)
130 (string-append "ld " args " " zlib "/lib/libz.a"))
131 (("\\(cd \\.\\./zlib; ([-a-zA-Z0-9=./ ]+))")
133 (substitute* (find-files "mats" "Mf-.*")
134 (("^[[:space:]]+(cc ) *") "\tgcc "))
136 (find-files "." (string-append
139 "|Makefile[a-zA-Z0-9.]*"
144 ;;"|[a-zA-Z0-9.]+\\.ms" ; guile can't read
146 (("/bin/rm") (which "rm"))
147 (("/bin/ln") (which "ln"))
148 (("/bin/cp") (which "cp")))
149 (substitute* "makefiles/installsh"
150 (("/bin/true") (which "true")))
151 (substitute* "stex/Makefile"
152 (("PREFIX=/usr") (string-append "PREFIX=" out)))
153 (zero? (system* "./configure" "--threads"
154 (string-append "--installprefix=" out))))))
155 ;; Installation of the documentation requires a running "chez".
156 (add-after 'install 'install-doc
157 (lambda* (#:key inputs outputs #:allow-other-keys)
158 (let ((bin (string-append (assoc-ref outputs "out") "/bin"))
159 (doc (string-append (assoc-ref outputs "doc")
160 "/share/doc/" ,name "-" ,version)))
161 (setenv "HOME" (getcwd))
162 (setenv "PATH" (string-append (getenv "PATH") ":" bin))
163 (with-directory-excursion "stex"
164 (system* "make" (string-append "BIN=" bin)))
165 (system* "make" "docs")
166 (with-directory-excursion "csug"
167 (substitute* "Makefile"
168 (("/tmp/csug9") doc))
169 (system* "make" "install")
170 (install-file "csug.pdf" doc))
171 (with-directory-excursion "release_notes"
172 (install-file "release_notes.pdf" doc))
174 ;; The binary file name is called "scheme" as the one from MIT/GNU
175 ;; Scheme. We add a symlink to use in case both are installed.
176 (add-after 'install 'install-symlink
177 (lambda* (#:key outputs #:allow-other-keys)
178 (let* ((out (assoc-ref outputs "out"))
179 (bin (string-append out "/bin"))
180 (lib (string-append out "/lib"))
181 (name "chez-scheme"))
182 (symlink (string-append bin "/scheme")
183 (string-append bin "/" name))
185 (symlink file (string-append (dirname file)
187 (find-files lib "scheme.boot"))
189 ;; According to the documentation MIPS is not supported.
190 (supported-systems (delete "mips64el-linux" %supported-systems))
191 (home-page "http://www.scheme.com")
192 (synopsis "R6RS Scheme compiler and run-time")
194 "Chez Scheme is a compiler and run-time system for the language of the
195 Revised^6 Report on Scheme (R6RS), with numerous extensions. The compiler
196 generates native code for each target processor, with support for x86, x86_64,
197 and 32-bit PowerPC architectures.")
200 (define-public chez-srfi
208 "https://github.com/fedeinthemix/chez-srfi/archive"
209 "/v" version ".tar.gz"))
211 (base32 "17i4wly7bcr5kb5hf04ljpbvv4r5hsr9xsmw650fj43z9jr303gs"))
212 (file-name (string-append name "-" version ".tar.gz"))))
213 (build-system gnu-build-system)
215 `(("chez-scheme" ,chez-scheme)))
217 `(#:make-flags (let ((out (assoc-ref %outputs "out")))
218 (list (string-append "PREFIX=" out)))
220 #:phases (modify-phases %standard-phases
221 (delete 'configure))))
222 (home-page "https://github.com/fedeinthemix/chez-srfi")
223 (synopsis "SRFI libraries for Chez Scheme")
225 "This package provides a collection of SRFI libraries for Chez Scheme.")
228 (define-public chez-web
229 (let ((commit "5fd177fe53f31f466bf88720d03c95a3711a8bea")
233 ;; release 2.0 is different and doesn't work.
234 (version (string-append "2.0-" revision "."
235 (string-take commit 7)))
240 (url "https://github.com/arcfide/ChezWEB.git")
242 (file-name (string-append name "-" version "-checkout"))
244 (base32 "1dq25qygyncbfq4kwwqqgyyakfqjwhp5q23vrf3bff1p66nyfl3b"))))
245 (build-system gnu-build-system)
247 `(("chez-scheme" ,chez-scheme)
248 ("texlive" ,texlive)))
250 `(#:make-flags (list (string-append "PREFIX=" %output)
251 (string-append "DOCDIR=" %output "/share/doc/"
253 (string-append "LIBDIR=" %output "/lib/chezweb")
254 (string-append "TEXDIR=" %output "/share/texmf-local"))
255 #:tests? #f ; no tests
257 (modify-phases %standard-phases
260 (copy-file "config.mk.template" "config.mk")
261 (substitute* "tangleit"
262 (("\\./cheztangle\\.ss" all)
263 (string-append "chez-scheme --program " all)))
264 (substitute* "weaveit"
265 (("mpost chezweb\\.mp")
266 "mpost --tex=tex chezweb.mp")
267 (("\\./chezweave" all)
268 (string-append "chez-scheme --program " all)))
269 (substitute* "installit"
270 (("-g \\$GROUP -o \\$OWNER") "")))))))
271 (home-page "https://github.com/arcfide/ChezWEB")
272 (synopsis "Hygienic Literate Programming for Chez Scheme")
273 (description "ChezWEB is a system for doing Knuthian style WEB
274 programming in Scheme.")
277 (define-public chez-sockets
278 (let ((commit "bce96881c06bd69a6757a6bff139744153924140")
281 (name "chez-sockets")
282 (version (string-append "0.0-" revision "."
283 (string-take commit 7)))
288 (url "https://github.com/arcfide/chez-sockets.git")
290 (file-name (string-append name "-" version "-checkout"))
292 (base32 "1n5fbwwz51fdzvjackgmnsgh363g9inyxv7kmzi0469cwavwcx5m"))))
293 (build-system gnu-build-system)
295 `(("chez-scheme" ,chez-scheme)
296 ("chez-web" ,chez-web)
297 ("texlive" ,texlive)))
299 `(#:tests? #f ; no tests
301 (modify-phases %standard-phases
303 (lambda* (#:key outputs inputs #:allow-other-keys)
304 (let* ((out (assoc-ref outputs "out"))
305 (chez-web (assoc-ref inputs "chez-web"))
306 (chez (assoc-ref inputs "chez-scheme"))
307 (chez-h (dirname (car (find-files chez "scheme\\.h")))))
308 (substitute* "Makefile"
309 (("(SCHEMEH=).*$" all var)
310 (string-append var chez-h)))
312 (add-before 'build 'tangle
314 ;; just using "make" tries to build the .c files before
316 (and (zero? (system* "make" "sockets"))
317 (zero? (system* "make")))))
319 (lambda* (#:key outputs inputs #:allow-other-keys)
320 (let* ((out (assoc-ref outputs "out"))
321 (chez-site (string-append out "/lib/csv"
322 ,(package-version chez-scheme)
324 ;; make sure Chez Scheme can find the shared libraries.
325 (substitute* "sockets.ss"
326 (("(load-shared-object) \"(socket-ffi-values\\.[sd][oy].*)\""
328 (string-append cmd " \"" chez-site "/" so "\""))
329 (("sockets-stub\\.[sd][oy].*" all)
330 (string-append chez-site "/" all)))
331 ;; to compile chez-sockets, the .so files must be
332 ;; installed (because of the absolute path we
334 (for-each (lambda (f d) (install-file f d))
335 '("socket-ffi-values.so" "sockets-stub.so")
336 (list chez-site chez-site))
337 (zero? (system "echo '(compile-file \"sockets.sls\")' | scheme -q")))))
339 (lambda* (#:key outputs inputs #:allow-other-keys)
340 (let* ((out (assoc-ref outputs "out"))
341 (lib (string-append out "/lib/chez-sockets"))
342 (doc (string-append out "/share/doc/" ,name "-" ,version))
343 (chez-site (string-append out "/lib/csv"
344 ,(package-version chez-scheme)
346 (for-each (lambda (f d) (install-file f d))
347 '("sockets.pdf" "sockets.so")
348 (list doc chez-site))
350 (home-page "https://github.com/arcfide/chez-sockets")
351 (synopsis "Extensible sockets library for Chez Scheme")
352 (description "Chez-sockets is an extensible sockets library for
356 ;; Help function for Chez Scheme to add the current path to
357 ;; CHEZSCHEMELIBDIRS.
358 (define chez-configure
360 (let ((chez-env (getenv "CHEZSCHEMELIBDIRS")))
361 (setenv "CHEZSCHEMELIBDIRS"
363 (string-append ".:" chez-env)
367 ;; Help function to define make flags for some Chez Scheme custom make
369 (define (chez-make-flags name version)
370 `(let ((out (assoc-ref %outputs "out")))
371 (list (string-append "PREFIX=" out)
372 (string-append "DOCDIR=" out "/share/doc/"
373 ,name "-" ,version))))
375 (define-public chez-matchable
377 (name "chez-matchable")
379 (home-page "https://github.com/fedeinthemix/chez-matchable")
383 (uri (string-append home-page "/archive" "/v" version ".tar.gz"))
385 (base32 "0cl4vc6487pikjq159pj4n5ghyaax31nywb5n4yn1682h3ir1hs0"))
386 (file-name (string-append name "-" version ".tar.gz"))))
387 (build-system gnu-build-system)
389 `(("chez-srfi" ,chez-srfi))) ; for tests
391 `(("chez-scheme" ,chez-scheme)))
393 `(#:make-flags ,(chez-make-flags name version)
395 #:phases (modify-phases %standard-phases
396 (replace 'configure ,chez-configure))))
397 (synopsis "Portable hygienic pattern matcher for Scheme")
398 (description "This package provides a superset of the popular Scheme
399 @code{match} package by Andrew Wright, written in fully portable
400 @code{syntax-rules} and thus preserving hygiene.")
401 (license public-domain)))
403 (define-public chez-irregex
405 (name "chez-irregex")
411 "https://github.com/fedeinthemix/chez-irregex/archive"
412 "/v" version ".tar.gz"))
414 (base32 "0ywy5syaw549a58viz68dmgnv756ic705rcnlqxgjq27lnaim53b"))
415 (file-name (string-append name "-" version ".tar.gz"))))
416 (build-system gnu-build-system)
418 `(("chez-matchable" ,chez-matchable))) ; for tests
420 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
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 (home-page "https://github.com/fedeinthemix/chez-irregex")
429 (synopsis "Portable regular expression library for Scheme")
430 (description "This package provides a portable and efficient
431 R[4567]RS implementation of regular expressions, supporting both POSIX
432 syntax with various (irregular) PCRE extensions, as well as SCSH's SRE
433 syntax, with various aliases for commonly used patterns.")
436 (define-public chez-fmt
444 "http://synthcode.com/scheme/fmt/fmt-" version ".tar.gz"))
446 (base32 "1zxqlw1jyg85yzclylh8bp2b3fwcy3l3xal68jw837n5illvsjcl"))
447 (file-name (string-append name "-" version ".tar.gz"))))
448 (build-system gnu-build-system)
450 `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
452 `(("chez-scheme" ,chez-scheme)))
454 `(#:make-flags ,(chez-make-flags name version)
455 #:test-target "chez-check"
457 (modify-phases %standard-phases
458 (replace 'configure ,chez-configure)
460 (lambda* (#:key (make-flags '()) #:allow-other-keys)
461 (zero? (apply system* "make" "chez-build" make-flags))))
463 (lambda* (#:key (make-flags '()) #:allow-other-keys)
464 (zero? (apply system* "make" "chez-install" make-flags)))))))
465 (home-page "http://synthcode.com/scheme/fmt")
466 (synopsis "Combinator formatting library for Chez Scheme")
467 (description "This package provides a library of procedures for
468 formatting Scheme objects to text in various ways, and for easily
469 concatenating, composing and extending these formatters efficiently
470 without resorting to capturing and manipulating intermediate