tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

make: .PHONY lacks .TARGET



The makefile below:

all ok also.ok bug phony:
        @echo '${.TARGET .PREFIX .IMPSRC:L:@v@$v="${$v}"@}'

.END:   ok also.ok bug

phony bug:      .PHONY
all: phony

produces the following output:

.TARGET="phony" .PREFIX="" .IMPSRC=""
.TARGET="all" .PREFIX="all" .IMPSRC=""
.TARGET="ok" .PREFIX="ok" .IMPSRC=""
.TARGET="also.ok" .PREFIX="also.ok" .IMPSRC=""
.TARGET="" .PREFIX="" .IMPSRC=""

the only difference between the targets phony and bug is that the
later is run via .END, and never gets .TARGET set.
The patch below, seems to be an appropriate fix.

Index: suff.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/suff.c,v
retrieving revision 1.68
diff -u -p -r1.68 suff.c
--- suff.c      30 Jun 2011 20:09:42 -0000      1.68
+++ suff.c      27 Sep 2011 17:00:21 -0000
@@ -2411,6 +2411,10 @@ SuffFindDeps(GNode *gn, Lst slst)
         * If dependencies already found, no need to do it again...
         * If this is a .PHONY target, we do not apply suffix rules.
         */
+       if (gn->type & OP_PHONY) {
+           /* But we do want to make sure this is set. */
+           Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
+       }
        return;
     } else {
        gn->type |= OP_DEPS_FOUND;


Home | Main Index | Thread Index | Old Index