Add support for a saving build objects in a separate directory.
Modifications are based on the linux kernel approach and
support two use cases:

  1) Add O= to the make command line
  'make O=/tmp/build all'

  2) Set environement variable BUILD_DIR to point to the desired location
  'export BUILD_DIR=/tmp/build'
  'make'

The second approach can also be used with a MAKEALL script
'export BUILD_DIR=/tmp/build'
'./MAKEALL'

Command line 'O=' setting overrides BUILD_DIR environent variable.

When none of the above methods is used the local build is performed and
the object files are placed in the source directory.
diff --git a/CHANGELOG b/CHANGELOG
index 229db83..b2f2aa9 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,26 @@
 Changes since U-Boot 1.1.4:
 ======================================================================
 
+* Add support for a saving build objects in a separate directory.
+  Modifications are based on the linux kernel approach and 
+  support two use cases:
+  
+  1) Add O= to the make command line
+  'make O=/tmp/build all'
+
+  2) Set environement variable BUILD_DIR to point to the desired location
+  'export BUILD_DIR=/tmp/build'
+  'make'
+
+  The second approach can also be used with a MAKEALL script
+  'export BUILD_DIR=/tmp/build'
+  './MAKEALL'
+ 
+  Command line 'O=' setting overrides BUILD_DIR environent variable.
+ 
+  When none of the above methods is used the local build is performed and
+  the object files are placed in the source directory.
+
 * Remove the board/netstar/crcit binary from git repository.
 
 * Fix tools/updater build error.
diff --git a/MAKEALL b/MAKEALL
index 720ab03..d2f86d3 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -8,7 +8,17 @@
 	MAKE=make
 fi
 
-[ -d LOG ] || mkdir LOG || exit 1
+if [ "${MAKEALL_LOGDIR}" ] ; then
+	LOG_DIR=${MAKEALL_LOGDIR}
+else
+	LOG_DIR="LOG"
+fi
+	
+if [ ! "${BUILD_DIR}" ] ; then
+	BUILD_DIR="."
+fi
+
+[ -d ${MAKEALL_LOGDIR} ] || mkdir ${MAKEALL_LOGDIR} || exit 1
 
 LIST=""
 
@@ -303,8 +313,12 @@
 
 	${MAKE} distclean >/dev/null
 	${MAKE} ${target}_config
-	${MAKE} ${JOBS} all 2>&1 >LOG/$target.MAKELOG | tee LOG/$target.ERR
-	${CROSS_COMPILE:-ppc_8xx-}size u-boot | tee -a LOG/$target.MAKELOG
+
+	${MAKE} ${JOBS} all 2>&1 >${LOG_DIR}/$target.MAKELOG \
+				| tee ${LOG_DIR}/$target.ERR
+
+	${CROSS_COMPILE:-ppc_8xx-}size ${BUILD_DIR}/u-boot \
+				| tee -a ${LOG_DIR}/$target.MAKELOG
 }
 
 #-----------------------------------------------------------------------
diff --git a/Makefile b/Makefile
index 9bf7c49..fc7b117 100644
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@
 SUBLEVEL = 4
 EXTRAVERSION =
 U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
-VERSION_FILE = include/version_autogenerated.h
+VERSION_FILE = $(obj)include/version_autogenerated.h
 
 HOSTARCH := $(shell uname -m | \
 	sed -e s/i.86/i386/ \
@@ -45,14 +45,73 @@
 VENDOR=
 
 #########################################################################
+#
+# U-boot build supports producing a object files to the separate external
+# directory. Two use cases are supported:
+# 
+# 1) Add O= to the make command line
+# 'make O=/tmp/build all'
+#
+# 2) Set environement variable BUILD_DIR to point to the desired location
+# 'export BUILD_DIR=/tmp/build'
+# 'make'
+#
+# The second approach can also be used with a MAKEALL script
+# 'export BUILD_DIR=/tmp/build'
+# './MAKEALL'
+# 
+# Command line 'O=' setting overrides BUILD_DIR environent variable.
+# 
+# When none of the above methods is used the local build is performed and
+# the object files are placed in the source directory.
+# 
 
-TOPDIR	:= $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
-export	TOPDIR
+ifdef O
+ifeq ("$(origin O)", "command line")
+BUILD_DIR := $(O)
+endif
+endif
+
+ifneq ($(BUILD_DIR),)
+saved-output := $(BUILD_DIR)
+BUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd)
+$(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist))
+endif # ifneq ($(BUILD_DIR),)
+
+OBJTREE		:= $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))
+SRCTREE		:= $(CURDIR)
+TOPDIR		:= $(SRCTREE)
+LNDIR		:= $(OBJTREE)
+export	TOPDIR SRCTREE OBJTREE
+
+MKCONFIG	:= $(SRCTREE)/mkconfig
+export MKCONFIG
+
+ifneq ($(OBJTREE),$(SRCTREE))
+REMOTE_BUILD 	:= 1
+export REMOTE_BUILD
+endif
 
-ifeq (include/config.mk,$(wildcard include/config.mk))
+# $(obj) and (src) are defined in config.mk but here in main Makefile
+# we also need them before config.mk is included which is the case for
+# some targets like unconfig, clean, clobber, distclean, etc.
+ifneq ($(OBJTREE),$(SRCTREE))
+obj := $(OBJTREE)/
+src := $(SRCTREE)/
+else
+obj :=
+src :=
+endif   
+export obj src
+
+#########################################################################
+
+ifeq ($(OBJTREE)/include/config.mk,$(wildcard $(OBJTREE)/include/config.mk))
+
 # load ARCH, BOARD, and CPU configuration
-include include/config.mk
+include $(OBJTREE)/include/config.mk
 export	ARCH CPU BOARD VENDOR SOC
+
 ifndef CROSS_COMPILE
 ifeq ($(HOSTARCH),ppc)
 CROSS_COMPILE =
@@ -96,7 +155,6 @@
 # load other configuration
 include $(TOPDIR)/config.mk
 
-
 #########################################################################
 # U-Boot objects....order is important (i.e. start must be first)
 
@@ -119,6 +177,8 @@
 OBJS += cpu/$(CPU)/cplbhdlr.o	cpu/$(CPU)/cplbmgr.o	cpu/$(CPU)/flush.o
 endif
 
+OBJS := $(addprefix $(obj),$(OBJS))
+
 LIBS  = lib_generic/libgeneric.a
 LIBS += board/$(BOARDDIR)/lib$(BOARD).a
 LIBS += cpu/$(CPU)/lib$(CPU).a
@@ -139,12 +199,13 @@
 LIBS += post/libpost.a post/cpu/libcpu.a
 LIBS += common/libcommon.a
 LIBS += $(BOARDLIBS)
+
+LIBS := $(addprefix $(obj),$(LIBS))
 .PHONY : $(LIBS)
 
 # Add GCC lib
 PLATFORM_LIBS += -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
 
-
 # The "tools" are needed early, so put this first
 # Don't include stuff already done in $(LIBS)
 SUBDIRS	= tools \
@@ -153,40 +214,46 @@
 	  post/cpu
 .PHONY : $(SUBDIRS)
 
+__OBJS := $(subst $(obj),,$(OBJS))
+__LIBS := $(subst $(obj),,$(LIBS))
+
 #########################################################################
 #########################################################################
 
-ALL = u-boot.srec u-boot.bin System.map
+ALL = $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map
 
 all:		$(ALL)
 
-u-boot.hex:	u-boot
+$(obj)u-boot.hex:	$(obj)u-boot
 		$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
 
-u-boot.srec:	u-boot
+$(obj)u-boot.srec:	$(obj)u-boot
 		$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@
 
-u-boot.bin:	u-boot
+$(obj)u-boot.bin:	$(obj)u-boot
 		$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
 
-u-boot.img:	u-boot.bin
+$(obj)u-boot.img:	$(obj)u-boot.bin
 		./tools/mkimage -A $(ARCH) -T firmware -C none \
 		-a $(TEXT_BASE) -e 0 \
 		-n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
 			sed -e 's/"[	 ]*$$/ for $(BOARD) board"/') \
 		-d $< $@
 
-u-boot.dis:	u-boot
+$(obj)u-boot.dis:	$(obj)u-boot
 		$(OBJDUMP) -d $< > $@
 
-u-boot:		depend version $(SUBDIRS) $(OBJS) $(LIBS) $(LDSCRIPT)
+$(obj)u-boot:		depend version $(SUBDIRS) $(OBJS) $(LIBS) $(LDSCRIPT)
 		UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) |sed  -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
-		$(LD) $(LDFLAGS) $$UNDEF_SYM $(OBJS) \
-			--start-group $(LIBS) --end-group $(PLATFORM_LIBS) \
+		cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \
+			--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
 			-Map u-boot.map -o u-boot
 
+$(OBJS):
+		$(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@))
+
 $(LIBS):
-		$(MAKE) -C `dirname $@`
+		$(MAKE) -C $(dir $(subst $(obj),,$@))
 
 $(SUBDIRS):
 		$(MAKE) -C $@ all
@@ -199,33 +266,42 @@
 		echo "\"" >> $(VERSION_FILE)
 
 gdbtools:
-		$(MAKE) -C tools/gdb || exit 1
+		$(MAKE) -C tools/gdb all || exit 1
+
+updater:
+		$(MAKE) -C tools/updater all || exit 1
+
+env:
+		$(MAKE) -C tools/env all || exit 1
 
 depend dep:
-		@for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir .depend ; done
+		for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir _depend ; done
 
-tags:
-		ctags -w `find $(SUBDIRS) include \
+tags ctags:
+		ctags -w -o $(OBJTREE)/ctags `find $(SUBDIRS) include \
 				lib_generic board/$(BOARDDIR) cpu/$(CPU) lib_$(ARCH) \
 				fs/cramfs fs/fat fs/fdos fs/jffs2 \
 				net disk rtc dtt drivers drivers/sk98lin common \
 			\( -name CVS -prune \) -o \( -name '*.[ch]' -print \)`
 
 etags:
-		etags -a `find $(SUBDIRS) include \
+		etags -a -o $(OBJTREE)/etags `find $(SUBDIRS) include \
 				lib_generic board/$(BOARDDIR) cpu/$(CPU) lib_$(ARCH) \
 				fs/cramfs fs/fat fs/fdos fs/jffs2 \
 				net disk rtc dtt drivers drivers/sk98lin common \
 			\( -name CVS -prune \) -o \( -name '*.[ch]' -print \)`
 
-System.map:	u-boot
+$(obj)System.map:	$(obj)u-boot
 		@$(NM) $< | \
 		grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
-		sort > System.map
+		sort > $(obj)System.map
 
 #########################################################################
 else
-all install u-boot u-boot.srec depend dep:
+all $(obj)u-boot.hex $(obj)u-boot.srec $(obj)u-boot.bin \
+$(obj)u-boot.img $(obj)u-boot.dis $(obj)u-boot \
+$(SUBDIRS) version gdbtools updater env depend \
+dep tags ctags etags $(obj)System.map:
 	@echo "System not configured - see README" >&2
 	@ exit 1
 endif
@@ -233,7 +309,7 @@
 #########################################################################
 
 unconfig:
-	@rm -f include/config.h include/config.mk board/*/config.tmp
+	@rm -f $(obj)include/config.h $(obj)include/config.mk $(obj)board/*/config.tmp
 
 #========================================================================
 # PowerPC
@@ -244,29 +320,29 @@
 #########################################################################
 
 canmb_config:	unconfig
-	@./mkconfig -a canmb ppc mpc5xxx canmb
+	@$(MKCONFIG) -a canmb ppc mpc5xxx canmb
 
 cmi_mpc5xx_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc5xx cmi
+	@$(MKCONFIG) $(@:_config=) ppc mpc5xx cmi
 
 PATI_config:		unconfig
-	@./mkconfig $(@:_config=) ppc mpc5xx pati mpl
+	@$(MKCONFIG) $(@:_config=) ppc mpc5xx pati mpl
 
 #########################################################################
 ## MPC5xxx Systems
 #########################################################################
 
 aev_config: unconfig
-	@./mkconfig -a aev ppc mpc5xxx tqm5200
+	@$(MKCONFIG) -a aev ppc mpc5xxx tqm5200
 
 BC3450_config:	unconfig
-	@./mkconfig -a BC3450 ppc mpc5xxx bc3450
+	@$(MKCONFIG) -a BC3450 ppc mpc5xxx bc3450
 
 cpci5200_config:  unconfig
-	@./mkconfig -a cpci5200  ppc mpc5xxx cpci5200 esd
+	@$(MKCONFIG) -a cpci5200  ppc mpc5xxx cpci5200 esd
 
 hmi1001_config:         unconfig
-	@./mkconfig hmi1001 ppc mpc5xxx hmi1001
+	@$(MKCONFIG) hmi1001 ppc mpc5xxx hmi1001
 
 Lite5200_config				\
 Lite5200_LOWBOOT_config			\
@@ -278,49 +354,53 @@
 icecube_5200_DDR_LOWBOOT_config 	\
 icecube_5200_DDR_LOWBOOT08_config	\
 icecube_5100_config:			unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@mkdir -p $(obj)board/icecube
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring LOWBOOT_,$@)" ] || \
 		{ if [ "$(findstring DDR,$@)" ] ; \
-			then echo "TEXT_BASE = 0xFF800000" >board/icecube/config.tmp ; \
-			else echo "TEXT_BASE = 0xFF000000" >board/icecube/config.tmp ; \
+			then echo "TEXT_BASE = 0xFF800000" >$(obj)board/icecube/config.tmp ; \
+			else echo "TEXT_BASE = 0xFF000000" >$(obj)board/icecube/config.tmp ; \
 		  fi ; \
 		  echo "... with LOWBOOT configuration" ; \
 		}
 	@[ -z "$(findstring LOWBOOT08,$@)" ] || \
-		{ echo "TEXT_BASE = 0xFF800000" >board/icecube/config.tmp ; \
+		{ echo "TEXT_BASE = 0xFF800000" >$(obj)board/icecube/config.tmp ; \
 		  echo "... with 8 MB flash only" ; \
 		  echo "... with LOWBOOT configuration" ; \
 		}
 	@[ -z "$(findstring DDR,$@)" ] || \
-		{ echo "#define CONFIG_MPC5200_DDR"	>>include/config.h ; \
+		{ echo "#define CONFIG_MPC5200_DDR"	>>$(obj)include/config.h ; \
 		  echo "... DDR memory revision" ; \
 		}
 	@[ -z "$(findstring 5200,$@)" ] || \
-		{ echo "#define CONFIG_MPC5200"		>>include/config.h ; \
+		{ echo "#define CONFIG_MPC5200"		>>$(obj)include/config.h ; \
 		  echo "... with MPC5200 processor" ; \
 		}
 	@[ -z "$(findstring 5100,$@)" ] || \
-		{ echo "#define CONFIG_MGT5100"		>>include/config.h ; \
+		{ echo "#define CONFIG_MGT5100"		>>$(obj)include/config.h ; \
 		  echo "... with MGT5100 processor" ; \
 		}
-	@./mkconfig -a IceCube ppc mpc5xxx icecube
+	@$(MKCONFIG) -a IceCube ppc mpc5xxx icecube
 
 inka4x0_config:	unconfig
-	@./mkconfig inka4x0 ppc mpc5xxx inka4x0
+	@$(MKCONFIG) inka4x0 ppc mpc5xxx inka4x0
 
 lite5200b_config	\
 lite5200b_LOWBOOT_config:	unconfig
-	@ >include/config.h
-	@ echo "#define CONFIG_MPC5200_DDR"	>>include/config.h
+	@mkdir -p $(obj)include
+	@mkdir -p $(obj)board/icecube
+	@ >$(obj)include/config.h
+	@ echo "#define CONFIG_MPC5200_DDR"	>>$(obj)include/config.h
 	@ echo "... DDR memory revision"
-	@ echo "#define CONFIG_MPC5200"		>>include/config.h
-	@ echo "#define CONFIG_LITE5200B"	>>include/config.h
+	@ echo "#define CONFIG_MPC5200"		>>$(obj)include/config.h
+	@ echo "#define CONFIG_LITE5200B"	>>$(obj)include/config.h
 	@[ -z "$(findstring LOWBOOT_,$@)" ] || \
-		{ echo "TEXT_BASE = 0xFF000000" >board/icecube/config.tmp ; \
+		{ echo "TEXT_BASE = 0xFF000000" >$(obj)board/icecube/config.tmp ; \
 		  echo "... with LOWBOOT configuration" ; \
 		}
 	@ echo "... with MPC5200B processor"
-	@./mkconfig -a IceCube  ppc mpc5xxx icecube
+	@$(MKCONFIG) -a IceCube  ppc mpc5xxx icecube
 
 mcc200_config	\
 mcc200_SDRAM_config	\
@@ -334,12 +414,14 @@
 prs200_DDR_config	\
 prs200_highboot_config	\
 prs200_highboot_DDR_config:	unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@mkdir -p $(obj)board/mcc200
+	@ >$(obj)include/config.h
 	@[ -n "$(findstring highboot,$@)" ] || \
 		{ echo "... with lowboot configuration" ; \
 		}
 	@[ -z "$(findstring highboot,$@)" ] || \
-		{ echo "TEXT_BASE = 0xFFF00000" >board/mcc200/config.tmp ; \
+		{ echo "TEXT_BASE = 0xFFF00000" >$(obj)board/mcc200/config.tmp ; \
 		  echo "... with highboot configuration" ; \
 		}
 	@[ -n "$(findstring _SDRAM,$@)" ] || \
@@ -351,92 +433,97 @@
 			then \
 				echo "... with DDR" ; \
 			else \
-				echo "#define CONFIG_MCC200_SDRAM" >>include/config.h ;\
+				echo "#define CONFIG_MCC200_SDRAM" >>$(obj)include/config.h ;\
 				echo "... with SDRAM" ; \
 			fi; \
 		  fi; \
 		}
 	@[ -z "$(findstring _SDRAM,$@)" ] || \
-		{ echo "#define CONFIG_MCC200_SDRAM"	>>include/config.h ; \
+		{ echo "#define CONFIG_MCC200_SDRAM"	>>$(obj)include/config.h ; \
 		  echo "... with SDRAM" ; \
 		}
 	@[ -z "$(findstring COM12,$@)" ] || \
-		{ echo "#define CONFIG_CONSOLE_COM12"	>>include/config.h ; \
+		{ echo "#define CONFIG_CONSOLE_COM12"	>>$(obj)include/config.h ; \
 		  echo "... with console on COM12" ; \
 		}
 	@[ -z "$(findstring prs200,$@)" ] || \
-		{ echo "#define CONFIG_PRS200"  >>include/config.h ;\
+		{ echo "#define CONFIG_PRS200"  >>$(obj)include/config.h ;\
 		}
-	@./mkconfig -n $@ -a mcc200 ppc mpc5xxx mcc200
+	@$(MKCONFIG) -n $@ -a mcc200 ppc mpc5xxx mcc200
 
 o2dnt_config:
-	@./mkconfig o2dnt ppc mpc5xxx o2dnt
+	@$(MKCONFIG) o2dnt ppc mpc5xxx o2dnt
 
 pf5200_config:  unconfig
-	@./mkconfig pf5200  ppc mpc5xxx pf5200 esd
+	@$(MKCONFIG) pf5200  ppc mpc5xxx pf5200 esd
 
 PM520_config \
 PM520_DDR_config \
 PM520_ROMBOOT_config \
 PM520_ROMBOOT_DDR_config:	unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring DDR,$@)" ] || \
-		{ echo "#define CONFIG_MPC5200_DDR"	>>include/config.h ; \
+		{ echo "#define CONFIG_MPC5200_DDR"	>>$(obj)include/config.h ; \
 		  echo "... DDR memory revision" ; \
 		}
 	@[ -z "$(findstring ROMBOOT,$@)" ] || \
-		{ echo "#define CONFIG_BOOT_ROM" >>include/config.h ; \
+		{ echo "#define CONFIG_BOOT_ROM" >>$(obj)include/config.h ; \
 		  echo "... booting from 8-bit flash" ; \
 		}
-	@./mkconfig -a PM520 ppc mpc5xxx pm520
+	@$(MKCONFIG) -a PM520 ppc mpc5xxx pm520
 
 smmaco4_config: unconfig
-	@./mkconfig -a smmaco4 ppc mpc5xxx tqm5200
+	@$(MKCONFIG) -a smmaco4 ppc mpc5xxx tqm5200
 
 spieval_config:	unconfig
-	@./mkconfig -a spieval ppc mpc5xxx tqm5200
+	@$(MKCONFIG) -a spieval ppc mpc5xxx tqm5200
 
 TB5200_B_config \
 TB5200_config:	unconfig
+	@mkdir -p $(obj)include
 	@[ -z "$(findstring _B,$@)" ] || \
-		{ echo "#define CONFIG_TQM5200_B"	>>include/config.h ; \
+		{ echo "#define CONFIG_TQM5200_B"	>>$(obj)include/config.h ; \
 		  echo "... with MPC5200B processor" ; \
 		}
-	@./mkconfig -n $@ -a TB5200 ppc mpc5xxx tqm5200
+	@$(MKCONFIG) -n $@ -a TB5200 ppc mpc5xxx tqm5200
 
 MINI5200_config	\
 EVAL5200_config	\
 TOP5200_config:	unconfig
-	@ echo "#define CONFIG_$(@:_config=) 1"	>include/config.h
-	@./mkconfig -n $@ -a TOP5200 ppc mpc5xxx top5200 emk
+	@mkdir -p $(obj)include
+	@ echo "#define CONFIG_$(@:_config=) 1"	>$(obj)include/config.h
+	@$(MKCONFIG) -n $@ -a TOP5200 ppc mpc5xxx top5200 emk
 
 Total5100_config		\
 Total5200_config		\
 Total5200_lowboot_config	\
 Total5200_Rev2_config		\
 Total5200_Rev2_lowboot_config:	unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@mkdir -p $(obj)board/total5200
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring 5100,$@)" ] || \
-		{ echo "#define CONFIG_MGT5100"		>>include/config.h ; \
+		{ echo "#define CONFIG_MGT5100"		>>$(obj)include/config.h ; \
 		  echo "... with MGT5100 processor" ; \
 		}
 	@[ -z "$(findstring 5200,$@)" ] || \
-		{ echo "#define CONFIG_MPC5200"		>>include/config.h ; \
+		{ echo "#define CONFIG_MPC5200"		>>$(obj)include/config.h ; \
 		  echo "... with MPC5200 processor" ; \
 		}
 	@[ -n "$(findstring Rev,$@)" ] || \
-		{ echo "#define CONFIG_TOTAL5200_REV 1"	>>include/config.h ; \
+		{ echo "#define CONFIG_TOTAL5200_REV 1"	>>$(obj)include/config.h ; \
 		  echo "... revision 1 board" ; \
 		}
 	@[ -z "$(findstring Rev2_,$@)" ] || \
-		{ echo "#define CONFIG_TOTAL5200_REV 2"	>>include/config.h ; \
+		{ echo "#define CONFIG_TOTAL5200_REV 2"	>>$(obj)include/config.h ; \
 		  echo "... revision 2 board" ; \
 		}
 	@[ -z "$(findstring lowboot_,$@)" ] || \
-		{ echo "TEXT_BASE = 0xFE000000" >board/total5200/config.tmp ; \
+		{ echo "TEXT_BASE = 0xFE000000" >$(obj)board/total5200/config.tmp ; \
 		  echo "... with lowboot configuration" ; \
 		}
-	@./mkconfig -a Total5200 ppc mpc5xxx total5200
+	@$(MKCONFIG) -a Total5200 ppc mpc5xxx total5200
 
 cam5200_config \
 fo300_config \
@@ -447,36 +534,38 @@
 TQM5200_B_HIGHBOOT_config \
 TQM5200_config	\
 TQM5200_STK100_config:	unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@mkdir -p $(obj)board/tqm5200
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring cam5200,$@)" ] || \
-		{ echo "#define CONFIG_CAM5200"	>>include/config.h ; \
-		  echo "#define CONFIG_TQM5200S"	>>include/config.h ; \
-		  echo "#define CONFIG_TQM5200_B"	>>include/config.h ; \
+		{ echo "#define CONFIG_CAM5200"	>>$(obj)include/config.h ; \
+		  echo "#define CONFIG_TQM5200S"	>>$(obj)include/config.h ; \
+		  echo "#define CONFIG_TQM5200_B"	>>$(obj)include/config.h ; \
 		  echo "... TQM5200S on Cam5200" ; \
 		}
 	@[ -z "$(findstring fo300,$@)" ] || \
-		{ echo "#define CONFIG_FO300"	>>include/config.h ; \
+		{ echo "#define CONFIG_FO300"	>>$(obj)include/config.h ; \
 		  echo "... TQM5200 on FO300" ; \
 		}
 	@[ -z "$(findstring MiniFAP,$@)" ] || \
-		{ echo "#define CONFIG_MINIFAP"	>>include/config.h ; \
+		{ echo "#define CONFIG_MINIFAP"	>>$(obj)include/config.h ; \
 		  echo "... TQM5200_AC on MiniFAP" ; \
 		}
 	@[ -z "$(findstring STK100,$@)" ] || \
-		{ echo "#define CONFIG_STK52XX_REV100"	>>include/config.h ; \
+		{ echo "#define CONFIG_STK52XX_REV100"	>>$(obj)include/config.h ; \
 		  echo "... on a STK52XX.100 base board" ; \
 		}
 	@[ -z "$(findstring TQM5200_B,$@)" ] || \
-		{ echo "#define CONFIG_TQM5200_B"	>>include/config.h ; \
+		{ echo "#define CONFIG_TQM5200_B"	>>$(obj)include/config.h ; \
 		}
 	@[ -z "$(findstring TQM5200S,$@)" ] || \
-		{ echo "#define CONFIG_TQM5200S"	>>include/config.h ; \
-		  echo "#define CONFIG_TQM5200_B"	>>include/config.h ; \
+		{ echo "#define CONFIG_TQM5200S"	>>$(obj)include/config.h ; \
+		  echo "#define CONFIG_TQM5200_B"	>>$(obj)include/config.h ; \
 		}
 	@[ -z "$(findstring HIGHBOOT,$@)" ] || \
-		{ echo "TEXT_BASE = 0xFFF00000" >board/tqm5200/config.tmp ; \
+		{ echo "TEXT_BASE = 0xFFF00000" >$(obj)board/tqm5200/config.tmp ; \
 		}
-	@./mkconfig -n $@ -a TQM5200 ppc mpc5xxx tqm5200
+	@$(MKCONFIG) -n $@ -a TQM5200 ppc mpc5xxx tqm5200
 
 #########################################################################
 ## MPC8xx Systems
@@ -486,9 +575,10 @@
 Adder87x_config \
 AdderII_config  \
 	:		unconfig
+	@mkdir -p $(obj)include
 	$(if $(findstring AdderII,$@), \
-	@echo "#define CONFIG_MPC852T" > include/config.h)
-	@./mkconfig -a Adder ppc mpc8xx adder
+	@echo "#define CONFIG_MPC852T" > $(obj)include/config.h)
+	@$(MKCONFIG) -a Adder ppc mpc8xx adder
 
 ADS860_config     \
 FADS823_config    \
@@ -496,154 +586,160 @@
 MPC86xADS_config  \
 MPC885ADS_config  \
 FADS860T_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx fads
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx fads
 
 AMX860_config	:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx amx860 westel
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx amx860 westel
 
 c2mon_config:		unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx c2mon
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx c2mon
 
 CCM_config:		unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx CCM siemens
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx CCM siemens
 
 cogent_mpc8xx_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx cogent
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx cogent
 
 ELPT860_config:		unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx elpt860 LEOX
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx elpt860 LEOX
 
 EP88x_config:		unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx ep88x
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx ep88x
 
 ESTEEM192E_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx esteem192e
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx esteem192e
 
 ETX094_config	:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx etx094
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx etx094
 
 FLAGADM_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx flagadm
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx flagadm
 
 xtract_GEN860T = $(subst _SC,,$(subst _config,,$1))
 
 GEN860T_SC_config	\
 GEN860T_config: unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring _SC,$@)" ] || \
-		{ echo "#define CONFIG_SC" >>include/config.h ; \
+		{ echo "#define CONFIG_SC" >>$(obj)include/config.h ; \
 		  echo "With reduced H/W feature set (SC)..." ; \
 		}
-	@./mkconfig -a $(call xtract_GEN860T,$@) ppc mpc8xx gen860t
+	@$(MKCONFIG) -a $(call xtract_GEN860T,$@) ppc mpc8xx gen860t
 
 GENIETV_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx genietv
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx genietv
 
 GTH_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx gth
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx gth
 
 hermes_config	:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx hermes
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx hermes
 
 HMI10_config	:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx tqm8xx
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx tqm8xx
 
 IAD210_config: unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx IAD210 siemens
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx IAD210 siemens
 
 xtract_ICU862 = $(subst _100MHz,,$(subst _config,,$1))
 
 ICU862_100MHz_config	\
 ICU862_config: unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring _100MHz,$@)" ] || \
-		{ echo "#define CONFIG_100MHz"	>>include/config.h ; \
+		{ echo "#define CONFIG_100MHz"	>>$(obj)include/config.h ; \
 		  echo "... with 100MHz system clock" ; \
 		}
-	@./mkconfig -a $(call xtract_ICU862,$@) ppc mpc8xx icu862
+	@$(MKCONFIG) -a $(call xtract_ICU862,$@) ppc mpc8xx icu862
 
 IP860_config	:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx ip860
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx ip860
 
 IVML24_256_config \
 IVML24_128_config \
 IVML24_config:	unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring IVML24_config,$@)" ] || \
-		 { echo "#define CONFIG_IVML24_16M"	>>include/config.h ; \
+		 { echo "#define CONFIG_IVML24_16M"	>>$(obj)include/config.h ; \
 		 }
 	@[ -z "$(findstring IVML24_128_config,$@)" ] || \
-		 { echo "#define CONFIG_IVML24_32M"	>>include/config.h ; \
+		 { echo "#define CONFIG_IVML24_32M"	>>$(obj)include/config.h ; \
 		 }
 	@[ -z "$(findstring IVML24_256_config,$@)" ] || \
-		 { echo "#define CONFIG_IVML24_64M"	>>include/config.h ; \
+		 { echo "#define CONFIG_IVML24_64M"	>>$(obj)include/config.h ; \
 		 }
-	@./mkconfig -a IVML24 ppc mpc8xx ivm
+	@$(MKCONFIG) -a IVML24 ppc mpc8xx ivm
 
 IVMS8_256_config \
 IVMS8_128_config \
 IVMS8_config:	unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring IVMS8_config,$@)" ] || \
-		 { echo "#define CONFIG_IVMS8_16M"	>>include/config.h ; \
+		 { echo "#define CONFIG_IVMS8_16M"	>>$(obj)include/config.h ; \
 		 }
 	@[ -z "$(findstring IVMS8_128_config,$@)" ] || \
-		 { echo "#define CONFIG_IVMS8_32M"	>>include/config.h ; \
+		 { echo "#define CONFIG_IVMS8_32M"	>>$(obj)include/config.h ; \
 		 }
 	@[ -z "$(findstring IVMS8_256_config,$@)" ] || \
-		 { echo "#define CONFIG_IVMS8_64M"	>>include/config.h ; \
+		 { echo "#define CONFIG_IVMS8_64M"	>>$(obj)include/config.h ; \
 		 }
-	@./mkconfig -a IVMS8 ppc mpc8xx ivm
+	@$(MKCONFIG) -a IVMS8 ppc mpc8xx ivm
 
 KUP4K_config	:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx kup4k kup
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx kup4k kup
 
 KUP4X_config    :       unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx kup4x kup
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx kup4x kup
 
 LANTEC_config	:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx lantec
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx lantec
 
 lwmon_config:		unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx lwmon
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx lwmon
 
 MBX_config	\
 MBX860T_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx mbx8xx
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx mbx8xx
 
 MHPC_config:		unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx mhpc eltec
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx mhpc eltec
 
 MVS1_config :		unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx mvs1
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx mvs1
 
 xtract_NETVIA = $(subst _V2,,$(subst _config,,$1))
 
 NETVIA_V2_config \
 NETVIA_config:		unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring NETVIA_config,$@)" ] || \
-		 { echo "#define CONFIG_NETVIA_VERSION 1" >>include/config.h ; \
+		 { echo "#define CONFIG_NETVIA_VERSION 1" >>$(obj)include/config.h ; \
 		  echo "... Version 1" ; \
 		 }
 	@[ -z "$(findstring NETVIA_V2_config,$@)" ] || \
-		 { echo "#define CONFIG_NETVIA_VERSION 2" >>include/config.h ; \
+		 { echo "#define CONFIG_NETVIA_VERSION 2" >>$(obj)include/config.h ; \
 		  echo "... Version 2" ; \
 		 }
-	@./mkconfig -a $(call xtract_NETVIA,$@) ppc mpc8xx netvia
+	@$(MKCONFIG) -a $(call xtract_NETVIA,$@) ppc mpc8xx netvia
 
 xtract_NETPHONE = $(subst _V2,,$(subst _config,,$1))
 
 NETPHONE_V2_config \
 NETPHONE_config:	unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring NETPHONE_config,$@)" ] || \
-		 { echo "#define CONFIG_NETPHONE_VERSION 1" >>include/config.h ; \
+		 { echo "#define CONFIG_NETPHONE_VERSION 1" >>$(obj)include/config.h ; \
 		 }
 	@[ -z "$(findstring NETPHONE_V2_config,$@)" ] || \
-		 { echo "#define CONFIG_NETPHONE_VERSION 2" >>include/config.h ; \
+		 { echo "#define CONFIG_NETPHONE_VERSION 2" >>$(obj)include/config.h ; \
 		 }
-	@./mkconfig -a $(call xtract_NETPHONE,$@) ppc mpc8xx netphone
+	@$(MKCONFIG) -a $(call xtract_NETPHONE,$@) ppc mpc8xx netphone
 
 xtract_NETTA = $(subst _SWAPHOOK,,$(subst _6412,,$(subst _ISDN,,$(subst _config,,$1))))
 
@@ -655,85 +751,88 @@
 NETTA_ISDN_config \
 NETTA_6412_config \
 NETTA_config:		unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring ISDN_,$@)" ] || \
-		 { echo "#define CONFIG_NETTA_ISDN 1" >>include/config.h ; \
+		 { echo "#define CONFIG_NETTA_ISDN 1" >>$(obj)include/config.h ; \
 		 }
 	@[ -n "$(findstring ISDN_,$@)" ] || \
-		 { echo "#undef CONFIG_NETTA_ISDN" >>include/config.h ; \
+		 { echo "#undef CONFIG_NETTA_ISDN" >>$(obj)include/config.h ; \
 		 }
 	@[ -z "$(findstring 6412_,$@)" ] || \
-		 { echo "#define CONFIG_NETTA_6412 1" >>include/config.h ; \
+		 { echo "#define CONFIG_NETTA_6412 1" >>$(obj)include/config.h ; \
 		 }
 	@[ -n "$(findstring 6412_,$@)" ] || \
-		 { echo "#undef CONFIG_NETTA_6412" >>include/config.h ; \
+		 { echo "#undef CONFIG_NETTA_6412" >>$(obj)include/config.h ; \
 		 }
 	@[ -z "$(findstring SWAPHOOK_,$@)" ] || \
-		 { echo "#define CONFIG_NETTA_SWAPHOOK 1" >>include/config.h ; \
+		 { echo "#define CONFIG_NETTA_SWAPHOOK 1" >>$(obj)include/config.h ; \
 		 }
 	@[ -n "$(findstring SWAPHOOK_,$@)" ] || \
-		 { echo "#undef CONFIG_NETTA_SWAPHOOK" >>include/config.h ; \
+		 { echo "#undef CONFIG_NETTA_SWAPHOOK" >>$(obj)include/config.h ; \
 		 }
-	@./mkconfig -a $(call xtract_NETTA,$@) ppc mpc8xx netta
+	@$(MKCONFIG) -a $(call xtract_NETTA,$@) ppc mpc8xx netta
 
 xtract_NETTA2 = $(subst _V2,,$(subst _config,,$1))
 
 NETTA2_V2_config \
 NETTA2_config:		unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring NETTA2_config,$@)" ] || \
-		 { echo "#define CONFIG_NETTA2_VERSION 1" >>include/config.h ; \
+		 { echo "#define CONFIG_NETTA2_VERSION 1" >>$(obj)include/config.h ; \
 		 }
 	@[ -z "$(findstring NETTA2_V2_config,$@)" ] || \
-		 { echo "#define CONFIG_NETTA2_VERSION 2" >>include/config.h ; \
+		 { echo "#define CONFIG_NETTA2_VERSION 2" >>$(obj)include/config.h ; \
 		 }
-	@./mkconfig -a $(call xtract_NETTA2,$@) ppc mpc8xx netta2
+	@$(MKCONFIG) -a $(call xtract_NETTA2,$@) ppc mpc8xx netta2
 
 NC650_Rev1_config \
 NC650_Rev2_config \
 CP850_config:	unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring CP850,$@)" ] || \
-		 { echo "#define CONFIG_CP850 1" >>include/config.h ; \
-		   echo "#define CONFIG_IDS852_REV2 1" >>include/config.h ; \
+		 { echo "#define CONFIG_CP850 1" >>$(obj)include/config.h ; \
+		   echo "#define CONFIG_IDS852_REV2 1" >>$(obj)include/config.h ; \
 		 }
 	@[ -z "$(findstring Rev1,$@)" ] || \
-		 { echo "#define CONFIG_IDS852_REV1 1" >>include/config.h ; \
+		 { echo "#define CONFIG_IDS852_REV1 1" >>$(obj)include/config.h ; \
 		 }
 	@[ -z "$(findstring Rev2,$@)" ] || \
-		 { echo "#define CONFIG_IDS852_REV2 1" >>include/config.h ; \
+		 { echo "#define CONFIG_IDS852_REV2 1" >>$(obj)include/config.h ; \
 		 }
-	@./mkconfig -a NC650 ppc mpc8xx nc650
+	@$(MKCONFIG) -a NC650 ppc mpc8xx nc650
 
 NX823_config:		unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx nx823
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx nx823
 
 pcu_e_config:		unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx pcu_e siemens
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx pcu_e siemens
 
 QS850_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx qs850 snmc
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx qs850 snmc
 
 QS823_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx qs850 snmc
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx qs850 snmc
 
 QS860T_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx qs860t snmc
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx qs860t snmc
 
 quantum_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx quantum
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx quantum
 
 R360MPI_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx r360mpi
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx r360mpi
 
 RBC823_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx rbc823
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx rbc823
 
 RPXClassic_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx RPXClassic
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx RPXClassic
 
 RPXlite_config:		unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx RPXlite
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx RPXlite
 
 RPXlite_DW_64_config  		\
 RPXlite_DW_LCD_config 		\
@@ -743,55 +842,56 @@
 RPXlite_DW_NVRAM_LCD_config	\
 RPXlite_DW_NVRAM_64_LCD_config  \
 RPXlite_DW_config:         unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring _64,$@)" ] || \
-		{ echo "#define RPXlite_64MHz"		>>include/config.h ; \
+		{ echo "#define RPXlite_64MHz"		>>$(obj)include/config.h ; \
 		  echo "... with 64MHz system clock ..."; \
 		}
 	@[ -z "$(findstring _LCD,$@)" ] || \
-		{ echo "#define CONFIG_LCD"          	>>include/config.h ; \
-		  echo "#define CONFIG_NEC_NL6448BC20"	>>include/config.h ; \
+		{ echo "#define CONFIG_LCD"          	>>$(obj)include/config.h ; \
+		  echo "#define CONFIG_NEC_NL6448BC20"	>>$(obj)include/config.h ; \
 		  echo "... with LCD display ..."; \
 		}
 	@[ -z "$(findstring _NVRAM,$@)" ] || \
-		{ echo "#define  CFG_ENV_IS_IN_NVRAM" 	>>include/config.h ; \
+		{ echo "#define  CFG_ENV_IS_IN_NVRAM" 	>>$(obj)include/config.h ; \
 		  echo "... with ENV in NVRAM ..."; \
 		}
-	@./mkconfig -a RPXlite_DW ppc mpc8xx RPXlite_dw
+	@$(MKCONFIG) -a RPXlite_DW ppc mpc8xx RPXlite_dw
 
 rmu_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx rmu
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx rmu
 
 RRvision_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx RRvision
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx RRvision
 
 RRvision_LCD_config:	unconfig
-	@echo "#define CONFIG_LCD" >include/config.h
-	@echo "#define CONFIG_SHARP_LQ104V7DS01" >>include/config.h
-	@./mkconfig -a RRvision ppc mpc8xx RRvision
+	@mkdir -p $(obj)include
+	@echo "#define CONFIG_LCD" >$(obj)include/config.h
+	@echo "#define CONFIG_SHARP_LQ104V7DS01" >>$(obj)include/config.h
+	@$(MKCONFIG) -a RRvision ppc mpc8xx RRvision
 
 SM850_config	:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx tqm8xx
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx tqm8xx
 
 spc1920_config:
-	@./mkconfig $(@:_config=) ppc mpc8xx spc1920
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx spc1920
 
 SPD823TS_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx spd8xx
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx spd8xx
 
 stxxtc_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx stxxtc
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx stxxtc
 
 svm_sc8xx_config:	unconfig
-	@ >include/config.h
-	@./mkconfig $(@:_config=) ppc mpc8xx svm_sc8xx
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx svm_sc8xx
 
 SXNI855T_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx sixnet
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx sixnet
 
 # EMK MPC8xx based modules
 TOP860_config:		unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx top860 emk
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx top860 emk
 
 # Play some tricks for configuration selection
 # Only 855 and 860 boards may come with FEC
@@ -815,31 +915,35 @@
 TQM866M_config		\
 TQM885D_config		\
 virtlab2_config:	unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring _LCD,$@)" ] || \
-		{ echo "#define CONFIG_LCD"		>>include/config.h ; \
-		  echo "#define CONFIG_NEC_NL6448BC20"	>>include/config.h ; \
+		{ echo "#define CONFIG_LCD"		>>$(obj)include/config.h ; \
+		  echo "#define CONFIG_NEC_NL6448BC20"	>>$(obj)include/config.h ; \
 		  echo "... with LCD display" ; \
 		}
-	@./mkconfig -a $(call xtract_8xx,$@) ppc mpc8xx tqm8xx
+	@$(MKCONFIG) -a $(call xtract_8xx,$@) ppc mpc8xx tqm8xx
 
 TTTech_config:	unconfig
-	@echo "#define CONFIG_LCD" >include/config.h
-	@echo "#define CONFIG_SHARP_LQ104V7DS01" >>include/config.h
-	@./mkconfig -a TQM823L ppc mpc8xx tqm8xx
+	@mkdir -p $(obj)include
+	@echo "#define CONFIG_LCD" >$(obj)include/config.h
+	@echo "#define CONFIG_SHARP_LQ104V7DS01" >>$(obj)include/config.h
+	@$(MKCONFIG) -a TQM823L ppc mpc8xx tqm8xx
 
 uc100_config	:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8xx uc100
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx uc100
 
 v37_config:	unconfig
-	@echo "#define CONFIG_LCD" >include/config.h
-	@echo "#define CONFIG_SHARP_LQ084V1DG21" >>include/config.h
-	@./mkconfig $(@:_config=) ppc mpc8xx v37
+	@mkdir -p $(obj)include
+	@echo "#define CONFIG_LCD" >$(obj)include/config.h
+	@echo "#define CONFIG_SHARP_LQ084V1DG21" >>$(obj)include/config.h
+	@$(MKCONFIG) $(@:_config=) ppc mpc8xx v37
 
 wtk_config:	unconfig
-	@echo "#define CONFIG_LCD" >include/config.h
-	@echo "#define CONFIG_SHARP_LQ065T9DR51U" >>include/config.h
-	@./mkconfig -a TQM823L ppc mpc8xx tqm8xx
+	@mkdir -p $(obj)include
+	@echo "#define CONFIG_LCD" >$(obj)include/config.h
+	@echo "#define CONFIG_SHARP_LQ065T9DR51U" >>$(obj)include/config.h
+	@$(MKCONFIG) -a TQM823L ppc mpc8xx tqm8xx
 
 #########################################################################
 ## PPC4xx Systems
@@ -847,146 +951,148 @@
 xtract_4xx = $(subst _25,,$(subst _33,,$(subst _BA,,$(subst _ME,,$(subst _HI,,$(subst _config,,$1))))))
 
 ADCIOP_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx adciop esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx adciop esd
 
 AP1000_config:unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx ap1000 amirix
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx ap1000 amirix
 
 APC405_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx apc405 esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx apc405 esd
 
 AR405_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx ar405 esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx ar405 esd
 
 ASH405_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx ash405 esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx ash405 esd
 
 bamboo_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx bamboo amcc
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx bamboo amcc
 
 bubinga_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx bubinga amcc
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx bubinga amcc
 
 CANBT_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx canbt esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx canbt esd
 
 CATcenter_config	\
 CATcenter_25_config	\
 CATcenter_33_config:	unconfig
-	@ echo "/* CATcenter uses PPChameleon Model ME */"  > include/config.h
-	@ echo "#define CONFIG_PPCHAMELEON_MODULE_MODEL 1" >> include/config.h
+	@mkdir -p $(obj)include
+	@ echo "/* CATcenter uses PPChameleon Model ME */"  > $(obj)include/config.h
+	@ echo "#define CONFIG_PPCHAMELEON_MODULE_MODEL 1" >> $(obj)include/config.h
 	@[ -z "$(findstring _25,$@)" ] || \
-		{ echo "#define CONFIG_PPCHAMELEON_CLK_25" >>include/config.h ; \
+		{ echo "#define CONFIG_PPCHAMELEON_CLK_25" >> $(obj)include/config.h ; \
 		  echo "SysClk = 25MHz" ; \
 		}
 	@[ -z "$(findstring _33,$@)" ] || \
-		{ echo "#define CONFIG_PPCHAMELEON_CLK_33" >>include/config.h ; \
+		{ echo "#define CONFIG_PPCHAMELEON_CLK_33" >> $(obj)include/config.h ; \
 		  echo "SysClk = 33MHz" ; \
 		}
-	@./mkconfig -a $(call xtract_4xx,$@) ppc ppc4xx PPChameleonEVB dave
+	@$(MKCONFIG) -a $(call xtract_4xx,$@) ppc ppc4xx PPChameleonEVB dave
 
 CPCI2DP_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx cpci2dp esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx cpci2dp esd
 
 CPCI405_config	\
 CPCI4052_config	\
 CPCI405DT_config	\
 CPCI405AB_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx cpci405 esd
-	@echo "BOARD_REVISION = $(@:_config=)"	>>include/config.mk
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx cpci405 esd
+	@echo "BOARD_REVISION = $(@:_config=)"	>> $(obj)include/config.mk
 
 CPCI440_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx cpci440 esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx cpci440 esd
 
 CPCIISER4_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx cpciiser4 esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx cpciiser4 esd
 
 CRAYL1_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx L1 cray
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx L1 cray
 
 csb272_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx csb272
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx csb272
 
 csb472_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx csb472
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx csb472
 
 DASA_SIM_config: unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx dasa_sim esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx dasa_sim esd
 
 DP405_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx dp405 esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx dp405 esd
 
 DU405_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx du405 esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx du405 esd
 
 ebony_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx ebony amcc
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx ebony amcc
 
 ERIC_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx eric
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx eric
 
 EXBITGEN_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx exbitgen
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx exbitgen
 
 G2000_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx g2000
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx g2000
 
 HH405_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx hh405 esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx hh405 esd
 
 HUB405_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx hub405 esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx hub405 esd
 
 JSE_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx jse
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx jse
 
 KAREF_config: unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx karef sandburst
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx karef sandburst
 
 luan_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx luan amcc
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx luan amcc
 
 METROBOX_config: unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx metrobox sandburst
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx metrobox sandburst
 
 MIP405_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx mip405 mpl
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx mip405 mpl
 
 MIP405T_config:	unconfig
-	@echo "#define CONFIG_MIP405T" >include/config.h
+	@mkdir -p $(obj)include
+	@echo "#define CONFIG_MIP405T" >$(obj)include/config.h
 	@echo "Enable subset config for MIP405T"
-	@./mkconfig -a MIP405 ppc ppc4xx mip405 mpl
+	@$(MKCONFIG) -a MIP405 ppc ppc4xx mip405 mpl
 
 ML2_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx ml2
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx ml2
 
 ml300_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx ml300 xilinx
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx ml300 xilinx
 
 ocotea_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx ocotea amcc
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx ocotea amcc
 
 OCRTC_config		\
 ORSG_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx ocrtc esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx ocrtc esd
 
 p3p440_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx p3p440 prodrive
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx p3p440 prodrive
 
 PCI405_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx pci405 esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx pci405 esd
 
 pcs440ep_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx pcs440ep
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx pcs440ep
 
 PIP405_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx pip405 mpl
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx pip405 mpl
 
 PLU405_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx plu405 esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx plu405 esd
 
 PMC405_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx pmc405 esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx pmc405 esd
 
 PPChameleonEVB_config		\
 PPChameleonEVB_BA_25_config	\
@@ -995,66 +1101,67 @@
 PPChameleonEVB_BA_33_config	\
 PPChameleonEVB_ME_33_config	\
 PPChameleonEVB_HI_33_config:	unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring EVB_BA,$@)" ] || \
-		{ echo "#define CONFIG_PPCHAMELEON_MODULE_MODEL 0" >>include/config.h ; \
+		{ echo "#define CONFIG_PPCHAMELEON_MODULE_MODEL 0" >>$(obj)include/config.h ; \
 		  echo "... BASIC model" ; \
 		}
 	@[ -z "$(findstring EVB_ME,$@)" ] || \
-		{ echo "#define CONFIG_PPCHAMELEON_MODULE_MODEL 1" >>include/config.h ; \
+		{ echo "#define CONFIG_PPCHAMELEON_MODULE_MODEL 1" >>$(obj)include/config.h ; \
 		  echo "... MEDIUM model" ; \
 		}
 	@[ -z "$(findstring EVB_HI,$@)" ] || \
-		{ echo "#define CONFIG_PPCHAMELEON_MODULE_MODEL 2" >>include/config.h ; \
+		{ echo "#define CONFIG_PPCHAMELEON_MODULE_MODEL 2" >>$(obj)include/config.h ; \
 		  echo "... HIGH-END model" ; \
 		}
 	@[ -z "$(findstring _25,$@)" ] || \
-		{ echo "#define CONFIG_PPCHAMELEON_CLK_25" >>include/config.h ; \
+		{ echo "#define CONFIG_PPCHAMELEON_CLK_25" >>$(obj)include/config.h ; \
 		  echo "SysClk = 25MHz" ; \
 		}
 	@[ -z "$(findstring _33,$@)" ] || \
-		{ echo "#define CONFIG_PPCHAMELEON_CLK_33" >>include/config.h ; \
+		{ echo "#define CONFIG_PPCHAMELEON_CLK_33" >>$(obj)include/config.h ; \
 		  echo "SysClk = 33MHz" ; \
 		}
-	@./mkconfig -a $(call xtract_4xx,$@) ppc ppc4xx PPChameleonEVB dave
+	@$(MKCONFIG) -a $(call xtract_4xx,$@) ppc ppc4xx PPChameleonEVB dave
 
 sbc405_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx sbc405
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx sbc405
 
 sycamore_config:	unconfig
 	@echo "Configuring for sycamore board as subset of walnut..."
-	@./mkconfig -a walnut ppc ppc4xx walnut amcc
+	@$(MKCONFIG) -a walnut ppc ppc4xx walnut amcc
 
 VOH405_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx voh405 esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx voh405 esd
 
 VOM405_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx vom405 esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx vom405 esd
 
 CMS700_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx cms700 esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx cms700 esd
 
 W7OLMC_config	\
 W7OLMG_config: unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx w7o
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx w7o
 
 walnut_config: unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx walnut amcc
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx walnut amcc
 
 WUH405_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx wuh405 esd
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx wuh405 esd
 
 XPEDITE1K_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx xpedite1k
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx xpedite1k
 
 yosemite_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx yosemite amcc
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx yosemite amcc
 
 yellowstone_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx yellowstone amcc
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx yellowstone amcc
 
 yucca_config:	unconfig
-	@./mkconfig $(@:_config=) ppc ppc4xx yucca amcc
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx yucca amcc
 
 #########################################################################
 ## MPC8220 Systems
@@ -1062,10 +1169,10 @@
 
 Alaska8220_config	\
 Yukon8220_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8220 alaska
+	@$(MKCONFIG) $(@:_config=) ppc mpc8220 alaska
 
 sorcery_config:		unconfig
-	@./mkconfig $(@:_config=) ppc mpc8220 sorcery
+	@$(MKCONFIG) $(@:_config=) ppc mpc8220 sorcery
 
 #########################################################################
 ## MPC824x Systems
@@ -1073,18 +1180,18 @@
 xtract_82xx = $(subst _BIGFLASH,,$(subst _ROMBOOT,,$(subst _L2,,$(subst _266MHz,,$(subst _300MHz,,$(subst _config,,$1))))))
 
 A3000_config: unconfig
-	@./mkconfig $(@:_config=) ppc mpc824x a3000
+	@$(MKCONFIG) $(@:_config=) ppc mpc824x a3000
 
 barco_config: unconfig
-	@./mkconfig $(@:_config=) ppc mpc824x barco
+	@$(MKCONFIG) $(@:_config=) ppc mpc824x barco
 
 BMW_config: unconfig
-	@./mkconfig $(@:_config=) ppc mpc824x bmw
+	@$(MKCONFIG) $(@:_config=) ppc mpc824x bmw
 
 CPC45_config	\
 CPC45_ROMBOOT_config:	unconfig
-	@./mkconfig $(call xtract_82xx,$@) ppc mpc824x cpc45
-	@cd ./include ;				\
+	@$(MKCONFIG) $(call xtract_82xx,$@) ppc mpc824x cpc45
+	@cd $(obj)include ;				\
 	if [ "$(findstring _ROMBOOT_,$@)" ] ; then \
 		echo "CONFIG_BOOT_ROM = y" >> config.mk ; \
 		echo "... booting from 8-bit flash" ; \
@@ -1095,64 +1202,64 @@
 	echo "export CONFIG_BOOT_ROM" >> config.mk;
 
 CU824_config: unconfig
-	@./mkconfig $(@:_config=) ppc mpc824x cu824
+	@$(MKCONFIG) $(@:_config=) ppc mpc824x cu824
 
 debris_config: unconfig
-	@./mkconfig $(@:_config=) ppc mpc824x debris etin
+	@$(MKCONFIG) $(@:_config=) ppc mpc824x debris etin
 
 eXalion_config: unconfig
-	@./mkconfig $(@:_config=) ppc mpc824x eXalion
+	@$(MKCONFIG) $(@:_config=) ppc mpc824x eXalion
 
 HIDDEN_DRAGON_config: unconfig
-	@./mkconfig $(@:_config=) ppc mpc824x hidden_dragon
+	@$(MKCONFIG) $(@:_config=) ppc mpc824x hidden_dragon
 
 kvme080_config: unconfig
-	@./mkconfig $(@:_config=) ppc mpc824x kvme080 etin
+	@$(MKCONFIG) $(@:_config=) ppc mpc824x kvme080 etin
 
 MOUSSE_config: unconfig
-	@./mkconfig $(@:_config=) ppc mpc824x mousse
+	@$(MKCONFIG) $(@:_config=) ppc mpc824x mousse
 
 MUSENKI_config: unconfig
-	@./mkconfig $(@:_config=) ppc mpc824x musenki
+	@$(MKCONFIG) $(@:_config=) ppc mpc824x musenki
 
 MVBLUE_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc824x mvblue
+	@$(MKCONFIG) $(@:_config=) ppc mpc824x mvblue
 
 OXC_config: unconfig
-	@./mkconfig $(@:_config=) ppc mpc824x oxc
+	@$(MKCONFIG) $(@:_config=) ppc mpc824x oxc
 
 PN62_config: unconfig
-	@./mkconfig $(@:_config=) ppc mpc824x pn62
+	@$(MKCONFIG) $(@:_config=) ppc mpc824x pn62
 
 Sandpoint8240_config: unconfig
-	@./mkconfig $(@:_config=) ppc mpc824x sandpoint
+	@$(MKCONFIG) $(@:_config=) ppc mpc824x sandpoint
 
 Sandpoint8245_config: unconfig
-	@./mkconfig $(@:_config=) ppc mpc824x sandpoint
+	@$(MKCONFIG) $(@:_config=) ppc mpc824x sandpoint
 
 sbc8240_config: unconfig
-	@./mkconfig $(@:_config=) ppc mpc824x sbc8240
+	@$(MKCONFIG) $(@:_config=) ppc mpc824x sbc8240
 
 SL8245_config: unconfig
-	@./mkconfig $(@:_config=) ppc mpc824x sl8245
+	@$(MKCONFIG) $(@:_config=) ppc mpc824x sl8245
 
 utx8245_config: unconfig
-	@./mkconfig $(@:_config=) ppc mpc824x utx8245
+	@$(MKCONFIG) $(@:_config=) ppc mpc824x utx8245
 
 #########################################################################
 ## MPC8260 Systems
 #########################################################################
 
 atc_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8260 atc
+	@$(MKCONFIG) $(@:_config=) ppc mpc8260 atc
 
 cogent_mpc8260_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8260 cogent
+	@$(MKCONFIG) $(@:_config=) ppc mpc8260 cogent
 
 CPU86_config	\
 CPU86_ROMBOOT_config: unconfig
-	@./mkconfig $(call xtract_82xx,$@) ppc mpc8260 cpu86
-	@cd ./include ;				\
+	@$(MKCONFIG) $(call xtract_82xx,$@) ppc mpc8260 cpu86
+	@cd $(obj)include ;				\
 	if [ "$(findstring _ROMBOOT_,$@)" ] ; then \
 		echo "CONFIG_BOOT_ROM = y" >> config.mk ; \
 		echo "... booting from 8-bit flash" ; \
@@ -1164,8 +1271,8 @@
 
 CPU87_config	\
 CPU87_ROMBOOT_config: unconfig
-	@./mkconfig $(call xtract_82xx,$@) ppc mpc8260 cpu87
-	@cd ./include ;				\
+	@$(MKCONFIG) $(call xtract_82xx,$@) ppc mpc8260 cpu87
+	@cd $(obj)include ;				\
 	if [ "$(findstring _ROMBOOT_,$@)" ] ; then \
 		echo "CONFIG_BOOT_ROM = y" >> config.mk ; \
 		echo "... booting from 8-bit flash" ; \
@@ -1177,29 +1284,30 @@
 
 ep8248_config	\
 ep8248E_config	:	unconfig
-	@./mkconfig ep8248 ppc mpc8260 ep8248
+	@$(MKCONFIG) ep8248 ppc mpc8260 ep8248
 
 ep8260_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8260 ep8260
+	@$(MKCONFIG) $(@:_config=) ppc mpc8260 ep8260
 
 gw8260_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8260 gw8260
+	@$(MKCONFIG) $(@:_config=) ppc mpc8260 gw8260
 
 hymod_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8260 hymod
+	@$(MKCONFIG) $(@:_config=) ppc mpc8260 hymod
 
 IDS8247_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8260 ids8247
+	@$(MKCONFIG) $(@:_config=) ppc mpc8260 ids8247
 
 IPHASE4539_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8260 iphase4539
+	@$(MKCONFIG) $(@:_config=) ppc mpc8260 iphase4539
 
 ISPAN_config		\
 ISPAN_REVB_config:	unconfig
+	@mkdir -p $(obj)include
 	@if [ "$(findstring _REVB_,$@)" ] ; then \
-		echo "#define CFG_REV_B" > include/config.h ; \
+		echo "#define CFG_REV_B" > $(obj)include/config.h ; \
 	fi
-	@./mkconfig -a ISPAN ppc mpc8260 ispan
+	@$(MKCONFIG) -a ISPAN ppc mpc8260 ispan
 
 MPC8260ADS_config	\
 MPC8260ADS_lowboot_config	\
@@ -1218,21 +1326,23 @@
 PQ2FADS-ZU_66MHz_config	\
 PQ2FADS-ZU_66MHz_lowboot_config	\
 	:		unconfig
+	@mkdir -p $(obj)include
+	@mkdir -p $(obj)board/mpc8260ads
 	$(if $(findstring PQ2FADS,$@), \
-	@echo "#define CONFIG_ADSTYPE CFG_PQ2FADS" > include/config.h, \
-	@echo "#define CONFIG_ADSTYPE CFG_"$(subst MPC,,$(word 1,$(subst _, ,$@))) > include/config.h)
+	@echo "#define CONFIG_ADSTYPE CFG_PQ2FADS" > $(obj)include/config.h, \
+	@echo "#define CONFIG_ADSTYPE CFG_"$(subst MPC,,$(word 1,$(subst _, ,$@))) > $(obj)include/config.h)
 	$(if $(findstring MHz,$@), \
-	@echo "#define CONFIG_8260_CLKIN" $(subst MHz,,$(word 2,$(subst _, ,$@)))"000000" >> include/config.h, \
+	@echo "#define CONFIG_8260_CLKIN" $(subst MHz,,$(word 2,$(subst _, ,$@)))"000000" >> $(obj)include/config.h, \
 	$(if $(findstring VR,$@), \
-	@echo "#define CONFIG_8260_CLKIN 66000000" >> include/config.h))
+	@echo "#define CONFIG_8260_CLKIN 66000000" >> $(obj)include/config.h))
 	@[ -z "$(findstring lowboot_,$@)" ] || \
-		{ echo "TEXT_BASE = 0xFF800000" >board/mpc8260ads/config.tmp ; \
+		{ echo "TEXT_BASE = 0xFF800000" >$(obj)board/mpc8260ads/config.tmp ; \
 		  echo "... with lowboot configuration" ; \
 		}
-	@./mkconfig -a MPC8260ADS ppc mpc8260 mpc8260ads
+	@$(MKCONFIG) -a MPC8260ADS ppc mpc8260 mpc8260ads
 
 MPC8266ADS_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8260 mpc8266ads
+	@$(MKCONFIG) $(@:_config=) ppc mpc8260 mpc8266ads
 
 # PM825/PM826 default configuration:  small (= 8 MB) Flash / boot from 64-bit flash
 PM825_config	\
@@ -1243,71 +1353,76 @@
 PM826_ROMBOOT_config	\
 PM826_BIGFLASH_config	\
 PM826_ROMBOOT_BIGFLASH_config:	unconfig
+	@mkdir -p $(obj)include
+	@mkdir -p $(obj)board/pm826
 	@if [ "$(findstring PM825_,$@)" ] ; then \
-		echo "#define CONFIG_PCI"	>include/config.h ; \
+		echo "#define CONFIG_PCI"	>$(obj)include/config.h ; \
 	else \
-		>include/config.h ; \
+		>$(obj)include/config.h ; \
 	fi
 	@if [ "$(findstring _ROMBOOT_,$@)" ] ; then \
 		echo "... booting from 8-bit flash" ; \
-		echo "#define CONFIG_BOOT_ROM" >>include/config.h ; \
-		echo "TEXT_BASE = 0xFF800000" >board/pm826/config.tmp ; \
+		echo "#define CONFIG_BOOT_ROM" >>$(obj)include/config.h ; \
+		echo "TEXT_BASE = 0xFF800000" >$(obj)board/pm826/config.tmp ; \
 		if [ "$(findstring _BIGFLASH_,$@)" ] ; then \
 			echo "... with 32 MB Flash" ; \
-			echo "#define CONFIG_FLASH_32MB" >>include/config.h ; \
+			echo "#define CONFIG_FLASH_32MB" >>$(obj)include/config.h ; \
 		fi; \
 	else \
 		echo "... booting from 64-bit flash" ; \
 		if [ "$(findstring _BIGFLASH_,$@)" ] ; then \
 			echo "... with 32 MB Flash" ; \
-			echo "#define CONFIG_FLASH_32MB" >>include/config.h ; \
-			echo "TEXT_BASE = 0x40000000" >board/pm826/config.tmp ; \
+			echo "#define CONFIG_FLASH_32MB" >>$(obj)include/config.h ; \
+			echo "TEXT_BASE = 0x40000000" >$(obj)board/pm826/config.tmp ; \
 		else \
-			echo "TEXT_BASE = 0xFF000000" >board/pm826/config.tmp ; \
+			echo "TEXT_BASE = 0xFF000000" >$(obj)board/pm826/config.tmp ; \
 		fi; \
 	fi
-	@./mkconfig -a PM826 ppc mpc8260 pm826
+	@$(MKCONFIG) -a PM826 ppc mpc8260 pm826
 
 PM828_config	\
 PM828_PCI_config	\
 PM828_ROMBOOT_config	\
 PM828_ROMBOOT_PCI_config:	unconfig
+	@mkdir -p $(obj)include
+	@mkdir -p $(obj)board/pm826
 	@if [ "$(findstring _PCI_,$@)" ] ; then \
-		echo "#define CONFIG_PCI"  >>include/config.h ; \
+		echo "#define CONFIG_PCI"  >>$(obj)include/config.h ; \
 		echo "... with PCI enabled" ; \
 	else \
-		>include/config.h ; \
+		>$(obj)include/config.h ; \
 	fi
 	@if [ "$(findstring _ROMBOOT_,$@)" ] ; then \
 		echo "... booting from 8-bit flash" ; \
-		echo "#define CONFIG_BOOT_ROM" >>include/config.h ; \
-		echo "TEXT_BASE = 0xFF800000" >board/pm826/config.tmp ; \
+		echo "#define CONFIG_BOOT_ROM" >>$(obj)include/config.h ; \
+		echo "TEXT_BASE = 0xFF800000" >$(obj)board/pm826/config.tmp ; \
 	fi
-	@./mkconfig -a PM828 ppc mpc8260 pm828
+	@$(MKCONFIG) -a PM828 ppc mpc8260 pm828
 
 ppmc8260_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8260 ppmc8260
+	@$(MKCONFIG) $(@:_config=) ppc mpc8260 ppmc8260
 
 Rattler8248_config	\
 Rattler_config:		unconfig
+	@mkdir -p $(obj)include
 	$(if $(findstring 8248,$@), \
-	@echo "#define CONFIG_MPC8248" > include/config.h)
-	@./mkconfig -a Rattler ppc mpc8260 rattler
+	@echo "#define CONFIG_MPC8248" > $(obj)include/config.h)
+	@$(MKCONFIG) -a Rattler ppc mpc8260 rattler
 
 RPXsuper_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8260 rpxsuper
+	@$(MKCONFIG) $(@:_config=) ppc mpc8260 rpxsuper
 
 rsdproto_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8260 rsdproto
+	@$(MKCONFIG) $(@:_config=) ppc mpc8260 rsdproto
 
 sacsng_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8260 sacsng
+	@$(MKCONFIG) $(@:_config=) ppc mpc8260 sacsng
 
 sbc8260_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc8260 sbc8260
+	@$(MKCONFIG) $(@:_config=) ppc mpc8260 sbc8260
 
 SCM_config:		unconfig
-	@./mkconfig $(@:_config=) ppc mpc8260 SCM siemens
+	@$(MKCONFIG) $(@:_config=) ppc mpc8260 SCM siemens
 
 TQM8255_AA_config \
 TQM8260_AA_config \
@@ -1320,6 +1435,7 @@
 TQM8260_AH_config \
 TQM8260_AI_config \
 TQM8265_AA_config:  unconfig
+	@mkdir -p $(obj)include
 	@case "$@" in \
 	TQM8255_AA_config) CTYPE=MPC8255; CFREQ=300; CACHE=no;	BMODE=8260;;  \
 	TQM8260_AA_config) CTYPE=MPC8260; CFREQ=200; CACHE=no;	BMODE=8260;; \
@@ -1333,205 +1449,214 @@
 	TQM8260_AI_config) CTYPE=MPC8260; CFREQ=300; CACHE=no;	BMODE=60x;;  \
 	TQM8265_AA_config) CTYPE=MPC8265; CFREQ=300; CACHE=no;	BMODE=60x;;  \
 	esac; \
-	>include/config.h ; \
+	>$(obj)include/config.h ; \
 	if [ "$${CTYPE}" != "MPC8260" ] ; then \
-		echo "#define CONFIG_$${CTYPE}"	>>include/config.h ; \
+		echo "#define CONFIG_$${CTYPE}"	>>$(obj)include/config.h ; \
 	fi; \
-	echo "#define CONFIG_$${CFREQ}MHz"	>>include/config.h ; \
+	echo "#define CONFIG_$${CFREQ}MHz"	>>$(obj)include/config.h ; \
 	echo "... with $${CFREQ}MHz system clock" ; \
 	if [ "$${CACHE}" == "yes" ] ; then \
-		echo "#define CONFIG_L2_CACHE"	>>include/config.h ; \
+		echo "#define CONFIG_L2_CACHE"	>>$(obj)include/config.h ; \
 		echo "... with L2 Cache support" ; \
 	else \
-		echo "#undef CONFIG_L2_CACHE"	>>include/config.h ; \
+		echo "#undef CONFIG_L2_CACHE"	>>$(obj)include/config.h ; \
 		echo "... without L2 Cache support" ; \
 	fi; \
 	if [ "$${BMODE}" == "60x" ] ; then \
-		echo "#define CONFIG_BUSMODE_60x" >>include/config.h ; \
+		echo "#define CONFIG_BUSMODE_60x" >>$(obj)include/config.h ; \
 		echo "... with 60x Bus Mode" ; \
 	else \
-		echo "#undef CONFIG_BUSMODE_60x"  >>include/config.h ; \
+		echo "#undef CONFIG_BUSMODE_60x"  >>$(obj)include/config.h ; \
 		echo "... without 60x Bus Mode" ; \
 	fi
-	@./mkconfig -a TQM8260 ppc mpc8260 tqm8260
+	@$(MKCONFIG) -a TQM8260 ppc mpc8260 tqm8260
 
 VoVPN-GW_66MHz_config	\
 VoVPN-GW_100MHz_config:		unconfig
-	@echo "#define CONFIG_CLKIN_$(word 2,$(subst _, ,$@))" > include/config.h
-	@./mkconfig -a VoVPN-GW ppc mpc8260 vovpn-gw funkwerk
+	@mkdir -p $(obj)include
+	@echo "#define CONFIG_CLKIN_$(word 2,$(subst _, ,$@))" > $(obj)include/config.h
+	@$(MKCONFIG) -a VoVPN-GW ppc mpc8260 vovpn-gw funkwerk
 
 ZPC1900_config: unconfig
-	@./mkconfig $(@:_config=) ppc mpc8260 zpc1900
+	@$(MKCONFIG) $(@:_config=) ppc mpc8260 zpc1900
 
 #########################################################################
 ## Coldfire
 #########################################################################
 
 cobra5272_config :		unconfig
-	@./mkconfig $(@:_config=) m68k mcf52x2 cobra5272
+	@$(MKCONFIG) $(@:_config=) m68k mcf52x2 cobra5272
 
 EB+MCF-EV123_config :		unconfig
-	@ >include/config.h
-	@echo "TEXT_BASE = 0xFFE00000"|tee board/BuS/EB+MCF-EV123/textbase.mk
-	@./mkconfig EB+MCF-EV123 m68k mcf52x2 EB+MCF-EV123 BuS
+	@mkdir -p $(obj)include
+	@mkdir -p $(obj)board/BuS/EB+MCF-EV123
+	@ >$(obj)include/config.h
+	@echo "TEXT_BASE = 0xFFE00000"|tee $(obj)board/BuS/EB+MCF-EV123/textbase.mk
+	@$(MKCONFIG) EB+MCF-EV123 m68k mcf52x2 EB+MCF-EV123 BuS
 
 EB+MCF-EV123_internal_config :	unconfig
-	@ >include/config.h
-	@echo "TEXT_BASE = 0xF0000000"|tee board/BuS/EB+MCF-EV123/textbase.mk
-	@./mkconfig EB+MCF-EV123 m68k mcf52x2 EB+MCF-EV123 BuS
+	@mkdir -p $(obj)include
+	@mkdir -p $(obj)board/BuS/EB+MCF-EV123
+	@ >$(obj)include/config.h
+	@echo "TEXT_BASE = 0xF0000000"|tee $(obj)board/BuS/EB+MCF-EV123/textbase.mk
+	@$(MKCONFIG) EB+MCF-EV123 m68k mcf52x2 EB+MCF-EV123 BuS
 
 M5271EVB_config :		unconfig
-	@./mkconfig $(@:_config=) m68k mcf52x2 m5271evb
+	@$(MKCONFIG) $(@:_config=) m68k mcf52x2 m5271evb
 
 M5272C3_config :		unconfig
-	@./mkconfig $(@:_config=) m68k mcf52x2 m5272c3
+	@$(MKCONFIG) $(@:_config=) m68k mcf52x2 m5272c3
 
 M5282EVB_config :		unconfig
-	@./mkconfig $(@:_config=) m68k mcf52x2 m5282evb
+	@$(MKCONFIG) $(@:_config=) m68k mcf52x2 m5282evb
 
 TASREG_config :		unconfig
-	@./mkconfig $(@:_config=) m68k mcf52x2 tasreg esd
+	@$(MKCONFIG) $(@:_config=) m68k mcf52x2 tasreg esd
 
 r5200_config :		unconfig
-	@./mkconfig $(@:_config=) m68k mcf52x2 r5200
+	@$(MKCONFIG) $(@:_config=) m68k mcf52x2 r5200
 
 #########################################################################
 ## MPC83xx Systems
 #########################################################################
 
 MPC8349ADS_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc83xx mpc8349ads
+	@$(MKCONFIG) $(@:_config=) ppc mpc83xx mpc8349ads
 
 TQM834x_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc83xx tqm834x
+	@$(MKCONFIG) $(@:_config=) ppc mpc83xx tqm834x
 
 MPC8349EMDS_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc83xx mpc8349emds
+	@$(MKCONFIG) $(@:_config=) ppc mpc83xx mpc8349emds
 
 #########################################################################
 ## MPC85xx Systems
 #########################################################################
 
 MPC8540ADS_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc85xx mpc8540ads
+	@$(MKCONFIG) $(@:_config=) ppc mpc85xx mpc8540ads
 
 MPC8540EVAL_config \
 MPC8540EVAL_33_config \
 MPC8540EVAL_66_config \
 MPC8540EVAL_33_slave_config \
 MPC8540EVAL_66_slave_config:      unconfig
-	@echo "" >include/config.h ; \
+	@mkdir -p $(obj)include
+	@echo "" >$(obj)include/config.h ; \
 	if [ "$(findstring _33_,$@)" ] ; then \
 		echo -n "... 33 MHz PCI" ; \
 	else \
-		echo "#define CONFIG_SYSCLK_66M" >>include/config.h ; \
+		echo "#define CONFIG_SYSCLK_66M" >>$(obj)include/config.h ; \
 		echo -n "... 66 MHz PCI" ; \
 	fi ; \
 	if [ "$(findstring _slave_,$@)" ] ; then \
-		echo "#define CONFIG_PCI_SLAVE" >>include/config.h ; \
+		echo "#define CONFIG_PCI_SLAVE" >>$(obj)include/config.h ; \
 		echo " slave" ; \
 	else \
 		echo " host" ; \
 	fi
-	@./mkconfig -a MPC8540EVAL ppc mpc85xx mpc8540eval
+	@$(MKCONFIG) -a MPC8540EVAL ppc mpc85xx mpc8540eval
 
 MPC8560ADS_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc85xx mpc8560ads
+	@$(MKCONFIG) $(@:_config=) ppc mpc85xx mpc8560ads
 
 MPC8541CDS_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc85xx mpc8541cds cds
+	@$(MKCONFIG) $(@:_config=) ppc mpc85xx mpc8541cds cds
 
 MPC8548CDS_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc85xx mpc8548cds cds
+	@$(MKCONFIG) $(@:_config=) ppc mpc85xx mpc8548cds cds
 
 MPC8555CDS_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc85xx mpc8555cds cds
+	@$(MKCONFIG) $(@:_config=) ppc mpc85xx mpc8555cds cds
 
 PM854_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc85xx pm854
+	@$(MKCONFIG) $(@:_config=) ppc mpc85xx pm854
 
 PM856_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc85xx pm856
+	@$(MKCONFIG) $(@:_config=) ppc mpc85xx pm856
 
 sbc8540_config \
 sbc8540_33_config \
 sbc8540_66_config:	unconfig
+	@mkdir -p $(obj)include
 	@if [ "$(findstring _66_,$@)" ] ; then \
-		echo "#define CONFIG_PCI_66"	>>include/config.h ; \
+		echo "#define CONFIG_PCI_66"	>>$(obj)include/config.h ; \
 		echo "... 66 MHz PCI" ; \
 	else \
-		>include/config.h ; \
+		>$(obj)include/config.h ; \
 		echo "... 33 MHz PCI" ; \
 	fi
-	@./mkconfig -a SBC8540 ppc mpc85xx sbc8560
+	@$(MKCONFIG) -a SBC8540 ppc mpc85xx sbc8560
 
 sbc8560_config \
 sbc8560_33_config \
 sbc8560_66_config:      unconfig
+	@mkdir -p $(obj)include
 	@if [ "$(findstring _66_,$@)" ] ; then \
-		echo "#define CONFIG_PCI_66"	>>include/config.h ; \
+		echo "#define CONFIG_PCI_66"	>>$(obj)include/config.h ; \
 		echo "... 66 MHz PCI" ; \
 	else \
-		>include/config.h ; \
+		>$(obj)include/config.h ; \
 		echo "... 33 MHz PCI" ; \
 	fi
-	@./mkconfig -a sbc8560 ppc mpc85xx sbc8560
+	@$(MKCONFIG) -a sbc8560 ppc mpc85xx sbc8560
 
 stxgp3_config:		unconfig
-	@./mkconfig $(@:_config=) ppc mpc85xx stxgp3
+	@$(MKCONFIG) $(@:_config=) ppc mpc85xx stxgp3
 
 TQM8540_config		\
 TQM8541_config		\
 TQM8555_config		\
 TQM8560_config:		unconfig
+	@mkdir -p $(obj)include
 	@CTYPE=$(subst TQM,,$(@:_config=)); \
-	>include/config.h ; \
+	>$(obj)include/config.h ; \
 	echo "... TQM"$${CTYPE}; \
-	echo "#define CONFIG_MPC$${CTYPE}">>include/config.h; \
-	echo "#define CONFIG_TQM$${CTYPE}">>include/config.h; \
-	echo "#define CONFIG_HOSTNAME tqm$${CTYPE}">>include/config.h; \
-	echo "#define CONFIG_BOARDNAME \"TQM$${CTYPE}\"">>include/config.h; \
-	echo "#define CFG_BOOTFILE \"bootfile=/tftpboot/tqm$${CTYPE}/uImage\0\"">>include/config.h
-	@./mkconfig -a TQM85xx ppc mpc85xx tqm85xx
+	echo "#define CONFIG_MPC$${CTYPE}">>$(obj)include/config.h; \
+	echo "#define CONFIG_TQM$${CTYPE}">>$(obj)include/config.h; \
+	echo "#define CONFIG_HOSTNAME tqm$${CTYPE}">>$(obj)include/config.h; \
+	echo "#define CONFIG_BOARDNAME \"TQM$${CTYPE}\"">>$(obj)include/config.h; \
+	echo "#define CFG_BOOTFILE \"bootfile=/tftpboot/tqm$${CTYPE}/uImage\0\"">>$(obj)include/config.h
+	@$(MKCONFIG) -a TQM85xx ppc mpc85xx tqm85xx
 
 #########################################################################
 ## 74xx/7xx Systems
 #########################################################################
 
 AmigaOneG3SE_config:	unconfig
-	@./mkconfig $(@:_config=) ppc 74xx_7xx AmigaOneG3SE MAI
+	@$(MKCONFIG) $(@:_config=) ppc 74xx_7xx AmigaOneG3SE MAI
 
 BAB7xx_config: unconfig
-	@./mkconfig $(@:_config=) ppc 74xx_7xx bab7xx eltec
+	@$(MKCONFIG) $(@:_config=) ppc 74xx_7xx bab7xx eltec
 
 CPCI750_config:        unconfig
-	@./mkconfig CPCI750 ppc 74xx_7xx cpci750 esd
+	@$(MKCONFIG) CPCI750 ppc 74xx_7xx cpci750 esd
 
 DB64360_config:  unconfig
-	@./mkconfig DB64360 ppc 74xx_7xx db64360 Marvell
+	@$(MKCONFIG) DB64360 ppc 74xx_7xx db64360 Marvell
 
 DB64460_config:  unconfig
-	@./mkconfig DB64460 ppc 74xx_7xx db64460 Marvell
+	@$(MKCONFIG) DB64460 ppc 74xx_7xx db64460 Marvell
 
 ELPPC_config: unconfig
-	@./mkconfig $(@:_config=) ppc 74xx_7xx elppc eltec
+	@$(MKCONFIG) $(@:_config=) ppc 74xx_7xx elppc eltec
 
 EVB64260_config	\
 EVB64260_750CX_config:	unconfig
-	@./mkconfig EVB64260 ppc 74xx_7xx evb64260
+	@$(MKCONFIG) EVB64260 ppc 74xx_7xx evb64260
 
 P3G4_config: unconfig
-	@./mkconfig $(@:_config=) ppc 74xx_7xx evb64260
+	@$(MKCONFIG) $(@:_config=) ppc 74xx_7xx evb64260
 
 PCIPPC2_config \
 PCIPPC6_config: unconfig
-	@./mkconfig $(@:_config=) ppc 74xx_7xx pcippc2
+	@$(MKCONFIG) $(@:_config=) ppc 74xx_7xx pcippc2
 
 ZUMA_config:	unconfig
-	@./mkconfig $(@:_config=) ppc 74xx_7xx evb64260
+	@$(MKCONFIG) $(@:_config=) ppc 74xx_7xx evb64260
 
 ppmc7xx_config: unconfig
-	@./mkconfig $(@:_config=) ppc 74xx_7xx ppmc7xx
+	@$(MKCONFIG) $(@:_config=) ppc 74xx_7xx ppmc7xx
 
 #========================================================================
 # ARM
@@ -1541,19 +1666,19 @@
 #########################################################################
 
 assabet_config	:	unconfig
-	@./mkconfig $(@:_config=) arm sa1100 assabet
+	@$(MKCONFIG) $(@:_config=) arm sa1100 assabet
 
 dnp1110_config	:	unconfig
-	@./mkconfig $(@:_config=) arm sa1100 dnp1110
+	@$(MKCONFIG) $(@:_config=) arm sa1100 dnp1110
 
 gcplus_config	:	unconfig
-	@./mkconfig $(@:_config=) arm sa1100 gcplus
+	@$(MKCONFIG) $(@:_config=) arm sa1100 gcplus
 
 lart_config	:	unconfig
-	@./mkconfig $(@:_config=) arm sa1100 lart
+	@$(MKCONFIG) $(@:_config=) arm sa1100 lart
 
 shannon_config	:	unconfig
-	@./mkconfig $(@:_config=) arm sa1100 shannon
+	@$(MKCONFIG) $(@:_config=) arm sa1100 shannon
 
 #########################################################################
 ## ARM92xT Systems
@@ -1566,16 +1691,16 @@
 xtract_omap730p2 = $(subst _cs0boot,,$(subst _cs3boot,, $(subst _config,,$1)))
 
 at91rm9200dk_config	:	unconfig
-	@./mkconfig $(@:_config=) arm arm920t at91rm9200dk NULL at91rm9200
+	@$(MKCONFIG) $(@:_config=) arm arm920t at91rm9200dk NULL at91rm9200
 
 cmc_pu2_config	:	unconfig
-	@./mkconfig $(@:_config=) arm arm920t cmc_pu2 NULL at91rm9200
+	@$(MKCONFIG) $(@:_config=) arm arm920t cmc_pu2 NULL at91rm9200
 
 csb637_config	:	unconfig
-	@./mkconfig $(@:_config=) arm arm920t csb637 NULL at91rm9200
+	@$(MKCONFIG) $(@:_config=) arm arm920t csb637 NULL at91rm9200
 
 mp2usb_config	:	unconfig
-	@./mkconfig $(@:_config=) arm arm920t mp2usb NULL at91rm9200
+	@$(MKCONFIG) $(@:_config=) arm arm920t mp2usb NULL at91rm9200
 
 
 ########################################################################
@@ -1605,34 +1730,35 @@
 	@board/integratorcp/split_by_variant.sh $@
 
 kb9202_config	:	unconfig
-	@./mkconfig $(@:_config=) arm arm920t kb9202 NULL at91rm9200
+	@$(MKCONFIG) $(@:_config=) arm arm920t kb9202 NULL at91rm9200
 
 lpd7a400_config \
 lpd7a404_config:	unconfig
-	@./mkconfig $(@:_config=) arm lh7a40x lpd7a40x
+	@$(MKCONFIG) $(@:_config=) arm lh7a40x lpd7a40x
 
 mx1ads_config	:	unconfig
-	@./mkconfig $(@:_config=) arm arm920t mx1ads NULL imx
+	@$(MKCONFIG) $(@:_config=) arm arm920t mx1ads NULL imx
 
 mx1fs2_config	:	unconfig
-	@./mkconfig $(@:_config=) arm arm920t mx1fs2 NULL imx
+	@$(MKCONFIG) $(@:_config=) arm arm920t mx1fs2 NULL imx
 
 netstar_32_config	\
 netstar_config:		unconfig
+	@mkdir -p $(obj)include
 	@if [ "$(findstring _32_,$@)" ] ; then \
 		echo "... 32MB SDRAM" ; \
-		echo "#define PHYS_SDRAM_1_SIZE SZ_32M" >>include/config.h ; \
+		echo "#define PHYS_SDRAM_1_SIZE SZ_32M" >>$(obj)include/config.h ; \
 	else \
 		echo "... 64MB SDRAM" ; \
-		echo "#define PHYS_SDRAM_1_SIZE SZ_64M" >>include/config.h ; \
+		echo "#define PHYS_SDRAM_1_SIZE SZ_64M" >>$(obj)include/config.h ; \
 	fi
-	@./mkconfig -a netstar arm arm925t netstar
+	@$(MKCONFIG) -a netstar arm arm925t netstar
 
 omap1510inn_config :	unconfig
-	@./mkconfig $(@:_config=) arm arm925t omap1510inn
+	@$(MKCONFIG) $(@:_config=) arm arm925t omap1510inn
 
 omap5912osk_config :	unconfig
-	@./mkconfig $(@:_config=) arm arm926ejs omap5912osk NULL omap
+	@$(MKCONFIG) $(@:_config=) arm arm926ejs omap5912osk NULL omap
 
 omap1610inn_config \
 omap1610inn_cs0boot_config \
@@ -1642,72 +1768,76 @@
 omap1610h2_cs0boot_config \
 omap1610h2_cs3boot_config \
 omap1610h2_cs_autoboot_config:	unconfig
+	@mkdir -p $(obj)include
 	@if [ "$(findstring _cs0boot_, $@)" ] ; then \
-		echo "#define CONFIG_CS0_BOOT" >> ./include/config.h ; \
+		echo "#define CONFIG_CS0_BOOT" >> .$(obj)/include/config.h ; \
 		echo "... configured for CS0 boot"; \
 	elif [ "$(findstring _cs_autoboot_, $@)" ] ; then \
-		echo "#define CONFIG_CS_AUTOBOOT" >> ./include/config.h ; \
+		echo "#define CONFIG_CS_AUTOBOOT" >> $(obj)./include/config.h ; \
 		echo "... configured for CS_AUTO boot"; \
 	else \
-		echo "#define CONFIG_CS3_BOOT" >> ./include/config.h ; \
+		echo "#define CONFIG_CS3_BOOT" >> $(obj)./include/config.h ; \
 		echo "... configured for CS3 boot"; \
 	fi;
-	@./mkconfig -a $(call xtract_omap1610xxx,$@) arm arm926ejs omap1610inn NULL omap
+	@$(MKCONFIG) -a $(call xtract_omap1610xxx,$@) arm arm926ejs omap1610inn NULL omap
 
 omap730p2_config \
 omap730p2_cs0boot_config \
 omap730p2_cs3boot_config :	unconfig
+	@mkdir -p $(obj)include
 	@if [ "$(findstring _cs0boot_, $@)" ] ; then \
-		echo "#define CONFIG_CS0_BOOT" >> ./include/config.h ; \
+		echo "#define CONFIG_CS0_BOOT" >> $(obj)include/config.h ; \
 		echo "... configured for CS0 boot"; \
 	else \
-		echo "#define CONFIG_CS3_BOOT" >> ./include/config.h ; \
+		echo "#define CONFIG_CS3_BOOT" >> $(obj)include/config.h ; \
 		echo "... configured for CS3 boot"; \
 	fi;
-	@./mkconfig -a $(call xtract_omap730p2,$@) arm arm926ejs omap730p2 NULL omap
+	@$(MKCONFIG) -a $(call xtract_omap730p2,$@) arm arm926ejs omap730p2 NULL omap
 
 sbc2410x_config: unconfig
-	@./mkconfig $(@:_config=) arm arm920t sbc2410x NULL s3c24x0
+	@$(MKCONFIG) $(@:_config=) arm arm920t sbc2410x NULL s3c24x0
 
 scb9328_config	:	unconfig
-	@./mkconfig $(@:_config=) arm arm920t scb9328 NULL imx
+	@$(MKCONFIG) $(@:_config=) arm arm920t scb9328 NULL imx
 
 smdk2400_config	:	unconfig
-	@./mkconfig $(@:_config=) arm arm920t smdk2400 NULL s3c24x0
+	@$(MKCONFIG) $(@:_config=) arm arm920t smdk2400 NULL s3c24x0
 
 smdk2410_config	:	unconfig
-	@./mkconfig $(@:_config=) arm arm920t smdk2410 NULL s3c24x0
+	@$(MKCONFIG) $(@:_config=) arm arm920t smdk2410 NULL s3c24x0
 
 SX1_config :		unconfig
-	@./mkconfig $(@:_config=) arm arm925t sx1
+	@$(MKCONFIG) $(@:_config=) arm arm925t sx1
 
 # TRAB default configuration:	8 MB Flash, 32 MB RAM
 trab_config \
 trab_bigram_config \
 trab_bigflash_config \
 trab_old_config:	unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@mkdir -p $(obj)board/trab
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring _bigram,$@)" ] || \
-		{ echo "#define CONFIG_FLASH_8MB"  >>include/config.h ; \
-		  echo "#define CONFIG_RAM_32MB"   >>include/config.h ; \
+		{ echo "#define CONFIG_FLASH_8MB"  >>$(obj)include/config.h ; \
+		  echo "#define CONFIG_RAM_32MB"   >>$(obj)include/config.h ; \
 		  echo "... with 8 MB Flash, 32 MB RAM" ; \
 		}
 	@[ -z "$(findstring _bigflash,$@)" ] || \
-		{ echo "#define CONFIG_FLASH_16MB" >>include/config.h ; \
-		  echo "#define CONFIG_RAM_16MB"   >>include/config.h ; \
+		{ echo "#define CONFIG_FLASH_16MB" >>$(obj)include/config.h ; \
+		  echo "#define CONFIG_RAM_16MB"   >>$(obj)include/config.h ; \
 		  echo "... with 16 MB Flash, 16 MB RAM" ; \
-		  echo "TEXT_BASE = 0x0CF40000" >board/trab/config.tmp ; \
+		  echo "TEXT_BASE = 0x0CF40000" >$(obj)board/trab/config.tmp ; \
 		}
 	@[ -z "$(findstring _old,$@)" ] || \
-		{ echo "#define CONFIG_FLASH_8MB"  >>include/config.h ; \
-		  echo "#define CONFIG_RAM_16MB"   >>include/config.h ; \
+		{ echo "#define CONFIG_FLASH_8MB"  >>$(obj)include/config.h ; \
+		  echo "#define CONFIG_RAM_16MB"   >>$(obj)include/config.h ; \
 		  echo "... with 8 MB Flash, 16 MB RAM" ; \
-		  echo "TEXT_BASE = 0x0CF40000" >board/trab/config.tmp ; \
+		  echo "TEXT_BASE = 0x0CF40000" >$(obj)board/trab/config.tmp ; \
 		}
-	@./mkconfig -a $(call xtract_trab,$@) arm arm920t trab NULL s3c24x0
+	@$(MKCONFIG) -a $(call xtract_trab,$@) arm arm920t trab NULL s3c24x0
 
 VCMA9_config	:	unconfig
-	@./mkconfig $(@:_config=) arm arm920t vcma9 mpl s3c24x0
+	@$(MKCONFIG) $(@:_config=) arm arm920t vcma9 mpl s3c24x0
 
 #========================================================================
 # ARM supplied Versatile development boards
@@ -1719,117 +1849,120 @@
 
 voiceblue_smallflash_config	\
 voiceblue_config:	unconfig
+	@mkdir -p $(obj)include
+	@mkdir -p $(obj)board/voiceblue
 	@if [ "$(findstring _smallflash_,$@)" ] ; then \
 		echo "... boot from lower flash bank" ; \
-		echo "#define VOICEBLUE_SMALL_FLASH" >>include/config.h ; \
-		echo "VOICEBLUE_SMALL_FLASH=y" >board/voiceblue/config.tmp ; \
+		echo "#define VOICEBLUE_SMALL_FLASH" >>$(obj)include/config.h ; \
+		echo "VOICEBLUE_SMALL_FLASH=y" >$(obj)board/voiceblue/config.tmp ; \
 	else \
 		echo "... boot from upper flash bank" ; \
-		>include/config.h ; \
-		echo "VOICEBLUE_SMALL_FLASH=n" >board/voiceblue/config.tmp ; \
+		>$(obj)include/config.h ; \
+		echo "VOICEBLUE_SMALL_FLASH=n" >$(obj)board/voiceblue/config.tmp ; \
 	fi
-	@./mkconfig -a voiceblue arm arm925t voiceblue
+	@$(MKCONFIG) -a voiceblue arm arm925t voiceblue
 
 cm4008_config	:	unconfig
-	@./mkconfig $(@:_config=) arm arm920t cm4008 NULL ks8695
+	@$(MKCONFIG) $(@:_config=) arm arm920t cm4008 NULL ks8695
 
 cm41xx_config	:	unconfig
-	@./mkconfig $(@:_config=) arm arm920t cm41xx NULL ks8695
+	@$(MKCONFIG) $(@:_config=) arm arm920t cm41xx NULL ks8695
 
 gth2_config		: 	unconfig
-	@ >include/config.h
-	@echo "#define CONFIG_GTH2 1" >>include/config.h
-	@./mkconfig -a gth2 mips mips gth2
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
+	@echo "#define CONFIG_GTH2 1" >>$(obj)include/config.h
+	@$(MKCONFIG) -a gth2 mips mips gth2
 
 #########################################################################
 ## S3C44B0 Systems
 #########################################################################
 
 B2_config	:	unconfig
-	@./mkconfig $(@:_config=) arm s3c44b0 B2 dave
+	@$(MKCONFIG) $(@:_config=) arm s3c44b0 B2 dave
 
 #########################################################################
 ## ARM720T Systems
 #########################################################################
 
 armadillo_config:	unconfig
-	@./mkconfig $(@:_config=) arm arm720t armadillo
+	@$(MKCONFIG) $(@:_config=) arm arm720t armadillo
 
 ep7312_config	:	unconfig
-	@./mkconfig $(@:_config=) arm arm720t ep7312
+	@$(MKCONFIG) $(@:_config=) arm arm720t ep7312
 
 impa7_config	:	unconfig
-	@./mkconfig $(@:_config=) arm arm720t impa7
+	@$(MKCONFIG) $(@:_config=) arm arm720t impa7
 
 modnet50_config :	unconfig
-	@./mkconfig $(@:_config=) arm arm720t modnet50
+	@$(MKCONFIG) $(@:_config=) arm arm720t modnet50
 
 evb4510_config :	unconfig
-	@./mkconfig $(@:_config=) arm arm720t evb4510
+	@$(MKCONFIG) $(@:_config=) arm arm720t evb4510
 
 #########################################################################
 ## XScale Systems
 #########################################################################
 
 adsvix_config	:	unconfig
-	@./mkconfig $(@:_config=) arm pxa adsvix
+	@$(MKCONFIG) $(@:_config=) arm pxa adsvix
 
 cerf250_config :	unconfig
-	@./mkconfig $(@:_config=) arm pxa cerf250
+	@$(MKCONFIG) $(@:_config=) arm pxa cerf250
 
 cradle_config	:	unconfig
-	@./mkconfig $(@:_config=) arm pxa cradle
+	@$(MKCONFIG) $(@:_config=) arm pxa cradle
 
 csb226_config	:	unconfig
-	@./mkconfig $(@:_config=) arm pxa csb226
+	@$(MKCONFIG) $(@:_config=) arm pxa csb226
 
 delta_config :
-	@./mkconfig $(@:_config=) arm pxa delta
+	@$(MKCONFIG) $(@:_config=) arm pxa delta
 
 innokom_config	:	unconfig
-	@./mkconfig $(@:_config=) arm pxa innokom
+	@$(MKCONFIG) $(@:_config=) arm pxa innokom
 
 ixdp425_config	:	unconfig
-	@./mkconfig $(@:_config=) arm ixp ixdp425
+	@$(MKCONFIG) $(@:_config=) arm ixp ixdp425
 
 ixdpg425_config	:	unconfig
-	@./mkconfig $(@:_config=) arm ixp ixdp425
+	@$(MKCONFIG) $(@:_config=) arm ixp ixdp425
 
 lubbock_config	:	unconfig
-	@./mkconfig $(@:_config=) arm pxa lubbock
+	@$(MKCONFIG) $(@:_config=) arm pxa lubbock
 
 pleb2_config	:	unconfig
-	@./mkconfig $(@:_config=) arm pxa pleb2
+	@$(MKCONFIG) $(@:_config=) arm pxa pleb2
 
 logodl_config	:	unconfig
-	@./mkconfig $(@:_config=) arm pxa logodl
+	@$(MKCONFIG) $(@:_config=) arm pxa logodl
 
 pdnb3_config	:	unconfig
-	@./mkconfig $(@:_config=) arm ixp pdnb3 prodrive
+	@$(MKCONFIG) $(@:_config=) arm ixp pdnb3 prodrive
 
 pxa255_idp_config:	unconfig
-	@./mkconfig $(@:_config=) arm pxa pxa255_idp
+	@$(MKCONFIG) $(@:_config=) arm pxa pxa255_idp
 
 wepep250_config	:	unconfig
-	@./mkconfig $(@:_config=) arm pxa wepep250
+	@$(MKCONFIG) $(@:_config=) arm pxa wepep250
 
 xaeniax_config	:	unconfig
-	@./mkconfig $(@:_config=) arm pxa xaeniax
+	@$(MKCONFIG) $(@:_config=) arm pxa xaeniax
 
 xm250_config	:	unconfig
-	@./mkconfig $(@:_config=) arm pxa xm250
+	@$(MKCONFIG) $(@:_config=) arm pxa xm250
 
 xsengine_config :	unconfig
-	@./mkconfig $(@:_config=) arm pxa xsengine
+	@$(MKCONFIG) $(@:_config=) arm pxa xsengine
 
 zylonite_config :
-	@./mkconfig $(@:_config=) arm pxa zylonite
+	@$(MKCONFIG) $(@:_config=) arm pxa zylonite
 
 #########################################################################
 ## ARM1136 Systems
 #########################################################################
 omap2420h4_config :    unconfig
-	@./mkconfig $(@:_config=) arm arm1136 omap2420h4
+	@$(MKCONFIG) $(@:_config=) arm arm1136 omap2420h4
 
 #========================================================================
 # i386
@@ -1838,13 +1971,13 @@
 ## AMD SC520 CDP
 #########################################################################
 sc520_cdp_config	:	unconfig
-	@./mkconfig $(@:_config=) i386 i386 sc520_cdp
+	@$(MKCONFIG) $(@:_config=) i386 i386 sc520_cdp
 
 sc520_spunk_config	:	unconfig
-	@./mkconfig $(@:_config=) i386 i386 sc520_spunk
+	@$(MKCONFIG) $(@:_config=) i386 i386 sc520_spunk
 
 sc520_spunk_rel_config	:	unconfig
-	@./mkconfig $(@:_config=) i386 i386 sc520_spunk
+	@$(MKCONFIG) $(@:_config=) i386 i386 sc520_spunk
 
 #========================================================================
 # MIPS
@@ -1859,63 +1992,70 @@
 incaip_133MHz_config	\
 incaip_150MHz_config	\
 incaip_config: unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring _100MHz,$@)" ] || \
-		{ echo "#define CPU_CLOCK_RATE 100000000" >>include/config.h ; \
+		{ echo "#define CPU_CLOCK_RATE 100000000" >>$(obj)include/config.h ; \
 		  echo "... with 100MHz system clock" ; \
 		}
 	@[ -z "$(findstring _133MHz,$@)" ] || \
-		{ echo "#define CPU_CLOCK_RATE 133000000" >>include/config.h ; \
+		{ echo "#define CPU_CLOCK_RATE 133000000" >>$(obj)include/config.h ; \
 		  echo "... with 133MHz system clock" ; \
 		}
 	@[ -z "$(findstring _150MHz,$@)" ] || \
-		{ echo "#define CPU_CLOCK_RATE 150000000" >>include/config.h ; \
+		{ echo "#define CPU_CLOCK_RATE 150000000" >>$(obj)include/config.h ; \
 		  echo "... with 150MHz system clock" ; \
 		}
-	@./mkconfig -a $(call xtract_incaip,$@) mips mips incaip
+	@$(MKCONFIG) -a $(call xtract_incaip,$@) mips mips incaip
 
 tb0229_config: unconfig
-	@./mkconfig $(@:_config=) mips mips tb0229
+	@$(MKCONFIG) $(@:_config=) mips mips tb0229
 
 #########################################################################
 ## MIPS32 AU1X00
 #########################################################################
 dbau1000_config		: 	unconfig
-	@ >include/config.h
-	@echo "#define CONFIG_DBAU1000 1" >>include/config.h
-	@./mkconfig -a dbau1x00 mips mips dbau1x00
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
+	@echo "#define CONFIG_DBAU1000 1" >>$(obj)include/config.h
+	@$(MKCONFIG) -a dbau1x00 mips mips dbau1x00
 
 dbau1100_config		: 	unconfig
-	@ >include/config.h
-	@echo "#define CONFIG_DBAU1100 1" >>include/config.h
-	@./mkconfig -a dbau1x00 mips mips dbau1x00
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
+	@echo "#define CONFIG_DBAU1100 1" >>$(obj)include/config.h
+	@$(MKCONFIG) -a dbau1x00 mips mips dbau1x00
 
 dbau1500_config		: 	unconfig
-	@ >include/config.h
-	@echo "#define CONFIG_DBAU1500 1" >>include/config.h
-	@./mkconfig -a dbau1x00 mips mips dbau1x00
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
+	@echo "#define CONFIG_DBAU1500 1" >>$(obj)include/config.h
+	@$(MKCONFIG) -a dbau1x00 mips mips dbau1x00
 
 dbau1550_config		:	unconfig
-	@ >include/config.h
-	@echo "#define CONFIG_DBAU1550 1" >>include/config.h
-	@./mkconfig -a dbau1x00 mips mips dbau1x00
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
+	@echo "#define CONFIG_DBAU1550 1" >>$(obj)include/config.h
+	@$(MKCONFIG) -a dbau1x00 mips mips dbau1x00
 
 dbau1550_el_config	:	unconfig
-	@ >include/config.h
-	@echo "#define CONFIG_DBAU1550 1" >>include/config.h
-	@./mkconfig -a dbau1x00 mips mips dbau1x00
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
+	@echo "#define CONFIG_DBAU1550 1" >>$(obj)include/config.h
+	@$(MKCONFIG) -a dbau1x00 mips mips dbau1x00
 
 pb1000_config		: 	unconfig
-	@ >include/config.h
-	@echo "#define CONFIG_PB1000 1" >>include/config.h
-	@./mkconfig -a pb1x00 mips mips pb1x00
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
+	@echo "#define CONFIG_PB1000 1" >>$(obj)include/config.h
+	@$(MKCONFIG) -a pb1x00 mips mips pb1x00
 
 #########################################################################
 ## MIPS64 5Kc
 #########################################################################
 
 purple_config :		unconfig
-	@./mkconfig $(@:_config=) mips mips purple
+	@$(MKCONFIG) $(@:_config=) mips mips purple
 
 #========================================================================
 # Nios
@@ -1927,80 +2067,83 @@
 DK1C20_safe_32_config		\
 DK1C20_standard_32_config	\
 DK1C20_config:	unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring _safe_32,$@)" ] || \
-		{ echo "#define CONFIG_NIOS_SAFE_32 1" >>include/config.h ; \
+		{ echo "#define CONFIG_NIOS_SAFE_32 1" >>$(obj)include/config.h ; \
 		  echo "... NIOS 'safe_32' configuration" ; \
 		}
 	@[ -z "$(findstring _standard_32,$@)" ] || \
-		{ echo "#define CONFIG_NIOS_STANDARD_32 1" >>include/config.h ; \
+		{ echo "#define CONFIG_NIOS_STANDARD_32 1" >>$(obj)include/config.h ; \
 		  echo "... NIOS 'standard_32' configuration" ; \
 		}
 	@[ -z "$(findstring DK1C20_config,$@)" ] || \
-		{ echo "#define CONFIG_NIOS_STANDARD_32 1" >>include/config.h ; \
+		{ echo "#define CONFIG_NIOS_STANDARD_32 1" >>$(obj)include/config.h ; \
 		  echo "... NIOS 'standard_32' configuration (DEFAULT)" ; \
 		}
-	@./mkconfig -a DK1C20 nios nios dk1c20 altera
+	@$(MKCONFIG) -a DK1C20 nios nios dk1c20 altera
 
 DK1S10_safe_32_config		\
 DK1S10_standard_32_config	\
 DK1S10_mtx_ldk_20_config	\
 DK1S10_config:	unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring _safe_32,$@)" ] || \
-		{ echo "#define CONFIG_NIOS_SAFE_32 1" >>include/config.h ; \
+		{ echo "#define CONFIG_NIOS_SAFE_32 1" >>$(obj)include/config.h ; \
 		  echo "... NIOS 'safe_32' configuration" ; \
 		}
 	@[ -z "$(findstring _standard_32,$@)" ] || \
-		{ echo "#define CONFIG_NIOS_STANDARD_32 1" >>include/config.h ; \
+		{ echo "#define CONFIG_NIOS_STANDARD_32 1" >>$(obj)include/config.h ; \
 		  echo "... NIOS 'standard_32' configuration" ; \
 		}
 	@[ -z "$(findstring _mtx_ldk_20,$@)" ] || \
-		{ echo "#define CONFIG_NIOS_MTX_LDK_20 1" >>include/config.h ; \
+		{ echo "#define CONFIG_NIOS_MTX_LDK_20 1" >>$(obj)include/config.h ; \
 		  echo "... NIOS 'mtx_ldk_20' configuration" ; \
 		}
 	@[ -z "$(findstring DK1S10_config,$@)" ] || \
-		{ echo "#define CONFIG_NIOS_STANDARD_32 1" >>include/config.h ; \
+		{ echo "#define CONFIG_NIOS_STANDARD_32 1" >>$(obj)include/config.h ; \
 		  echo "... NIOS 'standard_32' configuration (DEFAULT)" ; \
 		}
-	@./mkconfig -a DK1S10 nios nios dk1s10 altera
+	@$(MKCONFIG) -a DK1S10 nios nios dk1s10 altera
 
 ADNPESC1_DNPEVA2_base_32_config	\
 ADNPESC1_base_32_config		\
 ADNPESC1_config: unconfig
-	@ >include/config.h
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
 	@[ -z "$(findstring _DNPEVA2,$@)" ] || \
-		{ echo "#define CONFIG_DNPEVA2 1" >>include/config.h ; \
+		{ echo "#define CONFIG_DNPEVA2 1" >>$(obj)include/config.h ; \
 		  echo "... DNP/EVA2 configuration" ; \
 		}
 	@[ -z "$(findstring _base_32,$@)" ] || \
-		{ echo "#define CONFIG_NIOS_BASE_32 1" >>include/config.h ; \
+		{ echo "#define CONFIG_NIOS_BASE_32 1" >>$(obj)include/config.h ; \
 		  echo "... NIOS 'base_32' configuration" ; \
 		}
 	@[ -z "$(findstring ADNPESC1_config,$@)" ] || \
-		{ echo "#define CONFIG_NIOS_BASE_32 1" >>include/config.h ; \
+		{ echo "#define CONFIG_NIOS_BASE_32 1" >>$(obj)include/config.h ; \
 		  echo "... NIOS 'base_32' configuration (DEFAULT)" ; \
 		}
-	@./mkconfig -a ADNPESC1 nios nios adnpesc1 ssv
+	@$(MKCONFIG) -a ADNPESC1 nios nios adnpesc1 ssv
 
 #########################################################################
 ## Nios-II
 #########################################################################
 
 EP1C20_config : unconfig
-	@./mkconfig  EP1C20 nios2 nios2 ep1c20 altera
+	@$(MKCONFIG)  EP1C20 nios2 nios2 ep1c20 altera
 
 EP1S10_config : unconfig
-	@./mkconfig  EP1S10 nios2 nios2 ep1s10 altera
+	@$(MKCONFIG)  EP1S10 nios2 nios2 ep1s10 altera
 
 EP1S40_config : unconfig
-	@./mkconfig  EP1S40 nios2 nios2 ep1s40 altera
+	@$(MKCONFIG)  EP1S40 nios2 nios2 ep1s40 altera
 
 PK1C20_config : unconfig
-	@./mkconfig  PK1C20 nios2 nios2 pk1c20 psyent
+	@$(MKCONFIG)  PK1C20 nios2 nios2 pk1c20 psyent
 
 PCI5441_config : unconfig
-	@./mkconfig  PCI5441 nios2 nios2 pci5441 psyent
+	@$(MKCONFIG)  PCI5441 nios2 nios2 pci5441 psyent
 
 #========================================================================
 # MicroBlaze
@@ -2009,62 +2152,70 @@
 ## Microblaze
 #########################################################################
 suzaku_config:	unconfig
-	@ >include/config.h
-	@echo "#define CONFIG_SUZAKU 1" >> include/config.h
-	@./mkconfig -a $(@:_config=) microblaze microblaze suzaku AtmarkTechno
+	@mkdir -p $(obj)include
+	@ >$(obj)include/config.h
+	@echo "#define CONFIG_SUZAKU 1" >> $(obj)include/config.h
+	@$(MKCONFIG) -a $(@:_config=) microblaze microblaze suzaku AtmarkTechno
 
 #########################################################################
 ## Blackfin
 #########################################################################
 ezkit533_config	:	unconfig
-	@./mkconfig $(@:_config=) blackfin bf533 ezkit533
+	@$(MKCONFIG) $(@:_config=) blackfin bf533 ezkit533
 
 stamp_config	:	unconfig
-	@./mkconfig $(@:_config=) blackfin bf533 stamp
+	@$(MKCONFIG) $(@:_config=) blackfin bf533 stamp
 
 dspstamp_config	:	unconfig
-	@./mkconfig $(@:_config=) blackfin bf533 dsp_stamp
+	@$(MKCONFIG) $(@:_config=) blackfin bf533 dsp_stamp
 
 #########################################################################
 #########################################################################
 #########################################################################
 
 clean:
-	find . -type f \
+	find $(OBJTREE) -type f \
 		\( -name 'core' -o -name '*.bak' -o -name '*~' \
 		-o -name '*.o'  -o -name '*.a'  \) -print \
 		| xargs rm -f
-	rm -f examples/hello_world examples/timer \
-	      examples/eepro100_eeprom examples/sched \
-	      examples/mem_to_mem_idma2intr examples/82559_eeprom \
-	      examples/smc91111_eeprom \
-	      examples/test_burst
-	rm -f tools/img2srec tools/mkimage tools/envcrc tools/gen_eth_addr
-	rm -f tools/mpc86x_clk tools/ncb
-	rm -f tools/easylogo/easylogo tools/bmp_logo
-	rm -f tools/gdb/astest tools/gdb/gdbcont tools/gdb/gdbsend
-	rm -f tools/env/fw_printenv tools/env/fw_setenv
-	rm -f board/cray/L1/bootscript.c board/cray/L1/bootscript.image
-	rm -f board/netstar/eeprom board/netstar/crcek
-	rm -f board/netstar/*.srec board/netstar/*.bin
-	rm -f board/trab/trab_fkt board/voiceblue/eeprom
-	rm -f board/integratorap/u-boot.lds board/integratorcp/u-boot.lds
-	rm -f include/bmp_logo.h
+	rm -f $(obj)examples/hello_world $(obj)examples/timer \
+	      $(obj)examples/eepro100_eeprom $(obj)examples/sched \
+	      $(obj)examples/mem_to_mem_idma2intr $(obj)examples/82559_eeprom \
+	      $(obj)examples/smc91111_eeprom \
+	      $(obj)examples/test_burst
+	rm -f $(obj)tools/img2srec $(obj)tools/mkimage $(obj)tools/envcrc \
+		$(obj)tools/gen_eth_addr
+	rm -f $(obj)tools/mpc86x_clk $(obj)tools/ncb
+	rm -f $(obj)tools/easylogo/easylogo $(obj)tools/bmp_logo
+	rm -f $(obj)tools/gdb/astest $(obj)tools/gdb/gdbcont $(obj)tools/gdb/gdbsend
+	rm -f $(obj)tools/env/fw_printenv $(obj)tools/env/fw_setenv
+	rm -f $(obj)board/cray/L1/bootscript.c $(obj)board/cray/L1/bootscript.image
+	rm -f $(obj)board/netstar/eeprom $(obj)board/netstar/crcek $(obj)board/netstar/crcit
+	rm -f $(obj)board/netstar/*.srec $(obj)board/netstar/*.bin
+	rm -f $(obj)board/trab/trab_fkt $(obj)board/voiceblue/eeprom
+	rm -f $(obj)board/integratorap/u-boot.lds $(obj)board/integratorcp/u-boot.lds
+	rm -f $(obj)include/bmp_logo.h
 
 clobber:	clean
-	find . -type f \( -name .depend \
+	find $(OBJTREE) -type f \( -name .depend \
 		-o -name '*.srec' -o -name '*.bin' -o -name u-boot.img \) \
 		-print0 \
 		| xargs -0 rm -f
-	rm -f $(OBJS) *.bak tags TAGS include/version_autogenerated.h
-	rm -fr *.*~
-	rm -f u-boot u-boot.map u-boot.hex $(ALL)
-	rm -f tools/crc32.c tools/environment.c tools/env/crc32.c
-	rm -f tools/inca-swap-bytes cpu/mpc824x/bedbug_603e.c
-	rm -f include/asm/proc include/asm/arch include/asm
+	rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS $(obj)include/version_autogenerated.h
+	rm -fr $(obj)*.*~
+	rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL)
+	rm -f $(obj)tools/crc32.c $(obj)tools/environment.c $(obj)tools/env/crc32.c
+	rm -f $(obj)tools/inca-swap-bytes $(obj)cpu/mpc824x/bedbug_603e.c
+	rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
 
+ifeq ($(OBJTREE),$(SRCTREE))
+mrproper \
+distclean:	clobber unconfig
+else
 mrproper \
 distclean:	clobber unconfig
+	rm -rf $(OBJTREE)/*
+endif
 
 backup:
 	F=`basename $(TOPDIR)` ; cd .. ; \
diff --git a/board/AtmarkTechno/suzaku/Makefile b/board/AtmarkTechno/suzaku/Makefile
index 7a17067..b420269 100644
--- a/board/AtmarkTechno/suzaku/Makefile
+++ b/board/AtmarkTechno/suzaku/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/BuS/EB+MCF-EV123/Makefile b/board/BuS/EB+MCF-EV123/Makefile
index 0596572..57363bc 100644
--- a/board/BuS/EB+MCF-EV123/Makefile
+++ b/board/BuS/EB+MCF-EV123/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2003
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o cfm_flash.o flash.o VCxK.o
+COBJS	= $(BOARD).o cfm_flash.o flash.o VCxK.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/BuS/EB+MCF-EV123/textbase.mk b/board/BuS/EB+MCF-EV123/textbase.mk
index 10106f4..ecde6ed 100644
--- a/board/BuS/EB+MCF-EV123/textbase.mk
+++ b/board/BuS/EB+MCF-EV123/textbase.mk
@@ -1 +1 @@
-TEXT_BASE = 0xF0000000
+TEXT_BASE = 0xFFE00000
diff --git a/board/LEOX/elpt860/Makefile b/board/LEOX/elpt860/Makefile
index 3e73163..4304494 100644
--- a/board/LEOX/elpt860/Makefile
+++ b/board/LEOX/elpt860/Makefile
@@ -4,6 +4,9 @@
 # Copyright (C) 2000, 2001, 2002, 2003
 # The LEOX team <team@leox.org>, http://www.leox.org
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # LEOX.org is about the development of free hardware and software resources
 #   for system on chip.
 #
@@ -31,18 +34,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/MAI/AmigaOneG3SE/Makefile b/board/MAI/AmigaOneG3SE/Makefile
index b1247fe..e920482 100644
--- a/board/MAI/AmigaOneG3SE/Makefile
+++ b/board/MAI/AmigaOneG3SE/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2002
+# (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,8 +22,12 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../menu)
+$(shell mkdir -p $(obj)../bios_emulator)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
 COBJS	= $(BOARD).o articiaS.o flash.o serial.o smbus.o articiaS_pci.o \
 		via686.o i8259.o ../bios_emulator/x86interface.o 	\
@@ -31,26 +35,29 @@
 		interrupts.o ps2kbd.o video.o usb_uhci.o enet.o	        \
 		../menu/cmd_menu.o cmd_boota.o nvram.o
 
-AOBJS	= board_asm_init.o memio.o
-
-OBJS	= $(COBJS) $(AOBJS)
+SOBJS	= board_asm_init.o memio.o
 
 EMUDIR  = ../bios_emulator/scitech/src/x86emu/
 EMUOBJ  = $(EMUDIR)decode.o $(EMUDIR)ops2.o $(EMUDIR)fpu.o $(EMUDIR)prim_ops.o \
 		$(EMUDIR)ops.o $(EMUDIR)sys.o
-EMUSRC = $(EMUOBJ:.o=.c)
+EMUSRC  = $(EMUOBJ:.o=.c)
 
-$(LIB):	.depend $(OBJS) $(EMUSRC)
-	make libx86emu.a -C ../bios_emulator/scitech/src/x86emu -f makefile.uboot CROSS_COMPILE=$(CROSS_COMPILE)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+EMUOBJ  := $(addprefix $(obj),$(EMUOBJ))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS) $(EMUSRC)
+	make $(obj)libx86emu.a -C ../bios_emulator/scitech/src/x86emu -f makefile.uboot CROSS_COMPILE=$(CROSS_COMPILE)
 	-rm $(LIB)
-	$(AR) crv $@ $(OBJS) $(EMUOBJ)
+	$(AR) crv $@ $(OBJS) $(SOBJS) $(EMUOBJ)
 
 
 #########################################################################
 
-.depend: Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
-	$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/Marvell/db64360/Makefile b/board/Marvell/db64360/Makefile
index 768ccdd..a084c89 100644
--- a/board/Marvell/db64360/Makefile
+++ b/board/Marvell/db64360/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+# 
 # (C) Copyright 2001
 # Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
 #
@@ -22,23 +25,30 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
 SOBJS	= ../common/misc.o
 
-OBJS	= $(BOARD).o ../common/flash.o ../common/serial.o ../common/memory.o pci.o \
+COBJS	= $(BOARD).o ../common/flash.o ../common/serial.o ../common/memory.o pci.o \
 	  mv_eth.o ../common/ns16550.o mpsc.o ../common/i2c.o \
 	  sdram_init.o ../common/intel_flash.o
 
-$(LIB):	.depend $(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/Marvell/db64460/Makefile b/board/Marvell/db64460/Makefile
index 768ccdd..a084c89 100644
--- a/board/Marvell/db64460/Makefile
+++ b/board/Marvell/db64460/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+# 
 # (C) Copyright 2001
 # Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
 #
@@ -22,23 +25,30 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
 SOBJS	= ../common/misc.o
 
-OBJS	= $(BOARD).o ../common/flash.o ../common/serial.o ../common/memory.o pci.o \
+COBJS	= $(BOARD).o ../common/flash.o ../common/serial.o ../common/memory.o pci.o \
 	  mv_eth.o ../common/ns16550.o mpsc.o ../common/i2c.o \
 	  sdram_init.o ../common/intel_flash.o
 
-$(LIB):	.depend $(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/RPXClassic/Makefile b/board/RPXClassic/Makefile
index 93907ba..d8832ac 100644
--- a/board/RPXClassic/Makefile
+++ b/board/RPXClassic/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o eccx.o
+COBJS	= $(BOARD).o flash.o eccx.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/RPXlite/Makefile b/board/RPXlite/Makefile
index 13ce9fc..e3d24b3 100644
--- a/board/RPXlite/Makefile
+++ b/board/RPXlite/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/RPXlite_dw/Makefile b/board/RPXlite_dw/Makefile
index d457020..e3d24b3 100644
--- a/board/RPXlite_dw/Makefile
+++ b/board/RPXlite_dw/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/RRvision/Makefile b/board/RRvision/Makefile
index fdc6fd5..e3d24b3 100644
--- a/board/RRvision/Makefile
+++ b/board/RRvision/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/a3000/Makefile b/board/a3000/Makefile
index 5fde362..43c27e9 100644
--- a/board/a3000/Makefile
+++ b/board/a3000/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS 	= $(BOARD).o flash.o
+COBJS 	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/adder/Makefile b/board/adder/Makefile
index 9123a80..d0223b5 100644
--- a/board/adder/Makefile
+++ b/board/adder/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # Copyright (C) 2004 Arabella Software Ltd.
 # Yuli Barcohen <yuli@arabellasw.com>
 #
@@ -23,11 +26,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o
+COBJS	:= $(BOARD).o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/adsvix/Makefile b/board/adsvix/Makefile
index 24d5d06..0daa383 100644
--- a/board/adsvix/Makefile
+++ b/board/adsvix/Makefile
@@ -1,6 +1,5 @@
-
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -24,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= adsvix.o pcmcia.o
+COBJS	:= adsvix.o pcmcia.o
 SOBJS	:= lowlevel_init.o pxavoltage.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -40,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/alaska/Makefile b/board/alaska/Makefile
index a4c1d2e..969580e 100644
--- a/board/alaska/Makefile
+++ b/board/alaska/Makefile
@@ -1,4 +1,5 @@
-# (C) Copyright 2003-2005
+#
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o flash.o
+COBJS	:= $(BOARD).o flash.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -37,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/altera/dk1c20/Makefile b/board/altera/dk1c20/Makefile
index 9182a4e..26c724c 100644
--- a/board/altera/dk1c20/Makefile
+++ b/board/altera/dk1c20/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001-2004
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,14 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o flash.o misc.o
-
+COBJS	:= $(BOARD).o flash.o misc.o
 SOBJS  = vectors.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -40,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/altera/dk1s10/Makefile b/board/altera/dk1s10/Makefile
index 9182a4e..26c724c 100644
--- a/board/altera/dk1s10/Makefile
+++ b/board/altera/dk1s10/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001-2004
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,14 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o flash.o misc.o
-
+COBJS	:= $(BOARD).o flash.o misc.o
 SOBJS  = vectors.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -40,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/altera/ep1c20/Makefile b/board/altera/ep1c20/Makefile
index a92b258..26873b6 100644
--- a/board/altera/ep1c20/Makefile
+++ b/board/altera/ep1c20/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001-2004
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -12,7 +12,7 @@
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
@@ -22,17 +22,22 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
 COMOBJS := ../common/AMDLV065D.o ../common/epled.o
 
-OBJS	:= $(BOARD).o $(COMOBJS)
+COBJS	:= $(BOARD).o $(COMOBJS)
 
-SOBJS	=
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
-$(LIB): $(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+$(LIB):	$(obj).depend $(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -42,9 +47,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/altera/ep1s10/Makefile b/board/altera/ep1s10/Makefile
index a92b258..26873b6 100644
--- a/board/altera/ep1s10/Makefile
+++ b/board/altera/ep1s10/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001-2004
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -12,7 +12,7 @@
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
@@ -22,17 +22,22 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
 COMOBJS := ../common/AMDLV065D.o ../common/epled.o
 
-OBJS	:= $(BOARD).o $(COMOBJS)
+COBJS	:= $(BOARD).o $(COMOBJS)
 
-SOBJS	=
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
-$(LIB): $(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+$(LIB):	$(obj).depend $(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -42,9 +47,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/altera/ep1s40/Makefile b/board/altera/ep1s40/Makefile
index a92b258..26873b6 100644
--- a/board/altera/ep1s40/Makefile
+++ b/board/altera/ep1s40/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001-2004
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -12,7 +12,7 @@
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
@@ -22,17 +22,22 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
 COMOBJS := ../common/AMDLV065D.o ../common/epled.o
 
-OBJS	:= $(BOARD).o $(COMOBJS)
+COBJS	:= $(BOARD).o $(COMOBJS)
 
-SOBJS	=
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
-$(LIB): $(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+$(LIB):	$(obj).depend $(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -42,9 +47,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/amcc/bamboo/Makefile b/board/amcc/bamboo/Makefile
index 5654f91..5f3e34e 100644
--- a/board/amcc/bamboo/Makefile
+++ b/board/amcc/bamboo/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2002
+# (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o
-OBJS   += flash.o
+COBJS	= $(BOARD).o flash.o
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
@@ -40,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/amcc/bubinga/Makefile b/board/amcc/bubinga/Makefile
index f5bda55..e78ed5f 100644
--- a/board/amcc/bubinga/Makefile
+++ b/board/amcc/bubinga/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,9 +23,13 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/amcc/ebony/Makefile b/board/amcc/ebony/Makefile
index 4a3927b..5f3e34e 100644
--- a/board/amcc/ebony/Makefile
+++ b/board/amcc/ebony/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2002
+# (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/amcc/luan/Makefile b/board/amcc/luan/Makefile
index 5654f91..5f3e34e 100644
--- a/board/amcc/luan/Makefile
+++ b/board/amcc/luan/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2002
+# (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o
-OBJS   += flash.o
+COBJS	= $(BOARD).o flash.o
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
@@ -40,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/amcc/ocotea/Makefile b/board/amcc/ocotea/Makefile
index af223d2..4def7fd 100644
--- a/board/amcc/ocotea/Makefile
+++ b/board/amcc/ocotea/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2002
+# (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/amcc/walnut/Makefile b/board/amcc/walnut/Makefile
index f5bda55..e78ed5f 100644
--- a/board/amcc/walnut/Makefile
+++ b/board/amcc/walnut/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,9 +23,13 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/amcc/yellowstone/Makefile b/board/amcc/yellowstone/Makefile
index 47116d3..a47a067 100644
--- a/board/amcc/yellowstone/Makefile
+++ b/board/amcc/yellowstone/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2002
+# (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o
+COBJS	= $(BOARD).o
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/amcc/yosemite/Makefile b/board/amcc/yosemite/Makefile
index 47116d3..a47a067 100644
--- a/board/amcc/yosemite/Makefile
+++ b/board/amcc/yosemite/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2002
+# (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o
+COBJS	= $(BOARD).o
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/amcc/yucca/Makefile b/board/amcc/yucca/Makefile
index c85fa31..696fd40 100644
--- a/board/amcc/yucca/Makefile
+++ b/board/amcc/yucca/Makefile
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o cmd_yucca.o
+COBJS	= $(BOARD).o flash.o cmd_yucca.o
 SOBJS	= init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/amirix/ap1000/Makefile b/board/amirix/ap1000/Makefile
index 4e1ef21..08a17f9 100644
--- a/board/amirix/ap1000/Makefile
+++ b/board/amirix/ap1000/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o serial.o pci.o powerspan.o
+COBJS	= $(BOARD).o flash.o serial.o pci.o powerspan.o
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $^
 
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/armadillo/Makefile b/board/armadillo/Makefile
index 52ea7f2..80e1687 100644
--- a/board/armadillo/Makefile
+++ b/board/armadillo/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # (C) Copyright 2002
 # Sysgo Real-Time Solutions, GmbH <www.elinos.com>
 # Marius Groeger <mgroeger@sysgo.de>
@@ -24,12 +27,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= armadillo.o flash.o
+COBJS	:= armadillo.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -40,9 +47,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/assabet/Makefile b/board/assabet/Makefile
index c49f1b4..a7414e8 100644
--- a/board/assabet/Makefile
+++ b/board/assabet/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # 2004 (c) MontaVista Software, Inc.
@@ -25,12 +25,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= assabet.o
+COBJS	:= assabet.o
 SOBJS	:= setup.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -41,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/at91rm9200dk/Makefile b/board/at91rm9200dk/Makefile
index ec77da9..f087a0f 100644
--- a/board/at91rm9200dk/Makefile
+++ b/board/at91rm9200dk/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= at91rm9200dk.o at45.o flash.o
+COBJS	:= at91rm9200dk.o at45.o flash.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/atc/Makefile b/board/atc/Makefile
index 7573a0c..a041c99 100644
--- a/board/atc/Makefile
+++ b/board/atc/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ti113x.o
+COBJS	= $(BOARD).o flash.o ti113x.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/barco/Makefile b/board/barco/Makefile
index d6bbf2f..9ac6a4d 100644
--- a/board/barco/Makefile
+++ b/board/barco/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS =  $(BOARD).o flash.o
+COBJS =  $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/bc3450/Makefile b/board/bc3450/Makefile
index 4dec44f..122a22a 100644
--- a/board/bc3450/Makefile
+++ b/board/bc3450/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003-2004
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o cmd_bc3450.o
+COBJS	:= $(BOARD).o cmd_bc3450.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/bmw/Makefile b/board/bmw/Makefile
index 621640b..b775da2 100644
--- a/board/bmw/Makefile
+++ b/board/bmw/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # (C) Copyright 2002
 # James F. Dougherty, Broadcom Corporation, jfd@broadcom.com
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
@@ -24,20 +27,24 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ns16550.o serial.o m48t59y.o
+COBJS	= $(BOARD).o flash.o ns16550.o serial.o m48t59y.o
 
 SOBJS	= early_init.o
 
-$(LIB):	.depend $(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/c2mon/Makefile b/board/c2mon/Makefile
index 7b2b545..62db2f4 100644
--- a/board/c2mon/Makefile
+++ b/board/c2mon/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o pcmcia.o
+COBJS	= $(BOARD).o flash.o pcmcia.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/canmb/Makefile b/board/canmb/Makefile
index 607833f..47a3e8c 100644
--- a/board/canmb/Makefile
+++ b/board/canmb/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2005
+# (C) Copyright 2005-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,13 +22,20 @@
 #
 
 include $(TOPDIR)/config.mk
+#ifneq ($(OBJTREE),$(SRCTREE))
+#$(shell mkdir -p $(obj)../common)
+#endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o
+COBJS	:= $(BOARD).o
 #../common/flash.o ../common/vpd.o ../common/am79c874.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -39,9 +46,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/cds/mpc8541cds/Makefile b/board/cds/mpc8541cds/Makefile
index 0d4abbd..3f3a517 100644
--- a/board/cds/mpc8541cds/Makefile
+++ b/board/cds/mpc8541cds/Makefile
@@ -1,6 +1,6 @@
 #
 # Copyright 2004 Freescale Semiconductor.
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,16 +23,23 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o \
+COBJS	:= $(BOARD).o \
 	   ../common/cadmus.o \
 	   ../common/eeprom.o
 
 SOBJS	:= init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -43,9 +50,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/cds/mpc8548cds/Makefile b/board/cds/mpc8548cds/Makefile
index 0d4abbd..3f3a517 100644
--- a/board/cds/mpc8548cds/Makefile
+++ b/board/cds/mpc8548cds/Makefile
@@ -1,6 +1,6 @@
 #
 # Copyright 2004 Freescale Semiconductor.
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,16 +23,23 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o \
+COBJS	:= $(BOARD).o \
 	   ../common/cadmus.o \
 	   ../common/eeprom.o
 
 SOBJS	:= init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -43,9 +50,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/cds/mpc8555cds/Makefile b/board/cds/mpc8555cds/Makefile
index 0d4abbd..3f3a517 100644
--- a/board/cds/mpc8555cds/Makefile
+++ b/board/cds/mpc8555cds/Makefile
@@ -1,6 +1,6 @@
 #
 # Copyright 2004 Freescale Semiconductor.
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,16 +23,23 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o \
+COBJS	:= $(BOARD).o \
 	   ../common/cadmus.o \
 	   ../common/eeprom.o
 
 SOBJS	:= init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -43,9 +50,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/cerf250/Makefile b/board/cerf250/Makefile
index 83e3ba4..52712be 100644
--- a/board/cerf250/Makefile
+++ b/board/cerf250/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= cerf250.o flash.o
+COBJS	:= cerf250.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/cm4008/Makefile b/board/cm4008/Makefile
index c66dd71..fb18ad8 100644
--- a/board/cm4008/Makefile
+++ b/board/cm4008/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= cm4008.o flash.o
+COBJS	:= cm4008.o flash.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/cm41xx/Makefile b/board/cm41xx/Makefile
index f0d3451..d42e2a8 100644
--- a/board/cm41xx/Makefile
+++ b/board/cm41xx/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= cm41xx.o flash.o
+COBJS	:= cm41xx.o flash.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/cmc_pu2/Makefile b/board/cmc_pu2/Makefile
index d0def05..ccbf308 100644
--- a/board/cmc_pu2/Makefile
+++ b/board/cmc_pu2/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= cmc_pu2.o at45.o flash.o load_sernum_ethaddr.o
+COBJS	:= cmc_pu2.o at45.o flash.o load_sernum_ethaddr.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/cmi/Makefile b/board/cmi/Makefile
index 2324d87..d935044 100644
--- a/board/cmi/Makefile
+++ b/board/cmi/Makefile
@@ -1,6 +1,6 @@
 #
-# (C) Copyright 2001	Wolfgang Denk, DENX Software Engineering, wd@denx.de
-#
+# (C) Copyright 2001-2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de
 #
 # See file CREDITS for list of people who contributed to this
 # project.
@@ -23,12 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= flash.o cmi.o
-SOBJS	:=
+COBJS	:= flash.o cmi.o
 
-$(LIB):	$(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -39,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/cobra5272/Makefile b/board/cobra5272/Makefile
index e5d8446..e3d24b3 100644
--- a/board/cobra5272/Makefile
+++ b/board/cobra5272/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2003
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/cogent/Makefile b/board/cogent/Makefile
index 4084c7e..8498ace 100644
--- a/board/cogent/Makefile
+++ b/board/cogent/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= mb.o flash.o dipsw.o lcd.o serial.o # pci.o rtc.o par.o kbm.o
-SOBJS	:=
+COBJS	:= mb.o flash.o dipsw.o lcd.o serial.o # pci.o rtc.o par.o kbm.o
 
-$(LIB):	$(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -39,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/cpc45/Makefile b/board/cpc45/Makefile
index ccb811b..346833a 100644
--- a/board/cpc45/Makefile
+++ b/board/cpc45/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001-2003
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o plx9030.o pd67290.o
+COBJS	= $(BOARD).o flash.o plx9030.o pd67290.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/cpu86/Makefile b/board/cpu86/Makefile
index 7a2014d..1b57d2b 100644
--- a/board/cpu86/Makefile
+++ b/board/cpu86/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/cpu87/Makefile b/board/cpu87/Makefile
index 26f53ed..1b57d2b 100644
--- a/board/cpu87/Makefile
+++ b/board/cpu87/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001-2005
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/cradle/Makefile b/board/cradle/Makefile
index 265d500..c6a5a0d 100644
--- a/board/cradle/Makefile
+++ b/board/cradle/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= cradle.o flash.o
+COBJS	:= cradle.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/cray/L1/Makefile b/board/cray/L1/Makefile
index bfe0922..44ef9c2 100644
--- a/board/cray/L1/Makefile
+++ b/board/cray/L1/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,35 +23,41 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 SOBJS	= init.o
 
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 # HACK: depend needs bootscript.c, which needs tools/mkimage, which is not
 # built in the depend stage.  So... put bootscript.o here, not in OBJS
-$(LIB):	$(OBJS) $(SOBJS) bootscript.o
+$(LIB):	$(OBJS) $(SOBJS) $(obj)bootscript.o
 	$(AR) crv $@ $^
 
 clean:
-	rm -f $(SOBJS) $(OBJS) bootscript.c bootscript.image bootscript.o
+	rm -f $(SOBJS) $(OBJS) $(obj)bootscript.c \
+		$(obj)bootscript.image $(obj)bootscript.o
 
 distclean:	clean
 	rm -f $(LIB) core *.bak .depend
 
-$(BOARD).o : $(BOARD).c bootscript.o
+$(obj)$(BOARD).o : $(src)$(BOARD).c $(obj)bootscript.o
 
-bootscript.c: bootscript.image
+$(obj)bootscript.c: $(obj)bootscript.image
 	od -t x1 -v -A x $^ | awk -f x2c.awk > $@
 
-bootscript.image: bootscript.hush Makefile
-	-$(TOPDIR)/tools/mkimage -A ppc -O linux -T script -C none -a 0 -e 0 -n bootscript -d  bootscript.hush $@
+$(obj)bootscript.image: $(src)bootscript.hush $(src)Makefile
+	-$(OBJTREE)/tools/mkimage -A ppc -O linux -T script -C none -a 0 -e 0 -n bootscript -d $(src)bootscript.hush $@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/csb226/Makefile b/board/csb226/Makefile
index 5b311a9..34c071e 100644
--- a/board/csb226/Makefile
+++ b/board/csb226/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= csb226.o flash.o
+COBJS	:= csb226.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/csb272/Makefile b/board/csb272/Makefile
index 926e065..7acb7c8 100644
--- a/board/csb272/Makefile
+++ b/board/csb272/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,14 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-#OBJS	= $(BOARD).o flash.o
-#OBJS	= $(BOARD).o strataflash.o
-OBJS	= $(BOARD).o
+#COBJS	= $(BOARD).o flash.o
+#COBJS	= $(BOARD).o strataflash.o
+COBJS	= $(BOARD).o
 
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $^
@@ -43,9 +46,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/csb472/Makefile b/board/csb472/Makefile
index 926e065..7acb7c8 100644
--- a/board/csb472/Makefile
+++ b/board/csb472/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,14 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-#OBJS	= $(BOARD).o flash.o
-#OBJS	= $(BOARD).o strataflash.o
-OBJS	= $(BOARD).o
+#COBJS	= $(BOARD).o flash.o
+#COBJS	= $(BOARD).o strataflash.o
+COBJS	= $(BOARD).o
 
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $^
@@ -43,9 +46,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/csb637/Makefile b/board/csb637/Makefile
index 61d5a35..d766ea2 100644
--- a/board/csb637/Makefile
+++ b/board/csb637/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= csb637.o
+COBJS	:= csb637.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/cu824/Makefile b/board/cu824/Makefile
index 7a2014d..1b57d2b 100644
--- a/board/cu824/Makefile
+++ b/board/cu824/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/dave/B2/Makefile b/board/dave/B2/Makefile
index 548fd52..106025d 100644
--- a/board/dave/B2/Makefile
+++ b/board/dave/B2/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+# 
 # (C) Copyright 2002
 # Sysgo Real-Time Solutions, GmbH <www.elinos.com>
 # Marius Groeger <mgroeger@sysgo.de>
@@ -24,12 +27,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= B2.o flash.o
+COBJS	:= B2.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -40,9 +47,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/dave/PPChameleonEVB/Makefile b/board/dave/PPChameleonEVB/Makefile
index 581a580..e62981c 100644
--- a/board/dave/PPChameleonEVB/Makefile
+++ b/board/dave/PPChameleonEVB/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,9 +23,13 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o nand.o
+COBJS	= $(BOARD).o flash.o nand.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $^
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/dbau1x00/Makefile b/board/dbau1x00/Makefile
index d9b0e2d..13986b8 100644
--- a/board/dbau1x00/Makefile
+++ b/board/dbau1x00/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,19 +23,23 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 SOBJS	= lowlevel_init.o
 
-$(LIB):	.depend $(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/delta/Makefile b/board/delta/Makefile
index e744eec..514ca9b 100644
--- a/board/delta/Makefile
+++ b/board/delta/Makefile
@@ -1,6 +1,6 @@
 
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -24,12 +24,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= delta.o nand.o
+COBJS	:= delta.o nand.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -40,9 +44,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/dnp1110/Makefile b/board/dnp1110/Makefile
index eaa38bc..367d8ae 100644
--- a/board/dnp1110/Makefile
+++ b/board/dnp1110/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= dnp1110.o flash.o
+COBJS	:= dnp1110.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/eXalion/Makefile b/board/eXalion/Makefile
index cfbf465..0acb052 100644
--- a/board/eXalion/Makefile
+++ b/board/eXalion/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,19 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o
-SOBJS	=
+COBJS	= $(BOARD).o
 
-$(LIB):	.depend $(OBJS) $(SOBJS)
-	$(AR) crv $@ $(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/eltec/bab7xx/Makefile b/board/eltec/bab7xx/Makefile
index 7d8ed26..5c6b654 100644
--- a/board/eltec/bab7xx/Makefile
+++ b/board/eltec/bab7xx/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o pci.o misc.o el_srom.o dc_srom.o l2cache.o
+COBJS	= $(BOARD).o flash.o pci.o misc.o el_srom.o dc_srom.o l2cache.o
 
 SOBJS	= asm_init.o
 
-$(LIB):	.depend $(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -40,9 +44,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/eltec/elppc/Makefile b/board/eltec/elppc/Makefile
index 76b2cfe..5d186d9 100644
--- a/board/eltec/elppc/Makefile
+++ b/board/eltec/elppc/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,14 +23,18 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o pci.o misc.o mpc107_i2c.o eepro100_srom.o
+COBJS	= $(BOARD).o flash.o pci.o misc.o mpc107_i2c.o eepro100_srom.o
 
 SOBJS	= asm_init.o
 
-$(LIB):	.depend $(OBJS) $(SOBJS)
-	$(AR) crv $@  $(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -40,9 +44,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/eltec/mhpc/Makefile b/board/eltec/mhpc/Makefile
index 13ce9fc..e3d24b3 100644
--- a/board/eltec/mhpc/Makefile
+++ b/board/eltec/mhpc/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/emk/top5200/Makefile b/board/emk/top5200/Makefile
index 986608b..307ef4a 100644
--- a/board/emk/top5200/Makefile
+++ b/board/emk/top5200/Makefile
@@ -1,6 +1,6 @@
 
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,19 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o ../common/flash.o ../common/vpd.o ../common/am79c874.o
+COBJS	:= $(BOARD).o ../common/flash.o ../common/vpd.o ../common/am79c874.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -39,9 +46,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/emk/top860/Makefile b/board/emk/top860/Makefile
index a74dd2f..bd923af 100644
--- a/board/emk/top860/Makefile
+++ b/board/emk/top860/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,19 +22,26 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o ../common/flash.o ../common/vpd.o ../common/am79c874.o
+COBJS	= $(BOARD).o ../common/flash.o ../common/vpd.o ../common/am79c874.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/ep7312/Makefile b/board/ep7312/Makefile
index c53a3c7..c8c834f 100644
--- a/board/ep7312/Makefile
+++ b/board/ep7312/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # (C) Copyright 2002
 # Sysgo Real-Time Solutions, GmbH <www.elinos.com>
 # Marius Groeger <mgroeger@sysgo.de>
@@ -24,12 +27,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= ep7312.o flash.o
+COBJS	:= ep7312.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -40,9 +47,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/ep8248/Makefile b/board/ep8248/Makefile
index 8b10993..e880f87 100644
--- a/board/ep8248/Makefile
+++ b/board/ep8248/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o
+COBJS	:= $(BOARD).o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/ep8260/Makefile b/board/ep8260/Makefile
index 477e5ee..8744359 100644
--- a/board/ep8260/Makefile
+++ b/board/ep8260/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2002
+# (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o mii_phy.o
+COBJS	= $(BOARD).o flash.o mii_phy.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/ep88x/Makefile b/board/ep88x/Makefile
index 9123a80..d0223b5 100644
--- a/board/ep88x/Makefile
+++ b/board/ep88x/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # Copyright (C) 2004 Arabella Software Ltd.
 # Yuli Barcohen <yuli@arabellasw.com>
 #
@@ -23,11 +26,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o
+COBJS	:= $(BOARD).o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/eric/Makefile b/board/eric/Makefile
index f55e7e2..fff25ab 100644
--- a/board/eric/Makefile
+++ b/board/eric/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/adciop/Makefile b/board/esd/adciop/Makefile
index 67cf29b..699a848 100644
--- a/board/esd/adciop/Makefile
+++ b/board/esd/adciop/Makefile
@@ -1,6 +1,6 @@
 
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,10 +23,17 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ../common/misc.o ../common/pci.o
+COBJS	= $(BOARD).o flash.o ../common/misc.o ../common/pci.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
@@ -39,9 +46,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/apc405/Makefile b/board/esd/apc405/Makefile
index 8529ec7..a5060d2 100644
--- a/board/esd/apc405/Makefile
+++ b/board/esd/apc405/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,10 +22,17 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o strataflash.o ../common/misc.o
+COBJS	= $(BOARD).o strataflash.o ../common/misc.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $^
@@ -38,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/ar405/Makefile b/board/esd/ar405/Makefile
index a60495a..dec52af 100644
--- a/board/esd/ar405/Makefile
+++ b/board/esd/ar405/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,10 +22,17 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ../common/misc.o
+COBJS	= $(BOARD).o flash.o ../common/misc.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -38,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/ash405/Makefile b/board/esd/ash405/Makefile
index a60495a..dec52af 100644
--- a/board/esd/ash405/Makefile
+++ b/board/esd/ash405/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,10 +22,17 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ../common/misc.o
+COBJS	= $(BOARD).o flash.o ../common/misc.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -38,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/canbt/Makefile b/board/esd/canbt/Makefile
index a60495a..dec52af 100644
--- a/board/esd/canbt/Makefile
+++ b/board/esd/canbt/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,10 +22,17 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ../common/misc.o
+COBJS	= $(BOARD).o flash.o ../common/misc.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -38,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/cms700/Makefile b/board/esd/cms700/Makefile
index a11ee82..ab9d832 100644
--- a/board/esd/cms700/Makefile
+++ b/board/esd/cms700/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,15 +22,22 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common/xilinx_jtag)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
 # Objects for Xilinx JTAG programming (CPLD)
 CPLD    = ../common/xilinx_jtag/lenval.o \
 	  ../common/xilinx_jtag/micro.o \
 	  ../common/xilinx_jtag/ports.o
 
-OBJS	= $(BOARD).o flash.o ../common/misc.o $(CPLD)
+COBJS	= $(BOARD).o flash.o ../common/misc.o $(CPLD)
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -43,9 +50,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/cpci2dp/Makefile b/board/esd/cpci2dp/Makefile
index 88b0ae3..72c2562 100644
--- a/board/esd/cpci2dp/Makefile
+++ b/board/esd/cpci2dp/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,10 +22,17 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ../common/misc.o ../common/cmd_loadpci.o
+COBJS	= $(BOARD).o flash.o ../common/misc.o ../common/cmd_loadpci.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -38,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/cpci405/Makefile b/board/esd/cpci405/Makefile
index 9340a32..8f254dd 100644
--- a/board/esd/cpci405/Makefile
+++ b/board/esd/cpci405/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,10 +22,17 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ../common/misc.o ../common/auto_update.o
+COBJS	= $(BOARD).o flash.o ../common/misc.o ../common/auto_update.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -38,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/cpci440/Makefile b/board/esd/cpci440/Makefile
index 84d44fb..b4c74fc 100644
--- a/board/esd/cpci440/Makefile
+++ b/board/esd/cpci440/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2002
+# (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,12 +22,19 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o strataflash.o ../common/misc.o
+COBJS	= $(BOARD).o strataflash.o ../common/misc.o
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
@@ -39,9 +46,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/cpci5200/Makefile b/board/esd/cpci5200/Makefile
index 2ca73a9..78ffa0f 100644
--- a/board/esd/cpci5200/Makefile
+++ b/board/esd/cpci5200/Makefile
@@ -1,6 +1,5 @@
-
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +22,25 @@
 #
 
 include $(TOPDIR)/config.mk
+# ifneq ($(OBJTREE),$(SRCTREE))
+# $(shell mkdir -p $(obj)../common/xilinx_jtag)
+# endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
 # Objects for Xilinx JTAG programming (CPLD)
 # CPLD  = ../common/xilinx_jtag/lenval.o \
 # 	  ../common/xilinx_jtag/micro.o \
 # 	  ../common/xilinx_jtag/ports.o
 
-# OBJS	= $(BOARD).o flash.o $(CPLD)
-OBJS	= $(BOARD).o strataflash.o
+# COBJS	= $(BOARD).o flash.o $(CPLD)
+COBJS	= $(BOARD).o strataflash.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -45,9 +51,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/cpci5200/config.mk b/board/esd/cpci5200/config.mk
index 07b5de1..170779d 100644
--- a/board/esd/cpci5200/config.mk
+++ b/board/esd/cpci5200/config.mk
@@ -32,7 +32,7 @@
 #	0x00100000   boot from RAM (for testing only)
 #
 
-sinclude $(TOPDIR)/board/$(BOARDDIR)/config.tmp
+sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp
 
 ifndef TEXT_BASE
 ## Standard: boot high
diff --git a/board/esd/cpci750/Makefile b/board/esd/cpci750/Makefile
index cd38b2d..0dfec60 100644
--- a/board/esd/cpci750/Makefile
+++ b/board/esd/cpci750/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+# 
 # (C) Copyright 2001
 # Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
 #
@@ -22,23 +25,30 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../../Marvell/common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
 SOBJS	= misc.o
 
-OBJS	= $(BOARD).o serial.o ../../Marvell/common/memory.o pci.o \
+COBJS	= $(BOARD).o serial.o ../../Marvell/common/memory.o pci.o \
 	  mv_eth.o  mpsc.o i2c.o \
 	  sdram_init.o ide.o
 
-$(LIB):	.depend $(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/cpciiser4/Makefile b/board/esd/cpciiser4/Makefile
index a60495a..dec52af 100644
--- a/board/esd/cpciiser4/Makefile
+++ b/board/esd/cpciiser4/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,10 +22,17 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ../common/misc.o
+COBJS	= $(BOARD).o flash.o ../common/misc.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -38,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/dasa_sim/Makefile b/board/esd/dasa_sim/Makefile
index e3b1c87..c74d1ab 100644
--- a/board/esd/dasa_sim/Makefile
+++ b/board/esd/dasa_sim/Makefile
@@ -1,6 +1,6 @@
 
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,10 +23,17 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o cmd_dasa_sim.o eeprom.o ../common/pci.o
+COBJS	= $(BOARD).o flash.o cmd_dasa_sim.o eeprom.o ../common/pci.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
@@ -39,9 +46,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/dp405/Makefile b/board/esd/dp405/Makefile
index a11ee82..ab9d832 100644
--- a/board/esd/dp405/Makefile
+++ b/board/esd/dp405/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,15 +22,22 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common/xilinx_jtag)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
 # Objects for Xilinx JTAG programming (CPLD)
 CPLD    = ../common/xilinx_jtag/lenval.o \
 	  ../common/xilinx_jtag/micro.o \
 	  ../common/xilinx_jtag/ports.o
 
-OBJS	= $(BOARD).o flash.o ../common/misc.o $(CPLD)
+COBJS	= $(BOARD).o flash.o ../common/misc.o $(CPLD)
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -43,9 +50,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/du405/Makefile b/board/esd/du405/Makefile
index 5ec4a4f..dec52af 100644
--- a/board/esd/du405/Makefile
+++ b/board/esd/du405/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,10 +22,17 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ../common/misc.o
+COBJS	= $(BOARD).o flash.o ../common/misc.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -38,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/hh405/Makefile b/board/esd/hh405/Makefile
index 9340a32..8f254dd 100644
--- a/board/esd/hh405/Makefile
+++ b/board/esd/hh405/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,10 +22,17 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ../common/misc.o ../common/auto_update.o
+COBJS	= $(BOARD).o flash.o ../common/misc.o ../common/auto_update.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -38,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/hub405/Makefile b/board/esd/hub405/Makefile
index a60495a..dec52af 100644
--- a/board/esd/hub405/Makefile
+++ b/board/esd/hub405/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,10 +22,17 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ../common/misc.o
+COBJS	= $(BOARD).o flash.o ../common/misc.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -38,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/ocrtc/Makefile b/board/esd/ocrtc/Makefile
index b3039c6..1da3f7e 100644
--- a/board/esd/ocrtc/Makefile
+++ b/board/esd/ocrtc/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,10 +22,17 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ../common/misc.o cmd_ocrtc.o
+COBJS	= $(BOARD).o flash.o ../common/misc.o cmd_ocrtc.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -38,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/pci405/Makefile b/board/esd/pci405/Makefile
index 6db564f..9ae728d 100644
--- a/board/esd/pci405/Makefile
+++ b/board/esd/pci405/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,12 +22,19 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ../common/misc.o cmd_pci405.o
+COBJS	= $(BOARD).o flash.o ../common/misc.o cmd_pci405.o
 SOBJS	= writeibm.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 $(LIB):	$(OBJS) $(SOBJS)
 #	$(AR) crv $@ $(OBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
@@ -40,9 +47,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/pf5200/Makefile b/board/esd/pf5200/Makefile
index 603bbe2..82358af 100644
--- a/board/esd/pf5200/Makefile
+++ b/board/esd/pf5200/Makefile
@@ -1,6 +1,6 @@
 
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,25 @@
 #
 
 include $(TOPDIR)/config.mk
+# ifneq ($(OBJTREE),$(SRCTREE))
+# $(shell mkdir -p $(obj)../common/xilinx_jtag)
+# endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
 # Objects for Xilinx JTAG programming (CPLD)
 # CPLD  = ../common/xilinx_jtag/lenval.o \
 # 	  ../common/xilinx_jtag/micro.o \
 # 	  ../common/xilinx_jtag/ports.o
 
-# OBJS	= $(BOARD).o flash.o $(CPLD)
-OBJS	= $(BOARD).o flash.o
+# COBJS	= $(BOARD).o flash.o $(CPLD)
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -45,9 +52,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/pf5200/config.mk b/board/esd/pf5200/config.mk
index 07b5de1..170779d 100644
--- a/board/esd/pf5200/config.mk
+++ b/board/esd/pf5200/config.mk
@@ -32,7 +32,7 @@
 #	0x00100000   boot from RAM (for testing only)
 #
 
-sinclude $(TOPDIR)/board/$(BOARDDIR)/config.tmp
+sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp
 
 ifndef TEXT_BASE
 ## Standard: boot high
diff --git a/board/esd/plu405/Makefile b/board/esd/plu405/Makefile
index 9340a32..8f254dd 100644
--- a/board/esd/plu405/Makefile
+++ b/board/esd/plu405/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,10 +22,17 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ../common/misc.o ../common/auto_update.o
+COBJS	= $(BOARD).o flash.o ../common/misc.o ../common/auto_update.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -38,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/pmc405/Makefile b/board/esd/pmc405/Makefile
index 741e4aa..2775b8a 100644
--- a/board/esd/pmc405/Makefile
+++ b/board/esd/pmc405/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,15 +22,22 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common/xilinx_jtag)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
 # Objects for Xilinx JTAG programming (CPLD)
 CPLD    = ../common/xilinx_jtag/lenval.o \
 	  ../common/xilinx_jtag/micro.o \
 	  ../common/xilinx_jtag/ports.o
 
-OBJS	= $(BOARD).o ../common/misc.o ../common/cmd_loadpci.o $(CPLD)
+COBJS	= $(BOARD).o ../common/misc.o ../common/cmd_loadpci.o $(CPLD)
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -43,9 +50,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/tasreg/Makefile b/board/esd/tasreg/Makefile
index e5d8446..e3d24b3 100644
--- a/board/esd/tasreg/Makefile
+++ b/board/esd/tasreg/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2003
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/voh405/Makefile b/board/esd/voh405/Makefile
index a60495a..dec52af 100644
--- a/board/esd/voh405/Makefile
+++ b/board/esd/voh405/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,10 +22,17 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ../common/misc.o
+COBJS	= $(BOARD).o flash.o ../common/misc.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -38,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/vom405/Makefile b/board/esd/vom405/Makefile
index a11ee82..ab9d832 100644
--- a/board/esd/vom405/Makefile
+++ b/board/esd/vom405/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,15 +22,22 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common/xilinx_jtag)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
 # Objects for Xilinx JTAG programming (CPLD)
 CPLD    = ../common/xilinx_jtag/lenval.o \
 	  ../common/xilinx_jtag/micro.o \
 	  ../common/xilinx_jtag/ports.o
 
-OBJS	= $(BOARD).o flash.o ../common/misc.o $(CPLD)
+COBJS	= $(BOARD).o flash.o ../common/misc.o $(CPLD)
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -43,9 +50,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esd/wuh405/Makefile b/board/esd/wuh405/Makefile
index a60495a..dec52af 100644
--- a/board/esd/wuh405/Makefile
+++ b/board/esd/wuh405/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,10 +22,17 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ../common/misc.o
+COBJS	= $(BOARD).o flash.o ../common/misc.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -38,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/esteem192e/Makefile b/board/esteem192e/Makefile
index 13ce9fc..e3d24b3 100644
--- a/board/esteem192e/Makefile
+++ b/board/esteem192e/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/etin/debris/Makefile b/board/etin/debris/Makefile
index 305a1bf..17ef23d 100644
--- a/board/etin/debris/Makefile
+++ b/board/etin/debris/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS =  $(BOARD).o flash.o phantom.o
+COBJS =  $(BOARD).o flash.o phantom.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/etin/kvme080/Makefile b/board/etin/kvme080/Makefile
index 303ccfa..04ecf46 100644
--- a/board/etin/kvme080/Makefile
+++ b/board/etin/kvme080/Makefile
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS =  $(BOARD).o multiverse.o
+COBJS	= $(BOARD).o multiverse.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/etx094/Makefile b/board/etx094/Makefile
index 13ce9fc..e3d24b3 100644
--- a/board/etx094/Makefile
+++ b/board/etx094/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/evb4510/Makefile b/board/evb4510/Makefile
index 10850a9..c634f72 100644
--- a/board/evb4510/Makefile
+++ b/board/evb4510/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= evb4510.o flash.o
+COBJS	:= evb4510.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/evb64260/Makefile b/board/evb64260/Makefile
index c493d6c..b28372d 100644
--- a/board/evb64260/Makefile
+++ b/board/evb64260/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+# 
 # (C) Copyright 2001
 # Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
 #
@@ -23,22 +26,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
 SOBJS	= misc.o
-OBJS	= $(BOARD).o flash.o serial.o memory.o pci.o \
+COBJS	= $(BOARD).o flash.o serial.o memory.o pci.o \
 	  eth.o eth_addrtbl.o mpsc.o i2c.o \
 	  sdram_init.o zuma_pbb.o intel_flash.o zuma_pbb_mbox.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
-$(LIB):	.depend $(OBJS) $(SOBJS)
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/exbitgen/Makefile b/board/exbitgen/Makefile
index 34bd4b2..7a39592 100644
--- a/board/exbitgen/Makefile
+++ b/board/exbitgen/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $^
@@ -41,9 +44,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/ezkit533/Makefile b/board/ezkit533/Makefile
index c9b3c92..70feb4a 100644
--- a/board/ezkit533/Makefile
+++ b/board/ezkit533/Makefile
@@ -3,7 +3,7 @@
 #
 # Copyright (c) 2005 blackfin.uclinux.org
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -27,18 +27,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ezkit533.o
+COBJS	= $(BOARD).o flash.o ezkit533.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/fads/Makefile b/board/fads/Makefile
index 7fc88ee..c0c1722 100644
--- a/board/fads/Makefile
+++ b/board/fads/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o lamp.o pcmcia.o
+COBJS	= $(BOARD).o flash.o lamp.o pcmcia.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/flagadm/Makefile b/board/flagadm/Makefile
index 7a2014d..1b57d2b 100644
--- a/board/flagadm/Makefile
+++ b/board/flagadm/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/funkwerk/vovpn-gw/Makefile b/board/funkwerk/vovpn-gw/Makefile
index f77cc60..b2d1e35 100644
--- a/board/funkwerk/vovpn-gw/Makefile
+++ b/board/funkwerk/vovpn-gw/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o flash.o m88e6060.o
+COBJS	:= $(BOARD).o flash.o m88e6060.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/g2000/Makefile b/board/g2000/Makefile
index 5471d13..9b9f033 100644
--- a/board/g2000/Makefile
+++ b/board/g2000/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,9 +23,13 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o strataflash.o
+COBJS	= $(BOARD).o strataflash.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/gcplus/Makefile b/board/gcplus/Makefile
index 1954d66..695cd93 100644
--- a/board/gcplus/Makefile
+++ b/board/gcplus/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # 2003 (c) MontaVista Software, Inc.
@@ -25,12 +25,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= gcplus.o flash.o
+COBJS	:= gcplus.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -41,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/gen860t/Makefile b/board/gen860t/Makefile
index dd7ecf1..9d36711 100644
--- a/board/gen860t/Makefile
+++ b/board/gen860t/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o beeper.o fpga.o ioport.o
+COBJS	= $(BOARD).o flash.o beeper.o fpga.o ioport.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/genietv/Makefile b/board/genietv/Makefile
index 13ce9fc..e3d24b3 100644
--- a/board/genietv/Makefile
+++ b/board/genietv/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/gth/Makefile b/board/gth/Makefile
index 48f74cd..95bf072 100644
--- a/board/gth/Makefile
+++ b/board/gth/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ee_access.o pcmcia.o
+COBJS	= $(BOARD).o flash.o ee_access.o pcmcia.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/gth2/Makefile b/board/gth2/Makefile
index 8ef3a51..ed6a4a0 100644
--- a/board/gth2/Makefile
+++ b/board/gth2/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2005
+# (C) Copyright 2005-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,19 +23,23 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ee_access.o
+COBJS	= $(BOARD).o flash.o ee_access.o
 SOBJS	= lowlevel_init.o
 
-$(LIB):	.depend $(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/gw8260/Makefile b/board/gw8260/Makefile
index 827a6ac..bf5c508 100644
--- a/board/gw8260/Makefile
+++ b/board/gw8260/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= gw8260.o flash.o
+COBJS	:= gw8260.o flash.o
 SOBJS   :=
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/hermes/Makefile b/board/hermes/Makefile
index 13ce9fc..e3d24b3 100644
--- a/board/hermes/Makefile
+++ b/board/hermes/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/hidden_dragon/Makefile b/board/hidden_dragon/Makefile
index b9f1df6..9ac6a4d 100644
--- a/board/hidden_dragon/Makefile
+++ b/board/hidden_dragon/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2005
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS =  $(BOARD).o flash.o
+COBJS =  $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/hmi1001/Makefile b/board/hmi1001/Makefile
index ed36ea7..4b2bbe2 100644
--- a/board/hmi1001/Makefile
+++ b/board/hmi1001/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003-2004
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o
+COBJS	:= $(BOARD).o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/hymod/Makefile b/board/hymod/Makefile
index b52af9a..ff9fa90 100644
--- a/board/hymod/Makefile
+++ b/board/hymod/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o bsp.o eeprom.o fetch.o input.o env.o
+COBJS	= $(BOARD).o flash.o bsp.o eeprom.o fetch.o input.o env.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/icecube/Makefile b/board/icecube/Makefile
index eb5ed59..8e61c79 100644
--- a/board/icecube/Makefile
+++ b/board/icecube/Makefile
@@ -1,6 +1,6 @@
 
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -24,11 +24,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o flash.o
+COBJS	:= $(BOARD).o flash.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/icecube/config.mk b/board/icecube/config.mk
index 07b5de1..170779d 100644
--- a/board/icecube/config.mk
+++ b/board/icecube/config.mk
@@ -32,7 +32,7 @@
 #	0x00100000   boot from RAM (for testing only)
 #
 
-sinclude $(TOPDIR)/board/$(BOARDDIR)/config.tmp
+sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp
 
 ifndef TEXT_BASE
 ## Standard: boot high
diff --git a/board/icu862/Makefile b/board/icu862/Makefile
index 7b2b545..62db2f4 100644
--- a/board/icu862/Makefile
+++ b/board/icu862/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o pcmcia.o
+COBJS	= $(BOARD).o flash.o pcmcia.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/ids8247/Makefile b/board/ids8247/Makefile
index cfef750..d423793 100644
--- a/board/ids8247/Makefile
+++ b/board/ids8247/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # (C) Copyright 2005
 # Heiko Schocher, DENX Software Engineering, <hs@denx.de>
 #
@@ -23,18 +26,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/impa7/Makefile b/board/impa7/Makefile
index 08543f9..d77db72 100644
--- a/board/impa7/Makefile
+++ b/board/impa7/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= impa7.o flash.o
+COBJS	:= impa7.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/incaip/Makefile b/board/incaip/Makefile
index d9b0e2d..13986b8 100644
--- a/board/incaip/Makefile
+++ b/board/incaip/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,19 +23,23 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 SOBJS	= lowlevel_init.o
 
-$(LIB):	.depend $(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/inka4x0/Makefile b/board/inka4x0/Makefile
index bf83292..d00e05d 100644
--- a/board/inka4x0/Makefile
+++ b/board/inka4x0/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003-2004
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o flash.o
+COBJS	:= $(BOARD).o flash.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/innokom/Makefile b/board/innokom/Makefile
index 73f6a74..f4cc6cf 100644
--- a/board/innokom/Makefile
+++ b/board/innokom/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= innokom.o flash.o
+COBJS	:= innokom.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/integratorap/Makefile b/board/integratorap/Makefile
index 358df62..5b3729b 100644
--- a/board/integratorap/Makefile
+++ b/board/integratorap/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # (C) Copyright 2004
@@ -27,13 +27,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= integratorap.o flash.o
+COBJS	:= integratorap.o flash.o
 SOBJS	:= lowlevel_init.o memsetup.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -43,9 +47,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/integratorap/config.mk b/board/integratorap/config.mk
index 25b79b3..e4c5c3b 100644
--- a/board/integratorap/config.mk
+++ b/board/integratorap/config.mk
@@ -3,3 +3,9 @@
 #
 
 TEXT_BASE = 0x01000000
+
+ifneq ($(OBJTREE),$(SRCTREE))
+# We are building u-boot in a separate directory, use generated
+# .lds script from OBJTREE directory.
+LDSCRIPT := $(OBJTREE)/board/$(BOARDDIR)/u-boot.lds
+endif
diff --git a/board/integratorap/split_by_variant.sh b/board/integratorap/split_by_variant.sh
index 9f71bab..53b0d1e 100755
--- a/board/integratorap/split_by_variant.sh
+++ b/board/integratorap/split_by_variant.sh
@@ -103,14 +103,17 @@
 	echo -n	"#undef CONFIG_CM_TCRAM	" 		>> tmp.fil
 	echo	" /* CM may not have TCRAM */" 		>> tmp.fil
 fi
-mv tmp.fil ./include/config.h
+
+mkdir -p ${obj}include
+mkdir -p ${obj}board/integratorap
+mv tmp.fil ${obj}include/config.h
 # ---------------------------------------------------------
 #	Ensure correct core object loaded first in U-Boot image
 # ---------------------------------------------------------
-sed -r 's/CPU_FILE/cpu\/'$cpu'\/start.o/; s/#.*//' board/integratorap/u-boot.lds.template > board/integratorap/u-boot.lds
+sed -r 's/CPU_FILE/cpu\/'$cpu'\/start.o/; s/#.*//' ${src}board/integratorap/u-boot.lds.template > ${obj}board/integratorap/u-boot.lds
 # ---------------------------------------------------------
 # Complete the configuration
 # ---------------------------------------------------------
-./mkconfig -a integratorap arm $cpu integratorap;
+$MKCONFIG -a integratorap arm $cpu integratorap;
 echo "Variant:: $variant with core $cpu"
 
diff --git a/board/integratorcp/Makefile b/board/integratorcp/Makefile
index 3d589fc..efafeb6 100644
--- a/board/integratorcp/Makefile
+++ b/board/integratorcp/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= integratorcp.o flash.o
+COBJS	:= integratorcp.o flash.o
 SOBJS	:= lowlevel_init.o memsetup.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/integratorcp/config.mk b/board/integratorcp/config.mk
index 25b79b3..e4c5c3b 100644
--- a/board/integratorcp/config.mk
+++ b/board/integratorcp/config.mk
@@ -3,3 +3,9 @@
 #
 
 TEXT_BASE = 0x01000000
+
+ifneq ($(OBJTREE),$(SRCTREE))
+# We are building u-boot in a separate directory, use generated
+# .lds script from OBJTREE directory.
+LDSCRIPT := $(OBJTREE)/board/$(BOARDDIR)/u-boot.lds
+endif
diff --git a/board/integratorcp/split_by_variant.sh b/board/integratorcp/split_by_variant.sh
index 3a35433..37ae517 100755
--- a/board/integratorcp/split_by_variant.sh
+++ b/board/integratorcp/split_by_variant.sh
@@ -98,14 +98,17 @@
 	echo -n "#undef CONFIG_CM_TCRAM  " 		>> tmp.fil
 	echo    " /* CM may not have TCRAM */" 		>> tmp.fil
 fi
-mv tmp.fil ./include/config.h
+
+mkdir -p ${obj}include
+mkdir -p ${obj}board/integratorcp
+mv tmp.fil ${obj}include/config.h
 # ---------------------------------------------------------
 #  Ensure correct core object loaded first in U-Boot image
 # ---------------------------------------------------------
-sed -r 's/CPU_FILE/cpu\/'$cpu'\/start.o/; s/#.*//' board/integratorcp/u-boot.lds.template > board/integratorcp/u-boot.lds
+sed -r 's/CPU_FILE/cpu\/'$cpu'\/start.o/; s/#.*//' ${src}board/integratorcp/u-boot.lds.template > ${obj}board/integratorcp/u-boot.lds
 # ---------------------------------------------------------
 # Complete the configuration
 # ---------------------------------------------------------
-./mkconfig -a integratorcp arm $cpu integratorcp;
+$MKCONFIG -a integratorcp arm $cpu integratorcp;
 echo "Variant:: $variant with core $cpu"
 
diff --git a/board/ip860/Makefile b/board/ip860/Makefile
index 13ce9fc..e3d24b3 100644
--- a/board/ip860/Makefile
+++ b/board/ip860/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/iphase4539/Makefile b/board/iphase4539/Makefile
index 19da5d0..efdb1c1 100644
--- a/board/iphase4539/Makefile
+++ b/board/iphase4539/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # (C) Copyright 2002 Wolfgang Grandegger <wg@denx.de>
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,11 +25,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o flash.o
+COBJS	:= $(BOARD).o flash.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -37,9 +44,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/ispan/Makefile b/board/ispan/Makefile
index 9123a80..0c1cb02 100644
--- a/board/ispan/Makefile
+++ b/board/ispan/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+# 
 # Copyright (C) 2004 Arabella Software Ltd.
 # Yuli Barcohen <yuli@arabellasw.com>
 #
@@ -23,11 +26,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o
+COBJS	:= $(BOARD).o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/ivm/Makefile b/board/ivm/Makefile
index 13ce9fc..e3d24b3 100644
--- a/board/ivm/Makefile
+++ b/board/ivm/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/ixdp425/Makefile b/board/ixdp425/Makefile
index 59d6964..9568cb5 100644
--- a/board/ixdp425/Makefile
+++ b/board/ixdp425/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= ixdp425.o
+COBJS	:= ixdp425.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/ixdp425/config.mk b/board/ixdp425/config.mk
index 3420586..d49c0e7 100644
--- a/board/ixdp425/config.mk
+++ b/board/ixdp425/config.mk
@@ -1,4 +1,4 @@
 TEXT_BASE = 0x00f80000
 
 # include NPE ethernet driver
-BOARDLIBS = cpu/ixp/npe/libnpe.a
+BOARDLIBS = $(obj)cpu/ixp/npe/libnpe.a
diff --git a/board/jse/Makefile b/board/jse/Makefile
index 0da27b6..be6bd31 100644
--- a/board/jse/Makefile
+++ b/board/jse/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+# 
 # Copyright 2004 Picture Elements, Inc.
 # Stephen Williams <steve@icarus.com>
 #
@@ -20,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o sdram.o flash.o host_bridge.o
+COBJS	= $(BOARD).o sdram.o flash.o host_bridge.o
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
@@ -36,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/kb9202/Makefile b/board/kb9202/Makefile
index f36d88d..2adcb58 100644
--- a/board/kb9202/Makefile
+++ b/board/kb9202/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -26,12 +26,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= kb9202.o
+COBJS	:= kb9202.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -41,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/kup/Makefile b/board/kup/Makefile
index 071f0d2..eac75a3 100644
--- a/board/kup/Makefile
+++ b/board/kup/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o kup.o
+COBJS	= $(BOARD).o flash.o kup.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/kup/kup4k/Makefile b/board/kup/kup4k/Makefile
index 4a3954c..409e4cd 100644
--- a/board/kup/kup4k/Makefile
+++ b/board/kup/kup4k/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,19 +22,26 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o ../common/flash.o ../common/kup.o ../common/load_sernum_ethaddr.o ../common/pcmcia.o
+COBJS	= $(BOARD).o ../common/flash.o ../common/kup.o ../common/load_sernum_ethaddr.o ../common/pcmcia.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/kup/kup4x/Makefile b/board/kup/kup4x/Makefile
index 4a3954c..409e4cd 100644
--- a/board/kup/kup4x/Makefile
+++ b/board/kup/kup4x/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,19 +22,26 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o ../common/flash.o ../common/kup.o ../common/load_sernum_ethaddr.o ../common/pcmcia.o
+COBJS	= $(BOARD).o ../common/flash.o ../common/kup.o ../common/load_sernum_ethaddr.o ../common/pcmcia.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/lantec/Makefile b/board/lantec/Makefile
index 7a2014d..1b57d2b 100644
--- a/board/lantec/Makefile
+++ b/board/lantec/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/lart/Makefile b/board/lart/Makefile
index 550aa1d..7024c2b 100644
--- a/board/lart/Makefile
+++ b/board/lart/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= lart.o flash.o
+COBJS	:= lart.o flash.o
 SOBJS	:= flashasm.o lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/logodl/Makefile b/board/logodl/Makefile
index c7cde7d..fff3a51 100644
--- a/board/logodl/Makefile
+++ b/board/logodl/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= logodl.o flash.o
+COBJS	:= logodl.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/lpd7a40x/Makefile b/board/lpd7a40x/Makefile
index ebe14df..692f2d5 100644
--- a/board/lpd7a40x/Makefile
+++ b/board/lpd7a40x/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= lpd7a40x.o flash.o
+COBJS	:= lpd7a40x.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/lubbock/Makefile b/board/lubbock/Makefile
index 106622c..f562642 100644
--- a/board/lubbock/Makefile
+++ b/board/lubbock/Makefile
@@ -1,6 +1,6 @@
 
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -24,12 +24,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= lubbock.o flash.o
+COBJS	:= lubbock.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -40,9 +44,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/lwmon/Makefile b/board/lwmon/Makefile
index 7b2b545..62db2f4 100644
--- a/board/lwmon/Makefile
+++ b/board/lwmon/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o pcmcia.o
+COBJS	= $(BOARD).o flash.o pcmcia.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/m5271evb/Makefile b/board/m5271evb/Makefile
index 34de983..2951b96 100644
--- a/board/m5271evb/Makefile
+++ b/board/m5271evb/Makefile
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o
+COBJS	= $(BOARD).o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/m5272c3/Makefile b/board/m5272c3/Makefile
index e5d8446..e3d24b3 100644
--- a/board/m5272c3/Makefile
+++ b/board/m5272c3/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2003
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/m5282evb/Makefile b/board/m5282evb/Makefile
index e5d8446..e3d24b3 100644
--- a/board/m5282evb/Makefile
+++ b/board/m5282evb/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2003
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/mbx8xx/Makefile b/board/mbx8xx/Makefile
index e4d1099..feadf24 100644
--- a/board/mbx8xx/Makefile
+++ b/board/mbx8xx/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o vpd.o pcmcia.o
+COBJS	= $(BOARD).o flash.o vpd.o pcmcia.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/mcc200/Makefile b/board/mcc200/Makefile
index 7fdc088..4b2bbe2 100644
--- a/board/mcc200/Makefile
+++ b/board/mcc200/Makefile
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o
+COBJS	:= $(BOARD).o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/mcc200/config.mk b/board/mcc200/config.mk
index 1922723..d0f9289 100644
--- a/board/mcc200/config.mk
+++ b/board/mcc200/config.mk
@@ -31,7 +31,7 @@
 #	0x00100000   boot from RAM (for testing only)
 #
 
-sinclude $(TOPDIR)/board/$(BOARDDIR)/config.tmp
+sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp
 
 ifndef TEXT_BASE
 ## Standard: boot low
diff --git a/board/ml2/Makefile b/board/ml2/Makefile
index 40c60b1..ce5ba19 100644
--- a/board/ml2/Makefile
+++ b/board/ml2/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o serial.o
+COBJS	= $(BOARD).o flash.o serial.o
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/modnet50/Makefile b/board/modnet50/Makefile
index ab2c376..ae4de57 100644
--- a/board/modnet50/Makefile
+++ b/board/modnet50/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= modnet50.o flash.o
+COBJS	:= modnet50.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/mousse/Makefile b/board/mousse/Makefile
index ddc5546..490ac3b 100644
--- a/board/mousse/Makefile
+++ b/board/mousse/Makefile
@@ -1,6 +1,6 @@
 
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -24,18 +24,21 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o m48t59y.o pci.o flash.o
+COBJS	= $(BOARD).o m48t59y.o pci.o flash.o
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
-$(LIB):	.depend $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/mp2usb/Makefile b/board/mp2usb/Makefile
index b6ea3cf..c1e7ffd 100644
--- a/board/mp2usb/Makefile
+++ b/board/mp2usb/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= mp2usb.o flash.o
+COBJS	:= mp2usb.o flash.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/mpc8260ads/Makefile b/board/mpc8260ads/Makefile
index cc519d1..e1e0a0f 100644
--- a/board/mpc8260ads/Makefile
+++ b/board/mpc8260ads/Makefile
@@ -1,6 +1,6 @@
 
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -24,11 +24,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o flash.o
+COBJS	:= $(BOARD).o flash.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/mpc8260ads/config.mk b/board/mpc8260ads/config.mk
index eb6f7c9..e99e181 100644
--- a/board/mpc8260ads/config.mk
+++ b/board/mpc8260ads/config.mk
@@ -29,7 +29,7 @@
 # MPC8260ADS, MPC8266ADS, and PQ2FADS-ZU/VR boards
 #
 
-sinclude $(TOPDIR)/board/$(BOARDDIR)/config.tmp
+sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp
 
 ifndef TEXT_BASE
 ## Standard: boot high
diff --git a/board/mpc8266ads/Makefile b/board/mpc8266ads/Makefile
index cd0f40b..157c969 100644
--- a/board/mpc8266ads/Makefile
+++ b/board/mpc8266ads/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o flash.o
+COBJS	:= $(BOARD).o flash.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/mpc8349emds/Makefile b/board/mpc8349emds/Makefile
index 38bbb67..e699086 100644
--- a/board/mpc8349emds/Makefile
+++ b/board/mpc8349emds/Makefile
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o
+COBJS	:= $(BOARD).o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/mpc8540ads/Makefile b/board/mpc8540ads/Makefile
index 5d8ea34..3f1e8f2 100644
--- a/board/mpc8540ads/Makefile
+++ b/board/mpc8540ads/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o
+COBJS	:= $(BOARD).o
 SOBJS	:= init.o
 #SOBJS	:=
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -40,9 +44,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/mpc8540eval/Makefile b/board/mpc8540eval/Makefile
index 6f1995e..0a83970 100644
--- a/board/mpc8540eval/Makefile
+++ b/board/mpc8540eval/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,14 +23,18 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o flash.o
-#OBJS	:= $(BOARD).o flash.o $(BOARD)_slave.o
+COBJS	:= $(BOARD).o flash.o
+#COBJS	:= $(BOARD).o flash.o $(BOARD)_slave.o
 SOBJS	:= init.o
 #SOBJS	:=
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -41,9 +45,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/mpc8560ads/Makefile b/board/mpc8560ads/Makefile
index 5d8ea34..3f1e8f2 100644
--- a/board/mpc8560ads/Makefile
+++ b/board/mpc8560ads/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o
+COBJS	:= $(BOARD).o
 SOBJS	:= init.o
 #SOBJS	:=
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -40,9 +44,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/mpl/mip405/Makefile b/board/mpl/mip405/Makefile
index 9276f64..87e507e 100644
--- a/board/mpl/mip405/Makefile
+++ b/board/mpl/mip405/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,14 +22,21 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o ../common/flash.o cmd_mip405.o ../common/pci.o \
+COBJS	= $(BOARD).o ../common/flash.o cmd_mip405.o ../common/pci.o \
 			../common/usb_uhci.o ../common/memtst.o ../common/common_util.o
 
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
@@ -41,9 +48,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/mpl/pati/Makefile b/board/mpl/pati/Makefile
index 1a9ce12..c469e3f 100644
--- a/board/mpl/pati/Makefile
+++ b/board/mpl/pati/Makefile
@@ -1,6 +1,6 @@
 #
-# (C) Copyright 2001	Wolfgang Denk, DENX Software Engineering, wd@denx.de
-#
+# (C) Copyright 2001-2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de
 #
 # See file CREDITS for list of people who contributed to this
 # project.
@@ -22,14 +22,20 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:=  pati.o ../common/flash.o ../common/memtst.o cmd_pati.o ../common/common_util.o
+COBJS	:=  pati.o ../common/flash.o ../common/memtst.o cmd_pati.o ../common/common_util.o
 #### cmd_pati.o
-SOBJS	:=
 
-$(LIB):	$(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -40,9 +46,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/mpl/pip405/Makefile b/board/mpl/pip405/Makefile
index a818d08..833900d 100644
--- a/board/mpl/pip405/Makefile
+++ b/board/mpl/pip405/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,10 +22,13 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o \
+COBJS	= $(BOARD).o \
 	  ../common/flash.o cmd_pip405.o ../common/pci.o \
 	  ../common/isa.o ../common/kbd.o \
 	  ../common/usb_uhci.o \
@@ -33,6 +36,10 @@
 
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
@@ -44,9 +51,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/mpl/vcma9/Makefile b/board/mpl/vcma9/Makefile
index 304c965..bd76e74 100644
--- a/board/mpl/vcma9/Makefile
+++ b/board/mpl/vcma9/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,15 +22,22 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= vcma9.o flash.o cmd_vcma9.o
-OBJS	+= ../common/common_util.o ../common/memtst.o
+COBJS	:= vcma9.o flash.o cmd_vcma9.o
+COBJS	+= ../common/common_util.o ../common/memtst.o
 
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -41,9 +48,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/musenki/Makefile b/board/musenki/Makefile
index 24dc026..1b57d2b 100644
--- a/board/musenki/Makefile
+++ b/board/musenki/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,19 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
-SOBJS	=
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/mvblue/Makefile b/board/mvblue/Makefile
index 24dc026..1b57d2b 100644
--- a/board/mvblue/Makefile
+++ b/board/mvblue/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,19 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
-SOBJS	=
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/mvs1/Makefile b/board/mvs1/Makefile
index 13ce9fc..e3d24b3 100644
--- a/board/mvs1/Makefile
+++ b/board/mvs1/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/mx1ads/Makefile b/board/mx1ads/Makefile
index 3e805fe..96e5be5 100644
--- a/board/mx1ads/Makefile
+++ b/board/mx1ads/Makefile
@@ -1,6 +1,9 @@
 #
 # board/mx1ads/Makefile
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # (c) Copyright 2004
 # Techware Information Technology, Inc.
 # http://www.techware.com.tw/
@@ -24,12 +27,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= mx1ads.o syncflash.o
+COBJS	:= mx1ads.o syncflash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -40,9 +47,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/mx1fs2/Makefile b/board/mx1fs2/Makefile
index 9e3bca1..2a17f82 100644
--- a/board/mx1fs2/Makefile
+++ b/board/mx1fs2/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= mx1fs2.o flash.o
+COBJS	:= mx1fs2.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/nc650/Makefile b/board/nc650/Makefile
index 8dc4934..f044727 100644
--- a/board/nc650/Makefile
+++ b/board/nc650/Makefile
@@ -1,6 +1,6 @@
 #
 # (C) Copyright 2006 Detlev Zundel, dzu@denx.de
-# (C) Copyright 2004
+# (C) Copyright 2004-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -24,18 +24,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o nand.o flash.o
+COBJS	= $(BOARD).o nand.o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/nc650/config.mk b/board/nc650/config.mk
index 5b2284a..52c8ffe 100644
--- a/board/nc650/config.mk
+++ b/board/nc650/config.mk
@@ -27,4 +27,4 @@
 #
 
 TEXT_BASE = 0x40700000
-BOARDLIBS = drivers/nand/libnand.a
+BOARDLIBS = $(obj)drivers/nand/libnand.a
diff --git a/board/netphone/Makefile b/board/netphone/Makefile
index b3c1797..a8b2159 100644
--- a/board/netphone/Makefile
+++ b/board/netphone/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o phone_console.o
+COBJS	= $(BOARD).o flash.o phone_console.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/netstar/Makefile b/board/netstar/Makefile
index 3a20501..b7c092d 100644
--- a/board/netstar/Makefile
+++ b/board/netstar/Makefile
@@ -1,3 +1,6 @@
+# 
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # (C) Copyright 2005
 # Ladislav Michl, 2N Telekomunikace, michl@2n.cz
@@ -23,63 +26,71 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= netstar.o flash.o nand.o
+COBJS	:= netstar.o flash.o nand.o
 SOBJS	:= setup.o crcek.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c) eeprom.c \
+		eeprom_start.S
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
 
 LOAD_ADDR = 0x10400000
 LDSCRIPT = $(TOPDIR)/board/$(BOARDDIR)/eeprom.lds
+lnk = $(if $(obj),$(obj),.)
 
 HOST_CFLAGS = -Wall -pedantic -I$(TOPDIR)/include
 
-all:	$(LIB) eeprom.srec eeprom.bin crcek.srec crcek.bin crcit
+all:	$(obj).depend $(LIB) $(obj)eeprom.srec $(obj)eeprom.bin \
+		$(obj)crcek.srec $(obj)crcek.bin $(obj)crcit
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $^
 
-eeprom.srec:	eeprom.o eeprom_start.o
-	$(LD) -T $(LDSCRIPT) -g -Ttext $(LOAD_ADDR) \
-		-o $(<:.o=) -e $(<:.o=) $^ \
-		-L../../examples -lstubs \
-		-L../../lib_generic -lgeneric \
+$(obj)eeprom.srec:	$(obj)eeprom.o $(obj)eeprom_start.o
+	cd $(lnk) && $(LD) -T $(LDSCRIPT) -g -Ttext $(LOAD_ADDR) \
+		-o $(<:.o=) -e eeprom eeprom.o eeprom_start.o \
+		-L$(obj)../../examples -lstubs \
+		-L$(obj)../../lib_generic -lgeneric \
 		-L$(gcclibdir) -lgcc
 	$(OBJCOPY) -O srec $(<:.o=) $@
 
-eeprom.bin:	eeprom.srec
+$(obj)eeprom.bin:	$(obj)eeprom.srec
 	$(OBJCOPY) -I srec -O binary $< $@ 2>/dev/null
 
-crcek.srec:	crcek.o
+$(obj)crcek.srec:	$(obj)crcek.o
 	$(LD) -g -Ttext 0x00000000 \
-		-o $(<:.o=) -e $(<:.o=) $^
+		-o $(<:.o=) -e crcek $^
 	$(OBJCOPY) -O srec $(<:.o=) $@
 
-crcek.bin:	crcek.srec
+$(obj)crcek.bin:	$(obj)crcek.srec
 	$(OBJCOPY) -I srec -O binary $< $@ 2>/dev/null
 
-crcit:		crcit.o crc32.o
+$(obj)crcit:		$(obj)crcit.o $(obj)crc32.o
 	$(HOSTCC) $(HOST_CFLAGS) -o $@ $^
 
-crcit.o:	crcit.c
-	$(HOSTCC) $(HOST_CFLAGS) -c $<
+$(obj)crcit.o:	crcit.c
+	$(HOSTCC) $(HOST_CFLAGS) -o $@ -c $<
 
-crc32.o:	$(TOPDIR)/tools/crc32.c
-	$(HOSTCC) $(HOST_CFLAGS) -DUSE_HOSTCC -c $<
+$(obj)crc32.o:	$(OBJTREE)/tools/crc32.c
+	$(HOSTCC) $(HOST_CFLAGS) -DUSE_HOSTCC -o $@ -c $<
 
 clean:
-	rm -f $(SOBJS) $(OBJS) eeprom eeprom.srec eeprom.bin \
-		crcek crcek.srec crcek.bin
+	rm -f $(SOBJS) $(OBJS) $(obj)eeprom $(obj)eeprom.srec \
+		$(obj)eeprom.bin $(obj)crcek $(obj)crcek.srec \
+		$(obj)crcek.bin
 
 distclean:	clean
 	rm -f $(LIB) core *.bak .depend
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/netta/Makefile b/board/netta/Makefile
index ee200c2..39362c6 100644
--- a/board/netta/Makefile
+++ b/board/netta/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o dsp.o codec.o pcmcia.o
+COBJS	= $(BOARD).o flash.o dsp.o codec.o pcmcia.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/netta2/Makefile b/board/netta2/Makefile
index d457020..e3d24b3 100644
--- a/board/netta2/Makefile
+++ b/board/netta2/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/netvia/Makefile b/board/netvia/Makefile
index 13ce9fc..e3d24b3 100644
--- a/board/netvia/Makefile
+++ b/board/netvia/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/ns9750dev/Makefile b/board/ns9750dev/Makefile
index fb4333c..defc29b 100644
--- a/board/ns9750dev/Makefile
+++ b/board/ns9750dev/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= ns9750dev.o flash.o led.o
+COBJS	:= ns9750dev.o flash.o led.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/nx823/Makefile b/board/nx823/Makefile
index 7a2014d..1b57d2b 100644
--- a/board/nx823/Makefile
+++ b/board/nx823/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/o2dnt/Makefile b/board/o2dnt/Makefile
index 2eb4366..626f610 100644
--- a/board/o2dnt/Makefile
+++ b/board/o2dnt/Makefile
@@ -1,6 +1,6 @@
 
 #
-# (C) Copyright 2005
+# (C) Copyright 2005-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -24,11 +24,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o flash.o
+COBJS	:= $(BOARD).o flash.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/omap1510inn/Makefile b/board/omap1510inn/Makefile
index 902b24e..7cdc8d0 100644
--- a/board/omap1510inn/Makefile
+++ b/board/omap1510inn/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= omap1510innovator.o
+COBJS	:= omap1510innovator.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/omap1610inn/Makefile b/board/omap1610inn/Makefile
index 4560102..e523dc6 100644
--- a/board/omap1610inn/Makefile
+++ b/board/omap1610inn/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= omap1610innovator.o flash.o
+COBJS	:= omap1610innovator.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/omap2420h4/Makefile b/board/omap2420h4/Makefile
index ed47868..767a9d6 100644
--- a/board/omap2420h4/Makefile
+++ b/board/omap2420h4/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= omap2420h4.o mem.o sys_info.o
+COBJS	:= omap2420h4.o mem.o sys_info.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/omap5912osk/Makefile b/board/omap5912osk/Makefile
index 4b56421..c734b43 100644
--- a/board/omap5912osk/Makefile
+++ b/board/omap5912osk/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= omap5912osk.o
+COBJS	:= omap5912osk.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/omap730p2/Makefile b/board/omap730p2/Makefile
index 29467ac..d678fd5 100644
--- a/board/omap730p2/Makefile
+++ b/board/omap730p2/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= omap730p2.o flash.o
+COBJS	:= omap730p2.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/oxc/Makefile b/board/oxc/Makefile
index ae7a932..e3d24b3 100644
--- a/board/oxc/Makefile
+++ b/board/oxc/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/pb1x00/Makefile b/board/pb1x00/Makefile
index d1cdc6b..d1e9ad3 100644
--- a/board/pb1x00/Makefile
+++ b/board/pb1x00/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,19 +23,23 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 SOBJS	= memsetup.o
 
-$(LIB):	.depend $(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/pcippc2/Makefile b/board/pcippc2/Makefile
index 2998f23..2af3286 100644
--- a/board/pcippc2/Makefile
+++ b/board/pcippc2/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2002
+# (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,23 +23,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
 COBJS	= $(BOARD).o cpc710_pci.o flash.o sconsole.o \
 	  fpga_serial.o pcippc2_fpga.o cpc710_init_ram.o i2c.o
 
-AOBJS	=
+SOBJS	=
 
-OBJS	= $(COBJS) $(AOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
-$(LIB):	.depend $(OBJS)
-	$(AR) crv $@ $(OBJS)
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 #########################################################################
 
-.depend: Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
-	$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/pcs440ep/Makefile b/board/pcs440ep/Makefile
index 4a2a388..9da90c1 100644
--- a/board/pcs440ep/Makefile
+++ b/board/pcs440ep/Makefile
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/pleb2/Makefile b/board/pleb2/Makefile
index 95d9170..0799772 100644
--- a/board/pleb2/Makefile
+++ b/board/pleb2/Makefile
@@ -1,6 +1,6 @@
 
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -24,12 +24,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= pleb2.o flash.o
+COBJS	:= pleb2.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -40,9 +44,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/pm520/Makefile b/board/pm520/Makefile
index 8cf0d7d..8e61c79 100644
--- a/board/pm520/Makefile
+++ b/board/pm520/Makefile
@@ -1,6 +1,6 @@
 
 #
-# (C) Copyright 2003-2004
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -24,11 +24,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o flash.o
+COBJS	:= $(BOARD).o flash.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/pm826/Makefile b/board/pm826/Makefile
index 7a2014d..1b57d2b 100644
--- a/board/pm826/Makefile
+++ b/board/pm826/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/pm826/config.mk b/board/pm826/config.mk
index c93bad9..48ac299 100644
--- a/board/pm826/config.mk
+++ b/board/pm826/config.mk
@@ -26,7 +26,7 @@
 #
 
 
-sinclude $(TOPDIR)/board/$(BOARDDIR)/config.tmp
+sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp
 
 ifndef TEXT_BASE
 ## Standard: boot 64-bit flash
diff --git a/board/pm828/Makefile b/board/pm828/Makefile
index b9ef0c0..1b57d2b 100644
--- a/board/pm828/Makefile
+++ b/board/pm828/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001-2004
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/pm828/config.mk b/board/pm828/config.mk
index e894af7..6288431 100644
--- a/board/pm828/config.mk
+++ b/board/pm828/config.mk
@@ -26,7 +26,7 @@
 #
 
 
-sinclude $(TOPDIR)/board/$(BOARDDIR)/config.tmp
+sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp
 
 ifndef TEXT_BASE
 ## Standard: boot 64-bit flash
diff --git a/board/pm854/Makefile b/board/pm854/Makefile
index 7828166..3f1e8f2 100644
--- a/board/pm854/Makefile
+++ b/board/pm854/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001-2005
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o
+COBJS	:= $(BOARD).o
 SOBJS	:= init.o
 #SOBJS	:=
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -40,9 +44,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/pm856/Makefile b/board/pm856/Makefile
index 5d8ea34..3f1e8f2 100644
--- a/board/pm856/Makefile
+++ b/board/pm856/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o
+COBJS	:= $(BOARD).o
 SOBJS	:= init.o
 #SOBJS	:=
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -40,9 +44,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/pn62/Makefile b/board/pn62/Makefile
index e85d4fd..a837820 100644
--- a/board/pn62/Makefile
+++ b/board/pn62/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS =  $(BOARD).o cmd_pn62.o misc.o
+COBJS	= $(BOARD).o cmd_pn62.o misc.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/ppmc7xx/Makefile b/board/ppmc7xx/Makefile
index c378677..1655b3e 100644
--- a/board/ppmc7xx/Makefile
+++ b/board/ppmc7xx/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= ppmc7xx.o pci.o flash.o
 SOBJS	:= init.o
 
-$(LIB):	.depend $(OBJS) $(SOBJS)
+COBJS	:= ppmc7xx.o pci.o flash.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -39,9 +44,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/ppmc8260/Makefile b/board/ppmc8260/Makefile
index 351f4ee..e17cb7a 100644
--- a/board/ppmc8260/Makefile
+++ b/board/ppmc8260/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= ppmc8260.o
+COBJS	:= ppmc8260.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/prodrive/p3p440/Makefile b/board/prodrive/p3p440/Makefile
index 47116d3..a47a067 100644
--- a/board/prodrive/p3p440/Makefile
+++ b/board/prodrive/p3p440/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2002
+# (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o
+COBJS	= $(BOARD).o
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/prodrive/pdnb3/Makefile b/board/prodrive/pdnb3/Makefile
index f3cd5a3..32ffac0d 100644
--- a/board/prodrive/pdnb3/Makefile
+++ b/board/prodrive/pdnb3/Makefile
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= flash.o pdnb3.o nand.o
+COBJS	:= flash.o pdnb3.o nand.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/prodrive/pdnb3/config.mk b/board/prodrive/pdnb3/config.mk
index 6b0f18b..7670758 100644
--- a/board/prodrive/pdnb3/config.mk
+++ b/board/prodrive/pdnb3/config.mk
@@ -1,4 +1,4 @@
 TEXT_BASE = 0x01f00000
 
 # include NPE ethernet driver
-BOARDLIBS = cpu/ixp/npe/libnpe.a
+BOARDLIBS = $(obj)cpu/ixp/npe/libnpe.a
diff --git a/board/psyent/pci5441/Makefile b/board/psyent/pci5441/Makefile
index 8e55c9b..7d74b4e 100644
--- a/board/psyent/pci5441/Makefile
+++ b/board/psyent/pci5441/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001-2004
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -12,7 +12,7 @@
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
@@ -22,17 +22,22 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
 COMOBJS := ../common/AMDLV065D.o
 
-OBJS	:= $(BOARD).o $(COMOBJS)
+COBJS	:= $(BOARD).o $(COMOBJS)
 
-SOBJS	=
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
-$(LIB): $(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+$(LIB):	$(obj).depend $(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -42,9 +47,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/psyent/pk1c20/Makefile b/board/psyent/pk1c20/Makefile
index 5c1db03..cbe9919 100644
--- a/board/psyent/pk1c20/Makefile
+++ b/board/psyent/pk1c20/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001-2004
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -12,7 +12,7 @@
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
@@ -22,17 +22,22 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
 COMOBJS := ../common/AMDLV065D.o
 
-OBJS	:= $(BOARD).o led.o $(COMOBJS)
+COBJS	:= $(BOARD).o led.o $(COMOBJS)
 
-SOBJS	=
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
-$(LIB): $(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+$(LIB):	$(obj).depend $(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -42,9 +47,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/purple/Makefile b/board/purple/Makefile
index b2f2fc0..1262d80 100644
--- a/board/purple/Makefile
+++ b/board/purple/Makefile
@@ -1,6 +1,6 @@
 
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -24,19 +24,23 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o sconsole.o
+COBJS	= $(BOARD).o flash.o sconsole.o
 SOBJS	= lowlevel_init.o
 
-$(LIB):	.depend $(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/pxa255_idp/Makefile b/board/pxa255_idp/Makefile
index b5f352a..2d0077b 100644
--- a/board/pxa255_idp/Makefile
+++ b/board/pxa255_idp/Makefile
@@ -1,6 +1,6 @@
 
 #
-# (C) Copyright 2000-2005
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -24,12 +24,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= pxa_idp.o
+COBJS	:= pxa_idp.o
 SOBJS	:= memsetup.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -40,9 +44,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/quantum/Makefile b/board/quantum/Makefile
index e50f5ff..602865f 100644
--- a/board/quantum/Makefile
+++ b/board/quantum/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,19 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o fpga.o
+COBJS	= $(BOARD).o fpga.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
-$(LIB):	.depend $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/r360mpi/Makefile b/board/r360mpi/Makefile
index 1a7e7a6..0179b46 100644
--- a/board/r360mpi/Makefile
+++ b/board/r360mpi/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o pcmcia.o
+COBJS	= $(BOARD).o flash.o pcmcia.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/r5200/Makefile b/board/r5200/Makefile
index d0364ed..2951b96 100644
--- a/board/r5200/Makefile
+++ b/board/r5200/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2003
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o
+COBJS	= $(BOARD).o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/rattler/Makefile b/board/rattler/Makefile
index 52f0fd6..e880f87 100644
--- a/board/rattler/Makefile
+++ b/board/rattler/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001-2005
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o
+COBJS	:= $(BOARD).o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/rbc823/Makefile b/board/rbc823/Makefile
index 0121ddc..f004881 100644
--- a/board/rbc823/Makefile
+++ b/board/rbc823/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o kbd.o
+COBJS	= $(BOARD).o flash.o kbd.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/rmu/Makefile b/board/rmu/Makefile
index 13ce9fc..e3d24b3 100644
--- a/board/rmu/Makefile
+++ b/board/rmu/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/rpxsuper/Makefile b/board/rpxsuper/Makefile
index 4535106..2689c6b 100644
--- a/board/rpxsuper/Makefile
+++ b/board/rpxsuper/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= rpxsuper.o flash.o mii_phy.o
+COBJS	:= rpxsuper.o flash.o mii_phy.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/rsdproto/Makefile b/board/rsdproto/Makefile
index 9934787..4a7bd3d 100644
--- a/board/rsdproto/Makefile
+++ b/board/rsdproto/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,25 +23,29 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= rsdproto.o flash.o
+COBJS	:= rsdproto.o flash.o
 SOBJS	:= flash_asm.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
 
 distclean:	clean
-	rm -f $(LIB) core *.bak .depend
+	rm -f $(LIB) core *.bak $(obj).depend
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/sacsng/Makefile b/board/sacsng/Makefile
index baefa4a..2dff242 100644
--- a/board/sacsng/Makefile
+++ b/board/sacsng/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= sacsng.o flash.o clkinit.o
+COBJS	:= sacsng.o flash.o clkinit.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/sandburst/karef/Makefile b/board/sandburst/karef/Makefile
index 8b3173c..60d5573 100644
--- a/board/sandburst/karef/Makefile
+++ b/board/sandburst/karef/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # (C) Copyright 2005
 # Sandburst Corporation
 # Travis B. Sawyer
@@ -23,6 +26,9 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
 # TBS: add for debugging purposes
 BUILDUSER := $(shell whoami)
@@ -32,13 +38,16 @@
 # TBS: end debugging
 
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o ../common/flash.o ../common/ppc440gx_i2c.o \
+COBJS	= $(BOARD).o ../common/flash.o ../common/ppc440gx_i2c.o \
 	../common/sb_common.o
 
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -51,9 +60,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/sandburst/metrobox/Makefile b/board/sandburst/metrobox/Makefile
index 06a9a22..9579512 100644
--- a/board/sandburst/metrobox/Makefile
+++ b/board/sandburst/metrobox/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # (C) Copyright 2005
 # Travis B. Sawyer, Sandburst Corporation, tsawyer@sandburst.com
 #
@@ -22,6 +25,9 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
 # TBS: add for debugging purposes
 BUILDUSER := $(shell whoami)
@@ -31,12 +37,15 @@
 # TBS: end debugging
 
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o ../common/flash.o ../common/ppc440gx_i2c.o \
+COBJS	= $(BOARD).o ../common/flash.o ../common/ppc440gx_i2c.o \
 	../common/sb_common.o
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -49,9 +58,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/sandpoint/Makefile b/board/sandpoint/Makefile
index d6bbf2f..e3d24b3 100644
--- a/board/sandpoint/Makefile
+++ b/board/sandpoint/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS =  $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/sbc2410x/Makefile b/board/sbc2410x/Makefile
index ae8665e..908b5ff 100644
--- a/board/sbc2410x/Makefile
+++ b/board/sbc2410x/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= sbc2410x.o flash.o
+COBJS	:= sbc2410x.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/sbc405/Makefile b/board/sbc405/Makefile
index c4198c4..9b9f033 100644
--- a/board/sbc405/Makefile
+++ b/board/sbc405/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,9 +23,13 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o strataflash.o
+COBJS	= $(BOARD).o strataflash.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/sbc8240/Makefile b/board/sbc8240/Makefile
index 7a2014d..1b57d2b 100644
--- a/board/sbc8240/Makefile
+++ b/board/sbc8240/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/sbc8260/Makefile b/board/sbc8260/Makefile
index 14ed457..7077a82 100644
--- a/board/sbc8260/Makefile
+++ b/board/sbc8260/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= sbc8260.o flash.o
+COBJS	:= sbc8260.o flash.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/sbc8560/Makefile b/board/sbc8560/Makefile
index da295fb..4d9c2e7 100644
--- a/board/sbc8560/Makefile
+++ b/board/sbc8560/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2004
+# (C) Copyright 2004-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # (C) Copyright 2004 Wind River Systems Inc <www.windriver.com>.
@@ -26,13 +26,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o
+COBJS	:= $(BOARD).o
 SOBJS	:= init.o
 #SOBJS	:=
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -43,9 +47,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/sc520_cdp/Makefile b/board/sc520_cdp/Makefile
index ab06ebc..7555b4f 100644
--- a/board/sc520_cdp/Makefile
+++ b/board/sc520_cdp/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # (C) Copyright 2002
 # Daniel Engström, Omicron Ceti AB, daniel@omicron.se.
 #
@@ -23,12 +26,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= sc520_cdp.o flash.o
+COBJS	:= sc520_cdp.o flash.o
 SOBJS	:= sc520_cdp_asm.o sc520_cdp_asm16.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -39,9 +46,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/sc520_spunk/Makefile b/board/sc520_spunk/Makefile
index 242d53c..9958e80 100644
--- a/board/sc520_spunk/Makefile
+++ b/board/sc520_spunk/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+# 
 # (C) Copyright 2002
 # Daniel Engström, Omicron Ceti AB, daniel@omicron.se.
 #
@@ -23,12 +26,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= sc520_spunk.o flash.o
+COBJS	:= sc520_spunk.o flash.o
 SOBJS	:= sc520_spunk_asm.o sc520_spunk_asm16.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -39,9 +46,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/scb9328/Makefile b/board/scb9328/Makefile
index 5dc3fd4..01b908e 100644
--- a/board/scb9328/Makefile
+++ b/board/scb9328/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= scb9328.o flash.o
+COBJS	:= scb9328.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/shannon/Makefile b/board/shannon/Makefile
index f66b096..a04d841 100644
--- a/board/shannon/Makefile
+++ b/board/shannon/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= shannon.o flash.o
+COBJS	:= shannon.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/siemens/CCM/Makefile b/board/siemens/CCM/Makefile
index ee2fc53..2ad4c83 100644
--- a/board/siemens/CCM/Makefile
+++ b/board/siemens/CCM/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,20 +22,28 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+$(shell mkdir -p $(obj)../../tqm8xx)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= ccm.o flash.o fpga_ccm.o ../common/fpga.o \
+COBJS	= ccm.o flash.o fpga_ccm.o ../common/fpga.o \
 	  ../../tqm8xx/load_sernum_ethaddr.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/siemens/IAD210/Makefile b/board/siemens/IAD210/Makefile
index 87a6893..3964381 100644
--- a/board/siemens/IAD210/Makefile
+++ b/board/siemens/IAD210/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o atm.o
+COBJS	= $(BOARD).o flash.o atm.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/siemens/SCM/Makefile b/board/siemens/SCM/Makefile
index af646e4..b4bbb53 100644
--- a/board/siemens/SCM/Makefile
+++ b/board/siemens/SCM/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,21 +22,28 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+$(shell mkdir -p $(obj)../../tqm8xx/)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= scm.o flash.o fpga_scm.o ../common/fpga.o \
+COBJS	= scm.o flash.o fpga_scm.o ../common/fpga.o \
 	  ../../tqm8xx/load_sernum_ethaddr.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
-$(LIB):	.depend $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/siemens/pcu_e/Makefile b/board/siemens/pcu_e/Makefile
index 7a2014d..1b57d2b 100644
--- a/board/siemens/pcu_e/Makefile
+++ b/board/siemens/pcu_e/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/sixnet/Makefile b/board/sixnet/Makefile
index 13ce9fc..e3d24b3 100644
--- a/board/sixnet/Makefile
+++ b/board/sixnet/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/sl8245/Makefile b/board/sl8245/Makefile
index 6d11240..43c27e9 100644
--- a/board/sl8245/Makefile
+++ b/board/sl8245/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001 - 2003
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS 	= $(BOARD).o flash.o
+COBJS 	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/smdk2400/Makefile b/board/smdk2400/Makefile
index fc3d48f..b3cefcf 100644
--- a/board/smdk2400/Makefile
+++ b/board/smdk2400/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= smdk2400.o flash.o
+COBJS	:= smdk2400.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/smdk2410/Makefile b/board/smdk2410/Makefile
index 4ee21f5..65f1a4d 100644
--- a/board/smdk2410/Makefile
+++ b/board/smdk2410/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= smdk2410.o flash.o
+COBJS	:= smdk2410.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/snmc/qs850/Makefile b/board/snmc/qs850/Makefile
index e5d8446..e3d24b3 100644
--- a/board/snmc/qs850/Makefile
+++ b/board/snmc/qs850/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2003
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/snmc/qs860t/Makefile b/board/snmc/qs860t/Makefile
index 13ce9fc..e3d24b3 100644
--- a/board/snmc/qs860t/Makefile
+++ b/board/snmc/qs860t/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/sorcery/Makefile b/board/sorcery/Makefile
index 3d6d673..c59a3be 100644
--- a/board/sorcery/Makefile
+++ b/board/sorcery/Makefile
@@ -1,4 +1,5 @@
-# (C) Copyright 2005
+#
+# (C) Copyright 2005-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o
+COBJS	:= $(BOARD).o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -37,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/spc1920/Makefile b/board/spc1920/Makefile
index 47afef7..2951b96 100644
--- a/board/spc1920/Makefile
+++ b/board/spc1920/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o
+COBJS	= $(BOARD).o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/spd8xx/Makefile b/board/spd8xx/Makefile
index 13ce9fc..e3d24b3 100644
--- a/board/spd8xx/Makefile
+++ b/board/spd8xx/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/ssv/adnpesc1/Makefile b/board/ssv/adnpesc1/Makefile
index 9182a4e..77de4fb 100644
--- a/board/ssv/adnpesc1/Makefile
+++ b/board/ssv/adnpesc1/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001-2004
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,14 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o flash.o misc.o
+COBJS	:= $(BOARD).o flash.o misc.o
+SOBJS	:= vectors.o
 
-SOBJS  = vectors.o
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -40,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/stamp/Makefile b/board/stamp/Makefile
index ab97e1b..8c20543 100644
--- a/board/stamp/Makefile
+++ b/board/stamp/Makefile
@@ -3,7 +3,7 @@
 #
 # Copyright (c) 2005 blackfin.uclinux.org
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -26,7 +26,7 @@
 #
 
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -50,19 +50,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o stamp.o
-SOBJS	=
+COBJS	= $(BOARD).o stamp.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/stxgp3/Makefile b/board/stxgp3/Makefile
index d150df8..5477ff9 100644
--- a/board/stxgp3/Makefile
+++ b/board/stxgp3/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o flash.o
+COBJS	:= $(BOARD).o flash.o
 SOBJS	:= init.o
 #SOBJS	:=
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -40,9 +44,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/stxxtc/Makefile b/board/stxxtc/Makefile
index 11065cf..807da06 100644
--- a/board/stxxtc/Makefile
+++ b/board/stxxtc/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,26 +23,30 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o oftree.o
+COBJS	= $(BOARD).o oftree.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
-%.dtb: %.dts
+$(obj)%.dtb: $(src)%.dts
 	dtc -f -V 0x10 -I dts -O dtb $< >$@
 
-%.c: %.dtb
+$(obj)%.c: $(obj)%.dtb
 	xxd -i $< \
 	   | sed -e "s/^unsigned char/const unsigned char/g" \
 	   | sed -e "s/^unsigned int/const unsigned int/g" > $@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/svm_sc8xx/Makefile b/board/svm_sc8xx/Makefile
index 13ce9fc..e3d24b3 100644
--- a/board/svm_sc8xx/Makefile
+++ b/board/svm_sc8xx/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/sx1/Makefile b/board/sx1/Makefile
index 8fbdf2a..4e6adac 100644
--- a/board/sx1/Makefile
+++ b/board/sx1/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2004
+# (C) Copyright 2004-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= sx1.o
+COBJS	:= sx1.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/tb0229/Makefile b/board/tb0229/Makefile
index 4375073..aefaf0d 100644
--- a/board/tb0229/Makefile
+++ b/board/tb0229/Makefile
@@ -1,7 +1,7 @@
 #
 # (C) Masami Komiya <mkomiya@sonare.it> 2004
 #
-# (C) Copyright 2003-2004
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -25,19 +25,23 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o vr4131-pci.o
+COBJS	= $(BOARD).o flash.o vr4131-pci.o
 SOBJS	= lowlevel_init.o
 
-$(LIB):	.depend $(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/total5200/Makefile b/board/total5200/Makefile
index 232956a..4245f98 100644
--- a/board/total5200/Makefile
+++ b/board/total5200/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003-2004
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o sdram.o
+COBJS	:= $(BOARD).o sdram.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/total5200/config.mk b/board/total5200/config.mk
index 1a7a7cf..e7ac93d 100644
--- a/board/total5200/config.mk
+++ b/board/total5200/config.mk
@@ -31,7 +31,7 @@
 #	0x00100000   boot from RAM (for testing only)
 #
 
-sinclude $(TOPDIR)/board/$(BOARDDIR)/config.tmp
+sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp
 
 ifndef TEXT_BASE
 ## Standard: boot high
diff --git a/board/tqm5200/Makefile b/board/tqm5200/Makefile
index 9a1ea48..d0dde26 100644
--- a/board/tqm5200/Makefile
+++ b/board/tqm5200/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003-2004
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o cmd_stk52xx.o cmd_tb5200.o
+COBJS	:= $(BOARD).o cmd_stk52xx.o cmd_tb5200.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/tqm5200/config.mk b/board/tqm5200/config.mk
index 84ddee8..d72dfe7 100644
--- a/board/tqm5200/config.mk
+++ b/board/tqm5200/config.mk
@@ -32,7 +32,7 @@
 #	0x00100000   boot from RAM (for testing only)
 #
 
-sinclude $(TOPDIR)/board/$(BOARDDIR)/config.tmp
+sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp
 
 ifndef TEXT_BASE
 ## Standard: boot low
diff --git a/board/tqm8260/Makefile b/board/tqm8260/Makefile
index c10b9fe..d3adccd 100644
--- a/board/tqm8260/Makefile
+++ b/board/tqm8260/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,19 +22,26 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../tqm8xx/)
+endif
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o ../tqm8xx/load_sernum_ethaddr.o
+COBJS	= $(BOARD).o flash.o ../tqm8xx/load_sernum_ethaddr.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/tqm834x/Makefile b/board/tqm834x/Makefile
index 3ecc7d0..6991cfb 100644
--- a/board/tqm834x/Makefile
+++ b/board/tqm834x/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+# 
 # Copyright 2004 Freescale Semiconductor, Inc.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,11 +25,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o pci.o
+COBJS	= $(BOARD).o pci.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -37,9 +44,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/tqm85xx/Makefile b/board/tqm85xx/Makefile
index 3933d46..a6ad98a 100644
--- a/board/tqm85xx/Makefile
+++ b/board/tqm85xx/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -12,7 +12,7 @@
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o sdram.o
+COBJS	:= $(BOARD).o sdram.o
 SOBJS	:= init.o
 #SOBJS	:=
 
-$(LIB): $(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -40,9 +44,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/tqm8xx/Makefile b/board/tqm8xx/Makefile
index 2ff9b4d..312c0c4 100644
--- a/board/tqm8xx/Makefile
+++ b/board/tqm8xx/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2003
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o load_sernum_ethaddr.o
+COBJS	= $(BOARD).o flash.o load_sernum_ethaddr.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/trab/Makefile b/board/trab/Makefile
index 159404b..2b918f6 100644
--- a/board/trab/Makefile
+++ b/board/trab/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,43 +23,51 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= trab.o flash.o vfd.o cmd_trab.o memory.o tsc2000.o auto_update.o
+COBJS	:= trab.o flash.o vfd.o cmd_trab.o memory.o tsc2000.o auto_update.o
 SOBJS	:= lowlevel_init.o
 
+COBJS_FKT := trab_fkt.o rs485.o tsc2000.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c) $(COBJS_FKT:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+OBJS_FKT := $(addprefix $(obj),$(COBJS_FKT))
+
 gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
 
 LOAD_ADDR = 0xc100000
 
 #########################################################################
 
-all:	$(LIB) trab_fkt.srec trab_fkt.bin
+all:	$(LIB) $(obj)trab_fkt.srec $(obj)trab_fkt.bin
 
-$(LIB):	$(OBJS) $(SOBJS)
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
-trab_fkt.srec:	trab_fkt.o rs485.o tsc2000.o $(LIB)
-	$(LD) -g -Ttext $(LOAD_ADDR) -o $(<:.o=) -e $(<:.o=) $^ $(LIB) \
-		-L../../examples -lstubs \
-		-L../../lib_generic -lgeneric \
+$(obj)trab_fkt.srec:	$(OBJS_FKT) $(LIB)
+	$(LD) -g -Ttext $(LOAD_ADDR) -o $(<:.o=) -e trab_fkt $^ $(LIB) \
+		-L$(obj)../../examples -lstubs \
+		-L$(obj)../../lib_generic -lgeneric \
 		-L$(gcclibdir) -lgcc
 	$(OBJCOPY) -O srec $(<:.o=) $@
 
-trab_fkt.bin:	trab_fkt.srec
+$(obj)trab_fkt.bin:	$(obj)trab_fkt.srec
 	$(OBJCOPY) -I srec -O binary $< $@
 
 clean:
-	rm -f $(SOBJS) $(OBJS)
+	rm -f $(SOBJS) $(OBJS) $(OBJS_FKT)
 
 distclean:	clean
 	rm -f $(LIB) core *.bak .depend
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/trab/config.mk b/board/trab/config.mk
index f2411d0..800cc28 100644
--- a/board/trab/config.mk
+++ b/board/trab/config.mk
@@ -19,7 +19,7 @@
 # download areas is 0C80'0000
 #
 
-sinclude $(TOPDIR)/board/$(BOARDDIR)/config.tmp
+sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp
 
 ifndef TEXT_BASE
 TEXT_BASE = 0x0DF40000
diff --git a/board/uc100/Makefile b/board/uc100/Makefile
index 2d2cc23..a7a93ab 100644
--- a/board/uc100/Makefile
+++ b/board/uc100/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2003
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,19 +23,23 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-#OBJS	= $(BOARD).o flash.o pcmcia.o
-OBJS	= $(BOARD).o pcmcia.o
+#COBJS	= $(BOARD).o flash.o pcmcia.o
+COBJS	= $(BOARD).o pcmcia.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/utx8245/Makefile b/board/utx8245/Makefile
index e698afc..0664d9f 100644
--- a/board/utx8245/Makefile
+++ b/board/utx8245/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # (C) Copyright 2002
@@ -28,20 +28,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-SOBJS	=
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
 
-$(LIB):	.depend $(OBJS) $(SOBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/v37/Makefile b/board/v37/Makefile
index 7a17067..b420269 100644
--- a/board/v37/Makefile
+++ b/board/v37/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/versatile/Makefile b/board/versatile/Makefile
index fbdc627..27bca10 100644
--- a/board/versatile/Makefile
+++ b/board/versatile/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= versatile.o flash.o
+COBJS	:= versatile.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/versatile/split_by_variant.sh b/board/versatile/split_by_variant.sh
index 576f238..25461c2 100755
--- a/board/versatile/split_by_variant.sh
+++ b/board/versatile/split_by_variant.sh
@@ -5,28 +5,30 @@
 # ---------------------------------------------------------
 # Set up the Versatile type define
 # ---------------------------------------------------------
+
+mkdir -p ${obj}include
 variant=PB926EJ-S
 if [ "$1" == "" ]
 then
 	echo "$0:: No parameters - using versatilepb_config"
-	echo "#define CONFIG_ARCH_VERSATILE_PB" > ./include/config.h
+	echo "#define CONFIG_ARCH_VERSATILE_PB" > ${obj}include/config.h
 	variant=PB926EJ-S
 else
 	case "$1" in
 	versatilepb_config	|	\
 	versatile_config)
-	echo "#define CONFIG_ARCH_VERSATILE_PB" > ./include/config.h
+	echo "#define CONFIG_ARCH_VERSATILE_PB" > ${obj}include/config.h
 	;;
 
 	versatileab_config)
-	echo "#define CONFIG_ARCH_VERSATILE_AB" > ./include/config.h
+	echo "#define CONFIG_ARCH_VERSATILE_AB" > ${obj}include/config.h
 	variant=AB926EJ-S
 	;;
 
 
 	*)
 	echo "$0:: Unrecognised config - using versatilepb_config"
-	echo "#define CONFIG_ARCH_VERSATILE_PB" > ./include/config.h
+	echo "#define CONFIG_ARCH_VERSATILE_PB" > ${obj}include/config.h
 	variant=PB926EJ-S
 	;;
 
@@ -36,5 +38,5 @@
 # ---------------------------------------------------------
 # Complete the configuration
 # ---------------------------------------------------------
-./mkconfig -a versatile arm arm926ejs versatile NULL versatile
+$MKCONFIG -a versatile arm arm926ejs versatile NULL versatile
 echo "Variant:: $variant"
diff --git a/board/voiceblue/Makefile b/board/voiceblue/Makefile
index 6302fa8..fa614f8 100644
--- a/board/voiceblue/Makefile
+++ b/board/voiceblue/Makefile
@@ -1,4 +1,4 @@
-# (C) Copyright 2000-2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de
 #
 # (C) Copyright 2005
@@ -24,43 +24,51 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= voiceblue.o
+COBJS	:= voiceblue.o
 SOBJS	:= setup.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c) eeprom.c eeprom_start.S
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
 
 LOAD_ADDR = 0x10400000
 LDSCRIPT = $(TOPDIR)/board/$(BOARDDIR)/eeprom.lds
+lnk = $(if $(obj),$(obj),.)
 
-all:	$(LIB) eeprom.srec eeprom.bin
+all:	$(obj).depend $(LIB) $(obj)eeprom.srec $(obj)eeprom.bin
 
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
-eeprom.srec:	eeprom.o eeprom_start.o
-	$(LD) -T $(LDSCRIPT) -g -Ttext $(LOAD_ADDR) \
-		-o $(<:.o=) -e $(<:.o=) $^ \
-		-L../../examples -lstubs \
-		-L../../lib_generic -lgeneric \
+$(obj)eeprom.srec:	$(obj)eeprom.o $(obj)eeprom_start.o
+	cd $(lnk) && $(LD) -T $(LDSCRIPT) -g -Ttext $(LOAD_ADDR) \
+		-o $(<:.o=) -e eeprom eeprom.o eeprom_start.o \
+		-L$(obj)../../examples -lstubs \
+		-L$(obj)../../lib_generic -lgeneric \
 		-L$(gcclibdir) -lgcc
 	$(OBJCOPY) -O srec $(<:.o=) $@
 
-eeprom.bin:	eeprom.srec
+$(obj)eeprom.bin:	$(obj)eeprom.srec
 	$(OBJCOPY) -I srec -O binary $< $@ 2>/dev/null
 
 clean:
-	rm -f $(SOBJS) $(OBJS) eeprom eeprom.srec eeprom.bin
+	rm -f $(SOBJS) $(OBJS) $(obj)eeprom \
+		$(obj)eeprom.srec $(obj)eeprom.bin \
+		$(obj)eeprom.o $(obj)eeprom_start.o
+
 
 distclean:	clean
 	rm -f $(LIB) core config.tmp *.bak .depend
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/voiceblue/config.mk b/board/voiceblue/config.mk
index b77c91c..d55daa4 100644
--- a/board/voiceblue/config.mk
+++ b/board/voiceblue/config.mk
@@ -3,7 +3,7 @@
 # entry 1000'8000 (mem base + reserved)
 #
 
-sinclude $(TOPDIR)/board/$(BOARDDIR)/config.tmp
+sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp
 
 ifeq ($(VOICEBLUE_SMALL_FLASH),y)
 # We load ourself to internal SRAM at 2001'2000
diff --git a/board/w7o/Makefile b/board/w7o/Makefile
index d008f89..2ec449d 100644
--- a/board/w7o/Makefile
+++ b/board/w7o/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # (C) Copyright 2001
 # Erik Theisen, Wave 7 Optics, etheisen@mindspring.com.
 #
@@ -23,12 +26,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o fpga.o fsboot.o post2.o vpd.o cmd_vpd.o \
+COBJS	= $(BOARD).o flash.o fpga.o fsboot.o post2.o vpd.o cmd_vpd.o \
 	  watchdog.o
 SOBJS	= init.o post1.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $^
 
@@ -40,9 +47,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/wepep250/Makefile b/board/wepep250/Makefile
index 11ad8fb..b5b5a96 100644
--- a/board/wepep250/Makefile
+++ b/board/wepep250/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= wepep250.o flash.o
+COBJS	:= wepep250.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/westel/amx860/Makefile b/board/westel/amx860/Makefile
index 7a2014d..1b57d2b 100644
--- a/board/westel/amx860/Makefile
+++ b/board/westel/amx860/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,18 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o flash.o
+COBJS	= $(BOARD).o flash.o
 
-$(LIB):	.depend $(OBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/xaeniax/Makefile b/board/xaeniax/Makefile
index 7c5f0cd..655dc9a 100644
--- a/board/xaeniax/Makefile
+++ b/board/xaeniax/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= xaeniax.o flash.o
+COBJS	:= xaeniax.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/xilinx/ml300/Makefile b/board/xilinx/ml300/Makefile
index 880c494..4ecf37a 100644
--- a/board/xilinx/ml300/Makefile
+++ b/board/xilinx/ml300/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -19,14 +19,22 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 # MA 02111-1307 USA
+#
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+$(shell mkdir -p $(obj)../xilinx_enet)
+$(shell mkdir -p $(obj)../xilinx_iic)
+endif
 
-CFLAGS   += -I../ml300 -I../common -I../xilinx_enet -I../xilinx_iic
+INCS		:= -I../ml300 -I../common -I../xilinx_enet -I../xilinx_iic
+CFLAGS		+= $(INCS)
+HOST_CFLAGS	+= $(INCS)
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o \
+COBJS	= $(BOARD).o \
 	  serial.o \
 	  ../xilinx_enet/emac_adapter.o  ../xilinx_enet/xemac.o \
 	  ../xilinx_enet/xemac_options.o ../xilinx_enet/xemac_polled.o \
@@ -39,6 +47,10 @@
 
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $^
 
@@ -50,9 +62,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/xm250/Makefile b/board/xm250/Makefile
index 1b0a3f0..22f2024 100644
--- a/board/xm250/Makefile
+++ b/board/xm250/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,13 +23,17 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= xm250.o flash.o
+COBJS	:= xm250.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $^
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
+	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
 	rm -f $(SOBJS) $(OBJS)
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/xpedite1k/Makefile b/board/xpedite1k/Makefile
index c5c0915..5f3e34e 100644
--- a/board/xpedite1k/Makefile
+++ b/board/xpedite1k/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2002-2004
+# (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	= $(BOARD).o
-OBJS +=flash.o
+COBJS	= $(BOARD).o flash.o
 SOBJS	= init.o
 
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
 $(LIB):	$(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS)
 
@@ -40,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/xsengine/Makefile b/board/xsengine/Makefile
index ed1464a..78ca9d6 100644
--- a/board/xsengine/Makefile
+++ b/board/xsengine/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,12 +23,16 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= xsengine.o flash.o
+COBJS	:= xsengine.o flash.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -39,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/zpc1900/Makefile b/board/zpc1900/Makefile
index 8b10993..e880f87 100644
--- a/board/zpc1900/Makefile
+++ b/board/zpc1900/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,11 +23,15 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= $(BOARD).o
+COBJS	:= $(BOARD).o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 clean:
@@ -38,9 +42,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/zylonite/Makefile b/board/zylonite/Makefile
index f3ad674..4b70f70 100644
--- a/board/zylonite/Makefile
+++ b/board/zylonite/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -20,14 +20,19 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 # MA 02111-1307 USA
 #
+
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
-OBJS	:= zylonite.o nand.o
+COBJS	:= zylonite.o nand.o
 SOBJS	:= lowlevel_init.o
 
-$(LIB):	$(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS) $(SOBJS)
 	$(AR) crv $@ $(OBJS) $(SOBJS)
 
 clean:
@@ -38,9 +43,9 @@
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/board/zylonite/config.mk b/board/zylonite/config.mk
index b5d5955..09b0f71 100644
--- a/board/zylonite/config.mk
+++ b/board/zylonite/config.mk
@@ -2,5 +2,3 @@
 #TEXT_BASE = 0xa1700000
 #TEXT_BASE = 0xa3080000
 TEXT_BASE = 0xa3008000
-
-BOARDLIBS = drivers/nand/libnand.a
diff --git a/common/Makefile b/common/Makefile
index eb0b5da..d626fe4 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2004
+# (C) Copyright 2004-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,7 +23,7 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= libcommon.a
+LIB	= $(obj)libcommon.a
 
 AOBJS	=
 
@@ -53,28 +53,29 @@
 	  usb.o usb_kbd.o usb_storage.o \
 	  virtex2.o xilinx.o crc16.o xyzModem.o
 
-OBJS	= $(AOBJS) $(COBJS)
+SRCS	:= $(AOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(AOBJS) $(COBJS))
 
 CPPFLAGS += -I..
 
 all:	$(LIB) $(AOBJS)
 
-$(LIB): .depend $(OBJS)
+$(LIB): $(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
-environment.o: environment.c ../tools/envcrc
+$(obj)environment.o: $(src)environment.c $(obj)../tools/envcrc
 	$(CC) $(AFLAGS) -Wa,--no-warn \
-		-DENV_CRC=$(shell ../tools/envcrc) \
-		-c -o $@ environment.c
+		-DENV_CRC=$(shell $(obj)../tools/envcrc) \
+		-c -o $@ $(src)environment.c
 
-../tools/envcrc:
+$(obj)../tools/envcrc:
 	$(MAKE) -C ../tools
 
 #########################################################################
 
-.depend:	Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/config.mk b/config.mk
index b59667a..3ed7107 100644
--- a/config.mk
+++ b/config.mk
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,6 +23,22 @@
 
 #########################################################################
 
+ifneq ($(OBJTREE),$(SRCTREE))
+ifeq ($(CURDIR),$(SRCTREE))
+dir := 
+else
+dir := $(subst $(SRCTREE)/,,$(CURDIR))
+endif
+
+obj := $(if $(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/)
+src := $(if $(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/)
+
+$(shell mkdir -p $(obj))
+else
+obj :=
+src :=
+endif
+
 # clean the slate ...
 PLATFORM_RELFLAGS =
 PLATFORM_CPPFLAGS =
@@ -124,9 +140,14 @@
 
 CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)		\
 	-D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE)		\
-	-I$(TOPDIR)/include				\
-	-fno-builtin -ffreestanding -nostdinc -isystem	\
-	$(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
+
+ifneq ($(OBJTREE),$(SRCTREE))
+CPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/include
+endif
+
+CPPFLAGS += -I$(TOPDIR)/include
+CPPFLAGS += -fno-builtin -ffreestanding -nostdinc 	\
+	-isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
 
 ifdef BUILD_TAG
 CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes \
@@ -192,11 +213,23 @@
 
 #########################################################################
 
+ifndef REMOTE_BUILD
+
 %.s:	%.S
-	$(CPP) $(AFLAGS) -o $@ $(CURDIR)/$<
+	$(CPP) $(AFLAGS) -o $@ $<
 %.o:	%.S
-	$(CC) $(AFLAGS) -c -o $@ $(CURDIR)/$<
+	$(CC) $(AFLAGS) -c -o $@ $<
 %.o:	%.c
 	$(CC) $(CFLAGS) -c -o $@ $<
+
+else
+
+$(obj)%.s:	%.S
+	$(CPP) $(AFLAGS) -o $@ $<
+$(obj)%.o:	%.S
+	$(CC) $(AFLAGS) -c -o $@ $<
+$(obj)%.o:	%.c
+	$(CC) $(CFLAGS) -c -o $@ $<
+endif
 
 #########################################################################
diff --git a/cpu/74xx_7xx/Makefile b/cpu/74xx_7xx/Makefile
index 0e10d3a..e82fffc 100644
--- a/cpu/74xx_7xx/Makefile
+++ b/cpu/74xx_7xx/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # (C) Copyright 2001
 # Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
 #
@@ -23,22 +26,26 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-ASOBJS	= cache.o kgdb.o io.o
-OBJS	= traps.o cpu.o cpu_init.o speed.o interrupts.o
+SOBJS	= cache.o kgdb.o io.o
+COBJS	= traps.o cpu.o cpu_init.o speed.o interrupts.o
 
-all:	.depend $(START) $(ASOBJS) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
-	$(AR) crv $@ $(ASOBJS) $(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(ASOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/arm1136/Makefile b/cpu/arm1136/Makefile
index 203278e..5d2c7eb 100644
--- a/cpu/arm1136/Makefile
+++ b/cpu/arm1136/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2003
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,21 +23,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-OBJS	= interrupts.o cpu.o
+COBJS	= interrupts.o cpu.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/arm720t/Makefile b/cpu/arm720t/Makefile
index f273d92..539a48c 100644
--- a/cpu/arm720t/Makefile
+++ b/cpu/arm720t/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,21 +23,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-OBJS	= serial.o serial_netarm.o interrupts.o cpu.o
+COBJS	= serial.o serial_netarm.o interrupts.o cpu.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/arm920t/Makefile b/cpu/arm920t/Makefile
index 8f256e9..199fe0c 100644
--- a/cpu/arm920t/Makefile
+++ b/cpu/arm920t/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,21 +23,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-OBJS	= cpu.o interrupts.o
+COBJS	= cpu.o interrupts.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/arm920t/at91rm9200/Makefile b/cpu/arm920t/at91rm9200/Makefile
index aec9cb6..26b0b94 100644
--- a/cpu/arm920t/at91rm9200/Makefile
+++ b/cpu/arm920t/at91rm9200/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2005
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,22 +23,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(SOC).a
+LIB	= $(obj)lib$(SOC).a
 
-OBJS	= bcm5221.o dm9161.o ether.o i2c.o interrupts.o \
+COBJS	= bcm5221.o dm9161.o ether.o i2c.o interrupts.o \
 	  lxt972.o serial.o usb_ohci.o
 SOBJS	= lowlevel_init.o
 
-all:	.depend $(LIB)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $(OBJS) $(SOBJS)
+all:	$(obj).depend $(LIB)
+
+$(LIB):	$(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/arm920t/imx/Makefile b/cpu/arm920t/imx/Makefile
index 8865f82..e238fc0 100644
--- a/cpu/arm920t/imx/Makefile
+++ b/cpu/arm920t/imx/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,20 +23,23 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(SOC).a
+LIB	= $(obj)lib$(SOC).a
 
-OBJS	= generic.o interrupts.o serial.o speed.o
+COBJS	= generic.o interrupts.o serial.o speed.o
 
-all:	.depend $(LIB)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+
+all:	$(obj).depend $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/arm920t/ks8695/Makefile b/cpu/arm920t/ks8695/Makefile
index ac49060..6342435 100644
--- a/cpu/arm920t/ks8695/Makefile
+++ b/cpu/arm920t/ks8695/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2005
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,21 +23,24 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(SOC).a
+LIB	= $(obj)lib$(SOC).a
 
-OBJS	= interrupts.o serial.o
+COBJS	= interrupts.o serial.o
 SOBJS	= lowlevel_init.o
 
-all:	.depend $(LIB)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $(OBJS) $(SOBJS)
+all:	$(obj).depend $(LIB)
+
+$(LIB):	$(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/arm920t/s3c24x0/Makefile b/cpu/arm920t/s3c24x0/Makefile
index af9e4ef..557298e 100644
--- a/cpu/arm920t/s3c24x0/Makefile
+++ b/cpu/arm920t/s3c24x0/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,21 +23,24 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(SOC).a
+LIB	= $(obj)lib$(SOC).a
 
-OBJS	= i2c.o interrupts.o serial.o speed.o \
+COBJS	= i2c.o interrupts.o serial.o speed.o \
 	  usb_ohci.o
 
-all:	.depend $(LIB)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+
+all:	$(obj).depend $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/arm925t/Makefile b/cpu/arm925t/Makefile
index a1db818..086b1a3 100644
--- a/cpu/arm925t/Makefile
+++ b/cpu/arm925t/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2003
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,21 +23,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-OBJS	= interrupts.o cpu.o omap925.o
+COBJS	= interrupts.o cpu.o omap925.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/arm926ejs/Makefile b/cpu/arm926ejs/Makefile
index 060fd20..a410c2f 100644
--- a/cpu/arm926ejs/Makefile
+++ b/cpu/arm926ejs/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2003
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,21 +23,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-OBJS	= interrupts.o cpu.o cpuinfo.o
+COBJS	= interrupts.o cpu.o cpuinfo.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/arm926ejs/omap/Makefile b/cpu/arm926ejs/omap/Makefile
index f9d3378..7eca2f0 100644
--- a/cpu/arm926ejs/omap/Makefile
+++ b/cpu/arm926ejs/omap/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2005
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,21 +23,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(SOC).a
+LIB	= $(obj)lib$(SOC).a
 
-OBJS	= timer.o
+COBJS	= timer.o
 SOBJS	= reset.o
 
-all:	.depend $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+START	:= $(addprefix $(obj),$(START))
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $(OBJS) $(SOBJS)
+all:	$(obj).depend $(LIB)
+
+$(LIB):	$(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/arm926ejs/versatile/Makefile b/cpu/arm926ejs/versatile/Makefile
index f9d3378..7eca2f0 100644
--- a/cpu/arm926ejs/versatile/Makefile
+++ b/cpu/arm926ejs/versatile/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2005
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,21 +23,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(SOC).a
+LIB	= $(obj)lib$(SOC).a
 
-OBJS	= timer.o
+COBJS	= timer.o
 SOBJS	= reset.o
 
-all:	.depend $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+START	:= $(addprefix $(obj),$(START))
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $(OBJS) $(SOBJS)
+all:	$(obj).depend $(LIB)
+
+$(LIB):	$(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/arm946es/Makefile b/cpu/arm946es/Makefile
index 203278e..5d2c7eb 100644
--- a/cpu/arm946es/Makefile
+++ b/cpu/arm946es/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2003
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,21 +23,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-OBJS	= interrupts.o cpu.o
+COBJS	= interrupts.o cpu.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/arm_intcm/Makefile b/cpu/arm_intcm/Makefile
index 203278e..5d2c7eb 100644
--- a/cpu/arm_intcm/Makefile
+++ b/cpu/arm_intcm/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2003
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,21 +23,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-OBJS	= interrupts.o cpu.o
+COBJS	= interrupts.o cpu.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/bf533/Makefile b/cpu/bf533/Makefile
index c63a8f6..a5c48dc 100644
--- a/cpu/bf533/Makefile
+++ b/cpu/bf533/Makefile
@@ -2,7 +2,7 @@
 #
 # Copyright (c) 2005 blackfin.uclinux.org
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -26,21 +26,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o start1.o interrupt.o cache.o cplbhdlr.o cplbmgr.o flush.o
-OBJS	= cpu.o traps.o ints.o serial.o interrupts.o
+COBJS	= cpu.o traps.o ints.o serial.o interrupts.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/i386/Makefile b/cpu/i386/Makefile
index c44412a..cd46dea 100644
--- a/cpu/i386/Makefile
+++ b/cpu/i386/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+# 
 # (C) Copyright 2002
 # Daniel Engström, Omicron Ceti AB, daniel@omicron.se.
 #
@@ -23,22 +26,26 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o start16.o reset.o
 COBJS	= serial.o interrupts.o cpu.o timer.o sc520.o
-AOBJS	= sc520_asm.o
+SOBJS	= sc520_asm.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
 
-$(LIB):	$(COBJS) $(AOBJS)
-	$(AR) crv $@ $(COBJS) $(AOBJS)
+all:	$(obj).depend $(START) $(LIB)
+
+$(LIB):	$(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(COBJS:.o=.c) $(AOBJS:.o=.S)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(COBJS:.o=.c) $(AOBJS:.o=.S) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/ixp/Makefile b/cpu/ixp/Makefile
index ba2e589..2867270 100644
--- a/cpu/ixp/Makefile
+++ b/cpu/ixp/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,21 +23,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-OBJS	= serial.o interrupts.o cpu.o timer.o pci.o
+COBJS	= serial.o interrupts.o cpu.o timer.o pci.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/ixp/npe/Makefile b/cpu/ixp/npe/Makefile
index 937de9d..412b418 100644
--- a/cpu/ixp/npe/Makefile
+++ b/cpu/ixp/npe/Makefile
@@ -23,11 +23,13 @@
 
 include $(TOPDIR)/config.mk
 
-LIB := libnpe.a
+LIB := $(obj)libnpe.a
 
-CFLAGS  += -I$(TOPDIR)/cpu/ixp/npe/include -DCONFIG_IXP425_COMPONENT_ETHDB
+LOCAL_CFLAGS  += -I$(TOPDIR)/cpu/ixp/npe/include -DCONFIG_IXP425_COMPONENT_ETHDB
+CFLAGS  += $(LOCAL_CFLAGS)
+HOST_CFLAGS  += $(LOCAL_CFLAGS)
 
-OBJS := npe.o \
+COBJS := npe.o \
 	miiphy.o \
 	IxOsalBufferMgt.o \
 	IxOsalIoMem.o \
@@ -78,14 +80,21 @@
 	IxNpeMhSolicitedCbMgr.o \
 	IxNpeMhUnsolicitedCbMgr.o
 
+
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
+
 all:	$(LIB)
 
-$(LIB):	$(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/cpu/lh7a40x/Makefile b/cpu/lh7a40x/Makefile
index b45bd6a..2fcafb0 100644
--- a/cpu/lh7a40x/Makefile
+++ b/cpu/lh7a40x/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,21 +23,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-OBJS	= cpu.o speed.o interrupts.o serial.o
+COBJS	= cpu.o speed.o interrupts.o serial.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/mcf52x2/Makefile b/cpu/mcf52x2/Makefile
index 879deb7..a05a803 100644
--- a/cpu/mcf52x2/Makefile
+++ b/cpu/mcf52x2/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -25,21 +25,25 @@
 
 # CFLAGS += -DET_DEBUG
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	=
-OBJS	= serial.o interrupts.o cpu.o speed.o cpu_init.o fec.o
+COBJS	= serial.o interrupts.o cpu.o speed.o cpu_init.o fec.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/microblaze/Makefile b/cpu/microblaze/Makefile
index 610043e..07ed6ce 100644
--- a/cpu/microblaze/Makefile
+++ b/cpu/microblaze/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,21 +23,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-OBJS	= cpu.o interrupts.o
+COBJS	= cpu.o interrupts.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend: Makefile $(START:.o=.S) $(OBJS:.o=.c) $(AOBJS:.o=.S)
-	$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) $(AOBJS:.o=.S) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/mips/Makefile b/cpu/mips/Makefile
index c8b30c7..f9a49df 100644
--- a/cpu/mips/Makefile
+++ b/cpu/mips/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,23 +23,27 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-OBJS	= asc_serial.o au1x00_serial.o au1x00_eth.o au1x00_usb_ohci.o \
+COBJS	= asc_serial.o au1x00_serial.o au1x00_eth.o au1x00_usb_ohci.o \
 	  cpu.o interrupts.o incaip_clock.o
 SOBJS	= incaip_wdt.o cache.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $(OBJS) $(SOBJS)
+all:	$(obj).depend $(START) $(LIB)
+
+$(LIB):	$(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/mpc5xx/Makefile b/cpu/mpc5xx/Makefile
index b787b61..d696e79 100644
--- a/cpu/mpc5xx/Makefile
+++ b/cpu/mpc5xx/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # (C) Copyright 2003
 # Martin Winistoerfer, martinwinistoerfer@gmx.ch.
 #
@@ -32,21 +35,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
-START	= start.S
-OBJS	= serial.o cpu.o cpu_init.o interrupts.o traps.o speed.o spi.o
+START	= start.o
+COBJS	= serial.o cpu.o cpu_init.o interrupts.o traps.o speed.o spi.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S)  $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/mpc5xxx/Makefile b/cpu/mpc5xxx/Makefile
index a97b625..683ded8 100644
--- a/cpu/mpc5xxx/Makefile
+++ b/cpu/mpc5xxx/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,23 +23,27 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-ASOBJS	= io.o firmware_sc_task_bestcomm.impl.o firmware_sc_task.impl.o
-OBJS	= i2c.o traps.o cpu.o cpu_init.o fec.o ide.o interrupts.o \
+SOBJS	= io.o firmware_sc_task_bestcomm.impl.o firmware_sc_task.impl.o
+COBJS	= i2c.o traps.o cpu.o cpu_init.o fec.o ide.o interrupts.o \
 	  loadtask.o pci_mpc5200.o serial.o speed.o usb_ohci.o
 
-all:	.depend $(START) $(ASOBJS) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
-	$(AR) crv $@ $(ASOBJS) $(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(ASOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/mpc8220/Makefile b/cpu/mpc8220/Makefile
index 7c9b6c9..1f2e931 100644
--- a/cpu/mpc8220/Makefile
+++ b/cpu/mpc8220/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,24 +23,28 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-ASOBJS	= io.o fec_dma_tasks.o
-OBJS	= cpu.o cpu_init.o dramSetup.o fec.o i2c.o \
+SOBJS	= io.o fec_dma_tasks.o
+COBJS	= cpu.o cpu_init.o dramSetup.o fec.o i2c.o \
 	  interrupts.o loadtask.o speed.o \
 	  traps.o uart.o pci.o
 
-all:	.depend $(START) $(ASOBJS) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
-	$(AR) crv $@ $(ASOBJS) $(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(ASOBJS:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/mpc824x/Makefile b/cpu/mpc824x/Makefile
index df0d64e..d9fd9bf 100644
--- a/cpu/mpc824x/Makefile
+++ b/cpu/mpc824x/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,26 +22,35 @@
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)drivers/epic)
+$(shell mkdir -p $(obj)drivers/i2c)
+endif
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
-START	= start.S
-OBJS	= traps.o cpu.o cpu_init.o interrupts.o speed.o \
-	  drivers/epic/epic1.o drivers/i2c/i2c.o pci.o bedbug_603e.o
+START	= start.o
+COBJS	= traps.o cpu.o cpu_init.o interrupts.o speed.o \
+	  drivers/epic/epic1.o drivers/i2c/i2c.o pci.o
+COBJS_LN = bedbug_603e.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c) $(addprefix $(obj),$(COBJS_LN:.o=.c))
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS) $(COBJS_LN))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
-bedbug_603e.c:
-	ln -s ../mpc8260/bedbug_603e.c bedbug_603e.c
+$(obj)bedbug_603e.c:
+	ln -s $(src)../mpc8260/bedbug_603e.c $(obj)bedbug_603e.c
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S)  $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/mpc8260/Makefile b/cpu/mpc8260/Makefile
index b4c269f..b1f1c18 100644
--- a/cpu/mpc8260/Makefile
+++ b/cpu/mpc8260/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,23 +23,27 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o kgdb.o
-OBJS	= traps.o serial_smc.o serial_scc.o cpu.o cpu_init.o speed.o \
+COBJS	= traps.o serial_smc.o serial_scc.o cpu.o cpu_init.o speed.o \
 	  interrupts.o ether_scc.o ether_fcc.o i2c.o commproc.o \
 	  bedbug_603e.o pci.o spi.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
-	$(AR) crv $@ $(OBJS) kgdb.o
+	$(AR) crv $@ $(OBJS) $(obj)kgdb.o
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/mpc83xx/Makefile b/cpu/mpc83xx/Makefile
index 60df4cd..f3fa6fd 100644
--- a/cpu/mpc83xx/Makefile
+++ b/cpu/mpc83xx/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+# 
 # Copyright 2004 Freescale Semiconductor, Inc.
 #
 # See file CREDITS for list of people who contributed to this
@@ -22,31 +25,26 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
-START	= start.o \
-	resetvec.o
+START	= start.o resetvec.o
+COBJS	= traps.o cpu.o cpu_init.o speed.o interrupts.o \
+	  i2c.o spd_sdram.o
 
-COBJS	= traps.o \
-	  cpu.o \
-	  cpu_init.o \
-	  speed.o \
-	  interrupts.o \
-	  i2c.o \
-	  spd_sdram.o
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
 
-OBJS	= $(COBJS)
-
-all:	.depend $(START) $(LIB)
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(AOBJS:.o=.S) $(COBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/mpc85xx/Makefile b/cpu/mpc85xx/Makefile
index 5298dc1..bbc5084 100644
--- a/cpu/mpc85xx/Makefile
+++ b/cpu/mpc85xx/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # (C) Copyright 2002,2003 Motorola Inc.
 # Xianghua Xiao,X.Xiao@motorola.com
 #
@@ -23,23 +26,26 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o resetvec.o
 COBJS	= traps.o cpu.o cpu_init.o speed.o interrupts.o \
 	  pci.o serial_scc.o commproc.o ether_fcc.o i2c.o spd_sdram.o
-OBJS	= $(COBJS)
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(AOBJS:.o=.S) $(COBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/mpc8xx/Makefile b/cpu/mpc8xx/Makefile
index de75fad..6451e05 100644
--- a/cpu/mpc8xx/Makefile
+++ b/cpu/mpc8xx/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -25,25 +25,29 @@
 
 # CFLAGS += -DET_DEBUG
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o kgdb.o
-OBJS	= bedbug_860.o commproc.o cpu.o cpu_init.o	\
+COBJS	= bedbug_860.o commproc.o cpu.o cpu_init.o	\
 	  fec.o i2c.o interrupts.o lcd.o scc.o		\
 	  serial.o speed.o spi.o \
 	  traps.o upatch.o video.o
 SOBJS	= plprcr_write.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
 
-$(LIB):	$(OBJS) $(SOBJS)
-	$(AR) crv $@ $(OBJS) $(SOBJS) kgdb.o
+all:	$(obj).depend $(START) $(LIB)
+
+$(LIB):	$(OBJS)
+	$(AR) crv $@ $(OBJS) $(obj)kgdb.o
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c) $(SOBJS:.o=.S)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) $(SOBJS:.o=.S) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/nios/Makefile b/cpu/nios/Makefile
index 7855325..cdab7b0 100644
--- a/cpu/nios/Makefile
+++ b/cpu/nios/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,22 +23,26 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-AOBJS	= traps.o
-OBJS	= cpu.o interrupts.o serial.o asmi.o spi.o
+SOBJS	= traps.o
+COBJS	= cpu.o interrupts.o serial.o asmi.o spi.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
 
-$(LIB):	$(OBJS) $(AOBJS)
-	$(AR) crv $@ $(OBJS) $(AOBJS)
+all:	$(obj).depend $(START) $(LIB)
+
+$(LIB):	$(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend: Makefile $(START:.o=.S) $(OBJS:.o=.c) $(AOBJS:.o=.S)
-	$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) $(AOBJS:.o=.S) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/nios2/Makefile b/cpu/nios2/Makefile
index 11fda50..f903129 100644
--- a/cpu/nios2/Makefile
+++ b/cpu/nios2/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,22 +23,26 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-AOBJS	= exceptions.o
-OBJS	= cpu.o interrupts.o serial.o sysid.o traps.o epcs.o
+SOBJS	= exceptions.o
+COBJS	= cpu.o interrupts.o serial.o sysid.o traps.o epcs.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
 
-$(LIB):	$(OBJS) $(AOBJS)
-	$(AR) crv $@ $(OBJS) $(AOBJS)
+all:	$(obj).depend $(START) $(LIB)
+
+$(LIB):	$(OBJS)
+	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend: Makefile $(START:.o=.S) $(OBJS:.o=.c) $(AOBJS:.o=.S)
-	$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) $(AOBJS:.o=.S) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/ppc4xx/Makefile b/cpu/ppc4xx/Makefile
index 7d6990f..93416b5 100644
--- a/cpu/ppc4xx/Makefile
+++ b/cpu/ppc4xx/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,10 +23,10 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o resetvec.o kgdb.o
-AOBJS	= dcr.o
+SOBJS	= dcr.o
 COBJS	= 405gp_pci.o 4xx_enet.o \
 	  bedbug_405.o commproc.o \
 	  cpu.o cpu_init.o i2c.o interrupts.o \
@@ -34,18 +34,20 @@
 	  spd_sdram.o speed.o traps.o usb_ohci.o usbdev.o \
 	  440spe_pcie.o
 
-OBJS	= $(AOBJS) $(COBJS)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
 
-all:	.depend $(START) $(LIB)
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(AOBJS:.o=.S) $(COBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/pxa/Makefile b/cpu/pxa/Makefile
index 1af53d6..a6f6b59 100644
--- a/cpu/pxa/Makefile
+++ b/cpu/pxa/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,21 +23,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-OBJS	= serial.o interrupts.o cpu.o i2c.o pxafb.o mmc.o
+COBJS	= serial.o interrupts.o cpu.o i2c.o pxafb.o mmc.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/s3c44b0/Makefile b/cpu/s3c44b0/Makefile
index d43c73e..62cb514 100644
--- a/cpu/s3c44b0/Makefile
+++ b/cpu/s3c44b0/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,21 +23,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-OBJS	= serial.o interrupts.o cpu.o
+COBJS	= serial.o interrupts.o cpu.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/cpu/sa1100/Makefile b/cpu/sa1100/Makefile
index 8c950da..62cb514 100644
--- a/cpu/sa1100/Makefile
+++ b/cpu/sa1100/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,21 +23,25 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(CPU).a
+LIB	= $(obj)lib$(CPU).a
 
 START	= start.o
-OBJS	= serial.o interrupts.o cpu.o
+COBJS	= serial.o interrupts.o cpu.o
 
-all:	.depend $(START) $(LIB)
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
 
 $(LIB):	$(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(START:.o=.S) $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/disk/Makefile b/disk/Makefile
index 39677f1..3bdb018 100644
--- a/disk/Makefile
+++ b/disk/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -25,20 +25,23 @@
 
 #CFLAGS += -DET_DEBUG -DDEBUG
 
-LIB	= libdisk.a
+LIB	= $(obj)libdisk.a
 
-OBJS	= part.o part_mac.o part_dos.o part_iso.o part_amiga.o
+COBJS	= part.o part_mac.o part_dos.o part_iso.o part_amiga.o
+
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
 
 all:	$(LIB)
 
-$(LIB):	$(START) $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/drivers/Makefile b/drivers/Makefile
index 9be95c7..d0acf8e 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -25,9 +25,9 @@
 
 # CFLAGS += -DET_DEBUG -DDEBUG
 
-LIB	= libdrivers.a
+LIB	= $(obj)libdrivers.a
 
-OBJS	= 3c589.o 5701rls.o ali512x.o \
+COBJS	= 3c589.o 5701rls.o ali512x.o \
 	  bcm570x.o bcm570x_autoneg.o cfb_console.o cfi_flash.o \
 	  cs8900.o ct69000.o dataflash.o dc2114x.o dm9000x.o \
 	  e1000.o eepro100.o \
@@ -52,16 +52,19 @@
 	  pxa_pcmcia.o mpc8xx_pcmcia.o tqm8xx_pcmcia.o	\
 	  rpx_pcmcia.o
 
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+
 all:	$(LIB)
 
-$(LIB): $(OBJS)
+$(LIB): $(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/drivers/nand/Makefile b/drivers/nand/Makefile
index 96f67df..d707658 100644
--- a/drivers/nand/Makefile
+++ b/drivers/nand/Makefile
@@ -1,16 +1,45 @@
+#
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
 include $(TOPDIR)/config.mk
 
+LIB 	:= $(obj)libnand.a
+
-LIB := libnand.a
+COBJS 	:= nand.o nand_base.o nand_ids.o nand_ecc.o nand_bbt.o
 
-OBJS := nand.o nand_base.o nand_ids.o nand_ecc.o nand_bbt.o
+SRCS 	:= $(COBJS:.o=.c)
+OBJS 	:= $(addprefix $(obj),$(COBJS))
+
 all:	$(LIB)
 
-$(LIB):	$(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/drivers/nand_legacy/Makefile b/drivers/nand_legacy/Makefile
index 7e2cf66..23df5b7 100644
--- a/drivers/nand_legacy/Makefile
+++ b/drivers/nand_legacy/Makefile
@@ -1,16 +1,45 @@
+#
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
 include $(TOPDIR)/config.mk
 
+LIB 	:= $(obj)libnand_legacy.a
+
-LIB := libnand_legacy.a
+COBJS 	:= nand_legacy.o
 
-OBJS := nand_legacy.o
+SRCS 	:= $(COBJS:.o=.c)
+OBJS 	:= $(addprefix $(obj),$(COBJS))
+
 all:	$(LIB)
 
-$(LIB):	$(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/drivers/sk98lin/Makefile b/drivers/sk98lin/Makefile
index 8ee0e21..ac21e02 100644
--- a/drivers/sk98lin/Makefile
+++ b/drivers/sk98lin/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -24,15 +24,19 @@
 #
 # Makefile for the SysKonnect SK-98xx device driver.
 #
+
 include $(TOPDIR)/config.mk
 
-LIB := libsk98lin.a
+LIB	:= $(obj)libsk98lin.a
 
-OBJS :=     skge.o skaddr.o skgehwt.o skgeinit.o skgepnmi.o skgesirq.o \
-	     ski2c.o sklm80.o skqueue.o skrlmt.o sktimer.o skvpd.o \
-	     skxmac2.o skcsum.o #skproc.o
+COBJS	:= skge.o skaddr.o skgehwt.o skgeinit.o skgepnmi.o skgesirq.o \
+		ski2c.o sklm80.o skqueue.o skrlmt.o sktimer.o skvpd.o \
+		skxmac2.o skcsum.o #skproc.o
 
-OBJS +=     uboot_skb.o uboot_drv.o
+COBJS	+= uboot_skb.o uboot_drv.o
+
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
 
 # DBGDEF =  \
 # -DDEBUG
@@ -84,18 +88,20 @@
 EXTRA_CFLAGS += -I. -DSK_USE_CSUM $(DBGDEF)
 
 CFLAGS += $(EXTRA_CFLAGS)
+HOST_CFLAGS += $(EXTRA_CFLAGS)
 
 
 all:	$(LIB)
 
-$(LIB):	$(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
+
diff --git a/dtt/Makefile b/dtt/Makefile
index 0a33478..486008a 100644
--- a/dtt/Makefile
+++ b/dtt/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # (C) Copyright 2001
 # Erik Theisen, Wave 7 Optics, etheisen@mindspring.com.
 #
@@ -25,20 +28,23 @@
 
 #CFLAGS += -DDEBUG
 
-LIB	= libdtt.a
+LIB	= $(obj)libdtt.a
 
-OBJS	= lm75.o ds1621.o adm1021.o
+COBJS	= lm75.o ds1621.o adm1021.o
+
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
 
 all:	$(LIB)
 
-$(LIB):	$(START) $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/examples/Makefile b/examples/Makefile
index a342d75..85118ea 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -104,9 +104,9 @@
 EX_LDFLAGS += -EB
 endif
 
-OBJS	= $(SREC:.srec=.o)
+COBJS	:= $(SREC:.srec=.o)
 
-LIB	= libstubs.a
+LIB	= $(obj)libstubs.a
 LIBAOBJS=
 ifeq ($(ARCH),ppc)
 LIBAOBJS+= $(ARCH)_longjmp.o $(ARCH)_setjmp.o
@@ -115,34 +115,40 @@
 LIBAOBJS+= test_burst_lib.o
 endif
 LIBCOBJS= stubs.o
-LIBOBJS	= $(LIBAOBJS) $(LIBCOBJS)
+
+LIBOBJS	= $(addprefix $(obj),$(LIBAOBJS) $(LIBCOBJS))
+
+SRCS	:= $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(if $(LIBAOBJS),$(LIBAOBJS:.o=.S))
+OBJS	:= $(addprefix $(obj),$(COBJS))
+BIN	:= $(addprefix $(obj),$(BIN))
+SREC	:= $(addprefix $(obj),$(SREC))
 
 gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
 clibdir := $(shell dirname `$(CC) $(CFLAGS) -print-file-name=libc.a`)
 
 CPPFLAGS += -I..
 
-all:	.depend $(OBJS) $(LIB) $(SREC) $(BIN)
+all:	$(obj).depend $(OBJS) $(LIB) $(SREC) $(BIN)
 
 #########################################################################
-$(LIB): .depend $(LIBOBJS)
-	$(AR) crv $@ $(LIBOBJS)
+$(LIB):	$(obj).depend $(LIBOBJS)
+		$(AR) crv $@ $(LIBOBJS)
 
-%:	%.o $(LIB)
-	$(LD) -g $(EX_LDFLAGS) -Ttext $(LOAD_ADDR) \
-		-o $@ -e $(<:.o=) $< $(LIB) \
-		-L$(gcclibdir) -lgcc
-%.srec:	%
-	$(OBJCOPY) -O srec $< $@ 2>/dev/null
+$(obj)%:	$(obj)%.o $(LIB)
+		$(LD) -g $(EX_LDFLAGS) -Ttext $(LOAD_ADDR) \
+			-o $@ -e $(notdir $(<:.o=)) $< $(LIB) \
+			-L$(gcclibdir) -lgcc
+$(obj)%.srec:	$(obj)%
+		$(OBJCOPY) -O srec $< $@ 2>/dev/null
 
-%.bin:	%
-	$(OBJCOPY) -O binary $< $@ 2>/dev/null
+$(obj)%.bin:	$(obj)%
+		$(OBJCOPY) -O binary $< $@ 2>/dev/null
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/fs/Makefile b/fs/Makefile
index 79cbdea..273d90e 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -24,6 +24,6 @@
 
 SUBDIRS	:= jffs2 cramfs fdos fat reiserfs ext2
 
-.depend all:
+$(obj).depend all:
 	@for dir in $(SUBDIRS) ; do \
 		$(MAKE) -C $$dir $@ ; done
diff --git a/fs/cramfs/Makefile b/fs/cramfs/Makefile
index 54a475e..1a6f4b7 100644
--- a/fs/cramfs/Makefile
+++ b/fs/cramfs/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,25 +23,27 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= libcramfs.a
+LIB	= $(obj)libcramfs.a
 
 AOBJS	=
 COBJS	= cramfs.o uncompress.o
-OBJS	= $(AOBJS) $(COBJS)
+
+SRCS	:= $(AOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(AOBJS) $(COBJS))
 
 #CPPFLAGS +=
 
 all:	$(LIB) $(AOBJS)
 
-$(LIB):	.depend $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 
 #########################################################################
 
-.depend:	Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/fs/ext2/Makefile b/fs/ext2/Makefile
index 3b19368..2e420d5 100644
--- a/fs/ext2/Makefile
+++ b/fs/ext2/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # (C) Copyright 2003
 # Pavel Bartusek, Sysgo Real-Time Solutions AG, pba@sysgo.de
 #
@@ -24,25 +27,26 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= libext2fs.a
+LIB	= $(obj)libext2fs.a
 
 AOBJS	=
 COBJS	= ext2fs.o dev.o
-OBJS	= $(AOBJS) $(COBJS)
+
+SRCS	:= $(AOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(AOBJS) $(COBJS))
 
 #CPPFLAGS +=
 
 all:	$(LIB) $(AOBJS)
 
-$(LIB):	.depend $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
-
 #########################################################################
 
-.depend:	Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/fs/fat/Makefile b/fs/fat/Makefile
index e462757..2fa428c 100644
--- a/fs/fat/Makefile
+++ b/fs/fat/Makefile
@@ -19,28 +19,27 @@
 # MA 02111-1307 USA
 #
 
-TOPDIR=../../
-
 include $(TOPDIR)/config.mk
 
-LIB	= libfat.a
+LIB	= $(obj)libfat.a
 
 AOBJS	=
 COBJS	= fat.o file.o
 
-OBJS	= $(AOBJS) $(COBJS)
+SRCS	:= $(AOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(AOBJS) $(COBJS))
 
 all:	$(LIB) $(AOBJS)
 
-$(LIB):	.depend $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 
 #########################################################################
 
-.depend:	Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/fs/fdos/Makefile b/fs/fdos/Makefile
index c25e744..e55ac8a 100644
--- a/fs/fdos/Makefile
+++ b/fs/fdos/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # (C) Copyright 2002
 # Stäubli Faverges - <www.staubli.com>
 # Pierre AUBERT  p.aubert@staubli.com
@@ -25,25 +28,27 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= libfdos.a
+LIB	= $(obj)libfdos.a
 
 AOBJS	=
 COBJS	= fat.o vfat.o dev.o fdos.o fs.o subdir.o
-OBJS	= $(AOBJS) $(COBJS)
+
+SRCS	:= $(AOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(AOBJS) $(COBJS))
 
 #CPPFLAGS +=
 
 all:	$(LIB) $(AOBJS)
 
-$(LIB):	.depend $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 
 #########################################################################
 
-.depend:	Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/fs/jffs2/Makefile b/fs/jffs2/Makefile
index f28b17a..82436bb 100644
--- a/fs/jffs2/Makefile
+++ b/fs/jffs2/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000, 2001
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,26 +23,28 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= libjffs2.a
+LIB	= $(obj)libjffs2.a
 
 AOBJS	=
 COBJS	= jffs2_1pass.o compr_rtime.o compr_rubin.o compr_zlib.o mini_inflate.o
 COBJS	+= compr_lzo.o compr_lzari.o
-OBJS	= $(AOBJS) $(COBJS)
+
+SRCS	:= $(AOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(AOBJS) $(COBJS))
 
 #CPPFLAGS +=
 
 all:	$(LIB) $(AOBJS)
 
-$(LIB):	.depend $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 
 #########################################################################
 
-.depend:	Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/fs/reiserfs/Makefile b/fs/reiserfs/Makefile
index 98a9a8d..45028cb 100644
--- a/fs/reiserfs/Makefile
+++ b/fs/reiserfs/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # (C) Copyright 2003
 # Pavel Bartusek, Sysgo Real-Time Solutions AG, pba@sysgo.de
 #
@@ -24,25 +27,26 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= libreiserfs.a
+LIB	= $(obj)libreiserfs.a
 
 AOBJS	=
 COBJS	= reiserfs.o dev.o mode_string.o
-OBJS	= $(AOBJS) $(COBJS)
+
+SRCS	:= $(AOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(AOBJS) $(COBJS))
 
 #CPPFLAGS +=
 
 all:	$(LIB) $(AOBJS)
 
-$(LIB):	.depend $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
-
 #########################################################################
 
-.depend:	Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/lib_arm/Makefile b/lib_arm/Makefile
index e56e06b..3e0a5c7 100644
--- a/lib_arm/Makefile
+++ b/lib_arm/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2002
+# (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,23 +23,24 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(ARCH).a
+LIB	= $(obj)lib$(ARCH).a
 
-AOBJS	= _ashldi3.o _ashrdi3.o _divsi3.o _modsi3.o _udivsi3.o _umodsi3.o
+SOBJS	= _ashldi3.o _ashrdi3.o _divsi3.o _modsi3.o _udivsi3.o _umodsi3.o
 
 COBJS	= armlinux.o board.o \
 	  cache.o div0.o
 
-OBJS	= $(AOBJS) $(COBJS)
+SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
 
-$(LIB):	.depend $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/lib_blackfin/Makefile b/lib_blackfin/Makefile
index bc280d0..549c8c1 100644
--- a/lib_blackfin/Makefile
+++ b/lib_blackfin/Makefile
@@ -3,7 +3,7 @@
 #
 # Copyright (c) 2005 blackfin.uclinux.org
 #
-# (C) Copyright 2000-2004
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -27,21 +27,23 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(ARCH).a
+LIB	= $(obj)lib$(ARCH).a
 
-AOBJS	=
+SOBJS	=
 
 COBJS	= board.o bf533_linux.o bf533_string.o cache.o muldi3.o
-OBJS	= $(AOBJS) $(COBJS)
 
-$(LIB):	.depend $(OBJS)
+SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/lib_generic/Makefile b/lib_generic/Makefile
index 18c41b1..fcd43c6 100644
--- a/lib_generic/Makefile
+++ b/lib_generic/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2002
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,21 +23,24 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= libgeneric.a
+LIB	= $(obj)libgeneric.a
 
-OBJS	= bzlib.o bzlib_crctable.o bzlib_decompress.o \
+COBJS	= bzlib.o bzlib_crctable.o bzlib_decompress.o \
 	  bzlib_randtable.o bzlib_huffman.o \
 	  crc32.o ctype.o display_options.o ldiv.o \
 	  string.o vsprintf.o zlib.o
+	  
+SRCS 	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
 
-$(LIB):	.depend $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/lib_i386/Makefile b/lib_i386/Makefile
index e5925e5..8dc809e 100644
--- a/lib_i386/Makefile
+++ b/lib_i386/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2002
+# (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,23 +23,24 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(ARCH).a
+LIB	= $(obj)lib$(ARCH).a
 
-AOBJS	= bios.o bios_pci.o realmode_switch.o
+SOBJS	= bios.o bios_pci.o realmode_switch.o
 
 COBJS	= board.o bios_setup.o i386_linux.o zimage.o realmode.o \
 	  pci_type1.o pci.o video_bios.o video.o
 
-OBJS	= $(AOBJS) $(COBJS)
+SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
 
-$(LIB):	.depend $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/lib_m68k/Makefile b/lib_m68k/Makefile
index 698da36..f9e8398 100644
--- a/lib_m68k/Makefile
+++ b/lib_m68k/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,20 +23,23 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(ARCH).a
+LIB	= $(obj)lib$(ARCH).a
 
-AOBJS	=
+SOBJS	=
+
 COBJS	= cache.o traps.o time.o board.o m68k_linux.o
-OBJS	= $(AOBJS) $(COBJS)
 
-$(LIB):	.depend $(OBJS)
+SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/lib_microblaze/Makefile b/lib_microblaze/Makefile
index ec01722f..35de97f 100644
--- a/lib_microblaze/Makefile
+++ b/lib_microblaze/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003-2004
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,22 +23,23 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(ARCH).a
+LIB	= $(obj)lib$(ARCH).a
 
-AOBJS	=
+SOBJS	=
 
 COBJS	= board.o microblaze_linux.o time.o cache.o
 
-OBJS	= $(AOBJS) $(COBJS)
+SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
 
-$(LIB):	.depend $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/lib_mips/Makefile b/lib_mips/Makefile
index d5980e6..e2ac999 100644
--- a/lib_mips/Makefile
+++ b/lib_mips/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,22 +23,23 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(ARCH).a
+LIB	= $(obj)lib$(ARCH).a
 
-AOBJS	=
+SOBJS	=
 
 COBJS	= board.o time.o mips_linux.o
 
-OBJS	= $(AOBJS) $(COBJS)
+SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
 
-$(LIB):	.depend $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/lib_nios/Makefile b/lib_nios/Makefile
index eff46db..ad4c6c4 100644
--- a/lib_nios/Makefile
+++ b/lib_nios/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,22 +23,23 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(ARCH).a
+LIB	= $(obj)lib$(ARCH).a
 
-AOBJS	=
+SOBJS	=
 
 COBJS	= board.o cache.o divmod.o nios_linux.o mult.o time.o
 
-OBJS	= $(AOBJS) $(COBJS)
+SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
 
-$(LIB):	.depend $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/lib_nios2/Makefile b/lib_nios2/Makefile
index 44b893c..1c2ac72 100644
--- a/lib_nios2/Makefile
+++ b/lib_nios2/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,22 +23,23 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(ARCH).a
+LIB	= $(obj)lib$(ARCH).a
 
-AOBJS	= cache.o
+SOBJS	= cache.o
 
 COBJS	= board.o divmod.o nios_linux.o mult.o time.o
 
-OBJS	= $(AOBJS) $(COBJS)
+SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
 
-$(LIB):	.depend $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/lib_ppc/Makefile b/lib_ppc/Makefile
index 652a419..bae8cbc 100644
--- a/lib_ppc/Makefile
+++ b/lib_ppc/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,23 +23,24 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(ARCH).a
+LIB	= $(obj)lib$(ARCH).a
 
-AOBJS	= ppcstring.o ticks.o
+SOBJS	= ppcstring.o ticks.o
 
 COBJS	= board.o \
 	  bat_rw.o cache.o extable.o kgdb.o time.o interrupts.o
 
-OBJS	= $(AOBJS) $(COBJS)
+SRCS 	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
 
-$(LIB):	.depend $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/mkconfig b/mkconfig
index 4fe6e44..c3e4cea 100755
--- a/mkconfig
+++ b/mkconfig
@@ -5,7 +5,7 @@
 #
 # Parameters:  Target  Architecture  CPU  Board [VENDOR] [SOC]
 #
-# (C) 2002 DENX Software Engineering, Wolfgang Denk <wd@denx.de>
+# (C) 2002-2006 DENX Software Engineering, Wolfgang Denk <wd@denx.de>
 #
 
 APPEND=no	# Default: Create new config file
@@ -27,24 +27,38 @@
 
 echo "Configuring for ${BOARD_NAME} board..."
 
-cd ./include
-
 #
 # Create link to architecture specific headers
 #
-rm -f asm
-ln -s asm-$2 asm
+if [ "$SRCTREE" != "$OBJTREE" ] ; then
+	mkdir -p ${OBJTREE}/include
+	mkdir -p ${OBJTREE}/include2
+	cd ${OBJTREE}/include2
+	rm -f asm
+	ln -s ${SRCTREE}/include/asm-$2 asm
+	LNPREFIX="../../include2/asm/"
+	cd ../include
+	rm -rf asm-$2
+	rm -f asm
+	mkdir asm-$2
+	ln -s asm-$2 asm
+else
+	cd ./include
+	rm -f asm
+	ln -s asm-$2 asm
+fi
+
 rm -f asm-$2/arch
 
 if [ -z "$6" -o "$6" = "NULL" ] ; then
-	ln -s arch-$3 asm-$2/arch
+	ln -s ${LNPREFIX}arch-$3 asm-$2/arch
 else
-	ln -s arch-$6 asm-$2/arch
+	ln -s ${LNPREFIX}arch-$6 asm-$2/arch
 fi
 
 if [ "$2" = "arm" ] ; then
 	rm -f asm-$2/proc
-	ln -s proc-armv asm-$2/proc
+	ln -s ${LNPREFIX}proc-armv asm-$2/proc
 fi
 
 #
diff --git a/net/Makefile b/net/Makefile
index 7a70489..6fe4002 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -25,19 +25,23 @@
 
 # CFLAGS += -DET_DEBUG -DDEBUG
 
-LIB	= libnet.a
+LIB	= $(obj)libnet.a
 
-OBJS	= net.o tftp.o bootp.o rarp.o eth.o nfs.o sntp.o
+COBJS	= net.o tftp.o bootp.o rarp.o eth.o nfs.o sntp.o
+
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+
 all:	$(LIB)
 
-$(LIB):	$(START) $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/post/Makefile b/post/Makefile
index 4ee429d..228bafc 100644
--- a/post/Makefile
+++ b/post/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2002
+# (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
diff --git a/post/cpu/Makefile b/post/cpu/Makefile
index 43fc044..645e838 100644
--- a/post/cpu/Makefile
+++ b/post/cpu/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2002
+# (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
diff --git a/post/rules.mk b/post/rules.mk
index 1ad6959..a2f33ad 100644
--- a/post/rules.mk
+++ b/post/rules.mk
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2002
+# (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -23,20 +23,22 @@
 
 include $(TOPDIR)/config.mk
 
-OBJS	= $(AOBJS) $(COBJS)
+SRCS 	:= $(AOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(AOBJS) $(COBJS))
+LIB	:= $(obj)$(LIB)
 
 CPPFLAGS += -I$(TOPDIR)
 
 all:	$(LIB)
 
-$(LIB):	.depend $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend: Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
-	$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > .depend
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/rtc/Makefile b/rtc/Makefile
index 2c5d099..ca5b66b 100644
--- a/rtc/Makefile
+++ b/rtc/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2001-2004
+# (C) Copyright 2001-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -25,24 +25,27 @@
 
 #CFLAGS += -DDEBUG
 
-LIB	= librtc.a
+LIB	= $(obj)librtc.a
 
-OBJS	= date.o   \
+COBJS	= date.o   \
 	  bf533_rtc.o ds12887.o ds1302.o ds1306.o ds1307.o \
 	  ds1337.o ds1374.o ds1556.o ds164x.o ds174x.o \
 	  m41t11.o max6900.o m48t35ax.o mc146818.o mk48t59.o \
 	  mpc5xxx.o mpc8xx.o pcf8563.o s3c24x0_rtc.o rs5c372.o
 
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+
 all:	$(LIB)
 
-$(LIB):	$(START) $(OBJS)
+$(LIB):	$(obj).depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/rules.mk b/rules.mk
new file mode 100644
index 0000000..a77451b
--- /dev/null
+++ b/rules.mk
@@ -0,0 +1,35 @@
+#
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+#########################################################################
+
+_depend:	$(obj).depend
+
+$(obj).depend:	$(src)Makefile $(TOPDIR)/config.mk $(SRCS)
+		@rm -f $@
+		@for f in $(SRCS); do \
+			g=`basename $$f | sed -e 's/\(.*\)\.\w/\1.o/'`; \
+			$(CC) -M $(HOST_CFLAGS) $(CPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \
+		done
+
+#########################################################################
diff --git a/tools/Makefile b/tools/Makefile
index d3dcc7d..606f024 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2003
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -21,22 +21,23 @@
 # MA 02111-1307 USA
 #
 
-BINS	= img2srec$(SFX) mkimage$(SFX) envcrc$(SFX) gen_eth_addr$(SFX) bmp_logo$(SFX)
+BIN_FILES	= img2srec$(SFX) mkimage$(SFX) envcrc$(SFX) gen_eth_addr$(SFX) bmp_logo$(SFX)
 
-OBJS	= environment.o img2srec.o mkimage.o crc32.o envcrc.o gen_eth_addr.o bmp_logo.o
+OBJ_LINKS	= environment.o crc32.o
+OBJ_FILES	= img2srec.o mkimage.o envcrc.o gen_eth_addr.o bmp_logo.o
 
 ifeq ($(ARCH),mips)
-BINS   += inca-swap-bytes$(SFX)
-OBJS   += inca-swap-bytes.o
+BIN_FILES	+= inca-swap-bytes$(SFX)
+OBJ_FILES	+= inca-swap-bytes.o
 endif
 
 # Don't build by default
 #ifeq ($(ARCH),ppc)
-#BINS   += mpc86x_clk$(SFX)
-#OBJS   += mpc86x_clk.o
+#BIN_FILES		+= mpc86x_clk$(SFX)
+#OBJ_FILES	+= mpc86x_clk.o
 #endif
 
-LOGO_H	= $(TOPDIR)/include/bmp_logo.h
+LOGO_H	= $(OBJTREE)/include/bmp_logo.h
 
 ifeq ($(LOGO_BMP),)
 LOGO_BMP= logos/denx.bmp
@@ -106,69 +107,76 @@
 #
 include $(TOPDIR)/config.mk
 
+# now $(obj) is defined
+SRCS	:= $(addprefix $(obj),$(OBJ_LINKS:.o=.c)) $(OBJ_FILES:.o=.c) 
+BINS	:= $(addprefix $(obj),$(BIN_FILES))
+
 #
 # Use native tools and options
 #
-CPPFLAGS   = -idirafter ../include -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC
+CPPFLAGS   = -idirafter $(SRCTREE)/include \
+		-idirafter $(OBJTREE)/include2 \
+		-idirafter $(OBJTREE)/include \
+		-DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC
 CFLAGS     = $(HOST_CFLAGS) $(CPPFLAGS) -O
 AFLAGS	   = -D__ASSEMBLY__ $(CPPFLAGS)
 CC	   = $(HOSTCC)
 STRIP	   = $(HOSTSTRIP)
 MAKEDEPEND = makedepend
 
-all:	.depend $(BINS) $(LOGO_H) subdirs
+all:	$(obj).depend $(BINS) $(LOGO_H) subdirs
 
-envcrc$(SFX):	envcrc.o crc32.o environment.o
+$(obj)envcrc$(SFX):	$(obj)envcrc.o $(obj)crc32.o $(obj)environment.o
 		$(CC) $(CFLAGS) -o $@ $^
 
-img2srec$(SFX):	img2srec.o
+$(obj)img2srec$(SFX):	$(obj)img2srec.o
 		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
 		$(STRIP) $@
 
-mkimage$(SFX):	mkimage.o crc32.o
+$(obj)mkimage$(SFX):	$(obj)mkimage.o $(obj)crc32.o
 		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
 		$(STRIP) $@
 
-ncb$(SFX):	ncb.o
+$(obj)ncb$(SFX):	$(obj)ncb.o
 		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
 		$(STRIP) $@
 
-gen_eth_addr$(SFX):	gen_eth_addr.o
+$(obj)gen_eth_addr$(SFX):	$(obj)gen_eth_addr.o
 		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
 		$(STRIP) $@
 
-bmp_logo$(SFX):	bmp_logo.o
+$(obj)bmp_logo$(SFX):	$(obj)bmp_logo.o
 		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
 		$(STRIP) $@
 
-inca-swap-bytes$(SFX):	inca-swap-bytes.o
+$(obj)inca-swap-bytes$(SFX):	$(obj)inca-swap-bytes.o
 		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
 		$(STRIP) $@
 
-mpc86x_clk$(SFX):	mpc86x_clk.o
+$(obj)mpc86x_clk$(SFX):	$(obj)mpc86x_clk.o
 		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
 		$(STRIP) $@
 
-envcrc.o:	envcrc.c
-		$(CC) -g $(CFLAGS) -c $<
+$(obj)envcrc.o:	$(src)envcrc.c
+		$(CC) -g $(CFLAGS) -c -o $@ $<
 
-crc32.o:	crc32.c
-		$(CC) -g $(CFLAGS) -c $<
+$(obj)crc32.o:	$(obj)crc32.c
+		$(CC) -g $(CFLAGS) -c -o $@ $<
 
-mkimage.o:	mkimage.c
-		$(CC) -g $(CFLAGS) -c $<
+$(obj)mkimage.o:	$(src)mkimage.c
+		$(CC) -g $(CFLAGS) -c -o $@ $<
 
-ncb.o:		ncb.c
-		$(CC) -g $(CFLAGS) -c $<
+$(obj)ncb.o:		$(src)ncb.c
+		$(CC) -g $(CFLAGS) -c -o $@ $<
 
-gen_eth_addr.o:	gen_eth_addr.c
-		$(CC) -g $(CFLAGS) -c $<
+$(obj)gen_eth_addr.o:	$(src)gen_eth_addr.c
+		$(CC) -g $(CFLAGS) -c -o $@ $<
 
-inca-swap-bytes.o:	inca-swap-bytes.c
-		$(CC) -g $(CFLAGS) -c $<
+$(obj)inca-swap-bytes.o:	$(src)inca-swap-bytes.c
+		$(CC) -g $(CFLAGS) -c -o $@ $<
 
-mpc86x_clk.o:	mpc86x_clk.c
-		$(CC) -g $(CFLAGS) -c $<
+$(obj)mpc86x_clk.o:	$(src)mpc86x_clk.c
+		$(CC) -g $(CFLAGS) -c -o $@ $<
 
 subdirs:
 ifeq ($(TOOLSUBDIRS),)
@@ -184,25 +192,25 @@
 		done
 endif
 
-environment.c:
-		@rm -f environment.c
-		ln -s ../common/environment.c environment.c
+$(obj)environment.c:
+		@rm -f $(obj)environment.c
+		ln -s $(src)../common/environment.c $(obj)environment.c
 
-environment.o: environment.c
-		$(CC) -g $(HOST_ENVIRO_CFLAGS) $(CPPFLAGS) -c $<
+$(obj)environment.o:	$(obj)environment.c
+		$(CC) -g $(HOST_ENVIRO_CFLAGS) $(CPPFLAGS) -c -o $@ $<
 
-crc32.c:
-		@rm -f crc32.c
-		ln -s ../lib_generic/crc32.c crc32.c
+$(obj)crc32.c:
+		@rm -f $(obj)crc32.c
+		ln -s $(src)../lib_generic/crc32.c $(obj)crc32.c
 
-$(LOGO_H):	bmp_logo $(LOGO_BMP)
-		./bmp_logo $(LOGO_BMP) >$@
+$(LOGO_H):	$(obj)bmp_logo $(LOGO_BMP)
+		$(obj)./bmp_logo $(LOGO_BMP) >$@
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(HOST_CFLAGS) $(CPPFLAGS) $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/tools/env/Makefile b/tools/env/Makefile
index 9ce477c..1f16768 100644
--- a/tools/env/Makefile
+++ b/tools/env/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2002
+# (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -21,25 +21,28 @@
 # MA 02111-1307 USA
 #
 
-SOURCES := crc32.c  fw_env.c  fw_env_main.c
-HEADERS := fw_env.h
+include $(TOPDIR)/config.mk
 
-all:	fw_printenv
+SRCS	:= $(obj)crc32.c  fw_env.c  fw_env_main.c
+HEADERS	:= fw_env.h
 
-fw_printenv:	$(SOURCES) $(HEADERS)
-	$(CROSS_COMPILE)gcc -Wall -DUSE_HOSTCC $(SOURCES) -o fw_printenv
+CPPFLAGS := -Wall -DUSE_HOSTCC
+
+all:	$(obj)fw_printenv
+
+$(obj)fw_printenv:	$(SRCS) $(HEADERS)
+	$(CROSS_COMPILE)gcc $(CPPFLAGS) $(SRCS) -o $(obj)fw_printenv
 
 clean:
-	rm -f fw_printenv crc32.c
+	rm -f $(obj)fw_printenv $(obj)crc32.c
 
-crc32.c:
-	ln -s ../../lib_generic/crc32.c crc32.c
+$(obj)crc32.c:
+	ln -s $(src)../../lib_generic/crc32.c $(obj)crc32.c
 
 #########################################################################
 
-.depend:	Makefile $(SOURCES)
-		$(CC) -M $(HOST_CFLAGS) $(CPPFLAGS) -DUSE_HOSTCC $(SOURCES) > $@
+include $(TOPDIR)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################
diff --git a/tools/gdb/Makefile b/tools/gdb/Makefile
index e7618b7..dbcb91f 100644
--- a/tools/gdb/Makefile
+++ b/tools/gdb/Makefile
@@ -1,4 +1,7 @@
 #
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
 # (C) Copyright 2000
 # Murray Jensen <Murray.Jensen@csiro.au>
 #
@@ -25,7 +28,11 @@
 
 BINS	= gdbsend gdbcont
 
-OBJS	= gdbsend.o gdbcont.o error.o remote.o serial.o
+COBJS	= gdbsend.o gdbcont.o error.o remote.o serial.o
+
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SRCS	:= $(COBJS:.o=.c) 
+BINS	:= $(addprefix $(obj),$(BINS))
 
 #
 # Use native tools and options
@@ -44,26 +51,26 @@
 
 else	# ! CYGWIN
 
-all:	$(BINS)
+all:	$(obj).depend $(BINS)
 
-gdbsend:	gdbsend.o error.o remote.o serial.o
+$(obj)gdbsend:	$(obj)gdbsend.o $(obj)error.o $(obj)remote.o $(obj)serial.o
 		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
 
-gdbcont:	gdbcont.o error.o remote.o serial.o
+$(obj)gdbcont:	$(obj)gdbcont.o $(obj)error.o $(obj)remote.o $(obj)serial.o
 		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
 
 clean:
 	rm -f $(OBJS)
 
 distclean:	clean
-	rm -f $(BINS) core *.bak .depend
+	rm -f $(BINS) $(obj)core $(obj)*.bak $(obj).depend
 
 #########################################################################
 
-.depend:	Makefile $(OBJS:.o=.c)
-		$(CC) -M $(CPPFLAGS) -I../include $(OBJS:.o=.c) > $@
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
--include .depend
+sinclude $(obj).depend
 
 #########################################################################
 
diff --git a/tools/updater/Makefile b/tools/updater/Makefile
index 3fa1912..e9684cb4 100644
--- a/tools/updater/Makefile
+++ b/tools/updater/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -25,62 +25,81 @@
 
 include $(TOPDIR)/config.mk
 
-PROG    = updater
-IMAGE   = updater.image
-SRC     = update.c flash.c flash_hw.c utils.c cmd_flash.c string.c ctype.c dummy.c
-ASRC    = ppcstring.S
-OBJS	= $(SRC:.c=.o) $(ASRC:.S=.o)
+PROG		= $(obj)updater
+IMAGE		= $(obj)updater.image
 
-LIB	= $(TOPDIR)/examples/libstubs.a
-LIBAOBJS=
-LIBCOBJS= $(TOPDIR)/examples/stubs.o
-LIBOBJS	= $(LIBAOBJS) $(LIBCOBJS)
+COBJS		= update.o flash.o flash_hw.o utils.o cmd_flash.o string.o ctype.o dummy.o
+COBJS_LINKS	= stubs.o
+AOBJS		= ppcstring.o
+AOBJS_LINKS	= memio.o
+
+OBJS	:= $(addprefix $(obj),$(COBJS) $(COBJS_LINKS) $(AOBJS) $(AOBJS_LINKS))
+SRCS	:= $(COBJS:.o=.c) $(AOBJS:.o=.S) $(addprefix $(obj), $(COBJS_LINKS:.o:.c) $(AOBJS_LINKS:.o:.S))
 
 CPPFLAGS += -I$(TOPDIR) -I$(TOPDIR)/board/MAI/AmigaOneG3SE
 CFLAGS   += -I$(TOPDIR)/board/MAI/AmigaOneG3SE
+AFLAGS   += -I$(TOPDIR)/board/MAI/AmigaOneG3SE
+
+DEPS = $(OBJTREE)/u-boot.bin $(OBJTREE)/tools/mkimage
+ifneq ($(DEPS),$(wildcard $(DEPS)))
+$(error "updater: Missing required objects, please run regular build first")
+endif
 
-all:	.depend $(LIB) $(PROG)
+all:	$(obj).depend $(PROG) $(IMAGE)
 
 #########################################################################
-$(LIB): .depend $(LIBOBJS)
-	$(AR) crv $@ $(LIBOBJS)
 
-%.srec:	%.o $(LIB)
+$(obj)%.srec:	%.o $(LIB)
 	$(LD) -g -Ttext $(LOAD_ADDR) -o $(<:.o=) -e $(<:.o=) $< $(LIB)
 	$(OBJCOPY) -O srec $(<:.o=) $@
 
+$(obj)%.o: %.c
+	$(CC) $(CFLAGS) -c -o $@ $<
+
+$(obj)%.o: %.S
+	$(CC) $(AFLAGS) -c -o $@ $<
+
-%.o: %.c
-	$(CC) $(CPPFLAGS) -c $<
+$(obj)memio.o: $(obj)memio.S
+	$(CC) $(AFLAGS) -c -o $@ $<
 
-%.o: %.S
-	$(CC) $(CPPFLAGS) -c $<
+$(obj)memio.S:
+	rm -f $(obj)memio.c
+	ln -s $(SRCTREE)/board/MAI/AmigaOneG3SE/memio.S $(obj)memio.S
+
+$(obj)stubs.o: $(obj)stubs.c
+	$(CC) $(CFLAGS) -c -o $@ $<
+
+$(obj)stubs.c:
+	rm -f $(obj)stubs.c
+	ln -s $(SRCTREE)/examples/stubs.c $(obj)stubs.c
 
 #########################################################################
 
-updater: $(OBJS) $(LIB) $(TOPDIR)/board/MAI/AmigaOneG3SE/memio.o
-	$(LD) -g -Ttext $(LOAD_ADDR) -o updater -e _main $(OBJS) $(LIB)  \
-	$(TOPDIR)/board/MAI/AmigaOneG3SE/memio.o
-	$(OBJCOPY) -O binary updater updater.bin
+$(obj)updater: $(OBJS)
+	$(LD) -g -Ttext $(LOAD_ADDR) -o $(obj)updater -e _main $(OBJS)
+	$(OBJCOPY) -O binary $(obj)updater $(obj)updater.bin
 
-updater.image: updater $(TOPDIR)/u-boot.bin
-	cat >/tmp/tempimage updater.bin junk $(TOPDIR)/u-boot.bin
-	$(TOPDIR)/tools/mkimage -A ppc -O u-boot -T standalone -C none -a $(LOAD_ADDR) \
-	-e `ppc-elf32-nm updater | grep _main | cut --bytes=0-8` \
-	-n "Firmware Updater" -d /tmp/tempimage updater.image
+$(obj)updater.image: $(obj)updater $(OBJTREE)/u-boot.bin
+	cat >/tmp/tempimage $(obj)updater.bin junk $(OBJTREE)/u-boot.bin
+	$(OBJTREE)/tools/mkimage -A ppc -O u-boot -T standalone -C none -a $(LOAD_ADDR) \
+	-e `$(NM) $(obj)updater | grep _main | cut --bytes=0-8` \
+	-n "Firmware Updater" -d /tmp/tempimage $(obj)updater.image
 	rm /tmp/tempimage
-	cp updater.image /tftpboot
+	cp $(obj)updater.image /tftpboot
 
-updater.image2: updater $(TOPDIR)/u-boot.bin
-	cat >/tmp/tempimage updater.bin junk ../../create_image/image
-	$(TOPDIR)/tools/mkimage -A ppc -O u-boot -T standalone -C none -a $(LOAD_ADDR) \
-	-e `ppc-elf32-nm updater | grep _main | cut --bytes=0-8` \
-	-n "Firmware Updater" -d /tmp/tempimage updater.image
+(obj)updater.image2: $(obj)updater $(OBJTREE)/u-boot.bin
+	cat >/tmp/tempimage $(obj)updater.bin junk ../../create_image/image
+	$(OBJTREE)/tools/mkimage -A ppc -O u-boot -T standalone -C none -a $(LOAD_ADDR) \
+	-e `$(NM) $(obj)updater | grep _main | cut --bytes=0-8` \
+	-n "Firmware Updater" -d /tmp/tempimage $(obj)updater.image
 	rm /tmp/tempimage
-	cp updater.image /tftpboot
+	cp $(obj)updater.image /tftpboot
 
-.depend:	Makefile $(SRC) $(ASRC) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
-		$(CC) -M $(CFLAGS) $(SRC) $(ASRC) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S) > $@
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
 
-sinclude .depend
+sinclude $(obj).depend
 
 #########################################################################