Generate object macros before target macros
Modified: branches/xmlbuildsystem/reactos/tools/cabman/cabman.mak
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h
Modified: branches/xmlbuildsystem/reactos/tools/tools.mak

Modified: branches/xmlbuildsystem/reactos/tools/cabman/cabman.mak
--- branches/xmlbuildsystem/reactos/tools/cabman/cabman.mak	2005-03-25 13:40:33 UTC (rev 14310)
+++ branches/xmlbuildsystem/reactos/tools/cabman/cabman.mak	2005-03-25 14:31:00 UTC (rev 14311)
@@ -38,7 +38,7 @@
 .PHONY: cabman
 cabman: $(CABMAN_TARGET)
 
-$(CABMAN_TARGET): $(CABMAN_OBJECTS) $(CABMAN_HOST_LIBS) $(CABMAN_OUT)
+$(CABMAN_TARGET1): $(CABMAN_OBJECTS) $(CABMAN_HOST_LIBS) $(CABMAN_OUT)
 	$(ECHO_LD)
 	${host_gpp} $(CABMAN_OBJECTS) $(CABMAN_HOST_LFLAGS) -o $@
 

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp	2005-03-25 13:40:33 UTC (rev 14310)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp	2005-03-25 14:31:00 UTC (rev 14311)
@@ -142,6 +142,8 @@
 	size_t iend = v.size ();
 
 	for ( i = 0; i < iend; i++ )
+		v[i]->GenerateObjectMacro();
+	for ( i = 0; i < iend; i++ )
 		v[i]->GenerateTargetMacro();
 	fprintf ( fMakefile, "\n" );
 
@@ -419,26 +421,6 @@
 		d.CreateRule ( fMakefile, "" );
 		if ( i ) fprintf ( fMakefile, "endif\n" );
 	}
-	/*if ( directories.size () == 0 )
-		return;
-	
-	set_string::iterator i;
-	for ( i = directories.begin ();
-	      i != directories.end ();
-	      i++ )
-	{
-		if ( IncludeDirectoryTarget ( *i ) )
-		{
-			fprintf ( fMakefile,
-			          "%s: $(RMKDIR_TARGET)\n",
-			          i->c_str () );
-			fprintf ( fMakefile, 
-			          "\t${mkdir} %s\n\n",
-			          i->c_str () );
-		}
-	}
-
-	directories.clear ();*/
 }
 
 string

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-03-25 13:40:33 UTC (rev 14310)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-03-25 14:31:00 UTC (rev 14311)
@@ -614,6 +614,42 @@
 		}
 	}
 
