diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2001-11-22 21:18:11 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2001-11-22 21:18:11 +0000 |
commit | ec71a36688c1b5a0cfcfadc90f254d807c300a1e (patch) | |
tree | b5dab43999163bfa959fc6af923f12cf079b44f8 | |
parent | b758900e6e062ebe70d5e28898dcf4dfbf40e768 (diff) |
Explicitly mark nodes whose commands have been filled with
implicit (suffix) rules. Then, only expand the IMPSRC/< variable
if the node has been marked.
This matches what Single Unix 2 and common sense say: implicit rules
shouldn't count when an explicit rule has been found (an explicit rule
being a full-scale dependency, with some associated commands)
Note that Single Unix leaves the `PREFIX' question open, so we leave
the PREFIX code as it is.
This fixes regression case mk14, which now fails as it should.
This is just a bug-fix. Some more correct (and faster) code should
probably be substituted. Namely, right now, the suffix code is too
greedy, whereas it should test for explicit rules earlier, and not
even bother instantiating implicit rules from templates when they
duplicate actual existing rules.
ok millert@
-rw-r--r-- | usr.bin/make/compat.c | 14 | ||||
-rw-r--r-- | usr.bin/make/gnode.h | 3 | ||||
-rw-r--r-- | usr.bin/make/make.c | 5 | ||||
-rw-r--r-- | usr.bin/make/suff.c | 4 |
4 files changed, 15 insertions, 11 deletions
diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c index 7f32886d369..1987d62b128 100644 --- a/usr.bin/make/compat.c +++ b/usr.bin/make/compat.c @@ -1,5 +1,5 @@ /* $OpenPackages$ */ -/* $OpenBSD: compat.c,v 1.41 2001/11/17 19:37:53 deraadt Exp $ */ +/* $OpenBSD: compat.c,v 1.42 2001/11/22 21:18:10 espie Exp $ */ /* $NetBSD: compat.c,v 1.14 1996/11/06 17:59:01 christos Exp $ */ /* @@ -420,9 +420,9 @@ CompatMake(gnp, pgnp) return; } - if (Lst_Member(&gn->iParents, pgn) != NULL) { - Varq_Set(IMPSRC_INDEX, Varq_Value(TARGET_INDEX, gn), pgn); - } + if (Lst_Member(&gn->iParents, pgn) != NULL && + (pgn->type & OP_IS_SUFFIX)) + Varq_Set(IMPSRC_INDEX, Varq_Value(TARGET_INDEX, gn), pgn); /* All the children were made ok. Now cmtime contains the modification * time of the newest child, we need to find out if we exist and when @@ -547,9 +547,9 @@ CompatMake(gnp, pgnp) * to abort. */ pgn->make = false; else { - if (Lst_Member(&gn->iParents, pgn) != NULL) { - Varq_Set(IMPSRC_INDEX, Varq_Value(TARGET_INDEX, gn), pgn); - } + if (Lst_Member(&gn->iParents, pgn) != NULL && + (pgn->type & OP_IS_SUFFIX)) + Varq_Set(IMPSRC_INDEX, Varq_Value(TARGET_INDEX, gn), pgn); switch (gn->made) { case BEINGMADE: Error("Graph cycles through %s\n", gn->name); diff --git a/usr.bin/make/gnode.h b/usr.bin/make/gnode.h index 17d94d72be2..4087a885991 100644 --- a/usr.bin/make/gnode.h +++ b/usr.bin/make/gnode.h @@ -1,7 +1,7 @@ #ifndef GNODE_H #define GNODE_H /* $OpenPackages$ */ -/* $OpenBSD: gnode.h,v 1.2 2001/09/19 10:58:07 mpech Exp $ */ +/* $OpenBSD: gnode.h,v 1.3 2001/11/22 21:18:10 espie Exp $ */ /* * Copyright (c) 2001 Marc Espie. @@ -176,6 +176,7 @@ struct GNode_ { * commands for a target */ #define OP_SAVE_CMDS 0x04000000 /* Saving commands on .END (Compat) */ #define OP_DEPS_FOUND 0x02000000 /* Already processed by Suff_FindDeps */ +#define OP_IS_SUFFIX 0x01000000 /* Cmds filled by suffix rule */ /* * OP_NOP will return true if the node with the given type was not the diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c index 685669dd147..a0f0a1d4e20 100644 --- a/usr.bin/make/make.c +++ b/usr.bin/make/make.c @@ -1,5 +1,5 @@ /* $OpenPackages$ */ -/* $OpenBSD: make.c,v 1.30 2001/11/11 12:35:02 espie Exp $ */ +/* $OpenBSD: make.c,v 1.31 2001/11/22 21:18:10 espie Exp $ */ /* $NetBSD: make.c,v 1.10 1996/11/06 17:59:15 christos Exp $ */ /* @@ -512,7 +512,8 @@ Make_Update(cgn) for (ln = Lst_First(&cgn->iParents); ln != NULL; ln = Lst_Adv(ln)) { pgn = (GNode *)Lst_Datum(ln); if (pgn->make) { - Varq_Set(IMPSRC_INDEX, cname, pgn); + if (pgn->type & OP_IS_SUFFIX) + Varq_Set(IMPSRC_INDEX, cname, pgn); Varq_Set(PREFIX_INDEX, cpref, pgn); } } diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index e9db75dbe4e..b0ce597a434 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -1,5 +1,5 @@ /* $OpenPackages$ */ -/* $OpenBSD: suff.c,v 1.46 2001/11/11 12:35:03 espie Exp $ */ +/* $OpenBSD: suff.c,v 1.47 2001/11/22 21:18:10 espie Exp $ */ /* $NetBSD: suff.c,v 1.13 1996/11/06 17:59:25 christos Exp $ */ /* @@ -1431,6 +1431,8 @@ SuffApplyTransform(tGn, sGn, t, s) /* Record last child for expansion purposes. */ ln = Lst_Last(&tGn->children); + if (Lst_IsEmpty(&tGn->commands)) + tGn->type |= OP_IS_SUFFIX; /* Pass the buck to Make_HandleUse to apply the rule. */ Make_HandleUse(gn, tGn); |