-Add a new module type 'cabinet' to handle .cab files generation
[reactos.git] / reactos / tools / rbuild / backend / mingw / modulehandler.cpp
index 492e464..aebc7bb 100644 (file)
@@ -30,6 +30,7 @@ using std::string;
 using std::vector;
 
 #define CLEAN_FILE(f) clean_files.push_back ( (f).name.length () > 0 ? backend->GetFullName ( f ) : backend->GetFullPath ( f ) );
+#define IsStaticLibrary( module ) ( ( module.type == StaticLibrary ) || ( module.type == HostStaticLibrary ) )
 
 MingwBackend*
 MingwModuleHandler::backend = NULL;
@@ -170,6 +171,9 @@ MingwModuleHandler::InstanciateHandler (
                case StaticLibrary:
                        handler = new MingwStaticLibraryModuleHandler ( module );
                        break;
+               case HostStaticLibrary:
+                       handler = new MingwHostStaticLibraryModuleHandler ( module );
+                       break;
                case ObjectLibrary:
                        handler = new MingwObjectLibraryModuleHandler ( module );
                        break;
@@ -240,6 +244,9 @@ MingwModuleHandler::InstanciateHandler (
                case IdlHeader:
                        handler = new MingwIdlHeaderModuleHandler ( module );
                        break;
+               case Cabinet:
+                       handler = new MingwCabinetModuleHandler ( module );
+                       break;
                case EmbeddedTypeLib:
                        handler = new MingwEmbeddedTypeLibModuleHandler ( module );
                        break;
@@ -280,7 +287,7 @@ MingwModuleHandler::GetActualSourceFilename (
        string extension = GetExtension ( *file );
        if ( extension == ".spec" || extension == ".SPEC" )
        {
-               const FileLocation *objectFile = GetObjectFilename ( file, module, NULL );
+               const FileLocation *objectFile = GetObjectFilename ( file, module );
                FileLocation *sourceFile = new FileLocation (
                        objectFile->directory,
                        objectFile->relative_path,
@@ -291,7 +298,7 @@ MingwModuleHandler::GetActualSourceFilename (
        else if ( ( extension == ".idl" || extension == ".IDL" ) &&
                  ( module.type == RpcServer || module.type == RpcClient || module.type == RpcProxy ) )
        {
-               const FileLocation *objectFile = GetObjectFilename ( file, module, NULL );
+               const FileLocation *objectFile = GetObjectFilename ( file, module );
                FileLocation *sourceFile = new FileLocation (
                        objectFile->directory,
                        objectFile->relative_path,
@@ -301,7 +308,7 @@ MingwModuleHandler::GetActualSourceFilename (
        }
        else if ( extension == ".mc" || extension == ".MC" )
        {
-               const FileLocation *objectFile = GetObjectFilename ( file, module, NULL );
+               const FileLocation *objectFile = GetObjectFilename ( file, module );
                FileLocation *sourceFile = new FileLocation (
                        objectFile->directory,
                        objectFile->relative_path,
@@ -334,7 +341,7 @@ MingwModuleHandler::GetExtraDependencies (
 
                string dependencies = backend->GetFullName ( *header );
                delete header;
-               return dependencies;
+               return " " + dependencies;
        }
        else
                return "";
@@ -352,14 +359,14 @@ MingwModuleHandler::GetCompilationUnitDependencies (
                const File& file = *compilationUnit.GetFiles ()[i];
                sourceFiles.push_back ( backend->GetFullName ( file.file ) );
        }
-       return v2s ( sourceFiles, 10 );
+       return string ( " " ) + v2s ( sourceFiles, 10 );
 }
 
 /* caller needs to delete the returned object */
 const FileLocation*
 MingwModuleHandler::GetModuleArchiveFilename () const
 {
-       if ( module.type == StaticLibrary )
+       if ( IsStaticLibrary ( module ) )
                return GetTargetFilename ( module, NULL );
        return new FileLocation ( IntermediateDirectory,
                                  module.output->relative_path,
@@ -417,7 +424,7 @@ MingwModuleHandler::GetImportLibraryDependency (
                {
                        CompilationUnit& compilationUnit = *compilationUnits[i];
                        const FileLocation& compilationName = compilationUnit.GetFilename ();
-                       const FileLocation *objectFilename = GetObjectFilename ( &compilationName, importedModule, NULL );
+                       const FileLocation *objectFilename = GetObjectFilename ( &compilationName, importedModule );
                        if ( GetExtension ( *objectFilename ) == ".h" )
                                dep += ssprintf ( " $(%s_HEADERS)", importedModule.name.c_str () );
                        else if ( GetExtension ( *objectFilename ) == ".rc" )
@@ -529,8 +536,7 @@ MingwModuleHandler::GetSourceFilenamesWithoutGeneratedFiles (
 const FileLocation*
 MingwModuleHandler::GetObjectFilename (
        const FileLocation* sourceFile,
-       const Module& module,
-       string_list* pclean_files ) const
+       const Module& module ) const
 {
        DirectoryLocation destination_directory;
        string newExtension;
@@ -567,12 +573,8 @@ MingwModuleHandler::GetObjectFilename (
                destination_directory,
                sourceFile->relative_path,
                ReplaceExtension ( sourceFile->name, newExtension ) );
+       PassThruCacheDirectory ( obj_file );
 
-       if ( pclean_files )
-       {
-               string_list& clean_files = *pclean_files;
-               CLEAN_FILE ( *obj_file );
-       }
        return obj_file;
 }
 
@@ -616,7 +618,7 @@ MingwModuleHandler::GenerateCleanTarget () const
        }
        fprintf ( fMakefile, " 2>$(NUL)\n" );
 
-    if( ProxyMakefile::GenerateProxyMakefile(module) )
+       if( ProxyMakefile::GenerateProxyMakefile(module) )
        {
                DirectoryLocation root;
 
@@ -676,7 +678,7 @@ MingwModuleHandler::GetObjectFilenames ()
                if ( objectFilenames.size () > 0 )
                        objectFilenames += " ";
                const FileLocation& compilationName = compilationUnits[i]->GetFilename ();
-               const FileLocation *object_file = GetObjectFilename ( &compilationName, module, NULL );
+               const FileLocation *object_file = GetObjectFilename ( &compilationName, module );
                objectFilenames += backend->GetFullName ( *object_file );
                delete object_file;
        }
@@ -775,11 +777,7 @@ MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector<Compiler
        {
                CompilerFlag& compilerFlag = *compilerFlags[i];
                if ( compilerFlag.compiler == type )
-               {
-                       if ( parameters.length () > 0 )
-                               parameters += " ";
-                       parameters += compilerFlag.flag;
-               }
+                       parameters += " " + compilerFlag.flag;
        }
        return parameters;
 }
@@ -855,12 +853,12 @@ MingwModuleHandler::GenerateMacro (
 
        if ( generatingCompilerMacro )
        {
-               string compilerParameters = GenerateCompilerParametersFromVector ( data.compilerFlags , CompilerTypeDontCare );
+               string compilerParameters = GenerateCompilerParametersFromVector ( data.compilerFlags, CompilerTypeDontCare );
                if ( compilerParameters.size () > 0 )
                {
                        fprintf (
                                fMakefile,
-                               " %s",
+                               "%s",
                                compilerParameters.c_str () );
                }
        }
@@ -1097,7 +1095,7 @@ MingwModuleHandler::GenerateObjectMacros (
                        if ( compilationUnit.IsFirstFile () )
                        {
                                const FileLocation& compilationName = compilationUnit.GetFilename ();
-                               const FileLocation *object_file = GetObjectFilename ( &compilationName, module, NULL );
+                               const FileLocation *object_file = GetObjectFilename ( &compilationName, module );
                                fprintf ( fMakefile,
                                        "%s := %s $(%s)\n",
                                        objectsMacro.c_str(),
@@ -1117,7 +1115,7 @@ MingwModuleHandler::GenerateObjectMacros (
                        if ( !compilationUnit.IsFirstFile () )
                        {
                                const FileLocation& compilationName = compilationUnit.GetFilename ();
-                               const FileLocation *objectFilename = GetObjectFilename ( &compilationName, module, NULL );
+                               const FileLocation *objectFilename = GetObjectFilename ( &compilationName, module );
                                if ( GetExtension ( *objectFilename ) == ".h" )
                                        headers.push_back ( objectFilename );
                                else if ( GetExtension ( *objectFilename ) == ".rc" )
@@ -1227,7 +1225,7 @@ MingwModuleHandler::GenerateObjectMacros (
        for ( i = 0; i < sourceCompilationUnits.size (); i++ )
        {
                const FileLocation& compilationName = sourceCompilationUnits[i]->GetFilename ();
-               const FileLocation *object_file = GetObjectFilename ( &compilationName, module, NULL );
+               const FileLocation *object_file = GetObjectFilename ( &compilationName, module );
                fprintf (
                        fMakefile,
                        "%s += %s\n",
@@ -1245,25 +1243,38 @@ MingwModuleHandler::GetPrecompiledHeaderFilename () const
        if ( !module.pch || !use_pch )
                return NULL;
        return new FileLocation ( IntermediateDirectory,
-                                 module.pch->file.relative_path,
-                                 ReplaceExtension ( module.pch->file.name, "_" + module.name + ".gch" ) );
+                                 module.pch->file->relative_path,
+                                 ReplaceExtension ( module.pch->file->name, "_" + module.name + ".gch" ) );
 }
 
-Rule gasRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) $(module_rbuild) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
+Rule arRule1 ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a: $($(module_name)_OBJS) | $(INTERMEDIATE)$(SEP)$(source_dir)\n",
+               "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a",
+               "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
+Rule arRule2 ( "\t$(ECHO_AR)\n"
+              "\t${ar} -rc $@ $($(module_name)_OBJS)\n",
+              NULL );
+Rule arHostRule2 ( "\t$(ECHO_AR)\n"
+                   "\t${host_ar} -rc $@ $($(module_name)_OBJS)\n",
+                   NULL );
+Rule gasRule ( "$(source): ${$(module_name)_precondition}\n"
+               "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
                "\t$(ECHO_GAS)\n"
                "\t${gcc} -x assembler-with-cpp -c $< -o $@ -D__ASM__ $($(module_name)_CFLAGS)\n",
                "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
                "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
-Rule bootRule ( "$(module_output): $(source) $(module_rbuild) | $(OUTPUT)$(SEP)$(source_dir)\n"
+Rule bootRule ( "$(source): ${$(module_name)_precondition}\n"
+                "$(module_output): $(source)$(dependencies) | $(OUTPUT)$(SEP)$(source_dir)\n"
                 "\t$(ECHO_NASM)\n"
                 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
                 "$(OUTPUT)$(SEP)$(source_dir)$(SEP)", NULL );
-Rule nasmRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) $(module_rbuild) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
+Rule nasmRule ( "$(source): ${$(module_name)_precondition}\n"
+                "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source)$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
                 "\t$(ECHO_NASM)\n"
                 "\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
                 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
                 "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
-Rule windresRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff: $(source) $(module_rbuild) $(WRC_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir) $(TEMPORARY)\n"
+Rule windresRule ( "$(source): ${$(module_name)_precondition}\n"
+                   "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff: $(source)$(dependencies) $(WRC_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir) $(TEMPORARY)\n"
                    "\t$(ECHO_WRC)\n"
                    "\t${gcc} -xc -E -DRC_INVOKED ${$(module_name)_RCFLAGS} $(source) > $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp\n"
                    "\t$(Q)$(WRC_TARGET) ${$(module_name)_RCFLAGS} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp\n"
@@ -1276,82 +1287,113 @@ Rule wmcRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc
                "\t$(ECHO_WMC)\n"
                "\t$(Q)$(WMC_TARGET) -i -H $(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h -o $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc $(source)\n",
                "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc", "$(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h", NULL );
-Rule winebuildRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def: $(source) $(module_rbuild) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
+Rule winebuildRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def: $(source)$(dependencies) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
                      "\t$(ECHO_WINEBLD)\n"
-                     "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).spec.def --def -E $(source_path)$(SEP)$(source_name_noext).spec\n"
+                     "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).spec.def --def -E $(source)\n"
                      "$(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).stubs.c: $(source_path)$(SEP)$(source_name_noext).spec $(WINEBUILD_TARGET)\n"
                      "\t$(ECHO_WINEBLD)\n"
-                     "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).stubs.c --pedll $(source_path)$(SEP)$(source_name_noext).spec\n",
+                     "\t$(Q)$(WINEBUILD_TARGET) $(WINEBUILD_FLAGS) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).stubs.c --pedll $(source_path)$(SEP)$(source_name_noext).spec\n"
+                     "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
+                     "\t$(ECHO_CC)\n"
+                     "\t${gcc} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def",
                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c",
+                     "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.o",
                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
-Rule widlHeaderRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h: $(source) $(module_rbuild) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
+Rule widlHeaderRule ( "$(source): ${$(module_name)_precondition}\n"
+                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
                       "\t$(ECHO_WIDL)\n"
-                      "\t$(Q)$(WIDL_TARGET)  $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h $(source)\n",
+                      "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h $(source)\n",
                       "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).h",
                       "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
-Rule widlServerRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h: $(source) $(module_rbuild) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
+Rule widlServerRule ( "$(source): ${$(module_name)_precondition}\n"
+                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
                       "\t$(ECHO_WIDL)\n"
-                      "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h -s -S $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c $(source)\n",
+                      "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h -s -S $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c $(source)\n"
+                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
+                      "\t$(ECHO_CC)\n"
+                      "\t${gcc} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
                       "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.h",
                       "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.c",
+                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_s.o",
                       "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
-Rule widlClientRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h: $(source) $(module_rbuild) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
+Rule widlClientRule ( "$(source): ${$(module_name)_precondition}\n"
+                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
                       "\t$(ECHO_WIDL)\n"
-                      "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h -c -C $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c $(source)\n",
+                      "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h -c -C $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c $(source)\n"
+                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
+                      "\t$(ECHO_CC)\n"
+                      "\t${gcc} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
                       "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.h",
                       "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.c",
+                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_c.o",
                       "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
-Rule widlProxyRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h: $(source) $(module_rbuild) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
+Rule widlProxyRule ( "$(source): ${$(module_name)_precondition}\n"
+                     "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
                      "\t$(ECHO_WIDL)\n"
-                     "\t$(Q)$(WIDL_TARGET)  $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h -p -P $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c $(source)\n",
+                     "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h -p -P $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c $(source)\n"
+                     "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.o: $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
+                      "\t$(ECHO_CC)\n"
+                      "\t${gcc} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.h",
                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c",
+                     "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.o",
                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
-Rule widlTlbRule ( "$(OUTPUT)$(SEP)$(source_dir)$(SEP)$(module_name).tlb: $(source) $(module_rbuild) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
+Rule widlTlbRule ( "$(source): ${$(module_name)_precondition}\n"
+                   "$(OUTPUT)$(SEP)$(source_dir)$(SEP)$(module_name).tlb: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
                    "\t$(ECHO_WIDL)\n"
-                   "\t$(Q)$(WIDL_TARGET)  $($(module_name)_WIDLFLAGS) -t -T $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).tlb $(source)\n",
+                   "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -t -T $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).tlb $(source)\n",
                    "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
+Rule gccRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) ${$(module_name)_precondition}$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
+               "\t$(ECHO_CC)\n"
+               "\t${gcc} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
+               "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL );
+Rule gccHostRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) ${$(module_name)_precondition}$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
+                   "\t$(ECHO_CC)\n"
+                   "\t${host_gcc} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
+                   "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL );
+Rule gppRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) ${$(module_name)_precondition}$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
+               "\t$(ECHO_CC)\n"
+               "\t${gpp} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
+               "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL );
+Rule gppHostRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) ${$(module_name)_precondition}$(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
+                   "\t$(ECHO_CC)\n"
+                   "\t${host_gpp} -c $< -o $@ $($(module_name)_CFLAGS)$(compiler_flags)\n",
+                   "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o", NULL );
+Rule emptyRule ( "", NULL );
 
 void
 MingwModuleHandler::GenerateGccCommand (
        const FileLocation* sourceFile,
-       const string& extraDependencies,
-       const string& cc,
-       const string& cflagsMacro )
+       const Rule *rule,
+       const string& extraDependencies )
 {
        const FileLocation *generatedSourceFileName = GetActualSourceFilename ( sourceFile );
        const FileLocation *pchFilename = GetPrecompiledHeaderFilename ();
-       string dependencies = backend->GetFullName ( *generatedSourceFileName );
+       string dependencies = extraDependencies;
+
+       string flags;
+       string extension = GetExtension ( *sourceFile );
+       if ( extension == ".cc" || extension == ".cpp" || extension == ".cxx" )
+               flags = GenerateCompilerParametersFromVector ( module.non_if_data.compilerFlags, CompilerTypeCPP );
+       else
+               flags = GenerateCompilerParametersFromVector ( module.non_if_data.compilerFlags, CompilerTypeCC );
 
-       if ( extraDependencies != "" )
-               dependencies += " " + extraDependencies;
        if ( pchFilename )
+       {
                dependencies += " " + backend->GetFullName ( *pchFilename );
+               delete pchFilename;
+       }
 
        /* WIDL generated headers may be used */
        vector<FileLocation> rpcDependencies;
        GetRpcHeaderDependencies ( rpcDependencies );
-       dependencies += " " + v2s ( backend, rpcDependencies, 5 );
-       dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
+       if ( rpcDependencies.size () > 0 )
+               dependencies += " " + v2s ( backend, rpcDependencies, 5 );
 
-       const FileLocation *objectFilename = GetObjectFilename (
-               sourceFile, module, &clean_files );
-       fprintf ( fMakefile,
-                 "%s: %s | %s\n",
-                 backend->GetFullName ( *objectFilename ).c_str (),
-                 dependencies.c_str (),
-                 backend->GetFullPath ( *objectFilename ).c_str () );
-       fprintf ( fMakefile, "\t$(ECHO_CC)\n" );
-       fprintf ( fMakefile,
-                "\t%s -c $< -o $@ %s\n",
-                cc.c_str (),
-                cflagsMacro.c_str () );
+       rule->Execute ( fMakefile, backend, module, generatedSourceFileName, clean_files, dependencies, flags );
 
-       delete objectFilename;
        delete generatedSourceFileName;
-       if ( pchFilename )
-               delete pchFilename;
 }
 
 string
@@ -1409,13 +1451,7 @@ MingwModuleHandler::GetMcHeaderFilename ( const FileLocation *base ) const
 void
 MingwModuleHandler::GenerateCommands (
        const CompilationUnit& compilationUnit,
-       const string& extraDependencies,
-       const string& cc,
-       const string& cppc,
-       const string& cflagsMacro,
-       const string& nasmflagsMacro,
-       const string& windresflagsMacro,
-       const string& widlflagsMacro )
+       const string& extraDependencies )
 {
        const FileLocation& sourceFile = compilationUnit.GetFilename ();
        string extension = GetExtension ( sourceFile );
@@ -1439,6 +1475,15 @@ MingwModuleHandler::GenerateCommands (
                { HostDontCare, RpcProxy, ".idl", &widlProxyRule },
                { HostDontCare, EmbeddedTypeLib, ".idl", &widlTlbRule },
                { HostDontCare, TypeDontCare, ".idl", &widlHeaderRule },
+               { HostTrue, TypeDontCare, ".c", &gccHostRule },
+               { HostTrue, TypeDontCare, ".cc", &gppHostRule },
+               { HostTrue, TypeDontCare, ".cpp", &gppHostRule },
+               { HostTrue, TypeDontCare, ".cxx", &gppHostRule },
+               { HostFalse, TypeDontCare, ".c", &gccRule },
+               { HostFalse, TypeDontCare, ".cc", &gppRule },
+               { HostFalse, TypeDontCare, ".cpp", &gppRule },
+               { HostFalse, TypeDontCare, ".cxx", &gppRule },
+               { HostFalse, Cabinet, ".*", &emptyRule }
        };
        size_t i;
        Rule *customRule = NULL;
@@ -1449,51 +1494,21 @@ MingwModuleHandler::GenerateCommands (
                        continue;
                if ( rules[i].type != TypeDontCare && rules[i].type != module.type )
                        continue;
-               if ( rules[i].extension != extension )
+               if ( rules[i].extension != extension && rules[i].extension != ".*")
                        continue;
                customRule = rules[i].rule;
                break;
        }
 
-       if ( customRule )
-               customRule->Execute ( fMakefile, backend, module, &sourceFile, clean_files );
-
-       string flags = cflagsMacro;
-       flags += " ";
-       if ( extension == ".c" )
-       {
-               flags += GenerateCompilerParametersFromVector ( module.non_if_data.compilerFlags , CompilerTypeCC );
-               GenerateGccCommand ( &sourceFile,
-                                    GetCompilationUnitDependencies ( compilationUnit ) + extraDependencies,
-                                    cc,
-                                    flags );
-       }
-       else if ( extension == ".cc" ||
-                 extension == ".cpp" || 
-                 extension == ".cxx" )
+       if ( extension == ".c" || extension == ".cc" || extension == ".cpp" || extension == ".cxx" )
        {
-               flags += GenerateCompilerParametersFromVector ( module.non_if_data.compilerFlags , CompilerTypeCPP );
                GenerateGccCommand ( &sourceFile,
-                                    GetCompilationUnitDependencies ( compilationUnit ) + extraDependencies,
-                                    cppc,
-                                    flags );
+                                    customRule,
+                                    GetCompilationUnitDependencies ( compilationUnit ) + GetExtraDependencies ( &sourceFile ) + extraDependencies );
        }
-       else if ( extension == ".spec" )
-       {
-               GenerateGccCommand ( &sourceFile,
-                                    extraDependencies,
-                                    cc,
-                                    cflagsMacro );
-       }
-       else if ( extension == ".idl" &&
-               (module.type == RpcServer) || (module.type == RpcClient) || (module.type == RpcProxy) )
-       {
-               GenerateGccCommand ( &sourceFile,
-                                            GetExtraDependencies ( &sourceFile ),
-                                            cc,
-                                            cflagsMacro );
-       }
-       else if ( !customRule )
+       else if ( customRule )
+               customRule->Execute ( fMakefile, backend, module, &sourceFile, clean_files );
+       else
        {
                throw InvalidOperationException ( __FILE__,
                                                  __LINE__,
@@ -1589,7 +1604,7 @@ MingwModuleHandler::GetObjectsVector ( const IfableData& data,
        {
                CompilationUnit& compilationUnit = *data.compilationUnits[i];
                const FileLocation& compilationName = compilationUnit.GetFilename ();
-               const FileLocation *object_file = GetObjectFilename ( &compilationName, module, NULL );
+               const FileLocation *object_file = GetObjectFilename ( &compilationName, module );
                objectFiles.push_back ( *object_file );
                delete object_file;
        }
@@ -1641,28 +1656,28 @@ MingwModuleHandler::GenerateRunStripCode () const
 void
 MingwModuleHandler::GenerateLinkerCommand (
        const string& dependencies,
-       const string& linker,
        const string& linkerParameters,
-       const string& objectsMacro,
-       const string& libsMacro,
        const string& pefixupParameters )
 {
        const FileLocation *target_file = GetTargetFilename ( module, NULL );
        const FileLocation *definitionFilename = GetDefinitionFilename ();
+       string linker = module.cplusplus ? "${gpp}" : "${gcc}";
+       string objectsMacro = GetObjectsMacro ( module );
+       string libsMacro = GetLibsMacro ();
 
        string target_macro ( GetTargetMacro ( module ) );
        string target_folder ( backend->GetFullPath ( *target_file ) );
 
        string linkerScriptArgument;
        if ( module.linkerScript != NULL )
-               linkerScriptArgument = ssprintf ( "-Wl,-T,%s", backend->GetFullName ( module.linkerScript->file ).c_str () );
+               linkerScriptArgument = ssprintf ( " -Wl,-T,%s", backend->GetFullName ( *module.linkerScript->file ).c_str () );
        else
                linkerScriptArgument = "";
 
        fprintf ( fMakefile,
                "%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
                target_macro.c_str (),
-               backend->GetFullName ( *definitionFilename ).c_str (),
+               definitionFilename ? backend->GetFullName ( *definitionFilename ).c_str () : "",
                dependencies.c_str (),
                target_folder.c_str () );
        fprintf ( fMakefile, "\t$(ECHO_LD)\n" );
@@ -1671,7 +1686,7 @@ MingwModuleHandler::GenerateLinkerCommand (
        if ( !module.IsDLL () )
        {
                fprintf ( fMakefile,
-                         "\t%s %s %s -o %s %s %s %s\n",
+                         "\t%s %s%s -o %s %s %s %s\n",
                          linker.c_str (),
                          linkerParameters.c_str (),
                          linkerScriptArgument.c_str (),
@@ -1688,15 +1703,15 @@ MingwModuleHandler::GenerateLinkerCommand (
                CLEAN_FILE ( temp_exp );
 
                fprintf ( fMakefile,
-                         "\t${dlltool} --dllname %s --def %s --output-exp %s %s %s\n",
+                         "\t${dlltool} --dllname %s --def %s --output-exp %s%s%s\n",
                          targetName.c_str (),
-                         backend->GetFullName ( *definitionFilename ).c_str (),
+                         definitionFilename ? backend->GetFullName ( *definitionFilename ).c_str () : "",
                          backend->GetFullName ( temp_exp ).c_str (),
-                         module.mangledSymbols ? "" : "--kill-at",
-                         module.underscoreSymbols ? "--add-underscore" : "" );
+                         module.mangledSymbols ? "" : " --kill-at",
+                         module.underscoreSymbols ? " --add-underscore" : "" );
 
                fprintf ( fMakefile,
-                         "\t%s %s %s %s -o %s %s %s %s\n",
+                         "\t%s %s%s %s -o %s %s %s %s\n",
                          linker.c_str (),
                          linkerParameters.c_str (),
                          linkerScriptArgument.c_str (),
@@ -1707,7 +1722,7 @@ MingwModuleHandler::GenerateLinkerCommand (
                          GetLinkerMacro ().c_str () );
 
                fprintf ( fMakefile,
-                         "\t$(Q)$(PEFIXUP_TARGET) %s -exports %s\n",
+                         "\t$(Q)$(PEFIXUP_TARGET) %s -exports%s\n",
                          target_macro.c_str (),
                          pefixupParameters.c_str() );
 
@@ -1724,7 +1739,7 @@ MingwModuleHandler::GenerateLinkerCommand (
                //printf ( "%s will have all its functions exported\n",
                //         module.target->name.c_str () );
                fprintf ( fMakefile,
-                         "\t%s %s %s -o %s %s %s %s\n",
+                         "\t%s %s%s -o %s %s %s %s\n",
                          linker.c_str (),
                          linkerParameters.c_str (),
                          linkerScriptArgument.c_str (),
@@ -1740,7 +1755,8 @@ MingwModuleHandler::GenerateLinkerCommand (
        GenerateRunStripCode ();
        GenerateCleanObjectsAsYouGoCode ();
 
-       delete definitionFilename;
+       if ( definitionFilename )
+               delete definitionFilename;
        delete target_file;
 }
 
@@ -1761,14 +1777,7 @@ MingwModuleHandler::GeneratePhonyTarget() const
 }
 
 void
-MingwModuleHandler::GenerateObjectFileTargets (
-       const IfableData& data,
-       const string& cc,
-       const string& cppc,
-       const string& cflagsMacro,
-       const string& nasmflagsMacro,
-       const string& windresflagsMacro,
-       const string& widlflagsMacro )
+MingwModuleHandler::GenerateObjectFileTargets ( const IfableData& data )
 {
        size_t i;
        string moduleDependencies;
@@ -1778,7 +1787,7 @@ MingwModuleHandler::GenerateObjectFileTargets (
        {
                CompilationUnit& compilationUnit = *compilationUnits[i];
                const FileLocation& compilationName = compilationUnit.GetFilename ();
-               const FileLocation *objectFilename = GetObjectFilename ( &compilationName, module, NULL );
+               const FileLocation *objectFilename = GetObjectFilename ( &compilationName, module );
                if ( GetExtension ( *objectFilename ) == ".h" )
                        moduleDependencies += ssprintf ( " $(%s_HEADERS)", module.name.c_str () );
                else if ( GetExtension ( *objectFilename ) == ".rc" )
@@ -1789,13 +1798,7 @@ MingwModuleHandler::GenerateObjectFileTargets (
        for ( i = 0; i < compilationUnits.size (); i++ )
        {
                GenerateCommands ( *compilationUnits[i],
-                                  moduleDependencies,
-                                  cc,
-                                  cppc,
-                                  cflagsMacro,
-                                  nasmflagsMacro,
-                                  windresflagsMacro,
-                                  widlflagsMacro );
+                                  moduleDependencies );
                fprintf ( fMakefile,
                          "\n" );
        }
@@ -1803,13 +1806,7 @@ MingwModuleHandler::GenerateObjectFileTargets (
        const vector<If*>& ifs = data.ifs;
        for ( i = 0; i < ifs.size(); i++ )
        {
-               GenerateObjectFileTargets ( ifs[i]->data,
-                                           cc,
-                                           cppc,
-                                           cflagsMacro,
-                                           nasmflagsMacro,
-                                           windresflagsMacro,
-                                           widlflagsMacro );
+               GenerateObjectFileTargets ( ifs[i]->data );
        }
 
        vector<CompilationUnit*> sourceCompilationUnits;
@@ -1817,99 +1814,75 @@ MingwModuleHandler::GenerateObjectFileTargets (
        for ( i = 0; i < sourceCompilationUnits.size (); i++ )
        {
                GenerateCommands ( *sourceCompilationUnits[i],
-                                  moduleDependencies,
-                                  cc,
-                                  cppc,
-                                  cflagsMacro,
-                                  nasmflagsMacro,
-                                  windresflagsMacro,
-                                  widlflagsMacro );
+                                  moduleDependencies );
        }
        CleanupCompilationUnitVector ( sourceCompilationUnits );
 }
 
 void
-MingwModuleHandler::GenerateObjectFileTargets (
-       const string& cc,
-       const string& cppc,
-       const string& cflagsMacro,
-       const string& nasmflagsMacro,
-       const string& windresflagsMacro,
-       const string& widlflagsMacro )
+MingwModuleHandler::GenerateObjectFileTargets ()
 {
        const FileLocation *pchFilename = GetPrecompiledHeaderFilename ();
 
        if ( pchFilename )
        {
-               const FileLocation& baseHeaderFile = module.pch->file;
+               string cc = ( module.host == HostTrue ? "${host_gcc}" : "${gcc}" );
+               string cppc = ( module.host == HostTrue ? "${host_gpp}" : "${gpp}" );
+
+               const FileLocation& baseHeaderFile = *module.pch->file;
                CLEAN_FILE ( *pchFilename );
                string dependencies = backend->GetFullName ( baseHeaderFile );
-               string flags = cflagsMacro;
-               CompilerType type = module.cplusplus ? CompilerTypeCPP : CompilerTypeCC;
-               flags += " ";
-               flags += GenerateCompilerParametersFromVector ( module.non_if_data.compilerFlags , type );
                /* WIDL generated headers may be used */
                vector<FileLocation> rpcDependencies;
                GetRpcHeaderDependencies ( rpcDependencies );
-               dependencies += " " + v2s ( backend, rpcDependencies, 5 );
+               if ( rpcDependencies.size () > 0 )
+                       dependencies += " " + v2s ( backend, rpcDependencies, 5 );
                fprintf ( fMakefile,
-                         "%s: %s | %s\n",
+                         "%s: %s ${%s_precondition} | %s\n",
                          backend->GetFullName ( *pchFilename ).c_str(),
                          dependencies.c_str(),
+                         module.name.c_str (),
                          backend->GetFullPath ( *pchFilename ).c_str() );
                fprintf ( fMakefile, "\t$(ECHO_PCH)\n" );
                fprintf ( fMakefile,
                          "\t%s -o %s %s -g %s\n\n",
                          module.cplusplus ? cppc.c_str() : cc.c_str(),
                          backend->GetFullName ( *pchFilename ).c_str(),
-                         flags.c_str(),
+                         cflagsMacro.c_str(),
                          backend->GetFullName ( baseHeaderFile ).c_str() );
                delete pchFilename;
        }
 
-       GenerateObjectFileTargets ( module.non_if_data,
-                                   cc,
-                                   cppc,
-                                   cflagsMacro,
-                                   nasmflagsMacro,
-                                   windresflagsMacro,
-                                   widlflagsMacro );
+       GenerateObjectFileTargets ( module.non_if_data );
        fprintf ( fMakefile, "\n" );
 }
 
 /* caller needs to delete the returned object */
 const FileLocation*
-MingwModuleHandler::GenerateArchiveTarget ( const string& ar,
-                                            const string& objs_macro ) const
+MingwModuleHandler::GenerateArchiveTarget ()
 {
        const FileLocation *archiveFilename = GetModuleArchiveFilename ();
+       const FileLocation *definitionFilename = GetDefinitionFilename ();
 
-       fprintf ( fMakefile,
-                 "%s: %s | %s\n",
-                 backend->GetFullName ( *archiveFilename ).c_str (),
-                 objs_macro.c_str (),
-                 backend->GetFullPath ( *archiveFilename ).c_str() );
+       arRule1.Execute ( fMakefile, backend, module, archiveFilename, clean_files );
 
-       if ( module.type == StaticLibrary && module.importLibrary )
+       if ( IsStaticLibrary ( module ) && definitionFilename )
        {
-               const FileLocation *definitionFilename = GetDefinitionFilename ();
-
                fprintf ( fMakefile,
-                         "\t${dlltool} --dllname %s --def %s --output-lib $@ %s %s\n",
+                         "\t${dlltool} --dllname %s --def %s --output-lib $@%s%s\n",
                          module.importLibrary->dllname.c_str (),
                          backend->GetFullName ( *definitionFilename ).c_str (),
-                         module.mangledSymbols ? "" : "--kill-at",
-                         module.underscoreSymbols ? "--add-underscore" : "" );
-
-               delete definitionFilename;
+                         module.mangledSymbols ? "" : " --kill-at",
+                         module.underscoreSymbols ? " --add-underscore" : "" );
        }
 
-       fprintf ( fMakefile, "\t$(ECHO_AR)\n" );
+       if ( definitionFilename )
+               delete definitionFilename;
 
-       fprintf ( fMakefile,
-                 "\t%s -rc $@ %s\n",
-                 ar.c_str (),
-                 objs_macro.c_str ());
+       if(module.type == HostStaticLibrary)
+               arHostRule2.Execute ( fMakefile, backend, module, archiveFilename, clean_files );
+       else
+               arRule2.Execute ( fMakefile, backend, module, archiveFilename, clean_files );
 
        GenerateCleanObjectsAsYouGoCode ();
 
@@ -2069,11 +2042,14 @@ MingwModuleHandler::GenerateOtherMacros ()
                &module.linkerFlags,
                used_defs );
 
-       GenerateMacros (
-               "+=",
-               module.project.non_if_data,
-               NULL,
-               used_defs );
+       if ( module.host == HostFalse )
+       {
+               GenerateMacros (
+                       "+=",
+                       module.project.non_if_data,
+                       NULL,
+                       used_defs );
+       }
 
        vector<FileLocation> s;
        if ( module.importLibrary )
@@ -2101,7 +2077,12 @@ MingwModuleHandler::GenerateOtherMacros ()
                fprintf ( fMakefile, "\n" );
        }
 
-       string globalCflags = "-g";
+       string globalCflags = "";
+       if ( module.host == HostFalse )
+               globalCflags += " $(PROJECT_CFLAGS)";
+       else
+               globalCflags += " -Wall -Wpointer-arith -D__REACTOS__";
+       globalCflags += " -g";
        if ( backend->usePipe )
                globalCflags += " -pipe";
        if ( !module.allowWarnings )
@@ -2111,7 +2092,7 @@ MingwModuleHandler::GenerateOtherMacros ()
                if ( module.cplusplus )
                        globalCflags += " $(HOST_CPPFLAGS)";
                else
-                       globalCflags += " $(HOST_CFLAGS)";
+                       globalCflags += " -Wno-strict-aliasing $(HOST_CFLAGS)";
        }
        else
        {
@@ -2130,25 +2111,35 @@ MingwModuleHandler::GenerateOtherMacros ()
 
        fprintf (
                fMakefile,
-               "%s += $(PROJECT_CFLAGS) %s\n",
+               "%s +=%s\n",
                cflagsMacro.c_str (),
                globalCflags.c_str () );
 
-       fprintf (
-               fMakefile,
-               "%s += $(PROJECT_RCFLAGS)\n",
-               windresflagsMacro.c_str () );
+       if ( module.host == HostFalse )
+       {
+               fprintf (
+                       fMakefile,
+                       "%s += $(PROJECT_RCFLAGS)\n",
+                       windresflagsMacro.c_str () );
 
-       fprintf (
-               fMakefile,
-               "%s += $(PROJECT_WIDLFLAGS) -I%s\n",
-               widlflagsMacro.c_str (),
-               module.output->relative_path.c_str () );
+               fprintf (
+                       fMakefile,
+                       "%s += $(PROJECT_WIDLFLAGS) -I%s\n",
+                       widlflagsMacro.c_str (),
+                       module.output->relative_path.c_str () );
 
-       fprintf (
-               fMakefile,
-               "%s_LFLAGS += $(PROJECT_LFLAGS) -g\n",
-               module.name.c_str () );
+               fprintf (
+                       fMakefile,
+                       "%s_LFLAGS += $(PROJECT_LFLAGS) -g\n",
+                       module.name.c_str () );
+       }
+       else
+       {
+               fprintf (
+                       fMakefile,
+                       "%s_LFLAGS += $(HOST_LFLAGS)\n",
+                       module.name.c_str () );
+       }
 
        fprintf (
                fMakefile,
@@ -2183,7 +2174,7 @@ MingwModuleHandler::GenerateOtherMacros ()
                          linkerflags.c_str () );
        }
 
-       if ( module.type == StaticLibrary && module.isStartupLib )
+       if ( IsStaticLibrary ( module ) && module.isStartupLib )
        {
                fprintf ( fMakefile,
                          "%s += -Wno-main\n\n",
@@ -2201,10 +2192,6 @@ MingwModuleHandler::GenerateOtherMacros ()
 void
 MingwModuleHandler::GenerateRules ()
 {
-       string cc = ( module.host == HostTrue ? "${host_gcc}" : "${gcc}" );
-       string cppc = ( module.host == HostTrue ? "${host_gpp}" : "${gpp}" );
-       string ar = ( module.host == HostTrue ? "${host_ar}" : "${ar}" );
-
        string targetMacro = GetTargetMacro ( module );
        //CLEAN_FILE ( targetMacro );
        CLEAN_FILE ( FileLocation ( SourceDirectory, "", targetMacro ) );
@@ -2227,17 +2214,11 @@ MingwModuleHandler::GenerateRules ()
 
        if ( !ReferenceObjects ( module ) )
        {
-               const FileLocation* ar_target = GenerateArchiveTarget ( ar, objectsMacro );
-               CLEAN_FILE ( *ar_target );
+               const FileLocation* ar_target = GenerateArchiveTarget ();
                delete ar_target;
        }
 
-       GenerateObjectFileTargets ( cc,
-                                   cppc,
-                                   cflagsMacro,
-                                   nasmflagsMacro,
-                                   windresflagsMacro,
-                                   widlflagsMacro );
+       GenerateObjectFileTargets ();
 }
 
 void
@@ -2317,18 +2298,13 @@ MingwModuleHandler::GetDefaultDependencies (
        string_list& dependencies ) const
 {
        /* Avoid circular dependency */
-       if ( module.type != BuildTool
-               && module.name != "zlib"
-               && module.name != "hostzlib" )
-
-               dependencies.push_back ( "$(INIT)" );
-
-       if ( module.type != BuildTool
-               && module.name != "psdk" )
+       if ( module.host == HostTrue )
+               return;
 
-       dependencies.push_back ( "$(PSDK_TARGET) $(psdk_HEADERS)" );
+       if ( module.name != "psdk" )
+               dependencies.push_back ( "$(PSDK_TARGET) $(psdk_HEADERS)" );
 
-       /* Check if any dependent library relays on the generated headers */
+       /* Check if any dependent library relies on the generated headers */
        for ( size_t i = 0; i < module.project.modules.size (); i++ )
        {
                const Module& m = *module.project.modules[i];
@@ -2339,7 +2315,7 @@ MingwModuleHandler::GetDefaultDependencies (
                        string extension = GetExtension ( sourceFile );
                        if (extension == ".mc" || extension == ".MC" )
                        {
-                               string dependency = ssprintf ( " $(%s_MCHEADERS)", m.name.c_str () );
+                               string dependency = ssprintf ( "$(%s_MCHEADERS)", m.name.c_str () );
                                dependencies.push_back ( dependency );
                        }
                }
@@ -2370,13 +2346,6 @@ MingwModuleHandler::GeneratePreconditionDependencies ()
                fprintf ( fMakefile, "\n\n" );
        }
 
-       for ( size_t i = 0; i < sourceFilenames.size(); i++ )
-       {
-               fprintf ( fMakefile,
-                         "%s: ${%s}\n",
-                         backend->GetFullName ( sourceFilenames[i] ).c_str (),
-                         preconditionDependenciesName.c_str ());
-       }
        fprintf ( fMakefile, "\n" );
 }
 
@@ -2394,20 +2363,18 @@ MingwModuleHandler::IsWineModule () const
 const FileLocation*
 MingwModuleHandler::GetDefinitionFilename () const
 {
-       if ( module.importLibrary != NULL )
-       {
-               DirectoryLocation directory;
-               if ( IsWineModule () )
-                       directory = IntermediateDirectory;
-               else
-                       directory = SourceDirectory;
+       if ( module.importLibrary == NULL )
+               return NULL;
 
-               return new FileLocation ( directory,
-                                         module.importLibrary->source->relative_path,
-                                         module.importLibrary->source->name );
-       }
+       DirectoryLocation directory;
+       if ( IsWineModule () )
+               directory = IntermediateDirectory;
        else
-               return new FileLocation ( SourceDirectory, "tools" + sSep + "rbuild", "empty.def" );
+               directory = SourceDirectory;
+
+       return new FileLocation ( directory,
+                                 module.importLibrary->source->relative_path,
+                                 module.importLibrary->source->name );
 }
 
 void
@@ -2417,15 +2384,21 @@ MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
        {
                const FileLocation *library_target = GetImportLibraryFilename ( module, &clean_files );
                const FileLocation *defFilename = GetDefinitionFilename ();
+               string empty = "tools" + sSep + "rbuild" + sSep + "empty.def";
 
                vector<FileLocation> deps;
                GetDefinitionDependencies ( deps );
 
                fprintf ( fMakefile, "# IMPORT LIBRARY RULE:\n" );
 
-               fprintf ( fMakefile, "%s: %s",
-                         backend->GetFullName ( *library_target ).c_str (),
-                         backend->GetFullName ( *defFilename ).c_str () );
+               fprintf ( fMakefile, "%s:",
+                         backend->GetFullName ( *library_target ).c_str () );
+
+               if ( defFilename )
+               {
+                       fprintf ( fMakefile, " %s",
+                                 backend->GetFullName ( *defFilename ).c_str () );
+               }
 
                size_t i, iend = deps.size();
                for ( i = 0; i < iend; i++ )
@@ -2438,14 +2411,16 @@ MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
                fprintf ( fMakefile, "\t$(ECHO_DLLTOOL)\n" );
 
                fprintf ( fMakefile,
-                         "\t${dlltool} --dllname %s --def %s --output-lib %s %s %s\n\n",
+                         "\t${dlltool} --dllname %s --def %s --output-lib %s%s%s\n\n",
                          module.output->name.c_str (),
-                         backend->GetFullName ( *defFilename ).c_str (),
+                         defFilename ? backend->GetFullName ( *defFilename ).c_str ()
+                                     : empty.c_str (),
                          backend->GetFullName ( *library_target ).c_str (),
-                         module.mangledSymbols ? "" : "--kill-at",
-                         module.underscoreSymbols ? "--add-underscore" : "" );
+                         module.mangledSymbols ? "" : " --kill-at",
+                         module.underscoreSymbols ? " --add-underscore" : "" );
 
-               delete defFilename;
+               if ( defFilename )
+                       delete defFilename;
                delete library_target;
        }
 }
@@ -2614,9 +2589,7 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ()
 {
        string targetMacro ( GetTargetMacro ( module ) );
        string workingDirectory = GetWorkingDirectory ( );
-       string objectsMacro = GetObjectsMacro ( module );
        string linkDepsMacro = GetLinkingDependenciesMacro ();
-       string libsMacro = GetLibsMacro ();
 
        GenerateImportLibraryTargetIfNeeded ();
 
@@ -2626,16 +2599,13 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ()
 
                string dependencies = linkDepsMacro + " " + objectsMacro;
 
-        string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s",
-                                            module.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
-                                            module.baseaddress.c_str () );
-        
+               string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s",
+                                                    module.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
+                                                    module.baseaddress.c_str () );
+
                GenerateLinkerCommand ( dependencies,
-                                       "${gcc}",
-                                       linkerParameters + " $(NTOSKRNL_SHARED)",
-                                       objectsMacro,
-                                       libsMacro,
-                                       "-sections" );
+                                       linkerParameters + " $(NTOSKRNL_SHARED)",
+                                       " -sections" );
        }
        else
        {
@@ -2664,6 +2634,26 @@ MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ()
 }
 
 
+MingwHostStaticLibraryModuleHandler::MingwHostStaticLibraryModuleHandler (
+       const Module& module_ )
+
+       : MingwModuleHandler ( module_ )
+{
+}
+
+void
+MingwHostStaticLibraryModuleHandler::Process ()
+{
+       GenerateHostStaticLibraryModuleTarget ();
+}
+
+void
+MingwHostStaticLibraryModuleHandler::GenerateHostStaticLibraryModuleTarget ()
+{
+       GenerateRules ();
+}
+
+
 MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler (
        const Module& module_ )
 
@@ -2722,9 +2712,7 @@ MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
 {
        string targetMacro ( GetTargetMacro ( module ) );
        string workingDirectory = GetWorkingDirectory ( );
-       string objectsMacro = GetObjectsMacro ( module );
        string linkDepsMacro = GetLinkingDependenciesMacro ();
-       string libsMacro = GetLibsMacro ();
 
        GenerateImportLibraryTargetIfNeeded ();
 
@@ -2738,11 +2726,8 @@ MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
                                                     module.GetEntryPoint(true).c_str (),
                                                     module.baseaddress.c_str () );
                GenerateLinkerCommand ( dependencies,
-                                       "${gcc}",
                                        linkerParameters,
-                                       objectsMacro,
-                                       libsMacro,
-                                       "-sections" );
+                                       " -sections" );
        }
        else
        {
@@ -2776,9 +2761,7 @@ MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ()
 {
        string targetMacro ( GetTargetMacro (module) );
        string workingDirectory = GetWorkingDirectory ();
-       string objectsMacro = GetObjectsMacro ( module );
        string linkDepsMacro = GetLinkingDependenciesMacro ();
-       string libsMacro = GetLibsMacro ();
 
        GenerateImportLibraryTargetIfNeeded ();
 
@@ -2792,11 +2775,8 @@ MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ()
                                                     module.GetEntryPoint(true).c_str (),
                                                     module.baseaddress.c_str () );
                GenerateLinkerCommand ( dependencies,
-                                       "${gcc}",
                                        linkerParameters,
-                                       objectsMacro,
-                                       libsMacro,
-                                       "-sections" );
+                                       " -sections" );
        }
        else
        {
@@ -2829,9 +2809,7 @@ MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
 {
        string targetMacro ( GetTargetMacro (module) );
        string workingDirectory = GetWorkingDirectory ( );
-       string objectsMacro = GetObjectsMacro ( module );
        string linkDepsMacro = GetLinkingDependenciesMacro ();
-       string libsMacro = GetLibsMacro ();
 
        GenerateImportLibraryTargetIfNeeded ();
 
@@ -2845,10 +2823,7 @@ MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
                                                     module.GetEntryPoint(true).c_str (),
                                                     module.baseaddress.c_str () );
                GenerateLinkerCommand ( dependencies,
-                                       "${gcc}",
                                        linkerParameters,
-                                       objectsMacro,
-                                       libsMacro,
                                        "" );
        }
        else
@@ -2882,9 +2857,7 @@ MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
 {
        string targetMacro ( GetTargetMacro (module) );
        string workingDirectory = GetWorkingDirectory ( );
-       string objectsMacro = GetObjectsMacro ( module );
        string linkDepsMacro = GetLinkingDependenciesMacro ();
-       string libsMacro = GetLibsMacro ();
 
        GenerateImportLibraryTargetIfNeeded ();
 
@@ -2898,10 +2871,7 @@ MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
                                                     module.GetEntryPoint(true).c_str (),
                                                     module.baseaddress.c_str () );
                GenerateLinkerCommand ( dependencies,
-                                       "${gcc}",
                                        linkerParameters,
-                                       objectsMacro,
-                                       libsMacro,
                                        "" );
        }
        else
@@ -3012,9 +2982,7 @@ MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
 {
        string targetMacro ( GetTargetMacro (module) );
        string workingDirectory = GetWorkingDirectory ( );
-       string objectsMacro = GetObjectsMacro ( module );
        string linkDepsMacro = GetLinkingDependenciesMacro ();
-       string libsMacro = GetLibsMacro ();
 
        GenerateImportLibraryTargetIfNeeded ();
 
@@ -3024,20 +2992,11 @@ MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
 
                string dependencies = linkDepsMacro + " " + objectsMacro;
 
-               string linker;
-               if ( module.cplusplus )
-                       linker = "${gpp}";
-               else
-                       linker = "${gcc}";
-
                string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -shared",
                                                     module.GetEntryPoint(true).c_str (),
                                                     module.baseaddress.c_str () );
                GenerateLinkerCommand ( dependencies,
-                                       linker,
                                        linkerParameters,
-                                       objectsMacro,
-                                       libsMacro,
                                        "" );
        }
        else
@@ -3065,9 +3024,7 @@ MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
 {
        string targetMacro ( GetTargetMacro (module) );
        string workingDirectory = GetWorkingDirectory ( );
-       string objectsMacro = GetObjectsMacro ( module );
        string linkDepsMacro = GetLinkingDependenciesMacro ();
-       string libsMacro = GetLibsMacro ();
 
        GenerateImportLibraryTargetIfNeeded ();
 
@@ -3077,20 +3034,11 @@ MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
 
                string dependencies = linkDepsMacro + " " + objectsMacro;
 
-               string linker;
-               if ( module.cplusplus )
-                       linker = "${gpp}";
-               else
-                       linker = "${gcc}";
-
                string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -shared",
                                                     module.GetEntryPoint(true).c_str (),
                                                     module.baseaddress.c_str () );
                GenerateLinkerCommand ( dependencies,
-                                       linker,
                                        linkerParameters,
-                                       objectsMacro,
-                                       libsMacro,
                                        "" );
        }
        else
@@ -3125,9 +3073,7 @@ MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
 {
        string targetMacro ( GetTargetMacro (module) );
        string workingDirectory = GetWorkingDirectory ( );
-       string objectsMacro = GetObjectsMacro ( module );
        string linkDepsMacro = GetLinkingDependenciesMacro ();
-       string libsMacro = GetLibsMacro ();
 
        GenerateImportLibraryTargetIfNeeded ();
 
@@ -3137,20 +3083,11 @@ MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
 
                string dependencies = linkDepsMacro + " " + objectsMacro;
 
-               string linker;
-               if ( module.cplusplus )
-                       linker = "${gpp}";
-               else
-                       linker = "${gcc}";
-
                string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
                                                     module.GetEntryPoint(true).c_str (),
                                                     module.baseaddress.c_str () );
                GenerateLinkerCommand ( dependencies,
-                                       linker,
                                        linkerParameters,
-                                       objectsMacro,
-                                       libsMacro,
                                        "" );
        }
        else
@@ -3185,9 +3122,7 @@ MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
 {
        string targetMacro ( GetTargetMacro (module) );
        string workingDirectory = GetWorkingDirectory ( );
-       string objectsMacro = GetObjectsMacro ( module );
        string linkDepsMacro = GetLinkingDependenciesMacro ();
-       string libsMacro = GetLibsMacro ();
 
        GenerateImportLibraryTargetIfNeeded ();
 
@@ -3197,20 +3132,11 @@ MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
 
                string dependencies = linkDepsMacro + " " + objectsMacro;
 
-               string linker;
-               if ( module.cplusplus )
-                       linker = "${gpp}";
-               else
-                       linker = "${gcc}";
-
                string linkerParameters = ssprintf ( "-Wl,--subsystem,windows -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
                                                     module.GetEntryPoint(true).c_str (),
                                                     module.baseaddress.c_str () );
                GenerateLinkerCommand ( dependencies,
-                                       linker,
                                        linkerParameters,
-                                       objectsMacro,
-                                       libsMacro,
                                        "" );
        }
        else
@@ -3258,24 +3184,24 @@ MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
 
        fprintf ( fMakefile, "\t$(ECHO_LD)\n" );
 
-    if (Environment::GetArch() == "arm")
-    {
-        fprintf ( fMakefile,
-                 "\t${gcc} -Wl,--subsystem,native -Wl,--section-start,startup=0x8000 -o %s %s %s %s\n",
-                 backend->GetFullName ( junk_tmp ).c_str (),
-                 objectsMacro.c_str (),
-                 linkDepsMacro.c_str (),
-                 GetLinkerMacro ().c_str ());
-    }
-    else
-    {
-        fprintf ( fMakefile,
-                 "\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s\n",
-                 backend->GetFullName ( junk_tmp ).c_str (),
-                 objectsMacro.c_str (),
-                 linkDepsMacro.c_str (),
-                 GetLinkerMacro ().c_str ());
-    }
+       if (Environment::GetArch() == "arm")
+       {
+               fprintf ( fMakefile,
+                        "\t${gcc} -Wl,--subsystem,native -Wl,--section-start,startup=0x8000 -o %s %s %s %s\n",
+                        backend->GetFullName ( junk_tmp ).c_str (),
+                        objectsMacro.c_str (),
+                        linkDepsMacro.c_str (),
+                        GetLinkerMacro ().c_str ());
+       }
+       else
+       {
+               fprintf ( fMakefile,
+                        "\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s\n",
+                        backend->GetFullName ( junk_tmp ).c_str (),
+                        objectsMacro.c_str (),
+                        linkDepsMacro.c_str (),
+                        GetLinkerMacro ().c_str ());
+       }
        fprintf ( fMakefile,
                  "\t${objcopy} -O binary %s $@\n",
                  backend->GetFullName ( junk_tmp ).c_str () );
@@ -3563,12 +3489,6 @@ MingwIsoModuleHandler::GenerateIsoModuleTarget ()
        FileLocation reactosInf ( bootcdReactos.directory,
                                  bootcdReactos.relative_path,
                                  "reactos.inf" );
-    FileLocation vgafontsCab( bootcdReactos.directory,
-                              bootcdReactos.relative_path,
-                              "vgafonts.cab");
-    FileLocation vgafontsDir( SourceDirectory,
-                              "media" + sSep + "vgafonts",
-                              "" );
 
        vSourceFiles.push_back ( reactosDff );
 
@@ -3597,11 +3517,6 @@ MingwIsoModuleHandler::GenerateIsoModuleTarget ()
                  sourceFiles.c_str (),
                  cdFiles.c_str (),
                  cdDirectories.c_str () );
-       fprintf ( fMakefile, "\t$(ECHO_CABMAN)\n" );
-    fprintf ( fMakefile,
-              "\t$(Q)$(CABMAN_TARGET) -M raw -S %s %s\\*.bin\n",      // Escape the asterisk for Make
-              backend->GetFullName ( vgafontsCab ).c_str (),
-              backend->GetFullName ( vgafontsDir ).c_str ());
        fprintf ( fMakefile,
                  "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
                  backend->GetFullName ( reactosDff ).c_str (),
@@ -3816,9 +3731,7 @@ MingwTestModuleHandler::GenerateTestModuleTarget ()
 {
        string targetMacro ( GetTargetMacro ( module ) );
        string workingDirectory = GetWorkingDirectory ( );
-       string objectsMacro = GetObjectsMacro ( module );
        string linkDepsMacro = GetLinkingDependenciesMacro ();
-       string libsMacro = GetLibsMacro ();
 
        GenerateImportLibraryTargetIfNeeded ();
 
@@ -3828,20 +3741,11 @@ MingwTestModuleHandler::GenerateTestModuleTarget ()
 
                string dependencies = linkDepsMacro + " " + objectsMacro;
 
-               string linker;
-               if ( module.cplusplus )
-                       linker = "${gpp}";
-               else
-                       linker = "${gcc}";
-
                string linkerParameters = ssprintf ( "-Wl,--subsystem,console -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000",
                                                     module.GetEntryPoint(true).c_str (),
                                                     module.baseaddress.c_str () );
                GenerateLinkerCommand ( dependencies,
-                                       linker,
                                        linkerParameters,
-                                       objectsMacro,
-                                       libsMacro,
                                        "" );
        }
        else
@@ -3918,6 +3822,32 @@ MingwIdlHeaderModuleHandler::Process ()
        GenerateRules ();
 }
 
+MingwCabinetModuleHandler::MingwCabinetModuleHandler (
+       const Module& module_ )
+
+       : MingwModuleHandler ( module_ )
+{
+}
+
+void
+MingwCabinetModuleHandler::Process ()
+{
+       string targetMacro ( GetTargetMacro (module) );
+
+       GenerateRules ();
+       
+       const FileLocation *target_file = GetTargetFilename ( module, NULL );
+       fprintf ( fMakefile, "%s: | %s\n",
+                 targetMacro.c_str (),
+                 backend->GetFullPath ( *target_file ).c_str () );
+
+       fprintf ( fMakefile, "\t$(ECHO_CABMAN)\n" );
+       fprintf ( fMakefile,
+                 "\t$(Q)$(CABMAN_TARGET) -M raw -S %s $(%s_SOURCES)\n",      // Escape the asterisk for Make
+                 targetMacro.c_str (),
+                         module.name.c_str());
+}
+
 MingwElfExecutableModuleHandler::MingwElfExecutableModuleHandler (
        const Module& module_ )