ide/Project: Fixed crashes on replacing spaces (#156)
[sdk] / ide / src / project / Project.ec
old mode 100755 (executable)
new mode 100644 (file)
index 8ec3d3e..e1b6e7d
@@ -46,6 +46,7 @@ IDESettingsContainer settingsContainer
 #ifndef MAKEFILE_GENERATOR
       globalSettingsDialog.ideSettings = settings;
       ide.UpdateRecentMenus();
+      ide.UpdateCompilerConfigs(true);
 #endif
    }
 };
@@ -373,6 +374,36 @@ define PEEK_RESOLUTION = (18.2 * 10);
 #define SEPS    "/"
 #define SEP     '/'
 
+static Array<String> notLinkerOptions
+{ [
+   "-static-libgcc",
+   "-shared",
+   "-static",
+   "-s",
+   "-shared-libgcc",
+   "-nostartfiles",
+   "-nodefaultlibs",
+   "-nostdlib",
+   "-pie",
+   "-rdynamic",
+   "-static-libasan",
+   "-static-libtsan",
+   "-static libstdc++",
+   "-symbolic",
+   "-Wl,"
+   //"-T ",
+   //"-Xlinker ",
+   //"-u "
+] };
+
+static bool IsLinkerOption(String s)
+{
+   for(i : notLinkerOptions)
+      if(strstr(s, "-Wl,") || !strcmp(s, i))
+         return false;
+   return true;
+}
+
 static byte epjSignature[] = { 'E', 'P', 'J', 0x04, 0x01, 0x12, 0x03, 0x12 };
 
 enum GenMakefilePrintTypes { objects, cObjects, symbols, imports, sources, resources, eCsources };
@@ -381,7 +412,9 @@ define WorkspaceExtension = "ews";
 define ProjectExtension = "epj";
 
 define stringInFileIncludedFrom = "In file included from ";
+define stringFrom =               "                 from ";
 
+// This function cannot accept same pointer for source and output
 void ReplaceSpaces(char * output, char * source)
 {
    int c, dc;
@@ -402,6 +435,7 @@ void ReplaceSpaces(char * output, char * source)
    output[dc] = '\0';
 }
 
+// This function cannot accept same pointer for source and output
 void ReplaceUnwantedMakeChars(char * output, char * source)
 {
    int c, dc;
@@ -524,6 +558,18 @@ int OutputFileList(File f, char * name, Array<String> list, Map<String, int> var
    return numOfBreaks;
 }
 
+void OutputLinkObjectActions(File f, char * name, int parts)
+{
+   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);
+   } else if(parts) {
+      f.Printf("\t@$(call echo,$(%s)) >> $(OBJ)linkobjects.lst\n", name);
+   }
+}
+
 void OutputCleanActions(File f, char * name, int parts)
 {
    if(parts > 1)
@@ -696,7 +742,7 @@ char * GetConfigName(ProjectConfig config)
    return config ? config.name : "Common";
 }
 
-public enum SingleFileCompileMode { normal, debugPrecompile, debugCompile, debugGenerateSymbols };
+public enum SingleFileCompileMode { normal, debugPrecompile, debugCompile, debugGenerateSymbols, cObject };
 
 class Project : struct
 {
@@ -707,6 +753,34 @@ public:
    float version;
    String moduleName;
 
+   property 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
+   {
+      set { delete description; if(value && value[0]) description = CopyString(value); }
+      get { return description ? description : ""; }
+      isset { return description != null && description[0]; }
+   }
+
+   property 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
+   {
+      set { delete compilerConfigsDir; if(value && value[0]) compilerConfigsDir = CopyString(value); }
+      get { return compilerConfigsDir ? compilerConfigsDir : ""; }
+      isset { return compilerConfigsDir && compilerConfigsDir[0]; }
+   }
+
    property ProjectOptions options { get { return options; } set { options = value; } isset { return options && !options.isEmpty; } }
    property Array<PlatformOptions> platforms
    {
@@ -742,27 +816,6 @@ public:
    String resourcesPath;
    LinkList<ProjectNode> resources;
 
-   property 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
-   {
-      set { delete license; if(value && value[0]) license = CopyString(value); }
-      get { return license ? license : ""; }
-      isset { return license != null && license[0]; }
-   }
-
-   property char * compilerConfigsDir
-   {
-      set { delete compilerConfigsDir; if(value && value[0]) compilerConfigsDir = CopyString(value); }
-      get { return compilerConfigsDir ? compilerConfigsDir : ""; }
-      isset { return compilerConfigsDir && compilerConfigsDir[0]; }
-   }
-
 private:
    // topNode.name holds the file name (.epj)
    ProjectOptions options;
@@ -779,6 +832,8 @@ private:
    String description;
    String license;
    String compilerConfigsDir;
+   String moduleVersion;
+
 #ifndef MAKEFILE_GENERATOR
    FileMonitor fileMonitor
    {
@@ -819,26 +874,41 @@ private:
             ProjectView projectView = ide.projectView;
             DataRow prev = topNode.row ? topNode.row.previous : null;
             FileMonitor fm = fileMonitor;
-
-            if(projectView) projectView.DeleteNode(topNode);
-
-            *this = *project;
-            delete fileMonitor;
-            fileMonitor = fm;
-            topNode.project = this;
+            bool confirmation = true;
 
             if(projectView)
             {
-               CompilerConfig compiler = ideSettings.GetCompilerConfig(projectView.workspace.compiler);
-               projectView.AddNode(topNode, null);
-               topNode.row.Move(prev);
+               if(projectView.projectSettingsDialog)
+               {
+                  confirmation = projectView.projectSettingsDialog.CloseConfirmation(true);
+                  if(confirmation)
+                     projectView.projectSettingsDialog.Destroy(0);
+               }
+               if(confirmation)
+                  projectView.DeleteNode(topNode);
+            }
+            if(confirmation)
+            {
+               *this = *project;
+               delete fileMonitor;
+               fileMonitor = fm;
+               topNode.project = this;
 
-               projectView.ShowOutputBuildLog(true);
-               projectView.DisplayCompiler(compiler, false);
-               projectView.ProjectUpdateMakefileForAllConfigs(this);
-               delete compiler;
+               if(projectView)
+               {
+                  CompilerConfig compiler = ideSettings.GetCompilerConfig(projectView.workspace.compiler);
+                  projectView.AddNode(topNode, null);
+                  topNode.row.Move(prev);
+
+                  projectView.ShowOutputBuildLog(true);
+                  projectView.DisplayCompiler(compiler, false);
+                  projectView.ProjectUpdateMakefileForAllConfigs(this);
+                  delete compiler;
+               }
+               eSystem_Delete(project);
             }
-            eSystem_Delete(project);
+            else
+               delete project;
          }
          return true;
       }
@@ -863,6 +933,7 @@ private:
       delete license;
       delete compilerConfigsDir;
       delete moduleName;
+      delete moduleVersion;
       delete filePath;
       delete topNode;
       delete name;
@@ -938,11 +1009,11 @@ private:
       return expression;
    }
 
