On 3/9/24 8:15 PM, Collin Funk wrote:
> I don't remember those changes looking too hard, so _hopefully_ I can
> get them done soon.

The first two patches deal with the @NMD@ and @!NMD@ replacements. I
used a mix of the test cases from my previous emails and the Emacs
merge-gnulib script. All the output seems correct.

While testing I also noticed this diff in the tests Makefile.am:

 # Use $(gl_V_at) instead of $(AM_V_GEN) or $(AM_V_at) on a line that
-# is its recipe's first line if and only if @NMD@ lines are absent.
 gl_V_at = $(AM_V_GEN)

When updating the sed invocations in the regular gnulib-tool, I forgot
that the test Makefile.am uses these replacements as well. The third
patches adds them and fixes the diff.

Sorry for all the patches all at once. Let me know if I missed
anything or if my some of my code is confusing. :)

Collin
From a903cf8e58c222def96f041c5c527ba6e905b9fa Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Sun, 10 Mar 2024 00:43:20 -0800
Subject: [PATCH 3/5] gnulib-tool.py: Follow gnulib-tool changes, part 53.

Follow gnulib-tool change
2021-12-21  Bruno Haible  <br...@clisp.org>
Optimize redundant 'mkdir -p .' invocations.

* pygnulib/GLEmiter.py (_eliminate_NMD): New private function to
eliminate occurrences of @NMD@ from Automake snippets.
(GLEmiter.lib_Makefile_am, GLEmiter.tests_Makefile_am): Use it.
---
 ChangeLog            | 10 ++++++
 gnulib-tool.py.TODO  | 81 --------------------------------------------
 pygnulib/GLEmiter.py | 11 ++++++
 3 files changed, 21 insertions(+), 81 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8dda625922..27a9b2ea2c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-03-10  Collin Funk  <collin.fu...@gmail.com>
+
+	gnulib-tool.py: Follow gnulib-tool changes, part 53.
+	Follow gnulib-tool change
+	2021-12-21  Bruno Haible  <br...@clisp.org>
+	Optimize redundant 'mkdir -p .' invocations.
+	* pygnulib/GLEmiter.py (_eliminate_NMD): New private function to
+	eliminate occurrences of @NMD@ from Automake snippets.
+	(GLEmiter.lib_Makefile_am, GLEmiter.tests_Makefile_am): Use it.
+
 2024-03-09  Collin Funk  <collin.fu...@gmail.com>
 
 	gnulib-tool.py: Follow gnulib-tool changes, part 52.
diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO
index e6c94c8bb8..c3d5d65f5c 100644
--- a/gnulib-tool.py.TODO
+++ b/gnulib-tool.py.TODO
@@ -207,87 +207,6 @@ Date:   Fri Dec 24 17:22:00 2021 -0800
 
 --------------------------------------------------------------------------------
 
-commit 83a0d5891db50c00e283e70df694b6003b1f485d
-Author: Bruno Haible <br...@clisp.org>
-Date:   Tue Dec 21 09:59:17 2021 +0100
-
-    Optimize redundant 'mkdir -p .' invocations.
-
-    Reported by Paul Eggert.
-
-    * gnulib-tool (func_emit_lib_Makefile_am, func_emit_tests_Makefile_am):
-    Eliminate @NMD@ tokens.
-    * modules/alloca-opt (Makefile.am): Prefix the "$(MKDIR_P) '%reldir%'"
-    line with @NMD@.
-    * modules/argz (Makefile.am): Likewise.
-    * modules/assert-h (Makefile.am): Likewise.
-    * modules/byteswap (Makefile.am): Likewise.
-    * modules/configmake (Makefile.am): Likewise.
-    * modules/ctype (Makefile.am): Likewise.
-    * modules/dirent (Makefile.am): Likewise.
-    * modules/errno (Makefile.am): Likewise.
-    * modules/execinfo (Makefile.am): Likewise.
-    * modules/fcntl-h (Makefile.am): Likewise.
-    * modules/float (Makefile.am): Likewise.
-    * modules/fnmatch-h (Makefile.am): Likewise.
-    * modules/getopt-posix (Makefile.am): Likewise.
-    * modules/glob-h (Makefile.am): Likewise.
-    * modules/iconv-h (Makefile.am): Likewise.
-    * modules/ieee754-h (Makefile.am): Likewise.
-    * modules/inttypes-incomplete (Makefile.am): Likewise.
-    * modules/langinfo (Makefile.am): Likewise.
-    * modules/libtextstyle-optional (Makefile.am): Likewise.
-    * modules/limits-h (Makefile.am): Likewise.
-    * modules/locale (Makefile.am): Likewise.
-    * modules/malloc-h (Makefile.am): Likewise.
-    * modules/math (Makefile.am): Likewise.
-    * modules/monetary (Makefile.am): Likewise.
-    * modules/netdb (Makefile.am): Likewise.
-    * modules/openmp-init (Makefile.am): Likewise.
-    * modules/poll-h (Makefile.am): Likewise.
-    * modules/posix-shell (Makefile.am): Likewise.
-    * modules/pthread-h (Makefile.am): Likewise.
-    * modules/pty (Makefile.am): Likewise.
-    * modules/sched (Makefile.am): Likewise.
-    * modules/search (Makefile.am): Likewise.
-    * modules/signal-h (Makefile.am): Likewise.
-    * modules/sigsegv (Makefile.am): Likewise.
-    * modules/snippet/link-warning (Makefile.am): Likewise.
-    * modules/spawn (Makefile.am): Likewise.
-    * modules/stdalign (Makefile.am): Likewise.
-    * modules/stdarg (Makefile.am): Likewise.
-    * modules/stdbool (Makefile.am): Likewise.
-    * modules/stddef (Makefile.am): Likewise.
-    * modules/stdint (Makefile.am): Likewise.
-    * modules/stdio (Makefile.am): Likewise.
-    * modules/stdlib (Makefile.am): Likewise.
-    * modules/stdnoreturn (Makefile.am): Likewise.
-    * modules/string (Makefile.am): Likewise.
-    * modules/strings (Makefile.am): Likewise.
-    * modules/sysexits (Makefile.am): Likewise.
-    * modules/termios (Makefile.am): Likewise.
-    * modules/threads-h (Makefile.am): Likewise.
-    * modules/time (Makefile.am): Likewise.
-    * modules/uchar (Makefile.am): Likewise.
-    * modules/unicase/base (Makefile.am): Likewise.
-    * modules/uniconv/base (Makefile.am): Likewise.
-    * modules/unictype/base (Makefile.am): Likewise.
-    * modules/unigbrk/base (Makefile.am): Likewise.
-    * modules/unilbrk/base (Makefile.am): Likewise.
-    * modules/uniname/base (Makefile.am): Likewise.
-    * modules/uninorm/base (Makefile.am): Likewise.
-    * modules/unistd (Makefile.am): Likewise.
-    * modules/unistdio/base (Makefile.am): Likewise.
-    * modules/unistr/base (Makefile.am): Likewise.
-    * modules/unitypes (Makefile.am): Likewise.
-    * modules/uniwbrk/base (Makefile.am): Likewise.
-    * modules/uniwidth/base (Makefile.am): Likewise.
-    * modules/utime-h (Makefile.am): Likewise.
-    * modules/wchar (Makefile.am): Likewise.
-    * modules/wctype-h (Makefile.am): Likewise.
-
---------------------------------------------------------------------------------
-
 commit 4bdc327dbda59dcdbfa0f983a4f35c4a4ec3578c
 Author: Bruno Haible <br...@clisp.org>
 Date:   Sun Dec 19 12:49:16 2021 +0100
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index 9774a56378..0845bce5f1 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -65,6 +65,14 @@ def _convert_to_gnu_make(snippet: str) -> str:
     return snippet
 
 
+def _eliminate_NMD(snippet: str, automake_subdir: bool) -> str:
+    if automake_subdir:
+        lines = [line if not line.startswith('@NMD@') else line.replace('@NMD@', '') for line in snippet.splitlines()]
+    else:
+        lines = [line for line in snippet.splitlines() if not line.startswith('@NMD@')]
+    return '\n'.join(lines) + '\n'
+
+
 #===============================================================================
 # Define GLEmiter class
 #===============================================================================
