version 1.15, 2007/11/17 16:32:04 |
version 1.16, 2007/11/17 16:39:45 |
|
|
#include "error.h" |
#include "error.h" |
#include "str.h" |
#include "str.h" |
#include "memory.h" |
#include "memory.h" |
|
#include "buf.h" |
|
|
static void MakeTimeStamp(void *, void *); |
static void MakeTimeStamp(void *, void *); |
static void MakeAddAllSrc(void *, void *); |
|
static int rewrite_time(const char *); |
static int rewrite_time(const char *); |
static void setup_signal(int); |
static void setup_signal(int); |
static void setup_all_signals(void); |
static void setup_all_signals(void); |
|
|
* attributes or sources attached to .DEFAULT itself. |
* attributes or sources attached to .DEFAULT itself. |
*/ |
*/ |
Make_HandleUse(DEFAULT, gn); |
Make_HandleUse(DEFAULT, gn); |
Varq_Set(IMPSRC_INDEX, Varq_Value(TARGET_INDEX, gn), gn); |
Var(IMPSRC_INDEX, gn) = Var(TARGET_INDEX, gn); |
} else if (is_out_of_date(Dir_MTime(gn))) { |
} else if (is_out_of_date(Dir_MTime(gn))) { |
/* |
/* |
* The node wasn't the target of an operator we have no |
* The node wasn't the target of an operator we have no |
|
|
} |
} |
} |
} |
|
|
static void |
void |
MakeAddAllSrc(void *cgnp, void *pgnp) |
Make_DoAllVar(GNode *gn) |
{ |
{ |
GNode *child = (GNode *)cgnp; |
GNode *child; |
GNode *parent = (GNode *)pgnp; |
LstNode ln; |
if ((child->type & (OP_EXEC|OP_USE|OP_INVISIBLE)) == 0) { |
BUFFER allsrc, oodate; |
const char *target; |
char *target; |
|
bool do_oodate; |
|
int oodate_count, allsrc_count = 0; |
|
|
|
oodate_count = 0; |
|
allsrc_count = 0; |
|
|
|
for (ln = Lst_First(&gn->children); ln != NULL; ln = Lst_Adv(ln)) { |
|
child = (GNode *)Lst_Datum(ln); |
|
if ((child->type & (OP_EXEC|OP_USE|OP_INVISIBLE)) != 0) |
|
continue; |
if (OP_NOP(child->type) || |
if (OP_NOP(child->type) || |
(target = Varq_Value(TARGET_INDEX, child)) == NULL) { |
(target = Var(TARGET_INDEX, child)) == NULL) { |
/* |
/* |
* this node is only source; use the specific pathname |
* this node is only source; use the specific pathname |
* for it |
* for it |
|
|
child->name; |
child->name; |
} |
} |
|
|
Varq_Append(ALLSRC_INDEX, target, parent); |
/* |
if (parent->type & OP_JOIN) { |
* It goes in the OODATE variable if the parent is younger than |
|
* the child or if the child has been modified more recently |
|
* than the start of the make. This is to keep make from |
|
* getting confused if something else updates the parent after |
|
* the make starts (shouldn't happen, I know, but sometimes it |
|
* does). In such a case, if we've updated the kid, the parent |
|
* is likely to have a modification time later than that of the |
|
* kid and anything that relies on the OODATE variable will be |
|
* hosed. |
|
*/ |
|
do_oodate = false; |
|
if (gn->type & OP_JOIN) { |
if (child->built_status == MADE) |
if (child->built_status == MADE) |
Varq_Append(OODATE_INDEX, target, parent); |
do_oodate = true; |
} else if (is_strictly_before(parent->mtime, child->mtime) || |
} else if (is_strictly_before(gn->mtime, child->mtime) || |
(!is_strictly_before(child->mtime, now) && |
(!is_strictly_before(child->mtime, now) && |
child->built_status == MADE)) { |
child->built_status == MADE)) |
/* |
do_oodate = true; |
* It goes in the OODATE variable if the parent is |
if (do_oodate) { |
* younger than the child or if the child has been |
oodate_count++; |
* modified more recently than the start of the make. |
if (oodate_count == 1) |
* This is to keep make from getting confused if |
Var(OODATE_INDEX, gn) = target; |
* something else updates the parent after the |
else { |
* make starts (shouldn't happen, I know, but sometimes |
if (oodate_count == 2) { |
* it does). In such a case, if we've updated the kid, |
Buf_Init(&oodate, 0); |
* the parent is likely to have a modification time |
Buf_AddString(&oodate, |
* later than that of the kid and anything that relies |
Var(OODATE_INDEX, gn)); |
* on the OODATE variable will be hosed. |
} |
*/ |
Buf_AddSpace(&oodate); |
Varq_Append(OODATE_INDEX, target, parent); |
Buf_AddString(&oodate, target); |
|
} |
} |
} |
|
allsrc_count++; |
|
if (allsrc_count == 1) |
|
Var(ALLSRC_INDEX, gn) = target; |
|
else { |
|
if (allsrc_count == 2) { |
|
Buf_Init(&allsrc, 0); |
|
Buf_AddString(&allsrc, |
|
Var(ALLSRC_INDEX, gn)); |
|
} |
|
Buf_AddSpace(&allsrc); |
|
Buf_AddString(&allsrc, target); |
|
} |
} |
} |
} |
|
|
|
void |
if (allsrc_count > 1) |
Make_DoAllVar(GNode *gn) |
Var(ALLSRC_INDEX, gn) = Buf_Retrieve(&allsrc); |
{ |
if (oodate_count > 1) |
Lst_ForEach(&gn->children, MakeAddAllSrc, gn); |
Var(OODATE_INDEX, gn) = Buf_Retrieve(&oodate); |
|
|
if (gn->impliedsrc) |
if (gn->impliedsrc) |
Varq_Set(IMPSRC_INDEX, |
Var(IMPSRC_INDEX, gn) = Var(TARGET_INDEX, gn->impliedsrc); |
Varq_Value(TARGET_INDEX, gn->impliedsrc), gn); |
|
|
|
if (Varq_Value(OODATE_INDEX, gn) == NULL) |
|
Varq_Set(OODATE_INDEX, "", gn); |
|
if (Varq_Value(ALLSRC_INDEX, gn) == NULL) |
|
Varq_Set(ALLSRC_INDEX, "", gn); |
|
|
|
if (gn->type & OP_JOIN) |
if (gn->type & OP_JOIN) |
Varq_Set(TARGET_INDEX, Varq_Value(ALLSRC_INDEX, gn), gn); |
Var(TARGET_INDEX, gn) = Var(ALLSRC_INDEX, gn); |
} |
} |
|
|
/* Wrapper to call Make_TimeStamp from a forEach loop. */ |
/* Wrapper to call Make_TimeStamp from a forEach loop. */ |
|
|
handle_compat_interrupts(GNode *gn) |
handle_compat_interrupts(GNode *gn) |
{ |
{ |
if (!Targ_Precious(gn)) { |
if (!Targ_Precious(gn)) { |
char *file = Varq_Value(TARGET_INDEX, gn); |
char *file = Var(TARGET_INDEX, gn); |
|
|
if (!noExecute && eunlink(file) != -1) |
if (!noExecute && eunlink(file) != -1) |
Error("*** %s removed\n", file); |
Error("*** %s removed\n", file); |