Index: trunk/src/VBox/VMM/Makefile.kmk
===================================================================
--- trunk/src/VBox/VMM/Makefile.kmk	(revision 2516)
+++ trunk/src/VBox/VMM/Makefile.kmk	(revision 2517)
@@ -1,5 +1,5 @@
 # $Id$
 ## @file
-# Makefile for the VMM.
+# Top-level makefile for the VMM.
 #
 
@@ -21,19 +21,7 @@
 
 DEPTH = ../../..
-include	$(PATH_KBUILD)/header.kmk
-
-LIBRARIES       = VMMR3
-ifneq ($(BUILD_TARGET),darwin)
-LIBRARIES      += VMMGCBuiltin VMMGCImp VMMR0Imp
-endif
-SYSMODS         = VMMGC VMMR0
-DLLS            = VBoxVMM
-
-# Walk
-SUBDIRS_AFTER_BINARIES = testcase
-SUBDIRS_AFTER_OTHERS   = testcase
-SUBDIRS_AFTER_CLEAN    = testcase
-SUBDIRS_AFTER_NOTHING  = testcase
-
+include	$(PATH_KBUILD)/subheader.kmk
+
+## @todo get rid of these.
 # Enable the PDM lock.
 #DEFS += VBOX_WITH_PDM_LOCK
@@ -42,8 +30,13 @@
 endif
 
+# Include sub-makefiles.
+include $(PATH_SUB_CURRENT)/testcase/Makefile.kmk
+
 
 #
 # VMMR3.dll
 #
+LIBRARIES += VMMR3
+
 VMMR3_TEMPLATE  = VBOXR3
 VMMR3_DEFS      = IN_VMM_R3  IN_PDM_R3  IN_CFGM_R3 IN_IOM_R3  IN_VM_R3   IN_CPUM_R3 IN_SELM_R3 IN_PGM_R3 IN_TRPM_R3 IN_MM_R3 IN_DBG_R3 \
@@ -54,5 +47,5 @@
  endif
 endif                
-VMMR3_INCS      := \
+VMMR3_INCS     := \
 	PATM \
 	$(PATH_SUB_CURRENT)
@@ -146,6 +139,30 @@
 
 #
+# The VMM DLL.
+#
+DLLS += VBoxVMM
+VBoxVMM_TEMPLATE = VBOXR3
+VBoxVMM_DEFS     = $(VMMR3_DEFS)
+VBoxVMM_SOURCES  = VBoxVMMDeps.cpp
+VBoxVMM_SONAME.linux = VBoxVMM.so
+
+VBoxVMM_LIBS     = \
+	$(PATH_LIB)/VMMR3$(VBOX_SUFF_LIB) \
+	$(PATH_LIB)/Debugger$(VBOX_SUFF_LIB) \
+	$(PATH_LIB)/DisasmR3$(VBOX_SUFF_LIB) \
+	$(LIB_REM) \
+	$(LIB_RUNTIME)
+
+VBoxVMM_LIBS.win = $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/delayimp.lib
+VBoxVMM_LDFLAGS.win = /DELAYLOAD:dbghelp.dll
+VBoxVMM_LDFLAGS.linux = -Wl,--no-undefined
+VBoxVMM_LDFLAGS.darwin = -install_name @executable_path/VBoxVMM.dylib
+
+
+#
 # VMMGCBuiltin.lib
 #
+ifneq ($(BUILD_TARGET),darwin)
+LIBRARIES += VMMGCBuiltin
 VMMGCBuiltin_TEMPLATE = VBOXGC
 ifeq ($(VBOX_LDR_FMT32),pe)
@@ -158,8 +175,12 @@
 	$(MV) -f $@.tmp $@
 endif
+endif # !darwin
+
 
 #
 # VMMGCImp.lib
 #
+ifneq ($(BUILD_TARGET),darwin)
+LIBRARIES += VMMGCImp
 VMMGCImp_TEMPLATE = VBOXGC
 ifeq ($(VBOX_LDR_FMT32),pe)
@@ -174,8 +195,12 @@
 	$(MV) -f $@.tmp $@
 endif
