#
# (C) Copyright 2000-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
#
#########################################################################
i f n e q ( $( OBJTREE ) , $( SRCTREE ) )
i f e q ( $( CURDIR ) , $( SRCTREE ) )
dir :=
e l s e
dir := $( subst $( SRCTREE) /,,$( CURDIR) )
e n d i f
obj := $( if $( dir) ,$( OBJTREE) /$( dir) /,$( OBJTREE) /)
src := $( if $( dir) ,$( SRCTREE) /$( dir) /,$( SRCTREE) /)
$( shell mkdir -p $ ( obj ) )
e l s e
obj :=
src :=
e n d i f
# clean the slate ...
PLATFORM_RELFLAGS =
PLATFORM_CPPFLAGS =
PLATFORM_LDFLAGS =
#
# 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.
#
# [Tested on NetBSD/i386 1.5 + cross-powerpc-netbsd-1.3]
i f e q ( $( ARCH ) , p p c )
i f e q ( $( CROSS_COMPILE ) , p o w e r p c - n e t b s d - )
PLATFORM_CPPFLAGS += -D__PPC__
e n d i f
i f e q ( $( CROSS_COMPILE ) , p o w e r p c - o p e n b s d - )
PLATFORM_CPPFLAGS += -D__PPC__
e n d i f
e n d i f
i f e q ( $( ARCH ) , a r m )
i f e q ( $( CROSS_COMPILE ) , p o w e r p c - n e t b s d - )
PLATFORM_CPPFLAGS += -D__ARM__
e n d i f
i f e q ( $( CROSS_COMPILE ) , p o w e r p c - o p e n b s d - )
PLATFORM_CPPFLAGS += -D__ARM__
e n d i f
e n d i f
#########################################################################
CONFIG_SHELL := $( shell if [ -x " $$ BASH " ] ; then echo $$ BASH; \
else if [ -x /bin/bash ] ; then echo /bin/bash; \
else echo sh; fi ; fi )
i f e q ( $( HOSTOS ) - $( HOSTARCH ) , d a r w i n - p p c )
HOSTCC = cc
e l s e
HOSTCC = gcc
e n d i f
HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
HOSTSTRIP = strip
#########################################################################
#
# Option checker (courtesy linux kernel) to ensure
# only supported compiler options are used
#
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 ; )
#
# 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
#########################################################################
# Load generated board configuration
s i n c l u d e $( OBJTREE ) / i n c l u d e / a u t o c o n f . m k
i f d e f A R C H
s i n c l u d e $( TOPDIR ) / $( ARCH ) _ c o n f i g . m k # include architecture dependend rules
e n d i f
i f d e f C P U
s i n c l u d e $( TOPDIR ) / c p u / $( CPU ) / c o n f i g . m k # include CPU specific rules
e n d i f
i f d e f S O C
s i n c l u d e $( TOPDIR ) / c p u / $( CPU ) / $( SOC ) / c o n f i g . m k # include SoC specific rules
e n d i f
i f d e f V E N D O R
BOARDDIR = $( VENDOR) /$( BOARD)
e l s e
BOARDDIR = $( BOARD)
e n d i f
i f d e f B O A R D
s i n c l u d e $( TOPDIR ) / b o a r d / $( BOARDDIR ) / c o n f i g . m k # include board specific rules
e n d i f
#########################################################################
i f n e q ( , $( findstring s ,$ ( MAKEFLAGS ) ) )
ARFLAGS = cr
e l s e
ARFLAGS = crv
e n d i f
RELFLAGS = $( PLATFORM_RELFLAGS)
DBGFLAGS = -g # -DDEBUG
OPTFLAGS = -Os #-fomit-frame-pointer
i f n d e f L D S C R I P T
#LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
i f e q ( $( CONFIG_NAND_U_BOOT ) , y )
LDSCRIPT := $( TOPDIR) /board/$( BOARDDIR) /u-boot-nand.lds
e l s e
LDSCRIPT := $( TOPDIR) /board/$( BOARDDIR) /u-boot.lds
e n d i f
e n d i f
OBJCFLAGS += --gap-fill= 0xff
gccincdir := $( shell $( CC) -print-file-name= include)
CPPFLAGS := $( DBGFLAGS) $( OPTFLAGS) $( RELFLAGS) \
-D__KERNEL__
i f n e q ( $( TEXT_BASE ) , )
CPPFLAGS += -DTEXT_BASE= $( TEXT_BASE)
e n d i f
i f n e q ( $( OBJTREE ) , $( SRCTREE ) )
CPPFLAGS += -I$( OBJTREE) /include2 -I$( OBJTREE) /include
e n d i f
CPPFLAGS += -I$( TOPDIR) /include
CPPFLAGS += -fno-builtin -ffreestanding -nostdinc \
-isystem $( gccincdir) -pipe $( PLATFORM_CPPFLAGS)
i f d e f B U I L D _ T A G
CFLAGS := $( CPPFLAGS) -Wall -Wstrict-prototypes \
-DBUILD_TAG= '"$(BUILD_TAG)"'
e l s e
CFLAGS := $( CPPFLAGS) -Wall -Wstrict-prototypes
e n d i f
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
i f e q ( $( ARCH ) , n i o s )
i f e q ( $( findstring 2.9,$ ( shell $ ( CC ) --version ) ) , 2 . 9 )
CFLAGS := $( CPPFLAGS) -Wall -Wno-trigraphs
e n d i f
e n d i f
# $(CPPFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
# option to the assembler.
AFLAGS_DEBUG :=
# turn jbsr into jsr for m68k
i f e q ( $( ARCH ) , m 6 8 k )
i f e q ( $( findstring 3.4,$ ( shell $ ( CC ) --version ) ) , 3 . 4 )
AFLAGS_DEBUG := -Wa,-gstabs,-S
e n d i f
e n d i f
AFLAGS := $( AFLAGS_DEBUG) -D__ASSEMBLY__ $( CPPFLAGS)
LDFLAGS += -Bstatic -T $( LDSCRIPT) $( PLATFORM_LDFLAGS)
i f n e q ( $( TEXT_BASE ) , )
LDFLAGS += -Ttext $( TEXT_BASE)
e n d i f
# Location of a usable BFD library, where we define "usable" as
# "built for ${HOST}, supports ${TARGET}". Sensible values are
# - When cross-compiling: the root of the cross-environment
# - Linux/ppc (native): /usr
# - NetBSD/ppc (native): you lose ... (must extract these from the
# binutils build directory, plus the native and U-Boot include
# files don't like each other)
#
# So far, this is used only by tools/gdb/Makefile.
i f e q ( $( HOSTOS ) - $( HOSTARCH ) , d a r w i n - p p c )
BFD_ROOT_DIR = /usr/local/tools
e l s e
i f e q ( $( HOSTARCH ) , $( ARCH ) )
# native
BFD_ROOT_DIR = /usr
e l s e
#BFD_ROOT_DIR = /LinuxPPC/CDK # Linux/i386
#BFD_ROOT_DIR = /usr/pkg/cross # NetBSD/i386
BFD_ROOT_DIR = /opt/powerpc
e n d i f
e n d i f
i f e q ( $( PCI_CLOCK ) , P C I _ 6 6 M )
CFLAGS := $( CFLAGS) -DPCI_66M
e n d i f
#########################################################################
export C O N F I G _ S H E L L H P A T H H O S T C C H O S T C F L A G S C R O S S _ C O M P I L E \
AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP \
MAKE
export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
#########################################################################
i f n d e f R E M O T E _ B U I L D
%.s : %.S
$( CPP) $( AFLAGS) -o $@ $<
%.o : %.S
$( CC) $( AFLAGS) -c -o $@ $<
%.o : %.c
$( CC) $( CFLAGS) -c -o $@ $<
e l s e
$(obj)%.s : %.S
$( CPP) $( AFLAGS) -o $@ $<
$(obj)%.o : %.S
$( CC) $( AFLAGS) -c -o $@ $<
$(obj)%.o : %.c
$( CC) $( CFLAGS) -c -o $@ $<
e n d i f
#########################################################################