Merge pull request #119126 from fabaff/pycomfoconnect
[NixPkgs.git] / pkgs / development / compilers / mlton / 20180207-binary.nix
blob4846b58bf26be7156a0598846191823a34bf71ff
1 { lib, stdenv, fetchurl, patchelf, gmp }:
2 let
3   dynamic-linker = stdenv.cc.bintools.dynamicLinker;
4 in
5 stdenv.mkDerivation rec {
6   pname = "mlton";
7   version = "20180207";
9   src = if stdenv.hostPlatform.system == "x86_64-linux" then (fetchurl {
10     url = "https://github.com/MLton/mlton/releases/download/on-${version}-release/${pname}-${version}-1.amd64-linux.tgz";
11     sha256 = "0f4q575yfm5dpg4a2wsnqn4l2zrar96p6rlsk0dw10ggyfwvsjlf";
12     })
13   else if stdenv.hostPlatform.system == "x86_64-darwin" then (fetchurl {
14     url = "https://github.com/MLton/mlton/releases/download/on-${version}-release/${pname}-${version}-1.amd64-darwin.gmp-static.tgz";
15       sha256 = "1cw7yhw48qp12q0adwf8srpjzrgkp84kmlkqw3pz8vkxz4p9hbdv";
16     })
17   else
18     throw "Architecture not supported";
20   buildInputs = [ gmp ];
21   nativeBuildInputs = lib.optional stdenv.isLinux patchelf;
23   buildPhase = ''
24     make update \
25       CC="$(type -p cc)" \
26       WITH_GMP_INC_DIR="${gmp.dev}/include" \
27       WITH_GMP_LIB_DIR="${gmp}/lib"
28   '';
30   installPhase = ''
31     make install PREFIX=$out
32   '';
34   postFixup = lib.optionalString stdenv.isLinux ''
35     patchelf --set-interpreter ${dynamic-linker} $out/lib/mlton/mlton-compile
36     patchelf --set-rpath ${gmp}/lib $out/lib/mlton/mlton-compile
38     for e in mllex mlnlffigen mlprof mlyacc; do
39       patchelf --set-interpreter ${dynamic-linker} $out/bin/$e
40       patchelf --set-rpath ${gmp}/lib $out/bin/$e
41     done
42   '' + lib.optionalString stdenv.isDarwin ''
43     install_name_tool -change \
44       /opt/local/lib/libgmp.10.dylib \
45       ${gmp}/lib/libgmp.10.dylib \
46       $out/lib/mlton/mlton-compile
48     for e in mllex mlnlffigen mlprof mlyacc; do
49       install_name_tool -change \
50         /opt/local/lib/libgmp.10.dylib \
51         ${gmp}/lib/libgmp.10.dylib \
52         $out/bin/$e
53     done
54   '';
56   meta = import ./meta.nix;