buildsystem,epj2make,ide: add the optional use of resources.ear before target linking...
[sdk] / ide / src / project / Project.ec
index 044a05d..8934619 100644 (file)
@@ -21,7 +21,7 @@ import "IDESettings"
 
 default:
 
-static void DummyFunction()
+static __attribute__((unused)) void DummyFunction()
 {
 int a;
 a.OnFree();
@@ -42,8 +42,8 @@ IDESettingsContainer settingsContainer
 
    void OnLoad(GlobalSettingsData data)
    {
-      IDESettings settings = (IDESettings)data;
 #ifndef MAKEFILE_GENERATOR
+      IDESettings settings = (IDESettings)data;
       globalSettingsDialog.ideSettings = settings;
       ide.UpdateRecentMenus();
       ide.UpdateCompilerConfigs(true);
@@ -97,7 +97,7 @@ void ProjectNode::LegacyBinaryLoadNode(File f)
    fileNameLen += len;
    path = new char[len+1];
    f.Read(path, sizeof(char), len+1);
-   
+
    /*
    fileName = new char[fileNameLen+2];
    strcpy(fileName, path);
@@ -107,7 +107,7 @@ void ProjectNode::LegacyBinaryLoadNode(File f)
 
    f.Read(&type, sizeof(type), 1);
    f.Read(&count, sizeof(count), 1);
-   
+
    if(type == file)
    {
       nodeType = file;
@@ -194,7 +194,7 @@ void ProjectNode::LegacyAsciiSaveNode(File f, char * indentation, char * insideP
       if(path && path[0])
          f.Printf("%s   Path = %s\n", indentation, path);
    }
-   
+
    /*if(buildExclusions.first && type != project)
    {
       for(item = buildExclusions.first; item; item = item.next)
@@ -219,7 +219,7 @@ void ProjectNode::LegacyAsciiSaveNode(File f, char * indentation, char * insideP
       f.Printf("\n");
    }
    */
-   
+
    if(type == project && (files.count /*|| preprocessorDefs.first*/))
    {
       f.Printf("\n");
@@ -374,7 +374,7 @@ define PEEK_RESOLUTION = (18.2 * 10);
 #define SEPS    "/"
 #define SEP     '/'
 
-static Array<String> notLinkerOptions
+static Array<const String> notLinkerOptions
 { [
    "-static-libgcc",
    "-shared",
@@ -406,7 +406,7 @@ static bool IsLinkerOption(String s)
 
 static byte epjSignature[] = { 'E', 'P', 'J', 0x04, 0x01, 0x12, 0x03, 0x12 };
 
-enum GenMakefilePrintTypes { objects, cObjects, symbols, imports, sources, resources, eCsources, rcSources };
+enum GenMakefilePrintTypes { noPrint, objects, cObjects, symbols, imports, sources, resources, eCsources, rcSources };
 
 define WorkspaceExtension = "ews";
 define ProjectExtension = "epj";
@@ -414,30 +414,6 @@ define ProjectExtension = "epj";
 define stringInFileIncludedFrom = "In file included from ";
 define stringFrom =               "                 from ";
 
-// This function cannot accept same pointer for source and output
-// todo: rename ReplaceSpaces to EscapeSpaceAndSpecialChars or something
-void ReplaceSpaces(char * output, char * source)
-{
-   int c, dc;
-   char ch, pch = 0;
-
-   for(c = 0, dc = 0; (ch = source[c]); c++, dc++)
-   {
-      if(ch == ' ') output[dc++] = '\\';
-      if(ch == '\"') output[dc++] = '\\';
-      if(ch == '&') output[dc++] = '\\';
-      if(pch != '$')
-      {
-         if(ch == '(' || ch == ')') output[dc++] = '\\';
-         pch = ch;
-      }
-      else if(ch == ')')
-         pch = 0;
-      output[dc] = ch;
-   }
-   output[dc] = '\0';
-}
-
 // chars refused for project name: windowsFileNameCharsNotAllowed + " &,."
 
 //define gnuMakeCharsNeedEscaping = "$%";
@@ -451,9 +427,10 @@ void ReplaceSpaces(char * output, char * source)
 // NOTES: - this function should get only unescaped unix style paths
 //        - paths with literal $(somestring) in them are not supported
 //          my_$(messed_up)_path would likely become my__path
-void EscapeForMake(char * output, char * input, bool hideSpace, bool allowVars, bool allowDblQuote)
+void EscapeForMake(char * output, const char * input, bool hideSpace, bool allowVars, bool allowDblQuote)
 {
-   char ch, *i = input, *o = output;
+   char ch, *o = output;
+   const char *i = input;
    bool inVar = false;
 #ifdef _DEBUG
    int len = strlen(input);
@@ -506,7 +483,7 @@ void EscapeForMakeToFile(File output, char * input, bool hideSpace, bool allowVa
    delete buf;
 }
 
-void EscapeForMakeToDynString(DynamicString output, char * input, bool hideSpace, bool allowVars, bool allowDblQuote)
+void EscapeForMakeToDynString(DynamicString output, const char * input, bool hideSpace, bool allowVars, bool allowDblQuote)
 {
    char * buf = new char[strlen(input)*2+1];
    EscapeForMake(buf, input, hideSpace, allowVars, allowDblQuote);
@@ -514,7 +491,7 @@ void EscapeForMakeToDynString(DynamicString output, char * input, bool hideSpace
    delete buf;
 }
 
-int OutputFileList(File f, char * name, Array<String> list, Map<String, int> varStringLenDiffs, char * prefix)
+int OutputFileList(File f, const char * name, Array<String> list, Map<String, int> varStringLenDiffs, const char * prefix)
 {
    int numOfBreaks = 0;
    const int breakListLength = 1536;
@@ -569,7 +546,7 @@ int OutputFileList(File f, char * name, Array<String> list, Map<String, int> var
       {
          if(numOfBreaks > 1)
             f.Printf("%s%d =", name, c+1);
-         
+
          len = 3;
          itemCount = breaks[c];
          for(n=offset; n<offset+itemCount; n++)
@@ -604,35 +581,35 @@ int OutputFileList(File f, char * name, Array<String> list, Map<String, int> var
    return numOfBreaks;
 }
 
-void OutputLinkObjectActions(File f, char * name, int parts)
+void OutputFileListActions(File f, const char * name, int parts, const char * fileName)
 {
    if(parts > 1)
    {
       int c;
       for(c=0; c<parts; c++)
-         f.Printf("\t@$(call echo,$(%s%d)) >> $(OBJ)linkobjects.lst\n", name, c+1);
+         f.Printf("\t@$(call echo,$(%s%d)) >> %s\n", name, c+1, fileName);
    } else if(parts) {
-      f.Printf("\t@$(call echo,$(%s)) >> $(OBJ)linkobjects.lst\n", name);
+      f.Printf("\t@$(call echo,$(%s)) >> %s\n", name, fileName);
    }
 }
 
-void OutputCleanActions(File f, char * name, int parts)
+void OutputCleanActions(File f, const char * name, int parts)
 {
    if(parts > 1)
    {
       int c;
       for(c=0; c<parts; c++)
-         f.Printf("\t$(call rmq,$(%s%d))\n", name, c+1);
+         f.Printf("\t$(call rm,$(_%s%d))\n", name, c+1);
    }
    else
-      f.Printf("\t$(call rmq,$(%s))\n", name);
+      f.Printf("\t$(call rm,$(_%s))\n", name);
 }
 
 enum LineOutputMethod { inPlace, newLine, lineEach };
 enum StringOutputMethod { asIs, escape, escapePath};
 
 enum ToolchainFlag { any, _D, _I, _isystem, _Wl, _L/*, _Wl-rpath*/ };
-String flagNames[ToolchainFlag] = { "", "-D", "-I", "-isystem ", "-Wl,", "-Wl,--library-path="/*, "-Wl,-rpath "*/ };
+const String flagNames[ToolchainFlag] = { "", "-D", "-I", "-isystem ", "-Wl,", /*"-Wl,--library-path="*/"-L"/*, "-Wl,-rpath "*/ };
 void OutputFlags(File f, ToolchainFlag flag, Array<String> list, LineOutputMethod lineMethod)
 {
    if(list.count)
@@ -678,7 +655,7 @@ static void OutputLibraries(File f, Array<String> libraries)
                strcpy(temp, item);
             StripExtension(temp);
             s = temp;
-         } 
+         }
          f.Puts(" \\\n\t$(call _L,");
          usedFunction = true;
       }
@@ -690,9 +667,12 @@ static void OutputLibraries(File f, Array<String> libraries)
 
 void CamelCase(char * string)
 {
-   int c, len = strlen(string);
-   for(c=0; c<len && string[c] >= 'A' && string[c] <= 'Z'; c++)
-      string[c] = (char)tolower(string[c]);
+   if(string)
+   {
+      int c, len = strlen(string);
+      for(c=0; c<len && string[c] >= 'A' && string[c] <= 'Z'; c++)
+         string[c] = (char)tolower(string[c]);
+   }
 }
 
 CompilerConfig GetCompilerConfig()
@@ -708,6 +688,15 @@ CompilerConfig GetCompilerConfig()
 #endif
 }
 
+int GetBitDepth()
+{
+#ifdef MAKEFILE_GENERATOR
+   return 0; // todo: improve this somehow? add bit depth command line option?
+#else
+   return ide.workspace.bitDepth;
+#endif
+}
+
 define localTargetType = config && config.options && config.options.targetType ?
             config.options.targetType : options && options.targetType ?
             options.targetType : TargetTypes::executable;
@@ -768,7 +757,7 @@ define platformTargetType =
                projectPOs.options.targetType : TargetTypes::unset;
 
 
-char * PlatformToMakefileTargetVariable(Platform platform)
+const char * PlatformToMakefileTargetVariable(Platform platform)
 {
    return platform == win32 ? "WINDOWS_TARGET" :
           platform == tux   ? "LINUX_TARGET"   :
@@ -776,7 +765,7 @@ char * PlatformToMakefileTargetVariable(Platform platform)
                               "ERROR_BAD_TARGET";
 }
 
-char * TargetTypeToMakefileVariable(TargetTypes targetType)
+const char * TargetTypeToMakefileVariable(TargetTypes targetType)
 {
    return targetType == executable    ? "executable" :
           targetType == sharedLibrary ? "sharedlib"  :
@@ -785,7 +774,7 @@ char * TargetTypeToMakefileVariable(TargetTypes targetType)
 }
 
 // Move this to ProjectConfig? null vs Common to consider...
-char * GetConfigName(ProjectConfig config)
+const char * GetConfigName(ProjectConfig config)
 {
    return config ? config.name : "Common";
 }
@@ -806,28 +795,28 @@ public:
    float version;
    String moduleName;
 
-   property char * moduleVersion
+   property const char * moduleVersion
    {
       set { delete moduleVersion; if(value && value[0]) moduleVersion = CopyString(value); } // TODO: use CopyString function that filters chars
       get { return moduleVersion ? moduleVersion : ""; }                                     //       version number should only use digits and dots
       isset { return moduleVersion != null && moduleVersion[0]; }                            //       add leading/trailing 0 if value start/ends with dot(s)
    }
 
-   property char * description
+   property const char * description
    {
       set { delete description; if(value && value[0]) description = CopyString(value); }
       get { return description ? description : ""; }
       isset { return description != null && description[0]; }
    }
 
-   property char * license
+   property const char * license
    {
       set { delete license; if(value && value[0]) license = CopyString(value); }
       get { return license ? license : ""; }
       isset { return license != null && license[0]; }
    }
 
-   property char * compilerConfigsDir
+   property const char * compilerConfigsDir
    {
       set { delete compilerConfigsDir; if(value && value[0]) compilerConfigsDir = CopyString(value); }
       get { return compilerConfigsDir ? compilerConfigsDir : ""; }
@@ -890,13 +879,13 @@ private:
    String lastBuildConfigName;
    String lastBuildCompilerName;
 
-   Map<String, NameCollisionInfo> lastBuildNamesInfo;
+   Map<String, Map<String, NameCollisionInfo>> configsNameCollisions { };
 
 #ifndef MAKEFILE_GENERATOR
    FileMonitor fileMonitor
    {
       this, FileChange { modified = true };
-      bool OnFileNotify(FileChange action, char * param)
+      bool OnFileNotify(FileChange action, const char * param)
       {
          fileMonitor.StopMonitoring();
          if(OnProjectModified(action, param))
@@ -918,7 +907,7 @@ private:
       return true;
    }
 
-   bool OnProjectModified(FileChange fileChange, char * param)
+   bool OnProjectModified(FileChange fileChange, const char * param)
    {
       char temp[4096];
       sprintf(temp, $"The project %s was modified by another application.\n"
@@ -997,7 +986,9 @@ private:
       delete name;
       delete lastBuildConfigName;
       delete lastBuildCompilerName;
-      if(lastBuildNamesInfo) { lastBuildNamesInfo.Free(); delete lastBuildNamesInfo; }
+      for(map : configsNameCollisions)
+         map.Free();
+      configsNameCollisions.Free();
    }
 
    ~Project()
@@ -1020,7 +1011,7 @@ private:
       }
    }
 
-   property char * filePath
+   property const char * filePath
    {
       set
       {
@@ -1042,7 +1033,7 @@ private:
       }
    }
 
-   ProjectConfig GetConfig(char * configName)
+   ProjectConfig GetConfig(const char * configName)
    {
       ProjectConfig result = null;
       if(configName && configName[0] && configurations.count)
@@ -1056,12 +1047,16 @@ private:
       return result;
    }
 
-   ProjectNode FindNodeByObjectFileName(char * fileName, IntermediateFileType type, bool dotMain, ProjectConfig config)
+   ProjectNode FindNodeByObjectFileName(const char * fileName, IntermediateFileType type, bool dotMain, ProjectConfig config, const char * objectFileExt)
    {
       ProjectNode result;
-      if(!lastBuildNamesInfo)
+      const char * cfgName;
+      if(!config)
+         config = this.config;
+      cfgName = config ? config.name : "";
+      if(!configsNameCollisions[cfgName])
          ProjectLoadLastBuildNamesInfo(this, config);
-      result = topNode.FindByObjectFileName(fileName, type, dotMain, lastBuildNamesInfo);
+      result = topNode.FindByObjectFileName(fileName, type, dotMain, configsNameCollisions[cfgName], objectFileExt);
       return result;
    }
 
@@ -1084,10 +1079,10 @@ private:
       return false;
    }
 
-   char * GetObjDirExpression(ProjectConfig config)
+   const char * GetObjDirExpression(ProjectConfig config)
    {
       // TODO: Support platform options
-      char * expression = localObjectsDirectory;
+      const char * expression = localObjectsDirectory;
       if(!expression)
          expression = settingsObjectsDirectory;
       return expression;
@@ -1095,16 +1090,16 @@ private:
 
    DirExpression GetObjDir(CompilerConfig compiler, ProjectConfig config, int bitDepth)
    {
-      char * expression = GetObjDirExpression(config);
+      const char * expression = GetObjDirExpression(config);
       DirExpression objDir { type = intermediateObjectsDir };
       objDir.Evaluate(expression, this, compiler, config, bitDepth);
       return objDir;
    }
 
-   char * GetTargetDirExpression(ProjectConfig config)
+   const char * GetTargetDirExpression(ProjectConfig config)
    {
       // TODO: Support platform options
-      char * expression = localTargetDirectory;
+      const char * expression = localTargetDirectory;
       if(!expression)
          expression = settingsTargetDirectory;
       return expression;
@@ -1112,7 +1107,7 @@ private:
 
    DirExpression GetTargetDir(CompilerConfig compiler, ProjectConfig config, int bitDepth)
    {
-      char * expression = GetTargetDirExpression(config);
+      const char * expression = GetTargetDirExpression(config);
       DirExpression targetDir { type = DirExpressionType::targetDir /*intermediateObjectsDir*/};
       targetDir.Evaluate(expression, this, compiler, config, bitDepth);
       return targetDir;
@@ -1160,9 +1155,9 @@ private:
       return fastMath == true;
    }
 
-   String GetDefaultNameSpace(ProjectConfig config)
+   const String GetDefaultNameSpace(ProjectConfig config)
    {
-      String defaultNameSpace = localDefaultNameSpace;
+      const String defaultNameSpace = localDefaultNameSpace;
       return defaultNameSpace;
    }
 
@@ -1172,9 +1167,9 @@ private:
       return strictNameSpaces == true;
    }
 
-   String GetTargetFileName(ProjectConfig config)
+   const String GetTargetFileName(ProjectConfig config)
    {
-      String targetFileName = localTargetFileName;
+      const String targetFileName = localTargetFileName;
       return targetFileName;
    }
 
@@ -1197,6 +1192,8 @@ private:
    {
 #ifndef MAKEFILE_GENERATOR
       return ide.project == this && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isActive;
+#else
+      return false;
 #endif
    }
 
@@ -1204,6 +1201,8 @@ private:
    {
 #ifndef MAKEFILE_GENERATOR
       return ide.project == this && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared;
+#else
+      return false;
 #endif
    }
 
@@ -1215,7 +1214,7 @@ private:
    }
 
 #ifndef MAKEFILE_GENERATOR
-   bool Save(char * fileName)
+   bool Save(const char * fileName)
    {
       File f;
       /*char output[MAX_LOCATION];
@@ -1244,67 +1243,10 @@ private:
    }
 #endif
 
-   // This method is only called from Debugger, should be moved to Debugger class?
-#ifndef MAKEFILE_GENERATOR
-   bool GetRelativePath(char * filePath, char * relativePath)
-   {
-      ProjectNode node;
-      char moduleName[MAX_FILENAME];
-      GetLastDirectory(filePath, moduleName);
-      // try with workspace dir first?
-      if((node = topNode.Find(moduleName, false)))
-      {
-         strcpy(relativePath, strcmp(node.path, ".") ? node.path : "");
-         PathCatSlash(relativePath, node.name);
-         return true;
-      }
-      else
-      {
-         // Tweak for automatically resolving symbol loader modules
-         char * sl = strstr(moduleName, ".main.ec");
-         if(sl && (*sl = 0, !strcmpi(moduleName, name)))
-         {
-            char objDir[MAX_LOCATION];
-            DirExpression objDirExp;
-            CompilerConfig compiler = ide.debugger.currentCompiler;
-            ProjectConfig config = ide.debugger.prjConfig;
-            int bitDepth = ide.debugger.bitDepth;
-            // This is not perfect, as multiple source files exist for the symbol loader module...
-            // We try to set it in the debug config object directory.
-            if(!compiler || !config)
-            {
-               // If we're not currently debugging, set a breakpoint in the active compiler/config
-               compiler = GetCompilerConfig();
-               config = this.config;
-               // If the current config is not debuggable, set it in the first debuggable config found
-               if(config && !config.options.debug)
-               {
-                  for(c : configurations; c.options.debug)
-                  {
-                     config = c;
-                     break;
-                  }
-               }
-            }
-            objDirExp = GetObjDir(compiler, config, bitDepth);
-            strcpy(objDir, objDirExp.dir);
-            delete objDirExp;
-            ChangeCh(objDir, '\\', '/'); // TODO: this is a hack, paths should never include win32 path seperators - fix this in ProjectSettings and ProjectLoad instead
-            ReplaceSpaces(relativePath, objDir);
-            *sl = '.';
-            PathCatSlash(relativePath, moduleName);
-            return true;
-         }
-      }
-      // WARNING: On failure, relative path is uninitialized
-      return false;   
-   }
-#endif
-
    void CatTargetFileName(char * string, CompilerConfig compiler, ProjectConfig config)
    {
       TargetTypes targetType = GetTargetType(config);
-      String targetFileName = GetTargetFileName(config);
+      const String targetFileName = GetTargetFileName(config);
       if(targetType == staticLibrary)
       {
          PathCatSlash(string, "lib");
@@ -1317,7 +1259,7 @@ private:
       }
       else
          PathCatSlash(string, targetFileName);
-      
+
       switch(targetType)
       {
          case executable:
@@ -1331,7 +1273,7 @@ private:
                strcat(string, ".dylib");
             else
                strcat(string, ".so");
-            if(compiler.targetPlatform == tux && GetRuntimePlatform() == tux && moduleVersion && moduleVersion[0])
+            if(compiler.targetPlatform == tux && __runtimePlatform == tux && moduleVersion && moduleVersion[0])
             {
                strcat(string, ".");
                strcat(string, moduleVersion);
@@ -1416,6 +1358,42 @@ private:
    }
 
 #ifndef MAKEFILE_GENERATOR
+   ProjectNode GetObjectFileNode(const char * filePath, const char * objectFileExt)
+   {
+      ProjectNode node = null;
+      char ext[MAX_EXTENSION];
+      GetExtension(filePath, ext);
+      if(ext[0])
+      {
+         IntermediateFileType type = IntermediateFileType::FromExtension(ext);
+         if(type)
+         {
+            char fileName[MAX_FILENAME];
+            GetLastDirectory(filePath, fileName);
+            if(fileName[0])
+            {
+               DotMain dotMain = DotMain::FromFileName(fileName);
+               node = FindNodeByObjectFileName(fileName, type, dotMain, null, objectFileExt);
+            }
+         }
+      }
+      return node;
+   }
+
+   bool GetAbsoluteFromRelativePath(const char * relativePath, char * absolutePath, const char * objectFileExt)
+   {
+      ProjectNode node = topNode.FindWithPath(relativePath, false);
+      if(!node)
+         node = GetObjectFileNode(relativePath, objectFileExt);
+      if(node)
+      {
+         strcpy(absolutePath, node.project.topNode.path);
+         PathCat(absolutePath, relativePath);
+         MakeSlashPath(absolutePath);
+      }
+      return node != null;
+   }
+
    void MarkChanges(ProjectNode node)
    {
       for(cfg : topNode.configurations)
@@ -1426,8 +1404,8 @@ private:
          if(c && ((c.options && cfg.options && cfg.options.console != c.options.console) ||
                (!c.options || !cfg.options)))
             cfg.symbolGenModified = true;
-         if(c && ((c.options && cfg.options && 
-               ( (cfg.options.libraries && c.options.libraries && cfg.options.libraries.OnCompare(c.options.libraries)) || (!cfg.options.libraries || !c.options.libraries)) ) 
+         if(c && ((c.options && cfg.options &&
+               ( (cfg.options.libraries && c.options.libraries && cfg.options.libraries.OnCompare(c.options.libraries)) || (!cfg.options.libraries || !c.options.libraries)) )
             || (!c.options || !cfg.options)))
             cfg.linkingModified = true;
 
@@ -1437,10 +1415,28 @@ private:
 
    void ModifiedAllConfigs(bool making, bool compiling, bool linking, bool symbolGen)
    {
+      Map<String, NameCollisionInfo> cfgNameCollision;
+      MapIterator<const String, Map<String, NameCollisionInfo>> it { map = configsNameCollisions };
+      if(it.Index("", false))
+      {
+         cfgNameCollision = it.data;
+         cfgNameCollision.Free();
+         delete cfgNameCollision;
+         it.Remove();
+      }
       for(cfg : configurations)
       {
          if(making)
+         {
             cfg.makingModified = true;
+            if(it.Index(cfg.name, false))
+            {
+               cfgNameCollision = it.data;
+               cfgNameCollision.Free();
+               delete cfgNameCollision;
+               it.Remove();
+            }
+         }
          if(compiling)
             cfg.compilingModified = true;
          if(linking)
@@ -1454,8 +1450,8 @@ private:
          ide.workspace.modified = true;
       }
    }
-   
-   void RotateActiveConfig(bool forward)
+
+   void RotateActiveConfig(bool forward, bool syncAllProjects)
    {
       if(configurations.first && configurations.last != configurations.first)
       {
@@ -1475,10 +1471,15 @@ private:
                cfg.Prev();
          }
 
-         property::config = cfg.data;
-         ide.UpdateToolBarActiveConfigs(true);
-         ide.workspace.modified = true;
-         ide.projectView.Update(null);
+         if(syncAllProjects)
+            ide.workspace.SelectActiveConfig(cfg.data.name);
+         else
+         {
+            property::config = cfg.data;
+            ide.UpdateToolBarActiveConfigs(true);
+            ide.workspace.modified = true;
+            ide.projectView.Update(null);
+         }
       }
    }
 
@@ -1521,15 +1522,16 @@ private:
       CompilerConfig compiler, ProjectConfig config, int bitDepth)
    {
       char line[65536];
+      int linePos = 0;
       bool compiling = false, linking = false, precompiling = false;
       int compilingEC = 0;
       int numErrors = 0, numWarnings = 0;
       bool loggedALine = false;
       int lenMakeCommand = strlen(compiler.makeCommand);
       int testLen = 0;
-      char * t;
+      const char * t, * s, * s2;
       char moduleName[MAX_FILENAME];
-      char * gnuToolchainPrefix = compiler.gnuToolchainPrefix ? compiler.gnuToolchainPrefix : "";
+      const char * gnuToolchainPrefix = compiler.gnuToolchainPrefix ? compiler.gnuToolchainPrefix : "";
 
       DynamicString test { };
       DynamicString ecp { };
@@ -1543,8 +1545,9 @@ private:
       DynamicString strip { };
       DynamicString ar { };
       DynamicString windres { };
+
       /*
-      if(bitDepth == 64 && compiler.targetPlatform == win32) 
+      if(bitDepth == 64 && compiler.targetPlatform == win32)
          gnuToolchainPrefix = "x86_64-w64-mingw32-";
       else if(bitDepth == 32 && compiler.targetPlatform == win32)
          gnuToolchainPrefix = "i686-w64-mingw32-";
@@ -1582,309 +1585,350 @@ private:
 
       while(!f.Eof() && !ide.projectView.stopBuild)
       {
-         bool result = true;
          double lastTime = GetTime();
          bool wait = true;
-         while(result)
+         while(!f.Eof() && !ide.projectView.stopBuild)
          {
-            //printf("Peeking and GetLine...\n");
-            if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)) && line[0])
+            int nChars;
+            bool lineDone = f.GetLinePeek(line + linePos, sizeof(line)-linePos-1, &nChars);
+            if(!lineDone)
             {
-               char * message = null;
-               char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
-               char * from = strstr(line, stringFrom);
-               test.copyLenSingleBlankReplTrim(line, ' ', true, testLen);
-               if(strstr(line, compiler.makeCommand) == line && line[lenMakeCommand] == ':')
+               linePos += nChars;
+               Sleep(0.5 / PEEK_RESOLUTION);
+            }
+            else
+            {
+               linePos = 0;
+               if(line[0])
                {
-                  char * module = strstr(line, "No rule to make target `");
-                  if(module)
+                  const char * message = null;
+                  const char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
+                  const char * from = strstr(line, stringFrom);
+                  test.copyLenSingleBlankReplTrim(line, ' ', true, testLen);
+                  if((t = strstr(line, (s=": recipe for target"))) && (t = strstr(t+strlen(s), (s2 = " failed"))) && (t+strlen(s2))[0] == '\0')
+                     ; // ignore this new gnu make error but what is it about?
+                  else if(strstr(line, compiler.makeCommand) == line && line[lenMakeCommand] == ':')
                   {
-                     char * end;
-                     module = strchr(module, '`') + 1;
-                     end = strchr(module, '\'');
-                     if(end)
+                     const char * moduleBackTick = strstr(line, "No rule to make target `");
+                     const char * module = moduleBackTick ? moduleBackTick : strstr(line, "No rule to make target '");
+                     if(module)
                      {
-                        *end = '\0';
-                        ide.outputView.buildBox.Logf($"   %s: No such file or directory\n", module);
-                        // ide.outputView.buildBox.Logf("error: %s\n   No such file or directory\n", module);
-                        numErrors++;
+                        char * end;
+                        module = strchr(module, moduleBackTick ? '`' : '\'') + 1;
+                        end = strchr(module, '\'');
+                        if(end)
+                        {
+                           *end = '\0';
+                           ide.outputView.buildBox.Logf($"   %s: No such file or directory\n", module);
+                           // ide.outputView.buildBox.Logf("error: %s\n   No such file or directory\n", module);
+                           numErrors++;
+                        }
                      }
+                     //else
+                     //{
+                        //ide.outputView.buildBox.Logf("error: %s\n", line);
+                        //numErrors++;
+                     //}
                   }
-                  //else
-                  //{
-                     //ide.outputView.buildBox.Logf("error: %s\n", line);
-                     //numErrors++;
-                  //}
-               }
-               else if(strstr(test, "mkdir ") == test);
-               else if((t = strstr(line, "cd ")) && (t = strstr(line, "type ")) && (t = strstr(line, "nul ")) && (t = strstr(line, "copy ")) && (t = strstr(line, "cd ")));
-               else if(strstr(test, ear) == test);
-               else if(strstr(test, strip) == test);
-               else if(strstr(test, cc) == test || strstr(test, cxx) == test || strstr(test, ecp) == test || strstr(test, ecc) == test)
-               {
-                  char * module;
-                  bool isPrecomp = false;
-                  bool gotCC = false;
-
-                  if(strstr(test, cc) == test || strstr(test, cxx) == test)
+                  else if(strstr(test, "mkdir ") == test);
+                  else if((t = strstr(line, "cd ")) && (t = strstr(line, "type ")) && (t = strstr(line, "nul ")) && (t = strstr(line, "copy ")) && (t = strstr(line, "cd ")));
+                  else if(strstr(test, ear) == test);
+                  else if(strstr(test, strip) == test);
+                  else if(strstr(test, cc) == test || strstr(test, cxx) == test || strstr(test, ecp) == test || strstr(test, ecc) == test)
                   {
-                     module = strstr(line, " -c ");
-                     if(module) module += 4;
-                     gotCC = true;
-                  }
-                  else if(strstr(test, ecc) == test)
-                  {
-                     module = strstr(line, " -c ");
-                     if(module) module += 4;
-                     //module = line + 3;
-                     // Don't show GCC warnings about generated C code because it does not compile clean yet...
-                     compilingEC = 3;//2;
-                     gotCC = true;
-                  }
-                  else if(strstr(test, ecp) == test)
-                  {
-                     // module = line + 8;
-                     module = strstr(line, " -c ");
-                     if(module) module += 4;
-                     isPrecomp = true;
-                     compilingEC = 0;
-                     gotCC = true;
-                  }
+                     char * module = null;
+                     bool isPrecomp = false;
+                     bool gotCC = false;
+
+                     if(strstr(test, cc) == test || strstr(test, cxx) == test)
+                     {
+                        module = strstr(line, " -c ");
+                        if(module) module += 4;
+                        gotCC = true;
+                     }
+                     else if(strstr(test, ecc) == test)
+                     {
+                        module = strstr(line, " -c ");
+                        if(module) module += 4;
+                        //module = line + 3;
+                        // Don't show GCC warnings about generated C code because it does not compile clean yet...
+                        compilingEC = 3;//2;
+                        gotCC = true;
+                     }
+                     else if(strstr(test, ecp) == test)
+                     {
+                        // module = line + 8;
+                        module = strstr(line, " -c ");
+                        if(module) module += 4;
+                        isPrecomp = true;
+                        compilingEC = 0;
+                        gotCC = true;
+                     }
 
-                  loggedALine = true;
+                     loggedALine = true;
 
-                  if(module)
-                  {
-                     byte * tokens[1];
-                     if(!compiling && !isPrecomp)
+                     if(module)
                      {
-                        ide.outputView.buildBox.Logf($"Compiling...\n");
-                        compiling = true;
+                        char * tokens[1];
+                        if(!compiling && !isPrecomp)
+                        {
+                           ide.outputView.buildBox.Logf($"Compiling...\n");
+                           compiling = true;
+                        }
+                        else if(!precompiling && isPrecomp)
+                        {
+                           ide.outputView.buildBox.Logf($"Generating symbols...\n");
+                           precompiling = true;
+                        }
+                        Tokenize(module, 1, tokens, forArgsPassing/*(BackSlashEscaping)true*/);
+                        GetLastDirectory(tokens[0], moduleName);
+                        ide.outputView.buildBox.Logf("%s\n", moduleName);
                      }
-                     else if(!precompiling && isPrecomp)
+                     else if((module = strstr(line, " -o ")))
                      {
-                        ide.outputView.buildBox.Logf($"Generating symbols...\n");
-                        precompiling = true;
+                        compiling = false;
+                        precompiling = false;
+                        linking = true;
+                        ide.outputView.buildBox.Logf($"Linking...\n");
+                     }
+                     else
+                     {
+                        ide.outputView.buildBox.Logf("%s\n", line);
+                        if(strstr(line, "warning:") || strstr(line, "note:"))
+                           numWarnings++;
+                        else if(!gotCC && !strstr(line, "At top level") && !strstr(line, "In file included from") && !strstr(line, stringFrom))
+                           numErrors++;
                      }
-                     // Changed escapeBackSlashes here to handle paths with spaces
-                     Tokenize(module, 1, tokens, (BackSlashEscaping)true); // fix #139
-                     GetLastDirectory(module, moduleName);
-                     ide.outputView.buildBox.Logf("%s\n", moduleName);
-                  }
-                  else if((module = strstr(line, " -o ")))
-                  {
-                     compiling = false;
-                     precompiling = false;
-                     linking = true;
-                     ide.outputView.buildBox.Logf($"Linking...\n");
-                  }
-                  else
-                  {
-                     ide.outputView.buildBox.Logf("%s\n", line);
-                     if(strstr(line, "warning:") || strstr(line, "note:"))
-                        numWarnings++;
-                     else if(!gotCC && !strstr(line, "At top level") && !strstr(line, "In file included from") && !strstr(line, stringFrom))
-                        numErrors++;
-                  }
 
-                  if(compilingEC) compilingEC--;
-               }
-               else if(strstr(test, windres) == test)
-               {
-                  char * module;
-                  module = strstr(line, " ");
-                  if(module) module++;
-                  if(module)
+                     if(compilingEC) compilingEC--;
+                  }
+                  else if(strstr(test, windres) == test)
                   {
-                     byte * tokens[1];
-                     char * dashF = strstr(module, "-F ");
-                     if(dashF)
+                     char * module;
+                     module = strstr(line, " ");
+                     if(module) module++;
+                     if(module)
                      {
-                        dashF+= 3;
-                        while(*dashF && *dashF != ' ') dashF++;
-                        while(*dashF && *dashF == ' ') dashF++;
-                        module = dashF;
+                        char * tokens[1];
+                        char * dashF = strstr(module, "-F ");
+                        if(dashF)
+                        {
+                           dashF+= 3;
+                           while(*dashF && *dashF != ' ') dashF++;
+                           while(*dashF && *dashF == ' ') dashF++;
+                           module = dashF;
+                        }
+                        Tokenize(module, 1, tokens, forArgsPassing/*(BackSlashEscaping)true*/);
+                        GetLastDirectory(module, moduleName);
+                        ide.outputView.buildBox.Logf("%s\n", moduleName);
                      }
-                     Tokenize(module, 1, tokens, (BackSlashEscaping)true); // fix #139
-                     GetLastDirectory(module, moduleName);
-                     ide.outputView.buildBox.Logf("%s\n", moduleName);
                   }
-               }
-               else if(strstr(test, ar) == test)
-                  ide.outputView.buildBox.Logf($"Building library...\n");
-               else if(strstr(test, ecs) == test)
-                  ide.outputView.buildBox.Logf($"Writing symbol loader...\n");
-               else
-               {
-                  if(linking || compiling || precompiling)
+                  else if(strstr(test, ar) == test)
+                     ide.outputView.buildBox.Logf($"Building library...\n");
+                  else if(strstr(test, ecs) == test)
+                     ide.outputView.buildBox.Logf($"Writing symbol loader...\n");
+                  else
                   {
-                     char * start = inFileIncludedFrom ? inFileIncludedFrom + strlen(stringInFileIncludedFrom) : from ? from + strlen(stringFrom) : line;
-                     char * colon = strstr(start, ":"); //, * bracket;
-                     if(colon && (colon[1] == '/' || colon[1] == '\\'))
-                        colon = strstr(colon + 1, ":");
-                     if(colon)
+                     if(linking || compiling || precompiling)
                      {
-                        char * sayError = "";
-                        char moduleName[MAX_LOCATION], temp[MAX_LOCATION];
-                        char * pointer;
-                        char * error;
-                        int len = (int)(colon - start);
-                        char ext[MAX_EXTENSION];
-                        len = Min(len, MAX_LOCATION-1);
-                        // Don't be mistaken by the drive letter colon
-                        // Cut module name
-                        // TODO: need to fix colon - line gives char *
-                        // warning: incompatible expression colon - line (char *); expected int
-                        /*
-                        strncpy(moduleName, line, (int)(colon - line));
-                        moduleName[colon - line] = '\0';
-                        */
-                        strncpy(moduleName, start, len);
-                        moduleName[len] = '\0';
-                        // Remove stuff in brackets
-                        //bracket = strstr(moduleName, "(");
-                        //if(bracket) *bracket = '\0';
-
-                        GetLastDirectory(moduleName, temp);
-                        GetExtension(temp, ext);
-
-                        if(linking && (!strcmp(ext, "o") || !strcmp(ext, "a") || !strcmp(ext, "lib")))
+                        const char * start = inFileIncludedFrom ? inFileIncludedFrom + strlen(stringInFileIncludedFrom) : from ? from + strlen(stringFrom) : line;
+                        const char * colon = strstr(start, ":"); //, * bracket;
+                        if(colon && (colon[1] == '/' || colon[1] == '\\'))
+                           colon = strstr(colon + 1, ":");
+                        if(colon)
                         {
-                           char * cColon = strstr(colon+1, ":");
-                           if(cColon && (cColon[1] == '/' || cColon[1] == '\\'))
-                              cColon = strstr(cColon + 1, ":");
-                           if(cColon)
+                           const char * sayError = "";
+                           char moduleName[MAX_LOCATION], temp[MAX_LOCATION];
+                           char * pointer;
+                           char * error;
+                           int len = (int)(colon - start);
+                           char ext[MAX_EXTENSION];
+                           len = Min(len, MAX_LOCATION-1);
+                           // Don't be mistaken by the drive letter colon
+                           // Cut module name
+                           // TODO: need to fix colon - line gives char *
+                           // warning: incompatible expression colon - line (char *); expected int
+                           /*
+                           strncpy(moduleName, line, (int)(colon - line));
+                           moduleName[colon - line] = '\0';
+                           */
+                           strncpy(moduleName, start, len);
+                           moduleName[len] = '\0';
+                           // Remove stuff in brackets
+                           //bracket = strstr(moduleName, "(");
+                           //if(bracket) *bracket = '\0';
+
+                           GetLastDirectory(moduleName, temp);
+                           GetExtension(temp, ext);
+
+                           if(linking && (!strcmp(ext, "o") || !strcmp(ext, "a") || !strcmp(ext, "lib")))
                            {
-                              int len = (int)(cColon - (colon+1));
-                              char mName[MAX_LOCATION];
-                              len = Min(len, MAX_LOCATION-1);
-                              strncpy(mName, colon+1, len);
-                              mName[len] = '\0';
-                              GetLastDirectory(mName, temp);
-                              GetExtension(temp, ext);
-                              if(!strcmp(ext, "c") || !strcmp(ext, "cpp") || !strcmp(ext, "cxx") || !strcmp(ext, "ec"))
+                              char * cColon = strstr(colon+1, ":");
+                              if(cColon && (cColon[1] == '/' || cColon[1] == '\\'))
+                                 cColon = strstr(cColon + 1, ":");
+                              if(cColon)
                               {
-                                 colon = cColon;
-                                 strcpy(moduleName, mName);
+                                 int len = (int)(cColon - (colon+1));
+                                 char mName[MAX_LOCATION];
+                                 len = Min(len, MAX_LOCATION-1);
+                                 strncpy(mName, colon+1, len);
+                                 mName[len] = '\0';
+                                 GetLastDirectory(mName, temp);
+                                 GetExtension(temp, ext);
+                                 if(!strcmp(ext, "c") || !strcmp(ext, "cpp") || !strcmp(ext, "cxx") || !strcmp(ext, "ec"))
+                                 {
+                                    colon = cColon;
+                                    strcpy(moduleName, mName);
+                                 }
                               }
                            }
-                        }
-                        if(linking && (!strcmp(temp, "ld") || !strcmp(temp, "ld.exe")))
-                        {
-                           moduleName[0] = 0;
-                           if(strstr(colon, "skipping incompatible") || strstr(colon, "Recognised but unhandled"))
+                           if(linking && (!strcmp(temp, "ld") || !strcmp(temp, "ld.exe")))
                            {
-                              message = $"Linker Message: ";
+                              moduleName[0] = 0;
+                              if(strstr(colon, "skipping incompatible") || strstr(colon, "Recognised but unhandled"))
+                              {
+                                 message = $"Linker Message: ";
+                                 colon = line;
+                              }
+                              else if(SearchString(colon, 0, "warning:", false, false))
+                              {
+                                 message = $"Linker Warning: ";
+                                 colon = line;
+                              }
+                              else
+                              {
+                                 numErrors++;
+                                 message = $"Linker Error: ";
+                              }
+                           }
+                           else if(linking && (!strcmp(ext, "") || !strcmp(ext, "exe")))
+                           {
+                              moduleName[0] = 0;
                               colon = line;
+                              if(strstr(colon, "Warning:") == colon)
+                              {
+                                 message = $"Linker ";
+                                 numWarnings++;
+                              }
+                              else if(strstr(line, "error:"))
+                              {
+                                 message = $"Linker Error: ";
+                                 numErrors++;
+                              }
                            }
                            else
                            {
-                              numErrors++;
-                              message = $"Linker Error";
+                              strcpy(temp, topNode.path);
+                              PathCatSlash(temp, moduleName);
+                              MakePathRelative(temp, topNode.path, moduleName);
                            }
-                        }
-                        else if(linking && (!strcmp(ext, "") || !strcmp(ext, "exe")))
-                        {
-                           moduleName[0] = 0;
-                           colon = line;
-                           if(!strstr(line, "error:"))
-                           {
-                              message = $"Linker Error: ";
+                           error = strstr(line, "error:");
+                           if(!message && error && error > colon)
                               numErrors++;
-                           }
-                        }
-                        else
-                        {
-                           strcpy(temp, topNode.path);
-                           PathCatSlash(temp, moduleName);
-                           MakePathRelative(temp, topNode.path, moduleName);
-                        }
-                        error = strstr(line, "error:");
-                        if(!message && error && error > colon)
-                           numErrors++;
-                        else
-                        {
-                           // Silence warnings for compiled eC
-                           char * objDir = strstr(moduleName, objDirExp.dir);
-                        
-                           if(linking)
+                           else
                            {
-                              if((pointer = strstr(line, "undefined"))  ||
-                                   (pointer = strstr(line, "multiple definition")) ||
-                                   (pointer = strstr(line, "No such file")) ||
-                                   (pointer = strstr(line, "token")))
+                              // Silence warnings for compiled eC
+                              //char * objDir = strstr(moduleName, objDirExp.dir);
+
+                              if(linking)
+                              {
+                                 if((pointer = strstr(line, "undefined"))  ||
+                                      (pointer = strstr(line, "multiple definition")) ||
+                                      (pointer = strstr(line, "No such file")) ||
+                                      (pointer = strstr(line, "token")))
+                                 {
+                                    strncat(moduleName, colon, pointer - colon);
+                                    sayError = "error: ";
+                                    colon = pointer;
+                                    numErrors++;
+                                 }
+                              }
+                              else if((pointer = strstr(line, "No such file")))
                               {
                                  strncat(moduleName, colon, pointer - colon);
                                  sayError = "error: ";
                                  colon = pointer;
                                  numErrors++;
                               }
-                           }
-                           else if((pointer = strstr(line, "No such file")))
-                           {
-                              strncat(moduleName, colon, pointer - colon);
-                              sayError = "error: ";
-                              colon = pointer;
-                              numErrors++;
-                           }
-                           else if(compilingEC == 1 || (objDir && objDir == moduleName))
-                              continue;
-                           else if(strstr(line, "warning:"))
-                           {
-                              numWarnings++;
-                           }
-                        }
-                        if(message)
-                           ide.outputView.buildBox.Logf("   %s%s\n", message, colon);
-                        /*else if(this == ide.workspace.projects.firstIterator.data)
-                           ide.outputView.buildBox.Logf("   %s%s%s\n", moduleName, sayError, colon);*/
-                        else
-                        {
-                           char fullModuleName[MAX_LOCATION];
-                           FileAttribs found = 0;
-                           Project foundProject = this;
-                           if(moduleName[0])
-                           {
-                              char * loc = strstr(moduleName, ":");
-                              if(loc) *loc = 0;
-                              strcpy(fullModuleName, topNode.path);
-                              PathCat(fullModuleName, moduleName);
-                              found = FileExists(fullModuleName);
-                              if(!found && !strcmp(ext, "c"))
+                              else //if(compilingEC == 1 || (objDir && objDir == moduleName))
                               {
-                                 char ecName[MAX_LOCATION];
-                                 ChangeExtension(fullModuleName, "ec", ecName);
-                                 found = FileExists(ecName);
-                              }
-                              if(!found)
-                              {
-                                 char path[MAX_LOCATION];
-                                 if(ide && ide.workspace)
+                                 bool skip = false;
+
+                                 // Filter out these warnings caused by eC generated C code:
+
+                                 // Declaration ordering bugs -- Awaiting topo sort implementation
+                                 /*
+                                      if(strstr(line, "declared inside parameter list")) skip = true;
+                                 else if(strstr(line, "its scope is only this definition")) skip = true;
+                                 else if(strstr(line, "from incompatible pointer type")) skip = true;
+                                 else if(strstr(line, "note: expected 'struct ") || strstr(line, "note: expected â€˜struct "))
                                  {
-                                    for(prj : ide.workspace.projects)
-                                    {
-                                       ProjectNode node;
-                                       MakePathRelative(fullModuleName, prj.topNode.path, path);
+                                    #define STRUCT_A "'struct "
+                                    #define STRUCT_B "‘struct "
+                                    char * struct1, * struct2, ch1, ch2;
+                                    struct1 = strstr(line, STRUCT_A);
+                                    if(struct1) { struct1 += sizeof(STRUCT_A)-1; } else { struct1 = strstr(line, STRUCT_B); struct1 += sizeof(STRUCT_B)-1; };
 
-                                       if((node = prj.topNode.FindWithPath(path, false)))
-                                       {
-                                          strcpy(fullModuleName, prj.topNode.path);
-                                          PathCatSlash(fullModuleName, node.path);
-                                          PathCatSlash(fullModuleName, node.name);
-                                          found = FileExists(fullModuleName);
-                                          if(found)
-                                          {
-                                             foundProject = prj;
-                                             break;
-                                          }
-                                       }
+                                    struct2 = strstr(struct1, STRUCT_A);
+                                    if(struct2) { struct2 += sizeof(STRUCT_A)-1; } else { struct2 = strstr(struct1, STRUCT_B); if(struct2) struct2 += sizeof(STRUCT_B)-1; };
+
+                                    if(struct1 && struct2)
+                                    {
+                                       while(ch1 = *(struct1++), ch2 = *(struct2++), ch1 && ch2 && (ch1 == '_' || isalnum(ch1)) && (ch2 == '_' || isalnum(ch2)));
+                                       if(ch1 == ch2)
+                                          skip = true;
                                     }
-                                    if(!found && !strchr(moduleName, '/') && !strchr(moduleName, '\\'))
+                                 }
+
+                                 // For preprocessed code from objidl.h (MinGW-w64 headers)
+                                 else if(strstr(line, "declaration does not declare anything")) skip = true;
+
+                                 // Location information that could apply to ignored warnings
+                                 else if(strstr(line, "In function '") || strstr(line, "In function â€˜") ) skip = true;
+                                 else if(strstr(line, "At top level")) skip = true;
+                                 else if(strstr(line, "(near initialization for '") || strstr(line, "(near initialization for â€˜")) skip = true;
+                                 */
+                                 if(skip) continue;
+                                 numWarnings++;
+                              }
+                              /*else if(strstr(line, "warning:"))
+                              {
+                                 numWarnings++;
+                              }*/
+                           }
+                           if(message)
+                              ide.outputView.buildBox.Logf("   %s%s\n", message, colon);
+                           /*else if(this == ide.workspace.projects.firstIterator.data)
+                              ide.outputView.buildBox.Logf("   %s%s%s\n", moduleName, sayError, colon);*/
+                           else
+                           {
+                              char fullModuleName[MAX_LOCATION];
+                              FileAttribs found = 0;
+                              //Project foundProject = this;
+                              if(moduleName[0])
+                              {
+                                 char * loc = strstr(moduleName, ":");
+                                 if(loc) *loc = 0;
+                                 strcpy(fullModuleName, topNode.path);
+                                 PathCat(fullModuleName, moduleName);
+                                 found = FileExists(fullModuleName);
+                                 if(!found && !strcmp(ext, "c"))
+                                 {
+                                    char ecName[MAX_LOCATION];
+                                    ChangeExtension(fullModuleName, "ec", ecName);
+                                    found = FileExists(ecName);
+                                 }
+                                 if(!found)
+                                 {
+                                    char path[MAX_LOCATION];
+                                    if(ide && ide.workspace)
                                     {
                                        for(prj : ide.workspace.projects)
                                        {
                                           ProjectNode node;
-                                          if((node = prj.topNode.Find(moduleName, false)))
+                                          MakePathRelative(fullModuleName, prj.topNode.path, path);
+
+                                          if((node = prj.topNode.FindWithPath(path, false)))
                                           {
                                              strcpy(fullModuleName, prj.topNode.path);
                                              PathCatSlash(fullModuleName, node.path);
@@ -1892,44 +1936,62 @@ private:
                                              found = FileExists(fullModuleName);
                                              if(found)
                                              {
-                                                foundProject = prj;
+                                                //foundProject = prj;
                                                 break;
                                              }
                                           }
                                        }
+                                       if(!found && !strchr(moduleName, '/') && !strchr(moduleName, '\\'))
+                                       {
+                                          for(prj : ide.workspace.projects)
+                                          {
+                                             ProjectNode node;
+                                             if((node = prj.topNode.Find(moduleName, false)))
+                                             {
+                                                strcpy(fullModuleName, prj.topNode.path);
+                                                PathCatSlash(fullModuleName, node.path);
+                                                PathCatSlash(fullModuleName, node.name);
+                                                found = FileExists(fullModuleName);
+                                                if(found)
+                                                {
+                                                   //foundProject = prj;
+                                                   break;
+                                                }
+                                             }
+                                          }
+                                       }
                                     }
                                  }
-                              }
-                              if(found)
-                              {
-                                 MakePathRelative(fullModuleName, ide.workspace.projects.firstIterator.data.topNode.path, fullModuleName);
-                                 MakeSystemPath(fullModuleName);
+                                 if(found)
+                                 {
+                                    MakePathRelative(fullModuleName, ide.workspace.projects.firstIterator.data.topNode.path, fullModuleName);
+                                    MakeSystemPath(fullModuleName);
+                                 }
+                                 else
+                                    strcpy(fullModuleName, moduleName);
+                                 if(loc)
+                                 {
+                                    strcat(fullModuleName, ":");
+                                    strcat(fullModuleName, loc + 1);
+                                 }
                               }
                               else
-                                 strcpy(fullModuleName, moduleName);
-                              if(loc)
-                              {
-                                 strcat(fullModuleName, ":");
-                                 strcat(fullModuleName, loc + 1);
-                              }
+                                 fullModuleName[0] = 0;
+                              ide.outputView.buildBox.Logf("   %s%s%s%s\n", inFileIncludedFrom ? stringInFileIncludedFrom : from ? stringFrom : "", fullModuleName, sayError, colon);
                            }
-                           else
-                              fullModuleName[0] = 0;
-                           ide.outputView.buildBox.Logf("   %s%s%s%s\n", inFileIncludedFrom ? stringInFileIncludedFrom : from ? stringFrom : "", fullModuleName, sayError, colon);
+                        }
+                        else
+                        {
+                           ide.outputView.buildBox.Logf("%s\n", line);
+                           linking = compiling = precompiling = false;
                         }
                      }
                      else
-                     {
                         ide.outputView.buildBox.Logf("%s\n", line);
-                        linking = compiling = precompiling = false;
-                     }
                   }
-                  else
-                     ide.outputView.buildBox.Logf("%s\n", line);
+                  wait = false;
                }
-               wait = false;
             }
-            //printf("Done getting line\n");
             if(GetTime() - lastTime > 1.0 / PEEK_RESOLUTION) break;
          }
          //printf("Processing Input...\n");
@@ -1952,7 +2014,7 @@ private:
       {
          if(f.GetExitCode() && !numErrors)
          {
-            bool result = f.GetLine(line, sizeof(line)-1);
+            /*bool result = */f.GetLine(line, sizeof(line)-1);
             ide.outputView.buildBox.Logf($"Fatal Error: child process terminated unexpectedly\n");
          }
          else if(buildType != install)
@@ -1968,7 +2030,7 @@ private:
                ide.outputView.buildBox.Logf("%d %s, ", numErrors, (numErrors > 1) ? $"errors" : $"error");
             else
                ide.outputView.buildBox.Logf($"no error, ");
-   
+
             if(numWarnings)
                ide.outputView.buildBox.Logf("%d %s\n", numWarnings, (numWarnings > 1) ? $"warnings" : $"warning");
             else
@@ -1987,6 +2049,7 @@ private:
       delete cxx;
       delete strip;
       delete ar;
+      delete windres;
 
       return numErrors == 0 && !ide.projectView.stopBuild;
    }
@@ -2027,7 +2090,7 @@ private:
       }
    }
 
