> 2025-02-03  Bruno Haible  <br...@clisp.org>
> 
>       gnulib-tool: Apply libgnu.{,l}a specific CFLAGS to all its object files.

Oops, this change broke the --create-testdir option.

How to reproduce:
$ ./gnulib-tool --create-testdir --dir=../testdir1 --with-c++-tests 
--without-privileged-tests --single-configure obstack-zprintf c-vasnprintf 
snzprintf c-vaszprintf vasprintf vdzprintf c-vsnprintf c-vsnzprintf vaszprintf 
c-vasprintf zprintf vasnprintf vsnzprintf dprintf snprintf fzprintf xprintf 
xvasprintf dzprintf vfzprintf vzprintf c-xvasprintf c-snzprintf vszprintf 
unistdio/u32-vsnprintf unistdio/u16-u16-asnprintf unistdio/u8-u8-vasnprintf 
unistdio/ulc-asnprintf unistdio/u16-u16-vasnprintf unistdio/u16-vsnprintf 
unistdio/ulc-vsprintf unistdio/u16-u16-vsprintf unistdio/u8-asnprintf 
unistdio/ulc-fprintf unistdio/u16-vsprintf unistdio/u32-u32-vsnprintf 
unistdio/u16-snprintf unistdio/u32-u32-vasprintf unistdio/u16-asnprintf 
unistdio/u8-u8-sprintf unistdio/u8-u8-vasprintf unistdio/u32-vsprintf 
unistdio/u32-u32-sprintf unistdio/ulc-vfprintf unistdio/u8-asprintf 
unistdio/u16-vasnprintf unistdio/u16-u16-asprintf unistdio/u8-vasprintf 
unistdio/ulc-vasnprintf unistdio/u16-sprintf unistdio/u8-u8-asprintf 
unistdio/u32-u32-asnprintf unistdio/u32-asnprintf unistdio/u32-u32-snprintf 
unistdio/u8-snprintf unistdio/ulc-sprintf unistdio/u8-sprintf 
unistdio/u8-u8-asnprintf unistdio/u16-asprintf unistdio/u16-u16-snprintf 
unistdio/u16-u16-vasprintf unistdio/u8-vsnprintf unistdio/u32-u32-asprintf 
unistdio/u32-sprintf unistdio/ulc-snprintf unistdio/u8-u8-vsprintf 
unistdio/ulc-vasprintf unistdio/u16-vasprintf unistdio/ulc-vsnprintf 
unistdio/u32-u32-vsprintf unistdio/u32-asprintf unistdio/u8-vsprintf 
unistdio/u8-u8-snprintf unistdio/u16-u16-sprintf unistdio/u32-vasnprintf 
unistdio/u16-u16-vsnprintf unistdio/u8-vasnprintf unistdio/u32-u32-vasnprintf 
unistdio/u32-snprintf unistdio/u8-u8-vsnprintf unistdio/u32-vasprintf 
unistdio/ulc-asprintf c-snprintf vsnprintf vasnwprintf szprintf obstack-printf 
vdprintf
...
$ make
...
make[2]: Entering directory '/GNULIB/testdir1/gllib'
make[2]: *** No rule to make target 'libgnu_a-asnprintf.o', needed by 
'libgnu.a'.
make[2]: *** No rule to make target 'libgnu_a-printf-args.o', needed by 
'libgnu.a'.
make[2]: *** No rule to make target 'libgnu_a-printf-parse.o', needed by 
'libgnu.a'.
make[2]: *** No rule to make target 'libgnu_a-vasnprintf.o', needed by 
'libgnu.a'.

This produces a build error because the gl_libgnu_LIBOBJS variable contains
libgnu_a-printf-args.o — which does not exist since Automake has emitted
rules for creating printf-args.o in this case. So, here we need to use
$(gl_LIBOBJS), not $(gl_libgnu_LIBOBJS).


2025-02-04  Bruno Haible  <br...@clisp.org>

        gnulib-tool: Fix the result of --create-testdir (regression yesterday).
        * gnulib-tool.sh (func_emit_lib_Makefile_am): If $for_test, revert to
        the previous code.
        * pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am): If for_test, revert
        to the previous code.

diff --git a/gnulib-tool.sh b/gnulib-tool.sh
index bddd3073d6..0fbd805ebe 100755
--- a/gnulib-tool.sh
+++ b/gnulib-tool.sh
@@ -4044,8 +4044,16 @@ func_emit_lib_Makefile_am ()
   fi
   # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
   # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
