eliminate rmkdir and generate directory dependencies the right way.
treat ROS_TEMPORARY, ROS_INTERMEDIATE, and ROS_OUTPUT as potential different directories.
major refactor of mingw backend to simplify things, and fix some output bugs, as well as reduce makefile.auto size a bit.
create all macros before we start writing rules ( create all target macros before any other ), this fixes bug with macros being empty because they're used before they're defined
Modified: branches/xmlbuildsystem/reactos/Makefile
Modified: branches/xmlbuildsystem/reactos/lib/zlib/zlib.mak
Modified: branches/xmlbuildsystem/reactos/tools/bin2res/bin2res.mak
Modified: branches/xmlbuildsystem/reactos/tools/buildno/buildno.mak
Modified: branches/xmlbuildsystem/reactos/tools/cabman/cabman.mak
Modified: branches/xmlbuildsystem/reactos/tools/cdmake/cdmake.mak
Modified: branches/xmlbuildsystem/reactos/tools/nci/nci.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/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/tools/rbuild/rbuild.mak
Modified: branches/xmlbuildsystem/reactos/tools/tools.mak
Modified: branches/xmlbuildsystem/reactos/tools/unicode/unicode.mak
Modified: branches/xmlbuildsystem/reactos/tools/winebuild/winebuild.mak
Modified: branches/xmlbuildsystem/reactos/tools/wmc/wmc.mak
Modified: branches/xmlbuildsystem/reactos/tools/wpp/wpp.mak
Modified: branches/xmlbuildsystem/reactos/tools/wrc/wrc.mak

Modified: branches/xmlbuildsystem/reactos/Makefile
--- branches/xmlbuildsystem/reactos/Makefile	2005-03-22 03:06:03 UTC (rev 14264)
+++ branches/xmlbuildsystem/reactos/Makefile	2005-03-22 07:25:53 UTC (rev 14265)
@@ -100,7 +100,7 @@
 	EXEPREFIX = ./
 	EXEPOSTFIX =
 	SEP = /
-	nmkdir = -$(Q)mkdir -p
+	mkdir = -$(Q)mkdir -p
 	gcc = $(Q)mingw32-gcc
 	gpp = $(Q)mingw32-g++
 	ld = $(Q)mingw32-ld
@@ -116,7 +116,7 @@
 	EXEPOSTFIX = .exe
 	ROS_EMPTY =
 	SEP = \$(ROS_EMPTY)
-	nmkdir = -$(Q)mkdir
+	mkdir = -$(Q)mkdir
 	gcc = $(Q)gcc
 	gpp = $(Q)g++
 	ld = $(Q)ld
@@ -130,28 +130,26 @@
 endif
 
 ifneq ($(ROS_INTERMEDIATE),)
-  INTERMEDIATE = .$(SEP)$(ROS_INTERMEDIATE)$(SEP)
-  INTERMEDIATE_NO_SLASH := $(ROS_INTERMEDIATE)
+  INTERMEDIATE := $(ROS_INTERMEDIATE)
 else
-  INTERMEDIATE = obj-i386$(SEP)
-  INTERMEDIATE_NO_SLASH = obj-i386
+  INTERMEDIATE := obj-i386
 endif
+INTERMEDIATE_ := $(INTERMEDIATE)$(SEP)
 
 ifneq ($(ROS_OUTPUT),)
-  OUTPUT = $(ROS_OUTPUT)$(SEP)
-  OUTPUT_NO_SLASH = $(ROS_OUTPUT)
+  OUTPUT := $(ROS_OUTPUT)
 else
-  OUTPUT = obj-i386$(SEP)
-  OUTPUT_NO_SLASH = obj-i386
+  OUTPUT := obj-i386
 endif
+OUTPUT_ := $(OUTPUT)$(SEP)
 
-mkdir = -$(Q)$(INTERMEDIATE)rmkdir
-EXISTS = .exists
-INTERMEDIATE_EXISTS = $(INTERMEDIATE)$(EXISTS)
+$(INTERMEDIATE):
+	${mkdir} $@
 
-$(INTERMEDIATE_EXISTS):
-	-${nmkdir} $(INTERMEDIATE_NO_SLASH) 2>$(NUL) >$(NUL)
-	@echo . > $@
+ifneq ($(INTERMEDIATE),$(OUTPUT))
+$(OUTPUT):
+	${mkdir} $@
+endif
 
 NTOSKRNL_MC = ntoskrnl$(SEP)ntoskrnl.mc
 KERNEL32_MC = lib$(SEP)kernel32$(SEP)kernel32.mc
@@ -161,6 +159,7 @@
 ERRCODES_H = include$(SEP)reactos$(SEP)errcodes.h
 ERRCODES_RC = lib$(SEP)kernel32$(SEP)errcodes.rc
 
+include lib/lib.mak
 include tools/tools.mak
 -include makefile.auto
 

Modified: branches/xmlbuildsystem/reactos/lib/zlib/zlib.mak
--- branches/xmlbuildsystem/reactos/lib/zlib/zlib.mak	2005-03-22 03:06:03 UTC (rev 14264)
+++ branches/xmlbuildsystem/reactos/lib/zlib/zlib.mak	2005-03-22 07:25:53 UTC (rev 14265)
@@ -1,29 +1,31 @@
-ZLIB_BASE = lib$(SEP)zlib
+ZLIB_BASE = $(LIB_BASE_)zlib
+ZLIB_BASE_ = $(ZLIB_BASE)$(SEP)
 
-ZLIB_BASE_DIR = $(INTERMEDIATE)$(ZLIB_BASE)
+ZLIB_INT = $(INTERMEDIATE_)$(ZLIB_BASE)
+ZLIB_OUT = $(OUTPUT_)$(ZLIB_BASE)
 
-
-#$(ZLIB_BASE_DIR): $(INTERMEDIATE_NO_SLASH) $(RMKDIR_TARGET)
+#$(ZLIB_INT): $(INTERMEDIATE_NO_SLASH) $(RMKDIR_TARGET)
 #	${mkdir} $(INTERMEDIATE)$(ZLIB_BASE)
 
 ZLIB_HOST_TARGET = \