-   bool Build(BuildType buildType, List<ProjectNode> onlyNodes, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint, SingleFileCompileMode mode)
+   bool Build(BuildType buildType, List<ProjectNode> onlyNodes, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint, bool raw, SingleFileCompileMode mode)
    {
       bool result = false;
       DualPipe f;
@@ -2038,20 +2101,23 @@ private:
       char configName[MAX_LOCATION];
       DirExpression objDirExp = GetObjDir(compiler, config, bitDepth);
       PathBackup pathBackup { };
-      bool crossCompiling = (compiler.targetPlatform != GetRuntimePlatform());
-      char * targetPlatform = crossCompiling ? (char *)compiler.targetPlatform : "";
+      bool crossCompiling = (compiler.targetPlatform != __runtimePlatform);
+      const char * targetPlatform = crossCompiling ? (char *)compiler.targetPlatform : "";
 
       bool eC_Debug = mode.eC_ToolsDebug;
       bool singleProjectOnlyNode = onlyNodes && onlyNodes.count == 1 && onlyNodes[0].type == project;
       int numJobs = compiler.numJobs;
       char command[MAX_F_STRING*4];
       char * compilerName = CopyString(compiler.name);
+      Map<String, NameCollisionInfo> cfgNameCollisions;
+      const char * objFileExt = strcmp(compiler.objectFileExt, objectDefaultFileExt) != 0 ? compiler.objectFileExt : null;
 
       delete lastBuildConfigName;
       lastBuildConfigName = CopyString(config ? config.name : "Common");
       delete lastBuildCompilerName;
       lastBuildCompilerName = CopyString(compiler.name);
       ProjectLoadLastBuildNamesInfo(this, config);
+      cfgNameCollisions = configsNameCollisions[config ? config.name : ""];
 
       CamelCase(compilerName);
 
@@ -2075,7 +2141,6 @@ private:
          }
          else
          {
-            int len;
             char pushD[MAX_LOCATION];
             char cfDir[MAX_LOCATION];
             GetIDECompilerConfigsDir(cfDir, true, true);
@@ -2084,15 +2149,17 @@ private:
             // Create object dir if it does not exist already
             if(!FileExists(objDirExp.dir).isDirectory)
             {
-               sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s COMPILER=%s objdir -C \"%s\"%s -f \"%s\"",
+               sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s%s COMPILER=%s%s%s objdir -C \"%s\"%s -f \"%s\"",
                      compiler.makeCommand, cfDir,
                      crossCompiling ? " TARGET_PLATFORM=" : "",
                      targetPlatform,
                      bitDepth ? " ARCH=" : "", bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
                      /*(bitDepth == 64 && compiler.targetPlatform == win32) ? " GCC_PREFIX=x86_64-w64-mingw32-" : (bitDepth == 32 && compiler.targetPlatform == win32) ? " GCC_PREFIX=i686-w64-mingw32-" : */"",
 
-                     compilerName, topNode.path, justPrint ? " -n" : "", makeFilePath);
-               if(justPrint)
+                     compilerName,
+                     objFileExt ? " O=." : "", objFileExt ? objFileExt : "",
+                     topNode.path, justPrint ? " -n" : "", makeFilePath);
+               if(justPrint || raw)
                   ide.outputView.buildBox.Logf("%s\n", command);
                Execute(command);
             }