@@ -682,6 +690,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         auxdir = self.config['auxdir']
         gnu_make = self.config['gnu_make']
         makefile_name = self.config['makefile_name']
+        automake_subdir = self.config['automake_subdir']
         libtool = self.config['libtool']
         macro_prefix = self.config['macro_prefix']
         podomain = self.config['podomain']
@@ -735,6 +744,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                 if eliminate_LDFLAGS:
                     pattern = re.compile('^(lib_LDFLAGS[\t ]*\\+=.*$\n)', re.M)
                     amsnippet1 = pattern.sub('', amsnippet1)
+                amsnippet1 = _eliminate_NMD(amsnippet1, automake_subdir)
                 pattern = re.compile('lib_([A-Z][A-Z]*)', re.M)
                 amsnippet1 = pattern.sub('%s_%s_\\1' % (libname, libext),
                                          amsnippet1)
@@ -1035,6 +1045,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                 if eliminate_LDFLAGS:
                     pattern = re.compile('^(lib_LDFLAGS[\t ]*\\+=.*$\n)', re.M)
                     amsnippet1 = pattern.sub('', amsnippet1)
+                amsnippet1 = _eliminate_NMD(amsnippet1, False)
                 pattern = re.compile('lib_([A-Z][A-Z]*)', re.M)
                 amsnippet1 = pattern.sub('libtests_a_\\1', amsnippet1)
                 amsnippet1 = amsnippet1.replace('$(GNULIB_', '$(' + module_indicator_prefix + '_GNULIB_')
-- 
2.44.0

From ae88824aa879b9a8b97f05bd1623fea56880c7b1 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Sun, 10 Mar 2024 00:55:56 -0800
Subject: [PATCH 4/5] gnulib-tool.py: Follow gnulib-tool changes, part 54.

Follow gnulib-tool change
2021-12-24  Paul Eggert  <egg...@cs.ucla.edu>
maint: avoid empty lines in recipes

* pygnulib/GLEmiter.py (_eliminate_NMD): Eliminate occurrences of @!NMD@
too.
---
 ChangeLog            |  9 +++++++++
 gnulib-tool.py.TODO  | 38 --------------------------------------
 pygnulib/GLEmiter.py |  6 ++++--
 3 files changed, 13 insertions(+), 40 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 27a9b2ea2c..f565d0d657 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-03-10  Collin Funk  <collin.fu...@gmail.com>
+
+	gnulib-tool.py: Follow gnulib-tool changes, part 54.
+	Follow gnulib-tool change
+	2021-12-24  Paul Eggert  <egg...@cs.ucla.edu>
+	maint: avoid empty lines in recipes
+	* pygnulib/GLEmiter.py (_eliminate_NMD): Eliminate occurrences of @!NMD@
+	too.
+
 2024-03-10  Collin Funk  <collin.fu...@gmail.com>
 
 	gnulib-tool.py: Follow gnulib-tool changes, part 53.
diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO
index c3d5d65f5c..69d3cf7d72 100644
--- a/gnulib-tool.py.TODO
+++ b/gnulib-tool.py.TODO
@@ -169,44 +169,6 @@ Date:   Sat Dec 25 12:19:13 2021 +0100
 
 --------------------------------------------------------------------------------
 