+	const vector<If*>& ifs = data.ifs;
+	for ( i = 0; i < ifs.size(); i++ )
+	{
+		If& rIf = *ifs[i];
+		if ( rIf.data.defines.size()
+			|| rIf.data.includes.size()
+			|| rIf.data.libraries.size()
+			|| rIf.data.files.size()
+			|| rIf.data.ifs.size() )
+		{
+			fprintf (
+				fMakefile,
+				"ifeq (\"$(%s)\",\"%s\")\n",
+				rIf.property.c_str(),
+				rIf.value.c_str() );
+			GenerateMacros (
+				"+=",
+				rIf.data,
+				NULL,
+				NULL );
+			fprintf ( 
+				fMakefile,
+				"endif\n\n" );
+		}
+	}
+}
+
+void
+MingwModuleHandler::GenerateObjectMacros (
+	const char* assignmentOperation,
+	const IfableData& data,
+	const vector<CompilerFlag*>* compilerFlags,
+	const vector<LinkerFlag*>* linkerFlags )
+{
+	size_t i;
+
 	const vector<File*>& files = data.files;
 	if ( files.size () > 0 )
 	{
@@ -666,7 +702,7 @@
 				"ifeq (\"$(%s)\",\"%s\")\n",
 				rIf.property.c_str(),
 				rIf.value.c_str() );
-			GenerateMacros (
+			GenerateObjectMacros (
 				"+=",
 				rIf.data,
 				NULL,
@@ -887,7 +923,7 @@
 	const string& libsMacro )
 {
 	string target ( GetTargetMacro ( module ) );
-	string target_folder ( GetDirectory(GetTargetFilename(module,NULL)) );
+	string target_folder ( GetDirectory ( GetTargetFilename ( module, NULL ) ) );
 
 	fprintf ( fMakefile,
 		"%s: %s %s $(RSYM_TARGET)\n",
@@ -1107,13 +1143,37 @@
 	                  module.name.c_str () );
 }
 
+string
+MingwModuleHandler::GetModuleTargets ( const Module& module )
+{
+	if ( module.type == ObjectLibrary )
+		return GetObjectsMacro ( module );
+	else
+		return GetTargetFilename ( module, NULL );
+}
+
 void
+MingwModuleHandler::GenerateObjectMacro ()
+{
+	objectsMacro = ssprintf ("%s_OBJS", module.name.c_str ());
+
+	GenerateObjectMacros (
+		"=",
+		module.non_if_data,
+		&module.compilerFlags,
+		&module.linkerFlags );
+
+	// future references to the macro will be to get its values
+	objectsMacro = ssprintf ("$(%s)", objectsMacro.c_str ());
+}
+
+void
 MingwModuleHandler::GenerateTargetMacro ()
 {
 	fprintf ( fMakefile,
 		"%s := %s\n",
-		GetTargetMacro(module,false).c_str (),
-		GetTargetFilename(module,NULL).c_str () );
+		GetTargetMacro ( module, false ).c_str (),
+		GetModuleTargets ( module ).c_str () );
 }
 
 void
@@ -1123,7 +1183,6 @@
 	nasmflagsMacro = ssprintf ("%s_NASMFLAGS", module.name.c_str ());
 	windresflagsMacro = ssprintf ("%s_RCFLAGS", module.name.c_str ());
 	linkerflagsMacro = ssprintf ("%s_LFLAGS", module.name.c_str ());
-	objectsMacro = ssprintf ("%s_OBJS", module.name.c_str ());
 	libsMacro = ssprintf("%s_LIBS", module.name.c_str ());
 	linkDepsMacro = ssprintf ("%s_LINKDEPS", module.name.c_str ());
 
@@ -1202,7 +1261,6 @@
 	// future references to the macros will be to get their values
 	cflagsMacro = ssprintf ("$(%s)", cflagsMacro.c_str ());
 	nasmflagsMacro = ssprintf ("$(%s)", nasmflagsMacro.c_str ());
-	objectsMacro = ssprintf ("$(%s)", objectsMacro.c_str ());
 }
 
 void

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h	2005-03-25 13:40:33 UTC (rev 14310)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h	2005-03-25 14:31:00 UTC (rev 14311)
@@ -36,6 +36,8 @@
 		const Module& module,
 		string_list* pclean_files );
 
+	std::string GetModuleTargets ( const Module& module );
+	void GenerateObjectMacro();
 	void GenerateTargetMacro();
 	void GenerateOtherMacros();
 
@@ -101,6 +103,10 @@
 	                      const IfableData& data,
 	                      const std::vector<CompilerFlag*>* compilerFlags,
 	                      const std::vector<LinkerFlag*>* linkerFlags );
+	void GenerateObjectMacros ( const char* assignmentOperation,
+	                            const IfableData& data,
+	                            const std::vector<CompilerFlag*>* compilerFlags,
+	                            const std::vector<LinkerFlag*>* linkerFlags );
 	std::string GenerateGccIncludeParameters () const;
 	std::string GenerateGccParameters () const;
 	std::string GenerateNasmParameters () const;

Modified: branches/xmlbuildsystem/reactos/tools/tools.mak
--- branches/xmlbuildsystem/reactos/tools/tools.mak	2005-03-25 13:40:33 UTC (rev 14310)
+++ branches/xmlbuildsystem/reactos/tools/tools.mak	2005-03-25 14:31:00 UTC (rev 14311)
@@ -5,11 +5,13 @@
 TOOLS_OUT = $(OUTPUT_)$(TOOLS_BASE)
 TOOLS_OUT_ = $(TOOLS_OUT)$(SEP)
 
+.LOW_RESOLUTION_TIME: $(TOOLS_INT)
 $(TOOLS_INT): $(INTERMEDIATE)
 	$(ECHO_MKDIR)
 	${mkdir} $@
 
 ifneq ($(INTERMEDIATE),$(OUTPUT))
+.LOW_RESOLUTION_TIME: $(TOOLS_OUT)
 $(TOOLS_OUT): $(OUTPUT)
 	$(ECHO_MKDIR)
 	${mkdir} $@