11 #define uchar _mkuchar
12 #define ushort _mkushort
14 #define ulong _mkulong
15 #define vlong _mkvlong
16 #define uvlong _mkuvlong
18 #define nil ((void*)0)
20 typedef unsigned char uchar;
21 typedef unsigned short ushort;
22 typedef unsigned int uint;
23 typedef unsigned long ulong;
25 #define nelem(x) (sizeof(x)/sizeof((x)[0]))
27 #define OREAD O_RDONLY
28 #define OWRITE O_WRONLY
30 #define USED(x) if(x);else
33 #define exits(s) exit((s) && ((char*)s)[0] ? 1 : 0)
34 #define create(name, mode, perm) creat(name, perm)
38 #define assert mkassert
41 typedef struct Bufblock
43 struct Bufblock *next;
65 char *target; /* one target */
66 Word *tail; /* constituents of targets */
67 char *recipe; /* do it ! */
68 short attr; /* attributes */
69 short line; /* source line */
70 char *file; /* source file */
71 Word *alltargets; /* all the targets */
72 int rule; /* rule number */
73 Reprog *pat; /* reg exp goo */
74 char *prog; /* to use in out of date */
75 struct Rule *chain; /* hashed per target */
79 extern Rule *rules, *metarules, *patrule;
101 char *match[NREGEXP];
112 unsigned short flags;
114 struct Node *next; /* list for a rule */
118 #define VIRTUAL 0x0001
121 #define CANPRETEND 0x0008
122 #define PRETENDING 0x0010
123 #define NOTMADE 0x0020
124 #define BEINGMADE 0x0040
126 #define MADESET(n,m) n->flags = (n->flags&~(NOTMADE|BEINGMADE|MADE))|(m)
127 #define PROBABLE 0x0100
128 #define VACUOUS 0x0200
129 #define NORECIPE 0x0400
130 #define DELETE 0x0800
131 #define NOMINUSE 0x1000
135 Rule *r; /* master rule for job */
136 Node *n; /* list of node targets */
139 Word *p; /* prerequistes */
140 Word *np; /* new prerequistes */
141 Word *t; /* targets */
142 Word *at; /* all targets */
143 int nproc; /* slot number */
148 typedef struct Symtab
157 S_VAR, /* variable -> value */
158 S_TARGET, /* target -> rule */
159 S_TIME, /* file -> time */
160 S_PID, /* pid -> products */
161 S_NODE, /* target name -> node */
162 S_AGG, /* aggregate -> time */
163 S_BITCH, /* bitched about aggregate not there */
164 S_NOEXPORT, /* var -> noexport */
165 S_OVERRIDE, /* can't override */
166 S_OUTOFDATE, /* n1\377n2 -> 2(outofdate) or 1(not outofdate) */
167 S_MAKEFILE, /* target -> node */
168 S_MAKEVAR, /* dumpable mk variable */
169 S_EXPORTED, /* var -> current exported value */
170 S_WESET, /* variable; we set in the mkfile */
171 S_INTERNAL /* an internal mk variable (e.g., stem, target) */
175 extern int nflag, tflag, iflag, kflag, aflag, mflag;
179 extern char *explain;
180 extern char *termchars;
183 extern char *shellname;
184 extern char *shflags;
186 #define SYNERR(l) (fprint(2, "mk: %s:%d: syntax error; ", infile, ((l)>=0)?(l):mkinline))
187 #define RERR(r) (fprint(2, "mk: %s:%d: rule error; ", (r)->file, (r)->line))
188 #define NAMEBLOCK 1000
189 #define BIGBLOCK 20000
191 #define SEP(c) (((c)==' ')||((c)=='\t')||((c)=='\n'))
192 #define WORDCHR(r) ((r) > ' ' && !utfrune("!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~", (r)))
194 #define DEBUG(x) (debug&(x))
199 #define LSEEK(f,o,p) seek(f,o,p)
201 #define PERCENT(ch) (((ch) == '%') || ((ch) == '&'))