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-bignums-8.7
243
  (package
244
    (inherit coq-bignums)
245
    (name "coq-bignums")
246
    (version "8.7.0")
247
    (source (origin
248
              (method url-fetch)
249
              (uri (string-append "https://github.com/coq/bignums/archive/V"
250
                                  version ".tar.gz"))
251
              (file-name (string-append name "-" version ".tar.gz"))
252
              (sha256
253
               (base32
254
                "03iw9jiwq9jx45gsvp315y3lxr8m9ksppmcjvxs5c23qnky6zqjx"))))
255
    (native-inputs
256
     `(("ocaml" ,ocaml)
257
       ("coq-8.7" ,coq-8.7)))
258
    (inputs
259
     `(("camlp5" ,camlp5)))))
260
261
(define-public ppsimpl
262
  (package
263
    (name "ppsimpl")
264
    (version "8.7")
265
    (source (origin
266
              (method git-fetch)
267
              (uri (git-reference
268
                     (url "https://scm.gforge.inria.fr/anonscm/git/ppsimpl/ppsimpl.git")
269
                     (commit "86255a47568df58767d1d8e0b9e2da31cf73a5fc")))
270
              (file-name (string-append name "-" version))
271
              (sha256
272
               (base32
273
                "0h509w43j2wd2pyx04k3xfd0bsbmqscwqvhf8whzc3cxzl4j6vvq"))))
274
              ;(uri "https://gforge.inria.fr/frs/download.php/file/37615/ppsimpl-09-07-2018.tar.gz")
275
              ;(sha256
276
              ; (base32
277
              ;  "010zgskc1wd5v6wmmyxaapvwxjlgbdqqiks2dvf6llx03b07ak59"))))
278
    (build-system gnu-build-system)
279
    (arguments
280
     `(#:test-target "test"
281
       #:configure-flags
282
       (list "-R" (string-append (assoc-ref %build-inputs "compcert") "/lib/coq/user-contrib/compcert") "compcert")
283
       #:make-flags (list "COQC=coqc -R src PP -I src"
284
                          (string-append
285
                            "COQLIBINSTALL="
286
                            (assoc-ref %outputs "out")
287
                            "/lib/coq/user-contrib"))))
288
    (inputs
289
     `(("coq-bignums-8.7" ,coq-bignums-8.7)
290
       ("compcert" ,compcert)))