+endif # !darwin
+
 
 #
 # VMMR0Imp.lib
 #
+ifneq ($(BUILD_TARGET),darwin)
+LIBRARIES += VMMR0Imp
 VMMR0Imp_TEMPLATE = VBOXR0
 ifeq ($(VBOX_LDR_FMT),pe)
@@ -190,8 +215,11 @@
 	$(MV) -f $@.tmp $@
 endif
+endif # !darwin
+
 
 #
 # VMMGC.gc
 #
+SYSMODS += VMMGC
 VMMGC_TEMPLATE  = VBOXGC
 VMMGC_INCS     := \
@@ -276,4 +304,5 @@
 # VMMR0.r0
 #
+SYSMODS += VMMR0
 VMMR0_TEMPLATE  = VBOXR0
 VMMR0_INCS     := \
@@ -350,25 +379,5 @@
 
 
-#
-# The VMM DLL.
-#
-VBoxVMM_TEMPLATE = VBOXR3
-VBoxVMM_DEFS     = $(VMMR3_DEFS)
-VBoxVMM_SOURCES  = VBoxVMMDeps.cpp
-VBoxVMM_SONAME.linux = VBoxVMM.so
-
-VBoxVMM_LIBS     = \
-	$(PATH_LIB)/VMMR3$(VBOX_SUFF_LIB) \
-	$(PATH_LIB)/Debugger$(VBOX_SUFF_LIB) \
-	$(PATH_LIB)/DisasmR3$(VBOX_SUFF_LIB) \
-	$(LIB_REM) \
-	$(LIB_RUNTIME)
-
-VBoxVMM_LIBS.win = $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/delayimp.lib
-VBoxVMM_LDFLAGS.win = /DELAYLOAD:dbghelp.dll
-VBoxVMM_LDFLAGS.linux = -Wl,--no-undefined
-VBoxVMM_LDFLAGS.darwin = -install_name @executable_path/VBoxVMM.dylib
-
-include	$(PATH_KBUILD)/footer.kmk
+include	$(PATH_KBUILD)/subfooter.kmk
 
 
Index: trunk/src/VBox/VMM/testcase/Makefile.kmk
===================================================================
--- trunk/src/VBox/VMM/testcase/Makefile.kmk	(revision 2516)
+++ trunk/src/VBox/VMM/testcase/Makefile.kmk	(revision 2517)
@@ -1,5 +1,5 @@
 # $Id$
 ## @file
-# Makefile for the VMM testcases.
+# Sub-Makefile for the VMM testcases.
 #
 
@@ -20,17 +20,18 @@
 #
 
-DEPTH = ../../../..
-include	$(PATH_KBUILD)/header.kmk
+DEPTH ?= ../../../..
+SUB_DEPTH = ..
+include	$(PATH_KBUILD)/subheader.kmk
 
 #
 # Target lists.
 #
-PROGRAMS        = tstVMStructSize tstVMStructGC tstAsmStructs tstAsmStructsGC tstVMM tstVMM-HwAccm
+PROGRAMS   += tstVMStructSize tstVMStructGC tstAsmStructs tstAsmStructsGC tstVMM tstVMM-HwAccm
 ifdef VBOX_WITH_TESTCASES
- PROGRAMS       += tstCFGM tstSSM tstMMHyperHeap tstVMM-2 tstVMREQ tstMicro tstCompiler tstVMMR0CallHost-1
+ PROGRAMS  += tstCFGM tstSSM tstMMHyperHeap tstVMM-2 tstVMREQ tstMicro tstCompiler tstVMMR0CallHost-1
  ifneq ($(BUILD_TARGET),l4)
-  PROGRAMS      += tstAnimate
+  PROGRAMS += tstAnimate
  endif
- SYSMODS         = tstMicroGC
+ SYSMODS   += tstMicroGC
 endif # VBOX_WITH_TESTCASES
 
@@ -57,7 +58,7 @@
 
 #
-# Globals.
-#
-TEMPLATE = VBOXR3TSTEXE
+# Globals
+#
+VBOX_PATH_VMM_SRC = $(PATH_SUB_ROOT)
 
 #
