fixed some dependency issues, verbose support, 'make clean' gets more
[reactos.git] / reactos / tools / rbuild / backend / mingw / modulehandler.cpp
index 62f2891..9ad9327 100644 (file)
@@ -12,6 +12,8 @@ using std::set;
 \r
 typedef set<string> set_string;\r
 \r
+#define CLEAN_FILE(f) clean_files.push_back ( f ); /*if ( module.name == "crt" ) printf ( "%s(%i): clean: %s\n", __FILE__, __LINE__, f.c_str() )*/\r
+\r
 map<ModuleType,MingwModuleHandler*>*\r
 MingwModuleHandler::handler_map = NULL;\r
 set_string\r
@@ -134,21 +136,6 @@ MingwModuleHandler::GetImportLibraryDependency ( const Module& importedModule )
                return PassThruCacheDirectory ( FixupTargetFilename ( importedModule.GetDependencyPath () ) );\r
 }\r
 \r
-string\r
-MingwModuleHandler::GetImportLibraryDependencies ( const Module& module ) const\r
-{\r
-       string dependencies ( "" );\r
-       for ( size_t i = 0; i < module.libraries.size (); i++ )\r
-       {\r
-               if ( dependencies.size () > 0 )\r
-                       dependencies += " ";\r
-               const Module* importedModule = module.project.LocateModule ( module.libraries[i]->name );\r
-               assert ( importedModule != NULL );\r
-               dependencies += GetImportLibraryDependency ( *importedModule );\r
-       }\r
-       return dependencies;\r
-}\r
-\r
 string\r
 MingwModuleHandler::GetModuleDependencies ( const Module& module ) const\r
 {\r
@@ -172,10 +159,10 @@ MingwModuleHandler::GetModuleDependencies ( const Module& module ) const
        return dependencies;\r
 }\r
 \r
-string\r
+/*string\r
 MingwModuleHandler::GetAllDependencies ( const Module& module ) const\r
 {\r
-       string dependencies = GetImportLibraryDependencies ( module );\r
+       string dependencies = GetImportMacro ( module );\r
        string s = GetModuleDependencies ( module );\r
        if ( s.length () > 0 )\r
        {\r
@@ -183,7 +170,7 @@ MingwModuleHandler::GetAllDependencies ( const Module& module ) const
                dependencies += s;\r
        }\r
        return dependencies;\r
-}\r
+}*/\r
 \r
 string\r
 MingwModuleHandler::GetSourceFilenames ( const Module& module,\r
@@ -241,6 +228,25 @@ MingwModuleHandler::GetObjectFilename ( const string& sourceFilename )
        return FixupTargetFilename ( ReplaceExtension ( sourceFilename, newExtension ) );\r
 }\r
 \r
+void\r
+MingwModuleHandler::GenerateCleanTarget (\r
+       const Module& module,\r
+       const string_list& clean_files ) const\r
+{\r
+       if ( 0 == clean_files.size() )\r
+               return;\r
+       fprintf ( fMakefile, ".PHONY: %s_clean\n", module.name.c_str() );\r
+       fprintf ( fMakefile, "%s_clean:\n\t-@$(rm)", module.name.c_str() );\r
+       for ( size_t i = 0; i < clean_files.size(); i++ )\r
+       {\r
+               if ( 9==((i+1)%10) )\r
+                       fprintf ( fMakefile, " 2>$(NUL)\n\t-@$(rm)" );\r
+               fprintf ( fMakefile, " %s", clean_files[i].c_str() );\r
+       }\r
+       fprintf ( fMakefile, " 2>$(NUL)\n" );\r
+       fprintf ( fMakefile, "clean: %s_clean\n\n", module.name.c_str() );\r
+}\r
+\r
 string\r
 MingwModuleHandler::GetObjectFilenames ( const Module& module ) const\r
 {\r
@@ -272,32 +278,38 @@ MingwModuleHandler::GenerateDirectoryTargets () const
        if ( directory_set.size () == 0 )\r
                return;\r
        \r
-       set_string::iterator i;\r
+       set_string::iterator it;\r
+       size_t wrap_count = 0;\r
        fprintf ( fMakefile, "directories::" );\r
 \r
-       for ( i = directory_set.begin ();\r
-             i != directory_set.end ();\r
-             i++ )\r
+       for ( it = directory_set.begin ();\r
+             it != directory_set.end ();\r
+             it++ )\r
        {\r
-               if ( IncludeDirectoryTarget ( *i ) )\r
+               if ( IncludeDirectoryTarget ( *it ) )\r
                {\r
+                       if ( wrap_count++ == 5 )\r
+                               fprintf ( fMakefile, " \\\n\t\t" ), wrap_count = 0;\r
                        fprintf ( fMakefile,\r
                                  " %s",\r
-                                 i->c_str () );\r
+                                 it->c_str () );\r
                }\r
        }\r
 \r
        fprintf ( fMakefile, "\n\n" );\r
+       wrap_count = 0;\r
 \r
-       for ( i = directory_set.begin ();\r
-             i != directory_set.end ();\r
-             i++ )\r
+       for ( it = directory_set.begin ();\r
+             it != directory_set.end ();\r
+             it++ )\r
        {\r
-               if ( IncludeDirectoryTarget ( *i ) )\r
+               if ( IncludeDirectoryTarget ( *it ) )\r
                {\r
+                       if ( wrap_count++ == 5 )\r
+                               fprintf ( fMakefile, " \\\n\t\t" ), wrap_count = 0;\r
                        fprintf ( fMakefile,\r
                                  "%s ",\r
-                                 i->c_str () );\r
+                                 it->c_str () );\r
                }\r
        }\r
 \r
@@ -408,6 +420,23 @@ MingwModuleHandler::GenerateLinkerParametersFromVector ( const vector<LinkerFlag
        return parameters;\r
 }\r
 \r
+string\r
+MingwModuleHandler::GenerateImportLibraryDependenciesFromVector (\r
+       const vector<Library*>& libraries ) const\r
+{\r
+       string dependencies ( "" );\r
+       int wrap_count = 0;\r
+       for ( size_t i = 0; i < libraries.size (); i++ )\r
+       {\r
+               if ( wrap_count++ == 5 )\r
+                       dependencies += " \\\n\t\t", wrap_count = 0;\r
+               else if ( dependencies.size () > 0 )\r
+                       dependencies += " ";\r
+               dependencies += GetImportLibraryDependency ( *libraries[i]->imported_module );\r
+       }\r
+       return dependencies;\r
+}\r
+\r
 string\r
 MingwModuleHandler::GenerateLinkerParameters ( const Module& module ) const\r
 {\r
@@ -470,6 +499,7 @@ MingwModuleHandler::GenerateMacros (
        const vector<File*>& files,\r
        const vector<Include*>& includes,\r
        const vector<Define*>& defines,\r
+       const vector<Library*>& libraries,\r
        const vector<CompilerFlag*>* compilerFlags,\r
        const vector<LinkerFlag*>* linkerFlags,\r
        const vector<If*>& ifs,\r
@@ -477,7 +507,9 @@ MingwModuleHandler::GenerateMacros (
        const string& nasmflags_macro,\r
        const string& windresflags_macro,\r
        const string& linkerflags_macro,\r
-       const string& objs_macro) const\r
+       const string& objs_macro,\r
+       const string& libs_macro,\r
+       const string& linkdeps_macro ) const\r
 {\r
        size_t i;\r
 \r
@@ -508,7 +540,21 @@ MingwModuleHandler::GenerateMacros (
                                linkerParameters.c_str() );\r
                }\r
        }\r
