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;
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);
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;
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;