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 autotools)
30
  #:use-module (gnu packages base)
31
  #:use-module (gnu packages bison)
32
  #:use-module (gnu packages boost)
33
  #:use-module (gnu packages check)
34
  #:use-module (gnu packages coq)
35
  #:use-module (gnu packages emacs)
36
  #:use-module (gnu packages flex)
37
  #:use-module (gnu packages llvm)
38
  #:use-module (gnu packages m4)
39
  #:use-module (gnu packages maths)
40
  #:use-module (gnu packages multiprecision)
41
  #:use-module (gnu packages ocaml)
42
  #:use-module (gnu packages perl)
43
  #:use-module (gnu packages pkg-config)
44
  #:use-module (gnu packages protobuf)
45
  #:use-module (gnu packages python)
46
  #:use-module (gnu packages python-xyz)
47
  #:use-module (gnu packages tex)
48
  #:use-module (gnu packages texinfo)
49
  #:use-module (more packages smt)
50
  #:use-module (ice-9 match))
51
52
(define (ocaml-forge-uri name version file-number)
53
  (string-append "https://forge.ocamlcore.org/frs/download.php/"
54
                 (number->string file-number) "/" name "-" version
55
                 ".tar.gz"))
56
57
(define-public proof-general2
58
  (package
59
    (name "proof-general2")
60
    (version "4.4")
61
    (source (origin
62
              (method url-fetch)
63
              (uri (string-append
64
                    "https://github.com/ProofGeneral/PG/archive/v"
65
                    version ".tar.gz"))
66
              (file-name (string-append name "-" version ".tar.gz"))
67
              (sha256
68
               (base32
69
                "0zif2fv6mm4pv75nh10q3p37n293495rvx470bx7ma382zc3d8hv"))))
70
    (build-system gnu-build-system)
71
    (native-inputs
72
     `(("which" ,which)
73
       ("emacs" ,emacs-minimal)
74
       ("texinfo" ,texinfo)))
75
    (inputs
76
     `(("host-emacs" ,emacs)
77
       ("perl" ,perl)
78
       ("coq" ,coq)))
79
    (arguments
80
     `(#:tests? #f  ; no check target
81
       #:make-flags (list (string-append "PREFIX=" %output)
82
                          (string-append "DEST_PREFIX=" %output)
83
                          "-j1")
84
       #:modules ((guix build gnu-build-system)
85
                  (guix build utils)
86
                  (guix build emacs-utils))
87
       #:imported-modules (,@%gnu-build-system-modules
88
                           (guix build emacs-utils))
89
       #:phases
90
       (modify-phases %standard-phases
91
         (delete 'configure)
92
         (add-after 'unpack 'disable-byte-compile-error-on-warn
93
                    (lambda _
94
                      (substitute* "Makefile"
95
                        (("\\(setq byte-compile-error-on-warn t\\)")
96
                         "(setq byte-compile-error-on-warn nil)"))
97
                      #t))
98
         (add-after 'unpack 'patch-hardcoded-paths
99
                    (lambda* (#:key inputs outputs #:allow-other-keys)
100
                      (let ((out   (assoc-ref outputs "out"))
101
                            (coq   (assoc-ref inputs "coq"))
102
                            (emacs (assoc-ref inputs "host-emacs")))
103
                        (define (coq-prog name)
104
                          (string-append coq "/bin/" name))
105
                        (substitute* "pgshell/pgshell.el"
106
                          (("/bin/sh") (which "sh")))
107
                        ;(emacs-substitute-variables "coq/coq.el"
108
                        ;  ("coq-prog-name"           (coq-prog "coqtop"))
109
                        ;  ("coq-compiler"            (coq-prog "coqc"))
110
                        ;  ("coq-dependency-analyzer" (coq-prog "coqdep")))
111
                        (substitute* "Makefile"
112
                          (("/sbin/install-info") "install-info"))
113
                        (substitute* "bin/proofgeneral"
114
                          (("^PGHOMEDEFAULT=.*" all)
115
                           (string-append all
116
                                          "PGHOME=$PGHOMEDEFAULT\n"
117
                                          "EMACS=" emacs "/bin/emacs")))
118
                        #t))))))
119
         ;(add-after 'unpack 'clean
120
         ;           (lambda _
121
         ;             ;; Delete the pre-compiled elc files for Emacs 23.
122
         ;             (zero? (system* "make" "clean"))))
123
         ;(add-after 'install 'install-doc
124
         ;           (lambda* (#:key make-flags #:allow-other-keys)
125
         ;             ;; XXX FIXME avoid building/installing pdf files,
126
         ;             ;; due to unresolved errors building them.
127
         ;             (substitute* "Makefile"
128
         ;               ((" [^ ]*\\.pdf") ""))
129
         ;             (zero? (apply system* "make" "install-doc"
130
         ;                           make-flags)))))))
131
    (home-page "http://proofgeneral.inf.ed.ac.uk/")
132
    (synopsis "Generic front-end for proof assistants based on Emacs")
133
    (description
134
     "Proof General is a major mode to turn Emacs into an interactive proof
135
assistant to write formal mathematical proofs using a variety of theorem
136
provers.")
137
    (license license:gpl2+)))
138
139
(define-public ocaml4.02-camlp5
140
  (package
141
    (inherit camlp5)
142
    (inputs
143
     `(("ocaml" ,ocaml-4.02)))))