@@ -2101,13 +2168,13 @@ private:
 
             for(node : onlyNodes)
             {
-               if(node.GetIsExcluded(config))
+               if(node.GetIsExcludedForCompiler(config, compiler))
                   ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
                else
                {
                   if(!eC_Debug)
-                     node.DeleteIntermediateFiles(compiler, config, bitDepth, lastBuildNamesInfo, mode == cObject ? true : false);
-                  node.GetTargets(config, lastBuildNamesInfo, objDirExp.dir, makeTargets);
+                     node.DeleteIntermediateFiles(compiler, config, bitDepth, cfgNameCollisions, mode == cObject ? true : false);
+                  node.GetTargets(config, cfgNameCollisions, objDirExp.dir, compiler.objectFileExt, makeTargets);
                }
             }
          }
@@ -2115,20 +2182,20 @@ private:
 
       if(compiler.type.isVC)
       {
-         bool result = false;
+         //bool result = false;
          char oldwd[MAX_LOCATION];
          GetWorkingDir(oldwd, sizeof(oldwd));
          ChangeWorkingDir(topNode.path);
 
          // TODO: support justPrint
          sprintf(command, "%s /useenv /nologo /logcommands %s.sln %s|Win32", compiler.makeCommand, name, config.name);
-         if(justPrint)
+         if(justPrint || raw)
             ide.outputView.buildBox.Logf("%s\n", command);
-         if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
+         if((f = DualPipeOpen(PipeOpenMode { output = true, error = true/*, input = true*/ }, command)))
          {
             ProcessPipeOutputRaw(f);
             delete f;
-            result = true;
+            //result = true;
          }
          ChangeWorkingDir(oldwd);
       }
