|
|
1.1 root 1: #include "libc.h"
2: #include "fio.h"
3: #include "regexp.h"
4:
5: typedef struct Word
6: {
7: char *s;
8: struct Word *next;
9: } Word;
10: extern Word *newword(), *expand(), *wsubst(), *stow();
11:
12: typedef struct Rule
13: {
14: char *target; /* one target */
15: Word *tail; /* constituents of targets */
16: char *recipe; /* do it ! */
17: short attr; /* attributes */
18: short line; /* source line */
19: char *file; /* source file */
20: Word *alltargets; /* all the targets */
21: int rule; /* rule number */
22: regexp *pat; /* reg exp goo */
23: char *prog; /* to use in out of date */
24: struct Rule *chain; /* hashed per target */
25: struct Rule *next;
26: } Rule;
27: extern Rule *rules, *metarules, *patrule;
28:
29: #define META 0x0001
30: #define SEQ 0x0002
31: #define UPD 0x0004
32: #define RED 0x0008
33: #define QUIET 0x0010
34: #define VIR 0x0020
35: #define REGEXP 0x0040
36: #define NOREC 0x0080
37: #define DEL 0x0100
38:
39: #define NREGEXP 10
40:
41: typedef struct Arc
42: {
43: short flag;
44: struct Node *n;
45: Rule *r;
46: char *stem;
47: char *prog;
48: regsubexp match[NREGEXP];
49: struct Arc *next;
50: } Arc;
51: extern Arc *newarc();
52: #define TOGO 1
53:
54: typedef struct Node
55: {
56: char *name;
57: long time;
58: unsigned short flags;
59: Arc *prereqs;
60: struct Node *next; /* list for a rule */
61: } Node;
62: extern Node *graph();
63: #define VIRTUAL 0x0001
64: #define CYCLE 0x0002
65: #define READY 0x0004
66: #define CANPRETEND 0x0008
67: #define PRETENDING 0x0010
68: #define NOTMADE 0x0020
69: #define BEINGMADE 0x0040
70: #define MADE 0x0080
71: #define MADESET(n,m) n->flags = (n->flags&~(NOTMADE|BEINGMADE|MADE))|(m)
72: #define PROBABLE 0x0100
73: #define VACUOUS 0x0200
74: #define NORECIPE 0x0400
75: #define DELETE 0x0800
76:
77: typedef struct Job
78: {
79: Rule *r; /* master rule for job */
80: Node *n; /* list of node targets */
81: char *stem;
82: regsubexp *match;
83: Word *p; /* prerequisites */
84: Word *np; /* new prerequisites */
85: Word *t; /* targets */
86: Word *at; /* all targets */
87: int nproc; /* slot number */
88: int fd; /* if redirecting */
89: struct Job *next;
90: } Job;
91: extern Job *newjob(), *jobs;
92:
93: typedef struct Symtab
94: {
95: short space;
96: char *name;
97: char *value;
98: struct Symtab *next;
99: } Symtab;
100: extern Symtab *symlook();
101: enum {
102: S_VAR, /* variable -> value */
103: S_TARGET, /* target -> rule */
104: S_TIME, /* file -> time */
105: S_PID, /* pid -> products */
106: S_NODE, /* target name -> node */
107: S_AGG, /* aggregate -> time */
108: S_BITCH, /* bitched about aggregate not there */
109: S_NOEXPORT, /* var -> noexport */
110: S_OVERRIDE, /* can't override */
111: S_OUTOFDATE, /* n1\377n2 -> 2(outofdate) or 1(not outofdate) */
112: S_MAKEFILE, /* target -> node */
113: S_MAKEVAR, /* dumpable mk variable */
114: };
115:
116: extern int debug;
117: extern int nflag, tflag, iflag, kflag, aflag, mflag;
118: extern int inline;
119: extern char *infile;
120: extern char *Malloc(), *strndup();
121: extern long timeof();
122: extern void touch(), delete();
123: extern char *shname(), *vexpand();
124: extern int nproclimit;
125: extern int nreps;
126: extern char *explain;
127: extern char *envpr(), *wtos();
128: extern char *rulecnt();
129:
130: #define SYNERR(l) (Fprint(2, "mk: %s:%d: syntax error; ", infile, (((l)>=0)?(l):inline)))
131: #define RERR(r) (Fprint(2, "mk: %s:%d: rule error; ", (r)->file, (r)->line))
132: #define NAMEBLOCK 1000
133: #define BIGBLOCK 20000
134:
135: #ifndef SHELL
136: #define SHELL "/bin/sh" /* should be bourne-like */
137: #endif
138:
139: #define SEP(c) (((c)==' ')||((c)=='\t')||((c)=='\n'))
140:
141: #define DEBUG(x) (debug&(x))
142: #define D_PARSE 0x01
143: #define D_GRAPH 0x02
144: #define D_EXEC 0x04
145:
146: #define EBIT 0x80 /* sorry japan */
147:
148: #define PERCENT(ch) (((ch) == '%') || ((ch) == '&'))
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.