-   DirExpression GetObjDir(CompilerConfig compiler, ProjectConfig config)
+   DirExpression GetObjDir(CompilerConfig compiler, ProjectConfig config, int bitDepth)
    {
       char * expression = GetObjDirExpression(config);
       DirExpression objDir { type = intermediateObjectsDir };
-      objDir.Evaluate(expression, this, compiler, config);
+      objDir.Evaluate(expression, this, compiler, config, bitDepth);
       return objDir;
    }
 
@@ -955,11 +1026,11 @@ private:
       return expression;
    }
 
-   DirExpression GetTargetDir(CompilerConfig compiler, ProjectConfig config)
+   DirExpression GetTargetDir(CompilerConfig compiler, ProjectConfig config, int bitDepth)
    {
       char * expression = GetTargetDirExpression(config);
       DirExpression targetDir { type = DirExpressionType::targetDir /*intermediateObjectsDir*/};
-      targetDir.Evaluate(expression, this, compiler, config);
+      targetDir.Evaluate(expression, this, compiler, config, bitDepth);
       return targetDir;
    }
 
@@ -1052,10 +1123,10 @@ private:
 #endif
    }
 
-   void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config)
+   void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config, int bitDepth)
    {
 #ifndef MAKEFILE_GENERATOR
-      ide.SetPath(projectsDirs, compiler, config);
+      ide.SetPath(projectsDirs, compiler, config, bitDepth);
 #endif
    }
 
@@ -1113,6 +1184,7 @@ private:
             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)
@@ -1130,12 +1202,11 @@ private:
                   }
                }
             }
-            objDirExp = GetObjDir(compiler, config);
+            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(objDir, objDir);
-            strcpy(relativePath, objDir);
+            ReplaceSpaces(relativePath, objDir);
             *sl = '.';
             PathCatSlash(relativePath, moduleName);
             return true;
@@ -1176,6 +1247,11 @@ private:
                strcat(string, ".dylib");
             else
                strcat(string, ".so");
+            if(compiler.targetPlatform == tux && GetRuntimePlatform() == tux && moduleVersion && moduleVersion[0])
+            {
+               strcat(string, ".");
+               strcat(string, moduleVersion);
+            }
             break;
          case staticLibrary:
             strcat(string, ".a");
@@ -1218,7 +1294,7 @@ private:
       char temp[MAX_LOCATION];
       bool result = false;
       strcpy(cfDir, topNode.path);
-      if(ideSettings.compilerConfigsDir && ideSettings.compilerConfigsDir[0])
+      if(ideSettings && ideSettings.compilerConfigsDir && ideSettings.compilerConfigsDir[0])
       {
          PathCatSlash(cfDir, ideSettings.compilerConfigsDir);
          result = true;
@@ -1266,6 +1342,10 @@ 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)) ) 
+            || (!c.options || !cfg.options)))
+            cfg.linkingModified = true;
 
          cfg.makingModified = true;
       }
@@ -1312,6 +1392,7 @@ private:
          }
 
          property::config = cfg.data;
+         ide.UpdateToolBarActiveConfigs(true);
          ide.workspace.modified = true;
          ide.projectView.Update(null);
       }
@@ -1352,7 +1433,7 @@ private:
    }
 
    bool ProcessBuildPipeOutput(DualPipe f, DirExpression objDirExp, bool isARun, List<ProjectNode> onlyNodes,
-      CompilerConfig compiler, ProjectConfig config)
+      CompilerConfig compiler, ProjectConfig config, int bitDepth)
    {
       char line[65536];
       bool compiling = false, linking = false, precompiling = false;
@@ -1363,7 +1444,7 @@ private:
       int lenMakeCommand = strlen(compiler.makeCommand);
       int testLen = 0;
 
-      char * gccPrefix = compiler.gccPrefix ? compiler.gccPrefix : "";
+      char * gnuToolchainPrefix = compiler.gnuToolchainPrefix ? compiler.gnuToolchainPrefix : "";
 
       DynamicString test { };
       DynamicString ecp { };
@@ -1376,7 +1457,12 @@ private:
       DynamicString cxx { };
       DynamicString strip { };
       DynamicString ar { };
-
+      /*
+      if(bitDepth == 64 && compiler.targetPlatform == win32) 
+         gnuToolchainPrefix = "x86_64-w64-mingw32-";
+      else if(bitDepth == 32 && compiler.targetPlatform == win32)
+         gnuToolchainPrefix = "i686-w64-mingw32-";
+      */
       ecp.concatx(compiler.ecpCommand, " ");
       ecc.concatx(compiler.eccCommand, " ");
       ecs.concatx(compiler.ecsCommand, " ");
@@ -1385,14 +1471,14 @@ private:
       prefix.concatx(
             compiler.ccacheEnabled ? "ccache " : "",
             compiler.distccEnabled ? "distcc " : "",
-            gccPrefix);
+            gnuToolchainPrefix);
 
       cpp.concatx((String)prefix, compiler.cppCommand, " ");
       cc.concatx((String)prefix, compiler.ccCommand,  " ");
       cxx.concatx((String)prefix, compiler.cxxCommand, " ");
 
-      strip.concatx(gccPrefix, "strip ");
-      ar.concatx(gccPrefix, "ar rcs");
+      strip.concatx(gnuToolchainPrefix, "strip ");
+      ar.concatx(gnuToolchainPrefix, "ar rcs");
 
       testLen = Max(testLen, ecp.size);
       testLen = Max(testLen, ecc.size);
@@ -1415,7 +1501,9 @@ private:
             //printf("Peeking and GetLine...\n");
             if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)))
             {
+               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] == ':')
                {
@@ -1447,11 +1535,13 @@ private:
                   byte * tokens[1];
                   char * module;
                   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)
                   {
@@ -1460,6 +1550,7 @@ private:
                      //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)
                   {
@@ -1468,6 +1559,7 @@ private:
                      if(module) module += 4;
                      isPrecomp = true;
                      compilingEC = 0;
+                     gotCC = true;
                   }
 
                   loggedALine = true;
@@ -1499,7 +1591,10 @@ private:
                   else
                   {
                      ide.outputView.buildBox.Logf("%s\n", line);
-                     numErrors++;
+                     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--;
@@ -1517,11 +1612,13 @@ private:
                         colon = strstr(colon + 1, ":");
                      if(colon)
                      {
+                        char * sayError = "";
                         char moduleName[MAX_LOCATION], temp[MAX_LOCATION];
                         char * pointer;
                         char * error;
-                        char * start = inFileIncludedFrom ? line + strlen(stringInFileIncludedFrom) : line;
+                        char * start = inFileIncludedFrom ? inFileIncludedFrom + strlen(stringInFileIncludedFrom) : from ? from + strlen(stringFrom) : line;
                         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
@@ -1538,10 +1635,52 @@ private:
                         //if(bracket) *bracket = '\0';
 
                         GetLastDirectory(moduleName, temp);
+                        GetExtension(temp, ext);
+
+                        if(linking && (!strcmp(ext, "o") || !strcmp(ext, "a") || !strcmp(ext, "lib")))
+                        {
+                           char * cColon = strstr(colon+1, ":");
+                           if(cColon && (cColon[1] == '/' || cColon[1] == '\\'))
+                              cColon = strstr(cColon + 1, ":");
+                           if(cColon)
+                           {
+                              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")))
                         {
-                           numErrors++;
-                           strcpy(moduleName, $"Linker Error");
+                           moduleName[0] = 0;
+                           if(strstr(colon, "skipping incompatible") || strstr(colon, "Recognised but unhandled"))
+                           {
+                              message = $"Linker Message: ";
+                              colon = line;
+                           }
+                           else
+                           {
+                              numErrors++;
+                              message = $"Linker Error";
+                           }
+                        }
+                        else if(linking && (!strcmp(ext, "") || !strcmp(ext, "exe")))
+                        {
+                           moduleName[0] = 0;
+                           colon = line;
+                           if(!strstr(line, "error:"))
+                           {
+                              message = $"Linker Error: ";
+                              numErrors++;
+                           }
                         }
                         else
                         {
@@ -1549,31 +1688,33 @@ private:
                            PathCatSlash(temp, moduleName);
                            MakePathRelative(temp, topNode.path, moduleName);
                         }
-                        if(strstr(line, "error:"))
-                           numErrors ++;
+                        error = strstr(line, "error:");
+                        if(!message && error && error > colon)
+                           numErrors++;
                         else
                         {
-                           // Silence warnings for compiled EC
+                           // 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);
-                                 strcat(moduleName, "error: ");
+                                 sayError = "error: ";
                                  colon = pointer;
-                                 numErrors ++;
+                                 numErrors++;
                               }
                            }
                            else if((pointer = strstr(line, "No such file")))
                            {
                               strncat(moduleName, colon, pointer - colon);
-                              strcat(moduleName, "error: ");
+                              sayError = "error: ";
                               colon = pointer;
-                              numErrors ++;
+                              numErrors++;
                            }
                            else if(compilingEC == 1 || (objDir && objDir == moduleName))
                               continue;
@@ -1582,16 +1723,88 @@ private:
                               numWarnings++;
                            }
                         }
-                        if(this == ide.workspace.projects.firstIterator.data)
-                           ide.outputView.buildBox.Logf("   %s%s\n", moduleName, colon);
+                        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];
-                           strcpy(fullModuleName, topNode.path);
-                           PathCat(fullModuleName, moduleName);
-                           MakePathRelative(fullModuleName, ide.workspace.projects.firstIterator.data.topNode.path, fullModuleName);
-                           MakeSystemPath(fullModuleName);
-                           ide.outputView.buildBox.Logf("   %s%s%s\n", inFileIncludedFrom ? stringInFileIncludedFrom : "", fullModuleName, colon);
+                           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;
+                                       MakePathRelative(fullModuleName, prj.topNode.path, path);
+
+                                       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;
+                                          }
+                                       }
+                                    }
+                                    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);
+                              }
+                              else
+                                 strcpy(fullModuleName, moduleName);
+                              if(loc)
+                              {
+                                 strcat(fullModuleName, ":");
+                                 strcat(fullModuleName, loc + 1);
+                              }
+                           }
+                           else
+                              fullModuleName[0] = 0;
+                           ide.outputView.buildBox.Logf("   %s%s%s%s\n", inFileIncludedFrom ? stringInFileIncludedFrom : from ? stringFrom : "", fullModuleName, sayError, colon);
                         }
                      }
                      else
