Paul Eggert wrote: > I had problems updating Emacs to use gnulib commit > fde88b711c9b1df5b142444ac7b0bc2aa8892d3a along with emacs commit > fd859fbea2e9d13e76db1c5295d9ddd1c5955d83 (these are the same commits as > I mentioned earlier today). I reproduced it like this: > > cd emacs > admin/merge-gnulib > > The resulting lib/gnulib.mk.in had a line: > > -e 's|@''HAVE_OFF64_T''@|$(HAVE_OFF64_T)|g' \ > > but there was no "HAVE_OFF64_T = @HAVE_OFF64_T@" line
I reproduce it. But when I run admin/merge-gnulib a second time, it adds the line: $ diff -u lib/gnulib.mk.in~ lib/gnulib.mk.in --- lib/gnulib.mk.in~ 2024-05-05 15:17:51.168952913 +0200 +++ lib/gnulib.mk.in 2024-05-05 15:28:29.973871297 +0200 @@ -808,6 +808,7 @@ HAVE_MODULES = @HAVE_MODULES@ HAVE_NANOSLEEP = @HAVE_NANOSLEEP@ HAVE_NATIVE_COMP = @HAVE_NATIVE_COMP@ +HAVE_OFF64_T = @HAVE_OFF64_T@ HAVE_OPENAT = @HAVE_OPENAT@ HAVE_OPENDIR = @HAVE_OPENDIR@ HAVE_OS_H = @HAVE_OS_H@ The order in which gnulib-tool creates the files seems to be correct: lib/gnulib.mk.in is generated last. ... Replacing file m4/nstrftime.m4 (non-gnulib code backed up in m4/nstrftime.m4~) !! Copying file m4/off64_t.m4 Replacing file m4/off_t.m4 (non-gnulib code backed up in m4/off_t.m4~) !! ... Replacing file m4/xattr.m4 (non-gnulib code backed up in m4/xattr.m4~) !! Replacing file m4/zzgnulib.m4 (non-gnulib code backed up in m4/zzgnulib.m4~) !! Creating m4/gnulib-cache.m4 Updating m4/gnulib-comp.m4 (backup in m4/gnulib-comp.m4~) Updating lib/gnulib.mk.in (backup in lib/gnulib.mk.in~) Finished. The problem is that the new file m4/off64_t.m4 is not yet reflected in aclocal.m4 at the moment autoconf -t ... is run. This patch fixes it. I'm not including the fix in the old gnulib-tool.sh. Please document in emacs/admin/merge-gnulib that Python 3 is now needed as a prerequisite. 2024-05-05 Bruno Haible <br...@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. 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 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 @@ def execute(self, filetable: GLFileTable, transformers: dict[str, tuple[re.Patte 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)