Module Name: src Committed By: sjg Date: Thu Sep 29 23:38:04 UTC 2011
Modified Files: src/usr.bin/make: suff.c src/usr.bin/make/unit-tests: Makefile test.exp Added Files: src/usr.bin/make/unit-tests: phony-end Log Message: 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 To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 src/usr.bin/make/suff.c cvs rdiff -u -r1.32 -r1.33 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/phony-end cvs rdiff -u -r1.38 -r1.39 src/usr.bin/make/unit-tests/test.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/suff.c diff -u src/usr.bin/make/suff.c:1.68 src/usr.bin/make/suff.c:1.69 --- src/usr.bin/make/suff.c:1.68 Thu Jun 30 20:09:42 2011 +++ src/usr.bin/make/suff.c Thu Sep 29 23:38:04 2011 @@ -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 @@ Suff_FindDeps(GNode *gn) 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); } Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.32 src/usr.bin/make/unit-tests/Makefile:1.33 --- src/usr.bin/make/unit-tests/Makefile:1.32 Thu Apr 7 01:40:02 2011 +++ src/usr.bin/make/unit-tests/Makefile Thu Sep 29 23:38:04 2011 @@ -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 @@ SUBFILES= \ modorder \ modts \ modword \ + phony-end \ posix \ qequals \ sysv \ Index: src/usr.bin/make/unit-tests/test.exp diff -u src/usr.bin/make/unit-tests/test.exp:1.38 src/usr.bin/make/unit-tests/test.exp:1.39 --- src/usr.bin/make/unit-tests/test.exp:1.38 Fri Jun 3 21:10:42 2011 +++ src/usr.bin/make/unit-tests/test.exp Thu Sep 29 23:38:04 2011 @@ -292,6 +292,11 @@ LIST:tw:C/ /,/g="one two three four five 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, Added files: Index: src/usr.bin/make/unit-tests/phony-end diff -u /dev/null src/usr.bin/make/unit-tests/phony-end:1.1 --- /dev/null Thu Sep 29 23:38:05 2011 +++ src/usr.bin/make/unit-tests/phony-end Thu Sep 29 23:38:04 2011 @@ -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