-	$(INTERMEDIATE)$(ZLIB_BASE)$(SEP)zlib.host.a
+	$(ZLIB_OUT)$(SEP)zlib.host.a
 
-ZLIB_HOST_SOURCES = \
-	$(ZLIB_BASE)$(SEP)adler32.c \
-	$(ZLIB_BASE)$(SEP)compress.c \
-	$(ZLIB_BASE)$(SEP)crc32.c \
-	$(ZLIB_BASE)$(SEP)gzio.c \
-	$(ZLIB_BASE)$(SEP)uncompr.c \
-	$(ZLIB_BASE)$(SEP)deflate.c \
-	$(ZLIB_BASE)$(SEP)trees.c \
-	$(ZLIB_BASE)$(SEP)zutil.c \
-	$(ZLIB_BASE)$(SEP)inflate.c \
-	$(ZLIB_BASE)$(SEP)infblock.c \
-	$(ZLIB_BASE)$(SEP)inftrees.c \
-	$(ZLIB_BASE)$(SEP)infcodes.c \
-	$(ZLIB_BASE)$(SEP)infutil.c \
-	$(ZLIB_BASE)$(SEP)inffast.c
+ZLIB_HOST_SOURCES = $(addprefix $(ZLIB_BASE_), \
+	adler32.c \
+	compress.c \
+	crc32.c \
+	gzio.c \
+	uncompr.c \
+	deflate.c \
+	trees.c \
+	zutil.c \
+	inflate.c \
+	infblock.c \
+	inftrees.c \
+	infcodes.c \
+	infutil.c \
+	inffast.c \
+	)
 
 ZLIB_HOST_OBJECTS = \
 	$(ZLIB_HOST_SOURCES:.c=.o)
@@ -34,9 +36,9 @@
 .PHONY: zlib_host
 zlib_host: $(ZLIB_HOST_TARGET)
 
-$(ZLIB_HOST_TARGET): $(ZLIB_HOST_BASE_DIR) $(ZLIB_HOST_OBJECTS)
+$(ZLIB_HOST_TARGET): $(ZLIB_HOST_OBJECTS) $(ZLIB_OUT)
 	$(ECHO_AR)
-	$(host_ar) -r $(ZLIB_HOST_TARGET) $(ZLIB_HOST_OBJECTS)
+	$(host_ar) -r $@ $(ZLIB_HOST_OBJECTS)
 
 $(ZLIB_HOST_OBJECTS): %.o : %.c $(ZLIB_BASE_DIR)
 	$(ECHO_CC)

Modified: branches/xmlbuildsystem/reactos/tools/bin2res/bin2res.mak
--- branches/xmlbuildsystem/reactos/tools/bin2res/bin2res.mak	2005-03-22 03:06:03 UTC (rev 14264)
+++ branches/xmlbuildsystem/reactos/tools/bin2res/bin2res.mak	2005-03-22 07:25:53 UTC (rev 14265)
@@ -1,35 +1,44 @@
-BIN2RES_BASE = $(TOOLS_BASE)$(SEP)bin2res
+BIN2RES_BASE = $(TOOLS_BASE_)bin2res
+BIN2RES_BASE_ = $(BIN2RES_BASE)$(SEP)
+BIN2RES_INT = $(INTERMEDIATE_)$(BIN2RES_BASE)
+BIN2RES_INT_ = $(BIN2RES_INT)$(SEP)
+BIN2RES_OUT = $(OUTPUT_)$(BIN2RES_BASE)
+BIN2RES_OUT_ = $(BIN2RES_OUT)$(SEP)
 
-BIN2RES_BASE_DIR = $(INTERMEDIATE)$(BIN2RES_BASE)
-BIN2RES_BASE_DIR_EXISTS = $(BIN2RES_BASE_DIR)$(SEP)$(EXISTS)
+$(BIN2RES_INT): $(TOOLS_INT)
+	$(ECHO_MKDIR)
+	${mkdir} $@
 
-$(BIN2RES_BASE_DIR_EXISTS): $(TOOLS_BASE_DIR_EXISTS)
-	${mkdir} $(BIN2RES_BASE_DIR)
-	@echo . >$(BIN2RES_BASE_DIR_EXISTS)
+ifneq ($(INTERMEDIATE),$(OUTPUT))
+$(BIN2RES_OUT): $(TOOLS_OUT)
+	$(ECHO_MKDIR)
+	${mkdir} $@
+endif
 
 BIN2RES_TARGET = \
-	$(BIN2RES_BASE_DIR)$(SEP)bin2res$(EXEPOSTFIX)
+	$(EXEPREFIX)$(BIN2RES_OUT_)bin2res$(EXEPOSTFIX)
 
-BIN2RES_SOURCES = \
-	$(BIN2RES_BASE)$(SEP)bin2res.c \
-	$(BIN2RES_BASE)$(SEP)mkstemps.c
+BIN2RES_SOURCES = $(addprefix $(BIN2RES_BASE_), \
+	bin2res.c \
+	mkstemps.c \
+	)
 
 BIN2RES_OBJECTS = \
-	$(BIN2RES_SOURCES:.c=.o)
+	$addprefix ( $(INTERMEDIATE_), $(BIN2RES_SOURCES:.c=.o) )
 
 BIN2RES_HOST_CFLAGS = -Iinclude/wine -D__REACTOS__ -g -Werror -Wall
 
 BIN2RES_HOST_LFLAGS = -g
 
-$(BIN2RES_TARGET): $(BIN2RES_OBJECTS)
+$(BIN2RES_TARGET): $(BIN2RES_OBJECTS) $(BIN2RES_OUT)
 	$(ECHO_LD)
 	${host_gcc} $(BIN2RES_OBJECTS) $(BIN2RES_HOST_LFLAGS) -o $@
 
-$(BIN2RES_BASE_DIR)$(SEP)bin2res.o: $(BIN2RES_BASE)$(SEP)bin2res.c $(BIN2RES_BASE_DIR_EXISTS)
+$(BIN2RES_INT_)bin2res.o: $(BIN2RES_BASE_)bin2res.c $(BIN2RES_INT)
 	$(ECHO_CC)
 	${host_gcc} $(BIN2RES_HOST_CFLAGS) -c $< -o $@
 