@@ -67,14 +68,16 @@
 tstVMStructGC_DEFS      = IN_VMM_GC IN_PDM_GC IN_CFGM_GC IN_IOM_GC IN_VM_GC IN_CPUM_GC IN_SELM_GC IN_PGM_GC IN_TRPM_GC IN_MM_GC IN_PDM_GC IN_DBGF_GC IN_PATM_GC IN_DIS_GC IN_STAM_GC IN_VGADEVICE_GC IN_CSAM_GC IN_SSM_GC IN_REM_GC IN_RRM_GC
 tstVMStructGC_SOURCES   = tstVMStructGC.cpp
-tstVMStructGC_INCS      = .. ../PATM
-
+tstVMStructGC_INCS      = $(VBOX_PATH_VMM_SRC) $(VBOX_PATH_VMM_SRC)/PATM
+
+tstVMStructSize_TEMPLATE= VBOXR3TSTEXE
 tstVMStructSize_DEFS    = IN_VMM_R3 IN_PDM_R3 IN_CFGM_R3 IN_IOM_R3 IN_VM_R3 IN_CPUM_R3 IN_SELM_R3 IN_PGM_R3 IN_TRPM_R3 IN_MM_R3 IN_PDM_R3 IN_DBGF_R3 IN_PATM_R3 IN_DIS_R3 IN_STAM_R3 IN_VGADEVICE_R3 IN_CSAM_R3 IN_SSM_R3 IN_REM_R3
-tstVMStructSize_INCS    = .. ../PATM $(PATH_TARGET)
+tstVMStructSize_INCS    = $(VBOX_PATH_VMM_SRC) $(VBOX_PATH_VMM_SRC)/PATM $(PATH_TARGET)
 tstVMStructSize_SOURCES = tstVMStructSize.cpp
 tstVMStructSize_LIBS.l4 = $(LIB_RUNTIME)
 tstVMStructSize.cpp_DEPS= $(PATH_TARGET)/tstVMStructGC.h
 
+tstAsmStructs_TEMPLATE  = VBOXR3TSTEXE
 tstAsmStructs_DEFS      = IN_VMM_R3 IN_PDM_R3 IN_CFGM_R3 IN_IOM_R3 IN_VM_R3 IN_CPUM_R3 IN_SELM_R3 IN_PGM_R3 IN_TRPM_R3 IN_MM_R3 IN_PDM_R3 IN_DBGF_R3 IN_PATM_R3 IN_DIS_R3 IN_STAM_R3 IN_VGADEVICE_R3 IN_CSAM_R3 IN_SSM_R3
-tstAsmStructs_INCS      = .. $(PATH_TARGET)
+tstAsmStructs_INCS      = $(VBOX_PATH_VMM_SRC) $(PATH_TARGET)
 tstAsmStructs_SOURCES   = tstAsmStructs.cpp
 tstAsmStructs_LIBS.l4   = $(LIB_RUNTIME)
@@ -82,5 +85,5 @@
 tstAsmStructsGC_TEMPLATE= VBOXGCEXE
 tstAsmStructsGC_DEFS    = IN_VMM_GC IN_PDM_GC IN_CFGM_GC IN_IOM_GC IN_VM_GC IN_CPUM_GC IN_SELM_GC IN_PGM_GC IN_TRPM_GC IN_MM_GC IN_PDM_GC IN_DBGF_GC IN_PATM_GC IN_DIS_GC IN_STAM_GC IN_VGADEVICE_GC IN_CSAM_GC IN_SSM_GC IN_RRM_GC
-tstAsmStructsGC_INCS    = .. $(PATH_TARGET)
+tstAsmStructsGC_INCS    = $(VBOX_PATH_VMM_SRC) $(PATH_TARGET)
 tstAsmStructsGC_SOURCES = tstAsmStructs.cpp
 
@@ -88,45 +91,49 @@
 
 
+tstMMHyperHeap_TEMPLATE = VBOXR3TSTEXE
 tstMMHyperHeap_SOURCES  = tstMMHyperHeap.cpp
 tstMMHyperHeap_LIBS     = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
