2016-05-11 21:22:25 -07:00
|
|
|
##############################################################################
|
|
|
|
# Copyright (c) 2013-2016, 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/llnl/spack
|
|
|
|
# Please also see the LICENSE file 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
|
|
|
|
##############################################################################
|
2015-03-12 08:49:45 -07:00
|
|
|
from spack import *
|
2016-04-29 11:44:38 -07:00
|
|
|
import os, re
|
2015-03-12 08:49:45 -07:00
|
|
|
|
|
|
|
class Scotch(Package):
|
|
|
|
"""Scotch is a software package for graph and mesh/hypergraph
|
|
|
|
partitioning, graph clustering, and sparse matrix ordering."""
|
2016-04-22 14:50:19 -07:00
|
|
|
|
2015-03-12 08:49:45 -07:00
|
|
|
homepage = "http://www.labri.fr/perso/pelegrin/scotch/"
|
2016-04-29 11:44:38 -07:00
|
|
|
url = "http://gforge.inria.fr/frs/download.php/latestfile/298/scotch_6.0.3.tar.gz"
|
|
|
|
base_url = "http://gforge.inria.fr/frs/download.php/latestfile/298"
|
2015-03-12 08:49:45 -07:00
|
|
|
list_url = "http://gforge.inria.fr/frs/?group_id=248"
|
|
|
|
|
|
|
|
version('6.0.3', '10b0cc0f184de2de99859eafaca83cfc')
|
2016-04-29 11:44:38 -07:00
|
|
|
version('6.0.0', 'c50d6187462ba801f9a82133ee666e8e')
|
|
|
|
version('5.1.10b', 'f587201d6cf5cf63527182fbfba70753')
|
2015-03-13 13:32:24 -07:00
|
|
|
|
2015-12-14 21:59:40 +01:00
|
|
|
variant('mpi', default=False, description='Activate the compilation of PT-Scotch')
|
|
|
|
variant('compression', default=True, description='Activate the posibility to use compressed files')
|
|
|
|
variant('esmumps', default=False, description='Activate the compilation of the lib esmumps needed by mumps')
|
|
|
|
variant('shared', default=True, description='Build shared libraries')
|
2015-03-12 08:49:45 -07:00
|
|
|
|
2015-12-14 21:59:40 +01:00
|
|
|
depends_on('flex')
|
|
|
|
depends_on('bison')
|
2016-04-22 14:50:19 -07:00
|
|
|
depends_on('mpi', when='+mpi')
|
|
|
|
depends_on('zlib', when='+compression')
|
2015-03-12 08:49:45 -07:00
|
|
|
|
2016-04-29 11:44:38 -07:00
|
|
|
# NOTE: Versions of Scotch up to version 6.0.0 don't include support for
|
|
|
|
# building with 'esmumps' in their default packages. In order to enable
|
|
|
|
# support for this feature, we must grab the 'esmumps' enabled archives
|
|
|
|
# from the Scotch hosting site. These alternative archives include a strict
|
|
|
|
# superset of the behavior in their default counterparts, so we choose to
|
|
|
|
# always grab these versions for older Scotch versions for simplicity.
|
|
|
|
@when('@:6.0.0')
|
|
|
|
def url_for_version(self, version):
|
|
|
|
return '%s/scotch_%s_esmumps.tar.gz' % (Scotch.base_url, version)
|
|
|
|
|
|
|
|
@when('@6.0.1:')
|
|
|
|
def url_for_version(self, version):
|
|
|
|
return super(Scotch, self).url_for_version(version)
|
|
|
|
|
|
|
|
# NOTE: Several of the 'esmumps' enabled Scotch releases up to version 6.0.0
|
|
|
|
# have broken build scripts that don't properly build 'esmumps' as a separate
|
|
|
|
# target, so we need a patch procedure to remove 'esmumps' from existing targets
|
|
|
|
# and to add it as a standalone target.
|
|
|
|
@when('@:6.0.0')
|
|
|
|
def patch(self):
|
|
|
|
makefile_path = os.path.join('src', 'Makefile')
|
|
|
|
with open(makefile_path, 'r') as makefile:
|
|
|
|
esmumps_enabled = any(re.search(r'^esmumps(\s*):(.*)$', line) for line in makefile.readlines())
|
|
|
|
|
|
|
|
if not esmumps_enabled:
|
|
|
|
mff = FileFilter(makefile_path)
|
|
|
|
mff.filter(r'^.*((esmumps)|(ptesmumps)).*(install).*$', '')
|
2015-03-12 08:49:45 -07:00
|
|
|
|
2016-04-29 11:44:38 -07:00
|
|
|
makefile_esmumps_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Makefile.esmumps')
|
|
|
|
with open(makefile_path, 'a') as makefile:
|
|
|
|
makefile.write('\ninclude %s\n' % makefile_esmumps_path)
|
|
|
|
|
|
|
|
@when('@6.0.1:')
|
2016-04-22 14:50:19 -07:00
|
|
|
def patch(self):
|
2016-04-29 11:44:38 -07:00
|
|
|
pass
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
def configure(self):
|
2016-04-22 14:50:19 -07:00
|
|
|
makefile_inc = []
|
|
|
|
cflags = [
|
|
|
|
'-O3',
|
|
|
|
'-DCOMMON_RANDOM_FIXED_SEED',
|
|
|
|
'-DSCOTCH_DETERMINISTIC',
|
|
|
|
'-DSCOTCH_RENAME',
|
|
|
|
'-DIDXSIZE64'
|
|
|
|
]
|
2015-12-14 21:59:40 +01:00
|
|
|
|
2016-04-22 14:50:19 -07:00
|
|
|
## Library Build Type ##
|
|
|
|
|
|
|
|
if '+shared' in self.spec:
|
2015-12-14 21:59:40 +01:00
|
|
|
makefile_inc.extend([
|
2016-04-22 14:50:19 -07:00
|
|
|
'LIB = .so',
|
|
|
|
'CLIBFLAGS = -shared -fPIC',
|
|
|
|
'RANLIB = echo',
|
|
|
|
'AR = $(CC)',
|
|
|
|
'ARFLAGS = -shared $(LDFLAGS) -o'
|
|
|
|
])
|
|
|
|
cflags.append('-fPIC')
|
2015-12-14 21:59:40 +01:00
|
|
|
else:
|
|
|
|
makefile_inc.extend([
|
2016-04-22 14:50:19 -07:00
|
|
|
'LIB = .a',
|
|
|
|
'CLIBFLAGS = ',
|
|
|
|
'RANLIB = ranlib',
|
|
|
|
'AR = ar',
|
|
|
|
'ARFLAGS = -ruv '
|
|
|
|
])
|
2015-12-14 21:59:40 +01:00
|
|
|
|
2016-04-22 14:50:19 -07:00
|
|
|
## Compiler-Specific Options ##
|
2015-12-14 21:59:40 +01:00
|
|
|
|
2016-04-22 14:50:19 -07:00
|
|
|
if self.compiler.name == 'gcc':
|
|
|
|
cflags.append('-Drestrict=__restrict')
|
|
|
|
elif self.compiler.name == 'intel':
|
|
|
|
cflags.append('-restrict')
|
2015-12-14 21:59:40 +01:00
|
|
|
|
2016-04-22 14:50:19 -07:00
|
|
|
makefile_inc.append('CCS = $(CC)')
|
|
|
|
makefile_inc.append('CCP = %s' %
|
2016-05-09 14:39:42 -07:00
|
|
|
(self.spec['mpi'].mpicc if '+mpi' in self.spec else 'mpicc'))
|
2016-04-22 14:50:19 -07:00
|
|
|
makefile_inc.append('CCD = $(CCS)')
|
2015-12-14 21:59:40 +01:00
|
|
|
|
2016-04-22 14:50:19 -07:00
|
|
|
## Extra Features ##
|
2015-12-14 21:59:40 +01:00
|
|
|
|
|
|
|
ldflags = []
|
2016-04-22 14:50:19 -07:00
|
|
|
|
2015-12-14 21:59:40 +01:00
|
|
|
if '+compression' in self.spec:
|
2016-04-22 14:50:19 -07:00
|
|
|
cflags.append('-DCOMMON_FILE_COMPRESS_GZ')
|
2015-12-14 21:59:40 +01:00
|
|
|
ldflags.append('-L%s -lz' % (self.spec['zlib'].prefix.lib))
|
|
|
|
|
2016-04-22 14:50:19 -07:00
|
|
|
cflags.append('-DCOMMON_PTHREAD')
|
2015-12-14 21:59:40 +01:00
|
|
|
ldflags.append('-lm -lrt -pthread')
|
|
|
|
|
2016-04-22 14:50:19 -07:00
|
|
|
makefile_inc.append('LDFLAGS = %s' % ' '.join(ldflags))
|
2015-12-14 21:59:40 +01:00
|
|
|
|
2016-04-22 14:50:19 -07:00
|
|
|
## General Features ##
|
2015-12-14 21:59:40 +01:00
|
|
|
|
|
|
|
makefile_inc.extend([
|
|
|
|
'EXE =',
|
|
|
|
'OBJ = .o',
|
|
|
|
'MAKE = make',
|
|
|
|
'CAT = cat',
|
|
|
|
'LN = ln',
|
|
|
|
'MKDIR = mkdir',
|
|
|
|
'MV = mv',
|
|
|
|
'CP = cp',
|
2016-04-22 14:50:19 -07:00
|
|
|
'CFLAGS = %s' % ' '.join(cflags),
|
2015-12-14 21:59:40 +01:00
|
|
|
'LEX = %s -Pscotchyy -olex.yy.c' % os.path.join(self.spec['flex'].prefix.bin , 'flex'),
|
|
|
|
'YACC = %s -pscotchyy -y -b y' % os.path.join(self.spec['bison'].prefix.bin, 'bison'),
|
2016-04-22 14:50:19 -07:00
|
|
|
'prefix = %s' % self.prefix
|
2015-12-14 21:59:40 +01:00
|
|
|
])
|
|
|
|
|
2015-12-20 13:27:43 +01:00
|
|
|
with working_dir('src'):
|
2015-12-20 13:38:22 +01:00
|
|
|
with open('Makefile.inc', 'w') as fh:
|
|
|
|
fh.write('\n'.join(makefile_inc))
|
2016-04-22 14:50:19 -07:00
|
|
|
|
2015-03-12 08:49:45 -07:00
|
|
|
def install(self, spec, prefix):
|
2016-04-29 11:44:38 -07:00
|
|
|
self.configure()
|
2016-04-22 14:50:19 -07:00
|
|
|
|
2015-12-14 21:59:40 +01:00
|
|
|
targets = ['scotch']
|
|
|
|
if '+mpi' in self.spec:
|
|
|
|
targets.append('ptscotch')
|
|
|
|
|
|
|
|
if '+esmumps' in self.spec:
|
|
|
|
targets.append('esmumps')
|
|
|
|
if '+mpi' in self.spec:
|
|
|
|
targets.append('ptesmumps')
|
2015-03-12 08:49:45 -07:00
|
|
|
|
|
|
|
with working_dir('src'):
|
2016-04-22 14:50:19 -07:00
|
|
|
for target in targets:
|
|
|
|
make(target, parallel=(target!='ptesmumps'))
|
2015-03-12 08:49:45 -07:00
|
|
|
|
|
|
|
install_tree('bin', prefix.bin)
|
|
|
|
install_tree('lib', prefix.lib)
|
|
|
|
install_tree('include', prefix.include)
|
|
|
|
install_tree('man/man1', prefix.share_man1)
|