1 /* 2 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. 3 * Copyright (c) 1988, 1989 by Adam de Boor 4 * Copyright (c) 1989 by Berkeley Softworks 5 * 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 are permitted 11 * provided that the above copyright notice and this paragraph are 12 * duplicated in all such forms and that any documentation, 13 * advertising materials, and other materials related to such 14 * distribution and use acknowledge that the software was developed 15 * by the University of California, Berkeley. The name of the 16 * University may not be used to endorse or promote products derived 17 * from this software without specific prior written permission. 18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 * 22 * @(#)make.h 5.2 (Berkeley) 03/11/90 23 */ 24 25 /*- 26 * make.h -- 27 * The global definitions for pmake 28 */ 29 30 #ifndef _MAKE_H_ 31 #define _MAKE_H_ 32 33 #include <sys/types.h> 34 #include "sprite.h" 35 #include <ctype.h> 36 #include "lst.h" 37 #include "config.h" 38 39 #ifdef NO_VFORK 40 #define vfork fork 41 #else 42 43 #ifdef sparc 44 #include <vfork.h> 45 #endif 46 47 #endif /* NO_VFORK */ 48 49 /*- 50 * The structure for an individual graph node. Each node has several 51 * pieces of data associated with it. 52 * 1) the name of the target it describes 53 * 2) the location of the target file in the file system. 54 * 3) the type of operator used to define its sources (qv. parse.c) 55 * 4) whether it is involved in this invocation of make 56 * 5) whether the target has been remade 57 * 6) whether any of its children has been remade 58 * 7) the number of its children that are, as yet, unmade 59 * 8) its modification time 60 * 9) the modification time of its youngest child (qv. make.c) 61 * 10) a list of nodes for which this is a source 62 * 11) a list of nodes on which this depends 63 * 12) a list of nodes that depend on this, as gleaned from the 64 * transformation rules. 65 * 13) a list of nodes of the same name created by the :: operator 66 * 14) a list of nodes that must be made (if they're made) before 67 * this node can be, but that do no enter into the datedness of 68 * this node. 69 * 15) a list of nodes that must be made (if they're made) after 70 * this node is, but that do not depend on this node, in the 71 * normal sense. 72 * 16) a Lst of ``local'' variables that are specific to this target 73 * and this target only (qv. var.c [$@ $< $?, etc.]) 74 * 17) a Lst of strings that are commands to be given to a shell 75 * to create this target. 76 */ 77 typedef struct GNode { 78 char *name; /* The target's name */ 79 char *path; /* The full pathname of the file */ 80 int type; /* Its type (see the OP flags, below) */ 81 82 Boolean make; /* TRUE if this target needs to be remade */ 83 enum { 84 UNMADE, BEINGMADE, MADE, UPTODATE, ERROR, ABORTED, 85 CYCLE, ENDCYCLE, 86 } made; /* Set to reflect the state of processing 87 * on this node: 88 * UNMADE - Not examined yet 89 * BEINGMADE - Target is already being made. 90 * Indicates a cycle in the graph. (compat 91 * mode only) 92 * MADE - Was out-of-date and has been made 93 * UPTODATE - Was already up-to-date 94 * ERROR - An error occured while it was being 95 * made (used only in compat mode) 96 * ABORTED - The target was aborted due to 97 * an error making an inferior (compat). 98 * CYCLE - Marked as potentially being part of 99 * a graph cycle. If we come back to a 100 * node marked this way, it is printed 101 * and 'made' is changed to ENDCYCLE. 102 * ENDCYCLE - the cycle has been completely 103 * printed. Go back and unmark all its 104 * members. 105 */ 106 Boolean childMade; /* TRUE if one of this target's children was 107 * made */ 108 int unmade; /* The number of unmade children */ 109 110 int mtime; /* Its modification time */ 111 int cmtime; /* The modification time of its youngest 112 * child */ 113 114 Lst iParents; /* Links to parents for which this is an 115 * implied source, if any */ 116 Lst cohorts; /* Other nodes for the :: operator */ 117 Lst parents; /* Nodes that depend on this one */ 118 Lst children; /* Nodes on which this one depends */ 119 Lst successors; /* Nodes that must be made after this one */ 120 Lst preds; /* Nodes that must be made before this one */ 121 122 Lst context; /* The local variables */ 123 Lst commands; /* Creation commands */ 124 125 struct _Suff *suffix; /* Suffix for the node (determined by 126 * Suff_FindDeps and opaque to everyone 127 * but the Suff module) */ 128 } GNode; 129 130 /* 131 * Manifest constants 132 */ 133 #define NILGNODE ((GNode *) NIL) 134 135 /* 136 * The OP_ constants are used when parsing a dependency line as a way of 137 * communicating to other parts of the program the way in which a target 138 * should be made. These constants are bitwise-OR'ed together and 139 * placed in the 'type' field of each node. Any node that has 140 * a 'type' field which satisfies the OP_NOP function was never never on 141 * the lefthand side of an operator, though it may have been on the 142 * righthand side... 143 */ 144 #define OP_DEPENDS 0x00000001 /* Execution of commands depends on 145 * kids (:) */ 146 #define OP_FORCE 0x00000002 /* Always execute commands (!) */ 147 #define OP_DOUBLEDEP 0x00000004 /* Execution of commands depends on kids 148 * per line (::) */ 149 #define OP_OPMASK (OP_DEPENDS|OP_FORCE|OP_DOUBLEDEP) 150 151 #define OP_DONTCARE 0x00000008 /* Don't care if the target doesn't 152 * exist and can't be created */ 153 #define OP_USE 0x00000010 /* Use associated commands for parents */ 154 #define OP_EXEC 0x00000020 /* Target is never out of date, but always 155 * execute commands anyway. Its time 156 * doesn't matter, so it has none...sort 157 * of */ 158 #define OP_IGNORE 0x00000040 /* Ignore errors when creating the node */ 159 #define OP_PRECIOUS 0x00000080 /* Don't remove the target when 160 * interrupted */ 161 #define OP_SILENT 0x00000100 /* Don't echo commands when executed */ 162 #define OP_MAKE 0x00000200 /* Target is a recurrsive make so its 163 * commands should always be executed when 164 * it is out of date, regardless of the 165 * state of the -n or -t flags */ 166 #define OP_JOIN 0x00000400 /* Target is out-of-date only if any of its 167 * children was out-of-date */ 168 #define OP_EXPORT 0x00000800 /* UNUSED: The creation of the target 169 * should be sent somewhere else, if 170 * possible. */ 171 #define OP_NOEXPORT 0x00001000 /* The creation should not be sent 172 * elsewhere */ 173 #define OP_EXPORTSAME 0x00002000 /* Export only to machine with same 174 * architecture */ 175 #define OP_INVISIBLE 0x00004000 /* The node is invisible to its parents. 176 * I.e. it doesn't show up in the parents's 177 * local variables. */ 178 #define OP_NOTMAIN 0x00008000 /* The node is exempt from normal 'main 179 * target' processing in parse.c */ 180 /*XXX*/ 181 #define OP_M68020 0x00010000 /* Command must be run on a 68020 */ 182 /* Attributes applied by PMake */ 183 #define OP_TRANSFORM 0x80000000 /* The node is a transformation rule */ 184 #define OP_MEMBER 0x40000000 /* Target is a member of an archive */ 185 #define OP_LIB 0x20000000 /* Target is a library */ 186 #define OP_ARCHV 0x10000000 /* Target is an archive construct */ 187 #define OP_HAS_COMMANDS 0x08000000 /* Target has all the commands it should. 188 * Used when parsing to catch multiple 189 * commands for a target */ 190 #define OP_SAVE_CMDS 0x04000000 /* Saving commands on .END (Compat) */ 191 #define OP_DEPS_FOUND 0x02000000 /* Already processed by Suff_FindDeps */ 192 193 /* 194 * OP_NOP will return TRUE if the node with the given type was not the 195 * object of a dependency operator 196 */ 197 #define OP_NOP(t) (((t) & OP_OPMASK) == 0x00000000) 198 199 /* 200 * The TARG_ constants are used when calling the Targ_FindNode and 201 * Targ_FindList functions in targ.c. They simply tell the functions what to 202 * do if the desired node(s) is (are) not found. If the TARG_CREATE constant 203 * is given, a new, empty node will be created for the target, placed in the 204 * table of all targets and its address returned. If TARG_NOCREATE is given, 205 * a NIL pointer will be returned. 206 */ 207 #define TARG_CREATE 0x01 /* create node if not found */ 208 #define TARG_NOCREATE 0x00 /* don't create it */ 209 210 /* 211 * There are several places where expandable buffers are used (parse.c and 212 * var.c). This constant is merely the starting point for those buffers. If 213 * lines tend to be much shorter than this, it would be best to reduce BSIZE. 214 * If longer, it should be increased. Reducing it will cause more copying to 215 * be done for longer lines, but will save space for shorter ones. In any 216 * case, it ought to be a power of two simply because most storage allocation 217 * schemes allocate in powers of two. 218 */ 219 #define BSIZE 256 /* starting size for expandable buffers */ 220 221 /* 222 * These constants are all used by the Str_Concat function to decide how the 223 * final string should look. If STR_ADDSPACE is given, a space will be 224 * placed between the two strings. If STR_ADDSLASH is given, a '/' will 225 * be used instead of a space. If neither is given, no intervening characters 226 * will be placed between the two strings in the final output. If the 227 * STR_DOFREE bit is set, the two input strings will be freed before 228 * Str_Concat returns. 229 */ 230 #define STR_ADDSPACE 0x01 /* add a space when Str_Concat'ing */ 231 #define STR_DOFREE 0x02 /* free source strings after concatenation */ 232 #define STR_ADDSLASH 0x04 /* add a slash when Str_Concat'ing */ 233 234 /* 235 * Error levels for parsing. PARSE_FATAL means the process cannot continue 236 * once the makefile has been parsed. PARSE_WARNING means it can. Passed 237 * as the first argument to Parse_Error. 238 */ 239 #define PARSE_WARNING 2 240 #define PARSE_FATAL 1 241 242 /* 243 * Values returned by Cond_Eval. 244 */ 245 #define COND_PARSE 0 /* Parse the next lines */ 246 #define COND_SKIP 1 /* Skip the next lines */ 247 #define COND_INVALID 2 /* Not a conditional statement */ 248 249 /* 250 * Definitions for the "local" variables. Used only for clarity. 251 */ 252 #define TARGET "@" /* Target of dependency */ 253 #define OODATE "?" /* All out-of-date sources */ 254 #define ALLSRC ">" /* All sources */ 255 #define IMPSRC "<" /* Source implied by transformation */ 256 #define PREFIX "*" /* Common prefix */ 257 #define ARCHIVE "!" /* Archive in "archive(member)" syntax */ 258 #define MEMBER "%" /* Member in "archive(member)" syntax */ 259 260 #define FTARGET "@F" /* file part of TARGET */ 261 #define DTARGET "@D" /* directory part of TARGET */ 262 #define FIMPSRC "<F" /* file part of IMPSRC */ 263 #define DIMPSRC "<D" /* directory part of IMPSRC */ 264 #define FPREFIX "*F" /* file part of PREFIX */ 265 #define DPREFIX "*D" /* directory part of PREFIX */ 266 267 /* 268 * Global Variables 269 */ 270 extern Lst create; /* The list of target names specified on the 271 * command line. used to resolve #if 272 * make(...) statements */ 273 extern Lst dirSearchPath; /* The list of directories to search when 274 * looking for targets */ 275 276 extern Boolean ignoreErrors; /* True if should ignore all errors */ 277 extern Boolean beSilent; /* True if should print no commands */ 278 extern Boolean noExecute; /* True if should execute nothing */ 279 extern Boolean allPrecious; /* True if every target is precious */ 280 extern Boolean keepgoing; /* True if should continue on unaffected 281 * portions of the graph when have an error 282 * in one portion */ 283 extern Boolean touchFlag; /* TRUE if targets should just be 'touched' 284 * if out of date. Set by the -t flag */ 285 extern Boolean usePipes; /* TRUE if should capture the output of 286 * subshells by means of pipes. Otherwise it 287 * is routed to temporary files from which it 288 * is retrieved when the shell exits */ 289 extern Boolean queryFlag; /* TRUE if we aren't supposed to really make 290 * anything, just see if the targets are out- 291 * of-date */ 292 293 extern Boolean noWarnings; /* TRUE if should not print warning messages */ 294 extern Boolean noExport; /* TRUE if should not export any jobs */ 295 extern Boolean checkEnvFirst; /* TRUE if environment should be searched for 296 * variables before the global context */ 297 298 extern GNode *DEFAULT; /* .DEFAULT rule */ 299 300 extern GNode *VAR_GLOBAL; /* Variables defined in a global context, e.g 301 * in the Makefile itself */ 302 extern GNode *VAR_CMD; /* Variables defined on the command line */ 303 extern char var_Error[]; /* Value returned by Var_Parse when an error 304 * is encountered. It actually points to 305 * an empty string, so naive callers needn't 306 * worry about it. */ 307 308 extern time_t now; /* The time at the start of this whole 309 * process */ 310 311 /* 312 * Three levels of compatibility. amMake incorporates backwards and oldVars, 313 * backwards incorporates oldVars. 314 */ 315 extern Boolean amMake; /* Go all the way to backwards compatibility: 316 * - Depth-first traversal of the graph 317 * - No paralellism */ 318 extern Boolean backwards; /* Go halfway to backwards compatibility: 319 * - One shell per command */ 320 extern Boolean oldVars; /* Do old-style variable substitution */ 321 extern Boolean sysVmake; /* Imitate System V make in anything weird */ 322 323 /* 324 * Debug control: 325 * There is one bit per module. It is up to the module what debug 326 * information to print. 327 * DEBUG(module) returns TRUE if debugging is on for that module. 328 */ 329 extern int debug; 330 #define DEBUG_SUFF 0x00000001 331 #define DEBUG_MAKE 0x00000002 332 #define DEBUG_JOB 0x00000004 333 #define DEBUG_TARG 0x00000008 334 #define DEBUG_DIR 0x00000010 335 #define DEBUG_VAR 0x00000020 336 #define DEBUG_COND 0x00000040 337 #define DEBUG_PARSE 0x00000080 338 #define DEBUG_RMT 0x00000100 339 #define DEBUG_ARCH 0x00000200 340 341 #ifndef __STDC__ 342 #define I(a) a 343 #define CONCAT(a,b) I(a)b 344 #else 345 #define CONCAT(a,b) a##b 346 #endif /* __STDC__ */ 347 348 #define DEBUG(module) (debug & CONCAT(DEBUG_,module)) 349 350 /* 351 * Since there are so many, all functions that return non-integer values are 352 * extracted by means of a sed script or two and stuck in the file "nonints.h" 353 */ 354 #include "nonints.h" 355 356 #ifdef Sprite 357 #define Str_FindSubstring(s1, s2) strstr(s1, s2) 358 #endif /* Sprite */ 359 360 extern char *index(); 361 extern char *rindex(); 362 extern char *malloc(); 363 364 #endif _MAKE_H_ 365