From a87ae5173f5e30aa9d8b3360e67dbc17568342f5 Mon Sep 17 00:00:00 2001
From: Erik Schnetter <schnetter@gmail.com>
Date: Mon, 4 Apr 2016 18:16:25 -0400
Subject: Update Julia

- allow checking out the master branche
- add dependencies requires by important Julia package
- add OpenBLAS patch
---
 .../repos/builtin/packages/julia/openblas.patch    | 68 ++++++++++++++++++++++
 var/spack/repos/builtin/packages/julia/package.py  | 68 ++++++++++++++--------
 2 files changed, 113 insertions(+), 23 deletions(-)
 create mode 100644 var/spack/repos/builtin/packages/julia/openblas.patch

diff --git a/var/spack/repos/builtin/packages/julia/openblas.patch b/var/spack/repos/builtin/packages/julia/openblas.patch
new file mode 100644
index 0000000000..f75d7dd04f
--- /dev/null
+++ b/var/spack/repos/builtin/packages/julia/openblas.patch
@@ -0,0 +1,68 @@
+diff --git a/deps/Makefile b/deps/Makefile
+index 6cb73be..bcd8520 100644
+--- a/deps/Makefile
++++ b/deps/Makefile
+@@ -1049,7 +1049,7 @@ OPENBLAS_BUILD_OPTS += NO_AFFINITY=1
+ 
+ # Build for all architectures - required for distribution
+ ifeq ($(OPENBLAS_DYNAMIC_ARCH), 1)
+-OPENBLAS_BUILD_OPTS += DYNAMIC_ARCH=1
++OPENBLAS_BUILD_OPTS += DYNAMIC_ARCH=1 MAKE_NO_J=1
+ endif
+ 
+ # 64-bit BLAS interface
+@@ -1085,6 +1085,7 @@ OPENBLAS_BUILD_OPTS += NO_AVX2=1
+ endif
+ 
+ $(OPENBLAS_SRC_DIR)/config.status: $(OPENBLAS_SRC_DIR)/Makefile
++	cd $(dir $@) && patch -p1 < ../openblas-make.patch
+ ifeq ($(OS),WINNT)
+ 	cd $(dir $@) && patch -p1 < ../openblas-win64.patch
+ endif
+diff --git a/deps/openblas.version b/deps/openblas.version
+index 7c97e1b..58b9467 100644
+--- a/deps/openblas.version
++++ b/deps/openblas.version
+@@ -1,2 +1,2 @@
+-OPENBLAS_BRANCH=v0.2.15
+-OPENBLAS_SHA1=53e849f4fcae4363a64576de00e982722c7304f9
++OPENBLAS_BRANCH=v0.2.17
++OPENBLAS_SHA1=a71e8c82f6a9f73093b631e5deab1e8da716b61f
+--- a/deps/openblas-make.patch
++++ b/deps/openblas-make.patch
+@@ -0,0 +1,35 @@
++diff --git a/Makefile.system b/Makefile.system
++index b89f60e..2dbdad0 100644
++--- a/Makefile.system
+++++ b/Makefile.system
++@@ -139,6 +139,10 @@ NO_PARALLEL_MAKE=0
++ endif
++ GETARCH_FLAGS  += -DNO_PARALLEL_MAKE=$(NO_PARALLEL_MAKE)
++ 
+++ifdef MAKE_NO_J
+++GETARCH_FLAGS += -DMAKE_NO_J=$(MAKE_NO_J)
+++endif
+++
++ ifdef MAKE_NB_JOBS
++ GETARCH_FLAGS += -DMAKE_NB_JOBS=$(MAKE_NB_JOBS)
++ endif
++diff --git a/getarch.c b/getarch.c
++index f9c49e6..dffad70 100644
++--- a/getarch.c
+++++ b/getarch.c
++@@ -1012,6 +1012,7 @@ int main(int argc, char *argv[]){
++ #endif
++ #endif
++ 
+++#ifndef MAKE_NO_J
++ #ifdef MAKE_NB_JOBS
++     printf("MAKE += -j %d\n", MAKE_NB_JOBS);
++ #elif NO_PARALLEL_MAKE==1
++@@ -1021,6 +1022,7 @@ int main(int argc, char *argv[]){
++     printf("MAKE += -j %d\n", get_num_cores());
++ #endif
++ #endif
+++#endif
++ 
++     break;
++ 
diff --git a/var/spack/repos/builtin/packages/julia/package.py b/var/spack/repos/builtin/packages/julia/package.py
index 6900af38e4..b3a523bc45 100644
--- a/var/spack/repos/builtin/packages/julia/package.py
+++ b/var/spack/repos/builtin/packages/julia/package.py
@@ -4,43 +4,55 @@ import os
 class Julia(Package):
     """The Julia Language: A fresh approach to technical computing"""
     homepage = "http://julialang.org"
-    url      = "http://github.com/JuliaLang/julia/releases/download/v0.4.2/julia-0.4.2.tar.gz"
+    url      = "https://github.com/JuliaLang/julia/releases/download/v0.4.3/julia-0.4.3-full.tar.gz"
 
-    version('0.4.3', '7b9f096798fca4bef262a64674bc2b52')
-    version('0.4.2', 'ccfeb4f4090c8b31083f5e1ccb03eb06')
+    version('master',
+            git='https://github.com/JuliaLang/julia.git', branch='master')
+    version('0.4.5', '69141ff5aa6cee7c0ec8c85a34aa49a6')
+    version('0.4.3', '8a4a59fd335b05090dd1ebefbbe5aaac')
 
-    patch('gc.patch')
+    patch('gc.patch', when='@:0.5')
+    patch('openblas.patch')
 
-    # Build-time dependencies
-    depends_on("cmake @2.8:")
+    # Build-time dependencies:
     # depends_on("awk")
     # depends_on("m4")
     # depends_on("pkg-config")
-    depends_on("python @2.6:2.9")
 
-    # I think that Julia requires the dependencies above, but it builds find (on
-    # my system) without these. We should enable them as necessary.
+    # Combined build-time and run-time dependencies:
+    depends_on("cmake @2.8:")
+    depends_on("git")
+    depends_on("openssl")
+    depends_on("python @2.7:2.999")
+
+    # I think that Julia requires the dependencies above, but it
+    # builds fine (on my system) without these. We should enable them
+    # as necessary.
 
-    # Run-time dependencies
+    # Run-time dependencies:
     # depends_on("arpack")
     # depends_on("fftw +float")
     # depends_on("gmp")
+    # depends_on("libgit")
     # depends_on("mpfr")
+    # depends_on("openblas")
     # depends_on("pcre2")
 
-    # ARPACK: Requires BLAS and LAPACK; needs to use the same version as Julia.
+    # ARPACK: Requires BLAS and LAPACK; needs to use the same version
+    # as Julia.
 
-    # BLAS and LAPACK: Julia prefers 64-bit versions on 64-bit systems. OpenBLAS
-    # has an option for this; make it available as variant.
+    # BLAS and LAPACK: Julia prefers 64-bit versions on 64-bit
+    # systems. OpenBLAS has an option for this; make it available as
+    # variant.
 
-    # FFTW: Something doesn't work when using a pre-installed FFTW library; need
-    # to investigate.
+    # FFTW: Something doesn't work when using a pre-installed FFTW
+    # library; need to investigate.
 
-    # GMP, MPFR: Something doesn't work when using a pre-installed FFTW library;
-    # need to investigate.
+    # GMP, MPFR: Something doesn't work when using a pre-installed
+    # FFTW library; need to investigate.
 
-    # LLVM: Julia works only with specific versions, and might require patches.
-    # Thus we let Julia install its own LLVM.
+    # LLVM: Julia works only with specific versions, and might require
+    # patches. Thus we let Julia install its own LLVM.
 
     # Other possible dependencies:
     # USE_SYSTEM_OPENLIBM=0
@@ -50,11 +62,21 @@ class Julia(Package):
     # USE_SYSTEM_UTF8PROC=0
     # USE_SYSTEM_LIBGIT2=0
 
+    # Run-time dependencies for Julia packages:
+    depends_on("hdf5")
+    depends_on("mpi")
+
     def install(self, spec, prefix):
-        # Explicitly setting CC, CXX, or FC breaks building libuv, one of
-        # Julia's dependencies. This might be a Darwin-specific problem. Given
-        # how Spack sets up compilers, Julia should still use Spack's compilers,
-        # even if we don't specify them explicitly.
+        if '@master' in spec:
+            # Julia needs to know the offset from a specific commit
+            git = which('git')
+            git('fetch', '--unshallow')
+
+        # Explicitly setting CC, CXX, or FC breaks building libuv, one
+        # of Julia's dependencies. This might be a Darwin-specific
+        # problem. Given how Spack sets up compilers, Julia should
+        # still use Spack's compilers, even if we don't specify them
+        # explicitly.
         options = [#"CC=cc",
                    #"CXX=c++",
                    #"FC=fc",
-- 
cgit v1.2.3-70-g09d2