diff --git a/usr.bin/make/globals.h b/usr.bin/make/globals.h index c2e1f1116bc1..6f75eafcb270 100644 --- a/usr.bin/make/globals.h +++ b/usr.bin/make/globals.h @@ -81,6 +81,7 @@ extern Boolean noExecute; /* True if should execute nothing */ extern Boolean allPrecious; /* True if every target is precious */ extern Boolean is_posix; /* .POSIX target seen */ extern Boolean mfAutoDeps; /* .MAKEFILEDEPS target seen */ +extern Boolean remakingMakefiles; /* True if remaking makefiles is in progress */ /* True if should continue on unaffected portions of the graph * when have an error in one portion */ diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 6ccc59bb781a..0e165062c1bb 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -124,6 +124,7 @@ Lst create = Lst_Initializer(create); Boolean allPrecious; /* .PRECIOUS given on line by itself */ Boolean is_posix; /* .POSIX target seen */ Boolean mfAutoDeps; /* .MAKEFILEDEPS target seen */ +Boolean remakingMakefiles; /* True if remaking makefiles is in progress */ Boolean beSilent; /* -s flag */ Boolean beVerbose; /* -v flag */ Boolean beQuiet; /* -Q flag */ @@ -731,41 +732,6 @@ Remake_Makefiles(void) DEBUGF(MAKE, ("Checking %s...", gn->name)); Suff_FindDeps(gn); - /* - * ! dependencies as well as - * dependencies with .FORCE, .EXEC and .PHONY attributes - * are skipped to prevent infinite loops - */ - if (gn->type & (OP_FORCE | OP_EXEC | OP_PHONY)) { - DEBUGF(MAKE, ("skipping (force, exec or phony).\n", - gn->name)); - continue; - } - - /* - * Skip :: targets that have commands and no children - * because such targets are always out-of-date - */ - if ((gn->type & OP_DOUBLEDEP) && - !Lst_IsEmpty(&gn->commands) && - Lst_IsEmpty(&gn->children)) { - DEBUGF(MAKE, ("skipping (doubledep, no sources " - "and has commands).\n")); - continue; - } - - /* - * Skip targets without sources and without commands - */ - if (Lst_IsEmpty(&gn->commands) && - Lst_IsEmpty(&gn->children)) { - DEBUGF(MAKE, - ("skipping (no sources and no commands).\n")); - continue; - } - - DEBUGF(MAKE, ("\n")); - /* * -t, -q and -n has no effect unless the makefile is * specified as one of the targets explicitly in the @@ -787,7 +753,9 @@ Remake_Makefiles(void) * Check and remake the makefile */ mtime = Dir_MTime(gn); + remakingMakefiles = TRUE; Compat_Make(gn, gn); + remakingMakefiles = FALSE; /* * Restore -t, -q and -n behaviour diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1 index 736f27976649..a4e837ceba49 100644 --- a/usr.bin/make/make.1 +++ b/usr.bin/make/make.1 @@ -1629,7 +1629,7 @@ To prevent infinite loops the following source Makefile targets are ignored: .Bl -bullet .It .Ic :: -targets that have no prerequisites but have commands +targets that have no prerequisites .It .Ic ! targets diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c index 835e855aee6d..a6ddc85d4c8d 100644 --- a/usr.bin/make/make.c +++ b/usr.bin/make/make.c @@ -211,11 +211,15 @@ Make_OODate(GNode *gn) } else { DEBUGF(MAKE, (".EXEC node...")); } - oodate = TRUE; - } else if ((gn->mtime < gn->cmtime) || - ((gn->cmtime == 0) && - ((gn->mtime==0) || (gn->type & OP_DOUBLEDEP)))) { + if (remakingMakefiles) { + DEBUGF(MAKE, ("skipping (remaking makefiles)...")); + oodate = FALSE; + } else { + oodate = TRUE; + } + } else if (gn->mtime < gn->cmtime || + (gn->cmtime == 0 && (gn->mtime == 0 || (gn->type & OP_DOUBLEDEP)))) { /* * A node whose modification time is less than that of its * youngest child or that has no children (cmtime == 0) and @@ -226,12 +230,24 @@ Make_OODate(GNode *gn) if (gn->mtime < gn->cmtime) { DEBUGF(MAKE, ("modified before source (%s)...", gn->cmtime_gn ? gn->cmtime_gn->path : "???")); + oodate = TRUE; } else if (gn->mtime == 0) { DEBUGF(MAKE, ("non-existent and no sources...")); + if (remakingMakefiles && Lst_IsEmpty(&gn->commands)) { + DEBUGF(MAKE, ("skipping (no commands and remaking makefiles)...")); + oodate = FALSE; + } else { + oodate = TRUE; + } } else { DEBUGF(MAKE, (":: operator and no sources...")); + if (remakingMakefiles) { + DEBUGF(MAKE, ("skipping (remaking makefiles)...")); + oodate = FALSE; + } else { + oodate = TRUE; + } } - oodate = TRUE; } else oodate = FALSE;