-$(BIN2RES_BASE_DIR)$(SEP)mkstemps.o: $(BIN2RES_BASE)$(SEP)mkstemps.c $(BIN2RES_BASE_DIR_EXISTS)
+$(BIN2RES_INT_)mkstemps.o: $(BIN2RES_BASE_)mkstemps.c $(BIN2RES_INT)
 	$(ECHO_CC)
 	${host_gcc} $(BIN2RES_HOST_CFLAGS) -c $< -o $@
 

Modified: branches/xmlbuildsystem/reactos/tools/buildno/buildno.mak
--- branches/xmlbuildsystem/reactos/tools/buildno/buildno.mak	2005-03-22 03:06:03 UTC (rev 14264)
+++ branches/xmlbuildsystem/reactos/tools/buildno/buildno.mak	2005-03-22 07:25:53 UTC (rev 14265)
@@ -1,46 +1,54 @@
-BUILDNO_BASE = $(TOOLS_BASE)$(SEP)buildno
+BUILDNO_BASE = $(TOOLS_BASE_)buildno
+BUILDNO_BASE_ = $(BUILDNO_BASE)$(SEP)
+BUILDNO_INT = $(INTERMEDIATE_)$(BUILDNO_BASE)
+BUILDNO_INT_ = $(BUILDNO_INT)$(SEP)
+BUILDNO_OUT = $(OUTPUT_)$(BUILDNO_BASE)
+BUILDNO_OUT_ = $(BUILDNO_OUT)$(SEP)
 
-BUILDNO_BASE_DIR = $(INTERMEDIATE)$(BUILDNO_BASE)
-BUILDNO_BASE_DIR_EXISTS = $(BUILDNO_BASE_DIR)$(SEP)$(EXISTS)
+$(BUILDNO_INT): $(TOOLS_INT)
+	$(ECHO_MKDIR)
+	${mkdir} $@
 
-$(BUILDNO_BASE_DIR_EXISTS): $(TOOLS_BASE_DIR_EXISTS)
+ifneq ($(INTERMEDIATE),$(OUTPUT))
+$(BUILDNO_OUT): $(TOOLS_OUT)
 	$(ECHO_MKDIR)
-	${mkdir} $(BUILDNO_BASE_DIR)
-	@echo. > $@
+	${mkdir} $@
+endif
 
 BUILDNO_TARGET = \
-	$(BUILDNO_BASE_DIR)$(SEP)buildno$(EXEPOSTFIX)
+	$(EXEPREFIX)$(BUILDNO_OUT_)buildno$(EXEPOSTFIX)
 
-BUILDNO_SOURCES = \
-	$(BUILDNO_BASE)$(SEP)buildno.cpp \
-	$(BUILDNO_BASE)$(SEP)exception.cpp \
-	$(BUILDNO_BASE)$(SEP)ssprintf.cpp \
-	$(BUILDNO_BASE)$(SEP)XML.cpp
+BUILDNO_SOURCES = $(addprefix $(BUILDNO_BASE_), \
+	buildno.cpp \
+	exception.cpp \
+	ssprintf.cpp \
+	XML.cpp \
+	)
 
 BUILDNO_OBJECTS = \
-  $(addprefix $(INTERMEDIATE), $(BUILDNO_SOURCES:.cpp=.o))
+  $(addprefix $(INTERMEDIATE_), $(BUILDNO_SOURCES:.cpp=.o))
 
 BUILDNO_HOST_CFLAGS = -Iinclude/reactos -g -Werror -Wall
 
 BUILDNO_HOST_LFLAGS = -g
 
-$(BUILDNO_TARGET): $(BUILDNO_OBJECTS)
+$(BUILDNO_TARGET): $(BUILDNO_OBJECTS) $(BUILDNO_OUT)
 	$(ECHO_LD)
-	${host_gpp} $(BUILDNO_OBJECTS) $(BUILDNO_HOST_LFLAGS) -o $(BUILDNO_TARGET)
+	${host_gpp} $(BUILDNO_OBJECTS) $(BUILDNO_HOST_LFLAGS) -o $@
 
-$(BUILDNO_BASE_DIR)$(SEP)buildno.o: $(BUILDNO_BASE)$(SEP)buildno.cpp $(BUILDNO_BASE_DIR_EXISTS)
+$(BUILDNO_INT_)buildno.o: $(BUILDNO_BASE_)buildno.cpp $(BUILDNO_INT)
 	$(ECHO_CC)
 	${host_gpp} $(BUILDNO_HOST_CFLAGS) -c $< -o $@
 
-$(BUILDNO_BASE_DIR)$(SEP)exception.o: $(BUILDNO_BASE)$(SEP)exception.cpp $(BUILDNO_BASE_DIR_EXISTS)
+$(BUILDNO_INT_)exception.o: $(BUILDNO_BASE_)exception.cpp $(BUILDNO_INT)
 	$(ECHO_CC)
 	${host_gpp} $(BUILDNO_HOST_CFLAGS) -c $< -o $@
 
-$(BUILDNO_BASE_DIR)$(SEP)ssprintf.o: $(BUILDNO_BASE)$(SEP)ssprintf.cpp $(BUILDNO_BASE_DIR_EXISTS)
+$(BUILDNO_INT_)ssprintf.o: $(BUILDNO_BASE_)ssprintf.cpp $(BUILDNO_INT)
 	$(ECHO_CC)
 	${host_gpp} $(BUILDNO_HOST_CFLAGS) -c $< -o $@
 
-$(BUILDNO_BASE_DIR)$(SEP)XML.o: $(BUILDNO_BASE)$(SEP)XML.cpp $(BUILDNO_BASE_DIR_EXISTS)
+$(BUILDNO_INT_)XML.o: $(BUILDNO_BASE_)XML.cpp $(BUILDNO_INT)
 	$(ECHO_CC)
 	${host_gpp} $(BUILDNO_HOST_CFLAGS) -c $< -o $@
 