@@ -1634,7 +1847,12 @@ private:
          else
          {
             if(!onlyNodes)
-               ide.outputView.buildBox.Logf("\n%s (%s) - ", GetTargetFileName(config), configName);
+            {
+               char targetFileName[MAX_LOCATION];
+               targetFileName[0] = '\0';
+               CatTargetFileName(targetFileName, compiler, config);
+               ide.outputView.buildBox.Logf("\n%s (%s) - ", targetFileName, configName);
+            }
             if(numErrors)
                ide.outputView.buildBox.Logf("%d %s, ", numErrors, (numErrors > 1) ? $"errors" : $"error");
             else
@@ -1697,7 +1915,7 @@ private:
       }
    }
 
-   bool Build(bool isARun, List<ProjectNode> onlyNodes, CompilerConfig compiler, ProjectConfig config, bool justPrint, SingleFileCompileMode mode)
+   bool Build(bool isARun, List<ProjectNode> onlyNodes, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint, SingleFileCompileMode mode)
    {
       bool result = false;
       DualPipe f;
@@ -1706,7 +1924,7 @@ private:
       char makeFile[MAX_LOCATION];
       char makeFilePath[MAX_LOCATION];
       char configName[MAX_LOCATION];
-      DirExpression objDirExp = GetObjDir(compiler, config);
+      DirExpression objDirExp = GetObjDir(compiler, config, bitDepth);
       PathBackup pathBackup { };
       bool crossCompiling = (compiler.targetPlatform != GetRuntimePlatform());
       char * targetPlatform = crossCompiling ? (char *)compiler.targetPlatform : "";
@@ -1720,7 +1938,7 @@ private:
 
       strcpy(configName, config ? config.name : "Common");
 
-      SetPath(false, compiler, config); //true
+      SetPath(false, compiler, config, bitDepth); //true
       CatTargetFileName(targetFileName, compiler, config);
 
       strcpy(makeFilePath, topNode.path);
@@ -1739,15 +1957,20 @@ private:
             int len;
             char pushD[MAX_LOCATION];
             char cfDir[MAX_LOCATION];
+            Map<String, NameCollisionInfo> namesInfo { };
             GetIDECompilerConfigsDir(cfDir, true, true);
             GetWorkingDir(pushD, sizeof(pushD));
             ChangeWorkingDir(topNode.path);
             // Create object dir if it does not exist already
             if(!FileExists(objDirExp.dir).isDirectory)
             {
-               sprintf(command, "%s CF_DIR=\"%s\"%s%s COMPILER=%s objdir -C \"%s\"%s -f \"%s\"",
+               sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s COMPILER=%s objdir -C \"%s\"%s -f \"%s\"",
                      compiler.makeCommand, cfDir,
-                     crossCompiling ? " TARGET_PLATFORM=" : "", targetPlatform,
+                     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)
                   ide.outputView.buildBox.Logf("%s\n", command);
@@ -1756,16 +1979,19 @@ private:
 
             ChangeWorkingDir(pushD);
 
+            topNode.GenMakefileGetNameCollisionInfo(namesInfo, config);
             for(node : onlyNodes)
             {
                if(node.GetIsExcluded(config))
                   ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
                else
                {
-                  node.DeleteIntermediateFiles(compiler, config);
-                  node.GetTargets(config, objDirExp.dir, makeTargets);
+                  node.DeleteIntermediateFiles(compiler, config, bitDepth, namesInfo, mode == cObject ? true : false);
+                  node.GetTargets(config, namesInfo, objDirExp.dir, makeTargets);
                }
             }
+            namesInfo.Free();
+            delete namesInfo;
          }
       }
 
@@ -1792,17 +2018,22 @@ private:
       {
          char cfDir[MAX_LOCATION];
          GetIDECompilerConfigsDir(cfDir, true, true);
-         sprintf(command, "%s %sCF_DIR=\"%s\"%s%s COMPILER=%s -j%d %s%s%s -C \"%s\"%s -f \"%s\"",
+         sprintf(command, "%s %sCF_DIR=\"%s\"%s%s%s%s%s COMPILER=%s -j%d %s%s%s -C \"%s\"%s -f \"%s\"",
                compiler.makeCommand,
-               mode == normal ? "" : (mode == debugPrecompile ? "ECP_DEBUG=y " : mode == debugCompile ? "ECC_DEBUG=y " : mode == debugGenerateSymbols ? "ECS_DEBUG=y " : ""),
+               mode == debugPrecompile ? "ECP_DEBUG=y " : mode == debugCompile ? "ECC_DEBUG=y " : mode == debugGenerateSymbols ? "ECS_DEBUG=y " : "",
                cfDir,
-               crossCompiling ? " TARGET_PLATFORM=" : "", targetPlatform,
+               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, numJobs,
                compiler.ccacheEnabled ? "CCACHE=y " : "",
                compiler.distccEnabled ? "DISTCC=y " : "",
-               (String)makeTargets, topNode.path, (justPrint || mode != normal) ? " -n" : "", makeFilePath);
+               (String)makeTargets, topNode.path, (justPrint || (mode != normal && mode != cObject)) ? " -n" : "", makeFilePath);
          if(justPrint)
             ide.outputView.buildBox.Logf("%s\n", command);
+
          if((f = DualPipeOpen(PipeOpenMode { output = true, error = true, input = true }, command)))
          {
             bool found = false;
@@ -1811,7 +2042,7 @@ private:
                ProcessPipeOutputRaw(f);
                result = true;
             }
-            else if(mode != normal)
+            else if(mode != normal && mode != cObject)
             {
                char line[65536];
                while(!f.Eof())
@@ -1831,7 +2062,7 @@ private:
                }
             }
             else
