2021-01-22 12:25:31 +01:00
|
|
|
{ lib, stdenv, fetchurl, patchelf, gmp }:
|
2018-10-12 06:21:49 +02:00
|
|
|
let
|
|
|
|
dynamic-linker = stdenv.cc.bintools.dynamicLinker;
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 14:41:18 +02:00
|
|
|
pname = "mlton";
|
2018-10-12 06:21:49 +02:00
|
|
|
version = "20180207";
|
|
|
|
|
|
|
|
src = if stdenv.hostPlatform.system == "x86_64-linux" then (fetchurl {
|
2019-08-15 14:41:18 +02:00
|
|
|
url = "https://github.com/MLton/mlton/releases/download/on-${version}-release/${pname}-${version}-1.amd64-linux.tgz";
|
2018-10-12 06:21:49 +02:00
|
|
|
sha256 = "0f4q575yfm5dpg4a2wsnqn4l2zrar96p6rlsk0dw10ggyfwvsjlf";
|
|
|
|
})
|
|
|
|
else if stdenv.hostPlatform.system == "x86_64-darwin" then (fetchurl {
|
2019-08-15 14:41:18 +02:00
|
|
|
url = "https://github.com/MLton/mlton/releases/download/on-${version}-release/${pname}-${version}-1.amd64-darwin.gmp-static.tgz";
|
2018-10-12 06:21:49 +02:00
|
|
|
sha256 = "1cw7yhw48qp12q0adwf8srpjzrgkp84kmlkqw3pz8vkxz4p9hbdv";
|
|
|
|
})
|
|
|
|
else
|
|
|
|
throw "Architecture not supported";
|
|
|
|
|
|
|
|
buildInputs = [ gmp ];
|
2021-01-22 12:25:31 +01:00
|
|
|
nativeBuildInputs = lib.optional stdenv.isLinux patchelf;
|
2018-10-12 06:21:49 +02:00
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
make update \
|
|
|
|
CC="$(type -p cc)" \
|
|
|
|
WITH_GMP_INC_DIR="${gmp.dev}/include" \
|
|
|
|
WITH_GMP_LIB_DIR="${gmp}/lib"
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
make install PREFIX=$out
|
|
|
|
'';
|
|
|
|
|
2021-01-22 12:25:31 +01:00
|
|
|
postFixup = lib.optionalString stdenv.isLinux ''
|
2018-10-12 06:21:49 +02:00
|
|
|
patchelf --set-interpreter ${dynamic-linker} $out/lib/mlton/mlton-compile
|
|
|
|
patchelf --set-rpath ${gmp}/lib $out/lib/mlton/mlton-compile
|
|
|
|
|
|
|
|
for e in mllex mlnlffigen mlprof mlyacc; do
|
|
|
|
patchelf --set-interpreter ${dynamic-linker} $out/bin/$e
|
|
|
|
patchelf --set-rpath ${gmp}/lib $out/bin/$e
|
|
|
|
done
|
2021-01-22 12:25:31 +01:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
2018-10-12 06:21:49 +02:00
|
|
|
install_name_tool -change \
|
|
|
|
/opt/local/lib/libgmp.10.dylib \
|
|
|
|
${gmp}/lib/libgmp.10.dylib \
|
|
|
|
$out/lib/mlton/mlton-compile
|
|
|
|
|
|
|
|
for e in mllex mlnlffigen mlprof mlyacc; do
|
|
|
|
install_name_tool -change \
|
|
|
|
/opt/local/lib/libgmp.10.dylib \
|
|
|
|
${gmp}/lib/libgmp.10.dylib \
|
|
|
|
$out/bin/$e
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = import ./meta.nix;
|
|
|
|
}
|