-  echo "${libname}_${libext}_LIBADD = 
\$(${macro_prefix}_${libname}_${perhapsLT}LIBOBJS)"
-  echo "${libname}_${libext}_DEPENDENCIES = 
\$(${macro_prefix}_${libname}_${perhapsLT}LIBOBJS)"
+  if ! $for_test; then
+    # When there is a ${libname}_${libext}_CFLAGS or 
${libname}_${libext}_CPPFLAGS
+    # definition, Automake emits rules for creating object files prefixed with
+    # "${libname}_${libext}-".
+    echo "${libname}_${libext}_LIBADD = 
\$(${macro_prefix}_${libname}_${perhapsLT}LIBOBJS)"
+    echo "${libname}_${libext}_DEPENDENCIES = 
\$(${macro_prefix}_${libname}_${perhapsLT}LIBOBJS)"
+  else
+    echo "${libname}_${libext}_LIBADD = 
\$(${macro_prefix}_${perhapsLT}LIBOBJS)"
+    echo "${libname}_${libext}_DEPENDENCIES = 
\$(${macro_prefix}_${perhapsLT}LIBOBJS)"
+  fi
   echo "EXTRA_${libname}_${libext}_SOURCES ="
   if test "$libtool" = true; then
     echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
@@ -4081,7 +4089,14 @@ func_emit_lib_Makefile_am ()
   # Extend the 'distclean' rule.
   echo "distclean-local: distclean-gnulib-libobjs"
   echo "distclean-gnulib-libobjs:"
-  echo "       -rm -f @${macro_prefix}_${libname}_LIBOBJDEPS@"
+  if ! $for_test; then
+    # When there is a ${libname}_${libext}_CFLAGS or 
${libname}_${libext}_CPPFLAGS
+    # definition, Automake emits rules for creating object files prefixed with
+    # "${libname}_${libext}-".
+    echo "     -rm -f @${macro_prefix}_${libname}_LIBOBJDEPS@"
+  else
+    echo "     -rm -f @${macro_prefix}_LIBOBJDEPS@"
+  fi
   # Extend the 'maintainer-clean' rule.
   echo "maintainer-clean-local: distclean-gnulib-libobjs"
   rm -f "$tmp"/allsnippets
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index 814ccae571..cf16dd8654 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -929,8 +929,15 @@ def lib_Makefile_am(self, destfile: str, modules: 
list[GLModule], moduletable: G
             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)
-        emit += '%s_%s_DEPENDENCIES = $(%s_%s_%sLIBOBJS)\n' % (libname, 
libext, macro_prefix, libname, perhapsLT)
+        if not for_test:
+            # When there is a {libname}_{libext}_CFLAGS or 
{libname}_{libext}_CPPFLAGS
+            # definition, Automake emits rules for creating object files 
prefixed with
+            # "{libname}_{libext}-".
+            emit += '%s_%s_LIBADD = $(%s_%s_%sLIBOBJS)\n' % (libname, libext, 
macro_prefix, libname, perhapsLT)
+            emit += '%s_%s_DEPENDENCIES = $(%s_%s_%sLIBOBJS)\n' % (libname, 
libext, macro_prefix, libname, perhapsLT)
+        else:
+            emit += '%s_%s_LIBADD = $(%s_%sLIBOBJS)\n' % (libname, libext, 
macro_prefix, perhapsLT)
+            emit += '%s_%s_DEPENDENCIES = $(%s_%sLIBOBJS)\n' % (libname, 
libext, macro_prefix, perhapsLT)
         emit += 'EXTRA_%s_%s_SOURCES =\n' % (libname, libext)
         if libtool:
             emit += '%s_%s_LDFLAGS = $(AM_LDFLAGS)\n' % (libname, libext)
@@ -969,7 +976,13 @@ def lib_Makefile_am(self, destfile: str, modules: 
list[GLModule], moduletable: G
         # Extend the 'distclean' rule.
         emit += 'distclean-local: distclean-gnulib-libobjs\n'
         emit += 'distclean-gnulib-libobjs:\n'
-        emit += '\t-rm -f @%s_%s_LIBOBJDEPS@\n' % (macro_prefix, libname)
+        if not for_test:
+            # When there is a {libname}_{libext}_CFLAGS or 
{libname}_{libext}_CPPFLAGS
+            # definition, Automake emits rules for creating object files 
prefixed with
+            # "{libname}_{libext}-".
+            emit += '\t-rm -f @%s_%s_LIBOBJDEPS@\n' % (macro_prefix, libname)
+        else:
+            emit += '\t-rm -f @%s_LIBOBJDEPS@\n' % (macro_prefix)
         # Extend the 'maintainer-clean' rule.
         emit += 'maintainer-clean-local: distclean-gnulib-libobjs\n'
         return emit

Reply via email to