diff --git a/wmake/wmakeFunctions b/wmake/wmakeFunctions
index 2007467ae7d0efd36487ab3fce6c91a0464bc0ff..c011519b87b9e8a6bbb39cca38b34d9f4b2d396f 100755
--- a/wmake/wmakeFunctions
+++ b/wmake/wmakeFunctions
@@ -26,7 +26,7 @@
 #     wdepFunctions
 #
 # Description
-#     Functions to check wmake environment and find dep files
+#     Functions to check wmake environment and find .dep and .o files
 #------------------------------------------------------------------------------
 
 #------------------------------------------------------------------------------
@@ -51,11 +51,12 @@ checkEnv()
 
 expandPath()
 {
-    dir=$(dirname $1)
-    cwd=$PWD
-    cd $dir
-    exPath=$PWD
-    cd $cwd
+    if [ -d "$1" ]
+    then
+        exPath=$(cd "$1" && pwd -P)
+    else
+        exPath=$(cd $(dirname "$1") && pwd -P)
+    fi
 }
 
 findTarget()
@@ -97,5 +98,10 @@ findObjectDir()
     fi
 }
 
+depToSource()
+{
+    sourceFile=$(echo ${depFile%.dep} | \
+        sed -e s%platforms/${WM_OPTIONS}/%% -e s%Make/${WM_OPTIONS}/%% )
+}
 
 #------------------------------------------------------------------------------
diff --git a/bin/rmdepold b/wmake/wrmdepold
similarity index 69%
rename from bin/rmdepold
rename to wmake/wrmdepold
index cd0b80f7f7fd5a737321b506e356dd2ca85c78e3..b52a18bce6b7ac0601353e4018fb584557e9788a 100755
--- a/bin/rmdepold
+++ b/wmake/wrmdepold
@@ -3,7 +3,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+#   \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
 #    \\/     M anipulation  |
 #-------------------------------------------------------------------------------
 # License
@@ -23,21 +23,28 @@
 #     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 #
 # Script
-#     rmdepold
+#     wrmdepold
 #
 # Description
-#     Usage: rmdepold [dir1 .. dirN]
+#     Usage: wrmdepold [dir1 .. dirN]
 #
-#     Remove *.dep files that are without a corresponding .C or .L file.
+#     Remove *.dep files that are without a corresponding .C or .L source file.
 #     This often occurs when a directory has been moved.
 #         - print questionable directory and the *.dep file
 #         - optionally remove empty directories
 #------------------------------------------------------------------------------
+Script=${0##*/}
+
+# Source the wdep functions
+. ${0%/*}/wmakeFunctions
+
+set -x
+
 usage() {
     exec 1>&2
     while [ "$#" -ge 1 ]; do echo "$1"; shift; done
     cat<<USAGE
-Usage: ${0##*/} [OPTION] [dir1 .. dirN]
+Usage: $Script [OPTION] [dir1 .. dirN]
 options:
   -rmdir      find and remove empty directories (recursively)
 
@@ -50,6 +57,11 @@ USAGE
     exit 1
 }
 
+
+#------------------------------------------------------------------------------
+# Parse arguments and options
+#------------------------------------------------------------------------------
+
 unset optRmdir
 
 # parse options
@@ -72,38 +84,52 @@ do
     esac
 done
 
-# default is the current directory
+# Check environment variables
+checkEnv
+
+
+#------------------------------------------------------------------------------
+#
+#------------------------------------------------------------------------------
+
+# Default is the current directory
 [ "$#" -gt 0 ] || set -- .
 
 for checkDir
 do
-    if [ -d $checkDir ]
+    findObjectDir $checkDir
+
+    if [ -d $objectsDir ]
     then
-        echo "searching: $checkDir"
+        echo "Searching: $objectsDir"
     else
-        echo "skipping non-dir: $checkDir"
+        echo "Skipping non-dir: $objectsDir"
         continue
     fi
 
-    find $checkDir -name '*.dep' -print | while read depFile
+    find $objectsDir -name '*.dep' -print | while read depFile
     do
-        # check C++ and Flex files
-        if [ ! -r "${depFile%dep}C" -a ! -r "${depFile%dep}L" ];
+        depToSource $depFile
+
+        # Check C++ or Flex source file exists
+        if [ ! -r "$sourceFile" ];
         then
             echo "rm $depFile"
             rm -f $depFile 2>/dev/null
         fi
     done
 
-    # remove empty dirs
+    # Remove empty dirs
     if [ "$optRmdir" ]
     then
         # get subdirs ourselves so we can avoid particular directories
-        for dir in $(find $checkDir -mindepth 1 -maxdepth 1 -type d \( -name .git -prune -o -print \) )
+        for dir in $(find $objectsDir -mindepth 1 -maxdepth 1 -type d \( -name .git -prune -o -print \) )
         do
             echo "check dir: $dir"
             find $dir -depth -type d -empty -exec rmdir {} \; -print
         done
     fi
 done
+
+
 # -----------------------------------------------------------------------------