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 texlive)
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 (build-system gnu-build-system)
66 (list (search-path-specification
67 (variable "OCAMLPATH")
68 (files (list (string-append "lib/ocaml"))))))
71 ("pkg-config" ,pkg-config)))
74 ;; For libiberty, needed for objdump support.
75 ("gcc:lib" ,(canonical-package gcc-4.9) "lib")
76 ("zlib" ,zlib))) ;also needed for objdump support
78 `(#:modules ((guix build gnu-build-system)
82 (modify-phases %standard-phases
83 (add-after 'unpack 'patch-/bin/sh-references
84 (lambda* (#:key inputs #:allow-other-keys)
85 (let* ((sh (string-append (assoc-ref inputs "bash")
87 (quoted-sh (string-append "\"" sh "\"")))
88 (with-fluids ((%default-port-encoding #f))
89 (for-each (lambda (file)
93 (format (current-error-port) "\
94 patch-/bin/sh-references: ~a: changing `\"/bin/sh\"' to `~a'~%"
97 (find-files "." "\\.ml$"))
100 (lambda* (#:key outputs #:allow-other-keys)
101 (let* ((out (assoc-ref outputs "out"))
102 (mandir (string-append out "/share/man")))
103 ;; Custom configure script doesn't recognize
104 ;; --prefix=<PREFIX> syntax (with equals sign).
105 (zero? (system* "./configure"
107 "--mandir" mandir)))))
110 (zero? (system* "make" "-j" (number->string
111 (parallel-job-count))
114 (add-after 'install 'check
116 (with-directory-excursion "testsuite"
117 (zero? (system* "make" "all")))))
118 (add-before 'check 'prepare-socket-test
120 (format (current-error-port)
121 "Spawning local test web server on port 8080~%")
122 (when (zero? (primitive-fork))
123 (run-server (lambda (request request-body)
124 (values '((content-type . (text/plain)))
126 'http '(#:port 8080)))
127 (let ((file "testsuite/tests/lib-threads/testsocket.ml"))
128 (format (current-error-port)
129 "Patching ~a to use localhost port 8080~%"
132 (("caml.inria.fr") "localhost")
134 (("HTTP1.0") "HTTP/1.0"))
136 (home-page "https://ocaml.org/")
137 (synopsis "The OCaml programming language")
139 "OCaml is a general purpose industrial-strength programming language with
140 an emphasis on expressiveness and safety. Developed for more than 20 years at
141 Inria it benefits from one of the most advanced type systems and supports
142 functional, imperative and object-oriented styles of programming.")
143 ;; The compiler is distributed under qpl1.0 with a change to choice of
144 ;; law: the license is governed by the laws of France. The library is
145 ;; distributed under lgpl2.0.
146 (license (list qpl lgpl2.0))))
154 ;; Use the '-full' version, which includes all the dependencies.
156 "https://github.com/ocaml/opam/releases/download/"
157 version "/opam-full-" version ".tar.gz")
158 ;; (string-append "https://github.com/ocaml/opam/archive/"
159 ;; version ".tar.gz")
163 "1frzqkx6yn1pnyd9qz3bv3rbwv74bmc1xji8kl41r1dkqzfl3xqv"))))
164 (build-system gnu-build-system)
166 '(;; Sometimes, 'make -jX' would fail right after ./configure with
167 ;; "Fatal error: exception End_of_file".
170 ;; For some reason, 'ocp-build' needs $TERM to be set.
171 #:make-flags '("TERM=screen")
172 #:test-target "tests"
174 ;; FIXME: There's an obscure test failure:
175 ;; …/_obuild/opam/opam.asm install P1' failed.
178 #:phases (alist-cons-before
180 (lambda* (#:key inputs #:allow-other-keys)
181 (let ((bash (assoc-ref inputs "bash")))
182 (substitute* "src/core/opamSystem.ml"
184 (string-append "\"" bash "/bin/sh\"")))))
188 (setenv "HOME" (getcwd))
189 (and (system "git config --global user.email guix@gnu.org")
190 (system "git config --global user.name Guix")))
193 `(("git" ,git) ;for the tests
194 ("python" ,python))) ;for the tests
199 (home-page "http://opam.ocamlpro.com/")
200 (synopsis "Package manager for OCaml")
202 "OPAM is a tool to manage OCaml packages. It supports multiple
203 simultaneous compiler installations, flexible package constraints, and a
204 Git-friendly development workflow.")
206 ;; The 'LICENSE' file waives some requirements compared to LGPLv3.
209 (define-public camlp4
215 (uri (string-append "https://github.com/ocaml/camlp4/archive/"
219 "0icdfzhsbgf89925gc8gl3fm8z2xzszzlib0v9dj5wyzkyv3a342"))
220 (file-name (string-append name "-" version ".tar.gz"))))
221 (build-system gnu-build-system)
222 (native-inputs `(("ocaml" ,ocaml)
224 (inputs `(("ocaml" ,ocaml)))
226 '(#:tests? #f ;no documented test target
227 #:phases (modify-phases %standard-phases
230 (lambda* (#:key outputs #:allow-other-keys)
231 ;; This is a home-made 'configure' script.
232 (let ((out (assoc-ref outputs "out")))
233 (zero? (system* "./configure"
234 (string-append "--libdir=" out "/lib")
235 (string-append "--bindir=" out "/bin")
236 (string-append "--pkgdir=" out)))))))))
237 (home-page "https://github.com/ocaml/camlp4")
238 (synopsis "Write parsers in OCaml")
240 "Camlp4 is a software system for writing extensible parsers for
241 programming languages. It provides a set of OCaml libraries that are used to
242 define grammars as well as loadable syntax extensions of such grammars.
243 Camlp4 stands for Caml Preprocessor and Pretty-Printer and one of its most
244 important applications is the definition of domain-specific extensions of the
247 ;; This is LGPLv2 with an exception that allows packages statically-linked
248 ;; against the library to be released under any terms.
251 (define-public camlp5
257 (uri (string-append "http://camlp5.gforge.inria.fr/distrib/src/"
258 name "-" version ".tgz"))
261 "1ql04iyvclpyy9805kpddc4ndjb5d0qg4shhi2fc6bixi49fvy89"))))
262 (build-system gnu-build-system)
266 `(#:tests? #f ; XXX TODO figure out how to run the tests
268 (modify-phases %standard-phases
270 (lambda* (#:key outputs #:allow-other-keys)
271 (let* ((out (assoc-ref outputs "out"))
272 (mandir (string-append out "/share/man")))
273 ;; Custom configure script doesn't recognize
274 ;; --prefix=<PREFIX> syntax (with equals sign).
275 (zero? (system* "./configure"
277 "--mandir" mandir)))))
280 (zero? (system* "make" "-j" (number->string
281 (parallel-job-count))
283 (home-page "http://camlp5.gforge.inria.fr/")
284 (synopsis "Pre-processor Pretty Printer for OCaml")
286 "Camlp5 is a Pre-Processor-Pretty-Printer for Objective Caml. It offers
287 tools for syntax (Stream Parsers and Grammars) and the ability to modify the
288 concrete syntax of the language (Quotations, Syntax Extensions).")
289 ;; Most files are distributed under bsd-3, but ocaml_stuff/* is under qpl.
290 (license (list bsd-3 qpl))))
298 (uri (string-append "http://hevea.inria.fr/old/"
299 name "-" version ".tar.gz"))
302 "14fns13wlnpiv9i05841kvi3cq4b9v2sw5x3ff6ziws28q701qnd"))))
303 (build-system gnu-build-system)
307 `(#:tests? #f ; no test suite
308 #:make-flags (list (string-append "PREFIX=" %output))
309 #:phases (modify-phases %standard-phases
311 (add-before 'build 'patch-/bin/sh
314 (("/bin/sh") (which "sh")))
316 (home-page "http://hevea.inria.fr/")
317 (synopsis "LaTeX to HTML translator")
319 "HeVeA is a LaTeX to HTML translator that generates modern HTML 5. It is
320 written in Objective Caml.")
329 (uri (string-append "https://coq.inria.fr/distrib/V" version
330 "/files/" name "-" version ".tar.gz"))
333 "1mpbj4yf36kpjg2v2sln12i8dzqn8rag6fd07hslj2lpm4qs4h55"))))
334 (build-system gnu-build-system)
336 `(("texlive" ,texlive)
343 (modify-phases %standard-phases
345 (lambda* (#:key outputs #:allow-other-keys)
346 (let* ((out (assoc-ref outputs "out"))
347 (mandir (string-append out "/share/man"))
348 (browser "icecat -remote \"OpenURL(%s,new-tab)\""))
349 (zero? (system* "./configure"
352 "--browser" browser)))))
355 (zero? (system* "make" "-j" (number->string
356 (parallel-job-count))
359 (add-after 'install 'check
361 (with-directory-excursion "test-suite"
362 (zero? (system* "make"))))))))
363 (home-page "https://coq.inria.fr")
364 (synopsis "Proof assistant for higher-order logic")
366 "Coq is a proof assistant for higher-order logic, which allows the
367 development of computer programs consistent with their formal specification.
368 It is developed using Objective Caml and Camlp5.")
369 ;; The code is distributed under lgpl2.1.
370 ;; Some of the documentation is distributed under opl1.0+.
371 (license (list lgpl2.1 opl1.0+))))
373 (define-public proof-general
375 (name "proof-general")
380 "http://proofgeneral.inf.ed.ac.uk/releases/"
381 "ProofGeneral-" version ".tgz"))
384 "09qb0myq66fw17v4ziz401ilsb5xlxz1nl2wsp69d0vrfy0bcrrm"))))
385 (build-system gnu-build-system)
388 ("emacs" ,emacs-no-x)
389 ("texinfo" ,texinfo)))
391 `(("host-emacs" ,emacs)
395 `(#:tests? #f ; no check target
396 #:make-flags (list (string-append "PREFIX=" %output)
397 (string-append "DEST_PREFIX=" %output))
398 #:modules ((guix build gnu-build-system)
400 (guix build emacs-utils))
401 #:imported-modules (,@%gnu-build-system-modules
402 (guix build emacs-utils))
404 (modify-phases %standard-phases
406 (add-after 'unpack 'disable-byte-compile-error-on-warn
408 (substitute* "Makefile"
409 (("\\(setq byte-compile-error-on-warn t\\)")
410 "(setq byte-compile-error-on-warn nil)"))
412 (add-after 'unpack 'patch-hardcoded-paths
413 (lambda* (#:key inputs outputs #:allow-other-keys)
414 (let ((out (assoc-ref outputs "out"))
415 (coq (assoc-ref inputs "coq"))
416 (emacs (assoc-ref inputs "host-emacs")))
417 (define (coq-prog name)
418 (string-append coq "/bin/" name))
419 (emacs-substitute-variables "coq/coq.el"
420 ("coq-prog-name" (coq-prog "coqtop"))
421 ("coq-compiler" (coq-prog "coqc"))
422 ("coq-dependency-analyzer" (coq-prog "coqdep")))
423 (substitute* "Makefile"
424 (("/sbin/install-info") "install-info"))
425 (substitute* "bin/proofgeneral"
426 (("^PGHOMEDEFAULT=.*" all)
428 "PGHOME=$PGHOMEDEFAULT\n"
429 "EMACS=" emacs "/bin/emacs")))
431 (add-after 'unpack 'clean
433 ;; Delete the pre-compiled elc files for Emacs 23.
434 (zero? (system* "make" "clean"))))
435 (add-after 'install 'install-doc
436 (lambda* (#:key make-flags #:allow-other-keys)
437 ;; XXX FIXME avoid building/installing pdf files,
438 ;; due to unresolved errors building them.
439 (substitute* "Makefile"
440 ((" [^ ]*\\.pdf") ""))
441 (zero? (apply system* "make" "install-doc"
443 (home-page "http://proofgeneral.inf.ed.ac.uk/")
444 (synopsis "Generic front-end for proof assistants based on Emacs")
446 "Proof General is a major mode to turn Emacs into an interactive proof
447 assistant to write formal mathematical proofs using a variety of theorem
451 (define-public lablgtk
458 (uri (string-append "https://forge.ocamlcore.org/frs/download.php/"
459 "1479/lablgtk-2.18.3.tar.gz"))
462 "1bybn3jafxf4cx25zvn8h2xj9agn1xjbn7j3ywxxqx6az7rfnnwp"))))
463 (build-system gnu-build-system)
467 ("pkg-config" ,pkg-config)))
468 ;; FIXME: Add inputs gtkgl-2.0, libpanelapplet-2.0, gtkspell-2.0,
469 ;; and gtk+-quartz-2.0 once available.
472 ("gtksourceview" ,gtksourceview-2)
473 ("libgnomecanvas" ,libgnomecanvas)
474 ("libgnomeui" ,libgnomeui)
475 ("libglade" ,libglade)
476 ("librsvg" ,librsvg)))
478 `(#:tests? #f ; no check target
480 ;; opt: also install cmxa files
481 #:make-flags (list "all" "opt")
482 ;; Occasionally we would get "Error: Unbound module GtkThread" when
483 ;; compiling 'gtkThInit.ml', with 'make -j'. So build sequentially.
487 (modify-phases %standard-phases
489 (lambda* (#:key inputs outputs #:allow-other-keys)
490 (let ((out (assoc-ref outputs "out"))
491 (ocaml (assoc-ref inputs "ocaml")))
492 ;; Install into the output and not the ocaml directory.
493 (substitute* "config.make"
495 (system* "make" "old-install")
497 (home-page "http://lablgtk.forge.ocamlcore.org/")
498 (synopsis "GTK+ bindings for OCaml")
500 "LablGtk is an OCaml interface to GTK+ 1.2 and 2.x. It provides
501 a strongly-typed object-oriented interface that is compatible with the
502 dynamic typing of GTK+. Most widgets and methods are available. LablGtk
503 also provides bindings to
504 gdk-pixbuf, the GLArea widget (in combination with LablGL), gnomecanvas,
505 gnomeui, gtksourceview, gtkspell,
506 libglade (and it an generate OCaml code from .glade files),
507 libpanel, librsvg and quartz.")
510 (define-public unison
518 (url (string-append "https://webdav.seas.upenn.edu/svn/"
520 (version-major+minor version)))
522 (file-name (string-append name "-" version "-checkout"))
525 "0486s53wyayicj9f2raj2dvwvk4xyzar219rccc1iczdwixm4x05"))
526 (modules '((guix build utils)
532 ;; The svn revision in the release tarball appears to be
533 ;; artificially manipulated in order to set the desired point
534 ;; version number. Because the point version is calculated during
535 ;; the build, we can offset pointVersionOrigin by the desired
536 ;; point version and write that into "Rev: %d". We do this rather
537 ;; than hardcoding the necessary revision number, for
539 (with-atomic-file-replacement "src/mkProjectInfo.ml"
541 (let ((pt-ver (string->number (third (string-split ,version #\.))))
542 (pt-rx (make-regexp "^let pointVersionOrigin = ([0-9]+)"))
543 (rev-rx (make-regexp "Rev: [0-9]+")))
544 (let loop ((pt-origin #f))
545 (let ((line (read-line in 'concat)))
547 ((regexp-exec pt-rx line)
550 (loop (string->number (match:substring m 1)))))
551 ((regexp-exec rev-rx line)
553 (format out "~aRev: ~d~a"
557 (dump-port in out))) ;done
560 (loop pt-origin))))))))
561 ;; Without the '-fix' argument, the html file produced does not
562 ;; have functioning internal hyperlinks.
563 (substitute* "doc/Makefile"
564 (("hevea unison") "hevea -fix unison"))))))
565 (build-system gnu-build-system)
567 "doc")) ; 1.9 MiB of documentation
571 ("ghostscript" ,ghostscript)
576 `(#:parallel-build? #f
578 #:test-target "selftest"
579 #:tests? #f ; Tests require writing to $HOME.
580 ; If some $HOME is provided, they fail with the message
581 ; "Fatal error: Skipping some tests -- remove me!"
583 (modify-phases %standard-phases
585 (add-before 'install 'prepare-install
586 (lambda* (#:key outputs #:allow-other-keys)
587 (let* ((out (assoc-ref outputs "out"))
588 (bin (string-append out "/bin")))
590 (setenv "HOME" out) ; forces correct INSTALLDIR in Makefile
592 (add-after 'install 'install-doc
593 (lambda* (#:key inputs outputs #:allow-other-keys)
594 (let ((doc (string-append (assoc-ref outputs "doc")
595 "/share/doc/unison")))
597 ;; This file needs write-permissions, because it's
598 ;; overwritten by 'docs' during documentation generation.
599 (chmod "src/strings.ml" #o600)
600 (and (zero? (system* "make" "docs"
601 "TEXDIRECTIVES=\\\\draftfalse"))
603 (for-each (lambda (f)
604 (install-file f doc))
607 "doc/unison-manual." ext))
608 ;; Install only html documentation,
609 ;; since the build is currently
610 ;; non-reproducible with the ps, pdf,
615 (home-page "https://www.cis.upenn.edu/~bcpierce/unison/")
616 (synopsis "File synchronizer")
618 "Unison is a file-synchronization tool. It allows two replicas of
619 a collection of files and directories to be stored on different hosts
620 (or different disks on the same host), modified separately, and then
621 brought up to date by propagating the changes in each replica
625 (define-public ocaml-findlib
627 (name "ocaml-findlib")
631 (uri (string-append "http://download.camlcity.org/download/"
632 "findlib" "-" version ".tar.gz"))
635 "02abg1lsnwvjg3igdyb8qjgr5kv1nbwl4gaf8mdinzfii5p82721"))
636 (patches (search-patches "ocaml-findlib-make-install.patch"))))
637 (build-system gnu-build-system)
643 `(#:tests? #f ; no test suite
645 #:make-flags (list "all" "opt")
646 #:phases (modify-phases %standard-phases
649 (lambda* (#:key inputs outputs #:allow-other-keys)
650 (let ((out (assoc-ref outputs "out")))
653 "-bindir" (string-append out "/bin")
654 "-config" (string-append out "/etc/ocamfind.conf")
655 "-mandir" (string-append out "/share/man")
656 "-sitelib" (string-append out "/lib/ocaml/site-lib")
657 "-with-toolbox")))))))
658 (home-page "http://projects.camlcity.org/projects/findlib.html")
659 (synopsis "Management tool for OCaml libraries")
661 "The \"findlib\" library provides a scheme to manage reusable software
662 components (packages), and includes tools that support this scheme. Packages
663 are collections of OCaml modules for which metainformation can be stored. The
664 packages are kept in the filesystem hierarchy, but with strict directory
665 structure. The library contains functions to look the directory up that
666 stores a package, to query metainformation about a package, and to retrieve
667 dependency information about multiple packages. There is also a tool that
668 allows the user to enter queries on the command-line. In order to simplify
669 compilation and linkage, there are new frontends of the various OCaml
670 compilers that can directly deal with packages.")