From: Bruno Haible Date: Sun, 5 May 2024 14:30:10 +0000 (+0200) Subject: gnulib-tool.py: Regenerate aclocal.m4 before using 'autoconf -t ...'. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=655328ba465b4ab4edc6b4b2e411c6e4af35c2bd;p=gnulib.git gnulib-tool.py: Regenerate aclocal.m4 before using 'autoconf -t ...'. Reported by Paul Eggert in . * pygnulib/GLImport.py (GLImport): New field m4dirs. (GLImport.__init__): Accept an additional m4dirs argument. (GLImport.execute): Regenerate aclocal.m4 before creating the library Makefile. * pygnulib/main.py (main): Pass the guessed_m4dirs to GLImport. --- diff --git a/ChangeLog b/ChangeLog index f8e20e06c6..02ecbd341d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2024-05-05 Bruno Haible + + gnulib-tool.py: Regenerate aclocal.m4 before using 'autoconf -t ...'. + Reported by Paul Eggert in + . + * pygnulib/GLImport.py (GLImport): New field m4dirs. + (GLImport.__init__): Accept an additional m4dirs argument. + (GLImport.execute): Regenerate aclocal.m4 before creating the library + Makefile. + * pygnulib/main.py (main): Pass the guessed_m4dirs to GLImport. + 2024-05-04 Collin Funk gnulib-tool: Ignore autom4te.cache when using GNULIB_TOOL_IMPL=sh+py. diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index a11da0e63d..e67cbbe5a2 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -23,6 +23,7 @@ import re import subprocess as sp from .constants import ( DIRS, + UTILS, MODES, TESTS, cleaner, @@ -61,6 +62,7 @@ class GLImport: is a very good choice.''' mode: int + m4dirs: list[str] config: GLConfig cache: GLConfig emitter: GLEmiter @@ -68,19 +70,23 @@ class GLImport: moduletable: GLModuleTable makefiletable: GLMakefileTable - def __init__(self, config: GLConfig, mode: int) -> None: + def __init__(self, config: GLConfig, mode: int, m4dirs: list[str]) -> None: '''Create GLImport instance. - The first variable, mode, must be one of the values of the MODES dict - object, which is accessible from constants module. The second one, config, - must be a GLConfig object.''' + config - must be a GLConfig object. + mode - must be one of the values of the constants.MODES values. + m4dirs - list of all directories that contain relevant .m4 files.''' if type(config) is not GLConfig: raise TypeError('config must have GLConfig type, not %s' % repr(config)) - if type(mode) is int and MODES['import'] <= mode <= MODES['update']: - self.mode = mode - else: # if mode is not int or is not 0-3 + if not (type(mode) is int and MODES['import'] <= mode <= MODES['update']): raise TypeError('mode must be 0 <= mode <= 3, not %s' % repr(mode)) + if type(m4dirs) is not list: + raise TypeError('m4dirs must be a list of strings, not %s' + % repr(m4dirs)) + + self.mode = mode + self.m4dirs = m4dirs # config contains the configuration, as specified through command-line # parameters. @@ -1209,6 +1215,17 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix if os.path.isfile(tmpfile): os.remove(tmpfile) + if self.config['gnu_make']: + # Regenerate aclocal.m4. + # This is needed because the next step may run 'autoconf -t' and + # the preceding steps may have added new *.m4 files (which need to + # be reflected in aclocal.m4 before 'autoconf -t' is run). + aclocal_args = [] + for dir in self.m4dirs: + aclocal_args.append('-I') + aclocal_args.append(dir) + sp.run([UTILS['aclocal']] + aclocal_args, cwd=destdir) + # Create library makefile. # Do this after creating gnulib-comp.m4, because func_emit_lib_Makefile_am # can run 'autoconf -t', which reads gnulib-comp.m4. diff --git a/pygnulib/main.py b/pygnulib/main.py index 66bd67ea59..6e29374af2 100644 --- a/pygnulib/main.py +++ b/pygnulib/main.py @@ -948,7 +948,7 @@ def main(temp_directory: str) -> None: config.setMacroPrefix(macro_prefix) # Perform GLImport actions. - importer = GLImport(config, mode) + importer = GLImport(config, mode, guessed_m4dirs) filetable, transformers = importer.prepare() importer.execute(filetable, transformers) @@ -972,7 +972,7 @@ def main(temp_directory: str) -> None: config.setTestsBase(testsbase) config.setMacroPrefix(macro_prefix) # Perform GLImport actions. - importer = GLImport(config, mode) + importer = GLImport(config, mode, guessed_m4dirs) filetable, transformers = importer.prepare() importer.execute(filetable, transformers) else: # if not m4base @@ -1038,7 +1038,7 @@ def main(temp_directory: str) -> None: config.setTestsBase(testsbase) config.setMacroPrefix(macro_prefix) # Perform GLImport actions. - importer = GLImport(config, mode) + importer = GLImport(config, mode, guessed_m4dirs) filetable, transformers = importer.prepare() importer.execute(filetable, transformers) elif len(m4dirs) == 1: @@ -1047,7 +1047,7 @@ def main(temp_directory: str) -> None: m4base = m4dirs[-1] config.setM4Base(m4base) # Perform GLImport actions. - importer = GLImport(config, mode) + importer = GLImport(config, mode, guessed_m4dirs) filetable, transformers = importer.prepare() importer.execute(filetable, transformers) else: # if len(m4dirs) > 1 @@ -1055,7 +1055,7 @@ def main(temp_directory: str) -> None: for m4base in m4dirs: config.setM4Base(m4base) # Perform GLImport actions. - importer = GLImport(config, mode) + importer = GLImport(config, mode, guessed_m4dirs) filetable, transformers = importer.prepare() importer.execute(filetable, transformers)