Subject: bug#19961: [PATCH 2/2] automake: allow check-local to run early

From: Mike Frysinger <[email-masked]>
Date: Sun, 20 Feb 2022 22:36:32 -0500

Fixes automake bug https://bugs.gnu.org/19961.

* NEWS: Note that check-local may run earlier that before.
* bin/automake.in: Allow check-local to run before check-am instead
of after like check-hook does.
---
 NEWS            | 5 +++++
 bin/automake.in | 7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 183825e8f2ed..a4f3d6063073 100644
--- a/NEWS
+++ b/NEWS
@@ -31,6 +31,11 @@ New in 1.17:
 
   - The check target now supports user defined check-hook.
 
+* Miscellaneous changes
+
+  - The user defined check-local target may now run earlier in the check
+    process.  Users who want to always run at the end should use check-hook.
+
 * Obsolescent features:
 
   - py-compile no longer supports Python 0.x or 1.x versions.  Python 2.0,
diff --git a/bin/automake.in b/bin/automake.in
index 1a47865474f9..5a151455019e 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -4668,7 +4668,7 @@ sub handle_user_recursion ()
 sub do_check_merge_target ()
 {
   # Include user-defined local form of target.
-  push @check_tests, 'check-local'
+  $output_rules .= "check-local: all-am\n"
     if user_phony_rule 'check-local';
   push @check_tests, 'check-hook'
     if user_phony_rule 'check-hook';
@@ -4676,7 +4676,10 @@ sub do_check_merge_target ()
   # The check target must depend on the local equivalent of
   # 'all', to ensure all the primary targets are built.  Then it
   # must build the local check rules.
-  $output_rules .= "check-am: all-am\n";
+  $output_rules .= "check-am: all-am";
+  $output_rules .= " check-local"
+    if user_phony_rule 'check-local';
+  $output_rules .= "\n";
   if (@check)
     {
       pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t  ", @check);
-- 
2.34.1