Replace legacy make with bmake
[dragonfly.git] / usr.bin / make / GNode.h
1 /*-
2  * Copyright (c) 1988, 1989, 1990, 1993
3  *      The Regents of the University of California.  All rights reserved.
4  * Copyright (c) 1989 by Berkeley Softworks
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * Adam de Boor.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *      This product includes software developed by the University of
21  *      California, Berkeley and its contributors.
22  * 4. Neither the name of the University nor the names of its contributors
23  *    may be used to endorse or promote products derived from this software
24  *    without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  *
38  * $DragonFly: src/usr.bin/make/GNode.h,v 1.8 2005/08/03 19:48:44 okumoto Exp $
39  */
40
41 #ifndef GNode_h_39503bf2
42 #define GNode_h_39503bf2
43
44 #include <stdbool.h>
45
46 #include "lst.h"
47
48 struct Suff;
49
50 /*
51  * The structure for an individual graph node. Each node has several
52  * pieces of data associated with it.
53  */
54 typedef struct GNode {
55         char    *name;  /* The target's name */
56         char    *path;  /* The full pathname of the target file */
57
58         /*
59          * The type of operator used to define the sources (qv. parse.c)
60          *
61          * The OP_ constants are used when parsing a dependency line as a way of
62          * communicating to other parts of the program the way in which a target
63          * should be made. These constants are bitwise-OR'ed together and
64          * placed in the 'type' field of each node. Any node that has
65          * a 'type' field which satisfies the OP_NOP function was never never on
66          * the lefthand side of an operator, though it may have been on the
67          * righthand side...
68          */
69         int     type;
70 #define OP_DEPENDS      0x00000001      /* Execution of commands depends on
71                                          * kids (:) */
72 #define OP_FORCE        0x00000002      /* Always execute commands (!) */
73 #define OP_DOUBLEDEP    0x00000004      /* Execution of commands depends on
74                                          * kids per line (::) */
75 #define OP_OPMASK       (OP_DEPENDS|OP_FORCE|OP_DOUBLEDEP)
76
77 #define OP_OPTIONAL     0x00000008      /* Don't care if the target doesn't
78                                          * exist and can't be created */
79 #define OP_USE          0x00000010      /*
80                                          * Use associated commands for
81                                          * parents
82                                          */
83 #define OP_EXEC         0x00000020      /* Target is never out of date, but
84                                          * always execute commands anyway.
85                                          * Its time doesn't matter, so it has
86                                          * none...sort of
87                                          */
88 #define OP_IGNORE       0x00000040      /*
89                                          * Ignore errors when creating the node
90                                          */
91 #define OP_PRECIOUS     0x00000080      /* Don't remove the target when
92                                          * interrupted */
93 #define OP_SILENT       0x00000100      /* Don't echo commands when executed */
94 #define OP_MAKE         0x00000200      /*
95                                          * Target is a recurrsive make so its
96                                          * commands should always be executed
97                                          * when it is out of date, regardless
98                                          * of the state of the -n or -t flags
99                                          */
100 #define OP_JOIN         0x00000400      /* Target is out-of-date only if any of
101                                          * its children was out-of-date */
102 #define OP_INVISIBLE    0x00004000      /* The node is invisible to its parents.
103                                          * I.e. it doesn't show up in the
104                                          * parents's local variables. */
105 #define OP_NOTMAIN      0x00008000      /* The node is exempt from normal 'main
106                                          * target' processing in parse.c */
107 #define OP_PHONY        0x00010000      /* Not a file target; run always */
108 /* Attributes applied by PMake */
109 #define OP_TRANSFORM    0x80000000      /* The node is a transformation rule */
110 #define OP_MEMBER       0x40000000      /* Target is a member of an archive */
111 #define OP_LIB          0x20000000      /* Target is a library */
112 #define OP_ARCHV        0x10000000      /* Target is an archive construct */
113 #define OP_HAS_COMMANDS 0x08000000      /* Target has all the commands it
114                                          * should.  Used when parsing to catch
115                                          * multiple commands for a target */
116 #define OP_SAVE_CMDS    0x04000000      /* Saving commands on .END (Compat) */
117 #define OP_DEPS_FOUND   0x02000000      /* Already processed by Suff_FindDeps */
118
119 /*
120  * OP_NOP will return true if the node with the given type was not the
121  * object of a dependency operator
122  */
123 #define OP_NOP(t)       (((t) & OP_OPMASK) == 0x00000000)
124
125         int     order;  /* Its wait weight */
126
127         bool    make;   /* true if this target needs to be remade */
128
129         /* Set to reflect the state of processing on this node */
130         enum {
131                 UNMADE,         /* Not examined yet */
132
133                 /*
134                  * Target is already being made. Indicates a cycle in the graph.
135                  * (compat mode only)
136                  */
137                 BEINGMADE,
138
139                 MADE,           /* Was out-of-date and has been made */
140                 UPTODATE,       /* Was already up-to-date */
141
142                 /*
143                  * An error occured while it was being
144                  * made (used only in compat mode)
145                  */
146                 ERROR,
147
148                 /*
149                  * The target was aborted due to an
150                  * error making an inferior (compat).
151                  */
152                 ABORTED,
153
154                 /*
155                  * Marked as potentially being part of a graph cycle.  If we
156                  * come back to a node marked this way, it is printed and
157                  * 'made' is changed to ENDCYCLE.
158                  */
159                 CYCLE,
160
161                 /*
162                  * The cycle has been completely printed.  Go back and
163                  * unmark all its members.
164                  */
165                 ENDCYCLE
166         } made;
167
168         /* true if one of this target's children was made */
169         bool    childMade;
170
171         int     unmade;         /* The number of unmade children */
172         int     mtime;          /* Its modification time */
173         int     cmtime;         /* Modification time of its youngest child */
174
175         /*
176          * Links to parents for which this is an implied source, if any. (nodes
177          * that depend on this, as gleaned from the transformation rules.
178          */
179         Lst     iParents;
180
181         /* List of nodes of the same name created by the :: operator */
182         Lst     cohorts;
183
184         /* Lst of nodes for which this is a source (that depend on this one) */
185         Lst     parents;
186
187         /* List of nodes on which this depends */
188         Lst     children;
189
190         /*
191          * List of nodes that must be made (if they're made) after this node is,
192          * but that do not depend on this node, in the normal sense.
193          */
194         Lst     successors;
195
196         /*
197          * List of nodes that must be made (if they're made) before this node
198          * can be, but that do no enter into the datedness of this node.
199          */
200         Lst     preds;
201
202         /*
203          * List of ``local'' variables that are specific to this target
204          * and this target only (qv. var.c [$@ $< $?, etc.])
205          */
206         Lst     context;
207
208         /*
209          * List of strings that are commands to be given to a shell
210          * to create this target.
211          */
212         Lst     commands;
213
214         /* current command executing in compat mode */
215         LstNode *compat_command;
216
217         /*
218          * Suffix for the node (determined by Suff_FindDeps and opaque to
219          * everyone but the Suff module)
220          */
221         struct Suff     *suffix;
222 } GNode;
223
224 #endif /* GNode_h_39503bf2 */