Merge branch 'master' of git://www.denx.de/git/u-boot-ppc4xx
diff --git a/Makefile b/Makefile
index 6783fec..6548f8e 100644
--- a/Makefile
+++ b/Makefile
@@ -424,13 +424,19 @@
 # This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
 # the dep file is only include in this top level makefile to determine when
 # to regenerate the autoconf.mk file.
-$(obj)include/autoconf.mk: $(obj)include/config.h
-	@$(XECHO) Generating include/autoconf.mk ; \
+$(obj)include/autoconf.mk.dep: $(obj)include/config.h include/common.h
+	@$(XECHO) Generating $@ ; \
 	set -e ; \
 	: Generate the dependancies ; \
-	$(CC) -x c -M $(HOST_CFLAGS) $(CPPFLAGS) -MQ $@ include/common.h > $@.dep ; \
+	$(CC) -x c -DDO_DEPS_ONLY -M $(HOST_CFLAGS) $(CPPFLAGS) \
+		-MQ $(obj)include/autoconf.mk include/common.h > $@
+
+$(obj)include/autoconf.mk: $(obj)include/config.h
+	@$(XECHO) Generating $@ ; \
+	set -e ; \
 	: Extract the config macros ; \
-	$(CPP) $(CFLAGS) -dM include/common.h | sed -n -f tools/scripts/define2mk.sed > $@
+	$(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h | \
+		sed -n -f tools/scripts/define2mk.sed > $@
 
 sinclude $(obj)include/autoconf.mk.dep
 
diff --git a/api/api.c b/api/api.c
index 1ee7c68..19c7154 100644
--- a/api/api.c
+++ b/api/api.c
@@ -30,6 +30,7 @@
 #include <command.h>
 #include <common.h>
 #include <malloc.h>
+#include <environment.h>
 #include <linux/types.h>
 #include <api_public.h>
 
@@ -40,8 +41,6 @@
 
 /* U-Boot routines needed */
 extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern uchar (*env_get_char)(int);
-extern uchar *env_get_addr(int);
 
 /*****************************************************************************
  *
diff --git a/board/BuS/EB+MCF-EV123/config.mk b/board/BuS/EB+MCF-EV123/config.mk
index 9fe2fc5..f03e396 100644
--- a/board/BuS/EB+MCF-EV123/config.mk
+++ b/board/BuS/EB+MCF-EV123/config.mk
@@ -22,7 +22,7 @@
 # MA 02111-1307 USA
 #
 
-sinclude $(TOPDIR)/board/$(BOARDDIR)/textbase.mk
+sinclude $(OBJTREE)/board/$(BOARDDIR)/textbase.mk
 ifndef TEXT_BASE
 TEXT_BASE = 0xFE000000
 endif
diff --git a/board/esd/mecp5200/config.mk b/board/esd/mecp5200/config.mk
index 07b5de1..170779d 100644
--- a/board/esd/mecp5200/config.mk
+++ b/board/esd/mecp5200/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/linkstation/Makefile b/board/linkstation/Makefile
index 57c84de..8d92d8a 100644
--- a/board/linkstation/Makefile
+++ b/board/linkstation/Makefile
@@ -23,18 +23,21 @@
 
 include $(TOPDIR)/config.mk
 
-LIB	= lib$(BOARD).a
+LIB	= $(obj)lib$(BOARD).a
 
 OBJS	= $(BOARD).o ide.o hwctl.o avr.o
 
-$(LIB):	.depend $(OBJS) $(SOBJS)
-	$(AR) crv $@ $(OBJS) $(SOBJS)
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(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/linkstation/config.mk b/board/linkstation/config.mk
index bdf611d..d048290 100644
--- a/board/linkstation/config.mk
+++ b/board/linkstation/config.mk
@@ -35,7 +35,7 @@
 #       0x07F00000   boot from RAM
 #
 
-sinclude $(TOPDIR)/board/$(BOARDDIR)/config.tmp
+sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp
 
 ifndef TEXT_BASE
 # For flash image - all models
diff --git a/board/munices/config.mk b/board/munices/config.mk
index d226244..1b573bc 100644
--- a/board/munices/config.mk
+++ b/board/munices/config.mk
@@ -29,7 +29,7 @@
 #	0xFFF00000   boot high (standard configuration)
 #
 
-sinclude $(TOPDIR)/board/$(BOARDDIR)/config.tmp
+sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp
 
 ifndef TEXT_BASE
 TEXT_BASE = 0xFFF00000
diff --git a/board/v38b/config.mk b/board/v38b/config.mk
index 75577fc..bc55fc7 100644
--- a/board/v38b/config.mk
+++ b/board/v38b/config.mk
@@ -25,7 +25,7 @@
 # MarelV38B board
 #
 
-sinclude $(TOPDIR)/board/$(BOARDDIR)/config.tmp
+sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp
 
 TEXT_BASE = 0xFF000000
 
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index cab727f..9c5d1fc 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -68,19 +68,6 @@
 /************************************************************************
 ************************************************************************/
 
-/* Function that returns a character from the environment */
-extern uchar (*env_get_char)(int);
-
-/* Function that returns a pointer to a value from the environment */
-/* (Only memory version supported / needed). */
-extern uchar *env_get_addr(int);
-
-/* Function that updates CRC of the enironment */
-extern void env_crc_update (void);
-
-/************************************************************************
-************************************************************************/
-
 /*
  * Table with supported baudrates (defined in config_xyz.h)
  */
diff --git a/common/env_eeprom.c b/common/env_eeprom.c
index 2adc129..9e1a201 100644
--- a/common/env_eeprom.c
+++ b/common/env_eeprom.c
@@ -38,10 +38,6 @@
 
 char * env_name_spec = "EEPROM";
 
-extern uchar (*env_get_char)(int);
-extern uchar env_get_char_memory (int index);
-
-
 uchar env_get_char_spec (int index)
 {
 	uchar c;
diff --git a/common/env_nvram.c b/common/env_nvram.c
index 7c18896..fa77719 100644
--- a/common/env_nvram.c
+++ b/common/env_nvram.c
@@ -63,9 +63,6 @@
 extern uchar default_environment[];
 extern int default_environment_size;
 
-extern uchar (*env_get_char)(int);
-extern uchar env_get_char_memory (int index);
-
 #ifdef CONFIG_AMIGAONEG3SE
 uchar env_get_char_spec (int index)
 {
diff --git a/common/ft_build.c b/common/ft_build.c
index 0e5699a..b951178 100644
--- a/common/ft_build.c
+++ b/common/ft_build.c
@@ -396,9 +396,6 @@
 
 /********************************************************************/
 
-/* Function that returns a character from the environment */
-extern uchar(*env_get_char) (int);
-
 void ft_setup(void *blob, bd_t * bd, ulong initrd_start, ulong initrd_end)
 {
 	u32 *p;
diff --git a/include/environment.h b/include/environment.h
index c4f7c33..946a393 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -107,4 +107,14 @@
 	unsigned char	data[ENV_SIZE]; /* Environment data		*/
 } env_t;
 
+/* Function that returns a character from the environment */
+unsigned char (*env_get_char)(int);
+
+/* Function that returns a pointer to a value from the environment */
+unsigned char *env_get_addr(int);
+unsigned char env_get_char_memory (int index);
+
+/* Function that updates CRC of the enironment */
+void env_crc_update (void);
+
 #endif	/* _ENVIRONMENT_H_ */
diff --git a/include/version.h b/include/version.h
index b56d2e9..a34291a 100644
--- a/include/version.h
+++ b/include/version.h
@@ -24,6 +24,8 @@
 #ifndef	__VERSION_H__
 #define	__VERSION_H__
 
+#ifndef DO_DEPS_ONLY
 #include "version_autogenerated.h"
+#endif
 
 #endif	/* __VERSION_H__ */