]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Follow gnulib-tool changes, part 65.
authorCollin Funk <collin.funk1@gmail.com>
Mon, 18 Mar 2024 19:23:46 +0000 (12:23 -0700)
committerBruno Haible <bruno@clisp.org>
Tue, 19 Mar 2024 09:07:04 +0000 (10:07 +0100)
Follow gnulib-tool change
2021-12-19  Bruno Haible  <bruno@clisp.org>
gnulib-tool: Don't insist on ACLOCAL_AMFLAGS.

* pygnulib/GLImport.py (GLImport.execute): Don't add extra '-I' before
m4 directory in ACLOCAL_AMFLAGS. Prefer '0' instead of 'int()'. Mention
the use of AC_CONFIG_MACRO_DIRS in configure.ac as an alternative to
augmenting ACLOCAL_AMFLAGS.
* pygnulib/main.py (main): To find the m4 directories, look also for
AC_CONFIG_MACRO_DIR and AC_CONFIG_MACRO_DIRS invocations in
configure.ac. Remove unnecessary call to 'joinpath' since it accepts a
variable length of arguments.

ChangeLog
gnulib-tool.py.TODO
pygnulib/GLImport.py
pygnulib/main.py

index 075a52f6b3a0bbe2be8e599161dea04365c5e87a..3e0ceadca546a00a9e8c980d3085ebdbe50b15f9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2024-03-19  Collin Funk  <collin.funk1@gmail.com>
+
+       gnulib-tool.py: Follow gnulib-tool changes, part 65.
+       Follow gnulib-tool change
+       2021-12-19  Bruno Haible  <bruno@clisp.org>
+       gnulib-tool: Don't insist on ACLOCAL_AMFLAGS.
+       * pygnulib/GLImport.py (GLImport.execute): Don't add extra '-I' before
+       m4 directory in ACLOCAL_AMFLAGS. Prefer '0' instead of 'int()'. Mention
+       the use of AC_CONFIG_MACRO_DIRS in configure.ac as an alternative to
+       augmenting ACLOCAL_AMFLAGS.
+       * pygnulib/main.py (main): To find the m4 directories, look also for
+       AC_CONFIG_MACRO_DIR and AC_CONFIG_MACRO_DIRS invocations in
+       configure.ac. Remove unnecessary call to 'joinpath' since it accepts a
+       variable length of arguments.
+
 2024-03-18  Bruno Haible  <bruno@clisp.org>
 
        gnulib-tool.py: Tweak last change.
index 976439e2beb7d5602f350a48e353ae08b813f2d9..ada248c59f93bc2ba0a33049f3cde37c7fc5ddcc 100644 (file)
@@ -88,23 +88,6 @@ Date:   Sat Dec 25 14:30:57 2021 +0100
 
 --------------------------------------------------------------------------------
 
-commit 4bdc327dbda59dcdbfa0f983a4f35c4a4ec3578c
-Author: Bruno Haible <bruno@clisp.org>
-Date:   Sun Dec 19 12:49:16 2021 +0100
-
-    gnulib-tool: Don't insist on ACLOCAL_AMFLAGS.
-
-    Reported by Bjarni Ingi Gislason <bjarniig@rhi.hi.is> in
-    <https://lists.gnu.org/archive/html/bug-gnulib/2021-12/msg00112.html>.
-
-    * gnulib-tool (func_import): Mention an AC_CONFIG_MACRO_DIRS invocation
-    as an alternative to augmenting ACLOCAL_AMFLAGS.
-    (--import, --add-import, --remove-import, --update): To find the m4
-    directories, look also for AC_CONFIG_MACRO_DIR and AC_CONFIG_MACRO_DIRS
-    invocations in configure.ac.
-
---------------------------------------------------------------------------------
-
 commit 30459fe101541698ec704acb224946d73676750e
 Author: Bruno Haible <bruno@clisp.org>
 Date:   Thu Jun 8 15:09:31 2017 +0200
