version 1.17, 1999/12/18 02:11:27 |
version 1.18, 1999/12/18 21:53:33 |
|
|
* |
* |
* Suff_FindDeps Find implicit sources for and the location of |
* Suff_FindDeps Find implicit sources for and the location of |
* a target based on its suffix. Returns the |
* a target based on its suffix. Returns the |
* bottom-most node added to the graph or NILGNODE |
* bottom-most node added to the graph or NULL |
* if the target had no implicit sources. |
* if the target had no implicit sources. |
*/ |
*/ |
|
|
|
|
Lst l = (Lst) lp; |
Lst l = (Lst) lp; |
|
|
LstNode ln = Lst_Member(l, sp); |
LstNode ln = Lst_Member(l, sp); |
if (ln != NILLNODE) { |
if (ln != NULL) { |
Lst_Remove(l, ln); |
Lst_Remove(l, ln); |
((Suff *) sp)->refCount--; |
((Suff *) sp)->refCount--; |
} |
} |
|
|
if (Lst_Open (l) == FAILURE) { |
if (Lst_Open (l) == FAILURE) { |
return; |
return; |
} |
} |
while ((ln = Lst_Next (l)) != NILLNODE) { |
while ((ln = Lst_Next (l)) != NULL) { |
s2 = (Suff *) Lst_Datum (ln); |
s2 = (Suff *) Lst_Datum (ln); |
if (s2->sNum >= s->sNum) { |
if (s2->sNum >= s->sNum) { |
break; |
break; |
|
|
if (DEBUG(SUFF)) { |
if (DEBUG(SUFF)) { |
printf("inserting %s(%d)...", s->name, s->sNum); |
printf("inserting %s(%d)...", s->name, s->sNum); |
} |
} |
if (ln == NILLNODE) { |
if (ln == NULL) { |
if (DEBUG(SUFF)) { |
if (DEBUG(SUFF)) { |
printf("at end of list\n"); |
printf("at end of list\n"); |
} |
} |
|
|
Suff *single = NULL;/* Source of possible transformation to |
Suff *single = NULL;/* Source of possible transformation to |
* null suffix */ |
* null suffix */ |
|
|
srcLn = NILLNODE; |
srcLn = NULL; |
singleLn = NILLNODE; |
singleLn = NULL; |
|
|
/* |
/* |
* Loop looking first for a suffix that matches the start of the |
* Loop looking first for a suffix that matches the start of the |
|
|
* parsed the string. |
* parsed the string. |
*/ |
*/ |
for (;;) { |
for (;;) { |
if (srcLn == NILLNODE) { |
if (srcLn == NULL) { |
srcLn = Lst_Find(sufflist, (ClientData)str, SuffSuffIsPrefix); |
srcLn = Lst_Find(sufflist, (ClientData)str, SuffSuffIsPrefix); |
} else { |
} else { |
srcLn = Lst_FindFrom (sufflist, Lst_Succ(srcLn), (ClientData)str, |
srcLn = Lst_FindFrom (sufflist, Lst_Succ(srcLn), (ClientData)str, |
SuffSuffIsPrefix); |
SuffSuffIsPrefix); |
} |
} |
if (srcLn == NILLNODE) { |
if (srcLn == NULL) { |
/* |
/* |
* Ran out of source suffixes -- no such rule |
* Ran out of source suffixes -- no such rule |
*/ |
*/ |
if (singleLn != NILLNODE) { |
if (singleLn != NULL) { |
/* |
/* |
* Not so fast Mr. Smith! There was a suffix that encompassed |
* Not so fast Mr. Smith! There was a suffix that encompassed |
* the entire string, so we assume it was a transformation |
* the entire string, so we assume it was a transformation |
|
|
singleLn = srcLn; |
singleLn = srcLn; |
} else { |
} else { |
targLn = Lst_Find(sufflist, (ClientData)str2, SuffSuffHasNameP); |
targLn = Lst_Find(sufflist, (ClientData)str2, SuffSuffHasNameP); |
if (targLn != NILLNODE) { |
if (targLn != NULL) { |
*srcPtr = src; |
*srcPtr = src; |
*targPtr = (Suff *)Lst_Datum(targLn); |
*targPtr = (Suff *)Lst_Datum(targLn); |
return (TRUE); |
return (TRUE); |
|
|
LstNode ln; /* Node for existing transformation */ |
LstNode ln; /* Node for existing transformation */ |
|
|
ln = Lst_Find (transforms, (ClientData)line, SuffGNHasNameP); |
ln = Lst_Find (transforms, (ClientData)line, SuffGNHasNameP); |
if (ln == NILLNODE) { |
if (ln == NULL) { |
/* |
/* |
* Make a new graph node for the transformation. It will be filled in |
* Make a new graph node for the transformation. It will be filled in |
* by the Parse module. |
* by the Parse module. |
|
|
|
|
/* |
/* |
* Remove the source from the target's children list. We check for a |
* Remove the source from the target's children list. We check for a |
* nil return to handle a beanhead saying something like |
* null return to handle a beanhead saying something like |
* .c.o .c.o: |
* .c.o .c.o: |
* |
* |
* We'll be called twice when the next target is seen, but .c and .o |
* We'll be called twice when the next target is seen, but .c and .o |
|
|
cp = SuffStrIsPrefix(s->name, transform->name); |
cp = SuffStrIsPrefix(s->name, transform->name); |
if (cp != (char *)NULL) { |
if (cp != (char *)NULL) { |
ln = Lst_Find(sufflist, (ClientData)cp, SuffSuffHasNameP); |
ln = Lst_Find(sufflist, (ClientData)cp, SuffSuffHasNameP); |
if (ln != NILLNODE) { |
if (ln != NULL) { |
/* |
/* |
* Found target. Link in and return, since it can't be anything |
* Found target. Link in and return, since it can't be anything |
* else. |
* else. |
|
|
* Replace the start of the target suffix |
* Replace the start of the target suffix |
*/ |
*/ |
cp[1] = s->name[0]; |
cp[1] = s->name[0]; |
if (ln != NILLNODE) { |
if (ln != NULL) { |
/* |
/* |
* Found it -- establish the proper relationship |
* Found it -- establish the proper relationship |
*/ |
*/ |
|
|
LstNode ln; |
LstNode ln; |
|
|
ln = Lst_Find (sufflist, (ClientData)str, SuffSuffHasNameP); |
ln = Lst_Find (sufflist, (ClientData)str, SuffSuffHasNameP); |
if (ln == NILLNODE) { |
if (ln == NULL) { |
s = (Suff *) emalloc (sizeof (Suff)); |
s = (Suff *) emalloc (sizeof (Suff)); |
|
|
s->name = estrdup (str); |
s->name = estrdup (str); |
|
|
* Return the search path for the given suffix, if it's defined. |
* Return the search path for the given suffix, if it's defined. |
* |
* |
* Results: |
* Results: |
* The searchPath for the desired suffix or NILLST if the suffix isn't |
* The searchPath for the desired suffix or NULL if the suffix isn't |
* defined. |
* defined. |
* |
* |
* Side Effects: |
* Side Effects: |
|
|
Suff *s; |
Suff *s; |
|
|
ln = Lst_Find (sufflist, (ClientData)sname, SuffSuffHasNameP); |
ln = Lst_Find (sufflist, (ClientData)sname, SuffSuffHasNameP); |
if (ln == NILLNODE) { |
if (ln == NULL) { |
return (NILLST); |
return (NULL); |
} else { |
} else { |
s = (Suff *) Lst_Datum (ln); |
s = (Suff *) Lst_Datum (ln); |
return (s->searchPath); |
return (s->searchPath); |
|
|
inIncludes = Lst_Init(); |
inIncludes = Lst_Init(); |
inLibs = Lst_Init(); |
inLibs = Lst_Init(); |
|
|
while ((ln = Lst_Next (sufflist)) != NILLNODE) { |
while ((ln = Lst_Next (sufflist)) != NULL) { |
s = (Suff *) Lst_Datum (ln); |
s = (Suff *) Lst_Datum (ln); |
if (!Lst_IsEmpty (s->searchPath)) { |
if (!Lst_IsEmpty (s->searchPath)) { |
#ifdef INCLUDES |
#ifdef INCLUDES |
|
|
Suff *s; |
Suff *s; |
|
|
ln = Lst_Find (sufflist, (ClientData)sname, SuffSuffHasNameP); |
ln = Lst_Find (sufflist, (ClientData)sname, SuffSuffHasNameP); |
if (ln != NILLNODE) { |
if (ln != NULL) { |
s = (Suff *) Lst_Datum (ln); |
s = (Suff *) Lst_Datum (ln); |
s->flags |= SUFF_INCLUDE; |
s->flags |= SUFF_INCLUDE; |
} |
} |
|
|
Suff *s; |
Suff *s; |
|
|
ln = Lst_Find (sufflist, (ClientData)sname, SuffSuffHasNameP); |
ln = Lst_Find (sufflist, (ClientData)sname, SuffSuffHasNameP); |
if (ln != NILLNODE) { |
if (ln != NULL) { |
s = (Suff *) Lst_Datum (ln); |
s = (Suff *) Lst_Datum (ln); |
s->flags |= SUFF_LIBRARY; |
s->flags |= SUFF_LIBRARY; |
} |
} |
|
|
s2->file = estrdup(targ->pref); |
s2->file = estrdup(targ->pref); |
s2->pref = targ->pref; |
s2->pref = targ->pref; |
s2->parent = targ; |
s2->parent = targ; |
s2->node = NILGNODE; |
s2->node = NULL; |
s2->suff = s; |
s2->suff = s; |
s->refCount++; |
s->refCount++; |
s2->children = 0; |
s2->children = 0; |
|
|
s2->file = str_concat (targ->pref, s->name, 0); |
s2->file = str_concat (targ->pref, s->name, 0); |
s2->pref = targ->pref; |
s2->pref = targ->pref; |
s2->parent = targ; |
s2->parent = targ; |
s2->node = NILGNODE; |
s2->node = NULL; |
s2->suff = s; |
s2->suff = s; |
s->refCount++; |
s->refCount++; |
s2->children = 0; |
s2->children = 0; |
|
|
#endif |
#endif |
|
|
|
|
while ((ln = Lst_Next (l)) != NILLNODE) { |
while ((ln = Lst_Next (l)) != NULL) { |
s = (Src *) Lst_Datum (ln); |
s = (Src *) Lst_Datum (ln); |
if (s->children == 0) { |
if (s->children == 0) { |
free ((Address)s->file); |
free ((Address)s->file); |
|
|
else { |
else { |
#ifdef DEBUG_SRC |
#ifdef DEBUG_SRC |
LstNode ln = Lst_Member(s->parent->cp, (ClientData)s); |
LstNode ln = Lst_Member(s->parent->cp, (ClientData)s); |
if (ln != NILLNODE) |
if (ln != NULL) |
Lst_Remove(s->parent->cp, ln); |
Lst_Remove(s->parent->cp, ln); |
#endif |
#endif |
--s->parent->children; |
--s->parent->children; |
|
|
* A file is considered to exist if either a node exists in the |
* A file is considered to exist if either a node exists in the |
* graph for it or the file actually exists. |
* graph for it or the file actually exists. |
*/ |
*/ |
if (Targ_FindNode(s->file, TARG_NOCREATE) != NILGNODE) { |
if (Targ_FindNode(s->file, TARG_NOCREATE) != NULL) { |
#ifdef DEBUG_SRC |
#ifdef DEBUG_SRC |
printf("remove %x from %x\n", s, srcs); |
printf("remove %x from %x\n", s, srcs); |
#endif |
#endif |
|
|
* a Src structure is put together for it and returned. |
* a Src structure is put together for it and returned. |
* |
* |
* Results: |
* Results: |
* The Src structure of the "winning" child, or NIL if no such beast. |
* The Src structure of the "winning" child, or NULL if no such beast. |
* |
* |
* Side Effects: |
* Side Effects: |
* A Src structure may be allocated. |
* A Src structure may be allocated. |
|
|
(void) Lst_Open (t->children); |
(void) Lst_Open (t->children); |
prefLen = strlen (targ->pref); |
prefLen = strlen (targ->pref); |
|
|
while ((ln = Lst_Next (t->children)) != NILLNODE) { |
while ((ln = Lst_Next (t->children)) != NULL) { |
s = (GNode *)Lst_Datum (ln); |
s = (GNode *)Lst_Datum (ln); |
|
|
cp = strrchr (s->name, '/'); |
cp = strrchr (s->name, '/'); |
|
|
*/ |
*/ |
ln = Lst_Find (sufflist, (ClientData)&cp[prefLen], |
ln = Lst_Find (sufflist, (ClientData)&cp[prefLen], |
SuffSuffHasNameP); |
SuffSuffHasNameP); |
if (ln != NILLNODE) { |
if (ln != NULL) { |
/* |
/* |
* It even has a known suffix, see if there's a transformation |
* It even has a known suffix, see if there's a transformation |
* defined between the node's suffix and the target's suffix. |
* defined between the node's suffix and the target's suffix. |
|
|
suff = (Suff *)Lst_Datum (ln); |
suff = (Suff *)Lst_Datum (ln); |
|
|
if (Lst_Member (suff->parents, |
if (Lst_Member (suff->parents, |
(ClientData)targ->suff) != NILLNODE) |
(ClientData)targ->suff) != NULL) |
{ |
{ |
/* |
/* |
* Hot Damn! Create a new Src structure to describe |
* Hot Damn! Create a new Src structure to describe |
|
|
if (DEBUG(SUFF)) { |
if (DEBUG(SUFF)) { |
printf("%s...", gn->name); |
printf("%s...", gn->name); |
} |
} |
if (Lst_Member(pgn->children, (ClientData)gn) == NILLNODE) { |
if (Lst_Member(pgn->children, (ClientData)gn) == NULL) { |
(void)Lst_Append(pgn->children, prevLN, (ClientData)gn); |
(void)Lst_Append(pgn->children, prevLN, (ClientData)gn); |
prevLN = Lst_Succ(prevLN); |
prevLN = Lst_Succ(prevLN); |
(void)Lst_AtEnd(gn->parents, (ClientData)pgn); |
(void)Lst_AtEnd(gn->parents, (ClientData)pgn); |
|
|
printf("Wildcard expanding \"%s\"...", cgn->name); |
printf("Wildcard expanding \"%s\"...", cgn->name); |
} |
} |
|
|
if (ln != NILLNODE) { |
if (ln != NULL) { |
Suff *s = (Suff *)Lst_Datum(ln); |
Suff *s = (Suff *)Lst_Datum(ln); |
|
|
if (DEBUG(SUFF)) { |
if (DEBUG(SUFF)) { |
|
|
* If gn isn't already a child of the parent, make it so and |
* If gn isn't already a child of the parent, make it so and |
* up the parent's count of unmade children. |
* up the parent's count of unmade children. |
*/ |
*/ |
if (Lst_Member(pgn->children, (ClientData)gn) == NILLNODE) { |
if (Lst_Member(pgn->children, (ClientData)gn) == NULL) { |
(void)Lst_Append(pgn->children, prevLN, (ClientData)gn); |
(void)Lst_Append(pgn->children, prevLN, (ClientData)gn); |
prevLN = Lst_Succ(prevLN); |
prevLN = Lst_Succ(prevLN); |
(void)Lst_AtEnd(gn->parents, (ClientData)pgn); |
(void)Lst_AtEnd(gn->parents, (ClientData)pgn); |
|
|
char *tname; /* Name of transformation rule */ |
char *tname; /* Name of transformation rule */ |
GNode *gn; /* Node for same */ |
GNode *gn; /* Node for same */ |
|
|
if (Lst_Member(tGn->children, (ClientData)sGn) == NILLNODE) { |
if (Lst_Member(tGn->children, (ClientData)sGn) == NULL) { |
/* |
/* |
* Not already linked, so form the proper links between the |
* Not already linked, so form the proper links between the |
* target and source. |
* target and source. |
|
|
* sGn gets the target in its iParents list, however, as that |
* sGn gets the target in its iParents list, however, as that |
* will be sufficient to get the .IMPSRC variable set for tGn |
* will be sufficient to get the .IMPSRC variable set for tGn |
*/ |
*/ |
for (ln=Lst_First(sGn->cohorts); ln != NILLNODE; ln=Lst_Succ(ln)) { |
for (ln=Lst_First(sGn->cohorts); ln != NULL; ln=Lst_Succ(ln)) { |
gn = (GNode *)Lst_Datum(ln); |
gn = (GNode *)Lst_Datum(ln); |
|
|
if (Lst_Member(tGn->children, (ClientData)gn) == NILLNODE) { |
if (Lst_Member(tGn->children, (ClientData)gn) == NULL) { |
/* |
/* |
* Not already linked, so form the proper links between the |
* Not already linked, so form the proper links between the |
* target and source. |
* target and source. |
|
|
ln = Lst_Find(transforms, (ClientData)tname, SuffGNHasNameP); |
ln = Lst_Find(transforms, (ClientData)tname, SuffGNHasNameP); |
free(tname); |
free(tname); |
|
|
if (ln == NILLNODE) { |
if (ln == NULL) { |
/* |
/* |
* Not really such a transformation rule (can happen when we're |
* Not really such a transformation rule (can happen when we're |
* called to link an OP_MEMBER and OP_ARCHV node), so return |
* called to link an OP_MEMBER and OP_ARCHV node), so return |
|
|
* Deal with wildcards and variables in any acquired sources |
* Deal with wildcards and variables in any acquired sources |
*/ |
*/ |
ln = Lst_Succ(ln); |
ln = Lst_Succ(ln); |
if (ln != NILLNODE) { |
if (ln != NULL) { |
Lst_ForEachFrom(tGn->children, ln, |
Lst_ForEachFrom(tGn->children, ln, |
SuffExpandChildren, (ClientData)tGn); |
SuffExpandChildren, (ClientData)tGn); |
} |
} |
|
|
/* |
/* |
* Create the link between the two nodes right off |
* Create the link between the two nodes right off |
*/ |
*/ |
if (Lst_Member(gn->children, (ClientData)mem) == NILLNODE) { |
if (Lst_Member(gn->children, (ClientData)mem) == NULL) { |
(void)Lst_AtEnd(gn->children, (ClientData)mem); |
(void)Lst_AtEnd(gn->children, (ClientData)mem); |
(void)Lst_AtEnd(mem->parents, (ClientData)gn); |
(void)Lst_AtEnd(mem->parents, (ClientData)gn); |
gn->unmade += 1; |
gn->unmade += 1; |
|
|
*/ |
*/ |
ln = Lst_Find(ms->parents, eoarch, SuffSuffIsSuffixP); |
ln = Lst_Find(ms->parents, eoarch, SuffSuffIsSuffixP); |
|
|
if (ln != NILLNODE) { |
if (ln != NULL) { |
/* |
/* |
* Got one -- apply it |
* Got one -- apply it |
*/ |
*/ |
|
|
* Should we find one, we discard the one we found before. |
* Should we find one, we discard the one we found before. |
*/ |
*/ |
|
|
while (ln != NILLNODE) { |
while (ln != NULL) { |
/* |
/* |
* Look for next possible suffix... |
* Look for next possible suffix... |
*/ |
*/ |
ln = Lst_FindFrom(sufflist, ln, eoname, SuffSuffIsSuffixP); |
ln = Lst_FindFrom(sufflist, ln, eoname, SuffSuffIsSuffixP); |
|
|
if (ln != NILLNODE) { |
if (ln != NULL) { |
int prefLen; /* Length of the prefix */ |
int prefLen; /* Length of the prefix */ |
Src *targ; |
Src *targ; |
|
|
|
|
* up to, but not including, the parent node. |
* up to, but not including, the parent node. |
*/ |
*/ |
while (bottom && bottom->parent != NULL) { |
while (bottom && bottom->parent != NULL) { |
if (Lst_Member(slst, (ClientData) bottom) == NILLNODE) { |
if (Lst_Member(slst, (ClientData) bottom) == NULL) { |
Lst_AtEnd(slst, (ClientData) bottom); |
Lst_AtEnd(slst, (ClientData) bottom); |
} |
} |
bottom = bottom->parent; |
bottom = bottom->parent; |
|
|
* transformation rule. Also, the unmade field of gn is incremented. |
* transformation rule. Also, the unmade field of gn is incremented. |
* Etc. |
* Etc. |
*/ |
*/ |
if (bottom->node == NILGNODE) { |
if (bottom->node == NULL) { |
bottom->node = Targ_FindNode(bottom->file, TARG_CREATE); |
bottom->node = Targ_FindNode(bottom->file, TARG_CREATE); |
} |
} |
|
|
|
|
src->node->suffix = src->suff; |
src->node->suffix = src->suff; |
src->node->suffix->refCount++; |
src->node->suffix->refCount++; |
|
|
if (targ->node == NILGNODE) { |
if (targ->node == NULL) { |
targ->node = Targ_FindNode(targ->file, TARG_CREATE); |
targ->node = Targ_FindNode(targ->file, TARG_CREATE); |
} |
} |
|
|
|
|
*/ |
*/ |
sfnd_return: |
sfnd_return: |
if (bottom) |
if (bottom) |
if (Lst_Member(slst, (ClientData) bottom) == NILLNODE) |
if (Lst_Member(slst, (ClientData) bottom) == NULL) |
Lst_AtEnd(slst, (ClientData) bottom); |
Lst_AtEnd(slst, (ClientData) bottom); |
|
|
while (SuffRemoveSrc(srcs) || SuffRemoveSrc(targs)) |
while (SuffRemoveSrc(srcs) || SuffRemoveSrc(targs)) |
|
|
ln = Lst_Find (sufflist, (ClientData)LIBSUFF, SuffSuffHasNameP); |
ln = Lst_Find (sufflist, (ClientData)LIBSUFF, SuffSuffHasNameP); |
if (gn->suffix) |
if (gn->suffix) |
gn->suffix->refCount--; |
gn->suffix->refCount--; |
if (ln != NILLNODE) { |
if (ln != NULL) { |
gn->suffix = s = (Suff *) Lst_Datum (ln); |
gn->suffix = s = (Suff *) Lst_Datum (ln); |
gn->suffix->refCount++; |
gn->suffix->refCount++; |
Arch_FindLib (gn, s->searchPath); |
Arch_FindLib (gn, s->searchPath); |
|
|
LstNode ln; |
LstNode ln; |
|
|
ln = Lst_Find(sufflist, (ClientData)name, SuffSuffHasNameP); |
ln = Lst_Find(sufflist, (ClientData)name, SuffSuffHasNameP); |
if (ln != NILLNODE) { |
if (ln != NULL) { |
s = (Suff *)Lst_Datum(ln); |
s = (Suff *)Lst_Datum(ln); |
if (suffNull != (Suff *)NULL) { |
if (suffNull != (Suff *)NULL) { |
suffNull->flags &= ~SUFF_NULL; |
suffNull->flags &= ~SUFF_NULL; |