summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pkgs/development/compilers/gcc/gfortran-darwin.nix26
-rw-r--r--pkgs/development/libraries/science/math/openblas/default.nix13
-rw-r--r--pkgs/top-level/all-packages.nix3
3 files changed, 37 insertions, 5 deletions
diff --git a/pkgs/development/compilers/gcc/gfortran-darwin.nix b/pkgs/development/compilers/gcc/gfortran-darwin.nix
new file mode 100644
index 00000000000..954b236ff6f
--- /dev/null
+++ b/pkgs/development/compilers/gcc/gfortran-darwin.nix
@@ -0,0 +1,26 @@
+# This is a derivation specific to OS X (Darwin). It may work on other
+# systems as well but has not been tested.
+{gmp, mpfr, libmpc, fetchurl, stdenv}:
+
+stdenv.mkDerivation rec {
+  name = "gfortran-${version}";
+  version = "5.1.0";
+  buildInputs = [gmp mpfr libmpc];
+  src = fetchurl {
+    url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2";
+    sha256 = "1bd5vj4px3s8nlakbgrh38ynxq4s654m6nxz7lrj03mvkkwgvnmp";
+  };
+  configureFlags = ''
+    --enable-languages=fortran --enable-checking=release --disable-bootstrap
+    --with-gmp=${gmp}
+    --with-mpfr=${mpfr}
+    --with-mpc=${libmpc}
+  '';
+  makeFlags = ["CC=clang"];
+  meta = with stdenv.lib; {
+    description = "GNU Fortran compiler, part of the GNU Compiler Collection.";
+    homepage    = "https://gcc.gnu.org/fortran/";
+    license     = licenses.gpl3Plus;
+    platforms   = platforms.darwin;
+  };
+}
diff --git a/pkgs/development/libraries/science/math/openblas/default.nix b/pkgs/development/libraries/science/math/openblas/default.nix
index e779957a6fb..67d95f97e07 100644
--- a/pkgs/development/libraries/science/math/openblas/default.nix
+++ b/pkgs/development/libraries/science/math/openblas/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, gfortran, perl, liblapack, config }:
+{ stdenv, fetchurl, gfortran, perl, liblapack, config, coreutils }:
 
 with stdenv.lib;
 
@@ -7,6 +7,7 @@ let local = config.openblas.preferLocalBuild or false;
       {
         i686-linux = "32";
         x86_64-linux = "64";
+        x86_64-darwin = "64";
       }."${stdenv.system}" or (throw "unsupported system: ${stdenv.system}");
     genericFlags =
       [
@@ -29,14 +30,18 @@ stdenv.mkDerivation rec {
 
   preBuild = "cp ${liblapack.src} lapack-${liblapack.meta.version}.tgz";
 
-  nativeBuildInputs = [gfortran perl];
+  nativeBuildInputs = optionals stdenv.isDarwin [coreutils] ++ [gfortran perl];
 
   makeFlags =
     (if local then localFlags else genericFlags)
     ++
+    optionals stdenv.isDarwin ["MACOSX_DEPLOYMENT_TARGET=10.9"]
+    ++
     [
       "FC=gfortran"
-      "CC=gcc"
+      # Note that clang is available through the stdenv on OSX and
+      # thus is not an explicit dependency.
+      "CC=${if stdenv.isDarwin then "clang" else "gcc"}"
       ''PREFIX="''$(out)"''
       "INTERFACE64=1"
     ];
@@ -45,7 +50,7 @@ stdenv.mkDerivation rec {
     description = "Basic Linear Algebra Subprograms";
     license = licenses.bsd3;
     homepage = "https://github.com/xianyi/OpenBLAS";
-    platforms = with platforms; linux;
+    platforms = with platforms; unix;
     maintainers = with maintainers; [ ttuegel ];
   };
 }
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index f55c035c3a9..3913e9f65e8 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -3698,7 +3698,8 @@ let
     isl = isl_0_14;
   }));
 
-  gfortran = gfortran48;
+  gfortran = if !stdenv.isDarwin then gfortran48
+             else callPackage ../development/compilers/gcc/gfortran-darwin.nix {};
 
   gfortran48 = wrapCC (gcc48.cc.override {
     name = "gfortran";