support for <if> tag
.PHONY must be output before the target gets defined
Modified: branches/xmlbuildsystem/reactos/ReactOS.xml
Modified: branches/xmlbuildsystem/reactos/ntoskrnl/ntoskrnl.xml
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/rbuild/module.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h

Modified: branches/xmlbuildsystem/reactos/ReactOS.xml
--- branches/xmlbuildsystem/reactos/ReactOS.xml	2005-01-12 05:01:49 UTC (rev 12943)
+++ branches/xmlbuildsystem/reactos/ReactOS.xml	2005-01-12 06:02:58 UTC (rev 12944)
@@ -6,9 +6,18 @@
 			<xi:include href="config.template.xml" />
 		</xi:fallback>
 	</xi:include>
+
 	<define name="_M_IX86" />
+	<if property="dbg" value="true">
+		<define name="dbg_or_kdbg" value="true" />
+	</if>
+	<if property="kdbg" value="true">
+		<define name="dbg_or_kdbg" value="true" />
+	</if>
+
 	<include>include</include>
 	<include>w32api/include</include>
+
 	<directory name="tools">
 		<xi:include href="tools/tools.xml" />
 	</directory>

Modified: branches/xmlbuildsystem/reactos/ntoskrnl/ntoskrnl.xml
--- branches/xmlbuildsystem/reactos/ntoskrnl/ntoskrnl.xml	2005-01-12 05:01:49 UTC (rev 12943)
+++ branches/xmlbuildsystem/reactos/ntoskrnl/ntoskrnl.xml	2005-01-12 06:02:58 UTC (rev 12944)
@@ -41,10 +41,9 @@
 		<file>rtlfunc.c</file>
 	</directory>
 	<directory name="dbg">
-		<!--
 		<if property="arch" value="i386">
 			<directory name="i386">
-				<if property="kdbg" value="true">
+				<if property="kdbg" value="1">
 					<group>
 						<file>i386-dis.c</file>
 						<file>kdb_help.S</file>
@@ -52,36 +51,17 @@
 				</if>
 			</directory>
 		</if>
-		-->
-		<!--
-		<if property="kdbg" value="true">
-			<group>
-				<file>kdb.c</file>
-				<file>kdb_keyboard.c</file>
-				<file>kdb_serial.c</file>
-				<file>rdebug.c</file>
-				<file>profile.c</file>
-			</group>
+		<if property="kdbg" value="1">
+			<file>kdb.c</file>
+			<file>kdb_keyboard.c</file>
+			<file>kdb_serial.c</file>
+			<file>rdebug.c</file>
+			<file>profile.c</file>
 		</if>
-		-->
-		<or>
-			<!--
-			<if property="kdbg" value="true">
-				<group>
-					<file>kdb_stabs.c</file>
-					<file>kdb_symbols.c</file>
-				</group>
-			</if>
-			-->
-			<!--
-			<if property="dbg" value="true">
-				<group>
-					<file>kdb_stabs.c</file>
-					<file>kdb_symbols.c</file>
-				</group>
-			</if>
-			-->
-		</or>
+		<if property="dbg_or_kdbg" value="true">
+			<file>kdb_stabs.c</file>
+			<file>kdb_symbols.c</file>
+		</if>
 		<file>dbgctrl.c</file>
 		<file>errinfo.c</file>
 		<file>print.c</file>

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-01-12 05:01:49 UTC (rev 12943)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-01-12 06:02:58 UTC (rev 12944)
@@ -237,12 +237,14 @@
 void
 MingwModuleHandler::GenerateGccModuleIncludeVariable ( const Module& module ) const
 {
+#if 0
 	string name ( module.name + "_CFLAGS" );
 	fprintf ( fMakefile,
 	          "%s := %s %s\n",
 	          name.c_str(),
-			  GenerateGccDefineParameters(module).c_str(),
+	          GenerateGccDefineParameters(module).c_str(),
 	          GenerateGccIncludeParameters(module).c_str() );
+#endif
 }
 
 string
@@ -258,73 +260,174 @@
 	return parameters;
 }
 
