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