]> git.ipfire.org Git - thirdparty/make.git/commitdiff
Do not force targets to be SECONDARY
authorPaul Smith <psmith@gnu.org>
Wed, 29 Dec 2021 19:44:46 +0000 (14:44 -0500)
committerPaul Smith <psmith@gnu.org>
Wed, 29 Dec 2021 20:26:56 +0000 (15:26 -0500)
In SV 43677 we forced targets to be secondary if we found an
intermediate file that was listed as a prerequisite of another
target.  This overrides .INTERMEDIATE settings, so doesn't work.
Now that we have an is_explicit flag in targets, use that instead.

* src/implicit.c (pattern_search): Remove setting of secondary.
Preserve the value of the is_explicit flag when creating a new
file target, and consider it when setting the intermediate flag.
* tests/scripts/features/patternrules: Add a test w/out INTERMEDIATE
* tests/scripts/targets/INTERMEDIATE: Add a test with INTERMEDIATE

src/implicit.c
tests/scripts/features/patternrules
tests/scripts/targets/INTERMEDIATE

index c65aec6632acd56a693bf2992d54b6885c39e5d2..fef51fe1d0bc83e7e5061cc512b6b6be5469b6ef 100644 (file)
@@ -963,13 +963,7 @@ pattern_search (struct file *file, int archive,
           struct file *imf = pat->file;
           struct file *f = lookup_file (imf->name);
 
-          /* We don't want to delete an intermediate file that happened
-             to be a prerequisite of some (other) target. Mark it as
-             secondary.  We don't want it to be precious as that disables
-             DELETE_ON_ERROR etc.  */
-          if (f != 0)
-            f->secondary = 1;
-          else
+          if (!f)
             f = enter_file (imf->name);
 
           f->deps = imf->deps;
@@ -984,8 +978,9 @@ pattern_search (struct file *file, int archive,
           f->pat_searched = imf->pat_searched;
           f->also_make = imf->also_make;
           f->is_target = 1;
+          f->is_explicit |= imf->is_explicit || pat->is_explicit;
           f->notintermediate |= imf->notintermediate;
-          f->intermediate |= !(pat->is_explicit || f->notintermediate);
+          f->intermediate |= !f->is_explicit && !f->notintermediate;
           f->tried_implicit = 1;
 
           imf = lookup_file (pat->pattern);
index 25a80e7897860c2927efb7a8f1c902915072ee73..7303df5f4c1eba74ea63494baf19214e42f38994 100644 (file)
@@ -444,5 +444,17 @@ hello.tsk:
 
 unlink('hello.tsk');
 
+# A target explicitly listed as a prerequisite of a pattern rule, is still
+# considered mentioned and "ought to exist".
+
+run_make_test(q!
+1.all: 1.q ; touch $@
+%.q: 1.r ; touch $@
+%.r: ; touch $@
+!,
+              '', "touch 1.r\ntouch 1.q\ntouch 1.all\n");
+
+unlink('1.all', '1.q', '1.r');
+
 # This tells the test driver that the perl test script executed properly.
 1;
index e25a6135ee03d614224898204de0d33464a11b6d..eef8bc90f49893063999bacf3c0e754008d55f3b 100644 (file)
@@ -120,5 +120,18 @@ all: hello.z
 
 unlink('hello.z');
 
+# A target explicitly listed as a prerequisite of a pattern rule, is still
+# considered mentioned and "ought to exist".
+
+run_make_test(q!
+1.all: 1.q ; touch $@
+%.q: 1.r ; touch $@
+%.r: ; touch $@
+.INTERMEDIATE: 1.r
+!,
+              '', "touch 1.r\ntouch 1.q\ntouch 1.all\nrm 1.r\n");
+
+unlink('1.all', '1.q', '1.r');
+
 # This tells the test driver that the perl test script executed properly.
 1;