1 | /*************************************************************************
|
---|
2 | *
|
---|
3 | * m a k e : c h e c k . c
|
---|
4 | *
|
---|
5 | * debugging stuff: Check structures for make.
|
---|
6 | *========================================================================
|
---|
7 | * Edition history
|
---|
8 | *
|
---|
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
|
---|
16 | *
|
---|
17 | *************************************************************************/
|
---|
18 |
|
---|
19 | #include "h.h"
|
---|
20 |
|
---|
21 |
|
---|
22 | /*
|
---|
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).
|
---|
25 | */
|
---|
26 | void prt()
|
---|
27 | {
|
---|
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;
|
---|
33 |
|
---|
34 | register int i;
|
---|
35 |
|
---|
36 | for (mp = macrohead; mp; mp = mp->m_next)
|
---|
37 | printf("%s = %s\n", mp->m_name, mp->m_val);
|
---|
38 |
|
---|
39 | putchar('\n');
|
---|
40 |
|
---|
41 | for (i = 0; i <= maxsuffarray ; i++)
|
---|
42 | for (np = suffparray[i]->n_next; np; np = np->n_next)
|
---|
43 | {
|
---|
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)
|
---|
51 | {
|
---|
52 | putchar(':');
|
---|
53 | for (dp = lp->l_dep; dp; dp = dp->d_next)
|
---|
54 | printf(" %s", dp->d_name->n_name);
|
---|
55 | putchar('\n');
|
---|
56 |
|
---|
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');
|
---|
64 | }
|
---|
65 | putchar('\n');
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 |
|
---|
70 | /*
|
---|
71 | * Recursive routine that does the actual checking.
|
---|
72 | */
|
---|
73 | void check(np)
|
---|
74 | struct name *np;
|
---|
75 | {
|
---|
76 | register struct depend *dp;
|
---|
77 | register struct line *lp;
|
---|
78 |
|
---|
79 |
|
---|
80 | if (np->n_flag & N_MARK)
|
---|
81 | fatal("Circular dependency from %s", np->n_name,0);
|
---|
82 |
|
---|
83 | np->n_flag |= N_MARK;
|
---|
84 |
|
---|
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);
|
---|
88 |
|
---|
89 | np->n_flag &= ~N_MARK;
|
---|
90 | }
|
---|
91 |
|
---|
92 |
|
---|
93 | /*
|
---|
94 | * Look for circular dependancies.
|
---|
95 | * ie.
|
---|
96 | * a: b
|
---|
97 | * b: a
|
---|
98 | * is a circular dep
|
---|
99 | */
|
---|
100 | void circh()
|
---|
101 | {
|
---|
102 | register struct name *np;
|
---|
103 | register int i;
|
---|
104 |
|
---|
105 |
|
---|
106 | for (i = 0; i <= maxsuffarray ; i++)
|
---|
107 | for (np = suffparray[i]->n_next; np; np = np->n_next)
|
---|
108 | check(np);
|
---|
109 | }
|
---|
110 |
|
---|
111 |
|
---|
112 | /*
|
---|
113 | * Check the target .PRECIOUS, and mark its dependentd as precious
|
---|
114 | */
|
---|
115 | void precious()
|
---|
116 | {
|
---|
117 | register struct depend *dp;
|
---|
118 | register struct line *lp;
|
---|
119 | register struct name *np;
|
---|
120 |
|
---|
121 |
|
---|
122 | if (!((np = newname(".PRECIOUS"))->n_flag & N_TARG))
|
---|
123 | return;
|
---|
124 |
|
---|
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;
|
---|
128 | }
|
---|