* remake.c:
	(update_file_1):
	(check_dep): fixed problem with double colon rules and circular
	precursor detection.

	* remake.c (update_file_1): simplified handling of files with no
	command into a single block.

	* remake.c (notice_finished_file): fixed obsolete comment.
diff --git a/ChangeLog b/ChangeLog
index d7dc668..c4022c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,21 @@
+2000-03-13  Tim Magill  <magill@gate.net>
+
+	* remake.c: 
+	(update_file_1): 
+	(check_dep): fixed problem with double colon rules and circular
+	precursor detection.
+
 2000-03-12  Tim Magill  <magill@gate.net>
 
 	* remake.c (update_goal_chain): re-arranged logic so that it makes
 	more sense.  After update_file(), the target status is used to
 	handle the goal and possibly remove it from the goal chain.
 	
+	* remake.c (update_file_1): simplified handling of files with no
+	command into a single block.
+
+	* remake.c (notice_finished_file): fixed obsolete comment.
+
 	* remake.c (update_file): If -q we can bail as soon as we detect
 	that something needs to be remade.
 
diff --git a/remake.c b/remake.c
index e0b1bc0..578cd0d 100644
--- a/remake.c
+++ b/remake.c
@@ -56,6 +56,20 @@
 
   
 
+/* the test for circular dependencies is based just on the 'updating'
+   bit in 'struct file'.  However double colon targets have seperate
+   'struct file's.  Therefore, we will lose if we don't notice that a
+   double colon targets are really the same file.  Use the 'struct
+   file' at the base of the double colon chain. */
+
+#define set_updating(file) (((file)->double_colon ? \
+	(file)->double_colon : (file))->updating = 1)
+#define clr_updating(file) (((file)->double_colon ? \
+	(file)->double_colon : (file))->updating = 0)
+#define tst_updating(file) (((file)->double_colon ? \
+	(file)->double_colon : (file))->updating)
+
+
 /* Incremented when a command is started (under -n, when one would be).  */
 unsigned int commands_started = 0;
 
@@ -373,7 +387,7 @@
   ++depth;
 
   /* Notice recursive update of the same file.  */
-  file->updating = 1;
+  set_updating(file);
 
   /* Looking at the file's modtime beforehand allows the possibility
      that its name may be changed by a VPATH search, and thus it may
@@ -383,27 +397,30 @@
 
   this_mtime = file_mtime (file);
   check_renamed (file);
-  noexist = this_mtime == (FILE_TIMESTAMP) -1;
+  must_make = noexist = this_mtime == (FILE_TIMESTAMP) -1;
   if (noexist)
     DBF (DB_BASIC, _("File `%s' does not exist.\n"));
 
-  must_make = noexist;
+
 
   /* If file was specified as a target with no commands,
      come up with some default commands.  */
 
-  if (!file->phony && file->cmds == 0 && !file->tried_implicit)
+  if (file->cmds == 0) 
     {
-      if (try_implicit_rule (file, depth))
-	DBF (DB_IMPLICIT, _("Found an implicit rule for `%s'.\n"));
-      else
-	DBF (DB_IMPLICIT, _("No implicit rule found for `%s'.\n"));
-    }
-  if (file->cmds == 0 && !file->is_target
-      && default_file != 0 && default_file->cmds != 0)
-    {
-      DBF (DB_IMPLICIT, _("Using default commands for `%s'.\n"));
-      file->cmds = default_file->cmds;
+      if (!file->phony && !file->tried_implicit)
+	{
+	  if (try_implicit_rule (file, depth))
+	    DBF (DB_IMPLICIT, _("Found an implicit rule for `%s'.\n"));
+	  else
+	    DBF (DB_IMPLICIT, _("No implicit rule found for `%s'.\n"));
+	}
+      if (!file->is_target
+	  && default_file != 0 && default_file->cmds != 0)
+	{
+	  DBF (DB_IMPLICIT, _("Using default commands for `%s'.\n"));
+	  file->cmds = default_file->cmds;
+	}
     }
 
   /* Update all non-intermediate files we depend on, if necessary,
@@ -420,7 +437,7 @@
       mtime = file_mtime (d->file);
       check_renamed (d->file);
 
-      if (d->file->updating)
+      if (tst_updating(d->file))
 	{
 	  error (NILF, _("Circular %s <- %s dependency dropped."),
 		 file->name, d->file->name);
@@ -498,7 +515,7 @@
 	  }
     }
 
-  file->updating = 0;
+  clr_updating(file);
 
   DBF (DB_VERBOSE, _("Finished prerequisites of target file `%s'.\n"));
 
@@ -666,9 +683,8 @@
     }
 }
 
-/* Set FILE's `updated' flag and re-check its mtime and the mtime's of all
-   files listed in its `also_make' member.  Under -t, this function also
-   touches FILE.
+/* re-check FILE's mtime and the mtime's of all files listed in its
+   `also_make' member.  Under -t, this function also touches FILE.
 
    On return, FILE->update_status will no longer be -1 if it was.  */
 
@@ -783,7 +799,7 @@
   target_state_t dep_status = ts_done;
 
   ++depth;
-  file->updating = 1;
+  set_updating(file);
 
   if (!file->intermediate)
     /* If this is a non-intermediate file, update it and record
@@ -834,7 +850,7 @@
 	  d = file->deps;
 	  while (d != 0)
 	    {
-	      if (d->file->updating)
+	      if (tst_updating(d->file))
 		{
 		  error (NILF, _("Circular %s <- %s dependency dropped."),
 			 file->name, d->file->name);
@@ -873,7 +889,7 @@
 	}
     }
 
-  file->updating = 0;
+  clr_updating(file);
   return dep_status;
 }