Modified: branches/xmlbuildsystem/reactos/tools/cabman/cabman.mak
--- branches/xmlbuildsystem/reactos/tools/cabman/cabman.mak	2005-03-22 03:06:03 UTC (rev 14264)
+++ branches/xmlbuildsystem/reactos/tools/cabman/cabman.mak	2005-03-22 07:25:53 UTC (rev 14265)
@@ -1,51 +1,64 @@
-CABMAN_BASE = tools$(SEP)cabman
+CABMAN_BASE = $(TOOLS_BASE_)cabman
+CABMAN_BASE_ = $(CABMAN_BASE)$(SEP)
+CABMAN_INT = $(INTERMEDIATE_)$(CABMAN_BASE)
+CABMAN_INT_ = $(CABMAN_INT)$(SEP)
+CABMAN_OUT = $(OUTPUT_)$(CABMAN_BASE)
+CABMAN_OUT_ = $(CABMAN_OUT)$(SEP)
 
-CABMAN_BASE_DIR = $(INTERMEDIATE)$(CABMAN_BASE)
+$(CABMAN_INT): $(TOOLS_INT)
+	$(ECHO_MKDIR)
+	${mkdir} $@
 
-$(CABMAN_BASE_DIR): $(RMKDIR_TARGET)
-	${mkdir} $(INTERMEDIATE)$(CABMAN_BASE)
+ifneq ($(INTERMEDIATE),$(OUTPUT))
+$(CABMAN_OUT): $(TOOLS_OUT)
+	$(ECHO_MKDIR)
+	${mkdir} $@
+endif
 
 CABMAN_TARGET = \
-	$(CABMAN_BASE_DIR)$(SEP)cabman$(EXEPOSTFIX)
+	$(EXEPREFIX)$(CABMAN_OUT_)cabman$(EXEPOSTFIX)
 
-CABMAN_SOURCES = \
-	$(CABMAN_BASE)$(SEP)cabinet.cxx \
-	$(CABMAN_BASE)$(SEP)dfp.cxx \
-	$(CABMAN_BASE)$(SEP)main.cxx \
-	$(CABMAN_BASE)$(SEP)mszip.cxx \
-	$(CABMAN_BASE)$(SEP)raw.cxx
+CABMAN_SOURCES = $(addprefix $(CABMAN_INT_), \
+	cabinet.cxx \
+	dfp.cxx \
+	main.cxx \
+	mszip.cxx \
+	raw.cxx \
+	)
 
 CABMAN_OBJECTS = \
-  $(addprefix $(INTERMEDIATE), $(CABMAN_SOURCES:.cxx=.o))
+  $(addprefix $(INTERMEDIATE_), $(CABMAN_SOURCES:.cxx=.o))
 
 CABMAN_HOST_CFLAGS = -Iinclude/reactos -Ilib/zlib -g -Werror -Wall
 
-CABMAN_HOST_LFLAGS = -g $(ZLIB_HOST_TARGET)
+CABMAN_HOST_LIBS = $(ZLIB_HOST_TARGET)
 
+CABMAN_HOST_LFLAGS = -g $(CABMAN_HOST_LIBS)
+
 .PHONY: cabman
 cabman: $(CABMAN_TARGET)
 
-$(CABMAN_TARGET): $(CABMAN_OBJECTS) $(ZLIB_HOST_TARGET)
+$(CABMAN_TARGET): $(CABMAN_OBJECTS) $(CABMAN_HOST_LIBS) $(CABMAN_OUT)
 	$(ECHO_LD)
 	${host_gpp} $(CABMAN_OBJECTS) $(CABMAN_HOST_LFLAGS) -o $@
 
-$(CABMAN_BASE_DIR)$(SEP)cabinet.o: $(CABMAN_BASE)$(SEP)cabinet.cxx $(CABMAN_BASE_DIR)
+$(CABMAN_INT_)cabinet.o: $(CABMAN_BASE_)cabinet.cxx $(CABMAN_BASE_DIR)
 	$(ECHO_CC)
 	${host_gpp} $(CABMAN_HOST_CFLAGS) -c $< -o $@
 
-$(CABMAN_BASE_DIR)$(SEP)dfp.o: $(CABMAN_BASE)$(SEP)dfp.cxx $(CABMAN_BASE_DIR)
+$(CABMAN_INT_)dfp.o: $(CABMAN_BASE_)dfp.cxx $(CABMAN_BASE_DIR)
 	$(ECHO_CC)
 	${host_gpp} $(CABMAN_HOST_CFLAGS) -c $< -o $@
 
-$(CABMAN_BASE_DIR)$(SEP)main.o: $(CABMAN_BASE)$(SEP)main.cxx $(CABMAN_BASE_DIR)
+$(CABMAN_INT_)main.o: $(CABMAN_BASE_)main.cxx $(CABMAN_BASE_DIR)
 	$(ECHO_CC)
 	${host_gpp} $(CABMAN_HOST_CFLAGS) -c $< -o $@
 
-$(CABMAN_BASE_DIR)$(SEP)mszip.o: $(CABMAN_BASE)$(SEP)mszip.cxx $(CABMAN_BASE_DIR)
+$(CABMAN_INT_)mszip.o: $(CABMAN_BASE_)mszip.cxx $(CABMAN_BASE_DIR)
 	$(ECHO_CC)
 	${host_gpp} $(CABMAN_HOST_CFLAGS) -c $< -o $@
 
-$(CABMAN_BASE_DIR)$(SEP)raw.o: $(CABMAN_BASE)$(SEP)raw.cxx $(CABMAN_BASE_DIR)
+$(CABMAN_INT_)raw.o: $(CABMAN_BASE_)raw.cxx $(CABMAN_BASE_DIR)
 	$(ECHO_CC)
 	${host_gpp} $(CABMAN_HOST_CFLAGS) -c $< -o $@
 