+tstSSM_TEMPLATE         = VBOXR3TSTEXE
 tstSSM_SOURCES          = tstSSM.cpp
 tstSSM_LIBS             = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
+tstCFGM_TEMPLATE        = VBOXR3TSTEXE
 tstCFGM_SOURCES         = tstCFGM.cpp
 tstCFGM_LIBS            = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
+tstVMM_TEMPLATE         = VBOXR3EXE
 tstVMM_SOURCES          = tstVMM.cpp
-tstVMM_TEMPLATE         = VBOXR3EXE
 tstVMM_LIBS             = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
+tstVMM-HwAccm_TEMPLATE  = VBOXR3EXE
 tstVMM-HwAccm_SOURCES   = tstVMM-HwAccm.cpp
-tstVMM-HwAccm_TEMPLATE  = VBOXR3EXE
 tstVMM-HwAccm_LIBS      = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
+tstVMM-2_TEMPLATE       = VBOXR3EXE
 tstVMM-2_SOURCES        = tstVMM-2.cpp
-tstVMM-2_TEMPLATE       = VBOXR3EXE
 tstVMM-2_LIBS           = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
 tstVMMR0CallHost-1_TEMPLATE = VBOXR3EXE
-tstVMMR0CallHost-1_INCS  = ..
-tstVMMR0CallHost-1_SOURCES  = \
+tstVMMR0CallHost-1_INCS  = $(VBOX_PATH_VMM_SRC)
+tstVMMR0CallHost-1_SOURCES = \
 	tstVMMR0CallHost-1.cpp \
-	../VMMR0/VMMR0A.asm
-tstVMMR0CallHost-1_LIBS     = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
-
+	$(VBOX_PATH_VMM_SRC)/VMMR0/VMMR0A.asm
+tstVMMR0CallHost-1_LIBS  = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
+
+tstVMREQ_TEMPLATE       = VBOXR3EXE
 tstVMREQ_SOURCES        = tstVMREQ.cpp
-tstVMREQ_TEMPLATE       = VBOXR3EXE
 tstVMREQ_LIBS           = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
+tstAnimate_TEMPLATE     = VBOXR3EXE
 tstAnimate_SOURCES      = tstAnimate.cpp
-tstAnimate_TEMPLATE     = VBOXR3EXE
 tstAnimate_LIBS         = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
+tstCompiler_TEMPLATE    = VBOXR3TSTEXE
 tstCompiler_SOURCES     = tstCompiler.cpp
 tstCompiler_LIBS        = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
+tstMicro_TEMPLATE       = VBOXR3EXE
 tstMicro_SOURCES        = tstMicro.cpp
-tstMicro_TEMPLATE       = VBOXR3EXE
 tstMicro_LIBS           = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
@@ -150,9 +157,15 @@
 
 
-include	$(PATH_KBUILD)/footer.kmk
-
-
-#
-# Some handcrafted support for tstAsmStructs.
+
+
+include	$(PATH_KBUILD)/subfooter.kmk
+
+
+# temporary hack.
+.NOTPARALLEL: $(TARGET_tstMicroGC) $(LIB_VMMGC)
+
+
+#
+# Some handcrafted support targets for tstAsmStructs.
 #
 
@@ -165,14 +178,16 @@
 
 # 1a. make a header file which makes all the structures+members globals.
-$(PATH_TARGET)/tstAsmStructsAsm.mac: tstAsmStructsAsm.asm tstAsmStructsAsm-lst.sed \
+$(PATH_TARGET)/tstAsmStructsAsm.mac: \
+		$(VBOX_PATH_VMM_SRC)/testcase/tstAsmStructsAsm.asm \
+		$(VBOX_PATH_VMM_SRC)/testcase/tstAsmStructsAsm-lst.sed \
 		$(DEPTH)/include/iprt/asmdefs.mac \
 		$(DEPTH)/include/VBox/cpum.mac \
 		$(DEPTH)/include/VBox/vm.mac \
