mk.h 4.1 KB

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