Modified: branches/xmlbuildsystem/reactos/tools/cdmake/cdmake.mak
--- branches/xmlbuildsystem/reactos/tools/cdmake/cdmake.mak	2005-03-22 03:06:03 UTC (rev 14264)
+++ branches/xmlbuildsystem/reactos/tools/cdmake/cdmake.mak	2005-03-22 07:25:53 UTC (rev 14265)
@@ -1,22 +1,30 @@
-CDMAKE_BASE = $(TOOLS_BASE)$(SEP)cdmake
+CDMAKE_BASE = $(TOOLS_BASE_)cdmake
+CDMAKE_BASE_ = $(CDMAKE_BASE)$(SEP)
+CDMAKE_INT = $(INTERMEDIATE_)$(CDMAKE_BASE)
+CDMAKE_INT_ = $(CDMAKE_INT)$(SEP)
+CDMAKE_OUT = $(OUTPUT_)$(CDMAKE_BASE)
+CDMAKE_OUT_ = $(CDMAKE_OUT)$(SEP)
 
-CDMAKE_BASE_DIR = $(INTERMEDIATE)$(CDMAKE_BASE)
-CDMAKE_BASE_DIR_EXISTS = $(CDMAKE_BASE_DIR)$(SEP)$(EXISTS)
+$(CDMAKE_INT): $(TOOLS_INT)
+	$(ECHO_MKDIR)
+	${mkdir} $@
 
-$(CDMAKE_BASE_DIR_EXISTS): $(TOOLS_BASE_DIR_EXISTS)
+ifneq ($(INTERMEDIATE),$(OUTPUT))
+$(CDMAKE_OUT): $(TOOLS_OUT)
 	$(ECHO_MKDIR)
-	${mkdir} $(CDMAKE_BASE_DIR)
-	@echo . >$@
+	${mkdir} $@
+endif
 
 CDMAKE_TARGET = \
-	$(CDMAKE_BASE_DIR)$(SEP)cdmake$(EXEPOSTFIX)
+	$(EXEPREFIX)$(CDMAKE_OUT_)cdmake$(EXEPOSTFIX)
 
-CDMAKE_SOURCES = \
-	$(CDMAKE_BASE)$(SEP)cdmake.c \
-	$(CDMAKE_BASE)$(SEP)llmosrt.c
+CDMAKE_SOURCES = $(addprefix $(CDMAKE_BASE_), \
+	cdmake.c \
+	llmosrt.c \
+	)
 
 CDMAKE_OBJECTS = \
-	$(addprefix $(INTERMEDIATE), $(CDMAKE_SOURCES:.c=.o))
+	$(addprefix $(INTERMEDIATE_), $(CDMAKE_SOURCES:.c=.o))
 
 CDMAKE_HOST_CFLAGS = -Iinclude -g -Werror -Wall
 
@@ -25,15 +33,15 @@
 .PHONY: cdmake
 cdmake: $(CDMAKE_TARGET)
 
-$(CDMAKE_TARGET): $(CDMAKE_OBJECTS)
+$(CDMAKE_TARGET): $(CDMAKE_OBJECTS) $(CDMAKE_OUT)
 	$(ECHO_LD)
 	${host_gcc} $(CDMAKE_OBJECTS) $(CDMAKE_HOST_LFLAGS) -o $@
 
-$(CDMAKE_BASE_DIR)$(SEP)cdmake.o: $(CDMAKE_BASE)$(SEP)cdmake.c $(CDMAKE_BASE_DIR_EXISTS)
+$(CDMAKE_INT_)cdmake.o: $(CDMAKE_BASE_)cdmake.c $(CDMAKE_INT)
 	$(ECHO_CC)
 	${host_gcc} $(CDMAKE_HOST_CFLAGS) -c $< -o $@
 
-$(CDMAKE_BASE_DIR)$(SEP)llmosrt.o: $(CDMAKE_BASE)$(SEP)llmosrt.c $(CDMAKE_BASE_DIR_EXISTS)
+$(CDMAKE_INT_)llmosrt.o: $(CDMAKE_BASE_)llmosrt.c $(CDMAKE_INT)
 	$(ECHO_CC)
 	${host_gcc} $(CDMAKE_HOST_CFLAGS) -c $< -o $@
 

Modified: branches/xmlbuildsystem/reactos/tools/nci/nci.mak
--- branches/xmlbuildsystem/reactos/tools/nci/nci.mak	2005-03-22 03:06:03 UTC (rev 14264)
+++ branches/xmlbuildsystem/reactos/tools/nci/nci.mak	2005-03-22 07:25:53 UTC (rev 14265)
@@ -1,30 +1,38 @@
-NCI_BASE = $(TOOLS_BASE)$(SEP)nci
+NCI_BASE = $(TOOLS_BASE_)nci
+NCI_BASE_ = $(NCI_BASE)$(SEP)
+NCI_INT = $(INTERMEDIATE_)$(NCI_BASE)
+NCI_INT_ = $(NCI_INT)$(SEP)
+NCI_OUT = $(OUTPUT_)$(NCI_BASE)
+NCI_OUT_ = $(NCI_OUT)$(SEP)
 
-NCI_BASE_DIR = $(INTERMEDIATE)$(NCI_BASE)
-NCI_BASE_DIR_EXISTS = $(NCI_BASE_DIR)$(SEP)$(EXISTS)
+$(NCI_INT): $(TOOLS_INT)
+	$(ECHO_MKDIR)
+	${mkdir} $@
 
-$(NCI_BASE_DIR_EXISTS): $(TOOLS_BASE_DIR_EXIST)
-	${mkdir} $(NCI_BASE_DIR)
-	@echo . > $@
+ifneq ($(INTERMEDIATE),$(OUTPUT))
+$(NCI_OUT): $(TOOLS_OUT)
+	$(ECHO_MKDIR)
+	${mkdir} $@
+endif
 
 NCI_TARGET = \
-	$(NCI_BASE_DIR)$(SEP)nci$(EXEPOSTFIX)
+	$(EXEPREFIX)$(NCI_OUT_)nci$(EXEPOSTFIX)
 
 NCI_SOURCES = \
-	$(NCI_BASE)$(SEP)ncitool.c
+	$(NCI_BASE_)ncitool.c
 
 NCI_OBJECTS = \
