add static options for some libraries (#2876)
* add static options for some libraries * make requested changes: add comments and use configure_args
This commit is contained in:
parent
7d3da2ebdc
commit
6e895c4ccc
@ -36,6 +36,7 @@ class Bzip2(Package):
|
|||||||
url = "http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz"
|
url = "http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz"
|
||||||
|
|
||||||
version('1.0.6', '00b516f4704d4a7cb50a1d97e6e8e15b')
|
version('1.0.6', '00b516f4704d4a7cb50a1d97e6e8e15b')
|
||||||
|
variant('shared', default=True, description='Enables the build of shared libraries.')
|
||||||
|
|
||||||
def patch(self):
|
def patch(self):
|
||||||
# bzip2 comes with two separate Makefiles for static and dynamic builds
|
# bzip2 comes with two separate Makefiles for static and dynamic builds
|
||||||
@ -71,27 +72,30 @@ def patch(self):
|
|||||||
|
|
||||||
def install(self, spec, prefix):
|
def install(self, spec, prefix):
|
||||||
# Build the dynamic library first
|
# Build the dynamic library first
|
||||||
make('-f', 'Makefile-libbz2_so')
|
if '+shared' in spec:
|
||||||
|
make('-f', 'Makefile-libbz2_so')
|
||||||
|
|
||||||
# Build the static library and everything else
|
# Build the static library and everything else
|
||||||
make()
|
make()
|
||||||
make('install', 'PREFIX={0}'.format(prefix))
|
make('install', 'PREFIX={0}'.format(prefix))
|
||||||
|
|
||||||
install('bzip2-shared', join_path(prefix.bin, 'bzip2'))
|
if '+shared' in spec:
|
||||||
|
install('bzip2-shared', join_path(prefix.bin, 'bzip2'))
|
||||||
|
|
||||||
v1, v2, v3 = (self.spec.version.up_to(i) for i in (1, 2, 3))
|
v1, v2, v3 = (self.spec.version.up_to(i) for i in (1, 2, 3))
|
||||||
if 'darwin' in self.spec.architecture:
|
if 'darwin' in self.spec.architecture:
|
||||||
lib = 'libbz2.dylib'
|
lib = 'libbz2.dylib'
|
||||||
lib1, lib2, lib3 = ('libbz2.{0}.dylib'.format(v)
|
lib1, lib2, lib3 = ('libbz2.{0}.dylib'.format(v)
|
||||||
for v in (v1, v2, v3))
|
for v in (v1, v2, v3))
|
||||||
else:
|
else:
|
||||||
lib = 'libbz2.so'
|
lib = 'libbz2.so'
|
||||||
lib1, lib2, lib3 = ('libbz2.so.{0}'.format(v)
|
lib1, lib2, lib3 = ('libbz2.so.{0}'.format(v)
|
||||||
for v in (v1, v2, v3))
|
for v in (v1, v2, v3))
|
||||||
|
|
||||||
install(lib3, join_path(prefix.lib, lib3))
|
install(lib3, join_path(prefix.lib, lib3))
|
||||||
with working_dir(prefix.lib):
|
with working_dir(prefix.lib):
|
||||||
for l in (lib, lib1, lib2):
|
for l in (lib, lib1, lib2):
|
||||||
symlink(lib3, l)
|
symlink(lib3, l)
|
||||||
|
|
||||||
with working_dir(prefix.bin):
|
with working_dir(prefix.bin):
|
||||||
force_remove('bunzip2', 'bzcat')
|
force_remove('bunzip2', 'bzcat')
|
||||||
|
@ -37,6 +37,8 @@ class Matio(AutotoolsPackage):
|
|||||||
description='support for compressed mat files')
|
description='support for compressed mat files')
|
||||||
variant("hdf5", default=True,
|
variant("hdf5", default=True,
|
||||||
description='support for version 7.3 mat files via hdf5')
|
description='support for version 7.3 mat files via hdf5')
|
||||||
|
variant("shared", default=True, description='Enables the build of shared libraries.')
|
||||||
|
|
||||||
|
|
||||||
depends_on("zlib", when="+zlib")
|
depends_on("zlib", when="+zlib")
|
||||||
depends_on("hdf5", when="+hdf5")
|
depends_on("hdf5", when="+hdf5")
|
||||||
@ -47,4 +49,6 @@ def configure_args(self):
|
|||||||
args.append("--with-zlib=%s" % self.spec['zlib'].prefix)
|
args.append("--with-zlib=%s" % self.spec['zlib'].prefix)
|
||||||
if '+hdf5' in self.spec:
|
if '+hdf5' in self.spec:
|
||||||
args.append("--with-hdf5=%s" % self.spec['hdf5'].prefix)
|
args.append("--with-hdf5=%s" % self.spec['hdf5'].prefix)
|
||||||
|
if '+shared' not in self.spec:
|
||||||
|
args.append("--disable-shared")
|
||||||
return args
|
return args
|
||||||
|
@ -186,6 +186,15 @@ def install(self, spec, prefix):
|
|||||||
|
|
||||||
if '+shared' in spec:
|
if '+shared' in spec:
|
||||||
options.append('-DSHARED:BOOL=ON')
|
options.append('-DSHARED:BOOL=ON')
|
||||||
|
else:
|
||||||
|
# Remove all RPATH options
|
||||||
|
# (RPATHxxx options somehow trigger cmake to link dynamically)
|
||||||
|
rpath_options = []
|
||||||
|
for o in options:
|
||||||
|
if o.find('RPATH') >= 0:
|
||||||
|
rpath_options.append(o)
|
||||||
|
for o in rpath_options:
|
||||||
|
options.remove(o)
|
||||||
if '+debug' in spec:
|
if '+debug' in spec:
|
||||||
options.extend(['-DDEBUG:BOOL=ON',
|
options.extend(['-DDEBUG:BOOL=ON',
|
||||||
'-DCMAKE_BUILD_TYPE:STRING=Debug'])
|
'-DCMAKE_BUILD_TYPE:STRING=Debug'])
|
||||||
|
@ -71,6 +71,16 @@ def install(self, spec, prefix):
|
|||||||
|
|
||||||
if '+shared' in spec:
|
if '+shared' in spec:
|
||||||
options.append('-DSHARED:BOOL=ON')
|
options.append('-DSHARED:BOOL=ON')
|
||||||
|
else:
|
||||||
|
# Remove all RPATH options
|
||||||
|
# (RPATHxxx options somehow trigger cmake to link dynamically)
|
||||||
|
rpath_options = []
|
||||||
|
for o in options:
|
||||||
|
if o.find('RPATH') >= 0:
|
||||||
|
rpath_options.append(o)
|
||||||
|
for o in rpath_options:
|
||||||
|
options.remove(o)
|
||||||
|
|
||||||
if '+debug' in spec:
|
if '+debug' in spec:
|
||||||
options.extend(['-DDEBUG:BOOL=ON',
|
options.extend(['-DDEBUG:BOOL=ON',
|
||||||
'-DCMAKE_BUILD_TYPE:STRING=Debug'])
|
'-DCMAKE_BUILD_TYPE:STRING=Debug'])
|
||||||
|
@ -40,7 +40,15 @@ class Zlib(AutotoolsPackage):
|
|||||||
|
|
||||||
variant('pic', default=True,
|
variant('pic', default=True,
|
||||||
description='Produce position-independent code (for shared libs)')
|
description='Produce position-independent code (for shared libs)')
|
||||||
|
variant('shared', default=True,
|
||||||
|
description='Enables the build of shared libraries.')
|
||||||
|
|
||||||
def setup_environment(self, spack_env, run_env):
|
def setup_environment(self, spack_env, run_env):
|
||||||
if '+pic' in self.spec:
|
if '+pic' in self.spec:
|
||||||
spack_env.set('CFLAGS', self.compiler.pic_flag)
|
spack_env.set('CFLAGS', self.compiler.pic_flag)
|
||||||
|
|
||||||
|
def configure_args(self):
|
||||||
|
config_args = []
|
||||||
|
if '+shared' not in self.spec:
|
||||||
|
config_args.append('--static')
|
||||||
|
return config_args
|
||||||
|
Loading…
Reference in New Issue
Block a user