291
    (native-inputs
292
     `(("coq-8.7" ,coq-8.7)
293
       ("ocaml" ,ocaml)
294
       ("ocaml-findlib" ,ocaml-findlib)
295
       ("camlp4" ,camlp4)
296
       ("camlp5" ,camlp5)
297
       ("which" ,which)))
298
    (home-page "")
299
    (synopsis "")
300
    (description "")
301
    ;; No declared license -> all rights reserved
302
    (license #f)))
303
304
(define-public compcert
305
  (package
306
    (name "compcert")
307
    (version "3.3")
308
    (source (origin
309
              (method url-fetch)
310
              (uri (string-append "http://compcert.inria.fr/release/compcert-"
311
                                  version ".tgz"))
312
              (sha256
313
               (base32
314
                "16xrqcwak1v1fk5ndx6jf1yvxv3adsr7p7z34gfm2mpggxnq0xwn"))))
315
    (build-system gnu-build-system)
316
    (arguments
317
     `(#:phases
318
       (modify-phases %standard-phases
319
         (replace 'configure
320
           (lambda* (#:key outputs #:allow-other-keys)
321
             (let ((system ,(match (or (%current-target-system) (%current-system))
322
                              ("x86_64-linux" "x86_64-linux")
323
                              ("i686-linux" "x86_32-linux")
324
                              ("armhf-linux" "arm-linux"))))
325
               (format #t "Building for ~a~%" system)
326
               (invoke "./configure" system "-prefix"
327
                       (assoc-ref outputs "out")))
328
             #t))
329
         (add-after 'install 'install-lib
330
           (lambda* (#:key outputs #:allow-other-keys)
331
             (for-each
332
               (lambda (file)
333
                 (install-file
334
                   file
335
                   (string-append
336
                     (assoc-ref outputs "out")
337
                     "/lib/coq/user-contrib/compcert/" (dirname file))))
338
               (find-files "." ".*.vo$"))
339
             #t)))
340
       #:tests? #f))
341
    (native-inputs
342
     `(("ocaml" ,ocaml)
343
       ("coq" ,coq-8.7)))
344
    (inputs
345
     `(("menhir" ,ocaml-menhir)))
346
    (home-page "http://compcert.inria.fr")
347
    (synopsis "Certified C compiler")
348
    (description "CompCert is a certified (with coq) C compiler.  Warning: this
349
package is not free software!")
350
    ;; actually the "INRIA Non-Commercial License Agreement"
351
    ;; a non-free license.
352
    (license (license:non-copyleft "file:///LICENSE"))))
353
354
(define-public ocaml-c2newspeak
355
  (package
356
    (name "ocaml-c2newspeak")
357
    (version "1")
358
    (source (origin
359
              (method git-fetch)
360
              (uri (git-reference
361
                     (url "https://github.com/airbus-seclab/c2newspeak")
362
                     (commit "c97fd380111a49fa7baeb9e49c45238fca627492")))
363
              (file-name (string-append name "-" version))
364
              (sha256
365
               (base32
366
                "0fxh868s5jraq61mnig9ilhyjzsq4iw32f20zh3982naanp4p8r6"))))
367
    (build-system ocaml-build-system)
368
    (arguments
369
     `(#:test-target "check"
370
       #:tests? #f
371
       #:phases
372
       (modify-phases %standard-phases
373
         (delete 'configure)
374
         (add-after 'install 'install-bin
375
           (lambda* (#:key outputs #:allow-other-keys)
376
             (install-file "bin/c2newspeak" (string-append (assoc-ref outputs "out") "/bin")))))))
377
    (home-page "https://github.com/airbus-seclab/c2newspeak")
378
    (synopsis "")
379
    (description "")
380
    (license license:lgpl2.1+)))
381
382
(define-public ocaml-bincat
383
  (package
384
    (name "ocaml-bincat")
385
    (version "0.8.1")
386
    (source (origin
387
              (method url-fetch)
388
              (uri (string-append "https://github.com/airbus-seclab/bincat/archive/v"
389
                                  version ".tar.gz"))
390
              (file-name (string-append name "-" version ".tar.gz"))
391
              (sha256
392
               (base32
393
                "1ncwm1h428x1bs4sq7ql1isrkhw0angglsa9hnsvhhw2i1jsdk7j"))))
394
    (build-system ocaml-build-system)
395
    (arguments
396
     `(#:tests? #f; disabled for now
397
       #:validate-runpath? #f; disabled for now
398
       #:make-flags
399
       (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
400
             "LDCONFIG=true"
401
             (string-append "CFLAGS+=-I " (assoc-ref %build-inputs "ocaml")
402
                            "/lib/ocaml"))
403
       #:phases
404
       (modify-phases %standard-phases
405
         (delete 'configure)
406
         (add-before 'build 'python-path
407
           (lambda* (#:key outputs #:allow-other-keys)
408
             (setenv "PYTHONPATH" (string-append (getenv "PYTHONPATH")
409
                                                 ":../python:"
410
                                                 (assoc-ref outputs "out")
411
                                                 "/lib/python2.7/site-packages/"))
412
             #t))
413
         (add-before 'build 'fix-makefiles
414
           (lambda _
415
             (substitute* "ocaml/src/Makefile"
416
               (("GITVERSION:=.*") "GITVERSION:=0.8.1\n"))
417
             (substitute* "python/Makefile"
418
               (("./setup.py install") "./setup.py install --prefix=$(PREFIX)"))
419
             #t))
420
         (add-before 'check 'fix-test
421
           (lambda _
422
             (setenv "PATH" (string-append (getenv "PATH") ":" (getcwd) "/ocaml/src"))
423
             ;; Remove tests that require an armv8 compiler
424
             (substitute* "test/Makefile"
425
               (("eggloader_armv8 eggloader_armv7 eggloader_armv7thumb") ""))
426
             (chmod "test/eggloader_x86" #o755)
427
             #t))
428
         (add-before 'install 'install-python-dir
429
           (lambda* (#:key outputs #:allow-other-keys)
430
             (mkdir-p (string-append (assoc-ref outputs "out")
431
                                     "/lib/python2.7/site-packages/")))))))
432
    (inputs
433
     `(("c2newspeak" ,ocaml-c2newspeak)
434
       ("zarith" ,ocaml-zarith)
435
       ("menhir" ,ocaml-menhir)
436
       ("ocamlgraph" ,ocaml-graph)
437
       ("ocaml-cppo" ,ocaml-cppo)
438
       ("ocaml-ppx-tools" ,ocaml-ppx-tools)
439
       ("gmp" ,gmp)))
440
    (native-inputs
441
     `(("python" ,python-2)
442
       ("pytest" ,python2-pytest)
443
       ("sphinx" ,python2-sphinx)
444
       ("nasm" ,nasm)))
445
    (home-page "https://github.com/airbus-seclab/bincat")
446
    (synopsis "")
447
    (description "")
448
    (license license:lgpl2.1+)))
449
450
(define-public ocaml-ocplib-simplex
451
  (package
452
    (name "ocaml-ocplib-simplex")
453
    (version "0.4")
454
    (source (origin
455
              (method url-fetch)
456
              (uri (string-append "https://github.com/OCamlPro-Iguernlala/"
457
                                  "ocplib-simplex/archive/v" version ".tar.gz"))
458
              (sha256
459
               (base32
460
                "0y6q4bgly7fisdklriww48aknqf2vg4dphr7wwnd1wh80l4anzg1"))))
461
    (build-system gnu-build-system)
462
    (arguments
463
     `(#:tests? #f; Compilation error
464
       #:phases
465
       (modify-phases %standard-phases
466
         (add-after 'unpack 'autoreconf
467
           (lambda _
468
             (invoke "autoreconf" "-fiv")
469
             #t))
470
         (add-before 'install 'mkdir
471
           (lambda* (#:key outputs #:allow-other-keys)
472
             (let* ((out (assoc-ref outputs "out"))
473
                    (lib (string-append out "/lib")))
474
               (mkdir-p lib)
475
               #t))))))
476
    (native-inputs
477
     `(("autoconf" ,autoconf)
478
       ("automake" ,automake)
479
       ("ocaml" ,ocaml)
480
       ("ocaml-findlib" ,ocaml-findlib)
481
       ("which" ,which)))
482
    (home-page "")
483
    (synopsis "")
484
    (description "")
485
    ; lgpl2.1+ with linking exception
486
    (license license:lgpl2.1+)))
487
488
(define-public frama-c
489
  (package
490
    (name "frama-c")
491
    (version "20171101")
492
    (source (origin
493
              (method url-fetch)
494
              (uri (string-append "http://frama-c.com/download/frama-c-Sulfur-"
495
                                  version ".tar.gz"))
496
              (sha256
497
               (base32
498
                "1vwjfqmm1r36gkybsy3a7m89q5zicf4rnz5vlsn9imnpjpl9gjw1"))))
499
    (build-system ocaml-build-system)
500
    (arguments
501
     `(#:tests? #f; for now
502
       #:phases
503
       (modify-phases %standard-phases
504
         (add-before 'configure 'export-shell
505
           (lambda* (#:key inputs #:allow-other-keys)
506
             (setenv "CONFIG_SHELL" (string-append (assoc-ref inputs "bash")
507
                                                   "/bin/sh")))))))
508
    (inputs
509
     `(("gmp" ,gmp)
510
       ("ocaml-graph" ,ocaml-graph)
511
       ("ocaml-zarith" ,ocaml-zarith)))
512
    (home-page "")
513
    (synopsis "")
514
    (description "")
515
    (license license:lgpl2.1+)))
516
517
(define-public coq-io
518
  (package
519
    (name "coq-io")
520
    (version "3.3.0")
521
    (source (origin
522
              (method url-fetch)
523
              (uri (string-append "https://github.com/coq-io/io/archive/"
524
                                  version ".tar.gz"))
525
              (file-name (string-append name "-" version ".tar.gz"))
526
              (sha256
527
               (base32
528
                "0k1z8kav3wz5n04g3imm1hqjimb9cf12ga5wkj1skz8l5ccjxprw"))))
529
    (build-system gnu-build-system)
530
    (arguments
531
     `(#:tests? #f; no tests
532
       #:make-flags
533
       (list (string-append "COQLIB=" (assoc-ref %outputs "out") "/lib/coq/"))
534
       #:phases
535
       (modify-phases %standard-phases
536
         (replace 'configure
537
           (lambda _
538
             (invoke "./configure.sh")
539
             #t)))))
540
    (native-inputs
541
     `(("coq" ,coq-8.6)))
542
    (home-page "")
543
    (synopsis "")
544
    (description "")
545
    (license license:lgpl2.1+)))
546