@@ -2138,9 +2205,11 @@ private:
       }
       else
       {
+         GccVersionInfo ccVersion = GetGccVersionInfo(compiler, compiler.ccCommand);
+         GccVersionInfo cxxVersion = GetGccVersionInfo(compiler, compiler.cxxCommand);
          char cfDir[MAX_LOCATION];
          GetIDECompilerConfigsDir(cfDir, true, true);
-         sprintf(command, "%s%s %sCF_DIR=\"%s\"%s%s%s%s%s COMPILER=%s %s-j%d %s%s%s -C \"%s\"%s -f \"%s\"",
+         sprintf(command, "%s%s %sCF_DIR=\"%s\"%s%s%s%s%s%s COMPILER=%s%s%s %s%s%s-j%d %s%s%s -C \"%s\"%s -f \"%s\"",
 #if defined(__WIN32__)
                "",
 #else
@@ -2153,12 +2222,18 @@ private:
                targetPlatform,
                bitDepth ? " ARCH=" : "",
                bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
+               ide.workspace.useValgrind ? " DISABLED_POOLING=1" : "",
                /*(bitDepth == 64 && compiler.targetPlatform == win32) ? " GCC_PREFIX=x86_64-w64-mingw32-" : (bitDepth == 32 && compiler.targetPlatform == win32) ? " GCC_PREFIX=i686-w64-mingw32-" :*/ "",
-               compilerName, eC_Debug ? "--always-make " : "", numJobs,
+               compilerName,
+               objFileExt ? " O=." : "", objFileExt ? objFileExt : "",
+               eC_Debug ? "--always-make " : "",
+               ccVersion == post4_8 ? "GCC_CC_FLAGS=-fno-diagnostics-show-caret " : "",
+               cxxVersion == post4_8 ? "GCC_CXX_FLAGS=-fno-diagnostics-show-caret " : "",
+               numJobs,
                (compiler.ccacheEnabled && !eC_Debug) ? "CCACHE=y " : "",
                (compiler.distccEnabled && !eC_Debug) ? "DISTCC=y " : "",
                (String)makeTargets, topNode.path, (justPrint || eC_Debug) ? " -n" : "", makeFilePath);
-         if(justPrint)
+         if(justPrint || raw)
             ide.outputView.buildBox.Logf("%s\n", command);
 
          if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
@@ -2179,7 +2254,7 @@ private:
                      {
                         if(justPrint)
                            ide.outputView.buildBox.Logf("%s\n", line);
-                        if(!error && !found && strstr(line, "echo ") == line)
+                        if(!error && !found && strstr(line, "echo ") == line && strstr(line, "ECERE_SDK_SRC"))
                         {
                            strcpy(command, line+5);
                            error = true;
@@ -2195,7 +2270,7 @@ private:
                if(found)
                   result = true;
             }
-            else if(justPrint)
+            else if(justPrint || raw)
                result = ProcessPipeOutputRaw(f);
             else
                result = ProcessBuildPipeOutput(f, objDirExp, buildType, onlyNodes, compiler, config, bitDepth);
@@ -2218,7 +2293,7 @@ private:
       return result;
    }
 
-   void Clean(CompilerConfig compiler, ProjectConfig config, int bitDepth, CleanType cleanType, bool justPrint)
+   void Clean(CompilerConfig compiler, ProjectConfig config, int bitDepth, CleanType cleanType, bool justPrint, bool raw)
    {
       char makeFile[MAX_LOCATION];
       char makeFilePath[MAX_LOCATION];
@@ -2226,8 +2301,9 @@ private:
       char * compilerName;
       DualPipe f;
       PathBackup pathBackup { };
-      bool crossCompiling = (compiler.targetPlatform != GetRuntimePlatform());
-      char * targetPlatform = crossCompiling ? (char *)compiler.targetPlatform : "";
+      bool crossCompiling = (compiler.targetPlatform != __runtimePlatform);
+      const char * targetPlatform = crossCompiling ? (char *)compiler.targetPlatform : "";
+      const char * objFileExt = strcmp(compiler.objectFileExt, objectDefaultFileExt) ? compiler.objectFileExt : null;
 
       compilerName = CopyString(compiler.name);
       CamelCase(compilerName);
@@ -2237,46 +2313,47 @@ private:
       strcpy(makeFilePath, topNode.path);
       CatMakeFileName(makeFile, config);
       PathCatSlash(makeFilePath, makeFile);
-      
+
       if(compiler.type.isVC)
       {
-         bool result = false;
+         //bool result = false;
          char oldwd[MAX_LOCATION];
          GetWorkingDir(oldwd, sizeof(oldwd));
          ChangeWorkingDir(topNode.path);
-         
+
          // TODO: justPrint support
          sprintf(command, "%s /useenv /clean /nologo /logcommands %s.sln %s|Win32", compiler.makeCommand, name, config.name);
-         if(justPrint)
+         if(justPrint || raw)
             ide.outputView.buildBox.Logf("%s\n", command);
          if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
          {
             ProcessPipeOutputRaw(f);
             delete f;
-            result = true;
+            //result = true;
          }
          ChangeWorkingDir(oldwd);
-         return result;
+         //return result;
       }
       else
       {
          char cfDir[MAX_LOCATION];
          GetIDECompilerConfigsDir(cfDir, true, true);
-         sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s COMPILER=%s %sclean%s -C \"%s\"%s -f \"%s\"",
+         sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s COMPILER=%s%s%s %sclean%s -C \"%s\"%s -f \"%s\"",
                compiler.makeCommand, cfDir,
                crossCompiling ? " TARGET_PLATFORM=" : "", targetPlatform,
                bitDepth ? " ARCH=" : "", bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
                compilerName,
+               objFileExt ? " O=." : "", objFileExt ? objFileExt : "",
                cleanType == realClean ? "real" : "", cleanType == cleanTarget ? "target" : "",
                topNode.path, justPrint ? " -n": "", makeFilePath);
-         if(justPrint)
+         if(justPrint || raw)
             ide.outputView.buildBox.Logf("%s\n", command);
-         if((f = DualPipeOpen(PipeOpenMode { output = 1, error = 1, input = 2 }, command)))
+         if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
          {
             ide.outputView.buildBox.Tellf($"Deleting %s%s...",
                   cleanType == realClean ? $"intermediate objects directory" : $"target",
                   cleanType == clean ? $" and object files" : "");
-            if(justPrint)
+            if(justPrint || raw)
                ProcessPipeOutputRaw(f);
             else
                ProcessCleanPipeOutput(f, compiler, config);
@@ -2291,8 +2368,8 @@ private:
       delete compilerName;
    }
 
-   void Run(char * args, CompilerConfig compiler, ProjectConfig config, int bitDepth)
-   {   
+   void Run(const char * args, CompilerConfig compiler, ProjectConfig config, int bitDepth)
+   {
       String target = new char[maxPathLen];
       char oldDirectory[MAX_LOCATION];
       char * executableLauncher = compiler.executableLauncher;
@@ -2316,11 +2393,10 @@ private:
       }
       else
          ChangeWorkingDir(topNode.path);
-      // ChangeWorkingDir(topNode.path);
       SetPath(true, compiler, config, bitDepth);
       if(executableLauncher)
       {
-         char * prefixedTarget = new char[strlen(executableLauncher) + strlen(target) + 2];
+         char * prefixedTarget = new char[strlen(executableLauncher) + strlen(target) + 8];
          prefixedTarget[0] = '\0';
          strcat(prefixedTarget, executableLauncher);
          strcat(prefixedTarget, " ");
@@ -2338,9 +2414,9 @@ private:
       delete target;
    }
 
-   bool Compile(List<ProjectNode> nodes, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint, SingleFileCompileMode mode)
+   bool Compile(List<ProjectNode> nodes, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint, bool raw, SingleFileCompileMode mode)
    {
-      return Build(build, nodes, compiler, config, bitDepth, justPrint, mode);
+      return Build(build, nodes, compiler, config, bitDepth, justPrint, raw, mode);
    }
 #endif
 
@@ -2350,18 +2426,7 @@ private:
       if(targetType == staticLibrary || targetType == sharedLibrary)
          strcat(fileName, "$(LP)");
       strcat(fileName, GetTargetFileName(config));
-      switch(targetType)
-      {
-         case executable:
-            strcat(fileName, "$(E)");
-            break;
-         case sharedLibrary:
-            strcat(fileName, "$(SO)$(VER)");
-            break;
-         case staticLibrary:
-            strcat(fileName, "$(A)");
-            break;
-      }
+      strcat(fileName, "$(OUT)");
    }
 
    bool GenerateCrossPlatformMk(File altCrossPlatformMk)
@@ -2411,14 +2476,14 @@ private:
       return result;
    }
 
-   bool GenerateCompilerCf(CompilerConfig compiler)
+   bool GenerateCompilerCf(CompilerConfig compiler, bool eC)
    {
       bool result = false;
       char path[MAX_LOCATION];
       char * name;
       char * compilerName;
       bool gccCompiler = compiler.ccCommand && (strstr(compiler.ccCommand, "gcc") != null || strstr(compiler.ccCommand, "g++") != null);
-      char * gnuToolchainPrefix = compiler.gnuToolchainPrefix ? compiler.gnuToolchainPrefix : "";
+      const char * gnuToolchainPrefix = compiler.gnuToolchainPrefix ? compiler.gnuToolchainPrefix : "";
       Platform platform = compiler.targetPlatform;
 
       compilerName = CopyString(compiler.name);
@@ -2452,7 +2517,13 @@ private:
                f.Puts("\n");
                for(e : compiler.environmentVars)
                {
+#if defined(__WIN32__)
+                  ChangeCh(e.string, '\\', '/');
+#endif
                   f.Printf("export %s := %s\n", e.name, e.string);
+#if defined(__WIN32__)
+                  ChangeCh(e.string, '/', '\\');
+#endif
                }
                f.Puts("\n");
             }
@@ -2460,6 +2531,17 @@ private:
             f.Puts("# TOOLCHAIN\n");
             f.Puts("\n");
 
+            f.Puts("# OPTIONS\n");
+            if(compiler.resourcesDotEar)
+               f.Puts("USE_RESOURCES_EAR := defined\n");
+            f.Puts("\n");
+
+            f.Puts("# EXTENSIONS\n");
+            if(compiler.outputFileExt)
+               f.Printf("OUT := %s\n", compiler.outputFileExt);
+            else
+               f.Puts("OUT := $(if $(STATIC_LIBRARY_TARGET),$(A),$(if $(SHARED_LIBRARY_TARGET),$(SO)$(VER),$(if $(EXECUTABLE_TARGET),$(E),.x)))\n");
+
             if(gnuToolchainPrefix && gnuToolchainPrefix[0])
             {
                f.Printf("GCC_PREFIX := %s\n", gnuToolchainPrefix);
@@ -2475,24 +2557,34 @@ private:
 
             //f.Printf("SHELL := %s\n", "sh"/*compiler.shellCommand*/); // is this really needed?
             f.Printf("CPP := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)\n", compiler.cppCommand);
-            f.Printf("CC := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)\n", compiler.ccCommand);
-            f.Printf("CXX := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)\n", compiler.cxxCommand);
-            f.Printf("ECP := $(if $(ECP_DEBUG),ide -debug-start \"$(ECERE_SDK_SRC)/compiler/ecp/ecp.epj\" -debug-work-dir \"${CURDIR}\" -@,%s)\n", compiler.ecpCommand);
-            f.Printf("ECC := $(if $(ECC_DEBUG),ide -debug-start \"$(ECERE_SDK_SRC)/compiler/ecc/ecc.epj\" -debug-work-dir \"${CURDIR}\" -@,%s)$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)\n", compiler.eccCommand);
-            f.Printf("ECS := $(if $(ECS_DEBUG),ide -debug-start \"$(ECERE_SDK_SRC)/compiler/ecs/ecs.epj\" -debug-work-dir \"${CURDIR}\" -@,%s)$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)$(if $(OUTPUT_POT), -outputpot,)\n", compiler.ecsCommand);
+            f.Printf("CC := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)$(if $(GCC_CC_FLAGS),$(space)$(GCC_CC_FLAGS),)\n", compiler.ccCommand);
+            f.Printf("CXX := $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)%s$(_SYSROOT)$(if $(GCC_CXX_FLAGS),$(space)$(GCC_CXX_FLAGS),)\n", compiler.cxxCommand);
+            if(eC)
+            {
+               f.Printf("ECP := $(if $(ECP_DEBUG),ide -debug-start \"$(ECERE_SDK_SRC)/compiler/ecp/ecp.epj\" -debug-work-dir \"${CURDIR}\" -@,%s)$(if $(GCC_CC_FLAGS),$(space)$(GCC_CC_FLAGS),)\n", compiler.ecpCommand);
+               f.Printf("ECC := $(if $(ECC_DEBUG),ide -debug-start \"$(ECERE_SDK_SRC)/compiler/ecc/ecc.epj\" -debug-work-dir \"${CURDIR}\" -@,%s)$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)$(if $(GCC_CC_FLAGS),$(space)$(GCC_CC_FLAGS),)\n", compiler.eccCommand);
+               f.Printf("ECS := $(if $(ECS_DEBUG),ide -debug-start \"$(ECERE_SDK_SRC)/compiler/ecs/ecs.epj\" -debug-work-dir \"${CURDIR}\" -@,%s)$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)$(if $(OUTPUT_POT), -outputpot,)$(if $(DISABLED_POOLING), -disabled-pooling,)\n", compiler.ecsCommand);
+            }
+            else
+            {
+               f.Printf("ECP := %s\n", compiler.ecpCommand);
+               f.Printf("ECC := %s$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)\n", compiler.eccCommand);
+               f.Printf("ECS := %s$(if $(CROSS_TARGET), -t $(TARGET_PLATFORM),)$(if $(OUTPUT_POT), -outputpot,)$(if $(DISABLED_POOLING), -disabled-pooling,)\n", compiler.ecsCommand);
+            }
             f.Printf("EAR := %s\n", compiler.earCommand);
 
             f.Puts("AS := $(GCC_PREFIX)as\n");
-            f.Puts("LD := $(GCC_PREFIX)ld\n");
-            f.Puts("AR := $(GCC_PREFIX)ar\n");
+            f.Printf("LD := $(GCC_PREFIX)%s$(_SYSROOT)$(if $(GCC_LD_FLAGS),$(space)$(GCC_LD_FLAGS),)\n",
+                  compiler.ldCommand && compiler.ldCommand[0] ? compiler.ldCommand : "$(if $(CONTAINS_CXX),$(CXX),$(CC))");
+            f.Printf("AR := $(GCC_PREFIX)%s\n", compiler.arCommand);
             f.Puts("STRIP := $(GCC_PREFIX)strip\n");
             f.Puts("ifdef WINDOWS_TARGET\n");
             f.Puts("WINDRES := $(GCC_PREFIX)windres\n");
             f.Puts(" ifdef ARCH\n");
-            f.Puts("  ifeq \"$(ARCH)\" \"x32\"\n");
+            f.Puts("  ifeq ($(ARCH),x32)\n");
             f.Puts("WINDRES_FLAGS := -F pe-i386\n");
             f.Puts("  else\n");
-            f.Puts("   ifeq \"$(ARCH)\" \"x64\"\n");
+            f.Puts("   ifeq ($(ARCH),x64)\n");
             f.Puts("WINDRES_FLAGS := -F pe-x86-64\n");
             f.Puts("   endif\n");
             f.Puts("  endif\n");
@@ -2559,6 +2651,12 @@ private:
                   f.Puts(l);
                }
             }
+            if(compiler.eCcompilerFlags && compiler.eCcompilerFlags.count)
+            {
+               f.Puts("\nECFLAGS +=");
+               OutputFlags(f, any, compiler.eCcompilerFlags, inPlace);
+               f.Puts("\n");
+            }
             if(compiler.compilerFlags && compiler.compilerFlags.count)
             {
                f.Puts("\nCFLAGS +=");
@@ -2589,7 +2687,7 @@ private:
       return result;
    }
 
-   bool GenerateMakefile(char * altMakefilePath, bool noResources, char * includemkPath, ProjectConfig config)
+   bool GenerateMakefile(const char * altMakefilePath, bool noResources, const char * includemkPath, ProjectConfig config)
    {
       bool result = false;
       char filePath[MAX_LOCATION];
@@ -2623,7 +2721,7 @@ private:
          char targetDirExpNoSpaces[MAX_LOCATION];
          char fixedModuleName[MAX_FILENAME];
          char fixedConfigName[MAX_FILENAME];
-         int c, len;
+         int c;
          int lenObjDirExpNoSpaces, lenTargetDirExpNoSpaces;
          // Non-zero if we're building eC code
          // We'll have to be careful with this when merging configs where eC files can be excluded in some configs and included in others
@@ -2632,7 +2730,7 @@ private:
          int numRCObjects = 0;
          bool containsCXX = false; // True if the project contains a C++ file
          bool relObjDir, sameOrRelObjTargetDirs;
-         String objDirExp = GetObjDirExpression(config);
+         const String objDirExp = GetObjDirExpression(config);
          TargetTypes targetType = GetTargetType(config);
 
          char cfDir[MAX_LOCATION];
@@ -2680,6 +2778,9 @@ private:
          f.Printf("MODULE := %s\n", fixedModuleName);
          f.Printf("VERSION := %s\n", property::moduleVersion);
          f.Printf("CONFIG := %s\n", fixedConfigName);
+         topNode.GenMakefilePrintNode(f, this, noPrint, null, null, config, &containsCXX);
+         if(containsCXX)
+            f.Puts("CONTAINS_CXX := defined\n");
          f.Puts("ifndef COMPILER\n" "COMPILER := default\n" "endif\n");
          f.Puts("\n");
 
@@ -2739,7 +2840,7 @@ private:
          if(compilerConfigsDir && compilerConfigsDir[0])
          {
             strcpy(cfDir, compilerConfigsDir);
-            if(cfDir && cfDir[0] && cfDir[strlen(cfDir)-1] != '/')
+            if(cfDir[0] && cfDir[strlen(cfDir)-1] != '/')
                strcat(cfDir, "/");
          }
          else
@@ -2780,7 +2881,7 @@ private:
                      if(ifCount)
                         f.Puts("else\n");
                      ifCount++;
-                     f.Printf("ifeq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(type));
+                     f.Printf("ifeq ($(TARGET_TYPE),%s)\n", TargetTypeToMakefileVariable(type));
 
                      GetMakefileTargetFileName(type, target, config);
                      strcpy(temp, targetDir);
@@ -2816,7 +2917,7 @@ private:
 
          {
             int c;
-            char * map[5][2] = { { "COBJECTS", "C" }, { "SYMBOLS", "S" }, { "IMPORTS", "I" }, { "ECOBJECTS", "O" }, { "BOWLS", "B" } };
+            const char * map[5][2] = { { "COBJECTS", "C" }, { "SYMBOLS", "S" }, { "IMPORTS", "I" }, { "ECOBJECTS", "O" }, { "BOWLS", "B" } };
 
             numCObjects = topNode.GenMakefilePrintNode(f, this, eCsources, namesInfo, listItems, config, null);
             if(numCObjects)
@@ -2836,15 +2937,32 @@ private:
                   if(eCsourcesParts > 1)
                   {
                      int n;
+                     f.Printf("_%s =", map[c][0]);
+                     for(n = 1; n <= eCsourcesParts; n++)
+                        f.Printf(" $(%s%d)", map[c][0], n);
+                     f.Puts("\n");
+                     for(n = 1; n <= eCsourcesParts; n++)
+                        f.Printf("_%s%d = $(addprefix $(OBJ),$(patsubst %%.ec,%%$(%s),$(notdir $(_ECSOURCES%d))))\n", map[c][0], n, map[c][1], n);
+                  }
+                  else if(eCsourcesParts == 1)
+                     f.Printf("_%s = $(addprefix $(OBJ),$(patsubst %%.ec,%%$(%s),$(notdir $(_ECSOURCES))))\n", map[c][0], map[c][1]);
+                  f.Puts("\n");
+               }
+
+               for(c = 0; c < 5; c++)
+               {
+                  if(eCsourcesParts > 1)
+                  {
+                     int n;
                      f.Printf("%s =", map[c][0]);
                      for(n = 1; n <= eCsourcesParts; n++)
                         f.Printf(" $(%s%d)", map[c][0], n);
                      f.Puts("\n");
                      for(n = 1; n <= eCsourcesParts; n++)
-                        f.Printf("%s%d = $(call shwspace,$(addprefix $(OBJ),$(patsubst %%.ec,%%$(%s),$(notdir $(_ECSOURCES%d)))))\n", map[c][0], n, map[c][1], n);
+                        f.Printf("%s%d = $(call shwspace,$(_%s%d))\n", map[c][0], n, map[c][0], n);
                   }
                   else if(eCsourcesParts == 1)
-                     f.Printf("%s = $(call shwspace,$(addprefix $(OBJ),$(patsubst %%.ec,%%$(%s),$(notdir $(_ECSOURCES)))))\n", map[c][0], map[c][1]);
+                     f.Printf("%s = $(call shwspace,$(_%s))\n", map[c][0], map[c][0]);
                   f.Puts("\n");
                }
             }
@@ -2884,7 +3002,7 @@ private:
             f.Puts("endif\n\n");
          }
 
-         numObjects = topNode.GenMakefilePrintNode(f, this, objects, namesInfo, listItems, config, &containsCXX);
+         numObjects = topNode.GenMakefilePrintNode(f, this, objects, namesInfo, listItems, config, null);
          if(numObjects)
             objectsParts = OutputFileList(f, "_OBJECTS", listItems, varStringLenDiffs, null);
          f.Printf("OBJECTS =%s%s%s%s\n",
@@ -2895,7 +3013,7 @@ private:
 
          topNode.GenMakefilePrintNode(f, this, sources, null, listItems, config, null);
          {
-            char * prefix;
+            const char * prefix;
             if(numCObjects && numRCObjects)
                prefix = "$(ECSOURCES) $(RCSOURCES)";
             else if(numCObjects)
@@ -2909,6 +3027,13 @@ private:
             resNode.GenMakefilePrintNode(f, this, resources, null, listItems, config, null);
          OutputFileList(f, "RESOURCES", listItems, varStringLenDiffs, null);
 
+         f.Puts("ifdef USE_RESOURCES_EAR\n");
+         f.Puts("RESOURCES_EAR = $(OBJ)resources.ear\n");
+         f.Puts("else\n");
+         f.Puts("RESOURCES_EAR = $(RESOURCES)\n");
+         f.Puts("endif\n");
+         f.Puts("\n");
+
          f.Puts("LIBS += $(SHAREDLIB) $(EXECUTABLE) $(LINKOPT)\n");
          f.Puts("\n");
          if((config && config.options && config.options.libraries) ||
@@ -2925,11 +3050,12 @@ private:
             f.Puts("\n");
          }
 
-         topNode.GenMakeCollectAssignNodeFlags(config, numCObjects,
+         topNode.GenMakeCollectAssignNodeFlags(config, numCObjects != 0,
                cflagsVariations, nodeCFlagsMapping,
                ecflagsVariations, nodeECFlagsMapping, null);
 
          GenMakePrintCustomFlags(f, "PRJ_CFLAGS", false, cflagsVariations);
+         f.Puts("ECFLAGS += -module $(MODULE)\n");
          GenMakePrintCustomFlags(f, "ECFLAGS", true, ecflagsVariations);
 
          if(platforms || (config && config.platforms))
@@ -3160,10 +3286,12 @@ private:
 
          f.Puts("objdir:\n");
          if(!relObjDir)
-            f.Puts("\t$(if $(wildcard $(OBJ)),,$(call mkdirq,$(OBJ)))\n");
-
+            f.Puts("\t$(if $(wildcard $(OBJ)),,$(call mkdir,$(OBJ)))\n");
+         if(numCObjects)
+         {
             f.Puts("\t$(if $(ECERE_SDK_SRC),$(if $(wildcard $(call escspace,$(ECERE_SDK_SRC)/crossplatform.mk)),,@$(call echo,Ecere SDK Source Warning: The value of ECERE_SDK_SRC is pointing to an incorrect ($(ECERE_SDK_SRC)) location.)),)\n");
             f.Puts("\t$(if $(ECERE_SDK_SRC),,$(if $(ECP_DEBUG)$(ECC_DEBUG)$(ECS_DEBUG),@$(call echo,ECC Debug Warning: Please define ECERE_SDK_SRC before using ECP_DEBUG, ECC_DEBUG or ECS_DEBUG),))\n");
+         }
          //f.Puts("# PRE-BUILD COMMANDS\n");
          if(options && options.prebuildCommands)
          {
@@ -3216,7 +3344,7 @@ private:
          if(!sameOrRelObjTargetDirs)
          {
             f.Puts("targetdir:\n");
-               f.Printf("\t$(if $(wildcard %s),,$(call mkdirq,%s))\n", targetDirExpNoSpaces, targetDirExpNoSpaces);
+               f.Printf("\t$(if $(wildcard %s),,$(call mkdir,%s))\n", targetDirExpNoSpaces, targetDirExpNoSpaces);
             f.Puts("\n");
          }
 
@@ -3224,8 +3352,12 @@ private:
          {
             // Main Module (Linking) for ECERE C modules
             f.Puts("$(OBJ)$(MODULE).main.ec: $(SYMBOLS) $(COBJECTS)\n");
+            f.Printf("\t@$(call rm,$(OBJ)symbols.lst)\n");
+            f.Printf("\t@$(call touch,$(OBJ)symbols.lst)\n");
+            OutputFileListActions(f, "SYMBOLS", eCsourcesParts, "$(OBJ)symbols.lst");
+            OutputFileListActions(f, "IMPORTS", eCsourcesParts, "$(OBJ)symbols.lst");
             // use of objDirExpNoSpaces used instead of $(OBJ) to prevent problematic joining of arguments in ecs
-            f.Printf("\t$(ECS)%s $(ARCH_FLAGS) $(ECSLIBOPT) $(SYMBOLS) $(IMPORTS) -symbols %s -o $(call escspace,$@)\n",
+            f.Printf("\t$(ECS)%s $(ARCH_FLAGS) $(ECSLIBOPT) @$(OBJ)symbols.lst -symbols %s -o $(call quote_path,$@)\n",
                GetConsole(config) ? " -console" : "", objDirExpNoSpaces);
             f.Puts("\n");
             // Main Module (Linking) for ECERE C modules
@@ -3233,7 +3365,16 @@ private:
             f.Puts("\t$(ECP) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS)"
                   " -c $(OBJ)$(MODULE).main.ec -o $(OBJ)$(MODULE).main.sym -symbols $(OBJ)\n");
             f.Puts("\t$(ECC) $(CFLAGS) $(CECFLAGS) $(ECFLAGS) $(PRJ_CFLAGS) $(FVISIBILITY)"
-                  " -c $(OBJ)$(MODULE).main.ec -o $(call escspace,$@) -symbols $(OBJ)\n");
+                  " -c $(OBJ)$(MODULE).main.ec -o $(call quote_path,$@) -symbols $(OBJ)\n");
+            f.Puts("\n");
+         }
+
+         if(resNode.files && resNode.files.count && !noResources)
+         {
+            f.Puts("ifdef USE_RESOURCES_EAR\n");
+            f.Puts("$(RESOURCES_EAR): $(RESOURCES) | objdir\n");
+               resNode.GenMakefileAddResources(f, resNode.path, config, "RESOURCES_EAR");
+            f.Puts("endif\n");
             f.Puts("\n");
          }
 
@@ -3247,27 +3388,27 @@ private:
          f.Puts("$(OBJECTS): | objdir\n");
 
          // This alone was breaking the tarball, object directory does not get created first (order-only rules happen last it seems!)
-         f.Printf("$(TARGET): $(SOURCES)%s $(RESOURCES) $(SYMBOLS) $(OBJECTS) | objdir%s\n",
+         f.Printf("$(TARGET): $(SOURCES)%s $(RESOURCES_EAR) $(SYMBOLS) $(OBJECTS) | objdir%s\n",
                rcSourcesParts ? " $(RCSOURCES)" : "", sameOrRelObjTargetDirs ? "" : " targetdir");
 
-         f.Printf("\t@$(call rmq,$(OBJ)linkobjects.lst)\n");
-         f.Printf("\t@$(call touch,$(OBJ)linkobjects.lst)\n");
-         OutputLinkObjectActions(f, "_OBJECTS", objectsParts);
+         f.Printf("\t@$(call rm,$(OBJ)objects.lst)\n");
+         f.Printf("\t@$(call touch,$(OBJ)objects.lst)\n");
+         OutputFileListActions(f, "_OBJECTS", objectsParts, "$(OBJ)objects.lst");
          if(rcSourcesParts)
          {
             f.Puts("ifdef WINDOWS_TARGET\n");
-            OutputLinkObjectActions(f, "RCOBJECTS", rcSourcesParts);
+            OutputFileListActions(f, "RCOBJECTS", rcSourcesParts, "$(OBJ)objects.lst");
             f.Puts("endif\n");
          }
          if(numCObjects)
          {
-            f.Printf("\t@$(call echo,$(OBJ)$(MODULE).main$(O)) >> $(OBJ)linkobjects.lst\n");
-            OutputLinkObjectActions(f, "ECOBJECTS", eCsourcesParts);
+            f.Printf("\t@$(call echo,$(OBJ)$(MODULE).main$(O)) >> $(OBJ)objects.lst\n");
+            OutputFileListActions(f, "ECOBJECTS", eCsourcesParts, "$(OBJ)objects.lst");
          }
 
          f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
 
-         f.Printf("\t$(%s) $(OFLAGS) @$(OBJ)linkobjects.lst $(LIBS) %s-o $(TARGET) $(INSTALLNAME)\n", containsCXX ? "CXX" : "CC", containsCXX ? "-lstdc++ " : "");
+         f.Puts("\t$(LD) $(OFLAGS) @$(OBJ)objects.lst $(LIBS) -o $(TARGET) $(INSTALLNAME)\n");
          if(!GetDebug(config))
          {
             f.Puts("ifndef NOSTRIP\n");
@@ -3281,16 +3422,24 @@ private:
                   f.Puts("\t$(UPX) $(UPXFLAGS) $(TARGET)\n");
                f.Puts("endif\n");
                f.Puts("else\n");
-               f.Puts("ifneq \"$(TARGET_ARCH)\" \"x86_64\"");
+               //f.Puts("ifneq ($(TARGET_ARCH),x86_64)\n");
                   f.Puts("\t$(UPX) $(UPXFLAGS) $(TARGET)\n");
-               f.Puts("endif\n");
+               //f.Puts("endif\n");
                f.Puts("endif\n");
             }
          }
          if(resNode.files && resNode.files.count && !noResources)
-            resNode.GenMakefileAddResources(f, resNode.path, config);
+         {
+            f.Puts("ifndef USE_RESOURCES_EAR\n");
+            resNode.GenMakefileAddResources(f, resNode.path, config, "TARGET");
+            f.Puts("endif\n");
+         }
+         f.Puts("else\n");
+         f.Puts("ifdef WINDOWS_HOST\n");
+         f.Puts("\t$(AR) rcs $(TARGET) @$(OBJ)objects.lst $(LIBS)\n");
          f.Puts("else\n");
-         f.Puts("\t$(AR) rcs $(TARGET) @$(OBJ)linkobjects.lst $(LIBS)\n");
+         f.Puts("\t$(AR) rcs $(TARGET) $(OBJECTS) $(LIBS)\n");
+         f.Puts("endif\n");
          f.Puts("endif\n");
          f.Puts("ifdef SHARED_LIBRARY_TARGET\n");
          f.Puts("ifdef LINUX_TARGET\n");
@@ -3439,21 +3588,26 @@ private:
             GenMakefilePrintMainObjectRule(f, config);
 
          f.Printf("cleantarget: objdir%s\n", sameOrRelObjTargetDirs ? "" : " targetdir");
-         f.Puts("\t$(call rmq,$(TARGET))\n");
+         if(numCObjects)
+         {
+            f.Printf("\t$(call rm,%s)\n", "$(OBJ)$(MODULE).main$(O) $(OBJ)$(MODULE).main.c $(OBJ)$(MODULE).main.ec $(OBJ)$(MODULE).main$(I) $(OBJ)$(MODULE).main$(S)");
+            f.Printf("\t$(call rm,$(OBJ)symbols.lst)\n");
+         }
+         f.Printf("\t$(call rm,$(OBJ)objects.lst)\n");
+         f.Puts("\t$(call rm,$(TARGET))\n");
          f.Puts("ifdef SHARED_LIBRARY_TARGET\n");
          f.Puts("ifdef LINUX_TARGET\n");
          f.Puts("ifdef LINUX_HOST\n");
          // TODO?: support symlinks for longer version numbers
-         f.Puts("\t$(call rmq,$(OBJ)$(LP)$(MODULE)$(SO)$(basename $(VER)))\n");
-         f.Puts("\t$(call rmq,$(OBJ)$(LP)$(MODULE)$(SO))\n");
+         f.Puts("\t$(call rm,$(OBJ)$(LP)$(MODULE)$(SO)$(basename $(VER)))\n");
+         f.Puts("\t$(call rm,$(OBJ)$(LP)$(MODULE)$(SO))\n");
          f.Puts("endif\n");
          f.Puts("endif\n");
          f.Puts("endif\n");
          f.Puts("\n");
 
          f.Puts("clean: cleantarget\n");
-         f.Printf("\t$(call rmq,$(OBJ)linkobjects.lst)\n");
-         OutputCleanActions(f, "_OBJECTS", objectsParts);
+         OutputCleanActions(f, "OBJECTS", objectsParts);
          if(rcSourcesParts)
          {
             f.Puts("ifdef WINDOWS_TARGET\n");
@@ -3462,26 +3616,34 @@ private:
          }
          if(numCObjects)
          {
-            f.Printf("\t$(call rmq,%s)\n", "$(OBJ)$(MODULE).main.o $(OBJ)$(MODULE).main.c $(OBJ)$(MODULE).main.ec $(OBJ)$(MODULE).main$(I) $(OBJ)$(MODULE).main$(S)");
             OutputCleanActions(f, "ECOBJECTS", eCsourcesParts);
             OutputCleanActions(f, "COBJECTS", eCsourcesParts);
             OutputCleanActions(f, "BOWLS", eCsourcesParts);
             OutputCleanActions(f, "IMPORTS", eCsourcesParts);
             OutputCleanActions(f, "SYMBOLS", eCsourcesParts);
          }
+         if(resNode.files && resNode.files.count && !noResources)
+         {
+            f.Puts("ifdef USE_RESOURCES_EAR\n");
+            f.Printf("\t$(call rm,$(RESOURCES_EAR))\n");
+            f.Puts("endif\n");
+         }
          f.Puts("\n");
 
          f.Puts("realclean: cleantarget\n");
-         f.Puts("\t$(call rmrq,$(OBJ))\n");
+         f.Puts("\t$(call rmr,$(OBJ))\n");
          if(!sameOrRelObjTargetDirs)
-            f.Printf("\t$(call rmdirq,%s)\n", targetDirExpNoSpaces);
+            f.Printf("\t$(call rmdir,%s)\n", targetDirExpNoSpaces);
          f.Puts("\n");
 
          f.Puts("distclean: cleantarget\n");
          if(!sameOrRelObjTargetDirs)
-            f.Printf("\t$(call rmdirq,%s)\n", targetDirExpNoSpaces);
+            f.Printf("\t$(call rmdir,%s)\n", targetDirExpNoSpaces);
          if(!relObjDir)
-            f.Puts("\t$(call rmrq,obj/)\n");
+            f.Puts("\t$(call rmr,obj/)\n");
+         f.Puts("\t$(call rmr,.configs/)\n");
+         f.Puts("\t$(call rm,*.ews)\n");
+         f.Puts("\t$(call rm,*.Makefile)\n");
 
          delete f;
 
@@ -3511,16 +3673,16 @@ private:
    void GenMakefilePrintMainObjectRule(File f, ProjectConfig config)
    {
       char extension[MAX_EXTENSION] = "c";
-      char modulePath[MAX_LOCATION];
+      //char modulePath[MAX_LOCATION];
       char fixedModuleName[MAX_FILENAME];
-      DualPipe dep;
-      char command[2048];
+      //DualPipe dep;
+      //char command[2048];
       char objDirNoSpaces[MAX_LOCATION];
-      String objDirExp = GetObjDirExpression(config);
+      const String objDirExp = GetObjDirExpression(config);
 
       ReplaceSpaces(objDirNoSpaces, objDirExp);
       ReplaceSpaces(fixedModuleName, moduleName);
-      
+
       //sprintf(fixedModuleName, "%s.main", fixedPrjName);
       //strcat(fixedModuleName, ".main");
 
@@ -3561,7 +3723,7 @@ private:
       }
 
       // Execute it
-      if((dep = DualPipeOpen(PipeOpenMode { output = 1, error = 1, input = 2 }, command)))
+      if((dep = DualPipeOpen(PipeOpenMode { output = true, error = true/*, input = true*/ }, command)))
       {
          char line[1024];
          bool result = true;
@@ -3594,7 +3756,7 @@ private:
          {
 #endif
             f.Puts("$(OBJ)$(MODULE).main$(O): $(OBJ)$(MODULE).main.c\n");
-            f.Printf("\t$(CC) $(CFLAGS) $(PRJ_CFLAGS) $(FVISIBILITY) -c $(OBJ)$(MODULE).main.%s -o $(call escspace,$@)\n", extension);
+            f.Printf("\t$(CC) $(CFLAGS) $(PRJ_CFLAGS) $(FVISIBILITY) -c $(OBJ)$(MODULE).main.%s -o $(call quote_path,$@)\n", extension);
             f.Puts("\n");
 #if 0
          }
@@ -3602,7 +3764,7 @@ private:
 #endif
    }
 
-   void GenMakePrintCustomFlags(File f, String variableName, bool printNonCustom, Map<String, int> cflagsVariations)
+   void GenMakePrintCustomFlags(File f, const String variableName, bool printNonCustom, Map<String, int> cflagsVariations)
    {
       int c;
       for(c = printNonCustom ? 0 : 1; c <= cflagsVariations.count; c++)
@@ -3655,16 +3817,18 @@ private:
 
 static inline void ProjectLoadLastBuildNamesInfo(Project prj, ProjectConfig cfg)
 {
-   if(prj.lastBuildNamesInfo)
+   const char * cfgName = cfg ? cfg.name : "";
+   Map<String, NameCollisionInfo> cfgNameCollisions = prj.configsNameCollisions[cfgName];
+   if(cfgNameCollisions)
    {
-      prj.lastBuildNamesInfo.Free();
-      delete prj.lastBuildNamesInfo;
+      cfgNameCollisions.Free();
+      delete cfgNameCollisions;
    }
-   prj.lastBuildNamesInfo = { };
-   prj.topNode.GenMakefileGetNameCollisionInfo(prj.lastBuildNamesInfo, cfg);
+   prj.configsNameCollisions[cfgName] = cfgNameCollisions = { };
+   prj.topNode.GenMakefileGetNameCollisionInfo(cfgNameCollisions, cfg);
 }
 
-Project LegacyBinaryLoadProject(File f, char * filePath)
+Project LegacyBinaryLoadProject(File f, const char * filePath)
 {
    Project project = null;
    char signature[sizeof(epjSignature)];
@@ -3690,13 +3854,13 @@ Project LegacyBinaryLoadProject(File f, char * filePath)
 
       PathCatSlash(topNodePath, filePath);
       project.filePath = topNodePath;
-      
+
       /* THIS IS ALREADY DONE BY filePath property
       StripLastDirectory(topNodePath, topNodePath);
       project.topNode.path = CopyString(topNodePath);
       */
       // Shouldn't this be done BEFORE the StripLastDirectory? project.filePath = topNodePath;
-      
+
       // newConfig.options.defaultNameSpace = "";
       /*newConfig.objDir.dir = "obj";
       newConfig.targetDir.dir = "";*/
@@ -3740,7 +3904,7 @@ Project LegacyBinaryLoadProject(File f, char * filePath)
 
          f.Read(&temp, sizeof(int),1);
          project./*config.*/options.debug = temp ? true : false;
-         f.Read(&temp, sizeof(int),1);         
+         f.Read(&temp, sizeof(int),1);
          project./*config.*/options.optimization = temp ? speed : none;
          f.Read(&temp, sizeof(int),1);
          project./*config.*/options.profile = temp ? true : false;
@@ -3767,7 +3931,7 @@ Project LegacyBinaryLoadProject(File f, char * filePath)
             project.options.libraryDirs = { };
             for(c = 0; c < count; c++)
             {
-               char * name;            
+               char * name;
                f.Read(&len, sizeof(int),1);
                name = new char[len+1];
                f.Read(name, sizeof(char), len+1);
@@ -3822,7 +3986,7 @@ Project LegacyBinaryLoadProject(File f, char * filePath)
 }
 
 void ProjectConfig::LegacyProjectConfigLoad(File f)
-{  
+{
    delete options;
    options = { };
    while(!f.Eof())
@@ -3831,9 +3995,8 @@ void ProjectConfig::LegacyProjectConfigLoad(File f)
       char section[128];
       char subSection[128];
       char * equal;
-      int len;
       uint pos;
-      
+
       pos = f.Tell();
       f.GetLine(buffer, 65536 - 1);
       TrimLSpaces(buffer, buffer);
@@ -3964,15 +4127,14 @@ void ProjectConfig::LegacyProjectConfigLoad(File f)
    makingModified = true;
 }
 
-Project LegacyAsciiLoadProject(File f, char * filePath)
+Project LegacyAsciiLoadProject(File f, const char * filePath)
 {
    Project project = null;
-   ProjectNode node = null;
    int pos;
    char parentPath[MAX_LOCATION];
    char section[128] = "";
    char subSection[128] = "";
-   ProjectNode parent;
+   ProjectNode parent = null;
    bool configurationsPresent = false;
 
    f.Seek(0, start);
@@ -4035,7 +4197,7 @@ Project LegacyAsciiLoadProject(File f, char * filePath)
                   child.type = file;
                   child.icon = NodeIcons::SelectFileIcon(child.name);
                   parent.files.Add(child);
-                  node = child;
+                  //node = child;
                   //child = null;
                }
                else
@@ -4069,7 +4231,7 @@ Project LegacyAsciiLoadProject(File f, char * filePath)
                PathCatSlash(parentPath, child.name);
                parent.files.Add(child);
                parent = child;
-               node = child;
+               //node = child;
                //child = null;
             }
             else if(!strcmpi(section, "Configurations"))
@@ -4113,7 +4275,7 @@ Project LegacyAsciiLoadProject(File f, char * filePath)
             project.filePath = topNodePath;
             parentPath[0] = '\0';
             parent = project.topNode;
-            node = parent;
+            //node = parent;
             strcpy(section, "Target");
             equal = &buffer[6];
             if(equal[0] == ' ')
@@ -4150,7 +4312,7 @@ Project LegacyAsciiLoadProject(File f, char * filePath)
             child.icon = archiveFile;
             project.resNode = child;
             parent = child;
-            node = child;
+            //node = child;
             strcpy(subSection, buffer);
          }
          else
@@ -4296,7 +4458,7 @@ void SplitPlatformLibraries(Project project)
                }
             }
          }
-      }      
+      }
    }
 }
 