144
145
(define-public coq-8.6
146
  (package
147
    (inherit coq)
148
    (name "coq")
149
    (version "8.6.1")
150
    (source (origin
151
              (method url-fetch)
152
              (uri (string-append "https://github.com/coq/coq/archive/V"
153
                                  version ".tar.gz"))
154
              (file-name (string-append name "-" version ".tar.gz"))
155
              (sha256
156
               (base32
157
                "02nm5sn79hrb9fdmkhyclk80jydadf4jcafmr3idwr5h4z56qbms"))))
158
    (arguments
159
     `(#:ocaml ,ocaml-4.02
160
       #:findlib ,ocaml4.02-findlib
161
       #:phases
162
       (modify-phases %standard-phases
163
         (replace 'configure
164
           (lambda* (#:key outputs #:allow-other-keys)
165
             (let* ((out (assoc-ref outputs "out"))
166
                    (mandir (string-append out "/share/man"))
167
                    (browser "icecat -remote \"OpenURL(%s,new-tab)\""))
168
               (invoke "./configure"
169
                       "-prefix" out
170
                       "-mandir" mandir
171
                       "-browser" browser
172
                       "-coqide" "opt"))
173
             #t))
174
         (replace 'build
175
           (lambda* (#:key inputs #:allow-other-keys)
176
             (invoke "make" "-j" (number->string
177
                                  (parallel-job-count))
178
                     "world")
179
             #t))
180
         (delete 'check)
181
         (add-after 'install 'check
182
           (lambda _
183
             (with-directory-excursion "test-suite"
184
               (invoke "make"))
185
             #t)))))
186
    (native-inputs '())
187
    (inputs
188
     `(("lablgtk" ,ocaml4.02-lablgtk)
189
       ("python" ,python-2)
190
       ("camlp5" ,ocaml4.02-camlp5)))))
191
192
(define-public coq-8.7
193
  (package
194
    (inherit coq)
195
    (name "coq")
196
    (version "8.7.2")
197
    (source (origin
198
              (method url-fetch)
199
              (uri (string-append "https://github.com/coq/coq/archive/V"
200
                                  version ".tar.gz"))
201
              (file-name (string-append name "-" version ".tar.gz"))
202
              (sha256
203
               (base32
204
                "1lkqvs7ayzv5kkg26y837pg0d6r2b5hbjxl71ba93f39kybw69gg"))))
205
    (arguments
206
     `(#:phases
207
       (modify-phases %standard-phases
208
         (replace 'configure
209
           (lambda* (#:key outputs #:allow-other-keys)
210
             (let* ((out (assoc-ref outputs "out"))
211
                    (mandir (string-append out "/share/man"))
212
                    (browser "icecat -remote \"OpenURL(%s,new-tab)\""))
213
               (invoke "./configure"
214
                       "-prefix" out
215
                       "-mandir" mandir
216
                       "-browser" browser
217
                       "-coqide" "opt"))
218
             #t))
219
         (replace 'build
220
           (lambda* (#:key inputs #:allow-other-keys)
221
             (substitute* "ide/ideutils.ml"
222
               (("Bytes.unsafe_to_string read_string") "read_string"))
223
             (invoke "make" "-j" (number->string
224
                                  (parallel-job-count))
225
                     (string-append
226
                       "USERFLAGS=-I "
227
                       (assoc-ref inputs "ocaml-num")
228
                       "/lib/ocaml/site-lib")
229
                     "world")
230
             #t))
231
         (delete 'check)
232
         (add-after 'install 'check
233
           (lambda _
234
             (with-directory-excursion "test-suite"
235
               ;; These two tests fail.
236
               ;; This one fails because the output is not formatted as expected.
237
               (delete-file-recursively "coq-makefile/timing")
238
               ;; This one fails because we didn't build coqtop.byte.
239
               (delete-file-recursively "coq-makefile/findlib-package")
240
               (invoke "make"))
241
             #t)))))))
242
243
(define-public coq-8.9
244
  (package
245
    (inherit coq)
246
    (name "coq")
247
    (version "8.9.0")
248
    (source (origin
249
              (method url-fetch)
250
              (uri (string-append "https://github.com/coq/coq/archive/V"
251
                                  version ".tar.gz"))
252
              (file-name (string-append name "-" version ".tar.gz"))
253
              (sha256
254
               (base32
255
                "1w0g0w2ps3v17g0nkf9zrnlhzrfvvzxyp248kgqnvybrinyf5mlb"))))
256
    (native-inputs
257
     `(("ocaml-ounit" ,ocaml-ounit)
258
       ,@(package-native-inputs coq)))))
