summaryrefslogtreecommitdiff
path: root/commands.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1994-01-25 21:51:25 +0000
committerRoland McGrath <roland@redhat.com>1994-01-25 21:51:25 +0000
commit23e64a0b1303a86d24d79b7e1c42eb2468dbecbf (patch)
treedecbd037ddac4506598379a04f27ace379ed5168 /commands.c
parent1c0df127f875956392877048fa67d83ee56099d4 (diff)
downloadgunmake-23e64a0b1303a86d24d79b7e1c42eb2468dbecbf.tar.gz
Formerly commands.c.~20~
Diffstat (limited to 'commands.c')
-rw-r--r--commands.c69
1 files changed, 46 insertions, 23 deletions
diff --git a/commands.c b/commands.c
index cd71178..f37547f 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;
}