Merge trunk HEAD (r46369)
[reactos.git] / reactos / tools / rbuild / backend / mingw / mingw.cpp
index 69a1983..fa428a2 100644 (file)
@@ -365,11 +365,18 @@ MingwBackend::ProcessNormal ()
        GenerateTestSupportCode ();
        GenerateCompilationUnitSupportCode ();
        GenerateSysSetup ();
+       GenerateInstallerFileList();
        GenerateProxyMakefiles ();
        CheckAutomaticDependencies ();
        CloseMakefile ();
 }
 
+void
+MingwBackend::GenerateInstallerFileList()
+{
+       this->ProjectNode.GenerateInstallerFileList();
+}
+
 void
 MingwBackend::CreateMakefile ()
 {
@@ -480,13 +487,17 @@ MingwBackend::GenerateGlobalVariables () const
                fputs ( "BUILTIN_CXXINCLUDES+= $(TARGET_CPPFLAGS)\n", fMakefile );
 
                fprintf ( fMakefile, "PROJECT_CCLIBS := \"$(shell ${TARGET_CC} -print-libgcc-file-name)\"\n" );
-               fprintf ( fMakefile, "PROJECT_CXXLIBS := \"$(shell ${TARGET_CPP} -print-file-name=libstdc++.a)\" \"$(shell ${TARGET_CPP} -print-file-name=libgcc.a)\" \"$(shell ${TARGET_CPP} -print-file-name=libmingw32.a)\" \"$(shell ${TARGET_CPP} -print-file-name=libmingwex.a)\" " );
 
+               // We use our proprietary "ofmt_stub.a" to implement a stub for "_get_output_format" required by "libmingwex.a".
+               // This archive just contains the compiled "ofmt_stub.s" supplied with the MinGW Runtime sources.
+               fprintf ( fMakefile, "PROJECT_CXXLIBS := \"$(shell ${TARGET_CPP} -print-file-name=libstdc++.a)\" \"$(shell ${TARGET_CPP} -print-libgcc-file-name)\" \"$(shell ${TARGET_CPP} -print-file-name=libmingw32.a)\" \"$(shell ${TARGET_CPP} -print-file-name=libmingwex.a)\" \"$(shell ${TARGET_CPP} -print-file-name=ofmt_stub.a)\" \"$(shell ${TARGET_CPP} -print-file-name=libcoldname.a)\"\n" );
+               
                /* hack to get libgcc_eh.a, should check mingw version or something */
                if (Environment::GetArch() == "amd64")
-               {
                        fprintf ( fMakefile, " \"$(shell ${TARGET_CPP} -print-file-name=libgcc_eh.a)\"" );
-               }
+               /* hack to get _get_output_format, needed by libmingwex */
+               else if (Environment::GetArch() == "i386")
+                       fprintf ( fMakefile, "\"$(shell ${TARGET_CPP} -print-file-name=ofmt_stub.a)\"");
                fprintf ( fMakefile,"\n");
        }
        MingwModuleHandler::GenerateParameters ( "PROJECT", "+=", ProjectNode.non_if_data );
@@ -844,7 +855,7 @@ MingwBackend::GetVersionString ( const string& versionCommand )
        buffer[i] = '\0';
        pclose ( fp );
 
-       char separators[] = " ()";
+       char separators[] = " ()\n";
        char *token;
        char *prevtoken = NULL;
 
@@ -888,7 +899,7 @@ MingwBackend::GetNetwideAssemblerVersion ( const string& nasmCommand )
 string
 MingwBackend::GetCompilerVersion ( const string& compilerCommand )
 {
-       string versionCommand = ssprintf ( "%s --version gcc",
+       string versionCommand = ssprintf ( "%s --version",
                                           compilerCommand.c_str (),
                                           NUL,
                                           NUL );
@@ -908,7 +919,7 @@ MingwBackend::GetBinutilsVersion ( const string& binutilsCommand )
 bool
 MingwBackend::IsSupportedCompilerVersion ( const string& compilerVersion )
 {
-       if ( strcmp ( compilerVersion.c_str (), "3.4.2") < 0 )
+       if ( strcmp ( compilerVersion.c_str (), "4.4.0") < 0 )
                return false;
        else
                return true;
@@ -970,27 +981,32 @@ MingwBackend::GetBinutilsVersionDate ( const string& binutilsCommand )
 bool
 MingwBackend::IsSupportedBinutilsVersion ( const string& binutilsVersion )
 {
-       if ( manualBinutilsSetting ) return true;
-
-       /* linux */
-       if ( binutilsVersion.find('.') != std::string::npos )
+       int digit = binutilsVersion.find_last_of(".");
+       if(digit == -1)
+       {
+               printf("Unable to detect binutils version!\n");
+               return false;
+       }
+       
+       string date = string(binutilsVersion, digit + 1);
+       if(date.length() == 8)
        {
-               /* TODO: blacklist versions on version number instead of date */
-               return true;
+               /* This is a real date in the format YYYYMMDD.
+                  Check whether we have at least Binutils 20091016 (the oldest one
+                  we were still using after upgrading to RosBE 1.5). */
+               if(strcmp(date.c_str(), "20091016") < 0)
+                       return false;
        }
-
-       /*
-        * - Binutils older than 2003/10/01 have broken windres which can't handle
-        *   icons with alpha channel.
-        * - Binutils between 2004/09/02 and 2004/10/08 have broken handling of
-        *   forward exports in dlltool.
-        */
-       if ( ( ( strcmp ( binutilsVersion.c_str (), "20040902") >= 0 ) &&
-              ( strcmp ( binutilsVersion.c_str (), "20041008") <= 0 ) ) ||
-              ( strcmp ( binutilsVersion.c_str (), "20031001") < 0 ) )
-               return false;
        else
-               return true;
+       {
+               /* This is no date, so binutilsVersion should just contain the version
+                  number.
+                  Binutils 2.20 will hopefully contain the required features. */
+               if(strcmp(binutilsVersion.c_str(), "2.20") < 0)
+                       return false;
+       }
+       
+       return true;
 }
 
 void
@@ -1284,14 +1300,14 @@ MingwBackend::OutputRegistryInstallTarget ()
                  "install_registry: %s\n",
                  registryTargetFiles.c_str () );
        fprintf ( fMakefile,
-                 "%s: %s %s $(MKHIVE_TARGET)\n",
+                 "%s: %s %s $(mkhive_TARGET)\n",
                  registryTargetFiles.c_str (),
                  registrySourceFiles.c_str (),
                  GetFullPath ( system32 ).c_str () );
        fprintf ( fMakefile,
                  "\t$(ECHO_MKHIVE)\n" );
        fprintf ( fMakefile,
-                 "\t$(MKHIVE_TARGET) boot%cbootdata %s $(ARCH) boot%cbootdata%chiveinst_$(ARCH).inf\n",
+                 "\t$(mkhive_TARGET) boot%cbootdata %s $(ARCH) boot%cbootdata%chiveinst_$(ARCH).inf\n",
                  cSep, GetFullPath ( system32 ).c_str (),
                  cSep, cSep );
        fprintf ( fMakefile,