Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make Make sure .PHONY targets get .TARGET set.



details:   https://anonhg.NetBSD.org/src/rev/0de79e54d6d5
branches:  trunk
changeset: 770003:0de79e54d6d5
user:      sjg <sjg%NetBSD.org@localhost>
date:      Thu Sep 29 23:38:04 2011 +0000

description:
Make sure .PHONY targets get .TARGET set.
This wasn't happening when a dependency of .END.
Set .PREFIX too and add a unit-test.

PR: 43534

diffstat:

 usr.bin/make/suff.c               |  21 +++++++++++++++------
 usr.bin/make/unit-tests/Makefile  |   3 ++-
 usr.bin/make/unit-tests/phony-end |   9 +++++++++
 usr.bin/make/unit-tests/test.exp  |   5 +++++
 4 files changed, 31 insertions(+), 7 deletions(-)

diffs (100 lines):

diff -r c8d056bd024c -r 0de79e54d6d5 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c       Thu Sep 29 23:35:48 2011 +0000
+++ b/usr.bin/make/suff.c       Thu Sep 29 23:38:04 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: suff.c,v 1.68 2011/06/30 20:09:42 wiz Exp $    */
+/*     $NetBSD: suff.c,v 1.69 2011/09/29 23:38:04 sjg Exp $    */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: suff.c,v 1.68 2011/06/30 20:09:42 wiz Exp $";
+static char rcsid[] = "$NetBSD: suff.c,v 1.69 2011/09/29 23:38:04 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)suff.c     8.4 (Berkeley) 3/21/94";
 #else
-__RCSID("$NetBSD: suff.c,v 1.68 2011/06/30 20:09:42 wiz Exp $");
+__RCSID("$NetBSD: suff.c,v 1.69 2011/09/29 23:38:04 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2406,16 +2406,25 @@
 static void
 SuffFindDeps(GNode *gn, Lst slst)
 {
-    if (gn->type & (OP_DEPS_FOUND|OP_PHONY)) {
+    if (gn->type & OP_DEPS_FOUND) {
        /*
         * If dependencies already found, no need to do it again...
-        * If this is a .PHONY target, we do not apply suffix rules.
         */
        return;
     } else {
        gn->type |= OP_DEPS_FOUND;
     }
-
+    /*
+     * Make sure we have these set, may get revised below.
+     */
+    Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
+    Var_Set(PREFIX, gn->name, gn, 0);
+    if (gn->type & OP_PHONY) {
+       /*
+        * If this is a .PHONY target, we do not apply suffix rules.
+        */
+       return;
+    }
     if (DEBUG(SUFF)) {
        fprintf(debug_file, "SuffFindDeps (%s)\n", gn->name);
     }
diff -r c8d056bd024c -r 0de79e54d6d5 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Thu Sep 29 23:35:48 2011 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Thu Sep 29 23:38:04 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.32 2011/04/07 01:40:02 joerg Exp $
+# $NetBSD: Makefile,v 1.33 2011/09/29 23:38:04 sjg Exp $
 #
 # Unit tests for make(1)
 # The main targets are:
@@ -35,6 +35,7 @@
        modorder \
        modts \
        modword \
+       phony-end \
        posix \
        qequals \
        sysv \
diff -r c8d056bd024c -r 0de79e54d6d5 usr.bin/make/unit-tests/phony-end
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/phony-end Thu Sep 29 23:38:04 2011 +0000
@@ -0,0 +1,9 @@
+# $Id: phony-end,v 1.1 2011/09/29 23:38:04 sjg Exp $
+
+all ok also.ok bug phony:
+       @echo '${.TARGET .PREFIX .IMPSRC:L:@v@$v="${$v}"@}'
+
+.END:  ok also.ok bug
+
+phony bug:     .PHONY
+all: phony
diff -r c8d056bd024c -r 0de79e54d6d5 usr.bin/make/unit-tests/test.exp
--- a/usr.bin/make/unit-tests/test.exp  Thu Sep 29 23:35:48 2011 +0000
+++ b/usr.bin/make/unit-tests/test.exp  Thu Sep 29 23:38:04 2011 +0000
@@ -292,6 +292,11 @@
 LIST:tw:C/ /,/1g="one two three four five six"
 LIST:tw:tW:C/ /,/="one,two three four five six"
 LIST:tW:tw:C/ /,/="one two three four five six"
+.TARGET="phony" .PREFIX="phony" .IMPSRC=""
+.TARGET="all" .PREFIX="all" .IMPSRC=""
+.TARGET="ok" .PREFIX="ok" .IMPSRC=""
+.TARGET="also.ok" .PREFIX="also.ok" .IMPSRC=""
+.TARGET="bug" .PREFIX="bug" .IMPSRC=""
 Posix says we should execute the command as if run by system(3)
 Expect 'Hello,' and 'World!'
 Hello,



Home | Main Index | Thread Index | Old Index