diff options
author | fjoe <fjoe@FreeBSD.org> | 2009-04-07 19:49:38 +0000 |
---|---|---|
committer | fjoe <fjoe@FreeBSD.org> | 2009-04-07 19:49:38 +0000 |
commit | aff2f6a35ad17ffbe8f70440692c7429673cfa57 (patch) | |
tree | 62328bf7f402678c38010811a1c3b152881cb521 /usr.bin | |
parent | c19a362092c477c7ba8435cb7f9756152848d978 (diff) | |
download | FreeBSD-src-aff2f6a35ad17ffbe8f70440692c7429673cfa57.zip FreeBSD-src-aff2f6a35ad17ffbe8f70440692c7429673cfa57.tar.gz |
Avoid infinite loops when remaking makefiles not only
for Makefile targets but also for targets they depend on.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/make/globals.h | 1 | ||||
-rw-r--r-- | usr.bin/make/main.c | 38 | ||||
-rw-r--r-- | usr.bin/make/make.1 | 2 | ||||
-rw-r--r-- | usr.bin/make/make.c | 26 |
4 files changed, 26 insertions, 41 deletions
diff --git a/usr.bin/make/globals.h b/usr.bin/make/globals.h index c2e1f11..6f75eaf 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 6ccc59b..0e16506 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 */ @@ -732,41 +733,6 @@ Remake_Makefiles(void) 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 * command line @@ -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 736f279..a4e837c 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 835e855..a6ddc85 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; |