@@ -4334,16 +4496,16 @@ void CombineIdenticalConfigOptions(Project project)
                      if(cfg.options.targetType != staticLibrary)
                      {
                         int result;
-                        
+
                         if(type.type == noHeadClass || type.type == normalClass)
                         {
-                           result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type, 
+                           result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
                               *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
                               *(void **)((byte *)cfg.options         + member.offset + member._class.offset));
                         }
                         else
                         {
-                           result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type, 
+                           result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
                               (byte *)firstConfig.options + member.offset + member._class.offset,
                               (byte *)cfg.options         + member.offset + member._class.offset);
                         }
@@ -4353,30 +4515,30 @@ void CombineIdenticalConfigOptions(Project project)
                            break;
                         }
                      }
-                  }                  
+                  }
                }
                if(same)
                {
                   if(type.type == noHeadClass || type.type == normalClass)
                   {
-                     if(!((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type, 
+                     if(!((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
                         *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
                         *(void **)((byte *)nullOptions         + member.offset + member._class.offset)))
                         continue;
                   }
                   else
                   {
-                     if(!((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type, 
+                     if(!((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
                         (byte *)firstConfig.options + member.offset + member._class.offset,
                         (byte *)nullOptions         + member.offset + member._class.offset))
                         continue;
                   }
 
                   if(!project.options) project.options = { };
-                  
+
                   /*if(type.type == noHeadClass || type.type == normalClass)
                   {
-                     ((void (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCopy])(type, 
+                     ((void (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCopy])(type,
                         (byte *)project.options + member.offset + member._class.offset,
                         *(void **)((byte *)firstConfig.options + member.offset + member._class.offset));
                   }
@@ -4384,12 +4546,12 @@ void CombineIdenticalConfigOptions(Project project)
                   {
                      void * address = (byte *)firstConfig.options + member.offset + member._class.offset;
                      // TOFIX: ListBox::SetData / OnCopy mess
-                     ((void (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCopy])(type, 
+                     ((void (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCopy])(type,
                         (byte *)project.options + member.offset + member._class.offset,
-                        (type.typeSize > 4) ? address : 
-                           ((type.typeSize == 4) ? (void *)*(uint32 *)address : 
-                              ((type.typeSize == 2) ? (void *)*(uint16*)address : 
-                                 (void *)*(byte *)address )));                              
+                        (type.typeSize > 4) ? address :
+                           ((type.typeSize == 4) ? (void *)*(uint32 *)address :
+                              ((type.typeSize == 2) ? (void *)*(uint16*)address :
+                                 (void *)*(byte *)address )));
                   }*/
                   memcpy(
                      (byte *)project.options + member.offset + member._class.offset,
@@ -4400,16 +4562,16 @@ void CombineIdenticalConfigOptions(Project project)
                      if(cfg.options.targetType == staticLibrary)
                      {
                         int result;
-                        
+
                         if(type.type == noHeadClass || type.type == normalClass)
                         {
-                           result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type, 
+                           result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
                               *(void **)((byte *)firstConfig.options + member.offset + member._class.offset),
                               *(void **)((byte *)cfg.options         + member.offset + member._class.offset));
                         }
                         else
                         {
-                           result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type, 
+                           result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type,
                               (byte *)firstConfig.options + member.offset + member._class.offset,
                               (byte *)cfg.options         + member.offset + member._class.offset);
                         }
@@ -4420,16 +4582,16 @@ void CombineIdenticalConfigOptions(Project project)
                      {
                         if(type.type == noHeadClass || type.type == normalClass)
                         {
-                           ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, 
+                           ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type,
                               *(void **)((byte *)cfg.options + member.offset + member._class.offset));
                         }
                         else
                         {
-                           ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, 
+                           ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type,
                               (byte *)cfg.options + member.offset + member._class.offset);
                         }
                         memset((byte *)cfg.options + member.offset + member._class.offset, 0, type.typeSize);
-                     }                     
+                     }
                   }
                   memset((byte *)firstConfig.options + member.offset + member._class.offset, 0, type.typeSize);
                }
@@ -4458,12 +4620,11 @@ void CombineIdenticalConfigOptions(Project project)
                   continue;
                if(cfg != firstConfig)
                {
-                  cfg.platforms.Free();
-                  delete cfg.platforms;
+                  cfg.platforms = null;
                }
             }
             project.platforms = firstConfig.platforms;
-            firstConfig.platforms = null;
+            *&firstConfig.platforms = null;
          }
       }
 
@@ -4479,7 +4640,7 @@ void CombineIdenticalConfigOptions(Project project)
    }
 }
 