-string
-MingwModuleHandler::GenerateGccParameters ( const Module& module ) const
+void
+MingwModuleHandler::GenerateMacros (
+	const Module& module,
+	const char* op,
+	const vector<File*>& files,
+	const vector<Include*>* includes,
+	const vector<Define*>& defines,
+	const string& cflags_macro,
+	const string& nasmflags_macro,
+	const string& objs_macro) const
 {
-	return ssprintf(" $(%s_CFLAGS)", module.name.c_str());
+	size_t i;
+
+	if ( (includes && includes->size()) || defines.size() )
+	{
+		fprintf (
+			fMakefile,
+			"%s %s",
+			cflags_macro.c_str(),
+			op );
+		if ( includes )
+			for ( i = 0; i < includes->size(); i++ )
+				fprintf (
+					fMakefile,
+					" -I%s",
+					(*includes)[i]->directory.c_str() );
+		for ( i = 0; i < module.defines.size(); i++ )
+		{
+			Define& d = *module.defines[i];
+			fprintf (
+				fMakefile,
+				" -D%s",
+				d.name.c_str() );
+			if ( d.value.size() )
+				fprintf (
+					fMakefile,
+					"=%s",
+					d.value.c_str() );
+		}
+		fprintf ( fMakefile, "\n" );
+	}
+
+	if ( files.size() )
+	{
+		fprintf (
+			fMakefile,
+			"%s %s",
+			objs_macro.c_str(),
+			op );
+		for ( i = 0; i < files.size(); i++ )
+		{
+			fprintf (
+				fMakefile,
+				"%s%s",
+				( i%10 == 9 ? "\\\n\t" : " " ),
+				GetObjectFilename(files[i]->name).c_str() );
+		}
+		fprintf ( fMakefile, "\n" );
+	}
 }
 
-string
-MingwModuleHandler::GenerateNasmParameters ( const Module& module ) const
+void
+MingwModuleHandler::GenerateMacros (
+	const Module& module,
+	const string& cflags_macro,
+	const string& nasmflags_macro,
+	const string& objs_macro) const
 {
-	return "";
+	GenerateMacros (
+		module,
+		"=",
+		module.files,
+		&module.includes,
+		module.defines,
+		cflags_macro,
+		nasmflags_macro,
+		objs_macro );
+	fprintf ( fMakefile, "\n" );
+
+	for ( size_t i = 0; i < module.ifs.size(); i++ )
+	{
+		If& rIf = *module.ifs[i];
+		if ( rIf.defines.size() || rIf.files.size() )
+		{
+			fprintf (
+				fMakefile,
+				"ifeq ($(%s),\"%s\")\n",
+				rIf.property.c_str(),
+				rIf.value.c_str() );
+			GenerateMacros (
+				module,
+				"+=",
+				rIf.files,
+				NULL,
+				rIf.defines,
+				cflags_macro,
+				nasmflags_macro,
+				objs_macro );
+			fprintf ( 
+				fMakefile,
+				"endif\n\n" );
+		}
+	}
 }
 
 string
 MingwModuleHandler::GenerateGccCommand ( const Module& module,
-	                                     const string& sourceFilename,
-	                                     const string& cc ) const
+                                         const string& sourceFilename,
+                                         const string& cc,
+                                         const string& cflagsMacro ) const
 {
 	string objectFilename = GetObjectFilename ( sourceFilename );
 	return ssprintf ( "%s -c %s -o %s %s\n",
 		              cc.c_str (),
 		              sourceFilename.c_str (),
 		              objectFilename.c_str (),
-		              GenerateGccParameters ( module ).c_str () );
+		              cflagsMacro.c_str () );
 }
 
 string
 MingwModuleHandler::GenerateGccAssemblerCommand ( const Module& module,
-	                                              const string& sourceFilename,
-	                                              const string& cc ) const
+                                                  const string& sourceFilename,
+                                                  const string& cc,
+                                                  const string& cflagsMacro ) const
 {
 	string objectFilename = GetObjectFilename ( sourceFilename );
 	return ssprintf ( "%s -x assembler-with-cpp -c %s -o %s -D__ASM__ %s\n",
-		              cc.c_str (),
-		              sourceFilename.c_str (),
-		              objectFilename.c_str (),
-		              GenerateGccParameters ( module ).c_str () );
+	                  cc.c_str (),
+	                  sourceFilename.c_str (),
+	                  objectFilename.c_str (),
+	                  cflagsMacro.c_str () );
 }
 
 string
 MingwModuleHandler::GenerateNasmCommand ( const Module& module,
-	                                      const string& sourceFilename ) const
+                                          const string& sourceFilename,
+                                          const string& nasmflagsMacro ) const
 {
 	string objectFilename = GetObjectFilename ( sourceFilename );
 	return ssprintf ( "%s -f win32 %s -o %s %s\n",
 		              "nasm",
 		              sourceFilename.c_str (),
 		              objectFilename.c_str (),
-		              GenerateNasmParameters ( module ).c_str () );
+		              nasmflagsMacro.c_str () );
 }
 
 string
 MingwModuleHandler::GenerateCommand ( const Module& module,
-	                                  const string& sourceFilename,
-	                                  const string& cc ) const
+                                      const string& sourceFilename,
+                                      const string& cc,
+                                      const string& cflagsMacro,
+                                      const string& nasmflagsMacro ) const
 {
 	string extension = GetExtension ( sourceFilename );
 	if ( extension == ".c" || extension == ".C" )
 		return GenerateGccCommand ( module,
 		                            sourceFilename,
-		                            cc );
+		                            cc,
+		                            cflagsMacro );
 	else if ( extension == ".s" || extension == ".S" )
 		return GenerateGccAssemblerCommand ( module,
 		                                     sourceFilename,
-		                                     cc );
+		                                     cc,
+		                                     cflagsMacro );
 	else if ( extension == ".asm" || extension == ".ASM" )
 		return GenerateNasmCommand ( module,
-		                             sourceFilename );
+		                             sourceFilename,
+		                             nasmflagsMacro );
 
 	throw InvalidOperationException ( __FILE__,
 	                                  __LINE__,
@@ -335,16 +438,17 @@
 
 void
 MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
-	                                            const string& cc) const
+                                                const vector<File*>& files,
+                                                const string& cc,
+                                                const string& cflagsMacro,
+                                                const string& nasmflagsMacro ) const
 {
-	if ( module.files.size () == 0 )
+	if ( files.size () == 0 )
 		return;
-	
-	GenerateGccModuleIncludeVariable ( module );
 
-	for ( size_t i = 0; i < module.files.size (); i++ )
+	for ( size_t i = 0; i < files.size (); i++ )
 	{
-		string sourceFilename = module.files[i]->name;
+		string sourceFilename = files[i]->name;
 		string objectFilename = GetObjectFilename ( sourceFilename );
 		fprintf ( fMakefile,
 		          "%s: %s\n",
@@ -354,60 +458,78 @@
 		          "\t%s\n",
 		          GenerateCommand ( module,
 		                            sourceFilename,
-		                            cc ).c_str () );
+		                            cc,
+		                            cflagsMacro,
+		                            nasmflagsMacro ).c_str () );
 	}
 	
 	fprintf ( fMakefile, "\n" );
 }
 
 void
