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