Two more patches. The first is just a simple version bump to Automake
version 1.11.

The second fixes a problem I noticed when using the Emacs merge-gnulib
script. I noticed that most of the Automake conditionals for header
files weren't being converted to GNU Make syntax. The diff would have
many lines like this:

     -ifneq (,$(GL_GENERATE_ASSERT_H_CONDITION))
     +if GL_GENERATE_ASSERT_H

Turns out it was my fault... I forgot that in Python '^' only matches
the start of a string by default. I thought that it matched the start
of a new line. I've fixed it by using the re.MULTILINE flag [1]. Now
the diff looks like this:

    -ifneq (,$(GL_GENERATE_ASSERT_H_CONDITION))
    +ifneq (,$(GL_GENERATE_ASSERT_H))

The difference in naming is due to another item in
gnulib-tool.py.TODO, but the GNU Make syntax works correctly now. I've
also stored the compiled regular expression so it isn't written out
twice. It has the same name as the shell script variable so it should
be easy to cross reference.

Not sure if compiling it has any effect on performance [2].

[1] https://docs.python.org/3/library/re.html#re.MULTILINE
[2] https://docs.python.org/3/library/re.html#re.compile

Collin
From 4b792e51ede2559e3a9c90ab6a6605e2ecceeb1f Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Thu, 29 Feb 2024 18:15:19 -0800
Subject: [PATCH 2/3] gnulib-tool.py: Follow gnulib-tool changes, part 37.

Follow gnulib-tool change
2018-10-22  Bruno Haible  <br...@clisp.org>
Assume Automake >= 1.11.

* pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am)
(GLEmiter.tests_Makefile_am): Emit a Makefile.am that requires Automake
>= 1.11.
* pygnulib/GLTestDir.py (GLTestDir.execute, GLMegaTestDir.execute):
Likewise.
* pygnulib/constants.py: Update comment.
---
 ChangeLog             | 13 +++++++++++++
 gnulib-tool.py.TODO   | 16 ----------------
 pygnulib/GLEmiter.py  |  4 ++--
 pygnulib/GLTestDir.py |  4 ++--
 pygnulib/constants.py |  2 +-
 5 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9536c174f8..87d8b84c06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-02-29  Collin Funk  <collin.fu...@gmail.com>
+
+	gnulib-tool.py: Follow gnulib-tool changes, part 37.
+	Follow gnulib-tool change
+	2018-10-22  Bruno Haible  <br...@clisp.org>
+	Assume Automake >= 1.11.
+	* pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am)
+	(GLEmiter.tests_Makefile_am): Emit a Makefile.am that requires Automake
+	>= 1.11.
+	* pygnulib/GLTestDir.py (GLTestDir.execute, GLMegaTestDir.execute):
+	Likewise.
+	* pygnulib/constants.py: Update comment.
+
 2024-02-29  Collin Funk  <collin.fu...@gmail.com>
 
 	gnulib-tool.py: Follow gnulib-tool changes, part 36.
diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO
index 3fe32282a7..6e02953d57 100644
--- a/gnulib-tool.py.TODO
+++ b/gnulib-tool.py.TODO
@@ -687,22 +687,6 @@ Date:   Fri Jan 4 19:34:19 2019 +0100
 
 --------------------------------------------------------------------------------
 
-commit 97eae14a5b2506457a72f89d5897a20730ab6eee
-Author: Bruno Haible <br...@clisp.org>
-Date:   Tue Oct 23 00:06:46 2018 +0200
-
-    Assume Automake >= 1.11.
-
-    * m4/configmake.m4: Update comments.
-    * m4/lib-link.m4 (AC_LIB_RPATH): Assume AC_REQUIRE_AUX_FILE exists.
-    * m4/po.m4 (AM_PO_SUBDIRS, AM_POSTPROCESS_PO_MAKEFILE): Eliminate uses
-    of 'eval'.
-    * gnulib-tool (func_emit_lib_Makefile_am, func_emit_tests_Makefile_am,
-    func_create_testdir, func_create_megatestdir): Emit a Makefile.am that
-    requires Automake >= 1.11.
-
---------------------------------------------------------------------------------
-
 commit 8b1d4a63e34f3893036d82f39c5680e845de5ddf
 Author: Bruno Haible <br...@clisp.org>
 Date:   Mon Sep 3 21:19:16 2018 +0200
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index dcabc3523c..64800792ae 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -752,7 +752,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
             # object files (example: hash.c and libxml/hash.c).
             if uses_subdirs:
                 subdir_options = ' subdir-objects'
-            emit += 'AUTOMAKE_OPTIONS = 1.9.6 gnits%s\n' % subdir_options
+            emit += 'AUTOMAKE_OPTIONS = 1.11 gnits%s\n' % subdir_options
         emit += '\n'
         if not makefile_name:
             emit += 'SUBDIRS =\n'
@@ -1028,7 +1028,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         subdir_options = ''
         if uses_subdirs:
             subdir_options = ' subdir-objects'
-        emit += 'AUTOMAKE_OPTIONS = 1.9.6 foreign%s\n\n' % subdir_options
+        emit += 'AUTOMAKE_OPTIONS = 1.11 foreign%s\n\n' % subdir_options
         if for_test and not single_configure:
             emit += 'ACLOCAL_AMFLAGS = -I %s/%s\n\n' % (testsbase_inverse, m4base)
 
diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py
index a7fd806d4f..9f5e0fe38f 100644
--- a/pygnulib/GLTestDir.py
+++ b/pygnulib/GLTestDir.py
@@ -512,7 +512,7 @@ class GLTestDir(object):
 
         # Create Makefile.am.
         emit = '## Process this file with automake to produce Makefile.in.\n\n'
-        emit += 'AUTOMAKE_OPTIONS = 1.9.6 foreign\n\n'
+        emit += 'AUTOMAKE_OPTIONS = 1.11 foreign\n\n'
         emit += 'SUBDIRS = %s\n\n' % ' '.join(subdirs)
         emit += 'ACLOCAL_AMFLAGS = -I %s\n' % m4base
         emit = constants.nlconvert(emit)
@@ -962,7 +962,7 @@ class GLMegaTestDir(object):
 
         # Create Makefile.am.
         emit = '## Process this file with automake to produce Makefile.in.\n\n'
-        emit += 'AUTOMAKE_OPTIONS = 1.9.6 foreign\n\n'
+        emit += 'AUTOMAKE_OPTIONS = 1.11 foreign\n\n'
         emit += 'SUBDIRS = %s\n\n' % ' '.join(megasubdirs)
         emit += 'EXTRA_DIST = do-autobuild\n'
         emit = constants.nlconvert(emit)
diff --git a/pygnulib/constants.py b/pygnulib/constants.py
index 0f6f5c67f0..918faa8cc0 100644
--- a/pygnulib/constants.py
+++ b/pygnulib/constants.py
@@ -124,7 +124,7 @@ TESTS = \
 DEFAULT_AUTOCONF_MINVERSION = 2.64
 # You can set AUTOCONFPATH to empty if autoconf 2.64 is already in your PATH
 AUTOCONFPATH = ''
-# You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH
+# You can set AUTOMAKEPATH to empty if automake 1.11 is already in your PATH
 AUTOMAKEPATH = ''
 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH
 GETTEXTPATH = ''
-- 
2.39.2

From 2fd85bbc2cfb7c308b15e8fcc39ae4d89a4d5b37 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Thu, 29 Feb 2024 18:37:53 -0800
Subject: [PATCH 3/3] gnulib-tool.py: Fix GNU Make conversion regular
 expressions.

* pygnulib/GLEmiter.py: Reduce code duplication. Use re.MULTILINE so '^'
matches the start of each line instead of only the start of a string.
---
 ChangeLog            |  6 ++++++
 pygnulib/GLEmiter.py | 12 +++++-------
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 87d8b84c06..7b610c0d8e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-02-29  Collin Funk  <collin.fu...@gmail.com>
+
+	gnulib-tool.py: Fix GNU Make conversion regular expressions.
+	* pygnulib/GLEmiter.py: Reduce code duplication. Use re.MULTILINE so '^'
+	matches the start of each line instead of only the start of a string.
+
 2024-02-29  Collin Funk  <collin.fu...@gmail.com>
 
 	gnulib-tool.py: Follow gnulib-tool changes, part 37.
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index 64800792ae..2a28021938 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -640,6 +640,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         module_indicator_prefix = self.config.getModuleIndicatorPrefix()
         ac_version = self.config['ac_version']
         destfile = os.path.normpath(destfile)
+        convert_to_gnu_make_1 = (re.compile(r'^if (.*)', re.MULTILINE), r'ifneq (,$(\1))')
         emit = ''
 
         # When using GNU make, or when creating an includable Makefile.am snippet,
@@ -712,9 +713,6 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                     allsnippets += '## begin gnulib module %s\n' % str(module)
                     if gnu_make:
                         allsnippets += 'ifeq (,$(OMIT_GNULIB_MODULE_%s))\n' % str(module)
-                        convert_to_gnu_make = True
-                    else:
-                        convert_to_gnu_make = False
                     allsnippets += '\n'
                     if conddeps:
                         if moduletable.isConditional(module):
@@ -723,15 +721,15 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                                 allsnippets += 'ifneq (,$(%s))\n' % name
                             else:
                                 allsnippets += 'if %s\n' % name
-                    if convert_to_gnu_make:
-                        allsnippets += re.sub(r'^if (.*)', r'ifneq (,$(\1))', amsnippet1)
+                    if gnu_make:
+                        allsnippets += re.sub(convert_to_gnu_make_1[0], convert_to_gnu_make_1[1], amsnippet1)
                     else:
                         allsnippets += amsnippet1
                     if conddeps:
                         if moduletable.isConditional(module):
                             allsnippets += 'endif\n'
-                    if convert_to_gnu_make:
-                        allsnippets += re.sub(r'^if (.*)', r'ifneq (,$(\1))', amsnippet2)
+                    if gnu_make:
+                        allsnippets += re.sub(convert_to_gnu_make_1[0], convert_to_gnu_make_1[1], amsnippet2)
                     else:
                         allsnippets += amsnippet2
                     if gnu_make:
-- 
2.39.2

Reply via email to