1*e2211743Swdenk# 2*e2211743Swdenk# (C) Copyright 2000 3*e2211743Swdenk# Wolfgang Denk, DENX Software Engineering, wd@denx.de. 4*e2211743Swdenk# 5*e2211743Swdenk# See file CREDITS for list of people who contributed to this 6*e2211743Swdenk# project. 7*e2211743Swdenk# 8*e2211743Swdenk# This program is free software; you can redistribute it and/or 9*e2211743Swdenk# modify it under the terms of the GNU General Public License as 10*e2211743Swdenk# published by the Free Software Foundation; either version 2 of 11*e2211743Swdenk# the License, or (at your option) any later version. 12*e2211743Swdenk# 13*e2211743Swdenk# This program is distributed in the hope that it will be useful, 14*e2211743Swdenk# but WITHOUT ANY WARRANTY; without even the implied warranty of 15*e2211743Swdenk# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16*e2211743Swdenk# GNU General Public License for more details. 17*e2211743Swdenk# 18*e2211743Swdenk# You should have received a copy of the GNU General Public License 19*e2211743Swdenk# along with this program; if not, write to the Free Software 20*e2211743Swdenk# Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21*e2211743Swdenk# MA 02111-1307 USA 22*e2211743Swdenk# 23*e2211743Swdenk 24*e2211743Swdenk######################################################################### 25*e2211743Swdenk 26*e2211743Swdenk# 27*e2211743Swdenk# When cross-compiling on NetBSD, we have to define __PPC__ or else we 28*e2211743Swdenk# will pick up a va_list declaration that is incompatible with the 29*e2211743Swdenk# actual argument lists emitted by the compiler. 30*e2211743Swdenk# 31*e2211743Swdenk# [Tested on NetBSD/i386 1.5 + cross-powerpc-netbsd-1.3] 32*e2211743Swdenk 33*e2211743Swdenkifeq ($(ARCH),ppc) 34*e2211743Swdenkifeq ($(CROSS_COMPILE),powerpc-netbsd-) 35*e2211743SwdenkPLATFORM_CPPFLAGS+= -D__PPC__ 36*e2211743Swdenkendif 37*e2211743Swdenkifeq ($(CROSS_COMPILE),powerpc-openbsd-) 38*e2211743SwdenkPLATFORM_CPPFLAGS+= -D__PPC__ 39*e2211743Swdenkendif 40*e2211743Swdenkendif 41*e2211743Swdenk 42*e2211743Swdenkifeq ($(ARCH),arm) 43*e2211743Swdenkifeq ($(CROSS_COMPILE),powerpc-netbsd-) 44*e2211743SwdenkPLATFORM_CPPFLAGS+= -D__ARM__ 45*e2211743Swdenkendif 46*e2211743Swdenkifeq ($(CROSS_COMPILE),powerpc-openbsd-) 47*e2211743SwdenkPLATFORM_CPPFLAGS+= -D__ARM__ 48*e2211743Swdenkendif 49*e2211743Swdenkendif 50*e2211743Swdenk 51*e2211743Swdenkifdef ARCH 52*e2211743Swdenksinclude $(TOPDIR)/$(ARCH)_config.mk # include architecture dependend rules 53*e2211743Swdenkendif 54*e2211743Swdenkifdef CPU 55*e2211743Swdenksinclude $(TOPDIR)/cpu/$(CPU)/config.mk # include CPU specific rules 56*e2211743Swdenkendif 57*e2211743Swdenkifdef VENDOR 58*e2211743SwdenkBOARDDIR = $(VENDOR)/$(BOARD) 59*e2211743Swdenkelse 60*e2211743SwdenkBOARDDIR = $(BOARD) 61*e2211743Swdenkendif 62*e2211743Swdenkifdef BOARD 63*e2211743Swdenksinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk # include board specific rules 64*e2211743Swdenkendif 65*e2211743Swdenk 66*e2211743Swdenk######################################################################### 67*e2211743Swdenk 68*e2211743SwdenkCONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ 69*e2211743Swdenk else if [ -x /bin/bash ]; then echo /bin/bash; \ 70*e2211743Swdenk else echo sh; fi ; fi) 71*e2211743Swdenk 72*e2211743Swdenkifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc) 73*e2211743SwdenkHOSTCC = cc 74*e2211743Swdenkelse 75*e2211743SwdenkHOSTCC = gcc 76*e2211743Swdenkendif 77*e2211743SwdenkHOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer 78*e2211743SwdenkHOSTSTRIP = strip 79*e2211743Swdenk 80*e2211743Swdenk######################################################################### 81*e2211743Swdenk 82*e2211743Swdenk# 83*e2211743Swdenk# Include the make variables (CC, etc...) 84*e2211743Swdenk# 85*e2211743SwdenkAS = $(CROSS_COMPILE)as 86*e2211743SwdenkLD = $(CROSS_COMPILE)ld 87*e2211743SwdenkCC = $(CROSS_COMPILE)gcc 88*e2211743SwdenkCPP = $(CC) -E 89*e2211743SwdenkAR = $(CROSS_COMPILE)ar 90*e2211743SwdenkNM = $(CROSS_COMPILE)nm 91*e2211743SwdenkSTRIP = $(CROSS_COMPILE)strip 92*e2211743SwdenkOBJCOPY = $(CROSS_COMPILE)objcopy 93*e2211743SwdenkOBJDUMP = $(CROSS_COMPILE)objdump 94*e2211743SwdenkRANLIB = $(CROSS_COMPILE)RANLIB 95*e2211743Swdenk 96*e2211743SwdenkRELFLAGS= $(PLATFORM_RELFLAGS) 97*e2211743SwdenkDBGFLAGS= -g #-DDEBUG 98*e2211743SwdenkOPTFLAGS= -Os #-fomit-frame-pointer 99*e2211743Swdenk#LDSCRIPT := board/$(BOARDDIR)/u-boot.lds.debug 100*e2211743SwdenkLDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds 101*e2211743SwdenkOBJCFLAGS := --gap-fill=0xff 102*e2211743Swdenk 103*e2211743SwdenkCPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \ 104*e2211743Swdenk -D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE) \ 105*e2211743Swdenk -I$(TOPDIR)/include \ 106*e2211743Swdenk -fno-builtin \ 107*e2211743Swdenk -pipe $(PLATFORM_CPPFLAGS) 108*e2211743Swdenk 109*e2211743Swdenkifdef BUILD_TAG 110*e2211743SwdenkCFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes \ 111*e2211743Swdenk -DBUILD_TAG='"$(BUILD_TAG)"' 112*e2211743Swdenkelse 113*e2211743SwdenkCFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes 114*e2211743Swdenkendif 115*e2211743Swdenk 116*e2211743SwdenkAFLAGS_DEBUG := -Wa,-gstabs 117*e2211743SwdenkAFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS) 118*e2211743Swdenk 119*e2211743SwdenkLDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) 120*e2211743Swdenk 121*e2211743Swdenk# Location of a usable BFD library, where we define "usable" as 122*e2211743Swdenk# "built for ${HOST}, supports ${TARGET}". Sensible values are 123*e2211743Swdenk# - When cross-compiling: the root of the cross-environment 124*e2211743Swdenk# - Linux/ppc (native): /usr 125*e2211743Swdenk# - NetBSD/ppc (native): you lose ... (must extract these from the 126*e2211743Swdenk# binutils build directory, plus the native and U-Boot include 127*e2211743Swdenk# files don't like each other) 128*e2211743Swdenk# 129*e2211743Swdenk# So far, this is used only by tools/gdb/Makefile. 130*e2211743Swdenk 131*e2211743Swdenkifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc) 132*e2211743SwdenkBFD_ROOT_DIR = /usr/local/tools 133*e2211743Swdenkelse 134*e2211743Swdenk#BFD_ROOT_DIR = /LinuxPPC/CDK # Linux/i386 135*e2211743Swdenk#BFD_ROOT_DIR = /usr/pkg/cross # NetBSD/i386 136*e2211743Swdenk#BFD_ROOT_DIR = /usr # native 137*e2211743SwdenkBFD_ROOT_DIR = /opt/powerpc 138*e2211743Swdenkendif 139*e2211743Swdenk 140*e2211743Swdenk######################################################################### 141*e2211743Swdenk 142*e2211743Swdenkexport CONFIG_SHELL HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE \ 143*e2211743Swdenk AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP \ 144*e2211743Swdenk MAKE 145*e2211743Swdenkexport TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS 146*e2211743Swdenk 147*e2211743Swdenk######################################################################### 148*e2211743Swdenk 149*e2211743Swdenk%.s: %.S 150*e2211743Swdenk $(CPP) $(AFLAGS) -o $@ $(CURDIR)/$< 151*e2211743Swdenk%.o: %.S 152*e2211743Swdenk $(CC) $(AFLAGS) -c -o $@ $(CURDIR)/$< 153*e2211743Swdenk%.o: %.c 154*e2211743Swdenk $(CC) $(CFLAGS) -c -o $@ $< 155*e2211743Swdenk 156*e2211743Swdenk######################################################################### 157