summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGregory Lee <lee218@llnl.gov>2016-11-04 12:12:37 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2016-11-04 12:12:37 -0700
commitee6eb508cbaf6e34643bec8fd2759149b48b92cc (patch)
tree2c5204e2f42af9160298aca5e3e9d3ed90ce843c /lib
parent296a349d49f552b222120053eee227ccb14d0b7d (diff)
downloadspack-ee6eb508cbaf6e34643bec8fd2759149b48b92cc.tar.gz
spack-ee6eb508cbaf6e34643bec8fd2759149b48b92cc.tar.bz2
spack-ee6eb508cbaf6e34643bec8fd2759149b48b92cc.tar.xz
spack-ee6eb508cbaf6e34643bec8fd2759149b48b92cc.zip
patch older config.guess for newer architectures (#2221)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/docs/packaging_guide.rst4
-rw-r--r--lib/spack/spack/build_systems/autotools.py77
2 files changed, 79 insertions, 2 deletions
diff --git a/lib/spack/docs/packaging_guide.rst b/lib/spack/docs/packaging_guide.rst
index bf5763f4f8..a22fcd71ba 100644
--- a/lib/spack/docs/packaging_guide.rst
+++ b/lib/spack/docs/packaging_guide.rst
@@ -2026,8 +2026,8 @@ The last element of a package is its ``install()`` method. This is
where the real work of installation happens, and it's the main part of
the package you'll need to customize for each piece of software.
-.. literalinclude:: ../../../var/spack/repos/builtin/packages/libelf/package.py
- :pyobject: Libelf.install
+.. literalinclude:: ../../../var/spack/repos/builtin/packages/libpng/package.py
+ :pyobject: Libpng.install
:linenos:
``install`` takes a ``spec``: a description of how the package should
diff --git a/lib/spack/spack/build_systems/autotools.py b/lib/spack/spack/build_systems/autotools.py
index 0bb5576708..8535c9d3e3 100644
--- a/lib/spack/spack/build_systems/autotools.py
+++ b/lib/spack/spack/build_systems/autotools.py
@@ -24,7 +24,11 @@
##############################################################################
import inspect
+import os
import os.path
+import shutil
+from subprocess import PIPE
+from subprocess import check_call
import llnl.util.tty as tty
from spack.package import PackageBase
@@ -46,6 +50,79 @@ class AutotoolsPackage(PackageBase):
# To be used in UI queries that require to know which
# build-system class we are using
build_system_class = 'AutotoolsPackage'
+ patch_config_guess = True
+
+ def do_patch_config_guess(self):
+ """Some packages ship with an older config.guess and need to have
+ this updated when installed on a newer architecture."""
+
+ my_config_guess = None
+ config_guess = None
+ if os.path.exists('config.guess'):
+ # First search the top-level source directory
+ my_config_guess = 'config.guess'
+ else:
+ # Then search in all sub directories.
+ # We would like to use AC_CONFIG_AUX_DIR, but not all packages
+ # ship with their configure.in or configure.ac.
+ d = '.'
+ dirs = [os.path.join(d, o) for o in os.listdir(d)
+ if os.path.isdir(os.path.join(d, o))]
+ for dirname in dirs:
+ path = os.path.join(dirname, 'config.guess')
+ if os.path.exists(path):
+ my_config_guess = path
+
+ if my_config_guess is not None:
+ try:
+ check_call([my_config_guess], stdout=PIPE, stderr=PIPE)
+ # The package's config.guess already runs OK, so just use it
+ return True
+ except:
+ pass
+
+ # Look for a spack-installed automake package
+ if 'automake' in self.spec:
+ automake_path = os.path.join(self.spec['automake'].prefix, 'share',
+ 'automake-' +
+ str(self.spec['automake'].version))
+ path = os.path.join(automake_path, 'config.guess')
+ if os.path.exists(path):
+ config_guess = path
+ if config_guess is not None:
+ try:
+ check_call([config_guess], stdout=PIPE, stderr=PIPE)
+ shutil.copyfile(config_guess, my_config_guess)
+ return True
+ except:
+ pass
+
+ # Look for the system's config.guess
+ if os.path.exists('/usr/share'):
+ automake_dir = [s for s in os.listdir('/usr/share') if
+ "automake" in s]
+ if automake_dir:
+ automake_path = os.path.join('/usr/share', automake_dir[0])
+ path = os.path.join(automake_path, 'config.guess')
+ if os.path.exists(path):
+ config_guess = path
+ if config_guess is not None:
+ try:
+ check_call([config_guess], stdout=PIPE, stderr=PIPE)
+ shutil.copyfile(config_guess, my_config_guess)
+ return True
+ except:
+ pass
+
+ return False
+
+ def patch(self):
+ """Perform any required patches."""
+
+ if self.patch_config_guess and self.spec.satisfies(
+ 'arch=linux-redhat7-ppc64le'):
+ if not self.do_patch_config_guess():
+ raise RuntimeError('Failed to find suitable config.guess')
def autoreconf(self, spec, prefix):
"""Not needed usually, configure should be already there"""