xref: /openbmc/u-boot/Makefile (revision fea1ca8e)
17ebf7443Swdenk#
2eca3aeb3SWolfgang Denk# (C) Copyright 2000-2013
37ebf7443Swdenk# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
47ebf7443Swdenk#
5eca3aeb3SWolfgang Denk# SPDX-License-Identifier:	GPL-2.0+
67ebf7443Swdenk#
77ebf7443Swdenk
8d19ad726STom RiniVERSION = 2014
9d19ad726STom RiniPATCHLEVEL = 01
10211e4754SWolfgang DenkSUBLEVEL =
11b44bd2c7STom RiniEXTRAVERSION =
128b9e4787SWolfgang Denkifneq "$(SUBLEVEL)" ""
13881a87ecSWolfgang DenkU_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
148b9e4787SWolfgang Denkelse
158b9e4787SWolfgang DenkU_BOOT_VERSION = $(VERSION).$(PATCHLEVEL)$(EXTRAVERSION)
168b9e4787SWolfgang Denkendif
17efb2172eSSimon GlassTIMESTAMP_FILE = $(obj)include/generated/timestamp_autogenerated.h
18efb2172eSSimon GlassVERSION_FILE = $(obj)include/generated/version_autogenerated.h
19881a87ecSWolfgang Denk
207ebf7443SwdenkHOSTARCH := $(shell uname -m | \
21fea25720SGraeme Russ	sed -e s/i.86/x86/ \
227ebf7443Swdenk	    -e s/sun4u/sparc64/ \
237ebf7443Swdenk	    -e s/arm.*/arm/ \
247ebf7443Swdenk	    -e s/sa110/arm/ \
25d0179083SKumar Gala	    -e s/ppc64/powerpc/ \
26d0179083SKumar Gala	    -e s/ppc/powerpc/ \
278d1f6355SNobuhiro Iwamatsu	    -e s/macppc/powerpc/\
288d1f6355SNobuhiro Iwamatsu	    -e s/sh.*/sh/)
297ebf7443Swdenk
30f9d77ed3SWolfgang DenkHOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
317ebf7443Swdenk	    sed -e 's/\(cygwin\).*/cygwin/')
327ebf7443Swdenk
33120ae609SBenoît Thébaudeauexport	HOSTARCH HOSTOS
347ebf7443Swdenk
357ebf7443Swdenk# Deal with colliding definitions from tcsh etc.
367ebf7443SwdenkVENDOR=
377ebf7443Swdenk
387ebf7443Swdenk#########################################################################
39ae6d1056SWolfgang Denk# Allow for silent builds
40ae6d1056SWolfgang Denkifeq (,$(findstring s,$(MAKEFLAGS)))
41ae6d1056SWolfgang DenkXECHO = echo
42ae6d1056SWolfgang Denkelse
43ae6d1056SWolfgang DenkXECHO = :
44ae6d1056SWolfgang Denkendif
45ae6d1056SWolfgang Denk
46ae6d1056SWolfgang Denk#########################################################################
47f9328639SMarian Balakowicz#
481bce2aebSRobert P. J. Day# U-boot build supports generating object files in a separate external
49f9328639SMarian Balakowicz# directory. Two use cases are supported:
50f9328639SMarian Balakowicz#
51f9328639SMarian Balakowicz# 1) Add O= to the make command line
52f9328639SMarian Balakowicz# 'make O=/tmp/build all'
53f9328639SMarian Balakowicz#
541bce2aebSRobert P. J. Day# 2) Set environment variable BUILD_DIR to point to the desired location
55f9328639SMarian Balakowicz# 'export BUILD_DIR=/tmp/build'
56f9328639SMarian Balakowicz# 'make'
57f9328639SMarian Balakowicz#
58f9328639SMarian Balakowicz# The second approach can also be used with a MAKEALL script
59f9328639SMarian Balakowicz# 'export BUILD_DIR=/tmp/build'
60f9328639SMarian Balakowicz# './MAKEALL'
61f9328639SMarian Balakowicz#
621bce2aebSRobert P. J. Day# Command line 'O=' setting overrides BUILD_DIR environment variable.
63f9328639SMarian Balakowicz#
64f9328639SMarian Balakowicz# When none of the above methods is used the local build is performed and
65f9328639SMarian Balakowicz# the object files are placed in the source directory.
66f9328639SMarian Balakowicz#
677ebf7443Swdenk
68f9328639SMarian Balakowiczifeq ("$(origin O)", "command line")
69f9328639SMarian BalakowiczBUILD_DIR := $(O)
70f9328639SMarian Balakowiczendif
717ebf7443Swdenk
724ab64933SKim Phillips# Call a source code checker (by default, "sparse") as part of the
734ab64933SKim Phillips# C compilation.
744ab64933SKim Phillips#
754ab64933SKim Phillips# Use 'make C=1' to enable checking of re-compiled files.
764ab64933SKim Phillips#
774ab64933SKim Phillips# See the linux kernel file "Documentation/sparse.txt" for more details,
784ab64933SKim Phillips# including where to get the "sparse" utility.
794ab64933SKim Phillips
804ab64933SKim Phillipsifdef C
814ab64933SKim Phillipsifeq ("$(origin C)", "command line")
824ab64933SKim PhillipsCHECKSRC := $(C)
834ab64933SKim Phillipsendif
844ab64933SKim Phillipsendif
854ab64933SKim Phillipsifndef CHECKSRC
864ab64933SKim Phillips  CHECKSRC = 0
874ab64933SKim Phillipsendif
884ab64933SKim Phillipsexport CHECKSRC
894ab64933SKim Phillips
90f9328639SMarian Balakowiczifneq ($(BUILD_DIR),)
91f9328639SMarian Balakowiczsaved-output := $(BUILD_DIR)
924f0645ebSMarian Balakowicz
934f0645ebSMarian Balakowicz# Attempt to create a output directory.
944f0645ebSMarian Balakowicz$(shell [ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR})
954f0645ebSMarian Balakowicz
964f0645ebSMarian Balakowicz# Verify if it was successful.
97f9328639SMarian BalakowiczBUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd)
98f9328639SMarian Balakowicz$(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist))
99f9328639SMarian Balakowiczendif # ifneq ($(BUILD_DIR),)
100f9328639SMarian Balakowicz
101f9328639SMarian BalakowiczOBJTREE		:= $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))
102c8f9c302SDaniel SchwierzeckSPLTREE		:= $(OBJTREE)/spl
1033aa29de0SYing ZhangTPLTREE		:= $(OBJTREE)/tpl
104f9328639SMarian BalakowiczSRCTREE		:= $(CURDIR)
105bf4b3de1SMasahiro Yamadasrctree		:= $(SRCTREE)
106f9328639SMarian BalakowiczTOPDIR		:= $(SRCTREE)
107f9328639SMarian BalakowiczLNDIR		:= $(OBJTREE)
108bf4b3de1SMasahiro Yamadaexport	TOPDIR SRCTREE srctree OBJTREE SPLTREE TPLTREE
109f9328639SMarian Balakowicz
110f9328639SMarian BalakowiczMKCONFIG	:= $(SRCTREE)/mkconfig
111f9328639SMarian Balakowiczexport MKCONFIG
112f9328639SMarian Balakowicz
113f9328639SMarian Balakowicz# $(obj) and (src) are defined in config.mk but here in main Makefile
114f9328639SMarian Balakowicz# we also need them before config.mk is included which is the case for
115f9328639SMarian Balakowicz# some targets like unconfig, clean, clobber, distclean, etc.
116f9328639SMarian Balakowiczifneq ($(OBJTREE),$(SRCTREE))
117f9328639SMarian Balakowiczobj := $(OBJTREE)/
118f9328639SMarian Balakowiczsrc := $(SRCTREE)/
119f9328639SMarian Balakowiczelse
120f9328639SMarian Balakowiczobj :=
121f9328639SMarian Balakowiczsrc :=
122f9328639SMarian Balakowiczendif
123f9328639SMarian Balakowiczexport obj src
124f9328639SMarian Balakowicz
1255013c09fSWolfgang Denk# Make sure CDPATH settings don't interfere
1265013c09fSWolfgang Denkunexport CDPATH
1275013c09fSWolfgang Denk
128f9328639SMarian Balakowicz#########################################################################
129f9328639SMarian Balakowicz
1306d1ce387SMike Frysinger# The "tools" are needed early, so put this first
1316d1ce387SMike Frysinger# Don't include stuff already done in $(LIBS)
132349e83f0SChe-liang Chiou# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
133349e83f0SChe-liang Chiou# is "yes"), so compile examples after U-Boot is compiled.
134349e83f0SChe-liang ChiouSUBDIR_TOOLS = tools
135349e83f0SChe-liang ChiouSUBDIRS = $(SUBDIR_TOOLS)
1366d1ce387SMike Frysinger
137249b53a6SLoïc Minier.PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE)
1386d1ce387SMike Frysinger
139ae6d1056SWolfgang Denkifeq ($(obj)include/config.mk,$(wildcard $(obj)include/config.mk))
140f9328639SMarian Balakowicz
1412632c008SMike Frysinger# Include autoconf.mk before config.mk so that the config options are available
1422632c008SMike Frysinger# to all top level build files.  We need the dummy all: target to prevent the
1432632c008SMike Frysinger# dependency target in autoconf.mk.dep from being the default.
1442632c008SMike Frysingerall:
1452632c008SMike Frysingersinclude $(obj)include/autoconf.mk.dep
1462632c008SMike Frysingersinclude $(obj)include/autoconf.mk
1472632c008SMike Frysinger
1488a7e7d56SMasahiro YamadaSUBDIR_EXAMPLES-y := examples/standalone
1498a7e7d56SMasahiro YamadaSUBDIR_EXAMPLES-$(CONFIG_API) += examples/api
150b5728756SSimon Glassifndef CONFIG_SANDBOX
1518a7e7d56SMasahiro YamadaSUBDIRS += $(SUBDIR_EXAMPLES-y)
152b5728756SSimon Glassendif
153b5728756SSimon Glass
1547ebf7443Swdenk# load ARCH, BOARD, and CPU configuration
155ae6d1056SWolfgang Denkinclude $(obj)include/config.mk
1561d9f4105Swdenkexport	ARCH CPU BOARD VENDOR SOC
157f9328639SMarian Balakowicz
1581ea6bcd8SMike Frysinger# set default to nothing for native builds
159a5284efdSWolfgang Denkifeq ($(HOSTARCH),$(ARCH))
1601ea6bcd8SMike FrysingerCROSS_COMPILE ?=
1617ebf7443Swdenkendif
1627ebf7443Swdenk
163f6322eb7SMasahiro Yamada# SHELL used by kbuild
164f6322eb7SMasahiro YamadaCONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
165f6322eb7SMasahiro Yamada	  else if [ -x /bin/bash ]; then echo /bin/bash; \
166f6322eb7SMasahiro Yamada	  else echo sh; fi ; fi)
167f6322eb7SMasahiro Yamada
168f6322eb7SMasahiro YamadaHOSTCC       = gcc
169f6322eb7SMasahiro YamadaHOSTCFLAGS   = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
170f6322eb7SMasahiro Yamada
171f6322eb7SMasahiro Yamadaifeq ($(HOSTOS),cygwin)
172f6322eb7SMasahiro YamadaHOSTCFLAGS	+= -ansi
173f6322eb7SMasahiro Yamadaendif
174f6322eb7SMasahiro Yamada
175f6322eb7SMasahiro Yamada# Mac OS X / Darwin's C preprocessor is Apple specific.  It
176f6322eb7SMasahiro Yamada# generates numerous errors and warnings.  We want to bypass it
177f6322eb7SMasahiro Yamada# and use GNU C's cpp.	To do this we pass the -traditional-cpp
178f6322eb7SMasahiro Yamada# option to the compiler.  Note that the -traditional-cpp flag
179f6322eb7SMasahiro Yamada# DOES NOT have the same semantics as GNU C's flag, all it does
180f6322eb7SMasahiro Yamada# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
181f6322eb7SMasahiro Yamada#
182f6322eb7SMasahiro Yamada# Apple's linker is similar, thanks to the new 2 stage linking
183f6322eb7SMasahiro Yamada# multiple symbol definitions are treated as errors, hence the
184f6322eb7SMasahiro Yamada# -multiply_defined suppress option to turn off this error.
185f6322eb7SMasahiro Yamada#
186f6322eb7SMasahiro Yamadaifeq ($(HOSTOS),darwin)
187f6322eb7SMasahiro Yamada# get major and minor product version (e.g. '10' and '6' for Snow Leopard)
188f6322eb7SMasahiro YamadaDARWIN_MAJOR_VERSION	= $(shell sw_vers -productVersion | cut -f 1 -d '.')
189f6322eb7SMasahiro YamadaDARWIN_MINOR_VERSION	= $(shell sw_vers -productVersion | cut -f 2 -d '.')
190f6322eb7SMasahiro Yamada
191f6322eb7SMasahiro Yamadaos_x_before	= $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \
192f6322eb7SMasahiro Yamada	$(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;)
193f6322eb7SMasahiro Yamada
194f6322eb7SMasahiro Yamada# Snow Leopards build environment has no longer restrictions as described above
195f6322eb7SMasahiro YamadaHOSTCC       = $(call os_x_before, 10, 5, "cc", "gcc")
196f6322eb7SMasahiro YamadaHOSTCFLAGS  += $(call os_x_before, 10, 4, "-traditional-cpp")
197f6322eb7SMasahiro YamadaHOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress")
198f6322eb7SMasahiro Yamadaendif
199f6322eb7SMasahiro Yamada
200bf4b3de1SMasahiro Yamada# We need some generic definitions (do not try to remake the file).
201bf4b3de1SMasahiro Yamada$(srctree)/scripts/Kbuild.include: ;
202bf4b3de1SMasahiro Yamadainclude $(srctree)/scripts/Kbuild.include
203bf4b3de1SMasahiro Yamada
204f6322eb7SMasahiro Yamada# Make variables (CC, etc...)
205f6322eb7SMasahiro Yamada
206f6322eb7SMasahiro YamadaAS		= $(CROSS_COMPILE)as
207f6322eb7SMasahiro Yamada# Always use GNU ld
208f6322eb7SMasahiro Yamadaifneq ($(shell $(CROSS_COMPILE)ld.bfd -v 2> /dev/null),)
209f6322eb7SMasahiro YamadaLD		= $(CROSS_COMPILE)ld.bfd
210f6322eb7SMasahiro Yamadaelse
211f6322eb7SMasahiro YamadaLD		= $(CROSS_COMPILE)ld
212f6322eb7SMasahiro Yamadaendif
213f6322eb7SMasahiro YamadaCC		= $(CROSS_COMPILE)gcc
214f6322eb7SMasahiro YamadaCPP		= $(CC) -E
215f6322eb7SMasahiro YamadaAR		= $(CROSS_COMPILE)ar
216f6322eb7SMasahiro YamadaNM		= $(CROSS_COMPILE)nm
217f6322eb7SMasahiro YamadaLDR		= $(CROSS_COMPILE)ldr
218f6322eb7SMasahiro YamadaSTRIP		= $(CROSS_COMPILE)strip
219f6322eb7SMasahiro YamadaOBJCOPY		= $(CROSS_COMPILE)objcopy
220f6322eb7SMasahiro YamadaOBJDUMP		= $(CROSS_COMPILE)objdump
221f6322eb7SMasahiro YamadaAWK		= awk
222f6322eb7SMasahiro YamadaRANLIB		= $(CROSS_COMPILE)RANLIB
223f6322eb7SMasahiro YamadaDTC		= dtc
224f6322eb7SMasahiro YamadaCHECK		= sparse
225f6322eb7SMasahiro Yamada
226f6322eb7SMasahiro YamadaCHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
227f6322eb7SMasahiro Yamada		  -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
228f6322eb7SMasahiro Yamada
229*fea1ca8eSMasahiro Yamada# Use UBOOTINCLUDE when you must reference the include/ directory.
230*fea1ca8eSMasahiro Yamada# Needed to be compatible with the O= option
231*fea1ca8eSMasahiro YamadaUBOOTINCLUDE    :=
232*fea1ca8eSMasahiro Yamadaifneq ($(OBJTREE),$(SRCTREE))
233*fea1ca8eSMasahiro YamadaUBOOTINCLUDE	+= -I$(OBJTREE)/include
234*fea1ca8eSMasahiro Yamadaendif
235*fea1ca8eSMasahiro YamadaUBOOTINCLUDE	+= -I$(srctree)/include \
236*fea1ca8eSMasahiro Yamada		-I$(srctree)/arch/$(ARCH)/include
237*fea1ca8eSMasahiro Yamada
2382b3c9d3dSMasahiro YamadaKBUILD_CPPFLAGS := -D__KERNEL__
2392b3c9d3dSMasahiro Yamada
2402b3c9d3dSMasahiro YamadaKBUILD_CFLAGS   := -Wall -Wstrict-prototypes \
2412b3c9d3dSMasahiro Yamada		   -Wno-format-security \
2422b3c9d3dSMasahiro Yamada		   -fno-builtin -ffreestanding
2432b3c9d3dSMasahiro YamadaKBUILD_AFLAGS   := -D__ASSEMBLY__
2442b3c9d3dSMasahiro Yamada
245f6322eb7SMasahiro Yamadaexport CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC
246f6322eb7SMasahiro Yamadaexport CPP AR NM LDR STRIP OBJCOPY OBJDUMP
247f6322eb7SMasahiro Yamadaexport MAKE AWK
248f6322eb7SMasahiro Yamadaexport DTC CHECK CHECKFLAGS
249f6322eb7SMasahiro Yamada
250*fea1ca8eSMasahiro Yamadaexport KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE
2512b3c9d3dSMasahiro Yamadaexport KBUILD_CFLAGS KBUILD_AFLAGS
2522b3c9d3dSMasahiro Yamada
2532b3c9d3dSMasahiro YamadaKBUILD_CFLAGS += -Os #-fomit-frame-pointer
2542b3c9d3dSMasahiro Yamada
2552b3c9d3dSMasahiro Yamadaifdef BUILD_TAG
2562b3c9d3dSMasahiro YamadaKBUILD_CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"'
2572b3c9d3dSMasahiro Yamadaendif
2582b3c9d3dSMasahiro Yamada
2592b3c9d3dSMasahiro YamadaKBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
2602b3c9d3dSMasahiro Yamada
2612b3c9d3dSMasahiro YamadaKBUILD_CFLAGS	+= -g
2622b3c9d3dSMasahiro Yamada# $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
2632b3c9d3dSMasahiro Yamada# option to the assembler.
2642b3c9d3dSMasahiro YamadaKBUILD_AFLAGS	+= -g
2652b3c9d3dSMasahiro Yamada
266*fea1ca8eSMasahiro YamadaNOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
267*fea1ca8eSMasahiro YamadaCHECKFLAGS     += $(NOSTDINC_FLAGS)
268*fea1ca8eSMasahiro Yamada
2692b3c9d3dSMasahiro Yamada# Report stack usage if supported
2702b3c9d3dSMasahiro YamadaKBUILD_CFLAGS += $(call cc-option,-fstack-usage)
2712b3c9d3dSMasahiro Yamada
2722b3c9d3dSMasahiro YamadaKBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral)
2732b3c9d3dSMasahiro Yamada
2742b3c9d3dSMasahiro Yamada# turn jbsr into jsr for m68k
2752b3c9d3dSMasahiro Yamadaifeq ($(ARCH),m68k)
2762b3c9d3dSMasahiro Yamadaifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
2772b3c9d3dSMasahiro YamadaKBUILD_AFLAGS += -Wa,-gstabs,-S
2782b3c9d3dSMasahiro Yamadaendif
2792b3c9d3dSMasahiro Yamadaendif
2802b3c9d3dSMasahiro Yamada
28192b197f0SWolfgang Denk# load other configuration
28292b197f0SWolfgang Denkinclude $(TOPDIR)/config.mk
28392b197f0SWolfgang Denk
284fada9e20SSimon Glass# Targets which don't build the source code
285ace8f506SBo ShenNON_BUILD_TARGETS = backup clean clobber distclean mrproper tidy unconfig
286fada9e20SSimon Glass
287fada9e20SSimon Glass# Only do the generic board check when actually building, not configuring
288fada9e20SSimon Glassifeq ($(filter $(NON_BUILD_TARGETS),$(MAKECMDGOALS)),)
289fada9e20SSimon Glassifeq ($(findstring _config,$(MAKECMDGOALS)),)
290fada9e20SSimon Glass$(CHECK_GENERIC_BOARD)
291fada9e20SSimon Glassendif
292fada9e20SSimon Glassendif
293fada9e20SSimon Glass
294d51dfff7SIlya Yanok# If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
295d51dfff7SIlya Yanok# that (or fail if absent).  Otherwise, search for a linker script in a
296d51dfff7SIlya Yanok# standard location.
297d51dfff7SIlya Yanok
298ee60197eSSimon GlassLDSCRIPT_MAKEFILE_DIR = $(dir $(LDSCRIPT))
299ee60197eSSimon Glass
300d51dfff7SIlya Yanokifndef LDSCRIPT
301d51dfff7SIlya Yanok	#LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
302d51dfff7SIlya Yanok	ifdef CONFIG_SYS_LDSCRIPT
303d51dfff7SIlya Yanok		# need to strip off double quotes
304a8c07541SMasahiro Yamada		LDSCRIPT := $(CONFIG_SYS_LDSCRIPT:"%"=%)
305d51dfff7SIlya Yanok	endif
306d51dfff7SIlya Yanokendif
307d51dfff7SIlya Yanok
308ee60197eSSimon Glass# If there is no specified link script, we look in a number of places for it
309d51dfff7SIlya Yanokifndef LDSCRIPT
310d51dfff7SIlya Yanok	ifeq ($(CONFIG_NAND_U_BOOT),y)
311d51dfff7SIlya Yanok		LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
312d51dfff7SIlya Yanok		ifeq ($(wildcard $(LDSCRIPT)),)
313d51dfff7SIlya Yanok			LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds
314d51dfff7SIlya Yanok		endif
315d51dfff7SIlya Yanok	endif
316d51dfff7SIlya Yanok	ifeq ($(wildcard $(LDSCRIPT)),)
317d51dfff7SIlya Yanok		LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
318d51dfff7SIlya Yanok	endif
319d51dfff7SIlya Yanok	ifeq ($(wildcard $(LDSCRIPT)),)
320d51dfff7SIlya Yanok		LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot.lds
321d51dfff7SIlya Yanok	endif
322d51dfff7SIlya Yanok	ifeq ($(wildcard $(LDSCRIPT)),)
323ee60197eSSimon Glass		LDSCRIPT := $(TOPDIR)/arch/$(ARCH)/cpu/u-boot.lds
324ee60197eSSimon Glass		# We don't expect a Makefile here
325ee60197eSSimon Glass		LDSCRIPT_MAKEFILE_DIR =
326ee60197eSSimon Glass	endif
327ee60197eSSimon Glass	ifeq ($(wildcard $(LDSCRIPT)),)
328d51dfff7SIlya Yanok$(error could not find linker script)
329d51dfff7SIlya Yanok	endif
330d51dfff7SIlya Yanokendif
331d51dfff7SIlya Yanok
3327ebf7443Swdenk#########################################################################
3337ebf7443Swdenk# U-Boot objects....order is important (i.e. start must be first)
3347ebf7443Swdenk
335e8a8b824SMasahiro Yamadahead-y := $(CPUDIR)/start.o
336e8a8b824SMasahiro Yamadahead-$(CONFIG_4xx) += arch/powerpc/cpu/ppc4xx/resetvec.o
337e8a8b824SMasahiro Yamadahead-$(CONFIG_MPC85xx) += arch/powerpc/cpu/mpc85xx/resetvec.o
3387ebf7443Swdenk
339e8a8b824SMasahiro YamadaOBJS := $(addprefix $(obj),$(head-y))
340f9328639SMarian Balakowicz
3418b5a0264SDaniel SchwierzeckHAVE_VENDOR_COMMON_LIB = $(if $(wildcard board/$(VENDOR)/common/Makefile),y,n)
3428b5a0264SDaniel Schwierzeck
343e2906a59SMasahiro YamadaLIBS-y += lib/
344e2906a59SMasahiro YamadaLIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
345e2906a59SMasahiro YamadaLIBS-y += $(CPUDIR)/
3461d9f4105Swdenkifdef SOC
347e2906a59SMasahiro YamadaLIBS-y += $(CPUDIR)/$(SOC)/
3481d9f4105Swdenkendif
349e2906a59SMasahiro YamadaLIBS-$(CONFIG_IXP4XX_NPE) += drivers/net/npe/
350e2906a59SMasahiro YamadaLIBS-$(CONFIG_OF_EMBED) += dts/
351e2906a59SMasahiro YamadaLIBS-y += arch/$(ARCH)/lib/
35257c3e5fcSMasahiro YamadaLIBS-y += fs/
353e2906a59SMasahiro YamadaLIBS-y += net/
354e2906a59SMasahiro YamadaLIBS-y += disk/
355e2906a59SMasahiro YamadaLIBS-y += drivers/
356e2906a59SMasahiro YamadaLIBS-y += drivers/dma/
357e2906a59SMasahiro YamadaLIBS-y += drivers/gpio/
358e2906a59SMasahiro YamadaLIBS-y += drivers/i2c/
359e2906a59SMasahiro YamadaLIBS-y += drivers/input/
360e2906a59SMasahiro YamadaLIBS-y += drivers/mmc/
361e2906a59SMasahiro YamadaLIBS-y += drivers/mtd/
362392ba525SMasahiro YamadaLIBS-$(CONFIG_CMD_NAND) += drivers/mtd/nand/
363e2906a59SMasahiro YamadaLIBS-y += drivers/mtd/onenand/
364392ba525SMasahiro YamadaLIBS-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/
365e2906a59SMasahiro YamadaLIBS-y += drivers/mtd/spi/
366e2906a59SMasahiro YamadaLIBS-y += drivers/net/
367e2906a59SMasahiro YamadaLIBS-y += drivers/net/phy/
368e2906a59SMasahiro YamadaLIBS-y += drivers/pci/
369e2906a59SMasahiro YamadaLIBS-y += drivers/power/ \
370e2906a59SMasahiro Yamada	drivers/power/fuel_gauge/ \
371e2906a59SMasahiro Yamada	drivers/power/mfd/ \
372e2906a59SMasahiro Yamada	drivers/power/pmic/ \
373e2906a59SMasahiro Yamada	drivers/power/battery/
374e2906a59SMasahiro YamadaLIBS-y += drivers/spi/
375e2906a59SMasahiro YamadaLIBS-$(CONFIG_FMAN_ENET) += drivers/net/fm/
3765614e71bSYork SunLIBS-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/
377e2906a59SMasahiro YamadaLIBS-y += drivers/serial/
378e2906a59SMasahiro YamadaLIBS-y += drivers/usb/eth/
379e2906a59SMasahiro YamadaLIBS-y += drivers/usb/gadget/
380e2906a59SMasahiro YamadaLIBS-y += drivers/usb/host/
381e2906a59SMasahiro YamadaLIBS-y += drivers/usb/musb/
382e2906a59SMasahiro YamadaLIBS-y += drivers/usb/musb-new/
383e2906a59SMasahiro YamadaLIBS-y += drivers/usb/phy/
384e2906a59SMasahiro YamadaLIBS-y += drivers/usb/ulpi/
385e2906a59SMasahiro YamadaLIBS-y += common/
386e2906a59SMasahiro YamadaLIBS-y += lib/libfdt/
3878a7e7d56SMasahiro YamadaLIBS-$(CONFIG_API) += api/
388755e08f0SMasahiro YamadaLIBS-$(CONFIG_HAS_POST) += post/
389e2906a59SMasahiro YamadaLIBS-y += test/
390f9328639SMarian Balakowicz
39124e8bee5SAlison Wangifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610))
392e2906a59SMasahiro YamadaLIBS-y += arch/$(ARCH)/imx-common/
39318936ee2SJason Liuendif
39418936ee2SJason Liu
395e2906a59SMasahiro YamadaLIBS-$(CONFIG_ARM) += arch/arm/cpu/
396e2906a59SMasahiro YamadaLIBS-$(CONFIG_PPC) += arch/powerpc/cpu/
397852bd07cSMinkyu Kang
398e2906a59SMasahiro YamadaLIBS-y += board/$(BOARDDIR)/
39908e39a84SMasahiro Yamada
400e2906a59SMasahiro YamadaLIBS-y := $(patsubst %/, %/built-in.o, $(LIBS-y))
401f52d7b35SDaniel SchwierzeckLIBS := $(addprefix $(obj),$(sort $(LIBS-y)))
402249b53a6SLoïc Minier.PHONY : $(LIBS)
403a8c7c708Swdenk
4044f7cb08eSwdenk# Add GCC lib
40552b1bf2cSWolfgang Denkifdef USE_PRIVATE_LIBGCC
40652b1bf2cSWolfgang Denkifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
407635d1b3eSMatthias WeisserPLATFORM_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/libgcc.o
40852b1bf2cSWolfgang Denkelse
40952b1bf2cSWolfgang DenkPLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc
41052b1bf2cSWolfgang Denkendif
41152b1bf2cSWolfgang Denkelse
412cca4e4aeSWolfgang DenkPLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
41352b1bf2cSWolfgang Denkendif
41452b1bf2cSWolfgang DenkPLATFORM_LIBS += $(PLATFORM_LIBGCC)
41552b1bf2cSWolfgang Denkexport PLATFORM_LIBS
4163d3befa7Swdenk
4176ac9f479SMike Frysinger# Special flags for CPP when processing the linker script.
4186ac9f479SMike Frysinger# Pass the version down so we can handle backwards compatibility
4196ac9f479SMike Frysinger# on the fly.
4206ac9f479SMike FrysingerLDPPFLAGS += \
4216ac9f479SMike Frysinger	-include $(TOPDIR)/include/u-boot/u-boot.lds.h \
4227e6403a6SSimon Glass	-DCPUDIR=$(CPUDIR) \
4236ac9f479SMike Frysinger	$(shell $(LD) --version | \
4246ac9f479SMike Frysinger	  sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
4256ac9f479SMike Frysinger
426f9328639SMarian Balakowicz__OBJS := $(subst $(obj),,$(OBJS))
42708e39a84SMasahiro Yamada__LIBS := $(subst $(obj),,$(LIBS))
428f9328639SMarian Balakowicz
4297ebf7443Swdenk#########################################################################
430bdccc4feSwdenk#########################################################################
4317ebf7443Swdenk
432f3a14d37SMike Frysingerifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
433f3a14d37SMike FrysingerBOARD_SIZE_CHECK = \
434f3a14d37SMike Frysinger	@actual=`wc -c $@ | awk '{print $$1}'`; \
435d060e6f4SJoe Hershberger	limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
436f3a14d37SMike Frysinger	if test $$actual -gt $$limit; then \
437d060e6f4SJoe Hershberger		echo "$@ exceeds file size limit:" >&2 ; \
438d060e6f4SJoe Hershberger		echo "  limit:  $$limit bytes" >&2 ; \
439d060e6f4SJoe Hershberger		echo "  actual: $$actual bytes" >&2 ; \
440d060e6f4SJoe Hershberger		echo "  excess: $$((actual - limit)) bytes" >&2; \
441f3a14d37SMike Frysinger		exit 1; \
442f3a14d37SMike Frysinger	fi
443f3a14d37SMike Frysingerelse
444f3a14d37SMike FrysingerBOARD_SIZE_CHECK =
445f3a14d37SMike Frysingerendif
446f3a14d37SMike Frysinger
4478137af19SScott Wood# Statically apply RELA-style relocations (currently arm64 only)
4488137af19SScott Woodifneq ($(CONFIG_STATIC_RELA),)
4498137af19SScott Wood# $(1) is u-boot ELF, $(2) is u-boot bin, $(3) is text base
4508137af19SScott WoodDO_STATIC_RELA = \
4518137af19SScott Wood	start=$$($(NM) $(1) | grep __rel_dyn_start | cut -f 1 -d ' '); \
4528137af19SScott Wood	end=$$($(NM) $(1) | grep __rel_dyn_end | cut -f 1 -d ' '); \
4538137af19SScott Wood	$(obj)tools/relocate-rela $(2) $(3) $$start $$end
4548137af19SScott Woodelse
4558137af19SScott WoodDO_STATIC_RELA =
4568137af19SScott Woodendif
4578137af19SScott Wood
4583e88337bSMike Frysinger# Always append ALL so that arch config.mk's can add custom ones
4594e0fbb98SDaniel SchwierzeckALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map
460e935a374SHaiying Wang
4614e0fbb98SDaniel SchwierzeckALL-$(CONFIG_NAND_U_BOOT) += $(obj)u-boot-nand.bin
4624e0fbb98SDaniel SchwierzeckALL-$(CONFIG_ONENAND_U_BOOT) += $(obj)u-boot-onenand.bin
463262737f0SShaohui XieALL-$(CONFIG_RAMBOOT_PBL) += $(obj)u-boot.pbl
4645df2ee27SDaniel SchwierzeckALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin
4654c267374SHenrik NordströmALL-$(CONFIG_SPL_FRAMEWORK) += $(obj)u-boot.img
4663aa29de0SYing ZhangALL-$(CONFIG_TPL) += $(obj)tpl/u-boot-tpl.bin
4672c0f79e4SSimon GlassALL-$(CONFIG_OF_SEPARATE) += $(obj)u-boot.dtb $(obj)u-boot-dtb.bin
468b343bbb5SVadim Bendeburyifneq ($(CONFIG_SPL_TARGET),)
469a8c07541SMasahiro YamadaALL-$(CONFIG_SPL) += $(obj)$(CONFIG_SPL_TARGET:"%"=%)
470b343bbb5SVadim Bendeburyendif
471f4dc714aSScott WoodALL-$(CONFIG_REMAKE_ELF) += $(obj)u-boot.elf
4727ebf7443Swdenk
47312b7b70cSAllen Martin# enable combined SPL/u-boot/dtb rules for tegra
4746d6c0baeSTom Warrenifneq ($(CONFIG_TEGRA),)
4757dcd3a21SVidya Sagarifeq ($(CONFIG_SPL),y)
47612b7b70cSAllen Martinifeq ($(CONFIG_OF_SEPARATE),y)
47712b7b70cSAllen MartinALL-y += $(obj)u-boot-dtb-tegra.bin
47812b7b70cSAllen Martinelse
47912b7b70cSAllen MartinALL-y += $(obj)u-boot-nodtb-tegra.bin
48012b7b70cSAllen Martinendif
48112b7b70cSAllen Martinendif
4827dcd3a21SVidya Sagarendif
48312b7b70cSAllen Martin
4848a7e7d56SMasahiro Yamadaall:		$(ALL-y) $(SUBDIR_EXAMPLES-y)
4857ebf7443Swdenk
486501ebdf2SStephen Warren$(obj)u-boot.dtb:	checkdtc $(obj)u-boot
487bcfe8fdfSMasahiro Yamada		$(MAKE) $(build) dts binary
4882c0f79e4SSimon Glass		mv $(obj)dts/dt.dtb $@
4892c0f79e4SSimon Glass
4902c0f79e4SSimon Glass$(obj)u-boot-dtb.bin:	$(obj)u-boot.bin $(obj)u-boot.dtb
4912c0f79e4SSimon Glass		cat $^ >$@
4922c0f79e4SSimon Glass
493f9328639SMarian Balakowicz$(obj)u-boot.hex:	$(obj)u-boot
4946310eb9dSwdenk		$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
4956310eb9dSwdenk
496f9328639SMarian Balakowicz$(obj)u-boot.srec:	$(obj)u-boot
49747ed5dd0SAlbert ARIBAUD		$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@
4987ebf7443Swdenk
499f9328639SMarian Balakowicz$(obj)u-boot.bin:	$(obj)u-boot
5007ebf7443Swdenk		$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
5018137af19SScott Wood		$(call DO_STATIC_RELA,$<,$@,$(CONFIG_SYS_TEXT_BASE))
502f3a14d37SMike Frysinger		$(BOARD_SIZE_CHECK)
5037ebf7443Swdenk
50494a91e24SMike Frysinger$(obj)u-boot.ldr:	$(obj)u-boot
50576d82187SMike Frysinger		$(CREATE_LDR_ENV)
50668e56324SMike Frysinger		$(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS)
507f3a14d37SMike Frysinger		$(BOARD_SIZE_CHECK)
50894a91e24SMike Frysinger
50994a91e24SMike Frysinger$(obj)u-boot.ldr.hex:	$(obj)u-boot.ldr
51094a91e24SMike Frysinger		$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ -I binary
51194a91e24SMike Frysinger
51294a91e24SMike Frysinger$(obj)u-boot.ldr.srec:	$(obj)u-boot.ldr
51394a91e24SMike Frysinger		$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ -I binary
51494a91e24SMike Frysinger
515b40bda6bSStefan Roese#
516b40bda6bSStefan Roese# U-Boot entry point, needed for booting of full-blown U-Boot
517b40bda6bSStefan Roese# from the SPL U-Boot version.
518b40bda6bSStefan Roese#
519b40bda6bSStefan Roeseifndef CONFIG_SYS_UBOOT_START
520b40bda6bSStefan RoeseCONFIG_SYS_UBOOT_START := 0
521b40bda6bSStefan Roeseendif
522b40bda6bSStefan Roese
523f9328639SMarian Balakowicz$(obj)u-boot.img:	$(obj)u-boot.bin
524a2a0a717SWolfgang Denk		$(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
525b40bda6bSStefan Roese		-O u-boot -a $(CONFIG_SYS_TEXT_BASE) \
526b40bda6bSStefan Roese		-e $(CONFIG_SYS_UBOOT_START) \
527881a87ecSWolfgang Denk		-n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
528bdccc4feSwdenk			sed -e 's/"[	 ]*$$/ for $(BOARD) board"/') \
529bdccc4feSwdenk		-d $< $@
530bdccc4feSwdenk
531291b3dcdSOtavio Salvador$(obj)u-boot.imx: $(obj)u-boot.bin depend
53271f84ef0SMasahiro Yamada		$(MAKE) $(build) $(SRCTREE)/arch/arm/imx-common $(OBJTREE)/u-boot.imx
5338edcde5eSStefano Babic
534aa0c7a86SPrafulla Wadaskar$(obj)u-boot.kwb:       $(obj)u-boot.bin
53531d80c77SPrafulla Wadaskar		$(obj)tools/mkimage -n $(CONFIG_SYS_KWD_CONFIG) -T kwbimage \
5362ea88b06SEric Cooper		-a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) -d $< $@
537aa0c7a86SPrafulla Wadaskar
5385d898a00SShaohui Xie$(obj)u-boot.pbl:	$(obj)u-boot.bin
539690e4258SPrabhakar Kushwaha		$(obj)tools/mkimage -n $(CONFIG_SYS_FSL_PBL_RCW) \
540690e4258SPrabhakar Kushwaha		-R $(CONFIG_SYS_FSL_PBL_PBI) -T pblimage \
5415d898a00SShaohui Xie		-d $< $@
5425d898a00SShaohui Xie
543566a494fSHeiko Schocher$(obj)u-boot.sha1:	$(obj)u-boot.bin
54401159530SHeiko Schocher		$(obj)tools/ubsha1 $(obj)u-boot.bin
545566a494fSHeiko Schocher
546f9328639SMarian Balakowicz$(obj)u-boot.dis:	$(obj)u-boot
5477ebf7443Swdenk		$(OBJDUMP) -d $< > $@
5487ebf7443Swdenk
5493aa29de0SYing Zhang# $@ is output, $(1) and $(2) are inputs, $(3) is padded intermediate,
5503aa29de0SYing Zhang# $(4) is pad-to
5513aa29de0SYing ZhangSPL_PAD_APPEND = \
5523aa29de0SYing Zhang		$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(4) -I binary -O binary \
5533aa29de0SYing Zhang		$(1) $(obj)$(3); \
554b6df9b01SYork Sun		cat $(obj)$(3) $(2) > $@; \
5553aa29de0SYing Zhang		rm $(obj)$(3)
55674752baaSScott Wood
5573aa29de0SYing Zhangifdef CONFIG_TPL
5583aa29de0SYing ZhangSPL_PAYLOAD := $(obj)tpl/u-boot-with-tpl.bin
5593aa29de0SYing Zhangelse
5603aa29de0SYing ZhangSPL_PAYLOAD := $(obj)u-boot.bin
5613aa29de0SYing Zhangendif
56274752baaSScott Wood
5633aa29de0SYing Zhang$(obj)u-boot-with-spl.bin: $(obj)spl/u-boot-spl.bin $(SPL_PAYLOAD)
5643aa29de0SYing Zhang		$(call SPL_PAD_APPEND,$<,$(SPL_PAYLOAD),spl/u-boot-spl-pad.bin,$(CONFIG_SPL_PAD_TO))
5653aa29de0SYing Zhang
5663aa29de0SYing Zhang$(obj)tpl/u-boot-with-tpl.bin: $(obj)tpl/u-boot-tpl.bin $(obj)u-boot.bin
567b6df9b01SYork Sun		$(call SPL_PAD_APPEND,$<,$(obj)u-boot.bin,tpl/u-boot-tpl-pad.bin,$(CONFIG_TPL_PAD_TO))
5687816f2cfSHeiko Schocher
569ba597609SBenoît Thébaudeau$(obj)u-boot-with-spl.imx: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
57071f84ef0SMasahiro Yamada		$(MAKE) $(build) $(SRCTREE)/arch/arm/imx-common \
571ba597609SBenoît Thébaudeau			$(OBJTREE)/u-boot-with-spl.imx
572ba597609SBenoît Thébaudeau
5737d5a5c79SBenoît Thébaudeau$(obj)u-boot-with-nand-spl.imx: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
57471f84ef0SMasahiro Yamada		$(MAKE) $(build) $(SRCTREE)/arch/arm/imx-common \
5757d5a5c79SBenoît Thébaudeau			$(OBJTREE)/u-boot-with-nand-spl.imx
5767d5a5c79SBenoît Thébaudeau
5775364add4SScott Wood$(obj)u-boot.ubl:       $(obj)u-boot-with-spl.bin
578277f00f5SJosé Miguel Gonçalves		$(obj)tools/mkimage -n $(UBL_CONFIG) -T ublimage \
5795364add4SScott Wood		-e $(CONFIG_SYS_TEXT_BASE) -d $< $(obj)u-boot.ubl
580277f00f5SJosé Miguel Gonçalves
5813f7f2414STom Rini$(obj)u-boot.ais:       $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
5826d660e77SSughosh Ganu		$(obj)tools/mkimage -s -n $(if $(CONFIG_AIS_CONFIG_FILE),$(CONFIG_AIS_CONFIG_FILE),"/dev/null") \
5836d660e77SSughosh Ganu			-T aisimage \
584d36d8859SChristian Riesch			-e $(CONFIG_SPL_TEXT_BASE) \
585d36d8859SChristian Riesch			-d $(obj)spl/u-boot-spl.bin \
586d36d8859SChristian Riesch			$(obj)spl/u-boot-spl.ais
587d36d8859SChristian Riesch		$(OBJCOPY) ${OBJCFLAGS} -I binary \
588d36d8859SChristian Riesch			--pad-to=$(CONFIG_SPL_MAX_SIZE) -O binary \
589d36d8859SChristian Riesch			$(obj)spl/u-boot-spl.ais $(obj)spl/u-boot-spl-pad.ais
5903f7f2414STom Rini		cat $(obj)spl/u-boot-spl-pad.ais $(obj)u-boot.img > \
591d36d8859SChristian Riesch			$(obj)u-boot.ais
592d36d8859SChristian Riesch
593a5453555SOtavio Salvador
59430b9b932SMarek Vasut$(obj)u-boot.sb:       $(obj)u-boot.bin $(obj)spl/u-boot-spl.bin
595edabc1bcSMasahiro Yamada		$(MAKE) $(build) $(SRCTREE)/$(CPUDIR)/$(SOC)/ $(OBJTREE)/u-boot.sb
59630b9b932SMarek Vasut
59794aebe6cSStefan Roese# On x600 (SPEAr600) U-Boot is appended to U-Boot SPL.
59894aebe6cSStefan Roese# Both images are created using mkimage (crc etc), so that the ROM
59994aebe6cSStefan Roese# bootloader can check its integrity. Padding needs to be done to the
60094aebe6cSStefan Roese# SPL image (with mkimage header) and not the binary. Otherwise the resulting image
60194aebe6cSStefan Roese# which is loaded/copied by the ROM bootloader to SRAM doesn't fit.
60294aebe6cSStefan Roese# The resulting image containing both U-Boot images is called u-boot.spr
60394aebe6cSStefan Roese$(obj)u-boot.spr:	$(obj)u-boot.img $(obj)spl/u-boot-spl.bin
60494aebe6cSStefan Roese		$(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
60594aebe6cSStefan Roese		-a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER \
60657270260SMasahiro Yamada		-d $(obj)spl/u-boot-spl.bin $@
60757270260SMasahiro Yamada		$(OBJCOPY) -I binary -O binary \
60857270260SMasahiro Yamada			--pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff $@
60957270260SMasahiro Yamada		cat $(obj)u-boot.img >> $@
61094aebe6cSStefan Roese
6116d6c0baeSTom Warrenifneq ($(CONFIG_TEGRA),)
6129972db5cSStephen Warren$(obj)u-boot-nodtb-tegra.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
613e4ec9346SStephen Warren		$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SYS_TEXT_BASE) -O binary $(obj)spl/u-boot-spl $(obj)spl/u-boot-spl-pad.bin
6149972db5cSStephen Warren		cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin > $@
615e4ec9346SStephen Warren		rm $(obj)spl/u-boot-spl-pad.bin
6169972db5cSStephen Warren
6179972db5cSStephen Warrenifeq ($(CONFIG_OF_SEPARATE),y)
6189972db5cSStephen Warren$(obj)u-boot-dtb-tegra.bin: $(obj)u-boot-nodtb-tegra.bin $(obj)u-boot.dtb
6199972db5cSStephen Warren		cat $(obj)u-boot-nodtb-tegra.bin $(obj)u-boot.dtb > $@
6209972db5cSStephen Warrenendif
621984df4ecSAllen Martinendif
622984df4ecSAllen Martin
623fb3d2b8aSStefan Roese$(obj)u-boot-img.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
624fb3d2b8aSStefan Roese		cat $(obj)spl/u-boot-spl.bin $(obj)u-boot.img > $@
625fb3d2b8aSStefan Roese
626ecddccd0SStefan Roese# PPC4xx needs the SPL at the end of the image, since the reset vector
627ecddccd0SStefan Roese# is located at 0xfffffffc. So we can't use the "u-boot-img.bin" target
628ecddccd0SStefan Roese# and need to introduce a new build target with the full blown U-Boot
629ecddccd0SStefan Roese# at the start padded up to the start of the SPL image. And then concat
630ecddccd0SStefan Roese# the SPL image to the end.
631ecddccd0SStefan Roese$(obj)u-boot-img-spl-at-end.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
63257270260SMasahiro Yamada		$(OBJCOPY) -I binary -O binary --pad-to=$(CONFIG_UBOOT_PAD_TO) \
63357270260SMasahiro Yamada			 --gap-fill=0xff $(obj)u-boot.img $@
63457270260SMasahiro Yamada		cat $(obj)spl/u-boot-spl.bin >> $@
635ecddccd0SStefan Roese
636f4dc714aSScott Wood# Create a new ELF from a raw binary file.  This is useful for arm64
637f4dc714aSScott Wood# where static relocation needs to be performed on the raw binary,
638f4dc714aSScott Wood# but certain simulators only accept an ELF file (but don't do the
639f4dc714aSScott Wood# relocation).
640f4dc714aSScott Wood# FIXME refactor dts/Makefile to share target/arch detection
641f4dc714aSScott Wood$(obj)u-boot.elf: $(obj)u-boot.bin
642f4dc714aSScott Wood	@$(OBJCOPY)  -B aarch64 -I binary -O elf64-littleaarch64 \
643f4dc714aSScott Wood		$< $(obj)u-boot-elf.o
644f4dc714aSScott Wood	@$(LD) $(obj)u-boot-elf.o -o $@ \
645f4dc714aSScott Wood		--defsym=_start=$(CONFIG_SYS_TEXT_BASE) \
646f4dc714aSScott Wood		-Ttext=$(CONFIG_SYS_TEXT_BASE)
647f4dc714aSScott Wood
64886eb49b3SSimon Glassifeq ($(CONFIG_SANDBOX),y)
64986eb49b3SSimon GlassGEN_UBOOT = \
65086eb49b3SSimon Glass		cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \
65186eb49b3SSimon Glass			-Wl,--start-group $(__LIBS) -Wl,--end-group \
65286eb49b3SSimon Glass			$(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot
65386eb49b3SSimon Glasselse
654ecb1dc89SMike FrysingerGEN_UBOOT = \
65597b24d3dSMarek Vasut		cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
656ef123c52SAlbert ARIBAUD			$(__OBJS) \
657f9328639SMarian Balakowicz			--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
658b2184c31Swdenk			-Map u-boot.map -o u-boot
65986eb49b3SSimon Glassendif
66086eb49b3SSimon Glass
66116a354f9SWolfgang Denk$(obj)u-boot:	depend \
6628e9a6cb1SMasahiro Yamada		$(SUBDIR_TOOLS) $(OBJS) $(LIBS) $(obj)u-boot.lds
663ecb1dc89SMike Frysinger		$(GEN_UBOOT)
664ecb1dc89SMike Frysingerifeq ($(CONFIG_KALLSYMS),y)
6658a156fb6SMike Frysinger		smap=`$(call SYSTEM_MAP,$(obj)u-boot) | \
6661aada9cdSWolfgang Denk			awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \
6671aada9cdSWolfgang Denk		$(CC) $(CFLAGS) -DSYSTEM_MAP="\"$${smap}\"" \
6681aada9cdSWolfgang Denk			-c common/system_map.c -o $(obj)common/system_map.o
669ecb1dc89SMike Frysinger		$(GEN_UBOOT) $(obj)common/system_map.o
670ecb1dc89SMike Frysingerendif
6717ebf7443Swdenk
6723bddafaaSMasahiro Yamada$(OBJS):
6733bddafaaSMasahiro Yamada	@:
674f9328639SMarian Balakowicz
675349e83f0SChe-liang Chiou$(LIBS):	depend $(SUBDIR_TOOLS)
6763bddafaaSMasahiro Yamada		$(MAKE) $(build) $(dir $(subst $(obj),,$@))
677a8c7c708Swdenk
6784a20df39SMasahiro Yamada$(SUBDIRS):	depend
679940db16dSMasahiro Yamada		$(MAKE) $(build) $@ all
680940db16dSMasahiro Yamada
6818a7e7d56SMasahiro Yamada$(SUBDIR_EXAMPLES-y): $(obj)u-boot
682349e83f0SChe-liang Chiou
6838e9a6cb1SMasahiro Yamada$(obj)u-boot.lds: $(LDSCRIPT) depend
68497b24d3dSMarek Vasut		$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
6851aada9cdSWolfgang Denk
686e935a374SHaiying Wangnand_spl:	$(TIMESTAMP_FILE) $(VERSION_FILE) depend
687a0b14c3fSMasahiro Yamada		$(MAKE) $(build) nand_spl/board/$(BOARDDIR) all
688887e2ec9SStefan Roese
689e935a374SHaiying Wang$(obj)u-boot-nand.bin:	nand_spl $(obj)u-boot.bin
6908318fbf8SMarian Balakowicz		cat $(obj)nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > $(obj)u-boot-nand.bin
691887e2ec9SStefan Roese
692bd25fdbaSAneesh V$(obj)spl/u-boot-spl.bin:	$(SUBDIR_TOOLS) depend
6935df2ee27SDaniel Schwierzeck		$(MAKE) -C spl all
6945df2ee27SDaniel Schwierzeck
6953aa29de0SYing Zhang$(obj)tpl/u-boot-tpl.bin:	$(SUBDIR_TOOLS) depend
6963aa29de0SYing Zhang		$(MAKE) -C spl all CONFIG_TPL_BUILD=y
6973aa29de0SYing Zhang
6982a998793SDaniel Hobi# Explicitly make _depend in subdirs containing multiple targets to prevent
6992a998793SDaniel Hobi# parallel sub-makes creating .depend files simultaneously.
70016a354f9SWolfgang Denkdepend dep:	$(TIMESTAMP_FILE) $(VERSION_FILE) \
70139bc12ddSJoel Fernandes		$(obj)include/spl-autoconf.mk \
7023aa29de0SYing Zhang		$(obj)include/tpl-autoconf.mk \
70316a354f9SWolfgang Denk		$(obj)include/autoconf.mk \
704a4814a69SStefano Babic		$(obj)include/generated/generic-asm-offsets.h \
705a4814a69SStefano Babic		$(obj)include/generated/asm-offsets.h
7067ebf7443Swdenk
707e5e4e705SLi YangTAG_SUBDIRS = $(SUBDIRS)
708e5e4e705SLi YangTAG_SUBDIRS += $(dir $(__LIBS))
709a340c325SJean-Christophe PLAGNIOL-VILLARDTAG_SUBDIRS += include
710a340c325SJean-Christophe PLAGNIOL-VILLARD
711857d9ea6SHorst KronstorferFIND := find
712857d9ea6SHorst KronstorferFINDFLAGS := -L
713857d9ea6SHorst Kronstorfer
7141064d980STom Rinicheckstack:
7151064d980STom Rini		$(CROSS_COMPILE)objdump -d $(obj)u-boot \
7161064d980STom Rini			`$(FIND) $(obj) -name u-boot-spl -print` | \
717dd88ab32SMasahiro Yamada			perl $(src)scripts/checkstack.pl $(ARCH)
7181064d980STom Rini
719f9328639SMarian Balakowicztags ctags:
720857d9ea6SHorst Kronstorfer		ctags -w -o $(obj)ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
721e5e4e705SLi Yang						-name '*.[chS]' -print`
7227ebf7443Swdenk
7237ebf7443Swdenketags:
724857d9ea6SHorst Kronstorfer		etags -a -o $(obj)etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
725e5e4e705SLi Yang						-name '*.[chS]' -print`
726ffda586fSLi Yangcscope:
727857d9ea6SHorst Kronstorfer		$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \
728857d9ea6SHorst Kronstorfer						cscope.files
729ffda586fSLi Yang		cscope -b -q -k
7307ebf7443Swdenk
731ecb1dc89SMike FrysingerSYSTEM_MAP = \
732ecb1dc89SMike Frysinger		$(NM) $1 | \
7337ebf7443Swdenk		grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
734ecb1dc89SMike Frysinger		LC_ALL=C sort
735ecb1dc89SMike Frysinger$(obj)System.map:	$(obj)u-boot
736bc8bb6ecSMasahiro Yamada		@$(call SYSTEM_MAP,$<) > $@
7377ebf7443Swdenk
73806a119a0STom Rinicheckthumb:
73906a119a0STom Rini	@if test $(call cc-version) -lt 0404; then \
74006a119a0STom Rini		echo -n '*** Your GCC does not produce working '; \
74106a119a0STom Rini		echo 'binaries in THUMB mode.'; \
74206a119a0STom Rini		echo '*** Your board is configured for THUMB mode.'; \
74306a119a0STom Rini		false; \
74406a119a0STom Rini	fi
7456ec63f41SScott Wood
7466ec63f41SScott Wood# GCC 3.x is reported to have problems generating the type of relocation
7476ec63f41SScott Wood# that U-Boot wants.
7486ec63f41SScott Wood# See http://lists.denx.de/pipermail/u-boot/2012-September/135156.html
7496ec63f41SScott Woodcheckgcc4:
7506ec63f41SScott Wood	@if test $(call cc-version) -lt 0400; then \
7516ec63f41SScott Wood		echo -n '*** Your GCC is too old, please upgrade to GCC 4.x or newer'; \
7526ec63f41SScott Wood		false; \
7536ec63f41SScott Wood	fi
7546ec63f41SScott Wood
755501ebdf2SStephen Warrencheckdtc:
756501ebdf2SStephen Warren	@if test $(call dtc-version) -lt 0104; then \
757501ebdf2SStephen Warren		echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \
758501ebdf2SStephen Warren		false; \
759501ebdf2SStephen Warren	fi
760501ebdf2SStephen Warren
7612f155f6cSGrant Likely#
7622f155f6cSGrant Likely# Auto-generate the autoconf.mk file (which is included by all makefiles)
7632f155f6cSGrant Likely#
7642f155f6cSGrant Likely# This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
7652f155f6cSGrant Likely# the dep file is only include in this top level makefile to determine when
7662f155f6cSGrant Likely# to regenerate the autoconf.mk file.
7671510b82dSWolfgang Denk$(obj)include/autoconf.mk.dep: $(obj)include/config.h include/common.h
7681510b82dSWolfgang Denk	@$(XECHO) Generating $@ ; \
769ae6d1056SWolfgang Denk	: Generate the dependancies ; \
7704c34b2a0SMike Frysinger	$(CC) -x c -DDO_DEPS_ONLY -M $(CFLAGS) $(CPPFLAGS) \
77165947ab4SMasahiro Yamada		-MQ $(obj)include/autoconf.mk include/common.h > $@ || \
77265947ab4SMasahiro Yamada		rm $@
7731510b82dSWolfgang Denk
7741510b82dSWolfgang Denk$(obj)include/autoconf.mk: $(obj)include/config.h
7751510b82dSWolfgang Denk	@$(XECHO) Generating $@ ; \
776ae6d1056SWolfgang Denk	: Extract the config macros ; \
77765947ab4SMasahiro Yamada	$(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h > $@.tmp && \
77865947ab4SMasahiro Yamada		sed -n -f tools/scripts/define2mk.sed $@.tmp > $@; \
77965947ab4SMasahiro Yamada	rm $@.tmp
7802f155f6cSGrant Likely
78139bc12ddSJoel Fernandes# Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL)
7823aa29de0SYing Zhang$(obj)include/tpl-autoconf.mk: $(obj)include/config.h
7833aa29de0SYing Zhang	@$(XECHO) Generating $@ ; \
7843aa29de0SYing Zhang	: Extract the config macros ; \
7853aa29de0SYing Zhang	$(CPP) $(CFLAGS) -DCONFIG_TPL_BUILD  -DCONFIG_SPL_BUILD\
78665947ab4SMasahiro Yamada			-DDO_DEPS_ONLY -dM include/common.h > $@.tmp && \
78765947ab4SMasahiro Yamada		sed -n -f tools/scripts/define2mk.sed $@.tmp > $@; \
78865947ab4SMasahiro Yamada	rm $@.tmp
7893aa29de0SYing Zhang
79039bc12ddSJoel Fernandes$(obj)include/spl-autoconf.mk: $(obj)include/config.h
79139bc12ddSJoel Fernandes	@$(XECHO) Generating $@ ; \
79239bc12ddSJoel Fernandes	: Extract the config macros ; \
79365947ab4SMasahiro Yamada	$(CPP) $(CFLAGS) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM include/common.h > $@.tmp && \
79465947ab4SMasahiro Yamada		sed -n -f tools/scripts/define2mk.sed $@.tmp > $@; \
79565947ab4SMasahiro Yamada	rm $@.tmp
79639bc12ddSJoel Fernandes
79774c43bb3SMasahiro Yamada$(obj)include/generated/generic-asm-offsets.h: $(obj)lib/asm-offsets.s
79816a354f9SWolfgang Denk	@$(XECHO) Generating $@
79916a354f9SWolfgang Denk	tools/scripts/make-asm-offsets $(obj)lib/asm-offsets.s $@
80016a354f9SWolfgang Denk
80174c43bb3SMasahiro Yamada$(obj)lib/asm-offsets.s: $(obj)include/config.h $(src)lib/asm-offsets.c
80216a354f9SWolfgang Denk	@mkdir -p $(obj)lib
80316a354f9SWolfgang Denk	$(CC) -DDO_DEPS_ONLY \
80416a354f9SWolfgang Denk		$(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
80516a354f9SWolfgang Denk		-o $@ $(src)lib/asm-offsets.c -c -S
80616a354f9SWolfgang Denk
80774c43bb3SMasahiro Yamada$(obj)include/generated/asm-offsets.h: $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s
808b12734eeSWolfgang Denk	@$(XECHO) Generating $@
809a4814a69SStefano Babic	tools/scripts/make-asm-offsets $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s $@
810a4814a69SStefano Babic
81174c43bb3SMasahiro Yamada$(obj)$(CPUDIR)/$(SOC)/asm-offsets.s: $(obj)include/config.h
812a4814a69SStefano Babic	@mkdir -p $(obj)$(CPUDIR)/$(SOC)
813a4814a69SStefano Babic	if [ -f $(src)$(CPUDIR)/$(SOC)/asm-offsets.c ];then \
814a4814a69SStefano Babic		$(CC) -DDO_DEPS_ONLY \
815a4814a69SStefano Babic		$(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
816a4814a69SStefano Babic			-o $@ $(src)$(CPUDIR)/$(SOC)/asm-offsets.c -c -S; \
817a4814a69SStefano Babic	else \
818a4814a69SStefano Babic		touch $@; \
819a4814a69SStefano Babic	fi
820a4814a69SStefano Babic
8217ebf7443Swdenk#########################################################################
822ae6d1056SWolfgang Denkelse	# !config.mk
823f9328639SMarian Balakowiczall $(obj)u-boot.hex $(obj)u-boot.srec $(obj)u-boot.bin \
824f9328639SMarian Balakowicz$(obj)u-boot.img $(obj)u-boot.dis $(obj)u-boot \
825249b53a6SLoïc Minier$(filter-out tools,$(SUBDIRS)) \
8262e78e75eSMasahiro Yamadadepend dep tags ctags etags cscope $(obj)System.map:
8277ebf7443Swdenk	@echo "System not configured - see README" >&2
8287ebf7443Swdenk	@ exit 1
829c7c0d542SMike Frysinger
830249b53a6SLoïc Miniertools: $(VERSION_FILE) $(TIMESTAMP_FILE)
831940db16dSMasahiro Yamada	$(MAKE) $(build) $@ all
832ae6d1056SWolfgang Denkendif	# config.mk
8337ebf7443Swdenk
83454799e45SScott Wood# ARM relocations should all be R_ARM_RELATIVE (32-bit) or
83554799e45SScott Wood# R_AARCH64_RELATIVE (64-bit).
836c37980c3SAlbert ARIBAUDcheckarmreloc: $(obj)u-boot
83754799e45SScott Wood	@RELOC="`$(CROSS_COMPILE)readelf -r -W $< | cut -d ' ' -f 4 | \
83854799e45SScott Wood		grep R_A | sort -u`"; \
83954799e45SScott Wood	if test "$$RELOC" != "R_ARM_RELATIVE" -a \
84054799e45SScott Wood		 "$$RELOC" != "R_AARCH64_RELATIVE"; then \
84154799e45SScott Wood		echo "$< contains unexpected relocations: $$RELOC"; \
84254799e45SScott Wood		false; \
84354799e45SScott Wood	fi
844c37980c3SAlbert ARIBAUD
84528abd48fSIlya Yanok$(VERSION_FILE):
84614ce91b1SMike Frysinger		@mkdir -p $(dir $(VERSION_FILE))
847dd88ab32SMasahiro Yamada		@( localvers='$(shell $(TOPDIR)/scripts/setlocalversion $(TOPDIR))' ; \
84828abd48fSIlya Yanok		   printf '#define PLAIN_VERSION "%s%s"\n' \
84928abd48fSIlya Yanok			"$(U_BOOT_VERSION)" "$${localvers}" ; \
85028abd48fSIlya Yanok		   printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' \
85128abd48fSIlya Yanok			"$(U_BOOT_VERSION)" "$${localvers}" ; \
85228abd48fSIlya Yanok		) > $@.tmp
85328abd48fSIlya Yanok		@( printf '#define CC_VERSION_STRING "%s"\n' \
85428abd48fSIlya Yanok		 '$(shell $(CC) --version | head -n 1)' )>>  $@.tmp
85528abd48fSIlya Yanok		@( printf '#define LD_VERSION_STRING "%s"\n' \
85628abd48fSIlya Yanok		 '$(shell $(LD) -v | head -n 1)' )>>  $@.tmp
85728abd48fSIlya Yanok		@cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
85828abd48fSIlya Yanok
859249b53a6SLoïc Minier$(TIMESTAMP_FILE):
860249b53a6SLoïc Minier		@mkdir -p $(dir $(TIMESTAMP_FILE))
861a76406fbSLoïc Minier		@LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > $@.tmp
862a76406fbSLoïc Minier		@LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> $@.tmp
863a76406fbSLoïc Minier		@cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
864249b53a6SLoïc Minier
8650358df42SMike Frysingereasylogo env gdb:
866940db16dSMasahiro Yamada	$(MAKE) $(build) tools/$@ MTD_VERSION=${MTD_VERSION}
867940db16dSMasahiro Yamada
8680358df42SMike Frysingergdbtools: gdb
8690358df42SMike Frysinger
87030ff8918SMarek Vasutxmldocs pdfdocs psdocs htmldocs mandocs: tools/kernel-doc/docproc
87130ff8918SMarek Vasut	$(MAKE) U_BOOT_VERSION=$(U_BOOT_VERSION) -C doc/DocBook/ $@
87230ff8918SMarek Vasut
873249b53a6SLoïc Miniertools-all: easylogo env gdb $(VERSION_FILE) $(TIMESTAMP_FILE)
874940db16dSMasahiro Yamada	$(MAKE) $(build) tools HOST_TOOLS_ALL=y
8750358df42SMike Frysinger
8764e53a258SWolfgang Denk.PHONY : CHANGELOG
8774e53a258SWolfgang DenkCHANGELOG:
878b985b5d6SBen Warren	git log --no-merges U-Boot-1_1_5.. | \
879b985b5d6SBen Warren	unexpand -a | sed -e 's/\s\s*$$//' > $@
8804e53a258SWolfgang Denk
8810a823aa2SHarald Welteinclude/license.h: tools/bin2header COPYING
8820a823aa2SHarald Welte	cat COPYING | gzip -9 -c | ./tools/bin2header license_gzip > include/license.h
8837ebf7443Swdenk#########################################################################
8847ebf7443Swdenk
8857ebf7443Swdenkunconfig:
886887e2ec9SStefan Roese	@rm -f $(obj)include/config.h $(obj)include/config.mk \
8872f155f6cSGrant Likely		$(obj)board/*/config.tmp $(obj)board/*/*/config.tmp \
88839bc12ddSJoel Fernandes		$(obj)include/autoconf.mk $(obj)include/autoconf.mk.dep \
8893aa29de0SYing Zhang		$(obj)include/spl-autoconf.mk \
8903aa29de0SYing Zhang		$(obj)include/tpl-autoconf.mk
8917ebf7443Swdenk
892a6862bc1SWolfgang Denk%_config::	unconfig
893a6862bc1SWolfgang Denk	@$(MKCONFIG) -A $(@:_config=)
894a6862bc1SWolfgang Denk
895d6a5e6d5SLoïc Miniersinclude $(obj).boards.depend
896d6a5e6d5SLoïc Minier$(obj).boards.depend:	boards.cfg
89750c2a91bSMasahiro Yamada	@awk '(NF && $$1 !~ /^#/) { print $$7 ": " $$7 "_config; $$(MAKE)" }' $< > $@
8989f4a4206SMike Frysinger
899699f0512SWolfgang Denk#########################################################################
9003e38691eSwdenk#########################################################################
9017ebf7443Swdenk
9027ebf7443Swdenkclean:
903aaed2eb5SMasahiro Yamada	@rm -f $(obj)examples/standalone/atmel_df_pow2			  \
9041bc15386SPeter Tyser	       $(obj)examples/standalone/hello_world			  \
9051bc15386SPeter Tyser	       $(obj)examples/standalone/interrupt			  \
9061bc15386SPeter Tyser	       $(obj)examples/standalone/mem_to_mem_idma2intr		  \
9071bc15386SPeter Tyser	       $(obj)examples/standalone/sched				  \
908f6322eb7SMasahiro Yamada	       $(addprefix $(obj)examples/standalone/, smc91111_eeprom smc911x_eeprom) \
9091bc15386SPeter Tyser	       $(obj)examples/standalone/test_burst			  \
9101bc15386SPeter Tyser	       $(obj)examples/standalone/timer
911f6322eb7SMasahiro Yamada	@rm -f $(addprefix $(obj)examples/api/, demo demo.bin)
912f9301e1cSWolfgang Denk	@rm -f $(obj)tools/bmp_logo	   $(obj)tools/easylogo/easylogo  \
913475c506dSMasahiro Yamada	       $(obj)tools/env/fw_printenv				  \
914f9301e1cSWolfgang Denk	       $(obj)tools/envcrc					  \
915f6322eb7SMasahiro Yamada	       $(addprefix $(obj)tools/gdb/, gdbcont gdbsend)		  \
916f9301e1cSWolfgang Denk	       $(obj)tools/gen_eth_addr    $(obj)tools/img2srec		  \
917f6322eb7SMasahiro Yamada	       $(obj)tools/dumpimage					  \
918f6322eb7SMasahiro Yamada	       $(addprefix $(obj)tools/, mkenvimage mkimage)		  \
919f6322eb7SMasahiro Yamada	       $(obj)tools/mpc86x_clk					  \
920f6322eb7SMasahiro Yamada	       $(addprefix $(obj)tools/, mk$(BOARD)spl mkexynosspl)	  \
9218aa09026SMarek Vasut	       $(obj)tools/mxsboot					  \
92230ff8918SMarek Vasut	       $(obj)tools/ncb		   $(obj)tools/ubsha1		  \
9236c887b2aSSimon Glass	       $(obj)tools/kernel-doc/docproc				  \
9246c887b2aSSimon Glass	       $(obj)tools/proftool
925f6322eb7SMasahiro Yamada	@rm -f $(addprefix $(obj)board/cray/L1/, bootscript.c bootscript.image) \
92674c7a95fSWolfgang Denk	       $(obj)board/matrix_vision/*/bootscript.img		  \
927e183a174SMasahiro Yamada	       $(obj)spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl	  \
9281aada9cdSWolfgang Denk	       $(obj)u-boot.lds						  \
929f6322eb7SMasahiro Yamada	       $(addprefix $(obj)arch/blackfin/cpu/, init.lds init.elf)
930dc7746d8SWolfgang Denk	@rm -f $(obj)include/bmp_logo.h
931c270730fSChe-Liang Chiou	@rm -f $(obj)include/bmp_logo_data.h
93216a354f9SWolfgang Denk	@rm -f $(obj)lib/asm-offsets.s
933a4814a69SStefano Babic	@rm -f $(obj)include/generated/asm-offsets.h
934a4814a69SStefano Babic	@rm -f $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s
935d4abc757SPeter Tyser	@rm -f $(TIMESTAMP_FILE) $(VERSION_FILE)
936b3141fdbSAndreas Bießmann	@$(MAKE) -s -C doc/DocBook/ cleandocs
937ae6d1056SWolfgang Denk	@find $(OBJTREE) -type f \
9384a30f1e8STom Rini		\( -name 'core' -o -name '*.bak' -o -name '*~' -o -name '*.su' \
93971a988aaSTroy Kisky		-o -name '*.o'	-o -name '*.a' -o -name '*.exe' \
94071a988aaSTroy Kisky		-o -name '*.cfgtmp' \) -print \
9417ebf7443Swdenk		| xargs rm -f
9427ebf7443Swdenk
943734329f9SAndy Fleming# Removes everything not needed for testing u-boot
944734329f9SAndy Flemingtidy:	clean
945734329f9SAndy Fleming	@find $(OBJTREE) -type f \( -name '*.depend*' \) -print | xargs rm -f
946734329f9SAndy Fleming
947734329f9SAndy Flemingclobber:	tidy
948734329f9SAndy Fleming	@find $(OBJTREE) -type f \( -name '*.srec' \
949734329f9SAndy Fleming		-o -name '*.bin' -o -name u-boot.img \) \
950734329f9SAndy Fleming		-print0 | xargs -0 rm -f
951ffda586fSLi Yang	@rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \
9525013c09fSWolfgang Denk		$(obj)cscope.* $(obj)*.*~
9534e0fbb98SDaniel Schwierzeck	@rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL-y)
954aa0c7a86SPrafulla Wadaskar	@rm -f $(obj)u-boot.kwb
9555d898a00SShaohui Xie	@rm -f $(obj)u-boot.pbl
956c5fb70c9SStefano Babic	@rm -f $(obj)u-boot.imx
957ba597609SBenoît Thébaudeau	@rm -f $(obj)u-boot-with-spl.imx
9587d5a5c79SBenoît Thébaudeau	@rm -f $(obj)u-boot-with-nand-spl.imx
9597816f2cfSHeiko Schocher	@rm -f $(obj)u-boot.ubl
960d36d8859SChristian Riesch	@rm -f $(obj)u-boot.ais
961bbb0b128SSimon Glass	@rm -f $(obj)u-boot.dtb
96230b9b932SMarek Vasut	@rm -f $(obj)u-boot.sb
96394aebe6cSStefan Roese	@rm -f $(obj)u-boot.spr
964f6322eb7SMasahiro Yamada	@rm -f $(addprefix $(obj)nand_spl/, u-boot.lds u-boot.lst System.map)
965f6322eb7SMasahiro Yamada	@rm -f $(addprefix $(obj)nand_spl/, u-boot-nand_spl.lds u-boot-spl u-boot-spl.map)
966f6322eb7SMasahiro Yamada	@rm -f $(addprefix $(obj)spl/, u-boot-spl u-boot-spl.bin u-boot-spl.map)
967ef123c52SAlbert ARIBAUD	@rm -f $(obj)spl/u-boot-spl.lds
968f6322eb7SMasahiro Yamada	@rm -f $(addprefix $(obj)tpl/, u-boot-tpl u-boot-tpl.bin u-boot-tpl.map)
9693aa29de0SYing Zhang	@rm -f $(obj)tpl/u-boot-spl.lds
97094bcfe52SNishanth Menon	@rm -f $(obj)MLO MLO.byteswap
971a3cbc396SStefano Babic	@rm -f $(obj)SPL
9728b425b3fSDaniel Schwierzeck	@rm -f $(obj)tools/xway-swap-bytes
973a9d8bc98SLoïc Minier	@rm -fr $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
97416a354f9SWolfgang Denk	@rm -fr $(obj)include/generated
975a958b663SJean-Christophe PLAGNIOL-VILLARD	@[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f
976bbb0b128SSimon Glass	@rm -f $(obj)dts/*.tmp
977f6322eb7SMasahiro Yamada	@rm -f $(addprefix $(obj)spl/, u-boot-spl.ais, u-boot-spl-pad.ais)
9787ebf7443Swdenk
9797ebf7443Swdenkmrproper \
9807ebf7443Swdenkdistclean:	clobber unconfig
981afd077bdSMike Frysingerifneq ($(OBJTREE),$(SRCTREE))
982ae6d1056SWolfgang Denk	rm -rf $(obj)*
983f9328639SMarian Balakowiczendif
9847ebf7443Swdenk
9857ebf7443Swdenkbackup:
9867ebf7443Swdenk	F=`basename $(TOPDIR)` ; cd .. ; \
987d6b93714SIlya Yanok	gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
9887ebf7443Swdenk
9897ebf7443Swdenk#########################################################################
990