-MingwModuleHandler::GenerateObjectFileTargetsHost ( const Module& module ) const
+MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
+                                                const string& cc,
+                                                const string& cflagsMacro,
+                                                const string& nasmflagsMacro ) const
 {
-	GenerateObjectFileTargets ( module,
-	                            "${host_gcc}" );
+	GenerateObjectFileTargets ( module, module.files, cc, cflagsMacro, nasmflagsMacro );
+	for ( size_t i = 0; i < module.ifs.size(); i++ )
+		GenerateObjectFileTargets ( module, module.ifs[i]->files, cc, cflagsMacro, nasmflagsMacro );
 }
 
 void
-MingwModuleHandler::GenerateObjectFileTargetsTarget ( const Module& module ) const
-{
-	GenerateObjectFileTargets ( module,
-	                            "${gcc}" );
-}
-
-void
 MingwModuleHandler::GenerateArchiveTarget ( const Module& module,
-	                                        const string& ar ) const
+                                            const string& ar,
+                                            const string& objs_macro ) const
 {
 	string archiveFilename = GetModuleArchiveFilename ( module );
 	string sourceFilenames = GetSourceFilenames ( module );
-	string objectsMacro = GenerateObjectList ( module );
 	
 	fprintf ( fMakefile,
 	          "%s: %s\n",
 	          archiveFilename.c_str (),
-	          objectsMacro.c_str ());
+	          objs_macro.c_str ());
 
 	fprintf ( fMakefile,
 	          "\t%s -rc %s %s\n\n",
 	          ar.c_str (),
 	          archiveFilename.c_str (),
-	          objectsMacro.c_str ());
+	          objs_macro.c_str ());
 }
 
 void
-MingwModuleHandler::GenerateArchiveTargetHost ( const Module& module ) const
+MingwModuleHandler::GenerateMacrosAndTargets (
+	const Module& module,
+	const string& cc,
+	const string& ar ) const
 {
-	GenerateArchiveTarget ( module,
-	                        "${host_ar}" );
+	string cflagsMacro = ssprintf("%s_CFLAGS",module.name.c_str());
+	string nasmflagsMacro = ssprintf("%s_NASMFLAGS",module.name.c_str());
+	string objectsMacro = ssprintf("%s_OBJS",module.name.c_str());
+
+	GenerateMacros ( module, cflagsMacro, nasmflagsMacro, objectsMacro );
+
+	// 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());
+
+	GenerateArchiveTarget ( module, ar, objectsMacro );
+	GenerateObjectFileTargets ( module, cc, cflagsMacro, nasmflagsMacro );
 }
 
 void
-MingwModuleHandler::GenerateArchiveTargetTarget ( const Module& module ) const
+MingwModuleHandler::GenerateMacrosAndTargetsHost ( const Module& module ) const
 {
-	GenerateArchiveTarget ( module,
-	                        "${ar}" );
+	GenerateMacrosAndTargets ( module, "${host_gcc}", "${host_ar}" );
 }
 
+void
+MingwModuleHandler::GenerateMacrosAndTargetsTarget ( const Module& module ) const
+{
+	GenerateMacrosAndTargets ( module, "${gcc}", "${ar}" );
+}
+
 string
 MingwModuleHandler::GetInvocationDependencies ( const Module& module ) const
 {
@@ -514,30 +636,39 @@
 	}
 	
 	fprintf ( fMakefile,
+	          ".PHONY: %s\n\n",
+	          preconditionDependenciesName.c_str () );
+	fprintf ( fMakefile,
 	          "%s: %s\n\n",
 	          preconditionDependenciesName.c_str (),
 	          dependencies.c_str () );
-	fprintf ( fMakefile,
-	          "%s: %s\n\n",
-	          sourceFilenames.c_str (),
-	          preconditionDependenciesName.c_str ());
-	fprintf ( fMakefile,
-	          ".PHONY: %s\n\n",
-	          preconditionDependenciesName.c_str () );
+	const char* p = sourceFilenames.c_str();
+	const char* end = p + strlen(p);
+	while ( p < end )
+	{
+		const char* p2 = &p[512];
+		if ( p2 > end )
+			p2 = end;
+		while ( p2 > p && !isspace(*p2) )
+			--p2;
+		if ( p == p2 )
+		{
+			p2 = strpbrk ( p, " \t" );
+			if ( !p2 )
+				p2 = end;
+		}
+		fprintf ( fMakefile,
+				  "%.*s: %s\n",
+				  p2-p,
+				  p,
+				  preconditionDependenciesName.c_str ());
+		p = p2;
+		p += strspn ( p, " \t" );
+	}
+	fprintf ( fMakefile, "\n" );
 }
 
-string MingwModuleHandler::GenerateObjectList ( const Module& module ) const
-{
-	string macro ( ssprintf("%s_OBJS",module.name.c_str()) );
-	fprintf (
-		fMakefile,
-		"%s = %s\n",
-		macro.c_str(),
-		GetObjectFilenames(module).c_str() );
-	return ssprintf("$(%s)",macro.c_str());
-}
 
-
 static MingwBuildToolModuleHandler buildtool_handler;
 
 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler()
@@ -562,11 +693,10 @@
 	          target.c_str (),
 	          archiveFilename.c_str () );
 	fprintf ( fMakefile,
-	          "\t${host_gcc} -o %s %s\n",
+	          "\t${host_gcc} -o %s %s\n\n",
 	          target.c_str (),
 	          archiveFilename.c_str () );
-	GenerateArchiveTargetHost ( module );
-	GenerateObjectFileTargetsHost ( module );
+	GenerateMacrosAndTargetsHost ( module );
 }
 
 static MingwKernelModuleHandler kernelmodule_handler;
@@ -628,11 +758,10 @@
 	          archiveFilename.c_str (),
 	          importLibraryDependencies.c_str () );
 	fprintf ( fMakefile,
-	          "\t${rm} %s\n",
+	          "\t${rm} %s\n\n",
 	          temp_exp.c_str () );
 	
-	GenerateArchiveTargetTarget ( module );
-	GenerateObjectFileTargetsTarget ( module );
+	GenerateMacrosAndTargetsTarget ( module );
 }
 
 
