about summary refs log tree commit diff
path: root/pkgs/development/compilers/ghc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2007-12-14 17:51:11 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2007-12-14 17:51:11 +0000
commit65c1809b67369027ae75df71df735423ca60a13b (patch)
treede06dad9c216926325448c4028e04c839135be75 /pkgs/development/compilers/ghc
parentbe02132b5d26c7244dd3738369a750bcec2203df (diff)
* Support for building a bootstrap GHC (ghcboot) on i686-darwin.
  Building of the bootstrapped compiler isn't tested yet.

svn path=/nixpkgs/trunk/; revision=9940
Diffstat (limited to 'pkgs/development/compilers/ghc')
-rw-r--r--pkgs/development/compilers/ghc/boot.nix65
-rw-r--r--pkgs/development/compilers/ghc/boot.sh10
2 files changed, 51 insertions, 24 deletions
diff --git a/pkgs/development/compilers/ghc/boot.nix b/pkgs/development/compilers/ghc/boot.nix
index 50eff51e0630f..84a0316c25293 100644
--- a/pkgs/development/compilers/ghc/boot.nix
+++ b/pkgs/development/compilers/ghc/boot.nix
@@ -1,20 +1,57 @@
 {stdenv, fetchurl, perl, readline, ncurses, gmp}:
 
-assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
-
 stdenv.mkDerivation {
-  name = "ghc-6.4.2";
+  name = if stdenv.system == "i686-darwin" then "ghc-6.6.1" else "ghc-6.4.2";
   builder = ./boot.sh;
-  src = if stdenv.system == "i686-linux" then
-        (fetchurl {
-             url = http://nix.cs.uu.nl/dist/tarballs/ghc-6.4.2-i386-unknown-linux.tar.bz2;
-             md5 = "092fe2e25dab22b926babe97cc77db1f";
-        }) else
-        (fetchurl {
-             url = http://haskell.org/ghc/dist/6.4.2/ghc-6.4.2-x86_64-unknown-linux.tar.bz2;
-             md5 = "8f5fe48798f715cd05214a10987bf6d5";
-        });             
+
+  src =
+    if stdenv.system == "i686-linux" then
+      fetchurl {
+        url = http://nix.cs.uu.nl/dist/tarballs/ghc-6.4.2-i386-unknown-linux.tar.bz2;
+        md5 = "092fe2e25dab22b926babe97cc77db1f";
+      }
+    else if stdenv.system == "x86_64-linux" then
+      fetchurl {
+        url = http://haskell.org/ghc/dist/6.4.2/ghc-6.4.2-x86_64-unknown-linux.tar.bz2;
+        md5 = "8f5fe48798f715cd05214a10987bf6d5";
+      }
+    else if stdenv.system == "i686-darwin" then
+      fetchurl {
+        url = http://www.haskell.org/ghc/dist/6.6.1/ghc-6.6.1-i386-apple-darwin.tar.bz2;
+        sha256 = "1drbsicanr6jlykvs4vs6gbi2q9ac1bcaxz2vzwh3pfv3lfibwia";
+      }
+    else throw "cannot bootstrap GHC on this platform"; 
+
   buildInputs = [perl];
-  propagatedBuildInputs = [readline ncurses gmp];
-  inherit readline ncurses gmp;
+
+  # On Linux, use patchelf to modify the executables so that they can
+  # find readline/gmp.
+  postBuild = if stdenv.isLinux then "
+    find . -type f -perm +100 \\
+        -exec patchelf --interpreter \"$(cat $NIX_GCC/nix-support/dynamic-linker)\" \\
+        --set-rpath \"${readline}/lib:${ncurses}/lib:${gmp}/lib\" {} \;
+  " else "";
+
+  # The binaries for Darwin use frameworks, so fake those frameworks,
+  # and create some wrapper scripts that set DYLD_FRAMEWORK_PATH so
+  # that the executables work with no special setup.
+  postInstall = if stdenv.isDarwin then "
+
+    ensureDir $out/frameworks/GMP.framework/Versions/A
+    ln -s ${gmp}/lib/libgmp.dylib $out/frameworks/GMP.framework/GMP
+    ln -s ${gmp}/lib/libgmp.dylib $out/frameworks/GMP.framework/Versions/A/GMP
+    ensureDir $out/frameworks/GNUreadline.framework/Versions/A
+    ln -s ${readline}/lib/libreadline.dylib $out/frameworks/GNUreadline.framework/GNUreadline
+    ln -s ${readline}/lib/libreadline.dylib $out/frameworks/GNUreadline.framework/Versions/A/GNUreadline
+
+    mv $out/bin $out/bin-orig
+    mkdir $out/bin
+    for i in $(cd $out/bin-orig && ls); do
+        echo \"#! $SHELL -e\" >> $out/bin/$i
+        echo \"DYLD_FRAMEWORK_PATH=$out/frameworks exec $out/bin-orig/$i -framework-path $out/frameworks \\\"\\$@\\\"\" >> $out/bin/$i
+        chmod +x $out/bin/$i
+    done
+
+  " else "";
+
 }
diff --git a/pkgs/development/compilers/ghc/boot.sh b/pkgs/development/compilers/ghc/boot.sh
deleted file mode 100644
index 4b88b6bdba387..0000000000000
--- a/pkgs/development/compilers/ghc/boot.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-source $stdenv/setup
-
-postBuild=postBuild
-postBuild () {
-    find . -type f -perm +100 \
-        -exec patchelf --interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" \
-        --set-rpath "$readline/lib:$ncurses/lib:$gmp/lib" {} \;
-}
-
-genericBuild