lol
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 17.09-beta 133 lines 5.8 kB view raw
1{ stdenv, fetchurl, patchelf, gmp }: 2 3let 4 version = "20130715"; 5 6 usr_prefix = if stdenv.isDarwin then "usr/local" else "usr"; 7 8 dynamic_linker = 9 if stdenv.isx86_64 then "${stdenv.glibc.out}/lib/ld-linux-x86-64.so.2" 10 else "${stdenv.glibc.out}/lib/ld-linux.so.2"; 11in 12 13stdenv.mkDerivation rec { 14 name = "mlton-${version}"; 15 16 binSrc = 17 if stdenv.system == "i686-linux" then (fetchurl { 18 url = "mirror://sourceforge/project/mlton/mlton/${version}/${name}-1.x86-linux.tgz"; 19 sha256 = "1kxjjmnw4xk2d9hpvz43w9dvyhb3025k4zvjx785c33nrwkrdn4j"; 20 }) 21 else if stdenv.system == "x86_64-linux" then (fetchurl { 22 url = "mirror://sourceforge/project/mlton/mlton/${version}/${name}-1.amd64-linux.tgz"; 23 sha256 = "0fyhwxb4nmpirjbjcvk9f6w67gmn2gkz7xcgz0xbfih9kc015ygn"; 24 }) 25 else if stdenv.system == "x86_64-darwin" then (fetchurl { 26 url = "mirror://sourceforge/project/mlton/mlton/${version}/${name}-1.amd64-darwin.gmp-macports.tgz"; 27 sha256 = "044wnh9hhg6if886xy805683k0as347xd37r0r1yi4x7qlxzzgx9"; 28 }) 29 else throw "Architecture not supported"; 30 31 codeSrc = 32 fetchurl { 33 url = "mirror://sourceforge/project/mlton/mlton/${version}/${name}.src.tgz"; 34 sha256 = "0v1x2hrh9hiqkvnbq11kf34v4i5a2x0ffxbzqaa8skyl26nmfn11"; 35 }; 36 37 srcs = [ binSrc codeSrc ]; 38 39 sourceRoot = name; 40 41 buildInputs = [ gmp ] ++ stdenv.lib.optional stdenv.isLinux patchelf; 42 43 makeFlags = [ "all-no-docs" ]; 44 45 configurePhase = '' 46 # Fix paths in the source. 47 find . -type f | grep -v -e '\.tgz''$' | xargs sed -i "s@/usr/bin/env bash@$(type -p bash)@" 48 49 substituteInPlace $(pwd)/Makefile --replace '/bin/cp' $(type -p cp) 50 substituteInPlace bin/mlton-script --replace gcc cc 51 substituteInPlace bin/regression --replace gcc cc 52 substituteInPlace lib/mlnlffi-lib/Makefile --replace gcc cc 53 substituteInPlace mlnlffigen/gen-cppcmd --replace gcc cc 54 substituteInPlace runtime/Makefile --replace gcc cc 55 substituteInPlace ../${usr_prefix}/bin/mlton --replace gcc cc 56 57 # Fix paths in the binary distribution. 58 BIN_DIST_DIR="$(pwd)/../${usr_prefix}" 59 for f in "bin/mlton" "lib/mlton/platform" "lib/mlton/static-library" ; do 60 substituteInPlace "$BIN_DIST_DIR/$f" --replace '/${usr_prefix}/bin/env bash' $(type -p bash) 61 done 62 63 substituteInPlace $(pwd)/../${usr_prefix}/bin/mlton --replace '/${usr_prefix}/lib/mlton' $(pwd)/../${usr_prefix}/lib/mlton 64 '' + stdenv.lib.optionalString stdenv.cc.isClang '' 65 sed -i "s_ patch -s -p0 <gdtoa.hide-public-fns.patch_ patch -s -p0 <gdtoa.hide-public-fns.patch\n\tsed -i 's|printf(emptyfmt|printf(\"\"|g' ./gdtoa/arithchk.c_" ./runtime/Makefile 66 '' + stdenv.lib.optionalString stdenv.isDarwin '' 67 sed -i 's|XCFLAGS += -I/usr/local/include -I/sw/include -I/opt/local/include||' ./runtime/Makefile 68 ''; 69 70 preBuild = '' 71 # To build the source we have to put the binary distribution in the $PATH. 72 export PATH="$PATH:$(pwd)/../${usr_prefix}/bin/" 73 74 # Let the builder execute the binary distribution. 75 chmod u+x $(pwd)/../${usr_prefix}/bin/mllex 76 chmod u+x $(pwd)/../${usr_prefix}/bin/mlyacc 77 chmod u+x $(pwd)/../${usr_prefix}/bin/mlton 78 79 # So the builder runs the binary compiler with gmp. 80 export LD_LIBRARY_PATH=${gmp.out}/lib:$LD_LIBRARY_PATH 81 82 '' + stdenv.lib.optionalString stdenv.isLinux '' 83 # Patch ELF interpreter. 84 patchelf --set-interpreter ${dynamic_linker} $(pwd)/../${usr_prefix}/lib/mlton/mlton-compile 85 for e in mllex mlyacc ; do 86 patchelf --set-interpreter ${dynamic_linker} $(pwd)/../${usr_prefix}/bin/$e 87 done 88 '' + stdenv.lib.optionalString stdenv.isDarwin '' 89 # Patch libgmp linking 90 install_name_tool -change /opt/local/lib/libgmp.10.dylib ${gmp}/lib/libgmp.10.dylib $(pwd)/../${usr_prefix}/lib/mlton/mlton-compile 91 install_name_tool -change /opt/local/lib/libgmp.10.dylib ${gmp}/lib/libgmp.10.dylib $(pwd)/../${usr_prefix}/bin/mlyacc 92 install_name_tool -change /opt/local/lib/libgmp.10.dylib ${gmp}/lib/libgmp.10.dylib $(pwd)/../${usr_prefix}/bin/mllex 93 ''; 94 95 doCheck = true; 96 97 installTargets = [ "install-no-docs" ]; 98 99 postInstall = '' 100 # Fix path to mlton libraries. 101 substituteInPlace $(pwd)/install/${usr_prefix}/bin/mlton --replace '/${usr_prefix}/lib/mlton' $out/lib/mlton 102 103 # Path to libgmp. 104 substituteInPlace $(pwd)/install/${usr_prefix}/bin/mlton --replace "-link-opt '-lm -lgmp'" "-link-opt '-lm -lgmp -L${gmp.out}/lib'" 105 106 # Path to gmp.h. 107 substituteInPlace $(pwd)/install/${usr_prefix}/bin/mlton --replace "-cc-opt '-O1 -fno-common'" "-cc-opt '-O1 -fno-common -I${gmp.dev}/include'" 108 109 # Path to the same cc used in the build; needed at runtime. 110 substituteInPlace $(pwd)/install/${usr_prefix}/bin/mlton --replace "gcc='gcc'" "gcc='"$(type -p cc)"'" 111 112 # Copy files to final positions. 113 cp -r $(pwd)/install/${usr_prefix}/bin $out 114 cp -r $(pwd)/install/${usr_prefix}/lib $out 115 cp -r $(pwd)/install/${usr_prefix}/man $out 116 ''; 117 118 meta = { 119 description = "Open-source, whole-program, optimizing Standard ML compiler"; 120 longDescription = '' 121 MLton is an open source, whole-program optimizing compiler for the Standard ML programming language. 122 MLton aims to produce fast executables, and to encourage rapid prototyping and modular programming 123 by eliminating performance penalties often associated with the use of high-level language features. 124 MLton development began in 1997, and continues to this day with a growing worldwide community of 125 developers and users, who have helped to port MLton to a number of platforms. 126 Description taken from http://en.wikipedia.org/wiki/Mlton . 127 ''; 128 129 homepage = http://mlton.org/; 130 license = "bsd"; 131 platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin"]; 132 }; 133}