~ubuntu-branches/ubuntu/maverick/9base/maverick

« back to all changes in this revision

Viewing changes to mk/mk.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-08-20 17:34:06 UTC
  • mfrom: (6.2.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090820173406-xpwqa9ruyevvc0ut
Tags: 1:3-3
* Updating maintainer field.
* Updating vcs fields.
* Updating package to standards version 3.8.3.
* Updatin variables writing in rules to consistent style.

Show diffs side-by-side

added added

removed removed

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