]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
gnulib-tool.py: Follow gnulib-tool changes, part 55.
authorCollin Funk <collin.funk1@gmail.com>
Tue, 12 Mar 2024 01:50:28 +0000 (18:50 -0700)
committerBruno Haible <bruno@clisp.org>
Tue, 12 Mar 2024 16:47:30 +0000 (17:47 +0100)
Follow gnulib-tool changes
2022-01-05  Bruno Haible  <bruno@clisp.org>
gnulib-tool: Avoid known warnings that reflect Gnulib's coding style.
2022-01-08  Bruno Haible  <bruno@clisp.org>
gnulib-tool: Remove all *.Po files upon distclean (regr. 2022-01-05).

* pygnulib/GLEmiter.py (GLEmiter.initmacro_end): Collect the *.Po or
*.Plo files to remove into an AC_SUBSTed variable gl_LIBOBJDEPS. Use
Python f-strings instead of string replacements.
(GLEmiter.lib_Makefile_am): Add the GL_CFLAG_GNULIB_WARNINGS to the
CFLAGS of all the compilation units of the library. Extend the distclean
and maintainer-clean rules.
(GLEmiter.tests_Makefile_am): Add the GL_CFLAG_GNULIB_WARNINGS to the
CFLAGS.
* pygnulib/GLImport.py (GLImport.gnulib_comp): Emit an invocation of
gl_CC_GNULIB_WARNINGS.

ChangeLog
gnulib-tool.py.TODO
pygnulib/GLEmiter.py
pygnulib/GLImport.py

index 83979be9f477c7d6eb5654f51e728c02ed22ec23..ac803c2e18d51799b5bf582ace047129b91427ce 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2024-03-12  Collin Funk  <collin.funk1@gmail.com>
+
+       gnulib-tool.py: Follow gnulib-tool changes, part 55.
+       Follow gnulib-tool changes
+       2022-01-05  Bruno Haible  <bruno@clisp.org>
+       gnulib-tool: Avoid known warnings that reflect Gnulib's coding style.
+       2022-01-08  Bruno Haible  <bruno@clisp.org>
+       gnulib-tool: Remove all *.Po files upon distclean (regr. 2022-01-05).
+       * pygnulib/GLEmiter.py (GLEmiter.initmacro_end): Collect the *.Po or
+       *.Plo files to remove into an AC_SUBSTed variable gl_LIBOBJDEPS. Use
+       Python f-strings instead of string replacements.
+       (GLEmiter.lib_Makefile_am): Add the GL_CFLAG_GNULIB_WARNINGS to the
+       CFLAGS of all the compilation units of the library. Extend the distclean
+       and maintainer-clean rules.
+       (GLEmiter.tests_Makefile_am): Add the GL_CFLAG_GNULIB_WARNINGS to the
+       CFLAGS.
+       * pygnulib/GLImport.py (GLImport.gnulib_comp): Emit an invocation of
+       gl_CC_GNULIB_WARNINGS.
+
 2024-03-11  Collin Funk  <collin.funk1@gmail.com>
 
        gnulib-tool.py: Follow gnulib-tool changes, part 54.
index 69d3cf7d72299ce333dba97f5e2149652130f717..47e3fe56dcce9e5f651cabd2686120600ac4bc28 100644 (file)
@@ -98,36 +98,6 @@ Date:   Sun Jan 9 15:38:51 2022 +0100
 
 --------------------------------------------------------------------------------
 
-commit 9abc30c383303fab68aa5ed2841113876bfa90d1
-Author: Bruno Haible <bruno@clisp.org>
-Date:   Sat Jan 8 22:10:54 2022 +0100
-
-    gnulib-tool: Remove all *.Po files upon distclean (regr. 2022-01-05).
-
-    Reported by Mohammad Akhlaghi <mohammad@akhlaghi.org> in
-    <https://lists.gnu.org/archive/html/bug-gnulib/2022-01/msg00061.html>.
-
-    * gnulib-tool (func_emit_initmacro_end): Collect the *.Po or *.Plo files
-    to remove into an AC_SUBSTed variable gl_LIBOBJDEPS.
-    (func_emit_lib_Makefile_am): Extend the distclean and maintainer-clean
-    rules.
-
-commit 0c8a563f65d44752b33aec42cceec25bd485f2d5
-Author: Bruno Haible <bruno@clisp.org>
-Date:   Wed Jan 5 18:21:55 2022 +0100
-
-    gnulib-tool: Avoid known warnings that reflect Gnulib's coding style.
-
-    * m4/gnulib-common.m4 (gl_CC_GNULIB_WARNINGS): New macro.
-    * gnulib-tool (func_emit_lib_Makefile_am): Add the
-    GL_CFLAG_GNULIB_WARNINGS to the CFLAGS of all the compilation units of
-    the library.
-    (func_emit_tests_Makefile_am): Add the GL_CFLAG_GNULIB_WARNINGS to the
-    CFLAGS.
-    (func_import): Emit an invocation of gl_CC_GNULIB_WARNINGS.
-
---------------------------------------------------------------------------------
-
 commit 87e6634b28df65084321fed22f60d114a0931d21
 Author: Bernhard Voelker <mail@bernhard-voelker.de>
 Date:   Tue Jan 4 00:16:50 2022 +0100
