xref: /openbmc/u-boot/Makefile (revision b3141fdb9f07449307683103e5e5004053211704)
17ebf7443Swdenk#
244b333efSChander Kashyap# (C) Copyright 2000-2012
37ebf7443Swdenk# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
47ebf7443Swdenk#
57ebf7443Swdenk# See file CREDITS for list of people who contributed to this
67ebf7443Swdenk# project.
77ebf7443Swdenk#
87ebf7443Swdenk# This program is free software; you can redistribute it and/or
97ebf7443Swdenk# modify it under the terms of the GNU General Public License as
1045a212c4SWolfgang Denk# published by the Free Software Foundatio; either version 2 of
117ebf7443Swdenk# the License, or (at your option) any later version.
127ebf7443Swdenk#
137ebf7443Swdenk# This program is distributed in the hope that it will be useful,
147ebf7443Swdenk# but WITHOUT ANY WARRANTY; without even the implied warranty of
157ebf7443Swdenk# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
167ebf7443Swdenk# GNU General Public License for more details.
177ebf7443Swdenk#
187ebf7443Swdenk# You should have received a copy of the GNU General Public License
197ebf7443Swdenk# along with this program; if not, write to the Free Software
207ebf7443Swdenk# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
217ebf7443Swdenk# MA 02111-1307 USA
227ebf7443Swdenk#
237ebf7443Swdenk
243ae7b240STom RiniVERSION = 2013
253ae7b240STom RiniPATCHLEVEL = 01
26a6e8dcafSWolfgang DenkSUBLEVEL =
27a6e8dcafSWolfgang DenkEXTRAVERSION = -rc1
288b9e4787SWolfgang Denkifneq "$(SUBLEVEL)" ""
29881a87ecSWolfgang DenkU_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
308b9e4787SWolfgang Denkelse
318b9e4787SWolfgang DenkU_BOOT_VERSION = $(VERSION).$(PATCHLEVEL)$(EXTRAVERSION)
328b9e4787SWolfgang Denkendif
33efb2172eSSimon GlassTIMESTAMP_FILE = $(obj)include/generated/timestamp_autogenerated.h
34efb2172eSSimon GlassVERSION_FILE = $(obj)include/generated/version_autogenerated.h
35881a87ecSWolfgang Denk
367ebf7443SwdenkHOSTARCH := $(shell uname -m | \
37fea25720SGraeme Russ	sed -e s/i.86/x86/ \
387ebf7443Swdenk	    -e s/sun4u/sparc64/ \
397ebf7443Swdenk	    -e s/arm.*/arm/ \
407ebf7443Swdenk	    -e s/sa110/arm/ \
41d0179083SKumar Gala	    -e s/ppc64/powerpc/ \
42d0179083SKumar Gala	    -e s/ppc/powerpc/ \
438d1f6355SNobuhiro Iwamatsu	    -e s/macppc/powerpc/\
448d1f6355SNobuhiro Iwamatsu	    -e s/sh.*/sh/)
457ebf7443Swdenk
46f9d77ed3SWolfgang DenkHOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
477ebf7443Swdenk	    sed -e 's/\(cygwin\).*/cygwin/')
487ebf7443Swdenk
49cf7a7b99SPeter Tyser# Set shell to bash if possible, otherwise fall back to sh
50cf7a7b99SPeter TyserSHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
51cf7a7b99SPeter Tyser	else if [ -x /bin/bash ]; then echo /bin/bash; \
52cf7a7b99SPeter Tyser	else echo sh; fi; fi)
53cf7a7b99SPeter Tyser
54cf7a7b99SPeter Tyserexport	HOSTARCH HOSTOS SHELL
557ebf7443Swdenk
567ebf7443Swdenk# Deal with colliding definitions from tcsh etc.
577ebf7443SwdenkVENDOR=
587ebf7443Swdenk
597ebf7443Swdenk#########################################################################
60ae6d1056SWolfgang Denk# Allow for silent builds
61ae6d1056SWolfgang Denkifeq (,$(findstring s,$(MAKEFLAGS)))
62ae6d1056SWolfgang DenkXECHO = echo
63ae6d1056SWolfgang Denkelse
64ae6d1056SWolfgang DenkXECHO = :
65ae6d1056SWolfgang Denkendif
66ae6d1056SWolfgang Denk
67ae6d1056SWolfgang Denk#########################################################################
68f9328639SMarian Balakowicz#
69f9328639SMarian Balakowicz# U-boot build supports producing a object files to the separate external
70f9328639SMarian Balakowicz# directory. Two use cases are supported:
71f9328639SMarian Balakowicz#
72f9328639SMarian Balakowicz# 1) Add O= to the make command line
73f9328639SMarian Balakowicz# 'make O=/tmp/build all'
74f9328639SMarian Balakowicz#
75f9328639SMarian Balakowicz# 2) Set environement variable BUILD_DIR to point to the desired location
76f9328639SMarian Balakowicz# 'export BUILD_DIR=/tmp/build'
77f9328639SMarian Balakowicz# 'make'
78f9328639SMarian Balakowicz#
79f9328639SMarian Balakowicz# The second approach can also be used with a MAKEALL script
80f9328639SMarian Balakowicz# 'export BUILD_DIR=/tmp/build'
81f9328639SMarian Balakowicz# './MAKEALL'
82f9328639SMarian Balakowicz#
83f9328639SMarian Balakowicz# Command line 'O=' setting overrides BUILD_DIR environent variable.
84f9328639SMarian Balakowicz#
85f9328639SMarian Balakowicz# When none of the above methods is used the local build is performed and
86f9328639SMarian Balakowicz# the object files are placed in the source directory.
87f9328639SMarian Balakowicz#
887ebf7443Swdenk
89f9328639SMarian Balakowiczifdef O
90f9328639SMarian Balakowiczifeq ("$(origin O)", "command line")
91f9328639SMarian BalakowiczBUILD_DIR := $(O)
92f9328639SMarian Balakowiczendif
93f9328639SMarian Balakowiczendif
947ebf7443Swdenk
954ab64933SKim Phillips# Call a source code checker (by default, "sparse") as part of the
964ab64933SKim Phillips# C compilation.
974ab64933SKim Phillips#
984ab64933SKim Phillips# Use 'make C=1' to enable checking of re-compiled files.
994ab64933SKim Phillips#
1004ab64933SKim Phillips# See the linux kernel file "Documentation/sparse.txt" for more details,
1014ab64933SKim Phillips# including where to get the "sparse" utility.
1024ab64933SKim Phillips
1034ab64933SKim Phillipsifdef C
1044ab64933SKim Phillipsifeq ("$(origin C)", "command line")
1054ab64933SKim PhillipsCHECKSRC := $(C)
1064ab64933SKim Phillipsendif
1074ab64933SKim Phillipsendif
1084ab64933SKim Phillipsifndef CHECKSRC
1094ab64933SKim Phillips  CHECKSRC = 0
1104ab64933SKim Phillipsendif
1114ab64933SKim Phillipsexport CHECKSRC
1124ab64933SKim Phillips
113f9328639SMarian Balakowiczifneq ($(BUILD_DIR),)
114f9328639SMarian Balakowiczsaved-output := $(BUILD_DIR)
1154f0645ebSMarian Balakowicz
1164f0645ebSMarian Balakowicz# Attempt to create a output directory.
1174f0645ebSMarian Balakowicz$(shell [ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR})
1184f0645ebSMarian Balakowicz
1194f0645ebSMarian Balakowicz# Verify if it was successful.
120f9328639SMarian BalakowiczBUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd)
121f9328639SMarian Balakowicz$(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist))
122f9328639SMarian Balakowiczendif # ifneq ($(BUILD_DIR),)
123f9328639SMarian Balakowicz
124f9328639SMarian BalakowiczOBJTREE		:= $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))
125c8f9c302SDaniel SchwierzeckSPLTREE		:= $(OBJTREE)/spl
126f9328639SMarian BalakowiczSRCTREE		:= $(CURDIR)
127f9328639SMarian BalakowiczTOPDIR		:= $(SRCTREE)
128f9328639SMarian BalakowiczLNDIR		:= $(OBJTREE)
129c8f9c302SDaniel Schwierzeckexport	TOPDIR SRCTREE OBJTREE SPLTREE
130f9328639SMarian Balakowicz
131f9328639SMarian BalakowiczMKCONFIG	:= $(SRCTREE)/mkconfig
132f9328639SMarian Balakowiczexport MKCONFIG
133f9328639SMarian Balakowicz
134f9328639SMarian Balakowiczifneq ($(OBJTREE),$(SRCTREE))
135f9328639SMarian BalakowiczREMOTE_BUILD	:= 1
136f9328639SMarian Balakowiczexport REMOTE_BUILD
137f9328639SMarian Balakowiczendif
138f9328639SMarian Balakowicz
139f9328639SMarian Balakowicz# $(obj) and (src) are defined in config.mk but here in main Makefile
140f9328639SMarian Balakowicz# we also need them before config.mk is included which is the case for
141f9328639SMarian Balakowicz# some targets like unconfig, clean, clobber, distclean, etc.
142f9328639SMarian Balakowiczifneq ($(OBJTREE),$(SRCTREE))
143f9328639SMarian Balakowiczobj := $(OBJTREE)/
144f9328639SMarian Balakowiczsrc := $(SRCTREE)/
145f9328639SMarian Balakowiczelse
146f9328639SMarian Balakowiczobj :=
147f9328639SMarian Balakowiczsrc :=
148f9328639SMarian Balakowiczendif
149f9328639SMarian Balakowiczexport obj src
150f9328639SMarian Balakowicz
1515013c09fSWolfgang Denk# Make sure CDPATH settings don't interfere
1525013c09fSWolfgang Denkunexport CDPATH
1535013c09fSWolfgang Denk
154f9328639SMarian Balakowicz#########################################################################
155f9328639SMarian Balakowicz
1566d1ce387SMike Frysinger# The "tools" are needed early, so put this first
1576d1ce387SMike Frysinger# Don't include stuff already done in $(LIBS)
158349e83f0SChe-liang Chiou# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
159349e83f0SChe-liang Chiou# is "yes"), so compile examples after U-Boot is compiled.
160349e83f0SChe-liang ChiouSUBDIR_TOOLS = tools
161349e83f0SChe-liang ChiouSUBDIR_EXAMPLES = examples/standalone examples/api
162349e83f0SChe-liang ChiouSUBDIRS = $(SUBDIR_TOOLS)
1636d1ce387SMike Frysinger
164249b53a6SLoïc Minier.PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE)
1656d1ce387SMike Frysinger
166ae6d1056SWolfgang Denkifeq ($(obj)include/config.mk,$(wildcard $(obj)include/config.mk))
167f9328639SMarian Balakowicz
1682632c008SMike Frysinger# Include autoconf.mk before config.mk so that the config options are available
1692632c008SMike Frysinger# to all top level build files.  We need the dummy all: target to prevent the
1702632c008SMike Frysinger# dependency target in autoconf.mk.dep from being the default.
1712632c008SMike Frysingerall:
1722632c008SMike Frysingersinclude $(obj)include/autoconf.mk.dep
1732632c008SMike Frysingersinclude $(obj)include/autoconf.mk
1742632c008SMike Frysinger
175b5728756SSimon Glassifndef CONFIG_SANDBOX
176b5728756SSimon GlassSUBDIRS += $(SUBDIR_EXAMPLES)
177b5728756SSimon Glassendif
178b5728756SSimon Glass
1797ebf7443Swdenk# load ARCH, BOARD, and CPU configuration
180ae6d1056SWolfgang Denkinclude $(obj)include/config.mk
1811d9f4105Swdenkexport	ARCH CPU BOARD VENDOR SOC
182f9328639SMarian Balakowicz
1831ea6bcd8SMike Frysinger# set default to nothing for native builds
184a5284efdSWolfgang Denkifeq ($(HOSTARCH),$(ARCH))
1851ea6bcd8SMike FrysingerCROSS_COMPILE ?=
1867ebf7443Swdenkendif
1877ebf7443Swdenk
18892b197f0SWolfgang Denk# load other configuration
18992b197f0SWolfgang Denkinclude $(TOPDIR)/config.mk
19092b197f0SWolfgang Denk
191d51dfff7SIlya Yanok# If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
192d51dfff7SIlya Yanok# that (or fail if absent).  Otherwise, search for a linker script in a
193d51dfff7SIlya Yanok# standard location.
194d51dfff7SIlya Yanok
195ee60197eSSimon GlassLDSCRIPT_MAKEFILE_DIR = $(dir $(LDSCRIPT))
196ee60197eSSimon Glass
197d51dfff7SIlya Yanokifndef LDSCRIPT
198d51dfff7SIlya Yanok	#LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
199d51dfff7SIlya Yanok	ifdef CONFIG_SYS_LDSCRIPT
200d51dfff7SIlya Yanok		# need to strip off double quotes
201d51dfff7SIlya Yanok		LDSCRIPT := $(subst ",,$(CONFIG_SYS_LDSCRIPT))
202d51dfff7SIlya Yanok	endif
203d51dfff7SIlya Yanokendif
204d51dfff7SIlya Yanok
205ee60197eSSimon Glass# If there is no specified link script, we look in a number of places for it
206d51dfff7SIlya Yanokifndef LDSCRIPT
207d51dfff7SIlya Yanok	ifeq ($(CONFIG_NAND_U_BOOT),y)
208d51dfff7SIlya Yanok		LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
209d51dfff7SIlya Yanok		ifeq ($(wildcard $(LDSCRIPT)),)
210d51dfff7SIlya Yanok			LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds
211d51dfff7SIlya Yanok		endif
212d51dfff7SIlya Yanok	endif
213d51dfff7SIlya Yanok	ifeq ($(wildcard $(LDSCRIPT)),)
214d51dfff7SIlya Yanok		LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
215d51dfff7SIlya Yanok	endif
216d51dfff7SIlya Yanok	ifeq ($(wildcard $(LDSCRIPT)),)
217d51dfff7SIlya Yanok		LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot.lds
218d51dfff7SIlya Yanok	endif
219d51dfff7SIlya Yanok	ifeq ($(wildcard $(LDSCRIPT)),)
220ee60197eSSimon Glass		LDSCRIPT := $(TOPDIR)/arch/$(ARCH)/cpu/u-boot.lds
221ee60197eSSimon Glass		# We don't expect a Makefile here
222ee60197eSSimon Glass		LDSCRIPT_MAKEFILE_DIR =
223ee60197eSSimon Glass	endif
224ee60197eSSimon Glass	ifeq ($(wildcard $(LDSCRIPT)),)
225d51dfff7SIlya Yanok$(error could not find linker script)
226d51dfff7SIlya Yanok	endif
227d51dfff7SIlya Yanokendif
228d51dfff7SIlya Yanok
2297ebf7443Swdenk#########################################################################
2307ebf7443Swdenk# U-Boot objects....order is important (i.e. start must be first)
2317ebf7443Swdenk
23203b7004dSPeter TyserOBJS  = $(CPUDIR)/start.o
233fea25720SGraeme Russifeq ($(CPU),x86)
23403b7004dSPeter TyserOBJS += $(CPUDIR)/start16.o
23503b7004dSPeter TyserOBJS += $(CPUDIR)/resetvec.o
2362262cfeeSwdenkendif
2377ebf7443Swdenkifeq ($(CPU),ppc4xx)
23803b7004dSPeter TyserOBJS += $(CPUDIR)/resetvec.o
2397ebf7443Swdenkendif
24042d1f039Swdenkifeq ($(CPU),mpc85xx)
24103b7004dSPeter TyserOBJS += $(CPUDIR)/resetvec.o
24242d1f039Swdenkendif
2437ebf7443Swdenk
244f9328639SMarian BalakowiczOBJS := $(addprefix $(obj),$(OBJS))
245f9328639SMarian Balakowicz
2468b5a0264SDaniel SchwierzeckHAVE_VENDOR_COMMON_LIB = $(if $(wildcard board/$(VENDOR)/common/Makefile),y,n)
2478b5a0264SDaniel Schwierzeck
248f52d7b35SDaniel SchwierzeckLIBS-y += lib/libgeneric.o
249f52d7b35SDaniel SchwierzeckLIBS-y += lib/lzma/liblzma.o
250f52d7b35SDaniel SchwierzeckLIBS-y += lib/lzo/liblzo.o
251f52d7b35SDaniel SchwierzeckLIBS-y += lib/zlib/libz.o
2528b5a0264SDaniel SchwierzeckLIBS-$(CONFIG_TIZEN) += lib/tizen/libtizen.o
2538b5a0264SDaniel SchwierzeckLIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/lib$(VENDOR).o
254f52d7b35SDaniel SchwierzeckLIBS-y += $(CPUDIR)/lib$(CPU).o
2551d9f4105Swdenkifdef SOC
256f52d7b35SDaniel SchwierzeckLIBS-y += $(CPUDIR)/$(SOC)/lib$(SOC).o
2571d9f4105Swdenkendif
258323bfa8fSStefan Roeseifeq ($(CPU),ixp)
25961e12988SMarek VasutLIBS-y += drivers/net/npe/libnpe.o
260323bfa8fSStefan Roeseendif
2618b5a0264SDaniel SchwierzeckLIBS-$(CONFIG_OF_EMBED) += dts/libdts.o
262f52d7b35SDaniel SchwierzeckLIBS-y += arch/$(ARCH)/lib/lib$(ARCH).o
263045fa1e1SStephen WarrenLIBS-y += fs/libfs.o \
264045fa1e1SStephen Warren	fs/cbfs/libcbfs.o \
26584cd9327SGabe Black	fs/cramfs/libcramfs.o \
266a1596438SUma Shankar	fs/ext4/libext4fs.o \
267a1596438SUma Shankar	fs/fat/libfat.o \
268a1596438SUma Shankar	fs/fdos/libfdos.o \
269a1596438SUma Shankar	fs/jffs2/libjffs2.o \
270a1596438SUma Shankar	fs/reiserfs/libreiserfs.o \
271a1596438SUma Shankar	fs/ubifs/libubifs.o \
272a1596438SUma Shankar	fs/yaffs2/libyaffs2.o \
273a1596438SUma Shankar	fs/zfs/libzfs.o
274f52d7b35SDaniel SchwierzeckLIBS-y += net/libnet.o
275f52d7b35SDaniel SchwierzeckLIBS-y += disk/libdisk.o
276f52d7b35SDaniel SchwierzeckLIBS-y += drivers/bios_emulator/libatibiosemu.o
277f52d7b35SDaniel SchwierzeckLIBS-y += drivers/block/libblock.o
2780044c42eSStefan RoeseLIBS-$(CONFIG_BOOTCOUNT_LIMIT) += drivers/bootcount/libbootcount.o
279f52d7b35SDaniel SchwierzeckLIBS-y += drivers/dma/libdma.o
280f52d7b35SDaniel SchwierzeckLIBS-y += drivers/fpga/libfpga.o
281f52d7b35SDaniel SchwierzeckLIBS-y += drivers/gpio/libgpio.o
282f52d7b35SDaniel SchwierzeckLIBS-y += drivers/hwmon/libhwmon.o
283f52d7b35SDaniel SchwierzeckLIBS-y += drivers/i2c/libi2c.o
284f52d7b35SDaniel SchwierzeckLIBS-y += drivers/input/libinput.o
285f52d7b35SDaniel SchwierzeckLIBS-y += drivers/misc/libmisc.o
286f52d7b35SDaniel SchwierzeckLIBS-y += drivers/mmc/libmmc.o
287f52d7b35SDaniel SchwierzeckLIBS-y += drivers/mtd/libmtd.o
288f52d7b35SDaniel SchwierzeckLIBS-y += drivers/mtd/nand/libnand.o
289f52d7b35SDaniel SchwierzeckLIBS-y += drivers/mtd/onenand/libonenand.o
290f52d7b35SDaniel SchwierzeckLIBS-y += drivers/mtd/ubi/libubi.o
291f52d7b35SDaniel SchwierzeckLIBS-y += drivers/mtd/spi/libspi_flash.o
292f52d7b35SDaniel SchwierzeckLIBS-y += drivers/net/libnet.o
293f52d7b35SDaniel SchwierzeckLIBS-y += drivers/net/phy/libphy.o
294f52d7b35SDaniel SchwierzeckLIBS-y += drivers/pci/libpci.o
295f52d7b35SDaniel SchwierzeckLIBS-y += drivers/pcmcia/libpcmcia.o
296f52d7b35SDaniel SchwierzeckLIBS-y += drivers/power/libpower.o
297f52d7b35SDaniel SchwierzeckLIBS-y += drivers/spi/libspi.o
298f22b11c1SLukasz MajewskiLIBS-y += drivers/dfu/libdfu.o
2997737d5c6SDave Liuifeq ($(CPU),mpc83xx)
300f52d7b35SDaniel SchwierzeckLIBS-y += drivers/qe/libqe.o
301f52d7b35SDaniel SchwierzeckLIBS-y += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
302f52d7b35SDaniel SchwierzeckLIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
3037737d5c6SDave Liuendif
304da9d4610SAndy Flemingifeq ($(CPU),mpc85xx)
305f52d7b35SDaniel SchwierzeckLIBS-y += drivers/qe/libqe.o
306f52d7b35SDaniel SchwierzeckLIBS-y += drivers/net/fm/libfm.o
307f52d7b35SDaniel SchwierzeckLIBS-y += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
308f52d7b35SDaniel SchwierzeckLIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
30958e5e9afSKumar Galaendif
31058e5e9afSKumar Galaifeq ($(CPU),mpc86xx)
311f52d7b35SDaniel SchwierzeckLIBS-y += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
312f52d7b35SDaniel SchwierzeckLIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
313da9d4610SAndy Flemingendif
314f52d7b35SDaniel SchwierzeckLIBS-y += drivers/rtc/librtc.o
315f52d7b35SDaniel SchwierzeckLIBS-y += drivers/serial/libserial.o
3168b5a0264SDaniel SchwierzeckLIBS-$(CONFIG_GENERIC_LPC_TPM) += drivers/tpm/libtpm.o
317f52d7b35SDaniel SchwierzeckLIBS-y += drivers/twserial/libtws.o
318f52d7b35SDaniel SchwierzeckLIBS-y += drivers/usb/eth/libusb_eth.o
319f52d7b35SDaniel SchwierzeckLIBS-y += drivers/usb/gadget/libusb_gadget.o
320f52d7b35SDaniel SchwierzeckLIBS-y += drivers/usb/host/libusb_host.o
321f52d7b35SDaniel SchwierzeckLIBS-y += drivers/usb/musb/libusb_musb.o
322f52d7b35SDaniel SchwierzeckLIBS-y += drivers/usb/phy/libusb_phy.o
323f52d7b35SDaniel SchwierzeckLIBS-y += drivers/usb/ulpi/libusb_ulpi.o
324f52d7b35SDaniel SchwierzeckLIBS-y += drivers/video/libvideo.o
325f52d7b35SDaniel SchwierzeckLIBS-y += drivers/watchdog/libwatchdog.o
326f52d7b35SDaniel SchwierzeckLIBS-y += common/libcommon.o
327f52d7b35SDaniel SchwierzeckLIBS-y += lib/libfdt/libfdt.o
328f52d7b35SDaniel SchwierzeckLIBS-y += api/libapi.o
329f52d7b35SDaniel SchwierzeckLIBS-y += post/libpost.o
330f52d7b35SDaniel SchwierzeckLIBS-y += test/libtest.o
331f9328639SMarian Balakowicz
332f16da746SChandan Nathifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),)
333f52d7b35SDaniel SchwierzeckLIBS-y += $(CPUDIR)/omap-common/libomap-common.o
334f0f4b5ffSChandan Nathendif
33518936ee2SJason Liu
336ea00e59bSStefano Babicifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35))
337ea00e59bSStefano BabicLIBS-y += arch/$(ARCH)/imx-common/libimx-common.o
33818936ee2SJason Liuendif
33918936ee2SJason Liu
340852bd07cSMinkyu Kangifeq ($(SOC),s5pc1xx)
341f52d7b35SDaniel SchwierzeckLIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o
342852bd07cSMinkyu Kangendif
343393cb361SChander Kashyapifeq ($(SOC),exynos)
344f52d7b35SDaniel SchwierzeckLIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o
345852bd07cSMinkyu Kangendif
346d9e73a87SAllen Martinifeq ($(SOC),tegra20)
347d9e73a87SAllen MartinLIBS-y += arch/$(ARCH)/cpu/$(SOC)-common/lib$(SOC)-common.o
3483064f322STom WarrenLIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o
3493064f322STom WarrenLIBS-y += $(CPUDIR)/tegra-common/libtegra-common.o
350d9e73a87SAllen Martinendif
351852bd07cSMinkyu Kang
352f52d7b35SDaniel SchwierzeckLIBS := $(addprefix $(obj),$(sort $(LIBS-y)))
353249b53a6SLoïc Minier.PHONY : $(LIBS)
354a8c7c708Swdenk
3556d8962e8SSebastien CarlierLIBBOARD = board/$(BOARDDIR)/lib$(BOARD).o
356de109d90SWolfgang DenkLIBBOARD := $(addprefix $(obj),$(LIBBOARD))
357de109d90SWolfgang Denk
3584f7cb08eSwdenk# Add GCC lib
35952b1bf2cSWolfgang Denkifdef USE_PRIVATE_LIBGCC
36052b1bf2cSWolfgang Denkifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
361635d1b3eSMatthias WeisserPLATFORM_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/libgcc.o
36252b1bf2cSWolfgang Denkelse
36352b1bf2cSWolfgang DenkPLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc
36452b1bf2cSWolfgang Denkendif
36552b1bf2cSWolfgang Denkelse
366cca4e4aeSWolfgang DenkPLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
36752b1bf2cSWolfgang Denkendif
36852b1bf2cSWolfgang DenkPLATFORM_LIBS += $(PLATFORM_LIBGCC)
36952b1bf2cSWolfgang Denkexport PLATFORM_LIBS
3703d3befa7Swdenk
3716ac9f479SMike Frysinger# Special flags for CPP when processing the linker script.
3726ac9f479SMike Frysinger# Pass the version down so we can handle backwards compatibility
3736ac9f479SMike Frysinger# on the fly.
3746ac9f479SMike FrysingerLDPPFLAGS += \
3756ac9f479SMike Frysinger	-include $(TOPDIR)/include/u-boot/u-boot.lds.h \
3767e6403a6SSimon Glass	-DCPUDIR=$(CPUDIR) \
3776ac9f479SMike Frysinger	$(shell $(LD) --version | \
3786ac9f479SMike Frysinger	  sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
3796ac9f479SMike Frysinger
380f9328639SMarian Balakowicz__OBJS := $(subst $(obj),,$(OBJS))
381de109d90SWolfgang Denk__LIBS := $(subst $(obj),,$(LIBS)) $(subst $(obj),,$(LIBBOARD))
382f9328639SMarian Balakowicz
3837ebf7443Swdenk#########################################################################
384bdccc4feSwdenk#########################################################################
3857ebf7443Swdenk
386f3a14d37SMike Frysingerifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
387f3a14d37SMike FrysingerBOARD_SIZE_CHECK = \
388f3a14d37SMike Frysinger	@actual=`wc -c $@ | awk '{print $$1}'`; \
389f3a14d37SMike Frysinger	limit=$(CONFIG_BOARD_SIZE_LIMIT); \
390f3a14d37SMike Frysinger	if test $$actual -gt $$limit; then \
391f3a14d37SMike Frysinger		echo "$@ exceeds file size limit:"; \
392f3a14d37SMike Frysinger		echo "  limit:  $$limit bytes"; \
393f3a14d37SMike Frysinger		echo "  actual: $$actual bytes"; \
394f3a14d37SMike Frysinger		echo "  excess: $$((actual - limit)) bytes"; \
395f3a14d37SMike Frysinger		exit 1; \
396f3a14d37SMike Frysinger	fi
397f3a14d37SMike Frysingerelse
398f3a14d37SMike FrysingerBOARD_SIZE_CHECK =
399f3a14d37SMike Frysingerendif
400f3a14d37SMike Frysinger
4013e88337bSMike Frysinger# Always append ALL so that arch config.mk's can add custom ones
4024e0fbb98SDaniel SchwierzeckALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map
403e935a374SHaiying Wang
4044e0fbb98SDaniel SchwierzeckALL-$(CONFIG_NAND_U_BOOT) += $(obj)u-boot-nand.bin
4054e0fbb98SDaniel SchwierzeckALL-$(CONFIG_ONENAND_U_BOOT) += $(obj)u-boot-onenand.bin
4065df2ee27SDaniel SchwierzeckALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin
4072c0f79e4SSimon GlassALL-$(CONFIG_OF_SEPARATE) += $(obj)u-boot.dtb $(obj)u-boot-dtb.bin
4087ebf7443Swdenk
40912b7b70cSAllen Martin# enable combined SPL/u-boot/dtb rules for tegra
41012b7b70cSAllen Martinifeq ($(SOC),tegra20)
41112b7b70cSAllen Martinifeq ($(CONFIG_OF_SEPARATE),y)
41212b7b70cSAllen MartinALL-y += $(obj)u-boot-dtb-tegra.bin
41312b7b70cSAllen Martinelse
41412b7b70cSAllen MartinALL-y += $(obj)u-boot-nodtb-tegra.bin
41512b7b70cSAllen Martinendif
41612b7b70cSAllen Martinendif
41712b7b70cSAllen Martin
418349e83f0SChe-liang Chiouall:		$(ALL-y) $(SUBDIR_EXAMPLES)
4197ebf7443Swdenk
4202c0f79e4SSimon Glass$(obj)u-boot.dtb:	$(obj)u-boot
4212c0f79e4SSimon Glass		$(MAKE) -C dts binary
4222c0f79e4SSimon Glass		mv $(obj)dts/dt.dtb $@
4232c0f79e4SSimon Glass
4242c0f79e4SSimon Glass$(obj)u-boot-dtb.bin:	$(obj)u-boot.bin $(obj)u-boot.dtb
4252c0f79e4SSimon Glass		cat $^ >$@
4262c0f79e4SSimon Glass
427f9328639SMarian Balakowicz$(obj)u-boot.hex:	$(obj)u-boot
4286310eb9dSwdenk		$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
4296310eb9dSwdenk
430f9328639SMarian Balakowicz$(obj)u-boot.srec:	$(obj)u-boot
4310817d688SRicardo Ribalda Delgado		$(OBJCOPY) -O srec $< $@
4327ebf7443Swdenk
433f9328639SMarian Balakowicz$(obj)u-boot.bin:	$(obj)u-boot
4347ebf7443Swdenk		$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
435f3a14d37SMike Frysinger		$(BOARD_SIZE_CHECK)
4367ebf7443Swdenk
43794a91e24SMike Frysinger$(obj)u-boot.ldr:	$(obj)u-boot
43876d82187SMike Frysinger		$(CREATE_LDR_ENV)
43968e56324SMike Frysinger		$(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS)
440f3a14d37SMike Frysinger		$(BOARD_SIZE_CHECK)
44194a91e24SMike Frysinger
44294a91e24SMike Frysinger$(obj)u-boot.ldr.hex:	$(obj)u-boot.ldr
44394a91e24SMike Frysinger		$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ -I binary
44494a91e24SMike Frysinger
44594a91e24SMike Frysinger$(obj)u-boot.ldr.srec:	$(obj)u-boot.ldr
44694a91e24SMike Frysinger		$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ -I binary
44794a91e24SMike Frysinger
448f9328639SMarian Balakowicz$(obj)u-boot.img:	$(obj)u-boot.bin
449a2a0a717SWolfgang Denk		$(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
4503857f8f5Saneeshv		-O u-boot -a $(CONFIG_SYS_TEXT_BASE) -e 0 \
451881a87ecSWolfgang Denk		-n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
452bdccc4feSwdenk			sed -e 's/"[	 ]*$$/ for $(BOARD) board"/') \
453bdccc4feSwdenk		-d $< $@
454bdccc4feSwdenk
4558edcde5eSStefano Babic$(obj)u-boot.imx:       $(obj)u-boot.bin
45645d7d72bSStefano Babic		$(obj)tools/mkimage -n  $(CONFIG_IMX_CONFIG) -T imximage \
45714d0a02aSWolfgang Denk		-e $(CONFIG_SYS_TEXT_BASE) -d $< $@
4588edcde5eSStefano Babic
459aa0c7a86SPrafulla Wadaskar$(obj)u-boot.kwb:       $(obj)u-boot.bin
46031d80c77SPrafulla Wadaskar		$(obj)tools/mkimage -n $(CONFIG_SYS_KWD_CONFIG) -T kwbimage \
4612ea88b06SEric Cooper		-a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) -d $< $@
462aa0c7a86SPrafulla Wadaskar
4635d898a00SShaohui Xie$(obj)u-boot.pbl:	$(obj)u-boot.bin
4645d898a00SShaohui Xie		$(obj)tools/mkimage -n $(CONFIG_PBLRCW_CONFIG) \
4655d898a00SShaohui Xie		-R $(CONFIG_PBLPBI_CONFIG) -T pblimage \
4665d898a00SShaohui Xie		-d $< $@
4675d898a00SShaohui Xie
468566a494fSHeiko Schocher$(obj)u-boot.sha1:	$(obj)u-boot.bin
46901159530SHeiko Schocher		$(obj)tools/ubsha1 $(obj)u-boot.bin
470566a494fSHeiko Schocher
471f9328639SMarian Balakowicz$(obj)u-boot.dis:	$(obj)u-boot
4727ebf7443Swdenk		$(OBJDUMP) -d $< > $@
4737ebf7443Swdenk
474435199f3SHeiko Schocher$(obj)u-boot.ubl:       $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
475435199f3SHeiko Schocher		$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(PAD_TO) -O binary $(obj)spl/u-boot-spl $(obj)spl/u-boot-spl-pad.bin
476435199f3SHeiko Schocher		cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin > $(obj)u-boot-ubl.bin
4777816f2cfSHeiko Schocher		$(obj)tools/mkimage -n $(UBL_CONFIG) -T ublimage \
478435199f3SHeiko Schocher		-e $(CONFIG_SYS_TEXT_BASE) -d $(obj)u-boot-ubl.bin $(obj)u-boot.ubl
479435199f3SHeiko Schocher		rm $(obj)u-boot-ubl.bin
480435199f3SHeiko Schocher		rm $(obj)spl/u-boot-spl-pad.bin
4817816f2cfSHeiko Schocher
4823f7f2414STom Rini$(obj)u-boot.ais:       $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
4836d660e77SSughosh Ganu		$(obj)tools/mkimage -s -n $(if $(CONFIG_AIS_CONFIG_FILE),$(CONFIG_AIS_CONFIG_FILE),"/dev/null") \
4846d660e77SSughosh Ganu			-T aisimage \
485d36d8859SChristian Riesch			-e $(CONFIG_SPL_TEXT_BASE) \
486d36d8859SChristian Riesch			-d $(obj)spl/u-boot-spl.bin \
487d36d8859SChristian Riesch			$(obj)spl/u-boot-spl.ais
488d36d8859SChristian Riesch		$(OBJCOPY) ${OBJCFLAGS} -I binary \
489d36d8859SChristian Riesch			--pad-to=$(CONFIG_SPL_MAX_SIZE) -O binary \
490d36d8859SChristian Riesch			$(obj)spl/u-boot-spl.ais $(obj)spl/u-boot-spl-pad.ais
4913f7f2414STom Rini		cat $(obj)spl/u-boot-spl-pad.ais $(obj)u-boot.img > \
492d36d8859SChristian Riesch			$(obj)u-boot.ais
493d36d8859SChristian Riesch
494a5453555SOtavio Salvador# Specify the target for use in elftosb call
495a5453555SOtavio SalvadorELFTOSB_TARGET-$(CONFIG_MX28) = imx28
496a5453555SOtavio Salvador
49730b9b932SMarek Vasut$(obj)u-boot.sb:       $(obj)u-boot.bin $(obj)spl/u-boot-spl.bin
498a5453555SOtavio Salvador		elftosb -zdf $(ELFTOSB_TARGET-y) -c $(TOPDIR)/$(CPUDIR)/$(SOC)/u-boot-$(ELFTOSB_TARGET-y).bd \
49930b9b932SMarek Vasut			-o $(obj)u-boot.sb
50030b9b932SMarek Vasut
50194aebe6cSStefan Roese# On x600 (SPEAr600) U-Boot is appended to U-Boot SPL.
50294aebe6cSStefan Roese# Both images are created using mkimage (crc etc), so that the ROM
50394aebe6cSStefan Roese# bootloader can check its integrity. Padding needs to be done to the
50494aebe6cSStefan Roese# SPL image (with mkimage header) and not the binary. Otherwise the resulting image
50594aebe6cSStefan Roese# which is loaded/copied by the ROM bootloader to SRAM doesn't fit.
50694aebe6cSStefan Roese# The resulting image containing both U-Boot images is called u-boot.spr
50794aebe6cSStefan Roese$(obj)u-boot.spr:	$(obj)u-boot.img $(obj)spl/u-boot-spl.bin
50894aebe6cSStefan Roese		$(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
50994aebe6cSStefan Roese		-a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER \
51094aebe6cSStefan Roese		-d $(obj)spl/u-boot-spl.bin $(obj)spl/u-boot-spl.img
51194aebe6cSStefan Roese		tr "\000" "\377" < /dev/zero | dd ibs=1 count=$(CONFIG_SPL_PAD_TO) \
51294aebe6cSStefan Roese			of=$(obj)spl/u-boot-spl-pad.img 2>/dev/null
51394aebe6cSStefan Roese		dd if=$(obj)spl/u-boot-spl.img of=$(obj)spl/u-boot-spl-pad.img \
51494aebe6cSStefan Roese			conv=notrunc 2>/dev/null
51594aebe6cSStefan Roese		cat $(obj)spl/u-boot-spl-pad.img $(obj)u-boot.img > $@
51694aebe6cSStefan Roese
517984df4ecSAllen Martinifeq ($(SOC),tegra20)
518984df4ecSAllen Martinifeq ($(CONFIG_OF_SEPARATE),y)
519e4ec9346SStephen Warrennodtb=dtb
520e4ec9346SStephen Warrendtbfile=$(obj)u-boot.dtb
521984df4ecSAllen Martinelse
522e4ec9346SStephen Warrennodtb=nodtb
523e4ec9346SStephen Warrendtbfile=
524984df4ecSAllen Martinendif
525e4ec9346SStephen Warren
526e4ec9346SStephen Warren$(obj)u-boot-$(nodtb)-tegra.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin $(dtbfile)
527e4ec9346SStephen Warren		$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SYS_TEXT_BASE) -O binary $(obj)spl/u-boot-spl $(obj)spl/u-boot-spl-pad.bin
528e4ec9346SStephen Warren		cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin $(dtbfile) > $@
529e4ec9346SStephen Warren		rm $(obj)spl/u-boot-spl-pad.bin
530984df4ecSAllen Martinendif
531984df4ecSAllen Martin
53286eb49b3SSimon Glassifeq ($(CONFIG_SANDBOX),y)
53386eb49b3SSimon GlassGEN_UBOOT = \
53486eb49b3SSimon Glass		cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \
53586eb49b3SSimon Glass			-Wl,--start-group $(__LIBS) -Wl,--end-group \
53686eb49b3SSimon Glass			$(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot
53786eb49b3SSimon Glasselse
538ecb1dc89SMike FrysingerGEN_UBOOT = \
53997b24d3dSMarek Vasut		UNDEF_LST=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \
54097b24d3dSMarek Vasut		sed  -n -e 's/.*\($(SYM_PREFIX)_u_boot_list_.*\)/-u\1/p'|sort|uniq`;\
54197b24d3dSMarek Vasut		cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
5428b493a52SMarek Vasut			$$UNDEF_LST $(__OBJS) \
543f9328639SMarian Balakowicz			--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
544b2184c31Swdenk			-Map u-boot.map -o u-boot
54586eb49b3SSimon Glassendif
54686eb49b3SSimon Glass
54716a354f9SWolfgang Denk$(obj)u-boot:	depend \
548349e83f0SChe-liang Chiou		$(SUBDIR_TOOLS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds
549ecb1dc89SMike Frysinger		$(GEN_UBOOT)
550ecb1dc89SMike Frysingerifeq ($(CONFIG_KALLSYMS),y)
5518a156fb6SMike Frysinger		smap=`$(call SYSTEM_MAP,$(obj)u-boot) | \
5521aada9cdSWolfgang Denk			awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \
5531aada9cdSWolfgang Denk		$(CC) $(CFLAGS) -DSYSTEM_MAP="\"$${smap}\"" \
5541aada9cdSWolfgang Denk			-c common/system_map.c -o $(obj)common/system_map.o
555ecb1dc89SMike Frysinger		$(GEN_UBOOT) $(obj)common/system_map.o
556ecb1dc89SMike Frysingerendif
5577ebf7443Swdenk
558d0d6144eSPeter Tyser$(OBJS):	depend
55903b7004dSPeter Tyser		$(MAKE) -C $(CPUDIR) $(if $(REMOTE_BUILD),$@,$(notdir $@))
560f9328639SMarian Balakowicz
561349e83f0SChe-liang Chiou$(LIBS):	depend $(SUBDIR_TOOLS)
562f9328639SMarian Balakowicz		$(MAKE) -C $(dir $(subst $(obj),,$@))
563a8c7c708Swdenk
564d0d6144eSPeter Tyser$(LIBBOARD):	depend $(LIBS)
565de109d90SWolfgang Denk		$(MAKE) -C $(dir $(subst $(obj),,$@))
566de109d90SWolfgang Denk
567d0d6144eSPeter Tyser$(SUBDIRS):	depend
568b028f715Swdenk		$(MAKE) -C $@ all
5697ebf7443Swdenk
570349e83f0SChe-liang Chiou$(SUBDIR_EXAMPLES): $(obj)u-boot
571349e83f0SChe-liang Chiou
572d0d6144eSPeter Tyser$(LDSCRIPT):	depend
573f65c9812SMike Frysinger		$(MAKE) -C $(dir $@) $(notdir $@)
574f65c9812SMike Frysinger
57597b24d3dSMarek Vasut# The following line expands into whole rule which generates u-boot.lst,
57697b24d3dSMarek Vasut# the file containing u-boots LG-array linker section. This is included into
57797b24d3dSMarek Vasut# $(LDSCRIPT). The function make_u_boot_list is defined in helper.mk file.
57897b24d3dSMarek Vasut$(eval $(call make_u_boot_list, $(obj)include/u-boot.lst, $(LIBBOARD) $(LIBS)))
57997b24d3dSMarek Vasut$(obj)u-boot.lds: $(LDSCRIPT) $(obj)include/u-boot.lst
58097b24d3dSMarek Vasut		$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
5811aada9cdSWolfgang Denk
582e935a374SHaiying Wangnand_spl:	$(TIMESTAMP_FILE) $(VERSION_FILE) depend
5838318fbf8SMarian Balakowicz		$(MAKE) -C nand_spl/board/$(BOARDDIR) all
584887e2ec9SStefan Roese
585e935a374SHaiying Wang$(obj)u-boot-nand.bin:	nand_spl $(obj)u-boot.bin
5868318fbf8SMarian Balakowicz		cat $(obj)nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > $(obj)u-boot-nand.bin
587887e2ec9SStefan Roese
588bd25fdbaSAneesh V$(obj)spl/u-boot-spl.bin:	$(SUBDIR_TOOLS) depend
5895df2ee27SDaniel Schwierzeck		$(MAKE) -C spl all
5905df2ee27SDaniel Schwierzeck
591f9328639SMarian Balakowiczupdater:
5920358df42SMike Frysinger		$(MAKE) -C tools/updater all
5938f713fdfSdzu
5942a998793SDaniel Hobi# Explicitly make _depend in subdirs containing multiple targets to prevent
5952a998793SDaniel Hobi# parallel sub-makes creating .depend files simultaneously.
59616a354f9SWolfgang Denkdepend dep:	$(TIMESTAMP_FILE) $(VERSION_FILE) \
59716a354f9SWolfgang Denk		$(obj)include/autoconf.mk \
598a4814a69SStefano Babic		$(obj)include/generated/generic-asm-offsets.h \
599a4814a69SStefano Babic		$(obj)include/generated/asm-offsets.h
600ee60197eSSimon Glass		for dir in $(SUBDIRS) $(CPUDIR) $(LDSCRIPT_MAKEFILE_DIR) ; do \
6012a998793SDaniel Hobi			$(MAKE) -C $$dir _depend ; done
6027ebf7443Swdenk
603e5e4e705SLi YangTAG_SUBDIRS = $(SUBDIRS)
604e5e4e705SLi YangTAG_SUBDIRS += $(dir $(__LIBS))
605a340c325SJean-Christophe PLAGNIOL-VILLARDTAG_SUBDIRS += include
606a340c325SJean-Christophe PLAGNIOL-VILLARD
607857d9ea6SHorst KronstorferFIND := find
608857d9ea6SHorst KronstorferFINDFLAGS := -L
609857d9ea6SHorst Kronstorfer
6101064d980STom Rinicheckstack:
6111064d980STom Rini		$(CROSS_COMPILE)objdump -d $(obj)u-boot \
6121064d980STom Rini			`$(FIND) $(obj) -name u-boot-spl -print` | \
6131064d980STom Rini			perl $(src)tools/checkstack.pl $(ARCH)
6141064d980STom Rini
615f9328639SMarian Balakowicztags ctags:
616857d9ea6SHorst Kronstorfer		ctags -w -o $(obj)ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
617e5e4e705SLi Yang						-name '*.[chS]' -print`
6187ebf7443Swdenk
6197ebf7443Swdenketags:
620857d9ea6SHorst Kronstorfer		etags -a -o $(obj)etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
621e5e4e705SLi Yang						-name '*.[chS]' -print`
622ffda586fSLi Yangcscope:
623857d9ea6SHorst Kronstorfer		$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \
624857d9ea6SHorst Kronstorfer						cscope.files
625ffda586fSLi Yang		cscope -b -q -k
6267ebf7443Swdenk
627ecb1dc89SMike FrysingerSYSTEM_MAP = \
628ecb1dc89SMike Frysinger		$(NM) $1 | \
6297ebf7443Swdenk		grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
630ecb1dc89SMike Frysinger		LC_ALL=C sort
631ecb1dc89SMike Frysinger$(obj)System.map:	$(obj)u-boot
632ecb1dc89SMike Frysinger		@$(call SYSTEM_MAP,$<) > $(obj)System.map
6337ebf7443Swdenk
63406a119a0STom Rinicheckthumb:
63506a119a0STom Rini	@if test $(call cc-version) -lt 0404; then \
63606a119a0STom Rini		echo -n '*** Your GCC does not produce working '; \
63706a119a0STom Rini		echo 'binaries in THUMB mode.'; \
63806a119a0STom Rini		echo '*** Your board is configured for THUMB mode.'; \
63906a119a0STom Rini		false; \
64006a119a0STom Rini	fi
6412f155f6cSGrant Likely#
6422f155f6cSGrant Likely# Auto-generate the autoconf.mk file (which is included by all makefiles)
6432f155f6cSGrant Likely#
6442f155f6cSGrant Likely# This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
6452f155f6cSGrant Likely# the dep file is only include in this top level makefile to determine when
6462f155f6cSGrant Likely# to regenerate the autoconf.mk file.
6471510b82dSWolfgang Denk$(obj)include/autoconf.mk.dep: $(obj)include/config.h include/common.h
6481510b82dSWolfgang Denk	@$(XECHO) Generating $@ ; \
64916fe7775SMike Frysinger	set -e ; \
650ae6d1056SWolfgang Denk	: Generate the dependancies ; \
6514c34b2a0SMike Frysinger	$(CC) -x c -DDO_DEPS_ONLY -M $(CFLAGS) $(CPPFLAGS) \
6521510b82dSWolfgang Denk		-MQ $(obj)include/autoconf.mk include/common.h > $@
6531510b82dSWolfgang Denk
6541510b82dSWolfgang Denk$(obj)include/autoconf.mk: $(obj)include/config.h
6551510b82dSWolfgang Denk	@$(XECHO) Generating $@ ; \
6561510b82dSWolfgang Denk	set -e ; \
657ae6d1056SWolfgang Denk	: Extract the config macros ; \
6581510b82dSWolfgang Denk	$(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h | \
6594a0f7538SWolfgang Denk		sed -n -f tools/scripts/define2mk.sed > $@.tmp && \
6604a0f7538SWolfgang Denk	mv $@.tmp $@
6612f155f6cSGrant Likely
66216a354f9SWolfgang Denk$(obj)include/generated/generic-asm-offsets.h:	$(obj)include/autoconf.mk.dep \
66316a354f9SWolfgang Denk	$(obj)lib/asm-offsets.s
66416a354f9SWolfgang Denk	@$(XECHO) Generating $@
66516a354f9SWolfgang Denk	tools/scripts/make-asm-offsets $(obj)lib/asm-offsets.s $@
66616a354f9SWolfgang Denk
66716a354f9SWolfgang Denk$(obj)lib/asm-offsets.s:	$(obj)include/autoconf.mk.dep \
66816a354f9SWolfgang Denk	$(src)lib/asm-offsets.c
66916a354f9SWolfgang Denk	@mkdir -p $(obj)lib
67016a354f9SWolfgang Denk	$(CC) -DDO_DEPS_ONLY \
67116a354f9SWolfgang Denk		$(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
67216a354f9SWolfgang Denk		-o $@ $(src)lib/asm-offsets.c -c -S
67316a354f9SWolfgang Denk
674a4814a69SStefano Babic$(obj)include/generated/asm-offsets.h:	$(obj)include/autoconf.mk.dep \
675a4814a69SStefano Babic	$(obj)$(CPUDIR)/$(SOC)/asm-offsets.s
676b12734eeSWolfgang Denk	@$(XECHO) Generating $@
677a4814a69SStefano Babic	tools/scripts/make-asm-offsets $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s $@
678a4814a69SStefano Babic
679a4814a69SStefano Babic$(obj)$(CPUDIR)/$(SOC)/asm-offsets.s:	$(obj)include/autoconf.mk.dep
680a4814a69SStefano Babic	@mkdir -p $(obj)$(CPUDIR)/$(SOC)
681a4814a69SStefano Babic	if [ -f $(src)$(CPUDIR)/$(SOC)/asm-offsets.c ];then \
682a4814a69SStefano Babic		$(CC) -DDO_DEPS_ONLY \
683a4814a69SStefano Babic		$(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
684a4814a69SStefano Babic			-o $@ $(src)$(CPUDIR)/$(SOC)/asm-offsets.c -c -S; \
685a4814a69SStefano Babic	else \
686a4814a69SStefano Babic		touch $@; \
687a4814a69SStefano Babic	fi
688a4814a69SStefano Babic
6897ebf7443Swdenk#########################################################################
690ae6d1056SWolfgang Denkelse	# !config.mk
691f9328639SMarian Balakowiczall $(obj)u-boot.hex $(obj)u-boot.srec $(obj)u-boot.bin \
692f9328639SMarian Balakowicz$(obj)u-boot.img $(obj)u-boot.dis $(obj)u-boot \
693249b53a6SLoïc Minier$(filter-out tools,$(SUBDIRS)) \
6940358df42SMike Frysingerupdater depend dep tags ctags etags cscope $(obj)System.map:
6957ebf7443Swdenk	@echo "System not configured - see README" >&2
6967ebf7443Swdenk	@ exit 1
697c7c0d542SMike Frysinger
698249b53a6SLoïc Miniertools: $(VERSION_FILE) $(TIMESTAMP_FILE)
6990358df42SMike Frysinger	$(MAKE) -C $@ all
700ae6d1056SWolfgang Denkendif	# config.mk
7017ebf7443Swdenk
70228abd48fSIlya Yanok$(VERSION_FILE):
70314ce91b1SMike Frysinger		@mkdir -p $(dir $(VERSION_FILE))
70428abd48fSIlya Yanok		@( localvers='$(shell $(TOPDIR)/tools/setlocalversion $(TOPDIR))' ; \
70528abd48fSIlya Yanok		   printf '#define PLAIN_VERSION "%s%s"\n' \
70628abd48fSIlya Yanok			"$(U_BOOT_VERSION)" "$${localvers}" ; \
70728abd48fSIlya Yanok		   printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' \
70828abd48fSIlya Yanok			"$(U_BOOT_VERSION)" "$${localvers}" ; \
70928abd48fSIlya Yanok		) > $@.tmp
71028abd48fSIlya Yanok		@( printf '#define CC_VERSION_STRING "%s"\n' \
71128abd48fSIlya Yanok		 '$(shell $(CC) --version | head -n 1)' )>>  $@.tmp
71228abd48fSIlya Yanok		@( printf '#define LD_VERSION_STRING "%s"\n' \
71328abd48fSIlya Yanok		 '$(shell $(LD) -v | head -n 1)' )>>  $@.tmp
71428abd48fSIlya Yanok		@cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
71528abd48fSIlya Yanok
716249b53a6SLoïc Minier$(TIMESTAMP_FILE):
717249b53a6SLoïc Minier		@mkdir -p $(dir $(TIMESTAMP_FILE))
718a76406fbSLoïc Minier		@LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > $@.tmp
719a76406fbSLoïc Minier		@LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> $@.tmp
720a76406fbSLoïc Minier		@cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
721249b53a6SLoïc Minier
7220358df42SMike Frysingereasylogo env gdb:
7230358df42SMike Frysinger	$(MAKE) -C tools/$@ all MTD_VERSION=${MTD_VERSION}
7240358df42SMike Frysingergdbtools: gdb
7250358df42SMike Frysinger
72630ff8918SMarek Vasutxmldocs pdfdocs psdocs htmldocs mandocs: tools/kernel-doc/docproc
72730ff8918SMarek Vasut	$(MAKE) U_BOOT_VERSION=$(U_BOOT_VERSION) -C doc/DocBook/ $@
72830ff8918SMarek Vasut
729249b53a6SLoïc Miniertools-all: easylogo env gdb $(VERSION_FILE) $(TIMESTAMP_FILE)
7300358df42SMike Frysinger	$(MAKE) -C tools HOST_TOOLS_ALL=y
7310358df42SMike Frysinger
7324e53a258SWolfgang Denk.PHONY : CHANGELOG
7334e53a258SWolfgang DenkCHANGELOG:
734b985b5d6SBen Warren	git log --no-merges U-Boot-1_1_5.. | \
735b985b5d6SBen Warren	unexpand -a | sed -e 's/\s\s*$$//' > $@
7364e53a258SWolfgang Denk
7370a823aa2SHarald Welteinclude/license.h: tools/bin2header COPYING
7380a823aa2SHarald Welte	cat COPYING | gzip -9 -c | ./tools/bin2header license_gzip > include/license.h
7397ebf7443Swdenk#########################################################################
7407ebf7443Swdenk
7417ebf7443Swdenkunconfig:
742887e2ec9SStefan Roese	@rm -f $(obj)include/config.h $(obj)include/config.mk \
7432f155f6cSGrant Likely		$(obj)board/*/config.tmp $(obj)board/*/*/config.tmp \
7442f155f6cSGrant Likely		$(obj)include/autoconf.mk $(obj)include/autoconf.mk.dep
7457ebf7443Swdenk
746a6862bc1SWolfgang Denk%_config::	unconfig
747a6862bc1SWolfgang Denk	@$(MKCONFIG) -A $(@:_config=)
748a6862bc1SWolfgang Denk
749d6a5e6d5SLoïc Miniersinclude $(obj).boards.depend
750d6a5e6d5SLoïc Minier$(obj).boards.depend:	boards.cfg
75137d0e777SLauri Hintsala	@awk '(NF && $$1 !~ /^#/) { print $$1 ": " $$1 "_config; $$(MAKE)" }' $< > $@
7529f4a4206SMike Frysinger
7538c994630SWolfgang Denk#
7548c994630SWolfgang Denk# Functions to generate common board directory names
7558c994630SWolfgang Denk#
7568c994630SWolfgang Denklcname	= $(shell echo $(1) | sed -e 's/\(.*\)_config/\L\1/')
7578c994630SWolfgang Denkucname	= $(shell echo $(1) | sed -e 's/\(.*\)_config/\U\1/')
7588c994630SWolfgang Denk
759699f0512SWolfgang Denk#########################################################################
76011edcfe2SGuennadi Liakhovetski## ARM1176 Systems
76111edcfe2SGuennadi Liakhovetski#########################################################################
76211edcfe2SGuennadi Liakhovetskismdk6400_noUSB_config	\
76311edcfe2SGuennadi Liakhovetskismdk6400_config	:	unconfig
76411edcfe2SGuennadi Liakhovetski	@mkdir -p $(obj)include $(obj)board/samsung/smdk6400
76511edcfe2SGuennadi Liakhovetski	@mkdir -p $(obj)nand_spl/board/samsung/smdk6400
76611edcfe2SGuennadi Liakhovetski	@echo "#define CONFIG_NAND_U_BOOT" > $(obj)include/config.h
7670e42ada3SWolfgang Denk	@echo "CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk
76811edcfe2SGuennadi Liakhovetski	@if [ -z "$(findstring smdk6400_noUSB_config,$@)" ]; then			\
76911edcfe2SGuennadi Liakhovetski		echo "RAM_TEXT = 0x57e00000" >> $(obj)board/samsung/smdk6400/config.tmp;\
77011edcfe2SGuennadi Liakhovetski	else										\
77111edcfe2SGuennadi Liakhovetski		echo "RAM_TEXT = 0xc7e00000" >> $(obj)board/samsung/smdk6400/config.tmp;\
77211edcfe2SGuennadi Liakhovetski	fi
77354e19a7dSWolfgang Denk	@$(MKCONFIG) smdk6400 arm arm1176 smdk6400 samsung s3c64xx
77411edcfe2SGuennadi Liakhovetski	@echo "CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk
77511edcfe2SGuennadi Liakhovetski
7760afe519aSWolfgang Denk#########################################################################
7773e38691eSwdenk#########################################################################
7787ebf7443Swdenk
7797ebf7443Swdenkclean:
7801bc15386SPeter Tyser	@rm -f $(obj)examples/standalone/82559_eeprom			  \
781d640ac58SWolfgang Denk	       $(obj)examples/standalone/atmel_df_pow2			  \
7821bc15386SPeter Tyser	       $(obj)examples/standalone/eepro100_eeprom		  \
7831bc15386SPeter Tyser	       $(obj)examples/standalone/hello_world			  \
7841bc15386SPeter Tyser	       $(obj)examples/standalone/interrupt			  \
7851bc15386SPeter Tyser	       $(obj)examples/standalone/mem_to_mem_idma2intr		  \
7861bc15386SPeter Tyser	       $(obj)examples/standalone/sched				  \
787201a017cSMike Frysinger	       $(obj)examples/standalone/smc911{11,x}_eeprom		  \
7881bc15386SPeter Tyser	       $(obj)examples/standalone/test_burst			  \
7891bc15386SPeter Tyser	       $(obj)examples/standalone/timer
790d4abc757SPeter Tyser	@rm -f $(obj)examples/api/demo{,.bin}
791f9301e1cSWolfgang Denk	@rm -f $(obj)tools/bmp_logo	   $(obj)tools/easylogo/easylogo  \
792f9301e1cSWolfgang Denk	       $(obj)tools/env/{fw_printenv,fw_setenv}			  \
793f9301e1cSWolfgang Denk	       $(obj)tools/envcrc					  \
794f9301e1cSWolfgang Denk	       $(obj)tools/gdb/{astest,gdbcont,gdbsend}			  \
795f9301e1cSWolfgang Denk	       $(obj)tools/gen_eth_addr    $(obj)tools/img2srec		  \
7967717fe10SHorst Kronstorfer	       $(obj)tools/mk{env,}image   $(obj)tools/mpc86x_clk	  \
79781e35203SChander Kashyap	       $(obj)tools/mk{smdk5250,}spl				  \
7988aa09026SMarek Vasut	       $(obj)tools/mxsboot					  \
79930ff8918SMarek Vasut	       $(obj)tools/ncb		   $(obj)tools/ubsha1		  \
80030ff8918SMarek Vasut	       $(obj)tools/kernel-doc/docproc
801f9301e1cSWolfgang Denk	@rm -f $(obj)board/cray/L1/{bootscript.c,bootscript.image}	  \
80274c7a95fSWolfgang Denk	       $(obj)board/matrix_vision/*/bootscript.img		  \
803566e5cf4SWolfgang Denk	       $(obj)board/voiceblue/eeprom 				  \
8041aada9cdSWolfgang Denk	       $(obj)u-boot.lds						  \
80597b24d3dSMarek Vasut	       $(obj)include/u-boot.lst			  		  \
806fb5166ceSMike Frysinger	       $(obj)arch/blackfin/cpu/bootrom-asm-offsets.[chs]	  \
807fb5166ceSMike Frysinger	       $(obj)arch/blackfin/cpu/init.{lds,elf}
808dc7746d8SWolfgang Denk	@rm -f $(obj)include/bmp_logo.h
809c270730fSChe-Liang Chiou	@rm -f $(obj)include/bmp_logo_data.h
81016a354f9SWolfgang Denk	@rm -f $(obj)lib/asm-offsets.s
811a4814a69SStefano Babic	@rm -f $(obj)include/generated/asm-offsets.h
812a4814a69SStefano Babic	@rm -f $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s
813d4abc757SPeter Tyser	@rm -f $(TIMESTAMP_FILE) $(VERSION_FILE)
814*b3141fdbSAndreas Bießmann	@$(MAKE) -s -C doc/DocBook/ cleandocs
815ae6d1056SWolfgang Denk	@find $(OBJTREE) -type f \
8164a30f1e8STom Rini		\( -name 'core' -o -name '*.bak' -o -name '*~' -o -name '*.su' \
8172b48f7d5SPeter Tyser		-o -name '*.o'	-o -name '*.a' -o -name '*.exe'	\) -print \
8187ebf7443Swdenk		| xargs rm -f
8197ebf7443Swdenk
820734329f9SAndy Fleming# Removes everything not needed for testing u-boot
821734329f9SAndy Flemingtidy:	clean
822734329f9SAndy Fleming	@find $(OBJTREE) -type f \( -name '*.depend*' \) -print | xargs rm -f
823734329f9SAndy Fleming
824734329f9SAndy Flemingclobber:	tidy
825734329f9SAndy Fleming	@find $(OBJTREE) -type f \( -name '*.srec' \
826734329f9SAndy Fleming		-o -name '*.bin' -o -name u-boot.img \) \
827734329f9SAndy Fleming		-print0 | xargs -0 rm -f
828ffda586fSLi Yang	@rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \
8295013c09fSWolfgang Denk		$(obj)cscope.* $(obj)*.*~
8304e0fbb98SDaniel Schwierzeck	@rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL-y)
831aa0c7a86SPrafulla Wadaskar	@rm -f $(obj)u-boot.kwb
8325d898a00SShaohui Xie	@rm -f $(obj)u-boot.pbl
833c5fb70c9SStefano Babic	@rm -f $(obj)u-boot.imx
8347816f2cfSHeiko Schocher	@rm -f $(obj)u-boot.ubl
835d36d8859SChristian Riesch	@rm -f $(obj)u-boot.ais
836bbb0b128SSimon Glass	@rm -f $(obj)u-boot.dtb
83730b9b932SMarek Vasut	@rm -f $(obj)u-boot.sb
83894aebe6cSStefan Roese	@rm -f $(obj)u-boot.spr
83997b24d3dSMarek Vasut	@rm -f $(obj)nand_spl/{u-boot.{lds,lst},System.map}
84097b24d3dSMarek Vasut	@rm -f $(obj)nand_spl/{u-boot-nand_spl.lds,u-boot-spl,u-boot-spl.map}
84197b24d3dSMarek Vasut	@rm -f $(obj)spl/{u-boot-spl,u-boot-spl.bin,u-boot-spl.map}
84297b24d3dSMarek Vasut	@rm -f $(obj)spl/{u-boot-spl.lds,u-boot.lst}
843659e559dSTom Rini	@rm -f $(obj)MLO
8448b425b3fSDaniel Schwierzeck	@rm -f $(obj)tools/xway-swap-bytes
845a47a12beSStefan Roese	@rm -f $(obj)arch/powerpc/cpu/mpc824x/bedbug_603e.c
8462d14e36aSYork Sun	@rm -f $(obj)arch/powerpc/cpu/mpc83xx/ddr-gen?.c
847a9d8bc98SLoïc Minier	@rm -fr $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
84816a354f9SWolfgang Denk	@rm -fr $(obj)include/generated
849a958b663SJean-Christophe PLAGNIOL-VILLARD	@[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f
850bbb0b128SSimon Glass	@rm -f $(obj)dts/*.tmp
8516d660e77SSughosh Ganu	@rm -f $(obj)spl/u-boot-spl{,-pad}.ais
8527ebf7443Swdenk
8537ebf7443Swdenkmrproper \
8547ebf7443Swdenkdistclean:	clobber unconfig
855afd077bdSMike Frysingerifneq ($(OBJTREE),$(SRCTREE))
856ae6d1056SWolfgang Denk	rm -rf $(obj)*
857f9328639SMarian Balakowiczendif
8587ebf7443Swdenk
8597ebf7443Swdenkbackup:
8607ebf7443Swdenk	F=`basename $(TOPDIR)` ; cd .. ; \
861d6b93714SIlya Yanok	gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
8627ebf7443Swdenk
8637ebf7443Swdenk#########################################################################
864