@@ -654,8 +783,7 @@
 void
 MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Module& module )
 {
-	GenerateArchiveTargetTarget ( module );
-	GenerateObjectFileTargetsTarget ( module );
+	GenerateMacrosAndTargetsTarget ( module );
 }
 
 
@@ -703,17 +831,16 @@
 		          importLibraryDependencies.c_str () );
 	
 		fprintf ( fMakefile,
-		          "\t${gcc} -Wl,--subsystem,native -Wl,--entry,_DriverEntry@8 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll -o %s %s %s\n",
+		          "\t${gcc} -Wl,--subsystem,native -Wl,--entry,_DriverEntry@8 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll -o %s %s %s\n\n",
 		          target.c_str (),
 		          archiveFilename.c_str (),
 		          importLibraryDependencies.c_str () );
 		
-		GenerateArchiveTargetTarget ( module );
-		GenerateObjectFileTargetsTarget ( module );
+		GenerateMacrosAndTargetsTarget ( module );
 	}
 	else
 	{
-		fprintf ( fMakefile, "%s:\n\n",
+		fprintf ( fMakefile, "%s:\n",
 		          target.c_str ());
 		fprintf ( fMakefile, ".PHONY: %s\n\n",
 		          target.c_str ());
@@ -765,13 +892,12 @@
 		          importLibraryDependencies.c_str () );
 	
 		fprintf ( fMakefile,
-		          "\t${gcc} -Wl,--subsystem,native -Wl,--entry,_DllMainCRTStartup@12 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll -o %s %s %s\n",
+		          "\t${gcc} -Wl,--subsystem,native -Wl,--entry,_DllMainCRTStartup@12 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -nostdlib -mdll -o %s %s %s\n\n",
 		          target.c_str (),
 		          archiveFilename.c_str (),
 		          importLibraryDependencies.c_str () );
 		
-		GenerateArchiveTargetTarget ( module );
-		GenerateObjectFileTargetsTarget ( module );
+		GenerateMacrosAndTargetsTarget ( module );
 	}
 	else
 	{

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h	2005-01-12 05:01:49 UTC (rev 12943)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h	2005-01-12 06:02:58 UTC (rev 12944)
@@ -30,15 +30,15 @@
 
 	std::string GetObjectFilename ( const std::string& sourceFilename ) const;
 	std::string GetObjectFilenames ( const Module& module ) const;
-	void GenerateObjectFileTargetsHost ( const Module& module ) const;
-	void GenerateObjectFileTargetsTarget ( const Module& module ) const;
-	void GenerateArchiveTargetHost ( const Module& module ) const;
-	void GenerateArchiveTargetTarget ( const Module& module ) const;
+	void GenerateMacrosAndTargetsHost ( const Module& module ) const;
+	void GenerateMacrosAndTargetsTarget ( const Module& module ) const;
 	std::string GetInvocationDependencies ( const Module& module ) const;
 	std::string GetInvocationParameters ( const Invoke& invoke ) const;
 	void GenerateInvocations ( const Module& module ) const;
 	void GeneratePreconditionDependencies ( const Module& module ) const;
-	std::string GenerateObjectList ( const Module& module ) const;
+	std::string GenerateMacros ( const Module& module,
+	                             const std::string& cflags_macro,
+	                             const std::string& objs_macro ) const;
 	static FILE* fMakefile;
 private:
 	std::string ConcatenatePaths ( const std::string& path1,
@@ -46,25 +46,53 @@
 	std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines ) const;
 	std::string GenerateGccDefineParameters ( const Module& module ) const;
 	std::string GenerateGccIncludeParametersFromVector ( const std::vector<Include*>& includes ) const;
+	void GenerateMacros ( const Module& module,
+	                      const char* op,
+	                      const std::vector<File*>& files,
+	                      const std::vector<Include*>* includes,
+	                      const std::vector<Define*>& defines,
+	                      const std::string& cflags_macro,
+	                      const std::string& nasmflags_macro,
+	                      const std::string& objs_macro) const;
+	void GenerateMacros ( const Module& module,
+	                      const std::string& cflags_macro,
+	                      const std::string& nasmflags_macro,
+	                      const std::string& objs_macro) const;
 	void GenerateGccModuleIncludeVariable ( const Module& module ) const;
 	std::string GenerateGccIncludeParameters ( const Module& module ) const;
 	std::string GenerateGccParameters ( const Module& module ) const;
 	std::string GenerateNasmParameters ( const Module& module ) const;
 	std::string GenerateGccCommand ( const Module& module,
 	                                 const std::string& sourceFilename,
-	                                 const std::string& cc ) const;
+	                                 const std::string& cc,
+	                                 const std::string& cflagsMacro ) const;
 	std::string GenerateGccAssemblerCommand ( const Module& module,
 	                                          const std::string& sourceFilename,
-	                                          const std::string& cc ) const;
+	                                          const std::string& cc,
+	                                          const std::string& cflagsMacro ) const;
 	std::string GenerateNasmCommand ( const Module& module,
-	                                  const std::string& sourceFilename ) const;
+	                                  const std::string& sourceFilename,
+	                                  const std::string& nasmflagsMacro ) const;
 	std::string GenerateCommand ( const Module& module,
 	                              const std::string& sourceFilename,
-	                              const std::string& cc ) const;
+	                              const std::string& cc,
+	                              const std::string& cflagsMacro,
+	                              const std::string& nasmflagsMacro ) const;
 	void GenerateObjectFileTargets ( const Module& module,
-	                                 const std::string& cc ) const;
+	                                 const std::vector<File*>& files,
+	                                 const std::string& cc,
+	                                 const std::string& cflagsMacro,
+	                                 const std::string& nasmflagsMacro ) const;
+	void GenerateObjectFileTargets ( const Module& module,
+	                                 const std::string& cc,
+	                                 const std::string& cflagsMacro,
+	                                 const std::string& nasmflagsMacro ) const;
 	void GenerateArchiveTarget ( const Module& module,
-	                             const std::string& ar ) const;
+	                             const std::string& ar,
+	                             const std::string& objs_macro ) const;
+	void GenerateMacrosAndTargets ( const Module& module,
+	                                const std::string& cc,
+	                                const std::string& ar ) const;
 	std::string GetPreconditionDependenciesName ( const Module& module ) const;
 };
 

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp	2005-01-12 05:01:49 UTC (rev 12943)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp	2005-01-12 06:02:58 UTC (rev 12944)
@@ -63,6 +63,8 @@
 		delete invocations[i];
 	for ( i = 0; i < dependencies.size(); i++ )
 		delete dependencies[i];
