diff --git a/wmake/wmakeCollect b/wmake/wmakeCollect
index c0435e4af5e57ec2062e2f46909e65ea6c40e5fa..99c7413ae701523eb8eb01da0083fbab263fa01e 100755
--- a/wmake/wmakeCollect
+++ b/wmake/wmakeCollect
@@ -125,12 +125,12 @@ then
     # Make sure directories exist
     mkdir -p $collectDir
 
-    # Unique file name for makefile for the current target
-    file="$collectDir/$$_${RANDOM}"
-
     # The current target
     object="${@: -1:1}"
 
+    # Create a unique name for the makefile from the object path
+    file=$collectDir/${object////_}
+
     # Add the current target to the list of objects
     echo "OBJECTS += $object" >> $file