From: Bruno Haible <bruno@clisp.org>
Date: Sat, 7 Nov 2020 20:07:04 +0000 (+0100)
Subject: gnulib-tool: Fix link error with 'version-etc' (regression 2020-05-29).
X-Git-Tag: v1.0~3524
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=f570a82be35e36832adf0344d8d4e983c8db9e1a;p=gnulib.git

gnulib-tool: Fix link error with 'version-etc' (regression 2020-05-29).

Reported by Simon Josefsson in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-11/msg00032.html>.

* gnulib-tool (func_emit_tests_Makefile_am): Add libtests.a to
LDADD a third time, after the second occurrence of ../lib/libgnu.a.
* pygnulib/GLEmiter.py (tests_Makefile_am): Likewise.
---

diff --git a/ChangeLog b/ChangeLog
index f30e1489b9..90169c0595 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2020-11-07  Bruno Haible  <bruno@clisp.org>
+
+	gnulib-tool: Fix link error with 'version-etc' (regression 2020-05-29).
+	Reported by Simon Josefsson in
+	<https://lists.gnu.org/archive/html/bug-gnulib/2020-11/msg00032.html>.
+	* gnulib-tool (func_emit_tests_Makefile_am): Add libtests.a to
+	LDADD a third time, after the second occurrence of ../lib/libgnu.a.
+	* pygnulib/GLEmiter.py (tests_Makefile_am): Likewise.
+
 2020-11-04  Paul Eggert  <eggert@cs.ucla.edu>
 
 	tests: pacify Sun C 5.9
diff --git a/gnulib-tool b/gnulib-tool
index 1ce9c30894..8b7e305dd2 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -4170,11 +4170,12 @@ func_emit_tests_Makefile_am ()
     # It needs to be passed to the linker before ${libname}.${libext}, since
     # the tests-related modules depend on the main modules.
     # It also needs to be passed to the linker after ${libname}.${libext}
-    # because the latter might contain incomplete modules (such as the 'error'
-    # module whose dependency to 'progname' is voluntarily omitted).
+    # because the latter might contain incomplete modules (such as the
+    # 'version-etc' module whose dependency to 'version-etc-fsf' is voluntarily
+    # omitted).
     # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
     # not matter.
-    echo "LDADD = libtests.a ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext} libtests.a ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext} \$(LIBTESTS_LIBDEPS)"
+    echo "LDADD = libtests.a ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext} libtests.a ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext} libtests.a \$(LIBTESTS_LIBDEPS)"
   else
     echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
   fi
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index 441d2956d8..107f88cf21 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -1125,14 +1125,15 @@ AC_DEFUN([%V1%_LIBSOURCES], [
 
         if libtests:
             # All test programs need to be linked with libtests.a.
-            # It needs to be passed to the linker before ${libname}.${libext}, since
-            # the tests-related modules depend on the main modules.
+            # It needs to be passed to the linker before ${libname}.${libext},
+            # since the tests-related modules depend on the main modules.
             # It also needs to be passed to the linker after ${libname}.${libext}
             # because the latter might contain incomplete modules (such as the
-            # 'error' module whose dependency to 'progname' is voluntarily omitted).
-            # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
-            # not matter.
-            emit += 'LDADD = libtests.a %s/%s/%s.%s libtests.a %s/%s/%s.%s $(LIBTESTS_LIBDEPS)\n\n' % \
+            # 'version-etc' module whose dependency to 'version-etc-fsf' is
+            # voluntarily omitted).
+            # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it
+            # does not matter.
+            emit += 'LDADD = libtests.a %s/%s/%s.%s libtests.a %s/%s/%s.%s libtests.a $(LIBTESTS_LIBDEPS)\n\n' % \
                 (testsbase_inverse, sourcebase, libname, libext,
                  testsbase_inverse, sourcebase, libname, libext)
         else: