guix-more/more/packages/ocaml.scm

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