-    $(addprefix $(INTERMEDIATE), $(NCI_SOURCES:.c=.o))
+    $(addprefix $(INTERMEDIATE_), $(NCI_SOURCES:.c=.o))
 
 NCI_HOST_CFLAGS = -Iinclude -g -Werror -Wall
 
 NCI_HOST_LFLAGS = -g
 
-$(NCI_TARGET): $(NCI_OBJECTS)
+$(NCI_TARGET): $(NCI_OBJECTS) $(NCI_OUT)
 	$(ECHO_LD)
-	${host_gcc} $(NCI_OBJECTS) $(NCI_HOST_CFLAGS) -o $(NCI_TARGET)
+	${host_gcc} $(NCI_OBJECTS) $(NCI_HOST_LFLAGS) -o $@
 
-$(NCI_BASE_DIR)$(SEP)ncitool.o: $(NCI_BASE)$(SEP)ncitool.c $(NCI_BASE_DIR_EXISTS)
+$(NCI_INT_)ncitool.o: $(NCI_BASE_)ncitool.c $(NCI_INT)
 	$(ECHO_CC)
 	${host_gcc} $(NCI_HOST_CFLAGS) -c $< -o $@
 
@@ -34,13 +42,13 @@
 clean: nci_clean
 
 # WIN32K.SYS
-WIN32K_SVC_DB = $(NCI_BASE)$(SEP)w32ksvc.db
+WIN32K_SVC_DB = $(NCI_BASE_)w32ksvc.db
 WIN32K_SERVICE_TABLE = subsys$(SEP)win32k$(SEP)main$(SEP)svctab.c
 WIN32K_GDI_STUBS = lib$(SEP)gdi32$(SEP)misc$(SEP)win32k.S
 WIN32K_USER_STUBS = lib$(SEP)user32$(SEP)misc$(SEP)win32k.S
 
 # NTOSKRNL.EXE
-KERNEL_SVC_DB = $(NCI_BASE)$(SEP)sysfuncs.lst
+KERNEL_SVC_DB = $(NCI_BASE_)sysfuncs.lst
 KERNEL_SERVICE_TABLE = include$(SEP)ntdll$(SEP)napi.h
 NTDLL_STUBS = lib$(SEP)ntdll$(SEP)napi.S
 KERNEL_STUBS = ntoskrnl$(SEP)ex$(SEP)zw.S

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp	2005-03-22 03:06:03 UTC (rev 14264)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp	2005-03-22 07:25:53 UTC (rev 14265)
@@ -3,13 +3,76 @@
 
 #include "mingw.h"
 #include <assert.h>
+#include "modulehandler.h"
 
 using std::string;
 using std::vector;
 using std::set;
+using std::map;
 
 typedef set<string> set_string;
+typedef map<string,Directory*> directory_map;
 
+class Directory
+{
+public:
+	string name;
+	directory_map subdirs;
+	Directory ( const string& name );
+	void Add ( const char* subdir );
+	void CreateRule ( FILE* f, const string& parent );
+};
+
+Directory::Directory ( const string& name_ )
+	: name(name_)
+{
+}
+
+void Directory::Add ( const char* subdir )
+{
+	const char* p = strpbrk ( subdir, "/\\" );
+	if ( !p )
+		p = subdir + strlen(subdir);
+	string s ( subdir, p-subdir );
+	if ( subdirs.find(s) == subdirs.end() )
+		subdirs[s] = new Directory(s);
+	if ( *p && *++p )
+		subdirs[s]->Add ( p );
+}
+
+void
+Directory::CreateRule ( FILE* f, const string& parent )
+{
+	string path;
+
+	if ( parent.size() )
+	{
+		fprintf ( f,
+			"%s%c%s: %s\n",
+			parent.c_str (),
+			CSEP,
+			name.c_str (),
+			parent.c_str () );
+
+		fprintf ( f,
+			"\t$(ECHO_MKDIR)\n" );
+
+		fprintf ( f,
+			"\t${mkdir} $@\n" );
+
+		path = parent + SSEP + name;
+	}
+	else
+		path = name;
+
+	for ( directory_map::iterator i = subdirs.begin();
+		i != subdirs.end();
+		++i )
+	{
+		i->second->CreateRule ( f, path );
+	}
+}
+
 static class MingwFactory : public Backend::Factory
 {
 public:
@@ -22,33 +85,82 @@
 
 
 MingwBackend::MingwBackend ( Project& project )
-	: Backend ( project )
+	: Backend ( project ),
+	  int_directories ( new Directory("$(INTERMEDIATE)") ),
+	  out_directories ( new Directory("$(OUTPUT)") )
 {
 }
 
-void
-MingwBackend::CreateDirectoryTargetIfNotYetCreated ( const string& directory )
+MingwBackend::~MingwBackend()
 {
-	directories.insert ( directory );
+	delete int_directories;
+	delete out_directories;
 }
 
+string
+MingwBackend::AddDirectoryTarget ( const string& directory, bool out )
+{
+	const char* dir_name = "$(INTERMEDIATE)";
+	Directory* dir = int_directories;
+	if ( out )
+	{
+		dir_name = "$(OUTPUT)";
+		dir = out_directories;
+	}
+	dir->Add ( directory.c_str() );
+	return dir_name;
+}
 
 void
 MingwBackend::Process ()
 {
+	size_t i;
+
 	DetectPCHSupport();
 
 	CreateMakefile ();
 	GenerateHeader ();
 	GenerateGlobalVariables ();
-	GenerateAllTarget ();
-	GenerateInitTarget ();
 	GenerateXmlBuildFilesMacro();
-	for ( size_t i = 0; i < ProjectNode.modules.size (); i++ )
+
+	vector<MingwModuleHandler*> v;
+
+	for ( i = 0; i < ProjectNode.modules.size (); i++ )
 	{
 		Module& module = *ProjectNode.modules[i];
-		ProcessModule ( module );
+		MingwModuleHandler* h = MingwModuleHandler::InstanciateHandler (
+			module,
+			this );
+		if ( module.host == HostDefault )
+		{
+			module.host = h->DefaultHost();
+			assert ( module.host != HostDefault );
+		}
+		v.push_back ( h );
 	}
+
+	size_t iend = v.size ();
+
+	for ( i = 0; i < iend; i++ )
+		v[i]->GenerateTargetMacro();
+	fprintf ( fMakefile, "\n" );
+
+	GenerateAllTarget ( v );
+	GenerateInitTarget ();
+
+	for ( i = 0; i < iend; i++ )
+		v[i]->GenerateOtherMacros();
+
+	for ( i = 0; i < iend; i++ )
+	{
+		MingwModuleHandler& h = *v[i];
+		h.GeneratePreconditionDependencies ();
+		h.Process ();
+		h.GenerateInvocations ();
+		h.GenerateCleanTarget ();
+		delete v[i];
+	}
+
 	GenerateDirectoryTargets ();
 	CheckAutomaticDependencies ();
 	CloseMakefile ();
@@ -60,6 +172,7 @@
 	fMakefile = fopen ( ProjectNode.makefile.c_str (), "w" );
 	if ( !fMakefile )
 		throw AccessDeniedException ( ProjectNode.makefile );
+	MingwModuleHandler::SetBackend ( this );
 	MingwModuleHandler::SetMakefile ( fMakefile );
 	MingwModuleHandler::SetUsePch ( use_pch );
 }
@@ -129,7 +242,7 @@
 	if ( data.includes.size() || data.defines.size() )
 	{
 		GenerateProjectCFlagsMacro ( assignmentOperation,
-                                     data );
+		                             data );
 	}
 
 	for ( i = 0; i < data.ifs.size(); i++ )
