From 920ce3551d730e4a35e9b987d4270f79287cf03d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andres=20L=C3=B6h?= <mail@andres-loeh.de>
Date: Wed, 15 Aug 2007 11:25:20 +0000
Subject: [PATCH] * make ghc use the nix-provided gmp   - this fixes ghc on
 x86_64 and hopefully doesn't break 32-bit   - ghc-6.6.1 and -6.6 are tested
 on 64-bit, 6.4.2 might fail

svn path=/nixpkgs/trunk/; revision=9132
---
 pkgs/development/compilers/ghc-6.6.1/builder.sh  |  5 +++++
 pkgs/development/compilers/ghc-6.6.1/default.nix |  4 +++-
 pkgs/development/compilers/ghc-6.6/builder.sh    | 11 +++++++++++
 pkgs/development/compilers/ghc-6.6/default.nix   |  4 +++-
 pkgs/development/compilers/ghc/boot.nix          |  4 ++--
 pkgs/development/compilers/ghc/default.nix       |  4 ++--
 pkgs/top-level/all-packages.nix                  |  9 ++++-----
 7 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/pkgs/development/compilers/ghc-6.6.1/builder.sh b/pkgs/development/compilers/ghc-6.6.1/builder.sh
index 75b97218f30..0ea4fc496f9 100644
--- a/pkgs/development/compilers/ghc-6.6.1/builder.sh
+++ b/pkgs/development/compilers/ghc-6.6.1/builder.sh
@@ -11,11 +11,16 @@ postInstall()
 }
 postInstall=postInstall
 
+configureFlags="--with-gmp-libraries=$gmp/lib --with-readline-libraries=\"$readline/lib\""
+
 preConfigure()
 {
     chmod u+x rts/gmp/configure
+    # still requires a hack for ncurses
+    sed -i "s|^\(library-dirs.*$\)|\1 \"$ncurses/lib\"|" libraries/readline/package.conf.in
 }
 preConfigure=preConfigure
 
+
 # Standard configure/make/make install
 genericBuild
diff --git a/pkgs/development/compilers/ghc-6.6.1/default.nix b/pkgs/development/compilers/ghc-6.6.1/default.nix
index b4daeba07f2..738b6a79fc7 100644
--- a/pkgs/development/compilers/ghc-6.6.1/default.nix
+++ b/pkgs/development/compilers/ghc-6.6.1/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, readline, ghc, perl, m4}:
+{stdenv, fetchurl, readline, ghc, perl, m4, gmp, ncurses}:
 
 stdenv.mkDerivation {
   name = "ghc-6.6.1";
@@ -21,4 +21,6 @@ stdenv.mkDerivation {
   meta = {
     description = "The Glasgow Haskell Compiler v6.6.1";
   };
+
+  inherit readline gmp ncurses;
 }
diff --git a/pkgs/development/compilers/ghc-6.6/builder.sh b/pkgs/development/compilers/ghc-6.6/builder.sh
index 716fb38f0da..4f4760d6917 100644
--- a/pkgs/development/compilers/ghc-6.6/builder.sh
+++ b/pkgs/development/compilers/ghc-6.6/builder.sh
@@ -11,5 +11,16 @@ postInstall()
 }
 postInstall=postInstall
 
+configureFlags="--with-readline-libraries=\"$readline/lib\""
+
+preConfigure()
+{
+    chmod u+x rts/gmp/configure
+    # add library paths for gmp, ncurses
+    sed -i "s|^\(library-dirs.*$\)|\1 \"$gmp/lib\"|" rts/package.conf.in
+    sed -i "s|^\(library-dirs.*$\)|\1 \"$ncurses/lib\"|" libraries/readline/package.conf.in
+}
+preConfigure=preConfigure
+
 # Standard configure/make/make install
 genericBuild
diff --git a/pkgs/development/compilers/ghc-6.6/default.nix b/pkgs/development/compilers/ghc-6.6/default.nix
index cfb44dca67d..f76547c89d7 100644
--- a/pkgs/development/compilers/ghc-6.6/default.nix
+++ b/pkgs/development/compilers/ghc-6.6/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, readline, ghc, perl, m4}:
+{stdenv, fetchurl, readline, ghc, perl, m4, gmp, ncurses}:
 
 stdenv.mkDerivation {
   name = "ghc-6.6";
@@ -21,4 +21,6 @@ stdenv.mkDerivation {
   meta = {
     description = "The Glasgow Haskell Compiler v6.6";
   };
+
+  inherit readline gmp ncurses;
 }
diff --git a/pkgs/development/compilers/ghc/boot.nix b/pkgs/development/compilers/ghc/boot.nix
index 52c8374f4ac..50eff51e063 100644
--- a/pkgs/development/compilers/ghc/boot.nix
+++ b/pkgs/development/compilers/ghc/boot.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, perl, readline, ncurses, gmp ? null}:
+{stdenv, fetchurl, perl, readline, ncurses, gmp}:
 
 assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
 
@@ -15,6 +15,6 @@ stdenv.mkDerivation {
              md5 = "8f5fe48798f715cd05214a10987bf6d5";
         });             
   buildInputs = [perl];
-  propagatedBuildInputs = [readline ncurses (if stdenv.system == "x86_64-linux" then gmp else null)];
+  propagatedBuildInputs = [readline ncurses gmp];
   inherit readline ncurses gmp;
 }
diff --git a/pkgs/development/compilers/ghc/default.nix b/pkgs/development/compilers/ghc/default.nix
index eea9f4de8c0..0aeb8086a1d 100644
--- a/pkgs/development/compilers/ghc/default.nix
+++ b/pkgs/development/compilers/ghc/default.nix
@@ -1,4 +1,4 @@
-{stdenv, gcc, fetchurl, perl, ghc, m4, readline, ncurses}:
+{stdenv, gcc, fetchurl, perl, ghc, m4, readline, ncurses, gmp}:
 
 stdenv.mkDerivation {
   name = "ghc-6.4.2";
@@ -7,7 +7,7 @@ stdenv.mkDerivation {
     md5 = "a394bf14e94c3bca5507d568fcc03375";
   };
   buildInputs = [perl ghc m4];
-  propagatedBuildInputs = [readline ncurses];
+  propagatedBuildInputs = [readline ncurses gmp];
   builder = ./builder.sh;
   inherit gcc;
 
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index cf72e7d2d8b..23b7ae32704 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -762,27 +762,26 @@ rec {
   ghc = ghc661;
 
   ghc661 = import ../development/compilers/ghc-6.6.1 {
-    inherit fetchurl stdenv readline perl;
+    inherit fetchurl stdenv readline perl gmp ncurses;
     m4 = gnum4;
     ghc = ghcboot;
   };
 
   ghc66 = import ../development/compilers/ghc-6.6 {
-    inherit fetchurl stdenv readline perl;
+    inherit fetchurl stdenv readline perl gmp ncurses;
     m4 = gnum4;
     ghc = ghcboot;
   };
 
   ghc64 = import ../development/compilers/ghc {
-    inherit fetchurl stdenv perl ncurses readline m4;
+    inherit fetchurl stdenv perl ncurses readline m4 gmp;
     gcc = stdenv.gcc;
     ghc = ghcboot;
   };
 
   ghcboot = lowPrio (appendToName "boot" (import ../development/compilers/ghc/boot.nix {
-    inherit fetchurl stdenv perl ncurses;
+    inherit fetchurl stdenv perl ncurses gmp;
     readline = if stdenv.system == "i686-linux" then readline4 else readline;
-    gmp = if stdenv.system == "x86_64-linux" then gmp else null;
   }));
 
   /*