Generate registry hives on 'make install'
Modified: branches/xmlbuildsystem/reactos/Makefile
Added: branches/xmlbuildsystem/reactos/tools/mkhive/mkhive.mak
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
Modified: branches/xmlbuildsystem/reactos/tools/tools.mak

Modified: branches/xmlbuildsystem/reactos/Makefile
--- branches/xmlbuildsystem/reactos/Makefile	2005-04-05 17:12:52 UTC (rev 14506)
+++ branches/xmlbuildsystem/reactos/Makefile	2005-04-05 17:22:02 UTC (rev 14507)
@@ -90,6 +90,7 @@
   ECHO_NCI     =@echo [NCI]      $@
   ECHO_CABMAN  =@echo [CABMAN]   $<
   ECHO_CDMAKE  =@echo [CDMAKE]   $@
+  ECHO_MKHIVE  =@echo [MKHIVE]   $@
   ECHO_REGTESTS=@echo [REGTESTS] $@
   ECHO_TEST    =@echo [TEST]     $@
 else
@@ -115,6 +116,7 @@
   ECHO_NCI     =
   ECHO_CABMAN  =
   ECHO_CDMAKE  =
+  ECHO_MKHIVE  =
   ECHO_REGTESTS=
   ECHO_TEST    =
 endif
@@ -139,7 +141,7 @@
 	objcopy = $(Q)mingw32-objcopy
 	dlltool = $(Q)mingw32-dlltool
 	windres = $(Q)mingw32-windres
-	rm = rm -f
+	rm = $(Q)rm -f
 	cp = $(Q)cp
 	NUL = /dev/null
 else # mingw32-windows
@@ -157,7 +159,7 @@
 	objcopy = $(Q)objcopy
 	dlltool = $(Q)dlltool
 	windres = $(Q)windres
-	rm = del /f /q
+	rm = $(Q)del /f /q
 	cp = $(Q)copy /y
 	NUL = NUL
 endif

Added: branches/xmlbuildsystem/reactos/tools/mkhive/mkhive.mak
--- branches/xmlbuildsystem/reactos/tools/mkhive/mkhive.mak	2005-04-05 17:12:52 UTC (rev 14506)
+++ branches/xmlbuildsystem/reactos/tools/mkhive/mkhive.mak	2005-04-05 17:22:02 UTC (rev 14507)
@@ -0,0 +1,66 @@
+MKHIVE_BASE = $(TOOLS_BASE_)mkhive
+MKHIVE_BASE_ = $(MKHIVE_BASE)$(SEP)
+MKHIVE_INT = $(INTERMEDIATE_)$(MKHIVE_BASE)
+MKHIVE_INT_ = $(MKHIVE_INT)$(SEP)
+MKHIVE_OUT = $(OUTPUT_)$(MKHIVE_BASE)
+MKHIVE_OUT_ = $(MKHIVE_OUT)$(SEP)
+
+$(MKHIVE_INT): $(TOOLS_INT)
+	$(ECHO_MKDIR)
+	${mkdir} $@
+
+ifneq ($(INTERMEDIATE),$(OUTPUT))
+$(MKHIVE_OUT): $(TOOLS_OUT)
+	$(ECHO_MKDIR)
+	${mkdir} $@
+endif
+
+MKHIVE_TARGET = \
+	$(EXEPREFIX)$(MKHIVE_OUT_)mkhive$(EXEPOSTFIX)
+
+MKHIVE_SOURCES = $(addprefix $(MKHIVE_BASE_), \
+	binhive.c \
+	infcache.c \
+	mkhive.c \
+	reginf.c \
+	registry.c \
+	)
+
+MKHIVE_OBJECTS = \
+	$(addprefix $(INTERMEDIATE_), $(MKHIVE_SOURCES:.c=.o))
+
+MKHIVE_HOST_CFLAGS = -g -Werror -Wall
+
+MKHIVE_HOST_LFLAGS = -g
+
+.PHONY: mkhive
+mkhive: $(MKHIVE_TARGET)
+
+$(MKHIVE_TARGET): $(MKHIVE_OBJECTS) $(MKHIVE_OUT)
+	$(ECHO_LD)
+	${host_gcc} $(MKHIVE_OBJECTS) $(MKHIVE_HOST_LFLAGS) -o $@
+
+$(MKHIVE_INT_)binhive.o: $(MKHIVE_BASE_)binhive.c $(MKHIVE_INT)
+	$(ECHO_CC)
+	${host_gcc} $(MKHIVE_HOST_CFLAGS) -c $< -o $@
+
+$(MKHIVE_INT_)infcache.o: $(MKHIVE_BASE_)infcache.c $(MKHIVE_INT)
+	$(ECHO_CC)
+	${host_gcc} $(MKHIVE_HOST_CFLAGS) -c $< -o $@
+
+$(MKHIVE_INT_)mkhive.o: $(MKHIVE_BASE_)mkhive.c $(MKHIVE_INT)
+	$(ECHO_CC)
+	${host_gcc} $(MKHIVE_HOST_CFLAGS) -c $< -o $@
+
+$(MKHIVE_INT_)reginf.o: $(MKHIVE_BASE_)reginf.c $(MKHIVE_INT)
+	$(ECHO_CC)
+	${host_gcc} $(MKHIVE_HOST_CFLAGS) -c $< -o $@
+
+$(MKHIVE_INT_)registry.o: $(MKHIVE_BASE_)registry.c $(MKHIVE_INT)
+	$(ECHO_CC)
+	${host_gcc} $(MKHIVE_HOST_CFLAGS) -c $< -o $@
+
+.PHONY: mkhive_clean
+mkhive_clean: $(MKHIVE_TARGET)
+	-@$(rm) $(MKHIVE_TARGET) $(MKHIVE_OBJECTS) 2>$(NUL)
+clean: mkhive_clean

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp	2005-04-05 17:12:52 UTC (rev 14506)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp	2005-04-05 17:22:02 UTC (rev 14507)
@@ -680,7 +680,7 @@
 	fprintf ( fMakefile,
 	          "\t$(ECHO_CP)\n" );
 	fprintf ( fMakefile,
-	          "\t${cp} %s %s\n",
+	          "\t${cp} %s %s 1>$(NUL)\n",
 	          sourceFilename.c_str (),
 	          normalizedTargetFilename.c_str () );
 }