-commit b4c57b4240992832fa89a02dc620c4fa5ac36973
-Author: Paul Eggert <egg...@cs.ucla.edu>
-Date:   Fri Dec 24 17:22:00 2021 -0800
-
-    maint: avoid empty lines in recipes
-
-    AIX 7.2 ‘make’ complains about recipe lines that are empty after
-    macro expansion, and I suppose there’s a good chance some
-    non-POSIX ‘make’ would prohibit them.  Rework macros so
-    that we can avoid them.
-    * gnulib-tool (func_emit_lib_Makefile_am)
-    (func_emit_lib_Makefile_am): Support @!NMD@ too.
-    * modules/gen-header (@gl_V_at): New macro.
-    * modules/alloca-opt, modules/argz, modules/assert-h:
-    * modules/byteswap, modules/configmake, modules/ctype:
-    * modules/dirent, modules/errno, modules/execinfo, modules/fcntl-h:
-    * modules/float, modules/fnmatch-h, modules/getopt-posix:
-    * modules/glob-h, modules/iconv-h, modules/ieee754-h:
-    * modules/inttypes-incomplete, modules/langinfo:
-    * modules/libtextstyle-optional, modules/limits-h, modules/locale:
-    * modules/malloc-h, modules/math, modules/monetary, modules/netdb:
-    * modules/openmp-init, modules/poll-h, modules/posix-shell:
-    * modules/pthread-h, modules/pty, modules/sched, modules/search:
-    * modules/signal-h, modules/sigsegv, modules/snippet/link-warning:
-    * modules/spawn, modules/stdalign, modules/stdarg, modules/stdbool:
-    * modules/stddef, modules/stdint, modules/stdio, modules/stdlib:
-    * modules/stdnoreturn, modules/string, modules/strings:
-    * modules/sysexits, modules/termios, modules/threads-h:
-    * modules/time, modules/uchar, modules/unicase/base:
-    * modules/uniconv/base, modules/unictype/base, modules/unigbrk/base:
-    * modules/unilbrk/base, modules/uniname/base, modules/uninorm/base:
-    * modules/unistd, modules/unistdio/base, modules/unistr/base:
-    * modules/unitypes, modules/uniwbrk/base, modules/uniwidth/base:
-    * modules/utime-h, modules/wchar, modules/wctype-h:
-    Use it.
-
---------------------------------------------------------------------------------
-
 commit 4bdc327dbda59dcdbfa0f983a4f35c4a4ec3578c
 Author: Bruno Haible <br...@clisp.org>
 Date:   Sun Dec 19 12:49:16 2021 +0100
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index 0845bce5f1..d907adeaef 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -67,9 +67,11 @@ def _convert_to_gnu_make(snippet: str) -> str:
 
 def _eliminate_NMD(snippet: str, automake_subdir: bool) -> str:
     if automake_subdir:
-        lines = [line if not line.startswith('@NMD@') else line.replace('@NMD@', '') for line in snippet.splitlines()]
+        lines = [line if not line.startswith('@NMD@') else line.replace('@NMD@', '')
+                 for line in snippet.splitlines() if not line.startswith('@!NMD@')]
     else:
-        lines = [line for line in snippet.splitlines() if not line.startswith('@NMD@')]
+        lines = [line if not line.startswith('@!NMD@') else line.replace('@!NMD@', '')
+                 for line in snippet.splitlines() if not line.startswith('@NMD@')]
     return '\n'.join(lines) + '\n'
 
 
-- 
2.44.0

From d50f5538ddaca6a266c79166b956d40be5c2aa6c Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Sun, 10 Mar 2024 01:02:30 -0800
Subject: [PATCH 5/5] gnulib-tool: Don't remove comments referencing @NMD@,
 part 2.

* gnulib-tool (func_emit_tests_Makefile_am): Replace lines that start
with @NMD@ or @!NMD@ instead of lines that contain them.
---
 ChangeLog   | 6 ++++++
 gnulib-tool | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index f565d0d657..9880ab1703 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-03-10  Collin Funk  <collin.fu...@gmail.com>
+
+	gnulib-tool: Don't remove comments referencing @NMD@, part 2.
+	* gnulib-tool (func_emit_tests_Makefile_am): Replace lines that start
+	with @NMD@ or @!NMD@ instead of lines that contain them.
+
 2024-03-10  Collin Funk  <collin.fu...@gmail.com>
 
 	gnulib-tool.py: Follow gnulib-tool changes, part 54.
diff --git a/gnulib-tool b/gnulib-tool
index 0cf5e54a20..47ee378444 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -4164,7 +4164,7 @@ func_emit_tests_Makefile_am ()
   fi
   # Replace NMD, so as to remove redundant "$(MKDIR_P) '.'" invocations.
   # The logic is similar to how we define gl_source_base_prefix.
-  sed_eliminate_NMD='/@NMD@/d;s/@!NMD@//'
+  sed_eliminate_NMD='/^@NMD@/d;s/^@!NMD@//'
   if $for_test; then
     # When creating a package for testing: Attempt to provoke failures,
     # especially link errors, already during "make" rather than during
-- 
2.44.0

Reply via email to