index bfb7d51c016ee51b4697f67068403a9af3924653..c403df61413f27b514876c5daa6764ed8fe87efe 100644 (file)
@@ -606,6 +606,7 @@ USE_MSGCTXT = no\n"""
                             % type(gentests).__name__)
         sourcebase = self.config['sourcebase']
         automake_subdir = self.config['automake_subdir']
+        libtool = self.config['libtool']
         emit = ''
         # Check the presence of files that are mentioned as AC_LIBSOURCES
         # arguments. The check is performed only when autoconf is run from the
@@ -615,12 +616,16 @@ USE_MSGCTXT = no\n"""
             subdir = f'{sourcebase}/'
         else:
             subdir = ''
-        emit += r'''
-  m4_ifval(%V1%_LIBSOURCES_LIST, [
-    m4_syscmd([test ! -d ]m4_defn([%V1%_LIBSOURCES_DIR])[ ||
-      for gl_file in ]%V1%_LIBSOURCES_LIST[ ; do
-        if test ! -r ]m4_defn([%V1%_LIBSOURCES_DIR])[/$gl_file ; then
-          echo "missing file ]m4_defn([%V1%_LIBSOURCES_DIR])[/$gl_file" >&2
+        if libtool:
+            libobjdeps = f'{macro_prefix_arg}_libobjdeps="${macro_prefix_arg}_libobjdeps {subdir}$i_dir/\$(DEPDIR)/$i_base.Plo"'
+        else:
+            libobjdeps = f'{macro_prefix_arg}_libobjdeps="${macro_prefix_arg}_libobjdeps {subdir}$i_dir/\$(DEPDIR)/$i_base.Po"'
+        emit += fr'''
+  m4_ifval({macro_prefix_arg}_LIBSOURCES_LIST, [
+    m4_syscmd([test ! -d ]m4_defn([{macro_prefix_arg}_LIBSOURCES_DIR])[ ||
+      for gl_file in ]{macro_prefix_arg}_LIBSOURCES_LIST[ ; do
+        if test ! -r ]m4_defn([{macro_prefix_arg}_LIBSOURCES_DIR])[/$gl_file ; then
+          echo "missing file ]m4_defn([{macro_prefix_arg}_LIBSOURCES_DIR])[/$gl_file" >&2
           exit 1
         fi
       done])dnl
@@ -629,28 +634,38 @@ USE_MSGCTXT = no\n"""
   ])
   m4_popdef([GL_MODULE_INDICATOR_PREFIX])
   m4_popdef([GL_MACRO_PREFIX])
-  m4_popdef([%V1%_LIBSOURCES_DIR])
-  m4_popdef([%V1%_LIBSOURCES_LIST])
+  m4_popdef([{macro_prefix_arg}_LIBSOURCES_DIR])
+  m4_popdef([{macro_prefix_arg}_LIBSOURCES_LIST])
   m4_popdef([AC_LIBSOURCES])
   m4_popdef([AC_REPLACE_FUNCS])
   m4_popdef([AC_LIBOBJ])
   AC_CONFIG_COMMANDS_PRE([
-    %V1%_libobjs=
-    %V1%_ltlibobjs=
-    if test -n "$%V1%_LIBOBJS"; then
+    {macro_prefix_arg}_libobjs=
+    {macro_prefix_arg}_ltlibobjs=
+    {macro_prefix_arg}_libobjdeps=
+    if test -n "${macro_prefix_arg}_LIBOBJS"; then
       # Remove the extension.
+changequote(,)dnl
       sed_drop_objext='s/\.o$//;s/\.obj$//'
-      for i in `for i in $%V1%_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
-        %V1%_libobjs="$%V1%_libobjs %V2%$i.$ac_objext"
-        %V1%_ltlibobjs="$%V1%_ltlibobjs %V2%$i.lo"
+      sed_dirname1='s,//*,/,g'
+      sed_dirname2='s,\(.\)/$,\1,'
+      sed_dirname3='s,^[^/]*$,.,'
+      sed_dirname4='s,\(.\)/[^/]*$,\1,'
+      sed_basename1='s,.*/,,'
+changequote([, ])dnl
+      for i in `for i in ${macro_prefix_arg}_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
+        {macro_prefix_arg}_libobjs="${macro_prefix_arg}_libobjs {subdir}$i.$ac_objext"
+        {macro_prefix_arg}_ltlibobjs="${macro_prefix_arg}_ltlibobjs {subdir}$i.lo"
+        i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3" -e "$sed_dirname4"`
+        i_base=`echo "$i" | sed -e "$sed_basename1"`
+        {libobjdeps}
       done
     fi
-    AC_SUBST([%V1%_LIBOBJS], [$%V1%_libobjs])
-    AC_SUBST([%V1%_LTLIBOBJS], [$%V1%_ltlibobjs])
+    AC_SUBST([{macro_prefix_arg}_LIBOBJS], [${macro_prefix_arg}_libobjs])
+    AC_SUBST([{macro_prefix_arg}_LTLIBOBJS], [${macro_prefix_arg}_ltlibobjs])
+    AC_SUBST([{macro_prefix_arg}_LIBOBJDEPS], [${macro_prefix_arg}_libobjdeps])
   ])
 '''
-        emit = emit.replace('%V1%', macro_prefix_arg)
-        emit = emit.replace('%V2%', subdir)
         return emit
 
     def initmacro_done(self, macro_prefix_arg, sourcebase_arg):
@@ -960,6 +975,8 @@ AC_DEFUN([%V1%_LIBSOURCES], [
 
         emit += '\n'
         emit += '%s_%s_SOURCES =\n' % (libname, libext)
+        if not for_test:
+            emit += '%s_%s_CFLAGS = $(AM_CFLAGS) $(GL_CFLAG_GNULIB_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_%sLIBOBJS)\n' % (libname, libext, macro_prefix, perhapsLT)
@@ -998,6 +1015,13 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         emit += '\t  fi; \\\n'
         emit += '\tdone; \\\n'
         emit += '\t:\n'
+        # Emit rules to erase .Po and .Plo files for AC_LIBOBJ invocations.
+        # Extend the 'distclean' rule.
+        emit += 'distclean-local: distclean-gnulib-libobjs\n'
+        emit += 'distclean-gnulib-libobjs:\n'
+        emit += '\t-rm -f @%s_LIBOBJDEPS@\n' % (macro_prefix)
+        # Extend the 'maintainer-clean' rule.
+        emit += 'maintainer-clean-local: distclean-gnulib-libobjs\n'
         result = tuple([emit, uses_subdirs])
         return result
 
@@ -1242,7 +1266,11 @@ 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'.
-        emit += 'CFLAGS = @GL_CFLAG_ALLOW_WARNINGS@ @CFLAGS@\n'
+        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)'
+        emit += 'CFLAGS = @GL_CFLAG_ALLOW_WARNINGS@%s @CFLAGS@\n' % (cflags_for_gnulib_code)
         emit += 'CXXFLAGS = @GL_CXXFLAG_ALLOW_WARNINGS@ @CXXFLAGS@\n'
         emit += '\n'
 
index 1dabccd20198da63d7825211e42f6ab645fd7f04..db8c1c24a6b52c4f35b963551526836f8c1f86f4 100644 (file)
@@ -744,6 +744,7 @@ AC_DEFUN([%s_INIT],
                                               moduletable, 0, True, True, True, replace_auxdir)
         emit += '  m4_popdef([gl_MODULE_INDICATOR_CONDITION])\n'
         emit += self.emitter.initmacro_end('%stests' % macro_prefix, gentests)
+        emit += '  AC_REQUIRE([gl_CC_GNULIB_WARNINGS])\n'
         # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
         # created using libtool, because libtool already handles the dependencies.
         if not libtool: