Index: trunk/kBuild/footer.kmk
===================================================================
--- trunk/kBuild/footer.kmk	(revision 182)
+++ trunk/kBuild/footer.kmk	(revision 183)
@@ -98,5 +98,5 @@
 	$($(type)TOOL.$(BUILD_TARGET)) $(TOOL.$(BUILD_TARGET)) \
 	$($(type)TOOL) $(TOOL) ))
-		
+
 ## Figure out the tool for a target.
 # @param    $target 		normalized target.
@@ -112,5 +112,5 @@
 	$(TOOL) \
 	))
-	
+
 ## Removes the drive letter from a path (if it has one)
 # @param	$1 		the path
@@ -214,5 +214,5 @@
 endef
 
-## Inherit one template property.		
+## Inherit one template property.
 # @param    $(prop)     Property name
 # @param    $(target)	Target name
@@ -252,5 +252,5 @@
 #
 # Include tools
-# 			
+#
 _TOOLS := $(TOOL)
 define def_tools_target_source
@@ -647,4 +647,5 @@
 ))
 $(eval lib         := $(outbase)$(libsuff))
+$(eval TARGET_$(target) := $(lib))
 
 # source -> object
@@ -675,5 +676,5 @@
 $(publib) : $(lib) $(dir $(publib)).dir_created
 	$(CP) $(lib) $(publib)
-	
+
 _LIBS += $(publib)
 _OUT_FILES += $(lib) $(publib)
@@ -703,4 +704,5 @@
 $(eval exesuff     := $(firstword $($(target)_EXESUFF) $($(target)_EXESUFF) $(TOOL_$(tool)_LDEXESUFF) $(SUFF_EXE)))
 $(eval exe         := $(outbase)$(exesuff))
+$(eval TARGET_$(target) := $(exe))
 
 # source -> object
@@ -826,5 +828,5 @@
 $(pubexe) : $(exe) $(dir $(pubexe)).dir_created
 	$(CP) $(exe) $(pubexe)
-	
+
 _DLLS += $(pubexe)
 _OUT_FILES += $(exe) $(pubexe)
@@ -854,9 +856,10 @@
 $(eval dllsuff     := $(firstword $($(target)_DLLSUFF) $($(target)_DLLSUFF) $(TOOL_$(tool)_LDDLLSUFF) $(SUFF_DLL)))
 $(eval dll         := $(outbase)$(dllsuff))
+$(eval TARGET_$(target) := $(dll))
 
 # source -> object
 $(eval $(def_target_sources))
 
-# dllmod linking. 
+# dllmod linking.
 $(eval tool        := $(call _TARGET_TOOL,$(target),LD))
 $(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
@@ -982,9 +985,9 @@
 	7 $(TOOL.$(BUILD_TARGET)) \
 	8 $(TOOL) )
-endif	
+endif
 
 $(eval $(TOOL_$(tool)_LINK_DLL))
 
-					
+
 # publish rule (still need work)
 ifndef $(target)_NOINST
@@ -992,5 +995,5 @@
 $(pubdll) : $(dll) $(dir $(pubdll)).dir_created
 	$(CP) $(dll) $(pubdll)
-	
+
 _DLLS += $(pubdll)
 _OUT_FILES += $(dll) $(pubdll)
@@ -1019,4 +1022,5 @@
 $(eval syssuff     := $(firstword $($(target)_SYSSUFF) $($(target)_SYSSUFF) $(TOOL_$(tool)_LDSYSSUFF) $(SUFF_SYS)))
 $(eval sys         := $(outbase)$(syssuff))
+$(eval TARGET_$(target) := $(sys))
 
 # source -> object
@@ -1147,5 +1151,5 @@
 	7 $(TOOL.$(BUILD_TARGET)) \
 	8 $(TOOL) )
-endif	
+endif
 
 $(eval $(TOOL_$(tool)_LINK_SYSMOD))
@@ -1156,5 +1160,5 @@
 $(pubsys): $(sys) $(dir $(pubsys)).dir_created
 	$(CP) $(sys) $(pubsys)
-	
+
 $(eval _SYSMODS += $(pubsys))
 $(eval _OUT_FILES += $(sys) $(pubsys))
@@ -1197,5 +1201,5 @@
 $(foreach dirfile,$(_DIRFILES),$(eval $(def_createdir)))
 
-		
+
 #
 # Include dependency files.
@@ -1203,5 +1207,5 @@
 $(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
 
-		
+
 #
 # PASSES (including directory and makefile walking)
@@ -1241,16 +1245,16 @@
 # @param	$(PASS)		Uppercase pass name.
 define def_pass
-$(eval SUBDIRS_$(PASS)          ?= $(SUBDIRS))
-$(eval SUBDIRS_AFTER_$(PASS)    ?= $(SUBDIRS_AFTER))
-$(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE))
-$(eval MAKEFILES_AFTER_$(PASS)  ?= $(MAKEFILES_AFTER))
+$(eval SUBDIRS_$(PASS)          ?= $(SUBDIRS)          $(SUBDIRS.$(BUILD_TARGET)))
+$(eval SUBDIRS_AFTER_$(PASS)    ?= $(SUBDIRS_AFTER)    $(SUBDIRS_AFTER.$(BUILD_TARGET)))
+$(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)))
+$(eval MAKEFILES_AFTER_$(PASS)  ?= $(MAKEFILES_AFTER)  $(MAKEFILES_AFTER.$(BUILD_TARGET)))
 
 $(eval tag:=_before)
