+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.
import subprocess as sp
from .constants import (
DIRS,
+ UTILS,
MODES,
TESTS,
cleaner,
is a very good choice.'''
mode: int
+ m4dirs: list[str]
config: GLConfig
cache: GLConfig
emitter: GLEmiter
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.
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.
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)
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
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:
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
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)