index 5ab314af36c1b545e792acfb7f22af6e57c49d3b..937c8d42e217059a01fbb5a1be9b5b14580422ee 100644 (file)
@@ -1181,7 +1181,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
                 testsbase_dir = os.path.dirname(testsbase)
                 testsbase_base = os.path.basename(testsbase)
                 self.makefiletable.editor(testsbase_dir, 'SUBDIRS', testsbase_base, True)
-        self.makefiletable.editor('', 'ACLOCAL_AMFLAGS', '-I %s' % m4base)
+        self.makefiletable.editor('', 'ACLOCAL_AMFLAGS', m4base)
         self.makefiletable.parent(gentests, source_makefile_am, tests_makefile_am)
 
         # Create library makefile.
@@ -1481,13 +1481,19 @@ in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library.''')
             else:  # if makefile_am != 'Makefile.am'
                 print('  - "include %s" from within "%s/Makefile.am",' % (tests_makefile_am, testsbase))
         # Print makefile edits.
-        current_edit = int()
+        current_edit = 0
         makefile_am_edits = self.makefiletable.count()
         while current_edit != makefile_am_edits:
             dictionary = self.makefiletable[current_edit]
             if dictionary['var']:
-                print('  - mention "%s" in %s in %s,'
-                      % (dictionary['val'], dictionary['var'], joinpath(dictionary['dir'], 'Makefile.am')))
+                if dictionary['var'] == 'ACLOCAL_AMFLAGS':
+                    print('  - mention "-I %s" in %s in %s'
+                          % (dictionary['val'], dictionary['var'], joinpath(dictionary['dir'], 'Makefile.am')))
+                    print('    or add an AC_CONFIG_MACRO_DIRS([%s]) invocation in %s,'
+                          % (dictionary['val'], configure_ac))
+                else:
+                    print('  - mention "%s" in %s in %s,'
+                          % (dictionary['val'], dictionary['var'], joinpath(dictionary['dir'], 'Makefile.am')))
             current_edit += 1
 
         # Detect position_early_after.
index e4499400c649c482669d40c5d0a16fac5324bc9c..5042cd3c824ea9b9a7c27d077f5096255f1ffa42 100644 (file)
@@ -872,6 +872,17 @@ def main():
             destdir = '.'
         config.setDestDir(destdir)
 
+        # Analyze configure.ac.
+        with open(joinpath(destdir, 'configure.ac'), 'r', encoding='utf-8') as file:
+            configure_ac_data = file.read()
+
+        guessed_m4dirs = []
+        pattern = re.compile(r'^.*AC_CONFIG_MACRO_DIRS?\([\[ ]*([^\]"\$`\\\)]*).*$', re.MULTILINE)
+        match = pattern.findall(configure_ac_data)
+        # Append the match to guessed_m4dirs.
+        if match:
+            guessed_m4dirs += match
+
         if mode == MODES['import']:
             # Set variables to default values.
             if not sourcebase:
@@ -937,7 +948,7 @@ def main():
                         if dirisnext:
                             # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
                             if not isabs(aclocal_amflag):
-                                if isfile(joinpath(destdir, joinpath(aclocal_amflag, 'gnulib-cache.m4'))):
+                                if isfile(joinpath(destdir, aclocal_amflag, 'gnulib-cache.m4')):
                                     m4dirs += [aclocal_amflag]
                             dirisnext = False
                         else:  # if not dirisnext
@@ -945,6 +956,11 @@ def main():
                                 dirisnext = True
                             else:  # if aclocal_amflag != '-I'
                                 dirisnext = False
+                    for arg in guessed_m4dirs:
+                        # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
+                        if not isabs(arg):
+                            if isfile(joinpath(destdir, arg, 'gnulib-cache.m4')):
+                                m4dirs += [arg]
                 else:  # if not isfile(filepath)
                     # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
                     filepath = joinpath(destdir, 'aclocal.m4')