From ec1b2d0a3a0ffed93825e90f927db542149d3bda Mon Sep 17 00:00:00 2001
From: twang15 <twang15@ncsu.edu>
Date: Mon, 18 Jun 2018 11:52:24 -0700
Subject: [PATCH] samrai: update package for 3.12.0 and fix compilation bugs
 for earlier versions (#8501)

* SAMRAI: remove dependency on boost for samrai 3.12.0 or later versions, but keep the older versions ccontinuing working with boost 1.64.0 or earlier. Also, the older versions cannot compile with boost 1.65.0 or above. (#8491)

* SAMRAI: fix typos of comments and remove obsolete code.
---
 .../repos/builtin/packages/samrai/package.py  | 26 ++++++++++++-------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/var/spack/repos/builtin/packages/samrai/package.py b/var/spack/repos/builtin/packages/samrai/package.py
index 9caf76c888..f1c8f78332 100644
--- a/var/spack/repos/builtin/packages/samrai/package.py
+++ b/var/spack/repos/builtin/packages/samrai/package.py
@@ -66,11 +66,10 @@ class Samrai(AutotoolsPackage):
     depends_on('hdf5+mpi')
     depends_on('m4', type='build')
 
-    # At some point later versions of boost were not able to be found
-    # by SAMRAI during configure, so we're using boost <= 1.60.0 for
-    # < 3.12.0 versions. I don't know what version of boost that
-    # happened at though without trying each version of boost.
-    depends_on('boost@:1.60.0', when='@0:3.11.99')
+    # Starting with 3.12.0, samrai no longer depends on boost.
+    # version 3.11.5 or earlier can only work with boost version
+    # 1.64.0 or earlier.
+    depends_on('boost@:1.64.0', when='@0:3.11.99', type='build')
 
     # don't build tools with gcc
     patch('no-tool-build.patch', when='%gcc')
@@ -90,11 +89,6 @@ def configure_args(self):
             '--with-hypre=no',
             '--with-petsc=no'])
 
-        if self.spec.satisfies('@0:3.11.99'):
-            options.extend([
-                '--with-boost=%s' % self.spec['boost'].prefix
-            ])
-
         if '+debug' in self.spec:
             options.extend([
                 '--disable-opt',
@@ -104,4 +98,16 @@ def configure_args(self):
                 '--enable-opt',
                 '--disable-debug'])
 
+        if self.version >= Version('3.12.0'):
+            # only version 3.12.0 and above, samrai does not use
+            # boost, but needs c++11. Without c++11 flags, samrai
+            # cannot build with either gcc or intel compilers.
+            if 'CXXFLAGS' in env and env['CXXFLAGS']:
+                env['CXXFLAGS'] += ' ' + self.compiler.cxx11_flag
+            else:
+                env['CXXFLAGS'] = self.compiler.cxx11_flag
+        else:
+            # boost 1.64.0 or earlier works with samrai 2.4.4~3.11.5
+            options.append('--with-boost=%s' % self.spec['boost'].prefix)
+
         return options
-- 
GitLab