Merge branch 'master' of git://git.denx.de/u-boot-sh
[platform/kernel/u-boot.git] / config.mk
index 75bbac5..b1254e9 100644 (file)
--- 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
 
 #########################################################################
 
+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 =
 PLATFORM_LDFLAGS =
 
+#########################################################################
+
+ifeq ($(HOSTOS),darwin)
+HOSTCC         = cc
+else
+HOSTCC         = gcc
+endif
+HOSTCFLAGS     = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
+HOSTSTRIP      = strip
+
+#########################################################################
 #
-# When cross-compiling on NetBSD, we have to define __PPC__ or else we
-# will pick up a va_list declaration that is incompatible with the
-# actual argument lists emitted by the compiler.
+# Option checker (courtesy linux kernel) to ensure
+# only supported compiler options are used
 #
-# [Tested on NetBSD/i386 1.5 + cross-powerpc-netbsd-1.3]
+cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
+               > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
 
-ifeq ($(ARCH),ppc)
-ifeq ($(CROSS_COMPILE),powerpc-netbsd-)
-PLATFORM_CPPFLAGS+= -D__PPC__
-endif
-ifeq ($(CROSS_COMPILE),powerpc-openbsd-)
-PLATFORM_CPPFLAGS+= -D__PPC__
-endif
-endif
+#
+# Include the make variables (CC, etc...)
+#
+AS     = $(CROSS_COMPILE)as
+LD     = $(CROSS_COMPILE)ld
+CC     = $(CROSS_COMPILE)gcc
+CPP    = $(CC) -E
+AR     = $(CROSS_COMPILE)ar
+NM     = $(CROSS_COMPILE)nm
+LDR    = $(CROSS_COMPILE)ldr
+STRIP  = $(CROSS_COMPILE)strip
+OBJCOPY = $(CROSS_COMPILE)objcopy
+OBJDUMP = $(CROSS_COMPILE)objdump
+RANLIB = $(CROSS_COMPILE)RANLIB
 
-ifeq ($(ARCH),arm)
-ifeq ($(CROSS_COMPILE),powerpc-netbsd-)
-PLATFORM_CPPFLAGS+= -D__ARM__
-endif
-ifeq ($(CROSS_COMPILE),powerpc-openbsd-)
-PLATFORM_CPPFLAGS+= -D__ARM__
-endif
-endif
+#########################################################################
+
+# Load generated board configuration
+sinclude $(OBJTREE)/include/autoconf.mk
 
 ifdef  ARCH
 sinclude $(TOPDIR)/$(ARCH)_config.mk   # include architecture dependend rules
@@ -73,50 +102,39 @@ endif
 
 #########################################################################
 
-CONFIG_SHELL   := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
-                   else if [ -x /bin/bash ]; then echo /bin/bash; \
-                   else echo sh; fi ; fi)
-
-ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
-HOSTCC         = cc
+ifneq (,$(findstring s,$(MAKEFLAGS)))
+ARFLAGS = cr
 else
-HOSTCC         = gcc
+ARFLAGS = crv
 endif
-HOSTCFLAGS     = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
-HOSTSTRIP      = strip
-
-#########################################################################
-
-#
-# Include the make variables (CC, etc...)
-#
-AS     = $(CROSS_COMPILE)as
-LD     = $(CROSS_COMPILE)ld
-CC     = $(CROSS_COMPILE)gcc
-CPP    = $(CC) -E
-AR     = $(CROSS_COMPILE)ar
-NM     = $(CROSS_COMPILE)nm
-STRIP  = $(CROSS_COMPILE)strip
-OBJCOPY = $(CROSS_COMPILE)objcopy
-OBJDUMP = $(CROSS_COMPILE)objdump
-RANLIB = $(CROSS_COMPILE)RANLIB
-
 RELFLAGS= $(PLATFORM_RELFLAGS)
-DBGFLAGS= -g #-DDEBUG
+DBGFLAGS= -g # -DDEBUG
 OPTFLAGS= -Os #-fomit-frame-pointer
 ifndef LDSCRIPT
 #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
+ifeq ($(CONFIG_NAND_U_BOOT),y)
+LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
+else
 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
 endif
+endif
 OBJCFLAGS += --gap-fill=0xff
 
 gccincdir := $(shell $(CC) -print-file-name=include)
 
 CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)                \
-       -D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE)           \
-       -I$(TOPDIR)/include                             \
-       -fno-builtin -ffreestanding -nostdinc -isystem  \
-       $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
+       -D__KERNEL__
+ifneq ($(TEXT_BASE),)
+CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE)
+endif
+
+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 \
@@ -125,6 +143,8 @@ else
 CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes
 endif
 
+CFLAGS += $(call cc-option,-fno-stack-protector)
+
 # avoid trigraph warnings while parsing pci.h (produced by NIOS gcc-2.9)
 # this option have to be placed behind -Wall -- that's why it is here
 ifeq ($(ARCH),nios)
@@ -133,10 +153,23 @@ CFLAGS := $(CPPFLAGS) -Wall -Wno-trigraphs
 endif
 endif
 
-AFLAGS_DEBUG := -Wa,-gstabs
+# $(CPPFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
+# option to the assembler.
+AFLAGS_DEBUG :=
+
+# turn jbsr into jsr for m68k
+ifeq ($(ARCH),m68k)
+ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
+AFLAGS_DEBUG := -Wa,-gstabs,-S
+endif
+endif
+
 AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
 
-LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS)
+LDFLAGS += -Bstatic -T $(LDSCRIPT) $(PLATFORM_LDFLAGS)
+ifneq ($(TEXT_BASE),)
+LDFLAGS += -Ttext $(TEXT_BASE)
+endif
 
 # Location of a usable BFD library, where we define "usable" as
 # "built for ${HOST}, supports ${TARGET}".  Sensible values are
@@ -148,7 +181,7 @@ LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS)
 #
 # So far, this is used only by tools/gdb/Makefile.
 
-ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
+ifeq ($(HOSTOS),darwin)
 BFD_ROOT_DIR =         /usr/local/tools
 else
 ifeq ($(HOSTARCH),$(ARCH))
@@ -161,20 +194,35 @@ BFD_ROOT_DIR =            /opt/powerpc
 endif
 endif
 
+ifeq ($(PCI_CLOCK),PCI_66M)
+CFLAGS := $(CFLAGS) -DPCI_66M
+endif
+
 #########################################################################
 
-export CONFIG_SHELL HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE \
-       AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP \
-       MAKE
+export HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE \
+       AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP MAKE
 export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
 
 #########################################################################
 
+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
+
 #########################################################################