          print("Attempting to move " + file + " to " + targetDir + FILE_SEPARATOR + file)
          _ = try fm.moveItem(atPath:file, toPath: targetDir + FILE_SEPARATOR + file)
       }
+   }
+   
+   //relativePath function - given two filepaths under a common root, determine a relative path from the source to the target
+   func relativePath(sourceFilePath: String, targetFilePath: String) -> String {
+      var sourcePath = sourceFilePath.componentsSeparated(by: FILE_SEPARATOR)
+      var targetPath = targetFilePath.componentsSeparated(by: "/")
+      ///Remove the last elements of the paths (the file names)
+      ///retain the last element of targetPath for reinsertion later
+      let targetFile = targetPath.removeLast()
+      _ = sourcePath.removeLast()
+      //remove common directories from the start of the paths
+      while sourcePath.first == targetPath.first {
+         _ = sourcePath.removeFirst()
+         _ = targetPath.removeFirst()
+      }
+      var targetFilePath = ""
+      for i in 1..sourcePath.count {
+         targetFilePath += "../"
+      }
+      for dir in targetPath {
+         targetFilePath +="\(dir)/"
+      }
+      return targetFilePath + targetFile
    }
 
    let rootDirPath = fm.currentDirectoryPath

   ///Public header file names
   let AGENT_EXTENSIONS = "AgentExtensions.h"

   ///moveSource function
   func moveSource(rootDir: String, pluginSrcDir: String, pluginTargetDir: String) throws {

      ///move plugin source to plugin directories - need to call this from rootDir

       
   }
   _ = fm.changeCurrentDirectoryPath(prevWorkingDir)
   
   //finally, we alter libagentcore's headers to become relative.
   let targetWorkingDir = srcDirPath + FILE_SEPARATOR + AGENT_CORE_DIR
   _ = fm.changeCurrentDirectoryPath(targetWorkingDir)
   print("Attempting to enumerate " + targetWorkingDir)
   fileEnum = fm.enumerator(atPath: targetWorkingDir)
   while let fn = fileEnum?.nextObject() {
      print(fn)
      let fileName = String(fn)
      //ignore the include directory and anything that isn't a header or source file
      if fileName.hasPrefix(IBMRAS_DIR) && (fileName.hasSuffix(".cpp") || fileName.hasSuffix(".h") {
         var fileContents = try String(contentsOfFile: fileName, encoding: encoding)
         fileContents = fileContents.replacingOccurrences(of: "#include \"(" + IBMRAS_DIR + ".*?)\"", 
                                                          with:"#include \"\(relativePath(fileName, $1))\"",
                                                          options: .regularExpressionSearch)
         try fileContents.write(toFile: fileName, atomically: true, encoding: encoding)
      }
   }
   
}

#if os(Linux)
