Fixes for /usr/xbin binaries bootstrap dir.
[minix3.git] / commands / make / check.c
blob1ac62c99016d3dc0bb23c9d2e3301f3c8c13f726
1 /*************************************************************************
3 * m a k e : c h e c k . c
5 * debugging stuff: Check structures for make.
6 *========================================================================
7 * Edition history
9 * # Date Comments By
10 * --- -------- ---------------------------------------------------- ---
11 * 1 ?? ??
12 * 2 23.08.89 adapted to new name tree structure RAL
13 * 3 30.08.89 indention changed PSH,RAL
14 * 4 06.09.89 prt output redirected to stdout RAL
15 * ------------ Version 2.0 released ------------------------------- RAL
17 *************************************************************************/
19 #include "h.h"
23 * Prints out the structures as defined in memory. Good for check
24 * that you make file does what you want (and for debugging make).
26 void prt()
28 register struct name *np;
29 register struct depend *dp;
30 register struct line *lp;
31 register struct cmd *cp;
32 register struct macro *mp;
34 register int i;
36 for (mp = macrohead; mp; mp = mp->m_next)
37 printf("%s = %s\n", mp->m_name, mp->m_val);
39 putchar('\n');
41 for (i = 0; i <= maxsuffarray ; i++)
42 for (np = suffparray[i]->n_next; np; np = np->n_next)
44 if (np->n_flag & N_DOUBLE)
45 printf("%s::\n", np->n_name);
46 else
47 printf("%s:\n", np->n_name);
48 if (np == firstname)
49 printf("(MAIN NAME)\n");
50 for (lp = np->n_line; lp; lp = lp->l_next)
52 putchar(':');
53 for (dp = lp->l_dep; dp; dp = dp->d_next)
54 printf(" %s", dp->d_name->n_name);
55 putchar('\n');
57 for (cp = lp->l_cmd; cp; cp = cp->c_next)
58 #ifdef os9
59 printf("- %s\n", cp->c_cmd);
60 #else
61 printf("-\t%s\n", cp->c_cmd);
62 #endif
63 putchar('\n');
65 putchar('\n');
71 * Recursive routine that does the actual checking.
73 void check(np)
74 struct name *np;
76 register struct depend *dp;
77 register struct line *lp;
80 if (np->n_flag & N_MARK)
81 fatal("Circular dependency from %s", np->n_name,0);
83 np->n_flag |= N_MARK;
85 for (lp = np->n_line; lp; lp = lp->l_next)
86 for (dp = lp->l_dep; dp; dp = dp->d_next)
87 check(dp->d_name);
89 np->n_flag &= ~N_MARK;
94 * Look for circular dependancies.
95 * ie.
96 * a: b
97 * b: a
98 * is a circular dep
100 void circh()
102 register struct name *np;
103 register int i;
106 for (i = 0; i <= maxsuffarray ; i++)
107 for (np = suffparray[i]->n_next; np; np = np->n_next)
108 check(np);
113 * Check the target .PRECIOUS, and mark its dependentd as precious
115 void precious()
117 register struct depend *dp;
118 register struct line *lp;
119 register struct name *np;
122 if (!((np = newname(".PRECIOUS"))->n_flag & N_TARG))
123 return;
125 for (lp = np->n_line; lp; lp = lp->l_next)
126 for (dp = lp->l_dep; dp; dp = dp->d_next)
127 dp->d_name->n_flag |= N_PREC;