259
260
(define-public coq-bignums-8.7
261
  (package
262
    (inherit coq-bignums)
263
    (name "coq-bignums")
264
    (version "8.7.0")
265
    (source (origin
266
              (method url-fetch)
267
              (uri (string-append "https://github.com/coq/bignums/archive/V"
268
                                  version ".tar.gz"))
269
              (file-name (string-append name "-" version ".tar.gz"))
270
              (sha256
271
               (base32
272
                "03iw9jiwq9jx45gsvp315y3lxr8m9ksppmcjvxs5c23qnky6zqjx"))))
273
    (native-inputs
274
     `(("ocaml" ,ocaml)
275
       ("coq-8.7" ,coq-8.7)))
276
    (inputs
277
     `(("camlp5" ,camlp5)))))
278
279
(define-public ppsimpl
280
  (package
281
    (name "ppsimpl")
282
    (version "8.7")
283
    (source (origin
284
              (method git-fetch)
285
              (uri (git-reference
286
                     (url "https://scm.gforge.inria.fr/anonscm/git/ppsimpl/ppsimpl.git")
287
                     (commit "86255a47568df58767d1d8e0b9e2da31cf73a5fc")))
288
              (file-name (string-append name "-" version))
289
              (sha256
290
               (base32
291
                "0h509w43j2wd2pyx04k3xfd0bsbmqscwqvhf8whzc3cxzl4j6vvq"))))
292
              ;(uri "https://gforge.inria.fr/frs/download.php/file/37615/ppsimpl-09-07-2018.tar.gz")
293
              ;(sha256
294
              ; (base32
295
              ;  "010zgskc1wd5v6wmmyxaapvwxjlgbdqqiks2dvf6llx03b07ak59"))))
296
    (build-system gnu-build-system)
297
    (arguments
298
     `(#:test-target "test"
299
       #:configure-flags
300
       (list "-R" (string-append (assoc-ref %build-inputs "compcert") "/lib/coq/user-contrib/compcert") "compcert")
301
       #:make-flags (list "COQC=coqc -R src PP -I src"
302
                          (string-append
303
                            "COQLIBINSTALL="
304
                            (assoc-ref %outputs "out")
305
                            "/lib/coq/user-contrib"))))
306
    (inputs
307
     `(("coq-bignums-8.7" ,coq-bignums-8.7)
308
       ("compcert" ,compcert)))
