1*0a6a1f1dSLionel Sambuc /* $NetBSD: make.h,v 1.96 2015/09/21 21:50:16 pooka Exp $ */ 22e2caf59SThomas Veerman 32e2caf59SThomas Veerman /* 42e2caf59SThomas Veerman * Copyright (c) 1988, 1989, 1990, 1993 52e2caf59SThomas Veerman * The Regents of the University of California. All rights reserved. 62e2caf59SThomas Veerman * 72e2caf59SThomas Veerman * This code is derived from software contributed to Berkeley by 82e2caf59SThomas Veerman * Adam de Boor. 92e2caf59SThomas Veerman * 102e2caf59SThomas Veerman * Redistribution and use in source and binary forms, with or without 112e2caf59SThomas Veerman * modification, are permitted provided that the following conditions 122e2caf59SThomas Veerman * are met: 132e2caf59SThomas Veerman * 1. Redistributions of source code must retain the above copyright 142e2caf59SThomas Veerman * notice, this list of conditions and the following disclaimer. 152e2caf59SThomas Veerman * 2. Redistributions in binary form must reproduce the above copyright 162e2caf59SThomas Veerman * notice, this list of conditions and the following disclaimer in the 172e2caf59SThomas Veerman * documentation and/or other materials provided with the distribution. 182e2caf59SThomas Veerman * 3. Neither the name of the University nor the names of its contributors 192e2caf59SThomas Veerman * may be used to endorse or promote products derived from this software 202e2caf59SThomas Veerman * without specific prior written permission. 212e2caf59SThomas Veerman * 222e2caf59SThomas Veerman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 232e2caf59SThomas Veerman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 242e2caf59SThomas Veerman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 252e2caf59SThomas Veerman * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 262e2caf59SThomas Veerman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 272e2caf59SThomas Veerman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 282e2caf59SThomas Veerman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 292e2caf59SThomas Veerman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 302e2caf59SThomas Veerman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 312e2caf59SThomas Veerman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 322e2caf59SThomas Veerman * SUCH DAMAGE. 332e2caf59SThomas Veerman * 342e2caf59SThomas Veerman * from: @(#)make.h 8.3 (Berkeley) 6/13/95 352e2caf59SThomas Veerman */ 362e2caf59SThomas Veerman 372e2caf59SThomas Veerman /* 382e2caf59SThomas Veerman * Copyright (c) 1989 by Berkeley Softworks 392e2caf59SThomas Veerman * All rights reserved. 402e2caf59SThomas Veerman * 412e2caf59SThomas Veerman * This code is derived from software contributed to Berkeley by 422e2caf59SThomas Veerman * Adam de Boor. 432e2caf59SThomas Veerman * 442e2caf59SThomas Veerman * Redistribution and use in source and binary forms, with or without 452e2caf59SThomas Veerman * modification, are permitted provided that the following conditions 462e2caf59SThomas Veerman * are met: 472e2caf59SThomas Veerman * 1. Redistributions of source code must retain the above copyright 482e2caf59SThomas Veerman * notice, this list of conditions and the following disclaimer. 492e2caf59SThomas Veerman * 2. Redistributions in binary form must reproduce the above copyright 502e2caf59SThomas Veerman * notice, this list of conditions and the following disclaimer in the 512e2caf59SThomas Veerman * documentation and/or other materials provided with the distribution. 522e2caf59SThomas Veerman * 3. All advertising materials mentioning features or use of this software 532e2caf59SThomas Veerman * must display the following acknowledgement: 542e2caf59SThomas Veerman * This product includes software developed by the University of 552e2caf59SThomas Veerman * California, Berkeley and its contributors. 562e2caf59SThomas Veerman * 4. Neither the name of the University nor the names of its contributors 572e2caf59SThomas Veerman * may be used to endorse or promote products derived from this software 582e2caf59SThomas Veerman * without specific prior written permission. 592e2caf59SThomas Veerman * 602e2caf59SThomas Veerman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 612e2caf59SThomas Veerman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 622e2caf59SThomas Veerman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 632e2caf59SThomas Veerman * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 642e2caf59SThomas Veerman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 652e2caf59SThomas Veerman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 662e2caf59SThomas Veerman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 672e2caf59SThomas Veerman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 682e2caf59SThomas Veerman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 692e2caf59SThomas Veerman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 702e2caf59SThomas Veerman * SUCH DAMAGE. 712e2caf59SThomas Veerman * 722e2caf59SThomas Veerman * from: @(#)make.h 8.3 (Berkeley) 6/13/95 732e2caf59SThomas Veerman */ 742e2caf59SThomas Veerman 752e2caf59SThomas Veerman /*- 762e2caf59SThomas Veerman * make.h -- 772e2caf59SThomas Veerman * The global definitions for pmake 782e2caf59SThomas Veerman */ 792e2caf59SThomas Veerman 802e2caf59SThomas Veerman #ifndef _MAKE_H_ 812e2caf59SThomas Veerman #define _MAKE_H_ 822e2caf59SThomas Veerman 832e2caf59SThomas Veerman #include <sys/types.h> 842e2caf59SThomas Veerman #include <sys/param.h> 852e2caf59SThomas Veerman 862e2caf59SThomas Veerman #include <ctype.h> 872e2caf59SThomas Veerman #include <stdio.h> 882e2caf59SThomas Veerman #include <stdlib.h> 892e2caf59SThomas Veerman #include <string.h> 902e2caf59SThomas Veerman #include <unistd.h> 912e2caf59SThomas Veerman 922e2caf59SThomas Veerman #ifdef BSD4_4 932e2caf59SThomas Veerman # include <sys/cdefs.h> 942e2caf59SThomas Veerman #endif 952e2caf59SThomas Veerman 962e2caf59SThomas Veerman #if defined(__GNUC__) 972bc7c627SLionel Sambuc #define MAKE_GNUC_PREREQ(x, y) \ 982e2caf59SThomas Veerman ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \ 992e2caf59SThomas Veerman (__GNUC__ > (x))) 1002e2caf59SThomas Veerman #else /* defined(__GNUC__) */ 101eabd612bSAntoine Leca #define MAKE_GNUC_PREREQ(x, y) 0 1022e2caf59SThomas Veerman #endif /* defined(__GNUC__) */ 1032e2caf59SThomas Veerman 1042bc7c627SLionel Sambuc #if MAKE_GNUC_PREREQ(2, 7) 1052bc7c627SLionel Sambuc #define MAKE_ATTR_UNUSED __attribute__((__unused__)) 1062e2caf59SThomas Veerman #else 1072bc7c627SLionel Sambuc #define MAKE_ATTR_UNUSED /* delete */ 1082e2caf59SThomas Veerman #endif 1092e2caf59SThomas Veerman 1102bc7c627SLionel Sambuc #if MAKE_GNUC_PREREQ(2, 5) 1112bc7c627SLionel Sambuc #define MAKE_ATTR_DEAD __attribute__((__noreturn__)) 1122bc7c627SLionel Sambuc #elif defined(__GNUC__) 1132bc7c627SLionel Sambuc #define MAKE_ATTR_DEAD __volatile 1142bc7c627SLionel Sambuc #else 1152bc7c627SLionel Sambuc #define MAKE_ATTR_DEAD /* delete */ 1162bc7c627SLionel Sambuc #endif 1172bc7c627SLionel Sambuc 1182bc7c627SLionel Sambuc #if MAKE_GNUC_PREREQ(2, 7) 1192bc7c627SLionel Sambuc #define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) \ 1202bc7c627SLionel Sambuc __attribute__((__format__ (__printf__, fmtarg, firstvararg))) 1212bc7c627SLionel Sambuc #else 1222bc7c627SLionel Sambuc #define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) /* delete */ 1232e2caf59SThomas Veerman #endif 1242e2caf59SThomas Veerman 1252e2caf59SThomas Veerman #include "sprite.h" 1262e2caf59SThomas Veerman #include "lst.h" 1272e2caf59SThomas Veerman #include "hash.h" 1282e2caf59SThomas Veerman #include "config.h" 1292e2caf59SThomas Veerman #include "buf.h" 1302e2caf59SThomas Veerman #include "make_malloc.h" 1312e2caf59SThomas Veerman 1322e2caf59SThomas Veerman /*- 1332e2caf59SThomas Veerman * The structure for an individual graph node. Each node has several 1342e2caf59SThomas Veerman * pieces of data associated with it. 1352e2caf59SThomas Veerman * 1) the name of the target it describes 1362e2caf59SThomas Veerman * 2) the location of the target file in the file system. 1372e2caf59SThomas Veerman * 3) the type of operator used to define its sources (qv. parse.c) 1382e2caf59SThomas Veerman * 4) whether it is involved in this invocation of make 1392e2caf59SThomas Veerman * 5) whether the target has been remade 1402e2caf59SThomas Veerman * 6) whether any of its children has been remade 1412e2caf59SThomas Veerman * 7) the number of its children that are, as yet, unmade 1422e2caf59SThomas Veerman * 8) its modification time 1432e2caf59SThomas Veerman * 9) the modification time of its youngest child (qv. make.c) 1442e2caf59SThomas Veerman * 10) a list of nodes for which this is a source (parents) 1452e2caf59SThomas Veerman * 11) a list of nodes on which this depends (children) 1462e2caf59SThomas Veerman * 12) a list of nodes that depend on this, as gleaned from the 1472e2caf59SThomas Veerman * transformation rules (iParents) 1482e2caf59SThomas Veerman * 13) a list of ancestor nodes, which includes parents, iParents, 1492e2caf59SThomas Veerman * and recursive parents of parents 1502e2caf59SThomas Veerman * 14) a list of nodes of the same name created by the :: operator 1512e2caf59SThomas Veerman * 15) a list of nodes that must be made (if they're made) before 1522e2caf59SThomas Veerman * this node can be, but that do not enter into the datedness of 1532e2caf59SThomas Veerman * this node. 1542e2caf59SThomas Veerman * 16) a list of nodes that must be made (if they're made) before 1552e2caf59SThomas Veerman * this node or any child of this node can be, but that do not 1562e2caf59SThomas Veerman * enter into the datedness of this node. 1572e2caf59SThomas Veerman * 17) a list of nodes that must be made (if they're made) after 1582e2caf59SThomas Veerman * this node is, but that do not depend on this node, in the 1592e2caf59SThomas Veerman * normal sense. 1602e2caf59SThomas Veerman * 18) a Lst of ``local'' variables that are specific to this target 1612e2caf59SThomas Veerman * and this target only (qv. var.c [$@ $< $?, etc.]) 1622e2caf59SThomas Veerman * 19) a Lst of strings that are commands to be given to a shell 1632e2caf59SThomas Veerman * to create this target. 1642e2caf59SThomas Veerman */ 1652e2caf59SThomas Veerman typedef struct GNode { 1662e2caf59SThomas Veerman char *name; /* The target's name */ 1672e2caf59SThomas Veerman char *uname; /* The unexpanded name of a .USE node */ 1682e2caf59SThomas Veerman char *path; /* The full pathname of the file */ 1692e2caf59SThomas Veerman int type; /* Its type (see the OP flags, below) */ 1702e2caf59SThomas Veerman 1712e2caf59SThomas Veerman int flags; 1722e2caf59SThomas Veerman #define REMAKE 0x1 /* this target needs to be (re)made */ 1732e2caf59SThomas Veerman #define CHILDMADE 0x2 /* children of this target were made */ 1742e2caf59SThomas Veerman #define FORCE 0x4 /* children don't exist, and we pretend made */ 1752e2caf59SThomas Veerman #define DONE_WAIT 0x8 /* Set by Make_ProcessWait() */ 1762e2caf59SThomas Veerman #define DONE_ORDER 0x10 /* Build requested by .ORDER processing */ 1772e2caf59SThomas Veerman #define FROM_DEPEND 0x20 /* Node created from .depend */ 1782e2caf59SThomas Veerman #define DONE_ALLSRC 0x40 /* We do it once only */ 1792e2caf59SThomas Veerman #define CYCLE 0x1000 /* Used by MakePrintStatus */ 1802e2caf59SThomas Veerman #define DONECYCLE 0x2000 /* Used by MakePrintStatus */ 1812e2caf59SThomas Veerman enum enum_made { 1822e2caf59SThomas Veerman UNMADE, DEFERRED, REQUESTED, BEINGMADE, 1832e2caf59SThomas Veerman MADE, UPTODATE, ERROR, ABORTED 1842e2caf59SThomas Veerman } made; /* Set to reflect the state of processing 1852e2caf59SThomas Veerman * on this node: 1862e2caf59SThomas Veerman * UNMADE - Not examined yet 1872e2caf59SThomas Veerman * DEFERRED - Examined once (building child) 1882e2caf59SThomas Veerman * REQUESTED - on toBeMade list 1892e2caf59SThomas Veerman * BEINGMADE - Target is already being made. 1902e2caf59SThomas Veerman * Indicates a cycle in the graph. 1912e2caf59SThomas Veerman * MADE - Was out-of-date and has been made 1922e2caf59SThomas Veerman * UPTODATE - Was already up-to-date 1932e2caf59SThomas Veerman * ERROR - An error occurred while it was being 1942e2caf59SThomas Veerman * made (used only in compat mode) 1952e2caf59SThomas Veerman * ABORTED - The target was aborted due to 1962e2caf59SThomas Veerman * an error making an inferior (compat). 1972e2caf59SThomas Veerman */ 1982e2caf59SThomas Veerman int unmade; /* The number of unmade children */ 1992e2caf59SThomas Veerman 2002e2caf59SThomas Veerman time_t mtime; /* Its modification time */ 2012e2caf59SThomas Veerman struct GNode *cmgn; /* The youngest child */ 2022e2caf59SThomas Veerman 2032e2caf59SThomas Veerman Lst iParents; /* Links to parents for which this is an 2042e2caf59SThomas Veerman * implied source, if any */ 2052e2caf59SThomas Veerman Lst cohorts; /* Other nodes for the :: operator */ 2062e2caf59SThomas Veerman Lst parents; /* Nodes that depend on this one */ 2072e2caf59SThomas Veerman Lst children; /* Nodes on which this one depends */ 2082e2caf59SThomas Veerman Lst order_pred; /* .ORDER nodes we need made */ 2092e2caf59SThomas Veerman Lst order_succ; /* .ORDER nodes who need us */ 2102e2caf59SThomas Veerman 2112e2caf59SThomas Veerman char cohort_num[8]; /* #n for this cohort */ 2122e2caf59SThomas Veerman int unmade_cohorts;/* # of unmade instances on the 2132e2caf59SThomas Veerman cohorts list */ 2142e2caf59SThomas Veerman struct GNode *centurion; /* Pointer to the first instance of a :: 2152e2caf59SThomas Veerman node; only set when on a cohorts list */ 2162e2caf59SThomas Veerman unsigned int checked; /* Last time we tried to makle this node */ 2172e2caf59SThomas Veerman 2182e2caf59SThomas Veerman Hash_Table context; /* The local variables */ 2192e2caf59SThomas Veerman Lst commands; /* Creation commands */ 2202e2caf59SThomas Veerman 2212e2caf59SThomas Veerman struct _Suff *suffix; /* Suffix for the node (determined by 2222e2caf59SThomas Veerman * Suff_FindDeps and opaque to everyone 2232e2caf59SThomas Veerman * but the Suff module) */ 2242e2caf59SThomas Veerman const char *fname; /* filename where the GNode got defined */ 2252e2caf59SThomas Veerman int lineno; /* line number where the GNode got defined */ 2262e2caf59SThomas Veerman } GNode; 2272e2caf59SThomas Veerman 2282e2caf59SThomas Veerman /* 2292e2caf59SThomas Veerman * The OP_ constants are used when parsing a dependency line as a way of 2302e2caf59SThomas Veerman * communicating to other parts of the program the way in which a target 2312e2caf59SThomas Veerman * should be made. These constants are bitwise-OR'ed together and 2322e2caf59SThomas Veerman * placed in the 'type' field of each node. Any node that has 2332e2caf59SThomas Veerman * a 'type' field which satisfies the OP_NOP function was never never on 2342e2caf59SThomas Veerman * the lefthand side of an operator, though it may have been on the 2352e2caf59SThomas Veerman * righthand side... 2362e2caf59SThomas Veerman */ 2372e2caf59SThomas Veerman #define OP_DEPENDS 0x00000001 /* Execution of commands depends on 2382e2caf59SThomas Veerman * kids (:) */ 2392e2caf59SThomas Veerman #define OP_FORCE 0x00000002 /* Always execute commands (!) */ 2402e2caf59SThomas Veerman #define OP_DOUBLEDEP 0x00000004 /* Execution of commands depends on kids 2412e2caf59SThomas Veerman * per line (::) */ 2422e2caf59SThomas Veerman #define OP_OPMASK (OP_DEPENDS|OP_FORCE|OP_DOUBLEDEP) 2432e2caf59SThomas Veerman 2442e2caf59SThomas Veerman #define OP_OPTIONAL 0x00000008 /* Don't care if the target doesn't 2452e2caf59SThomas Veerman * exist and can't be created */ 2462e2caf59SThomas Veerman #define OP_USE 0x00000010 /* Use associated commands for parents */ 2472e2caf59SThomas Veerman #define OP_EXEC 0x00000020 /* Target is never out of date, but always 2482e2caf59SThomas Veerman * execute commands anyway. Its time 2492e2caf59SThomas Veerman * doesn't matter, so it has none...sort 2502e2caf59SThomas Veerman * of */ 2512e2caf59SThomas Veerman #define OP_IGNORE 0x00000040 /* Ignore errors when creating the node */ 2522e2caf59SThomas Veerman #define OP_PRECIOUS 0x00000080 /* Don't remove the target when 2532e2caf59SThomas Veerman * interrupted */ 2542e2caf59SThomas Veerman #define OP_SILENT 0x00000100 /* Don't echo commands when executed */ 2552e2caf59SThomas Veerman #define OP_MAKE 0x00000200 /* Target is a recursive make so its 2562e2caf59SThomas Veerman * commands should always be executed when 2572e2caf59SThomas Veerman * it is out of date, regardless of the 2582e2caf59SThomas Veerman * state of the -n or -t flags */ 2592e2caf59SThomas Veerman #define OP_JOIN 0x00000400 /* Target is out-of-date only if any of its 2602e2caf59SThomas Veerman * children was out-of-date */ 2612e2caf59SThomas Veerman #define OP_MADE 0x00000800 /* Assume the children of the node have 2622e2caf59SThomas Veerman * been already made */ 2632e2caf59SThomas Veerman #define OP_SPECIAL 0x00001000 /* Special .BEGIN, .END, .INTERRUPT */ 2642e2caf59SThomas Veerman #define OP_USEBEFORE 0x00002000 /* Like .USE, only prepend commands */ 2652e2caf59SThomas Veerman #define OP_INVISIBLE 0x00004000 /* The node is invisible to its parents. 2662e2caf59SThomas Veerman * I.e. it doesn't show up in the parents's 2672e2caf59SThomas Veerman * local variables. */ 2682e2caf59SThomas Veerman #define OP_NOTMAIN 0x00008000 /* The node is exempt from normal 'main 2692e2caf59SThomas Veerman * target' processing in parse.c */ 2702e2caf59SThomas Veerman #define OP_PHONY 0x00010000 /* Not a file target; run always */ 2712e2caf59SThomas Veerman #define OP_NOPATH 0x00020000 /* Don't search for file in the path */ 2722e2caf59SThomas Veerman #define OP_WAIT 0x00040000 /* .WAIT phony node */ 2732e2caf59SThomas Veerman #define OP_NOMETA 0x00080000 /* .NOMETA do not create a .meta file */ 2742e2caf59SThomas Veerman #define OP_META 0x00100000 /* .META we _do_ want a .meta file */ 2752e2caf59SThomas Veerman #define OP_NOMETA_CMP 0x00200000 /* Do not compare commands in .meta file */ 276*0a6a1f1dSLionel Sambuc #define OP_SUBMAKE 0x00400000 /* Possibly a submake node */ 2772e2caf59SThomas Veerman /* Attributes applied by PMake */ 2782e2caf59SThomas Veerman #define OP_TRANSFORM 0x80000000 /* The node is a transformation rule */ 2792e2caf59SThomas Veerman #define OP_MEMBER 0x40000000 /* Target is a member of an archive */ 2802e2caf59SThomas Veerman #define OP_LIB 0x20000000 /* Target is a library */ 2812e2caf59SThomas Veerman #define OP_ARCHV 0x10000000 /* Target is an archive construct */ 2822e2caf59SThomas Veerman #define OP_HAS_COMMANDS 0x08000000 /* Target has all the commands it should. 2832e2caf59SThomas Veerman * Used when parsing to catch multiple 2842e2caf59SThomas Veerman * commands for a target */ 2852e2caf59SThomas Veerman #define OP_SAVE_CMDS 0x04000000 /* Saving commands on .END (Compat) */ 2862e2caf59SThomas Veerman #define OP_DEPS_FOUND 0x02000000 /* Already processed by Suff_FindDeps */ 2872e2caf59SThomas Veerman #define OP_MARK 0x01000000 /* Node found while expanding .ALLSRC */ 2882e2caf59SThomas Veerman 2892e2caf59SThomas Veerman #define NoExecute(gn) ((gn->type & OP_MAKE) ? noRecursiveExecute : noExecute) 2902e2caf59SThomas Veerman /* 2912e2caf59SThomas Veerman * OP_NOP will return TRUE if the node with the given type was not the 2922e2caf59SThomas Veerman * object of a dependency operator 2932e2caf59SThomas Veerman */ 2942e2caf59SThomas Veerman #define OP_NOP(t) (((t) & OP_OPMASK) == 0x00000000) 2952e2caf59SThomas Veerman 2962e2caf59SThomas Veerman #define OP_NOTARGET (OP_NOTMAIN|OP_USE|OP_EXEC|OP_TRANSFORM) 2972e2caf59SThomas Veerman 2982e2caf59SThomas Veerman /* 2992e2caf59SThomas Veerman * The TARG_ constants are used when calling the Targ_FindNode and 3002e2caf59SThomas Veerman * Targ_FindList functions in targ.c. They simply tell the functions what to 3012e2caf59SThomas Veerman * do if the desired node(s) is (are) not found. If the TARG_CREATE constant 3022e2caf59SThomas Veerman * is given, a new, empty node will be created for the target, placed in the 3032e2caf59SThomas Veerman * table of all targets and its address returned. If TARG_NOCREATE is given, 3042e2caf59SThomas Veerman * a NULL pointer will be returned. 3052e2caf59SThomas Veerman */ 3062e2caf59SThomas Veerman #define TARG_NOCREATE 0x00 /* don't create it */ 3072e2caf59SThomas Veerman #define TARG_CREATE 0x01 /* create node if not found */ 3082e2caf59SThomas Veerman #define TARG_NOHASH 0x02 /* don't look in/add to hash table */ 3092e2caf59SThomas Veerman 3102e2caf59SThomas Veerman /* 3112e2caf59SThomas Veerman * These constants are all used by the Str_Concat function to decide how the 3122e2caf59SThomas Veerman * final string should look. If STR_ADDSPACE is given, a space will be 3132e2caf59SThomas Veerman * placed between the two strings. If STR_ADDSLASH is given, a '/' will 3142e2caf59SThomas Veerman * be used instead of a space. If neither is given, no intervening characters 3152e2caf59SThomas Veerman * will be placed between the two strings in the final output. If the 3162e2caf59SThomas Veerman * STR_DOFREE bit is set, the two input strings will be freed before 3172e2caf59SThomas Veerman * Str_Concat returns. 3182e2caf59SThomas Veerman */ 3192e2caf59SThomas Veerman #define STR_ADDSPACE 0x01 /* add a space when Str_Concat'ing */ 3202e2caf59SThomas Veerman #define STR_ADDSLASH 0x02 /* add a slash when Str_Concat'ing */ 3212e2caf59SThomas Veerman 3222e2caf59SThomas Veerman /* 3232e2caf59SThomas Veerman * Error levels for parsing. PARSE_FATAL means the process cannot continue 3242e2caf59SThomas Veerman * once the makefile has been parsed. PARSE_WARNING means it can. Passed 3252e2caf59SThomas Veerman * as the first argument to Parse_Error. 3262e2caf59SThomas Veerman */ 3272e2caf59SThomas Veerman #define PARSE_WARNING 2 3282e2caf59SThomas Veerman #define PARSE_FATAL 1 3292e2caf59SThomas Veerman 3302e2caf59SThomas Veerman /* 3312e2caf59SThomas Veerman * Values returned by Cond_Eval. 3322e2caf59SThomas Veerman */ 3332e2caf59SThomas Veerman #define COND_PARSE 0 /* Parse the next lines */ 3342e2caf59SThomas Veerman #define COND_SKIP 1 /* Skip the next lines */ 3352e2caf59SThomas Veerman #define COND_INVALID 2 /* Not a conditional statement */ 3362e2caf59SThomas Veerman 3372e2caf59SThomas Veerman /* 3382e2caf59SThomas Veerman * Definitions for the "local" variables. Used only for clarity. 3392e2caf59SThomas Veerman */ 3402e2caf59SThomas Veerman #define TARGET "@" /* Target of dependency */ 3412e2caf59SThomas Veerman #define OODATE "?" /* All out-of-date sources */ 3422e2caf59SThomas Veerman #define ALLSRC ">" /* All sources */ 3432e2caf59SThomas Veerman #define IMPSRC "<" /* Source implied by transformation */ 3442e2caf59SThomas Veerman #define PREFIX "*" /* Common prefix */ 3452e2caf59SThomas Veerman #define ARCHIVE "!" /* Archive in "archive(member)" syntax */ 3462e2caf59SThomas Veerman #define MEMBER "%" /* Member in "archive(member)" syntax */ 3472e2caf59SThomas Veerman 3482e2caf59SThomas Veerman #define FTARGET "@F" /* file part of TARGET */ 3492e2caf59SThomas Veerman #define DTARGET "@D" /* directory part of TARGET */ 3502e2caf59SThomas Veerman #define FIMPSRC "<F" /* file part of IMPSRC */ 3512e2caf59SThomas Veerman #define DIMPSRC "<D" /* directory part of IMPSRC */ 3522e2caf59SThomas Veerman #define FPREFIX "*F" /* file part of PREFIX */ 3532e2caf59SThomas Veerman #define DPREFIX "*D" /* directory part of PREFIX */ 3542e2caf59SThomas Veerman 3552e2caf59SThomas Veerman /* 3562e2caf59SThomas Veerman * Global Variables 3572e2caf59SThomas Veerman */ 3582e2caf59SThomas Veerman extern Lst create; /* The list of target names specified on the 3592e2caf59SThomas Veerman * command line. used to resolve #if 3602e2caf59SThomas Veerman * make(...) statements */ 3612e2caf59SThomas Veerman extern Lst dirSearchPath; /* The list of directories to search when 3622e2caf59SThomas Veerman * looking for targets */ 3632e2caf59SThomas Veerman 3642e2caf59SThomas Veerman extern Boolean compatMake; /* True if we are make compatible */ 3652e2caf59SThomas Veerman extern Boolean ignoreErrors; /* True if should ignore all errors */ 3662e2caf59SThomas Veerman extern Boolean beSilent; /* True if should print no commands */ 3672e2caf59SThomas Veerman extern Boolean noExecute; /* True if should execute nothing */ 3682e2caf59SThomas Veerman extern Boolean noRecursiveExecute; /* True if should execute nothing */ 3692e2caf59SThomas Veerman extern Boolean allPrecious; /* True if every target is precious */ 3702e2caf59SThomas Veerman extern Boolean keepgoing; /* True if should continue on unaffected 3712e2caf59SThomas Veerman * portions of the graph when have an error 3722e2caf59SThomas Veerman * in one portion */ 3732e2caf59SThomas Veerman extern Boolean touchFlag; /* TRUE if targets should just be 'touched' 3742e2caf59SThomas Veerman * if out of date. Set by the -t flag */ 3752e2caf59SThomas Veerman extern Boolean queryFlag; /* TRUE if we aren't supposed to really make 3762e2caf59SThomas Veerman * anything, just see if the targets are out- 3772e2caf59SThomas Veerman * of-date */ 3782e2caf59SThomas Veerman extern Boolean doing_depend; /* TRUE if processing .depend */ 3792e2caf59SThomas Veerman 3802e2caf59SThomas Veerman extern Boolean checkEnvFirst; /* TRUE if environment should be searched for 3812e2caf59SThomas Veerman * variables before the global context */ 3822e2caf59SThomas Veerman extern Boolean jobServer; /* a jobServer already exists */ 3832e2caf59SThomas Veerman 3842e2caf59SThomas Veerman extern Boolean parseWarnFatal; /* TRUE if makefile parsing warnings are 3852e2caf59SThomas Veerman * treated as errors */ 3862e2caf59SThomas Veerman 3872e2caf59SThomas Veerman extern Boolean varNoExportEnv; /* TRUE if we should not export variables 3882e2caf59SThomas Veerman * set on the command line to the env. */ 3892e2caf59SThomas Veerman 3902e2caf59SThomas Veerman extern GNode *DEFAULT; /* .DEFAULT rule */ 3912e2caf59SThomas Veerman 39284d9c625SLionel Sambuc extern GNode *VAR_INTERNAL; /* Variables defined internally by make 39384d9c625SLionel Sambuc * which should not override those set by 39484d9c625SLionel Sambuc * makefiles. 39584d9c625SLionel Sambuc */ 3962e2caf59SThomas Veerman extern GNode *VAR_GLOBAL; /* Variables defined in a global context, e.g 3972e2caf59SThomas Veerman * in the Makefile itself */ 3982e2caf59SThomas Veerman extern GNode *VAR_CMD; /* Variables defined on the command line */ 3992e2caf59SThomas Veerman extern GNode *VAR_FOR; /* Iteration variables */ 4002e2caf59SThomas Veerman extern char var_Error[]; /* Value returned by Var_Parse when an error 4012e2caf59SThomas Veerman * is encountered. It actually points to 4022e2caf59SThomas Veerman * an empty string, so naive callers needn't 4032e2caf59SThomas Veerman * worry about it. */ 4042e2caf59SThomas Veerman 4052e2caf59SThomas Veerman extern time_t now; /* The time at the start of this whole 4062e2caf59SThomas Veerman * process */ 4072e2caf59SThomas Veerman 4082e2caf59SThomas Veerman extern Boolean oldVars; /* Do old-style variable substitution */ 4092e2caf59SThomas Veerman 4102e2caf59SThomas Veerman extern Lst sysIncPath; /* The system include path. */ 4112e2caf59SThomas Veerman extern Lst defIncPath; /* The default include path. */ 4122e2caf59SThomas Veerman 4132e2caf59SThomas Veerman extern char curdir[]; /* Startup directory */ 4142e2caf59SThomas Veerman extern char *progname; /* The program name */ 4152e2caf59SThomas Veerman extern char *makeDependfile; /* .depend */ 4162bc7c627SLionel Sambuc extern char **savedEnv; /* if we replaced environ this will be non-NULL */ 4172e2caf59SThomas Veerman 4182e2caf59SThomas Veerman /* 4192e2caf59SThomas Veerman * We cannot vfork() in a child of vfork(). 4202e2caf59SThomas Veerman * Most systems do not enforce this but some do. 4212e2caf59SThomas Veerman */ 4222e2caf59SThomas Veerman #define vFork() ((getpid() == myPid) ? vfork() : fork()) 4232e2caf59SThomas Veerman extern pid_t myPid; 4242e2caf59SThomas Veerman 4252e2caf59SThomas Veerman #define MAKEFLAGS ".MAKEFLAGS" 4262e2caf59SThomas Veerman #define MAKEOVERRIDES ".MAKEOVERRIDES" 4272e2caf59SThomas Veerman #define MAKE_JOB_PREFIX ".MAKE.JOB.PREFIX" /* prefix for job target output */ 4282e2caf59SThomas Veerman #define MAKE_EXPORTED ".MAKE.EXPORTED" /* variables we export */ 4292e2caf59SThomas Veerman #define MAKE_MAKEFILES ".MAKE.MAKEFILES" /* all the makefiles we read */ 4302e2caf59SThomas Veerman #define MAKE_LEVEL ".MAKE.LEVEL" /* recursion level */ 4312e2caf59SThomas Veerman #define MAKEFILE_PREFERENCE ".MAKE.MAKEFILE_PREFERENCE" 4322e2caf59SThomas Veerman #define MAKE_DEPENDFILE ".MAKE.DEPENDFILE" /* .depend */ 4332e2caf59SThomas Veerman #define MAKE_MODE ".MAKE.MODE" 43484d9c625SLionel Sambuc #ifndef MAKE_LEVEL_ENV 43584d9c625SLionel Sambuc # define MAKE_LEVEL_ENV "MAKELEVEL" 43684d9c625SLionel Sambuc #endif 4372e2caf59SThomas Veerman 4382e2caf59SThomas Veerman /* 4392e2caf59SThomas Veerman * debug control: 4402e2caf59SThomas Veerman * There is one bit per module. It is up to the module what debug 4412e2caf59SThomas Veerman * information to print. 4422e2caf59SThomas Veerman */ 4432e2caf59SThomas Veerman FILE *debug_file; /* Output written here - default stdout */ 4442e2caf59SThomas Veerman extern int debug; 4452e2caf59SThomas Veerman #define DEBUG_ARCH 0x00001 4462e2caf59SThomas Veerman #define DEBUG_COND 0x00002 4472e2caf59SThomas Veerman #define DEBUG_DIR 0x00004 4482e2caf59SThomas Veerman #define DEBUG_GRAPH1 0x00008 4492e2caf59SThomas Veerman #define DEBUG_GRAPH2 0x00010 4502e2caf59SThomas Veerman #define DEBUG_JOB 0x00020 4512e2caf59SThomas Veerman #define DEBUG_MAKE 0x00040 4522e2caf59SThomas Veerman #define DEBUG_SUFF 0x00080 4532e2caf59SThomas Veerman #define DEBUG_TARG 0x00100 4542e2caf59SThomas Veerman #define DEBUG_VAR 0x00200 4552e2caf59SThomas Veerman #define DEBUG_FOR 0x00400 4562e2caf59SThomas Veerman #define DEBUG_SHELL 0x00800 4572e2caf59SThomas Veerman #define DEBUG_ERROR 0x01000 4582e2caf59SThomas Veerman #define DEBUG_LOUD 0x02000 4592e2caf59SThomas Veerman #define DEBUG_META 0x04000 4602e2caf59SThomas Veerman 4612e2caf59SThomas Veerman #define DEBUG_GRAPH3 0x10000 4622e2caf59SThomas Veerman #define DEBUG_SCRIPT 0x20000 4632e2caf59SThomas Veerman #define DEBUG_PARSE 0x40000 4642e2caf59SThomas Veerman #define DEBUG_CWD 0x80000 4652e2caf59SThomas Veerman 4662e2caf59SThomas Veerman #define CONCAT(a,b) a##b 4672e2caf59SThomas Veerman 4682e2caf59SThomas Veerman #define DEBUG(module) (debug & CONCAT(DEBUG_,module)) 4692e2caf59SThomas Veerman 4702e2caf59SThomas Veerman #include "nonints.h" 4712e2caf59SThomas Veerman 4722e2caf59SThomas Veerman int Make_TimeStamp(GNode *, GNode *); 4732e2caf59SThomas Veerman Boolean Make_OODate(GNode *); 4742e2caf59SThomas Veerman void Make_ExpandUse(Lst); 4752e2caf59SThomas Veerman time_t Make_Recheck(GNode *); 4762e2caf59SThomas Veerman void Make_HandleUse(GNode *, GNode *); 4772e2caf59SThomas Veerman void Make_Update(GNode *); 4782e2caf59SThomas Veerman void Make_DoAllVar(GNode *); 4792e2caf59SThomas Veerman Boolean Make_Run(Lst); 4802e2caf59SThomas Veerman char * Check_Cwd_Cmd(const char *); 4812e2caf59SThomas Veerman void Check_Cwd(const char **); 4822e2caf59SThomas Veerman void PrintOnError(GNode *, const char *); 4832e2caf59SThomas Veerman void Main_ExportMAKEFLAGS(Boolean); 4842e2caf59SThomas Veerman Boolean Main_SetObjdir(const char *); 4852e2caf59SThomas Veerman int mkTempFile(const char *, char **); 4862e2caf59SThomas Veerman int str2Lst_Append(Lst, char *, const char *); 4872e2caf59SThomas Veerman 4882e2caf59SThomas Veerman #ifdef __GNUC__ 4892e2caf59SThomas Veerman #define UNCONST(ptr) ({ \ 4902e2caf59SThomas Veerman union __unconst { \ 4912e2caf59SThomas Veerman const void *__cp; \ 4922e2caf59SThomas Veerman void *__p; \ 4932e2caf59SThomas Veerman } __d; \ 4942e2caf59SThomas Veerman __d.__cp = ptr, __d.__p; }) 4952e2caf59SThomas Veerman #else 4962e2caf59SThomas Veerman #define UNCONST(ptr) (void *)(ptr) 4972e2caf59SThomas Veerman #endif 4982e2caf59SThomas Veerman 4992e2caf59SThomas Veerman #ifndef MIN 5002e2caf59SThomas Veerman #define MIN(a, b) ((a < b) ? a : b) 5012e2caf59SThomas Veerman #endif 5022e2caf59SThomas Veerman #ifndef MAX 5032e2caf59SThomas Veerman #define MAX(a, b) ((a > b) ? a : b) 5042e2caf59SThomas Veerman #endif 5052e2caf59SThomas Veerman 506*0a6a1f1dSLionel Sambuc /* At least GNU/Hurd systems lack hardcoded MAXPATHLEN/PATH_MAX */ 507*0a6a1f1dSLionel Sambuc #include <limits.h> 508*0a6a1f1dSLionel Sambuc #ifndef MAXPATHLEN 509*0a6a1f1dSLionel Sambuc #define MAXPATHLEN 4096 510*0a6a1f1dSLionel Sambuc #endif 511*0a6a1f1dSLionel Sambuc #ifndef PATH_MAX 512*0a6a1f1dSLionel Sambuc #define PATH_MAX MAXPATHLEN 513*0a6a1f1dSLionel Sambuc #endif 514*0a6a1f1dSLionel Sambuc 5152e2caf59SThomas Veerman #endif /* _MAKE_H_ */ 516