From cdbb586a93b8f1149e98b79be62856e663ff1ea5 Mon Sep 17 00:00:00 2001 From: bernhardkaindl <43588962+bernhardkaindl@users.noreply.github.com> Date: Fri, 24 Sep 2021 17:17:07 +0200 Subject: autotools.py/autoreconf: Show the depends_on()s to add to the package (#26115) This commit shows a template for cut-and-paste into the package to fix it: ```py ==> fast-global-file-status: Executing phase: 'autoreconf' ==> Error: RuntimeError: Cannot generate configure: missing dependencies autoconf, automake, libtool. Please add the following lines to the package: depends_on('autoconf', type='build', when='@master') depends_on('automake', type='build', when='@master') depends_on('libtool', type='build', when='@master') Update the version (when='@master') as needed. ``` Co-authored-by: Harmen Stoppels --- lib/spack/spack/build_systems/autotools.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/build_systems/autotools.py b/lib/spack/spack/build_systems/autotools.py index b12a1afc2e..66b5379975 100644 --- a/lib/spack/spack/build_systems/autotools.py +++ b/lib/spack/spack/build_systems/autotools.py @@ -252,17 +252,31 @@ class AutotoolsPackage(PackageBase): if self.force_autoreconf: force_remove(self.configure_abs_path) + def _autoreconf_warning(self, spec, missing): + msg = ("Cannot generate configure: missing dependencies {0}.\n\nPlease add " + "the following lines to the package:\n\n".format(", ".join(missing))) + + for dep in missing: + msg += (" depends_on('{0}', type='build', when='@{1}')\n" + .format(dep, spec.version)) + + msg += "\nUpdate the version (when='@{0}') as needed.".format(spec.version) + + return msg + def autoreconf(self, spec, prefix): """Not needed usually, configure should be already there""" # If configure exists nothing needs to be done if os.path.exists(self.configure_abs_path): return # Else try to regenerate it - autotools = ['m4', 'autoconf', 'automake', 'libtool'] - missing = [x for x in autotools if x not in spec] + needed_dependencies = ['autoconf', 'automake', 'libtool'] + build_deps = [d.name for d in spec.dependencies(deptype='build')] + missing = [x for x in needed_dependencies if x not in build_deps] + if missing: - msg = 'Cannot generate configure: missing dependencies {0}' - raise RuntimeError(msg.format(missing)) + raise RuntimeError(self._autoreconf_warning(spec, missing)) + tty.msg('Configure script not found: trying to generate it') tty.warn('*********************************************************') tty.warn('* If the default procedure fails, consider implementing *') -- cgit v1.2.3-60-g2f50