-       \r
+\r
+       if ( libraries.size () > 0 )\r
+       {\r
+               string deps = GenerateImportLibraryDependenciesFromVector ( libraries );\r
+               if ( deps.size () > 0 )\r
+               {\r
+                       fprintf (\r
+                               fMakefile,\r
+                               "%s %s %s\n",\r
+                               libs_macro.c_str(),\r
+                               assignmentOperation,\r
+                               deps.c_str() );\r
+               }\r
+       }\r
+\r
        if ( files.size () > 0 )\r
        {\r
                for ( i = 0; i < files.size (); i++ )\r
@@ -544,7 +590,11 @@ MingwModuleHandler::GenerateMacros (
        for ( i = 0; i < ifs.size(); i++ )\r
        {\r
                If& rIf = *ifs[i];\r
-               if ( rIf.defines.size() || rIf.includes.size() || rIf.files.size() || rIf.ifs.size() )\r
+               if ( rIf.defines.size()\r
+                       || rIf.includes.size()\r
+                       || rIf.libraries.size()\r
+                       || rIf.files.size()\r
+                       || rIf.ifs.size() )\r
                {\r
                        fprintf (\r
                                fMakefile,\r
@@ -556,6 +606,7 @@ MingwModuleHandler::GenerateMacros (
                                rIf.files,\r
                                rIf.includes,\r
                                rIf.defines,\r
+                               rIf.libraries,\r
                                NULL,\r
                                NULL,\r
                                rIf.ifs,\r
@@ -563,7 +614,9 @@ MingwModuleHandler::GenerateMacros (
                                nasmflags_macro,\r
                                windresflags_macro,\r
                                linkerflags_macro,\r
-                               objs_macro );\r
+                               objs_macro,\r
+                               libs_macro,\r
+                               linkdeps_macro );\r
                        fprintf ( \r
                                fMakefile,\r
                                "endif\n\n" );\r
@@ -578,13 +631,16 @@ MingwModuleHandler::GenerateMacros (
        const string& nasmflags_macro,\r
        const string& windresflags_macro,\r
        const string& linkerflags_macro,\r
-       const string& objs_macro) const\r
+       const string& objs_macro,\r
+       const string& libs_macro,\r
+       const string& linkdeps_macro ) const\r
 {\r
        GenerateMacros (\r
                "=",\r
                module.files,\r
                module.includes,\r
                module.defines,\r
+               module.libraries,\r
                &module.compilerFlags,\r
                &module.linkerFlags,\r
                module.ifs,\r
@@ -592,23 +648,56 @@ MingwModuleHandler::GenerateMacros (
                nasmflags_macro,\r
                windresflags_macro,\r
                linkerflags_macro,\r
-               objs_macro );\r
-       fprintf ( fMakefile, "\n" );\r
+               objs_macro,\r
+               libs_macro,\r
+               linkdeps_macro );\r
+\r
+       if ( module.importLibrary )\r
+       {\r
+               string s;\r
+               for ( size_t i = 0; i < module.files.size (); i++ )\r
+               {\r
+                       File& file = *module.files[i];\r
+                       string extension = GetExtension ( file.name );\r
+                       if ( extension == ".spec" || extension == ".SPEC" )\r
+                       {\r
+                               if ( s.length () > 0 )\r
+                                       s += " ";\r
+                               s += GetSpecObjectDependencies ( file.name );\r
+                       }\r
+               }\r
+               if ( s.length () > 0 )\r
+               {\r
+                       fprintf (\r
+                               fMakefile,\r
+                               "%s += %s\n",\r
+                               linkdeps_macro.c_str(),\r
+                               s.c_str() );\r
+               }\r
+       }\r
 \r
        fprintf (\r
                fMakefile,\r
-               "%s += $(PROJECT_CFLAGS)\n\n",\r
+               "%s += $(PROJECT_CFLAGS)\n",\r
                cflags_macro.c_str () );\r
 \r
        fprintf (\r
                fMakefile,\r
-               "%s += $(PROJECT_RCFLAGS)\n\n",\r
+               "%s += $(PROJECT_RCFLAGS)\n",\r
                windresflags_macro.c_str () );\r
 \r
        fprintf (\r
                fMakefile,\r
-               "%s_LFLAGS += $(PROJECT_LFLAGS)\n\n",\r
+               "%s_LFLAGS += $(PROJECT_LFLAGS)\n",\r
                module.name.c_str () );\r
+\r
+       fprintf (\r
+               fMakefile,\r
+               "%s += $(%s)",\r
+               linkdeps_macro.c_str (),\r
+               libs_macro.c_str () );\r
+\r
+       fprintf ( fMakefile, "\n" );\r
 }\r
 \r
 void\r
@@ -622,6 +711,7 @@ MingwModuleHandler::GenerateGccCommand ( const Module& module,
                  "%s: %s\n",\r
                  objectFilename.c_str (),\r
                  sourceFilename.c_str () );\r
+       fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [CC]      $<\n" );\r
        fprintf ( fMakefile,\r
                 "\t%s -c %s -o %s %s\n",\r
                 cc.c_str (),\r
@@ -641,6 +731,7 @@ MingwModuleHandler::GenerateGccAssemblerCommand ( const Module& module,
                  "%s: %s\n",\r
                  objectFilename.c_str (),\r
                  sourceFilename.c_str () );\r
+       fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [GAS]     $<\n" );\r
        fprintf ( fMakefile,\r
                  "\t%s -x assembler-with-cpp -c %s -o %s -D__ASM__ %s\n",\r
                  cc.c_str (),\r
@@ -659,9 +750,10 @@ MingwModuleHandler::GenerateNasmCommand ( const Module& module,
                  "%s: %s\n",\r
                  objectFilename.c_str (),\r
                  sourceFilename.c_str () );\r
+       fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [NASM]    $<\n" );\r
        fprintf ( fMakefile,\r
                  "\t%s -f win32 %s -o %s %s\n",\r
-                 "nasm",\r
+                 "$(Q)nasm",\r
                  sourceFilename.c_str (),\r
                  objectFilename.c_str (),\r
                  nasmflagsMacro.c_str () );\r
@@ -673,14 +765,15 @@ MingwModuleHandler::GenerateWindresCommand ( const Module& module,
                                              const string& windresflagsMacro ) const\r
 {\r
        string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) );\r
-  string rciFilename = ReplaceExtension ( sourceFilename,\r
-                                          ".rci" );\r
-  string resFilename = ReplaceExtension ( sourceFilename,\r
-                                          ".res" );\r
+       string rciFilename = ReplaceExtension ( sourceFilename,\r
+                                               ".rci" );\r
+       string resFilename = ReplaceExtension ( sourceFilename,\r
+                                               ".res" );\r
        fprintf ( fMakefile,\r
                  "%s: %s\n",\r
                  objectFilename.c_str (),\r
                  sourceFilename.c_str () );\r
+       fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [WRC]     $@\n" );\r
        fprintf ( fMakefile,\r
                 "\t${gcc} -xc -E -DRC_INVOKED ${%s} %s > %s\n",\r
                 windresflagsMacro.c_str (),\r
@@ -692,52 +785,66 @@ MingwModuleHandler::GenerateWindresCommand ( const Module& module,
                 rciFilename.c_str (),\r
                 resFilename.c_str () );\r
        fprintf ( fMakefile,\r
-                "\t${rm} %s\n",\r
+                "\t-@${rm} %s\n",\r
                 rciFilename.c_str () );\r
        fprintf ( fMakefile,\r
                 "\t${windres} %s -o %s\n",\r
                 resFilename.c_str (),\r
                 objectFilename.c_str () );\r
        fprintf ( fMakefile,\r
-                "\t${rm} %s\n",\r
+                "\t-@${rm} %s\n",\r
                 resFilename.c_str () );\r
 }\r
 \r
 void\r
-MingwModuleHandler::GenerateWinebuildCommands ( const Module& module,\r
-                                                const string& sourceFilename ) const\r
+MingwModuleHandler::GenerateWinebuildCommands (\r
+       const Module& module,\r
+       const string& sourceFilename,\r
+       string_list& clean_files ) const\r
 {\r
        string basename = GetBasename ( sourceFilename );\r
+\r
+       string def_file = basename + ".spec.def";\r
+       CLEAN_FILE ( def_file );\r
+\r
+       string stub_file = basename + ".stubs.c";\r
+       CLEAN_FILE ( stub_file );\r
+\r
        fprintf ( fMakefile,\r
-                 "%s.spec.def: %s\n",\r
-                 basename.c_str (),\r
+                 "%s: %s\n",\r
+                 def_file.c_str (),\r
                  sourceFilename.c_str () );\r
+       fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [WINEBLD] $@\n" );\r
        fprintf ( fMakefile,\r
-                 "\t%s --def=%s -o %s.spec.def\n",\r
+                 "\t%s --def=%s -o %s\n",\r
                  "${winebuild}",\r
                  sourceFilename.c_str (),\r
-                 basename.c_str () );\r
+                 def_file.c_str () );\r
 \r
        fprintf ( fMakefile,\r
-                 "%s.stubs.c: %s\n",\r
-                 basename.c_str (),\r
+                 "%s: %s\n",\r
+                 stub_file.c_str (),\r
                  sourceFilename.c_str () );\r
+       fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [WINEBLD] $@\n" );\r
        fprintf ( fMakefile,\r
-                 "\t%s --pedll=%s -o %s.stubs.c\n",\r
+                 "\t%s --pedll=%s -o %s\n",\r
                  "${winebuild}",\r
                  sourceFilename.c_str (),\r
-                 basename.c_str () );\r
+                 stub_file.c_str () );\r
 }\r
 \r
 void\r
-MingwModuleHandler::GenerateCommands ( const Module& module,\r
-                                       const string& sourceFilename,\r
-                                       const string& cc,\r
-                                       const string& cppc,\r
-                                       const string& cflagsMacro,\r
-                                       const string& nasmflagsMacro,\r
-                                       const string& windresflagsMacro ) const\r
+MingwModuleHandler::GenerateCommands (\r
+       const Module& module,\r
+       const string& sourceFilename,\r
+       const string& cc,\r
+       const string& cppc,\r
+       const string& cflagsMacro,\r
+       const string& nasmflagsMacro,\r
+       const string& windresflagsMacro,\r
+       string_list& clean_files ) const\r
 {\r
+       CLEAN_FILE ( GetObjectFilename(sourceFilename) );\r
        string extension = GetExtension ( sourceFilename );\r
        if ( extension == ".c" || extension == ".C" )\r
        {\r
@@ -782,7 +889,8 @@ MingwModuleHandler::GenerateCommands ( const Module& module,
        else if ( extension == ".spec" || extension == ".SPEC" )\r
        {\r
                GenerateWinebuildCommands ( module,\r
-                                           sourceFilename );\r
+                                           sourceFilename,\r
+                                           clean_files );\r
                GenerateGccCommand ( module,\r
                                     GetActualSourceFilename ( sourceFilename ),\r
                                     cc,\r
@@ -798,20 +906,27 @@ MingwModuleHandler::GenerateCommands ( const Module& module,
 }\r
 \r
 void\r
-MingwModuleHandler::GenerateLinkerCommand ( const Module& module,\r
-                                            const string& linker,\r
-                                            const string& linkerParameters,\r
-                                            const string& objectFilenames ) const\r
+MingwModuleHandler::GenerateLinkerCommand (\r
+       const Module& module,\r
+       const string& linker,\r
+       const string& linkerParameters,\r
+       const string& objectsMacro,\r
+       const string& libsMacro,\r
+       string_list& clean_files ) const\r
 {\r
+       fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [LD]      $@\n" );\r
        string targetName ( module.GetTargetName () );\r
        string target ( FixupTargetFilename ( module.GetPath () ) );\r
-       string importLibraryDependencies = GetImportLibraryDependencies ( module );\r
        if ( module.importLibrary != NULL )\r
        {\r
                static string ros_junk ( "$(ROS_TEMPORARY)" );\r
                string base_tmp = ros_junk + module.name + ".base.tmp";\r
+               CLEAN_FILE ( base_tmp );\r
                string junk_tmp = ros_junk + module.name + ".junk.tmp";\r
+               CLEAN_FILE ( junk_tmp );\r
                string temp_exp = ros_junk + module.name + ".temp.exp";\r
+               CLEAN_FILE ( temp_exp );\r
+               string def_file = module.GetBasePath () + SSEP + module.importLibrary->definition;\r
 \r
                fprintf ( fMakefile,\r
                          "\t%s %s -Wl,--base-file,%s -o %s %s %s %s\n",\r
@@ -819,12 +934,12 @@ MingwModuleHandler::GenerateLinkerCommand ( const Module& module,
                          linkerParameters.c_str (),\r
                          base_tmp.c_str (),\r
                          junk_tmp.c_str (),\r
-                         objectFilenames.c_str (),\r
-                         importLibraryDependencies.c_str (),\r
+                         objectsMacro.c_str (),\r
+                         libsMacro.c_str (),\r
                          GetLinkerMacro ( module ).c_str () );\r
 \r
                fprintf ( fMakefile,\r
-                         "\t${rm} %s\n",\r
+                         "\t-@${rm} %s\n",\r
                          junk_tmp.c_str () );\r
 \r
                string killAt = module.mangledSymbols ? "" : "--kill-at";\r
@@ -832,26 +947,26 @@ MingwModuleHandler::GenerateLinkerCommand ( const Module& module,
                          "\t${dlltool} --dllname %s --base-file %s --def %s --output-exp %s %s\n",\r
                          targetName.c_str (),\r
                          base_tmp.c_str (),\r
-                         ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (),\r
+                         def_file.c_str (),\r
                          temp_exp.c_str (),\r
                          killAt.c_str () );\r
 \r
                fprintf ( fMakefile,\r
-                         "\t${rm} %s\n",\r
+                         "\t-@${rm} %s\n",\r
                          base_tmp.c_str () );\r
 \r
                fprintf ( fMakefile,\r
-                         "\t%s %s %s -o %s %s %s %s\n\n",\r
+                         "\t%s %s %s -o %s %s %s %s\n",\r
                          linker.c_str (),\r
                          linkerParameters.c_str (),\r
                          temp_exp.c_str (),\r
                          target.c_str (),\r
-                         objectFilenames.c_str (),\r
-                         importLibraryDependencies.c_str (),\r
+                         objectsMacro.c_str (),\r
+                         libsMacro.c_str (),\r
                          GetLinkerMacro ( module ).c_str () );\r
 \r
                fprintf ( fMakefile,\r
-                         "\t${rm} %s\n\n",\r
+                         "\t-@${rm} %s\n",\r
                          temp_exp.c_str () );\r
        }\r
        else\r
@@ -861,26 +976,29 @@ MingwModuleHandler::GenerateLinkerCommand ( const Module& module,
                          linker.c_str (),\r
                          linkerParameters.c_str (),\r
                          target.c_str (),\r
-                         objectFilenames.c_str (),\r
-                         importLibraryDependencies.c_str (),\r
+                         objectsMacro.c_str (),\r
+                         libsMacro.c_str (),\r
                          GetLinkerMacro ( module ).c_str () );\r
        }\r
 \r
+       fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [RSYM]    $@\n" );\r
        fprintf ( fMakefile,\r
-                     "\t${rsym} %s %s\n\n",\r
-                     target.c_str (),\r
-                     target.c_str () );\r
+                 "\t${rsym} %s %s\n\n",\r
+                 target.c_str (),\r
+                 target.c_str () );\r
 }\r
 \r
 void\r
-MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,\r
-                                                const vector<File*>& files,\r
-                                                const vector<If*>& ifs,\r
-                                                const string& cc,\r
-                                                const string& cppc,\r
-                                                const string& cflagsMacro,\r
-                                                const string& nasmflagsMacro,\r
-                                                const string& windresflagsMacro ) const\r
+MingwModuleHandler::GenerateObjectFileTargets (\r
+       const Module& module,\r
+       const vector<File*>& files,\r
+       const vector<If*>& ifs,\r
+       const string& cc,\r
+       const string& cppc,\r
+       const string& cflagsMacro,\r
+       const string& nasmflagsMacro,\r
+       const string& windresflagsMacro,\r
+       string_list& clean_files ) const\r
 {\r
        size_t i;\r
 \r
@@ -893,7 +1011,8 @@ MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
                                   cppc,\r
                                   cflagsMacro,\r
                                   nasmflagsMacro,\r
-                                  windresflagsMacro );\r
+                                  windresflagsMacro,\r
+                                  clean_files );\r
                fprintf ( fMakefile,\r
                          "\n" );\r
        }\r
@@ -907,17 +1026,20 @@ MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
                                            cppc,\r
                                            cflagsMacro,\r
                                            nasmflagsMacro,\r
-                                           windresflagsMacro );\r
+                                           windresflagsMacro,\r
+                                           clean_files );\r
        }\r
 }\r
 \r
 void\r
-MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,\r
-                                                const string& cc,\r
-                                                const string& cppc,\r
-                                                const string& cflagsMacro,\r
-                                                const string& nasmflagsMacro,\r
-                                                const string& windresflagsMacro ) const\r
+MingwModuleHandler::GenerateObjectFileTargets (\r
+       const Module& module,\r
+       const string& cc,\r
+       const string& cppc,\r
+       const string& cflagsMacro,\r
+       const string& nasmflagsMacro,\r
+       const string& windresflagsMacro,\r
+       string_list& clean_files ) const\r
 {\r
        GenerateObjectFileTargets ( module,\r
                                    module.files,\r
@@ -926,12 +1048,13 @@ MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
                                    cppc,\r
                                    cflagsMacro,\r
                                    nasmflagsMacro,\r
-                                   windresflagsMacro );\r
+                                   windresflagsMacro,\r
+                                   clean_files );\r
        fprintf ( fMakefile, "\n" );\r
 }\r
 \r
 void\r
-MingwModuleHandler::GetCleanTargets ( vector<string>& out,\r
+MingwModuleHandler::GetCleanTargets ( string_list& out,\r
                                       const vector<File*>& files,\r
                                       const vector<If*>& ifs ) const\r
 {\r
@@ -956,6 +1079,8 @@ MingwModuleHandler::GenerateArchiveTarget ( const Module& module,
                  archiveFilename.c_str (),\r
                  objs_macro.c_str ());\r
 \r
+       fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [AR]      $@\n" );\r
+\r
        fprintf ( fMakefile,\r
                  "\t%s -rc %s %s\n\n",\r
                  ar.c_str (),\r
@@ -979,13 +1104,25 @@ MingwModuleHandler::GetObjectsMacro ( const Module& module ) const
                          module.name.c_str () );\r
 }\r
 \r
+string\r
+MingwModuleHandler::GetLinkingDependenciesMacro ( const Module& module ) const\r
+{\r
+       return ssprintf ( "$(%s_LINKDEPS)", module.name.c_str () );\r
+}\r
+\r
+string\r
+MingwModuleHandler::GetLibsMacro ( const Module& module ) const\r
+{\r
+       return ssprintf ( "$(%s_LIBS)", module.name.c_str () );\r
+}\r
+\r
 string\r
 MingwModuleHandler::GetLinkerMacro ( const Module& module ) const\r
 {\r
        return ssprintf ( "$(%s_LFLAGS)",\r
                          module.name.c_str () );\r
 }\r
-                                           \r
+\r
 void\r
 MingwModuleHandler::GenerateMacrosAndTargets (\r
        const Module& module,\r
@@ -993,20 +1130,25 @@ MingwModuleHandler::GenerateMacrosAndTargets (
        const string& cppc,\r
        const string& ar,\r
        const string* cflags,\r
-       const string* nasmflags ) const\r
+       const string* nasmflags,\r
+       string_list& clean_files ) const\r
 {\r
        string cflagsMacro = ssprintf ("%s_CFLAGS", module.name.c_str ());\r
        string nasmflagsMacro = ssprintf ("%s_NASMFLAGS", module.name.c_str ());\r
        string windresflagsMacro = ssprintf ("%s_RCFLAGS", module.name.c_str ());\r
        string linkerFlagsMacro = ssprintf ("%s_LFLAGS", module.name.c_str ());\r
        string objectsMacro = ssprintf ("%s_OBJS", module.name.c_str ());\r
+       string libsMacro = ssprintf("%s_LIBS", module.name.c_str ());\r
+       string linkDepsMacro = ssprintf ("%s_LINKDEPS", module.name.c_str ());\r
 \r
        GenerateMacros ( module,\r
                        cflagsMacro,\r
                        nasmflagsMacro,\r
                        windresflagsMacro,\r
                        linkerFlagsMacro,\r
-                       objectsMacro );\r
+                       objectsMacro,\r
+                       libsMacro,\r
+                       linkDepsMacro );\r
 \r
        if ( cflags != NULL )\r
        {\r
@@ -1042,55 +1184,59 @@ MingwModuleHandler::GenerateMacrosAndTargets (
                                    cppc,\r
                                    cflagsMacro,\r
                                    nasmflagsMacro,\r
-                                   windresflagsMacro );\r
+                                   windresflagsMacro,\r
+                                   clean_files );\r
 \r
-       vector<string> clean_files;\r
-       clean_files.push_back ( FixupTargetFilename(module.GetPath()) );\r
-       clean_files.push_back ( ar_target );\r
-       GetCleanTargets ( clean_files, module.files, module.ifs );\r
-\r
-       fprintf ( fMakefile, ".PHONY: %s_clean\n", module.name.c_str() );\r
-       fprintf ( fMakefile, "%s_clean:\n\t-@$(rm)", module.name.c_str() );\r
-       for ( size_t i = 0; i < clean_files.size(); i++ )\r
+       CLEAN_FILE ( ar_target );\r
+       string tgt = FixupTargetFilename(module.GetPath());\r
+       if ( tgt != ar_target )\r
        {\r
-               if ( 9==(i%10) )\r
-                       fprintf ( fMakefile, " 2>$(NUL)\n\t-@$(rm)" );\r
-               fprintf ( fMakefile, " %s", clean_files[i].c_str() );\r
+               CLEAN_FILE ( tgt );\r
        }\r
-       fprintf ( fMakefile, " 2>$(NUL)\n" );\r
-       fprintf ( fMakefile, "clean: %s_clean\n\n", module.name.c_str() );\r
 }\r
 \r
 void\r