@@ -717,7 +717,56 @@
 	}
 }
 
+string
+MingwBackend::GetRegistrySourceFiles ()
+{
+	return "bootdata" SSEP "hivecls.inf "
+		"bootdata" SSEP "hivedef.inf "
+		"bootdata" SSEP "hiveinst.inf "
+		"bootdata" SSEP "hivesft.inf "
+		"bootdata" SSEP "hivesys.inf";
+}
+
+string
+MingwBackend::GetRegistryTargetFiles ( const string& installDirectory )
+{
+	string system32ConfigDirectory = MingwModuleHandler::PassThruCacheDirectory (
+		NormalizeFilename ( installDirectory + SSEP + "system32" + SSEP "config" ),
+		true );
+	return system32ConfigDirectory + SSEP "default " +
+		system32ConfigDirectory + SSEP "sam " +
+		system32ConfigDirectory + SSEP "security " +
+		system32ConfigDirectory + SSEP "software " +
+		system32ConfigDirectory + SSEP "system";
+}
+
 void
+MingwBackend::OutputRegistryInstallTarget ( const string& installDirectory )
+{
+	string system32ConfigDirectory = MingwModuleHandler::PassThruCacheDirectory (
+		NormalizeFilename ( installDirectory + SSEP + "system32" + SSEP "config" ),
+		true );
+
+	string registrySourceFiles = GetRegistrySourceFiles ();
+	string registryTargetFiles = GetRegistryTargetFiles ( installDirectory );
+	fprintf ( fMakefile,
+	          "install_registry: %s\n",
+	          registryTargetFiles.c_str () );
+	fprintf ( fMakefile,
+	          "%s: %s %s $(MKHIVE_TARGET)\n",
+	          registryTargetFiles.c_str (),
+	          registrySourceFiles.c_str (),
+	          system32ConfigDirectory.c_str () );
+	fprintf ( fMakefile,
+	          "\t$(ECHO_MKHIVE)\n" );
+	fprintf ( fMakefile,
+	          "\t$(MKHIVE_TARGET) bootdata %s bootdata" SSEP "hiveinst.inf\n",
+	          system32ConfigDirectory.c_str () );
+	fprintf ( fMakefile,
+	          "\n" );
+}
+
+void
 MingwBackend::GenerateInstallTarget ()
 {
 	string installDirectoryNoFixup = "reactos";
@@ -730,11 +779,12 @@
 	string installTargetFiles = v2s ( vInstallTargetFiles, 5 );
 
 	fprintf ( fMakefile,
-	          "install: %s %s\n",
+	          "install: %s %s install_registry\n",
 	          installDirectory.c_str (),
 	          installTargetFiles.c_str () );
 	OutputNonModuleInstallTargets ( installDirectoryNoFixup );
 	OutputModuleInstallTargets ( installDirectoryNoFixup );
+	OutputRegistryInstallTarget ( installDirectoryNoFixup );
 	fprintf ( fMakefile,
 	          "\n" );
 }

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h	2005-04-05 17:12:52 UTC (rev 14506)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h	2005-04-05 17:22:02 UTC (rev 14507)
@@ -60,6 +60,9 @@
 	                           const std::string& targetDirectory );
 	void OutputNonModuleInstallTargets ( const std::string& installDirectory );
 	void OutputModuleInstallTargets ( const std::string& installDirectory );
+	std::string GetRegistrySourceFiles ();
+	std::string GetRegistryTargetFiles ( const std::string& installDirectory );
+	void OutputRegistryInstallTarget ( const std::string& installDirectory );
 	void GenerateInstallTarget ();
 	FILE* fMakefile;
 	bool use_pch;

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-04-05 17:12:52 UTC (rev 14506)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-04-05 17:22:02 UTC (rev 14507)
@@ -2189,7 +2189,7 @@
 			fprintf ( fMakefile,
 			          "\t$(ECHO_CP)\n" );
 			fprintf ( fMakefile,
-			          "\t${cp} %s %s\n",
+			          "\t${cp} %s %s 1>$(NUL)\n",
 			          m.GetPath ().c_str (),
 			          targetFilename.c_str () );
 		}
@@ -2210,7 +2210,7 @@
 		fprintf ( fMakefile,
 		          "\t$(ECHO_CP)\n" );
 		fprintf ( fMakefile,
-		          "\t${cp} %s %s\n",
+		          "\t${cp} %s %s 1>$(NUL)\n",
 		          cdfile.GetPath ().c_str (),
 		          targetFilename.c_str () );
 	}

Modified: branches/xmlbuildsystem/reactos/tools/tools.mak
--- branches/xmlbuildsystem/reactos/tools/tools.mak	2005-04-05 17:12:52 UTC (rev 14506)
+++ branches/xmlbuildsystem/reactos/tools/tools.mak	2005-04-05 17:22:02 UTC (rev 14507)
@@ -57,6 +57,7 @@
 include tools/buildno/buildno.mak
 include tools/cabman/cabman.mak
 include tools/cdmake/cdmake.mak
+include tools/mkhive/mkhive.mak
 include tools/nci/nci.mak
 include tools/rbuild/rbuild.mak
 include tools/unicode/unicode.mak