+	for ( i = 0; i < ifs.size(); i++ )
+		delete ifs[i];
 }
 
 void
@@ -83,21 +85,32 @@
 		invocations[i]->ProcessXML ();
 	for ( i = 0; i < dependencies.size(); i++ )
 		dependencies[i]->ProcessXML ();
+	for ( i = 0; i < ifs.size(); i++ )
+		ifs[i]->ProcessXML();
 }
 
 void
 Module::ProcessXMLSubElement ( const XMLElement& e,
-                               const string& path )
+                               const string& path,
+                               If* pIf /*= NULL*/ )
 {
 	bool subs_invalid = false;
 	string subpath ( path );
 	if ( e.name == "file" && e.value.size () > 0 )
 	{
-		files.push_back ( new File ( FixSeparator ( path + CSEP + e.value ) ) );
+		File* pFile = new File ( FixSeparator ( path + CSEP + e.value ) );
+		if ( pIf )
+			pIf->files.push_back ( pFile );
+		else
+			files.push_back ( pFile );
 		subs_invalid = true;
 	}
 	else if ( e.name == "library" && e.value.size () )
 	{
+		if ( pIf )
+			throw InvalidBuildFileException (
+				e.location,
+				"<library> is not a valid sub-element of <if>" );
 		libraries.push_back ( new Library ( e, *this, e.value ) );
 		subs_invalid = true;
 	}
@@ -109,36 +122,66 @@
 	}
 	else if ( e.name == "include" )
 	{
+		if ( pIf )
+			throw InvalidBuildFileException (
+				e.location,
+				"<include> is not a valid sub-element of <if>" );
 		includes.push_back ( new Include ( project, this, e ) );
 		subs_invalid = true;
 	}
 	else if ( e.name == "define" )
 	{
-		defines.push_back ( new Define ( project, this, e ) );
+		Define* pDefine = new Define ( project, this, e );
+		if ( pIf )
+			pIf->defines.push_back ( pDefine );
+		else
+			defines.push_back ( pDefine );
 		subs_invalid = true;
 	}
 	else if ( e.name == "invoke" )
 	{
+		if ( pIf )
+			throw InvalidBuildFileException (
+				e.location,
+				"<invoke> is not a valid sub-element of <if>" );
 		invocations.push_back ( new Invoke ( e, *this ) );
 		subs_invalid = false;
 	}
 	else if ( e.name == "dependency" )
 	{
+		if ( pIf )
+			throw InvalidBuildFileException (
+				e.location,
+				"<dependency> is not a valid sub-element of <if>" );
 		dependencies.push_back ( new Dependency ( e, *this ) );
 		subs_invalid = true;
 	}
 	else if ( e.name == "importlibrary" )
 	{
+		if ( pIf )
+			throw InvalidBuildFileException (
+				e.location,
+				"<importlibrary> is not a valid sub-element of <if>" );
+		if ( importLibrary )
+			throw InvalidBuildFileException (
+				e.location,
+				"Only one <importlibrary> is valid per module" );
 		importLibrary = new ImportLibrary ( e, *this );
 		subs_invalid = true;
 	}
