1255253Ssjg/*	$NetBSD: make.h,v 1.92 2013/09/04 15:38:26 sjg Exp $	*/
2236769Sobrien
3236769Sobrien/*
4236769Sobrien * Copyright (c) 1988, 1989, 1990, 1993
5236769Sobrien *	The Regents of the University of California.  All rights reserved.
6236769Sobrien *
7236769Sobrien * This code is derived from software contributed to Berkeley by
8236769Sobrien * Adam de Boor.
9236769Sobrien *
10236769Sobrien * Redistribution and use in source and binary forms, with or without
11236769Sobrien * modification, are permitted provided that the following conditions
12236769Sobrien * are met:
13236769Sobrien * 1. Redistributions of source code must retain the above copyright
14236769Sobrien *    notice, this list of conditions and the following disclaimer.
15236769Sobrien * 2. Redistributions in binary form must reproduce the above copyright
16236769Sobrien *    notice, this list of conditions and the following disclaimer in the
17236769Sobrien *    documentation and/or other materials provided with the distribution.
18236769Sobrien * 3. Neither the name of the University nor the names of its contributors
19236769Sobrien *    may be used to endorse or promote products derived from this software
20236769Sobrien *    without specific prior written permission.
21236769Sobrien *
22236769Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23236769Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24236769Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25236769Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26236769Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27236769Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28236769Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29236769Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30236769Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31236769Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32236769Sobrien * SUCH DAMAGE.
33236769Sobrien *
34236769Sobrien *	from: @(#)make.h	8.3 (Berkeley) 6/13/95
35236769Sobrien */
36236769Sobrien
37236769Sobrien/*
38236769Sobrien * Copyright (c) 1989 by Berkeley Softworks
39236769Sobrien * All rights reserved.
40236769Sobrien *
41236769Sobrien * This code is derived from software contributed to Berkeley by
42236769Sobrien * Adam de Boor.
43236769Sobrien *
44236769Sobrien * Redistribution and use in source and binary forms, with or without
45236769Sobrien * modification, are permitted provided that the following conditions
46236769Sobrien * are met:
47236769Sobrien * 1. Redistributions of source code must retain the above copyright
48236769Sobrien *    notice, this list of conditions and the following disclaimer.
49236769Sobrien * 2. Redistributions in binary form must reproduce the above copyright
50236769Sobrien *    notice, this list of conditions and the following disclaimer in the
51236769Sobrien *    documentation and/or other materials provided with the distribution.
52236769Sobrien * 3. All advertising materials mentioning features or use of this software
53236769Sobrien *    must display the following acknowledgement:
54236769Sobrien *	This product includes software developed by the University of
55236769Sobrien *	California, Berkeley and its contributors.
56236769Sobrien * 4. Neither the name of the University nor the names of its contributors
57236769Sobrien *    may be used to endorse or promote products derived from this software
58236769Sobrien *    without specific prior written permission.
59236769Sobrien *
60236769Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
61236769Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62236769Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63236769Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64236769Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65236769Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66236769Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67236769Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68236769Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69236769Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
70236769Sobrien * SUCH DAMAGE.
71236769Sobrien *
72236769Sobrien *	from: @(#)make.h	8.3 (Berkeley) 6/13/95
73236769Sobrien */
74236769Sobrien
75236769Sobrien/*-
76236769Sobrien * make.h --
77236769Sobrien *	The global definitions for pmake
78236769Sobrien */
79236769Sobrien
80236769Sobrien#ifndef _MAKE_H_
81236769Sobrien#define _MAKE_H_
82236769Sobrien
83236769Sobrien#ifdef HAVE_CONFIG_H
84236769Sobrien# include "config.h"
85236769Sobrien#endif
86236769Sobrien
87236769Sobrien#include <sys/types.h>
88236769Sobrien#include <sys/param.h>
89236769Sobrien
90236769Sobrien#include <ctype.h>
91236769Sobrien#include <stdio.h>
92236769Sobrien#include <stdlib.h>
93236769Sobrien#ifdef HAVE_STRING_H
94236769Sobrien#include <string.h>
95236769Sobrien#else
96236769Sobrien#include <strings.h>
97236769Sobrien#endif
98236769Sobrien#include <unistd.h>
99236769Sobrien#include <sys/cdefs.h>
100236769Sobrien
101236769Sobrien#if defined(__GNUC__)
102237578Sobrien#define	MAKE_GNUC_PREREQ(x, y)						\
103236769Sobrien	((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) ||			\
104236769Sobrien	 (__GNUC__ > (x)))
105236769Sobrien#else /* defined(__GNUC__) */
106249033Ssjg#define	MAKE_GNUC_PREREQ(x, y)	0
107236769Sobrien#endif /* defined(__GNUC__) */
108236769Sobrien
109237578Sobrien#if MAKE_GNUC_PREREQ(2, 7)
110237578Sobrien#define	MAKE_ATTR_UNUSED	__attribute__((__unused__))
111236769Sobrien#else
112237578Sobrien#define	MAKE_ATTR_UNUSED	/* delete */
113236769Sobrien#endif
114237578Sobrien
115237578Sobrien#if MAKE_GNUC_PREREQ(2, 5)
116237578Sobrien#define	MAKE_ATTR_DEAD		__attribute__((__noreturn__))
117237578Sobrien#elif defined(__GNUC__)
118237578Sobrien#define	MAKE_ATTR_DEAD		__volatile
119237578Sobrien#else
120237578Sobrien#define	MAKE_ATTR_DEAD		/* delete */
121236769Sobrien#endif
122236769Sobrien
123237578Sobrien#if MAKE_GNUC_PREREQ(2, 7)
124237578Sobrien#define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg)	\
125237578Sobrien	    __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
126237578Sobrien#else
127237578Sobrien#define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg)	/* delete */
128236769Sobrien#endif
129236769Sobrien
130236769Sobrien#include "sprite.h"
131236769Sobrien#include "lst.h"
132236769Sobrien#include "hash.h"
133236769Sobrien#include "make-conf.h"
134236769Sobrien#include "buf.h"
135236769Sobrien#include "make_malloc.h"
136236769Sobrien
137236769Sobrien/*
138236769Sobrien * some vendors don't have this --sjg
139236769Sobrien */
140236769Sobrien#if defined(S_IFDIR) && !defined(S_ISDIR)
141236769Sobrien# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
142236769Sobrien#endif
143236769Sobrien
144236769Sobrien#if defined(sun) && (defined(__svr4__) || defined(__SVR4))
145236769Sobrien#define POSIX_SIGNALS
146236769Sobrien#endif
147236769Sobrien
148236769Sobrien/*-
149236769Sobrien * The structure for an individual graph node. Each node has several
150236769Sobrien * pieces of data associated with it.
151236769Sobrien *	1) the name of the target it describes
152236769Sobrien *	2) the location of the target file in the file system.
153236769Sobrien *	3) the type of operator used to define its sources (qv. parse.c)
154236769Sobrien *	4) whether it is involved in this invocation of make
155236769Sobrien *	5) whether the target has been remade
156236769Sobrien *	6) whether any of its children has been remade
157236769Sobrien *	7) the number of its children that are, as yet, unmade
158236769Sobrien *	8) its modification time
159236769Sobrien *	9) the modification time of its youngest child (qv. make.c)
160236769Sobrien *	10) a list of nodes for which this is a source (parents)
161236769Sobrien *	11) a list of nodes on which this depends (children)
162236769Sobrien *	12) a list of nodes that depend on this, as gleaned from the
163236769Sobrien *	    transformation rules (iParents)
164236769Sobrien *	13) a list of ancestor nodes, which includes parents, iParents,
165236769Sobrien *	    and recursive parents of parents
166236769Sobrien *	14) a list of nodes of the same name created by the :: operator
167236769Sobrien *	15) a list of nodes that must be made (if they're made) before
168236769Sobrien *	    this node can be, but that do not enter into the datedness of
169236769Sobrien *	    this node.
170236769Sobrien *	16) a list of nodes that must be made (if they're made) before
171236769Sobrien *	    this node or any child of this node can be, but that do not
172236769Sobrien *	    enter into the datedness of this node.
173236769Sobrien *	17) a list of nodes that must be made (if they're made) after
174236769Sobrien *	    this node is, but that do not depend on this node, in the
175236769Sobrien *	    normal sense.
176236769Sobrien *	18) a Lst of ``local'' variables that are specific to this target
177236769Sobrien *	   and this target only (qv. var.c [$@ $< $?, etc.])
178236769Sobrien *	19) a Lst of strings that are commands to be given to a shell
179236769Sobrien *	   to create this target.
180236769Sobrien */
181236769Sobrientypedef struct GNode {
182236769Sobrien    char            *name;     	/* The target's name */
183236769Sobrien    char            *uname;    	/* The unexpanded name of a .USE node */
184236769Sobrien    char    	    *path;     	/* The full pathname of the file */
185236769Sobrien    int             type;      	/* Its type (see the OP flags, below) */
186236769Sobrien
187236769Sobrien    int             flags;
188236769Sobrien#define REMAKE		0x1    	/* this target needs to be (re)made */
189236769Sobrien#define	CHILDMADE	0x2	/* children of this target were made */
190236769Sobrien#define FORCE		0x4	/* children don't exist, and we pretend made */
191236769Sobrien#define DONE_WAIT	0x8	/* Set by Make_ProcessWait() */
192236769Sobrien#define DONE_ORDER	0x10	/* Build requested by .ORDER processing */
193236769Sobrien#define FROM_DEPEND	0x20	/* Node created from .depend */
194236769Sobrien#define DONE_ALLSRC	0x40	/* We do it once only */
195236769Sobrien#define CYCLE		0x1000  /* Used by MakePrintStatus */
196236769Sobrien#define DONECYCLE	0x2000  /* Used by MakePrintStatus */
197236769Sobrien    enum enum_made {
198236769Sobrien	UNMADE, DEFERRED, REQUESTED, BEINGMADE,
199236769Sobrien	MADE, UPTODATE, ERROR, ABORTED
200236769Sobrien    }	    	    made;    	/* Set to reflect the state of processing
201236769Sobrien				 * on this node:
202236769Sobrien				 *  UNMADE - Not examined yet
203236769Sobrien				 *  DEFERRED - Examined once (building child)
204236769Sobrien				 *  REQUESTED - on toBeMade list
205236769Sobrien				 *  BEINGMADE - Target is already being made.
206236769Sobrien				 *  	Indicates a cycle in the graph.
207236769Sobrien				 *  MADE - Was out-of-date and has been made
208236769Sobrien				 *  UPTODATE - Was already up-to-date
209236769Sobrien				 *  ERROR - An error occurred while it was being
210236769Sobrien				 *  	made (used only in compat mode)
211236769Sobrien				 *  ABORTED - The target was aborted due to
212236769Sobrien				 *  	an error making an inferior (compat).
213236769Sobrien				 */
214236769Sobrien    int             unmade;    	/* The number of unmade children */
215236769Sobrien
216236769Sobrien    time_t          mtime;     	/* Its modification time */
217236769Sobrien    struct GNode    *cmgn;    	/* The youngest child */
218236769Sobrien
219236769Sobrien    Lst     	    iParents;  	/* Links to parents for which this is an
220236769Sobrien				 * implied source, if any */
221236769Sobrien    Lst	    	    cohorts;  	/* Other nodes for the :: operator */
222236769Sobrien    Lst             parents;   	/* Nodes that depend on this one */
223236769Sobrien    Lst             children;  	/* Nodes on which this one depends */
224236769Sobrien    Lst             order_pred;	/* .ORDER nodes we need made */
225236769Sobrien    Lst             order_succ;	/* .ORDER nodes who need us */
226236769Sobrien
227236769Sobrien    char	    cohort_num[8]; /* #n for this cohort */
228236769Sobrien    int		    unmade_cohorts;/* # of unmade instances on the
229236769Sobrien				      cohorts list */
230236769Sobrien    struct GNode    *centurion;	/* Pointer to the first instance of a ::
231236769Sobrien				   node; only set when on a cohorts list */
232236769Sobrien    unsigned int    checked;    /* Last time we tried to makle this node */
233236769Sobrien
234236769Sobrien    Hash_Table      context;	/* The local variables */
235236769Sobrien    Lst             commands;  	/* Creation commands */
236236769Sobrien
237236769Sobrien    struct _Suff    *suffix;	/* Suffix for the node (determined by
238236769Sobrien				 * Suff_FindDeps and opaque to everyone
239236769Sobrien				 * but the Suff module) */
240236769Sobrien    const char	    *fname;	/* filename where the GNode got defined */
241236769Sobrien    int		     lineno;	/* line number where the GNode got defined */
242236769Sobrien} GNode;
243236769Sobrien
244236769Sobrien/*
245236769Sobrien * The OP_ constants are used when parsing a dependency line as a way of
246236769Sobrien * communicating to other parts of the program the way in which a target
247236769Sobrien * should be made. These constants are bitwise-OR'ed together and
248236769Sobrien * placed in the 'type' field of each node. Any node that has
249236769Sobrien * a 'type' field which satisfies the OP_NOP function was never never on
250236769Sobrien * the lefthand side of an operator, though it may have been on the
251236769Sobrien * righthand side...
252236769Sobrien */
253236769Sobrien#define OP_DEPENDS	0x00000001  /* Execution of commands depends on
254236769Sobrien				     * kids (:) */
255236769Sobrien#define OP_FORCE	0x00000002  /* Always execute commands (!) */
256236769Sobrien#define OP_DOUBLEDEP	0x00000004  /* Execution of commands depends on kids
257236769Sobrien				     * per line (::) */
258236769Sobrien#define OP_OPMASK	(OP_DEPENDS|OP_FORCE|OP_DOUBLEDEP)
259236769Sobrien
260236769Sobrien#define OP_OPTIONAL	0x00000008  /* Don't care if the target doesn't
261236769Sobrien				     * exist and can't be created */
262236769Sobrien#define OP_USE		0x00000010  /* Use associated commands for parents */
263236769Sobrien#define OP_EXEC	  	0x00000020  /* Target is never out of date, but always
264236769Sobrien				     * execute commands anyway. Its time
265236769Sobrien				     * doesn't matter, so it has none...sort
266236769Sobrien				     * of */
267236769Sobrien#define OP_IGNORE	0x00000040  /* Ignore errors when creating the node */
268236769Sobrien#define OP_PRECIOUS	0x00000080  /* Don't remove the target when
269236769Sobrien				     * interrupted */
270236769Sobrien#define OP_SILENT	0x00000100  /* Don't echo commands when executed */
271236769Sobrien#define OP_MAKE		0x00000200  /* Target is a recursive make so its
272236769Sobrien				     * commands should always be executed when
273236769Sobrien				     * it is out of date, regardless of the
274236769Sobrien				     * state of the -n or -t flags */
275236769Sobrien#define OP_JOIN 	0x00000400  /* Target is out-of-date only if any of its
276236769Sobrien				     * children was out-of-date */
277236769Sobrien#define	OP_MADE		0x00000800  /* Assume the children of the node have
278236769Sobrien				     * been already made */
279236769Sobrien#define OP_SPECIAL	0x00001000  /* Special .BEGIN, .END, .INTERRUPT */
280236769Sobrien#define	OP_USEBEFORE	0x00002000  /* Like .USE, only prepend commands */
281236769Sobrien#define OP_INVISIBLE	0x00004000  /* The node is invisible to its parents.
282236769Sobrien				     * I.e. it doesn't show up in the parents's
283236769Sobrien				     * local variables. */
284236769Sobrien#define OP_NOTMAIN	0x00008000  /* The node is exempt from normal 'main
285236769Sobrien				     * target' processing in parse.c */
286236769Sobrien#define OP_PHONY	0x00010000  /* Not a file target; run always */
287236769Sobrien#define OP_NOPATH	0x00020000  /* Don't search for file in the path */
288236769Sobrien#define OP_WAIT 	0x00040000  /* .WAIT phony node */
289236769Sobrien#define OP_NOMETA	0x00080000  /* .NOMETA do not create a .meta file */
290236769Sobrien#define OP_META		0x00100000  /* .META we _do_ want a .meta file */
291236769Sobrien#define OP_NOMETA_CMP	0x00200000  /* Do not compare commands in .meta file */
292236769Sobrien/* Attributes applied by PMake */
293236769Sobrien#define OP_TRANSFORM	0x80000000  /* The node is a transformation rule */
294236769Sobrien#define OP_MEMBER 	0x40000000  /* Target is a member of an archive */
295236769Sobrien#define OP_LIB	  	0x20000000  /* Target is a library */
296236769Sobrien#define OP_ARCHV  	0x10000000  /* Target is an archive construct */
297236769Sobrien#define OP_HAS_COMMANDS	0x08000000  /* Target has all the commands it should.
298236769Sobrien				     * Used when parsing to catch multiple
299236769Sobrien				     * commands for a target */
300236769Sobrien#define OP_SAVE_CMDS	0x04000000  /* Saving commands on .END (Compat) */
301236769Sobrien#define OP_DEPS_FOUND	0x02000000  /* Already processed by Suff_FindDeps */
302236769Sobrien#define	OP_MARK		0x01000000  /* Node found while expanding .ALLSRC */
303236769Sobrien
304236769Sobrien#define NoExecute(gn) ((gn->type & OP_MAKE) ? noRecursiveExecute : noExecute)
305236769Sobrien/*
306236769Sobrien * OP_NOP will return TRUE if the node with the given type was not the
307236769Sobrien * object of a dependency operator
308236769Sobrien */
309236769Sobrien#define OP_NOP(t)	(((t) & OP_OPMASK) == 0x00000000)
310236769Sobrien
311236769Sobrien#define OP_NOTARGET (OP_NOTMAIN|OP_USE|OP_EXEC|OP_TRANSFORM)
312236769Sobrien
313236769Sobrien/*
314236769Sobrien * The TARG_ constants are used when calling the Targ_FindNode and
315236769Sobrien * Targ_FindList functions in targ.c. They simply tell the functions what to
316236769Sobrien * do if the desired node(s) is (are) not found. If the TARG_CREATE constant
317236769Sobrien * is given, a new, empty node will be created for the target, placed in the
318236769Sobrien * table of all targets and its address returned. If TARG_NOCREATE is given,
319236769Sobrien * a NULL pointer will be returned.
320236769Sobrien */
321236769Sobrien#define TARG_NOCREATE	0x00	  /* don't create it */
322236769Sobrien#define TARG_CREATE	0x01	  /* create node if not found */
323236769Sobrien#define TARG_NOHASH	0x02	  /* don't look in/add to hash table */
324236769Sobrien
325236769Sobrien/*
326236769Sobrien * These constants are all used by the Str_Concat function to decide how the
327236769Sobrien * final string should look. If STR_ADDSPACE is given, a space will be
328236769Sobrien * placed between the two strings. If STR_ADDSLASH is given, a '/' will
329236769Sobrien * be used instead of a space. If neither is given, no intervening characters
330236769Sobrien * will be placed between the two strings in the final output. If the
331236769Sobrien * STR_DOFREE bit is set, the two input strings will be freed before
332236769Sobrien * Str_Concat returns.
333236769Sobrien */
334236769Sobrien#define STR_ADDSPACE	0x01	/* add a space when Str_Concat'ing */
335236769Sobrien#define STR_ADDSLASH	0x02	/* add a slash when Str_Concat'ing */
336236769Sobrien
337236769Sobrien/*
338236769Sobrien * Error levels for parsing. PARSE_FATAL means the process cannot continue
339236769Sobrien * once the makefile has been parsed. PARSE_WARNING means it can. Passed
340236769Sobrien * as the first argument to Parse_Error.
341236769Sobrien */
342236769Sobrien#define PARSE_WARNING	2
343236769Sobrien#define PARSE_FATAL	1
344236769Sobrien
345236769Sobrien/*
346236769Sobrien * Values returned by Cond_Eval.
347236769Sobrien */
348236769Sobrien#define COND_PARSE	0   	/* Parse the next lines */
349236769Sobrien#define COND_SKIP 	1   	/* Skip the next lines */
350236769Sobrien#define COND_INVALID	2   	/* Not a conditional statement */
351236769Sobrien
352236769Sobrien/*
353236769Sobrien * Definitions for the "local" variables. Used only for clarity.
354236769Sobrien */
355236769Sobrien#define TARGET	  	  "@" 	/* Target of dependency */
356236769Sobrien#define OODATE	  	  "?" 	/* All out-of-date sources */
357236769Sobrien#define ALLSRC	  	  ">" 	/* All sources */
358236769Sobrien#define IMPSRC	  	  "<" 	/* Source implied by transformation */
359236769Sobrien#define PREFIX	  	  "*" 	/* Common prefix */
360236769Sobrien#define ARCHIVE	  	  "!" 	/* Archive in "archive(member)" syntax */
361236769Sobrien#define MEMBER	  	  "%" 	/* Member in "archive(member)" syntax */
362236769Sobrien
363236769Sobrien#define FTARGET           "@F"  /* file part of TARGET */
364236769Sobrien#define DTARGET           "@D"  /* directory part of TARGET */
365236769Sobrien#define FIMPSRC           "<F"  /* file part of IMPSRC */
366236769Sobrien#define DIMPSRC           "<D"  /* directory part of IMPSRC */
367236769Sobrien#define FPREFIX           "*F"  /* file part of PREFIX */
368236769Sobrien#define DPREFIX           "*D"  /* directory part of PREFIX */
369236769Sobrien
370236769Sobrien/*
371236769Sobrien * Global Variables
372236769Sobrien */
373236769Sobrienextern Lst  	create;	    	/* The list of target names specified on the
374236769Sobrien				 * command line. used to resolve #if
375236769Sobrien				 * make(...) statements */
376236769Sobrienextern Lst     	dirSearchPath; 	/* The list of directories to search when
377236769Sobrien				 * looking for targets */
378236769Sobrien
379236769Sobrienextern Boolean	compatMake;	/* True if we are make compatible */
380236769Sobrienextern Boolean	ignoreErrors;  	/* True if should ignore all errors */
381236769Sobrienextern Boolean  beSilent;    	/* True if should print no commands */
382236769Sobrienextern Boolean  noExecute;    	/* True if should execute nothing */
383236769Sobrienextern Boolean  noRecursiveExecute;    	/* True if should execute nothing */
384236769Sobrienextern Boolean  allPrecious;   	/* True if every target is precious */
385236769Sobrienextern Boolean  keepgoing;    	/* True if should continue on unaffected
386236769Sobrien				 * portions of the graph when have an error
387236769Sobrien				 * in one portion */
388236769Sobrienextern Boolean 	touchFlag;    	/* TRUE if targets should just be 'touched'
389236769Sobrien				 * if out of date. Set by the -t flag */
390236769Sobrienextern Boolean 	queryFlag;    	/* TRUE if we aren't supposed to really make
391236769Sobrien				 * anything, just see if the targets are out-
392236769Sobrien				 * of-date */
393236769Sobrienextern Boolean	doing_depend;	/* TRUE if processing .depend */
394236769Sobrien
395236769Sobrienextern Boolean	checkEnvFirst;	/* TRUE if environment should be searched for
396236769Sobrien				 * variables before the global context */
397236769Sobrienextern Boolean	jobServer;	/* a jobServer already exists */
398236769Sobrien
399236769Sobrienextern Boolean	parseWarnFatal;	/* TRUE if makefile parsing warnings are
400236769Sobrien				 * treated as errors */
401236769Sobrien
402236769Sobrienextern Boolean	varNoExportEnv;	/* TRUE if we should not export variables
403236769Sobrien				 * set on the command line to the env. */
404236769Sobrien
405236769Sobrienextern GNode    *DEFAULT;    	/* .DEFAULT rule */
406236769Sobrien
407255253Ssjgextern GNode	*VAR_INTERNAL;	/* Variables defined internally by make
408255253Ssjg				 * which should not override those set by
409255253Ssjg				 * makefiles.
410255253Ssjg				 */
411236769Sobrienextern GNode    *VAR_GLOBAL;   	/* Variables defined in a global context, e.g
412236769Sobrien				 * in the Makefile itself */
413236769Sobrienextern GNode    *VAR_CMD;    	/* Variables defined on the command line */
414236769Sobrienextern GNode	*VAR_FOR;	/* Iteration variables */
415236769Sobrienextern char    	var_Error[];   	/* Value returned by Var_Parse when an error
416236769Sobrien				 * is encountered. It actually points to
417236769Sobrien				 * an empty string, so naive callers needn't
418236769Sobrien				 * worry about it. */
419236769Sobrien
420236769Sobrienextern time_t 	now;	    	/* The time at the start of this whole
421236769Sobrien				 * process */
422236769Sobrien
423236769Sobrienextern Boolean	oldVars;    	/* Do old-style variable substitution */
424236769Sobrien
425236769Sobrienextern Lst	sysIncPath;	/* The system include path. */
426236769Sobrienextern Lst	defIncPath;	/* The default include path. */
427236769Sobrien
428236769Sobrienextern char	curdir[];	/* Startup directory */
429236769Sobrienextern char	*progname;	/* The program name */
430236769Sobrienextern char	*makeDependfile; /* .depend */
431236769Sobrienextern char	**savedEnv;	 /* if we replaced environ this will be non-NULL */
432236769Sobrien
433236769Sobrien/*
434236769Sobrien * We cannot vfork() in a child of vfork().
435236769Sobrien * Most systems do not enforce this but some do.
436236769Sobrien */
437236769Sobrien#define vFork() ((getpid() == myPid) ? vfork() : fork())
438236769Sobrienextern pid_t	myPid;
439236769Sobrien
440236769Sobrien#define	MAKEFLAGS	".MAKEFLAGS"
441236769Sobrien#define	MAKEOVERRIDES	".MAKEOVERRIDES"
442236769Sobrien#define	MAKE_JOB_PREFIX	".MAKE.JOB.PREFIX" /* prefix for job target output */
443236769Sobrien#define	MAKE_EXPORTED	".MAKE.EXPORTED"   /* variables we export */
444236769Sobrien#define	MAKE_MAKEFILES	".MAKE.MAKEFILES"  /* all the makefiles we read */
445236769Sobrien#define	MAKE_LEVEL	".MAKE.LEVEL"	   /* recursion level */
446236769Sobrien#define MAKEFILE_PREFERENCE ".MAKE.MAKEFILE_PREFERENCE"
447236769Sobrien#define MAKE_DEPENDFILE	".MAKE.DEPENDFILE" /* .depend */
448236769Sobrien#define MAKE_MODE	".MAKE.MODE"
449253883Ssjg#ifndef MAKE_LEVEL_ENV
450253883Ssjg# define MAKE_LEVEL_ENV	"MAKELEVEL"
451236769Sobrien#endif
452236769Sobrien
453236769Sobrien/*
454236769Sobrien * debug control:
455236769Sobrien *	There is one bit per module.  It is up to the module what debug
456236769Sobrien *	information to print.
457236769Sobrien */
458236769SobrienFILE *debug_file;		/* Output written here - default stdout */
459236769Sobrienextern int debug;
460236769Sobrien#define	DEBUG_ARCH	0x00001
461236769Sobrien#define	DEBUG_COND	0x00002
462236769Sobrien#define	DEBUG_DIR	0x00004
463236769Sobrien#define	DEBUG_GRAPH1	0x00008
464236769Sobrien#define	DEBUG_GRAPH2	0x00010
465236769Sobrien#define	DEBUG_JOB	0x00020
466236769Sobrien#define	DEBUG_MAKE	0x00040
467236769Sobrien#define	DEBUG_SUFF	0x00080
468236769Sobrien#define	DEBUG_TARG	0x00100
469236769Sobrien#define	DEBUG_VAR	0x00200
470236769Sobrien#define DEBUG_FOR	0x00400
471236769Sobrien#define DEBUG_SHELL	0x00800
472236769Sobrien#define DEBUG_ERROR	0x01000
473236769Sobrien#define DEBUG_LOUD	0x02000
474236769Sobrien#define DEBUG_META	0x04000
475236769Sobrien
476236769Sobrien#define DEBUG_GRAPH3	0x10000
477236769Sobrien#define DEBUG_SCRIPT	0x20000
478236769Sobrien#define DEBUG_PARSE	0x40000
479236769Sobrien#define DEBUG_CWD	0x80000
480236769Sobrien
481236769Sobrien#define CONCAT(a,b)	a##b
482236769Sobrien
483236769Sobrien#define	DEBUG(module)	(debug & CONCAT(DEBUG_,module))
484236769Sobrien
485236769Sobrien#include "nonints.h"
486236769Sobrien
487236769Sobrienint Make_TimeStamp(GNode *, GNode *);
488236769SobrienBoolean Make_OODate(GNode *);
489236769Sobrienvoid Make_ExpandUse(Lst);
490236769Sobrientime_t Make_Recheck(GNode *);
491236769Sobrienvoid Make_HandleUse(GNode *, GNode *);
492236769Sobrienvoid Make_Update(GNode *);
493236769Sobrienvoid Make_DoAllVar(GNode *);
494236769SobrienBoolean Make_Run(Lst);
495236769Sobrienchar * Check_Cwd_Cmd(const char *);
496236769Sobrienvoid Check_Cwd(const char **);
497236769Sobrienvoid PrintOnError(GNode *, const char *);
498236769Sobrienvoid Main_ExportMAKEFLAGS(Boolean);
499236769SobrienBoolean Main_SetObjdir(const char *);
500236769Sobrienint mkTempFile(const char *, char **);
501236769Sobrienint str2Lst_Append(Lst, char *, const char *);
502236769Sobrien
503236769Sobrien#ifdef __GNUC__
504236769Sobrien#define UNCONST(ptr)	({ 		\
505236769Sobrien    union __unconst {			\
506236769Sobrien	const void *__cp;		\
507236769Sobrien	void *__p;			\
508236769Sobrien    } __d;				\
509236769Sobrien    __d.__cp = ptr, __d.__p; })
510236769Sobrien#else
511236769Sobrien#define UNCONST(ptr)	(void *)(ptr)
512236769Sobrien#endif
513236769Sobrien
514236769Sobrien#ifndef MIN
515236769Sobrien#define MIN(a, b) ((a < b) ? a : b)
516236769Sobrien#endif
517236769Sobrien#ifndef MAX
518236769Sobrien#define MAX(a, b) ((a > b) ? a : b)
519236769Sobrien#endif
520236769Sobrien
521236769Sobrien#endif /* _MAKE_H_ */
522