forked from Stichting-MINIX-Research-Foundation/minix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.c
More file actions
executable file
·128 lines (104 loc) · 2.89 KB
/
Copy pathcheck.c
File metadata and controls
executable file
·128 lines (104 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*************************************************************************
*
* m a k e : c h e c k . c
*
* debugging stuff: Check structures for make.
*========================================================================
* Edition history
*
* # Date Comments By
* --- -------- ---------------------------------------------------- ---
* 1 ?? ??
* 2 23.08.89 adapted to new name tree structure RAL
* 3 30.08.89 indention changed PSH,RAL
* 4 06.09.89 prt output redirected to stdout RAL
* ------------ Version 2.0 released ------------------------------- RAL
*
*************************************************************************/
#include "h.h"
/*
* Prints out the structures as defined in memory. Good for check
* that you make file does what you want (and for debugging make).
*/
void prt()
{
register struct name *np;
register struct depend *dp;
register struct line *lp;
register struct cmd *cp;
register struct macro *mp;
register int i;
for (mp = macrohead; mp; mp = mp->m_next)
printf("%s = %s\n", mp->m_name, mp->m_val);
putchar('\n');
for (i = 0; i <= maxsuffarray ; i++)
for (np = suffparray[i]->n_next; np; np = np->n_next)
{
if (np->n_flag & N_DOUBLE)
printf("%s::\n", np->n_name);
else
printf("%s:\n", np->n_name);
if (np == firstname)
printf("(MAIN NAME)\n");
for (lp = np->n_line; lp; lp = lp->l_next)
{
putchar(':');
for (dp = lp->l_dep; dp; dp = dp->d_next)
printf(" %s", dp->d_name->n_name);
putchar('\n');
for (cp = lp->l_cmd; cp; cp = cp->c_next)
#ifdef os9
printf("- %s\n", cp->c_cmd);
#else
printf("-\t%s\n", cp->c_cmd);
#endif
putchar('\n');
}
putchar('\n');
}
}
/*
* Recursive routine that does the actual checking.
*/
void check(np)
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,0);
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 &= ~N_MARK;
}
/*
* Look for circular dependancies.
* ie.
* a: b
* b: a
* is a circular dep
*/
void circh()
{
register struct name *np;
register int i;
for (i = 0; i <= maxsuffarray ; i++)
for (np = suffparray[i]->n_next; np; np = np->n_next)
check(np);
}
/*
* Check the target .PRECIOUS, and mark its dependentd as precious
*/
void precious()
{
register struct depend *dp;
register struct line *lp;
register struct name *np;
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;
}