make.h revision 1.164 1 /* $NetBSD: make.h,v 1.164 2020/10/23 18:36:09 rillig Exp $ */
2
3 /*
4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. 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. 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
20 * without specific prior written permission.
21 *
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
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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
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
32 * SUCH DAMAGE.
33 *
34 * from: @(#)make.h 8.3 (Berkeley) 6/13/95
35 */
36
37 /*
38 * Copyright (c) 1989 by Berkeley Softworks
39 * All rights reserved.
40 *
41 * This code is derived from software contributed to Berkeley by
42 * Adam de Boor.
43 *
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
46 * are met:
47 * 1. Redistributions of source code must retain the above copyright
48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 * 3. All advertising materials mentioning features or use of this software
53 * must display the following acknowledgement:
54 * This product includes software developed by the University of
55 * California, Berkeley and 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
58 * without specific prior written permission.
59 *
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
62 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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
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
70 * SUCH DAMAGE.
71 *
72 * from: @(#)make.h 8.3 (Berkeley) 6/13/95
73 */
74
75 /*-
76 * make.h --
77 * The global definitions for pmake
78 */
79
80 #ifndef MAKE_MAKE_H
81 #define MAKE_MAKE_H
82
83 #include <sys/types.h>
84 #include <sys/param.h>
85 #include <sys/stat.h>
86
87 #include <assert.h>
88 #include <ctype.h>
89 #include <fcntl.h>
90 #include <stdarg.h>
91 #include <stdio.h>
92 #include <stdlib.h>
93 #include <string.h>
94 #include <unistd.h>
95
96 #ifdef BSD4_4
97 # include <sys/cdefs.h>
98 #endif
99
100 #ifndef FD_CLOEXEC
101 #define FD_CLOEXEC 1
102 #endif
103
104 #if defined(__GNUC__)
105 #define MAKE_GNUC_PREREQ(x, y) \
106 ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \
107 (__GNUC__ > (x)))
108 #else /* defined(__GNUC__) */
109 #define MAKE_GNUC_PREREQ(x, y) 0
110 #endif /* defined(__GNUC__) */
111
112 #if MAKE_GNUC_PREREQ(2, 7)
113 #define MAKE_ATTR_UNUSED __attribute__((__unused__))
114 #else
115 #define MAKE_ATTR_UNUSED /* delete */
116 #endif
117
118 #if MAKE_GNUC_PREREQ(2, 5)
119 #define MAKE_ATTR_DEAD __attribute__((__noreturn__))
120 #elif defined(__GNUC__)
121 #define MAKE_ATTR_DEAD __volatile
122 #else
123 #define MAKE_ATTR_DEAD /* delete */
124 #endif
125
126 #if MAKE_GNUC_PREREQ(2, 7)
127 #define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) \
128 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
129 #else
130 #define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) /* delete */
131 #endif
132
133 /*
134 * A boolean type is defined as an integer, not an enum, for historic reasons.
135 * The only allowed values are the constants TRUE and FALSE (1 and 0).
136 */
137
138 #ifdef USE_DOUBLE_BOOLEAN
139 /* During development, to find type mismatches in function declarations. */
140 typedef double Boolean;
141 #define TRUE 1.0
142 #define FALSE 0.0
143 #elif defined(USE_UCHAR_BOOLEAN)
144 /* During development, to find code that depends on the exact value of TRUE or
145 * that stores other values in Boolean variables. */
146 typedef unsigned char Boolean;
147 #define TRUE ((unsigned char)0xFF)
148 #define FALSE ((unsigned char)0x00)
149 #elif defined(USE_CHAR_BOOLEAN)
150 /* During development, to find code that uses a boolean as array index, via
151 * -Wchar-subscripts. */
152 typedef char Boolean;
153 #define TRUE ((char)-1)
154 #define FALSE ((char)0x00)
155 #elif defined(USE_ENUM_BOOLEAN)
156 typedef enum Boolean { FALSE, TRUE } Boolean;
157 #else
158 typedef int Boolean;
159 #ifndef TRUE
160 #define TRUE 1
161 #endif
162 #ifndef FALSE
163 #define FALSE 0
164 #endif
165 #endif
166
167 #include "lst.h"
168 #include "enum.h"
169 #include "hash.h"
170 #include "config.h"
171 #include "buf.h"
172 #include "make_malloc.h"
173
174 typedef enum {
175 UNMADE, /* Not examined yet */
176 DEFERRED, /* Examined once (building child) */
177 REQUESTED, /* on toBeMade list */
178 BEINGMADE, /* Target is already being made.
179 * Indicates a cycle in the graph. */
180 MADE, /* Was out-of-date and has been made */
181 UPTODATE, /* Was already up-to-date */
182 ERROR, /* An error occurred while it was being
183 * made (used only in compat mode) */
184 ABORTED /* The target was aborted due to an error
185 * making an inferior (compat). */
186 } GNodeMade;
187
188 /* The OP_ constants are used when parsing a dependency line as a way of
189 * communicating to other parts of the program the way in which a target
190 * should be made.
191 *
192 * Some of the OP_ constants can be combined, others cannot. */
193 typedef enum GNodeType {
194 /* Execution of commands depends on children (:) */
195 OP_DEPENDS = 1 << 0,
196 /* Always execute commands (!) */
197 OP_FORCE = 1 << 1,
198 /* Execution of commands depends on children per line (::) */
199 OP_DOUBLEDEP = 1 << 2,
200
201 /* Matches the dependency operators ':', '!' and '::'. */
202 OP_OPMASK = OP_DEPENDS|OP_FORCE|OP_DOUBLEDEP,
203
204 /* Don't care if the target doesn't exist and can't be created */
205 OP_OPTIONAL = 1 << 3,
206 /* Use associated commands for parents */
207 OP_USE = 1 << 4,
208 /* Target is never out of date, but always execute commands anyway.
209 * Its time doesn't matter, so it has none...sort of */
210 OP_EXEC = 1 << 5,
211 /* Ignore non-zero exit status from shell commands when creating the node */
212 OP_IGNORE = 1 << 6,
213 /* Don't remove the target when interrupted */
214 OP_PRECIOUS = 1 << 7,
215 /* Don't echo commands when executed */
216 OP_SILENT = 1 << 8,
217 /* Target is a recursive make so its commands should always be executed
218 * when it is out of date, regardless of the state of the -n or -t flags */
219 OP_MAKE = 1 << 9,
220 /* Target is out-of-date only if any of its children was out-of-date */
221 OP_JOIN = 1 << 10,
222 /* Assume the children of the node have been already made */
223 OP_MADE = 1 << 11,
224 /* Special .BEGIN, .END, .INTERRUPT */
225 OP_SPECIAL = 1 << 12,
226 /* Like .USE, only prepend commands */
227 OP_USEBEFORE = 1 << 13,
228 /* The node is invisible to its parents. I.e. it doesn't show up in the
229 * parents' local variables. */
230 OP_INVISIBLE = 1 << 14,
231 /* The node is exempt from normal 'main target' processing in parse.c */
232 OP_NOTMAIN = 1 << 15,
233 /* Not a file target; run always */
234 OP_PHONY = 1 << 16,
235 /* Don't search for file in the path */
236 OP_NOPATH = 1 << 17,
237 /* .WAIT phony node */
238 OP_WAIT = 1 << 18,
239 /* .NOMETA do not create a .meta file */
240 OP_NOMETA = 1 << 19,
241 /* .META we _do_ want a .meta file */
242 OP_META = 1 << 20,
243 /* Do not compare commands in .meta file */
244 OP_NOMETA_CMP = 1 << 21,
245 /* Possibly a submake node */
246 OP_SUBMAKE = 1 << 22,
247
248 /* Attributes applied by PMake */
249
250 /* The node is a transformation rule */
251 OP_TRANSFORM = 1 << 31,
252 /* Target is a member of an archive */
253 OP_MEMBER = 1 << 30,
254 /* Target is a library;
255 * the node's name has the form "-l<libname>" */
256 OP_LIB = 1 << 29,
257 /* Target is an archive construct;
258 * the node's name has the form "archive(member)" */
259 OP_ARCHV = 1 << 28,
260 /* Target has all the commands it should. Used when parsing to catch
261 * multiple command groups for a target. Only applies to the dependency
262 * operators ':' and '!', but not to '::'. */
263 OP_HAS_COMMANDS = 1 << 27,
264 /* The special command "..." has been seen. All further commands from
265 * this node will be saved on the .END node instead, to be executed at
266 * the very end. */
267 OP_SAVE_CMDS = 1 << 26,
268 /* Already processed by Suff_FindDeps */
269 OP_DEPS_FOUND = 1 << 25,
270 /* Node found while expanding .ALLSRC */
271 OP_MARK = 1 << 24,
272
273 OP_NOTARGET = OP_NOTMAIN | OP_USE | OP_EXEC | OP_TRANSFORM
274 } GNodeType;
275
276 typedef enum GNodeFlags {
277 REMAKE = 0x0001, /* this target needs to be (re)made */
278 CHILDMADE = 0x0002, /* children of this target were made */
279 FORCE = 0x0004, /* children don't exist, and we pretend made */
280 DONE_WAIT = 0x0008, /* Set by Make_ProcessWait() */
281 DONE_ORDER = 0x0010, /* Build requested by .ORDER processing */
282 FROM_DEPEND = 0x0020, /* Node created from .depend */
283 DONE_ALLSRC = 0x0040, /* We do it once only */
284 CYCLE = 0x1000, /* Used by MakePrintStatus */
285 DONECYCLE = 0x2000, /* Used by MakePrintStatus */
286 INTERNAL = 0x4000 /* Internal use only */
287 } GNodeFlags;
288
289 typedef struct List StringList;
290 typedef struct ListNode StringListNode;
291
292 typedef struct List GNodeList;
293 typedef struct ListNode GNodeListNode;
294
295 typedef struct List /* of CachedDir */ SearchPath;
296
297 /* A graph node represents a target that can possibly be made, including its
298 * relation to other targets and a lot of other details. */
299 typedef struct GNode {
300 /* The target's name, such as "clean" or "make.c" */
301 char *name;
302 /* The unexpanded name of a .USE node */
303 char *uname;
304 /* The full pathname of the file belonging to the target.
305 * XXX: What about .PHONY targets? These don't have an associated path. */
306 char *path;
307
308 /* The type of operator used to define the sources (see the OP flags below).
309 * XXX: This looks like a wild mixture of type and flags. */
310 GNodeType type;
311 GNodeFlags flags;
312
313 /* The state of processing on this node */
314 GNodeMade made;
315 int unmade; /* The number of unmade children */
316
317 /* The modification time; 0 means the node does not have a corresponding
318 * file; see Make_OODate. */
319 time_t mtime;
320 struct GNode *cmgn; /* The youngest child */
321
322 /* The GNodes for which this node is an implied source. May be empty.
323 * For example, when there is an inference rule for .c.o, the node for
324 * file.c has the node for file.o in this list. */
325 GNodeList *implicitParents;
326
327 /* Other nodes of the same name, for the '::' operator. */
328 GNodeList *cohorts;
329
330 /* The nodes that depend on this one, or in other words, the nodes for
331 * which this is a source. */
332 GNodeList *parents;
333 /* The nodes on which this one depends. */
334 GNodeList *children;
335
336 /* .ORDER nodes we need made. The nodes that must be made (if they're
337 * made) before this node can be made, but that do not enter into the
338 * datedness of this node. */
339 GNodeList *order_pred;
340 /* .ORDER nodes who need us. The nodes that must be made (if they're made
341 * at all) after this node is made, but that do not depend on this node,
342 * in the normal sense. */
343 GNodeList *order_succ;
344
345 /* The "#n" suffix for this cohort, or "" for other nodes */
346 char cohort_num[8];
347 /* The number of unmade instances on the cohorts list */
348 int unmade_cohorts;
349 /* Pointer to the first instance of a '::' node; only set when on a
350 * cohorts list */
351 struct GNode *centurion;
352
353 /* Last time (sequence number) we tried to make this node */
354 unsigned int checked_seqno;
355
356 /* The "local" variables that are specific to this target and this target
357 * only, such as $@, $<, $?.
358 *
359 * Also used for the global variable scopes VAR_GLOBAL, VAR_CMD,
360 * VAR_INTERNAL, which contain variables with arbitrary names. */
361 HashTable context;
362
363 /* The commands to be given to a shell to create this target. */
364 StringList *commands;
365
366 /* Suffix for the node (determined by Suff_FindDeps and opaque to everyone
367 * but the Suff module) */
368 struct Suff *suffix;
369
370 /* filename where the GNode got defined */
371 const char *fname;
372 /* line number where the GNode got defined */
373 int lineno;
374 } GNode;
375
376 /*
377 * Error levels for parsing. PARSE_FATAL means the process cannot continue
378 * once the makefile has been parsed. PARSE_WARNING means it can. Passed
379 * as the first argument to Parse_Error.
380 */
381 #define PARSE_INFO 3
382 #define PARSE_WARNING 2
383 #define PARSE_FATAL 1
384
385 /*
386 * Values returned by Cond_EvalLine and Cond_EvalCondition.
387 */
388 typedef enum CondEvalResult {
389 COND_PARSE, /* Parse the next lines */
390 COND_SKIP, /* Skip the next lines */
391 COND_INVALID /* Not a conditional statement */
392 } CondEvalResult;
393
394 /*
395 * Definitions for the "local" variables. Used only for clarity.
396 */
397 #define TARGET "@" /* Target of dependency */
398 #define OODATE "?" /* All out-of-date sources */
399 #define ALLSRC ">" /* All sources */
400 #define IMPSRC "<" /* Source implied by transformation */
401 #define PREFIX "*" /* Common prefix */
402 #define ARCHIVE "!" /* Archive in "archive(member)" syntax */
403 #define MEMBER "%" /* Member in "archive(member)" syntax */
404
405 #define FTARGET "@F" /* file part of TARGET */
406 #define DTARGET "@D" /* directory part of TARGET */
407 #define FIMPSRC "<F" /* file part of IMPSRC */
408 #define DIMPSRC "<D" /* directory part of IMPSRC */
409 #define FPREFIX "*F" /* file part of PREFIX */
410 #define DPREFIX "*D" /* directory part of PREFIX */
411
412 /*
413 * Global Variables
414 */
415 extern StringList *create; /* The list of target names specified on the
416 * command line. used to resolve #if
417 * make(...) statements */
418 extern SearchPath *dirSearchPath;
419 /* The list of directories to search when
420 * looking for targets */
421
422 extern Boolean compatMake; /* True if we are make compatible */
423 extern Boolean ignoreErrors; /* True if should ignore all errors */
424 extern Boolean beSilent; /* True if should print no commands */
425 extern Boolean noExecute; /* True if should execute nothing */
426 extern Boolean noRecursiveExecute;
427 /* True if should execute nothing */
428 extern Boolean allPrecious; /* True if every target is precious */
429 extern Boolean deleteOnError; /* True if failed targets should be deleted */
430 extern Boolean keepgoing; /* True if should continue on unaffected
431 * portions of the graph when have an error
432 * in one portion */
433 extern Boolean touchFlag; /* TRUE if targets should just be 'touched'
434 * if out of date. Set by the -t flag */
435 extern Boolean queryFlag; /* TRUE if we aren't supposed to really make
436 * anything, just see if the targets are out-
437 * of-date */
438 extern Boolean doing_depend; /* TRUE if processing .depend */
439
440 extern Boolean checkEnvFirst; /* TRUE if environment should be searched for
441 * variables before the global context */
442
443 extern Boolean parseWarnFatal; /* TRUE if makefile parsing warnings are
444 * treated as errors */
445
446 extern Boolean varNoExportEnv; /* TRUE if we should not export variables
447 * set on the command line to the env. */
448
449 extern GNode *DEFAULT; /* .DEFAULT rule */
450
451 extern GNode *VAR_INTERNAL; /* Variables defined internally by make
452 * which should not override those set by
453 * makefiles.
454 */
455 extern GNode *VAR_GLOBAL; /* Variables defined in a global context, e.g
456 * in the Makefile itself */
457 extern GNode *VAR_CMD; /* Variables defined on the command line */
458 extern char var_Error[]; /* Value returned by Var_Parse when an error
459 * is encountered. It actually points to
460 * an empty string, so naive callers needn't
461 * worry about it. */
462
463 extern time_t now; /* The time at the start of this whole
464 * process */
465
466 extern Boolean oldVars; /* Do old-style variable substitution */
467
468 extern SearchPath *sysIncPath; /* The system include path. */
469 extern SearchPath *defIncPath; /* The default include path. */
470
471 extern char curdir[]; /* Startup directory */
472 extern char *progname; /* The program name */
473 extern char *makeDependfile; /* .depend */
474 extern char **savedEnv; /* if we replaced environ this will be non-NULL */
475
476 extern int makelevel;
477
478 /*
479 * We cannot vfork() in a child of vfork().
480 * Most systems do not enforce this but some do.
481 */
482 #define vFork() ((getpid() == myPid) ? vfork() : fork())
483 extern pid_t myPid;
484
485 #define MAKEFLAGS ".MAKEFLAGS"
486 #define MAKEOVERRIDES ".MAKEOVERRIDES"
487 #define MAKE_JOB_PREFIX ".MAKE.JOB.PREFIX" /* prefix for job target output */
488 #define MAKE_EXPORTED ".MAKE.EXPORTED" /* variables we export */
489 #define MAKE_MAKEFILES ".MAKE.MAKEFILES" /* all makefiles already loaded */
490 #define MAKE_LEVEL ".MAKE.LEVEL" /* recursion level */
491 #define MAKEFILE_PREFERENCE ".MAKE.MAKEFILE_PREFERENCE"
492 #define MAKE_DEPENDFILE ".MAKE.DEPENDFILE" /* .depend */
493 #define MAKE_MODE ".MAKE.MODE"
494 #ifndef MAKE_LEVEL_ENV
495 # define MAKE_LEVEL_ENV "MAKELEVEL"
496 #endif
497
498 /*
499 * debug control:
500 * There is one bit per module. It is up to the module what debug
501 * information to print.
502 */
503 extern FILE *debug_file; /* Output is written here - default stderr */
504 extern int debug;
505 #define DEBUG_ARCH 0x00001
506 #define DEBUG_COND 0x00002
507 #define DEBUG_DIR 0x00004
508 #define DEBUG_GRAPH1 0x00008
509 #define DEBUG_GRAPH2 0x00010
510 #define DEBUG_JOB 0x00020
511 #define DEBUG_MAKE 0x00040
512 #define DEBUG_SUFF 0x00080
513 #define DEBUG_TARG 0x00100
514 #define DEBUG_VAR 0x00200
515 #define DEBUG_FOR 0x00400
516 #define DEBUG_SHELL 0x00800
517 #define DEBUG_ERROR 0x01000
518 #define DEBUG_LOUD 0x02000
519 #define DEBUG_META 0x04000
520 #define DEBUG_HASH 0x08000
521
522 #define DEBUG_GRAPH3 0x10000
523 #define DEBUG_SCRIPT 0x20000
524 #define DEBUG_PARSE 0x40000
525 #define DEBUG_CWD 0x80000
526
527 #define DEBUG_LINT 0x100000
528
529 #define CONCAT(a,b) a##b
530
531 #define DEBUG(module) (debug & CONCAT(DEBUG_,module))
532
533 void debug_printf(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);
534
535 #define DEBUG0(module, text) \
536 if (!DEBUG(module)) (void)0; \
537 else debug_printf("%s", text)
538
539 #define DEBUG1(module, fmt, arg1) \
540 if (!DEBUG(module)) (void)0; \
541 else debug_printf(fmt, arg1)
542
543 #define DEBUG2(module, fmt, arg1, arg2) \
544 if (!DEBUG(module)) (void)0; \
545 else debug_printf(fmt, arg1, arg2)
546
547 #define DEBUG3(module, fmt, arg1, arg2, arg3) \
548 if (!DEBUG(module)) (void)0; \
549 else debug_printf(fmt, arg1, arg2, arg3)
550
551 #define DEBUG4(module, fmt, arg1, arg2, arg3, arg4) \
552 if (!DEBUG(module)) (void)0; \
553 else debug_printf(fmt, arg1, arg2, arg3, arg4)
554
555 #define DEBUG5(module, fmt, arg1, arg2, arg3, arg4, arg5) \
556 if (!DEBUG(module)) (void)0; \
557 else debug_printf(fmt, arg1, arg2, arg3, arg4, arg5)
558
559 #include "nonints.h"
560
561 void Make_TimeStamp(GNode *, GNode *);
562 Boolean Make_OODate(GNode *);
563 void Make_ExpandUse(GNodeList *);
564 time_t Make_Recheck(GNode *);
565 void Make_HandleUse(GNode *, GNode *);
566 void Make_Update(GNode *);
567 void Make_DoAllVar(GNode *);
568 Boolean Make_Run(GNodeList *);
569 int dieQuietly(GNode *, int);
570 void PrintOnError(GNode *, const char *);
571 void Main_ExportMAKEFLAGS(Boolean);
572 Boolean Main_SetObjdir(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);
573 int mkTempFile(const char *, char **);
574 int str2Lst_Append(StringList *, char *, const char *);
575 void GNode_FprintDetails(FILE *, const char *, const GNode *, const char *);
576 Boolean NoExecute(GNode *gn);
577
578 /* See if the node was seen on the left-hand side of a dependency operator. */
579 static Boolean MAKE_ATTR_UNUSED
580 GNode_IsTarget(const GNode *gn)
581 {
582 return (gn->type & OP_OPMASK) != 0;
583 }
584
585 #ifdef __GNUC__
586 #define UNCONST(ptr) ({ \
587 union __unconst { \
588 const void *__cp; \
589 void *__p; \
590 } __d; \
591 __d.__cp = ptr, __d.__p; })
592 #else
593 #define UNCONST(ptr) (void *)(ptr)
594 #endif
595
596 #ifndef MIN
597 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
598 #endif
599 #ifndef MAX
600 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
601 #endif
602
603 /* At least GNU/Hurd systems lack hardcoded MAXPATHLEN/PATH_MAX */
604 #include <limits.h>
605 #ifndef MAXPATHLEN
606 #define MAXPATHLEN 4096
607 #endif
608 #ifndef PATH_MAX
609 #define PATH_MAX MAXPATHLEN
610 #endif
611
612 #if defined(SYSV)
613 #define KILLPG(pid, sig) kill(-(pid), (sig))
614 #else
615 #define KILLPG(pid, sig) killpg((pid), (sig))
616 #endif
617
618 static inline MAKE_ATTR_UNUSED Boolean ch_isalnum(char ch)
619 { return isalnum((unsigned char)ch) != 0; }
620 static inline MAKE_ATTR_UNUSED Boolean ch_isalpha(char ch)
621 { return isalpha((unsigned char)ch) != 0; }
622 static inline MAKE_ATTR_UNUSED Boolean ch_isdigit(char ch)
623 { return isdigit((unsigned char)ch) != 0; }
624 static inline MAKE_ATTR_UNUSED Boolean ch_isspace(char ch)
625 { return isspace((unsigned char)ch) != 0; }
626 static inline MAKE_ATTR_UNUSED Boolean ch_isupper(char ch)
627 { return isupper((unsigned char)ch) != 0; }
628 static inline MAKE_ATTR_UNUSED char ch_tolower(char ch)
629 { return (char)tolower((unsigned char)ch); }
630 static inline MAKE_ATTR_UNUSED char ch_toupper(char ch)
631 { return (char)toupper((unsigned char)ch); }
632
633 static inline MAKE_ATTR_UNUSED void
634 cpp_skip_whitespace(const char **pp)
635 {
636 while (ch_isspace(**pp))
637 (*pp)++;
638 }
639
640 static inline MAKE_ATTR_UNUSED void
641 pp_skip_whitespace(char **pp)
642 {
643 while (ch_isspace(**pp))
644 (*pp)++;
645 }
646
647 #ifdef MAKE_NATIVE
648 # include <sys/cdefs.h>
649 # ifndef lint
650 # define MAKE_RCSID(id) __RCSID(id)
651 # endif
652 #else
653 # define MAKE_RCSID(id) static volatile char rcsid[] = id
654 #endif
655
656 #endif /* MAKE_MAKE_H */
657