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