From b4b621552381fe022d9481a7d4a9cb7aff270105 Mon Sep 17 00:00:00 2001 From: Allen Nelson Date: Mon, 18 May 2015 17:01:43 -0500 Subject: [PATCH 1/5] added flags/switches necessary to get openblas to compile on osx --- .../libraries/science/math/openblas/default.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkgs/development/libraries/science/math/openblas/default.nix b/pkgs/development/libraries/science/math/openblas/default.nix index e779957a6fb..6fdb09c3e7e 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, clang }: 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,16 @@ 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" + "CC=${if stdenv.isDarwin then "clang" else "gcc"}" ''PREFIX="''$(out)"'' "INTERFACE64=1" ]; @@ -45,7 +48,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; all; maintainers = with maintainers; [ ttuegel ]; }; } From 2a0a5c697e46d144a2a8cec04352533d5c39d852 Mon Sep 17 00:00:00 2001 From: Allen Nelson Date: Mon, 18 May 2015 17:45:18 -0500 Subject: [PATCH 2/5] added clang dependency, using unix platform --- .../development/libraries/science/math/openblas/default.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/science/math/openblas/default.nix b/pkgs/development/libraries/science/math/openblas/default.nix index 6fdb09c3e7e..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, coreutils, clang }: +{ stdenv, fetchurl, gfortran, perl, liblapack, config, coreutils }: with stdenv.lib; @@ -39,6 +39,8 @@ stdenv.mkDerivation rec { ++ [ "FC=gfortran" + # 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" @@ -48,7 +50,7 @@ stdenv.mkDerivation rec { description = "Basic Linear Algebra Subprograms"; license = licenses.bsd3; homepage = "https://github.com/xianyi/OpenBLAS"; - platforms = with platforms; all; + platforms = with platforms; unix; maintainers = with maintainers; [ ttuegel ]; }; } From ec2f3eb855ed22df4a56ccded9d285321fd4a69d Mon Sep 17 00:00:00 2001 From: Allen Nelson Date: Tue, 19 May 2015 15:59:55 -0500 Subject: [PATCH 3/5] added gfortran expression for darwin --- .../compilers/gcc/gfortran-darwin.nix | 22 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/compilers/gcc/gfortran-darwin.nix diff --git a/pkgs/development/compilers/gcc/gfortran-darwin.nix b/pkgs/development/compilers/gcc/gfortran-darwin.nix new file mode 100644 index 00000000000..58f30f677b6 --- /dev/null +++ b/pkgs/development/compilers/gcc/gfortran-darwin.nix @@ -0,0 +1,22 @@ +# This is a derivation customized to work on OS X (Darwin). +{gmp, mpfr, libmpc, fetchurl, stdenv}: + +# This package is only intended for OSX. +assert stdenv.isDarwin; + +stdenv.mkDerivation rec { + name = "gfortran"; + version = "5.1.0"; + buildInputs = [gmp mpfr libmpc]; + src = fetchurl { + url = "https://ftp.gnu.org/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=/usr/bin/gcc"]; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 40a77f8a623..86f71ddb502 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3676,7 +3676,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"; From e70f9e74f222dce8f8dbebb38ab49530e53e10ba Mon Sep 17 00:00:00 2001 From: Allen Nelson Date: Tue, 19 May 2015 16:49:58 -0500 Subject: [PATCH 4/5] changed to CC=clang --- pkgs/development/compilers/gcc/gfortran-darwin.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/gcc/gfortran-darwin.nix b/pkgs/development/compilers/gcc/gfortran-darwin.nix index 58f30f677b6..4c596c4f1fb 100644 --- a/pkgs/development/compilers/gcc/gfortran-darwin.nix +++ b/pkgs/development/compilers/gcc/gfortran-darwin.nix @@ -18,5 +18,5 @@ stdenv.mkDerivation rec { --with-mpfr=${mpfr} --with-mpc=${libmpc} ''; - makeFlags = ["CC=/usr/bin/gcc"]; + makeFlags = ["CC=clang"]; } From e802740b69375fc628e446ffd7c3f746c59312d0 Mon Sep 17 00:00:00 2001 From: Allen Nelson Date: Fri, 22 May 2015 00:31:14 -0500 Subject: [PATCH 5/5] adding metadata, putting version in name --- .../compilers/gcc/gfortran-darwin.nix | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pkgs/development/compilers/gcc/gfortran-darwin.nix b/pkgs/development/compilers/gcc/gfortran-darwin.nix index 4c596c4f1fb..954b236ff6f 100644 --- a/pkgs/development/compilers/gcc/gfortran-darwin.nix +++ b/pkgs/development/compilers/gcc/gfortran-darwin.nix @@ -1,15 +1,13 @@ -# This is a derivation customized to work on OS X (Darwin). +# 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}: -# This package is only intended for OSX. -assert stdenv.isDarwin; - stdenv.mkDerivation rec { - name = "gfortran"; + name = "gfortran-${version}"; version = "5.1.0"; buildInputs = [gmp mpfr libmpc]; src = fetchurl { - url = "https://ftp.gnu.org/gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2"; + url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2"; sha256 = "1bd5vj4px3s8nlakbgrh38ynxq4s654m6nxz7lrj03mvkkwgvnmp"; }; configureFlags = '' @@ -19,4 +17,10 @@ stdenv.mkDerivation rec { --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; + }; }