xref: /openbmc/u-boot/Makefile (revision 18936ee2)
17ebf7443Swdenk#
2b1af6f53SWolfgang Denk# (C) Copyright 2000-2011
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
2442d44f63SWolfgang DenkVERSION = 2011
256ceb0135SWolfgang DenkPATCHLEVEL = 09
268b9e4787SWolfgang DenkSUBLEVEL =
271d5e7fb4SWolfgang 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
177d51dfff7SIlya Yanokifndef LDSCRIPT
178d51dfff7SIlya Yanok	#LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
179d51dfff7SIlya Yanok	ifdef CONFIG_SYS_LDSCRIPT
180d51dfff7SIlya Yanok		# need to strip off double quotes
181d51dfff7SIlya Yanok		LDSCRIPT := $(subst ",,$(CONFIG_SYS_LDSCRIPT))
182d51dfff7SIlya Yanok	endif
183d51dfff7SIlya Yanokendif
184d51dfff7SIlya Yanok
185d51dfff7SIlya Yanokifndef LDSCRIPT
186d51dfff7SIlya Yanok	ifeq ($(CONFIG_NAND_U_BOOT),y)
187d51dfff7SIlya Yanok		LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
188d51dfff7SIlya Yanok		ifeq ($(wildcard $(LDSCRIPT)),)
189d51dfff7SIlya Yanok			LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds
190d51dfff7SIlya Yanok		endif
191d51dfff7SIlya Yanok	endif
192d51dfff7SIlya Yanok	ifeq ($(wildcard $(LDSCRIPT)),)
193d51dfff7SIlya Yanok		LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
194d51dfff7SIlya Yanok	endif
195d51dfff7SIlya Yanok	ifeq ($(wildcard $(LDSCRIPT)),)
196d51dfff7SIlya Yanok		LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot.lds
197d51dfff7SIlya Yanok	endif
198d51dfff7SIlya Yanok	ifeq ($(wildcard $(LDSCRIPT)),)
199d51dfff7SIlya Yanok$(error could not find linker script)
200d51dfff7SIlya Yanok	endif
201d51dfff7SIlya Yanokendif
202d51dfff7SIlya Yanok
2037ebf7443Swdenk#########################################################################
2047ebf7443Swdenk# U-Boot objects....order is important (i.e. start must be first)
2057ebf7443Swdenk
20603b7004dSPeter TyserOBJS  = $(CPUDIR)/start.o
207fea25720SGraeme Russifeq ($(CPU),x86)
20803b7004dSPeter TyserOBJS += $(CPUDIR)/start16.o
20903b7004dSPeter TyserOBJS += $(CPUDIR)/resetvec.o
2102262cfeeSwdenkendif
2117ebf7443Swdenkifeq ($(CPU),ppc4xx)
21203b7004dSPeter TyserOBJS += $(CPUDIR)/resetvec.o
2137ebf7443Swdenkendif
21442d1f039Swdenkifeq ($(CPU),mpc85xx)
21503b7004dSPeter TyserOBJS += $(CPUDIR)/resetvec.o
21642d1f039Swdenkendif
2177ebf7443Swdenk
218f9328639SMarian BalakowiczOBJS := $(addprefix $(obj),$(OBJS))
219f9328639SMarian Balakowicz
2206d8962e8SSebastien CarlierLIBS  = lib/libgeneric.o
2216d8962e8SSebastien CarlierLIBS += lib/lzma/liblzma.o
2226d8962e8SSebastien CarlierLIBS += lib/lzo/liblzo.o
223e89516f0SMike FrysingerLIBS += lib/zlib/libz.o
2247608d75fSKim PhillipsLIBS += $(shell if [ -f board/$(VENDOR)/common/Makefile ]; then echo \
2256d8962e8SSebastien Carlier	"board/$(VENDOR)/common/lib$(VENDOR).o"; fi)
2266d8962e8SSebastien CarlierLIBS += $(CPUDIR)/lib$(CPU).o
2271d9f4105Swdenkifdef SOC
2286d8962e8SSebastien CarlierLIBS += $(CPUDIR)/$(SOC)/lib$(SOC).o
2291d9f4105Swdenkendif
230323bfa8fSStefan Roeseifeq ($(CPU),ixp)
2316d8962e8SSebastien CarlierLIBS += arch/arm/cpu/ixp/npe/libnpe.o
232323bfa8fSStefan Roeseendif
233bbb0b128SSimon Glassifeq ($(CONFIG_OF_EMBED),y)
234bbb0b128SSimon GlassLIBS += dts/libdts.o
235bbb0b128SSimon Glassendif
2366d8962e8SSebastien CarlierLIBS += arch/$(ARCH)/lib/lib$(ARCH).o
2376d8962e8SSebastien CarlierLIBS += fs/cramfs/libcramfs.o fs/fat/libfat.o fs/fdos/libfdos.o fs/jffs2/libjffs2.o \
2386d8962e8SSebastien Carlier	fs/reiserfs/libreiserfs.o fs/ext2/libext2fs.o fs/yaffs2/libyaffs2.o \
2396d8962e8SSebastien Carlier	fs/ubifs/libubifs.o
2406d8962e8SSebastien CarlierLIBS += net/libnet.o
2416d8962e8SSebastien CarlierLIBS += disk/libdisk.o
2426d8962e8SSebastien CarlierLIBS += drivers/bios_emulator/libatibiosemu.o
2436d8962e8SSebastien CarlierLIBS += drivers/block/libblock.o
2446d8962e8SSebastien CarlierLIBS += drivers/dma/libdma.o
2456d8962e8SSebastien CarlierLIBS += drivers/fpga/libfpga.o
2466d8962e8SSebastien CarlierLIBS += drivers/gpio/libgpio.o
2476d8962e8SSebastien CarlierLIBS += drivers/hwmon/libhwmon.o
2486d8962e8SSebastien CarlierLIBS += drivers/i2c/libi2c.o
2496d8962e8SSebastien CarlierLIBS += drivers/input/libinput.o
2506d8962e8SSebastien CarlierLIBS += drivers/misc/libmisc.o
2516d8962e8SSebastien CarlierLIBS += drivers/mmc/libmmc.o
2526d8962e8SSebastien CarlierLIBS += drivers/mtd/libmtd.o
2536d8962e8SSebastien CarlierLIBS += drivers/mtd/nand/libnand.o
2546d8962e8SSebastien CarlierLIBS += drivers/mtd/onenand/libonenand.o
2556d8962e8SSebastien CarlierLIBS += drivers/mtd/ubi/libubi.o
2566d8962e8SSebastien CarlierLIBS += drivers/mtd/spi/libspi_flash.o
2576d8962e8SSebastien CarlierLIBS += drivers/net/libnet.o
2586d8962e8SSebastien CarlierLIBS += drivers/net/phy/libphy.o
2596d8962e8SSebastien CarlierLIBS += drivers/pci/libpci.o
2606d8962e8SSebastien CarlierLIBS += drivers/pcmcia/libpcmcia.o
2616d8962e8SSebastien CarlierLIBS += drivers/power/libpower.o
2626d8962e8SSebastien CarlierLIBS += drivers/spi/libspi.o
2637737d5c6SDave Liuifeq ($(CPU),mpc83xx)
2646d8962e8SSebastien CarlierLIBS += drivers/qe/libqe.o
265d29d17d7SYork SunLIBS += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
2666d8962e8SSebastien CarlierLIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
2677737d5c6SDave Liuendif
268da9d4610SAndy Flemingifeq ($(CPU),mpc85xx)
2696d8962e8SSebastien CarlierLIBS += drivers/qe/libqe.o
270c916d7c9SKumar GalaLIBS += drivers/net/fm/libfm.o
2716d8962e8SSebastien CarlierLIBS += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
2726d8962e8SSebastien CarlierLIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
27358e5e9afSKumar Galaendif
27458e5e9afSKumar Galaifeq ($(CPU),mpc86xx)
2756d8962e8SSebastien CarlierLIBS += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
2766d8962e8SSebastien CarlierLIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
277da9d4610SAndy Flemingendif
2786d8962e8SSebastien CarlierLIBS += drivers/rtc/librtc.o
2796d8962e8SSebastien CarlierLIBS += drivers/serial/libserial.o
2805e124724SVadim Bendeburyifeq ($(CONFIG_GENERIC_LPC_TPM),y)
2815e124724SVadim BendeburyLIBS += drivers/tpm/libtpm.o
2825e124724SVadim Bendeburyendif
2836d8962e8SSebastien CarlierLIBS += drivers/twserial/libtws.o
284181f565cSMike FrysingerLIBS += drivers/usb/eth/libusb_eth.o
2856d8962e8SSebastien CarlierLIBS += drivers/usb/gadget/libusb_gadget.o
2866d8962e8SSebastien CarlierLIBS += drivers/usb/host/libusb_host.o
2876d8962e8SSebastien CarlierLIBS += drivers/usb/musb/libusb_musb.o
2886d8962e8SSebastien CarlierLIBS += drivers/usb/phy/libusb_phy.o
2896d8962e8SSebastien CarlierLIBS += drivers/video/libvideo.o
2906d8962e8SSebastien CarlierLIBS += drivers/watchdog/libwatchdog.o
2916d8962e8SSebastien CarlierLIBS += common/libcommon.o
2926d8962e8SSebastien CarlierLIBS += lib/libfdt/libfdt.o
2936d8962e8SSebastien CarlierLIBS += api/libapi.o
2946d8962e8SSebastien CarlierLIBS += post/libpost.o
295f9328639SMarian Balakowicz
296a9c1c042SSricharanifneq ($(CONFIG_AM335X)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),)
297f0f4b5ffSChandan NathLIBS += $(CPUDIR)/omap-common/libomap-common.o
298f0f4b5ffSChandan Nathendif
299*18936ee2SJason Liu
300*18936ee2SJason Liuifeq ($(SOC),mx5)
301*18936ee2SJason LiuLIBS += $(CPUDIR)/imx-common/libimx-common.o
302*18936ee2SJason Liuendif
303*18936ee2SJason Liuifeq ($(SOC),mx6)
304*18936ee2SJason LiuLIBS += $(CPUDIR)/imx-common/libimx-common.o
305*18936ee2SJason Liuendif
306*18936ee2SJason Liu
307852bd07cSMinkyu Kangifeq ($(SOC),s5pc1xx)
3086d8962e8SSebastien CarlierLIBS += $(CPUDIR)/s5p-common/libs5p-common.o
309852bd07cSMinkyu Kangendif
310393cb361SChander Kashyapifeq ($(SOC),exynos)
3116d8962e8SSebastien CarlierLIBS += $(CPUDIR)/s5p-common/libs5p-common.o
312852bd07cSMinkyu Kangendif
313852bd07cSMinkyu Kang
314566d49a3SWolfgang DenkLIBS := $(addprefix $(obj),$(sort $(LIBS)))
315249b53a6SLoïc Minier.PHONY : $(LIBS)
316a8c7c708Swdenk
3176d8962e8SSebastien CarlierLIBBOARD = board/$(BOARDDIR)/lib$(BOARD).o
318de109d90SWolfgang DenkLIBBOARD := $(addprefix $(obj),$(LIBBOARD))
319de109d90SWolfgang Denk
3204f7cb08eSwdenk# Add GCC lib
32152b1bf2cSWolfgang Denkifdef USE_PRIVATE_LIBGCC
32252b1bf2cSWolfgang Denkifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
323635d1b3eSMatthias WeisserPLATFORM_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/libgcc.o
32452b1bf2cSWolfgang Denkelse
32552b1bf2cSWolfgang DenkPLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc
32652b1bf2cSWolfgang Denkendif
32752b1bf2cSWolfgang Denkelse
328cca4e4aeSWolfgang DenkPLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
32952b1bf2cSWolfgang Denkendif
33052b1bf2cSWolfgang DenkPLATFORM_LIBS += $(PLATFORM_LIBGCC)
33152b1bf2cSWolfgang Denkexport PLATFORM_LIBS
3323d3befa7Swdenk
3336ac9f479SMike Frysinger# Special flags for CPP when processing the linker script.
3346ac9f479SMike Frysinger# Pass the version down so we can handle backwards compatibility
3356ac9f479SMike Frysinger# on the fly.
3366ac9f479SMike FrysingerLDPPFLAGS += \
3376ac9f479SMike Frysinger	-include $(TOPDIR)/include/u-boot/u-boot.lds.h \
3386ac9f479SMike Frysinger	$(shell $(LD) --version | \
3396ac9f479SMike Frysinger	  sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
3406ac9f479SMike Frysinger
341f9328639SMarian Balakowicz__OBJS := $(subst $(obj),,$(OBJS))
342de109d90SWolfgang Denk__LIBS := $(subst $(obj),,$(LIBS)) $(subst $(obj),,$(LIBBOARD))
343f9328639SMarian Balakowicz
3447ebf7443Swdenk#########################################################################
345bdccc4feSwdenk#########################################################################
3467ebf7443Swdenk
347f3a14d37SMike Frysingerifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
348f3a14d37SMike FrysingerBOARD_SIZE_CHECK = \
349f3a14d37SMike Frysinger	@actual=`wc -c $@ | awk '{print $$1}'`; \
350f3a14d37SMike Frysinger	limit=$(CONFIG_BOARD_SIZE_LIMIT); \
351f3a14d37SMike Frysinger	if test $$actual -gt $$limit; then \
352f3a14d37SMike Frysinger		echo "$@ exceeds file size limit:"; \
353f3a14d37SMike Frysinger		echo "  limit:  $$limit bytes"; \
354f3a14d37SMike Frysinger		echo "  actual: $$actual bytes"; \
355f3a14d37SMike Frysinger		echo "  excess: $$((actual - limit)) bytes"; \
356f3a14d37SMike Frysinger		exit 1; \
357f3a14d37SMike Frysinger	fi
358f3a14d37SMike Frysingerelse
359f3a14d37SMike FrysingerBOARD_SIZE_CHECK =
360f3a14d37SMike Frysingerendif
361f3a14d37SMike Frysinger
3623e88337bSMike Frysinger# Always append ALL so that arch config.mk's can add custom ones
3634e0fbb98SDaniel SchwierzeckALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map
364e935a374SHaiying Wang
3654e0fbb98SDaniel SchwierzeckALL-$(CONFIG_NAND_U_BOOT) += $(obj)u-boot-nand.bin
3664e0fbb98SDaniel SchwierzeckALL-$(CONFIG_ONENAND_U_BOOT) += $(obj)u-boot-onenand.bin
367e935a374SHaiying WangONENAND_BIN ?= $(obj)onenand_ipl/onenand-ipl-2k.bin
3684e0fbb98SDaniel SchwierzeckALL-$(CONFIG_MMC_U_BOOT) += $(obj)mmc_spl/u-boot-mmc-spl.bin
3695df2ee27SDaniel SchwierzeckALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin
3702c0f79e4SSimon GlassALL-$(CONFIG_OF_SEPARATE) += $(obj)u-boot.dtb $(obj)u-boot-dtb.bin
3717ebf7443Swdenk
372349e83f0SChe-liang Chiouall:		$(ALL-y) $(SUBDIR_EXAMPLES)
3737ebf7443Swdenk
3742c0f79e4SSimon Glass$(obj)u-boot.dtb:	$(obj)u-boot
3752c0f79e4SSimon Glass		$(MAKE) -C dts binary
3762c0f79e4SSimon Glass		mv $(obj)dts/dt.dtb $@
3772c0f79e4SSimon Glass
3782c0f79e4SSimon Glass$(obj)u-boot-dtb.bin:	$(obj)u-boot.bin $(obj)u-boot.dtb
3792c0f79e4SSimon Glass		cat $^ >$@
3802c0f79e4SSimon Glass
381f9328639SMarian Balakowicz$(obj)u-boot.hex:	$(obj)u-boot
3826310eb9dSwdenk		$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
3836310eb9dSwdenk
384f9328639SMarian Balakowicz$(obj)u-boot.srec:	$(obj)u-boot
3850817d688SRicardo Ribalda Delgado		$(OBJCOPY) -O srec $< $@
3867ebf7443Swdenk
387f9328639SMarian Balakowicz$(obj)u-boot.bin:	$(obj)u-boot
3887ebf7443Swdenk		$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
389f3a14d37SMike Frysinger		$(BOARD_SIZE_CHECK)
3907ebf7443Swdenk
39194a91e24SMike Frysinger$(obj)u-boot.ldr:	$(obj)u-boot
39276d82187SMike Frysinger		$(CREATE_LDR_ENV)
39368e56324SMike Frysinger		$(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS)
394f3a14d37SMike Frysinger		$(BOARD_SIZE_CHECK)
39594a91e24SMike Frysinger
39694a91e24SMike Frysinger$(obj)u-boot.ldr.hex:	$(obj)u-boot.ldr
39794a91e24SMike Frysinger		$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ -I binary
39894a91e24SMike Frysinger
39994a91e24SMike Frysinger$(obj)u-boot.ldr.srec:	$(obj)u-boot.ldr
40094a91e24SMike Frysinger		$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ -I binary
40194a91e24SMike Frysinger
402f9328639SMarian Balakowicz$(obj)u-boot.img:	$(obj)u-boot.bin
403a2a0a717SWolfgang Denk		$(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
4043857f8f5Saneeshv		-O u-boot -a $(CONFIG_SYS_TEXT_BASE) -e 0 \
405881a87ecSWolfgang Denk		-n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
406bdccc4feSwdenk			sed -e 's/"[	 ]*$$/ for $(BOARD) board"/') \
407bdccc4feSwdenk		-d $< $@
408bdccc4feSwdenk
4098edcde5eSStefano Babic$(obj)u-boot.imx:       $(obj)u-boot.bin
41045d7d72bSStefano Babic		$(obj)tools/mkimage -n  $(CONFIG_IMX_CONFIG) -T imximage \
41114d0a02aSWolfgang Denk		-e $(CONFIG_SYS_TEXT_BASE) -d $< $@
4128edcde5eSStefano Babic
413aa0c7a86SPrafulla Wadaskar$(obj)u-boot.kwb:       $(obj)u-boot.bin
41431d80c77SPrafulla Wadaskar		$(obj)tools/mkimage -n $(CONFIG_SYS_KWD_CONFIG) -T kwbimage \
4152ea88b06SEric Cooper		-a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) -d $< $@
416aa0c7a86SPrafulla Wadaskar
417566a494fSHeiko Schocher$(obj)u-boot.sha1:	$(obj)u-boot.bin
41801159530SHeiko Schocher		$(obj)tools/ubsha1 $(obj)u-boot.bin
419566a494fSHeiko Schocher
420f9328639SMarian Balakowicz$(obj)u-boot.dis:	$(obj)u-boot
4217ebf7443Swdenk		$(OBJDUMP) -d $< > $@
4227ebf7443Swdenk
423435199f3SHeiko Schocher$(obj)u-boot.ubl:       $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
424435199f3SHeiko Schocher		$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(PAD_TO) -O binary $(obj)spl/u-boot-spl $(obj)spl/u-boot-spl-pad.bin
425435199f3SHeiko Schocher		cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin > $(obj)u-boot-ubl.bin
4267816f2cfSHeiko Schocher		$(obj)tools/mkimage -n $(UBL_CONFIG) -T ublimage \
427435199f3SHeiko Schocher		-e $(CONFIG_SYS_TEXT_BASE) -d $(obj)u-boot-ubl.bin $(obj)u-boot.ubl
428435199f3SHeiko Schocher		rm $(obj)u-boot-ubl.bin
429435199f3SHeiko Schocher		rm $(obj)spl/u-boot-spl-pad.bin
4307816f2cfSHeiko Schocher
43130b9b932SMarek Vasut$(obj)u-boot.sb:       $(obj)u-boot.bin $(obj)spl/u-boot-spl.bin
43230b9b932SMarek Vasut		elftosb -zdf imx28 -c $(TOPDIR)/board/$(BOARDDIR)/u-boot.bd \
43330b9b932SMarek Vasut			-o $(obj)u-boot.sb
43430b9b932SMarek Vasut
43586eb49b3SSimon Glassifeq ($(CONFIG_SANDBOX),y)
43686eb49b3SSimon GlassGEN_UBOOT = \
43786eb49b3SSimon Glass		cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \
43886eb49b3SSimon Glass			-Wl,--start-group $(__LIBS) -Wl,--end-group \
43986eb49b3SSimon Glass			$(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot
44086eb49b3SSimon Glasselse
441ecb1dc89SMike FrysingerGEN_UBOOT = \
442de109d90SWolfgang Denk		UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \
443de109d90SWolfgang Denk		sed  -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
4448aba9dceSNobuhiro Iwamatsu		cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM $(__OBJS) \
445f9328639SMarian Balakowicz			--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
446b2184c31Swdenk			-Map u-boot.map -o u-boot
44786eb49b3SSimon Glassendif
44886eb49b3SSimon Glass
44916a354f9SWolfgang Denk$(obj)u-boot:	depend \
450349e83f0SChe-liang Chiou		$(SUBDIR_TOOLS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds
451ecb1dc89SMike Frysinger		$(GEN_UBOOT)
452ecb1dc89SMike Frysingerifeq ($(CONFIG_KALLSYMS),y)
4531aada9cdSWolfgang Denk		smap=`$(call SYSTEM_MAP,u-boot) | \
4541aada9cdSWolfgang Denk			awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \
4551aada9cdSWolfgang Denk		$(CC) $(CFLAGS) -DSYSTEM_MAP="\"$${smap}\"" \
4561aada9cdSWolfgang Denk			-c common/system_map.c -o $(obj)common/system_map.o
457ecb1dc89SMike Frysinger		$(GEN_UBOOT) $(obj)common/system_map.o
458ecb1dc89SMike Frysingerendif
4597ebf7443Swdenk
460d0d6144eSPeter Tyser$(OBJS):	depend
46103b7004dSPeter Tyser		$(MAKE) -C $(CPUDIR) $(if $(REMOTE_BUILD),$@,$(notdir $@))
462f9328639SMarian Balakowicz
463349e83f0SChe-liang Chiou$(LIBS):	depend $(SUBDIR_TOOLS)
464f9328639SMarian Balakowicz		$(MAKE) -C $(dir $(subst $(obj),,$@))
465a8c7c708Swdenk
466d0d6144eSPeter Tyser$(LIBBOARD):	depend $(LIBS)
467de109d90SWolfgang Denk		$(MAKE) -C $(dir $(subst $(obj),,$@))
468de109d90SWolfgang Denk
469d0d6144eSPeter Tyser$(SUBDIRS):	depend
470b028f715Swdenk		$(MAKE) -C $@ all
4717ebf7443Swdenk
472349e83f0SChe-liang Chiou$(SUBDIR_EXAMPLES): $(obj)u-boot
473349e83f0SChe-liang Chiou
474d0d6144eSPeter Tyser$(LDSCRIPT):	depend
475f65c9812SMike Frysinger		$(MAKE) -C $(dir $@) $(notdir $@)
476f65c9812SMike Frysinger
4771aada9cdSWolfgang Denk$(obj)u-boot.lds: $(LDSCRIPT)
4781aada9cdSWolfgang Denk		$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
4791aada9cdSWolfgang Denk
480e935a374SHaiying Wangnand_spl:	$(TIMESTAMP_FILE) $(VERSION_FILE) depend
4818318fbf8SMarian Balakowicz		$(MAKE) -C nand_spl/board/$(BOARDDIR) all
482887e2ec9SStefan Roese
483e935a374SHaiying Wang$(obj)u-boot-nand.bin:	nand_spl $(obj)u-boot.bin
4848318fbf8SMarian Balakowicz		cat $(obj)nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > $(obj)u-boot-nand.bin
485887e2ec9SStefan Roese
486e935a374SHaiying Wangonenand_ipl:	$(TIMESTAMP_FILE) $(VERSION_FILE) $(obj)include/autoconf.mk
487f2302d44SStefan Roese		$(MAKE) -C onenand_ipl/board/$(BOARDDIR) all
488751b9b51SKyungmin Park
489e935a374SHaiying Wang$(obj)u-boot-onenand.bin:	onenand_ipl $(obj)u-boot.bin
490ca6189dbSKyungmin Park		cat $(ONENAND_BIN) $(obj)u-boot.bin > $(obj)u-boot-onenand.bin
491751b9b51SKyungmin Park
4920d3c62e4SChander Kashyapmmc_spl:	$(TIMESTAMP_FILE) $(VERSION_FILE) depend
4930d3c62e4SChander Kashyap		$(MAKE) -C mmc_spl/board/$(BOARDDIR) all
4940d3c62e4SChander Kashyap
4950d3c62e4SChander Kashyap$(obj)mmc_spl/u-boot-mmc-spl.bin:	mmc_spl
4960d3c62e4SChander Kashyap
497bd25fdbaSAneesh V$(obj)spl/u-boot-spl.bin:	$(SUBDIR_TOOLS) depend
4985df2ee27SDaniel Schwierzeck		$(MAKE) -C spl all
4995df2ee27SDaniel Schwierzeck
500f9328639SMarian Balakowiczupdater:
5010358df42SMike Frysinger		$(MAKE) -C tools/updater all
5028f713fdfSdzu
5032a998793SDaniel Hobi# Explicitly make _depend in subdirs containing multiple targets to prevent
5042a998793SDaniel Hobi# parallel sub-makes creating .depend files simultaneously.
50516a354f9SWolfgang Denkdepend dep:	$(TIMESTAMP_FILE) $(VERSION_FILE) \
50616a354f9SWolfgang Denk		$(obj)include/autoconf.mk \
507a4814a69SStefano Babic		$(obj)include/generated/generic-asm-offsets.h \
508a4814a69SStefano Babic		$(obj)include/generated/asm-offsets.h
50903b7004dSPeter Tyser		for dir in $(SUBDIRS) $(CPUDIR) $(dir $(LDSCRIPT)) ; do \
5102a998793SDaniel Hobi			$(MAKE) -C $$dir _depend ; done
5117ebf7443Swdenk
512e5e4e705SLi YangTAG_SUBDIRS = $(SUBDIRS)
513e5e4e705SLi YangTAG_SUBDIRS += $(dir $(__LIBS))
514a340c325SJean-Christophe PLAGNIOL-VILLARDTAG_SUBDIRS += include
515a340c325SJean-Christophe PLAGNIOL-VILLARD
516857d9ea6SHorst KronstorferFIND := find
517857d9ea6SHorst KronstorferFINDFLAGS := -L
518857d9ea6SHorst Kronstorfer
519f9328639SMarian Balakowicztags ctags:
520857d9ea6SHorst Kronstorfer		ctags -w -o $(obj)ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
521e5e4e705SLi Yang						-name '*.[chS]' -print`
5227ebf7443Swdenk
5237ebf7443Swdenketags:
524857d9ea6SHorst Kronstorfer		etags -a -o $(obj)etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
525e5e4e705SLi Yang						-name '*.[chS]' -print`
526ffda586fSLi Yangcscope:
527857d9ea6SHorst Kronstorfer		$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \
528857d9ea6SHorst Kronstorfer						cscope.files
529ffda586fSLi Yang		cscope -b -q -k
5307ebf7443Swdenk
531ecb1dc89SMike FrysingerSYSTEM_MAP = \
532ecb1dc89SMike Frysinger		$(NM) $1 | \
5337ebf7443Swdenk		grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
534ecb1dc89SMike Frysinger		LC_ALL=C sort
535ecb1dc89SMike Frysinger$(obj)System.map:	$(obj)u-boot
536ecb1dc89SMike Frysinger		@$(call SYSTEM_MAP,$<) > $(obj)System.map
5377ebf7443Swdenk
5382f155f6cSGrant Likely#
5392f155f6cSGrant Likely# Auto-generate the autoconf.mk file (which is included by all makefiles)
5402f155f6cSGrant Likely#
5412f155f6cSGrant Likely# This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
5422f155f6cSGrant Likely# the dep file is only include in this top level makefile to determine when
5432f155f6cSGrant Likely# to regenerate the autoconf.mk file.
5441510b82dSWolfgang Denk$(obj)include/autoconf.mk.dep: $(obj)include/config.h include/common.h
5451510b82dSWolfgang Denk	@$(XECHO) Generating $@ ; \
54616fe7775SMike Frysinger	set -e ; \
547ae6d1056SWolfgang Denk	: Generate the dependancies ; \
5484c34b2a0SMike Frysinger	$(CC) -x c -DDO_DEPS_ONLY -M $(CFLAGS) $(CPPFLAGS) \
5491510b82dSWolfgang Denk		-MQ $(obj)include/autoconf.mk include/common.h > $@
5501510b82dSWolfgang Denk
5511510b82dSWolfgang Denk$(obj)include/autoconf.mk: $(obj)include/config.h
5521510b82dSWolfgang Denk	@$(XECHO) Generating $@ ; \
5531510b82dSWolfgang Denk	set -e ; \
554ae6d1056SWolfgang Denk	: Extract the config macros ; \
5551510b82dSWolfgang Denk	$(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h | \
5564a0f7538SWolfgang Denk		sed -n -f tools/scripts/define2mk.sed > $@.tmp && \
5574a0f7538SWolfgang Denk	mv $@.tmp $@
5582f155f6cSGrant Likely
55916a354f9SWolfgang Denk$(obj)include/generated/generic-asm-offsets.h:	$(obj)include/autoconf.mk.dep \
56016a354f9SWolfgang Denk	$(obj)lib/asm-offsets.s
56116a354f9SWolfgang Denk	@$(XECHO) Generating $@
56216a354f9SWolfgang Denk	tools/scripts/make-asm-offsets $(obj)lib/asm-offsets.s $@
56316a354f9SWolfgang Denk
56416a354f9SWolfgang Denk$(obj)lib/asm-offsets.s:	$(obj)include/autoconf.mk.dep \
56516a354f9SWolfgang Denk	$(src)lib/asm-offsets.c
56616a354f9SWolfgang Denk	@mkdir -p $(obj)lib
56716a354f9SWolfgang Denk	$(CC) -DDO_DEPS_ONLY \
56816a354f9SWolfgang Denk		$(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
56916a354f9SWolfgang Denk		-o $@ $(src)lib/asm-offsets.c -c -S
57016a354f9SWolfgang Denk
571a4814a69SStefano Babic$(obj)include/generated/asm-offsets.h:	$(obj)include/autoconf.mk.dep \
572a4814a69SStefano Babic	$(obj)$(CPUDIR)/$(SOC)/asm-offsets.s
573a4814a69SStefano Babic	@echo Generating $@
574a4814a69SStefano Babic	tools/scripts/make-asm-offsets $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s $@
575a4814a69SStefano Babic
576a4814a69SStefano Babic$(obj)$(CPUDIR)/$(SOC)/asm-offsets.s:	$(obj)include/autoconf.mk.dep
577a4814a69SStefano Babic	@mkdir -p $(obj)$(CPUDIR)/$(SOC)
578a4814a69SStefano Babic	if [ -f $(src)$(CPUDIR)/$(SOC)/asm-offsets.c ];then \
579a4814a69SStefano Babic		$(CC) -DDO_DEPS_ONLY \
580a4814a69SStefano Babic		$(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
581a4814a69SStefano Babic			-o $@ $(src)$(CPUDIR)/$(SOC)/asm-offsets.c -c -S; \
582a4814a69SStefano Babic	else \
583a4814a69SStefano Babic		touch $@; \
584a4814a69SStefano Babic	fi
585a4814a69SStefano Babic
5867ebf7443Swdenk#########################################################################
587ae6d1056SWolfgang Denkelse	# !config.mk
588f9328639SMarian Balakowiczall $(obj)u-boot.hex $(obj)u-boot.srec $(obj)u-boot.bin \
589f9328639SMarian Balakowicz$(obj)u-boot.img $(obj)u-boot.dis $(obj)u-boot \
590249b53a6SLoïc Minier$(filter-out tools,$(SUBDIRS)) \
5910358df42SMike Frysingerupdater depend dep tags ctags etags cscope $(obj)System.map:
5927ebf7443Swdenk	@echo "System not configured - see README" >&2
5937ebf7443Swdenk	@ exit 1
594c7c0d542SMike Frysinger
595249b53a6SLoïc Miniertools: $(VERSION_FILE) $(TIMESTAMP_FILE)
5960358df42SMike Frysinger	$(MAKE) -C $@ all
597ae6d1056SWolfgang Denkendif	# config.mk
5987ebf7443Swdenk
59928abd48fSIlya Yanok$(VERSION_FILE):
60014ce91b1SMike Frysinger		@mkdir -p $(dir $(VERSION_FILE))
60128abd48fSIlya Yanok		@( localvers='$(shell $(TOPDIR)/tools/setlocalversion $(TOPDIR))' ; \
60228abd48fSIlya Yanok		   printf '#define PLAIN_VERSION "%s%s"\n' \
60328abd48fSIlya Yanok			"$(U_BOOT_VERSION)" "$${localvers}" ; \
60428abd48fSIlya Yanok		   printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' \
60528abd48fSIlya Yanok			"$(U_BOOT_VERSION)" "$${localvers}" ; \
60628abd48fSIlya Yanok		) > $@.tmp
60728abd48fSIlya Yanok		@( printf '#define CC_VERSION_STRING "%s"\n' \
60828abd48fSIlya Yanok		 '$(shell $(CC) --version | head -n 1)' )>>  $@.tmp
60928abd48fSIlya Yanok		@( printf '#define LD_VERSION_STRING "%s"\n' \
61028abd48fSIlya Yanok		 '$(shell $(LD) -v | head -n 1)' )>>  $@.tmp
61128abd48fSIlya Yanok		@cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
61228abd48fSIlya Yanok
613249b53a6SLoïc Minier$(TIMESTAMP_FILE):
614249b53a6SLoïc Minier		@mkdir -p $(dir $(TIMESTAMP_FILE))
615a76406fbSLoïc Minier		@LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > $@.tmp
616a76406fbSLoïc Minier		@LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> $@.tmp
617a76406fbSLoïc Minier		@cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
618249b53a6SLoïc Minier
6190358df42SMike Frysingereasylogo env gdb:
6200358df42SMike Frysinger	$(MAKE) -C tools/$@ all MTD_VERSION=${MTD_VERSION}
6210358df42SMike Frysingergdbtools: gdb
6220358df42SMike Frysinger
623249b53a6SLoïc Miniertools-all: easylogo env gdb $(VERSION_FILE) $(TIMESTAMP_FILE)
6240358df42SMike Frysinger	$(MAKE) -C tools HOST_TOOLS_ALL=y
6250358df42SMike Frysinger
6264e53a258SWolfgang Denk.PHONY : CHANGELOG
6274e53a258SWolfgang DenkCHANGELOG:
628b985b5d6SBen Warren	git log --no-merges U-Boot-1_1_5.. | \
629b985b5d6SBen Warren	unexpand -a | sed -e 's/\s\s*$$//' > $@
6304e53a258SWolfgang Denk
6310a823aa2SHarald Welteinclude/license.h: tools/bin2header COPYING
6320a823aa2SHarald Welte	cat COPYING | gzip -9 -c | ./tools/bin2header license_gzip > include/license.h
6337ebf7443Swdenk#########################################################################
6347ebf7443Swdenk
6357ebf7443Swdenkunconfig:
636887e2ec9SStefan Roese	@rm -f $(obj)include/config.h $(obj)include/config.mk \
6372f155f6cSGrant Likely		$(obj)board/*/config.tmp $(obj)board/*/*/config.tmp \
6382f155f6cSGrant Likely		$(obj)include/autoconf.mk $(obj)include/autoconf.mk.dep
6397ebf7443Swdenk
640a6862bc1SWolfgang Denk%_config::	unconfig
641a6862bc1SWolfgang Denk	@$(MKCONFIG) -A $(@:_config=)
642a6862bc1SWolfgang Denk
643d6a5e6d5SLoïc Miniersinclude $(obj).boards.depend
644d6a5e6d5SLoïc Minier$(obj).boards.depend:	boards.cfg
645727ebd9fSMike Frysinger	awk '(NF && $$1 !~ /^#/) { print $$1 ": " $$1 "_config; $$(MAKE)" }' $< > $@
6469f4a4206SMike Frysinger
6478c994630SWolfgang Denk#
6488c994630SWolfgang Denk# Functions to generate common board directory names
6498c994630SWolfgang Denk#
6508c994630SWolfgang Denklcname	= $(shell echo $(1) | sed -e 's/\(.*\)_config/\L\1/')
6518c994630SWolfgang Denkucname	= $(shell echo $(1) | sed -e 's/\(.*\)_config/\U\1/')
6528c994630SWolfgang Denk
6537ebf7443Swdenk#========================================================================
6547ebf7443Swdenk# ARM
6557ebf7443Swdenk#========================================================================
65643a5f0dfSPo-Yu Chuang
657a4b46ed6SUlf Samuelssonxtract_omap1610xxx = $(subst _cs0boot,,$(subst _cs3boot,,$(subst _cs_autoboot,,$(subst _config,,$1))))
658a4b46ed6SUlf Samuelsson
65963e73c9aSwdenkomap1610inn_config \
66063e73c9aSwdenkomap1610inn_cs0boot_config \
66163e73c9aSwdenkomap1610inn_cs3boot_config \
6623ff02c27Swdenkomap1610inn_cs_autoboot_config \
66363e73c9aSwdenkomap1610h2_config \
66463e73c9aSwdenkomap1610h2_cs0boot_config \
6653ff02c27Swdenkomap1610h2_cs3boot_config \
6663ff02c27Swdenkomap1610h2_cs_autoboot_config:	unconfig
667f9328639SMarian Balakowicz	@mkdir -p $(obj)include
66863e73c9aSwdenk	@if [ "$(findstring _cs0boot_, $@)" ] ; then \
669cdd917a4SWolfgang Denk		echo "#define CONFIG_CS0_BOOT" >> .$(obj)include/config.h ; \
6703ff02c27Swdenk	elif [ "$(findstring _cs_autoboot_, $@)" ] ; then \
671cdd917a4SWolfgang Denk		echo "#define CONFIG_CS_AUTOBOOT" >> $(obj)include/config.h ; \
67263e73c9aSwdenk	else \
673cdd917a4SWolfgang Denk		echo "#define CONFIG_CS3_BOOT" >> $(obj)include/config.h ; \
67463e73c9aSwdenk	fi;
6750e42ada3SWolfgang Denk	@$(MKCONFIG) -n $@ -a $(call xtract_omap1610xxx,$@) arm arm926ejs omap1610inn ti omap
6766f21347dSwdenk
677a56bd922Swdenkomap730p2_config \
678a56bd922Swdenkomap730p2_cs0boot_config \
679a56bd922Swdenkomap730p2_cs3boot_config :	unconfig
680f9328639SMarian Balakowicz	@mkdir -p $(obj)include
681a56bd922Swdenk	@if [ "$(findstring _cs0boot_, $@)" ] ; then \
682f9328639SMarian Balakowicz		echo "#define CONFIG_CS0_BOOT" >> $(obj)include/config.h ; \
683a56bd922Swdenk	else \
684f9328639SMarian Balakowicz		echo "#define CONFIG_CS3_BOOT" >> $(obj)include/config.h ; \
685a56bd922Swdenk	fi;
686ed7a196cSWolfgang Denk	@$(MKCONFIG) -n $@ -a omap730p2 arm arm926ejs omap730p2 ti omap
687a56bd922Swdenk
688080cfee7SVipin KUMARspear300_config \
6897da69236SVipin KUMARspear310_config \
6907da69236SVipin KUMARspear320_config :	unconfig
691ed7a196cSWolfgang Denk	@$(MKCONFIG) -n $@ -t $@ spear3xx arm arm926ejs $(@:_config=) spear spear
6927e074158SVipin KUMAR
693566c9c16SVipin KUMARspear600_config :	unconfig
694ed7a196cSWolfgang Denk	@$(MKCONFIG) -n $@ -t $@ spear6xx arm arm926ejs $(@:_config=) spear spear
695566c9c16SVipin KUMAR
69647fd3bffSJean-Christophe PLAGNIOL-VILLARDSX1_stdout_serial_config \
6972d24a3a7SwdenkSX1_config:		unconfig
69847fd3bffSJean-Christophe PLAGNIOL-VILLARD	@mkdir -p $(obj)include
69947fd3bffSJean-Christophe PLAGNIOL-VILLARD	@if [ "$(findstring _stdout_serial_, $@)" ] ; then \
70047fd3bffSJean-Christophe PLAGNIOL-VILLARD		echo "#undef CONFIG_STDOUT_USBTTY" >> $(obj)include/config.h ; \
70147fd3bffSJean-Christophe PLAGNIOL-VILLARD	else \
70247fd3bffSJean-Christophe PLAGNIOL-VILLARD		echo "#define CONFIG_STDOUT_USBTTY" >> $(obj)include/config.h ; \
70347fd3bffSJean-Christophe PLAGNIOL-VILLARD	fi;
7040e42ada3SWolfgang Denk	@$(MKCONFIG) -n $@ SX1 arm arm925t sx1
7052d24a3a7Swdenk
706699f0512SWolfgang Denk#########################################################################
70743d9616cSwdenk## XScale Systems
7087ebf7443Swdenk#########################################################################
7097ebf7443Swdenk
7109d8d5a5bSStefan Roesepdnb3_config \
7119d8d5a5bSStefan Roesescpu_config:	unconfig
712cdd917a4SWolfgang Denk	@mkdir -p $(obj)include
7139d8d5a5bSStefan Roese	@if [ "$(findstring scpu_,$@)" ] ; then \
714cdd917a4SWolfgang Denk		echo "#define CONFIG_SCPU"	>>$(obj)include/config.h ; \
7159d8d5a5bSStefan Roese	fi
7160e42ada3SWolfgang Denk	@$(MKCONFIG) -n $@ -a pdnb3 arm ixp pdnb3 prodrive
717ba94a1bbSWolfgang Denk
7188ed96046Swdenk#########################################################################
7198ed96046Swdenk## ARM1136 Systems
7208ed96046Swdenk#########################################################################
7215ca9881aSPeter Pearse
7225ca9881aSPeter Pearseapollon_config		: unconfig
7238cbf4e4fSWolfgang Denk	@mkdir -p $(obj)include
724751b9b51SKyungmin Park	@echo "#define CONFIG_ONENAND_U_BOOT" > $(obj)include/config.h
725751b9b51SKyungmin Park	@echo "CONFIG_ONENAND_U_BOOT = y" >> $(obj)include/config.mk
726a6862bc1SWolfgang Denk	@$(MKCONFIG) $@ arm arm1136 apollon - omap24xx
7278ed96046Swdenk
72811edcfe2SGuennadi Liakhovetski#########################################################################
72911edcfe2SGuennadi Liakhovetski## ARM1176 Systems
73011edcfe2SGuennadi Liakhovetski#########################################################################
73111edcfe2SGuennadi Liakhovetskismdk6400_noUSB_config	\
73211edcfe2SGuennadi Liakhovetskismdk6400_config	:	unconfig
73311edcfe2SGuennadi Liakhovetski	@mkdir -p $(obj)include $(obj)board/samsung/smdk6400
73411edcfe2SGuennadi Liakhovetski	@mkdir -p $(obj)nand_spl/board/samsung/smdk6400
73511edcfe2SGuennadi Liakhovetski	@echo "#define CONFIG_NAND_U_BOOT" > $(obj)include/config.h
7360e42ada3SWolfgang Denk	@echo "CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk
73711edcfe2SGuennadi Liakhovetski	@if [ -z "$(findstring smdk6400_noUSB_config,$@)" ]; then			\
73811edcfe2SGuennadi Liakhovetski		echo "RAM_TEXT = 0x57e00000" >> $(obj)board/samsung/smdk6400/config.tmp;\
73911edcfe2SGuennadi Liakhovetski	else										\
74011edcfe2SGuennadi Liakhovetski		echo "RAM_TEXT = 0xc7e00000" >> $(obj)board/samsung/smdk6400/config.tmp;\
74111edcfe2SGuennadi Liakhovetski	fi
74254e19a7dSWolfgang Denk	@$(MKCONFIG) smdk6400 arm arm1176 smdk6400 samsung s3c64xx
74311edcfe2SGuennadi Liakhovetski	@echo "CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk
74411edcfe2SGuennadi Liakhovetski
7450afe519aSWolfgang Denk#########################################################################
7463e38691eSwdenk#########################################################################
7477ebf7443Swdenk
7487ebf7443Swdenkclean:
7491bc15386SPeter Tyser	@rm -f $(obj)examples/standalone/82559_eeprom			  \
750d640ac58SWolfgang Denk	       $(obj)examples/standalone/atmel_df_pow2			  \
7511bc15386SPeter Tyser	       $(obj)examples/standalone/eepro100_eeprom		  \
7521bc15386SPeter Tyser	       $(obj)examples/standalone/hello_world			  \
7531bc15386SPeter Tyser	       $(obj)examples/standalone/interrupt			  \
7541bc15386SPeter Tyser	       $(obj)examples/standalone/mem_to_mem_idma2intr		  \
7551bc15386SPeter Tyser	       $(obj)examples/standalone/sched				  \
756201a017cSMike Frysinger	       $(obj)examples/standalone/smc911{11,x}_eeprom		  \
7571bc15386SPeter Tyser	       $(obj)examples/standalone/test_burst			  \
7581bc15386SPeter Tyser	       $(obj)examples/standalone/timer
759d4abc757SPeter Tyser	@rm -f $(obj)examples/api/demo{,.bin}
760f9301e1cSWolfgang Denk	@rm -f $(obj)tools/bmp_logo	   $(obj)tools/easylogo/easylogo  \
761f9301e1cSWolfgang Denk	       $(obj)tools/env/{fw_printenv,fw_setenv}			  \
762f9301e1cSWolfgang Denk	       $(obj)tools/envcrc					  \
763f9301e1cSWolfgang Denk	       $(obj)tools/gdb/{astest,gdbcont,gdbsend}			  \
764f9301e1cSWolfgang Denk	       $(obj)tools/gen_eth_addr    $(obj)tools/img2srec		  \
7657717fe10SHorst Kronstorfer	       $(obj)tools/mk{env,}image   $(obj)tools/mpc86x_clk	  \
766f9301e1cSWolfgang Denk	       $(obj)tools/ncb		   $(obj)tools/ubsha1
767f9301e1cSWolfgang Denk	@rm -f $(obj)board/cray/L1/{bootscript.c,bootscript.image}	  \
76874c7a95fSWolfgang Denk	       $(obj)board/matrix_vision/*/bootscript.img		  \
769566e5cf4SWolfgang Denk	       $(obj)board/voiceblue/eeprom 				  \
7701aada9cdSWolfgang Denk	       $(obj)u-boot.lds						  \
771fb5166ceSMike Frysinger	       $(obj)arch/blackfin/cpu/bootrom-asm-offsets.[chs]	  \
772fb5166ceSMike Frysinger	       $(obj)arch/blackfin/cpu/init.{lds,elf}
773dc7746d8SWolfgang Denk	@rm -f $(obj)include/bmp_logo.h
774c270730fSChe-Liang Chiou	@rm -f $(obj)include/bmp_logo_data.h
77516a354f9SWolfgang Denk	@rm -f $(obj)lib/asm-offsets.s
776a4814a69SStefano Babic	@rm -f $(obj)include/generated/asm-offsets.h
777a4814a69SStefano Babic	@rm -f $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s
778ff6b47adSKumar Gala	@rm -f $(obj)nand_spl/{u-boot.lds,u-boot-nand_spl.lds,u-boot-spl,u-boot-spl.map,System.map}
779ca6189dbSKyungmin Park	@rm -f $(obj)onenand_ipl/onenand-{ipl,ipl.bin,ipl.map}
7800d3c62e4SChander Kashyap	@rm -f $(obj)mmc_spl/{u-boot.lds,u-boot-spl,u-boot-spl.map,u-boot-spl.bin,u-boot-mmc-spl.bin}
781ca6189dbSKyungmin Park	@rm -f $(ONENAND_BIN)
7821aada9cdSWolfgang Denk	@rm -f $(obj)onenand_ipl/u-boot.lds
7835df2ee27SDaniel Schwierzeck	@rm -f $(obj)spl/{u-boot-spl,u-boot-spl.bin,u-boot-spl.lds,u-boot-spl.map}
7844e4b21bdSJoel A Fernandes	@rm -f $(obj)MLO
785d4abc757SPeter Tyser	@rm -f $(TIMESTAMP_FILE) $(VERSION_FILE)
786ae6d1056SWolfgang Denk	@find $(OBJTREE) -type f \
7877ebf7443Swdenk		\( -name 'core' -o -name '*.bak' -o -name '*~' \
7882b48f7d5SPeter Tyser		-o -name '*.o'	-o -name '*.a' -o -name '*.exe'	\) -print \
7897ebf7443Swdenk		| xargs rm -f
7907ebf7443Swdenk
791734329f9SAndy Fleming# Removes everything not needed for testing u-boot
792734329f9SAndy Flemingtidy:	clean
793734329f9SAndy Fleming	@find $(OBJTREE) -type f \( -name '*.depend*' \) -print | xargs rm -f
794734329f9SAndy Fleming
795734329f9SAndy Flemingclobber:	tidy
796734329f9SAndy Fleming	@find $(OBJTREE) -type f \( -name '*.srec' \
797734329f9SAndy Fleming		-o -name '*.bin' -o -name u-boot.img \) \
798734329f9SAndy Fleming		-print0 | xargs -0 rm -f
799ffda586fSLi Yang	@rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \
8005013c09fSWolfgang Denk		$(obj)cscope.* $(obj)*.*~
8014e0fbb98SDaniel Schwierzeck	@rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL-y)
802aa0c7a86SPrafulla Wadaskar	@rm -f $(obj)u-boot.kwb
803c5fb70c9SStefano Babic	@rm -f $(obj)u-boot.imx
8047816f2cfSHeiko Schocher	@rm -f $(obj)u-boot.ubl
805bbb0b128SSimon Glass	@rm -f $(obj)u-boot.dtb
80630b9b932SMarek Vasut	@rm -f $(obj)u-boot.sb
807dca61f01SAndreas Bießmann	@rm -f $(obj)tools/inca-swap-bytes
808a47a12beSStefan Roese	@rm -f $(obj)arch/powerpc/cpu/mpc824x/bedbug_603e.c
8092d14e36aSYork Sun	@rm -f $(obj)arch/powerpc/cpu/mpc83xx/ddr-gen?.c
810a9d8bc98SLoïc Minier	@rm -fr $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
81116a354f9SWolfgang Denk	@rm -fr $(obj)include/generated
812a958b663SJean-Christophe PLAGNIOL-VILLARD	@[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f
813a958b663SJean-Christophe PLAGNIOL-VILLARD	@[ ! -d $(obj)onenand_ipl ] || find $(obj)onenand_ipl -name "*" -type l -print | xargs rm -f
8140d3c62e4SChander Kashyap	@[ ! -d $(obj)mmc_spl ] || find $(obj)mmc_spl -name "*" -type l -print | xargs rm -f
815bbb0b128SSimon Glass	@rm -f $(obj)dts/*.tmp
8167ebf7443Swdenk
8177ebf7443Swdenkmrproper \
8187ebf7443Swdenkdistclean:	clobber unconfig
819afd077bdSMike Frysingerifneq ($(OBJTREE),$(SRCTREE))
820ae6d1056SWolfgang Denk	rm -rf $(obj)*
821f9328639SMarian Balakowiczendif
8227ebf7443Swdenk
8237ebf7443Swdenkbackup:
8247ebf7443Swdenk	F=`basename $(TOPDIR)` ; cd .. ; \
825d6b93714SIlya Yanok	gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
8267ebf7443Swdenk
8277ebf7443Swdenk#########################################################################
828