309
    (native-inputs
310
     `(("coq-8.7" ,coq-8.7)
311
       ("ocaml" ,ocaml)
312
       ("ocaml-findlib" ,ocaml-findlib)
313
       ("camlp4" ,camlp4)
314
       ("camlp5" ,camlp5)
315
       ("which" ,which)))
316
    (home-page "")
317
    (synopsis "")
318
    (description "")
319
    ;; No declared license -> all rights reserved
320
    (license #f)))
321
322
(define-public compcert
323
  (package
324
    (name "compcert")
325
    (version "3.3")
326
    (source (origin
327
              (method url-fetch)
328
              (uri (string-append "http://compcert.inria.fr/release/compcert-"
329
                                  version ".tgz"))
330
              (sha256
331
               (base32
332
                "16xrqcwak1v1fk5ndx6jf1yvxv3adsr7p7z34gfm2mpggxnq0xwn"))))
333
    (build-system gnu-build-system)
334
    (arguments
335
     `(#:phases
336
       (modify-phases %standard-phases
337
         (replace 'configure
338
           (lambda* (#:key outputs #:allow-other-keys)
339
             (let ((system ,(match (or (%current-target-system) (%current-system))
340
                              ("x86_64-linux" "x86_64-linux")
341
                              ("i686-linux" "x86_32-linux")
342
                              ("armhf-linux" "arm-linux"))))
343
               (format #t "Building for ~a~%" system)
344
               (invoke "./configure" system "-prefix"
345
                       (assoc-ref outputs "out")))
346
             #t))
347
         (add-after 'install 'install-lib
348
           (lambda* (#:key outputs #:allow-other-keys)
349
             (for-each
350
               (lambda (file)
351
                 (install-file
352
                   file
353
                   (string-append
354
                     (assoc-ref outputs "out")
355
                     "/lib/coq/user-contrib/compcert/" (dirname file))))
356
               (find-files "." ".*.vo$"))
357
             #t)))
358
       #:tests? #f))
359
    (native-inputs
360
     `(("ocaml" ,ocaml)
361
       ("coq" ,coq-8.7)))
362
    (inputs
363
     `(("menhir" ,ocaml-menhir)))
364
    (home-page "http://compcert.inria.fr")
365
    (synopsis "Certified C compiler")
366
    (description "CompCert is a certified (with coq) C compiler.  Warning: this
367
package is not free software!")
368
    ;; actually the "INRIA Non-Commercial License Agreement"
369
    ;; a non-free license.
370
    (license (license:non-copyleft "file:///LICENSE"))))
371
372
(define-public ocaml-c2newspeak
373
  (package
374
    (name "ocaml-c2newspeak")
375
    (version "1")
376
    (source (origin
377
              (method git-fetch)
378
              (uri (git-reference
379
                     (url "https://github.com/airbus-seclab/c2newspeak")
380
                     (commit "c97fd380111a49fa7baeb9e49c45238fca627492")))
381
              (file-name (string-append name "-" version))
382
              (sha256
383
               (base32
384
                "0fxh868s5jraq61mnig9ilhyjzsq4iw32f20zh3982naanp4p8r6"))))
385
    (build-system ocaml-build-system)
386
    (arguments
387
     `(#:test-target "check"
388
       #:tests? #f
389
       #:phases
390
       (modify-phases %standard-phases
391
         (delete 'configure)
392
         (add-after 'install 'install-bin
393
           (lambda* (#:key outputs #:allow-other-keys)
394
             (install-file "bin/c2newspeak" (string-append (assoc-ref outputs "out") "/bin")))))))
395
    (home-page "https://github.com/airbus-seclab/c2newspeak")
396
    (synopsis "")
397
    (description "")
398
    (license license:lgpl2.1+)))
399
400
(define-public ocaml-bincat
401
  (package
402
    (name "ocaml-bincat")
403
    (version "0.8.1")
404
    (source (origin
405
              (method url-fetch)
406
              (uri (string-append "https://github.com/airbus-seclab/bincat/archive/v"
407
                                  version ".tar.gz"))
408
              (file-name (string-append name "-" version ".tar.gz"))
409
              (sha256
410
               (base32
411
                "1ncwm1h428x1bs4sq7ql1isrkhw0angglsa9hnsvhhw2i1jsdk7j"))))
412
    (build-system ocaml-build-system)
413
    (arguments
414
     `(#:tests? #f; disabled for now
415
       #:validate-runpath? #f; disabled for now
416
       #:make-flags
417
       (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
418
             "LDCONFIG=true"
419
             (string-append "CFLAGS+=-I " (assoc-ref %build-inputs "ocaml")
420
                            "/lib/ocaml"))
421
       #:phases
422
       (modify-phases %standard-phases
423
         (delete 'configure)
424
         (add-before 'build 'python-path
425
           (lambda* (#:key outputs #:allow-other-keys)
426
             (setenv "PYTHONPATH" (string-append (getenv "PYTHONPATH")
427
                                                 ":../python:"
428
                                                 (assoc-ref outputs "out")
429
                                                 "/lib/python2.7/site-packages/"))
430
             #t))
431
         (add-before 'build 'fix-makefiles
432
           (lambda _
433
             (substitute* "ocaml/src/Makefile"
434
               (("GITVERSION:=.*") "GITVERSION:=0.8.1\n"))
435
             (substitute* "python/Makefile"
436
               (("./setup.py install") "./setup.py install --prefix=$(PREFIX)"))
437
             #t))
438
         (add-before 'check 'fix-test
439
           (lambda _
440
             (setenv "PATH" (string-append (getenv "PATH") ":" (getcwd) "/ocaml/src"))
441
             ;; Remove tests that require an armv8 compiler
442
             (substitute* "test/Makefile"
443
               (("eggloader_armv8 eggloader_armv7 eggloader_armv7thumb") ""))
444
             (chmod "test/eggloader_x86" #o755)
445
             #t))
446
         (add-before 'install 'install-python-dir
447
           (lambda* (#:key outputs #:allow-other-keys)
448
             (mkdir-p (string-append (assoc-ref outputs "out")
449
                                     "/lib/python2.7/site-packages/")))))))
450
    (inputs
451
     `(("c2newspeak" ,ocaml-c2newspeak)
452
       ("zarith" ,ocaml-zarith)
453
       ("menhir" ,ocaml-menhir)
454
       ("ocamlgraph" ,ocaml-graph)
455
       ("ocaml-cppo" ,ocaml-cppo)
456
       ("ocaml-ppx-tools" ,ocaml-ppx-tools)
457
       ("gmp" ,gmp)))
458
    (native-inputs
459
     `(("python" ,python-2)
460
       ("pytest" ,python2-pytest)
461
       ("sphinx" ,python2-sphinx)
462
       ("nasm" ,nasm)))
463
    (home-page "https://github.com/airbus-seclab/bincat")
464
    (synopsis "")
465
    (description "")
466
    (license license:lgpl2.1+)))
467
468
(define-public ocaml-ocplib-simplex
469
  (package
470
    (name "ocaml-ocplib-simplex")
471
    (version "0.4")
472
    (source (origin
473
              (method url-fetch)
474
              (uri (string-append "https://github.com/OCamlPro-Iguernlala/"
475
                                  "ocplib-simplex/archive/v" version ".tar.gz"))
476
              (sha256
477
               (base32
478
                "0y6q4bgly7fisdklriww48aknqf2vg4dphr7wwnd1wh80l4anzg1"))))
479
    (build-system gnu-build-system)
480
    (arguments
481
     `(#:tests? #f; Compilation error
482
       #:phases
483
       (modify-phases %standard-phases
484
         (add-after 'unpack 'autoreconf
485
           (lambda _
486
             (invoke "autoreconf" "-fiv")
487
             #t))
488
         (add-before 'install 'mkdir
489
           (lambda* (#:key outputs #:allow-other-keys)
490
             (let* ((out (assoc-ref outputs "out"))
491
                    (lib (string-append out "/lib")))
492
               (mkdir-p lib)
493
               #t))))))
494
    (native-inputs
495
     `(("autoconf" ,autoconf)
496
       ("automake" ,automake)
497
       ("ocaml" ,ocaml)
498
       ("ocaml-findlib" ,ocaml-findlib)
499
       ("which" ,which)))
500
    (home-page "")
501
    (synopsis "")
502
    (description "")
503
    ; lgpl2.1+ with linking exception
504
    (license license:lgpl2.1+)))
505
506
(define-public frama-c
507
  (package
508
    (name "frama-c")
509
    (version "20171101")
510
    (source (origin
511
              (method url-fetch)
512
              (uri (string-append "http://frama-c.com/download/frama-c-Sulfur-"
513
                                  version ".tar.gz"))
514
              (sha256
515
               (base32
516
                "1vwjfqmm1r36gkybsy3a7m89q5zicf4rnz5vlsn9imnpjpl9gjw1"))))
517
    (build-system ocaml-build-system)
518
    (arguments
519
     `(#:tests? #f; for now
520
       #:phases
521
       (modify-phases %standard-phases
522
         (add-before 'configure 'export-shell
523
           (lambda* (#:key inputs #:allow-other-keys)
524
             (setenv "CONFIG_SHELL" (string-append (assoc-ref inputs "bash")
525
                                                   "/bin/sh")))))))
526
    (inputs
527
     `(("gmp" ,gmp)
528
       ("ocaml-graph" ,ocaml-graph)
529
       ("ocaml-zarith" ,ocaml-zarith)))
530
    (home-page "")
531
    (synopsis "")
532
    (description "")
533
    (license license:lgpl2.1+)))
534
535
(define-public coq-io
536
  (package
537
    (name "coq-io")
538
    (version "3.3.0")
539
    (source (origin
540
              (method url-fetch)
541
              (uri (string-append "https://github.com/coq-io/io/archive/"
542
                                  version ".tar.gz"))
543
              (file-name (string-append name "-" version ".tar.gz"))
544
              (sha256
545
               (base32
546
                "0k1z8kav3wz5n04g3imm1hqjimb9cf12ga5wkj1skz8l5ccjxprw"))))
547
    (build-system gnu-build-system)
548
    (arguments
549
     `(#:tests? #f; no tests
550
       #:make-flags
551
       (list (string-append "COQLIB=" (assoc-ref %outputs "out") "/lib/coq/"))
552
       #:phases
553
       (modify-phases %standard-phases
554
         (replace 'configure
555
           (lambda _
556
             (invoke "./configure.sh")
557
             #t)))))
558
    (native-inputs
559
     `(("coq" ,coq-8.6)))
560
    (home-page "")
561
    (synopsis "")
562
    (description "")
563
    (license license:lgpl2.1+)))
564