-$(foreach subdir,$(SUBDIRS_$(PASS)),$(eval $(def_pass_subdir)))
-$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)),$(eval $(def_pass_makefile)))
+$(foreach subdir,$(SUBDIRS_$(PASS))            $(SUBDIRS_$(PASS).$(BUILD_TARGET))         ,$(eval $(def_pass_subdir)))
+$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)),$(eval $(def_pass_makefile)))
 
 $(eval tag:=_after)
-$(foreach subdir,$(SUBDIRS_AFTER_$(PASS)),$(eval $(def_pass_subdir)))
-$(foreach makefile,$(MAKEFILES_AFTER_$(PASS)),$(eval $(def_pass_makefile)))
+$(foreach subdir,$(SUBDIRS_AFTER_$(PASS))      $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET))   ,$(eval $(def_pass_subdir)))
+$(foreach makefile,$(MAKEFILES_AFTER_$(PASS))  $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile)))
 
 .NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
@@ -1260,8 +1264,8 @@
 	pass_$(pass)_doit \
 	pass_$(pass)_after
-	
-endef	
-
-					
+
+endef
+
+
 ## PASS: needed
 # This pass builds targets which are required for building the rest.
@@ -1299,8 +1303,8 @@
 PASS := PUBLISH
 # $(sort).. not nice.
-SUBDIRS_PUBLISH         ?= $(sort $(SUBDIRS) $(SUBDIRS_LIBRARIES) $(SUBDIRS_BINARIES) $(SUBDIRS_OTHERS))
-SUBDIRS_AFTER_PUBLISH   ?= $(sort $(SUBDIRS_AFTER) $(SUBDIRS_AFTER_LIBRARIES) $(SUBDIRS_AFTER_BINARIES) $(SUBDIRS_AFTER_OTHERS))
-MAKEFILES_BEFORE_PUBLISH?= $(sort $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE_LIBRARIES) $(MAKEFILES_BEFORE_BINARIES) $(MAKEFILES_BEFORE_OTHERS))
-MAKEFILES_AFTER_PUBLISH ?= $(sort $(MAKEFILES_AFTER) $(MAKEFILES_AFTER_LIBRARIES) $(MAKEFILES_AFTER_BINARIES) $(MAKEFILES_AFTER_OTHERS))
+SUBDIRS_PUBLISH         ?= $(sort $(SUBDIRS)          $(SUBDIRS.$(BUILD_TARGET))          $(SUBDIRS_LIBRARIES)          $(SUBDIRS_LIBRARIES.$(BUILD_TARGET))          $(SUBDIRS_BINARIES)          $(SUBDIRS_BINARIES.$(BUILD_TARGET))          $(SUBDIRS_OTHERS)          $(SUBDIRS_OTHERS.$(BUILD_TARGET)))
+SUBDIRS_AFTER_PUBLISH   ?= $(sort $(SUBDIRS_AFTER)    $(SUBDIRS_AFTER.$(BUILD_TARGET))    $(SUBDIRS_AFTER_LIBRARIES)    $(SUBDIRS_AFTER_LIBRARIES.$(BUILD_TARGET))    $(SUBDIRS_AFTER_BINARIES)    $(SUBDIRS_AFTER_BINARIES.$(BUILD_TARGET))    $(SUBDIRS_AFTER_OTHERS)    $(SUBDIRS_AFTER_OTHERS.$(BUILD_TARGET)))
+MAKEFILES_BEFORE_PUBLISH?= $(sort $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)) $(MAKEFILES_BEFORE_LIBRARIES) $(MAKEFILES_BEFORE_LIBRARIES.$(BUILD_TARGET)) $(MAKEFILES_BEFORE_BINARIES) $(MAKEFILES_BEFORE_BINARIES.$(BUILD_TARGET)) $(MAKEFILES_BEFORE_OTHERS) $(MAKEFILES_BEFORE_OTHERS.$(BUILD_TARGET)))
+MAKEFILES_AFTER_PUBLISH ?= $(sort $(MAKEFILES_AFTER)  $(MAKEFILES_AFTER.$(BUILD_TARGET))  $(MAKEFILES_AFTER_LIBRARIES)  $(MAKEFILES_AFTER_LIBRARIES.$(BUILD_TARGET))  $(MAKEFILES_AFTER_BINARIES)  $(MAKEFILES_AFTER_BINARIES.$(BUILD_TARGET))  $(MAKEFILES_AFTER_OTHERS)  $(MAKEFILES_AFTER_OTHERS.$(BUILD_TARGET)))
 $(eval $(def_pass))
 
@@ -1321,5 +1325,5 @@
 $(eval $(def_pass))
 clean: pass_clean
-		
+
 ## PASS: nothing
 # This pass just walks the tree.
@@ -1331,5 +1335,5 @@
 nothing: pass_nothing
 
-					
+
 
 #
@@ -1346,5 +1350,5 @@
 objects:   $(_OBJS)
 programs:  $(_EXES)
-dlls:      $(_DLLS)	
+dlls:      $(_DLLS)
 sysmods:   $(_SYSMODS)
 