-               result = ProcessBuildPipeOutput(f, objDirExp, isARun, onlyNodes, compiler, config);
+               result = ProcessBuildPipeOutput(f, objDirExp, isARun, onlyNodes, compiler, config, bitDepth);
             delete f;
             if(found)
                Execute(command);
@@ -1847,7 +2078,7 @@ private:
       return result;
    }
 
-   void Clean(CompilerConfig compiler, ProjectConfig config, bool realclean, bool justPrint)
+   void Clean(CompilerConfig compiler, ProjectConfig config, int bitDepth, CleanType cleanType, bool justPrint)
    {
       char makeFile[MAX_LOCATION];
       char makeFilePath[MAX_LOCATION];
@@ -1861,7 +2092,7 @@ private:
       compilerName = CopyString(compiler.name);
       CamelCase(compilerName);
 
-      SetPath(false, compiler, config);
+      SetPath(false, compiler, config, bitDepth);
 
       strcpy(makeFilePath, topNode.path);
       CatMakeFileName(makeFile, config);
@@ -1891,10 +2122,13 @@ private:
       {
          char cfDir[MAX_LOCATION];
          GetIDECompilerConfigsDir(cfDir, true, true);
-         sprintf(command, "%s CF_DIR=\"%s\"%s%s COMPILER=%s %sclean -C \"%s\"%s -f \"%s\"",
+         sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s COMPILER=%s %sclean%s -C \"%s\"%s -f \"%s\"",
                compiler.makeCommand, cfDir,
                crossCompiling ? " TARGET_PLATFORM=" : "", targetPlatform,
-               compilerName, realclean ? "real" : "", topNode.path, justPrint ? " -n": "", makeFilePath);
+               bitDepth ? " ARCH=" : "", bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
+               compilerName,
+               cleanType == realClean ? "real" : "", cleanType == cleanTarget ? "target" : "",
+               topNode.path, justPrint ? " -n": "", makeFilePath);
          if(justPrint)
             ide.outputView.buildBox.Logf("%s\n", command);
          if((f = DualPipeOpen(PipeOpenMode { output = 1, error = 1, input = 2 }, command)))
@@ -1914,11 +2148,12 @@ private:
       delete compilerName;
    }
 
-   void Run(char * args, CompilerConfig compiler, ProjectConfig config)
+   void Run(char * args, CompilerConfig compiler, ProjectConfig config, int bitDepth)
    {   
       String target = new char[maxPathLen];
       char oldDirectory[MAX_LOCATION];
-      DirExpression targetDirExp = GetTargetDir(compiler, config);
+      char * executableLauncher = compiler.executableLauncher;
+      DirExpression targetDirExp = GetTargetDir(compiler, config, bitDepth);
       PathBackup pathBackup { };
 
       // Build(project, ideMain, true, null, false);
@@ -1943,12 +2178,12 @@ private:
       else
          ChangeWorkingDir(topNode.path);
       // ChangeWorkingDir(topNode.path);
-      SetPath(true, compiler, config);
-      if(compiler.execPrefixCommand)
+      SetPath(true, compiler, config, bitDepth);
+      if(executableLauncher)
       {
-         char * prefixedTarget = new char[strlen(compiler.execPrefixCommand) + strlen(target) + 2];
+         char * prefixedTarget = new char[strlen(executableLauncher) + strlen(target) + 2];
          prefixedTarget[0] = '\0';
-         strcat(prefixedTarget, compiler.execPrefixCommand);
+         strcat(prefixedTarget, executableLauncher);
          strcat(prefixedTarget, " ");
          strcat(prefixedTarget, target);
          Execute(prefixedTarget);
@@ -1964,9 +2199,9 @@ private:
       delete target;
    }
 
-   void Compile(List<ProjectNode> nodes, CompilerConfig compiler, ProjectConfig config, bool justPrint, SingleFileCompileMode mode)
+   void Compile(List<ProjectNode> nodes, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint, SingleFileCompileMode mode)
    {
-      Build(false, nodes, compiler, config, justPrint, mode);
+      Build(false, nodes, compiler, config, bitDepth, justPrint, mode);
    }
 #endif
 
@@ -1984,7 +2219,7 @@ private:
             strcat(fileName, "$(E)");
             break;
          case sharedLibrary:
-            strcat(fileName, "$(SO)");
+            strcat(fileName, "$(SO)$(VER)");
             break;
          case staticLibrary:
             strcat(fileName, "$(A)");
@@ -1992,7 +2227,7 @@ private:
       }
    }
 
