]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bmake/make.h
Update to bmake-20200902
[FreeBSD/FreeBSD.git] / contrib / bmake / make.h
1 /*      $NetBSD: make.h,v 1.137 2020/09/02 23:42:58 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 #ifdef HAVE_CONFIG_H
84 # include "config.h"
85 #endif
86
87 #include <sys/types.h>
88 #include <sys/param.h>
89 #include <sys/stat.h>
90
91 #include <assert.h>
92 #include <ctype.h>
93 #include <fcntl.h>
94 #include <stdio.h>
95 #include <stdlib.h>
96 #ifdef HAVE_STRING_H
97 #include <string.h>
98 #else
99 #include <strings.h>
100 #endif
101 #include <unistd.h>
102 #include <sys/cdefs.h>
103
104 #ifndef FD_CLOEXEC
105 #define FD_CLOEXEC 1
106 #endif
107
108 #if defined(__GNUC__)
109 #define MAKE_GNUC_PREREQ(x, y)                                          \
110         ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) ||                  \
111          (__GNUC__ > (x)))
112 #else /* defined(__GNUC__) */
113 #define MAKE_GNUC_PREREQ(x, y)  0
114 #endif /* defined(__GNUC__) */
115
116 #if MAKE_GNUC_PREREQ(2, 7)
117 #define MAKE_ATTR_UNUSED        __attribute__((__unused__))
118 #else
119 #define MAKE_ATTR_UNUSED        /* delete */
120 #endif
121
122 #if MAKE_GNUC_PREREQ(2, 5)
123 #define MAKE_ATTR_DEAD          __attribute__((__noreturn__))
124 #elif defined(__GNUC__)
125 #define MAKE_ATTR_DEAD          __volatile
126 #else
127 #define MAKE_ATTR_DEAD          /* delete */
128 #endif
129
130 #if MAKE_GNUC_PREREQ(2, 7)
131 #define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg)       \
132             __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
133 #else
134 #define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg)       /* delete */
135 #endif
136
137 /*
138  * A boolean type is defined as an integer, not an enum, for historic reasons.
139  * The only allowed values are the constants TRUE and FALSE (1 and 0).
140  */
141
142 #ifdef USE_DOUBLE_BOOLEAN
143 /* During development, to find type mismatches in function declarations. */
144 typedef double Boolean;
145 #elif defined(USE_UCHAR_BOOLEAN)
146 /* During development, to find code that depends on the exact value of TRUE or
147  * that stores other values in Boolean variables. */
148 typedef unsigned char Boolean;
149 #define TRUE ((unsigned char)0xFF)
150 #define FALSE ((unsigned char)0x00)
151 #elif defined(USE_ENUM_BOOLEAN)
152 typedef enum { FALSE, TRUE} Boolean;
153 #else
154 typedef int Boolean;
155 #endif
156 #ifndef TRUE
157 #define TRUE    1
158 #endif /* TRUE */
159 #ifndef FALSE
160 #define FALSE   0
161 #endif /* FALSE */
162
163 #include "lst.h"
164 #include "enum.h"
165 #include "hash.h"
166 #include "make-conf.h"
167 #include "buf.h"
168 #include "make_malloc.h"
169
170 /*
171  * some vendors don't have this --sjg
172  */
173 #if defined(S_IFDIR) && !defined(S_ISDIR)
174 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
175 #endif
176
177 #if defined(sun) && (defined(__svr4__) || defined(__SVR4))
178 #define POSIX_SIGNALS
179 #endif
180
181 typedef enum  {
182     UNMADE,                     /* Not examined yet */
183     DEFERRED,                   /* Examined once (building child) */
184     REQUESTED,                  /* on toBeMade list */
185     BEINGMADE,                  /* Target is already being made.
186                                  * Indicates a cycle in the graph. */
187     MADE,                       /* Was out-of-date and has been made */
188     UPTODATE,                   /* Was already up-to-date */
189     ERROR,                      /* An error occurred while it was being
190                                  * made (used only in compat mode) */
191     ABORTED                     /* The target was aborted due to an error
192                                  * making an inferior (compat). */
193 } GNodeMade;
194
195 /* The OP_ constants are used when parsing a dependency line as a way of
196  * communicating to other parts of the program the way in which a target
197  * should be made.
198  *
199  * These constants are bitwise-OR'ed together and placed in the 'type' field
200  * of each node. Any node that has a 'type' field which satisfies the OP_NOP
201  * function was never never on the left-hand side of an operator, though it
202  * may have been on the right-hand side... */
203 typedef enum {
204     /* Execution of commands depends on children (:) */
205     OP_DEPENDS          = 1 << 0,
206     /* Always execute commands (!) */
207     OP_FORCE            = 1 << 1,
208     /* Execution of commands depends on children per line (::) */
209     OP_DOUBLEDEP        = 1 << 2,
210
211     OP_OPMASK           = OP_DEPENDS|OP_FORCE|OP_DOUBLEDEP,
212
213     /* Don't care if the target doesn't exist and can't be created */
214     OP_OPTIONAL         = 1 << 3,
215     /* Use associated commands for parents */
216     OP_USE              = 1 << 4,
217     /* Target is never out of date, but always execute commands anyway.
218      * Its time doesn't matter, so it has none...sort of */
219     OP_EXEC             = 1 << 5,
220     /* Ignore errors when creating the node */
221     OP_IGNORE           = 1 << 6,
222     /* Don't remove the target when interrupted */
223     OP_PRECIOUS         = 1 << 7,
224     /* Don't echo commands when executed */
225     OP_SILENT           = 1 << 8,
226     /* Target is a recursive make so its commands should always be executed
227      * when it is out of date, regardless of the state of the -n or -t flags */
228     OP_MAKE             = 1 << 9,
229     /* Target is out-of-date only if any of its children was out-of-date */
230     OP_JOIN             = 1 << 10,
231     /* Assume the children of the node have been already made */
232     OP_MADE             = 1 << 11,
233     /* Special .BEGIN, .END, .INTERRUPT */
234     OP_SPECIAL          = 1 << 12,
235     /* Like .USE, only prepend commands */
236     OP_USEBEFORE        = 1 << 13,
237     /* The node is invisible to its parents. I.e. it doesn't show up in the
238      * parents' local variables. */
239     OP_INVISIBLE        = 1 << 14,
240     /* The node is exempt from normal 'main target' processing in parse.c */
241     OP_NOTMAIN          = 1 << 15,
242     /* Not a file target; run always */
243     OP_PHONY            = 1 << 16,
244     /* Don't search for file in the path */
245     OP_NOPATH           = 1 << 17,
246     /* .WAIT phony node */
247     OP_WAIT             = 1 << 18,
248     /* .NOMETA do not create a .meta file */
249     OP_NOMETA           = 1 << 19,
250     /* .META we _do_ want a .meta file */
251     OP_META             = 1 << 20,
252     /* Do not compare commands in .meta file */
253     OP_NOMETA_CMP       = 1 << 21,
254     /* Possibly a submake node */
255     OP_SUBMAKE          = 1 << 22,
256
257     /* Attributes applied by PMake */
258
259     /* The node is a transformation rule */
260     OP_TRANSFORM        = 1 << 31,
261     /* Target is a member of an archive */
262     OP_MEMBER           = 1 << 30,
263     /* Target is a library */
264     OP_LIB              = 1 << 29,
265     /* Target is an archive construct */
266     OP_ARCHV            = 1 << 28,
267     /* Target has all the commands it should. Used when parsing to catch
268      * multiple commands for a target. */
269     OP_HAS_COMMANDS     = 1 << 27,
270     /* Saving commands on .END (Compat) */
271     OP_SAVE_CMDS        = 1 << 26,
272     /* Already processed by Suff_FindDeps */
273     OP_DEPS_FOUND       = 1 << 25,
274     /* Node found while expanding .ALLSRC */
275     OP_MARK             = 1 << 24
276 } GNodeType;
277
278 typedef enum {
279     REMAKE      = 0x0001,       /* this target needs to be (re)made */
280     CHILDMADE   = 0x0002,       /* children of this target were made */
281     FORCE       = 0x0004,       /* children don't exist, and we pretend made */
282     DONE_WAIT   = 0x0008,       /* Set by Make_ProcessWait() */
283     DONE_ORDER  = 0x0010,       /* Build requested by .ORDER processing */
284     FROM_DEPEND = 0x0020,       /* Node created from .depend */
285     DONE_ALLSRC = 0x0040,       /* We do it once only */
286     CYCLE       = 0x1000,       /* Used by MakePrintStatus */
287     DONECYCLE   = 0x2000,       /* Used by MakePrintStatus */
288     INTERNAL    = 0x4000        /* Internal use only */
289 } GNodeFlags;
290
291 /* A graph node represents a target that can possibly be made, including its
292  * relation to other targets and a lot of other details. */
293 typedef struct GNode {
294     /* The target's name, such as "clean" or "make.c" */
295     char *name;
296     /* The unexpanded name of a .USE node */
297     char *uname;
298     /* The full pathname of the file belonging to the target.
299      * XXX: What about .PHONY targets? These don't have an associated path. */
300     char *path;
301
302     /* The type of operator used to define the sources (see the OP flags below).
303      * XXX: This looks like a wild mixture of type and flags. */
304     GNodeType type;
305     /* whether it is involved in this invocation of make */
306     GNodeFlags flags;
307
308     /* The state of processing on this node */
309     GNodeMade made;
310     int unmade;                 /* The number of unmade children */
311
312     time_t mtime;               /* Its modification time */
313     struct GNode *cmgn;         /* The youngest child */
314
315     /* The GNodes for which this node is an implied source. May be empty.
316      * For example, when there is an inference rule for .c.o, the node for
317      * file.c has the node for file.o in this list. */
318     Lst implicitParents;
319
320     /* Other nodes of the same name for the :: operator. */
321     Lst cohorts;
322
323     /* The nodes that depend on this one, or in other words, the nodes for
324      * which this is a source. */
325     Lst parents;
326     /* The nodes on which this one depends. */
327     Lst children;
328
329     /* .ORDER nodes we need made. The nodes that must be made (if they're
330      * made) before this node can be made, but that do not enter into the
331      * datedness of this node. */
332     Lst order_pred;
333     /* .ORDER nodes who need us. The nodes that must be made (if they're made
334      * at all) after this node is made, but that do not depend on this node,
335      * in the normal sense. */
336     Lst order_succ;
337
338     /* #n for this cohort */
339     char cohort_num[8];
340     /* The number of unmade instances on the cohorts list */
341     int unmade_cohorts;
342     /* Pointer to the first instance of a '::' node; only set when on a
343      * cohorts list */
344     struct GNode *centurion;
345
346     /* Last time (sequence number) we tried to make this node */
347     unsigned int checked;
348
349     /* The "local" variables that are specific to this target and this target
350      * only, such as $@, $<, $?. */
351     Hash_Table context;
352
353     /* The commands to be given to a shell to create this target. */
354     Lst commands;
355
356     /* Suffix for the node (determined by Suff_FindDeps and opaque to everyone
357      * but the Suff module) */
358     struct Suff *suffix;
359
360     /* filename where the GNode got defined */
361     const char *fname;
362     /* line number where the GNode got defined */
363     int lineno;
364 } GNode;
365
366 #define NoExecute(gn) ((gn->type & OP_MAKE) ? noRecursiveExecute : noExecute)
367 /*
368  * OP_NOP will return TRUE if the node with the given type was not the
369  * object of a dependency operator
370  */
371 #define OP_NOP(t)       (((t) & OP_OPMASK) == 0x00000000)
372
373 #define OP_NOTARGET (OP_NOTMAIN|OP_USE|OP_EXEC|OP_TRANSFORM)
374
375 /*
376  * The TARG_ constants are used when calling the Targ_FindNode and
377  * Targ_FindList functions in targ.c. They simply tell the functions what to
378  * do if the desired node(s) is (are) not found. If the TARG_CREATE constant
379  * is given, a new, empty node will be created for the target, placed in the
380  * table of all targets and its address returned. If TARG_NOCREATE is given,
381  * a NULL pointer will be returned.
382  */
383 #define TARG_NOCREATE   0x00      /* don't create it */
384 #define TARG_CREATE     0x01      /* create node if not found */
385 #define TARG_NOHASH     0x02      /* don't look in/add to hash table */
386
387 /*
388  * Error levels for parsing. PARSE_FATAL means the process cannot continue
389  * once the makefile has been parsed. PARSE_WARNING means it can. Passed
390  * as the first argument to Parse_Error.
391  */
392 #define PARSE_INFO      3
393 #define PARSE_WARNING   2
394 #define PARSE_FATAL     1
395
396 /*
397  * Values returned by Cond_Eval.
398  */
399 typedef enum {
400     COND_PARSE,                 /* Parse the next lines */
401     COND_SKIP,                  /* Skip the next lines */
402     COND_INVALID                /* Not a conditional statement */
403 } CondEvalResult;
404
405 /*
406  * Definitions for the "local" variables. Used only for clarity.
407  */
408 #define TARGET            "@"   /* Target of dependency */
409 #define OODATE            "?"   /* All out-of-date sources */
410 #define ALLSRC            ">"   /* All sources */
411 #define IMPSRC            "<"   /* Source implied by transformation */
412 #define PREFIX            "*"   /* Common prefix */
413 #define ARCHIVE           "!"   /* Archive in "archive(member)" syntax */
414 #define MEMBER            "%"   /* Member in "archive(member)" syntax */
415
416 #define FTARGET           "@F"  /* file part of TARGET */
417 #define DTARGET           "@D"  /* directory part of TARGET */
418 #define FIMPSRC           "<F"  /* file part of IMPSRC */
419 #define DIMPSRC           "<D"  /* directory part of IMPSRC */
420 #define FPREFIX           "*F"  /* file part of PREFIX */
421 #define DPREFIX           "*D"  /* directory part of PREFIX */
422
423 /*
424  * Global Variables
425  */
426 extern Lst      create;         /* The list of target names specified on the
427                                  * command line. used to resolve #if
428                                  * make(...) statements */
429 extern Lst      dirSearchPath;  /* The list of directories to search when
430                                  * looking for targets */
431
432 extern Boolean  compatMake;     /* True if we are make compatible */
433 extern Boolean  ignoreErrors;   /* True if should ignore all errors */
434 extern Boolean  beSilent;       /* True if should print no commands */
435 extern Boolean  noExecute;      /* True if should execute nothing */
436 extern Boolean  noRecursiveExecute;     /* True if should execute nothing */
437 extern Boolean  allPrecious;    /* True if every target is precious */
438 extern Boolean  deleteOnError;  /* True if failed targets should be deleted */
439 extern Boolean  keepgoing;      /* True if should continue on unaffected
440                                  * portions of the graph when have an error
441                                  * in one portion */
442 extern Boolean  touchFlag;      /* TRUE if targets should just be 'touched'
443                                  * if out of date. Set by the -t flag */
444 extern Boolean  queryFlag;      /* TRUE if we aren't supposed to really make
445                                  * anything, just see if the targets are out-
446                                  * of-date */
447 extern Boolean  doing_depend;   /* TRUE if processing .depend */
448
449 extern Boolean  checkEnvFirst;  /* TRUE if environment should be searched for
450                                  * variables before the global context */
451
452 extern Boolean  parseWarnFatal; /* TRUE if makefile parsing warnings are
453                                  * treated as errors */
454
455 extern Boolean  varNoExportEnv; /* TRUE if we should not export variables
456                                  * set on the command line to the env. */
457
458 extern GNode    *DEFAULT;       /* .DEFAULT rule */
459
460 extern GNode    *VAR_INTERNAL;  /* Variables defined internally by make
461                                  * which should not override those set by
462                                  * makefiles.
463                                  */
464 extern GNode    *VAR_GLOBAL;    /* Variables defined in a global context, e.g
465                                  * in the Makefile itself */
466 extern GNode    *VAR_CMD;       /* Variables defined on the command line */
467 extern char     var_Error[];    /* Value returned by Var_Parse when an error
468                                  * is encountered. It actually points to
469                                  * an empty string, so naive callers needn't
470                                  * worry about it. */
471
472 extern time_t   now;            /* The time at the start of this whole
473                                  * process */
474
475 extern Boolean  oldVars;        /* Do old-style variable substitution */
476
477 extern Lst      sysIncPath;     /* The system include path. */
478 extern Lst      defIncPath;     /* The default include path. */
479
480 extern char     curdir[];       /* Startup directory */
481 extern char     *progname;      /* The program name */
482 extern char     *makeDependfile; /* .depend */
483 extern char     **savedEnv;      /* if we replaced environ this will be non-NULL */
484
485 extern int      makelevel;
486
487 /*
488  * We cannot vfork() in a child of vfork().
489  * Most systems do not enforce this but some do.
490  */
491 #define vFork() ((getpid() == myPid) ? vfork() : fork())
492 extern pid_t    myPid;
493
494 #define MAKEFLAGS       ".MAKEFLAGS"
495 #define MAKEOVERRIDES   ".MAKEOVERRIDES"
496 #define MAKE_JOB_PREFIX ".MAKE.JOB.PREFIX" /* prefix for job target output */
497 #define MAKE_EXPORTED   ".MAKE.EXPORTED"   /* variables we export */
498 #define MAKE_MAKEFILES  ".MAKE.MAKEFILES"  /* all the makefiles we read */
499 #define MAKE_LEVEL      ".MAKE.LEVEL"      /* recursion level */
500 #define MAKEFILE_PREFERENCE ".MAKE.MAKEFILE_PREFERENCE"
501 #define MAKE_DEPENDFILE ".MAKE.DEPENDFILE" /* .depend */
502 #define MAKE_MODE       ".MAKE.MODE"
503 #ifndef MAKE_LEVEL_ENV
504 # define MAKE_LEVEL_ENV "MAKELEVEL"
505 #endif
506
507 /*
508  * debug control:
509  *      There is one bit per module.  It is up to the module what debug
510  *      information to print.
511  */
512 extern FILE *debug_file;        /* Output is written here - default stderr */
513 extern int debug;
514 #define DEBUG_ARCH      0x00001
515 #define DEBUG_COND      0x00002
516 #define DEBUG_DIR       0x00004
517 #define DEBUG_GRAPH1    0x00008
518 #define DEBUG_GRAPH2    0x00010
519 #define DEBUG_JOB       0x00020
520 #define DEBUG_MAKE      0x00040
521 #define DEBUG_SUFF      0x00080
522 #define DEBUG_TARG      0x00100
523 #define DEBUG_VAR       0x00200
524 #define DEBUG_FOR       0x00400
525 #define DEBUG_SHELL     0x00800
526 #define DEBUG_ERROR     0x01000
527 #define DEBUG_LOUD      0x02000
528 #define DEBUG_META      0x04000
529 #define DEBUG_HASH      0x08000
530
531 #define DEBUG_GRAPH3    0x10000
532 #define DEBUG_SCRIPT    0x20000
533 #define DEBUG_PARSE     0x40000
534 #define DEBUG_CWD       0x80000
535
536 #define DEBUG_LINT      0x100000
537
538 #define CONCAT(a,b)     a##b
539
540 #define DEBUG(module)   (debug & CONCAT(DEBUG_,module))
541
542 #include "nonints.h"
543
544 int Make_TimeStamp(GNode *, GNode *);
545 Boolean Make_OODate(GNode *);
546 void Make_ExpandUse(Lst);
547 time_t Make_Recheck(GNode *);
548 void Make_HandleUse(GNode *, GNode *);
549 void Make_Update(GNode *);
550 void Make_DoAllVar(GNode *);
551 Boolean Make_Run(Lst);
552 int dieQuietly(GNode *, int);
553 void PrintOnError(GNode *, const char *);
554 void Main_ExportMAKEFLAGS(Boolean);
555 Boolean Main_SetObjdir(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);
556 int mkTempFile(const char *, char **);
557 int str2Lst_Append(Lst, char *, const char *);
558 void GNode_FprintDetails(FILE *, const char *, const GNode *, const char *);
559
560 #ifdef __GNUC__
561 #define UNCONST(ptr)    ({              \
562     union __unconst {                   \
563         const void *__cp;               \
564         void *__p;                      \
565     } __d;                              \
566     __d.__cp = ptr, __d.__p; })
567 #else
568 #define UNCONST(ptr)    (void *)(ptr)
569 #endif
570
571 #ifndef MIN
572 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
573 #endif
574 #ifndef MAX
575 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
576 #endif
577
578 /* At least GNU/Hurd systems lack hardcoded MAXPATHLEN/PATH_MAX */
579 #ifdef HAVE_LIMITS_H
580 #include <limits.h>
581 #endif
582 #ifndef MAXPATHLEN
583 #define MAXPATHLEN      BMAKE_PATH_MAX
584 #endif
585 #ifndef PATH_MAX
586 #define PATH_MAX        MAXPATHLEN
587 #endif
588
589 #if defined(SYSV)
590 #define KILLPG(pid, sig)        kill(-(pid), (sig))
591 #else
592 #define KILLPG(pid, sig)        killpg((pid), (sig))
593 #endif
594
595 #endif /* MAKE_MAKE_H */