-MingwModuleHandler::GenerateMacrosAndTargetsHost ( const Module& module ) const\r
+MingwModuleHandler::GenerateMacrosAndTargetsHost (\r
+       const Module& module,\r
+       string_list& clean_files ) const\r
 {\r
-       GenerateMacrosAndTargets ( module,\r
-                                  "${host_gcc}",\r
-                                  "${host_gpp}",\r
-                                  "${host_ar}",\r
-                                  NULL,\r
-                                  NULL );\r
+       GenerateMacrosAndTargets (\r
+               module,\r
+               "${host_gcc}",\r
+               "${host_gpp}",\r
+               "${host_ar}",\r
+               NULL,\r
+               NULL,\r
+               clean_files );\r
 }\r
 \r
 void\r
-MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module& module ) const\r
+MingwModuleHandler::GenerateMacrosAndTargetsTarget (\r
+       const Module& module,\r
+       string_list& clean_files ) const\r
 {\r
-       GenerateMacrosAndTargetsTarget ( module,\r
-                                        NULL,\r
-                                        NULL );\r
+       GenerateMacrosAndTargetsTarget (\r
+               module,\r
+               NULL,\r
+               NULL,\r
+               clean_files );\r
 }\r
 \r
 void\r
-MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module& module,\r
-                                                        const string* cflags,\r
-                                                        const string* nasmflags ) const\r
+MingwModuleHandler::GenerateMacrosAndTargetsTarget (\r
+       const Module& module,\r
+       const string* cflags,\r
+       const string* nasmflags,\r
+       string_list& clean_files ) const\r
 {\r
-       GenerateMacrosAndTargets ( module,\r
-                                 "${gcc}",\r
-                                 "${gpp}",\r
-                                 "${ar}",\r
-                                 cflags,\r
-                                 nasmflags );\r
+       GenerateMacrosAndTargets (\r
+               module,\r
+               "${gcc}",\r
+               "${gpp}",\r
+               "${ar}",\r
+               cflags,\r
+               nasmflags,\r
+               clean_files );\r
 }\r
 \r
 string\r
@@ -1138,6 +1284,7 @@ MingwModuleHandler::GenerateInvocations ( const Module& module ) const
                          "%s: %s\n",\r
                          invoke.GetTargets ().c_str (),\r
                          FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str () );\r
+               fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [INVOKE]  $<\n" );\r
                fprintf ( fMakefile,\r
                          "\t%s %s\n\n",\r
                          FixupTargetFilename ( invoke.invokeModule->GetPath () ).c_str (),\r
@@ -1218,21 +1365,28 @@ MingwModuleHandler::GeneratePreconditionDependencies ( const Module& module ) co
 }\r
 \r
 void\r
-MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ( const Module& module ) const\r
+MingwModuleHandler::GenerateImportLibraryTargetIfNeeded (\r
+       const Module& module,\r
+       string_list& clean_files ) const\r
 {\r
        if ( module.importLibrary != NULL )\r
        {\r
+               string library_target = FixupTargetFilename( module.GetDependencyPath () ).c_str ();\r
+               CLEAN_FILE ( library_target );\r
+\r
                string definitionDependencies = GetDefinitionDependencies ( module );\r
                fprintf ( fMakefile, "%s: %s\n",\r
-                         FixupTargetFilename( module.GetDependencyPath () ).c_str (),\r
+                         library_target.c_str (),\r
                          definitionDependencies.c_str () );\r
 \r
+               fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [DLLTOOL] $@\n" );\r
+\r
                string killAt = module.mangledSymbols ? "" : "--kill-at";\r
                fprintf ( fMakefile,\r
                          "\t${dlltool} --dllname %s --def %s --output-lib %s %s\n\n",\r
                          module.GetTargetName ().c_str (),\r
                          ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (),\r
-                         FixupTargetFilename ( module.GetDependencyPath () ).c_str (),\r
+                         library_target.c_str (),\r
                          killAt.c_str () );\r
        }\r
 }\r
@@ -1265,7 +1419,7 @@ MingwModuleHandler::GetDefinitionDependencies ( const Module& module ) const
        return dependencies;\r
 }\r
 \r
-string\r
+/*string\r
 MingwModuleHandler::GetLinkingDependencies ( const Module& module ) const\r
 {\r
        string dependencies = GetImportLibraryDependencies ( module );\r
@@ -1276,7 +1430,7 @@ MingwModuleHandler::GetLinkingDependencies ( const Module& module ) const
                dependencies += s;\r
        }\r
        return dependencies;\r
-}\r
+}*/\r
 \r
 bool\r
 MingwModuleHandler::IsCPlusPlusModule ( const Module& module ) const\r
@@ -1299,21 +1453,22 @@ MingwBuildToolModuleHandler::MingwBuildToolModuleHandler()
 }\r
 \r
 void\r
-MingwBuildToolModuleHandler::Process ( const Module& module )\r
+MingwBuildToolModuleHandler::Process ( const Module& module, string_list& clean_files )\r
 {\r
        GeneratePreconditionDependencies ( module );\r
-       GenerateBuildToolModuleTarget ( module );\r
+       GenerateBuildToolModuleTarget ( module, clean_files );\r
        GenerateInvocations ( module );\r
 }\r
 \r
 void\r
-MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module& module )\r
+MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module& module, string_list& clean_files )\r
 {\r
        string target ( FixupTargetFilename ( module.GetPath () ) );\r
        string objectsMacro = GetObjectsMacro ( module );\r
-       string importLibraryDependencies = GetImportLibraryDependencies ( module );\r
+       string linkDepsMacro = GetLinkingDependenciesMacro ( module );\r
+       string libsMacro = GetLibsMacro ( module );\r
 \r
-       GenerateMacrosAndTargetsHost ( module );\r
+       GenerateMacrosAndTargetsHost ( module, clean_files );\r
 \r
        string linker;\r
        if ( IsCPlusPlusModule ( module ) )\r
@@ -1324,14 +1479,15 @@ MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module& modul
        fprintf ( fMakefile, "%s: %s %s\n",\r
                  target.c_str (),\r
                  objectsMacro.c_str (),\r
-                 importLibraryDependencies.c_str () );\r
+                 linkDepsMacro.c_str () );\r
+       fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [LD]      $@\n" );\r
        fprintf ( fMakefile,\r
                  "\t%s %s -o %s %s %s\n\n",\r
                  linker.c_str (),\r
                  GetLinkerMacro ( module ).c_str (),\r
                  target.c_str (),\r
                  objectsMacro.c_str (),\r
-                 importLibraryDependencies.c_str () );\r
+                 libsMacro.c_str () );\r
 }\r
 \r
 \r
@@ -1343,38 +1499,43 @@ MingwKernelModuleHandler::MingwKernelModuleHandler ()
 }\r
 \r
 void\r
-MingwKernelModuleHandler::Process ( const Module& module )\r
+MingwKernelModuleHandler::Process ( const Module& module, string_list& clean_files )\r
 {\r
        GeneratePreconditionDependencies ( module );\r
-       GenerateKernelModuleTarget ( module );\r
+       GenerateKernelModuleTarget ( module, clean_files );\r
        GenerateInvocations ( module );\r
 }\r
 \r
 void\r
-MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module )\r
+MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module, string_list& clean_files )\r
 {\r
        static string ros_junk ( "$(ROS_TEMPORARY)" );\r
-       string targetName ( module.GetTargetName () );\r
-       string target ( FixupTargetFilename (module.GetPath ()) );\r
+       string targetName ( module.GetTargetName () ); // i.e. "ntoskrnl.exe"\r
+       string target ( FixupTargetFilename (module.GetPath ()) ); // i.e. "$(ROS_INT).\ntoskrnl\ntoskrnl.exe"\r
        string workingDirectory = GetWorkingDirectory ();\r
        string objectsMacro = GetObjectsMacro ( module );\r
-       string importLibraryDependencies = GetImportLibraryDependencies ( module );\r
+       string linkDepsMacro = GetLinkingDependenciesMacro ( module );\r
+       string libsMacro = GetLibsMacro ( module );\r
        string base_tmp = ros_junk + module.name + ".base.tmp";\r
+       CLEAN_FILE ( base_tmp );\r
        string junk_tmp = ros_junk + module.name + ".junk.tmp";\r
+       CLEAN_FILE ( junk_tmp );\r
        string temp_exp = ros_junk + module.name + ".temp.exp";\r
+       CLEAN_FILE ( temp_exp );\r
        string gccOptions = ssprintf ("-Wl,-T,%s" SSEP "ntoskrnl.lnk -Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",\r
                                      module.GetBasePath ().c_str (),\r
                                      module.entrypoint.c_str (),\r
                                      module.baseaddress.c_str () );\r
 \r
-       GenerateMacrosAndTargetsTarget ( module );\r
+       GenerateMacrosAndTargetsTarget ( module, clean_files );\r
 \r
-       GenerateImportLibraryTargetIfNeeded ( module );\r
+       GenerateImportLibraryTargetIfNeeded ( module, clean_files );\r
 \r
        fprintf ( fMakefile, "%s: %s %s\n",\r
                  target.c_str (),\r
                  objectsMacro.c_str (),\r
-                 importLibraryDependencies.c_str () );\r
+                 linkDepsMacro.c_str () );\r
+       fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [LD]      $@\n" );\r
        fprintf ( fMakefile,\r
                  "\t${gcc} %s %s -Wl,--base-file,%s -o %s %s %s\n",\r
                  GetLinkerMacro ( module ).c_str (),\r
@@ -1382,9 +1543,9 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module )
                  base_tmp.c_str (),\r
                  junk_tmp.c_str (),\r
                  objectsMacro.c_str (),\r
-                 importLibraryDependencies.c_str () );\r
+                 linkDepsMacro.c_str () );\r
        fprintf ( fMakefile,\r
-                 "\t${rm} %s\n",\r
+                 "\t-@${rm} %s\n",\r
                  junk_tmp.c_str () );\r
        string killAt = module.mangledSymbols ? "" : "--kill-at";\r
        fprintf ( fMakefile,\r
@@ -1394,7 +1555,7 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module )
                  temp_exp.c_str (),\r
                  killAt.c_str () );\r
        fprintf ( fMakefile,\r
-                 "\t${rm} %s\n",\r
+                 "\t-@${rm} %s\n",\r
                  base_tmp.c_str () );\r
        fprintf ( fMakefile,\r
                  "\t${gcc} %s %s -Wl,%s -o %s %s %s\n",\r
@@ -1403,10 +1564,11 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module )
                  temp_exp.c_str (),\r
                  target.c_str (),\r
                  objectsMacro.c_str (),\r
-                 importLibraryDependencies.c_str () );\r
+                 linkDepsMacro.c_str () );\r
        fprintf ( fMakefile,\r
-                 "\t${rm} %s\n",\r
+                 "\t-@${rm} %s\n",\r
                  temp_exp.c_str () );\r