-   bool GenerateCrossPlatformMk()
+   bool GenerateCrossPlatformMk(File altCrossPlatformMk)
    {
       bool result = false;
       char path[MAX_LOCATION];
@@ -2015,12 +2250,13 @@ private:
       if(FileExists(path))
          DeleteFile(path);
       {
-         File include = FileOpen(":crossplatform.mk", read);
+         File include = altCrossPlatformMk ? altCrossPlatformMk : FileOpen(":crossplatform.mk", read);
          if(include)
          {
             File f = FileOpen(path, write);
             if(f)
             {
+               include.Seek(0, start);
                for(; !include.Eof(); )
                {
                   char buffer[4096];
@@ -2031,7 +2267,8 @@ private:
 
                result = true;
             }
-            delete include;
+            if(!altCrossPlatformMk)
+               delete include;
          }
       }
       return result;
@@ -2044,6 +2281,7 @@ private:
       char * name;
       char * compilerName;
       bool gccCompiler = compiler.ccCommand && (strstr(compiler.ccCommand, "gcc") != null || strstr(compiler.ccCommand, "g++") != null);
+      char * gnuToolchainPrefix = compiler.gnuToolchainPrefix ? compiler.gnuToolchainPrefix : "";
       Platform platform = compiler.targetPlatform;
 
       compilerName = CopyString(compiler.name);
@@ -2079,14 +2317,15 @@ private:
                {
                   f.Printf("export %s := %s\n", e.name, e.string);
                }
+               f.Puts("\n");
             }
 
             f.Puts("# TOOLCHAIN\n");
             f.Puts("\n");
 
-            if(compiler.gccPrefix && compiler.gccPrefix[0])
+            if(gnuToolchainPrefix && gnuToolchainPrefix[0])
             {
-               f.Printf("GCC_PREFIX := %s\n", compiler.gccPrefix);
+               f.Printf("GCC_PREFIX := %s\n", gnuToolchainPrefix);
                f.Puts("\n");
             }
             if(compiler.sysroot && compiler.sysroot[0])
@@ -2119,6 +2358,17 @@ private:
             f.Puts("EARFLAGS = \n");
             f.Puts("\n");
 
+            f.Puts("ifndef ARCH\n");
+            f.Puts("TARGET_ARCH :=$(shell $(CC) -dumpmachine)\n");
+            f.Puts(" ifdef WINDOWS_HOST\n");
+            f.Puts("  ifneq ($(filter x86_64%,$(TARGET_ARCH)),)\n");
+            f.Puts("     TARGET_ARCH := x86_64\n");
+            f.Puts("  else\n");
+            f.Puts("     TARGET_ARCH := i386\n");
+            f.Puts("  endif\n");
+            f.Puts(" endif\n");
+            f.Puts("endif\n\n");
+
             f.Puts("# HARD CODED TARGET_PLATFORM-SPECIFIC OPTIONS\n");
             f.Printf("LDFLAGS +=$(if $(%s), -Wl$(comma)--no-undefined,)\n", PlatformToMakefileTargetVariable(tux));
             f.Puts("\n");
@@ -2166,11 +2416,13 @@ private:
                OutputListOption(f, "Wl,", compiler.linkerFlags, inPlace, true);
                f.Puts("\n");
             }
-            f.Printf("\nFORCE_64_BIT := %s", compiler.supportsBitDepth ? "-m64" : "");
-            f.Printf("\nFORCE_32_BIT := %s", compiler.supportsBitDepth ? "-m32" : "");
             f.Puts("\n");
             f.Puts("\nOFLAGS += $(LDFLAGS)");
             f.Puts("\n");
+            f.Puts("ifdef ARCH_FLAGS\n");
+            f.Puts("CFLAGS += $(ARCH_FLAGS)\n");
+            f.Puts("OFLAGS += $(ARCH_FLAGS)\n");
+            f.Puts("endif\n");
 
             delete f;
 
@@ -2231,13 +2483,12 @@ private:
          Array<String> listItems { };
          Map<String, int> varStringLenDiffs { };
          Map<String, NameCollisionInfo> namesInfo { };
-         bool forceBitDepth = false;
 
          Map<String, int> cflagsVariations { };
-         Map<int, int> nodeCFlagsMapping { };
+         Map<intptr, int> nodeCFlagsMapping { };
 
          Map<String, int> ecflagsVariations { };
-         Map<int, int> nodeECFlagsMapping { };
+         Map<intptr, int> nodeECFlagsMapping { };
 
          ReplaceSpaces(objDirNoSpaces, objDirExp);
          strcpy(targetDir, GetTargetDirExpression(config));
@@ -2245,7 +2496,11 @@ private:
 
          strcpy(objDirExpNoSpaces, GetObjDirExpression(config));
          ChangeCh(objDirExpNoSpaces, '\\', '/'); // TODO: this is a hack, paths should never include win32 path seperators - fix this in ProjectSettings and ProjectLoad instead
-         ReplaceSpaces(objDirExpNoSpaces, objDirExpNoSpaces);
+         {
+            char temp[MAX_LOCATION];
+            ReplaceSpaces(temp, objDirExpNoSpaces);
+            strcpy(objDirExpNoSpaces, temp);
+         }
          ReplaceSpaces(resDirNoSpaces, resNode.path ? resNode.path : "");
          ReplaceSpaces(fixedModuleName, moduleName);
          ReplaceSpaces(fixedConfigName, GetConfigName(config));
@@ -2258,7 +2513,7 @@ private:
          f.Puts("# CORE VARIABLES\n\n");
 
          f.Printf("MODULE := %s\n", fixedModuleName);
-         //f.Printf("VERSION = %s\n", version);
+         f.Printf("VERSION := %s\n", property::moduleVersion);
          f.Printf("CONFIG := %s\n", fixedConfigName);
          f.Puts("ifndef COMPILER\n" "COMPILER := default\n" "endif\n");
          f.Puts("\n");
@@ -2348,7 +2603,7 @@ private:
          // test = GetTargetTypeIsSetByPlatform(config);
          {
             char target[MAX_LOCATION];
-            char targetNoSpaces[MAX_LOCATION];
+            char temp[MAX_LOCATION];
             if(test)
             {
                TargetTypes type;
@@ -2363,19 +2618,19 @@ private:
                      f.Printf("ifeq \"$(TARGET_TYPE)\" \"%s\"\n", TargetTypeToMakefileVariable(type));
 
                      GetMakefileTargetFileName(type, target, config);
-                     strcpy(targetNoSpaces, targetDir);
-                     PathCatSlash(targetNoSpaces, target);
-                     ReplaceSpaces(targetNoSpaces, targetNoSpaces);
-                     f.Printf("TARGET = %s\n", targetNoSpaces);
+                     strcpy(temp, targetDir);
+                     PathCatSlash(temp, target);
+                     ReplaceSpaces(target, temp);
+                     f.Printf("TARGET = %s\n", target);
                   }
                }
                f.Puts("else\n");
             }
             GetMakefileTargetFileName(targetType, target, config);
-            strcpy(targetNoSpaces, targetDir);
-            PathCatSlash(targetNoSpaces, target);
-            ReplaceSpaces(targetNoSpaces, targetNoSpaces);
-            f.Printf("TARGET = %s\n", targetNoSpaces);
+            strcpy(temp, targetDir);
+            PathCatSlash(temp, target);
+            ReplaceSpaces(target, temp);
+            f.Printf("TARGET = %s\n", target);
 
             if(test)
             {
@@ -2489,19 +2744,44 @@ private:
                   if((projectPlatformOptions && projectPlatformOptions.options.linkerOptions && projectPlatformOptions.options.linkerOptions.count) ||
                      (configPlatformOptions && configPlatformOptions.options.linkerOptions && configPlatformOptions.options.linkerOptions.count))
                   {
-                     f.Puts("PRJ_CFLAGS +=");
-                     // tocheck: does any of that -Wl stuff from linkerOptions have any business being in CFLAGS?
+                     f.Puts("OFLAGS +=");
                      if(projectPlatformOptions && projectPlatformOptions.options.linkerOptions && projectPlatformOptions.options.linkerOptions.count)
                      {
-                        f.Puts(" \\\n\t -Wl");
+                        bool needWl = false;
+                        f.Puts(" \\\n\t ");
                         for(s : projectPlatformOptions.options.linkerOptions)
-                           f.Printf(",%s", s);
+                        {
+                           if(!IsLinkerOption(s))
+                              f.Printf(" %s", s);
+                           else
+                              needWl = true;
+                        }
+                        if(needWl)
+                        {
+                           f.Puts(" -Wl");
+                           for(s : projectPlatformOptions.options.linkerOptions)
+                              if(IsLinkerOption(s))
+                                 f.Printf(",%s", s);
+                        }
                      }
                      if(configPlatformOptions && configPlatformOptions.options.linkerOptions && configPlatformOptions.options.linkerOptions.count)
                      {
-                        f.Puts(" \\\n\t -Wl");
+                        bool needWl = false;
+                        f.Puts(" \\\n\t ");
                         for(s : configPlatformOptions.options.linkerOptions)
-                           f.Printf(",%s", s);
+                        {
+                           if(IsLinkerOption(s))
+                              f.Printf(" %s", s);
+                           else
+                              needWl = true;
+                        }
+                        if(needWl)
+                        {
+                           f.Puts(" -Wl");
+                           for(s : configPlatformOptions.options.linkerOptions)
+                              if(!IsLinkerOption(s))
+                                 f.Printf(",%s", s);
+                        }
                      }
                      f.Puts("\n");
                      f.Puts("\n");
@@ -2555,13 +2835,48 @@ private:
             f.Puts("\n");
          }
 
-         // tocheck: does any of that -Wl stuff from linkerOptions have any business being in CFLAGS?
-         if(options && options.linkerOptions && options.linkerOptions.count)
+         if((config && config.options && config.options.linkerOptions && config.options.linkerOptions.count) ||
+               (options && options.linkerOptions && options.linkerOptions.count))
          {
-            f.Puts("PRJ_CFLAGS +=");
-            f.Puts(" \\\n\t -Wl");
-            for(s : options.linkerOptions)
-               f.Printf(",%s", s);
+            f.Puts("OFLAGS +=");
+            f.Puts(" \\\n\t");
+
+            if(config && config.options && config.options.linkerOptions && config.options.linkerOptions.count)
+            {
+               bool needWl = false;
+               for(s : config.options.linkerOptions)
+               {
+                  if(!IsLinkerOption(s))
+                     f.Printf(" %s", s);
+                  else
+                     needWl = true;
+               }
+               if(needWl)
+               {
+                  f.Puts(" -Wl");
+                  for(s : config.options.linkerOptions)
+                     if(IsLinkerOption(s))
+                        f.Printf(",%s", s);
+               }
+            }
+            if(options && options.linkerOptions && options.linkerOptions.count)
+            {
+               bool needWl = false;
+               for(s : options.linkerOptions)
+               {
+                  if(!IsLinkerOption(s))
+                     f.Printf(" %s", s);
+                  else
+                     needWl = true;
+               }
+               if(needWl)
+               {
+                  f.Puts(" -Wl");
+                  for(s : options.linkerOptions)
+                     if(IsLinkerOption(s))
+                        f.Printf(",%s", s);
+               }
+            }
          }
          f.Puts("\n");
          f.Puts("\n");
@@ -2570,21 +2885,21 @@ private:
          f.Puts("\n");
          f.Puts("\n");
 
-         f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
-         f.Puts("OFLAGS +=");
-         forceBitDepth = (options && options.buildBitDepth) || numCObjects;
-         if(forceBitDepth)
-            f.Puts((!options || !options.buildBitDepth || options.buildBitDepth == bits32) ? " $(FORCE_32_BIT)" : " $(FORCE_64_BIT) \\\n");
-
          if(GetProfile(config))
-            f.Puts(" -pg");
-         if(config && config.options && config.options.libraryDirs)
-            OutputListOption(f, "L", config.options.libraryDirs, lineEach, true);
-         if(options && options.libraryDirs)
-            OutputListOption(f, "L", options.libraryDirs, lineEach, true);
-         f.Puts("\n");
-         f.Puts("endif\n");
-         f.Puts("\n");
+            f.Puts("OFLAGS += -pg\n\n");
+
+         if((config && config.options && config.options.libraryDirs) || (options && options.libraryDirs))
+         {
+            f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
+            f.Puts("OFLAGS +=");
+            if(config && config.options && config.options.libraryDirs)
+               OutputListOption(f, "L", config.options.libraryDirs, lineEach, true);
+            if(options && options.libraryDirs)
+               OutputListOption(f, "L", options.libraryDirs, lineEach, true);
+            f.Puts("\n");
+            f.Puts("endif\n");
+            f.Puts("\n");
+         }
 
          f.Puts("# TARGETS\n");
          f.Puts("\n");
@@ -2655,7 +2970,7 @@ private:
             // Main Module (Linking) for ECERE C modules
             f.Puts("$(OBJ)$(MODULE).main.ec: $(SYMBOLS) $(COBJECTS)\n");
             // use of objDirExpNoSpaces used instead of $(OBJ) to prevent problematic joining of arguments in ecs
-            f.Printf("\t$(ECS)%s $(ECSLIBOPT) $(SYMBOLS) $(IMPORTS) -symbols %s -o $(OBJ)$(MODULE).main.ec\n", 
+            f.Printf("\t$(ECS)%s $(ARCH_FLAGS) $(ECSLIBOPT) $(SYMBOLS) $(IMPORTS) -symbols %s -o $(OBJ)$(MODULE).main.ec\n", 
                GetConsole(config) ? " -console" : "", objDirExpNoSpaces);
             f.Puts("\n");
             // Main Module (Linking) for ECERE C modules
@@ -2679,8 +2994,18 @@ private:
          // This alone was breaking the tarball, object directory does not get created first (order-only rules happen last it seems!)
          f.Printf("$(TARGET): $(SOURCES) $(RESOURCES) $(SYMBOLS) $(OBJECTS) | objdir%s\n", sameObjTargetDirs ? "" : " targetdir");
 
+         f.Printf("\t@$(call rmq,$(OBJ)linkobjects.lst)\n");
+         f.Printf("\t@$(call touch,$(OBJ)linkobjects.lst)\n");
+         OutputLinkObjectActions(f, "_OBJECTS", objectsParts);
+         if(numCObjects)
+         {
+            f.Printf("\t@$(call echo,$(OBJ)$(MODULE).main$(O)) >> $(OBJ)linkobjects.lst\n");
+            OutputLinkObjectActions(f, "ECOBJECTS", eCsourcesParts);
+         }
+
          f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
-         f.Printf("\t$(%s) $(OFLAGS) $(OBJECTS) $(LIBS) %s-o $(TARGET) $(INSTALLNAME)\n", containsCXX ? "CXX" : "CC", containsCXX ? "-lstdc++ " : "");
+
+         f.Printf("\t$(%s) $(OFLAGS) @$(OBJ)linkobjects.lst $(LIBS) %s-o $(TARGET) $(INSTALLNAME)\n", containsCXX ? "CXX" : "CC", containsCXX ? "-lstdc++ " : "");
          if(!GetDebug(config))
          {
             f.Puts("ifndef NOSTRIP\n");
@@ -2701,7 +3026,16 @@ private:
          if(resNode.files && resNode.files.count && !noResources)
             resNode.GenMakefileAddResources(f, resNode.path, config);
          f.Puts("else\n");
-         f.Puts("\t$(AR) rcs $(TARGET) $(OBJECTS) $(LIBS)\n");
+         f.Puts("\t$(AR) rcs $(TARGET) @$(OBJ)linkobjects.lst $(LIBS)\n");
+         f.Puts("endif\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$(if $(basename $(VER)),ln -sf $(LP)$(MODULE)$(SO)$(VER) $(OBJ)$(LP)$(MODULE)$(SO)$(basename $(VER)),)\n");
+         f.Puts("\t$(if $(VER),ln -sf $(LP)$(MODULE)$(SO)$(VER) $(OBJ)$(LP)$(MODULE)$(SO),)\n");
+         f.Puts("endif\n");
+         f.Puts("endif\n");
          f.Puts("endif\n");
 
          //f.Puts("# POST-BUILD COMMANDS\n");
@@ -2774,9 +3108,19 @@ private:
 
          f.Printf("cleantarget: objdir%s\n", sameObjTargetDirs ? "" : " targetdir");
          f.Puts("\t$(call rmq,$(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("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);
          if(numCObjects)
          {
@@ -3645,13 +3989,13 @@ void CombineIdenticalConfigOptions(Project project)
                         
                         if(type.type == noHeadClass || type.type == normalClass)
                         {
-                           result = 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 = 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);
                         }
@@ -3667,14 +4011,14 @@ void CombineIdenticalConfigOptions(Project project)
                {
                   if(type.type == noHeadClass || type.type == normalClass)
                   {
-                     if(!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(!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;
@@ -3684,7 +4028,7 @@ void CombineIdenticalConfigOptions(Project project)
                   
                   /*if(type.type == noHeadClass || type.type == normalClass)
                   {
-                     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));
                   }
@@ -3692,7 +4036,7 @@ void CombineIdenticalConfigOptions(Project project)
                   {
                      void * address = (byte *)firstConfig.options + member.offset + member._class.offset;
                      // TOFIX: ListBox::SetData / OnCopy mess
-                     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 : 
@@ -3711,13 +4055,13 @@ void CombineIdenticalConfigOptions(Project project)
                         
                         if(type.type == noHeadClass || type.type == normalClass)
                         {
-                           result = 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 = 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);
                         }
@@ -3728,12 +4072,12 @@ void CombineIdenticalConfigOptions(Project project)
                      {
                         if(type.type == noHeadClass || type.type == normalClass)
                         {
-                           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
                         {
-                           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);