+	else if ( e.name == "if" )
+	{
+		pIf = new If ( e, *this );
+		ifs.push_back ( pIf );
+		subs_invalid = false;
+	}
 	if ( subs_invalid && e.subElements.size() > 0 )
 		throw InvalidBuildFileException (
 			e.location,
 			"<%s> cannot have sub-elements",
 			e.name.c_str() );
 	for ( size_t i = 0; i < e.subElements.size (); i++ )
-		ProcessXMLSubElement ( *e.subElements[i], subpath );
+		ProcessXMLSubElement ( *e.subElements[i], subpath, pIf );
 }
 
 ModuleType
@@ -188,14 +231,23 @@
 string
 Module::GetDependencyPath () const
 {
-	if ( type == KernelModeDLL )
+	switch ( type )
+	{
+	case KernelModeDLL:
 		return ssprintf ( "dk%snkm%slib%slib%s.a",
 		                  SSEP,
 		                  SSEP,
 		                  SSEP,
 		                  name.c_str () );
-	else
-		return GetPath ();
+	case NativeDLL:
+		return ssprintf ( "dk%sw32%slib%slib%s.a",
+		                  SSEP,
+		                  SSEP,
+		                  SSEP,
+		                  name.c_str () );
+	default:
+		return GetPath();
+	}
 }
 
 string
@@ -425,5 +477,36 @@
 
 	att = _node.GetAttribute ( "definition", true );
 	assert (att);
-	definition = att->value;
+	definition = FixSeparator(att->value);
 }
+
+
+If::If ( const XMLElement& node_, const Module& module_ )
+	: node(node_), module(module_)
+{
+	const XMLAttribute* att;
+
+	att = node.GetAttribute ( "property", true );
+	assert(att);
+	property = att->value;
+
+	att = node.GetAttribute ( "value", true );
+	assert(att);
+	value = att->value;
+}
+
+If::~If ()
+{
+	size_t i;
+	for ( i = 0; i < files.size(); i++ )
+		delete files[i];
+	for ( i = 0; i < defines.size(); i++ )
+		delete defines[i];
+	for ( i = 0; i < ifs.size(); i++ )
+		delete ifs[i];
+}
+
+void
+If::ProcessXML()
+{
+}

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h	2005-01-12 05:01:49 UTC (rev 12943)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h	2005-01-12 06:02:58 UTC (rev 12944)
@@ -31,6 +31,7 @@
 class InvokeFile;
 class Dependency;
 class ImportLibrary;
+class If;
 
 class Project
 {
@@ -86,6 +87,7 @@
 	std::vector<Define*> defines;
 	std::vector<Invoke*> invocations;
 	std::vector<Dependency*> dependencies;
+	std::vector<If*> ifs;
 
 	Module ( const Project& project,
 	         const XMLElement& moduleNode,
@@ -104,7 +106,8 @@
 private:
 	std::string GetDefaultModuleExtension () const;
 	void ProcessXMLSubElement ( const XMLElement& e,
-	                            const std::string& path );
+	                            const std::string& path,
+	                            If* pIf = NULL );
 };
 
 
@@ -239,6 +242,23 @@
 	void ProcessXML ();
 };
 
+class If
+{
+public:
+	const XMLElement& node;
+	const Module& module;
+	std::string property, value;
+	std::vector<File*> files;
+	std::vector<Define*> defines;
+	std::vector<If*> ifs;
+
+	If ( const XMLElement& node_,
+	     const Module& module_ );
+	~If();
+
+	void ProcessXML();
+};
+
 extern std::string
 FixSeparator ( const std::string& s );