about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/ocaml-modules/optcomp/default.nix
blob: c177ef52e1519dc4e0238c2494e9bf0e32b24f65 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{ stdenv, fetchurl, fetchpatch, ocaml, findlib, ocamlbuild, camlp4 }:

stdenv.mkDerivation {
  name = "ocaml-optcomp-1.6";
  src = fetchurl {
    url = "https://github.com/diml/optcomp/archive/1.6.tar.gz";
    sha256 = "0hhhb2gisah1h22zlg5iszbgqxdd7x85cwd57bd4mfkx9l7dh8jh";
  };

  patches =
    let inherit (stdenv.lib) optional versionAtLeast; in
    optional (versionAtLeast ocaml.version "4.02") (fetchpatch {
      url = "https://github.com/diml/optcomp/commit/b7f809360c9794b383a4bc0492f6df381276b429.patch";
      sha256 = "1n095lk94jq1rwi0l24g2wbgms7249wdd31n0ji895dr6755s93y";
    })
  ;
  
  createFindlibDestdir = true;

  buildInputs = [ ocaml findlib ocamlbuild camlp4 ];

  configurePhase = ''
    cp ${./META} META
  '';

  buildPhase = ''
    ocamlbuild src/optcomp.cmxs src/optcomp.cma src/optcomp_o.native src/optcomp_r.native
  '';

  installPhase = ''
    mkdir -p $out/bin
    cp _build/src/optcomp_o.native $out/bin/optcomp-o
    cp _build/src/optcomp_r.native $out/bin/optcomp-r
    ocamlfind install optcomp META _build/src/optcomp.{a,cma,cmxa,cmxs} _build/src/pa_optcomp.{cmi,cmx,mli}
  '';

  meta =  {
    homepage = "https://github.com/diml/optcomp";
    description = "Optional compilation for OCaml with cpp-like directives";
    license = stdenv.lib.licenses.bsd3;
    platforms = ocaml.meta.platforms or [];
    maintainers = [
      stdenv.lib.maintainers.gal_bolle
    ];
  };

}