Slowly trying to sync the output of gnulibtool.py.
I am hesitant to change the TODO file until we can better testing
everything. This patch should (hopefully) fix the following commit entries:

16c3e1868a15a5946c0f0f7df6e107e9b3c6389d
d465dd70e1ec5fe332160780eb66511028f5897b
39d08c09b444db57f45804bfe86ee17203c45a8a
3a24ff8a1045d8d38824088c0984bb59d0192e65

Also, is there a preference against using f-strings [1] or is it just
because the code is old? I find them to be much more readable than the
older syntax for formatting.

[1] https://docs.python.org/3/tutorial/inputoutput.html#tut-f-strings
From 159fec290bd19f20f98fce1de053cff2bc69d67d Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Wed, 21 Feb 2024 12:21:24 -0800
Subject: [PATCH] gnulib-tool.py: Improve output of testdir Makefile.am.

* pygnulib/GLEmiter.py (GLEmiter.tests_Makefile_am):
Add 'all-notice' rule as dependency of 'all' which prints a
notice. Add 'check-notice' as a dependency of 'check-am' which
prints a notice. Demand Automake >= 1.14, for %reldir%. Add
overrides for CFLAGS and CXX_FLAGS in test directories.
---
 ChangeLog            |  7 +++++++
 pygnulib/GLEmiter.py | 29 +++++++++++++++++++++++++++--
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e313032178..cff7a2ef05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2024-02-21  Collin Funk  <collin.fu...@gmail.com>
 
+	gnulib-tool.py: Improve output of testdir Makefile.am.
+	* pygnulib/GLEmiter.py (GLEmiter.tests_Makefile_am):
+	Add 'all-notice' rule as dependency of 'all' which prints a
+	notice. Add 'check-notice' as a dependency of 'check-am' which
+	prints a notice. Demand Automake >= 1.14, for %reldir%. Add
+	overrides for CFLAGS and CXX_FLAGS in test directories.
+
 	gnulib-tool.py: Fix undefined variable while emitting testdir.
 	* pygnulib/GLTestDir.py (GLTestDir.execute): Fix undefined
 	variable refrence caused by commit
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index f83aa40ea9..3f103c101d 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -987,7 +987,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.14 foreign%s\n\n' % subdir_options
         if for_test and not single_configure:
             emit += 'ACLOCAL_AMFLAGS = -I %s/%s\n\n' % (testsbase_inverse, m4base)
 
@@ -1001,6 +1001,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         emit += 'noinst_PROGRAMS =\n'
         if not for_test:
             emit += 'check_PROGRAMS =\n'
+        emit += 'EXTRA_PROGRAMS =\n'
         emit += 'noinst_HEADERS =\n'
         emit += 'noinst_LIBRARIES =\n'
         if libtests:
@@ -1036,7 +1037,15 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                     emit += '%s += %s\n' % (dictionary['var'], dictionary['val'])
                     dictionary.pop('var')
 
-        emit += '\nAM_CPPFLAGS = \\\n'
+        emit += '\n'
+        if not for_test:
+            cflags_for_gnulib_code = " $(GL_CFLAG_GNULIB_WARNINGS)"
+        else:
+            cflags_for_gnulib_code = ""
+        emit += 'CFLAGS = @GL_CFLAG_ALLOW_WARNINGS@%s @CFLAGS@\n' % cflags_for_gnulib_code
+        emit += 'CXXFLAGS = @GL_CXXFLAG_ALLOW_WARNINGS@ @CXXFLAGS@\n'
+        emit += '\n'
+        emit += 'AM_CPPFLAGS = \\\n'
         if for_test:
             emit += '  -DGNULIB_STRICT_CHECKING=1 \\\n'
         if witness_c_macro:
@@ -1084,6 +1093,22 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         all_snippets = all_snippets.replace('$(top_srcdir)/build-aux/',
                                             '$(top_srcdir)/%s/' % auxdir)
         emit += all_snippets
+        # Arrange to print a message before compiling the files in this directory.
+        emit += "all: all-notice\n"
+        emit += "all-notice:\n"
+        emit += "\t@echo '## ---------------------------------------------------- ##'\n"
+        emit += "\t@echo '## ------------------- Gnulib tests ------------------- ##'\n"
+        emit += "\t@echo '## You can ignore compiler warnings in this directory.  ##'\n"
+        emit += "\t@echo '## ---------------------------------------------------- ##'\n"
+        emit += "\n"
+        # Arrange to print a message before executing the tests in this directory.
+        emit += "check-am: check-notice\n"
+        emit += "check-notice:\n"
+        emit += "\t@echo '## ---------------------------------------------------------------------- ##'\n"
+        emit += "\t@echo '## ---------------------------- Gnulib tests ---------------------------- ##'\n"
+        emit += "\t@echo '## Please report test failures in this directory to <bug-gnulib@gnu.org>. ##'\n"
+        emit += "\t@echo '## ---------------------------------------------------------------------- ##'\n"
+        emit += "\n"
         emit += '# Clean up after Solaris cc.\n'
         emit += 'clean-local:\n'
         emit += '\trm -rf SunWS_cache\n\n'
-- 
2.39.2

Reply via email to