Annotation of 43BSDReno/usr.bin/make/make.h, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.