1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013 Cyril Roelandt <tipecaml@gmail.com>
3 ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
5 ;;; Copyright © 2015 David Hashe <david.hashe@dhashe.com>
6 ;;; Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
7 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
8 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
10 ;;; This file is part of GNU Guix.
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25 (define-module (gnu packages ocaml)
26 #:use-module ((guix licenses) #:hide (zlib))
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix svn-download)
30 #:use-module (guix utils)
31 #:use-module (guix build-system gnu)
32 #:use-module (gnu packages)
33 #:use-module (gnu packages gcc)
34 #:use-module (gnu packages gnome)
35 #:use-module (gnu packages gtk)
36 #:use-module (gnu packages base)
37 #:use-module (gnu packages emacs)
38 #:use-module (gnu packages texinfo)
39 #:use-module (gnu packages pkg-config)
40 #:use-module (gnu packages compression)
41 #:use-module (gnu packages xorg)
42 #:use-module (gnu packages tex)
43 #:use-module (gnu packages ghostscript)
44 #:use-module (gnu packages lynx)
45 #:use-module (gnu packages perl)
46 #:use-module (gnu packages python)
47 #:use-module (gnu packages m4)
48 #:use-module (gnu packages ncurses)
49 #:use-module (gnu packages version-control)
50 #:use-module (gnu packages curl))
59 "http://caml.inria.fr/pub/distrib/ocaml-"
60 (version-major+minor version)
61 "/ocaml-" version ".tar.xz"))
64 "1qwwvy8nzd87hk8rd9sm667nppakiapnx4ypdwcrlnav2dz6kil3"))
65 (patches (search-patches "ocaml-CVE-2015-8869.patch"))))
66 (build-system gnu-build-system)
68 (list (search-path-specification
69 (variable "OCAMLPATH")
70 (files (list (string-append "lib/ocaml"))))))
73 ("pkg-config" ,pkg-config)))
76 ;; For libiberty, needed for objdump support.
77 ("gcc:lib" ,(canonical-package gcc-4.9) "lib")
78 ("zlib" ,zlib))) ;also needed for objdump support
80 `(#:modules ((guix build gnu-build-system)
84 (modify-phases %standard-phases
85 (add-after 'unpack 'patch-/bin/sh-references
86 (lambda* (#:key inputs #:allow-other-keys)
87 (let* ((sh (string-append (assoc-ref inputs "bash")
89 (quoted-sh (string-append "\"" sh "\"")))
90 (with-fluids ((%default-port-encoding #f))
91 (for-each (lambda (file)
95 (format (current-error-port) "\
96 patch-/bin/sh-references: ~a: changing `\"/bin/sh\"' to `~a'~%"
99 (find-files "." "\\.ml$"))
102 (lambda* (#:key outputs #:allow-other-keys)
103 (let* ((out (assoc-ref outputs "out"))
104 (mandir (string-append out "/share/man")))
105 ;; Custom configure script doesn't recognize
106 ;; --prefix=<PREFIX> syntax (with equals sign).
107 (zero? (system* "./configure"
109 "--mandir" mandir)))))
112 (zero? (system* "make" "-j" (number->string
113 (parallel-job-count))
116 (add-after 'install 'check
118 (with-directory-excursion "testsuite"
119 (zero? (system* "make" "all")))))
120 (add-before 'check 'prepare-socket-test
122 (format (current-error-port)
123 "Spawning local test web server on port 8080~%")
124 (when (zero? (primitive-fork))
125 (run-server (lambda (request request-body)
126 (values '((content-type . (text/plain)))
128 'http '(#:port 8080)))
129 (let ((file "testsuite/tests/lib-threads/testsocket.ml"))
130 (format (current-error-port)
131 "Patching ~a to use localhost port 8080~%"
134 (("caml.inria.fr") "localhost")
136 (("HTTP1.0") "HTTP/1.0"))
138 (home-page "https://ocaml.org/")
139 (synopsis "The OCaml programming language")
141 "OCaml is a general purpose industrial-strength programming language with
142 an emphasis on expressiveness and safety. Developed for more than 20 years at
143 Inria it benefits from one of the most advanced type systems and supports
144 functional, imperative and object-oriented styles of programming.")
145 ;; The compiler is distributed under qpl1.0 with a change to choice of
146 ;; law: the license is governed by the laws of France. The library is
147 ;; distributed under lgpl2.0.
148 (license (list qpl lgpl2.0))))
156 ;; Use the '-full' version, which includes all the dependencies.
158 "https://github.com/ocaml/opam/releases/download/"
159 version "/opam-full-" version ".tar.gz")
160 ;; (string-append "https://github.com/ocaml/opam/archive/"
161 ;; version ".tar.gz")
165 "004gwn6rbpcb53y3rpb3v23vk39rp2xmf0liyd5iy12ij8bigrhm"))))
166 (build-system gnu-build-system)
168 '(;; Sometimes, 'make -jX' would fail right after ./configure with
169 ;; "Fatal error: exception End_of_file".
172 ;; For some reason, 'ocp-build' needs $TERM to be set.
173 #:make-flags `("TERM=screen"
174 ,(string-append "SHELL="
175 (assoc-ref %build-inputs "bash")
177 #:test-target "tests"
179 ;; FIXME: There's an obscure test failure:
180 ;; …/_obuild/opam/opam.asm install P1' failed.
183 #:phases (modify-phases %standard-phases
184 (add-before 'build 'pre-build
185 (lambda* (#:key inputs make-flags #:allow-other-keys)
186 (let ((bash (assoc-ref inputs "bash")))
187 (substitute* "src/core/opamSystem.ml"
189 (string-append "\"" bash "/bin/sh\"")))
190 ;; Build dependencies
191 (zero? (apply system* "make" "lib-ext" make-flags)))))
192 (add-before 'check 'pre-check
194 (setenv "HOME" (getcwd))
195 (and (system "git config --global user.email guix@gnu.org")
196 (system "git config --global user.name Guix")))))))
198 `(("git" ,git) ;for the tests
199 ("python" ,python) ;for the tests
205 (home-page "http://opam.ocamlpro.com/")
206 (synopsis "Package manager for OCaml")
208 "OPAM is a tool to manage OCaml packages. It supports multiple
209 simultaneous compiler installations, flexible package constraints, and a
210 Git-friendly development workflow.")
212 ;; The 'LICENSE' file waives some requirements compared to LGPLv3.
215 (define-public camlp4
221 (uri (string-append "https://github.com/ocaml/camlp4/archive/"
225 "0icdfzhsbgf89925gc8gl3fm8z2xzszzlib0v9dj5wyzkyv3a342"))
226 (file-name (string-append name "-" version ".tar.gz"))))
227 (build-system gnu-build-system)
228 (native-inputs `(("ocaml" ,ocaml)
230 (inputs `(("ocaml" ,ocaml)))
232 '(#:tests? #f ;no documented test target
233 #:phases (modify-phases %standard-phases
236 (lambda* (#:key outputs #:allow-other-keys)
237 ;; This is a home-made 'configure' script.
238 (let ((out (assoc-ref outputs "out")))
239 (zero? (system* "./configure"
240 (string-append "--libdir=" out "/lib")
241 (string-append "--bindir=" out "/bin")
242 (string-append "--pkgdir=" out)))))))))
243 (home-page "https://github.com/ocaml/camlp4")
244 (synopsis "Write parsers in OCaml")
246 "Camlp4 is a software system for writing extensible parsers for
247 programming languages. It provides a set of OCaml libraries that are used to
248 define grammars as well as loadable syntax extensions of such grammars.
249 Camlp4 stands for Caml Preprocessor and Pretty-Printer and one of its most
250 important applications is the definition of domain-specific extensions of the
253 ;; This is LGPLv2 with an exception that allows packages statically-linked
254 ;; against the library to be released under any terms.
257 (define-public camlp5
263 (uri (string-append "http://camlp5.gforge.inria.fr/distrib/src/"
264 name "-" version ".tgz"))
267 "1ql04iyvclpyy9805kpddc4ndjb5d0qg4shhi2fc6bixi49fvy89"))))
268 (build-system gnu-build-system)
272 `(#:tests? #f ; XXX TODO figure out how to run the tests
274 (modify-phases %standard-phases
276 (lambda* (#:key outputs #:allow-other-keys)
277 (let* ((out (assoc-ref outputs "out"))
278 (mandir (string-append out "/share/man")))
279 ;; Custom configure script doesn't recognize
280 ;; --prefix=<PREFIX> syntax (with equals sign).
281 (zero? (system* "./configure"
283 "--mandir" mandir)))))
286 (zero? (system* "make" "-j" (number->string
287 (parallel-job-count))
289 (home-page "http://camlp5.gforge.inria.fr/")
290 (synopsis "Pre-processor Pretty Printer for OCaml")
292 "Camlp5 is a Pre-Processor-Pretty-Printer for Objective Caml. It offers
293 tools for syntax (Stream Parsers and Grammars) and the ability to modify the
294 concrete syntax of the language (Quotations, Syntax Extensions).")
295 ;; Most files are distributed under bsd-3, but ocaml_stuff/* is under qpl.
296 (license (list bsd-3 qpl))))
304 (uri (string-append "http://hevea.inria.fr/old/"
305 name "-" version ".tar.gz"))
308 "14fns13wlnpiv9i05841kvi3cq4b9v2sw5x3ff6ziws28q701qnd"))))
309 (build-system gnu-build-system)
313 `(#:tests? #f ; no test suite
314 #:make-flags (list (string-append "PREFIX=" %output))
315 #:phases (modify-phases %standard-phases
317 (add-before 'build 'patch-/bin/sh
320 (("/bin/sh") (which "sh")))
322 (home-page "http://hevea.inria.fr/")
323 (synopsis "LaTeX to HTML translator")
325 "HeVeA is a LaTeX to HTML translator that generates modern HTML 5. It is
326 written in Objective Caml.")
335 (uri (string-append "https://coq.inria.fr/distrib/V" version
336 "/files/" name "-" version ".tar.gz"))
339 "1mpbj4yf36kpjg2v2sln12i8dzqn8rag6fd07hslj2lpm4qs4h55"))))
340 (build-system gnu-build-system)
342 `(("texlive" ,texlive)
349 (modify-phases %standard-phases
351 (lambda* (#:key outputs #:allow-other-keys)
352 (let* ((out (assoc-ref outputs "out"))
353 (mandir (string-append out "/share/man"))
354 (browser "icecat -remote \"OpenURL(%s,new-tab)\""))
355 (zero? (system* "./configure"
358 "--browser" browser)))))
361 (zero? (system* "make" "-j" (number->string
362 (parallel-job-count))
365 (add-after 'install 'check
367 (with-directory-excursion "test-suite"
368 (zero? (system* "make"))))))))
369 (home-page "https://coq.inria.fr")
370 (synopsis "Proof assistant for higher-order logic")
372 "Coq is a proof assistant for higher-order logic, which allows the
373 development of computer programs consistent with their formal specification.
374 It is developed using Objective Caml and Camlp5.")
375 ;; The code is distributed under lgpl2.1.
376 ;; Some of the documentation is distributed under opl1.0+.
377 (license (list lgpl2.1 opl1.0+))))
379 (define-public proof-general
381 (name "proof-general")
386 "http://proofgeneral.inf.ed.ac.uk/releases/"
387 "ProofGeneral-" version ".tgz"))
390 "09qb0myq66fw17v4ziz401ilsb5xlxz1nl2wsp69d0vrfy0bcrrm"))))
391 (build-system gnu-build-system)
394 ("emacs" ,emacs-minimal)
395 ("texinfo" ,texinfo)))
397 `(("host-emacs" ,emacs)
401 `(#:tests? #f ; no check target
402 #:make-flags (list (string-append "PREFIX=" %output)
403 (string-append "DEST_PREFIX=" %output))
404 #:modules ((guix build gnu-build-system)
406 (guix build emacs-utils))
407 #:imported-modules (,@%gnu-build-system-modules
408 (guix build emacs-utils))
410 (modify-phases %standard-phases
412 (add-after 'unpack 'disable-byte-compile-error-on-warn
414 (substitute* "Makefile"
415 (("\\(setq byte-compile-error-on-warn t\\)")
416 "(setq byte-compile-error-on-warn nil)"))
418 (add-after 'unpack 'patch-hardcoded-paths
419 (lambda* (#:key inputs outputs #:allow-other-keys)
420 (let ((out (assoc-ref outputs "out"))
421 (coq (assoc-ref inputs "coq"))
422 (emacs (assoc-ref inputs "host-emacs")))
423 (define (coq-prog name)
424 (string-append coq "/bin/" name))
425 (emacs-substitute-variables "coq/coq.el"
426 ("coq-prog-name" (coq-prog "coqtop"))
427 ("coq-compiler" (coq-prog "coqc"))
428 ("coq-dependency-analyzer" (coq-prog "coqdep")))
429 (substitute* "Makefile"
430 (("/sbin/install-info") "install-info"))
431 (substitute* "bin/proofgeneral"
432 (("^PGHOMEDEFAULT=.*" all)
434 "PGHOME=$PGHOMEDEFAULT\n"
435 "EMACS=" emacs "/bin/emacs")))
437 (add-after 'unpack 'clean
439 ;; Delete the pre-compiled elc files for Emacs 23.
440 (zero? (system* "make" "clean"))))
441 (add-after 'install 'install-doc
442 (lambda* (#:key make-flags #:allow-other-keys)
443 ;; XXX FIXME avoid building/installing pdf files,
444 ;; due to unresolved errors building them.
445 (substitute* "Makefile"
446 ((" [^ ]*\\.pdf") ""))
447 (zero? (apply system* "make" "install-doc"
449 (home-page "http://proofgeneral.inf.ed.ac.uk/")
450 (synopsis "Generic front-end for proof assistants based on Emacs")
452 "Proof General is a major mode to turn Emacs into an interactive proof
453 assistant to write formal mathematical proofs using a variety of theorem
457 (define-public lablgtk
464 (uri (string-append "https://forge.ocamlcore.org/frs/download.php/"
465 "1479/lablgtk-2.18.3.tar.gz"))
468 "1bybn3jafxf4cx25zvn8h2xj9agn1xjbn7j3ywxxqx6az7rfnnwp"))))
469 (build-system gnu-build-system)
473 ("pkg-config" ,pkg-config)))
474 ;; FIXME: Add inputs gtkgl-2.0, libpanelapplet-2.0, gtkspell-2.0,
475 ;; and gtk+-quartz-2.0 once available.
478 ("gtksourceview" ,gtksourceview-2)
479 ("libgnomecanvas" ,libgnomecanvas)
480 ("libgnomeui" ,libgnomeui)
481 ("libglade" ,libglade)
482 ("librsvg" ,librsvg)))
484 `(#:tests? #f ; no check target
486 ;; opt: also install cmxa files
487 #:make-flags (list "all" "opt")
488 ;; Occasionally we would get "Error: Unbound module GtkThread" when
489 ;; compiling 'gtkThInit.ml', with 'make -j'. So build sequentially.
493 (modify-phases %standard-phases
495 (lambda* (#:key inputs outputs #:allow-other-keys)
496 (let ((out (assoc-ref outputs "out"))
497 (ocaml (assoc-ref inputs "ocaml")))
498 ;; Install into the output and not the ocaml directory.
499 (substitute* "config.make"
501 (system* "make" "old-install")
503 (home-page "http://lablgtk.forge.ocamlcore.org/")
504 (synopsis "GTK+ bindings for OCaml")
506 "LablGtk is an OCaml interface to GTK+ 1.2 and 2.x. It provides
507 a strongly-typed object-oriented interface that is compatible with the
508 dynamic typing of GTK+. Most widgets and methods are available. LablGtk
509 also provides bindings to
510 gdk-pixbuf, the GLArea widget (in combination with LablGL), gnomecanvas,
511 gnomeui, gtksourceview, gtkspell,
512 libglade (and it an generate OCaml code from .glade files),
513 libpanel, librsvg and quartz.")
516 (define-public unison
524 (url (string-append "https://webdav.seas.upenn.edu/svn/"
526 (version-major+minor version)))
528 (file-name (string-append name "-" version "-checkout"))
531 "0486s53wyayicj9f2raj2dvwvk4xyzar219rccc1iczdwixm4x05"))
532 (modules '((guix build utils)
538 ;; The svn revision in the release tarball appears to be
539 ;; artificially manipulated in order to set the desired point
540 ;; version number. Because the point version is calculated during
541 ;; the build, we can offset pointVersionOrigin by the desired
542 ;; point version and write that into "Rev: %d". We do this rather
543 ;; than hardcoding the necessary revision number, for
545 (with-atomic-file-replacement "src/mkProjectInfo.ml"
547 (let ((pt-ver (string->number (third (string-split ,version #\.))))
548 (pt-rx (make-regexp "^let pointVersionOrigin = ([0-9]+)"))
549 (rev-rx (make-regexp "Rev: [0-9]+")))
550 (let loop ((pt-origin #f))
551 (let ((line (read-line in 'concat)))
553 ((regexp-exec pt-rx line)
556 (loop (string->number (match:substring m 1)))))
557 ((regexp-exec rev-rx line)
559 (format out "~aRev: ~d~a"
563 (dump-port in out))) ;done
566 (loop pt-origin))))))))
567 ;; Without the '-fix' argument, the html file produced does not
568 ;; have functioning internal hyperlinks.
569 (substitute* "doc/Makefile"
570 (("hevea unison") "hevea -fix unison"))))))
571 (build-system gnu-build-system)
573 "doc")) ; 1.9 MiB of documentation
577 ("ghostscript" ,ghostscript)
582 `(#:parallel-build? #f
584 #:test-target "selftest"
585 #:tests? #f ; Tests require writing to $HOME.
586 ; If some $HOME is provided, they fail with the message
587 ; "Fatal error: Skipping some tests -- remove me!"
589 (modify-phases %standard-phases
591 (add-before 'install 'prepare-install
592 (lambda* (#:key outputs #:allow-other-keys)
593 (let* ((out (assoc-ref outputs "out"))
594 (bin (string-append out "/bin")))
596 (setenv "HOME" out) ; forces correct INSTALLDIR in Makefile
598 (add-after 'install 'install-fsmonitor
599 (lambda* (#:key outputs #:allow-other-keys)
600 (let* ((out (assoc-ref outputs "out"))
601 (bin (string-append out "/bin")))
602 ;; 'unison-fsmonitor' is used in "unison -repeat watch" mode.
603 (install-file "src/unison-fsmonitor" bin))))
604 (add-after 'install 'install-doc
605 (lambda* (#:key outputs #:allow-other-keys)
606 (let ((doc (string-append (assoc-ref outputs "doc")
607 "/share/doc/unison")))
609 ;; This file needs write-permissions, because it's
610 ;; overwritten by 'docs' during documentation generation.
611 (chmod "src/strings.ml" #o600)
612 (and (zero? (system* "make" "docs"
613 "TEXDIRECTIVES=\\\\draftfalse"))
615 (for-each (lambda (f)
616 (install-file f doc))
619 "doc/unison-manual." ext))
620 ;; Install only html documentation,
621 ;; since the build is currently
622 ;; non-reproducible with the ps, pdf,
627 (home-page "https://www.cis.upenn.edu/~bcpierce/unison/")
628 (synopsis "File synchronizer")
630 "Unison is a file-synchronization tool. It allows two replicas of
631 a collection of files and directories to be stored on different hosts
632 (or different disks on the same host), modified separately, and then
633 brought up to date by propagating the changes in each replica
637 (define-public ocaml-findlib
639 (name "ocaml-findlib")
643 (uri (string-append "http://download.camlcity.org/download/"
644 "findlib" "-" version ".tar.gz"))
647 "02abg1lsnwvjg3igdyb8qjgr5kv1nbwl4gaf8mdinzfii5p82721"))
648 (patches (search-patches "ocaml-findlib-make-install.patch"))))
649 (build-system gnu-build-system)
655 `(#:tests? #f ; no test suite
657 #:make-flags (list "all" "opt")
658 #:phases (modify-phases %standard-phases
661 (lambda* (#:key inputs outputs #:allow-other-keys)
662 (let ((out (assoc-ref outputs "out")))
665 "-bindir" (string-append out "/bin")
666 "-config" (string-append out "/etc/ocamfind.conf")
667 "-mandir" (string-append out "/share/man")
668 "-sitelib" (string-append out "/lib/ocaml/site-lib")
669 "-with-toolbox")))))))
670 (home-page "http://projects.camlcity.org/projects/findlib.html")
671 (synopsis "Management tool for OCaml libraries")
673 "The \"findlib\" library provides a scheme to manage reusable software
674 components (packages), and includes tools that support this scheme. Packages
675 are collections of OCaml modules for which metainformation can be stored. The
676 packages are kept in the file system hierarchy, but with strict directory
677 structure. The library contains functions to look the directory up that
678 stores a package, to query metainformation about a package, and to retrieve
679 dependency information about multiple packages. There is also a tool that
680 allows the user to enter queries on the command-line. In order to simplify
681 compilation and linkage, there are new frontends of the various OCaml
682 compilers that can directly deal with packages.")