-Project LoadProject(char * filePath, char * activeConfigName)
+Project LoadProject(const char * filePath, const char * activeConfigName)
 {
    Project project = null;
    File f = FileOpen(filePath, read);
@@ -4489,7 +4650,7 @@ Project LoadProject(char * filePath, char * activeConfigName)
       if(!project)
       {
          JSONParser parser { f = f };
-         JSONResult result = parser.GetObject(class(Project), &project);
+         /*JSONResult result = */parser.GetObject(class(Project), &project);
          if(project)
          {
             char insidePath[MAX_LOCATION];
@@ -4540,15 +4701,15 @@ Project LoadProject(char * filePath, char * activeConfigName)
          {
             project.resNode = project.topNode.Add(project, "Resources", project.topNode.files.last, resources, archiveFile, false);
          }
-         
+
          if(!project.moduleName)
             project.moduleName = CopyString(project.name);
-         if(project.config && 
+         if(project.config &&
             (!project.options || !project.options.targetFileName || !project.options.targetFileName[0]) &&
             (!project.config.options.targetFileName || !project.config.options.targetFileName[0]))
          {
             //delete project.config.options.targetFileName;
-            
+
             project.options.targetFileName = /*CopyString(*/project.moduleName/*)*/;
             project.config.options.optimization = none;
             project.config.options.debug = true;
@@ -4570,3 +4731,77 @@ Project LoadProject(char * filePath, char * activeConfigName)
    }
    return project;
 }
+
+#ifndef MAKEFILE_GENERATOR
+static GccVersionInfo GetGccVersionInfo(CompilerConfig compiler, const String compilerCommand)
+{
+   GccVersionInfo result = unknown;
+   if(compiler.ccCommand)
+   {
+      char command[MAX_F_STRING*4];
+      DualPipe f;
+      sprintf(command, "%s%s --version", compiler.gccPrefix ? compiler.gccPrefix : "", compilerCommand);
+      if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
+      {
+         bool firstLine = true;
+         while(!f.eof)
+         {
+            char line[1024];
+            char * tokens[128];
+            if(f.GetLine(line,sizeof(line)))
+            {
+               if(firstLine)
+               {
+                  uint count = Tokenize(line, sizeof(tokens)/sizeof(tokens[0]), tokens,false);
+                  char * token = null;
+                  int i;
+                  bool inPar = false;
+                  for(i = 0; i < count; i++)
+                  {
+                     if(tokens[i][0] == '(')
+                     {
+                        if(tokens[i][strlen(tokens[i])-1] != ')')
+                           inPar = true;
+                     }
+                     else if(tokens[i][0] && tokens[i][strlen(tokens[i])-1] == ')')
+                        inPar = false;
+                     else if(!inPar && isdigit(tokens[i][0]) && strchr(tokens[i], '.'))
+                        token = tokens[i];
+                  }
+                  if(token)
+                     result = GccVersionInfo::GetVersionInfo(token);
+                  firstLine = false;
+               }
+            }
+         }
+         delete f;
+      }
+   }
+   return result;
+}
+
+static enum GccVersionInfo
+{
+   unknown, pre4_8, post4_8;
+
+   GccVersionInfo ::GetVersionInfo(char * version)
+   {
+      GccVersionInfo result = unknown;
+      int ver;
+      char * s = CopyString(version);
+      char * tokens[16];
+      uint count = TokenizeWith(s, sizeof(tokens)/sizeof(tokens[0]), tokens, ".", false);
+      ver = count > 1 ? atoi(tokens[1]) : 0;
+      ver += count ? atoi(tokens[0]) * 1000 : 0;
+      if(ver > 0)
+      {
+         if(ver < 4008)
+            result = pre4_8;
+         else
+            result = post4_8;
+      }
+      delete s;
+      return result;
+   }
+};
+#endif