| @@ -1,1199 +1,1199 @@ | | | @@ -1,1199 +1,1199 @@ |
1 | /* $NetBSD: make.h,v 1.320 2023/06/01 07:44:10 rillig Exp $ */ | | 1 | /* $NetBSD: make.h,v 1.321 2023/06/16 07:12:46 rillig Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1988, 1989, 1990, 1993 | | 4 | * Copyright (c) 1988, 1989, 1990, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to Berkeley by | | 7 | * This code is derived from software contributed to Berkeley by |
8 | * Adam de Boor. | | 8 | * Adam de Boor. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
15 | * 2. Redistributions in binary form must reproduce the above copyright | | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in the | | 16 | * notice, this list of conditions and the following disclaimer in the |
17 | * documentation and/or other materials provided with the distribution. | | 17 | * documentation and/or other materials provided with the distribution. |
18 | * 3. Neither the name of the University nor the names of its contributors | | 18 | * 3. Neither the name of the University nor the names of its contributors |
19 | * may be used to endorse or promote products derived from this software | | 19 | * may be used to endorse or promote products derived from this software |
20 | * without specific prior written permission. | | 20 | * without specific prior written permission. |
21 | * | | 21 | * |
22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
32 | * SUCH DAMAGE. | | 32 | * SUCH DAMAGE. |
33 | * | | 33 | * |
34 | * from: @(#)make.h 8.3 (Berkeley) 6/13/95 | | 34 | * from: @(#)make.h 8.3 (Berkeley) 6/13/95 |
35 | */ | | 35 | */ |
36 | | | 36 | |
37 | /* | | 37 | /* |
38 | * Copyright (c) 1989 by Berkeley Softworks | | 38 | * Copyright (c) 1989 by Berkeley Softworks |
39 | * All rights reserved. | | 39 | * All rights reserved. |
40 | * | | 40 | * |
41 | * This code is derived from software contributed to Berkeley by | | 41 | * This code is derived from software contributed to Berkeley by |
42 | * Adam de Boor. | | 42 | * Adam de Boor. |
43 | * | | 43 | * |
44 | * Redistribution and use in source and binary forms, with or without | | 44 | * Redistribution and use in source and binary forms, with or without |
45 | * modification, are permitted provided that the following conditions | | 45 | * modification, are permitted provided that the following conditions |
46 | * are met: | | 46 | * are met: |
47 | * 1. Redistributions of source code must retain the above copyright | | 47 | * 1. Redistributions of source code must retain the above copyright |
48 | * notice, this list of conditions and the following disclaimer. | | 48 | * notice, this list of conditions and the following disclaimer. |
49 | * 2. Redistributions in binary form must reproduce the above copyright | | 49 | * 2. Redistributions in binary form must reproduce the above copyright |
50 | * notice, this list of conditions and the following disclaimer in the | | 50 | * notice, this list of conditions and the following disclaimer in the |
51 | * documentation and/or other materials provided with the distribution. | | 51 | * documentation and/or other materials provided with the distribution. |
52 | * 3. All advertising materials mentioning features or use of this software | | 52 | * 3. All advertising materials mentioning features or use of this software |
53 | * must display the following acknowledgement: | | 53 | * must display the following acknowledgement: |
54 | * This product includes software developed by the University of | | 54 | * This product includes software developed by the University of |
55 | * California, Berkeley and its contributors. | | 55 | * California, Berkeley and its contributors. |
56 | * 4. Neither the name of the University nor the names of its contributors | | 56 | * 4. Neither the name of the University nor the names of its contributors |
57 | * may be used to endorse or promote products derived from this software | | 57 | * may be used to endorse or promote products derived from this software |
58 | * without specific prior written permission. | | 58 | * without specific prior written permission. |
59 | * | | 59 | * |
60 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 60 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
61 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 61 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
62 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 62 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
63 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 63 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
64 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 64 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
65 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 65 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
66 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 66 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
67 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 67 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
68 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 68 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
69 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 69 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
70 | * SUCH DAMAGE. | | 70 | * SUCH DAMAGE. |
71 | * | | 71 | * |
72 | * from: @(#)make.h 8.3 (Berkeley) 6/13/95 | | 72 | * from: @(#)make.h 8.3 (Berkeley) 6/13/95 |
73 | */ | | 73 | */ |
74 | | | 74 | |
75 | /* | | 75 | /* |
76 | * make.h -- | | 76 | * make.h -- |
77 | * The global definitions for make | | 77 | * The global definitions for make |
78 | */ | | 78 | */ |
79 | | | 79 | |
80 | #ifndef MAKE_MAKE_H | | 80 | #ifndef MAKE_MAKE_H |
81 | #define MAKE_MAKE_H | | 81 | #define MAKE_MAKE_H |
82 | | | 82 | |
83 | #include <sys/types.h> | | 83 | #include <sys/types.h> |
84 | #include <sys/param.h> | | 84 | #include <sys/param.h> |
85 | #include <sys/stat.h> | | 85 | #include <sys/stat.h> |
86 | | | 86 | |
87 | #include <assert.h> | | 87 | #include <assert.h> |
88 | #include <ctype.h> | | 88 | #include <ctype.h> |
89 | #include <fcntl.h> | | 89 | #include <fcntl.h> |
90 | #include <stdarg.h> | | 90 | #include <stdarg.h> |
91 | #include <stdio.h> | | 91 | #include <stdio.h> |
92 | #include <stdlib.h> | | 92 | #include <stdlib.h> |
93 | #include <string.h> | | 93 | #include <string.h> |
94 | #include <unistd.h> | | 94 | #include <unistd.h> |
95 | | | 95 | |
96 | #ifdef BSD4_4 | | 96 | #ifdef BSD4_4 |
97 | # include <sys/cdefs.h> | | 97 | # include <sys/cdefs.h> |
98 | #endif | | 98 | #endif |
99 | | | 99 | |
100 | #ifndef FD_CLOEXEC | | 100 | #ifndef FD_CLOEXEC |
101 | #define FD_CLOEXEC 1 | | 101 | #define FD_CLOEXEC 1 |
102 | #endif | | 102 | #endif |
103 | | | 103 | |
104 | #if defined(__GNUC__) | | 104 | #if defined(__GNUC__) |
105 | #define MAKE_GNUC_PREREQ(x, y) \ | | 105 | #define MAKE_GNUC_PREREQ(x, y) \ |
106 | ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \ | | 106 | ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \ |
107 | (__GNUC__ > (x))) | | 107 | (__GNUC__ > (x))) |
108 | #else | | 108 | #else |
109 | #define MAKE_GNUC_PREREQ(x, y) 0 | | 109 | #define MAKE_GNUC_PREREQ(x, y) 0 |
110 | #endif | | 110 | #endif |
111 | | | 111 | |
112 | #if MAKE_GNUC_PREREQ(2, 7) | | 112 | #if MAKE_GNUC_PREREQ(2, 7) |
113 | #define MAKE_ATTR_UNUSED __attribute__((__unused__)) | | 113 | #define MAKE_ATTR_UNUSED __attribute__((__unused__)) |
114 | #else | | 114 | #else |
115 | #define MAKE_ATTR_UNUSED /* delete */ | | 115 | #define MAKE_ATTR_UNUSED /* delete */ |
116 | #endif | | 116 | #endif |
117 | | | 117 | |
118 | #if MAKE_GNUC_PREREQ(2, 5) | | 118 | #if MAKE_GNUC_PREREQ(2, 5) |
119 | #define MAKE_ATTR_DEAD __attribute__((__noreturn__)) | | 119 | #define MAKE_ATTR_DEAD __attribute__((__noreturn__)) |
120 | #elif defined(__GNUC__) | | 120 | #elif defined(__GNUC__) |
121 | #define MAKE_ATTR_DEAD __volatile | | 121 | #define MAKE_ATTR_DEAD __volatile |
122 | #else | | 122 | #else |
123 | #define MAKE_ATTR_DEAD /* delete */ | | 123 | #define MAKE_ATTR_DEAD /* delete */ |
124 | #endif | | 124 | #endif |
125 | | | 125 | |
126 | #if MAKE_GNUC_PREREQ(2, 7) | | 126 | #if MAKE_GNUC_PREREQ(2, 7) |
127 | #define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) \ | | 127 | #define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) \ |
128 | __attribute__((__format__ (__printf__, fmtarg, firstvararg))) | | 128 | __attribute__((__format__ (__printf__, fmtarg, firstvararg))) |
129 | #else | | 129 | #else |
130 | #define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) /* delete */ | | 130 | #define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) /* delete */ |
131 | #endif | | 131 | #endif |
132 | | | 132 | |
133 | #if MAKE_GNUC_PREREQ(4, 0) | | 133 | #if MAKE_GNUC_PREREQ(4, 0) |
134 | #define MAKE_ATTR_USE __attribute__((__warn_unused_result__)) | | 134 | #define MAKE_ATTR_USE __attribute__((__warn_unused_result__)) |
135 | #else | | 135 | #else |
136 | #define MAKE_ATTR_USE /* delete */ | | 136 | #define MAKE_ATTR_USE /* delete */ |
137 | #endif | | 137 | #endif |
138 | | | 138 | |
139 | #if __STDC_VERSION__ >= 199901L || defined(lint) | | 139 | #if __STDC_VERSION__ >= 199901L || defined(lint) |
140 | #define MAKE_INLINE static inline MAKE_ATTR_UNUSED | | 140 | #define MAKE_INLINE static inline MAKE_ATTR_UNUSED |
141 | #else | | 141 | #else |
142 | #define MAKE_INLINE static MAKE_ATTR_UNUSED | | 142 | #define MAKE_INLINE static MAKE_ATTR_UNUSED |
143 | #endif | | 143 | #endif |
144 | | | 144 | |
145 | /* MAKE_STATIC marks a function that may or may not be inlined. */ | | 145 | /* MAKE_STATIC marks a function that may or may not be inlined. */ |
146 | #if defined(lint) | | 146 | #if defined(lint) |
147 | /* As of 2021-07-31, NetBSD lint ignores __attribute__((unused)). */ | | 147 | /* As of 2021-07-31, NetBSD lint ignores __attribute__((unused)). */ |
148 | #define MAKE_STATIC MAKE_INLINE | | 148 | #define MAKE_STATIC MAKE_INLINE |
149 | #else | | 149 | #else |
150 | #define MAKE_STATIC static MAKE_ATTR_UNUSED | | 150 | #define MAKE_STATIC static MAKE_ATTR_UNUSED |
151 | #endif | | 151 | #endif |
152 | | | 152 | |
153 | #if __STDC_VERSION__ >= 199901L || defined(lint) || defined(USE_C99_BOOLEAN) | | 153 | #if __STDC_VERSION__ >= 199901L || defined(lint) || defined(USE_C99_BOOLEAN) |
154 | #include <stdbool.h> | | 154 | #include <stdbool.h> |
155 | #elif defined(__bool_true_false_are_defined) | | 155 | #elif defined(__bool_true_false_are_defined) |
156 | /* | | 156 | /* |
157 | * All files of make must be compiled with the same definition of bool. | | 157 | * All files of make must be compiled with the same definition of bool. |
158 | * Since one of the files includes <stdbool.h>, that means the header is | | 158 | * Since one of the files includes <stdbool.h>, that means the header is |
159 | * available on this platform. Recompile everything with -DUSE_C99_BOOLEAN. | | 159 | * available on this platform. Recompile everything with -DUSE_C99_BOOLEAN. |
160 | */ | | 160 | */ |
161 | #error "<stdbool.h> is included in pre-C99 mode" | | 161 | #error "<stdbool.h> is included in pre-C99 mode" |
162 | #elif defined(bool) || defined(true) || defined(false) | | 162 | #elif defined(bool) || defined(true) || defined(false) |
163 | /* | | 163 | /* |
164 | * In pre-C99 mode, make does not expect that bool is already defined. | | 164 | * In pre-C99 mode, make does not expect that bool is already defined. |
165 | * You need to ensure that all translation units use the same definition for | | 165 | * You need to ensure that all translation units use the same definition for |
166 | * bool. | | 166 | * bool. |
167 | */ | | 167 | */ |
168 | #error "bool/true/false is defined in pre-C99 mode" | | 168 | #error "bool/true/false is defined in pre-C99 mode" |
169 | #else | | 169 | #else |
170 | typedef unsigned char bool; | | 170 | typedef unsigned char bool; |
171 | #define true 1 | | 171 | #define true 1 |
172 | #define false 0 | | 172 | #define false 0 |
173 | #endif | | 173 | #endif |
174 | | | 174 | |
175 | #include "lst.h" | | 175 | #include "lst.h" |
176 | #include "make_malloc.h" | | 176 | #include "make_malloc.h" |
177 | #include "str.h" | | 177 | #include "str.h" |
178 | #include "hash.h" | | 178 | #include "hash.h" |
179 | #include "config.h" | | 179 | #include "config.h" |
180 | #include "buf.h" | | 180 | #include "buf.h" |
181 | | | 181 | |
182 | /* | | 182 | /* |
183 | * The typical flow of states is: | | 183 | * The typical flow of states is: |
184 | * | | 184 | * |
185 | * The direct successful path: | | 185 | * The direct successful path: |
186 | * UNMADE -> BEINGMADE -> MADE. | | 186 | * UNMADE -> BEINGMADE -> MADE. |
187 | * | | 187 | * |
188 | * The direct error path: | | 188 | * The direct error path: |
189 | * UNMADE -> BEINGMADE -> ERROR. | | 189 | * UNMADE -> BEINGMADE -> ERROR. |
190 | * | | 190 | * |
191 | * The successful path when dependencies need to be made first: | | 191 | * The successful path when dependencies need to be made first: |
192 | * UNMADE -> DEFERRED -> REQUESTED -> BEINGMADE -> MADE. | | 192 | * UNMADE -> DEFERRED -> REQUESTED -> BEINGMADE -> MADE. |
193 | * | | 193 | * |
194 | * A node that has dependencies, and one of the dependencies cannot be made: | | 194 | * A node that has dependencies, and one of the dependencies cannot be made: |
195 | * UNMADE -> DEFERRED -> ABORTED. | | 195 | * UNMADE -> DEFERRED -> ABORTED. |
196 | * | | 196 | * |
197 | * A node that turns out to be up-to-date: | | 197 | * A node that turns out to be up-to-date: |
198 | * UNMADE -> BEINGMADE -> UPTODATE. | | 198 | * UNMADE -> BEINGMADE -> UPTODATE. |
199 | */ | | 199 | */ |
200 | typedef enum GNodeMade { | | 200 | typedef enum GNodeMade { |
201 | /* Not examined yet. */ | | 201 | /* Not examined yet. */ |
202 | UNMADE, | | 202 | UNMADE, |
203 | /* | | 203 | /* |
204 | * The node has been examined but is not yet ready since its | | 204 | * The node has been examined but is not yet ready since its |
205 | * dependencies have to be made first. | | 205 | * dependencies have to be made first. |
206 | */ | | 206 | */ |
207 | DEFERRED, | | 207 | DEFERRED, |
208 | | | 208 | |
209 | /* The node is on the toBeMade list. */ | | 209 | /* The node is on the toBeMade list. */ |
210 | REQUESTED, | | 210 | REQUESTED, |
211 | | | 211 | |
212 | /* | | 212 | /* |
213 | * The node is already being made. Trying to build a node in this | | 213 | * The node is already being made. Trying to build a node in this |
214 | * state indicates a cycle in the graph. | | 214 | * state indicates a cycle in the graph. |
215 | */ | | 215 | */ |
216 | BEINGMADE, | | 216 | BEINGMADE, |
217 | | | 217 | |
218 | /* Was out-of-date and has been made. */ | | 218 | /* Was out-of-date and has been made. */ |
219 | MADE, | | 219 | MADE, |
220 | /* Was already up-to-date, does not need to be made. */ | | 220 | /* Was already up-to-date, does not need to be made. */ |
221 | UPTODATE, | | 221 | UPTODATE, |
222 | /* | | 222 | /* |
223 | * An error occurred while it was being made. Used only in compat | | 223 | * An error occurred while it was being made. Used only in compat |
224 | * mode. | | 224 | * mode. |
225 | */ | | 225 | */ |
226 | ERROR, | | 226 | ERROR, |
227 | /* | | 227 | /* |
228 | * The target was aborted due to an error making a dependency. Used | | 228 | * The target was aborted due to an error making a dependency. Used |
229 | * only in compat mode. | | 229 | * only in compat mode. |
230 | */ | | 230 | */ |
231 | ABORTED | | 231 | ABORTED |
232 | } GNodeMade; | | 232 | } GNodeMade; |
233 | | | 233 | |
234 | /* | | 234 | /* |
235 | * The OP_ constants are used when parsing a dependency line as a way of | | 235 | * The OP_ constants are used when parsing a dependency line as a way of |
236 | * communicating to other parts of the program the way in which a target | | 236 | * communicating to other parts of the program the way in which a target |
237 | * should be made. | | 237 | * should be made. |
238 | * | | 238 | * |
239 | * Some of the OP_ constants can be combined, others cannot. | | 239 | * Some of the OP_ constants can be combined, others cannot. |
240 | * | | 240 | * |
241 | * See the tests depsrc-*.mk and deptgt-*.mk. | | 241 | * See the tests depsrc-*.mk and deptgt-*.mk. |
242 | */ | | 242 | */ |
243 | typedef enum GNodeType { | | 243 | typedef enum GNodeType { |
244 | OP_NONE = 0, | | 244 | OP_NONE = 0, |
245 | | | 245 | |
246 | /* | | 246 | /* |
247 | * The dependency operator ':' is the most common one. The commands | | 247 | * The dependency operator ':' is the most common one. The commands |
248 | * of this node are executed if any child is out-of-date. | | 248 | * of this node are executed if any child is out-of-date. |
249 | */ | | 249 | */ |
250 | OP_DEPENDS = 1 << 0, | | 250 | OP_DEPENDS = 1 << 0, |
251 | /* | | 251 | /* |
252 | * The dependency operator '!' always executes its commands, even if | | 252 | * The dependency operator '!' always executes its commands, even if |
253 | * its children are up-to-date. | | 253 | * its children are up-to-date. |
254 | */ | | 254 | */ |
255 | OP_FORCE = 1 << 1, | | 255 | OP_FORCE = 1 << 1, |
256 | /* | | 256 | /* |
257 | * The dependency operator '::' behaves like ':', except that it | | 257 | * The dependency operator '::' behaves like ':', except that it |
258 | * allows multiple dependency groups to be defined. Each of these | | 258 | * allows multiple dependency groups to be defined. Each of these |
259 | * groups is executed on its own, independently from the others. Each | | 259 | * groups is executed on its own, independently from the others. Each |
260 | * individual dependency group is called a cohort. | | 260 | * individual dependency group is called a cohort. |
261 | */ | | 261 | */ |
262 | OP_DOUBLEDEP = 1 << 2, | | 262 | OP_DOUBLEDEP = 1 << 2, |
263 | | | 263 | |
264 | /* Matches the dependency operators ':', '!' and '::'. */ | | 264 | /* Matches the dependency operators ':', '!' and '::'. */ |
265 | OP_OPMASK = OP_DEPENDS | OP_FORCE | OP_DOUBLEDEP, | | 265 | OP_OPMASK = OP_DEPENDS | OP_FORCE | OP_DOUBLEDEP, |
266 | | | 266 | |
267 | /* Don't care if the target doesn't exist and can't be created. */ | | 267 | /* Don't care if the target doesn't exist and can't be created. */ |
268 | OP_OPTIONAL = 1 << 3, | | 268 | OP_OPTIONAL = 1 << 3, |
269 | /* Use associated commands for parents. */ | | 269 | /* Use associated commands for parents. */ |
270 | OP_USE = 1 << 4, | | 270 | OP_USE = 1 << 4, |
271 | /* | | 271 | /* |
272 | * Target is never out of date, but always execute commands anyway. | | 272 | * Target is never out of date, but always execute commands anyway. |
273 | * Its time doesn't matter, so it has none...sort of. | | 273 | * Its time doesn't matter, so it has none...sort of. |
274 | */ | | 274 | */ |
275 | OP_EXEC = 1 << 5, | | 275 | OP_EXEC = 1 << 5, |
276 | /* | | 276 | /* |
277 | * Ignore non-zero exit status from shell commands when creating the | | 277 | * Ignore non-zero exit status from shell commands when creating the |
278 | * node. | | 278 | * node. |
279 | */ | | 279 | */ |
280 | OP_IGNORE = 1 << 6, | | 280 | OP_IGNORE = 1 << 6, |
281 | /* Don't remove the target when interrupted. */ | | 281 | /* Don't remove the target when interrupted. */ |
282 | OP_PRECIOUS = 1 << 7, | | 282 | OP_PRECIOUS = 1 << 7, |
283 | /* Don't echo commands when executed. */ | | 283 | /* Don't echo commands when executed. */ |
284 | OP_SILENT = 1 << 8, | | 284 | OP_SILENT = 1 << 8, |
285 | /* | | 285 | /* |
286 | * Target is a recursive make so its commands should always be | | 286 | * Target is a recursive make so its commands should always be |
287 | * executed when it is out of date, regardless of the state of the -n | | 287 | * executed when it is out of date, regardless of the state of the -n |
288 | * or -t flags. | | 288 | * or -t flags. |
289 | */ | | 289 | */ |
290 | OP_MAKE = 1 << 9, | | 290 | OP_MAKE = 1 << 9, |
291 | /* | | 291 | /* |
292 | * Target is out-of-date only if any of its children was out-of-date. | | 292 | * Target is out-of-date only if any of its children was out-of-date. |
293 | */ | | 293 | */ |
294 | OP_JOIN = 1 << 10, | | 294 | OP_JOIN = 1 << 10, |
295 | /* Assume the children of the node have been already made. */ | | 295 | /* Assume the children of the node have been already made. */ |
296 | OP_MADE = 1 << 11, | | 296 | OP_MADE = 1 << 11, |
297 | /* Special .BEGIN, .END or .INTERRUPT. */ | | 297 | /* Special .BEGIN, .END or .INTERRUPT. */ |
298 | OP_SPECIAL = 1 << 12, | | 298 | OP_SPECIAL = 1 << 12, |
299 | /* Like .USE, only prepend commands. */ | | 299 | /* Like .USE, only prepend commands. */ |
300 | OP_USEBEFORE = 1 << 13, | | 300 | OP_USEBEFORE = 1 << 13, |
301 | /* | | 301 | /* |
302 | * The node is invisible to its parents. I.e. it doesn't show up in | | 302 | * The node is invisible to its parents. I.e. it doesn't show up in |
303 | * the parents' local variables (.IMPSRC, .ALLSRC). | | 303 | * the parents' local variables (.IMPSRC, .ALLSRC). |
304 | */ | | 304 | */ |
305 | OP_INVISIBLE = 1 << 14, | | 305 | OP_INVISIBLE = 1 << 14, |
306 | /* | | 306 | /* |
307 | * The node does not become the main target, even if it is the first | | 307 | * The node does not become the main target, even if it is the first |
308 | * target in the first makefile. | | 308 | * target in the first makefile. |
309 | */ | | 309 | */ |
310 | OP_NOTMAIN = 1 << 15, | | 310 | OP_NOTMAIN = 1 << 15, |
311 | /* Not a file target; run always. */ | | 311 | /* Not a file target; run always. */ |
312 | OP_PHONY = 1 << 16, | | 312 | OP_PHONY = 1 << 16, |
313 | /* Don't search for the file in the path. */ | | 313 | /* Don't search for the file in the path. */ |
314 | OP_NOPATH = 1 << 17, | | 314 | OP_NOPATH = 1 << 17, |
315 | /* | | 315 | /* |
316 | * In a dependency line "target: source1 .WAIT source2", source1 is | | 316 | * In a dependency line "target: source1 .WAIT source2", source1 is |
317 | * made first, including its children. Once that is finished, | | 317 | * made first, including its children. Once that is finished, |
318 | * source2 is made, including its children. The .WAIT keyword may | | 318 | * source2 is made, including its children. The .WAIT keyword may |
319 | * appear more than once in a single dependency declaration. | | 319 | * appear more than once in a single dependency declaration. |
320 | */ | | 320 | */ |
321 | OP_WAIT = 1 << 18, | | 321 | OP_WAIT = 1 << 18, |
322 | /* .NOMETA do not create a .meta file */ | | 322 | /* .NOMETA do not create a .meta file */ |
323 | OP_NOMETA = 1 << 19, | | 323 | OP_NOMETA = 1 << 19, |
324 | /* .META we _do_ want a .meta file */ | | 324 | /* .META we _do_ want a .meta file */ |
325 | OP_META = 1 << 20, | | 325 | OP_META = 1 << 20, |
326 | /* Do not compare commands in .meta file */ | | 326 | /* Do not compare commands in .meta file */ |
327 | OP_NOMETA_CMP = 1 << 21, | | 327 | OP_NOMETA_CMP = 1 << 21, |
328 | /* Possibly a submake node */ | | 328 | /* Possibly a submake node */ |
329 | OP_SUBMAKE = 1 << 22, | | 329 | OP_SUBMAKE = 1 << 22, |
330 | | | 330 | |
331 | /* Attributes applied by PMake */ | | 331 | /* Attributes applied by PMake */ |
332 | | | 332 | |
333 | /* The node is a transformation rule, such as ".c.o". */ | | 333 | /* The node is a transformation rule, such as ".c.o". */ |
334 | OP_TRANSFORM = 1 << 30, | | 334 | OP_TRANSFORM = 1 << 30, |
335 | /* Target is a member of an archive */ | | 335 | /* Target is a member of an archive */ |
336 | /* XXX: How does this differ from OP_ARCHV? */ | | 336 | /* XXX: How does this differ from OP_ARCHV? */ |
337 | OP_MEMBER = 1 << 29, | | 337 | OP_MEMBER = 1 << 29, |
338 | /* | | 338 | /* |
339 | * The node is a library, its name has the form "-l<libname>". | | 339 | * The node is a library, its name has the form "-l<libname>". |
340 | */ | | 340 | */ |
341 | OP_LIB = 1 << 28, | | 341 | OP_LIB = 1 << 28, |
342 | /* | | 342 | /* |
343 | * The node is an archive member, its name has the form | | 343 | * The node is an archive member, its name has the form |
344 | * "archive(member)". | | 344 | * "archive(member)". |
345 | */ | | 345 | */ |
346 | /* XXX: How does this differ from OP_MEMBER? */ | | 346 | /* XXX: How does this differ from OP_MEMBER? */ |
347 | OP_ARCHV = 1 << 27, | | 347 | OP_ARCHV = 1 << 27, |
348 | /* | | 348 | /* |
349 | * Target has all the commands it should. Used when parsing to catch | | 349 | * Target has all the commands it should. Used when parsing to catch |
350 | * multiple command groups for a target. Only applies to the | | 350 | * multiple command groups for a target. Only applies to the |
351 | * dependency operators ':' and '!', but not to '::'. | | 351 | * dependency operators ':' and '!', but not to '::'. |
352 | */ | | 352 | */ |
353 | OP_HAS_COMMANDS = 1 << 26, | | 353 | OP_HAS_COMMANDS = 1 << 26, |
354 | /* | | 354 | /* |
355 | * The special command "..." has been seen. All further commands from | | 355 | * The special command "..." has been seen. All further commands from |
356 | * this node will be saved on the .END node instead, to be executed | | 356 | * this node will be saved on the .END node instead, to be executed |
357 | * at the very end. | | 357 | * at the very end. |
358 | */ | | 358 | */ |
359 | OP_SAVE_CMDS = 1 << 25, | | 359 | OP_SAVE_CMDS = 1 << 25, |
360 | /* | | 360 | /* |
361 | * Already processed by Suff_FindDeps, to find dependencies from | | 361 | * Already processed by Suff_FindDeps, to find dependencies from |
362 | * suffix transformation rules. | | 362 | * suffix transformation rules. |
363 | */ | | 363 | */ |
364 | OP_DEPS_FOUND = 1 << 24, | | 364 | OP_DEPS_FOUND = 1 << 24, |
365 | /* Node found while expanding .ALLSRC */ | | 365 | /* Node found while expanding .ALLSRC */ |
366 | OP_MARK = 1 << 23 | | 366 | OP_MARK = 1 << 23 |
367 | } GNodeType; | | 367 | } GNodeType; |
368 | | | 368 | |
369 | typedef struct GNodeFlags { | | 369 | typedef struct GNodeFlags { |
370 | /* this target needs to be (re)made */ | | 370 | /* this target needs to be (re)made */ |
371 | bool remake:1; | | 371 | bool remake:1; |
372 | /* children of this target were made */ | | 372 | /* children of this target were made */ |
373 | bool childMade:1; | | 373 | bool childMade:1; |
374 | /* children don't exist, and we pretend made */ | | 374 | /* children don't exist, and we pretend made */ |
375 | bool force:1; | | 375 | bool force:1; |
376 | /* Set by Make_ProcessWait() */ | | 376 | /* Set by Make_ProcessWait() */ |
377 | bool doneWait:1; | | 377 | bool doneWait:1; |
378 | /* Build requested by .ORDER processing */ | | 378 | /* Build requested by .ORDER processing */ |
379 | bool doneOrder:1; | | 379 | bool doneOrder:1; |
380 | /* Node created from .depend */ | | 380 | /* Node created from .depend */ |
381 | bool fromDepend:1; | | 381 | bool fromDepend:1; |
382 | /* We do it once only */ | | 382 | /* We do it once only */ |
383 | bool doneAllsrc:1; | | 383 | bool doneAllsrc:1; |
384 | /* Used by MakePrintStatus */ | | 384 | /* Used by MakePrintStatus */ |
385 | bool cycle:1; | | 385 | bool cycle:1; |
386 | /* Used by MakePrintStatus */ | | 386 | /* Used by MakePrintStatus */ |
387 | bool doneCycle:1; | | 387 | bool doneCycle:1; |
388 | } GNodeFlags; | | 388 | } GNodeFlags; |
389 | | | 389 | |
390 | typedef struct List StringList; | | 390 | typedef struct List StringList; |
391 | typedef struct ListNode StringListNode; | | 391 | typedef struct ListNode StringListNode; |
392 | | | 392 | |
393 | typedef struct List GNodeList; | | 393 | typedef struct List GNodeList; |
394 | typedef struct ListNode GNodeListNode; | | 394 | typedef struct ListNode GNodeListNode; |
395 | | | 395 | |
396 | typedef struct SearchPath { | | 396 | typedef struct SearchPath { |
397 | List /* of CachedDir */ dirs; | | 397 | List /* of CachedDir */ dirs; |
398 | } SearchPath; | | 398 | } SearchPath; |
399 | | | 399 | |
400 | /* | | 400 | /* |
401 | * A graph node represents a target that can possibly be made, including its | | 401 | * A graph node represents a target that can possibly be made, including its |
402 | * relation to other targets and a lot of other details. | | 402 | * relation to other targets and a lot of other details. |
403 | */ | | 403 | */ |
404 | typedef struct GNode { | | 404 | typedef struct GNode { |
405 | /* The target's name, such as "clean" or "make.c" */ | | 405 | /* The target's name, such as "clean" or "make.c" */ |
406 | char *name; | | 406 | char *name; |
407 | /* The unexpanded name of a .USE node */ | | 407 | /* The unexpanded name of a .USE node */ |
408 | char *uname; | | 408 | char *uname; |
409 | /* | | 409 | /* |
410 | * The full pathname of the file belonging to the target. | | 410 | * The full pathname of the file belonging to the target. |
411 | * | | 411 | * |
412 | * XXX: What about .PHONY targets? These don't have an associated | | 412 | * XXX: What about .PHONY targets? These don't have an associated |
413 | * path. | | 413 | * path. |
414 | */ | | 414 | */ |
415 | char *path; | | 415 | char *path; |
416 | | | 416 | |
417 | /* | | 417 | /* |
418 | * The type of operator used to define the sources (see the OP flags | | 418 | * The type of operator used to define the sources (see the OP flags |
419 | * below). | | 419 | * below). |
420 | * | | 420 | * |
421 | * XXX: This looks like a wild mixture of type and flags. | | 421 | * XXX: This looks like a wild mixture of type and flags. |
422 | */ | | 422 | */ |
423 | GNodeType type; | | 423 | GNodeType type; |
424 | GNodeFlags flags; | | 424 | GNodeFlags flags; |
425 | | | 425 | |
426 | /* The state of processing on this node */ | | 426 | /* The state of processing on this node */ |
427 | GNodeMade made; | | 427 | GNodeMade made; |
428 | /* The number of unmade children */ | | 428 | /* The number of unmade children */ |
429 | int unmade; | | 429 | int unmade; |
430 | | | 430 | |
431 | /* | | 431 | /* |
432 | * The modification time; 0 means the node does not have a | | 432 | * The modification time; 0 means the node does not have a |
433 | * corresponding file; see GNode_IsOODate. | | 433 | * corresponding file; see GNode_IsOODate. |
434 | */ | | 434 | */ |
435 | time_t mtime; | | 435 | time_t mtime; |
436 | struct GNode *youngestChild; | | 436 | struct GNode *youngestChild; |
437 | | | 437 | |
438 | /* | | 438 | /* |
439 | * The GNodes for which this node is an implied source. May be empty. | | 439 | * The GNodes for which this node is an implied source. May be empty. |
440 | * For example, when there is an inference rule for .c.o, the node | | 440 | * For example, when there is an inference rule for .c.o, the node |
441 | * for file.c has the node for file.o in this list. | | 441 | * for file.c has the node for file.o in this list. |
442 | */ | | 442 | */ |
443 | GNodeList implicitParents; | | 443 | GNodeList implicitParents; |
444 | | | 444 | |
445 | /* | | 445 | /* |
446 | * The nodes that depend on this one, or in other words, the nodes | | 446 | * The nodes that depend on this one, or in other words, the nodes |
447 | * for which this is a source. | | 447 | * for which this is a source. |
448 | */ | | 448 | */ |
449 | GNodeList parents; | | 449 | GNodeList parents; |
450 | /* The nodes on which this one depends. */ | | 450 | /* The nodes on which this one depends. */ |
451 | GNodeList children; | | 451 | GNodeList children; |
452 | | | 452 | |
453 | /* | | 453 | /* |
454 | * .ORDER nodes we need made. The nodes that must be made (if they're | | 454 | * .ORDER nodes we need made. The nodes that must be made (if they're |
455 | * made) before this node can be made, but that do not enter into the | | 455 | * made) before this node can be made, but that do not enter into the |
456 | * datedness of this node. | | 456 | * datedness of this node. |
457 | */ | | 457 | */ |
458 | GNodeList order_pred; | | 458 | GNodeList order_pred; |
459 | /* | | 459 | /* |
460 | * .ORDER nodes who need us. The nodes that must be made (if they're | | 460 | * .ORDER nodes who need us. The nodes that must be made (if they're |
461 | * made at all) after this node is made, but that do not depend on | | 461 | * made at all) after this node is made, but that do not depend on |
462 | * this node, in the normal sense. | | 462 | * this node, in the normal sense. |
463 | */ | | 463 | */ |
464 | GNodeList order_succ; | | 464 | GNodeList order_succ; |
465 | | | 465 | |
466 | /* | | 466 | /* |
467 | * Other nodes of the same name, for targets that were defined using | | 467 | * Other nodes of the same name, for targets that were defined using |
468 | * the '::' dependency operator (OP_DOUBLEDEP). | | 468 | * the '::' dependency operator (OP_DOUBLEDEP). |
469 | */ | | 469 | */ |
470 | GNodeList cohorts; | | 470 | GNodeList cohorts; |
471 | /* The "#n" suffix for this cohort, or "" for other nodes */ | | 471 | /* The "#n" suffix for this cohort, or "" for other nodes */ |
472 | char cohort_num[8]; | | 472 | char cohort_num[8]; |
473 | /* The number of unmade instances on the cohorts list */ | | 473 | /* The number of unmade instances on the cohorts list */ |
474 | int unmade_cohorts; | | 474 | int unmade_cohorts; |
475 | /* | | 475 | /* |
476 | * Pointer to the first instance of a '::' node; only set when on a | | 476 | * Pointer to the first instance of a '::' node; only set when on a |
477 | * cohorts list | | 477 | * cohorts list |
478 | */ | | 478 | */ |
479 | struct GNode *centurion; | | 479 | struct GNode *centurion; |
480 | | | 480 | |
481 | /* Last time (sequence number) we tried to make this node */ | | 481 | /* Last time (sequence number) we tried to make this node */ |
482 | unsigned int checked_seqno; | | 482 | unsigned int checked_seqno; |
483 | | | 483 | |
484 | /* | | 484 | /* |
485 | * The "local" variables that are specific to this target and this | | 485 | * The "local" variables that are specific to this target and this |
486 | * target only, such as $@, $<, $?. | | 486 | * target only, such as $@, $<, $?. |
487 | * | | 487 | * |
488 | * Also used for the global variable scopes SCOPE_GLOBAL, | | 488 | * Also used for the global variable scopes SCOPE_GLOBAL, |
489 | * SCOPE_CMDLINE, SCOPE_INTERNAL, which contain variables with | | 489 | * SCOPE_CMDLINE, SCOPE_INTERNAL, which contain variables with |
490 | * arbitrary names. | | 490 | * arbitrary names. |
491 | */ | | 491 | */ |
492 | HashTable /* of Var pointer */ vars; | | 492 | HashTable /* of Var pointer */ vars; |
493 | | | 493 | |
494 | /* The commands to be given to a shell to create this target. */ | | 494 | /* The commands to be given to a shell to create this target. */ |
495 | StringList commands; | | 495 | StringList commands; |
496 | | | 496 | |
497 | /* | | 497 | /* |
498 | * Suffix for the node (determined by Suff_FindDeps and opaque to | | 498 | * Suffix for the node (determined by Suff_FindDeps and opaque to |
499 | * everyone but the Suff module) | | 499 | * everyone but the Suff module) |
500 | */ | | 500 | */ |
501 | struct Suffix *suffix; | | 501 | struct Suffix *suffix; |
502 | | | 502 | |
503 | /* Filename where the GNode got defined, unlimited lifetime */ | | 503 | /* Filename where the GNode got defined, unlimited lifetime */ |
504 | const char *fname; | | 504 | const char *fname; |
505 | /* Line number where the GNode got defined, 1-based */ | | 505 | /* Line number where the GNode got defined, 1-based */ |
506 | unsigned lineno; | | 506 | unsigned lineno; |
507 | } GNode; | | 507 | } GNode; |
508 | | | 508 | |
509 | /* | | 509 | /* |
510 | * Keep track of whether to include <posix.mk> when parsing the line | | 510 | * Keep track of whether to include <posix.mk> when parsing the line |
511 | * '.POSIX:'. | | 511 | * '.POSIX:'. |
512 | */ | | 512 | */ |
513 | extern enum PosixState { | | 513 | extern enum PosixState { |
514 | PS_NOT_YET, | | 514 | PS_NOT_YET, |
515 | PS_MAYBE_NEXT_LINE, | | 515 | PS_MAYBE_NEXT_LINE, |
516 | PS_NOW_OR_NEVER, | | 516 | PS_NOW_OR_NEVER, |
517 | PS_TOO_LATE | | 517 | PS_TOO_LATE |
518 | } posix_state; | | 518 | } posix_state; |
519 | | | 519 | |
520 | /* Error levels for diagnostics during parsing. */ | | 520 | /* Error levels for diagnostics during parsing. */ |
521 | typedef enum ParseErrorLevel { | | 521 | typedef enum ParseErrorLevel { |
522 | /* | | 522 | /* |
523 | * Exit when the current top-level makefile has been parsed | | 523 | * Exit when the current top-level makefile has been parsed |
524 | * completely. | | 524 | * completely. |
525 | */ | | 525 | */ |
526 | PARSE_FATAL = 1, | | 526 | PARSE_FATAL = 1, |
527 | /* Print "warning"; may be upgraded to fatal by the -w option. */ | | 527 | /* Print "warning"; may be upgraded to fatal by the -w option. */ |
528 | PARSE_WARNING, | | 528 | PARSE_WARNING, |
529 | /* Informational, mainly used during development of makefiles. */ | | 529 | /* Informational, mainly used during development of makefiles. */ |
530 | PARSE_INFO | | 530 | PARSE_INFO |
531 | } ParseErrorLevel; | | 531 | } ParseErrorLevel; |
532 | | | 532 | |
533 | /* | | 533 | /* |
534 | * Values returned by Cond_EvalLine and Cond_EvalCondition. | | 534 | * Values returned by Cond_EvalLine and Cond_EvalCondition. |
535 | */ | | 535 | */ |
536 | typedef enum CondResult { | | 536 | typedef enum CondResult { |
537 | CR_TRUE, /* Parse the next lines */ | | 537 | CR_TRUE, /* Parse the next lines */ |
538 | CR_FALSE, /* Skip the next lines */ | | 538 | CR_FALSE, /* Skip the next lines */ |
539 | CR_ERROR /* Unknown directive or parse error */ | | 539 | CR_ERROR /* Unknown directive or parse error */ |
540 | } CondResult; | | 540 | } CondResult; |
541 | | | 541 | |
542 | /* Names of the variables that are "local" to a specific target. */ | | 542 | /* Names of the variables that are "local" to a specific target. */ |
543 | #define TARGET "@" /* Target of dependency */ | | 543 | #define TARGET "@" /* Target of dependency */ |
544 | #define OODATE "?" /* All out-of-date sources */ | | 544 | #define OODATE "?" /* All out-of-date sources */ |
545 | #define ALLSRC ">" /* All sources */ | | 545 | #define ALLSRC ">" /* All sources */ |
546 | #define IMPSRC "<" /* Source implied by transformation */ | | 546 | #define IMPSRC "<" /* Source implied by transformation */ |
547 | #define PREFIX "*" /* Common prefix */ | | 547 | #define PREFIX "*" /* Common prefix */ |
548 | #define ARCHIVE "!" /* Archive in "archive(member)" syntax */ | | 548 | #define ARCHIVE "!" /* Archive in "archive(member)" syntax */ |
549 | #define MEMBER "%" /* Member in "archive(member)" syntax */ | | 549 | #define MEMBER "%" /* Member in "archive(member)" syntax */ |
550 | | | 550 | |
551 | /* | | 551 | /* |
552 | * Global Variables | | 552 | * Global Variables |
553 | */ | | 553 | */ |
554 | | | 554 | |
555 | /* True if every target is precious */ | | 555 | /* True if every target is precious */ |
556 | extern bool allPrecious; | | 556 | extern bool allPrecious; |
557 | /* True if failed targets should be deleted */ | | 557 | /* True if failed targets should be deleted */ |
558 | extern bool deleteOnError; | | 558 | extern bool deleteOnError; |
559 | /* true while processing .depend */ | | 559 | /* true while processing .depend */ |
560 | extern bool doing_depend; | | 560 | extern bool doing_depend; |
561 | /* .DEFAULT rule */ | | 561 | /* .DEFAULT rule */ |
562 | extern GNode *defaultNode; | | 562 | extern GNode *defaultNode; |
563 | | | 563 | |
564 | /* | | 564 | /* |
565 | * Variables defined internally by make which should not override those set | | 565 | * Variables defined internally by make which should not override those set |
566 | * by makefiles. | | 566 | * by makefiles. |
567 | */ | | 567 | */ |
568 | extern GNode *SCOPE_INTERNAL; | | 568 | extern GNode *SCOPE_INTERNAL; |
569 | /* Variables defined in a global scope, e.g in the makefile itself. */ | | 569 | /* Variables defined in a global scope, e.g in the makefile itself. */ |
570 | extern GNode *SCOPE_GLOBAL; | | 570 | extern GNode *SCOPE_GLOBAL; |
571 | /* Variables defined on the command line. */ | | 571 | /* Variables defined on the command line. */ |
572 | extern GNode *SCOPE_CMDLINE; | | 572 | extern GNode *SCOPE_CMDLINE; |
573 | | | 573 | |
574 | /* | | 574 | /* |
575 | * Value returned by Var_Parse when an error is encountered. It actually | | 575 | * Value returned by Var_Parse when an error is encountered. It actually |
576 | * points to an empty string, so naive callers needn't worry about it. | | 576 | * points to an empty string, so naive callers needn't worry about it. |
577 | */ | | 577 | */ |
578 | extern char var_Error[]; | | 578 | extern char var_Error[]; |
579 | | | 579 | |
580 | /* The time at the start of this whole process */ | | 580 | /* The time at the start of this whole process */ |
581 | extern time_t now; | | 581 | extern time_t now; |
582 | | | 582 | |
583 | /* | | 583 | /* |
584 | * The list of directories to search when looking for targets (set by the | | 584 | * The list of directories to search when looking for targets (set by the |
585 | * special target .PATH). | | 585 | * special target .PATH). |
586 | */ | | 586 | */ |
587 | extern SearchPath dirSearchPath; | | 587 | extern SearchPath dirSearchPath; |
588 | /* Used for .include "...". */ | | 588 | /* Used for .include "...". */ |
589 | extern SearchPath *parseIncPath; | | 589 | extern SearchPath *parseIncPath; |
590 | /* | | 590 | /* |
591 | * Used for .include <...>, for the built-in sys.mk and for makefiles from | | 591 | * Used for .include <...>, for the built-in sys.mk and for makefiles from |
592 | * the command line arguments. | | 592 | * the command line arguments. |
593 | */ | | 593 | */ |
594 | extern SearchPath *sysIncPath; | | 594 | extern SearchPath *sysIncPath; |
595 | /* The default for sysIncPath. */ | | 595 | /* The default for sysIncPath. */ |
596 | extern SearchPath *defSysIncPath; | | 596 | extern SearchPath *defSysIncPath; |
597 | | | 597 | |
598 | /* Startup directory */ | | 598 | /* Startup directory */ |
599 | extern char curdir[]; | | 599 | extern char curdir[]; |
600 | /* The basename of the program name, suffixed with [n] for sub-makes. */ | | 600 | /* The basename of the program name, suffixed with [n] for sub-makes. */ |
601 | extern const char *progname; | | 601 | extern const char *progname; |
602 | extern int makelevel; | | 602 | extern int makelevel; |
603 | /* Name of the .depend makefile */ | | 603 | /* Name of the .depend makefile */ |
604 | extern char *makeDependfile; | | 604 | extern char *makeDependfile; |
605 | /* If we replaced environ, this will be non-NULL. */ | | 605 | /* If we replaced environ, this will be non-NULL. */ |
606 | extern char **savedEnv; | | 606 | extern char **savedEnv; |
607 | extern GNode *mainNode; | | 607 | extern GNode *mainNode; |
608 | | | 608 | |
609 | extern pid_t myPid; | | 609 | extern pid_t myPid; |
610 | | | 610 | |
611 | #define MAKEFLAGS ".MAKEFLAGS" | | 611 | #define MAKEFLAGS ".MAKEFLAGS" |
612 | #ifndef MAKE_LEVEL_ENV | | 612 | #ifndef MAKE_LEVEL_ENV |
613 | # define MAKE_LEVEL_ENV "MAKELEVEL" | | 613 | # define MAKE_LEVEL_ENV "MAKELEVEL" |
614 | #endif | | 614 | #endif |
615 | | | 615 | |
616 | typedef struct DebugFlags { | | 616 | typedef struct DebugFlags { |
617 | bool DEBUG_ARCH:1; | | 617 | bool DEBUG_ARCH:1; |
618 | bool DEBUG_COND:1; | | 618 | bool DEBUG_COND:1; |
619 | bool DEBUG_CWD:1; | | 619 | bool DEBUG_CWD:1; |
620 | bool DEBUG_DIR:1; | | 620 | bool DEBUG_DIR:1; |
621 | bool DEBUG_ERROR:1; | | 621 | bool DEBUG_ERROR:1; |
622 | bool DEBUG_FOR:1; | | 622 | bool DEBUG_FOR:1; |
623 | bool DEBUG_GRAPH1:1; | | 623 | bool DEBUG_GRAPH1:1; |
624 | bool DEBUG_GRAPH2:1; | | 624 | bool DEBUG_GRAPH2:1; |
625 | bool DEBUG_GRAPH3:1; | | 625 | bool DEBUG_GRAPH3:1; |
626 | bool DEBUG_HASH:1; | | 626 | bool DEBUG_HASH:1; |
627 | bool DEBUG_JOB:1; | | 627 | bool DEBUG_JOB:1; |
628 | bool DEBUG_LOUD:1; | | 628 | bool DEBUG_LOUD:1; |
629 | bool DEBUG_MAKE:1; | | 629 | bool DEBUG_MAKE:1; |
630 | bool DEBUG_META:1; | | 630 | bool DEBUG_META:1; |
631 | bool DEBUG_PARSE:1; | | 631 | bool DEBUG_PARSE:1; |
632 | bool DEBUG_SCRIPT:1; | | 632 | bool DEBUG_SCRIPT:1; |
633 | bool DEBUG_SHELL:1; | | 633 | bool DEBUG_SHELL:1; |
634 | bool DEBUG_SUFF:1; | | 634 | bool DEBUG_SUFF:1; |
635 | bool DEBUG_TARG:1; | | 635 | bool DEBUG_TARG:1; |
636 | bool DEBUG_VAR:1; | | 636 | bool DEBUG_VAR:1; |
637 | } DebugFlags; | | 637 | } DebugFlags; |
638 | | | 638 | |
639 | #define CONCAT(a, b) a##b | | 639 | #define CONCAT(a, b) a##b |
640 | | | 640 | |
641 | #define DEBUG(module) (opts.debug.CONCAT(DEBUG_, module)) | | 641 | #define DEBUG(module) (opts.debug.CONCAT(DEBUG_, module)) |
642 | | | 642 | |
643 | void debug_printf(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2); | | 643 | void debug_printf(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2); |
644 | | | 644 | |
645 | #define DEBUG_IMPL(module, args) \ | | 645 | #define DEBUG_IMPL(module, args) \ |
646 | do { \ | | 646 | do { \ |
647 | if (DEBUG(module)) \ | | 647 | if (DEBUG(module)) \ |
648 | debug_printf args; \ | | 648 | debug_printf args; \ |
649 | } while (false) | | 649 | } while (false) |
650 | | | 650 | |
651 | #define DEBUG0(module, fmt) \ | | 651 | #define DEBUG0(module, fmt) \ |
652 | DEBUG_IMPL(module, (fmt)) | | 652 | DEBUG_IMPL(module, (fmt)) |
653 | #define DEBUG1(module, fmt, arg1) \ | | 653 | #define DEBUG1(module, fmt, arg1) \ |
654 | DEBUG_IMPL(module, (fmt, arg1)) | | 654 | DEBUG_IMPL(module, (fmt, arg1)) |
655 | #define DEBUG2(module, fmt, arg1, arg2) \ | | 655 | #define DEBUG2(module, fmt, arg1, arg2) \ |
656 | DEBUG_IMPL(module, (fmt, arg1, arg2)) | | 656 | DEBUG_IMPL(module, (fmt, arg1, arg2)) |
657 | #define DEBUG3(module, fmt, arg1, arg2, arg3) \ | | 657 | #define DEBUG3(module, fmt, arg1, arg2, arg3) \ |
658 | DEBUG_IMPL(module, (fmt, arg1, arg2, arg3)) | | 658 | DEBUG_IMPL(module, (fmt, arg1, arg2, arg3)) |
659 | #define DEBUG4(module, fmt, arg1, arg2, arg3, arg4) \ | | 659 | #define DEBUG4(module, fmt, arg1, arg2, arg3, arg4) \ |
660 | DEBUG_IMPL(module, (fmt, arg1, arg2, arg3, arg4)) | | 660 | DEBUG_IMPL(module, (fmt, arg1, arg2, arg3, arg4)) |
661 | #define DEBUG5(module, fmt, arg1, arg2, arg3, arg4, arg5) \ | | 661 | #define DEBUG5(module, fmt, arg1, arg2, arg3, arg4, arg5) \ |
662 | DEBUG_IMPL(module, (fmt, arg1, arg2, arg3, arg4, arg5)) | | 662 | DEBUG_IMPL(module, (fmt, arg1, arg2, arg3, arg4, arg5)) |
663 | | | 663 | |
664 | typedef enum PrintVarsMode { | | 664 | typedef enum PrintVarsMode { |
665 | PVM_NONE, | | 665 | PVM_NONE, |
666 | PVM_UNEXPANDED, | | 666 | PVM_UNEXPANDED, |
667 | PVM_EXPANDED | | 667 | PVM_EXPANDED |
668 | } PrintVarsMode; | | 668 | } PrintVarsMode; |
669 | | | 669 | |
670 | /* Command line options */ | | 670 | /* Command line options */ |
671 | typedef struct CmdOpts { | | 671 | typedef struct CmdOpts { |
672 | /* -B: whether we are make compatible */ | | 672 | /* -B: whether we are make compatible */ |
673 | bool compatMake; | | 673 | bool compatMake; |
674 | | | 674 | |
675 | /* | | 675 | /* |
676 | * -d: debug control: There is one bit per module. It is up to the | | 676 | * -d: debug control: There is one bit per module. It is up to the |
677 | * module what debug information to print. | | 677 | * module what debug information to print. |
678 | */ | | 678 | */ |
679 | DebugFlags debug; | | 679 | DebugFlags debug; |
680 | | | 680 | |
681 | /* -df: debug output is written here - default stderr */ | | 681 | /* -df: debug output is written here - default stderr */ |
682 | FILE *debug_file; | | 682 | FILE *debug_file; |
683 | | | 683 | |
684 | /* | | 684 | /* |
685 | * -dL: lint mode | | 685 | * -dL: lint mode |
686 | * | | 686 | * |
687 | * Runs make in strict mode, with additional checks and better error | | 687 | * Runs make in strict mode, with additional checks and better error |
688 | * handling. | | 688 | * handling. |
689 | */ | | 689 | */ |
690 | bool strict; | | 690 | bool strict; |
691 | | | 691 | |
692 | /* -dV: for the -V option, print unexpanded variable values */ | | 692 | /* -dV: for the -V option, print unexpanded variable values */ |
693 | bool debugVflag; | | 693 | bool debugVflag; |
694 | | | 694 | |
695 | /* -e: check environment variables before global variables */ | | 695 | /* -e: check environment variables before global variables */ |
696 | bool checkEnvFirst; | | 696 | bool checkEnvFirst; |
697 | | | 697 | |
698 | /* -f: the makefiles to read */ | | 698 | /* -f: the makefiles to read */ |
699 | StringList makefiles; | | 699 | StringList makefiles; |
700 | | | 700 | |
701 | /* -i: if true, ignore all errors from shell commands */ | | 701 | /* -i: if true, ignore all errors from shell commands */ |
702 | bool ignoreErrors; | | 702 | bool ignoreErrors; |
703 | | | 703 | |
704 | /* | | 704 | /* |
705 | * -j: the maximum number of jobs that can run in parallel; this is | | 705 | * -j: the maximum number of jobs that can run in parallel; this is |
706 | * coordinated with the submakes | | 706 | * coordinated with the submakes |
707 | */ | | 707 | */ |
708 | int maxJobs; | | 708 | int maxJobs; |
709 | | | 709 | |
710 | /* | | 710 | /* |
711 | * -k: if true and an error occurs while making a node, continue | | 711 | * -k: if true and an error occurs while making a node, continue |
712 | * making nodes that do not depend on the erroneous node | | 712 | * making nodes that do not depend on the erroneous node |
713 | */ | | 713 | */ |
714 | bool keepgoing; | | 714 | bool keepgoing; |
715 | | | 715 | |
716 | /* -N: execute no commands from the targets */ | | 716 | /* -N: execute no commands from the targets */ |
717 | bool noRecursiveExecute; | | 717 | bool noRecursiveExecute; |
718 | | | 718 | |
719 | /* -n: execute almost no commands from the targets */ | | 719 | /* -n: execute almost no commands from the targets */ |
720 | bool noExecute; | | 720 | bool noExecute; |
721 | | | 721 | |
722 | /* | | 722 | /* |
723 | * -q: if true, do not really make anything, just see if the targets | | 723 | * -q: if true, do not really make anything, just see if the targets |
724 | * are out-of-date | | 724 | * are out-of-date |
725 | */ | | 725 | */ |
726 | bool query; | | 726 | bool query; |
727 | | | 727 | |
728 | /* -r: raw mode, do not load the builtin rules. */ | | 728 | /* -r: raw mode, do not load the builtin rules. */ |
729 | bool noBuiltins; | | 729 | bool noBuiltins; |
730 | | | 730 | |
731 | /* -s: don't echo the shell commands before executing them */ | | 731 | /* -s: don't echo the shell commands before executing them */ |
732 | bool silent; | | 732 | bool silent; |
733 | | | 733 | |
734 | /* | | 734 | /* |
735 | * -t: touch the targets if they are out-of-date, but don't actually | | 735 | * -t: touch the targets if they are out-of-date, but don't actually |
736 | * make them | | 736 | * make them |
737 | */ | | 737 | */ |
738 | bool touch; | | 738 | bool touch; |
739 | | | 739 | |
740 | /* -[Vv]: print expanded or unexpanded selected variables */ | | 740 | /* -[Vv]: print expanded or unexpanded selected variables */ |
741 | PrintVarsMode printVars; | | 741 | PrintVarsMode printVars; |
742 | /* -[Vv]: the variables to print */ | | 742 | /* -[Vv]: the variables to print */ |
743 | StringList variables; | | 743 | StringList variables; |
744 | | | 744 | |
745 | /* -W: if true, makefile parsing warnings are treated as errors */ | | 745 | /* -W: if true, makefile parsing warnings are treated as errors */ |
746 | bool parseWarnFatal; | | 746 | bool parseWarnFatal; |
747 | | | 747 | |
748 | /* -w: print 'Entering' and 'Leaving' for submakes */ | | 748 | /* -w: print 'Entering' and 'Leaving' for submakes */ |
749 | bool enterFlag; | | 749 | bool enterFlag; |
750 | | | 750 | |
751 | /* | | 751 | /* |
752 | * -X: if true, do not export variables set on the command line to | | 752 | * -X: if true, do not export variables set on the command line to |
753 | * the environment. | | 753 | * the environment. |
754 | */ | | 754 | */ |
755 | bool varNoExportEnv; | | 755 | bool varNoExportEnv; |
756 | | | 756 | |
757 | /* | | 757 | /* |
758 | * The target names specified on the command line. Used to resolve | | 758 | * The target names specified on the command line. Used to resolve |
759 | * .if make(...) statements. | | 759 | * .if make(...) statements. |
760 | */ | | 760 | */ |
761 | StringList create; | | 761 | StringList create; |
762 | | | 762 | |
763 | /* | | 763 | /* |
764 | * Randomize the order in which the targets from toBeMade are made, | | 764 | * Randomize the order in which the targets from toBeMade are made, |
765 | * to catch undeclared dependencies. | | 765 | * to catch undeclared dependencies. |
766 | */ | | 766 | */ |
767 | bool randomizeTargets; | | 767 | bool randomizeTargets; |
768 | } CmdOpts; | | 768 | } CmdOpts; |
769 | | | 769 | |
770 | extern CmdOpts opts; | | 770 | extern CmdOpts opts; |
771 | extern bool forceJobs; | | 771 | extern bool forceJobs; |
772 | extern char **environ; | | 772 | extern char **environ; |
773 | | | 773 | |
774 | /* arch.c */ | | 774 | /* arch.c */ |
775 | void Arch_Init(void); | | 775 | void Arch_Init(void); |
776 | void Arch_End(void); | | 776 | void Arch_End(void); |
777 | | | 777 | |
778 | bool Arch_ParseArchive(char **, GNodeList *, GNode *); | | 778 | bool Arch_ParseArchive(char **, GNodeList *, GNode *); |
779 | void Arch_Touch(GNode *); | | 779 | void Arch_Touch(GNode *); |
780 | void Arch_TouchLib(GNode *); | | 780 | void Arch_TouchLib(GNode *); |
781 | void Arch_UpdateMTime(GNode *gn); | | 781 | void Arch_UpdateMTime(GNode *); |
782 | void Arch_UpdateMemberMTime(GNode *gn); | | 782 | void Arch_UpdateMemberMTime(GNode *); |
783 | void Arch_FindLib(GNode *, SearchPath *); | | 783 | void Arch_FindLib(GNode *, SearchPath *); |
784 | bool Arch_LibOODate(GNode *) MAKE_ATTR_USE; | | 784 | bool Arch_LibOODate(GNode *) MAKE_ATTR_USE; |
785 | bool Arch_IsLib(GNode *) MAKE_ATTR_USE; | | 785 | bool Arch_IsLib(GNode *) MAKE_ATTR_USE; |
786 | | | 786 | |
787 | /* compat.c */ | | 787 | /* compat.c */ |
788 | bool Compat_RunCommand(const char *, GNode *, StringListNode *); | | 788 | bool Compat_RunCommand(const char *, GNode *, StringListNode *); |
789 | void Compat_MakeAll(GNodeList *); | | 789 | void Compat_MakeAll(GNodeList *); |
790 | void Compat_Make(GNode *, GNode *); | | 790 | void Compat_Make(GNode *, GNode *); |
791 | | | 791 | |
792 | /* cond.c */ | | 792 | /* cond.c */ |
793 | extern unsigned int cond_depth; | | 793 | extern unsigned int cond_depth; |
794 | CondResult Cond_EvalCondition(const char *) MAKE_ATTR_USE; | | 794 | CondResult Cond_EvalCondition(const char *) MAKE_ATTR_USE; |
795 | CondResult Cond_EvalLine(const char *) MAKE_ATTR_USE; | | 795 | CondResult Cond_EvalLine(const char *) MAKE_ATTR_USE; |
796 | void Cond_EndFile(void); | | 796 | void Cond_EndFile(void); |
797 | | | 797 | |
798 | /* dir.c; see also dir.h */ | | 798 | /* dir.c; see also dir.h */ |
799 | | | 799 | |
800 | MAKE_INLINE const char * MAKE_ATTR_USE | | 800 | MAKE_INLINE const char * MAKE_ATTR_USE |
801 | str_basename(const char *pathname) | | 801 | str_basename(const char *pathname) |
802 | { | | 802 | { |
803 | const char *lastSlash = strrchr(pathname, '/'); | | 803 | const char *lastSlash = strrchr(pathname, '/'); |
804 | return lastSlash != NULL ? lastSlash + 1 : pathname; | | 804 | return lastSlash != NULL ? lastSlash + 1 : pathname; |
805 | } | | 805 | } |
806 | | | 806 | |
807 | MAKE_INLINE SearchPath * MAKE_ATTR_USE | | 807 | MAKE_INLINE SearchPath * MAKE_ATTR_USE |
808 | SearchPath_New(void) | | 808 | SearchPath_New(void) |
809 | { | | 809 | { |
810 | SearchPath *path = bmake_malloc(sizeof *path); | | 810 | SearchPath *path = bmake_malloc(sizeof *path); |
811 | Lst_Init(&path->dirs); | | 811 | Lst_Init(&path->dirs); |
812 | return path; | | 812 | return path; |
813 | } | | 813 | } |
814 | | | 814 | |
815 | void SearchPath_Free(SearchPath *); | | 815 | void SearchPath_Free(SearchPath *); |
816 | | | 816 | |
817 | /* for.c */ | | 817 | /* for.c */ |
818 | struct ForLoop; | | 818 | struct ForLoop; |
819 | int For_Eval(const char *) MAKE_ATTR_USE; | | 819 | int For_Eval(const char *) MAKE_ATTR_USE; |
820 | bool For_Accum(const char *, int *) MAKE_ATTR_USE; | | 820 | bool For_Accum(const char *, int *) MAKE_ATTR_USE; |
821 | void For_Run(unsigned, unsigned); | | 821 | void For_Run(unsigned, unsigned); |
822 | bool For_NextIteration(struct ForLoop *, Buffer *); | | 822 | bool For_NextIteration(struct ForLoop *, Buffer *); |
823 | char *ForLoop_Details(const struct ForLoop *); | | 823 | char *ForLoop_Details(const struct ForLoop *); |
824 | void ForLoop_Free(struct ForLoop *); | | 824 | void ForLoop_Free(struct ForLoop *); |
825 | void For_Break(struct ForLoop *); | | 825 | void For_Break(struct ForLoop *); |
826 | | | 826 | |
827 | /* job.c */ | | 827 | /* job.c */ |
828 | void JobReapChild(pid_t, int, bool); | | 828 | void JobReapChild(pid_t, int, bool); |
829 | | | 829 | |
830 | /* main.c */ | | 830 | /* main.c */ |
831 | void Main_ParseArgLine(const char *); | | 831 | void Main_ParseArgLine(const char *); |
832 | char *Cmd_Exec(const char *, char **) MAKE_ATTR_USE; | | 832 | char *Cmd_Exec(const char *, char **) MAKE_ATTR_USE; |
833 | void Error(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2); | | 833 | void Error(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2); |
834 | void Fatal(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD; | | 834 | void Fatal(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD; |
835 | void Punt(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD; | | 835 | void Punt(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD; |
836 | void DieHorribly(void) MAKE_ATTR_DEAD; | | 836 | void DieHorribly(void) MAKE_ATTR_DEAD; |
837 | void Finish(int) MAKE_ATTR_DEAD; | | 837 | void Finish(int) MAKE_ATTR_DEAD; |
838 | int unlink_file(const char *) MAKE_ATTR_USE; | | 838 | int unlink_file(const char *) MAKE_ATTR_USE; |
839 | void execDie(const char *, const char *); | | 839 | void execDie(const char *, const char *); |
840 | char *getTmpdir(void) MAKE_ATTR_USE; | | 840 | char *getTmpdir(void) MAKE_ATTR_USE; |
841 | bool ParseBoolean(const char *, bool) MAKE_ATTR_USE; | | 841 | bool ParseBoolean(const char *, bool) MAKE_ATTR_USE; |
842 | const char *cached_realpath(const char *, char *); | | 842 | const char *cached_realpath(const char *, char *); |
843 | bool GetBooleanExpr(const char *, bool); | | 843 | bool GetBooleanExpr(const char *, bool); |
844 | | | 844 | |
845 | /* parse.c */ | | 845 | /* parse.c */ |
846 | void Parse_Init(void); | | 846 | void Parse_Init(void); |
847 | void Parse_End(void); | | 847 | void Parse_End(void); |
848 | | | 848 | |
849 | void PrintLocation(FILE *, bool, const GNode *); | | 849 | void PrintLocation(FILE *, bool, const GNode *); |
850 | void PrintStackTrace(bool); | | 850 | void PrintStackTrace(bool); |
851 | void Parse_Error(ParseErrorLevel, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3); | | 851 | void Parse_Error(ParseErrorLevel, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3); |
852 | bool Parse_VarAssign(const char *, bool, GNode *) MAKE_ATTR_USE; | | 852 | bool Parse_VarAssign(const char *, bool, GNode *) MAKE_ATTR_USE; |
853 | void Parse_AddIncludeDir(const char *); | | 853 | void Parse_AddIncludeDir(const char *); |
854 | void Parse_File(const char *, int); | | 854 | void Parse_File(const char *, int); |
855 | void Parse_PushInput(const char *, unsigned, unsigned, Buffer, | | 855 | void Parse_PushInput(const char *, unsigned, unsigned, Buffer, |
856 | struct ForLoop *); | | 856 | struct ForLoop *); |
857 | void Parse_MainName(GNodeList *); | | 857 | void Parse_MainName(GNodeList *); |
858 | int Parse_NumErrors(void) MAKE_ATTR_USE; | | 858 | int Parse_NumErrors(void) MAKE_ATTR_USE; |
859 | unsigned int CurFile_CondMinDepth(void) MAKE_ATTR_USE; | | 859 | unsigned int CurFile_CondMinDepth(void) MAKE_ATTR_USE; |
860 | | | 860 | |
861 | | | 861 | |
862 | /* suff.c */ | | 862 | /* suff.c */ |
863 | void Suff_Init(void); | | 863 | void Suff_Init(void); |
864 | void Suff_End(void); | | 864 | void Suff_End(void); |
865 | | | 865 | |
866 | void Suff_ClearSuffixes(void); | | 866 | void Suff_ClearSuffixes(void); |
867 | bool Suff_IsTransform(const char *) MAKE_ATTR_USE; | | 867 | bool Suff_IsTransform(const char *) MAKE_ATTR_USE; |
868 | GNode *Suff_AddTransform(const char *); | | 868 | GNode *Suff_AddTransform(const char *); |
869 | void Suff_EndTransform(GNode *); | | 869 | void Suff_EndTransform(GNode *); |
870 | void Suff_AddSuffix(const char *); | | 870 | void Suff_AddSuffix(const char *); |
871 | SearchPath *Suff_GetPath(const char *) MAKE_ATTR_USE; | | 871 | SearchPath *Suff_GetPath(const char *) MAKE_ATTR_USE; |
872 | void Suff_ExtendPaths(void); | | 872 | void Suff_ExtendPaths(void); |
873 | void Suff_AddInclude(const char *); | | 873 | void Suff_AddInclude(const char *); |
874 | void Suff_AddLib(const char *); | | 874 | void Suff_AddLib(const char *); |
875 | void Suff_FindDeps(GNode *); | | 875 | void Suff_FindDeps(GNode *); |
876 | SearchPath *Suff_FindPath(GNode *) MAKE_ATTR_USE; | | 876 | SearchPath *Suff_FindPath(GNode *) MAKE_ATTR_USE; |
877 | void Suff_SetNull(const char *); | | 877 | void Suff_SetNull(const char *); |
878 | void Suff_PrintAll(void); | | 878 | void Suff_PrintAll(void); |
879 | char *Suff_NamesStr(void) MAKE_ATTR_USE; | | 879 | char *Suff_NamesStr(void) MAKE_ATTR_USE; |
880 | | | 880 | |
881 | /* targ.c */ | | 881 | /* targ.c */ |
882 | void Targ_Init(void); | | 882 | void Targ_Init(void); |
883 | void Targ_End(void); | | 883 | void Targ_End(void); |
884 | | | 884 | |
885 | void Targ_Stats(void); | | 885 | void Targ_Stats(void); |
886 | GNodeList *Targ_List(void) MAKE_ATTR_USE; | | 886 | GNodeList *Targ_List(void) MAKE_ATTR_USE; |
887 | GNode *GNode_New(const char *) MAKE_ATTR_USE; | | 887 | GNode *GNode_New(const char *) MAKE_ATTR_USE; |
888 | GNode *Targ_FindNode(const char *) MAKE_ATTR_USE; | | 888 | GNode *Targ_FindNode(const char *) MAKE_ATTR_USE; |
889 | GNode *Targ_GetNode(const char *) MAKE_ATTR_USE; | | 889 | GNode *Targ_GetNode(const char *) MAKE_ATTR_USE; |
890 | GNode *Targ_NewInternalNode(const char *) MAKE_ATTR_USE; | | 890 | GNode *Targ_NewInternalNode(const char *) MAKE_ATTR_USE; |
891 | GNode *Targ_GetEndNode(void); | | 891 | GNode *Targ_GetEndNode(void); |
892 | void Targ_FindList(GNodeList *, StringList *); | | 892 | void Targ_FindList(GNodeList *, StringList *); |
893 | void Targ_PrintCmds(GNode *); | | 893 | void Targ_PrintCmds(GNode *); |
894 | void Targ_PrintNode(GNode *, int); | | 894 | void Targ_PrintNode(GNode *, int); |
895 | void Targ_PrintNodes(GNodeList *, int); | | 895 | void Targ_PrintNodes(GNodeList *, int); |
896 | const char *Targ_FmtTime(time_t) MAKE_ATTR_USE; | | 896 | const char *Targ_FmtTime(time_t) MAKE_ATTR_USE; |
897 | void Targ_PrintType(GNodeType); | | 897 | void Targ_PrintType(GNodeType); |
898 | void Targ_PrintGraph(int); | | 898 | void Targ_PrintGraph(int); |
899 | void Targ_Propagate(void); | | 899 | void Targ_Propagate(void); |
900 | const char *GNodeMade_Name(GNodeMade) MAKE_ATTR_USE; | | 900 | const char *GNodeMade_Name(GNodeMade) MAKE_ATTR_USE; |
901 | | | 901 | |
902 | /* var.c */ | | 902 | /* var.c */ |
903 | void Var_Init(void); | | 903 | void Var_Init(void); |
904 | void Var_End(void); | | 904 | void Var_End(void); |
905 | | | 905 | |
906 | typedef enum VarEvalMode { | | 906 | typedef enum VarEvalMode { |
907 | | | 907 | |
908 | /* | | 908 | /* |
909 | * Only parse the expression but don't evaluate any part of it. | | 909 | * Only parse the expression but don't evaluate any part of it. |
910 | * | | 910 | * |
911 | * TODO: Document what Var_Parse and Var_Subst return in this mode. | | 911 | * TODO: Document what Var_Parse and Var_Subst return in this mode. |
912 | * As of 2021-03-15, they return unspecified, inconsistent results. | | 912 | * As of 2021-03-15, they return unspecified, inconsistent results. |
913 | */ | | 913 | */ |
914 | VARE_PARSE_ONLY, | | 914 | VARE_PARSE_ONLY, |
915 | | | 915 | |
916 | /* | | 916 | /* |
917 | * Parse text in which '${...}' and '$(...)' are not parsed as | | 917 | * Parse text in which '${...}' and '$(...)' are not parsed as |
918 | * subexpressions (with all their individual escaping rules) but | | 918 | * subexpressions (with all their individual escaping rules) but |
919 | * instead simply as text with balanced '${}' or '$()'. Other '$' | | 919 | * instead simply as text with balanced '${}' or '$()'. Other '$' |
920 | * are copied verbatim. | | 920 | * are copied verbatim. |
921 | */ | | 921 | */ |
922 | VARE_PARSE_BALANCED, | | 922 | VARE_PARSE_BALANCED, |
923 | | | 923 | |
924 | /* Parse and evaluate the expression. */ | | 924 | /* Parse and evaluate the expression. */ |
925 | VARE_WANTRES, | | 925 | VARE_WANTRES, |
926 | | | 926 | |
927 | /* | | 927 | /* |
928 | * Parse and evaluate the expression. It is an error if a | | 928 | * Parse and evaluate the expression. It is an error if a |
929 | * subexpression evaluates to undefined. | | 929 | * subexpression evaluates to undefined. |
930 | */ | | 930 | */ |
931 | VARE_UNDEFERR, | | 931 | VARE_UNDEFERR, |
932 | | | 932 | |
933 | /* | | 933 | /* |
934 | * Parse and evaluate the expression. Keep '$$' as '$$' instead of | | 934 | * Parse and evaluate the expression. Keep '$$' as '$$' instead of |
935 | * reducing it to a single '$'. Subexpressions that evaluate to | | 935 | * reducing it to a single '$'. Subexpressions that evaluate to |
936 | * undefined expand to an empty string. | | 936 | * undefined expand to an empty string. |
937 | * | | 937 | * |
938 | * Used in variable assignments using the ':=' operator. It allows | | 938 | * Used in variable assignments using the ':=' operator. It allows |
939 | * multiple such assignments to be chained without accidentally | | 939 | * multiple such assignments to be chained without accidentally |
940 | * expanding '$$file' to '$file' in the first assignment and | | 940 | * expanding '$$file' to '$file' in the first assignment and |
941 | * interpreting it as '${f}' followed by 'ile' in the next assignment. | | 941 | * interpreting it as '${f}' followed by 'ile' in the next assignment. |
942 | */ | | 942 | */ |
943 | VARE_EVAL_KEEP_DOLLAR, | | 943 | VARE_EVAL_KEEP_DOLLAR, |
944 | | | 944 | |
945 | /* | | 945 | /* |
946 | * Parse and evaluate the expression. Keep undefined variables as-is | | 946 | * Parse and evaluate the expression. Keep undefined variables as-is |
947 | * instead of expanding them to an empty string. | | 947 | * instead of expanding them to an empty string. |
948 | * | | 948 | * |
949 | * Example for a ':=' assignment: | | 949 | * Example for a ':=' assignment: |
950 | * CFLAGS = $(.INCLUDES) | | 950 | * CFLAGS = $(.INCLUDES) |
951 | * CFLAGS := -I.. $(CFLAGS) | | 951 | * CFLAGS := -I.. $(CFLAGS) |
952 | * # If .INCLUDES (an undocumented special variable, by the | | 952 | * # If .INCLUDES (an undocumented special variable, by the |
953 | * # way) is still undefined, the updated CFLAGS becomes | | 953 | * # way) is still undefined, the updated CFLAGS becomes |
954 | * # "-I.. $(.INCLUDES)". | | 954 | * # "-I.. $(.INCLUDES)". |
955 | */ | | 955 | */ |
956 | VARE_EVAL_KEEP_UNDEF, | | 956 | VARE_EVAL_KEEP_UNDEF, |
957 | | | 957 | |
958 | /* | | 958 | /* |
959 | * Parse and evaluate the expression. Keep '$$' as '$$' and preserve | | 959 | * Parse and evaluate the expression. Keep '$$' as '$$' and preserve |
960 | * undefined subexpressions. | | 960 | * undefined subexpressions. |
961 | */ | | 961 | */ |
962 | VARE_KEEP_DOLLAR_UNDEF | | 962 | VARE_KEEP_DOLLAR_UNDEF |
963 | } VarEvalMode; | | 963 | } VarEvalMode; |
964 | | | 964 | |
965 | typedef enum VarSetFlags { | | 965 | typedef enum VarSetFlags { |
966 | VAR_SET_NONE = 0, | | 966 | VAR_SET_NONE = 0, |
967 | | | 967 | |
968 | /* do not export */ | | 968 | /* do not export */ |
969 | VAR_SET_NO_EXPORT = 1 << 0, | | 969 | VAR_SET_NO_EXPORT = 1 << 0, |
970 | | | 970 | |
971 | /* | | 971 | /* |
972 | * Make the variable read-only. No further modification is possible, | | 972 | * Make the variable read-only. No further modification is possible, |
973 | * except for another call to Var_Set with the same flag. See the | | 973 | * except for another call to Var_Set with the same flag. See the |
974 | * special targets '.NOREADONLY' and '.READONLY'. | | 974 | * special targets '.NOREADONLY' and '.READONLY'. |
975 | */ | | 975 | */ |
976 | VAR_SET_READONLY = 1 << 1 | | 976 | VAR_SET_READONLY = 1 << 1 |
977 | } VarSetFlags; | | 977 | } VarSetFlags; |
978 | | | 978 | |
979 | typedef enum VarExportMode { | | 979 | typedef enum VarExportMode { |
980 | /* .export-env */ | | 980 | /* .export-env */ |
981 | VEM_ENV, | | 981 | VEM_ENV, |
982 | /* .export: Initial export or update an already exported variable. */ | | 982 | /* .export: Initial export or update an already exported variable. */ |
983 | VEM_PLAIN, | | 983 | VEM_PLAIN, |
984 | /* .export-literal: Do not expand the variable value. */ | | 984 | /* .export-literal: Do not expand the variable value. */ |
985 | VEM_LITERAL | | 985 | VEM_LITERAL |
986 | } VarExportMode; | | 986 | } VarExportMode; |
987 | | | 987 | |
988 | void Var_Delete(GNode *, const char *); | | 988 | void Var_Delete(GNode *, const char *); |
989 | void Var_Undef(const char *); | | 989 | void Var_Undef(const char *); |
990 | void Var_Set(GNode *, const char *, const char *); | | 990 | void Var_Set(GNode *, const char *, const char *); |
991 | void Var_SetExpand(GNode *, const char *, const char *); | | 991 | void Var_SetExpand(GNode *, const char *, const char *); |
992 | void Var_SetWithFlags(GNode *, const char *, const char *, VarSetFlags); | | 992 | void Var_SetWithFlags(GNode *, const char *, const char *, VarSetFlags); |
993 | void Var_Append(GNode *, const char *, const char *); | | 993 | void Var_Append(GNode *, const char *, const char *); |
994 | void Var_AppendExpand(GNode *, const char *, const char *); | | 994 | void Var_AppendExpand(GNode *, const char *, const char *); |
995 | bool Var_Exists(GNode *, const char *) MAKE_ATTR_USE; | | 995 | bool Var_Exists(GNode *, const char *) MAKE_ATTR_USE; |
996 | bool Var_ExistsExpand(GNode *, const char *) MAKE_ATTR_USE; | | 996 | bool Var_ExistsExpand(GNode *, const char *) MAKE_ATTR_USE; |
997 | FStr Var_Value(GNode *, const char *) MAKE_ATTR_USE; | | 997 | FStr Var_Value(GNode *, const char *) MAKE_ATTR_USE; |
998 | const char *GNode_ValueDirect(GNode *, const char *) MAKE_ATTR_USE; | | 998 | const char *GNode_ValueDirect(GNode *, const char *) MAKE_ATTR_USE; |
999 | FStr Var_Parse(const char **, GNode *, VarEvalMode); | | 999 | FStr Var_Parse(const char **, GNode *, VarEvalMode); |
1000 | char *Var_Subst(const char *, GNode *, VarEvalMode); | | 1000 | char *Var_Subst(const char *, GNode *, VarEvalMode); |
1001 | void Var_Expand(FStr *, GNode *, VarEvalMode); | | 1001 | void Var_Expand(FStr *, GNode *, VarEvalMode); |
1002 | void Var_Stats(void); | | 1002 | void Var_Stats(void); |
1003 | void Var_Dump(GNode *); | | 1003 | void Var_Dump(GNode *); |
1004 | void Var_ReexportVars(void); | | 1004 | void Var_ReexportVars(void); |
1005 | void Var_Export(VarExportMode, const char *); | | 1005 | void Var_Export(VarExportMode, const char *); |
1006 | void Var_ExportVars(const char *); | | 1006 | void Var_ExportVars(const char *); |
1007 | void Var_UnExport(bool, const char *); | | 1007 | void Var_UnExport(bool, const char *); |
1008 | void Var_ReadOnly(const char *, bool); | | 1008 | void Var_ReadOnly(const char *, bool); |
1009 | | | 1009 | |
1010 | void Global_Set(const char *, const char *); | | 1010 | void Global_Set(const char *, const char *); |
1011 | void Global_Append(const char *, const char *); | | 1011 | void Global_Append(const char *, const char *); |
1012 | void Global_Delete(const char *); | | 1012 | void Global_Delete(const char *); |
1013 | void Global_Set_ReadOnly(const char *, const char *); | | 1013 | void Global_Set_ReadOnly(const char *, const char *); |
1014 | | | 1014 | |
1015 | /* util.c */ | | 1015 | /* util.c */ |
1016 | typedef void (*SignalProc)(int); | | 1016 | typedef void (*SignalProc)(int); |
1017 | SignalProc bmake_signal(int, SignalProc); | | 1017 | SignalProc bmake_signal(int, SignalProc); |
1018 | | | 1018 | |
1019 | /* make.c */ | | 1019 | /* make.c */ |
1020 | void GNode_UpdateYoungestChild(GNode *, GNode *); | | 1020 | void GNode_UpdateYoungestChild(GNode *, GNode *); |
1021 | bool GNode_IsOODate(GNode *) MAKE_ATTR_USE; | | 1021 | bool GNode_IsOODate(GNode *) MAKE_ATTR_USE; |
1022 | void Make_ExpandUse(GNodeList *); | | 1022 | void Make_ExpandUse(GNodeList *); |
1023 | time_t Make_Recheck(GNode *) MAKE_ATTR_USE; | | 1023 | time_t Make_Recheck(GNode *) MAKE_ATTR_USE; |
1024 | void Make_HandleUse(GNode *, GNode *); | | 1024 | void Make_HandleUse(GNode *, GNode *); |
1025 | void Make_Update(GNode *); | | 1025 | void Make_Update(GNode *); |
1026 | void GNode_SetLocalVars(GNode *); | | 1026 | void GNode_SetLocalVars(GNode *); |
1027 | bool Make_Run(GNodeList *); | | 1027 | bool Make_Run(GNodeList *); |
1028 | bool shouldDieQuietly(GNode *, int) MAKE_ATTR_USE; | | 1028 | bool shouldDieQuietly(GNode *, int) MAKE_ATTR_USE; |
1029 | void PrintOnError(GNode *, const char *); | | 1029 | void PrintOnError(GNode *, const char *); |
1030 | void Main_ExportMAKEFLAGS(bool); | | 1030 | void Main_ExportMAKEFLAGS(bool); |
1031 | bool Main_SetObjdir(bool, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3); | | 1031 | bool Main_SetObjdir(bool, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3); |
1032 | int mkTempFile(const char *, char *, size_t) MAKE_ATTR_USE; | | 1032 | int mkTempFile(const char *, char *, size_t) MAKE_ATTR_USE; |
1033 | int str2Lst_Append(StringList *, char *); | | 1033 | int str2Lst_Append(StringList *, char *); |
1034 | void GNode_FprintDetails(FILE *, const char *, const GNode *, const char *); | | 1034 | void GNode_FprintDetails(FILE *, const char *, const GNode *, const char *); |
1035 | bool GNode_ShouldExecute(GNode *gn) MAKE_ATTR_USE; | | 1035 | bool GNode_ShouldExecute(GNode *gn) MAKE_ATTR_USE; |
1036 | | | 1036 | |
1037 | /* See if the node was seen on the left-hand side of a dependency operator. */ | | 1037 | /* See if the node was seen on the left-hand side of a dependency operator. */ |
1038 | MAKE_INLINE bool MAKE_ATTR_USE | | 1038 | MAKE_INLINE bool MAKE_ATTR_USE |
1039 | GNode_IsTarget(const GNode *gn) | | 1039 | GNode_IsTarget(const GNode *gn) |
1040 | { | | 1040 | { |
1041 | return (gn->type & OP_OPMASK) != OP_NONE; | | 1041 | return (gn->type & OP_OPMASK) != OP_NONE; |
1042 | } | | 1042 | } |
1043 | | | 1043 | |
1044 | MAKE_INLINE const char * MAKE_ATTR_USE | | 1044 | MAKE_INLINE const char * MAKE_ATTR_USE |
1045 | GNode_Path(const GNode *gn) | | 1045 | GNode_Path(const GNode *gn) |
1046 | { | | 1046 | { |
1047 | return gn->path != NULL ? gn->path : gn->name; | | 1047 | return gn->path != NULL ? gn->path : gn->name; |
1048 | } | | 1048 | } |
1049 | | | 1049 | |
1050 | MAKE_INLINE bool MAKE_ATTR_USE | | 1050 | MAKE_INLINE bool MAKE_ATTR_USE |
1051 | GNode_IsWaitingFor(const GNode *gn) | | 1051 | GNode_IsWaitingFor(const GNode *gn) |
1052 | { | | 1052 | { |
1053 | return gn->flags.remake && gn->made <= REQUESTED; | | 1053 | return gn->flags.remake && gn->made <= REQUESTED; |
1054 | } | | 1054 | } |
1055 | | | 1055 | |
1056 | MAKE_INLINE bool MAKE_ATTR_USE | | 1056 | MAKE_INLINE bool MAKE_ATTR_USE |
1057 | GNode_IsReady(const GNode *gn) | | 1057 | GNode_IsReady(const GNode *gn) |
1058 | { | | 1058 | { |
1059 | return gn->made > DEFERRED; | | 1059 | return gn->made > DEFERRED; |
1060 | } | | 1060 | } |
1061 | | | 1061 | |
1062 | MAKE_INLINE bool MAKE_ATTR_USE | | 1062 | MAKE_INLINE bool MAKE_ATTR_USE |
1063 | GNode_IsDone(const GNode *gn) | | 1063 | GNode_IsDone(const GNode *gn) |
1064 | { | | 1064 | { |
1065 | return gn->made >= MADE; | | 1065 | return gn->made >= MADE; |
1066 | } | | 1066 | } |
1067 | | | 1067 | |
1068 | MAKE_INLINE bool MAKE_ATTR_USE | | 1068 | MAKE_INLINE bool MAKE_ATTR_USE |
1069 | GNode_IsError(const GNode *gn) | | 1069 | GNode_IsError(const GNode *gn) |
1070 | { | | 1070 | { |
1071 | return gn->made == ERROR || gn->made == ABORTED; | | 1071 | return gn->made == ERROR || gn->made == ABORTED; |
1072 | } | | 1072 | } |
1073 | | | 1073 | |
1074 | MAKE_INLINE bool MAKE_ATTR_USE | | 1074 | MAKE_INLINE bool MAKE_ATTR_USE |
1075 | GNode_IsMainCandidate(const GNode *gn) | | 1075 | GNode_IsMainCandidate(const GNode *gn) |
1076 | { | | 1076 | { |
1077 | return (gn->type & (OP_NOTMAIN | OP_USE | OP_USEBEFORE | | | 1077 | return (gn->type & (OP_NOTMAIN | OP_USE | OP_USEBEFORE | |
1078 | OP_EXEC | OP_TRANSFORM)) == 0; | | 1078 | OP_EXEC | OP_TRANSFORM)) == 0; |
1079 | } | | 1079 | } |
1080 | | | 1080 | |
1081 | /* Return whether the target file should be preserved on interrupt. */ | | 1081 | /* Return whether the target file should be preserved on interrupt. */ |
1082 | MAKE_INLINE bool MAKE_ATTR_USE | | 1082 | MAKE_INLINE bool MAKE_ATTR_USE |
1083 | GNode_IsPrecious(const GNode *gn) | | 1083 | GNode_IsPrecious(const GNode *gn) |
1084 | { | | 1084 | { |
1085 | /* XXX: Why are '::' targets precious? */ | | 1085 | /* XXX: Why are '::' targets precious? */ |
1086 | return allPrecious || gn->type & (OP_PRECIOUS | OP_DOUBLEDEP); | | 1086 | return allPrecious || gn->type & (OP_PRECIOUS | OP_DOUBLEDEP); |
1087 | } | | 1087 | } |
1088 | | | 1088 | |
1089 | MAKE_INLINE const char * MAKE_ATTR_USE | | 1089 | MAKE_INLINE const char * MAKE_ATTR_USE |
1090 | GNode_VarTarget(GNode *gn) { return GNode_ValueDirect(gn, TARGET); } | | 1090 | GNode_VarTarget(GNode *gn) { return GNode_ValueDirect(gn, TARGET); } |
1091 | MAKE_INLINE const char * MAKE_ATTR_USE | | 1091 | MAKE_INLINE const char * MAKE_ATTR_USE |
1092 | GNode_VarOodate(GNode *gn) { return GNode_ValueDirect(gn, OODATE); } | | 1092 | GNode_VarOodate(GNode *gn) { return GNode_ValueDirect(gn, OODATE); } |
1093 | MAKE_INLINE const char * MAKE_ATTR_USE | | 1093 | MAKE_INLINE const char * MAKE_ATTR_USE |
1094 | GNode_VarAllsrc(GNode *gn) { return GNode_ValueDirect(gn, ALLSRC); } | | 1094 | GNode_VarAllsrc(GNode *gn) { return GNode_ValueDirect(gn, ALLSRC); } |
1095 | MAKE_INLINE const char * MAKE_ATTR_USE | | 1095 | MAKE_INLINE const char * MAKE_ATTR_USE |
1096 | GNode_VarImpsrc(GNode *gn) { return GNode_ValueDirect(gn, IMPSRC); } | | 1096 | GNode_VarImpsrc(GNode *gn) { return GNode_ValueDirect(gn, IMPSRC); } |
1097 | MAKE_INLINE const char * MAKE_ATTR_USE | | 1097 | MAKE_INLINE const char * MAKE_ATTR_USE |
1098 | GNode_VarPrefix(GNode *gn) { return GNode_ValueDirect(gn, PREFIX); } | | 1098 | GNode_VarPrefix(GNode *gn) { return GNode_ValueDirect(gn, PREFIX); } |
1099 | MAKE_INLINE const char * MAKE_ATTR_USE | | 1099 | MAKE_INLINE const char * MAKE_ATTR_USE |
1100 | GNode_VarArchive(GNode *gn) { return GNode_ValueDirect(gn, ARCHIVE); } | | 1100 | GNode_VarArchive(GNode *gn) { return GNode_ValueDirect(gn, ARCHIVE); } |
1101 | MAKE_INLINE const char * MAKE_ATTR_USE | | 1101 | MAKE_INLINE const char * MAKE_ATTR_USE |
1102 | GNode_VarMember(GNode *gn) { return GNode_ValueDirect(gn, MEMBER); } | | 1102 | GNode_VarMember(GNode *gn) { return GNode_ValueDirect(gn, MEMBER); } |
1103 | | | 1103 | |
1104 | MAKE_INLINE void * MAKE_ATTR_USE | | 1104 | MAKE_INLINE void * MAKE_ATTR_USE |
1105 | UNCONST(const void *ptr) | | 1105 | UNCONST(const void *ptr) |
1106 | { | | 1106 | { |
1107 | void *ret; | | 1107 | void *ret; |
1108 | memcpy(&ret, &ptr, sizeof(ret)); | | 1108 | memcpy(&ret, &ptr, sizeof(ret)); |
1109 | return ret; | | 1109 | return ret; |
1110 | } | | 1110 | } |
1111 | | | 1111 | |
1112 | /* At least GNU/Hurd systems lack hardcoded MAXPATHLEN/PATH_MAX */ | | 1112 | /* At least GNU/Hurd systems lack hardcoded MAXPATHLEN/PATH_MAX */ |
1113 | #include <limits.h> | | 1113 | #include <limits.h> |
1114 | #ifndef MAXPATHLEN | | 1114 | #ifndef MAXPATHLEN |
1115 | #define MAXPATHLEN 4096 | | 1115 | #define MAXPATHLEN 4096 |
1116 | #endif | | 1116 | #endif |
1117 | #ifndef PATH_MAX | | 1117 | #ifndef PATH_MAX |
1118 | #define PATH_MAX MAXPATHLEN | | 1118 | #define PATH_MAX MAXPATHLEN |
1119 | #endif | | 1119 | #endif |
1120 | | | 1120 | |
1121 | #if defined(SYSV) | | 1121 | #if defined(SYSV) |
1122 | #define KILLPG(pid, sig) kill(-(pid), (sig)) | | 1122 | #define KILLPG(pid, sig) kill(-(pid), (sig)) |
1123 | #else | | 1123 | #else |
1124 | #define KILLPG(pid, sig) killpg((pid), (sig)) | | 1124 | #define KILLPG(pid, sig) killpg((pid), (sig)) |
1125 | #endif | | 1125 | #endif |
1126 | | | 1126 | |
1127 | MAKE_INLINE bool MAKE_ATTR_USE | | 1127 | MAKE_INLINE bool MAKE_ATTR_USE |
1128 | ch_isalnum(char ch) { return isalnum((unsigned char)ch) != 0; } | | 1128 | ch_isalnum(char ch) { return isalnum((unsigned char)ch) != 0; } |
1129 | MAKE_INLINE bool MAKE_ATTR_USE | | 1129 | MAKE_INLINE bool MAKE_ATTR_USE |
1130 | ch_isalpha(char ch) { return isalpha((unsigned char)ch) != 0; } | | 1130 | ch_isalpha(char ch) { return isalpha((unsigned char)ch) != 0; } |
1131 | MAKE_INLINE bool MAKE_ATTR_USE | | 1131 | MAKE_INLINE bool MAKE_ATTR_USE |
1132 | ch_isdigit(char ch) { return isdigit((unsigned char)ch) != 0; } | | 1132 | ch_isdigit(char ch) { return isdigit((unsigned char)ch) != 0; } |
1133 | MAKE_INLINE bool MAKE_ATTR_USE | | 1133 | MAKE_INLINE bool MAKE_ATTR_USE |
1134 | ch_islower(char ch) { return islower((unsigned char)ch) != 0; } | | 1134 | ch_islower(char ch) { return islower((unsigned char)ch) != 0; } |
1135 | MAKE_INLINE bool MAKE_ATTR_USE | | 1135 | MAKE_INLINE bool MAKE_ATTR_USE |
1136 | ch_isspace(char ch) { return isspace((unsigned char)ch) != 0; } | | 1136 | ch_isspace(char ch) { return isspace((unsigned char)ch) != 0; } |
1137 | MAKE_INLINE bool MAKE_ATTR_USE | | 1137 | MAKE_INLINE bool MAKE_ATTR_USE |
1138 | ch_isupper(char ch) { return isupper((unsigned char)ch) != 0; } | | 1138 | ch_isupper(char ch) { return isupper((unsigned char)ch) != 0; } |
1139 | MAKE_INLINE char MAKE_ATTR_USE | | 1139 | MAKE_INLINE char MAKE_ATTR_USE |
1140 | ch_tolower(char ch) { return (char)tolower((unsigned char)ch); } | | 1140 | ch_tolower(char ch) { return (char)tolower((unsigned char)ch); } |
1141 | MAKE_INLINE char MAKE_ATTR_USE | | 1141 | MAKE_INLINE char MAKE_ATTR_USE |
1142 | ch_toupper(char ch) { return (char)toupper((unsigned char)ch); } | | 1142 | ch_toupper(char ch) { return (char)toupper((unsigned char)ch); } |
1143 | | | 1143 | |
1144 | MAKE_INLINE void | | 1144 | MAKE_INLINE void |
1145 | cpp_skip_whitespace(const char **pp) | | 1145 | cpp_skip_whitespace(const char **pp) |
1146 | { | | 1146 | { |
1147 | while (ch_isspace(**pp)) | | 1147 | while (ch_isspace(**pp)) |
1148 | (*pp)++; | | 1148 | (*pp)++; |
1149 | } | | 1149 | } |
1150 | | | 1150 | |
1151 | MAKE_INLINE void | | 1151 | MAKE_INLINE void |
1152 | cpp_skip_hspace(const char **pp) | | 1152 | cpp_skip_hspace(const char **pp) |
1153 | { | | 1153 | { |
1154 | while (**pp == ' ' || **pp == '\t') | | 1154 | while (**pp == ' ' || **pp == '\t') |
1155 | (*pp)++; | | 1155 | (*pp)++; |
1156 | } | | 1156 | } |
1157 | | | 1157 | |
1158 | MAKE_INLINE bool | | 1158 | MAKE_INLINE bool |
1159 | cpp_skip_string(const char **pp, const char *s) | | 1159 | cpp_skip_string(const char **pp, const char *s) |
1160 | { | | 1160 | { |
1161 | const char *p = *pp; | | 1161 | const char *p = *pp; |
1162 | while (*p == *s && *s != '\0') | | 1162 | while (*p == *s && *s != '\0') |
1163 | p++, s++; | | 1163 | p++, s++; |
1164 | if (*s == '\0') | | 1164 | if (*s == '\0') |
1165 | *pp = p; | | 1165 | *pp = p; |
1166 | return *s == '\0'; | | 1166 | return *s == '\0'; |
1167 | } | | 1167 | } |
1168 | | | 1168 | |
1169 | MAKE_INLINE void | | 1169 | MAKE_INLINE void |
1170 | pp_skip_whitespace(char **pp) | | 1170 | pp_skip_whitespace(char **pp) |
1171 | { | | 1171 | { |
1172 | while (ch_isspace(**pp)) | | 1172 | while (ch_isspace(**pp)) |
1173 | (*pp)++; | | 1173 | (*pp)++; |
1174 | } | | 1174 | } |
1175 | | | 1175 | |
1176 | MAKE_INLINE void | | 1176 | MAKE_INLINE void |
1177 | pp_skip_hspace(char **pp) | | 1177 | pp_skip_hspace(char **pp) |
1178 | { | | 1178 | { |
1179 | while (**pp == ' ' || **pp == '\t') | | 1179 | while (**pp == ' ' || **pp == '\t') |
1180 | (*pp)++; | | 1180 | (*pp)++; |
1181 | } | | 1181 | } |
1182 | | | 1182 | |
1183 | #if defined(lint) | | 1183 | #if defined(lint) |
1184 | extern void do_not_define_rcsid(void); /* for lint */ | | 1184 | extern void do_not_define_rcsid(void); /* for lint */ |
1185 | # define MAKE_RCSID(id) extern void do_not_define_rcsid(void) | | 1185 | # define MAKE_RCSID(id) extern void do_not_define_rcsid(void) |
1186 | #elif defined(MAKE_NATIVE) | | 1186 | #elif defined(MAKE_NATIVE) |
1187 | # include <sys/cdefs.h> | | 1187 | # include <sys/cdefs.h> |
1188 | # define MAKE_RCSID(id) __RCSID(id) | | 1188 | # define MAKE_RCSID(id) __RCSID(id) |
1189 | #elif defined(MAKE_ALL_IN_ONE) && defined(__COUNTER__) | | 1189 | #elif defined(MAKE_ALL_IN_ONE) && defined(__COUNTER__) |
1190 | # define MAKE_RCSID_CONCAT(x, y) CONCAT(x, y) | | 1190 | # define MAKE_RCSID_CONCAT(x, y) CONCAT(x, y) |
1191 | # define MAKE_RCSID(id) static volatile char \ | | 1191 | # define MAKE_RCSID(id) static volatile char \ |
1192 | MAKE_RCSID_CONCAT(rcsid_, __COUNTER__)[] = id | | 1192 | MAKE_RCSID_CONCAT(rcsid_, __COUNTER__)[] = id |
1193 | #elif defined(MAKE_ALL_IN_ONE) | | 1193 | #elif defined(MAKE_ALL_IN_ONE) |
1194 | # define MAKE_RCSID(id) extern void do_not_define_rcsid(void) | | 1194 | # define MAKE_RCSID(id) extern void do_not_define_rcsid(void) |
1195 | #else | | 1195 | #else |
1196 | # define MAKE_RCSID(id) static volatile char rcsid[] = id | | 1196 | # define MAKE_RCSID(id) static volatile char rcsid[] = id |
1197 | #endif | | 1197 | #endif |
1198 | | | 1198 | |
1199 | #endif | | 1199 | #endif |