diff options
Diffstat (limited to 'var/spack/repos/builtin/packages/scotch/package.py')
-rw-r--r-- | var/spack/repos/builtin/packages/scotch/package.py | 129 |
1 files changed, 40 insertions, 89 deletions
diff --git a/var/spack/repos/builtin/packages/scotch/package.py b/var/spack/repos/builtin/packages/scotch/package.py index 166455876e..b957db31bf 100644 --- a/var/spack/repos/builtin/packages/scotch/package.py +++ b/var/spack/repos/builtin/packages/scotch/package.py @@ -3,12 +3,15 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import spack.build_systems.cmake +import spack.build_systems.makefile from spack.package import * -class Scotch(CMakePackage): +class Scotch(CMakePackage, MakefilePackage): """Scotch is a software package for graph and mesh/hypergraph - partitioning, graph clustering, and sparse matrix ordering.""" + partitioning, graph clustering, and sparse matrix ordering. + """ homepage = "https://gitlab.inria.fr/scotch/scotch" git = "https://gitlab.inria.fr/scotch/scotch.git" @@ -32,13 +35,10 @@ class Scotch(CMakePackage): version("6.0.0", sha256="8206127d038bda868dda5c5a7f60ef8224f2e368298fbb01bf13fa250e378dd4") version("5.1.10b", sha256="54c9e7fafefd49d8b2017d179d4f11a655abe10365961583baaddc4eeb6a9add") - variant("mpi", default=True, description="Activate the compilation of parallel libraries") - variant( - "compression", default=True, description="Activate the posibility to use compressed files" - ) - variant( - "esmumps", default=False, description="Activate the compilation of esmumps needed by mumps" - ) + build_system(conditional("cmake", when="@7:"), "makefile", default="cmake") + variant("mpi", default=True, description="Compile parallel libraries") + variant("compression", default=True, description="May use compressed files") + variant("esmumps", default=False, description="Compile esmumps (needed by mumps)") variant("shared", default=True, description="Build a shared version of the library") variant( "metis", default=False, description="Expose vendored METIS/ParMETIS libraries and wrappers" @@ -70,8 +70,6 @@ class Scotch(CMakePackage): conflicts("^metis", when="+metis") conflicts("^parmetis", when="+metis") - # NOTE: In cross-compiling environment parallel build - # produces weird linker errors. parallel = False # NOTE: Versions of Scotch up to version 6.0.0 don't include support for @@ -107,16 +105,30 @@ class Scotch(CMakePackage): return scotchlibs + zlibs - @when("@:6") - def patch(self): - self.configure() - # NOTE: Configuration of Scotch is achieved by writing a 'Makefile.inc' - # file that contains all of the configuration variables and their desired - # values for the installation. This function writes this file based on - # the given installation variants. - @when("@:6") - def configure(self): +class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder): + def cmake_args(self): + spec = self.spec + args = [ + self.define_from_variant("BUILD_LIBSCOTCHMETIS", "metis"), + self.define_from_variant("INSTALL_METIS_HEADERS", "metis"), + self.define_from_variant("BUILD_LIBESMUMPS", "esmumps"), + self.define_from_variant("BUILD_SHARED_LIBS", "shared"), + self.define_from_variant("BUILD_PTSCOTCH", "mpi"), + ] + + # TODO should we enable/disable THREADS? + + if "+int64" in spec: + args.append("-DINTSIZE=64") + + return args + + +class MakefileBuilder(spack.build_systems.makefile.MakefileBuilder): + build_directory = "src" + + def edit(self, pkg, spec, prefix): makefile_inc = [] cflags = [ "-O3", @@ -147,7 +159,7 @@ class Scotch(CMakePackage): makefile_inc.extend( [ "LIB = .dylib", - "CLIBFLAGS = -dynamiclib {0}".format(self.compiler.cc_pic_flag), + "CLIBFLAGS = -dynamiclib {0}".format(pkg.compiler.cc_pic_flag), "RANLIB = echo", "AR = $(CC)", ( @@ -162,13 +174,13 @@ class Scotch(CMakePackage): makefile_inc.extend( [ "LIB = .so", - "CLIBFLAGS = -shared {0}".format(self.compiler.cc_pic_flag), + "CLIBFLAGS = -shared {0}".format(pkg.compiler.cc_pic_flag), "RANLIB = echo", "AR = $(CC)", "ARFLAGS = -shared $(LDFLAGS) -o", ] ) - cflags.append(self.compiler.cc_pic_flag) + cflags.append(pkg.compiler.cc_pic_flag) else: makefile_inc.extend( [ @@ -182,9 +194,9 @@ class Scotch(CMakePackage): # Compiler-Specific Options # - if self.compiler.name == "gcc": + if pkg.compiler.name == "gcc": cflags.append("-Drestrict=__restrict") - elif self.compiler.name == "intel": + elif pkg.compiler.name == "intel": cflags.append("-Drestrict=") mpicc_path = self.spec["mpi"].mpicc if "+mpi" in self.spec else "mpicc" @@ -237,8 +249,8 @@ class Scotch(CMakePackage): with open("Makefile.inc", "w") as fh: fh.write("\n".join(makefile_inc)) - @when("@:6") - def install(self, spec, prefix): + @property + def build_targets(self): targets = ["scotch"] if "+mpi" in self.spec: targets.append("ptscotch") @@ -248,65 +260,4 @@ class Scotch(CMakePackage): targets.append("esmumps") if "+mpi" in self.spec: targets.append("ptesmumps") - - with working_dir("src"): - for target in targets: - # It seems that building ptesmumps in parallel fails, for - # version prior to 6.0.0 there is no separated targets force - # ptesmumps, this library is built by the ptscotch target. This - # should explain the test for the can_make_parallel variable - can_make_parallel = not ( - target == "ptesmumps" - or (self.spec.version < Version("6.0.0") and target == "ptscotch") - ) - make(target, parallel=can_make_parallel) - - lib_ext = dso_suffix if "+shared" in self.spec else "a" - # It seems easier to remove metis wrappers from the folder that will be - # installed than to tweak the Makefiles - if "+metis" not in self.spec: - with working_dir("lib"): - force_remove("libscotchmetis.{0}".format(lib_ext)) - force_remove("libptscotchparmetis.{0}".format(lib_ext)) - - with working_dir("include"): - force_remove("metis.h") - force_remove("parmetis.h") - - if "~esmumps" in self.spec and self.spec.version < Version("6.0.0"): - with working_dir("lib"): - force_remove("libesmumps.{0}".format(lib_ext)) - force_remove("libptesmumps.{0}".format(lib_ext)) - - with working_dir("include"): - force_remove("esmumps.h") - - install_tree("bin", prefix.bin) - install_tree("lib", prefix.lib) - install_tree("include", prefix.include) - install_tree("man/man1", prefix.share.man.man1) - - @when("@:6") - def cmake(self, spec, prefix): - self.configure() - - @when("@:6") - def build(self, spec, prefix): - pass - - def cmake_args(self): - spec = self.spec - args = [ - self.define_from_variant("BUILD_LIBSCOTCHMETIS", "metis"), - self.define_from_variant("INSTALL_METIS_HEADERS", "metis"), - self.define_from_variant("BUILD_LIBESMUMPS", "esmumps"), - self.define_from_variant("BUILD_SHARED_LIBS", "shared"), - self.define_from_variant("BUILD_PTSCOTCH", "mpi"), - ] - - # TODO should we enable/disable THREADS? - - if "+int64" in spec: - args.append("-DINTSIZE=64") - - return args + return targets |