about summary refs log tree commit diff
path: root/pkgs/development/compilers/ehc/default.nix
blob: cdb6481caf0171746d631a67f3d787960c1562d2 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{stdenv, coreutils, fetchsvn, m4, libtool, ghc, uulib, uuagc, llvm}:

stdenv.mkDerivation (rec {
  name = "ehc-svn-1036";
  homepage = "http://www.cs.uu.nl/wiki/Ehc/WebHome/";

  src = fetchsvn {
          url = https://svn.cs.uu.nl:12443/repos/EHC/trunk/EHC;
          rev = "1037";
          sha256 = "b2388cfadeb26ce716ff355fbdd73ba2e30219c5b423fbd609355b420300644c";
  };

  buildInputs = [coreutils m4 ghc libtool uulib uuagc llvm];

  preConfigure = ''
    find src -name files\*.mk -exec sed -i -- "s/--user//g" '{}' \;
    sed -i "s|/bin/date|${coreutils}/bin/date|g" mk/dist.mk
    echo "RTS_GCC_CC_OPTS := -std=gnu99" >> mk/shared.mk.in
  '';

  buildFlags = "100/ehc 100/ehclib";

  installPhase = ''
    cd bin

    # install executables
    echo "installing executables..."
    mkdir -p $out/bin-ehc
    for i in *; do
      if [[ -d $i ]]; then
        cp $i/ehc $out/bin-ehc/ehc-$i
      fi;
    done

    # install runtime support
    cp -r ../install/* $out

    # install prelude
    echo "installing prelude..."
    mkdir -p $out/lib-ehc
    for i in *; do
      if [[ -d ../build/$i/ehclib/ehcbase ]]; then
        mkdir -p $out/lib-ehc/$i
        cp -r ../build/$i/ehclib/ehcbase $out/lib-ehc/$i
      fi;
    done

    # generate wrappers
    echo "generating wrappers..."
    mkdir -p $out/bin
    for in in *; do
      if [[ -d $i ]]; then
        echo '#!'"$SHELL" > $out/bin/ehc-$i
        echo "exec \"$out/bin-ehc/ehc-$i\" -P $out/lib-ehc/$i/ehcbase" '"$@"' >> $out/bin/ehc-$i
        chmod 751 $out/bin/ehc-$i
      fi;
    done
  '';

  meta = {
    description = "Essential Haskell Compiler";
  };

  inherit coreutils;
})