]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool: Allow compiler warnings in Gnulib code.
authorBruno Haible <bruno@clisp.org>
Mon, 3 Feb 2025 21:28:51 +0000 (22:28 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 3 Feb 2025 22:56:09 +0000 (23:56 +0100)
* gnulib-tool.sh (func_emit_lib_Makefile_am): Append
$(GL_CFLAG_ALLOW_WARNINGS) to the ${libname}_${libext}_CFLAGS variable.
* pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am): Likewise.

ChangeLog
gnulib-tool.sh
pygnulib/GLEmiter.py

index 62827cda3f2a4e1bc88ef87f39de48a34ff9dfa7..62d625435926d044c69cc49cf7a0286ac2ec0e6f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-02-03  Bruno Haible  <bruno@clisp.org>
+
+       gnulib-tool: Allow compiler warnings in Gnulib code.
+       * gnulib-tool.sh (func_emit_lib_Makefile_am): Append
+       $(GL_CFLAG_ALLOW_WARNINGS) to the ${libname}_${libext}_CFLAGS variable.
+       * pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am): Likewise.
+
 2025-02-03  Bruno Haible  <bruno@clisp.org>
 
        gnulib-tool: Apply libgnu.{,l}a specific CFLAGS to all its object files.
index eedeb306bca702fb62734bef0d6626c51bd9ee19..bddd3073d621de5521065a4190e6816c9a6baecb 100755 (executable)
@@ -4025,8 +4025,22 @@ func_emit_lib_Makefile_am ()
   fi
   echo
   echo "${libname}_${libext}_SOURCES ="
+  # Insert a '-Wno-error' option in the compilation commands emitted by
+  # Automake, between $(AM_CPPFLAGS) and before the reference to @CFLAGS@.
+  # Why?
+  # - Because every package maintainer has their preferred set of warnings
+  #   that they may want to enforce in the main source code of their package,
+  #   and some of these warnings (such as '-Wswitch-enum') complain about code
+  #   that is just perfect.
+  #   Gnulib source code is maintained according to Gnulib coding style.
+  #   Package maintainers have no right to force their coding style upon Gnulib.
+  # Why before @CFLAGS@?
+  # - Because "the user is always right": If a user adds '-Werror' to their
+  #   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; then
-    echo "${libname}_${libext}_CFLAGS = \$(AM_CFLAGS) \$(GL_CFLAG_GNULIB_WARNINGS)"
+    echo "${libname}_${libext}_CFLAGS = \$(AM_CFLAGS) \$(GL_CFLAG_GNULIB_WARNINGS) \$(GL_CFLAG_ALLOW_WARNINGS)"
   fi
   # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
   # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
@@ -4391,7 +4405,9 @@ func_emit_tests_Makefile_am ()
   #    arguments, endless recursions, etc.) that a compiler may warn about,
   #    even with just the normal '-Wall' option.
   # 2) Because every package maintainer has their preferred set of warnings
-  #    that they may want to enforce in the main source code of their package.
+  #    that they may want to enforce in the main source code of their package,
+  #    and some of these warnings (such as '-Wswitch-enum') complain about code
+  #    that is just perfect.
   #    But Gnulib tests are maintained in Gnulib and don't end up in binaries
   #    that that package installs; therefore it does not make sense for
   #    package maintainers to enforce the absence of warnings on these tests.
index a8f22ed97c67242bbc565f8f1e201e0ebb72c76c..814ccae571c0cff799b96075935b24992ccc1888 100644 (file)
@@ -911,8 +911,22 @@ AC_DEFUN([%V1%_LIBSOURCES], [
 
         emit += '\n'
         emit += '%s_%s_SOURCES =\n' % (libname, libext)
+        # Insert a '-Wno-error' option in the compilation commands emitted by
+        # Automake, between $(AM_CPPFLAGS) and before the reference to @CFLAGS@.
+        # Why?
+        # - Because every package maintainer has their preferred set of warnings
+        #   that they may want to enforce in the main source code of their package,
+        #   and some of these warnings (such as '-Wswitch-enum') complain about code
+        #   that is just perfect.
+        #   Gnulib source code is maintained according to Gnulib coding style.
+        #   Package maintainers have no right to force their coding style upon Gnulib.
+        # Why before @CFLAGS@?
+        # - Because "the user is always right": If a user adds '-Werror' to their
+        #   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:
-            emit += '%s_%s_CFLAGS = $(AM_CFLAGS) $(GL_CFLAG_GNULIB_WARNINGS)\n' % (libname, libext)
+            emit += '%s_%s_CFLAGS = $(AM_CFLAGS) $(GL_CFLAG_GNULIB_WARNINGS) $(GL_CFLAG_ALLOW_WARNINGS)\n' % (libname, libext)
         # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
         # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
         emit += '%s_%s_LIBADD = $(%s_%s_%sLIBOBJS)\n' % (libname, libext, macro_prefix, libname, perhapsLT)
@@ -1183,7 +1197,9 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         #    arguments, endless recursions, etc.) that a compiler may warn about,
         #    even with just the normal '-Wall' option.
         # 2) Because every package maintainer has their preferred set of warnings
-        #    that they may want to enforce in the main source code of their package.
+        #    that they may want to enforce in the main source code of their package,
+        #    and some of these warnings (such as '-Wswitch-enum') complain about code
+        #    that is just perfect.
         #    But Gnulib tests are maintained in Gnulib and don't end up in binaries
         #    that that package installs; therefore it does not make sense for
         #    package maintainers to enforce the absence of warnings on these tests.