ocaml.scm
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2017 Julien Lepiller <julien@lepiller.eu> |
3 | ;;; |
4 | ;;; This file is part of GNU Guix. |
5 | ;;; |
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. |
10 | ;;; |
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. |
15 | ;;; |
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/>. |
18 | |
19 | (define-module (more packages ocaml) |
20 | #:use-module (guix packages) |
21 | #:use-module (guix download) |
22 | #:use-module (guix git-download) |
23 | #:use-module (guix utils) |
24 | #:use-module (guix build-system gnu) |
25 | #:use-module (guix build-system ocaml) |
26 | #:use-module ((guix licenses) #:prefix license:) |
27 | #:use-module (gnu packages) |
28 | #:use-module (gnu packages assembly) |
29 | #:use-module (gnu packages base) |
30 | #:use-module (gnu packages bison) |
31 | #:use-module (gnu packages boost) |
32 | #:use-module (gnu packages emacs) |
33 | #:use-module (gnu packages flex) |
34 | #:use-module (gnu packages llvm) |
35 | #:use-module (gnu packages m4) |
36 | #:use-module (gnu packages maths) |
37 | #:use-module (gnu packages multiprecision) |
38 | #:use-module (gnu packages ocaml) |
39 | #:use-module (gnu packages perl) |
40 | #:use-module (gnu packages pkg-config) |
41 | #:use-module (gnu packages protobuf) |
42 | #:use-module (gnu packages python) |
43 | #:use-module (gnu packages tex) |
44 | #:use-module (gnu packages texinfo) |
45 | #:use-module (more packages smt)) |
46 | |
47 | (define-public ocaml-fix |
48 | (package |
49 | (inherit ocaml) |
50 | (version "4.05.0") |
51 | (source (origin |
52 | (method url-fetch) |
53 | (uri (string-append |
54 | "http://caml.inria.fr/pub/distrib/ocaml-" |
55 | (version-major+minor version) |
56 | "/ocaml-" version ".tar.xz")) |
57 | (sha256 |
58 | (base32 |
59 | "1y9fw1ci9pwnbbrr9nwr8cq8vypcxwdf4akvxard3mxl2jx2g984")))) |
60 | (arguments |
61 | `(#:modules ((guix build gnu-build-system) |
62 | (guix build utils) |
63 | (web server)) |
64 | #:phases |
65 | (modify-phases %standard-phases |
66 | (add-after 'unpack 'patch-/bin/sh-references |
67 | (lambda* (#:key inputs #:allow-other-keys) |
68 | (let* ((sh (string-append (assoc-ref inputs "bash") |
69 | "/bin/sh")) |
70 | (quoted-sh (string-append "\"" sh "\""))) |
71 | (with-fluids ((%default-port-encoding #f)) |
72 | (for-each |
73 | (lambda (file) |
74 | (substitute* file |
75 | (("\"/bin/sh\"") |
76 | (begin |
77 | (format (current-error-port) "\ |
78 | patch-/bin/sh-references: ~a: changing `\"/bin/sh\"' to `~a'~%" |
79 | file quoted-sh) |
80 | quoted-sh)))) |
81 | (find-files "." "\\.ml$")) |
82 | #t)))) |
83 | (replace 'configure |
84 | (lambda* (#:key outputs #:allow-other-keys) |
85 | (let* ((out (assoc-ref outputs "out")) |
86 | (mandir (string-append out "/share/man"))) |
87 | ;; Custom configure script doesn't recognize |
88 | ;; --prefix=<PREFIX> syntax (with equals sign). |
89 | (zero? (system* "./configure" |
90 | "--prefix" out |
91 | "--mandir" mandir))))) |
92 | (replace 'build |
93 | (lambda _ |
94 | (zero? (system* "make" "-j1" ;; fails to build otherwise |
95 | "world.opt")))) |
96 | (delete 'check) |
97 | (add-after 'install 'check |
98 | (lambda _ |
99 | (with-directory-excursion "testsuite" |
100 | (zero? (system* "make" "all")))))))))) |
101 | |
102 | (define-public proof-general2 |
103 | (package |
104 | (name "proof-general2") |
105 | (version "4.4") |
106 | (source (origin |
107 | (method url-fetch) |
108 | (uri (string-append |
109 | "https://github.com/ProofGeneral/PG/archive/v" |
110 | version ".tar.gz")) |
111 | (file-name (string-append name "-" version ".tar.gz")) |
112 | (sha256 |
113 | (base32 |
114 | "0zif2fv6mm4pv75nh10q3p37n293495rvx470bx7ma382zc3d8hv")))) |
115 | (build-system gnu-build-system) |
116 | (native-inputs |
117 | `(("which" ,which) |
118 | ("emacs" ,emacs-minimal) |
119 | ("texinfo" ,texinfo))) |
120 | (inputs |
121 | `(("host-emacs" ,emacs) |
122 | ("perl" ,perl) |
123 | ("coq" ,coq))) |
124 | (arguments |
125 | `(#:tests? #f ; no check target |
126 | #:make-flags (list (string-append "PREFIX=" %output) |
127 | (string-append "DEST_PREFIX=" %output) |
128 | "-j1") |
129 | #:modules ((guix build gnu-build-system) |
130 | (guix build utils) |
131 | (guix build emacs-utils)) |
132 | #:imported-modules (,@%gnu-build-system-modules |
133 | (guix build emacs-utils)) |
134 | #:phases |
135 | (modify-phases %standard-phases |
136 | (delete 'configure) |
137 | (add-after 'unpack 'disable-byte-compile-error-on-warn |
138 | (lambda _ |
139 | (substitute* "Makefile" |
140 | (("\\(setq byte-compile-error-on-warn t\\)") |
141 | "(setq byte-compile-error-on-warn nil)")) |
142 | #t)) |
143 | (add-after 'unpack 'patch-hardcoded-paths |
144 | (lambda* (#:key inputs outputs #:allow-other-keys) |
145 | (let ((out (assoc-ref outputs "out")) |
146 | (coq (assoc-ref inputs "coq")) |
147 | (emacs (assoc-ref inputs "host-emacs"))) |
148 | (define (coq-prog name) |
149 | (string-append coq "/bin/" name)) |
150 | (substitute* "pgshell/pgshell.el" |
151 | (("/bin/sh") (which "sh"))) |
152 | ;(emacs-substitute-variables "coq/coq.el" |
153 | ; ("coq-prog-name" (coq-prog "coqtop")) |
154 | ; ("coq-compiler" (coq-prog "coqc")) |
155 | ; ("coq-dependency-analyzer" (coq-prog "coqdep"))) |
156 | (substitute* "Makefile" |
157 | (("/sbin/install-info") "install-info")) |
158 | (substitute* "bin/proofgeneral" |
159 | (("^PGHOMEDEFAULT=.*" all) |
160 | (string-append all |
161 | "PGHOME=$PGHOMEDEFAULT\n" |
162 | "EMACS=" emacs "/bin/emacs"))) |
163 | #t)))))) |
164 | ;(add-after 'unpack 'clean |
165 | ; (lambda _ |
166 | ; ;; Delete the pre-compiled elc files for Emacs 23. |
167 | ; (zero? (system* "make" "clean")))) |
168 | ;(add-after 'install 'install-doc |
169 | ; (lambda* (#:key make-flags #:allow-other-keys) |
170 | ; ;; XXX FIXME avoid building/installing pdf files, |
171 | ; ;; due to unresolved errors building them. |
172 | ; (substitute* "Makefile" |
173 | ; ((" [^ ]*\\.pdf") "")) |
174 | ; (zero? (apply system* "make" "install-doc" |
175 | ; make-flags))))))) |
176 | (home-page "http://proofgeneral.inf.ed.ac.uk/") |
177 | (synopsis "Generic front-end for proof assistants based on Emacs") |
178 | (description |
179 | "Proof General is a major mode to turn Emacs into an interactive proof |
180 | assistant to write formal mathematical proofs using a variety of theorem |
181 | provers.") |
182 | (license license:gpl2+))) |
183 | |
184 | (define-public ocaml-build |
185 | (package |
186 | (name "ocaml-build") |
187 | (version "0.11.0") |
188 | (source (origin |
189 | (method url-fetch) |
190 | (uri (string-append "https://github.com/ocaml/ocamlbuild/archive/" |
191 | version ".tar.gz")) |
192 | (file-name (string-append name "-" version ".tar.gz")) |
193 | (sha256 |
194 | (base32 |
195 | "1vh30731gv1brr4ljfzd6m5lni44ifyb1w8hwir81ff9874fs5qp")))) |
196 | (build-system gnu-build-system) |
197 | (arguments |
198 | `(#:test-target "test" |
199 | #:tests? #f; FIXME: tests fail to find Findlib |
200 | #:make-flags |
201 | (list (string-append "OCAMLBUILD_PREFIX=" (assoc-ref %outputs "out")) |
202 | (string-append "OCAMLBUILD_BINDIR=" (assoc-ref %outputs "out") "/bin") |
203 | (string-append "OCAMLBUILD_LIBDIR=" (assoc-ref %outputs "out") "/lib") |
204 | (string-append "OCAMLBUILD_MANDIR=" (assoc-ref %outputs "out") "/share/man")) |
205 | #:phases |
206 | (modify-phases %standard-phases |
207 | (delete 'configure) |
208 | ;(replace 'configure |
209 | ; (lambda* (#:key outputs #:allow-other-keys) |
210 | ; (let ((out (assoc-ref %outputs "out"))) |
211 | ; (zero? (system* "make" "-f" "configure.make" "all"))))) |
212 | (add-before 'build 'findlib-environment |
213 | (lambda* (#:key outputs #:allow-other-keys) |
214 | (let* ((out (assoc-ref outputs "out"))) |
215 | (setenv "OCAMLFIND_DESTDIR" (string-append out "/lib/ocaml/site-lib")) |
216 | (setenv "OCAMLFIND_LDCONF" "ignore") |
217 | #t)))))) |
218 | (native-inputs |
219 | `(("ocaml" ,ocaml-fix))) |
220 | (home-page "") |
221 | (synopsis "") |
222 | (description "") |
223 | (license license:lgpl2.1+))) |
224 | |
225 | (define-public camlp4-fix |
226 | (package |
227 | (inherit camlp4) |
228 | (name "camlp4") |
229 | (version "4.05+2") |
230 | (source (origin |
231 | (method url-fetch) |
232 | (uri (string-append "https://github.com/ocaml/camlp4/archive/" |
233 | version ".tar.gz")) |
234 | (file-name (string-append name "-" version ".tar.gz")) |
235 | (sha256 |
236 | (base32 |
237 | "0dd9scf50y0928syvxflljwry2dzm35n903fgpfdkpcn907jq96v")))) |
238 | (inputs `(("ocaml" ,ocaml-fix))) |
239 | (native-inputs |
240 | `(("ocaml" ,ocaml-fix) |
241 | ("which" ,which) |
242 | ("build" ,ocaml-build))))) |
243 | |
244 | (define-public ocaml-findlib-fix |
245 | (package |
246 | (inherit ocaml-findlib) |
247 | (native-inputs |
248 | `(("camlp4" ,camlp4-fix) |
249 | ("ocaml" ,ocaml-fix) |
250 | ("m4" ,m4))))) |
251 | |
252 | (define-public camlp5-fix |
253 | (package |
254 | (inherit camlp5) |
255 | (name "camlp5") |
256 | (version "7.03") |
257 | (source (origin |
258 | (method url-fetch) |
259 | (uri (string-append "https://github.com/camlp5/camlp5/archive/rel" |
260 | (string-delete #\. version) ".tar.gz")) |
261 | (sha256 |
262 | (base32 |
263 | "06pj7l75r586gngam7nspd1a13ay7cj2bjh035z64w4fgaahlgf1")))) |
264 | (inputs |
265 | `(("ocaml" ,ocaml-fix))))) |
266 | |
267 | (define-public lablgtk-fix |
268 | (package |
269 | (inherit lablgtk) |
270 | (native-inputs |
271 | `(("ocaml" ,ocaml-fix) |
272 | ("build" ,ocaml-build) |
273 | ("camlp4" ,camlp4-fix) |
274 | ("findlib" ,ocaml-findlib-fix) |
275 | ("pkg-config" ,pkg-config))))) |
276 | |
277 | (define-public ocaml-menhir-fix |
278 | (package |
279 | (inherit ocaml-menhir) |
280 | (version "20170607") |
281 | (name "ocaml-menhir-fix") |
282 | (source (origin |
283 | (method url-fetch) |
284 | (uri (string-append |
285 | "http://gallium.inria.fr/~fpottier/menhir/" |
286 | "menhir-" version ".tar.gz")) |
287 | (sha256 |
288 | (base32 |
289 | "0qffci9qxgfabzyalx851q994yykl4n9ylr4vbplsm6is1padjh0")))) |
290 | (inputs |
291 | `(("ocaml" ,ocaml-fix) |
292 | ("ocamlbuild" ,ocaml-build))))) |
293 | |
294 | (define-public coq-fix |
295 | (package |
296 | (inherit coq) |
297 | (native-inputs |
298 | `(("ocamlbuild" ,ocaml-build) |
299 | ("hevea" ,hevea) |
300 | ("texlive" ,texlive))) |
301 | (inputs |
302 | `(("lablgtk" ,lablgtk-fix) |
303 | ("python" ,python-2) |
304 | ("camlp5" ,camlp5-fix))) |
305 | (arguments |
306 | `(#:ocaml ,ocaml-fix |
307 | #:findlib ,ocaml-findlib-fix |
308 | ,@(package-arguments coq))))) |
309 | |
310 | (define-public compcert |
311 | (package |
312 | (name "compcert") |
313 | (version "3.0.1") |
314 | (source (origin |
315 | (method url-fetch) |
316 | (uri (string-append "http://compcert.inria.fr/release/compcert-" |
317 | version ".tgz")) |
318 | (sha256 |
319 | (base32 |
320 | "0dgrj26dzdy4n3s9b5hwc6lm54vans1v4qx9hdp1q8w1qqcdriq9")))) |
321 | (build-system gnu-build-system) |
322 | (arguments |
323 | `(#:phases |
324 | (modify-phases %standard-phases |
325 | (replace 'configure |
326 | (lambda* (#:key outputs #:allow-other-keys) |
327 | (zero? (system* "./configure" "x86_64-linux" "-prefix" |
328 | (assoc-ref outputs "out")))))) |
329 | #:tests? #f)) |
330 | (native-inputs |
331 | `(("ocaml" ,ocaml-fix) |
332 | ("coq" ,coq-fix))) |
333 | (inputs |
334 | `(("menhir" ,ocaml-menhir-fix))) |
335 | (home-page "http://compcert.inria.fr") |
336 | (synopsis "Certified C compiler") |
337 | (description "CompCert is a certified (with coq) C compiler. Warning: this |
338 | package is not free software!") |
339 | ;; actually the "INRIA Non-Commercial License Agreement" |
340 | ;; a non-free license. |
341 | (license (license:non-copyleft "file:///LICENSE")))) |
342 | |
343 | (define-public cubicle |
344 | (package |
345 | (name "cubicle") |
346 | (version "1.1.1") |
347 | (source (origin |
348 | (method url-fetch) |
349 | (uri (string-append "http://cubicle.lri.fr/cubicle-" |
350 | version ".tar.gz")) |
351 | (sha256 |
352 | (base32 |
353 | "1sny9c4fm14k014pk62ibpwbrjjirkx8xmhs9jg7q1hk7y7x3q2h")))) |
354 | (build-system gnu-build-system) |
355 | (native-inputs |
356 | `(("ocaml" ,ocaml) |
357 | ("which" ,which))) |
358 | (propagated-inputs |
359 | `(("z3" ,z3))) |
360 | (arguments |
361 | `(#:configure-flags (list "--with-z3") |
362 | #:tests? #f |
363 | #:phases |
364 | (modify-phases %standard-phases |
365 | (add-before 'configure 'configure-for-release |
366 | (lambda _ |
367 | (substitute* "Makefile.in" |
368 | (("SVNREV=") "#SVNREV=")))) |
369 | (add-before 'configure 'fix-/bin/sh |
370 | (lambda _ |
371 | (substitute* "configure" |
372 | (("/bin/sh") (which "sh"))))) |
373 | (add-before 'configure 'fix-smt-z3wrapper.ml |
374 | (lambda _ |
375 | (substitute* "Makefile.in" |
376 | (("\\\\n") ""))))))) |
377 | (home-page "http://cubicle.lri.fr/") |
378 | (synopsis "Model checker for array-based systems") |
379 | (description "Cubicle is an open source model checker for verifying safety |
380 | properties of array-based systems. This is a syntactically restricted class of |
381 | parametrized transition systems with states represented as arrays indexed by an |
382 | arbitrary number of processes. Cache coherence protocols and mutual exclusion |
383 | algorithms are typical examples of such systems.") |
384 | (license license:asl2.0))) |
385 | |
386 | (define-public ocaml-c2newspeak |
387 | (package |
388 | (name "ocaml-c2newspeak") |
389 | (version "1") |
390 | (source (origin |
391 | (method git-fetch) |
392 | (uri (git-reference |
393 | (url "https://github.com/airbus-seclab/c2newspeak") |
394 | (commit "6f7adf13fefb7f8d4dc668b8290226e3c6a30063"))) |
395 | (file-name (string-append name "-" version)) |
396 | (sha256 |
397 | (base32 |
398 | "1apaz0b84865xfba0mxbskbnaq6llqsn3qhy8b0sssbdxzw5w1x4")))) |
399 | (build-system ocaml-build-system) |
400 | (arguments |
401 | `(#:test-target "check" |
402 | #:tests? #f |
403 | #:phases |
404 | (modify-phases %standard-phases |
405 | (delete 'configure) |
406 | (add-before 'install 'modify-installed-file-list |
407 | (lambda _ |
408 | (substitute* "src/newspeak.Makefile" |
409 | (("c2newspeak/typedC.cmi") |
410 | "c2newspeak/typedC.cmi c2newspeak/typedC.cmx c2newspeak/typedC.o")))) |
411 | (add-after 'install 'install-bin |
412 | (lambda* (#:key outputs #:allow-other-keys) |
413 | (install-file "bin/c2newspeak" (string-append (assoc-ref outputs "out") "/bin"))))))) |
414 | (home-page "https://github.com/airbus-seclab/c2newspeak") |
415 | (synopsis "") |
416 | (description "") |
417 | (license license:lgpl2.1+))) |
418 | |
419 | (define-public ocaml-bincat |
420 | (package |
421 | (name "ocaml-bincat") |
422 | (version "0.6") |
423 | (source (origin |
424 | (method url-fetch) |
425 | (uri (string-append "https://github.com/airbus-seclab/bincat/archive/v" |
426 | version ".tar.gz")) |
427 | (file-name (string-append name "-" version ".tar.gz")) |
428 | (sha256 |
429 | (base32 |
430 | "1762wrvf7fv16kxfvpblj4b0pwbwny1b39263q4jnqni12474djl")))) |
431 | (build-system ocaml-build-system) |
432 | (arguments |
433 | `(#:tests? #f; some failures for unknown reasons |
434 | #:make-flags |
435 | (list (string-append "PREFIX=" (assoc-ref %outputs "out")) |
436 | "LDCONFIG=true" |
437 | (string-append "CFLAGS+=-I " (assoc-ref %build-inputs "ocaml") |
438 | "/lib/ocaml")) |
439 | #:phases |
440 | (modify-phases %standard-phases |
441 | (delete 'configure) |
442 | (add-before 'build 'python-path |
443 | (lambda _ |
444 | (setenv "PYTHONPATH" (string-append (getenv "PYTHONPATH") |
445 | ":../python")))) |
446 | (add-before 'build 'fix-makefile |
447 | (lambda _ |
448 | (substitute* "ocaml/src/Makefile" |
449 | (("GITVERSION:=.*") "GITVERSION:=0.6\n") |
450 | ;; typedC library is embedded in newspeak.cmxa |
451 | (("typedC.cmx") "")))) |
452 | (add-before 'check 'fix-test |
453 | (lambda _ |
454 | (setenv "PATH" (string-append (getenv "PATH") ":" (getcwd) "/ocaml/src")) |
455 | (chmod "test/eggloader_x86" #o755)))))) |
456 | (inputs |
457 | `(("c2newspeak" ,ocaml-c2newspeak) |
458 | ("zarith" ,ocaml-zarith) |
459 | ("menhir" ,ocaml-menhir) |
460 | ("ocamlgraph" ,ocaml-graph) |
461 | ("gmp" ,gmp))) |
462 | (native-inputs |
463 | `(("python" ,python-2) |
464 | ("pytest" ,python2-pytest) |
465 | ("sphinx" ,python2-sphinx) |
466 | ("nasm" ,nasm))) |
467 | (home-page "https://github.com/airbus-seclab/bincat") |
468 | (synopsis "") |
469 | (description "") |
470 | (license license:lgpl2.1+))) |
471 | |
472 |