1{ stdenv, lib, fetchurl
2, coq, ocamlPackages
3, tools ? stdenv.cc
4}:
5
6assert lib.versionAtLeast ocamlPackages.ocaml.version "4.02";
7
8stdenv.mkDerivation rec {
9 name = "compcert-${version}";
10 version = "3.2";
11
12 src = fetchurl {
13 url = "http://compcert.inria.fr/release/${name}.tgz";
14 sha256 = "11q4121s0rxva63njjwya7syfx9w0p4hzr6avh8s57vfbrcakc93";
15 };
16
17 buildInputs = [ coq ]
18 ++ (with ocamlPackages; [ ocaml findlib menhir ]);
19
20 enableParallelBuilding = true;
21
22 postPatch = ''
23 sed -i -e 's/8\.6\.1|8\.7\.0|8\.7\.1)/8.6.1|8.7.0|8.7.1|8.7.2)/' configure
24 '';
25
26 configurePhase = ''
27 substituteInPlace ./configure --replace '{toolprefix}gcc' '{toolprefix}cc'
28 ./configure -clightgen -prefix $out -toolprefix ${tools}/bin/ '' +
29 (if stdenv.isDarwin then "x86_64-macosx" else "x86_64-linux");
30
31 installTargets = "documentation install";
32
33 postInstall = ''
34 mkdir -p $lib/share/doc/compcert
35 mv doc/html $lib/share/doc/compcert/
36 mkdir -p $lib/lib/coq/${coq.coq-version}/user-contrib/compcert/
37 mv backend cfrontend common cparser driver flocq x86 x86_64 lib \
38 $lib/lib/coq/${coq.coq-version}/user-contrib/compcert/
39 '';
40
41 outputs = [ "out" "lib" ];
42
43 meta = with stdenv.lib; {
44 description = "Formally verified C compiler";
45 homepage = "http://compcert.inria.fr";
46 license = licenses.inria-compcert;
47 platforms = platforms.linux ++
48 platforms.darwin;
49 maintainers = with maintainers; [ thoughtpolice jwiegley vbgl ];
50 };
51}