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>
9 ;;; This file is part of GNU Guix.
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24 (define-module (gnu packages ocaml)
25 #:use-module ((guix licenses) #:hide (zlib))
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix svn-download)
29 #:use-module (guix utils)
30 #:use-module (guix build-system gnu)
31 #:use-module (gnu packages)
32 #:use-module (gnu packages gcc)
33 #:use-module (gnu packages gnome)
34 #:use-module (gnu packages gtk)
35 #:use-module (gnu packages base)
36 #:use-module (gnu packages emacs)
37 #:use-module (gnu packages texinfo)
38 #:use-module (gnu packages pkg-config)
39 #:use-module (gnu packages compression)
40 #:use-module (gnu packages xorg)
41 #:use-module (gnu packages tex)
42 #:use-module (gnu packages ghostscript)
43 #:use-module (gnu packages lynx)
44 #:use-module (gnu packages perl)
45 #:use-module (gnu packages python)
46 #:use-module (gnu packages m4)
47 #:use-module (gnu packages ncurses)
48 #:use-module (gnu packages version-control)
49 #:use-module (gnu packages curl))
58 "http://caml.inria.fr/pub/distrib/ocaml-"
59 (version-major+minor version)
60 "/ocaml-" version ".tar.xz"))
63 "1qwwvy8nzd87hk8rd9sm667nppakiapnx4ypdwcrlnav2dz6kil3"))
64 (patches (search-patches "ocaml-CVE-2015-8869.patch"))))
65 (build-system gnu-build-system)
67 (list (search-path-specification
68 (variable "OCAMLPATH")
69 (files (list (string-append "lib/ocaml"))))))
72 ("pkg-config" ,pkg-config)))
75 ;; For libiberty, needed for objdump support.
76 ("gcc:lib" ,(canonical-package gcc-4.9) "lib")
77 ("zlib" ,zlib))) ;also needed for objdump support
79 `(#:modules ((guix build gnu-build-system)
83 (modify-phases %standard-phases
84 (add-after 'unpack 'patch-/bin/sh-references
85 (lambda* (#:key inputs #:allow-other-keys)
86 (let* ((sh (string-append (assoc-ref inputs "bash")
88 (quoted-sh (string-append "\"" sh "\"")))
89 (with-fluids ((%default-port-encoding #f))
90 (for-each (lambda (file)
94 (format (current-error-port) "\
95 patch-/bin/sh-references: ~a: changing `\"/bin/sh\"' to `~a'~%"
98 (find-files "." "\\.ml$"))
101 (lambda* (#:key outputs #:allow-other-keys)
102 (let* ((out (assoc-ref outputs "out"))
103 (mandir (string-append out "/share/man")))
104 ;; Custom configure script doesn't recognize
105 ;; --prefix=<PREFIX> syntax (with equals sign).
106 (zero? (system* "./configure"
108 "--mandir" mandir)))))
111 (zero? (system* "make" "-j" (number->string
112 (parallel-job-count))
115 (add-after 'install 'check
117 (with-directory-excursion "testsuite"
118 (zero? (system* "make" "all")))))
119 (add-before 'check 'prepare-socket-test
121 (format (current-error-port)
122 "Spawning local test web server on port 8080~%")
123 (when (zero? (primitive-fork))
124 (run-server (lambda (request request-body)
125 (values '((content-type . (text/plain)))
127 'http '(#:port 8080)))
128 (let ((file "testsuite/tests/lib-threads/testsocket.ml"))
129 (format (current-error-port)
130 "Patching ~a to use localhost port 8080~%"
133 (("caml.inria.fr") "localhost")
135 (("HTTP1.0") "HTTP/1.0"))
137 (home-page "https://ocaml.org/")
138 (synopsis "The OCaml programming language")
140 "OCaml is a general purpose industrial-strength programming language with
141 an emphasis on expressiveness and safety. Developed for more than 20 years at
142 Inria it benefits from one of the most advanced type systems and supports
143 functional, imperative and object-oriented styles of programming.")
144 ;; The compiler is distributed under qpl1.0 with a change to choice of
145 ;; law: the license is governed by the laws of France. The library is
146 ;; distributed under lgpl2.0.
147 (license (list qpl lgpl2.0))))
155 ;; Use the '-full' version, which includes all the dependencies.
157 "https://github.com/ocaml/opam/releases/download/"
158 version "/opam-full-" version ".tar.gz")
159 ;; (string-append "https://github.com/ocaml/opam/archive/"
160 ;; version ".tar.gz")
164 "004gwn6rbpcb53y3rpb3v23vk39rp2xmf0liyd5iy12ij8bigrhm"))))
165 (build-system gnu-build-system)
167 '(;; Sometimes, 'make -jX' would fail right after ./configure with
168 ;; "Fatal error: exception End_of_file".
171 ;; For some reason, 'ocp-build' needs $TERM to be set.
172 #:make-flags `("TERM=screen"
173 ,(string-append "SHELL="
174 (assoc-ref %build-inputs "bash")
176 #:test-target "tests"
178 ;; FIXME: There's an obscure test failure:
179 ;; …/_obuild/opam/opam.asm install P1' failed.
182 #:phases (modify-phases %standard-phases
183 (add-before 'build 'pre-build
184 (lambda* (#:key inputs make-flags #:allow-other-keys)
185 (let ((bash (assoc-ref inputs "bash")))
186 (substitute* "src/core/opamSystem.ml"
188 (string-append "\"" bash "/bin/sh\"")))
189 ;; Build dependencies
190 (zero? (apply system* "make" "lib-ext" make-flags)))))
191 (add-before 'check 'pre-check
193 (setenv "HOME" (getcwd))
194 (and (system "git config --global user.email guix@gnu.org")
195 (system "git config --global user.name Guix")))))))
197 `(("git" ,git) ;for the tests
198 ("python" ,python) ;for the tests
204 (home-page "http://opam.ocamlpro.com/")
205 (synopsis "Package manager for OCaml")
207 "OPAM is a tool to manage OCaml packages. It supports multiple
208 simultaneous compiler installations, flexible package constraints, and a
209 Git-friendly development workflow.")
211 ;; The 'LICENSE' file waives some requirements compared to LGPLv3.
214 (define-public camlp4
220 (uri (string-append "https://github.com/ocaml/camlp4/archive/"
224 "0icdfzhsbgf89925gc8gl3fm8z2xzszzlib0v9dj5wyzkyv3a342"))
225 (file-name (string-append name "-" version ".tar.gz"))))
226 (build-system gnu-build-system)
227 (native-inputs `(("ocaml" ,ocaml)
229 (inputs `(("ocaml" ,ocaml)))
231 '(#:tests? #f ;no documented test target
232 #:phases (modify-phases %standard-phases
235 (lambda* (#:key outputs #:allow-other-keys)
236 ;; This is a home-made 'configure' script.
237 (let ((out (assoc-ref outputs "out")))
238 (zero? (system* "./configure"
239 (string-append "--libdir=" out "/lib")
240 (string-append "--bindir=" out "/bin")
241 (string-append "--pkgdir=" out)))))))))
242 (home-page "https://github.com/ocaml/camlp4")
243 (synopsis "Write parsers in OCaml")
245 "Camlp4 is a software system for writing extensible parsers for
246 programming languages. It provides a set of OCaml libraries that are used to
247 define grammars as well as loadable syntax extensions of such grammars.
248 Camlp4 stands for Caml Preprocessor and Pretty-Printer and one of its most
249 important applications is the definition of domain-specific extensions of the
252 ;; This is LGPLv2 with an exception that allows packages statically-linked
253 ;; against the library to be released under any terms.
256 (define-public camlp5
262 (uri (string-append "http://camlp5.gforge.inria.fr/distrib/src/"
263 name "-" version ".tgz"))
266 "1ql04iyvclpyy9805kpddc4ndjb5d0qg4shhi2fc6bixi49fvy89"))))
267 (build-system gnu-build-system)
271 `(#:tests? #f ; XXX TODO figure out how to run the tests
273 (modify-phases %standard-phases
275 (lambda* (#:key outputs #:allow-other-keys)
276 (let* ((out (assoc-ref outputs "out"))
277 (mandir (string-append out "/share/man")))
278 ;; Custom configure script doesn't recognize
279 ;; --prefix=<PREFIX> syntax (with equals sign).
280 (zero? (system* "./configure"
282 "--mandir" mandir)))))
285 (zero? (system* "make" "-j" (number->string
286 (parallel-job-count))
288 (home-page "http://camlp5.gforge.inria.fr/")
289 (synopsis "Pre-processor Pretty Printer for OCaml")
291 "Camlp5 is a Pre-Processor-Pretty-Printer for Objective Caml. It offers
292 tools for syntax (Stream Parsers and Grammars) and the ability to modify the
293 concrete syntax of the language (Quotations, Syntax Extensions).")
294 ;; Most files are distributed under bsd-3, but ocaml_stuff/* is under qpl.
295 (license (list bsd-3 qpl))))
303 (uri (string-append "http://hevea.inria.fr/old/"
304 name "-" version ".tar.gz"))
307 "14fns13wlnpiv9i05841kvi3cq4b9v2sw5x3ff6ziws28q701qnd"))))
308 (build-system gnu-build-system)
312 `(#:tests? #f ; no test suite
313 #:make-flags (list (string-append "PREFIX=" %output))
314 #:phases (modify-phases %standard-phases
316 (add-before 'build 'patch-/bin/sh
319 (("/bin/sh") (which "sh")))
321 (home-page "http://hevea.inria.fr/")
322 (synopsis "LaTeX to HTML translator")
324 "HeVeA is a LaTeX to HTML translator that generates modern HTML 5. It is
325 written in Objective Caml.")
334 (uri (string-append "https://coq.inria.fr/distrib/V" version
335 "/files/" name "-" version ".tar.gz"))
338 "1mpbj4yf36kpjg2v2sln12i8dzqn8rag6fd07hslj2lpm4qs4h55"))))
339 (build-system gnu-build-system)
341 `(("texlive" ,texlive)
348 (modify-phases %standard-phases
350 (lambda* (#:key outputs #:allow-other-keys)
351 (let* ((out (assoc-ref outputs "out"))
352 (mandir (string-append out "/share/man"))
353 (browser "icecat -remote \"OpenURL(%s,new-tab)\""))
354 (zero? (system* "./configure"
357 "--browser" browser)))))
360 (zero? (system* "make" "-j" (number->string
361 (parallel-job-count))
364 (add-after 'install 'check
366 (with-directory-excursion "test-suite"
367 (zero? (system* "make"))))))))
368 (home-page "https://coq.inria.fr")
369 (synopsis "Proof assistant for higher-order logic")
371 "Coq is a proof assistant for higher-order logic, which allows the
372 development of computer programs consistent with their formal specification.
373 It is developed using Objective Caml and Camlp5.")
374 ;; The code is distributed under lgpl2.1.
375 ;; Some of the documentation is distributed under opl1.0+.
376 (license (list lgpl2.1 opl1.0+))))
378 (define-public proof-general
380 (name "proof-general")
385 "http://proofgeneral.inf.ed.ac.uk/releases/"
386 "ProofGeneral-" version ".tgz"))
389 "09qb0myq66fw17v4ziz401ilsb5xlxz1nl2wsp69d0vrfy0bcrrm"))))
390 (build-system gnu-build-system)
393 ("emacs" ,emacs-minimal)
394 ("texinfo" ,texinfo)))
396 `(("host-emacs" ,emacs)
400 `(#:tests? #f ; no check target
401 #:make-flags (list (string-append "PREFIX=" %output)
402 (string-append "DEST_PREFIX=" %output))
403 #:modules ((guix build gnu-build-system)
405 (guix build emacs-utils))
406 #:imported-modules (,@%gnu-build-system-modules
407 (guix build emacs-utils))
409 (modify-phases %standard-phases
411 (add-after 'unpack 'disable-byte-compile-error-on-warn
413 (substitute* "Makefile"
414 (("\\(setq byte-compile-error-on-warn t\\)")
415 "(setq byte-compile-error-on-warn nil)"))
417 (add-after 'unpack 'patch-hardcoded-paths
418 (lambda* (#:key inputs outputs #:allow-other-keys)
419 (let ((out (assoc-ref outputs "out"))
420 (coq (assoc-ref inputs "coq"))
421 (emacs (assoc-ref inputs "host-emacs")))
422 (define (coq-prog name)
423 (string-append coq "/bin/" name))
424 (emacs-substitute-variables "coq/coq.el"
425 ("coq-prog-name" (coq-prog "coqtop"))
426 ("coq-compiler" (coq-prog "coqc"))
427 ("coq-dependency-analyzer" (coq-prog "coqdep")))
428 (substitute* "Makefile"
429 (("/sbin/install-info") "install-info"))
430 (substitute* "bin/proofgeneral"
431 (("^PGHOMEDEFAULT=.*" all)
433 "PGHOME=$PGHOMEDEFAULT\n"
434 "EMACS=" emacs "/bin/emacs")))
436 (add-after 'unpack 'clean
438 ;; Delete the pre-compiled elc files for Emacs 23.
439 (zero? (system* "make" "clean"))))
440 (add-after 'install 'install-doc
441 (lambda* (#:key make-flags #:allow-other-keys)
442 ;; XXX FIXME avoid building/installing pdf files,
443 ;; due to unresolved errors building them.
444 (substitute* "Makefile"
445 ((" [^ ]*\\.pdf") ""))
446 (zero? (apply system* "make" "install-doc"
448 (home-page "http://proofgeneral.inf.ed.ac.uk/")
449 (synopsis "Generic front-end for proof assistants based on Emacs")
451 "Proof General is a major mode to turn Emacs into an interactive proof
452 assistant to write formal mathematical proofs using a variety of theorem
456 (define-public lablgtk
463 (uri (string-append "https://forge.ocamlcore.org/frs/download.php/"
464 "1479/lablgtk-2.18.3.tar.gz"))
467 "1bybn3jafxf4cx25zvn8h2xj9agn1xjbn7j3ywxxqx6az7rfnnwp"))))
468 (build-system gnu-build-system)
472 ("pkg-config" ,pkg-config)))
473 ;; FIXME: Add inputs gtkgl-2.0, libpanelapplet-2.0, gtkspell-2.0,
474 ;; and gtk+-quartz-2.0 once available.
477 ("gtksourceview" ,gtksourceview-2)
478 ("libgnomecanvas" ,libgnomecanvas)
479 ("libgnomeui" ,libgnomeui)
480 ("libglade" ,libglade)
481 ("librsvg" ,librsvg)))
483 `(#:tests? #f ; no check target
485 ;; opt: also install cmxa files
486 #:make-flags (list "all" "opt")
487 ;; Occasionally we would get "Error: Unbound module GtkThread" when
488 ;; compiling 'gtkThInit.ml', with 'make -j'. So build sequentially.
492 (modify-phases %standard-phases
494 (lambda* (#:key inputs outputs #:allow-other-keys)
495 (let ((out (assoc-ref outputs "out"))
496 (ocaml (assoc-ref inputs "ocaml")))
497 ;; Install into the output and not the ocaml directory.
498 (substitute* "config.make"
500 (system* "make" "old-install")
502 (home-page "http://lablgtk.forge.ocamlcore.org/")
503 (synopsis "GTK+ bindings for OCaml")
505 "LablGtk is an OCaml interface to GTK+ 1.2 and 2.x. It provides
506 a strongly-typed object-oriented interface that is compatible with the
507 dynamic typing of GTK+. Most widgets and methods are available. LablGtk
508 also provides bindings to
509 gdk-pixbuf, the GLArea widget (in combination with LablGL), gnomecanvas,
510 gnomeui, gtksourceview, gtkspell,
511 libglade (and it an generate OCaml code from .glade files),
512 libpanel, librsvg and quartz.")
515 (define-public unison
523 (url (string-append "https://webdav.seas.upenn.edu/svn/"
525 (version-major+minor version)))
527 (file-name (string-append name "-" version "-checkout"))
530 "0486s53wyayicj9f2raj2dvwvk4xyzar219rccc1iczdwixm4x05"))
531 (modules '((guix build utils)
537 ;; The svn revision in the release tarball appears to be
538 ;; artificially manipulated in order to set the desired point
539 ;; version number. Because the point version is calculated during
540 ;; the build, we can offset pointVersionOrigin by the desired
541 ;; point version and write that into "Rev: %d". We do this rather
542 ;; than hardcoding the necessary revision number, for
544 (with-atomic-file-replacement "src/mkProjectInfo.ml"
546 (let ((pt-ver (string->number (third (string-split ,version #\.))))
547 (pt-rx (make-regexp "^let pointVersionOrigin = ([0-9]+)"))
548 (rev-rx (make-regexp "Rev: [0-9]+")))
549 (let loop ((pt-origin #f))
550 (let ((line (read-line in 'concat)))
552 ((regexp-exec pt-rx line)
555 (loop (string->number (match:substring m 1)))))
556 ((regexp-exec rev-rx line)
558 (format out "~aRev: ~d~a"
562 (dump-port in out))) ;done
565 (loop pt-origin))))))))
566 ;; Without the '-fix' argument, the html file produced does not
567 ;; have functioning internal hyperlinks.
568 (substitute* "doc/Makefile"
569 (("hevea unison") "hevea -fix unison"))))))
570 (build-system gnu-build-system)
572 "doc")) ; 1.9 MiB of documentation
576 ("ghostscript-gs" ,ghostscript-gs)
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.")