1988-07-22 19:01:13 +00:00
|
|
|
/*
|
|
|
|
* Check structures for make.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "h.h"
|
|
|
|
|
2019-02-18 16:39:39 +00:00
|
|
|
/*
|
|
|
|
* Recursive routine that does the actual checking.
|
|
|
|
*/
|
|
|
|
static void check(struct name *np)
|
|
|
|
{
|
|
|
|
register struct depend * dp;
|
|
|
|
register struct line * lp;
|
|
|
|
|
|
|
|
if (np->n_flag & N_MARK)
|
|
|
|
fatal("Circular dependency from %s", np->n_name);
|
|
|
|
|
|
|
|
np->n_flag |= N_MARK;
|
|
|
|
|
|
|
|
for (lp = np->n_line; lp; lp = lp->l_next)
|
|
|
|
for (dp = lp->l_dep; dp; dp = dp->d_next)
|
|
|
|
check(dp->d_name);
|
|
|
|
|
|
|
|
np->n_flag &= (uchar)~N_MARK;
|
|
|
|
}
|
|
|
|
|
1988-07-22 19:01:13 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Prints out the structures as defined in memory. Good for check
|
|
|
|
* that you make file does what you want (and for debugging make).
|
|
|
|
*/
|
2019-02-18 16:39:39 +00:00
|
|
|
void prt(void)
|
1988-07-22 19:01:13 +00:00
|
|
|
{
|
2019-02-18 16:39:39 +00:00
|
|
|
register struct name * np;
|
|
|
|
register struct depend * dp;
|
|
|
|
register struct line * lp;
|
|
|
|
register struct cmd * cp;
|
|
|
|
register struct macro * mp;
|
1988-07-22 19:01:13 +00:00
|
|
|
|
|
|
|
for (mp = macrohead; mp; mp = mp->m_next)
|
|
|
|
fprintf(stderr, "%s = %s\n", mp->m_name, mp->m_val);
|
|
|
|
|
|
|
|
fputc('\n', stderr);
|
|
|
|
|
|
|
|
for (np = namehead.n_next; np; np = np->n_next)
|
|
|
|
{
|
|
|
|
if (np->n_flag & N_DOUBLE)
|
|
|
|
fprintf(stderr, "%s::\n", np->n_name);
|
2019-02-18 16:39:39 +00:00
|
|
|
else
|
1988-07-22 19:01:13 +00:00
|
|
|
fprintf(stderr, "%s:\n", np->n_name);
|
2019-02-18 16:39:39 +00:00
|
|
|
if (np == firstname)
|
1988-07-22 19:01:13 +00:00
|
|
|
fprintf(stderr, "(MAIN NAME)\n");
|
2019-02-18 16:39:39 +00:00
|
|
|
for (lp = np->n_line; lp; lp = lp->l_next)
|
|
|
|
{
|
|
|
|
fputc(':', stderr);
|
|
|
|
for (dp = lp->l_dep; dp; dp = dp->d_next)
|
1988-07-22 19:01:13 +00:00
|
|
|
fprintf(stderr, " %s", dp->d_name->n_name);
|
2019-02-18 16:39:39 +00:00
|
|
|
fputc('\n', stderr);
|
1988-07-22 19:01:13 +00:00
|
|
|
|
2019-02-18 16:39:39 +00:00
|
|
|
for (cp = lp->l_cmd; cp; cp = cp->c_next)
|
1988-07-22 19:01:13 +00:00
|
|
|
fprintf(stderr, "-\t%s\n", cp->c_cmd);
|
2019-02-18 16:39:39 +00:00
|
|
|
fputc('\n', stderr);
|
|
|
|
}
|
1988-07-22 19:01:13 +00:00
|
|
|
fputc('\n', stderr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for circular dependancies.
|
|
|
|
* ie.
|
|
|
|
* a: b
|
|
|
|
* b: a
|
|
|
|
* is a circular dep
|
|
|
|
*/
|
2019-02-18 16:39:39 +00:00
|
|
|
void circh(void)
|
1988-07-22 19:01:13 +00:00
|
|
|
{
|
2019-02-18 16:39:39 +00:00
|
|
|
register struct name * np;
|
1988-07-22 19:01:13 +00:00
|
|
|
|
|
|
|
for (np = namehead.n_next; np; np = np->n_next)
|
|
|
|
check(np);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check the target .PRECIOUS, and mark its dependentd as precious
|
|
|
|
*/
|
2019-02-18 16:39:39 +00:00
|
|
|
void precious(void)
|
1988-07-22 19:01:13 +00:00
|
|
|
{
|
2019-02-18 16:39:39 +00:00
|
|
|
register struct depend * dp;
|
|
|
|
register struct line * lp;
|
|
|
|
register struct name * np;
|
1988-07-22 19:01:13 +00:00
|
|
|
|
|
|
|
if (!((np = newname(".PRECIOUS"))->n_flag & N_TARG))
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (lp = np->n_line; lp; lp = lp->l_next)
|
|
|
|
for (dp = lp->l_dep; dp; dp = dp->d_next)
|
|
|
|
dp->d_name->n_flag |= N_PREC;
|
|
|
|
}
|