Repository: spack/spack

Issue:
scorep: Convert hard-coded dependencies into variants
There are some hard-coded dependencies in the Score-P package that should be variants (mpi, pdt, papi).


Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/cubelib/package.py b/var/spack/repos/builtin/packages/cubelib/package.py
new file mode 100644
--- /dev/null
+++ b/var/spack/repos/builtin/packages/cubelib/package.py
@@ -0,0 +1,44 @@
+##############################################################################
+# Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC.
+# Produced at the Lawrence Livermore National Laboratory.
+#
+# This file is part of Spack.
+# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
+# LLNL-CODE-647188
+#
+# For details, see https://github.com/spack/spack
+# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License (as
+# published by the Free Software Foundation) version 2.1, February 1999.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
+# conditions of the GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##############################################################################
+from spack import *
+
+
+class Cubelib(AutotoolsPackage):
+    """Component of CubeBundle: General purpose C++ library and tools """
+
+    homepage = "http://www.scalasca.org/software/cube-4.x/download.html"
+    url = "http://apps.fz-juelich.de/scalasca/releases/cube/4.4/dist/cubelib-4.4.tar.gz"
+
+    version('4.4', 'c903f3c44d3228ebefd00c831966988e')
+
+    depends_on('zlib')
+
+    def configure_args(self):
+        configure_args = ['--enable-shared']
+
+        return configure_args
+
+    def install(self, spec, prefix):
+        make('install', parallel=False)
diff --git a/var/spack/repos/builtin/packages/cubew/package.py b/var/spack/repos/builtin/packages/cubew/package.py
new file mode 100644
--- /dev/null
+++ b/var/spack/repos/builtin/packages/cubew/package.py
@@ -0,0 +1,44 @@
+##############################################################################
+# Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC.
+# Produced at the Lawrence Livermore National Laboratory.
+#
+# This file is part of Spack.
+# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
+# LLNL-CODE-647188
+#
+# For details, see https://github.com/spack/spack
+# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License (as
+# published by the Free Software Foundation) version 2.1, February 1999.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
+# conditions of the GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##############################################################################
+from spack import *
+
+
+class Cubew(AutotoolsPackage):
+    """Component of CubeBundle: High performance C Writer library """
+
+    homepage = "http://www.scalasca.org/software/cube-4.x/download.html"
+    url = "http://apps.fz-juelich.de/scalasca/releases/cube/4.4/dist/cubew-4.4.tar.gz"
+
+    version('4.4', 'e9beb140719c2ad3d971e1efb99e0916')
+
+    depends_on('zlib')
+
+    def configure_args(self):
+        configure_args = ['--enable-shared']
+
+        return configure_args
+
+    def install(self, spec, prefix):
+        make('install', parallel=True)
diff --git a/var/spack/repos/builtin/packages/scorep/package.py b/var/spack/repos/builtin/packages/scorep/package.py
--- a/var/spack/repos/builtin/packages/scorep/package.py
+++ b/var/spack/repos/builtin/packages/scorep/package.py
@@ -43,13 +43,20 @@ class Scorep(AutotoolsPackage):
 
     patch('gcc7.patch', when='@:3')
 
-    ##########
+    variant('mpi', default=True, description="Enable MPI support")
+    variant('papi', default=True, description="Enable PAPI")
+    variant('pdt', default=False, description="Enable PDT")
+    variant('shmem', default=False, description='Enable shmem tracing')
+
     # Dependencies for SCORE-P are quite tight. See the homepage for more
-    # information.
+    # information. Starting with scorep 4.0 / cube 4.4, Score-P only depends on
+    # two components of cube -- cubew and cubelib.
+
     # SCOREP 4
     depends_on('otf2@2.1:', when='@4:')
     depends_on('opari2@2.0:', when='@4:')
-    depends_on('cube@4.4:', when='@4:')
+    depends_on('cubew@4.4:', when='@4:')
+    depends_on('cubelib@4.4:', when='@4:')
     # SCOREP 3
     depends_on('otf2@2:', when='@3:3.99')
     depends_on('opari2@2:', when='@3:3.99')
@@ -66,13 +73,10 @@ class Scorep(AutotoolsPackage):
     depends_on("otf2@1.4", when='@1.3')
     depends_on("opari2@1.1.4", when='@1.3')
     depends_on("cube@4.2.3", when='@1.3')
-    ##########
 
-    depends_on("mpi")
-    depends_on("papi")
-    depends_on('pdt')
-
-    variant('shmem', default=False, description='Enable shmem tracing')
+    depends_on('mpi', when="+mpi")
+    depends_on('papi', when="+papi")
+    depends_on('pdt', when="+pdt")
 
     # Score-P requires a case-sensitive file system, and therefore
     # does not work on macOS
@@ -85,15 +89,29 @@ def configure_args(self):
         config_args = [
             "--with-otf2=%s" % spec['otf2'].prefix.bin,
             "--with-opari2=%s" % spec['opari2'].prefix.bin,
-            "--with-cube=%s" % spec['cube'].prefix.bin,
-            "--with-papi-header=%s" % spec['papi'].prefix.include,
-            "--with-papi-lib=%s" % spec['papi'].prefix.lib,
-            "--with-pdt=%s" % spec['pdt'].prefix.bin,
             "--enable-shared"]
 
         cname = spec.compiler.name
         config_args.append('--with-nocross-compiler-suite={0}'.format(cname))
 
+        if self.version >= Version('4.0'):
+            config_args.append("--with-cubew=%s" % spec['cubew'].prefix.bin)
+            config_args.append("--with-cubelib=%s" %
+                               spec['cubelib'].prefix.bin)
+        else:
+            config_args.append("--with-cube=%s" % spec['cube'].prefix.bin)
+
+        if "+papi" in spec:
+            config_args.append("--with-papi-header=%s" %
+                               spec['papi'].prefix.include)
+            config_args.append("--with-papi-lib=%s" % spec['papi'].prefix.lib)
+
+        if "+pdt" in spec:
+            config_args.append("--with-pdt=%s" % spec['pdt'].prefix.bin)
+
+        config_args += self.with_or_without('shmem')
+        config_args += self.with_or_without('mpi')
+
         if spec.satisfies('^intel-mpi'):
             config_args.append('--with-mpi=intel3')
         elif spec.satisfies('^mpich') or spec.satisfies('^mvapich2'):
@@ -101,16 +119,17 @@ def configure_args(self):
         elif spec.satisfies('^openmpi'):
             config_args.append('--with-mpi=openmpi')
 
-        if '~shmem' in spec:
-            config_args.append("--without-shmem")
-
         config_args.extend([
             'CFLAGS={0}'.format(self.compiler.pic_flag),
-            'CXXFLAGS={0}'.format(self.compiler.pic_flag),
-            'MPICC={0}'.format(spec['mpi'].mpicc),
-            'MPICXX={0}'.format(spec['mpi'].mpicxx),
-            'MPIF77={0}'.format(spec['mpi'].mpif77),
-            'MPIFC={0}'.format(spec['mpi'].mpifc)
+            'CXXFLAGS={0}'.format(self.compiler.pic_flag)
         ])
 
+        if "+mpi" in spec:
+            config_args.extend([
+                'MPICC={0}'.format(spec['mpi'].mpicc),
+                'MPICXX={0}'.format(spec['mpi'].mpicxx),
+                'MPIF77={0}'.format(spec['mpi'].mpif77),
+                'MPIFC={0}'.format(spec['mpi'].mpifc)
+            ])
+
         return config_args


Test patch: