Index: /trunk/src/kmk/commands.c
===================================================================
--- /trunk/src/kmk/commands.c	(revision 2593)
+++ /trunk/src/kmk/commands.c	(revision 2594)
@@ -116,4 +116,48 @@
 
 #endif /* CONFIG_WITH_STRCACHE2 */
+
+#ifdef CONFIG_WITH_LAZY_DEPS_VARS
+/* Create as copy of DEPS without duplicates, similar to what
+   set_file_variables does.  Used by func_deps.  */
+
+struct dep *create_uniqute_deps_chain (struct dep *deps)
+{
+  struct dep *d;
+  struct dep *head = NULL;
+  struct dep **ppnext= &head;
+  struct hash_table dep_hash;
+  void **slot;
+
+  hash_init (&dep_hash, 500, dep_hash_1, dep_hash_2, dep_hash_cmp);
+
+  for (d = deps; d != 0; d = d->next)
+    {
+      if (d->need_2nd_expansion)
+        continue;
+
+      slot = hash_find_slot (&dep_hash, d);
+      if (HASH_VACANT (*slot))
+        {
+          struct dep *n = alloc_dep();
+          *n = *d;
+          n->next = NULL;
+          *ppnext = n;
+          ppnext = &n->next;
+          hash_insert_at (&dep_hash, n, slot);
+        }
+      else
+        {
+          /* Upgrade order only if a normal dep exists.
+             Note! Elected not to upgrade the original, only the sanitized
+                   list, need to check that out later. FIXME TODO */
+          struct dep *d2 = (struct dep *)*slot;
+          if (d->ignore_mtime != d2->ignore_mtime)
+            d->ignore_mtime = d2->ignore_mtime = 0;
+        }
+    }
+
+  return head;
+}
+#endif /* CONFIG_WITH_LAZY_DEPS_VARS */
 
 /* Set FILE's automatic variables up.  */
@@ -451,18 +495,4 @@
     DEFINE_VARIABLE ("|", 1, bar_value);
   }
-#ifdef CONFIG_WITH_LAZY_DEPS_VARS
-  else
-    {
-      /* Make a copy of the current dependency chain for later use in
-         potential $(dep-pluss $@) calls.  Then drop duplicate deps.  */
-
-      /* assert (file->org_deps == NULL); - FIXME? */
-      free_dep_chain (file->org_deps);
-      file->org_deps = copy_dep_chain (file->deps);
-
-      /** @todo do uniquize_deps (file->deps); in the $(dep-* ) functions, it'll
-       *        save even more space that way. */
-   }
-#endif /* CONFIG_WITH_LAZY_DEPS_VARS */
 #undef	DEFINE_VARIABLE
 }
Index: /trunk/src/kmk/commands.h
===================================================================
--- /trunk/src/kmk/commands.h	(revision 2593)
+++ /trunk/src/kmk/commands.h	(revision 2594)
@@ -62,2 +62,6 @@
 void set_file_variables (struct file *file);
 #endif
+#ifdef CONFIG_WITH_LAZY_DEPS_VARS
+struct dep *create_uniqute_deps_chain (struct dep *deps);
+#endif
+
Index: /trunk/src/kmk/filedef.h
===================================================================
--- /trunk/src/kmk/filedef.h	(revision 2593)
+++ /trunk/src/kmk/filedef.h	(revision 2594)
@@ -31,6 +31,6 @@
     struct dep *deps;		/* all dependencies, including duplicates */
 #ifdef CONFIG_WITH_LAZY_DEPS_VARS
-    struct dep *org_deps;	/* original dependencies before
-                                   duplicates were dropped. */
+    struct dep *deps_no_dupes;	/* dependencies without duplicates, created on
+                                   demaned by func_deps. */
 #endif
     struct commands *cmds;	/* Commands to execute for this target.  */
Index: /trunk/src/kmk/function.c
===================================================================
--- /trunk/src/kmk/function.c	(revision 2593)
+++ /trunk/src/kmk/function.c	(revision 2594)
@@ -3004,5 +3004,5 @@
 /* Implements $^ and $+.
 
-   The first is somes with with FUNCNAME 'deps', the second as 'deps-all'.
+   The first comes with FUNCNAME 'deps', the second as 'deps-all'.
 
    If no second argument is given, or if it's empty, or if it's zero,
@@ -3040,7 +3040,14 @@
   if (file)
     {
-      struct dep *deps = funcname[4] != '\0' && file->org_deps
-                       ? file->org_deps : file->deps;
+      struct dep *deps;
       struct dep *d;
+      if (funcname[4] == '\0')
+        {
+          deps = file->deps_no_dupes;
+          if (!deps && file->deps)
+            deps = file->deps = create_uniqute_deps_chain (file->deps);
+        }
+      else
+        deps = file->deps;
 
       if (   file->double_colon
