summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-11-06 21:12:24 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-11-06 21:12:24 +0000
commit78512124372e6ad11c3956569c3ee56796c27a3d (patch)
tree224ed73edd41385107835d4c24d45a7b1e61a8db /usr.bin/make
parent12a39b4123431614d42d8ab1d3219bcac3e30245 (diff)
simplify the way we deal with implicit rules and handle $<.
Having an `iParents' field is actually backwards, it's ways simpler to store the pointer in the child, as an impliedsrc, and to set the variable just in time along with all the rest in DoAllVar. This is simpler, and it should allow us to call SuffFindDeps much later.
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/compat.c11
-rw-r--r--usr.bin/make/engine.c6
-rw-r--r--usr.bin/make/gnode.h5
-rw-r--r--usr.bin/make/make.c16
-rw-r--r--usr.bin/make/suff.c11
-rw-r--r--usr.bin/make/targ.c12
6 files changed, 19 insertions, 42 deletions
diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c
index 8da3df0c660..8d51afe9f61 100644
--- a/usr.bin/make/compat.c
+++ b/usr.bin/make/compat.c
@@ -1,5 +1,5 @@
/* $OpenPackages$ */
-/* $OpenBSD: compat.c,v 1.65 2007/11/03 14:05:39 espie Exp $ */
+/* $OpenBSD: compat.c,v 1.66 2007/11/06 21:12:23 espie Exp $ */
/* $NetBSD: compat.c,v 1.14 1996/11/06 17:59:01 christos Exp $ */
/*
@@ -99,11 +99,6 @@ CompatMake(void *gnp, /* The node to make */
return;
}
- if (Lst_Member(&gn->iParents, pgn) != NULL) {
- 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 we were modified last. The criteria
@@ -189,10 +184,6 @@ CompatMake(void *gnp, /* The node to make */
* to abort. */
pgn->make = false;
else {
- if (Lst_Member(&gn->iParents, pgn) != NULL) {
- 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/engine.c b/usr.bin/make/engine.c
index 9bc499edf1e..76ed176fd2d 100644
--- a/usr.bin/make/engine.c
+++ b/usr.bin/make/engine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: engine.c,v 1.12 2007/11/03 14:05:39 espie Exp $ */
+/* $OpenBSD: engine.c,v 1.13 2007/11/06 21:12:23 espie Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* Copyright (c) 1988, 1989 by Adam de Boor
@@ -287,6 +287,10 @@ Make_DoAllVar(GNode *gn)
{
Lst_ForEach(&gn->children, MakeAddAllSrc, gn);
+ if (gn->impliedsrc)
+ Varq_Set(IMPSRC_INDEX,
+ Varq_Value(TARGET_INDEX, gn->impliedsrc), gn);
+
if (Varq_Value(OODATE_INDEX, gn) == NULL)
Varq_Set(OODATE_INDEX, "", gn);
if (Varq_Value(ALLSRC_INDEX, gn) == NULL)
diff --git a/usr.bin/make/gnode.h b/usr.bin/make/gnode.h
index 8317182d34e..6bd1687524b 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.7 2007/11/02 17:27:24 espie Exp $ */
+/* $OpenBSD: gnode.h,v 1.8 2007/11/06 21:12:23 espie Exp $ */
/*
* Copyright (c) 2001 Marc Espie.
@@ -121,8 +121,7 @@ struct GNode_ {
TIMESTAMP cmtime; /* The modification time of its youngest
* child */
- LIST iParents; /* Links to parents for which this is an
- * implied source, if any */
+ GNode *impliedsrc;
LIST cohorts; /* Other nodes for the :: operator */
LIST parents; /* Nodes that depend on this one */
LIST children; /* Nodes on which this one depends */
diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c
index e9b5053aea8..7cb4e75ffca 100644
--- a/usr.bin/make/make.c
+++ b/usr.bin/make/make.c
@@ -1,5 +1,5 @@
/* $OpenPackages$ */
-/* $OpenBSD: make.c,v 1.46 2007/11/06 21:09:42 espie Exp $ */
+/* $OpenBSD: make.c,v 1.47 2007/11/06 21:12:23 espie Exp $ */
/* $NetBSD: make.c,v 1.10 1996/11/06 17:59:15 christos Exp $ */
/*
@@ -137,9 +137,6 @@ MakeHandleUse(void *pgn, void *cgn)
* If the child wasn't made, the cmtime field of the parent will be
* altered if the child's mtime is big enough.
*
- * Finally, if the child is the implied source for the parent, the
- * parent's IMPSRC variable is set appropriately.
- *
*-----------------------------------------------------------------------
*/
void
@@ -147,7 +144,7 @@ Make_Update(GNode *cgn) /* the child node */
{
GNode *pgn; /* the parent node */
char *cname; /* the child's name */
- LstNode ln; /* Element in parents and iParents lists */
+ LstNode ln; /* Element in parents list */
cname = Varq_Value(TARGET_INDEX, cgn);
@@ -214,15 +211,6 @@ Make_Update(GNode *cgn) /* the child node */
if (succ->make && succ->unmade == 0 && succ->made == UNMADE)
(void)Lst_QueueNew(&toBeMade, succ);
}
-
- /* Set the .IMPSRC variables for all the implied parents
- * of this node. */
- 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);
- }
-
}
static bool
diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c
index 2a3e33ecda8..f161012ec22 100644
--- a/usr.bin/make/suff.c
+++ b/usr.bin/make/suff.c
@@ -1,5 +1,5 @@
/* $OpenPackages$ */
-/* $OpenBSD: suff.c,v 1.73 2007/11/02 17:27:24 espie Exp $ */
+/* $OpenBSD: suff.c,v 1.74 2007/11/06 21:12:23 espie Exp $ */
/* $NetBSD: suff.c,v 1.13 1996/11/06 17:59:25 christos Exp $ */
/*
@@ -1280,10 +1280,9 @@ SuffApplyTransform(
if ((sGn->type & OP_OPMASK) == OP_DOUBLEDEP) {
/* When a :: node is used as the implied source of a node, we
- * have to link all its cohorts in as sources as well. Only the
- * initial sGn gets the target in its iParents list, however,
- * as that will be sufficient to get the .IMPSRC variable set
- * for tGn. */
+ * have to link all its cohorts in as sources as well. There's
+ * only one implied src, as that will be sufficient to get
+ * the .IMPSRC variable set for tGn. */
for (ln=Lst_First(&sGn->cohorts); ln != NULL; ln=Lst_Adv(ln)) {
gn = (GNode *)Lst_Datum(ln);
@@ -1326,7 +1325,7 @@ SuffApplyTransform(
/* Keep track of another parent to which this beast is transformed so
* the .IMPSRC variable can be set correctly for the parent. */
- Lst_AtEnd(&sGn->iParents, tGn);
+ tGn->impliedsrc = sGn;
return true;
}
diff --git a/usr.bin/make/targ.c b/usr.bin/make/targ.c
index 27e678bef8a..4dabe25f231 100644
--- a/usr.bin/make/targ.c
+++ b/usr.bin/make/targ.c
@@ -1,5 +1,5 @@
/* $OpenPackages$ */
-/* $OpenBSD: targ.c,v 1.49 2007/11/02 17:27:24 espie Exp $ */
+/* $OpenBSD: targ.c,v 1.50 2007/11/06 21:12:23 espie Exp $ */
/* $NetBSD: targ.c,v 1.11 1997/02/20 16:51:50 christos Exp $ */
/*
@@ -186,7 +186,6 @@ Targ_NewGNi(const char *name, const char *ename)
gn->order = 0;
ts_set_out_of_date(gn->mtime);
ts_set_out_of_date(gn->cmtime);
- Lst_Init(&gn->iParents);
Lst_Init(&gn->cohorts);
Lst_Init(&gn->parents);
Lst_Init(&gn->children);
@@ -195,6 +194,7 @@ Targ_NewGNi(const char *name, const char *ename)
SymTable_Init(&gn->context);
gn->lineno = 0;
gn->fname = NULL;
+ gn->impliedsrc = NULL;
Lst_Init(&gn->commands);
gn->suffix = NULL;
@@ -215,7 +215,6 @@ TargFreeGN(void *gnp)
GNode *gn = (GNode *)gnp;
efree(gn->path);
- Lst_Destroy(&gn->iParents, NOFREE);
Lst_Destroy(&gn->cohorts, NOFREE);
Lst_Destroy(&gn->parents, NOFREE);
Lst_Destroy(&gn->children, NOFREE);
@@ -376,17 +375,14 @@ TargPrintNode(GNode *gn, int pass)
printf("# unmade\n");
}
}
- if (!Lst_IsEmpty(&gn->iParents)) {
- printf("# implicit parents: ");
- Lst_Every(&gn->iParents, TargPrintName);
- fputc('\n', stdout);
- }
}
if (!Lst_IsEmpty(&gn->parents)) {
printf("# parents: ");
Lst_Every(&gn->parents, TargPrintName);
fputc('\n', stdout);
}
+ if (gn->impliedsrc)
+ printf("# implied source: %s\n", gn->impliedsrc->name);
printf("%-16s", gn->name);
switch (gn->type & OP_OPMASK) {