chez.scm 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  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, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
  5. ;;; Copyright © 2019 Brett Gilio <brettg@gnu.org>
  6. ;;; Copyright © 2020 Brendan Tildesley <mail@brendan.scot>
  7. ;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
  8. ;;;
  9. ;;; This file is part of GNU Guix.
  10. ;;;
  11. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  12. ;;; under the terms of the GNU General Public License as published by
  13. ;;; the Free Software Foundation; either version 3 of the License, or (at
  14. ;;; your option) any later version.
  15. ;;;
  16. ;;; GNU Guix is distributed in the hope that it will be useful, but
  17. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. ;;; GNU General Public License for more details.
  20. ;;;
  21. ;;; You should have received a copy of the GNU General Public License
  22. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  23. (define-module (gnu packages chez)
  24. #:use-module (gnu packages)
  25. #:use-module ((guix licenses)
  26. #:select (gpl2+ gpl3+ lgpl2.0+ lgpl2.1+ asl2.0 bsd-3 expat
  27. public-domain))
  28. #:use-module (guix packages)
  29. #:use-module (guix download)
  30. #:use-module (guix git-download)
  31. #:use-module (guix utils)
  32. #:use-module (guix gexp)
  33. #:use-module (guix build-system gnu)
  34. #:use-module (gnu packages compression)
  35. #:use-module (gnu packages ncurses)
  36. #:use-module (gnu packages ghostscript)
  37. #:use-module (gnu packages linux)
  38. #:use-module (gnu packages netpbm)
  39. #:use-module (gnu packages tex)
  40. #:use-module (gnu packages compression)
  41. #:use-module (gnu packages image)
  42. #:use-module (gnu packages xorg)
  43. #:use-module (ice-9 match)
  44. #:use-module (srfi srfi-1))
  45. (define nanopass
  46. (let ((version "1.9.2"))
  47. (origin
  48. (method git-fetch)
  49. (uri (git-reference
  50. (url "https://github.com/nanopass/nanopass-framework-scheme")
  51. (commit (string-append "v" version))))
  52. (sha256 (base32 "16vjsik9rrzbabbhbxbaha51ppi3f9n8rk59pc6zdyffs0vziy4i"))
  53. (file-name (git-file-name "nanopass" version)))))
  54. (define stex
  55. ;; This commit includes a fix, which we would otherwise want to use as
  56. ;; patch. Let's revert to tagged releases as soon as one becomes available.
  57. (let* ((commit "54051494434a197772bf6ca5b4e6cf6be55f39a5")
  58. (version "1.2.2")
  59. (version (git-version version "1" commit)))
  60. (origin
  61. (method git-fetch)
  62. (uri (git-reference
  63. (url "https://github.com/dybvig/stex")
  64. (commit commit)))
  65. (sha256 (base32 "01jnvw8qw33gnpzwrakwhsr05h6b609lm180jnspcrb7lds2p23d"))
  66. (file-name (git-file-name "stex" version)))))
  67. (define-public chez-scheme
  68. (package
  69. (name "chez-scheme")
  70. (version "9.5.4")
  71. (source
  72. (origin
  73. (method git-fetch)
  74. (uri (git-reference
  75. (url "https://github.com/cisco/ChezScheme")
  76. (commit (string-append "v" version))))
  77. (sha256
  78. (base32 "0prgn2z9l888j93ydxaf04ph424g0fi3a8w7f8m0b2r7fr1v7388"))
  79. (file-name (git-file-name name version))
  80. (patches
  81. (search-patches
  82. ;; backported from upstream: remove on next release
  83. "chez-scheme-build-util-paths-backport.patch"))
  84. (snippet
  85. ;; remove bundled libraries
  86. (with-imported-modules '((guix build utils))
  87. #~(begin
  88. (use-modules (guix build utils))
  89. (for-each (lambda (dir)
  90. (when (directory-exists? dir)
  91. (delete-file-recursively dir)))
  92. '("stex"
  93. "nanopass"
  94. "lz4"
  95. "zlib")))))))
  96. (build-system gnu-build-system)
  97. (inputs
  98. `(("libuuid" ,util-linux "lib")
  99. ("zlib" ,zlib)
  100. ("zlib:static" ,zlib "static")
  101. ("lz4" ,lz4)
  102. ("lz4:static" ,lz4 "static")
  103. ;; for expeditor:
  104. ("ncurses" ,ncurses)
  105. ;; for X11 clipboard support in expeditor:
  106. ;; https://github.com/cisco/ChezScheme/issues/9#issuecomment-222057232
  107. ("libx11" ,libx11)))
  108. (native-inputs
  109. `(("nanopass" ,nanopass) ; source only
  110. ;; for docs
  111. ("stex" ,stex)
  112. ("xorg-rgb" ,xorg-rgb)
  113. ("texlive" ,(texlive-updmap.cfg (list texlive-oberdiek
  114. texlive-epsf)))
  115. ("ghostscript" ,ghostscript)
  116. ("netpbm" ,netpbm)))
  117. (native-search-paths
  118. (list (search-path-specification
  119. (variable "CHEZSCHEMELIBDIRS")
  120. (files (list (string-append "lib/csv" version "-site"))))))
  121. (outputs '("out" "doc"))
  122. (arguments
  123. `(#:modules
  124. ((guix build gnu-build-system)
  125. (guix build utils)
  126. (ice-9 ftw)
  127. (ice-9 match))
  128. #:test-target "test"
  129. #:configure-flags
  130. '("--threads") ;; TODO when we fix armhf, it doesn't support --threads
  131. #:phases
  132. (modify-phases %standard-phases
  133. ;; put these where configure expects them to be
  134. (add-after 'unpack 'unpack-nanopass+stex
  135. (lambda* (#:key native-inputs inputs #:allow-other-keys)
  136. (for-each (lambda (dep)
  137. (define src
  138. (assoc-ref (or native-inputs inputs) dep))
  139. (copy-recursively src dep
  140. #:keep-mtime? #t))
  141. '("nanopass" "stex"))
  142. #t))
  143. ;; NOTE: the custom Chez 'configure' script doesn't allow
  144. ;; unrecognized flags, such as those automatically added
  145. ;; by `gnu-build-system`.
  146. (replace 'configure
  147. (lambda* (#:key inputs outputs
  148. (configure-flags '())
  149. #:allow-other-keys)
  150. (let* ((zlib-static (assoc-ref inputs "zlib:static"))
  151. (lz4-static (assoc-ref inputs "lz4:static"))
  152. (out (assoc-ref outputs "out"))
  153. ;; add flags which are always required:
  154. (flags (cons*
  155. (string-append "--installprefix=" out)
  156. (string-append "ZLIB=" zlib-static "/lib/libz.a")
  157. (string-append "LZ4=" lz4-static "/lib/liblz4.a")
  158. ;; Guix will do compress man pages,
  159. ;; and letting Chez try causes an error
  160. "--nogzip-man-pages"
  161. configure-flags)))
  162. (format #t "configure flags: ~s~%" flags)
  163. ;; Some makefiles (for tests) don't seem to propagate CC
  164. ;; properly, so we take it out of their hands:
  165. (setenv "CC" ,(cc-for-target))
  166. (apply invoke
  167. "./configure"
  168. flags)
  169. #t)))
  170. ;; The binary file name is called "scheme" as is the one from MIT/GNU
  171. ;; Scheme. We add a symlink to use in case both are installed.
  172. (add-after 'install 'install-symlink
  173. (lambda* (#:key outputs #:allow-other-keys)
  174. (let* ((out (assoc-ref outputs "out"))
  175. (bin (string-append out "/bin"))
  176. (lib (string-append out "/lib"))
  177. (name "chez-scheme"))
  178. (symlink (string-append bin "/scheme")
  179. (string-append bin "/" name))
  180. (map (lambda (file)
  181. (symlink file (string-append (dirname file)
  182. "/" name ".boot")))
  183. (find-files lib "scheme.boot"))
  184. #t)))
  185. ;; Building explicitly lets us avoid using substitute*
  186. ;; to re-write makefiles.
  187. (add-after 'install-symlink 'prepare-stex
  188. (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
  189. (let* ((stex+version
  190. (strip-store-file-name
  191. (assoc-ref (or native-inputs inputs) "stex")))
  192. ;; Eventually we want to install stex as a real
  193. ;; package so it's reusable. For now:
  194. (stex-output "/tmp")
  195. (doc-dir (string-append stex-output
  196. "/share/doc/"
  197. stex+version)))
  198. (with-directory-excursion "stex"
  199. (invoke "make"
  200. "install"
  201. (string-append "LIB="
  202. stex-output
  203. "/lib/"
  204. stex+version)
  205. (string-append "Scheme="
  206. (assoc-ref outputs "out")
  207. "/bin/scheme"))
  208. (for-each (lambda (pth)
  209. (install-file pth doc-dir))
  210. '("ReadMe" ; includes the license
  211. "doc/stex.html"
  212. "doc/stex.css"
  213. "doc/stex.pdf"))
  214. #t))))
  215. ;; Building the documentation requires stex and a running scheme.
  216. ;; FIXME: this is probably wrong for cross-compilation
  217. (add-after 'prepare-stex 'install-doc
  218. (lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
  219. (let* ((chez+version (strip-store-file-name
  220. (assoc-ref outputs "out")))
  221. (stex+version
  222. (strip-store-file-name
  223. (assoc-ref (or native-inputs inputs) "stex")))
  224. (scheme (string-append (assoc-ref outputs "out")
  225. "/bin/scheme"))
  226. ;; see note on stex-output in phase build-stex, above:
  227. (stexlib (string-append "/tmp"
  228. "/lib/"
  229. stex+version))
  230. (doc-dir (string-append (assoc-ref outputs "doc")
  231. "/share/doc/"
  232. chez+version)))
  233. (define* (stex-make #:optional (suffix ""))
  234. (invoke "make"
  235. "install"
  236. (string-append "Scheme=" scheme)
  237. (string-append "STEXLIB=" stexlib)
  238. (string-append "installdir=" doc-dir suffix)))
  239. (with-directory-excursion "csug"
  240. (stex-make "/csug"))
  241. (with-directory-excursion "release_notes"
  242. (stex-make "/release_notes"))
  243. (with-directory-excursion doc-dir
  244. (symlink "release_notes/release_notes.pdf"
  245. "release_notes.pdf")
  246. (symlink "csug/csug9_5.pdf"
  247. "csug.pdf"))
  248. #t))))))
  249. ;; Chez Scheme does not have a MIPS backend.
  250. ;; FIXME: Debian backports patches to get armhf working.
  251. ;; We should too. It is the Chez machine type arm32le
  252. ;; (no threaded version upstream yet, though there is in
  253. ;; Racket's fork), more specifically (per the release notes) ARMv6.
  254. (supported-systems (fold delete %supported-systems
  255. '("mips64el-linux" "armhf-linux")))
  256. (home-page "https://cisco.github.io/ChezScheme/")
  257. (synopsis "R6RS Scheme compiler and run-time")
  258. (description
  259. "Chez Scheme is a compiler and run-time system for the language of the
  260. Revised^6 Report on Scheme (R6RS), with numerous extensions. The compiler
  261. generates native code for each target processor, with support for x86, x86_64,
  262. and 32-bit PowerPC architectures.")
  263. (license asl2.0)))
  264. (define-public chez-srfi
  265. (package
  266. (name "chez-srfi")
  267. (version "1.0")
  268. (source
  269. (origin
  270. (method git-fetch)
  271. (uri (git-reference
  272. (url "https://github.com/fedeinthemix/chez-srfi")
  273. (commit (string-append "v" version))))
  274. (sha256
  275. (base32 "1vgn984mj2q4w6r2q66h7qklp2hrh85wwh4k9yisga5fi0ps7myf"))
  276. (file-name (git-file-name name version))))
  277. (build-system gnu-build-system)
  278. (native-inputs
  279. `(("chez-scheme" ,chez-scheme)))
  280. (arguments
  281. `(#:make-flags (let ((out (assoc-ref %outputs "out")))
  282. (list (string-append "PREFIX=" out)
  283. "CHEZ=chez-scheme --libdirs ./"
  284. (string-append "chezversion=" ,(package-version chez-scheme))))
  285. #:test-target "test"
  286. #:phases (modify-phases %standard-phases
  287. (delete 'configure))))
  288. (home-page "https://github.com/fedeinthemix/chez-srfi")
  289. (synopsis "SRFI libraries for Chez Scheme")
  290. (description
  291. "This package provides a collection of SRFI libraries for Chez Scheme.")
  292. (license expat)))
  293. (define-public chez-web
  294. (let ((commit "5fd177fe53f31f466bf88720d03c95a3711a8bea")
  295. (revision "1"))
  296. (package
  297. (name "chez-web")
  298. ;; Release 2.0 is different and doesn't work.
  299. (version (git-version "2.0" revision commit))
  300. (source
  301. (origin
  302. (method git-fetch)
  303. (uri (git-reference
  304. (url "https://github.com/arcfide/ChezWEB")
  305. (commit commit)))
  306. (file-name (git-file-name name version))
  307. (sha256
  308. (base32 "1dq25qygyncbfq4kwwqqgyyakfqjwhp5q23vrf3bff1p66nyfl3b"))))
  309. (build-system gnu-build-system)
  310. (native-inputs
  311. `(("chez-scheme" ,chez-scheme)
  312. ("ghostscript" ,ghostscript)
  313. ("texlive" ,(texlive-updmap.cfg (list texlive-oberdiek
  314. texlive-epsf
  315. texlive-metapost
  316. texlive-charter
  317. texlive-pdftex
  318. texlive-context
  319. texlive-cm
  320. texlive-tex-plain)))))
  321. (arguments
  322. `(#:make-flags (list (string-append "PREFIX=" %output)
  323. (string-append "DOCDIR=" %output "/share/doc/"
  324. ,name "-" ,version)
  325. (string-append "LIBDIR=" %output "/lib/chezweb")
  326. (string-append "TEXDIR=" %output "/share/texmf-local"))
  327. #:tests? #f ; no tests
  328. #:phases
  329. (modify-phases %standard-phases
  330. ;; This package has a custom "bootstrap" script that
  331. ;; is meant to be run from the Makefile.
  332. (delete 'bootstrap)
  333. (replace 'configure
  334. (lambda* _
  335. (copy-file "config.mk.template" "config.mk")
  336. (substitute* "tangleit"
  337. (("\\./cheztangle\\.ss" all)
  338. (string-append "chez-scheme --program " all)))
  339. (substitute* "weaveit"
  340. (("mpost chezweb\\.mp")
  341. "mpost --tex=tex chezweb.mp")
  342. (("\\./chezweave" all)
  343. (string-append "chez-scheme --program " all)))
  344. (substitute* "installit"
  345. (("-g \\$GROUP -o \\$OWNER") ""))
  346. #t)))))
  347. (home-page "https://github.com/arcfide/ChezWEB")
  348. (synopsis "Hygienic Literate Programming for Chez Scheme")
  349. (description "ChezWEB is a system for doing Knuthian style WEB
  350. programming in Scheme.")
  351. (license expat))))
  352. (define-public chez-sockets
  353. (let ((commit "bce96881c06bd69a6757a6bff139744153924140")
  354. (revision "1"))
  355. (package
  356. (name "chez-sockets")
  357. (version (git-version "0.0.0" revision commit))
  358. (source
  359. (origin
  360. (method git-fetch)
  361. (uri (git-reference
  362. (url "https://github.com/arcfide/chez-sockets")
  363. (commit commit)))
  364. (file-name (git-file-name name version))
  365. (sha256
  366. (base32 "1n5fbwwz51fdzvjackgmnsgh363g9inyxv7kmzi0469cwavwcx5m"))))
  367. (build-system gnu-build-system)
  368. (native-inputs
  369. `(("chez-scheme" ,chez-scheme)
  370. ("chez-web" ,chez-web)
  371. ("texlive" ,(texlive-updmap.cfg (list texlive-pdftex)))))
  372. (arguments
  373. `(#:tests? #f ; no tests
  374. #:phases
  375. (modify-phases %standard-phases
  376. (replace 'configure
  377. (lambda* (#:key outputs inputs #:allow-other-keys)
  378. (let* ((out (assoc-ref outputs "out"))
  379. (chez-web (assoc-ref inputs "chez-web"))
  380. (chez (assoc-ref inputs "chez-scheme"))
  381. (chez-h (dirname (car (find-files chez "scheme\\.h")))))
  382. (substitute* "Makefile"
  383. (("(SCHEMEH=).*$" all var)
  384. (string-append var chez-h)))
  385. #t)))
  386. (add-before 'build 'tangle
  387. (lambda* (#:key inputs #:allow-other-keys)
  388. (setenv "TEXINPUTS"
  389. (string-append
  390. (getcwd) ":"
  391. (assoc-ref inputs "chez-web") "/share/texmf-local/tex/generic:"
  392. ":"))
  393. ;; just using "make" tries to build the .c files before
  394. ;; they are created.
  395. (and (invoke "make" "sockets")
  396. (invoke "make"))))
  397. (replace 'build
  398. (lambda* (#:key outputs inputs #:allow-other-keys)
  399. (let* ((out (assoc-ref outputs "out"))
  400. (chez-site (string-append out "/lib/csv"
  401. ,(package-version chez-scheme)
  402. "-site/arcfide")))
  403. ;; make sure Chez Scheme can find the shared libraries.
  404. (substitute* "sockets.ss"
  405. (("(load-shared-object) \"(socket-ffi-values\\.[sd][oy].*)\""
  406. all cmd so)
  407. (string-append cmd " \"" chez-site "/" so "\""))
  408. (("sockets-stub\\.[sd][oy].*" all)
  409. (string-append chez-site "/" all)))
  410. ;; to compile chez-sockets, the .so files must be
  411. ;; installed (because of the absolute path we
  412. ;; inserted above).
  413. (for-each (lambda (f d) (install-file f d))
  414. '("socket-ffi-values.so" "sockets-stub.so")
  415. (list chez-site chez-site))
  416. (zero? (system "echo '(compile-file \"sockets.sls\")' | scheme -q")))))
  417. (replace 'install
  418. (lambda* (#:key outputs inputs #:allow-other-keys)
  419. (let* ((out (assoc-ref outputs "out"))
  420. (lib (string-append out "/lib/chez-sockets"))
  421. (doc (string-append out "/share/doc/" ,name "-" ,version))
  422. (chez-site (string-append out "/lib/csv"
  423. ,(package-version chez-scheme)
  424. "-site/arcfide")))
  425. (for-each (lambda (f d) (install-file f d))
  426. '("sockets.pdf" "sockets.so")
  427. (list doc chez-site))
  428. #t))))))
  429. (home-page "https://github.com/arcfide/chez-sockets")
  430. (synopsis "Extensible sockets library for Chez Scheme")
  431. (description "Chez-sockets is an extensible sockets library for
  432. Chez Scheme.")
  433. (license expat))))
  434. ;; Help function for Chez Scheme to add the current path to
  435. ;; CHEZSCHEMELIBDIRS.
  436. (define chez-configure
  437. '(lambda _
  438. (let ((chez-env (getenv "CHEZSCHEMELIBDIRS")))
  439. (setenv "CHEZSCHEMELIBDIRS"
  440. (if chez-env
  441. (string-append ".:" chez-env)
  442. "."))
  443. #t)))
  444. ;; Help function to define make flags for some Chez Scheme custom make
  445. ;; files.
  446. (define (chez-make-flags name version)
  447. `(let ((out (assoc-ref %outputs "out")))
  448. (list
  449. ;; Set 'chezversion' so that libraries are installed in
  450. ;; 'lib/csvX.Y.Z-site' like Chez's 'native-search-paths' expects.
  451. (string-append "chezversion=" ,(package-version chez-scheme))
  452. (string-append "PREFIX=" out)
  453. (string-append "DOCDIR=" out "/share/doc/"
  454. ,name "-" ,version))))
  455. (define-public chez-matchable
  456. (package
  457. (name "chez-matchable")
  458. (version "20160306")
  459. (home-page "https://github.com/fedeinthemix/chez-matchable")
  460. (source
  461. (origin
  462. (method git-fetch)
  463. (uri (git-reference
  464. (url home-page)
  465. (commit (string-append "v" version))))
  466. (sha256
  467. (base32 "02qn7x348p23z1x5lwhkyj7i8z6mgwpzpnwr8dyina0yzsdkr71s"))
  468. (file-name (git-file-name name version))))
  469. (build-system gnu-build-system)
  470. (inputs
  471. `(("chez-srfi" ,chez-srfi))) ; for tests
  472. (native-inputs
  473. `(("chez-scheme" ,chez-scheme)))
  474. (arguments
  475. `(#:make-flags ,(chez-make-flags name version)
  476. #:test-target "test"
  477. #:phases (modify-phases %standard-phases
  478. (replace 'configure ,chez-configure))))
  479. (synopsis "Portable hygienic pattern matcher for Scheme")
  480. (description "This package provides a superset of the popular Scheme
  481. @code{match} package by Andrew Wright, written in fully portable
  482. @code{syntax-rules} and thus preserving hygiene.")
  483. (license public-domain)))
  484. (define-public chez-irregex
  485. (package
  486. (name "chez-irregex")
  487. (version "0.9.4")
  488. (source
  489. (origin
  490. (method git-fetch)
  491. (uri (git-reference
  492. (url "https://github.com/fedeinthemix/chez-irregex")
  493. (commit (string-append "v" version))))
  494. (sha256
  495. (base32 "0jh6piylw545j81llay9wfivgpv6lcnwd81gm4w17lkasslir50q"))
  496. (file-name (git-file-name name version))))
  497. (build-system gnu-build-system)
  498. (inputs
  499. `(("chez-matchable" ,chez-matchable))) ; for tests
  500. (propagated-inputs
  501. `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
  502. (native-inputs
  503. `(("chez-scheme" ,chez-scheme)))
  504. (arguments
  505. `(#:make-flags ,(chez-make-flags name version)
  506. #:test-target "test"
  507. #:phases (modify-phases %standard-phases
  508. (replace 'configure ,chez-configure))))
  509. (home-page "https://github.com/fedeinthemix/chez-irregex")
  510. (synopsis "Portable regular expression library for Scheme")
  511. (description "This package provides a portable and efficient
  512. R[4567]RS implementation of regular expressions, supporting both POSIX
  513. syntax with various (irregular) PCRE extensions, as well as SCSH's SRE
  514. syntax, with various aliases for commonly used patterns.")
  515. (license bsd-3)))
  516. (define-public chez-fmt
  517. (package
  518. (name "chez-fmt")
  519. (version "0.8.11")
  520. (source
  521. (origin
  522. (method url-fetch)
  523. (uri (string-append
  524. "http://synthcode.com/scheme/fmt/fmt-" version ".tar.gz"))
  525. (sha256
  526. (base32 "1zxqlw1jyg85yzclylh8bp2b3fwcy3l3xal68jw837n5illvsjcl"))
  527. (file-name (string-append name "-" version ".tar.gz"))))
  528. (build-system gnu-build-system)
  529. (propagated-inputs
  530. `(("chez-srfi" ,chez-srfi))) ; for irregex-utils
  531. (native-inputs
  532. `(("chez-scheme" ,chez-scheme)))
  533. (arguments
  534. `(#:make-flags ,(chez-make-flags name version)
  535. #:test-target "chez-check"
  536. #:phases
  537. (modify-phases %standard-phases
  538. (replace 'configure ,chez-configure)
  539. (replace 'build
  540. (lambda* (#:key (make-flags '()) #:allow-other-keys)
  541. (apply invoke "make" "chez-build" make-flags)))
  542. (replace 'install
  543. (lambda* (#:key (make-flags '()) #:allow-other-keys)
  544. (apply invoke "make" "chez-install" make-flags))))))
  545. (home-page "http://synthcode.com/scheme/fmt")
  546. (synopsis "Combinator formatting library for Chez Scheme")
  547. (description "This package provides a library of procedures for
  548. formatting Scheme objects to text in various ways, and for easily
  549. concatenating, composing and extending these formatters efficiently
  550. without resorting to capturing and manipulating intermediate
  551. strings.")
  552. (license bsd-3)))
  553. (define-public chez-mit
  554. (package
  555. (name "chez-mit")
  556. (version "0.1")
  557. (home-page "https://github.com/fedeinthemix/chez-mit")
  558. (source
  559. (origin
  560. (method git-fetch)
  561. (uri (git-reference
  562. (url home-page)
  563. (commit (string-append "v" version))))
  564. (sha256
  565. (base32 "0c7i3b6i90xk96nmxn1pc9272a4yal4v40dm1a4ybdi87x53zkk0"))
  566. (file-name (git-file-name name version))))
  567. (build-system gnu-build-system)
  568. (inputs
  569. `(("chez-srfi" ,chez-srfi))) ; for tests
  570. (native-inputs
  571. `(("chez-scheme" ,chez-scheme)))
  572. (arguments
  573. `(#:make-flags ,(chez-make-flags name version)
  574. #:test-target "test"
  575. #:phases (modify-phases %standard-phases
  576. (replace 'configure ,chez-configure))))
  577. (synopsis "MIT/GNU Scheme compatibility library for Chez Scheme")
  578. (description "This package provides a set of MIT/GNU Scheme compatibility
  579. libraries for Chez Scheme. The main goal was to provide the functionality
  580. required to port the program @code{Scmutils} to Chez Scheme.")
  581. (license gpl3+)))
  582. (define-public chez-scmutils
  583. (package
  584. (name "chez-scmutils")
  585. (version "0.1")
  586. (home-page "https://github.com/fedeinthemix/chez-scmutils")
  587. (source
  588. (origin
  589. (method git-fetch)
  590. (uri (git-reference
  591. (url home-page)
  592. (commit (string-append "v" version))))
  593. (sha256
  594. (base32 "0lb05wlf8qpgg8y0gdsyaxg1nbfx1qbaqdjvygrp64ndn8fnhq7l"))
  595. (file-name (git-file-name name version))))
  596. (build-system gnu-build-system)
  597. (inputs
  598. `(("chez-srfi" ,chez-srfi))) ; for tests
  599. (native-inputs
  600. `(("chez-scheme" ,chez-scheme)))
  601. (propagated-inputs
  602. `(("chez-mit" ,chez-mit)
  603. ("chez-srfi" ,chez-srfi)))
  604. (arguments
  605. `(#:make-flags ,(chez-make-flags name version)
  606. #:tests? #f ; no test suite
  607. #:phases
  608. (modify-phases %standard-phases
  609. (replace 'configure ,chez-configure)
  610. ;; Since the documentation is lacking, we install the source
  611. ;; code. For things to work correctly we have to replace
  612. ;; relative paths by absolute ones in 'include' forms. This
  613. ;; in turn requires us to compile the files in the final
  614. ;; destination.
  615. (delete 'build)
  616. (add-after 'install 'install-src
  617. (lambda* (#:key (make-flags '()) #:allow-other-keys)
  618. (apply invoke "make" "install-src" make-flags)))
  619. (add-after 'install-src 'absolute-path-in-scm-files
  620. (lambda* (#:key outputs #:allow-other-keys)
  621. (let ((out (assoc-ref outputs "out")))
  622. (for-each (lambda (file)
  623. (substitute* file
  624. (("include +\"\\./scmutils")
  625. (string-append "include \"" (dirname file)))))
  626. (find-files out "\\.sls"))
  627. (for-each (lambda (file)
  628. (substitute* file
  629. (("include +\"\\./scmutils/simplify")
  630. (string-append "include \"" (dirname file)))))
  631. (find-files out "fbe-syntax\\.scm"))
  632. #t)))
  633. (add-after 'absolute-path-in-scm-files 'build
  634. (lambda* (#:key outputs (make-flags '()) #:allow-other-keys)
  635. (let* ((out (assoc-ref outputs "out"))
  636. (mk-file (car (find-files out "Makefile"))))
  637. (with-directory-excursion (dirname mk-file)
  638. (apply invoke "make" "build" make-flags)))))
  639. (add-after 'build 'clean-up
  640. (lambda* (#:key outputs #:allow-other-keys)
  641. (let* ((out (assoc-ref outputs "out")))
  642. (for-each delete-file
  643. (find-files out "Makefile|compile-all\\.ss"))
  644. #t))))))
  645. (synopsis "Port of MIT/GNU Scheme Scmutils to Chez Scheme")
  646. (description "This package provides a port of the MIT/GNU Scheme
  647. Scmutils program to Chez Scheme. The port consists of a set of
  648. libraries providing most of the functionality of the original.")
  649. (license gpl3+)))