@@ -171,15 +284,6 @@
 void
 MingwBackend::GenerateGlobalVariables () const
 {
-#define TOOL_PREFIX "$(Q)$(INTERMEDIATE)tools" SSEP
-	fprintf ( fMakefile, "winebuild = " TOOL_PREFIX "winebuild" SSEP "winebuild" EXEPOSTFIX "\n" );
-	fprintf ( fMakefile, "bin2res = " TOOL_PREFIX "bin2res" SSEP "bin2res" EXEPOSTFIX "\n" );
-	fprintf ( fMakefile, "cabman = " TOOL_PREFIX "cabman" SSEP "cabman" EXEPOSTFIX "\n" );
-	fprintf ( fMakefile, "cdmake = " TOOL_PREFIX "cdmake" SSEP "cdmake" EXEPOSTFIX "\n" );
-	fprintf ( fMakefile, "regtests = " TOOL_PREFIX "regtests" EXEPOSTFIX "\n" );
-	fprintf ( fMakefile, "rsym = " TOOL_PREFIX "rsym" EXEPOSTFIX "\n" );
-	fprintf ( fMakefile, "wrc = " TOOL_PREFIX "wrc" SSEP "wrc" EXEPOSTFIX "\n" );
-	fprintf ( fMakefile, "\n" );
 	GenerateGlobalCFlagsAndProperties (
 		"=",
 		ProjectNode.non_if_data );
@@ -202,20 +306,21 @@
 }
 
 void
-MingwBackend::GenerateAllTarget () const
+MingwBackend::GenerateAllTarget ( const vector<MingwModuleHandler*>& handlers ) const
 {
 	fprintf ( fMakefile, "all:" );
 	int wrap_count = 0;
-	for ( size_t i = 0; i < ProjectNode.modules.size (); i++ )
+	size_t iend = handlers.size ();
+	for ( size_t i = 0; i < iend; i++ )
 	{
-		Module& module = *ProjectNode.modules[i];
+		const Module& module = handlers[i]->module;
 		if ( IncludeInAllTarget ( module ) )
 		{
 			if ( wrap_count++ == 5 )
 				fprintf ( fMakefile, " \\\n\t\t" ), wrap_count = 0;
 			fprintf ( fMakefile,
 			          " %s",
-			          FixupTargetFilename ( module.GetPath () ).c_str () );
+			          GetTargetMacro(module).c_str () );
 		}
 	}
 	fprintf ( fMakefile, "\n\t\n\n" );
@@ -244,8 +349,7 @@
 	fprintf ( fMakefile,
 	          "INIT = %s\n",
 	          GetBuildToolDependencies ().c_str () );
-	fprintf ( fMakefile,
-	          "\n" );
+	fprintf ( fMakefile, "\n" );
 }
 
 void
@@ -272,8 +376,7 @@
 			          xmlbuildFilenames.c_str ());
 			if ( i == ProjectNode.xmlbuildfiles.size () - 1 )
 			{
-				fprintf ( fMakefile,
-				          "\n" );
+				fprintf ( fMakefile, "\n" );
 			}
 			else
 			{
@@ -285,8 +388,7 @@
 		}
 		numberOfExistingFiles++;
 	}
-	fprintf ( fMakefile,
-	          "\n" );
+	fprintf ( fMakefile, "\n" );
 }
 
 void
@@ -297,27 +399,10 @@
 	automaticDependency.CheckAutomaticDependencies ();
 }
 