+       fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [RSYM]    $@\n" );\r
        fprintf ( fMakefile,\r
                      "\t${rsym} %s %s\n\n",\r
                      target.c_str (),\r
@@ -1422,17 +1584,17 @@ MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler ()
 }\r
 \r
 void\r
-MingwStaticLibraryModuleHandler::Process ( const Module& module )\r
+MingwStaticLibraryModuleHandler::Process ( const Module& module, string_list& clean_files )\r
 {\r
        GeneratePreconditionDependencies ( module );\r
-       GenerateStaticLibraryModuleTarget ( module );\r
+       GenerateStaticLibraryModuleTarget ( module, clean_files );\r
        GenerateInvocations ( module );\r
 }\r
 \r
 void\r
-MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Module& module )\r
+MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Module& module, string_list& clean_files )\r
 {\r
-       GenerateMacrosAndTargetsTarget ( module );\r
+       GenerateMacrosAndTargetsTarget ( module, clean_files );\r
 }\r
 \r
 \r
@@ -1444,17 +1606,17 @@ MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler ()
 }\r
 \r
 void\r
-MingwObjectLibraryModuleHandler::Process ( const Module& module )\r
+MingwObjectLibraryModuleHandler::Process ( const Module& module, string_list& clean_files )\r
 {\r
        GeneratePreconditionDependencies ( module );\r
-       GenerateObjectLibraryModuleTarget ( module );\r
+       GenerateObjectLibraryModuleTarget ( module, clean_files );\r
        GenerateInvocations ( module );\r
 }\r
 \r
 void\r
-MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ( const Module& module )\r
+MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget ( const Module& module, string_list& clean_files )\r
 {\r
-       GenerateMacrosAndTargetsTarget ( module );\r
+       GenerateMacrosAndTargetsTarget ( module, clean_files );\r
 }\r
 \r
 \r
@@ -1466,32 +1628,33 @@ MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler ()
 }\r
 \r
 void\r
-MingwKernelModeDLLModuleHandler::Process ( const Module& module )\r
+MingwKernelModeDLLModuleHandler::Process ( const Module& module, string_list& clean_files )\r
 {\r
        GeneratePreconditionDependencies ( module );\r
-       GenerateKernelModeDLLModuleTarget ( module );\r
+       GenerateKernelModeDLLModuleTarget ( module, clean_files );\r
        GenerateInvocations ( module );\r
 }\r
 \r
 void\r
-MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Module& module )\r
+MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Module& module, string_list& clean_files )\r
 {\r
        static string ros_junk ( "$(ROS_TEMPORARY)" );\r
        string target ( FixupTargetFilename ( module.GetPath () ) );\r
        string workingDirectory = GetWorkingDirectory ( );\r
        string objectsMacro = GetObjectsMacro ( module );\r
-       string importLibraryDependencies = GetImportLibraryDependencies ( module );\r
+       string linkDepsMacro = GetLinkingDependenciesMacro ( module );\r
+       string libsMacro = GetLibsMacro ( module );\r
 \r
-       GenerateImportLibraryTargetIfNeeded ( module );\r
+       GenerateImportLibraryTargetIfNeeded ( module, clean_files );\r
 \r
        if ( module.files.size () > 0 )\r
        {\r
-               GenerateMacrosAndTargetsTarget ( module );\r
+               GenerateMacrosAndTargetsTarget ( module, clean_files );\r
 \r
                fprintf ( fMakefile, "%s: %s %s\n",\r
                          target.c_str (),\r
                          objectsMacro.c_str (),\r
-                         importLibraryDependencies.c_str () );\r
+                         linkDepsMacro.c_str () );\r
 \r
                string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",\r
                                                     module.entrypoint.c_str (),\r
@@ -1499,7 +1662,9 @@ MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Modul
                GenerateLinkerCommand ( module,\r
                                        "${gcc}",\r
                                        linkerParameters,\r
-                                       objectsMacro );\r
+                                       objectsMacro,\r
+                                       libsMacro,\r
+                                       clean_files );\r
        }\r
        else\r
        {\r
@@ -1519,37 +1684,40 @@ MingwKernelModeDriverModuleHandler::MingwKernelModeDriverModuleHandler ()
 }\r
 \r
 void\r
-MingwKernelModeDriverModuleHandler::Process ( const Module& module )\r
+MingwKernelModeDriverModuleHandler::Process ( const Module& module, string_list& clean_files )\r
 {\r
        GeneratePreconditionDependencies ( module );\r
-       GenerateKernelModeDriverModuleTarget ( module );\r
+       GenerateKernelModeDriverModuleTarget ( module, clean_files );\r
        GenerateInvocations ( module );\r
 }\r
 \r
 \r
 void\r
-MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ( const Module& module )\r
+MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget (\r
+       const Module& module,\r
+       string_list& clean_files )\r
 {\r
        static string ros_junk ( "$(ROS_TEMPORARY)" );\r
        string target ( PassThruCacheDirectory( FixupTargetFilename ( module.GetPath () ) ) );\r
        string workingDirectory = GetWorkingDirectory ();\r
        string objectsMacro = GetObjectsMacro ( module );\r
-       string importLibraryDependencies = GetImportLibraryDependencies ( module );\r
+       string linkDepsMacro = GetLinkingDependenciesMacro ( module );\r
+       string libsMacro = GetLibsMacro ( module );\r
 \r
-       GenerateImportLibraryTargetIfNeeded ( module );\r
+       GenerateImportLibraryTargetIfNeeded ( module, clean_files );\r
 \r
        if ( module.files.size () > 0 )\r
        {\r
-               string* cflags = new string ( "-D__NTDRIVER__" );\r
+               string cflags ( "-D__NTDRIVER__" );\r
                GenerateMacrosAndTargetsTarget ( module,\r
-                                                cflags,\r
-                                                NULL );\r
-               delete cflags;\r
+                                                &cflags,\r
+                                                NULL,\r
+                                                clean_files);\r
 \r
                fprintf ( fMakefile, "%s: %s %s\n",\r
                          target.c_str (),\r
                          objectsMacro.c_str (),\r
-                         importLibraryDependencies.c_str () );\r
+                         linkDepsMacro.c_str () );\r
 \r
                string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",\r
                                                     module.entrypoint.c_str (),\r
@@ -1557,7 +1725,9 @@ MingwKernelModeDriverModuleHandler::GenerateKernelModeDriverModuleTarget ( const
                GenerateLinkerCommand ( module,\r
                                        "${gcc}",\r
                                        linkerParameters,\r
-                                       objectsMacro );\r
+                                       objectsMacro,\r
+                                       libsMacro,\r
+                                       clean_files );\r
        }\r
        else\r
        {\r
@@ -1577,32 +1747,33 @@ MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler ()
 }\r
 \r
 void\r
-MingwNativeDLLModuleHandler::Process ( const Module& module )\r
+MingwNativeDLLModuleHandler::Process ( const Module& module, string_list& clean_files )\r
 {\r
        GeneratePreconditionDependencies ( module );\r
-       GenerateNativeDLLModuleTarget ( module );\r
+       GenerateNativeDLLModuleTarget ( module, clean_files );\r
        GenerateInvocations ( module );\r
 }\r
 \r
 void\r
-MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module& module )\r
+MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module& module, string_list& clean_files )\r
 {\r
        static string ros_junk ( "$(ROS_TEMPORARY)" );\r
        string target ( FixupTargetFilename ( module.GetPath () ) );\r
        string workingDirectory = GetWorkingDirectory ( );\r
        string objectsMacro = GetObjectsMacro ( module );\r
-       string importLibraryDependencies = GetImportLibraryDependencies ( module );\r
+       string linkDepsMacro = GetLinkingDependenciesMacro ( module );\r
+       string libsMacro = GetLibsMacro ( module );\r
        \r
-       GenerateImportLibraryTargetIfNeeded ( module );\r
+       GenerateImportLibraryTargetIfNeeded ( module, clean_files );\r
 \r
        if ( module.files.size () > 0 )\r
        {\r
-               GenerateMacrosAndTargetsTarget ( module );\r
+               GenerateMacrosAndTargetsTarget ( module, clean_files );\r
 \r
                fprintf ( fMakefile, "%s: %s %s\n",\r
                          target.c_str (),\r
                          objectsMacro.c_str (),\r
-                         importLibraryDependencies.c_str () );\r
+                         linkDepsMacro.c_str () );\r
 \r
                string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll",\r
                                                     module.entrypoint.c_str (),\r
@@ -1610,7 +1781,9 @@ MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ( const Module& modul
                GenerateLinkerCommand ( module,\r
                                        "${gcc}",\r
                                        linkerParameters,\r
-                                       objectsMacro );\r
+                                       objectsMacro,\r
+                                       libsMacro,\r
+                                       clean_files );\r
        }\r
        else\r
        {\r
@@ -1630,36 +1803,37 @@ MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler ()
 }\r
 \r
 void\r
