=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/make/make.h,v retrieving revision 1.31 retrieving revision 1.32 diff -c -r1.31 -r1.32 *** src/usr.bin/make/make.h 2001/05/03 13:41:08 1.31 --- src/usr.bin/make/make.h 2001/05/23 12:34:46 1.32 *************** *** 1,5 **** /* $OpenPackages$ */ ! /* $OpenBSD: make.h,v 1.31 2001/05/03 13:41:08 espie Exp $ */ /* $NetBSD: make.h,v 1.15 1997/03/10 21:20:00 christos Exp $ */ /* --- 1,8 ---- + #ifndef _MAKE_H_ + #define _MAKE_H_ + /* $OpenPackages$ */ ! /* $OpenBSD: make.h,v 1.32 2001/05/23 12:34:46 espie Exp $ */ /* $NetBSD: make.h,v 1.15 1997/03/10 21:20:00 christos Exp $ */ /* *************** *** 42,459 **** * from: @(#)make.h 8.3 (Berkeley) 6/13/95 */ ! /*- ! * make.h -- ! * The global definitions for pmake ! */ ! ! #ifndef _MAKE_H_ ! #define _MAKE_H_ ! ! #include ! #include ! #include ! #include ! #include ! ! #ifdef __GNUC__ ! # define UNUSED __attribute__((__unused__)) ! # define HAS_INLINES ! # define INLINE __inline__ ! #else ! # define UNUSED ! #endif ! ! #ifdef HAS_INLINES ! # ifndef INLINE ! # define INLINE inline ! # endif ! #endif ! ! #if !defined(MAKE_BOOTSTRAP) && defined(BSD4_4) ! # include ! #endif ! ! #ifdef __STDC__ ! #include ! #include ! #endif ! #include "sprite.h" ! #include "lst.h" ! #include "config.h" ! #include "buf.h" ! ! #ifdef USE_TIMESPEC ! #include ! typedef struct timespec TIMESTAMP; ! #define set_out_of_date(t) (t).tv_sec = INT_MIN, (t).tv_nsec = 0 ! #define is_out_of_date(t) ((t).tv_sec == INT_MIN && (t).tv_nsec == 0) ! #define grab_stat(s, t) \ ! do { \ ! (t).tv_sec = (s).st_mtime; \ ! (t).tv_nsec = (s).st_mtimensec; \ ! if (is_out_of_date(t)) \ ! (t).tv_nsec++; \ ! } while (0) ! #define is_before(t1, t2) timespeccmp(&(t1), &(t2), <) ! #define grab_date(d, t) \ ! do { \ ! (t).tv_sec = d; \ ! (t).tv_nsec = 0; \ ! if (is_out_of_date(t)) \ ! (t).tv_nsec++; \ ! } while (0) ! #define grab(n) \ ! do { \ ! struct timeval tv; \ ! gettimeofday(&tv, NULL); \ ! TIMEVAL_TO_TIMESPEC(&(tv), &n); \ ! } while (0) ! #define timestamp2time_t(t) ((t).tv_sec) ! #else ! typedef time_t TIMESTAMP; ! #define is_out_of_date(t) ((t) == INT_MIN) ! #define set_out_of_date(t) (t) = INT_MIN ! #define grab_stat(s, t) \ ! do { \ ! (t) = (s).st_mtime; \ ! if (is_out_of_date(t)) \ ! (t)++; \ ! } while (0) ! #define is_before(t1, t2) ((t1) < (t2)) ! #define grab_date(d, t) \ ! do { \ ! (t) = d; \ ! if (is_out_of_date(t)) \ ! (t)++; \ ! } while (0) ! #define grab(n) time(&(n)) ! #define timestamp2time_t(t) (t) ! #endif ! ! /* local contexts are real small */ ! #define TARGET_INDEX 0 ! #define PREFIX_INDEX 1 ! #define ARCHIVE_INDEX 2 ! #define MEMBER_INDEX 3 ! #define OODATE_INDEX 4 ! #define ALLSRC_INDEX 5 ! #define IMPSRC_INDEX 6 ! ! #define LOCAL_SIZE 7 ! ! /* extended indices for System V stuff */ ! #define FTARGET_INDEX 7 ! #define DTARGET_INDEX 8 ! #define FPREFIX_INDEX 9 ! #define DPREFIX_INDEX 10 ! #define FARCHIVE_INDEX 11 ! #define DARCHIVE_INDEX 12 ! #define FMEMBER_INDEX 13 ! #define DMEMBER_INDEX 14 ! ! #define EXTENDED2SIMPLE(i) (((i)-LOCAL_SIZE)/2) ! #define IS_EXTENDED_F(i) ((i)%2 == 1) ! ! struct Var_; ! ! /* SymTable is private to var.c, but is declared here to allow for ! local declaration of context tables ! */ ! typedef struct { ! struct Var_ *locals[LOCAL_SIZE]; ! } SymTable; ! ! typedef struct ohash GSymT; ! ! /*- ! * The structure for an individual graph node. Each node has several ! * pieces of data associated with it. ! * 1) the name of the target it describes ! * 2) the location of the target file in the file system. ! * 3) the type of operator used to define its sources (qv. parse.c) ! * 4) whether it is involved in this invocation of make ! * 5) whether the target has been remade ! * 6) whether any of its children has been remade ! * 7) the number of its children that are, as yet, unmade ! * 8) its modification time ! * 9) the modification time of its youngest child (qv. make.c) ! * 10) a list of nodes for which this is a source ! * 11) a list of nodes on which this depends ! * 12) a list of nodes that depend on this, as gleaned from the ! * transformation rules. ! * 13) a list of nodes of the same name created by the :: operator ! * 14) a list of nodes that must be made (if they're made) before ! * this node can be, but that do no enter into the datedness of ! * this node. ! * 15) a list of nodes that must be made (if they're made) after ! * this node is, but that do not depend on this node, in the ! * normal sense. ! * 16) a Lst of ``local'' variables that are specific to this target ! * and this target only (qv. var.c [$@ $< $?, etc.]) ! * 17) a Lst of strings that are commands to be given to a shell ! * to create this target. ! */ ! typedef struct GNode_ { ! char *path; /* The full pathname of the file */ ! int type; /* Its type (see the OP flags, below) */ ! int order; /* Its wait weight */ ! ! Boolean make; /* TRUE if this target needs to be remade */ ! enum { ! UNMADE, BEINGMADE, MADE, UPTODATE, ERROR, ABORTED, ! CYCLE, ENDCYCLE ! } made; /* Set to reflect the state of processing ! * on this node: ! * UNMADE - Not examined yet ! * BEINGMADE - Target is already being made. ! * Indicates a cycle in the graph. (compat ! * mode only) ! * MADE - Was out-of-date and has been made ! * UPTODATE - Was already up-to-date ! * ERROR - An error occured while it was being ! * made (used only in compat mode) ! * ABORTED - The target was aborted due to ! * an error making an inferior (compat). ! * CYCLE - Marked as potentially being part of ! * a graph cycle. If we come back to a ! * node marked this way, it is printed ! * and 'made' is changed to ENDCYCLE. ! * ENDCYCLE - the cycle has been completely ! * printed. Go back and unmark all its ! * members. ! */ ! Boolean childMade; /* TRUE if one of this target's children was ! * made */ ! int unmade; /* The number of unmade children */ ! ! TIMESTAMP mtime; /* Its modification time */ ! TIMESTAMP cmtime; /* The modification time of its youngest ! * child */ ! ! LIST iParents; /* Links to parents for which this is an ! * implied source, if any */ ! LIST cohorts; /* Other nodes for the :: operator */ ! LIST parents; /* Nodes that depend on this one */ ! LIST children; /* Nodes on which this one depends */ ! LIST successors; /* Nodes that must be made after this one */ ! LIST preds; /* Nodes that must be made before this one */ ! ! SymTable context; /* The local variables */ ! unsigned long lineno; /* First line number of commands. */ ! const char * fname; /* File name of commands. */ ! LIST commands; /* Creation commands */ ! LstNode current; /* Current command, for job */ ! ! struct Suff_ *suffix; /* Suffix for the node (determined by ! * Suff_FindDeps and opaque to everyone ! * but the Suff module) */ ! char name[1]; /* The target's name */ ! } GNode; ! ! /* ! * The OP_ constants are used when parsing a dependency line as a way of ! * communicating to other parts of the program the way in which a target ! * should be made. These constants are bitwise-OR'ed together and ! * placed in the 'type' field of each node. Any node that has ! * a 'type' field which satisfies the OP_NOP function was never never on ! * the lefthand side of an operator, though it may have been on the ! * righthand side... ! */ ! #define OP_DEPENDS 0x00000001 /* Execution of commands depends on ! * kids (:) */ ! #define OP_FORCE 0x00000002 /* Always execute commands (!) */ ! #define OP_DOUBLEDEP 0x00000004 /* Execution of commands depends on kids ! * per line (::) */ ! #define OP_OPMASK (OP_DEPENDS|OP_FORCE|OP_DOUBLEDEP) ! ! #define OP_OPTIONAL 0x00000008 /* Don't care if the target doesn't ! * exist and can't be created */ ! #define OP_USE 0x00000010 /* Use associated commands for parents */ ! #define OP_EXEC 0x00000020 /* Target is never out of date, but always ! * execute commands anyway. Its time ! * doesn't matter, so it has none...sort ! * of */ ! #define OP_IGNORE 0x00000040 /* Ignore errors when creating the node */ ! #define OP_PRECIOUS 0x00000080 /* Don't remove the target when ! * interrupted */ ! #define OP_SILENT 0x00000100 /* Don't echo commands when executed */ ! #define OP_MAKE 0x00000200 /* Target is a recurrsive make so its ! * commands should always be executed when ! * it is out of date, regardless of the ! * state of the -n or -t flags */ ! #define OP_JOIN 0x00000400 /* Target is out-of-date only if any of its ! * children was out-of-date */ ! #define OP_MADE 0x00000800 /* Assume the node is already made; even if ! * it really is out of date */ ! #define OP_INVISIBLE 0x00004000 /* The node is invisible to its parents. ! * I.e. it doesn't show up in the parents's ! * local variables. */ ! #define OP_NOTMAIN 0x00008000 /* The node is exempt from normal 'main ! * target' processing in parse.c */ ! #define OP_PHONY 0x00010000 /* Not a file target; run always */ ! #define OP_NOPATH 0x00020000 /* Don't search for file in the path */ ! /* Attributes applied by PMake */ ! #define OP_TRANSFORM 0x80000000 /* The node is a transformation rule */ ! #define OP_MEMBER 0x40000000 /* Target is a member of an archive */ ! #define OP_LIB 0x20000000 /* Target is a library */ ! #define OP_ARCHV 0x10000000 /* Target is an archive construct */ ! #define OP_HAS_COMMANDS 0x08000000 /* Target has all the commands it should. ! * Used when parsing to catch multiple ! * commands for a target */ ! #define OP_SAVE_CMDS 0x04000000 /* Saving commands on .END (Compat) */ ! #define OP_DEPS_FOUND 0x02000000 /* Already processed by Suff_FindDeps */ ! ! /* ! * OP_NOP will return TRUE if the node with the given type was not the ! * object of a dependency operator ! */ ! #define OP_NOP(t) (((t) & OP_OPMASK) == 0x00000000) ! ! #define OP_NOTARGET (OP_NOTMAIN|OP_USE|OP_EXEC|OP_TRANSFORM) ! ! /* ! * The TARG_ constants are used when calling the Targ_FindNode functions targ.c. ! * They simply tell the function what to do if the desired node is not found. ! * If the TARG_CREATE constant is given, a new, empty node will be created ! * for the target, placed in the table of all targets and its address returned. ! * If TARG_NOCREATE is given, a NULL pointer will be returned. ! */ ! #define TARG_CREATE 0x01 /* create node if not found */ ! #define TARG_NOCREATE 0x00 /* don't create it */ ! ! /* ! * There are several places where expandable buffers are used (parse.c and ! * var.c). This constant is merely the starting point for those buffers. If ! * lines tend to be much shorter than this, it would be best to reduce BSIZE. ! * If longer, it should be increased. Reducing it will cause more copying to ! * be done for longer lines, but will save space for shorter ones. In any ! * case, it ought to be a power of two simply because most storage allocation ! * schemes allocate in powers of two. ! */ ! #define MAKE_BSIZE 256 /* starting size for expandable buffers */ ! ! /* ! * Error levels for parsing. PARSE_FATAL means the process cannot continue ! * once the makefile has been parsed. PARSE_WARNING means it can. Passed ! * as the first argument to Parse_Error. ! */ ! #define PARSE_WARNING 2 ! #define PARSE_FATAL 1 ! ! /* ! * Values returned by Cond_Eval. ! */ ! #define COND_PARSE 0 /* Parse the next lines */ ! #define COND_SKIP 1 /* Skip the next lines */ ! #define COND_INVALID 2 /* Not a conditional statement */ ! ! /* ! * Definitions for the "local" variables. Used only for clarity. ! */ ! #define TARGET "@" /* Target of dependency */ ! #define OODATE "?" /* All out-of-date sources */ ! #define ALLSRC ">" /* All sources */ ! #define IMPSRC "<" /* Source implied by transformation */ ! #define PREFIX "*" /* Common prefix */ ! #define ARCHIVE "!" /* Archive in "archive(member)" syntax */ ! #define MEMBER "%" /* Member in "archive(member)" syntax */ ! #define LONGTARGET ".TARGET" ! #define LONGOODATE ".OODATE" ! #define LONGALLSRC ".ALLSRC" ! #define LONGIMPSRC ".IMPSRC" ! #define LONGPREFIX ".PREFIX" ! #define LONGARCHIVE ".ARCHIVE" ! #define LONGMEMBER ".MEMBER" ! ! /* System V extended variables (get directory/file part) */ ! #define FTARGET "@F" ! #define DTARGET "@D" ! #define FIMPSRC "