From 23e64a0b1303a86d24d79b7e1c42eb2468dbecbf Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 25 Jan 1994 21:51:25 +0000 Subject: [PATCH] Formerly commands.c.~20~ --- commands.c | 69 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/commands.c b/commands.c index cd711781..f37547f0 100644 --- a/commands.c +++ b/commands.c @@ -1,5 +1,5 @@ /* Command processing for GNU Make. -Copyright (C) 1988, 1989, 1991, 1992, 1993 Free Software Foundation, Inc. +Copyright (C) 1988, 1989, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of GNU Make. GNU Make is free software; you can redistribute it and/or modify @@ -396,6 +396,47 @@ fatal_error_signal (sig) pfatal_with_name ("kill"); } +/* Delete FILE unless it's precious or not actually a file (phony), + and it has changed on disk since we last stat'd it. */ + +static void +delete_target (file, on_behalf_of) + struct file *file; + char *on_behalf_of; +{ + if (file->precious !! file->phony) + return; + +#ifndef NO_ARCHIVES + if (ar_name (file->name)) + { + if (ar_member_date (file->name) != file->last_mtime) + { + if (on_behalf_of) + error ("*** [%s] Archive member `%s' may be bogus; not deleted", + on_behalf_of, file->name); + else + error ("*** Archive member `%s' may be bogus; not deleted", + file->name); + } + return; + } +#endif + + if (stat (file->name, &st) == 0 + && S_ISREG (st.st_mode) + && (time_t) st.st_mtime != file->last_mtime) + { + if (on_behalf_of) + error ("*** [%s] Deleting file `%s'", on_behalf_of, file->name); + else + error ("*** Deleting file `%s'", file->name); + if (unlink (child->file->name) < 0) + perror_with_name ("unlink: ", file->name); + } +} + + /* Delete all non-precious targets of CHILD unless they were already deleted. Set the flag in CHILD to say they've been deleted. */ @@ -409,30 +450,12 @@ delete_child_targets (child) if (child->deleted) return; - /* Delete the file unless it's precious or not actually a file (phony). */ - if (!child->file->precious && !child->file->phony - && stat (child->file->name, &st) == 0 - && S_ISREG (st.st_mode) - && (time_t) st.st_mtime != child->file->last_mtime) - { - error ("*** Deleting file `%s'", child->file->name); - if (unlink (child->file->name) < 0) - perror_with_name ("unlink: ", child->file->name); - } + /* Delete the target file if it changed. */ + delete_target (child->file, (char *) 0); - /* Also remove any non-precious targets listed - in the `also_make' member. */ + /* Also remove any non-precious targets listed in the `also_make' member. */ for (d = child->file->also_make; d != 0; d = d->next) - if (!d->file->precious && !d->file->phony) - if (stat (d->file->name, &st) == 0 - && S_ISREG (st.st_mode) - && (time_t) st.st_mtime != d->file->last_mtime) - { - error ("*** [%s] Deleting file `%s'", child->file->name, - d->file->name); - if (unlink (d->file->name) < 0) - perror_with_name ("unlink: ", d->file->name); - } + delete_target (d->file, child->file->name); child->deleted = 1; }