]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
gnulib-tool: Improve changes from yesterday and today.
authorBruno Haible <bruno@clisp.org>
Thu, 4 Sep 2025 20:52:44 +0000 (22:52 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 4 Sep 2025 21:50:26 +0000 (23:50 +0200)
* gnulib-tool.sh (func_emit_tests_Makefile_am): Consider also the case
that --with-tests is specified and --makefile-name /
--tests-makefile-name are not specified. Simplify an initialization and
augmentation to an initialization.
* pygnulib/GLEmiter.py (GLEmiter.tests_Makefile_am): Likewise.

ChangeLog
gnulib-tool.sh
pygnulib/GLEmiter.py

index 3752bb91986b3e47fcdc6c4af475ac05e91fb37e..5052d65d2156b0d466ecf52dc863945f82e3479c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2025-09-04  Bruno Haible  <bruno@clisp.org>
+
+       gnulib-tool: Improve changes from yesterday and today.
+       * gnulib-tool.sh (func_emit_tests_Makefile_am): Consider also the case
+       that --with-tests is specified and --makefile-name /
+       --tests-makefile-name are not specified. Simplify an initialization and
+       augmentation to an initialization.
+       * pygnulib/GLEmiter.py (GLEmiter.tests_Makefile_am): Likewise.
+
 2025-09-03  Collin Funk  <collin.funk1@gmail.com>
 
        crypto/sha3-buffer: Don't abort on OOM.
index 566525742ac1826da204cf9cc7c7c8289dff26d9..15a642279faa44271b115af47ea5e0bb63af3784 100755 (executable)
@@ -4454,23 +4454,22 @@ func_emit_tests_Makefile_am ()
   #   CFLAGS, they have asked for errors, they will get errors. But they have
   #   no right to complain about these errors, because Gnulib does not support
   #   '-Werror'.
+  if ! $for_test && { test -n "$tests_makefile_name" || test -n "$makefile_name"; }; then
+    # This function produces a makefile that is meant to be 'include'd.
+    am_set_or_augment='+='
+  else
+    # This function produces a makefile 'Makefile.am' that is standalone.
+    am_set_or_augment='='
+  fi
   cflags_for_gnulib_code=
   if ! $for_test; then
     # Enable or disable warnings as suitable for the Gnulib coding style.
     cflags_for_gnulib_code=" \$(GL_CFLAG_GNULIB_WARNINGS)"
-  else
-    # Make sure AM_CFLAGS is set or Automake will error when we append to it
-    # using '+='.
-    echo 'AM_CFLAGS ='
-    # Likewise for AM_CXXFLAGS.
-    if test -n "$uses_cxx"; then
-      echo 'AM_CXXFLAGS ='
-    fi
   fi
   # The primary place to add these options is AM_CFLAGS.
-  echo "AM_CFLAGS += @GL_CFLAG_ALLOW_WARNINGS@${cflags_for_gnulib_code}"
+  echo "AM_CFLAGS ${am_set_or_augment} @GL_CFLAG_ALLOW_WARNINGS@${cflags_for_gnulib_code}"
   if test -n "$uses_cxx"; then
-    echo "AM_CXXFLAGS += @GL_CXXFLAG_ALLOW_WARNINGS@"
+    echo "AM_CXXFLAGS ${am_set_or_augment} @GL_CXXFLAG_ALLOW_WARNINGS@"
   fi
   echo
   # The secondary place to add these options is CFLAGS. This is less reliable,
index c055786a037a66f042f510316cae25e2497851d0..8461bfde54336fda559933731425888ac55446ee 100644 (file)
@@ -1000,9 +1000,9 @@ AC_DEFUN([%V1%_LIBSOURCES], [
     def tests_Makefile_am(self, destfile: str, modules: list[GLModule], moduletable: GLModuleTable,
                           makefiletable: GLMakefileTable, witness_macro: str, for_test: bool) -> str:
         '''Emit the contents of the tests Makefile. Returns it as a string.
-        GLConfig: localpath, modules, libname, auxdir, makefile_name, libtool,
-        sourcebase, m4base, testsbase, macro_prefix, witness_c_macro,
-        single_configure, libtests.
+        GLConfig: localpath, modules, libname, auxdir, makefile_name,
+        tests_makefile_name, libtool, sourcebase, m4base, testsbase,
+        macro_prefix, witness_c_macro, single_configure, libtests.
 
         destfile is a filename relative to destdir of Makefile being generated.
         witness_macro is a string which represents witness_c_macro with the suffix.
@@ -1034,6 +1034,8 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         m4base = self.config['m4base']
         testsbase = self.config['testsbase']
         gnu_make = self.config['gnu_make']
+        makefile_name = self.config['makefile_name']
+        tests_makefile_name = self.config['tests_makefile_name']
         libtool = self.config['libtool']
         macro_prefix = self.config['macro_prefix']
         conddeps = self.config['conddeps']
@@ -1238,21 +1240,20 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         #   CFLAGS, they have asked for errors, they will get errors. But they have
         #   no right to complain about these errors, because Gnulib does not support
         #   '-Werror'.
+        if (not for_test) and (tests_makefile_name or makefile_name):
+            # This function produces a makefile that is meant to be 'include'd.
+            am_set_or_augment = '+='
+        else:
+            # This function produces a makefile 'Makefile.am' that is standalone.
+            am_set_or_augment = '='
         cflags_for_gnulib_code = ''
         if not for_test:
             # Enable or disable warnings as suitable for the Gnulib coding style.
             cflags_for_gnulib_code = ' $(GL_CFLAG_GNULIB_WARNINGS)'
-        else:
-            # Make sure AM_CFLAGS is set or Automake will error when we append to it
-            # using '+='.
-            emit += 'AM_CFLAGS =\n'
-            # Likewise for AM_CXXFLAGS.
-            if uses_cxx:
-                emit += 'AM_CXXFLAGS =\n'
         # The primary place to add these options is AM_CFLAGS.
-        emit += 'AM_CFLAGS += @GL_CFLAG_ALLOW_WARNINGS@%s\n' % (cflags_for_gnulib_code)
+        emit += 'AM_CFLAGS %s @GL_CFLAG_ALLOW_WARNINGS@%s\n' % (am_set_or_augment, cflags_for_gnulib_code)
         if uses_cxx:
-            emit += 'AM_CXXFLAGS += @GL_CXXFLAG_ALLOW_WARNINGS@\n'
+            emit += 'AM_CXXFLAGS %s @GL_CXXFLAG_ALLOW_WARNINGS@\n' % (am_set_or_augment)
         emit += '\n'
         # The secondary place to add these options is CFLAGS. This is less reliable,
         # because the user can invoke e.g. "make CFLAGS=-O2"; see