-MingwNativeCUIModuleHandler::Process ( const Module& module )\r
+MingwNativeCUIModuleHandler::Process ( const Module& module, string_list& clean_files )\r
 {\r
        GeneratePreconditionDependencies ( module );\r
-       GenerateNativeCUIModuleTarget ( module );\r
+       GenerateNativeCUIModuleTarget ( module, clean_files );\r
        GenerateInvocations ( module );\r
 }\r
 \r
 void\r
-MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ( const Module& module )\r
+MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ( const Module& module, string_list& clean_files )\r
 {\r
        static string ros_junk ( "$(ROS_TEMPORARY)" );\r
        string target ( FixupTargetFilename ( module.GetPath () ) );\r
        string workingDirectory = GetWorkingDirectory ( );\r
        string objectsMacro = GetObjectsMacro ( module );\r
-       string importLibraryDependencies = GetImportLibraryDependencies ( module );\r
+       string linkDepsMacro = GetLinkingDependenciesMacro ( module );\r
+       string libsMacro = GetLibsMacro ( module );\r
        \r
-       GenerateImportLibraryTargetIfNeeded ( module );\r
+       GenerateImportLibraryTargetIfNeeded ( module, clean_files );\r
 \r
        if ( module.files.size () > 0 )\r
        {\r
-               string* cflags = new string ( "-D__NTAPP__" );\r
+               string cflags ( "-D__NTAPP__" );\r
                GenerateMacrosAndTargetsTarget ( module,\r
-                                                cflags,\r
-                                                NULL );\r
-               delete cflags;\r
+                                                &cflags,\r
+                                                NULL,\r
+                                                clean_files );\r
 \r
                fprintf ( fMakefile, "%s: %s %s\n",\r
                          target.c_str (),\r
                          objectsMacro.c_str (),\r
-                         importLibraryDependencies.c_str () );\r
+                         linkDepsMacro.c_str () );\r
 \r
                string linkerParameters = ssprintf ( "-Wl,--subsystem,native -Wl,--entry,%s -Wl,--image-base,%s -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib",\r
                                                     module.entrypoint.c_str (),\r
@@ -1667,7 +1841,9 @@ MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ( const Module& modul
                GenerateLinkerCommand ( module,\r
                                        "${gcc}",\r
                                        linkerParameters,\r
-                                       objectsMacro );\r
+                                       objectsMacro,\r
+                                       libsMacro,\r
+                                       clean_files );\r
        }\r
        else\r
        {\r
@@ -1687,16 +1863,16 @@ MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler ()
 }\r
 \r
 void\r
-MingwWin32DLLModuleHandler::Process ( const Module& module )\r
+MingwWin32DLLModuleHandler::Process ( const Module& module, string_list& clean_files )\r
 {\r
-       GenerateExtractWineDLLResourcesTarget ( module );\r
+       GenerateExtractWineDLLResourcesTarget ( module, clean_files );\r
        GeneratePreconditionDependencies ( module );\r
-       GenerateWin32DLLModuleTarget ( module );\r
+       GenerateWin32DLLModuleTarget ( module, clean_files );\r
        GenerateInvocations ( module );\r
 }\r
 \r
 void\r
-MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ( const Module& module )\r
+MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ( const Module& module, string_list& clean_files )\r
 {\r
        fprintf ( fMakefile, ".PHONY: %s_extractresources\n\n",\r
                  module.name.c_str () );\r
@@ -1709,7 +1885,8 @@ MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ( const Module
                if ( extension == ".rc" || extension == ".RC" )\r
                {\r
                        string resource = FixupTargetFilename ( file.name );\r
-                       fprintf ( fMakefile, "\t@echo ${bin2res} -f -x %s\n",\r
+                       fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [BIN2RES] $<\n" );\r
+                       fprintf ( fMakefile, "\t@:echo ${bin2res} -f -x %s\n",\r
                                  resource.c_str () );\r
                }\r
        }\r
@@ -1717,23 +1894,25 @@ MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ( const Module
 }\r
 \r
 void\r
-MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module& module )\r
+MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module& module, string_list& clean_files )\r
 {\r
        static string ros_junk ( "$(ROS_TEMPORARY)" );\r
        string target ( FixupTargetFilename ( module.GetPath () ) );\r
        string workingDirectory = GetWorkingDirectory ( );\r
        string objectsMacro = GetObjectsMacro ( module );\r
-       string linkingDependencies = GetLinkingDependencies ( module );\r
+       string linkDepsMacro = GetLinkingDependenciesMacro ( module );\r
+       string libsMacro = GetLibsMacro ( module );\r
+\r
+       GenerateImportLibraryTargetIfNeeded ( module, clean_files );\r
 \r
-       GenerateImportLibraryTargetIfNeeded ( module );\r
        if ( module.files.size () > 0 )\r
        {\r
-               GenerateMacrosAndTargetsTarget ( module );\r
-       \r
+               GenerateMacrosAndTargetsTarget ( module, clean_files );\r
+\r
                fprintf ( fMakefile, "%s: %s %s\n",\r
                          target.c_str (),\r
                          objectsMacro.c_str (),\r
-                         linkingDependencies.c_str () );\r
+                         linkDepsMacro.c_str () );\r
 \r
                string linker;\r
                if ( IsCPlusPlusModule ( module ) )\r
@@ -1747,7 +1926,9 @@ MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ( const Module& module
                GenerateLinkerCommand ( module,\r
                                        linker,\r
                                        linkerParameters,\r
-                                       objectsMacro );\r
+                                       objectsMacro,\r
+                                       libsMacro,\r
+                                       clean_files );\r
        }\r
        else\r
        {\r
@@ -1767,32 +1948,33 @@ MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler ()
 }\r
 \r
 void\r
-MingwWin32CUIModuleHandler::Process ( const Module& module )\r
+MingwWin32CUIModuleHandler::Process ( const Module& module, string_list& clean_files )\r
 {\r
        GeneratePreconditionDependencies ( module );\r
-       GenerateWin32CUIModuleTarget ( module );\r
+       GenerateWin32CUIModuleTarget ( module, clean_files );\r
        GenerateInvocations ( module );\r
 }\r
 \r
 void\r
-MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ( const Module& module )\r
+MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ( const Module& module, string_list& clean_files )\r
 {\r
        static string ros_junk ( "$(ROS_TEMPORARY)" );\r
        string target ( FixupTargetFilename ( module.GetPath () ) );\r
        string workingDirectory = GetWorkingDirectory ( );\r
        string objectsMacro = GetObjectsMacro ( module );\r
-       string importLibraryDependencies = GetImportLibraryDependencies ( module );\r
+       string linkDepsMacro = GetLinkingDependenciesMacro ( module );\r
+       string libsMacro = GetLibsMacro ( module );\r
 \r
-       GenerateImportLibraryTargetIfNeeded ( module );\r
+       GenerateImportLibraryTargetIfNeeded ( module, clean_files );\r
 \r
        if ( module.files.size () > 0 )\r
        {\r
-               GenerateMacrosAndTargetsTarget ( module );\r
+               GenerateMacrosAndTargetsTarget ( module, clean_files );\r
 \r
                fprintf ( fMakefile, "%s: %s %s\n",\r
                          target.c_str (),\r
                          objectsMacro.c_str (),\r
-                         importLibraryDependencies.c_str () );\r
+                         linkDepsMacro.c_str () );\r
 \r
                string linker;\r
                if ( IsCPlusPlusModule ( module ) )\r
@@ -1806,7 +1988,9 @@ MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ( const Module& module
                GenerateLinkerCommand ( module,\r
                                        linker,\r
                                        linkerParameters,\r
-                                       objectsMacro );\r
+                                       objectsMacro,\r
+                                       libsMacro,\r
+                                       clean_files );\r
        }\r
        else\r
        {\r
@@ -1826,32 +2010,33 @@ MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler ()
 }\r
 \r
 void\r
