summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/metis/package.py
diff options
context:
space:
mode:
Diffstat (limited to 'var/spack/repos/builtin/packages/metis/package.py')
-rw-r--r--var/spack/repos/builtin/packages/metis/package.py117
1 files changed, 112 insertions, 5 deletions
diff --git a/var/spack/repos/builtin/packages/metis/package.py b/var/spack/repos/builtin/packages/metis/package.py
index bbfc4de7d1..41e3ebb429 100644
--- a/var/spack/repos/builtin/packages/metis/package.py
+++ b/var/spack/repos/builtin/packages/metis/package.py
@@ -24,7 +24,7 @@
##############################################################################
from spack import *
-
+import glob, sys, os
class Metis(Package):
"""
@@ -36,7 +36,10 @@ class Metis(Package):
homepage = 'http://glaros.dtc.umn.edu/gkhome/metis/metis/overview'
url = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz"
- version('5.1.0', '5465e67079419a69e0116de24fce58fe')
+ version('5.1.0', '5465e67079419a69e0116de24fce58fe',
+ url='http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz')
+ version('4.0.3', '5efa35de80703c1b2c4d0de080fafbcf4e0d363a21149a1ad2f96e0144841a55',
+ url='http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/OLD/metis-4.0.3.tar.gz')
variant('shared', default=True, description='Enables the build of shared libraries')
variant('debug', default=False, description='Builds the library in debug mode')
@@ -45,10 +48,85 @@ class Metis(Package):
variant('idx64', default=False, description='Use int64_t as default index type')
variant('double', default=False, description='Use double precision floating point types')
- depends_on('cmake @2.8:') # build-time dependency
-
+ depends_on('cmake @2.8:', when='@5:') # build-time dependency
depends_on('gdb', when='+gdb')
+ patch('install_gklib_defs_rename.patch', when='@5:')
+
+
+ @when('@4:4.0.3')
+ def install(self, spec, prefix):
+
+ if '+gdb' in spec:
+ raise InstallError('gdb support not implemented in METIS 4!')
+ if '+idx64' in spec:
+ raise InstallError('idx64 option not implemented in METIS 4!')
+ if '+double' in spec:
+ raise InstallError('double option not implemented for METIS 4!')
+
+ options = ['COPTIONS=-fPIC']
+ if '+debug' in spec:
+ options.append('OPTFLAGS=-g -O0')
+ make(*options)
+
+ mkdir(prefix.bin)
+ for x in ('pmetis', 'kmetis', 'oemetis', 'onmetis', 'partnmesh',
+ 'partdmesh', 'mesh2nodal', 'mesh2dual', 'graphchk'):
+ install(x, prefix.bin)
+
+ mkdir(prefix.lib)
+ install('libmetis.a', prefix.lib)
+
+ mkdir(prefix.include)
+ for h in glob.glob(join_path('Lib', '*.h')):
+ install(h, prefix.include)
+
+ mkdir(prefix.share)
+ for f in (join_path(*p)
+ for p in (('Programs', 'io.c'),
+ ('Test','mtest.c'),
+ ('Graphs','4elt.graph'),
+ ('Graphs', 'metis.mesh'),
+ ('Graphs', 'test.mgraph'))):
+ install(f, prefix.share)
+
+ if '+shared' in spec:
+ if sys.platform == 'darwin':
+ lib_dsuffix = 'dylib'
+ load_flag = '-Wl,-all_load'
+ no_load_flag = ''
+ else:
+ lib_dsuffix = 'so'
+ load_flag = '-Wl,-whole-archive'
+ no_load_flag = '-Wl,-no-whole-archive'
+
+ os.system(spack_cc + ' -fPIC -shared ' + load_flag +
+ ' libmetis.a ' + no_load_flag + ' -o libmetis.' +
+ lib_dsuffix)
+ install('libmetis.' + lib_dsuffix, prefix.lib)
+
+ # Set up and run tests on installation
+ symlink(join_path(prefix.share, 'io.c'), 'io.c')
+ symlink(join_path(prefix.share, 'mtest.c'), 'mtest.c')
+ os.system(spack_cc + ' -I%s' % prefix.include + ' -c io.c')
+ os.system(spack_cc + ' -I%s' % prefix.include +
+ ' -L%s' % prefix.lib + ' -lmetis mtest.c io.o -o mtest')
+ _4eltgraph = join_path(prefix.share, '4elt.graph')
+ test_mgraph = join_path(prefix.share, 'test.mgraph')
+ metis_mesh = join_path(prefix.share, 'metis.mesh')
+ kmetis = join_path(prefix.bin, 'kmetis')
+ os.system('./mtest ' + _4eltgraph)
+ os.system(kmetis + ' ' + _4eltgraph + ' 40')
+ os.system(join_path(prefix.bin, 'onmetis') + ' ' + _4eltgraph)
+ os.system(join_path(prefix.bin, 'pmetis') + ' ' + test_mgraph + ' 2')
+ os.system(kmetis + ' ' + test_mgraph + ' 2')
+ os.system(kmetis + ' ' + test_mgraph + ' 5')
+ os.system(join_path(prefix.bin, 'partnmesh') + metis_mesh + ' 10')
+ os.system(join_path(prefix.bin, 'partdmesh') + metis_mesh + ' 10')
+ os.system(join_path(prefix.bin, 'mesh2dual') + metis_mesh)
+
+
+ @when('@5:')
def install(self, spec, prefix):
options = []
@@ -77,7 +155,36 @@ class Metis(Package):
if '+double' in spec:
filter_file('REALTYPEWIDTH 32', 'REALTYPEWIDTH 64', metis_header)
+ # Make clang 7.3 happy.
+ # Prevents "ld: section __DATA/__thread_bss extends beyond end of file"
+ # See upstream LLVM issue https://llvm.org/bugs/show_bug.cgi?id=27059
+ # Adopted from https://github.com/Homebrew/homebrew-science/blob/master/metis.rb
+ if spec.satisfies('%clang@7.3.0'):
+ filter_file('#define MAX_JBUFS 128', '#define MAX_JBUFS 24', join_path(source_directory, 'GKlib', 'error.c'))
+
with working_dir(build_directory, create=True):
cmake(source_directory, *options)
make()
- make("install") \ No newline at end of file
+ make("install")
+ # now run some tests:
+ for f in ["4elt", "copter2", "mdual"]:
+ graph = join_path(source_directory,'graphs','%s.graph' % f)
+ Executable(join_path(prefix.bin,'graphchk'))(graph)
+ Executable(join_path(prefix.bin,'gpmetis'))(graph,'2')
+ Executable(join_path(prefix.bin,'ndmetis'))(graph)
+
+ graph = join_path(source_directory,'graphs','test.mgraph')
+ Executable(join_path(prefix.bin,'gpmetis'))(graph,'2')
+ graph = join_path(source_directory,'graphs','metis.mesh')
+ Executable(join_path(prefix.bin,'mpmetis'))(graph,'2')
+
+ # install GKlib headers, which will be needed for ParMETIS
+ GKlib_dist = join_path(prefix.include,'GKlib')
+ mkdirp(GKlib_dist)
+ fs = glob.glob(join_path(source_directory,'GKlib',"*.h"))
+ for f in fs:
+ install(f, GKlib_dist)
+
+ # The shared library is not installed correctly on Darwin; correct this
+ if (sys.platform == 'darwin') and ('+shared' in spec):
+ fix_darwin_install_name(prefix.lib)