summary refs log tree commit diff
path: root/pkgs/development/tools/ocaml/camlp4/default.nix
blob: a8043a9fc5ee586785ee8e6d85fbe891f9ff729c (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
{stdenv, fetchurl, which, ocaml}:
let
  ocaml_version = (stdenv.lib.getVersion ocaml);
in

assert stdenv.lib.versionAtLeast ocaml_version "4.02";

stdenv.mkDerivation {
  name = "camlp4-4.02.0+1";
  src = fetchurl {
    url = https://github.com/ocaml/camlp4/archive/4.02.0+1.tar.gz;
    sha256 = "0055f4jiz82rgn581xhq3mr4qgq2qgdxqppmp8i2x1xnsim4h9pn";
  };

  buildInputs = [ which ocaml ];

  dontAddPrefix = true;

  preConfigure = ''
    configureFlagsArray=(
      --bindir=$out/bin
      --libdir=$out/lib/ocaml/${ocaml_version}/site-lib
      --pkgdir=$out/lib/ocaml/${ocaml_version}/site-lib
    )
  '';

  postConfigure = ''
    substituteInPlace camlp4/META.in \
    --replace +camlp4 $out/lib/ocaml/${ocaml_version}/site-lib/camlp4
    substituteInPlace camlp4/config/Camlp4_config.ml \
    --replace \
      "Filename.concat ocaml_standard_library" \
      "Filename.concat \"$out/lib/ocaml/${ocaml_version}/site-lib\""
  '';


  makeFlags = "all";

  installTargets = "install install-META";

  meta = with stdenv.lib; {
    description = "A software system for writing extensible parsers for programming languages";
    homepage = https://github.com/ocaml/camlp4;
    platforms = ocaml.meta.platforms;
  };
}