-void
-MingwBackend::ProcessModule ( Module& module )
-{
-	MingwModuleHandler* h = MingwModuleHandler::InstanciateHandler (
-		module.node.location,
-		module.type,
-	    this );
-	MingwModuleHandler::string_list clean_files;
-	if ( module.host == HostDefault )
-	{
-		module.host = h->DefaultHost();
-		assert ( module.host != HostDefault );
-	}
-	h->Process ( module, clean_files );
-	h->GenerateCleanTarget ( module, clean_files );
-}
-
 bool
 MingwBackend::IncludeDirectoryTarget ( const string& directory ) const
 {
-	if ( directory == "$(INTERMEDIATE)tools")
+	if ( directory == "$(INTERMEDIATE)" SSEP "tools")
 		return false;
 	else
 		return true;
@@ -326,7 +411,15 @@
 void
 MingwBackend::GenerateDirectoryTargets ()
 {
-	if ( directories.size () == 0 )
+	// TODO FIXME - write new directory creation
+	for ( int i = 0; i < 2; i++ )
+	{
+		Directory& d = *(!i ? int_directories : out_directories);
+		if ( i ) fprintf ( fMakefile, "ifneq ($(INTERMEDIATE),$(OUTPUT))\n" );
+		d.CreateRule ( fMakefile, "" );
+		if ( i ) fprintf ( fMakefile, "endif\n" );
+	}
+	/*if ( directories.size () == 0 )
 		return;
 	
 	set_string::iterator i;
@@ -345,13 +438,13 @@
 		}
 	}
 
-	directories.clear ();
+	directories.clear ();*/
 }
 
 string
 FixupTargetFilename ( const string& targetFilename )
 {
-	return string("$(INTERMEDIATE)") + NormalizeFilename ( targetFilename );
+	return NormalizeFilename ( targetFilename );
 }
 
 void

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h	2005-03-22 03:06:03 UTC (rev 14264)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h	2005-03-22 07:25:53 UTC (rev 14265)
@@ -2,17 +2,18 @@
 #define MINGW_H
 
 #include "../backend.h"
-#include "modulehandler.h"
 
+class Directory;
+class MingwModuleHandler;
+
 class MingwBackend : public Backend
 {
 public:
 	MingwBackend ( Project& project );
-	virtual ~MingwBackend () { };
+	virtual ~MingwBackend ();
 	virtual void Process ();
-	void CreateDirectoryTargetIfNotYetCreated ( const std::string& directory );
+	std::string AddDirectoryTarget ( const std::string& directory, bool out );
 private:
-	void ProcessModule ( Module& module );
 	void CreateMakefile ();
 	void CloseMakefile () const;
 	void GenerateHeader () const;
@@ -24,16 +25,16 @@
 	void GenerateDirectoryTargets ();
 	void GenerateGlobalVariables () const;
 	bool IncludeInAllTarget ( const Module& module ) const;
-	void GenerateAllTarget () const;
+	void GenerateAllTarget ( const std::vector<MingwModuleHandler*>& handlers ) const;
 	std::string GetBuildToolDependencies () const;
 	void GenerateInitTarget () const;
 	void GenerateXmlBuildFilesMacro() const;
 	void CheckAutomaticDependencies ();
 	bool IncludeDirectoryTarget ( const std::string& directory ) const;
 	void DetectPCHSupport();
-	std::set<std::string> directories;
 	FILE* fMakefile;
 	bool use_pch;
+	Directory *int_directories, *out_directories;
 };
 
 std::string FixupTargetFilename ( const std::string& targetFilename );

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-03-22 03:06:03 UTC (rev 14264)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-03-22 07:25:53 UTC (rev 14265)
@@ -10,29 +10,15 @@
 
 #define CLEAN_FILE(f) clean_files.push_back ( f ); /*if ( module.name == "crt" ) printf ( "%s(%i): clean: %s\n", __FILE__, __LINE__, f.c_str() )*/
 
+static string ros_temp = "$(ROS_TEMPORARY)";
+MingwBackend*
+MingwModuleHandler::backend = NULL;
 FILE*
 MingwModuleHandler::fMakefile = NULL;
 bool
 MingwModuleHandler::use_pch = false;
 
 string
-ReplaceExtension ( const string& filename,
-                   const string& newExtension )
-{
-	size_t index = filename.find_last_of ( '/' );
-	if ( index == string::npos )
-		index = 0;
-	size_t index2 = filename.find_last_of ( '\\' );
-	if ( index2 != string::npos && index2 > index )
-		index = index2;
-	string tmp = filename.substr( index /*, filename.size() - index*/ );
-	size_t ext_index = tmp.find_last_of( '.' );
-	if ( ext_index != string::npos )
-		return filename.substr ( 0, index + ext_index ) + newExtension;
-	return filename + newExtension;
-}
-
-string
 PrefixFilename (
 	const string& filename,
 	const string& prefix )
@@ -54,7 +40,8 @@
 	return out;
 }
 
-string v2s ( const vector<string>& v, int wrap_at )
+string
+v2s ( const string_list& v, int wrap_at )
 {
 	if ( !v.size() )
 		return "";
@@ -73,88 +60,144 @@
 	return s;
 }
 
-MingwModuleHandler::MingwModuleHandler ( ModuleType moduletype,
-                                         MingwBackend* backend_ )
-	: backend ( backend_ )
+string
+GetTargetMacro ( const Module& module, bool with_dollar )
 {
+	string s ( module.name );
+	strupr ( &s[0] );
+	s += "_TARGET";
+	if ( with_dollar )
+		return ssprintf ( "$(%s)", s.c_str() );
+	return s;
 }
 
+MingwModuleHandler::MingwModuleHandler (
+	const Module& module_ )
+
+	: module(module_)
+{
+}
+
 MingwModuleHandler::~MingwModuleHandler()
 {
 }
 
-const string &
-MingwModuleHandler::PassThruCacheDirectory ( const string &file )
+/*static*/ void
+MingwModuleHandler::SetBackend ( MingwBackend* backend_ )
 {
-	backend->CreateDirectoryTargetIfNotYetCreated ( GetDirectory ( file ) );
-	return file;
+	backend = backend_;
 }
 
-void
+/*static*/ void
 MingwModuleHandler::SetMakefile ( FILE* f )
 {
 	fMakefile = f;
 }
 
-void
+/*static*/ void
 MingwModuleHandler::SetUsePch ( bool b )
 {
 	use_pch = b;
 }
 
-MingwModuleHandler*
-MingwModuleHandler::InstanciateHandler ( const string& location,
-                                         ModuleType moduletype,
-                                         MingwBackend* backend )
+/*static*/ string
+MingwModuleHandler::PassThruCacheDirectory (
+	const string &file, bool out )
 {
+	string dir ( GetDirectory ( file ) );
+	return backend->AddDirectoryTarget ( dir, out ) + SSEP + file;
+}
+
+/*static*/ string
+MingwModuleHandler::GetTargetFilename (
+	const Module& module,
+	string_list* pclean_files )
+{
+	string target = PassThruCacheDirectory (
+		FixupTargetFilename ( module.GetPath () ),
+		true );
+	if ( pclean_files )
+	{
+		string_list& clean_files = *pclean_files;
+		CLEAN_FILE ( target );
+	}
+	return target;
+}
[truncated at 1000 lines; 4465 more skipped]