xref: /trueos/usr.bin/make/GNode.h (revision bcd0e15cf642d6e5bf78ee585ad282b0e3061864)
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  * $FreeBSD$
39  */
40 
41 #ifndef GNode_h_39503bf2
42 #define	GNode_h_39503bf2
43 
44 #include "lst.h"
45 #include "util.h"
46 
47 struct Suff;
48 
49 /*
50  * The structure for an individual graph node. Each node has several
51  * pieces of data associated with it.
52  */
53 typedef struct GNode {
54 	char	*name;	/* The target's name */
55 	char	*path;	/* The full pathname of the target file */
56 
57 	/*
58 	 * The type of operator used to define the sources (qv. parse.c)
59 	 *
60 	 * The OP_ constants are used when parsing a dependency line as a way of
61 	 * communicating to other parts of the program the way in which a target
62 	 * should be made. These constants are bitwise-OR'ed together and
63 	 * placed in the 'type' field of each node. Any node that has
64 	 * a 'type' field which satisfies the OP_NOP function was never never on
65 	 * the lefthand side of an operator, though it may have been on the
66 	 * righthand side...
67 	 */
68 	int	type;
69 #define	OP_DEPENDS	0x00000001	/* Execution of commands depends on
70 					 * kids (:) */
71 #define	OP_FORCE	0x00000002	/* Always execute commands (!) */
72 #define	OP_DOUBLEDEP	0x00000004	/* Execution of commands depends on
73 					 * kids per line (::) */
74 #define	OP_OPMASK	(OP_DEPENDS|OP_FORCE|OP_DOUBLEDEP)
75 
76 #define	OP_OPTIONAL	0x00000008	/* Don't care if the target doesn't
77 					 * exist and can't be created */
78 #define	OP_USE		0x00000010	/*
79 					 * Use associated commands for
80 					 * parents
81 					 */
82 #define	OP_EXEC		0x00000020	/* Target is never out of date, but
83 					 * always execute commands anyway.
84 					 * Its time doesn't matter, so it has
85 					 * none...sort of
86 					 */
87 #define	OP_IGNORE	0x00000040	/*
88 					 * Ignore errors when creating the node
89 					 */
90 #define	OP_PRECIOUS	0x00000080	/* Don't remove the target when
91 					 * interrupted */
92 #define	OP_SILENT	0x00000100	/* Don't echo commands when executed */
93 #define	OP_MAKE		0x00000200	/*
94 					 * Target is a recurrsive make so its
95 					 * commands should always be executed
96 					 * when it is out of date, regardless
97 					 * of the state of the -n or -t flags
98 					 */
99 #define	OP_JOIN		0x00000400	/* Target is out-of-date only if any of
100 					 * its children was out-of-date */
101 #define	OP_INVISIBLE	0x00004000	/* The node is invisible to its parents.
102 					 * I.e. it doesn't show up in the
103 					 * parents's local variables. */
104 #define	OP_NOTMAIN	0x00008000	/* The node is exempt from normal 'main
105 					 * target' processing in parse.c */
106 #define	OP_PHONY	0x00010000	/* Not a file target; run always */
107 /* Attributes applied by PMake */
108 #define	OP_TRANSFORM	0x80000000	/* The node is a transformation rule */
109 #define	OP_MEMBER	0x40000000	/* Target is a member of an archive */
110 #define	OP_LIB		0x20000000	/* Target is a library */
111 #define	OP_ARCHV	0x10000000	/* Target is an archive construct */
112 #define	OP_HAS_COMMANDS	0x08000000	/* Target has all the commands it
113 					 * should.  Used when parsing to catch
114 					 * multiple commands for a target */
115 #define	OP_SAVE_CMDS	0x04000000	/* Saving commands on .END (Compat) */
116 #define	OP_DEPS_FOUND	0x02000000	/* Already processed by Suff_FindDeps */
117 
118 /*
119  * OP_NOP will return TRUE if the node with the given type was not the
120  * object of a dependency operator
121  */
122 #define	OP_NOP(t)	(((t) & OP_OPMASK) == 0x00000000)
123 
124 	int	order;	/* Its wait weight */
125 
126 	Boolean	make;	/* TRUE if this target needs to be remade */
127 
128 	/* Set to reflect the state of processing on this node */
129 	enum {
130 		UNMADE,		/* Not examined yet */
131 
132 		/*
133 		 * Target is already being made. Indicates a cycle in the graph.
134 		 * (compat mode only)
135 		 */
136 		BEINGMADE,
137 
138 		MADE,		/* Was out-of-date and has been made */
139 		UPTODATE,	/* Was already up-to-date */
140 
141 		/*
142 		 * An error occurred while it was being
143 		 * made (used only in compat mode)
144 		 */
145 		ERROR,
146 
147 		/*
148 		 * The target was aborted due to an
149 		 * error making an inferior (compat).
150 		 */
151 		ABORTED,
152 
153 		/*
154 		 * Marked as potentially being part of a graph cycle.  If we
155 		 * come back to a node marked this way, it is printed and
156 		 * 'made' is changed to ENDCYCLE.
157 		 */
158 		CYCLE,
159 
160 		/*
161 		 * The cycle has been completely printed.  Go back and
162 		 * unmark all its members.
163 		 */
164 		ENDCYCLE
165 	} made;
166 
167 	/* TRUE if one of this target's children was made */
168 	Boolean	childMade;
169 
170 	int	unmade;		/* The number of unmade children */
171 	int	mtime;		/* Its modification time */
172 	int	cmtime;		/* Modification time of its youngest child */
173 	struct GNode *cmtime_gn;/* 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 */
225