projects/guix·blob javascript-team · refs

349 lines · 14.6 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2017 Andy Patterson <[email protected]>
3;;; Copyright © 2017, 2021 Tobias Geerinckx-Rice <[email protected]>
4;;; Copyright © 2018 Ricardo Wurmus <[email protected]>
5;;; Copyright © 2019, 2020 Brett Gilio <[email protected]>
6;;; Copyright © 2021, 2022 Foo Chuan Wei <[email protected]>
7;;; Copyright © 2025 Tomás Ortín Fernández <[email protected]>
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
24(define-module (gnu packages sml)
25 #:use-module (gnu packages toolkits)
26 #:use-module (gnu packages libffi)
27 #:use-module (gnu packages multiprecision)
28 #:use-module (gnu packages xorg)
29 #:use-module (guix build-system gnu)
30 #:use-module (guix download)
31 #:use-module (guix git-download)
32 #:use-module ((guix licenses) #:prefix license:)
33 #:use-module (guix packages)
34 #:use-module (guix utils))
35
36(define-public polyml
37 (package
38 (name "polyml")
39 (version "5.9.2")
40 (source (origin
41 (method git-fetch)
42 (uri (git-reference
43 (url "https://github.com/polyml/polyml")
44 (commit (string-append "v" version))))
45 (file-name (git-file-name name version))
46 (sha256
47 (base32
48 "1kvkpighzz6dkfh9gr1franvjfjhr4lcwyb0cmngzvb2nf6g8f6v"))))
49 (build-system gnu-build-system)
50 (inputs
51 (list gmp libffi libx11 libxt motif))
52 (arguments
53 '(#:configure-flags
54 (list "--with-gmp"
55 "--with-x")
56 #:phases
57 (modify-phases %standard-phases
58 (add-after 'unpack 'patch-config-h
59 (lambda _
60 ;; courtesy: https://github.com/NixOS/nixpkgs/pull/372200
61 (call-with-port (open-file "config.h.in" "a")
62 (lambda (out)
63 (display "\n#define _Static_assert static_assert\n" out)))))
64 (add-after 'build 'build-compiler
65 (lambda* (#:key make-flags parallel-build? #:allow-other-keys)
66 (define flags
67 (if parallel-build?
68 (cons (format #f "-j~d" (parallel-job-count))
69 make-flags)
70 make-flags))
71 (apply system* "make" (append flags (list "compiler"))))))))
72 (home-page "https://www.polyml.org/")
73 (synopsis "Standard ML implementation")
74 (description "Poly/ML is a Standard ML implementation. It is fully
75compatible with the ML97 standard. It includes a thread library, a foreign
76function interface, and a symbolic debugger.")
77 ;; Some source files specify 'or any later version'; some don't
78 (license
79 (list license:lgpl2.1
80 license:lgpl2.1+))))
81
82(define (smlnj-file version filename hash)
83 (origin
84 (method url-fetch)
85 (uri (string-append "http://smlnj.cs.uchicago.edu/dist/working/"
86 version "/" filename))
87 (sha256 (base32 hash))))
88
89(define-public smlnj
90 (package
91 (name "smlnj")
92 (version "110.99.7.1")
93 (source #f) ; Sources are passed as native-inputs.
94 (supported-systems '("x86_64-linux" "i686-linux"))
95 (build-system gnu-build-system)
96 (outputs '("out" "doc"))
97 (arguments
98 `(#:tests? #f
99 #:phases
100 (modify-phases %standard-phases
101 (replace 'unpack
102 (lambda* (#:key inputs #:allow-other-keys)
103 (for-each
104 (lambda (file)
105 (invoke "tar" "xvf" (assoc-ref inputs file)))
106 (list (if (string=? "i686-linux" ,(%current-system))
107 "boot.x86-unix"
108 "boot.amd64-unix")
109 "config"
110 "cm"
111 "compiler"
112 "runtime"
113 "system"
114 "MLRISC"
115 "smlnj-lib"
116 "old-basis"
117 "ckit"
118 "nlffi"
119 "cml"
120 "eXene"
121 "ml-lpt"
122 "ml-lex"
123 "ml-yacc"
124 "ml-burg"
125 "pgraph"
126 "trace-debug-profile"
127 "heap2asm"
128 "smlnj-c"
129 "doc"
130 "asdl"))
131 ;; Same directory structure as what the config/unpack script
132 ;; would produce.
133 (mkdir "base")
134 (rename-file "runtime" "base/runtime")
135 (rename-file "compiler" "base/compiler")
136 (rename-file "cm" "base/cm")
137 (rename-file "old-basis" "base/old-basis")
138 (rename-file "system" "base/system")
139 #t))
140 (delete 'configure)
141 (replace 'patch-source-shebangs
142 (lambda _
143 ;; Fix paths to /bin/sh.
144 (substitute* (list "config/install.sh"
145 (if (string=? "i686-linux" ,(%current-system))
146 "base/runtime/objs/mk.x86-linux"
147 "base/runtime/objs/mk.amd64-linux")
148 "asdl/configure"
149 "asdl/src/asdlgen/Makefile.in")
150 (("^SHELL[[:space:]]*=[[:space:]]*/bin/sh")
151 (string-append "SHELL=" (which "sh"))))
152 (substitute* "asdl/configure"
153 (("^SHELL=\\$\\{CONFIG_SHELL-/bin/sh\\}")
154 (string-append "SHELL=" (which "sh"))))
155 (substitute* (list "asdl/src/gen/fragments/mkfrags_sh.in"
156 "asdl/src/gen/fragments/mkmk_sh.in")
157 (("^#!/bin/sh")
158 (string-append "#!" (which "sh"))))
159 #t))
160 (replace 'build
161 (lambda* (#:key inputs outputs #:allow-other-keys)
162 (substitute* "config/chk-global-names.sh"
163 (("^CC=.*")
164 (string-append "CC=" ,(cc-for-target))))
165
166 ;; /bin and /usr/bin do not exist in the build environment.
167 (substitute* "config/_arch-n-opsys"
168 (("^export PATH") "")
169 (("^PATH=\"/bin:/usr/bin\"") "")
170 (("uname") (which "uname")))
171 (substitute* "base/runtime/config/gen-posix-names.sh"
172 (("^PATH=/bin:/usr/bin") ""))
173
174 ;; The build process uses an SML Basis Library function
175 ;; `OS.Process.system`, which uses "/bin/sh" (this is hardcoded).
176 ;; However, /bin/sh does not exist in the Guix build environment.
177 ;; Solution: binary patch — replace "/bin/sh" with "/tmp/sh".
178 (symlink (which "sh") "/tmp/sh")
179 (invoke "sed" "-i" "s,/bin/sh,/tmp/sh,"
180 (if (string=? "i686-linux" ,(%current-system))
181 "sml.boot.x86-unix/SMLNJ-BASIS/.cm/x86-unix/basis-common.cm"
182 "sml.boot.amd64-unix/SMLNJ-BASIS/.cm/amd64-unix/basis-common.cm"))
183
184 ;; Build.
185 ;; The `sml` executable built by this package somehow inherits the
186 ;; signal dispositions of the shell where it was built. If SIGINT
187 ;; is ignored in the shell, the resulting `sml` will also ignore
188 ;; SIGINT. This will break the use of Ctrl-c for interrupting
189 ;; execution in the SML/NJ REPL.
190 ;; Here, we use Guile's `system` procedure instead of Guix's
191 ;; `invoke` because `invoke` uses Guile's `system*`, which causes
192 ;; SIGINT and SIGQUIT to be ignored.
193 (let ((exit-code
194 (system (string-append "./config/install.sh -default "
195 (if (string=? "i686-linux"
196 ,(%current-system))
197 "32"
198 "64")))))
199 (unless (zero? exit-code)
200 (error (format #f "Exit code: ~a" exit-code))))
201
202 ;; Undo the binary patch.
203 (for-each
204 (lambda (file)
205 (invoke "sed" "-i" "s,/tmp/sh,/bin/sh," file))
206 (if (string=? "i686-linux" ,(%current-system))
207 '("bin/.heap/sml.x86-linux"
208 "lib/SMLNJ-BASIS/.cm/x86-unix/basis-common.cm")
209 '("bin/.heap/sml.amd64-linux"
210 "lib/SMLNJ-BASIS/.cm/amd64-unix/basis-common.cm")))
211
212 ;; Set SMLNJ_HOME in the bin/ files, so that `sml` is able to find
213 ;; the SML/NJ Library.
214 (let ((out (assoc-ref outputs "out")))
215 (for-each
216 (lambda (file)
217 (invoke "sed" "-i"
218 (string-append "2iSMLNJ_HOME=${SMLNJ_HOME:-" out "}")
219 file))
220 '("bin/.link-sml"
221 "bin/.run-sml"
222 "bin/ml-build"
223 "bin/ml-makedepend")))))
224 (replace 'install
225 (lambda* (#:key outputs #:allow-other-keys)
226 (let* ((out (assoc-ref outputs "out"))
227 (out-bin (string-append out "/bin/"))
228 (out-lib (string-append out "/lib/"))
229 (out-man (string-append out "/share/man/")))
230 (copy-recursively "bin" out-bin)
231 (copy-recursively "lib" out-lib)
232 (copy-recursively "doc/man" out-man))
233 #t))
234 (add-after 'install 'install-doc
235 (lambda* (#:key outputs #:allow-other-keys)
236 (let ((doc (string-append (assoc-ref outputs "doc")
237 "/share/doc/smlnj")))
238 (mkdir-p doc)
239 (copy-recursively "doc" doc))
240 #t)))))
241 (native-inputs
242 `(,(if (string=? "i686-linux" (%current-system))
243 `("boot.x86-unix"
244 ,(smlnj-file version
245 "boot.x86-unix.tgz"
246 "0nl71scc4q1jlwikfph9r01fs5nhqaiikbxq732y0199mwwlqhjm"))
247 `("boot.amd64-unix"
248 ,(smlnj-file version
249 "boot.amd64-unix.tgz"
250 "0m6p8zlcxd11c0zswma4bbh0wxi9f8926b21ddqhypnkrbq061xa")))
251 ("config"
252 ,(smlnj-file version
253 "config.tgz"
254 "108j8hk6zk9nf25hw53b3ig64gysj518v5997b0c06syjfnnpc3y"))
255 ("cm"
256 ,(smlnj-file version
257 "cm.tgz"
258 "0sh69rswnaarycm2i5v9piv9725ld62pxs4q4q4xw7nggmqfw4pq"))
259 ("compiler"
260 ,(smlnj-file version
261 "compiler.tgz"
262 "0qr1wghnld085bf55ygd0iwdqsyi39x7wjl2m36d8saymagc1lzm"))
263 ("runtime"
264 ,(smlnj-file version
265 "runtime.tgz"
266 "11f05pd5rgkn4k3apnb9zbimkqg6z2plmd2550zph3n8sq883fax"))
267 ("system"
268 ,(smlnj-file version
269 "system.tgz"
270 "0aj6vrbmpziqf50x7gggzkvijhny9xrwqmjjrqxq2rkywy41k1i2"))
271 ("MLRISC"
272 ,(smlnj-file version
273 "MLRISC.tgz"
274 "0svwsnpzcb1hiwfsjmh53wa2qsry3ycpk907jj1ggdz52vwj1p96"))
275 ("smlnj-lib"
276 ,(smlnj-file version
277 "smlnj-lib.tgz"
278 "04vhn7rvji05x4ms887xzwrm9bkd3164k9hhc885a6pdlrp7632f"))
279 ("old-basis"
280 ,(smlnj-file version
281 "old-basis.tgz"
282 "04ihh23vgrlqq4smxnnnh4k1xclqfmzz9430hc9d0w87ccy13hbm"))
283 ("ckit"
284 ,(smlnj-file version
285 "ckit.tgz"
286 "1ym96jg6a4x9nvbd2jsn6dy47nvdi92h5nlbdkxyzqf58r772ab7"))
287 ("nlffi"
288 ,(smlnj-file version
289 "nlffi.tgz"
290 "1q60lnhggxyhzdh7d9119mg5avfz1ax89lciwpd20alrjwjvkwv7"))
291 ("cml"
292 ,(smlnj-file version
293 "cml.tgz"
294 "1z5qc52i5k4a7144fmska0kawibrr5xsbvb0ppl98sqyzj34wa3r"))
295 ("eXene"
296 ,(smlnj-file version
297 "eXene.tgz"
298 "05fwzpks5whwgvfa9wd70rwrym1r6z8i79vbvipnncqz794nywr5"))
299 ("ml-lpt"
300 ,(smlnj-file version
301 "ml-lpt.tgz"
302 "1dlwl3b1kz1968yj2razsqvyv6pmz3ripg84rv8nvlj02sknw8p7"))
303 ("ml-lex"
304 ,(smlnj-file version
305 "ml-lex.tgz"
306 "1jjbs7zvzvajiz8zb1bz9k2i1w3przhk6q76964hg4y2zghi74kq"))
307 ("ml-yacc"
308 ,(smlnj-file version
309 "ml-yacc.tgz"
310 "0s53cgjs8zk16qywb18l08ycanfzycrl3bbm0177a1y0y2y1q5zx"))
311 ("ml-burg"
312 ,(smlnj-file version
313 "ml-burg.tgz"
314 "085i565maijp5mmyrcg7cg3ff75iw6c2wmjldgq1psbsjlymv7ni"))
315 ("pgraph"
316 ,(smlnj-file version
317 "pgraph.tgz"
318 "1vlb6hlicxf806z216x33qmx0mi3f8kgddp6jwqxxwbxlzpwa2h6"))
319 ("trace-debug-profile"
320 ,(smlnj-file version
321 "trace-debug-profile.tgz"
322 "08p9j4n3x2xnfksl8xkfr6ajynpfbcgsrcv5w98ri0akvny9dc6p"))
323 ("heap2asm"
324 ,(smlnj-file version
325 "heap2asm.tgz"
326 "0qzqnagpyfipgzkds8jxix9riaps591dnwa4nw7wb3b2pm7xpqm8"))
327 ("smlnj-c"
328 ,(smlnj-file version
329 "smlnj-c.tgz"
330 "194vzb5ig373np2lnldsq66pdwzf3wsjrmhhc1bpyfw6h5z1g82p"))
331 ("doc"
332 ,(smlnj-file version
333 "doc.tgz"
334 "0b9z1dhicg14dmb04zrla6jrmcv2pb08i5bvgw9pns0gvqzc5iyb"))
335 ("asdl"
336 ,(smlnj-file version
337 "asdl.tgz"
338 "1dzhc56m23gylj3jwgxg7qlbx4sh8wklraj1j4mic6dn4jqyqcvh"))))
339 (home-page "https://www.smlnj.org")
340 (synopsis "Standard ML of New Jersey interactive compiler")
341 (description
342 "SML/NJ is an implementation of the Standard ML programming language.
343Standard ML has many features, including type safety, polymorphism, algebraic
344data types with pattern matching, higher-order functions, and a sophisticated
345module system. It is especially well-suited for writing compilers and other
346language processors.")
347 (license (license:fsf-free
348 "https://www.smlnj.org/license.html"
349 "https://www.gnu.org/licenses/license-list#StandardMLofNJ"))))