-		../CPUMInternal.mac \
-		../TRPMInternal.mac \
-		../VMMInternal.mac \
-		Makefile.kmk \
+		$(VBOX_PATH_VMM_SRC)/CPUMInternal.mac \
+		$(VBOX_PATH_VMM_SRC)/TRPMInternal.mac \
+		$(VBOX_PATH_VMM_SRC)/VMMInternal.mac \
+		$(VBOX_PATH_VMM_SRC)/testcase/Makefile.kmk \
 		| $(call DIRDEP,$(PATH_TARGET))
-	$(call MSG_COMPILE,tstAsmStructsAsm,$<,$@,AS)
+	$(call MSG_GENERATE,tstVMStructSize,$@,$<)
 ifndef DONT_USE_YASM
 	$(QUIET)$(TOOL_YASM_AS) \
@@ -187,5 +202,5 @@
 		-f $(if $(eq $(BUILD_TARGET),darwin),macho,elf) \
 		$(foreach inc,$(INCS),-I$(inc)/) -o $@.o -l $@.lst $<
-	$(SED) -f tstAsmStructsAsm-lst.sed $@.lst > $@
+	$(SED) -f $(VBOX_PATH_VMM_SRC)/testcase/tstAsmStructsAsm-lst.sed $@.lst > $@
 else
 	$(QUIET)$(TOOL_NASM_AS) \
@@ -207,9 +222,9 @@
 endif
 
-
-
 # 1b. make an elf/macho object containing the offsets.
-$(PATH_TARGET)/tstAsmStructsAsm.o: tstAsmStructsAsm.asm $(PATH_TARGET)/tstAsmStructsAsm.mac \
-		Makefile.kmk \
+$(PATH_TARGET)/tstAsmStructsAsm.o: \
+		$(VBOX_PATH_VMM_SRC)/testcase/tstAsmStructsAsm.asm \
+		$(PATH_TARGET)/tstAsmStructsAsm.mac \
+		$(VBOX_PATH_VMM_SRC)/testcase/Makefile.kmk \
 		| $(call DIRDEP,$(PATH_TARGET))
 	$(call MSG_COMPILE,tstAsmStructsasm,$<,$@,AS)
@@ -244,5 +259,5 @@
 # 2. use nm and sed to transform this into the header we want.
 $(PATH_TARGET)/tstAsmStructsHC.h: $(PATH_TARGET)/tstAsmStructsAsm.o
-	$(call MSG_GENERATE,,$@,$<)
+	$(call MSG_GENERATE,tstVMStructSize,$@,$<)
 	$(QUIET)$(RM) -f $@ $@.dump $@.tmp
 	$(VBOX_NM) $< > $@.dump
@@ -258,5 +273,5 @@
 # 3. transform the HC header into a GC one by omitting some HC only structures.
 $(PATH_TARGET)/tstAsmStructsGC.h: $(PATH_TARGET)/tstAsmStructsHC.h
-	$(call MSG_GENERATE,,$@,$<)
+	$(call MSG_GENERATE,tstVMStructSize,$@,$<)
 	$(QUIET)$(SED) -e '/VMMSWITCHERDEF/d' \
 		$^ > $@
@@ -269,18 +284,16 @@
 	$(QUIET)$(APPEND) "$@" "done"
 
+
+
 #
 # Run rule for tstVMStructSize.
 #
 
-# 1. Dump selected structure in the VMMGC.gc debug info.
-# 2. Generate a testcase from the dump
-## future
-
-# 1&2. Manually dump selected structures and members.
+# 1. Manually dump selected structures and members.
 $(PATH_TARGET)/tstVMStructGC.h: $(INSTARGET_tstVMStructGC)
-	$(call MSG_GENERATE,,$@)
+	$(call MSG_GENERATE,tstVMStructSize,$@)
 	$(QUIET)$(INSTARGET_tstVMStructGC) > $@
 
-# 3. run it.
+# 2. run it.
 $(PATH_TARGET)/tstVMStructSize.run: $(INSTARGET_tstVMStructSize)
 	$(QUIET)$(RM) -f $@
