anchor.diff:  
     debugInfo = enableDebugInfo;
   
  -  patchPhase = '' sed -i "s@/bin/rm@rm@" lib/odbc/configure erts/configure '';
  +  rmAndPwdPatch = fetchurl {
  +     url = "https://github.com/erlang/otp/commit/98b8650d22e94a5ff839170833f691294f6276d0.patch";
  +     sha256 = "0cd5pkqrigiqz6cyma5irqwzn0bi17k371k9vlg8ir31h3zmqfip";
  +  };
  +
  +  envAndCpPatch = fetchurl {
  +     url = "https://github.com/binarin/otp/commit/9f9841eb7327c9fe73e84e197fd2965a97b639cf.patch";
  +     sha256 = "10h5348p6g279b4q01i5jdqlljww5chcvrx5b4b0dv79pk0p0m9f";
  +  };
  +
  +  patches = [
  +    rmAndPwdPatch
  +    envAndCpPatch
  +  ];
   
     preConfigure = ''
  -    export HOME=$PWD/../
  -    sed -e s@/bin/pwd@pwd@g -i otp_build
  +    ./otp_build autoconf
     '';
   
     configureFlags= [
  
positive.code:     ++ optional javacSupport "--with-javac"
      ++ optional stdenv.isDarwin "--enable-darwin-64bit";
  
    postInstall = let
      manpages = fetchurl {
        url = "http://www.erlang.org/download/otp_doc_man_${version}.tar.gz";
        sha256 = "0abaqnw6hkr1h1zw6cdqwg2k7rfmj2b9sqqldnqf3qaj0shz759n";
      };
    in ''
      ln -s $out/lib/erlang/lib/erl_interface*/bin/erl_call $out/bin/erl_call
      tar xf "${manpages}" -C "$out/lib/erlang"
      for i in "$out"/lib/erlang/man/man[0-9]/*.[0-9]; do
        prefix="''${i%/*}"
        ensureDir "$out/share/man/''${prefix##*/}"
        ln -s "$i" "$out/share/man/''${prefix##*/}/''${i##*/}erl"
      done
    '';
  
    # Some erlang bin/ scripts run sed and awk
  
negative.code: stdenv.mkDerivation rec {
    name = "erlang-" + version + "${optionalString odbcSupport "-odbc"}"
    + "${optionalString javacSupport "-javac"}";
    version = "18.3.4";
  
    # Minor OTP releases are not always released as tarbals at
    # http://erlang.org/download/ So we have to download from
    # github. And for the same reason we can't use a prebuilt manpages
    # tarball and need to build manpages ourselves.
    src = fetchFromGitHub {
      owner = "erlang";
      repo = "otp";
      rev = "OTP-${version}";
      sha256 = "1f8nhybzsdmjvkmkzpjj3wj9jzx8mihlvi6gfp47fxkalansz39h";
    };
  
    buildInputs =
      [ perl gnum4 ncurses openssl autoconf libxslt libxml2 makeWrapper
      ] ++ optionals wxSupport (if stdenv.isDarwin then [ wxmac ] else [ mesa wxGTK xorg.libX11 ])
        ++ optional odbcSupport unixODBC
        ++ optional javacSupport openjdk
  