Merge pull request #119126 from fabaff/pycomfoconnect
[NixPkgs.git] / pkgs / development / compilers / ocaml / ber-metaocaml.nix
blobd3ab0d6e1c6099b783919b6355b412a7dd758c33
1 { lib, stdenv, fetchurl
2 , ncurses
3 , libX11, xorgproto, buildEnv
4 }:
6 let
7    useX11 = stdenv.isi686 || stdenv.isx86_64;
8    x11deps = [ libX11 xorgproto ];
9    inherit (lib) optionals;
11    baseOcamlBranch  = "4.07";
12    baseOcamlVersion = "${baseOcamlBranch}.1";
13    metaocamlPatch   = "107";
16 stdenv.mkDerivation rec {
17   pname = "ber-metaocaml";
18   version = metaocamlPatch;
20   src = fetchurl {
21     url = "https://caml.inria.fr/pub/distrib/ocaml-${baseOcamlBranch}/ocaml-${baseOcamlVersion}.tar.gz";
22     sha256 = "1x4sln131mcspisr22qc304590rvg720rbl7g2i4xiymgvhkpm1a";
23   };
25   metaocaml = fetchurl {
26     url = "http://okmij.org/ftp/ML/ber-metaocaml-107.tar.gz";
27     sha256 = "0xy6n0yj1f53pk612zfmn49pn04bd75qa40xgmr0w0lzx6dqsfmm";
28   };
30   x11env = buildEnv { name = "x11env"; paths = x11deps; };
31   x11lib = "${x11env}/lib";
32   x11inc = "${x11env}/include";
34   prefixKey = "-prefix ";
35   configureFlags = optionals useX11
36     [ "-x11lib" x11lib
37       "-x11include" x11inc
38       "-flambda"
39     ];
41   dontStrip = true;
42   buildInputs = [ ncurses ] ++ optionals useX11 x11deps;
44   postConfigure = ''
45     tar -xvzf $metaocaml
46     cd ${pname}-${version}
47     make patch
48     cd ..
49   '';
51   buildPhase = ''
52     make world
54     make bootstrap
55     make opt.opt
56     make -i install
57     make installopt
58     mkdir -p $out/include
59     ln -sv $out/lib/ocaml/caml $out/include/caml
60     cd ${pname}-${version}
61     make all
62   '';
64   installPhase = ''
65     make install
66     make install.opt
67   '';
69   checkPhase = ''
70     cd ${pname}-${version}
71     make test
72     make test-compile
73     make test-native
74     cd ..
75   '';
77   passthru = {
78     nativeCompilers = true;
79   };
81   meta = with lib; {
82     description     = "Multi-Stage Programming extension for OCaml";
83     homepage        = "http://okmij.org/ftp/ML/MetaOCaml.html";
84     license         = with licenses; [ /* compiler */ qpl /* library */ lgpl2 ];
85     maintainers     = with maintainers; [ thoughtpolice ];
87     branch          = baseOcamlBranch;
88     platforms       = with platforms; linux ++ darwin;
89     broken          = stdenv.isAarch64 || stdenv.isMips;
91     longDescription = ''
92       A simple extension of OCaml with the primitive type of code values, and
93       three basic multi-stage expression forms: Brackets, Escape, and Run.
94     '';
95   };