Blob


1 #include "sys.h"
3 #undef assert
4 #define assert mkassert
5 extern Biobuf bout;
7 typedef struct Bufblock
8 {
9 struct Bufblock *next;
10 char *start;
11 char *end;
12 char *current;
13 } Bufblock;
15 typedef struct Word
16 {
17 char *s;
18 struct Word *next;
19 } Word;
21 typedef struct Envy
22 {
23 char *name;
24 Word *values;
25 } Envy;
27 extern Envy *envy;
29 typedef struct Rule
30 {
31 char *target; /* one target */
32 Word *tail; /* constituents of targets */
33 char *recipe; /* do it ! */
34 short attr; /* attributes */
35 short line; /* source line */
36 char *file; /* source file */
37 Word *alltargets; /* all the targets */
38 int rule; /* rule number */
39 Reprog *pat; /* reg exp goo */
40 char *prog; /* to use in out of date */
41 struct Rule *chain; /* hashed per target */
42 struct Rule *next;
43 } Rule;
45 extern Rule *rules, *metarules, *patrule;
47 /* Rule.attr */
48 #define META 0x0001
49 #define UNUSED 0x0002
50 #define UPD 0x0004
51 #define QUIET 0x0008
52 #define VIR 0x0010
53 #define REGEXP 0x0020
54 #define NOREC 0x0040
55 #define DEL 0x0080
56 #define NOVIRT 0x0100
58 #define NREGEXP 10
60 typedef struct Arc
61 {
62 short flag;
63 struct Node *n;
64 Rule *r;
65 char *stem;
66 char *prog;
67 char *match[NREGEXP];
68 struct Arc *next;
69 } Arc;
71 /* Arc.flag */
72 #define TOGO 1
74 typedef struct Node
75 {
76 char *name;
77 long time;
78 unsigned short flags;
79 Arc *prereqs;
80 struct Node *next; /* list for a rule */
81 } Node;
83 /* Node.flags */
84 #define VIRTUAL 0x0001
85 #define CYCLE 0x0002
86 #define READY 0x0004
87 #define CANPRETEND 0x0008
88 #define PRETENDING 0x0010
89 #define NOTMADE 0x0020
90 #define BEINGMADE 0x0040
91 #define MADE 0x0080
92 #define MADESET(n,m) n->flags = (n->flags&~(NOTMADE|BEINGMADE|MADE))|(m)
93 #define PROBABLE 0x0100
94 #define VACUOUS 0x0200
95 #define NORECIPE 0x0400
96 #define DELETE 0x0800
97 #define NOMINUSE 0x1000
99 typedef struct Job
101 Rule *r; /* master rule for job */
102 Node *n; /* list of node targets */
103 char *stem;
104 char **match;
105 Word *p; /* prerequistes */
106 Word *np; /* new prerequistes */
107 Word *t; /* targets */
108 Word *at; /* all targets */
109 int nproc; /* slot number */
110 struct Job *next;
111 } Job;
112 extern Job *jobs;
114 typedef struct Symtab
116 short space;
117 char *name;
118 void *value;
119 struct Symtab *next;
120 } Symtab;
122 enum {
123 S_VAR, /* variable -> value */
124 S_TARGET, /* target -> rule */
125 S_TIME, /* file -> time */
126 S_PID, /* pid -> products */
127 S_NODE, /* target name -> node */
128 S_AGG, /* aggregate -> time */
129 S_BITCH, /* bitched about aggregate not there */
130 S_NOEXPORT, /* var -> noexport */
131 S_OVERRIDE, /* can't override */
132 S_OUTOFDATE, /* n1\377n2 -> 2(outofdate) or 1(not outofdate) */
133 S_MAKEFILE, /* target -> node */
134 S_MAKEVAR, /* dumpable mk variable */
135 S_EXPORTED, /* var -> current exported value */
136 S_WESET, /* variable; we set in the mkfile */
137 S_INTERNAL /* an internal mk variable (e.g., stem, target) */
138 };
140 extern int debug;
141 extern int nflag, tflag, iflag, kflag, aflag, mflag;
142 extern int mkinline;
143 extern char *infile;
144 extern int nreps;
145 extern char *explain;
146 extern char *termchars;
147 extern int IWS;
148 extern char *shell;
149 extern char *shellname;
150 extern char *shflags;
152 #define SYNERR(l) (fprint(2, "mk: %s:%d: syntax error; ", infile, ((l)>=0)?(l):mkinline))
153 #define RERR(r) (fprint(2, "mk: %s:%d: rule error; ", (r)->file, (r)->line))
154 #define NAMEBLOCK 1000
155 #define BIGBLOCK 20000
157 #define SEP(c) (((c)==' ')||((c)=='\t')||((c)=='\n'))
158 #define WORDCHR(r) ((r) > ' ' && !utfrune("!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~", (r)))
160 #define DEBUG(x) (debug&(x))
161 #define D_PARSE 0x01
162 #define D_GRAPH 0x02
163 #define D_EXEC 0x04
165 #define LSEEK(f,o,p) seek(f,o,p)
167 #define PERCENT(ch) (((ch) == '%') || ((ch) == '&'))
169 #include "fns.h"