diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 0e165062c1bb..eec6bbf1e247 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -706,6 +706,7 @@ Main_AddSourceMakefile(const char *name) static void Remake_Makefiles(void) { + Lst cleanup; LstNode *ln; int error_cnt = 0; int remade_cnt = 0; @@ -716,6 +717,7 @@ Remake_Makefiles(void) Fatal("Failed to change directory to %s.", curdir); } + Lst_Init(&cleanup); LST_FOREACH(ln, &source_makefiles) { LstNode *ln2; struct GNode *gn; @@ -791,21 +793,7 @@ Remake_Makefiles(void) gn->name); error_cnt++; } else if (gn->made == UPTODATE) { - Lst examine; - - Lst_Init(&examine); - Lst_EnQueue(&examine, gn); - while (!Lst_IsEmpty(&examine)) { - LstNode *eln; - GNode *egn = Lst_DeQueue(&examine); - - egn->make = FALSE; - LST_FOREACH(eln, &egn->children) { - GNode *cgn = Lst_Datum(eln); - - Lst_EnQueue(&examine, cgn); - } - } + Lst_EnQueue(&cleanup, gn); } } @@ -827,6 +815,24 @@ Remake_Makefiles(void) } } + while (!Lst_IsEmpty(&cleanup)) { + GNode *gn = Lst_DeQueue(&cleanup); + + gn->unmade = 0; + gn->make = FALSE; + gn->made = UNMADE; + gn->childMade = FALSE; + gn->mtime = gn->cmtime = 0; + gn->cmtime_gn = NULL; + + LST_FOREACH(ln, &gn->children) { + GNode *cgn = Lst_Datum(ln); + + gn->unmade++; + Lst_EnQueue(&cleanup, cgn); + } + } + if (curdir != objdir) { if (chdir(objdir) < 0) Fatal("Failed to change directory to %s.", objdir);