xref: /openbmc/u-boot/Makefile (revision 8a156fb6)
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
24c008b6f6SWolfgang DenkVERSION = 2012
25211e4754SWolfgang DenkPATCHLEVEL = 07
26211e4754SWolfgang DenkSUBLEVEL =
27190649fbSWolfgang DenkEXTRAVERSION =
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
95f9328639SMarian Balakowiczifneq ($(BUILD_DIR),)
96f9328639SMarian Balakowiczsaved-output := $(BUILD_DIR)
974f0645ebSMarian Balakowicz
984f0645ebSMarian Balakowicz# Attempt to create a output directory.
994f0645ebSMarian Balakowicz$(shell [ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR})
1004f0645ebSMarian Balakowicz
1014f0645ebSMarian Balakowicz# Verify if it was successful.
102f9328639SMarian BalakowiczBUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd)
103f9328639SMarian Balakowicz$(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist))
104f9328639SMarian Balakowiczendif # ifneq ($(BUILD_DIR),)
105f9328639SMarian Balakowicz
106f9328639SMarian BalakowiczOBJTREE		:= $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))
107c8f9c302SDaniel SchwierzeckSPLTREE		:= $(OBJTREE)/spl
108f9328639SMarian BalakowiczSRCTREE		:= $(CURDIR)
109f9328639SMarian BalakowiczTOPDIR		:= $(SRCTREE)
110f9328639SMarian BalakowiczLNDIR		:= $(OBJTREE)
111c8f9c302SDaniel Schwierzeckexport	TOPDIR SRCTREE OBJTREE SPLTREE
112f9328639SMarian Balakowicz
113f9328639SMarian BalakowiczMKCONFIG	:= $(SRCTREE)/mkconfig
114f9328639SMarian Balakowiczexport MKCONFIG
115f9328639SMarian Balakowicz
116f9328639SMarian Balakowiczifneq ($(OBJTREE),$(SRCTREE))
117f9328639SMarian BalakowiczREMOTE_BUILD	:= 1
118f9328639SMarian Balakowiczexport REMOTE_BUILD
119f9328639SMarian Balakowiczendif
120f9328639SMarian Balakowicz
121f9328639SMarian Balakowicz# $(obj) and (src) are defined in config.mk but here in main Makefile
122f9328639SMarian Balakowicz# we also need them before config.mk is included which is the case for
123f9328639SMarian Balakowicz# some targets like unconfig, clean, clobber, distclean, etc.
124f9328639SMarian Balakowiczifneq ($(OBJTREE),$(SRCTREE))
125f9328639SMarian Balakowiczobj := $(OBJTREE)/
126f9328639SMarian Balakowiczsrc := $(SRCTREE)/
127f9328639SMarian Balakowiczelse
128f9328639SMarian Balakowiczobj :=
129f9328639SMarian Balakowiczsrc :=
130f9328639SMarian Balakowiczendif
131f9328639SMarian Balakowiczexport obj src
132f9328639SMarian Balakowicz
1335013c09fSWolfgang Denk# Make sure CDPATH settings don't interfere
1345013c09fSWolfgang Denkunexport CDPATH
1355013c09fSWolfgang Denk
136f9328639SMarian Balakowicz#########################################################################
137f9328639SMarian Balakowicz
1386d1ce387SMike Frysinger# The "tools" are needed early, so put this first
1396d1ce387SMike Frysinger# Don't include stuff already done in $(LIBS)
140349e83f0SChe-liang Chiou# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
141349e83f0SChe-liang Chiou# is "yes"), so compile examples after U-Boot is compiled.
142349e83f0SChe-liang ChiouSUBDIR_TOOLS = tools
143349e83f0SChe-liang ChiouSUBDIR_EXAMPLES = examples/standalone examples/api
144349e83f0SChe-liang ChiouSUBDIRS = $(SUBDIR_TOOLS)
1456d1ce387SMike Frysinger
146249b53a6SLoïc Minier.PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE)
1476d1ce387SMike Frysinger
148ae6d1056SWolfgang Denkifeq ($(obj)include/config.mk,$(wildcard $(obj)include/config.mk))
149f9328639SMarian Balakowicz
1502632c008SMike Frysinger# Include autoconf.mk before config.mk so that the config options are available
1512632c008SMike Frysinger# to all top level build files.  We need the dummy all: target to prevent the
1522632c008SMike Frysinger# dependency target in autoconf.mk.dep from being the default.
1532632c008SMike Frysingerall:
1542632c008SMike Frysingersinclude $(obj)include/autoconf.mk.dep
1552632c008SMike Frysingersinclude $(obj)include/autoconf.mk
1562632c008SMike Frysinger
157b5728756SSimon Glassifndef CONFIG_SANDBOX
158b5728756SSimon GlassSUBDIRS += $(SUBDIR_EXAMPLES)
159b5728756SSimon Glassendif
160b5728756SSimon Glass
1617ebf7443Swdenk# load ARCH, BOARD, and CPU configuration
162ae6d1056SWolfgang Denkinclude $(obj)include/config.mk
1631d9f4105Swdenkexport	ARCH CPU BOARD VENDOR SOC
164f9328639SMarian Balakowicz
1651ea6bcd8SMike Frysinger# set default to nothing for native builds
166a5284efdSWolfgang Denkifeq ($(HOSTARCH),$(ARCH))
1671ea6bcd8SMike FrysingerCROSS_COMPILE ?=
1687ebf7443Swdenkendif
1697ebf7443Swdenk
17092b197f0SWolfgang Denk# load other configuration
17192b197f0SWolfgang Denkinclude $(TOPDIR)/config.mk
17292b197f0SWolfgang Denk
173d51dfff7SIlya Yanok# If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
174d51dfff7SIlya Yanok# that (or fail if absent).  Otherwise, search for a linker script in a
175d51dfff7SIlya Yanok# standard location.
176d51dfff7SIlya Yanok
177ee60197eSSimon GlassLDSCRIPT_MAKEFILE_DIR = $(dir $(LDSCRIPT))
178ee60197eSSimon Glass
179d51dfff7SIlya Yanokifndef LDSCRIPT
180d51dfff7SIlya Yanok	#LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
181d51dfff7SIlya Yanok	ifdef CONFIG_SYS_LDSCRIPT
182d51dfff7SIlya Yanok		# need to strip off double quotes
183d51dfff7SIlya Yanok		LDSCRIPT := $(subst ",,$(CONFIG_SYS_LDSCRIPT))
184d51dfff7SIlya Yanok	endif
185d51dfff7SIlya Yanokendif
186d51dfff7SIlya Yanok
187ee60197eSSimon Glass# If there is no specified link script, we look in a number of places for it
188d51dfff7SIlya Yanokifndef LDSCRIPT
189d51dfff7SIlya Yanok	ifeq ($(CONFIG_NAND_U_BOOT),y)
190d51dfff7SIlya Yanok		LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
191d51dfff7SIlya Yanok		ifeq ($(wildcard $(LDSCRIPT)),)
192d51dfff7SIlya Yanok			LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds
193d51dfff7SIlya Yanok		endif
194d51dfff7SIlya Yanok	endif
195d51dfff7SIlya Yanok	ifeq ($(wildcard $(LDSCRIPT)),)
196d51dfff7SIlya Yanok		LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
197d51dfff7SIlya Yanok	endif
198d51dfff7SIlya Yanok	ifeq ($(wildcard $(LDSCRIPT)),)
199d51dfff7SIlya Yanok		LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot.lds
200d51dfff7SIlya Yanok	endif
201d51dfff7SIlya Yanok	ifeq ($(wildcard $(LDSCRIPT)),)
202ee60197eSSimon Glass		LDSCRIPT := $(TOPDIR)/arch/$(ARCH)/cpu/u-boot.lds
203ee60197eSSimon Glass		# We don't expect a Makefile here
204ee60197eSSimon Glass		LDSCRIPT_MAKEFILE_DIR =
205ee60197eSSimon Glass	endif
206ee60197eSSimon Glass	ifeq ($(wildcard $(LDSCRIPT)),)
207d51dfff7SIlya Yanok$(error could not find linker script)
208d51dfff7SIlya Yanok	endif
209d51dfff7SIlya Yanokendif
210d51dfff7SIlya Yanok
2117ebf7443Swdenk#########################################################################
2127ebf7443Swdenk# U-Boot objects....order is important (i.e. start must be first)
2137ebf7443Swdenk
21403b7004dSPeter TyserOBJS  = $(CPUDIR)/start.o
215fea25720SGraeme Russifeq ($(CPU),x86)
21603b7004dSPeter TyserOBJS += $(CPUDIR)/start16.o
21703b7004dSPeter TyserOBJS += $(CPUDIR)/resetvec.o
2182262cfeeSwdenkendif
2197ebf7443Swdenkifeq ($(CPU),ppc4xx)
22003b7004dSPeter TyserOBJS += $(CPUDIR)/resetvec.o
2217ebf7443Swdenkendif
22242d1f039Swdenkifeq ($(CPU),mpc85xx)
22303b7004dSPeter TyserOBJS += $(CPUDIR)/resetvec.o
22442d1f039Swdenkendif
2257ebf7443Swdenk
226f9328639SMarian BalakowiczOBJS := $(addprefix $(obj),$(OBJS))
227f9328639SMarian Balakowicz
2288b5a0264SDaniel SchwierzeckHAVE_VENDOR_COMMON_LIB = $(if $(wildcard board/$(VENDOR)/common/Makefile),y,n)
2298b5a0264SDaniel Schwierzeck
230f52d7b35SDaniel SchwierzeckLIBS-y += lib/libgeneric.o
231f52d7b35SDaniel SchwierzeckLIBS-y += lib/lzma/liblzma.o
232f52d7b35SDaniel SchwierzeckLIBS-y += lib/lzo/liblzo.o
233f52d7b35SDaniel SchwierzeckLIBS-y += lib/zlib/libz.o
2348b5a0264SDaniel SchwierzeckLIBS-$(CONFIG_TIZEN) += lib/tizen/libtizen.o
2358b5a0264SDaniel SchwierzeckLIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/lib$(VENDOR).o
236f52d7b35SDaniel SchwierzeckLIBS-y += $(CPUDIR)/lib$(CPU).o
2371d9f4105Swdenkifdef SOC
238f52d7b35SDaniel SchwierzeckLIBS-y += $(CPUDIR)/$(SOC)/lib$(SOC).o
2391d9f4105Swdenkendif
240323bfa8fSStefan Roeseifeq ($(CPU),ixp)
241f52d7b35SDaniel SchwierzeckLIBS-y += arch/arm/cpu/ixp/npe/libnpe.o
242323bfa8fSStefan Roeseendif
2438b5a0264SDaniel SchwierzeckLIBS-$(CONFIG_OF_EMBED) += dts/libdts.o
244f52d7b35SDaniel SchwierzeckLIBS-y += arch/$(ARCH)/lib/lib$(ARCH).o
245f52d7b35SDaniel SchwierzeckLIBS-y += fs/cramfs/libcramfs.o fs/fat/libfat.o fs/fdos/libfdos.o fs/jffs2/libjffs2.o \
2466d8962e8SSebastien Carlier	fs/reiserfs/libreiserfs.o fs/ext2/libext2fs.o fs/yaffs2/libyaffs2.o \
2474d3c95f5SJorgen Lundman	fs/ubifs/libubifs.o fs/zfs/libzfs.o
248f52d7b35SDaniel SchwierzeckLIBS-y += net/libnet.o
249f52d7b35SDaniel SchwierzeckLIBS-y += disk/libdisk.o
250f52d7b35SDaniel SchwierzeckLIBS-y += drivers/bios_emulator/libatibiosemu.o
251f52d7b35SDaniel SchwierzeckLIBS-y += drivers/block/libblock.o
2520044c42eSStefan RoeseLIBS-$(CONFIG_BOOTCOUNT_LIMIT) += drivers/bootcount/libbootcount.o
253f52d7b35SDaniel SchwierzeckLIBS-y += drivers/dma/libdma.o
254f52d7b35SDaniel SchwierzeckLIBS-y += drivers/fpga/libfpga.o
255f52d7b35SDaniel SchwierzeckLIBS-y += drivers/gpio/libgpio.o
256f52d7b35SDaniel SchwierzeckLIBS-y += drivers/hwmon/libhwmon.o
257f52d7b35SDaniel SchwierzeckLIBS-y += drivers/i2c/libi2c.o
258f52d7b35SDaniel SchwierzeckLIBS-y += drivers/input/libinput.o
259f52d7b35SDaniel SchwierzeckLIBS-y += drivers/misc/libmisc.o
260f52d7b35SDaniel SchwierzeckLIBS-y += drivers/mmc/libmmc.o
261f52d7b35SDaniel SchwierzeckLIBS-y += drivers/mtd/libmtd.o
262f52d7b35SDaniel SchwierzeckLIBS-y += drivers/mtd/nand/libnand.o
263f52d7b35SDaniel SchwierzeckLIBS-y += drivers/mtd/onenand/libonenand.o
264f52d7b35SDaniel SchwierzeckLIBS-y += drivers/mtd/ubi/libubi.o
265f52d7b35SDaniel SchwierzeckLIBS-y += drivers/mtd/spi/libspi_flash.o
266f52d7b35SDaniel SchwierzeckLIBS-y += drivers/net/libnet.o
267f52d7b35SDaniel SchwierzeckLIBS-y += drivers/net/phy/libphy.o
268f52d7b35SDaniel SchwierzeckLIBS-y += drivers/pci/libpci.o
269f52d7b35SDaniel SchwierzeckLIBS-y += drivers/pcmcia/libpcmcia.o
270f52d7b35SDaniel SchwierzeckLIBS-y += drivers/power/libpower.o
271f52d7b35SDaniel SchwierzeckLIBS-y += drivers/spi/libspi.o
272f22b11c1SLukasz MajewskiLIBS-y += drivers/dfu/libdfu.o
2737737d5c6SDave Liuifeq ($(CPU),mpc83xx)
274f52d7b35SDaniel SchwierzeckLIBS-y += drivers/qe/libqe.o
275f52d7b35SDaniel SchwierzeckLIBS-y += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
276f52d7b35SDaniel SchwierzeckLIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
2777737d5c6SDave Liuendif
278da9d4610SAndy Flemingifeq ($(CPU),mpc85xx)
279f52d7b35SDaniel SchwierzeckLIBS-y += drivers/qe/libqe.o
280f52d7b35SDaniel SchwierzeckLIBS-y += drivers/net/fm/libfm.o
281f52d7b35SDaniel SchwierzeckLIBS-y += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
282f52d7b35SDaniel SchwierzeckLIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
28358e5e9afSKumar Galaendif
28458e5e9afSKumar Galaifeq ($(CPU),mpc86xx)
285f52d7b35SDaniel SchwierzeckLIBS-y += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
286f52d7b35SDaniel SchwierzeckLIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
287da9d4610SAndy Flemingendif
288f52d7b35SDaniel SchwierzeckLIBS-y += drivers/rtc/librtc.o
289f52d7b35SDaniel SchwierzeckLIBS-y += drivers/serial/libserial.o
2908b5a0264SDaniel SchwierzeckLIBS-$(CONFIG_GENERIC_LPC_TPM) += drivers/tpm/libtpm.o
291f52d7b35SDaniel SchwierzeckLIBS-y += drivers/twserial/libtws.o
292f52d7b35SDaniel SchwierzeckLIBS-y += drivers/usb/eth/libusb_eth.o
293f52d7b35SDaniel SchwierzeckLIBS-y += drivers/usb/gadget/libusb_gadget.o
294f52d7b35SDaniel SchwierzeckLIBS-y += drivers/usb/host/libusb_host.o
295f52d7b35SDaniel SchwierzeckLIBS-y += drivers/usb/musb/libusb_musb.o
296f52d7b35SDaniel SchwierzeckLIBS-y += drivers/usb/phy/libusb_phy.o
297f52d7b35SDaniel SchwierzeckLIBS-y += drivers/usb/ulpi/libusb_ulpi.o
298f52d7b35SDaniel SchwierzeckLIBS-y += drivers/video/libvideo.o
299f52d7b35SDaniel SchwierzeckLIBS-y += drivers/watchdog/libwatchdog.o
300f52d7b35SDaniel SchwierzeckLIBS-y += common/libcommon.o
301f52d7b35SDaniel SchwierzeckLIBS-y += lib/libfdt/libfdt.o
302f52d7b35SDaniel SchwierzeckLIBS-y += api/libapi.o
303f52d7b35SDaniel SchwierzeckLIBS-y += post/libpost.o
304f52d7b35SDaniel SchwierzeckLIBS-y += test/libtest.o
305f9328639SMarian Balakowicz
306f16da746SChandan Nathifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),)
307f52d7b35SDaniel SchwierzeckLIBS-y += $(CPUDIR)/omap-common/libomap-common.o
308f0f4b5ffSChandan Nathendif
30918936ee2SJason Liu
31018936ee2SJason Liuifeq ($(SOC),mx5)
311f52d7b35SDaniel SchwierzeckLIBS-y += $(CPUDIR)/imx-common/libimx-common.o
31218936ee2SJason Liuendif
31318936ee2SJason Liuifeq ($(SOC),mx6)
314f52d7b35SDaniel SchwierzeckLIBS-y += $(CPUDIR)/imx-common/libimx-common.o
31518936ee2SJason Liuendif
31618936ee2SJason Liu
317852bd07cSMinkyu Kangifeq ($(SOC),s5pc1xx)
318f52d7b35SDaniel SchwierzeckLIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o
319852bd07cSMinkyu Kangendif
320393cb361SChander Kashyapifeq ($(SOC),exynos)
321f52d7b35SDaniel SchwierzeckLIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o
322852bd07cSMinkyu Kangendif
323d9e73a87SAllen Martinifeq ($(SOC),tegra20)
324d9e73a87SAllen MartinLIBS-y += arch/$(ARCH)/cpu/$(SOC)-common/lib$(SOC)-common.o
325d9e73a87SAllen Martinendif
326852bd07cSMinkyu Kang
327f52d7b35SDaniel SchwierzeckLIBS := $(addprefix $(obj),$(sort $(LIBS-y)))
328249b53a6SLoïc Minier.PHONY : $(LIBS)
329a8c7c708Swdenk
3306d8962e8SSebastien CarlierLIBBOARD = board/$(BOARDDIR)/lib$(BOARD).o
331de109d90SWolfgang DenkLIBBOARD := $(addprefix $(obj),$(LIBBOARD))
332de109d90SWolfgang Denk
3334f7cb08eSwdenk# Add GCC lib
33452b1bf2cSWolfgang Denkifdef USE_PRIVATE_LIBGCC
33552b1bf2cSWolfgang Denkifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
336635d1b3eSMatthias WeisserPLATFORM_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/libgcc.o
33752b1bf2cSWolfgang Denkelse
33852b1bf2cSWolfgang DenkPLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc
33952b1bf2cSWolfgang Denkendif
34052b1bf2cSWolfgang Denkelse
341cca4e4aeSWolfgang DenkPLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
34252b1bf2cSWolfgang Denkendif
34352b1bf2cSWolfgang DenkPLATFORM_LIBS += $(PLATFORM_LIBGCC)
34452b1bf2cSWolfgang Denkexport PLATFORM_LIBS
3453d3befa7Swdenk
3466ac9f479SMike Frysinger# Special flags for CPP when processing the linker script.
3476ac9f479SMike Frysinger# Pass the version down so we can handle backwards compatibility
3486ac9f479SMike Frysinger# on the fly.
3496ac9f479SMike FrysingerLDPPFLAGS += \
3506ac9f479SMike Frysinger	-include $(TOPDIR)/include/u-boot/u-boot.lds.h \
3517e6403a6SSimon Glass	-DCPUDIR=$(CPUDIR) \
3526ac9f479SMike Frysinger	$(shell $(LD) --version | \
3536ac9f479SMike Frysinger	  sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
3546ac9f479SMike Frysinger
355f9328639SMarian Balakowicz__OBJS := $(subst $(obj),,$(OBJS))
356de109d90SWolfgang Denk__LIBS := $(subst $(obj),,$(LIBS)) $(subst $(obj),,$(LIBBOARD))
357f9328639SMarian Balakowicz
3587ebf7443Swdenk#########################################################################
359bdccc4feSwdenk#########################################################################
3607ebf7443Swdenk
361f3a14d37SMike Frysingerifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
362f3a14d37SMike FrysingerBOARD_SIZE_CHECK = \
363f3a14d37SMike Frysinger	@actual=`wc -c $@ | awk '{print $$1}'`; \
364f3a14d37SMike Frysinger	limit=$(CONFIG_BOARD_SIZE_LIMIT); \
365f3a14d37SMike Frysinger	if test $$actual -gt $$limit; then \
366f3a14d37SMike Frysinger		echo "$@ exceeds file size limit:"; \
367f3a14d37SMike Frysinger		echo "  limit:  $$limit bytes"; \
368f3a14d37SMike Frysinger		echo "  actual: $$actual bytes"; \
369f3a14d37SMike Frysinger		echo "  excess: $$((actual - limit)) bytes"; \
370f3a14d37SMike Frysinger		exit 1; \
371f3a14d37SMike Frysinger	fi
372f3a14d37SMike Frysingerelse
373f3a14d37SMike FrysingerBOARD_SIZE_CHECK =
374f3a14d37SMike Frysingerendif
375f3a14d37SMike Frysinger
3763e88337bSMike Frysinger# Always append ALL so that arch config.mk's can add custom ones
3774e0fbb98SDaniel SchwierzeckALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map
378e935a374SHaiying Wang
3794e0fbb98SDaniel SchwierzeckALL-$(CONFIG_NAND_U_BOOT) += $(obj)u-boot-nand.bin
3804e0fbb98SDaniel SchwierzeckALL-$(CONFIG_ONENAND_U_BOOT) += $(obj)u-boot-onenand.bin
381e935a374SHaiying WangONENAND_BIN ?= $(obj)onenand_ipl/onenand-ipl-2k.bin
3825df2ee27SDaniel SchwierzeckALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin
3832c0f79e4SSimon GlassALL-$(CONFIG_OF_SEPARATE) += $(obj)u-boot.dtb $(obj)u-boot-dtb.bin
3847ebf7443Swdenk
38512b7b70cSAllen Martin# enable combined SPL/u-boot/dtb rules for tegra
38612b7b70cSAllen Martinifeq ($(SOC),tegra20)
38712b7b70cSAllen Martinifeq ($(CONFIG_OF_SEPARATE),y)
38812b7b70cSAllen MartinALL-y += $(obj)u-boot-dtb-tegra.bin
38912b7b70cSAllen Martinelse
39012b7b70cSAllen MartinALL-y += $(obj)u-boot-nodtb-tegra.bin
39112b7b70cSAllen Martinendif
39212b7b70cSAllen Martinendif
39312b7b70cSAllen Martin
394349e83f0SChe-liang Chiouall:		$(ALL-y) $(SUBDIR_EXAMPLES)
3957ebf7443Swdenk
3962c0f79e4SSimon Glass$(obj)u-boot.dtb:	$(obj)u-boot
3972c0f79e4SSimon Glass		$(MAKE) -C dts binary
3982c0f79e4SSimon Glass		mv $(obj)dts/dt.dtb $@
3992c0f79e4SSimon Glass
4002c0f79e4SSimon Glass$(obj)u-boot-dtb.bin:	$(obj)u-boot.bin $(obj)u-boot.dtb
4012c0f79e4SSimon Glass		cat $^ >$@
4022c0f79e4SSimon Glass
403f9328639SMarian Balakowicz$(obj)u-boot.hex:	$(obj)u-boot
4046310eb9dSwdenk		$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
4056310eb9dSwdenk
406f9328639SMarian Balakowicz$(obj)u-boot.srec:	$(obj)u-boot
4070817d688SRicardo Ribalda Delgado		$(OBJCOPY) -O srec $< $@
4087ebf7443Swdenk
409f9328639SMarian Balakowicz$(obj)u-boot.bin:	$(obj)u-boot
4107ebf7443Swdenk		$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
411f3a14d37SMike Frysinger		$(BOARD_SIZE_CHECK)
4127ebf7443Swdenk
41394a91e24SMike Frysinger$(obj)u-boot.ldr:	$(obj)u-boot
41476d82187SMike Frysinger		$(CREATE_LDR_ENV)
41568e56324SMike Frysinger		$(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS)
416f3a14d37SMike Frysinger		$(BOARD_SIZE_CHECK)
41794a91e24SMike Frysinger
41894a91e24SMike Frysinger$(obj)u-boot.ldr.hex:	$(obj)u-boot.ldr
41994a91e24SMike Frysinger		$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ -I binary
42094a91e24SMike Frysinger
42194a91e24SMike Frysinger$(obj)u-boot.ldr.srec:	$(obj)u-boot.ldr
42294a91e24SMike Frysinger		$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ -I binary
42394a91e24SMike Frysinger
424f9328639SMarian Balakowicz$(obj)u-boot.img:	$(obj)u-boot.bin
425a2a0a717SWolfgang Denk		$(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
4263857f8f5Saneeshv		-O u-boot -a $(CONFIG_SYS_TEXT_BASE) -e 0 \
427881a87ecSWolfgang Denk		-n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
428bdccc4feSwdenk			sed -e 's/"[	 ]*$$/ for $(BOARD) board"/') \
429bdccc4feSwdenk		-d $< $@
430bdccc4feSwdenk
4318edcde5eSStefano Babic$(obj)u-boot.imx:       $(obj)u-boot.bin
43245d7d72bSStefano Babic		$(obj)tools/mkimage -n  $(CONFIG_IMX_CONFIG) -T imximage \
43314d0a02aSWolfgang Denk		-e $(CONFIG_SYS_TEXT_BASE) -d $< $@
4348edcde5eSStefano Babic
435aa0c7a86SPrafulla Wadaskar$(obj)u-boot.kwb:       $(obj)u-boot.bin
43631d80c77SPrafulla Wadaskar		$(obj)tools/mkimage -n $(CONFIG_SYS_KWD_CONFIG) -T kwbimage \
4372ea88b06SEric Cooper		-a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) -d $< $@
438aa0c7a86SPrafulla Wadaskar
439566a494fSHeiko Schocher$(obj)u-boot.sha1:	$(obj)u-boot.bin
44001159530SHeiko Schocher		$(obj)tools/ubsha1 $(obj)u-boot.bin
441566a494fSHeiko Schocher
442f9328639SMarian Balakowicz$(obj)u-boot.dis:	$(obj)u-boot
4437ebf7443Swdenk		$(OBJDUMP) -d $< > $@
4447ebf7443Swdenk
445435199f3SHeiko Schocher$(obj)u-boot.ubl:       $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
446435199f3SHeiko Schocher		$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(PAD_TO) -O binary $(obj)spl/u-boot-spl $(obj)spl/u-boot-spl-pad.bin
447435199f3SHeiko Schocher		cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin > $(obj)u-boot-ubl.bin
4487816f2cfSHeiko Schocher		$(obj)tools/mkimage -n $(UBL_CONFIG) -T ublimage \
449435199f3SHeiko Schocher		-e $(CONFIG_SYS_TEXT_BASE) -d $(obj)u-boot-ubl.bin $(obj)u-boot.ubl
450435199f3SHeiko Schocher		rm $(obj)u-boot-ubl.bin
451435199f3SHeiko Schocher		rm $(obj)spl/u-boot-spl-pad.bin
4527816f2cfSHeiko Schocher
453d36d8859SChristian Riesch$(obj)u-boot.ais:       $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
4546d660e77SSughosh Ganu		$(obj)tools/mkimage -s -n $(if $(CONFIG_AIS_CONFIG_FILE),$(CONFIG_AIS_CONFIG_FILE),"/dev/null") \
4556d660e77SSughosh Ganu			-T aisimage \
456d36d8859SChristian Riesch			-e $(CONFIG_SPL_TEXT_BASE) \
457d36d8859SChristian Riesch			-d $(obj)spl/u-boot-spl.bin \
458d36d8859SChristian Riesch			$(obj)spl/u-boot-spl.ais
459d36d8859SChristian Riesch		$(OBJCOPY) ${OBJCFLAGS} -I binary \
460d36d8859SChristian Riesch			--pad-to=$(CONFIG_SPL_MAX_SIZE) -O binary \
461d36d8859SChristian Riesch			$(obj)spl/u-boot-spl.ais $(obj)spl/u-boot-spl-pad.ais
462d36d8859SChristian Riesch		cat $(obj)spl/u-boot-spl-pad.ais $(obj)u-boot.bin > \
463d36d8859SChristian Riesch			$(obj)u-boot.ais
464d36d8859SChristian Riesch
465a5453555SOtavio Salvador# Specify the target for use in elftosb call
466a5453555SOtavio SalvadorELFTOSB_TARGET-$(CONFIG_MX28) = imx28
467a5453555SOtavio Salvador
46830b9b932SMarek Vasut$(obj)u-boot.sb:       $(obj)u-boot.bin $(obj)spl/u-boot-spl.bin
469a5453555SOtavio Salvador		elftosb -zdf $(ELFTOSB_TARGET-y) -c $(TOPDIR)/$(CPUDIR)/$(SOC)/u-boot-$(ELFTOSB_TARGET-y).bd \
47030b9b932SMarek Vasut			-o $(obj)u-boot.sb
47130b9b932SMarek Vasut
47294aebe6cSStefan Roese# On x600 (SPEAr600) U-Boot is appended to U-Boot SPL.
47394aebe6cSStefan Roese# Both images are created using mkimage (crc etc), so that the ROM
47494aebe6cSStefan Roese# bootloader can check its integrity. Padding needs to be done to the
47594aebe6cSStefan Roese# SPL image (with mkimage header) and not the binary. Otherwise the resulting image
47694aebe6cSStefan Roese# which is loaded/copied by the ROM bootloader to SRAM doesn't fit.
47794aebe6cSStefan Roese# The resulting image containing both U-Boot images is called u-boot.spr
47894aebe6cSStefan Roese$(obj)u-boot.spr:	$(obj)u-boot.img $(obj)spl/u-boot-spl.bin
47994aebe6cSStefan Roese		$(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
48094aebe6cSStefan Roese		-a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER \
48194aebe6cSStefan Roese		-d $(obj)spl/u-boot-spl.bin $(obj)spl/u-boot-spl.img
48294aebe6cSStefan Roese		tr "\000" "\377" < /dev/zero | dd ibs=1 count=$(CONFIG_SPL_PAD_TO) \
48394aebe6cSStefan Roese			of=$(obj)spl/u-boot-spl-pad.img 2>/dev/null
48494aebe6cSStefan Roese		dd if=$(obj)spl/u-boot-spl.img of=$(obj)spl/u-boot-spl-pad.img \
48594aebe6cSStefan Roese			conv=notrunc 2>/dev/null
48694aebe6cSStefan Roese		cat $(obj)spl/u-boot-spl-pad.img $(obj)u-boot.img > $@
48794aebe6cSStefan Roese
488984df4ecSAllen Martinifeq ($(SOC),tegra20)
489984df4ecSAllen Martinifeq ($(CONFIG_OF_SEPARATE),y)
490984df4ecSAllen Martin$(obj)u-boot-dtb-tegra.bin:	$(obj)spl/u-boot-spl.bin $(obj)u-boot.bin $(obj)u-boot.dtb
491984df4ecSAllen Martin		$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SYS_TEXT_BASE) -O binary $(obj)spl/u-boot-spl $(obj)spl/u-boot-spl-pad.bin
492984df4ecSAllen Martin		cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin $(obj)u-boot.dtb > $@
493984df4ecSAllen Martin		rm $(obj)spl/u-boot-spl-pad.bin
494984df4ecSAllen Martinelse
495984df4ecSAllen Martin$(obj)u-boot-nodtb-tegra.bin:	$(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
496984df4ecSAllen Martin		$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SYS_TEXT_BASE) -O binary $(obj)spl/u-boot-spl $(obj)spl/u-boot-spl-pad.bin
497984df4ecSAllen Martin		cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin > $@
498984df4ecSAllen Martin		rm $(obj)spl/u-boot-spl-pad.bin
499984df4ecSAllen Martinendif
500984df4ecSAllen Martinendif
501984df4ecSAllen Martin
50286eb49b3SSimon Glassifeq ($(CONFIG_SANDBOX),y)
50386eb49b3SSimon GlassGEN_UBOOT = \
50486eb49b3SSimon Glass		cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \
50586eb49b3SSimon Glass			-Wl,--start-group $(__LIBS) -Wl,--end-group \
50686eb49b3SSimon Glass			$(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot
50786eb49b3SSimon Glasselse
508ecb1dc89SMike FrysingerGEN_UBOOT = \
509de109d90SWolfgang Denk		UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \
510de109d90SWolfgang Denk		sed  -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
5118aba9dceSNobuhiro Iwamatsu		cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM $(__OBJS) \
512f9328639SMarian Balakowicz			--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
513b2184c31Swdenk			-Map u-boot.map -o u-boot
51486eb49b3SSimon Glassendif
51586eb49b3SSimon Glass
51616a354f9SWolfgang Denk$(obj)u-boot:	depend \
517349e83f0SChe-liang Chiou		$(SUBDIR_TOOLS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds
518ecb1dc89SMike Frysinger		$(GEN_UBOOT)
519ecb1dc89SMike Frysingerifeq ($(CONFIG_KALLSYMS),y)
520*8a156fb6SMike Frysinger		smap=`$(call SYSTEM_MAP,$(obj)u-boot) | \
5211aada9cdSWolfgang Denk			awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \
5221aada9cdSWolfgang Denk		$(CC) $(CFLAGS) -DSYSTEM_MAP="\"$${smap}\"" \
5231aada9cdSWolfgang Denk			-c common/system_map.c -o $(obj)common/system_map.o
524ecb1dc89SMike Frysinger		$(GEN_UBOOT) $(obj)common/system_map.o
525ecb1dc89SMike Frysingerendif
5267ebf7443Swdenk
527d0d6144eSPeter Tyser$(OBJS):	depend
52803b7004dSPeter Tyser		$(MAKE) -C $(CPUDIR) $(if $(REMOTE_BUILD),$@,$(notdir $@))
529f9328639SMarian Balakowicz
530349e83f0SChe-liang Chiou$(LIBS):	depend $(SUBDIR_TOOLS)
531f9328639SMarian Balakowicz		$(MAKE) -C $(dir $(subst $(obj),,$@))
532a8c7c708Swdenk
533d0d6144eSPeter Tyser$(LIBBOARD):	depend $(LIBS)
534de109d90SWolfgang Denk		$(MAKE) -C $(dir $(subst $(obj),,$@))
535de109d90SWolfgang Denk
536d0d6144eSPeter Tyser$(SUBDIRS):	depend
537b028f715Swdenk		$(MAKE) -C $@ all
5387ebf7443Swdenk
539349e83f0SChe-liang Chiou$(SUBDIR_EXAMPLES): $(obj)u-boot
540349e83f0SChe-liang Chiou
541d0d6144eSPeter Tyser$(LDSCRIPT):	depend
542f65c9812SMike Frysinger		$(MAKE) -C $(dir $@) $(notdir $@)
543f65c9812SMike Frysinger
5441aada9cdSWolfgang Denk$(obj)u-boot.lds: $(LDSCRIPT)
5451aada9cdSWolfgang Denk		$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
5461aada9cdSWolfgang Denk
547e935a374SHaiying Wangnand_spl:	$(TIMESTAMP_FILE) $(VERSION_FILE) depend
5488318fbf8SMarian Balakowicz		$(MAKE) -C nand_spl/board/$(BOARDDIR) all
549887e2ec9SStefan Roese
550e935a374SHaiying Wang$(obj)u-boot-nand.bin:	nand_spl $(obj)u-boot.bin
5518318fbf8SMarian Balakowicz		cat $(obj)nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > $(obj)u-boot-nand.bin
552887e2ec9SStefan Roese
553e935a374SHaiying Wangonenand_ipl:	$(TIMESTAMP_FILE) $(VERSION_FILE) $(obj)include/autoconf.mk
554f2302d44SStefan Roese		$(MAKE) -C onenand_ipl/board/$(BOARDDIR) all
555751b9b51SKyungmin Park
556e935a374SHaiying Wang$(obj)u-boot-onenand.bin:	onenand_ipl $(obj)u-boot.bin
557ca6189dbSKyungmin Park		cat $(ONENAND_BIN) $(obj)u-boot.bin > $(obj)u-boot-onenand.bin
558751b9b51SKyungmin Park
559bd25fdbaSAneesh V$(obj)spl/u-boot-spl.bin:	$(SUBDIR_TOOLS) depend
5605df2ee27SDaniel Schwierzeck		$(MAKE) -C spl all
5615df2ee27SDaniel Schwierzeck
562f9328639SMarian Balakowiczupdater:
5630358df42SMike Frysinger		$(MAKE) -C tools/updater all
5648f713fdfSdzu
5652a998793SDaniel Hobi# Explicitly make _depend in subdirs containing multiple targets to prevent
5662a998793SDaniel Hobi# parallel sub-makes creating .depend files simultaneously.
56716a354f9SWolfgang Denkdepend dep:	$(TIMESTAMP_FILE) $(VERSION_FILE) \
56816a354f9SWolfgang Denk		$(obj)include/autoconf.mk \
569a4814a69SStefano Babic		$(obj)include/generated/generic-asm-offsets.h \
570a4814a69SStefano Babic		$(obj)include/generated/asm-offsets.h
571ee60197eSSimon Glass		for dir in $(SUBDIRS) $(CPUDIR) $(LDSCRIPT_MAKEFILE_DIR) ; do \
5722a998793SDaniel Hobi			$(MAKE) -C $$dir _depend ; done
5737ebf7443Swdenk
574e5e4e705SLi YangTAG_SUBDIRS = $(SUBDIRS)
575e5e4e705SLi YangTAG_SUBDIRS += $(dir $(__LIBS))
576a340c325SJean-Christophe PLAGNIOL-VILLARDTAG_SUBDIRS += include
577a340c325SJean-Christophe PLAGNIOL-VILLARD
578857d9ea6SHorst KronstorferFIND := find
579857d9ea6SHorst KronstorferFINDFLAGS := -L
580857d9ea6SHorst Kronstorfer
5811064d980STom Rinicheckstack:
5821064d980STom Rini		$(CROSS_COMPILE)objdump -d $(obj)u-boot \
5831064d980STom Rini			`$(FIND) $(obj) -name u-boot-spl -print` | \
5841064d980STom Rini			perl $(src)tools/checkstack.pl $(ARCH)
5851064d980STom Rini
586f9328639SMarian Balakowicztags ctags:
587857d9ea6SHorst Kronstorfer		ctags -w -o $(obj)ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
588e5e4e705SLi Yang						-name '*.[chS]' -print`
5897ebf7443Swdenk
5907ebf7443Swdenketags:
591857d9ea6SHorst Kronstorfer		etags -a -o $(obj)etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
592e5e4e705SLi Yang						-name '*.[chS]' -print`
593ffda586fSLi Yangcscope:
594857d9ea6SHorst Kronstorfer		$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \
595857d9ea6SHorst Kronstorfer						cscope.files
596ffda586fSLi Yang		cscope -b -q -k
5977ebf7443Swdenk
598ecb1dc89SMike FrysingerSYSTEM_MAP = \
599ecb1dc89SMike Frysinger		$(NM) $1 | \
6007ebf7443Swdenk		grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
601ecb1dc89SMike Frysinger		LC_ALL=C sort
602ecb1dc89SMike Frysinger$(obj)System.map:	$(obj)u-boot
603ecb1dc89SMike Frysinger		@$(call SYSTEM_MAP,$<) > $(obj)System.map
6047ebf7443Swdenk
60506a119a0STom Rinicheckthumb:
60606a119a0STom Rini	@if test $(call cc-version) -lt 0404; then \
60706a119a0STom Rini		echo -n '*** Your GCC does not produce working '; \
60806a119a0STom Rini		echo 'binaries in THUMB mode.'; \
60906a119a0STom Rini		echo '*** Your board is configured for THUMB mode.'; \
61006a119a0STom Rini		false; \
61106a119a0STom Rini	fi
6122f155f6cSGrant Likely#
6132f155f6cSGrant Likely# Auto-generate the autoconf.mk file (which is included by all makefiles)
6142f155f6cSGrant Likely#
6152f155f6cSGrant Likely# This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
6162f155f6cSGrant Likely# the dep file is only include in this top level makefile to determine when
6172f155f6cSGrant Likely# to regenerate the autoconf.mk file.
6181510b82dSWolfgang Denk$(obj)include/autoconf.mk.dep: $(obj)include/config.h include/common.h
6191510b82dSWolfgang Denk	@$(XECHO) Generating $@ ; \
62016fe7775SMike Frysinger	set -e ; \
621ae6d1056SWolfgang Denk	: Generate the dependancies ; \
6224c34b2a0SMike Frysinger	$(CC) -x c -DDO_DEPS_ONLY -M $(CFLAGS) $(CPPFLAGS) \
6231510b82dSWolfgang Denk		-MQ $(obj)include/autoconf.mk include/common.h > $@
6241510b82dSWolfgang Denk
6251510b82dSWolfgang Denk$(obj)include/autoconf.mk: $(obj)include/config.h
6261510b82dSWolfgang Denk	@$(XECHO) Generating $@ ; \
6271510b82dSWolfgang Denk	set -e ; \
628ae6d1056SWolfgang Denk	: Extract the config macros ; \
6291510b82dSWolfgang Denk	$(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h | \
6304a0f7538SWolfgang Denk		sed -n -f tools/scripts/define2mk.sed > $@.tmp && \
6314a0f7538SWolfgang Denk	mv $@.tmp $@
6322f155f6cSGrant Likely
63316a354f9SWolfgang Denk$(obj)include/generated/generic-asm-offsets.h:	$(obj)include/autoconf.mk.dep \
63416a354f9SWolfgang Denk	$(obj)lib/asm-offsets.s
63516a354f9SWolfgang Denk	@$(XECHO) Generating $@
63616a354f9SWolfgang Denk	tools/scripts/make-asm-offsets $(obj)lib/asm-offsets.s $@
63716a354f9SWolfgang Denk
63816a354f9SWolfgang Denk$(obj)lib/asm-offsets.s:	$(obj)include/autoconf.mk.dep \
63916a354f9SWolfgang Denk	$(src)lib/asm-offsets.c
64016a354f9SWolfgang Denk	@mkdir -p $(obj)lib
64116a354f9SWolfgang Denk	$(CC) -DDO_DEPS_ONLY \
64216a354f9SWolfgang Denk		$(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
64316a354f9SWolfgang Denk		-o $@ $(src)lib/asm-offsets.c -c -S
64416a354f9SWolfgang Denk
645a4814a69SStefano Babic$(obj)include/generated/asm-offsets.h:	$(obj)include/autoconf.mk.dep \
646a4814a69SStefano Babic	$(obj)$(CPUDIR)/$(SOC)/asm-offsets.s
647b12734eeSWolfgang Denk	@$(XECHO) Generating $@
648a4814a69SStefano Babic	tools/scripts/make-asm-offsets $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s $@
649a4814a69SStefano Babic
650a4814a69SStefano Babic$(obj)$(CPUDIR)/$(SOC)/asm-offsets.s:	$(obj)include/autoconf.mk.dep
651a4814a69SStefano Babic	@mkdir -p $(obj)$(CPUDIR)/$(SOC)
652a4814a69SStefano Babic	if [ -f $(src)$(CPUDIR)/$(SOC)/asm-offsets.c ];then \
653a4814a69SStefano Babic		$(CC) -DDO_DEPS_ONLY \
654a4814a69SStefano Babic		$(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
655a4814a69SStefano Babic			-o $@ $(src)$(CPUDIR)/$(SOC)/asm-offsets.c -c -S; \
656a4814a69SStefano Babic	else \
657a4814a69SStefano Babic		touch $@; \
658a4814a69SStefano Babic	fi
659a4814a69SStefano Babic
6607ebf7443Swdenk#########################################################################
661ae6d1056SWolfgang Denkelse	# !config.mk
662f9328639SMarian Balakowiczall $(obj)u-boot.hex $(obj)u-boot.srec $(obj)u-boot.bin \
663f9328639SMarian Balakowicz$(obj)u-boot.img $(obj)u-boot.dis $(obj)u-boot \
664249b53a6SLoïc Minier$(filter-out tools,$(SUBDIRS)) \
6650358df42SMike Frysingerupdater depend dep tags ctags etags cscope $(obj)System.map:
6667ebf7443Swdenk	@echo "System not configured - see README" >&2
6677ebf7443Swdenk	@ exit 1
668c7c0d542SMike Frysinger
669249b53a6SLoïc Miniertools: $(VERSION_FILE) $(TIMESTAMP_FILE)
6700358df42SMike Frysinger	$(MAKE) -C $@ all
671ae6d1056SWolfgang Denkendif	# config.mk
6727ebf7443Swdenk
67328abd48fSIlya Yanok$(VERSION_FILE):
67414ce91b1SMike Frysinger		@mkdir -p $(dir $(VERSION_FILE))
67528abd48fSIlya Yanok		@( localvers='$(shell $(TOPDIR)/tools/setlocalversion $(TOPDIR))' ; \
67628abd48fSIlya Yanok		   printf '#define PLAIN_VERSION "%s%s"\n' \
67728abd48fSIlya Yanok			"$(U_BOOT_VERSION)" "$${localvers}" ; \
67828abd48fSIlya Yanok		   printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' \
67928abd48fSIlya Yanok			"$(U_BOOT_VERSION)" "$${localvers}" ; \
68028abd48fSIlya Yanok		) > $@.tmp
68128abd48fSIlya Yanok		@( printf '#define CC_VERSION_STRING "%s"\n' \
68228abd48fSIlya Yanok		 '$(shell $(CC) --version | head -n 1)' )>>  $@.tmp
68328abd48fSIlya Yanok		@( printf '#define LD_VERSION_STRING "%s"\n' \
68428abd48fSIlya Yanok		 '$(shell $(LD) -v | head -n 1)' )>>  $@.tmp
68528abd48fSIlya Yanok		@cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
68628abd48fSIlya Yanok
687249b53a6SLoïc Minier$(TIMESTAMP_FILE):
688249b53a6SLoïc Minier		@mkdir -p $(dir $(TIMESTAMP_FILE))
689a76406fbSLoïc Minier		@LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > $@.tmp
690a76406fbSLoïc Minier		@LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> $@.tmp
691a76406fbSLoïc Minier		@cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
692249b53a6SLoïc Minier
6930358df42SMike Frysingereasylogo env gdb:
6940358df42SMike Frysinger	$(MAKE) -C tools/$@ all MTD_VERSION=${MTD_VERSION}
6950358df42SMike Frysingergdbtools: gdb
6960358df42SMike Frysinger
697249b53a6SLoïc Miniertools-all: easylogo env gdb $(VERSION_FILE) $(TIMESTAMP_FILE)
6980358df42SMike Frysinger	$(MAKE) -C tools HOST_TOOLS_ALL=y
6990358df42SMike Frysinger
7004e53a258SWolfgang Denk.PHONY : CHANGELOG
7014e53a258SWolfgang DenkCHANGELOG:
702b985b5d6SBen Warren	git log --no-merges U-Boot-1_1_5.. | \
703b985b5d6SBen Warren	unexpand -a | sed -e 's/\s\s*$$//' > $@
7044e53a258SWolfgang Denk
7050a823aa2SHarald Welteinclude/license.h: tools/bin2header COPYING
7060a823aa2SHarald Welte	cat COPYING | gzip -9 -c | ./tools/bin2header license_gzip > include/license.h
7077ebf7443Swdenk#########################################################################
7087ebf7443Swdenk
7097ebf7443Swdenkunconfig:
710887e2ec9SStefan Roese	@rm -f $(obj)include/config.h $(obj)include/config.mk \
7112f155f6cSGrant Likely		$(obj)board/*/config.tmp $(obj)board/*/*/config.tmp \
7122f155f6cSGrant Likely		$(obj)include/autoconf.mk $(obj)include/autoconf.mk.dep
7137ebf7443Swdenk
714a6862bc1SWolfgang Denk%_config::	unconfig
715a6862bc1SWolfgang Denk	@$(MKCONFIG) -A $(@:_config=)
716a6862bc1SWolfgang Denk
717d6a5e6d5SLoïc Miniersinclude $(obj).boards.depend
718d6a5e6d5SLoïc Minier$(obj).boards.depend:	boards.cfg
71937d0e777SLauri Hintsala	@awk '(NF && $$1 !~ /^#/) { print $$1 ": " $$1 "_config; $$(MAKE)" }' $< > $@
7209f4a4206SMike Frysinger
7218c994630SWolfgang Denk#
7228c994630SWolfgang Denk# Functions to generate common board directory names
7238c994630SWolfgang Denk#
7248c994630SWolfgang Denklcname	= $(shell echo $(1) | sed -e 's/\(.*\)_config/\L\1/')
7258c994630SWolfgang Denkucname	= $(shell echo $(1) | sed -e 's/\(.*\)_config/\U\1/')
7268c994630SWolfgang Denk
7277ebf7443Swdenk#========================================================================
7287ebf7443Swdenk# ARM
7297ebf7443Swdenk#========================================================================
73043a5f0dfSPo-Yu Chuang
73147fd3bffSJean-Christophe PLAGNIOL-VILLARDSX1_stdout_serial_config \
7322d24a3a7SwdenkSX1_config:		unconfig
73347fd3bffSJean-Christophe PLAGNIOL-VILLARD	@mkdir -p $(obj)include
73447fd3bffSJean-Christophe PLAGNIOL-VILLARD	@if [ "$(findstring _stdout_serial_, $@)" ] ; then \
73547fd3bffSJean-Christophe PLAGNIOL-VILLARD		echo "#undef CONFIG_STDOUT_USBTTY" >> $(obj)include/config.h ; \
73647fd3bffSJean-Christophe PLAGNIOL-VILLARD	else \
73747fd3bffSJean-Christophe PLAGNIOL-VILLARD		echo "#define CONFIG_STDOUT_USBTTY" >> $(obj)include/config.h ; \
73847fd3bffSJean-Christophe PLAGNIOL-VILLARD	fi;
7390e42ada3SWolfgang Denk	@$(MKCONFIG) -n $@ SX1 arm arm925t sx1
7402d24a3a7Swdenk
741699f0512SWolfgang Denk#########################################################################
74211edcfe2SGuennadi Liakhovetski## ARM1176 Systems
74311edcfe2SGuennadi Liakhovetski#########################################################################
74411edcfe2SGuennadi Liakhovetskismdk6400_noUSB_config	\
74511edcfe2SGuennadi Liakhovetskismdk6400_config	:	unconfig
74611edcfe2SGuennadi Liakhovetski	@mkdir -p $(obj)include $(obj)board/samsung/smdk6400
74711edcfe2SGuennadi Liakhovetski	@mkdir -p $(obj)nand_spl/board/samsung/smdk6400
74811edcfe2SGuennadi Liakhovetski	@echo "#define CONFIG_NAND_U_BOOT" > $(obj)include/config.h
7490e42ada3SWolfgang Denk	@echo "CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk
75011edcfe2SGuennadi Liakhovetski	@if [ -z "$(findstring smdk6400_noUSB_config,$@)" ]; then			\
75111edcfe2SGuennadi Liakhovetski		echo "RAM_TEXT = 0x57e00000" >> $(obj)board/samsung/smdk6400/config.tmp;\
75211edcfe2SGuennadi Liakhovetski	else										\
75311edcfe2SGuennadi Liakhovetski		echo "RAM_TEXT = 0xc7e00000" >> $(obj)board/samsung/smdk6400/config.tmp;\
75411edcfe2SGuennadi Liakhovetski	fi
75554e19a7dSWolfgang Denk	@$(MKCONFIG) smdk6400 arm arm1176 smdk6400 samsung s3c64xx
75611edcfe2SGuennadi Liakhovetski	@echo "CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk
75711edcfe2SGuennadi Liakhovetski
7580afe519aSWolfgang Denk#########################################################################
7593e38691eSwdenk#########################################################################
7607ebf7443Swdenk
7617ebf7443Swdenkclean:
7621bc15386SPeter Tyser	@rm -f $(obj)examples/standalone/82559_eeprom			  \
763d640ac58SWolfgang Denk	       $(obj)examples/standalone/atmel_df_pow2			  \
7641bc15386SPeter Tyser	       $(obj)examples/standalone/eepro100_eeprom		  \
7651bc15386SPeter Tyser	       $(obj)examples/standalone/hello_world			  \
7661bc15386SPeter Tyser	       $(obj)examples/standalone/interrupt			  \
7671bc15386SPeter Tyser	       $(obj)examples/standalone/mem_to_mem_idma2intr		  \
7681bc15386SPeter Tyser	       $(obj)examples/standalone/sched				  \
769201a017cSMike Frysinger	       $(obj)examples/standalone/smc911{11,x}_eeprom		  \
7701bc15386SPeter Tyser	       $(obj)examples/standalone/test_burst			  \
7711bc15386SPeter Tyser	       $(obj)examples/standalone/timer
772d4abc757SPeter Tyser	@rm -f $(obj)examples/api/demo{,.bin}
773f9301e1cSWolfgang Denk	@rm -f $(obj)tools/bmp_logo	   $(obj)tools/easylogo/easylogo  \
774f9301e1cSWolfgang Denk	       $(obj)tools/env/{fw_printenv,fw_setenv}			  \
775f9301e1cSWolfgang Denk	       $(obj)tools/envcrc					  \
776f9301e1cSWolfgang Denk	       $(obj)tools/gdb/{astest,gdbcont,gdbsend}			  \
777f9301e1cSWolfgang Denk	       $(obj)tools/gen_eth_addr    $(obj)tools/img2srec		  \
7787717fe10SHorst Kronstorfer	       $(obj)tools/mk{env,}image   $(obj)tools/mpc86x_clk	  \
77981e35203SChander Kashyap	       $(obj)tools/mk{smdk5250,}spl				  \
780f9301e1cSWolfgang Denk	       $(obj)tools/ncb		   $(obj)tools/ubsha1
781f9301e1cSWolfgang Denk	@rm -f $(obj)board/cray/L1/{bootscript.c,bootscript.image}	  \
78274c7a95fSWolfgang Denk	       $(obj)board/matrix_vision/*/bootscript.img		  \
783566e5cf4SWolfgang Denk	       $(obj)board/voiceblue/eeprom 				  \
7841aada9cdSWolfgang Denk	       $(obj)u-boot.lds						  \
785fb5166ceSMike Frysinger	       $(obj)arch/blackfin/cpu/bootrom-asm-offsets.[chs]	  \
786fb5166ceSMike Frysinger	       $(obj)arch/blackfin/cpu/init.{lds,elf}
787dc7746d8SWolfgang Denk	@rm -f $(obj)include/bmp_logo.h
788c270730fSChe-Liang Chiou	@rm -f $(obj)include/bmp_logo_data.h
78916a354f9SWolfgang Denk	@rm -f $(obj)lib/asm-offsets.s
790a4814a69SStefano Babic	@rm -f $(obj)include/generated/asm-offsets.h
791a4814a69SStefano Babic	@rm -f $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s
792ff6b47adSKumar Gala	@rm -f $(obj)nand_spl/{u-boot.lds,u-boot-nand_spl.lds,u-boot-spl,u-boot-spl.map,System.map}
793ca6189dbSKyungmin Park	@rm -f $(obj)onenand_ipl/onenand-{ipl,ipl.bin,ipl.map}
794ca6189dbSKyungmin Park	@rm -f $(ONENAND_BIN)
7951aada9cdSWolfgang Denk	@rm -f $(obj)onenand_ipl/u-boot.lds
7965df2ee27SDaniel Schwierzeck	@rm -f $(obj)spl/{u-boot-spl,u-boot-spl.bin,u-boot-spl.lds,u-boot-spl.map}
7974e4b21bdSJoel A Fernandes	@rm -f $(obj)MLO
798d4abc757SPeter Tyser	@rm -f $(TIMESTAMP_FILE) $(VERSION_FILE)
799ae6d1056SWolfgang Denk	@find $(OBJTREE) -type f \
8004a30f1e8STom Rini		\( -name 'core' -o -name '*.bak' -o -name '*~' -o -name '*.su' \
8012b48f7d5SPeter Tyser		-o -name '*.o'	-o -name '*.a' -o -name '*.exe'	\) -print \
8027ebf7443Swdenk		| xargs rm -f
8037ebf7443Swdenk
804734329f9SAndy Fleming# Removes everything not needed for testing u-boot
805734329f9SAndy Flemingtidy:	clean
806734329f9SAndy Fleming	@find $(OBJTREE) -type f \( -name '*.depend*' \) -print | xargs rm -f
807734329f9SAndy Fleming
808734329f9SAndy Flemingclobber:	tidy
809734329f9SAndy Fleming	@find $(OBJTREE) -type f \( -name '*.srec' \
810734329f9SAndy Fleming		-o -name '*.bin' -o -name u-boot.img \) \
811734329f9SAndy Fleming		-print0 | xargs -0 rm -f
812ffda586fSLi Yang	@rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \
8135013c09fSWolfgang Denk		$(obj)cscope.* $(obj)*.*~
8144e0fbb98SDaniel Schwierzeck	@rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL-y)
815aa0c7a86SPrafulla Wadaskar	@rm -f $(obj)u-boot.kwb
816c5fb70c9SStefano Babic	@rm -f $(obj)u-boot.imx
8177816f2cfSHeiko Schocher	@rm -f $(obj)u-boot.ubl
818d36d8859SChristian Riesch	@rm -f $(obj)u-boot.ais
819bbb0b128SSimon Glass	@rm -f $(obj)u-boot.dtb
82030b9b932SMarek Vasut	@rm -f $(obj)u-boot.sb
82194aebe6cSStefan Roese	@rm -f $(obj)u-boot.spr
8228b425b3fSDaniel Schwierzeck	@rm -f $(obj)tools/xway-swap-bytes
823a47a12beSStefan Roese	@rm -f $(obj)arch/powerpc/cpu/mpc824x/bedbug_603e.c
8242d14e36aSYork Sun	@rm -f $(obj)arch/powerpc/cpu/mpc83xx/ddr-gen?.c
825a9d8bc98SLoïc Minier	@rm -fr $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
82616a354f9SWolfgang Denk	@rm -fr $(obj)include/generated
827a958b663SJean-Christophe PLAGNIOL-VILLARD	@[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f
828a958b663SJean-Christophe PLAGNIOL-VILLARD	@[ ! -d $(obj)onenand_ipl ] || find $(obj)onenand_ipl -name "*" -type l -print | xargs rm -f
829bbb0b128SSimon Glass	@rm -f $(obj)dts/*.tmp
8306d660e77SSughosh Ganu	@rm -f $(obj)spl/u-boot-spl{,-pad}.ais
8317ebf7443Swdenk
8327ebf7443Swdenkmrproper \
8337ebf7443Swdenkdistclean:	clobber unconfig
834afd077bdSMike Frysingerifneq ($(OBJTREE),$(SRCTREE))
835ae6d1056SWolfgang Denk	rm -rf $(obj)*
836f9328639SMarian Balakowiczendif
8377ebf7443Swdenk
8387ebf7443Swdenkbackup:
8397ebf7443Swdenk	F=`basename $(TOPDIR)` ; cd .. ; \
840d6b93714SIlya Yanok	gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
8417ebf7443Swdenk
8427ebf7443Swdenk#########################################################################
843