]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Regenerate aclocal.m4 before using 'autoconf -t ...'.
authorBruno Haible <bruno@clisp.org>
Sun, 5 May 2024 14:30:10 +0000 (16:30 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 5 May 2024 14:30:10 +0000 (16:30 +0200)
Reported by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-05/msg00065.html>.

* 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.

ChangeLog
pygnulib/GLImport.py
pygnulib/main.py

index f8e20e06c64549c7a44090b00df83a7cafb977ba..02ecbd341d1dff201d2180a367b6a65dbee92ed2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-05-05  Bruno Haible  <bruno@clisp.org>
+
+       gnulib-tool.py: Regenerate aclocal.m4 before using 'autoconf -t ...'.
+       Reported by Paul Eggert in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2024-05/msg00065.html>.
+       * 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  <collin.funk1@gmail.com>
 
        gnulib-tool: Ignore autom4te.cache when using GNULIB_TOOL_IMPL=sh+py.
index a11da0e63d6b9110268d3aa3fca74b8a7388c7e7..e67cbbe5a23af2d10778cd6a1edfcab02270bce5 100644 (file)
@@ -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.
index 66bd67ea595c6f42edbf8ccf4761c56aa60107e6..6e29374af2fbface129d68672cae17511633771b 100644 (file)
@@ -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)