From cbe0d2e47f9f149ef9937358ba3a82c043e36175 Mon Sep 17 00:00:00 2001
From: Paul Smith <psmith@gnu.org>
Date: Wed, 19 Jan 2022 19:45:12 -0500
Subject: [PATCH] * tests/scripts/features/implicit_search: [SV 48643]
 Cleanups.

---
 NEWS                                   | 18 +++++++++---------
 tests/scripts/features/implicit_search | 18 ++++++------------
 2 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/NEWS b/NEWS
index eba371fa..e9f03d01 100644
--- a/NEWS
+++ b/NEWS
@@ -61,6 +61,15 @@ https://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=109&se
   avoiding the need for heuristics.
   Implementation provided by Sven C. Dack <sdack@gmx.com>
 
+* GNU make has sometimes chosen unexpected, and sub-optimal, chains of
+  implicit rules due to the definition of "ought to exist" in the implicit
+  rule search algorithm, which considered any prerequisite mentioned in the
+  makefile as "ought to exist".  This algorithm has been modified to prefer
+  prerequisites mentioned explicitly in the target being built and only if
+  that results in no matching rule, will GNU make consider prerequisites
+  mentioned in other targets as "ought to exist".
+  Implementation provided by Dmitry Goncharov <dgoncharov@users.sf.net>
+
 * If the MAKEFLAGS variable is modified in a makefile, it will be re-parsed
   immediately rather than after all makefiles have been read.  Note that
   although all options are parsed immediately, some special effects won't
@@ -89,15 +98,6 @@ https://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=109&se
   made as a side-effect of some other target's recipe are now noticed as
   expected.
 
-* GNU make has sometimes chosen unexpected, and sub-optimal, chains of
-  implicit rules due to the definition of "ought to exist" in the implicit
-  rule search algorithm, which considered any prerequisite mentioned in the
-  makefile as "ought to exist".  This algorithm has been modified to prefer
-  prerequisites mentioned explicitly in the target being built and only if
-  that results in no matching rule, will GNU make consider prerequisites
-  mentioned in other targets as "ought to exist".
-  Implementation provided by Dmitry Goncharov <dgoncharov@users.sf.net>
-
 * GNU Make can now be built for MS-Windows using the Tiny C tcc compiler.
   Port provided by Christian Jullien <eligis@orange.fr>
 
diff --git a/tests/scripts/features/implicit_search b/tests/scripts/features/implicit_search
index 745423d8..93a212bd 100644
--- a/tests/scripts/features/implicit_search
+++ b/tests/scripts/features/implicit_search
@@ -4,27 +4,21 @@ $description = "Test implicit rule search.";
 
 $details = "";
 
-
 # sv 48643
 # Each test has a %.c rule ahead of %.f rule.
 # hello.f exists and hello.c is missing.
 
 unlink('hello.c', 'hello.tsk', 'hello.o', 'hello.x');
 
-
-
 # Run every test with and without a suffix.
 my @suffixes = ('', '.o');
 # Run every test with single and double colon rules.
 my @rules = ('', ':');
 
-touch('hello.f');
-
 for my $s (@suffixes) {
 for my $r (@rules) {
 touch('hello.f');
 
-
 # Test that make finds the intended implicit rule based on existence of a
 # prerequisite in the filesystem.
 #
@@ -107,24 +101,24 @@ run_make_test("
 all: hello$s
 %$s:$r %.c; \$(info \$<)
 %$s:$r %.f; \$(info \$<)
-.DEFAULT:; true
+.DEFAULT:; \$(info \$\@) true
 unrelated: hello.c
 ", '', "hello.f\n#MAKE#: Nothing to be done for 'all'.");
 
 
-unlink('hello.f');
 # hello.f is missing.
 # This time both hello.c and hello.f are missing and both '%: %.c' and '%: %.f'
 # require an intermediate.
 # The default rule builds intemerdiate hello.c.
 # '%: %.c' rule is chosen to build hello.
+unlink('hello.f');
 run_make_test("
 all: hello$s
 %$s:$r %.c; \$(info \$<)
 %$s:$r %.f; \$(info \$<)
-.DEFAULT:; false
+.DEFAULT:; \$(info \$\@) false
 unrelated: hello.c
-", '', "false\n#MAKE#: *** [#MAKEFILE#:5: hello.c] Error 1\n", 512);
+", '', "hello.c\nfalse\n#MAKE#: *** [#MAKEFILE#:5: hello.c] Error 1\n", 512);
 
 # hello.f is missing.
 # No rule is found, because hello.c is not mentioned explicitly.
@@ -132,10 +126,10 @@ run_make_test("
 all: hello$s
 %$s:$r %.c; \$(info \$<)
 %$s:$r %.f; \$(info \$<)
-.DEFAULT:; \@echo default making \$\@ && false
+.DEFAULT:; \@\$(info \$\@) false
 ",
 '',
-"default making hello$s\n#MAKE#: *** [#MAKEFILE#:5: hello$s] Error 1\n",
+"hello$s\n#MAKE#: *** [#MAKEFILE#:5: hello$s] Error 1\n",
 512);
 
 }