-MingwWin32GUIModuleHandler::Process ( const Module& module )\r
+MingwWin32GUIModuleHandler::Process ( const Module& module, string_list& clean_files )\r
 {\r
        GeneratePreconditionDependencies ( module );\r
-       GenerateWin32GUIModuleTarget ( module );\r
+       GenerateWin32GUIModuleTarget ( module, clean_files );\r
        GenerateInvocations ( module );\r
 }\r
 \r
 void\r
-MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ( const Module& module )\r
+MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ( const Module& module, string_list& clean_files )\r
 {\r
        static string ros_junk ( "$(ROS_TEMPORARY)" );\r
        string target ( FixupTargetFilename ( module.GetPath () ) );\r
        string workingDirectory = GetWorkingDirectory ( );\r
        string objectsMacro = GetObjectsMacro ( module );\r
-       string importLibraryDependencies = GetImportLibraryDependencies ( module );\r
+       string linkDepsMacro = GetLinkingDependenciesMacro ( module );\r
+       string libsMacro = GetLibsMacro ( module );\r
 \r
-       GenerateImportLibraryTargetIfNeeded ( module );\r
+       GenerateImportLibraryTargetIfNeeded ( module, clean_files );\r
 \r
        if ( module.files.size () > 0 )\r
        {\r
-               GenerateMacrosAndTargetsTarget ( module );\r
+               GenerateMacrosAndTargetsTarget ( module, clean_files );\r
 \r
                fprintf ( fMakefile, "%s: %s %s\n",\r
                          target.c_str (),\r
                          objectsMacro.c_str (),\r
-                         importLibraryDependencies.c_str () );\r
+                         linkDepsMacro.c_str () );\r
 \r
                string linker;\r
                if ( IsCPlusPlusModule ( module ) )\r
@@ -1865,7 +2050,9 @@ MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ( const Module& module
                GenerateLinkerCommand ( module,\r
                                        linker,\r
                                        linkerParameters,\r
-                                       objectsMacro );\r
+                                       objectsMacro,\r
+                                       libsMacro,\r
+                                       clean_files );\r
        }\r
        else\r
        {\r
@@ -1885,43 +2072,49 @@ MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler ()
 }\r
 \r
 void\r
-MingwBootLoaderModuleHandler::Process ( const Module& module )\r
+MingwBootLoaderModuleHandler::Process ( const Module& module, string_list& clean_files )\r
 {\r
        GeneratePreconditionDependencies ( module );\r
-       GenerateBootLoaderModuleTarget ( module );\r
+       GenerateBootLoaderModuleTarget ( module, clean_files );\r
        GenerateInvocations ( module );\r
 }\r
 \r
 void\r
-MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ( const Module& module )\r
+MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget (\r
+       const Module& module,\r
+       string_list& clean_files )\r
 {\r
        static string ros_junk ( "$(ROS_TEMPORARY)" );\r
        string targetName ( module.GetTargetName () );\r
        string target ( FixupTargetFilename ( module.GetPath () ) );\r
        string workingDirectory = GetWorkingDirectory ();\r
        string junk_tmp = ros_junk + module.name + ".junk.tmp";\r
+       CLEAN_FILE ( junk_tmp );\r
        string objectsMacro = GetObjectsMacro ( module );\r
-       string importLibraryDependencies = GetImportLibraryDependencies ( module );\r
+       string linkDepsMacro = GetLinkingDependenciesMacro ( module );\r
+       string libsMacro = GetLibsMacro ( module );\r
 \r
-       GenerateMacrosAndTargetsTarget ( module );\r
+       GenerateMacrosAndTargetsTarget ( module, clean_files );\r
 \r
        fprintf ( fMakefile, "%s: %s %s\n",\r
                  target.c_str (),\r
                  objectsMacro.c_str (),\r
-                 importLibraryDependencies.c_str () );\r
+                 linkDepsMacro.c_str () );\r
+\r
+       fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [LD]      $@\n" );\r
 \r
        fprintf ( fMakefile,\r
                  "\t${ld} %s -N -Ttext=0x8000 -o %s %s %s\n",\r
                  GetLinkerMacro ( module ).c_str (),\r
                  junk_tmp.c_str (),\r
                  objectsMacro.c_str (),\r
-                 importLibraryDependencies.c_str () );\r
+                 linkDepsMacro.c_str () );\r
        fprintf ( fMakefile,\r
                  "\t${objcopy} -O binary %s %s\n",\r
                  junk_tmp.c_str (),\r
                  target.c_str () );\r
        fprintf ( fMakefile,\r
-                 "\t${rm} %s\n",\r
+                 "\t-@${rm} %s\n",\r
                  junk_tmp.c_str () );\r
 }\r
 \r
@@ -1934,22 +2127,23 @@ MingwBootSectorModuleHandler::MingwBootSectorModuleHandler ()
 }\r
 \r
 void\r
-MingwBootSectorModuleHandler::Process ( const Module& module )\r
+MingwBootSectorModuleHandler::Process ( const Module& module, string_list& clean_files )\r
 {\r
        GeneratePreconditionDependencies ( module );\r
-       GenerateBootSectorModuleTarget ( module );\r
+       GenerateBootSectorModuleTarget ( module, clean_files );\r
        GenerateInvocations ( module );\r
 }\r
 \r
 void\r
-MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ( const Module& module )\r
+MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget ( const Module& module, string_list& clean_files )\r
 {\r
        string objectsMacro = GetObjectsMacro ( module );\r
 \r
        string* nasmflags = new string ( "-f bin" );\r
        GenerateMacrosAndTargetsTarget ( module,\r
                                         NULL,\r
-                                        nasmflags);\r
+                                        nasmflags,\r
+                                        clean_files );\r
 \r
        fprintf ( fMakefile, ".PHONY: %s\n\n",\r
                      module.name.c_str ());\r
@@ -1968,10 +2162,10 @@ MingwIsoModuleHandler::MingwIsoModuleHandler ()
 }\r
 \r
 void\r
-MingwIsoModuleHandler::Process ( const Module& module )\r
+MingwIsoModuleHandler::Process ( const Module& module, string_list& clean_files )\r
 {\r
        GeneratePreconditionDependencies ( module );\r
-       GenerateIsoModuleTarget ( module );\r
+       GenerateIsoModuleTarget ( module, clean_files );\r
        GenerateInvocations ( module );\r
 }\r
 \r
@@ -2101,7 +2295,7 @@ MingwIsoModuleHandler::GetCdFiles ( const string bootcdDirectory,
 }\r
 \r
 void\r
-MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module )\r
+MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module, string_list& clean_files )\r
 {\r
        string bootcdDirectory = "cd";\r
        string isoboot = FixupTargetFilename ( "boot/freeldr/bootsect/isoboot.o" );\r
@@ -2123,6 +2317,7 @@ MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module )
                  isoboot.c_str (),\r
                  cdDirectories.c_str (),\r
                  cdFiles.c_str () );\r
+       fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [CABMAN]  $<\n" );\r
        fprintf ( fMakefile,\r
                  "\t${cabman} -C %s -L %s -I\n",\r
                  reactosDff.c_str (),\r
@@ -2133,12 +2328,13 @@ MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module )
                  reactosInf.c_str (),\r
                  bootcdReactos.c_str () );\r
        fprintf ( fMakefile,\r
-                 "\t- ${rm} %s\n",\r
+                 "\t-@${rm} %s\n",\r
                  reactosInf.c_str () );\r
        OutputBootstrapfileCopyCommands ( bootcdDirectory,\r
                                          module );\r
        OutputCdfileCopyCommands ( bootcdDirectory,\r
                                   module );\r
+       fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [CDMAKE]  $@\n" );\r
        fprintf ( fMakefile,\r
                  "\t${cdmake} -v -m -b %s %s REACTOS ReactOS.iso\n",\r
                  isoboot.c_str (),\r