1321964Ssjg/* $NetBSD: make.h,v 1.103 2017/07/20 19:29:54 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> 91321964Ssjg#include <fcntl.h> 92236769Sobrien#include <stdio.h> 93236769Sobrien#include <stdlib.h> 94236769Sobrien#ifdef HAVE_STRING_H 95236769Sobrien#include <string.h> 96236769Sobrien#else 97236769Sobrien#include <strings.h> 98236769Sobrien#endif 99236769Sobrien#include <unistd.h> 100236769Sobrien#include <sys/cdefs.h> 101236769Sobrien 102321964Ssjg#ifndef FD_CLOEXEC 103321964Ssjg#define FD_CLOEXEC 1 104321964Ssjg#endif 105321964Ssjg 106236769Sobrien#if defined(__GNUC__) 107237578Sobrien#define MAKE_GNUC_PREREQ(x, y) \ 108236769Sobrien ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \ 109236769Sobrien (__GNUC__ > (x))) 110236769Sobrien#else /* defined(__GNUC__) */ 111249033Ssjg#define MAKE_GNUC_PREREQ(x, y) 0 112236769Sobrien#endif /* defined(__GNUC__) */ 113236769Sobrien 114237578Sobrien#if MAKE_GNUC_PREREQ(2, 7) 115237578Sobrien#define MAKE_ATTR_UNUSED __attribute__((__unused__)) 116236769Sobrien#else 117237578Sobrien#define MAKE_ATTR_UNUSED /* delete */ 118236769Sobrien#endif 119237578Sobrien 120237578Sobrien#if MAKE_GNUC_PREREQ(2, 5) 121237578Sobrien#define MAKE_ATTR_DEAD __attribute__((__noreturn__)) 122237578Sobrien#elif defined(__GNUC__) 123237578Sobrien#define MAKE_ATTR_DEAD __volatile 124237578Sobrien#else 125237578Sobrien#define MAKE_ATTR_DEAD /* delete */ 126236769Sobrien#endif 127236769Sobrien 128237578Sobrien#if MAKE_GNUC_PREREQ(2, 7) 129237578Sobrien#define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) \ 130237578Sobrien __attribute__((__format__ (__printf__, fmtarg, firstvararg))) 131237578Sobrien#else 132237578Sobrien#define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) /* delete */ 133236769Sobrien#endif 134236769Sobrien 135236769Sobrien#include "sprite.h" 136236769Sobrien#include "lst.h" 137236769Sobrien#include "hash.h" 138236769Sobrien#include "make-conf.h" 139236769Sobrien#include "buf.h" 140236769Sobrien#include "make_malloc.h" 141236769Sobrien 142236769Sobrien/* 143236769Sobrien * some vendors don't have this --sjg 144236769Sobrien */ 145236769Sobrien#if defined(S_IFDIR) && !defined(S_ISDIR) 146236769Sobrien# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 147236769Sobrien#endif 148236769Sobrien 149236769Sobrien#if defined(sun) && (defined(__svr4__) || defined(__SVR4)) 150236769Sobrien#define POSIX_SIGNALS 151236769Sobrien#endif 152236769Sobrien 153236769Sobrien/*- 154236769Sobrien * The structure for an individual graph node. Each node has several 155236769Sobrien * pieces of data associated with it. 156236769Sobrien * 1) the name of the target it describes 157236769Sobrien * 2) the location of the target file in the file system. 158236769Sobrien * 3) the type of operator used to define its sources (qv. parse.c) 159236769Sobrien * 4) whether it is involved in this invocation of make 160236769Sobrien * 5) whether the target has been remade 161236769Sobrien * 6) whether any of its children has been remade 162236769Sobrien * 7) the number of its children that are, as yet, unmade 163236769Sobrien * 8) its modification time 164236769Sobrien * 9) the modification time of its youngest child (qv. make.c) 165236769Sobrien * 10) a list of nodes for which this is a source (parents) 166236769Sobrien * 11) a list of nodes on which this depends (children) 167236769Sobrien * 12) a list of nodes that depend on this, as gleaned from the 168236769Sobrien * transformation rules (iParents) 169236769Sobrien * 13) a list of ancestor nodes, which includes parents, iParents, 170236769Sobrien * and recursive parents of parents 171236769Sobrien * 14) a list of nodes of the same name created by the :: operator 172236769Sobrien * 15) a list of nodes that must be made (if they're made) before 173236769Sobrien * this node can be, but that do not enter into the datedness of 174236769Sobrien * this node. 175236769Sobrien * 16) a list of nodes that must be made (if they're made) before 176236769Sobrien * this node or any child of this node can be, but that do not 177236769Sobrien * enter into the datedness of this node. 178236769Sobrien * 17) a list of nodes that must be made (if they're made) after 179236769Sobrien * this node is, but that do not depend on this node, in the 180236769Sobrien * normal sense. 181236769Sobrien * 18) a Lst of ``local'' variables that are specific to this target 182236769Sobrien * and this target only (qv. var.c [$@ $< $?, etc.]) 183236769Sobrien * 19) a Lst of strings that are commands to be given to a shell 184236769Sobrien * to create this target. 185236769Sobrien */ 186236769Sobrientypedef struct GNode { 187236769Sobrien char *name; /* The target's name */ 188236769Sobrien char *uname; /* The unexpanded name of a .USE node */ 189236769Sobrien char *path; /* The full pathname of the file */ 190236769Sobrien int type; /* Its type (see the OP flags, below) */ 191236769Sobrien 192236769Sobrien int flags; 193236769Sobrien#define REMAKE 0x1 /* this target needs to be (re)made */ 194236769Sobrien#define CHILDMADE 0x2 /* children of this target were made */ 195236769Sobrien#define FORCE 0x4 /* children don't exist, and we pretend made */ 196236769Sobrien#define DONE_WAIT 0x8 /* Set by Make_ProcessWait() */ 197236769Sobrien#define DONE_ORDER 0x10 /* Build requested by .ORDER processing */ 198236769Sobrien#define FROM_DEPEND 0x20 /* Node created from .depend */ 199236769Sobrien#define DONE_ALLSRC 0x40 /* We do it once only */ 200236769Sobrien#define CYCLE 0x1000 /* Used by MakePrintStatus */ 201236769Sobrien#define DONECYCLE 0x2000 /* Used by MakePrintStatus */ 202321964Ssjg#define INTERNAL 0x4000 /* Internal use only */ 203236769Sobrien enum enum_made { 204236769Sobrien UNMADE, DEFERRED, REQUESTED, BEINGMADE, 205236769Sobrien MADE, UPTODATE, ERROR, ABORTED 206236769Sobrien } made; /* Set to reflect the state of processing 207236769Sobrien * on this node: 208236769Sobrien * UNMADE - Not examined yet 209236769Sobrien * DEFERRED - Examined once (building child) 210236769Sobrien * REQUESTED - on toBeMade list 211236769Sobrien * BEINGMADE - Target is already being made. 212236769Sobrien * Indicates a cycle in the graph. 213236769Sobrien * MADE - Was out-of-date and has been made 214236769Sobrien * UPTODATE - Was already up-to-date 215236769Sobrien * ERROR - An error occurred while it was being 216236769Sobrien * made (used only in compat mode) 217236769Sobrien * ABORTED - The target was aborted due to 218236769Sobrien * an error making an inferior (compat). 219236769Sobrien */ 220236769Sobrien int unmade; /* The number of unmade children */ 221236769Sobrien 222236769Sobrien time_t mtime; /* Its modification time */ 223236769Sobrien struct GNode *cmgn; /* The youngest child */ 224236769Sobrien 225236769Sobrien Lst iParents; /* Links to parents for which this is an 226236769Sobrien * implied source, if any */ 227236769Sobrien Lst cohorts; /* Other nodes for the :: operator */ 228236769Sobrien Lst parents; /* Nodes that depend on this one */ 229236769Sobrien Lst children; /* Nodes on which this one depends */ 230236769Sobrien Lst order_pred; /* .ORDER nodes we need made */ 231236769Sobrien Lst order_succ; /* .ORDER nodes who need us */ 232236769Sobrien 233236769Sobrien char cohort_num[8]; /* #n for this cohort */ 234236769Sobrien int unmade_cohorts;/* # of unmade instances on the 235236769Sobrien cohorts list */ 236236769Sobrien struct GNode *centurion; /* Pointer to the first instance of a :: 237236769Sobrien node; only set when on a cohorts list */ 238236769Sobrien unsigned int checked; /* Last time we tried to makle this node */ 239236769Sobrien 240236769Sobrien Hash_Table context; /* The local variables */ 241236769Sobrien Lst commands; /* Creation commands */ 242236769Sobrien 243236769Sobrien struct _Suff *suffix; /* Suffix for the node (determined by 244236769Sobrien * Suff_FindDeps and opaque to everyone 245236769Sobrien * but the Suff module) */ 246236769Sobrien const char *fname; /* filename where the GNode got defined */ 247236769Sobrien int lineno; /* line number where the GNode got defined */ 248236769Sobrien} GNode; 249236769Sobrien 250236769Sobrien/* 251236769Sobrien * The OP_ constants are used when parsing a dependency line as a way of 252236769Sobrien * communicating to other parts of the program the way in which a target 253236769Sobrien * should be made. These constants are bitwise-OR'ed together and 254236769Sobrien * placed in the 'type' field of each node. Any node that has 255236769Sobrien * a 'type' field which satisfies the OP_NOP function was never never on 256236769Sobrien * the lefthand side of an operator, though it may have been on the 257236769Sobrien * righthand side... 258236769Sobrien */ 259236769Sobrien#define OP_DEPENDS 0x00000001 /* Execution of commands depends on 260236769Sobrien * kids (:) */ 261236769Sobrien#define OP_FORCE 0x00000002 /* Always execute commands (!) */ 262236769Sobrien#define OP_DOUBLEDEP 0x00000004 /* Execution of commands depends on kids 263236769Sobrien * per line (::) */ 264236769Sobrien#define OP_OPMASK (OP_DEPENDS|OP_FORCE|OP_DOUBLEDEP) 265236769Sobrien 266236769Sobrien#define OP_OPTIONAL 0x00000008 /* Don't care if the target doesn't 267236769Sobrien * exist and can't be created */ 268236769Sobrien#define OP_USE 0x00000010 /* Use associated commands for parents */ 269236769Sobrien#define OP_EXEC 0x00000020 /* Target is never out of date, but always 270236769Sobrien * execute commands anyway. Its time 271236769Sobrien * doesn't matter, so it has none...sort 272236769Sobrien * of */ 273236769Sobrien#define OP_IGNORE 0x00000040 /* Ignore errors when creating the node */ 274236769Sobrien#define OP_PRECIOUS 0x00000080 /* Don't remove the target when 275236769Sobrien * interrupted */ 276236769Sobrien#define OP_SILENT 0x00000100 /* Don't echo commands when executed */ 277236769Sobrien#define OP_MAKE 0x00000200 /* Target is a recursive make so its 278236769Sobrien * commands should always be executed when 279236769Sobrien * it is out of date, regardless of the 280236769Sobrien * state of the -n or -t flags */ 281236769Sobrien#define OP_JOIN 0x00000400 /* Target is out-of-date only if any of its 282236769Sobrien * children was out-of-date */ 283236769Sobrien#define OP_MADE 0x00000800 /* Assume the children of the node have 284236769Sobrien * been already made */ 285236769Sobrien#define OP_SPECIAL 0x00001000 /* Special .BEGIN, .END, .INTERRUPT */ 286236769Sobrien#define OP_USEBEFORE 0x00002000 /* Like .USE, only prepend commands */ 287236769Sobrien#define OP_INVISIBLE 0x00004000 /* The node is invisible to its parents. 288236769Sobrien * I.e. it doesn't show up in the parents's 289236769Sobrien * local variables. */ 290236769Sobrien#define OP_NOTMAIN 0x00008000 /* The node is exempt from normal 'main 291236769Sobrien * target' processing in parse.c */ 292236769Sobrien#define OP_PHONY 0x00010000 /* Not a file target; run always */ 293236769Sobrien#define OP_NOPATH 0x00020000 /* Don't search for file in the path */ 294236769Sobrien#define OP_WAIT 0x00040000 /* .WAIT phony node */ 295236769Sobrien#define OP_NOMETA 0x00080000 /* .NOMETA do not create a .meta file */ 296236769Sobrien#define OP_META 0x00100000 /* .META we _do_ want a .meta file */ 297236769Sobrien#define OP_NOMETA_CMP 0x00200000 /* Do not compare commands in .meta file */ 298292068Ssjg#define OP_SUBMAKE 0x00400000 /* Possibly a submake node */ 299236769Sobrien/* Attributes applied by PMake */ 300236769Sobrien#define OP_TRANSFORM 0x80000000 /* The node is a transformation rule */ 301236769Sobrien#define OP_MEMBER 0x40000000 /* Target is a member of an archive */ 302236769Sobrien#define OP_LIB 0x20000000 /* Target is a library */ 303236769Sobrien#define OP_ARCHV 0x10000000 /* Target is an archive construct */ 304236769Sobrien#define OP_HAS_COMMANDS 0x08000000 /* Target has all the commands it should. 305236769Sobrien * Used when parsing to catch multiple 306236769Sobrien * commands for a target */ 307236769Sobrien#define OP_SAVE_CMDS 0x04000000 /* Saving commands on .END (Compat) */ 308236769Sobrien#define OP_DEPS_FOUND 0x02000000 /* Already processed by Suff_FindDeps */ 309236769Sobrien#define OP_MARK 0x01000000 /* Node found while expanding .ALLSRC */ 310236769Sobrien 311236769Sobrien#define NoExecute(gn) ((gn->type & OP_MAKE) ? noRecursiveExecute : noExecute) 312236769Sobrien/* 313236769Sobrien * OP_NOP will return TRUE if the node with the given type was not the 314236769Sobrien * object of a dependency operator 315236769Sobrien */ 316236769Sobrien#define OP_NOP(t) (((t) & OP_OPMASK) == 0x00000000) 317236769Sobrien 318236769Sobrien#define OP_NOTARGET (OP_NOTMAIN|OP_USE|OP_EXEC|OP_TRANSFORM) 319236769Sobrien 320236769Sobrien/* 321236769Sobrien * The TARG_ constants are used when calling the Targ_FindNode and 322236769Sobrien * Targ_FindList functions in targ.c. They simply tell the functions what to 323236769Sobrien * do if the desired node(s) is (are) not found. If the TARG_CREATE constant 324236769Sobrien * is given, a new, empty node will be created for the target, placed in the 325236769Sobrien * table of all targets and its address returned. If TARG_NOCREATE is given, 326236769Sobrien * a NULL pointer will be returned. 327236769Sobrien */ 328236769Sobrien#define TARG_NOCREATE 0x00 /* don't create it */ 329236769Sobrien#define TARG_CREATE 0x01 /* create node if not found */ 330236769Sobrien#define TARG_NOHASH 0x02 /* don't look in/add to hash table */ 331236769Sobrien 332236769Sobrien/* 333236769Sobrien * These constants are all used by the Str_Concat function to decide how the 334236769Sobrien * final string should look. If STR_ADDSPACE is given, a space will be 335236769Sobrien * placed between the two strings. If STR_ADDSLASH is given, a '/' will 336236769Sobrien * be used instead of a space. If neither is given, no intervening characters 337236769Sobrien * will be placed between the two strings in the final output. If the 338236769Sobrien * STR_DOFREE bit is set, the two input strings will be freed before 339236769Sobrien * Str_Concat returns. 340236769Sobrien */ 341236769Sobrien#define STR_ADDSPACE 0x01 /* add a space when Str_Concat'ing */ 342236769Sobrien#define STR_ADDSLASH 0x02 /* add a slash when Str_Concat'ing */ 343236769Sobrien 344236769Sobrien/* 345236769Sobrien * Error levels for parsing. PARSE_FATAL means the process cannot continue 346236769Sobrien * once the makefile has been parsed. PARSE_WARNING means it can. Passed 347236769Sobrien * as the first argument to Parse_Error. 348236769Sobrien */ 349236769Sobrien#define PARSE_WARNING 2 350236769Sobrien#define PARSE_FATAL 1 351236769Sobrien 352236769Sobrien/* 353236769Sobrien * Values returned by Cond_Eval. 354236769Sobrien */ 355236769Sobrien#define COND_PARSE 0 /* Parse the next lines */ 356236769Sobrien#define COND_SKIP 1 /* Skip the next lines */ 357236769Sobrien#define COND_INVALID 2 /* Not a conditional statement */ 358236769Sobrien 359236769Sobrien/* 360236769Sobrien * Definitions for the "local" variables. Used only for clarity. 361236769Sobrien */ 362236769Sobrien#define TARGET "@" /* Target of dependency */ 363236769Sobrien#define OODATE "?" /* All out-of-date sources */ 364236769Sobrien#define ALLSRC ">" /* All sources */ 365236769Sobrien#define IMPSRC "<" /* Source implied by transformation */ 366236769Sobrien#define PREFIX "*" /* Common prefix */ 367236769Sobrien#define ARCHIVE "!" /* Archive in "archive(member)" syntax */ 368236769Sobrien#define MEMBER "%" /* Member in "archive(member)" syntax */ 369236769Sobrien 370236769Sobrien#define FTARGET "@F" /* file part of TARGET */ 371236769Sobrien#define DTARGET "@D" /* directory part of TARGET */ 372236769Sobrien#define FIMPSRC "<F" /* file part of IMPSRC */ 373236769Sobrien#define DIMPSRC "<D" /* directory part of IMPSRC */ 374236769Sobrien#define FPREFIX "*F" /* file part of PREFIX */ 375236769Sobrien#define DPREFIX "*D" /* directory part of PREFIX */ 376236769Sobrien 377236769Sobrien/* 378236769Sobrien * Global Variables 379236769Sobrien */ 380236769Sobrienextern Lst create; /* The list of target names specified on the 381236769Sobrien * command line. used to resolve #if 382236769Sobrien * make(...) statements */ 383236769Sobrienextern Lst dirSearchPath; /* The list of directories to search when 384236769Sobrien * looking for targets */ 385236769Sobrien 386236769Sobrienextern Boolean compatMake; /* True if we are make compatible */ 387236769Sobrienextern Boolean ignoreErrors; /* True if should ignore all errors */ 388236769Sobrienextern Boolean beSilent; /* True if should print no commands */ 389236769Sobrienextern Boolean noExecute; /* True if should execute nothing */ 390236769Sobrienextern Boolean noRecursiveExecute; /* True if should execute nothing */ 391236769Sobrienextern Boolean allPrecious; /* True if every target is precious */ 392321964Ssjgextern Boolean deleteOnError; /* True if failed targets should be deleted */ 393236769Sobrienextern Boolean keepgoing; /* True if should continue on unaffected 394236769Sobrien * portions of the graph when have an error 395236769Sobrien * in one portion */ 396236769Sobrienextern Boolean touchFlag; /* TRUE if targets should just be 'touched' 397236769Sobrien * if out of date. Set by the -t flag */ 398236769Sobrienextern Boolean queryFlag; /* TRUE if we aren't supposed to really make 399236769Sobrien * anything, just see if the targets are out- 400236769Sobrien * of-date */ 401236769Sobrienextern Boolean doing_depend; /* TRUE if processing .depend */ 402236769Sobrien 403236769Sobrienextern Boolean checkEnvFirst; /* TRUE if environment should be searched for 404236769Sobrien * variables before the global context */ 405236769Sobrienextern Boolean jobServer; /* a jobServer already exists */ 406236769Sobrien 407236769Sobrienextern Boolean parseWarnFatal; /* TRUE if makefile parsing warnings are 408236769Sobrien * treated as errors */ 409236769Sobrien 410236769Sobrienextern Boolean varNoExportEnv; /* TRUE if we should not export variables 411236769Sobrien * set on the command line to the env. */ 412236769Sobrien 413236769Sobrienextern GNode *DEFAULT; /* .DEFAULT rule */ 414236769Sobrien 415255253Ssjgextern GNode *VAR_INTERNAL; /* Variables defined internally by make 416255253Ssjg * which should not override those set by 417255253Ssjg * makefiles. 418255253Ssjg */ 419236769Sobrienextern GNode *VAR_GLOBAL; /* Variables defined in a global context, e.g 420236769Sobrien * in the Makefile itself */ 421236769Sobrienextern GNode *VAR_CMD; /* Variables defined on the command line */ 422236769Sobrienextern GNode *VAR_FOR; /* Iteration variables */ 423236769Sobrienextern char var_Error[]; /* Value returned by Var_Parse when an error 424236769Sobrien * is encountered. It actually points to 425236769Sobrien * an empty string, so naive callers needn't 426236769Sobrien * worry about it. */ 427236769Sobrien 428236769Sobrienextern time_t now; /* The time at the start of this whole 429236769Sobrien * process */ 430236769Sobrien 431236769Sobrienextern Boolean oldVars; /* Do old-style variable substitution */ 432236769Sobrien 433236769Sobrienextern Lst sysIncPath; /* The system include path. */ 434236769Sobrienextern Lst defIncPath; /* The default include path. */ 435236769Sobrien 436236769Sobrienextern char curdir[]; /* Startup directory */ 437236769Sobrienextern char *progname; /* The program name */ 438236769Sobrienextern char *makeDependfile; /* .depend */ 439236769Sobrienextern char **savedEnv; /* if we replaced environ this will be non-NULL */ 440236769Sobrien 441236769Sobrien/* 442236769Sobrien * We cannot vfork() in a child of vfork(). 443236769Sobrien * Most systems do not enforce this but some do. 444236769Sobrien */ 445236769Sobrien#define vFork() ((getpid() == myPid) ? vfork() : fork()) 446236769Sobrienextern pid_t myPid; 447236769Sobrien 448236769Sobrien#define MAKEFLAGS ".MAKEFLAGS" 449236769Sobrien#define MAKEOVERRIDES ".MAKEOVERRIDES" 450236769Sobrien#define MAKE_JOB_PREFIX ".MAKE.JOB.PREFIX" /* prefix for job target output */ 451236769Sobrien#define MAKE_EXPORTED ".MAKE.EXPORTED" /* variables we export */ 452236769Sobrien#define MAKE_MAKEFILES ".MAKE.MAKEFILES" /* all the makefiles we read */ 453236769Sobrien#define MAKE_LEVEL ".MAKE.LEVEL" /* recursion level */ 454236769Sobrien#define MAKEFILE_PREFERENCE ".MAKE.MAKEFILE_PREFERENCE" 455236769Sobrien#define MAKE_DEPENDFILE ".MAKE.DEPENDFILE" /* .depend */ 456236769Sobrien#define MAKE_MODE ".MAKE.MODE" 457253883Ssjg#ifndef MAKE_LEVEL_ENV 458253883Ssjg# define MAKE_LEVEL_ENV "MAKELEVEL" 459236769Sobrien#endif 460236769Sobrien 461236769Sobrien/* 462236769Sobrien * debug control: 463236769Sobrien * There is one bit per module. It is up to the module what debug 464236769Sobrien * information to print. 465236769Sobrien */ 466236769SobrienFILE *debug_file; /* Output written here - default stdout */ 467236769Sobrienextern int debug; 468236769Sobrien#define DEBUG_ARCH 0x00001 469236769Sobrien#define DEBUG_COND 0x00002 470236769Sobrien#define DEBUG_DIR 0x00004 471236769Sobrien#define DEBUG_GRAPH1 0x00008 472236769Sobrien#define DEBUG_GRAPH2 0x00010 473236769Sobrien#define DEBUG_JOB 0x00020 474236769Sobrien#define DEBUG_MAKE 0x00040 475236769Sobrien#define DEBUG_SUFF 0x00080 476236769Sobrien#define DEBUG_TARG 0x00100 477236769Sobrien#define DEBUG_VAR 0x00200 478236769Sobrien#define DEBUG_FOR 0x00400 479236769Sobrien#define DEBUG_SHELL 0x00800 480236769Sobrien#define DEBUG_ERROR 0x01000 481236769Sobrien#define DEBUG_LOUD 0x02000 482236769Sobrien#define DEBUG_META 0x04000 483236769Sobrien 484236769Sobrien#define DEBUG_GRAPH3 0x10000 485236769Sobrien#define DEBUG_SCRIPT 0x20000 486236769Sobrien#define DEBUG_PARSE 0x40000 487236769Sobrien#define DEBUG_CWD 0x80000 488236769Sobrien 489236769Sobrien#define CONCAT(a,b) a##b 490236769Sobrien 491236769Sobrien#define DEBUG(module) (debug & CONCAT(DEBUG_,module)) 492236769Sobrien 493236769Sobrien#include "nonints.h" 494236769Sobrien 495236769Sobrienint Make_TimeStamp(GNode *, GNode *); 496236769SobrienBoolean Make_OODate(GNode *); 497236769Sobrienvoid Make_ExpandUse(Lst); 498236769Sobrientime_t Make_Recheck(GNode *); 499236769Sobrienvoid Make_HandleUse(GNode *, GNode *); 500236769Sobrienvoid Make_Update(GNode *); 501236769Sobrienvoid Make_DoAllVar(GNode *); 502236769SobrienBoolean Make_Run(Lst); 503236769Sobrienchar * Check_Cwd_Cmd(const char *); 504236769Sobrienvoid Check_Cwd(const char **); 505236769Sobrienvoid PrintOnError(GNode *, const char *); 506236769Sobrienvoid Main_ExportMAKEFLAGS(Boolean); 507321964SsjgBoolean Main_SetObjdir(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2); 508236769Sobrienint mkTempFile(const char *, char **); 509236769Sobrienint str2Lst_Append(Lst, char *, const char *); 510321964Ssjgint cached_lstat(const char *, void *); 511321964Ssjgint cached_stat(const char *, void *); 512236769Sobrien 513321964Ssjg#define VARF_UNDEFERR 1 514321964Ssjg#define VARF_WANTRES 2 515321964Ssjg#define VARF_ASSIGN 4 516321964Ssjg 517236769Sobrien#ifdef __GNUC__ 518236769Sobrien#define UNCONST(ptr) ({ \ 519236769Sobrien union __unconst { \ 520236769Sobrien const void *__cp; \ 521236769Sobrien void *__p; \ 522236769Sobrien } __d; \ 523236769Sobrien __d.__cp = ptr, __d.__p; }) 524236769Sobrien#else 525236769Sobrien#define UNCONST(ptr) (void *)(ptr) 526236769Sobrien#endif 527236769Sobrien 528236769Sobrien#ifndef MIN 529236769Sobrien#define MIN(a, b) ((a < b) ? a : b) 530236769Sobrien#endif 531236769Sobrien#ifndef MAX 532236769Sobrien#define MAX(a, b) ((a > b) ? a : b) 533236769Sobrien#endif 534236769Sobrien 535292068Ssjg/* At least GNU/Hurd systems lack hardcoded MAXPATHLEN/PATH_MAX */ 536292068Ssjg#ifdef HAVE_LIMITS_H 537292068Ssjg#include <limits.h> 538292068Ssjg#endif 539276305Sngie#ifndef MAXPATHLEN 540292068Ssjg#define MAXPATHLEN BMAKE_PATH_MAX 541276305Sngie#endif 542292068Ssjg#ifndef PATH_MAX 543292068Ssjg#define PATH_MAX MAXPATHLEN 544292068Ssjg#endif 545276305Sngie 546321964Ssjg#if defined(SYSV) 547321964Ssjg#define KILLPG(pid, sig) kill(-(pid), (sig)) 548321964Ssjg#else 549321964Ssjg#define KILLPG(pid, sig) killpg((pid), (sig)) 550321964Ssjg#endif 551321964Ssjg 552236769Sobrien#endif /* _MAKE_H_ */ 553