blob: ac7dccd07fb360ecf0a5ead4e738aa82b5230d80 [file] [log] [blame]
wdenk7ebf7442002-11-02 23:17:16 +00001#
Wolfgang Denk1234ce72013-06-21 10:22:36 +02002# (C) Copyright 2000-2013
wdenk7ebf7442002-11-02 23:17:16 +00003# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4#
Wolfgang Denk1234ce72013-06-21 10:22:36 +02005# SPDX-License-Identifier: GPL-2.0+
wdenk7ebf7442002-11-02 23:17:16 +00006#
7
Tom Rini9e4cfc42013-11-25 16:49:32 -05008VERSION = 2014
9PATCHLEVEL = 01
Wolfgang Denkec1ab282012-07-10 09:21:12 +020010SUBLEVEL =
Tom Rini65ffdc52014-01-20 17:52:59 -050011EXTRAVERSION =
Masahiro Yamada27d027f2014-02-04 17:24:30 +090012NAME =
Wolfgang Denk0a659ad2008-01-13 00:59:21 +010013
Masahiro Yamada0d68fb12014-02-04 17:24:28 +090014# *DOCUMENTATION*
15# To see a list of typical targets execute "make help"
16# More info can be located in ./README
17# Comments in this file are targeted only to the developer, do not
18# expect to learn how to build the kernel reading this file.
19
20# Do not:
21# o use make's built-in rules and variables
22# (this increases performance and avoids hard-to-debug behaviour);
23# o print "Entering directory ...";
24MAKEFLAGS += -rR --no-print-directory
25
26# Avoid funny character set dependencies
27unexport LC_ALL
28LC_COLLATE=C
29LC_NUMERIC=C
30export LC_COLLATE LC_NUMERIC
31
32# We are using a recursive build, so we need to do a little thinking
33# to get the ordering right.
34#
35# Most importantly: sub-Makefiles should only ever modify files in
36# their own directory. If in some directory we have a dependency on
37# a file in another dir (which doesn't happen often, but it's often
38# unavoidable when linking the built-in.o targets which finally
39# turn into vmlinux), we will call a sub make in that other dir, and
40# after that we are sure that everything which is in that other dir
41# is now up to date.
42#
43# The only cases where we need to modify files which have global
44# effects are thus separated out and done before the recursive
45# descending is started. They are now explicitly listed as the
46# prepare rule.
47
48# To put more focus on warnings, be less verbose as default
49# Use 'make V=1' to see the full commands
50
51ifeq ("$(origin V)", "command line")
52 KBUILD_VERBOSE = $(V)
53endif
54ifndef KBUILD_VERBOSE
55 KBUILD_VERBOSE = 0
56endif
57
58# Call a source code checker (by default, "sparse") as part of the
59# C compilation.
60#
61# Use 'make C=1' to enable checking of only re-compiled files.
62# Use 'make C=2' to enable checking of *all* source files, regardless
63# of whether they are re-compiled or not.
64#
65# See the file "Documentation/sparse.txt" for more details, including
66# where to get the "sparse" utility.
67
68ifeq ("$(origin C)", "command line")
69 KBUILD_CHECKSRC = $(C)
70endif
71ifndef KBUILD_CHECKSRC
72 KBUILD_CHECKSRC = 0
73endif
74
75# Use make M=dir to specify directory of external module to build
76# Old syntax make ... SUBDIRS=$PWD is still supported
77# Setting the environment variable KBUILD_EXTMOD take precedence
78ifdef SUBDIRS
79 KBUILD_EXTMOD ?= $(SUBDIRS)
80endif
81
82ifeq ("$(origin M)", "command line")
83 KBUILD_EXTMOD := $(M)
84endif
85
Masahiro Yamada59f15f22014-02-04 17:24:24 +090086# kbuild supports saving output files in a separate directory.
87# To locate output files in a separate directory two syntaxes are supported.
88# In both cases the working directory must be the root of the kernel src.
89# 1) O=
90# Use "make O=dir/to/store/output/files/"
Stefan Roese42fbddd2006-09-07 11:51:23 +020091#
Masahiro Yamada59f15f22014-02-04 17:24:24 +090092# 2) Set KBUILD_OUTPUT
93# Set the environment variable KBUILD_OUTPUT to point to the directory
94# where the output files shall be placed.
95# export KBUILD_OUTPUT=dir/to/store/output/files/
96# make
Stefan Roese42fbddd2006-09-07 11:51:23 +020097#
Masahiro Yamada59f15f22014-02-04 17:24:24 +090098# The O= assignment takes precedence over the KBUILD_OUTPUT environment
99# variable.
100
wdenk7ebf7442002-11-02 23:17:16 +0000101
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900102# KBUILD_SRC is set on invocation of make in OBJ directory
103# KBUILD_SRC is not intended to be used by the regular user (for now)
104ifeq ($(KBUILD_SRC),)
105
106# OK, Make called in directory where kernel src resides
107# Do we want to locate output files in a separate directory?
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200108ifeq ("$(origin O)", "command line")
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900109 KBUILD_OUTPUT := $(O)
110endif
111
112ifeq ("$(origin W)", "command line")
113 export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200114endif
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200115
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900116# That's our default target when none is given on the command line
117PHONY := _all
118_all:
119
120# Cancel implicit rules on top Makefile
121$(CURDIR)/Makefile Makefile: ;
122
123ifneq ($(KBUILD_OUTPUT),)
124# Invoke a second make in the output directory, passing relevant variables
125# check that the output directory actually exists
126saved-output := $(KBUILD_OUTPUT)
127KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
128$(if $(KBUILD_OUTPUT),, \
129 $(error output directory "$(saved-output)" does not exist))
130
131PHONY += $(MAKECMDGOALS) sub-make
132
133$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
134 @:
135
136sub-make: FORCE
137 $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
138 KBUILD_SRC=$(CURDIR) \
139 KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \
140 $(filter-out _all sub-make,$(MAKECMDGOALS))
141
142# Leave processing to above invocation of make
143skip-makefile := 1
144endif # ifneq ($(KBUILD_OUTPUT),)
145endif # ifeq ($(KBUILD_SRC),)
146
147# We process the rest of the Makefile if this is the final invocation of make
148ifeq ($(skip-makefile),)
149
Masahiro Yamada0d68fb12014-02-04 17:24:28 +0900150# If building an external module we do not care about the all: rule
151# but instead _all depend on modules
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900152PHONY += all
Masahiro Yamada0d68fb12014-02-04 17:24:28 +0900153ifeq ($(KBUILD_EXTMOD),)
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900154_all: all
Masahiro Yamada0d68fb12014-02-04 17:24:28 +0900155else
156_all: modules
157endif
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900158
159srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
160objtree := $(CURDIR)
161src := $(srctree)
162obj := $(objtree)
163
164VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
165
166export srctree objtree VPATH
167
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900168OBJTREE := $(objtree)
Daniel Schwierzecka180922a2011-07-18 06:09:15 +0000169SPLTREE := $(OBJTREE)/spl
Ying Zhang2d2e3b62013-08-16 15:16:15 +0800170TPLTREE := $(OBJTREE)/tpl
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900171SRCTREE := $(srctree)
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200172TOPDIR := $(SRCTREE)
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900173export TOPDIR SRCTREE OBJTREE SPLTREE TPLTREE
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200174
175MKCONFIG := $(SRCTREE)/mkconfig
176export MKCONFIG
177
Wolfgang Denk6570eb32008-03-02 22:45:33 +0100178# Make sure CDPATH settings don't interfere
179unexport CDPATH
180
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200181#########################################################################
wdenk7ebf7442002-11-02 23:17:16 +0000182
Masahiro Yamada27d027f2014-02-04 17:24:30 +0900183TIMESTAMP_FILE = include/generated/timestamp_autogenerated.h
184VERSION_FILE = include/generated/version_autogenerated.h
185
186HOSTARCH := $(shell uname -m | \
187 sed -e s/i.86/x86/ \
188 -e s/sun4u/sparc64/ \
189 -e s/arm.*/arm/ \
190 -e s/sa110/arm/ \
191 -e s/ppc64/powerpc/ \
192 -e s/ppc/powerpc/ \
193 -e s/macppc/powerpc/\
194 -e s/sh.*/sh/)
195
196HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
197 sed -e 's/\(cygwin\).*/cygwin/')
198
199export HOSTARCH HOSTOS
200
201# Deal with colliding definitions from tcsh etc.
202VENDOR=
203
204#########################################################################
Masahiro Yamada27d027f2014-02-04 17:24:30 +0900205
Mike Frysingerd8f0f912009-05-30 01:02:03 -0400206# The "tools" are needed early, so put this first
207# Don't include stuff already done in $(LIBS)
Che-liang Chioud74a67f2011-10-17 21:04:15 +0000208# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
209# is "yes"), so compile examples after U-Boot is compiled.
210SUBDIR_TOOLS = tools
Che-liang Chioud74a67f2011-10-17 21:04:15 +0000211SUBDIRS = $(SUBDIR_TOOLS)
Mike Frysingerd8f0f912009-05-30 01:02:03 -0400212
Loïc Minier4fd86112011-10-03 11:57:10 +0200213.PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE)
Mike Frysingerd8f0f912009-05-30 01:02:03 -0400214
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900215ifeq (include/config.mk,$(wildcard include/config.mk))
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200216
Mike Frysinger27e1c722009-07-21 22:59:36 -0400217# Include autoconf.mk before config.mk so that the config options are available
218# to all top level build files. We need the dummy all: target to prevent the
219# dependency target in autoconf.mk.dep from being the default.
220all:
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900221sinclude include/autoconf.mk.dep
222sinclude include/autoconf.mk
Mike Frysinger27e1c722009-07-21 22:59:36 -0400223
Masahiro Yamada6c9a0222013-11-18 11:08:35 +0900224SUBDIR_EXAMPLES-y := examples/standalone
225SUBDIR_EXAMPLES-$(CONFIG_API) += examples/api
Simon Glass2a973792011-10-25 11:29:28 +0000226ifndef CONFIG_SANDBOX
Masahiro Yamada6c9a0222013-11-18 11:08:35 +0900227SUBDIRS += $(SUBDIR_EXAMPLES-y)
Simon Glass2a973792011-10-25 11:29:28 +0000228endif
229
wdenk7ebf7442002-11-02 23:17:16 +0000230# load ARCH, BOARD, and CPU configuration
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900231include include/config.mk
wdenkf8e9a232004-10-09 22:21:29 +0000232export ARCH CPU BOARD VENDOR SOC
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200233
Mike Frysinger8378ba42009-06-14 23:33:14 -0400234# set default to nothing for native builds
Wolfgang Denkab4f2fe2007-03-06 18:01:47 +0100235ifeq ($(HOSTARCH),$(ARCH))
Mike Frysinger8378ba42009-06-14 23:33:14 -0400236CROSS_COMPILE ?=
Daniel Hellstrom9d7c6b22008-03-28 09:47:00 +0100237endif
wdenk7ebf7442002-11-02 23:17:16 +0000238
Masahiro Yamada57d42c92014-02-04 17:24:15 +0900239# SHELL used by kbuild
240CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
241 else if [ -x /bin/bash ]; then echo /bin/bash; \
242 else echo sh; fi ; fi)
243
244HOSTCC = gcc
245HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
246
247ifeq ($(HOSTOS),cygwin)
248HOSTCFLAGS += -ansi
249endif
250
251# Mac OS X / Darwin's C preprocessor is Apple specific. It
252# generates numerous errors and warnings. We want to bypass it
253# and use GNU C's cpp. To do this we pass the -traditional-cpp
254# option to the compiler. Note that the -traditional-cpp flag
255# DOES NOT have the same semantics as GNU C's flag, all it does
256# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
257#
258# Apple's linker is similar, thanks to the new 2 stage linking
259# multiple symbol definitions are treated as errors, hence the
260# -multiply_defined suppress option to turn off this error.
261#
262ifeq ($(HOSTOS),darwin)
263# get major and minor product version (e.g. '10' and '6' for Snow Leopard)
264DARWIN_MAJOR_VERSION = $(shell sw_vers -productVersion | cut -f 1 -d '.')
265DARWIN_MINOR_VERSION = $(shell sw_vers -productVersion | cut -f 2 -d '.')
266
267os_x_before = $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \
268 $(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;)
269
270# Snow Leopards build environment has no longer restrictions as described above
271HOSTCC = $(call os_x_before, 10, 5, "cc", "gcc")
272HOSTCFLAGS += $(call os_x_before, 10, 4, "-traditional-cpp")
273HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress")
274endif
275
Masahiro Yamada0d68fb12014-02-04 17:24:28 +0900276# Decide whether to build built-in, modular, or both.
277# Normally, just do built-in.
278
279KBUILD_MODULES :=
280KBUILD_BUILTIN := 1
281
282# If we have only "make modules", don't compile built-in objects.
283# When we're building modules with modversions, we need to consider
284# the built-in objects during the descend as well, in order to
285# make sure the checksums are up to date before we record them.
286
287ifeq ($(MAKECMDGOALS),modules)
288 KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
289endif
290
291# If we have "make <whatever> modules", compile modules
292# in addition to whatever we do anyway.
293# Just "make" or "make all" shall build modules as well
294
295# U-Boot does not need modules
296#ifneq ($(filter all _all modules,$(MAKECMDGOALS)),)
297# KBUILD_MODULES := 1
298#endif
299
300#ifeq ($(MAKECMDGOALS),)
301# KBUILD_MODULES := 1
302#endif
303
304export KBUILD_MODULES KBUILD_BUILTIN
305export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD
306
307# Beautify output
308# ---------------------------------------------------------------------------
309#
310# Normally, we echo the whole command before executing it. By making
311# that echo $($(quiet)$(cmd)), we now have the possibility to set
312# $(quiet) to choose other forms of output instead, e.g.
313#
314# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
315# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
316#
317# If $(quiet) is empty, the whole command will be printed.
318# If it is set to "quiet_", only the short version will be printed.
319# If it is set to "silent_", nothing will be printed at all, since
320# the variable $(silent_cmd_cc_o_c) doesn't exist.
321#
322# A simple variant is to prefix commands with $(Q) - that's useful
323# for commands that shall be hidden in non-verbose mode.
324#
325# $(Q)ln $@ :<
326#
327# If KBUILD_VERBOSE equals 0 then the above command will be hidden.
328# If KBUILD_VERBOSE equals 1 then the above command is displayed.
329
330ifeq ($(KBUILD_VERBOSE),1)
331 quiet =
332 Q =
333else
334 quiet=quiet_
335 Q = @
336endif
337
338# If the user is running make -s (silent mode), suppress echoing of
339# commands
340
341ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
342 quiet=silent_
343endif
344
345export quiet Q KBUILD_VERBOSE
346
347
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900348# Look for make include files relative to root of kernel src
349MAKEFLAGS += --include-dir=$(srctree)
350
Masahiro Yamada7449ab12014-02-04 17:24:18 +0900351# We need some generic definitions (do not try to remake the file).
352$(srctree)/scripts/Kbuild.include: ;
353include $(srctree)/scripts/Kbuild.include
354
Masahiro Yamada57d42c92014-02-04 17:24:15 +0900355# Make variables (CC, etc...)
356
357AS = $(CROSS_COMPILE)as
358# Always use GNU ld
359ifneq ($(shell $(CROSS_COMPILE)ld.bfd -v 2> /dev/null),)
360LD = $(CROSS_COMPILE)ld.bfd
361else
362LD = $(CROSS_COMPILE)ld
363endif
364CC = $(CROSS_COMPILE)gcc
365CPP = $(CC) -E
366AR = $(CROSS_COMPILE)ar
367NM = $(CROSS_COMPILE)nm
368LDR = $(CROSS_COMPILE)ldr
369STRIP = $(CROSS_COMPILE)strip
370OBJCOPY = $(CROSS_COMPILE)objcopy
371OBJDUMP = $(CROSS_COMPILE)objdump
372AWK = awk
373RANLIB = $(CROSS_COMPILE)RANLIB
374DTC = dtc
375CHECK = sparse
376
377CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
378 -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
379
Masahiro Yamada03024452014-02-04 17:24:20 +0900380# Use UBOOTINCLUDE when you must reference the include/ directory.
381# Needed to be compatible with the O= option
382UBOOTINCLUDE :=
383ifneq ($(OBJTREE),$(SRCTREE))
384UBOOTINCLUDE += -I$(OBJTREE)/include
385endif
386UBOOTINCLUDE += -I$(srctree)/include \
387 -I$(srctree)/arch/$(ARCH)/include
388
Masahiro Yamada700dd892014-02-04 17:24:19 +0900389KBUILD_CPPFLAGS := -D__KERNEL__
390
391KBUILD_CFLAGS := -Wall -Wstrict-prototypes \
392 -Wno-format-security \
393 -fno-builtin -ffreestanding
394KBUILD_AFLAGS := -D__ASSEMBLY__
395
Masahiro Yamada27d027f2014-02-04 17:24:30 +0900396U_BOOT_VERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
397
398export VERSION PATCHLEVEL SUBLEVEL U_BOOT_VERSION
Masahiro Yamada57d42c92014-02-04 17:24:15 +0900399export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC
400export CPP AR NM LDR STRIP OBJCOPY OBJDUMP
401export MAKE AWK
402export DTC CHECK CHECKFLAGS
403
Masahiro Yamada03024452014-02-04 17:24:20 +0900404export KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE
Masahiro Yamada700dd892014-02-04 17:24:19 +0900405export KBUILD_CFLAGS KBUILD_AFLAGS
406
Masahiro Yamada0d68fb12014-02-04 17:24:28 +0900407# When compiling out-of-tree modules, put MODVERDIR in the module
408# tree rather than in the kernel tree. The kernel tree might
409# even be read-only.
410export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions
411
412# Files to ignore in find ... statements
413
414RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \
415 -o -name .pc -o -name .hg -o -name .git \) -prune -o
416export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
417 --exclude CVS --exclude .pc --exclude .hg --exclude .git
418
419# ===========================================================================
420# Rules shared between *config targets and build targets
421
422# Basic helpers built in scripts/
423PHONY += scripts_basic
424scripts_basic:
425 $(Q)$(MAKE) $(build)=scripts/basic
426 $(Q)rm -f .tmp_quiet_recordmcount
427
428# To avoid any implicit rule to kick in, define an empty command.
429scripts/basic/%: scripts_basic ;
430
431
Masahiro Yamada700dd892014-02-04 17:24:19 +0900432KBUILD_CFLAGS += -Os #-fomit-frame-pointer
433
434ifdef BUILD_TAG
435KBUILD_CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"'
436endif
437
438KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
439
440KBUILD_CFLAGS += -g
441# $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
442# option to the assembler.
443KBUILD_AFLAGS += -g
444
Masahiro Yamada03024452014-02-04 17:24:20 +0900445NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
446CHECKFLAGS += $(NOSTDINC_FLAGS)
447
Masahiro Yamada700dd892014-02-04 17:24:19 +0900448# Report stack usage if supported
449KBUILD_CFLAGS += $(call cc-option,-fstack-usage)
450
451KBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral)
452
453# turn jbsr into jsr for m68k
454ifeq ($(ARCH),m68k)
455ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
456KBUILD_AFLAGS += -Wa,-gstabs,-S
457endif
458endif
459
Wolfgang Denkbb874e32006-03-12 01:37:50 +0100460# load other configuration
461include $(TOPDIR)/config.mk
462
Masahiro Yamada41ec9ba2014-02-04 17:24:21 +0900463ifneq ($(CONFIG_SYS_TEXT_BASE),)
464KBUILD_CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
465endif
466
467export CONFIG_SYS_TEXT_BASE
468
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900469LDFLAGS_u-boot += -T u-boot.lds $(LDFLAGS_FINAL)
Masahiro Yamada41ec9ba2014-02-04 17:24:21 +0900470ifneq ($(CONFIG_SYS_TEXT_BASE),)
471LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
472endif
473
Simon Glass07253bb2013-04-20 08:42:36 +0000474# Targets which don't build the source code
Masahiro Yamadad01ec132014-02-04 17:24:34 +0900475NON_BUILD_TARGETS = backup clean clobber distclean mrproper unconfig %_config
Simon Glass07253bb2013-04-20 08:42:36 +0000476
477# Only do the generic board check when actually building, not configuring
478ifeq ($(filter $(NON_BUILD_TARGETS),$(MAKECMDGOALS)),)
Masahiro Yamada41ec9ba2014-02-04 17:24:21 +0900479ifeq ($(__HAVE_ARCH_GENERIC_BOARD),)
480ifneq ($(CONFIG_SYS_GENERIC_BOARD),)
481CHECK_GENERIC_BOARD = $(error Your architecture does not support generic board. \
482Please undefined CONFIG_SYS_GENERIC_BOARD in your board config file)
483endif
Simon Glass07253bb2013-04-20 08:42:36 +0000484endif
485endif
486
Masahiro Yamada0d68fb12014-02-04 17:24:28 +0900487# FIX ME
488cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
489c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
490
Ilya Yanok4e16feb2011-06-20 12:45:37 +0000491# If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
492# that (or fail if absent). Otherwise, search for a linker script in a
493# standard location.
494
Simon Glass9b309372011-11-21 10:49:37 +0000495LDSCRIPT_MAKEFILE_DIR = $(dir $(LDSCRIPT))
496
Ilya Yanok4e16feb2011-06-20 12:45:37 +0000497ifndef LDSCRIPT
498 #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
499 ifdef CONFIG_SYS_LDSCRIPT
500 # need to strip off double quotes
Masahiro Yamada7c9c7442013-12-05 15:08:31 +0900501 LDSCRIPT := $(CONFIG_SYS_LDSCRIPT:"%"=%)
Ilya Yanok4e16feb2011-06-20 12:45:37 +0000502 endif
503endif
504
Simon Glass9b309372011-11-21 10:49:37 +0000505# If there is no specified link script, we look in a number of places for it
Ilya Yanok4e16feb2011-06-20 12:45:37 +0000506ifndef LDSCRIPT
507 ifeq ($(CONFIG_NAND_U_BOOT),y)
508 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
509 ifeq ($(wildcard $(LDSCRIPT)),)
510 LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds
511 endif
512 endif
513 ifeq ($(wildcard $(LDSCRIPT)),)
514 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
515 endif
516 ifeq ($(wildcard $(LDSCRIPT)),)
517 LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot.lds
518 endif
519 ifeq ($(wildcard $(LDSCRIPT)),)
Simon Glass9b309372011-11-21 10:49:37 +0000520 LDSCRIPT := $(TOPDIR)/arch/$(ARCH)/cpu/u-boot.lds
521 # We don't expect a Makefile here
522 LDSCRIPT_MAKEFILE_DIR =
523 endif
524 ifeq ($(wildcard $(LDSCRIPT)),)
Ilya Yanok4e16feb2011-06-20 12:45:37 +0000525$(error could not find linker script)
526 endif
527endif
528
wdenk7ebf7442002-11-02 23:17:16 +0000529#########################################################################
530# U-Boot objects....order is important (i.e. start must be first)
531
Masahiro Yamada71db7542013-11-28 12:09:59 +0900532head-y := $(CPUDIR)/start.o
533head-$(CONFIG_4xx) += arch/powerpc/cpu/ppc4xx/resetvec.o
534head-$(CONFIG_MPC85xx) += arch/powerpc/cpu/mpc85xx/resetvec.o
wdenk7ebf7442002-11-02 23:17:16 +0000535
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900536OBJS := $(head-y)
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200537
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900538HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)
Daniel Schwierzeck060b70b2012-07-19 13:39:58 +0000539
Masahiro Yamada30a198b2013-11-11 14:36:00 +0900540LIBS-y += lib/
Masahiro Yamada30a198b2013-11-11 14:36:00 +0900541LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
542LIBS-y += $(CPUDIR)/
wdenkf8e9a232004-10-09 22:21:29 +0000543ifdef SOC
Masahiro Yamada30a198b2013-11-11 14:36:00 +0900544LIBS-y += $(CPUDIR)/$(SOC)/
wdenkf8e9a232004-10-09 22:21:29 +0000545endif
Masahiro Yamada30a198b2013-11-11 14:36:00 +0900546LIBS-$(CONFIG_IXP4XX_NPE) += drivers/net/npe/
547LIBS-$(CONFIG_OF_EMBED) += dts/
548LIBS-y += arch/$(ARCH)/lib/
Masahiro Yamadaaf1274a2013-11-11 14:36:09 +0900549LIBS-y += fs/
Masahiro Yamada30a198b2013-11-11 14:36:00 +0900550LIBS-y += net/
551LIBS-y += disk/
552LIBS-y += drivers/
553LIBS-y += drivers/dma/
554LIBS-y += drivers/gpio/
555LIBS-y += drivers/i2c/
556LIBS-y += drivers/input/
557LIBS-y += drivers/mmc/
558LIBS-y += drivers/mtd/
Masahiro Yamada136cfe32013-11-28 12:22:17 +0900559LIBS-$(CONFIG_CMD_NAND) += drivers/mtd/nand/
Masahiro Yamada30a198b2013-11-11 14:36:00 +0900560LIBS-y += drivers/mtd/onenand/
Masahiro Yamada136cfe32013-11-28 12:22:17 +0900561LIBS-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/
Masahiro Yamada30a198b2013-11-11 14:36:00 +0900562LIBS-y += drivers/mtd/spi/
563LIBS-y += drivers/net/
564LIBS-y += drivers/net/phy/
565LIBS-y += drivers/pci/
566LIBS-y += drivers/power/ \
567 drivers/power/fuel_gauge/ \
568 drivers/power/mfd/ \
569 drivers/power/pmic/ \
570 drivers/power/battery/
571LIBS-y += drivers/spi/
572LIBS-$(CONFIG_FMAN_ENET) += drivers/net/fm/
York Sunf0626592013-09-30 09:22:09 -0700573LIBS-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/
Masahiro Yamada30a198b2013-11-11 14:36:00 +0900574LIBS-y += drivers/serial/
575LIBS-y += drivers/usb/eth/
576LIBS-y += drivers/usb/gadget/
577LIBS-y += drivers/usb/host/
578LIBS-y += drivers/usb/musb/
579LIBS-y += drivers/usb/musb-new/
580LIBS-y += drivers/usb/phy/
581LIBS-y += drivers/usb/ulpi/
582LIBS-y += common/
583LIBS-y += lib/libfdt/
Masahiro Yamada6c9a0222013-11-18 11:08:35 +0900584LIBS-$(CONFIG_API) += api/
Masahiro Yamada2a24c332013-11-28 12:09:58 +0900585LIBS-$(CONFIG_HAS_POST) += post/
Masahiro Yamada30a198b2013-11-11 14:36:00 +0900586LIBS-y += test/
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200587
Alison Wang035260a2013-05-27 22:55:42 +0000588ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610))
Masahiro Yamada30a198b2013-11-11 14:36:00 +0900589LIBS-y += arch/$(ARCH)/imx-common/
Jason Liu83aa8fe2011-11-25 00:18:01 +0000590endif
591
Masahiro Yamada30a198b2013-11-11 14:36:00 +0900592LIBS-$(CONFIG_ARM) += arch/arm/cpu/
593LIBS-$(CONFIG_PPC) += arch/powerpc/cpu/
Minkyu Kang0a2b6312010-08-19 13:48:11 +0900594
Masahiro Yamada30a198b2013-11-11 14:36:00 +0900595LIBS-y += board/$(BOARDDIR)/
Masahiro Yamada9dc93562013-11-11 14:35:55 +0900596
Masahiro Yamada30a198b2013-11-11 14:36:00 +0900597LIBS-y := $(patsubst %/, %/built-in.o, $(LIBS-y))
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900598LIBS := $(sort $(LIBS-y))
Loïc Minier4fd86112011-10-03 11:57:10 +0200599.PHONY : $(LIBS)
wdenkc0aa5c52003-12-06 19:49:23 +0000600
wdenk4cc02a82003-09-11 23:06:34 +0000601# Add GCC lib
Wolfgang Denkc73f44d2009-07-23 13:15:59 +0200602ifdef USE_PRIVATE_LIBGCC
603ifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
Masahiro Yamada0d68fb12014-02-04 17:24:28 +0900604PLATFORM_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/lib.a
Wolfgang Denkc73f44d2009-07-23 13:15:59 +0200605else
606PLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc
607endif
608else
Masahiro Yamada0d68fb12014-02-04 17:24:28 +0900609PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`) -lgcc
Wolfgang Denkc73f44d2009-07-23 13:15:59 +0200610endif
611PLATFORM_LIBS += $(PLATFORM_LIBGCC)
612export PLATFORM_LIBS
wdenk4989f872004-03-14 15:06:13 +0000613
Mike Frysinger91acc212009-08-23 02:47:59 -0400614# Special flags for CPP when processing the linker script.
615# Pass the version down so we can handle backwards compatibility
616# on the fly.
617LDPPFLAGS += \
618 -include $(TOPDIR)/include/u-boot/u-boot.lds.h \
Simon Glass7b0fb5f2011-11-21 10:49:40 +0000619 -DCPUDIR=$(CPUDIR) \
Mike Frysinger91acc212009-08-23 02:47:59 -0400620 $(shell $(LD) --version | \
621 sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
622
wdenk7ebf7442002-11-02 23:17:16 +0000623#########################################################################
wdenk0a658552003-08-05 17:43:17 +0000624#########################################################################
wdenk7ebf7442002-11-02 23:17:16 +0000625
Mike Frysinger4a7f5432010-10-13 22:58:23 -0400626ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
627BOARD_SIZE_CHECK = \
628 @actual=`wc -c $@ | awk '{print $$1}'`; \
Joe Hershbergerb102e202012-11-08 10:19:09 +0000629 limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
Mike Frysinger4a7f5432010-10-13 22:58:23 -0400630 if test $$actual -gt $$limit; then \
Joe Hershbergerb102e202012-11-08 10:19:09 +0000631 echo "$@ exceeds file size limit:" >&2 ; \
632 echo " limit: $$limit bytes" >&2 ; \
633 echo " actual: $$actual bytes" >&2 ; \
634 echo " excess: $$((actual - limit)) bytes" >&2; \
Mike Frysinger4a7f5432010-10-13 22:58:23 -0400635 exit 1; \
636 fi
637else
638BOARD_SIZE_CHECK =
639endif
640
Scott Wood49fa0592013-12-14 11:47:32 +0800641# Statically apply RELA-style relocations (currently arm64 only)
642ifneq ($(CONFIG_STATIC_RELA),)
643# $(1) is u-boot ELF, $(2) is u-boot bin, $(3) is text base
644DO_STATIC_RELA = \
645 start=$$($(NM) $(1) | grep __rel_dyn_start | cut -f 1 -d ' '); \
646 end=$$($(NM) $(1) | grep __rel_dyn_end | cut -f 1 -d ' '); \
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900647 tools/relocate-rela $(2) $(3) $$start $$end
Scott Wood49fa0592013-12-14 11:47:32 +0800648else
649DO_STATIC_RELA =
650endif
651
Mike Frysinger57047e02009-06-15 00:25:19 -0400652# Always append ALL so that arch config.mk's can add custom ones
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900653ALL-y += u-boot.srec u-boot.bin System.map
Haiying Wang8ad16cf2011-01-27 09:44:59 -0500654
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900655ALL-$(CONFIG_NAND_U_BOOT) += u-boot-nand.bin
656ALL-$(CONFIG_ONENAND_U_BOOT) += u-boot-onenand.bin
657ALL-$(CONFIG_RAMBOOT_PBL) += u-boot.pbl
658ALL-$(CONFIG_SPL) += spl/u-boot-spl.bin
659ALL-$(CONFIG_SPL_FRAMEWORK) += u-boot.img
660ALL-$(CONFIG_TPL) += tpl/u-boot-tpl.bin
661ALL-$(CONFIG_OF_SEPARATE) += u-boot.dtb u-boot-dtb.bin
Vadim Bendeburyf87a74a2013-03-27 14:34:18 +0000662ifneq ($(CONFIG_SPL_TARGET),)
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900663ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%)
Vadim Bendeburyf87a74a2013-03-27 14:34:18 +0000664endif
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900665ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf
wdenk7ebf7442002-11-02 23:17:16 +0000666
Allen Martinc9c98462012-08-31 08:30:12 +0000667# enable combined SPL/u-boot/dtb rules for tegra
Tom Warrend32b2a42012-12-11 13:34:17 +0000668ifneq ($(CONFIG_TEGRA),)
Vidya Sagar5ff24f22013-10-31 14:51:38 +0530669ifeq ($(CONFIG_SPL),y)
Allen Martinc9c98462012-08-31 08:30:12 +0000670ifeq ($(CONFIG_OF_SEPARATE),y)
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900671ALL-y += u-boot-dtb-tegra.bin
Allen Martinc9c98462012-08-31 08:30:12 +0000672else
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900673ALL-y += u-boot-nodtb-tegra.bin
Allen Martinc9c98462012-08-31 08:30:12 +0000674endif
675endif
Vidya Sagar5ff24f22013-10-31 14:51:38 +0530676endif
Allen Martinc9c98462012-08-31 08:30:12 +0000677
Masahiro Yamada6c9a0222013-11-18 11:08:35 +0900678all: $(ALL-y) $(SUBDIR_EXAMPLES-y)
wdenk7ebf7442002-11-02 23:17:16 +0000679
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900680u-boot.dtb: checkdtc u-boot
681 $(MAKE) $(build)=dts binary
682 mv dts/dt.dtb $@
Simon Glass5cb34db2011-10-24 19:15:31 +0000683
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900684u-boot-dtb.bin: u-boot.bin u-boot.dtb
Simon Glass5cb34db2011-10-24 19:15:31 +0000685 cat $^ >$@
686
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900687u-boot.hex: u-boot
wdenk68005192005-01-09 21:28:15 +0000688 $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
689
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900690u-boot.srec: u-boot
Albert ARIBAUD95fc6d62013-11-07 14:21:46 +0100691 $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@
wdenk7ebf7442002-11-02 23:17:16 +0000692
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900693u-boot.bin: u-boot
wdenk7ebf7442002-11-02 23:17:16 +0000694 $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
Scott Wood49fa0592013-12-14 11:47:32 +0800695 $(call DO_STATIC_RELA,$<,$@,$(CONFIG_SYS_TEXT_BASE))
Mike Frysinger4a7f5432010-10-13 22:58:23 -0400696 $(BOARD_SIZE_CHECK)
wdenk7ebf7442002-11-02 23:17:16 +0000697
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900698u-boot.ldr: u-boot
Mike Frysinger45b57bd2009-07-21 22:17:36 -0400699 $(CREATE_LDR_ENV)
Mike Frysinger41117ca2008-08-07 18:56:56 -0400700 $(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS)
Mike Frysinger4a7f5432010-10-13 22:58:23 -0400701 $(BOARD_SIZE_CHECK)
Mike Frysinger908e7762008-02-04 19:26:57 -0500702
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900703u-boot.ldr.hex: u-boot.ldr
Mike Frysinger908e7762008-02-04 19:26:57 -0500704 $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ -I binary
705
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900706u-boot.ldr.srec: u-boot.ldr
Mike Frysinger908e7762008-02-04 19:26:57 -0500707 $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ -I binary
708
Stefan Roesef7f05a92012-08-16 17:54:52 +0200709#
710# U-Boot entry point, needed for booting of full-blown U-Boot
711# from the SPL U-Boot version.
712#
713ifndef CONFIG_SYS_UBOOT_START
714CONFIG_SYS_UBOOT_START := 0
715endif
716
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900717u-boot.img: u-boot.bin
718 tools/mkimage -A $(ARCH) -T firmware -C none \
Stefan Roesef7f05a92012-08-16 17:54:52 +0200719 -O u-boot -a $(CONFIG_SYS_TEXT_BASE) \
720 -e $(CONFIG_SYS_UBOOT_START) \
Wolfgang Denk4d1d9a32006-02-21 17:33:04 +0100721 -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
wdenk0a658552003-08-05 17:43:17 +0000722 sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \
723 -d $< $@
724
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900725u-boot.imx: u-boot.bin depend
726 $(MAKE) $(build)=arch/arm/imx-common $(objtree)/u-boot.imx
Stefano Babic7b07f092010-01-20 18:19:10 +0100727
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900728u-boot.kwb: u-boot.bin
729 tools/mkimage -n $(CONFIG_SYS_KWD_CONFIG) -T kwbimage \
Eric Cooper28f39602010-10-19 13:31:11 -0400730 -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) -d $< $@
Prafulla Wadaskar07329412009-09-07 15:05:02 +0530731
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900732u-boot.pbl: u-boot.bin
733 tools/mkimage -n $(CONFIG_SYS_FSL_PBL_RCW) \
Prabhakar Kushwaha950f2f72014-01-13 11:28:04 +0530734 -R $(CONFIG_SYS_FSL_PBL_PBI) -T pblimage \
Shaohui Xieea65fd82012-08-10 02:49:35 +0000735 -d $< $@
736
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900737u-boot.sha1: u-boot.bin
738 tools/ubsha1 u-boot.bin
Heiko Schocher633e03a2007-06-22 19:11:54 +0200739
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900740u-boot.dis: u-boot
wdenk7ebf7442002-11-02 23:17:16 +0000741 $(OBJDUMP) -d $< > $@
742
Ying Zhang2d2e3b62013-08-16 15:16:15 +0800743# $@ is output, $(1) and $(2) are inputs, $(3) is padded intermediate,
744# $(4) is pad-to
745SPL_PAD_APPEND = \
746 $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(4) -I binary -O binary \
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900747 $(1) $(3); \
748 cat $(3) $(2) > $@; \
749 rm $(3)
Scott Woodeb7bd972012-12-06 13:33:16 +0000750
Ying Zhang2d2e3b62013-08-16 15:16:15 +0800751ifdef CONFIG_TPL
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900752SPL_PAYLOAD := tpl/u-boot-with-tpl.bin
Ying Zhang2d2e3b62013-08-16 15:16:15 +0800753else
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900754SPL_PAYLOAD := u-boot.bin
Ying Zhang2d2e3b62013-08-16 15:16:15 +0800755endif
Scott Woodeb7bd972012-12-06 13:33:16 +0000756
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900757u-boot-with-spl.bin: spl/u-boot-spl.bin $(SPL_PAYLOAD)
Ying Zhang2d2e3b62013-08-16 15:16:15 +0800758 $(call SPL_PAD_APPEND,$<,$(SPL_PAYLOAD),spl/u-boot-spl-pad.bin,$(CONFIG_SPL_PAD_TO))
759
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900760tpl/u-boot-with-tpl.bin: tpl/u-boot-tpl.bin u-boot.bin
761 $(call SPL_PAD_APPEND,$<,u-boot.bin,tpl/u-boot-tpl-pad.bin,$(CONFIG_TPL_PAD_TO))
Heiko Schocher58cb84d2011-07-16 00:06:42 +0000762
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900763u-boot-with-spl.imx: spl/u-boot-spl.bin u-boot.bin
764 $(MAKE) $(build)=arch/arm/imx-common \
Benoît Thébaudeaub2c79202013-04-11 09:35:56 +0000765 $(OBJTREE)/u-boot-with-spl.imx
766
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900767u-boot-with-nand-spl.imx: spl/u-boot-spl.bin u-boot.bin
768 $(MAKE) $(build)=arch/arm/imx-common \
Benoît Thébaudeau393b98d2013-04-11 09:35:57 +0000769 $(OBJTREE)/u-boot-with-nand-spl.imx
770
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900771u-boot.ubl: u-boot-with-spl.bin
772 tools/mkimage -n $(UBL_CONFIG) -T ublimage \
773 -e $(CONFIG_SYS_TEXT_BASE) -d $< u-boot.ubl
José Miguel Gonçalves479e6602012-09-19 01:25:26 +0000774
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900775u-boot.ais: spl/u-boot-spl.bin u-boot.img
776 tools/mkimage -s -n $(if $(CONFIG_AIS_CONFIG_FILE),$(srctree)/$(CONFIG_AIS_CONFIG_FILE:"%"=%),"/dev/null") \
Sughosh Ganuf806bbf2012-06-13 08:39:06 +0000777 -T aisimage \
Christian Rieschbd25f062011-12-09 09:47:39 +0000778 -e $(CONFIG_SPL_TEXT_BASE) \
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900779 -d spl/u-boot-spl.bin \
780 spl/u-boot-spl.ais
Christian Rieschbd25f062011-12-09 09:47:39 +0000781 $(OBJCOPY) ${OBJCFLAGS} -I binary \
782 --pad-to=$(CONFIG_SPL_MAX_SIZE) -O binary \
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900783 spl/u-boot-spl.ais spl/u-boot-spl-pad.ais
784 cat spl/u-boot-spl-pad.ais u-boot.img > u-boot.ais
Christian Rieschbd25f062011-12-09 09:47:39 +0000785
Otavio Salvador17811002012-08-18 07:25:25 +0000786
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900787u-boot.sb: u-boot.bin spl/u-boot-spl.bin
788 $(MAKE) $(build)=$(CPUDIR)/$(SOC)/ $(OBJTREE)/u-boot.sb
Marek Vasutb0d62962011-11-08 23:18:19 +0000789
Stefan Roese0ba64c32012-01-05 11:19:50 +0100790# On x600 (SPEAr600) U-Boot is appended to U-Boot SPL.
791# Both images are created using mkimage (crc etc), so that the ROM
792# bootloader can check its integrity. Padding needs to be done to the
793# SPL image (with mkimage header) and not the binary. Otherwise the resulting image
794# which is loaded/copied by the ROM bootloader to SRAM doesn't fit.
795# The resulting image containing both U-Boot images is called u-boot.spr
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900796u-boot.spr: u-boot.img spl/u-boot-spl.bin
797 tools/mkimage -A $(ARCH) -T firmware -C none \
Stefan Roese0ba64c32012-01-05 11:19:50 +0100798 -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER \
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900799 -d spl/u-boot-spl.bin $@
Masahiro Yamada62aa18a2013-12-18 19:00:51 +0900800 $(OBJCOPY) -I binary -O binary \
801 --pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff $@
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900802 cat u-boot.img >> $@
Stefan Roese0ba64c32012-01-05 11:19:50 +0100803
Tom Warrend32b2a42012-12-11 13:34:17 +0000804ifneq ($(CONFIG_TEGRA),)
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900805u-boot-nodtb-tegra.bin: spl/u-boot-spl.bin u-boot.bin
806 $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SYS_TEXT_BASE) -O binary spl/u-boot-spl spl/u-boot-spl-pad.bin
807 cat spl/u-boot-spl-pad.bin u-boot.bin > $@
808 rm spl/u-boot-spl-pad.bin
Stephen Warren1fa4e832013-05-14 08:00:53 +0000809
810ifeq ($(CONFIG_OF_SEPARATE),y)
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900811u-boot-dtb-tegra.bin: u-boot-nodtb-tegra.bin u-boot.dtb
812 cat u-boot-nodtb-tegra.bin u-boot.dtb > $@
Stephen Warren1fa4e832013-05-14 08:00:53 +0000813endif
Allen Martin21476ec2012-08-31 08:30:10 +0000814endif
Allen Martin21476ec2012-08-31 08:30:10 +0000815
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900816u-boot-img.bin: spl/u-boot-spl.bin u-boot.img
817 cat spl/u-boot-spl.bin u-boot.img > $@
Stefan Roese28eeffa2012-08-24 17:36:53 +0200818
Stefan Roese07a78db2013-02-22 11:36:50 +0100819# PPC4xx needs the SPL at the end of the image, since the reset vector
820# is located at 0xfffffffc. So we can't use the "u-boot-img.bin" target
821# and need to introduce a new build target with the full blown U-Boot
822# at the start padded up to the start of the SPL image. And then concat
823# the SPL image to the end.
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900824u-boot-img-spl-at-end.bin: spl/u-boot-spl.bin u-boot.img
Masahiro Yamada62aa18a2013-12-18 19:00:51 +0900825 $(OBJCOPY) -I binary -O binary --pad-to=$(CONFIG_UBOOT_PAD_TO) \
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900826 --gap-fill=0xff u-boot.img $@
827 cat spl/u-boot-spl.bin >> $@
Stefan Roese07a78db2013-02-22 11:36:50 +0100828
Scott Wooda8d49102013-12-14 11:47:33 +0800829# Create a new ELF from a raw binary file. This is useful for arm64
830# where static relocation needs to be performed on the raw binary,
831# but certain simulators only accept an ELF file (but don't do the
832# relocation).
833# FIXME refactor dts/Makefile to share target/arch detection
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900834u-boot.elf: u-boot.bin
Scott Wooda8d49102013-12-14 11:47:33 +0800835 @$(OBJCOPY) -B aarch64 -I binary -O elf64-littleaarch64 \
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900836 $< u-boot-elf.o
837 @$(LD) u-boot-elf.o -o $@ \
Scott Wooda8d49102013-12-14 11:47:33 +0800838 --defsym=_start=$(CONFIG_SYS_TEXT_BASE) \
839 -Ttext=$(CONFIG_SYS_TEXT_BASE)
840
Simon Glass9f53bbf2011-10-03 19:26:50 +0000841ifeq ($(CONFIG_SANDBOX),y)
842GEN_UBOOT = \
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900843 $(CC) $(SYMS) -T u-boot.lds \
844 -Wl,--start-group $(LIBS) -Wl,--end-group \
Simon Glass9f53bbf2011-10-03 19:26:50 +0000845 $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot
846else
Mike Frysingera46fbba2009-05-20 04:35:14 -0400847GEN_UBOOT = \
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900848 $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
849 $(OBJS) \
850 --start-group $(LIBS) --end-group $(PLATFORM_LIBS) \
wdenk67ff36c2002-11-19 23:01:07 +0000851 -Map u-boot.map -o u-boot
Simon Glass9f53bbf2011-10-03 19:26:50 +0000852endif
853
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900854u-boot: depend $(SUBDIR_TOOLS) $(OBJS) $(LIBS) u-boot.lds
Mike Frysingera46fbba2009-05-20 04:35:14 -0400855 $(GEN_UBOOT)
856ifeq ($(CONFIG_KALLSYMS),y)
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900857 smap=`$(call SYSTEM_MAP,u-boot) | \
Wolfgang Denk18d46c02009-08-17 14:00:53 +0200858 awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \
Masahiro Yamada0d68fb12014-02-04 17:24:28 +0900859 $(CC) $(c_flags) -DSYSTEM_MAP="\"$${smap}\"" \
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900860 -c $(srctree)/common/system_map.c -o common/system_map.o
861 $(GEN_UBOOT) common/system_map.o
Mike Frysingera46fbba2009-05-20 04:35:14 -0400862endif
wdenk7ebf7442002-11-02 23:17:16 +0000863
Masahiro Yamada33ed77e2013-10-21 11:53:41 +0900864$(OBJS):
865 @:
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200866
Masahiro Yamada0d68fb12014-02-04 17:24:28 +0900867$(LIBS): depend $(SUBDIR_TOOLS) scripts_basic
868 $(Q)$(MAKE) $(build)=$(patsubst %/,%,$(dir $@))
wdenkc0aa5c52003-12-06 19:49:23 +0000869
Masahiro Yamada0d68fb12014-02-04 17:24:28 +0900870$(SUBDIRS): depend scripts_basic
871 $(Q)$(MAKE) $(build)=$@
Masahiro Yamadaf2431802014-02-04 17:24:10 +0900872
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900873$(SUBDIR_EXAMPLES-y): u-boot
Che-liang Chioud74a67f2011-10-17 21:04:15 +0000874
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900875u-boot.lds: $(LDSCRIPT) depend
Masahiro Yamada0d68fb12014-02-04 17:24:28 +0900876 $(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
Wolfgang Denk18d46c02009-08-17 14:00:53 +0200877
Masahiro Yamada0d68fb12014-02-04 17:24:28 +0900878nand_spl: $(TIMESTAMP_FILE) $(VERSION_FILE) depend scripts_basic
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900879 $(MAKE) $(build)=nand_spl/board/$(BOARDDIR) all
Stefan Roese42fbddd2006-09-07 11:51:23 +0200880
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900881u-boot-nand.bin: nand_spl u-boot.bin
882 cat nand_spl/u-boot-spl-16k.bin u-boot.bin > u-boot-nand.bin
Stefan Roese42fbddd2006-09-07 11:51:23 +0200883
Masahiro Yamada0d68fb12014-02-04 17:24:28 +0900884spl/u-boot-spl.bin: $(SUBDIR_TOOLS) depend scripts_basic
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900885 $(MAKE) obj=spl -f $(srctree)/spl/Makefile all
Daniel Schwierzeck73f4f772011-07-13 05:11:04 +0000886
Masahiro Yamada0d68fb12014-02-04 17:24:28 +0900887tpl/u-boot-tpl.bin: $(SUBDIR_TOOLS) depend scripts_basic
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900888 $(MAKE) obj=tpl -f $(srctree)/spl/Makefile all CONFIG_TPL_BUILD=y
Ying Zhang2d2e3b62013-08-16 15:16:15 +0800889
Daniel Hobiad4eaa32010-01-18 18:13:39 +0100890# Explicitly make _depend in subdirs containing multiple targets to prevent
891# parallel sub-makes creating .depend files simultaneously.
Wolfgang Denk81aa2eb2010-10-26 00:08:35 +0200892depend dep: $(TIMESTAMP_FILE) $(VERSION_FILE) \
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900893 include/generated/generic-asm-offsets.h \
894 include/generated/asm-offsets.h
wdenk7ebf7442002-11-02 23:17:16 +0000895
Li Yang22a6da62009-12-09 18:13:26 +0800896TAG_SUBDIRS = $(SUBDIRS)
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900897TAG_SUBDIRS += $(dir $(LIBS))
Jean-Christophe PLAGNIOL-VILLARD957013c2007-11-25 18:45:47 +0100898TAG_SUBDIRS += include
Jean-Christophe PLAGNIOL-VILLARD957013c2007-11-25 18:45:47 +0100899
Horst Kronstorferb2bc9042011-07-18 01:21:18 +0000900FIND := find
901FINDFLAGS := -L
902
Masahiro Yamada4dd075d2014-02-04 17:24:31 +0900903PHONY += checkstack
904
Tom Rini0819fd82012-02-02 14:07:05 +0000905checkstack:
Masahiro Yamada4dd075d2014-02-04 17:24:31 +0900906 $(OBJDUMP) -d u-boot $$(find . -name u-boot-spl) | \
907 $(PERL) $(src)/scripts/checkstack.pl $(ARCH)
Tom Rini0819fd82012-02-02 14:07:05 +0000908
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200909tags ctags:
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900910 ctags -w -o ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
Li Yang22a6da62009-12-09 18:13:26 +0800911 -name '*.[chS]' -print`
wdenk7ebf7442002-11-02 23:17:16 +0000912
913etags:
Horst Kronstorferb2bc9042011-07-18 01:21:18 +0000914 etags -a -o $(obj)etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
Li Yang22a6da62009-12-09 18:13:26 +0800915 -name '*.[chS]' -print`
Li Yang8c6dcf02008-02-29 11:46:05 +0800916cscope:
Horst Kronstorferb2bc9042011-07-18 01:21:18 +0000917 $(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \
918 cscope.files
Li Yang8c6dcf02008-02-29 11:46:05 +0800919 cscope -b -q -k
wdenk7ebf7442002-11-02 23:17:16 +0000920
Mike Frysingera46fbba2009-05-20 04:35:14 -0400921SYSTEM_MAP = \
922 $(NM) $1 | \
wdenk7ebf7442002-11-02 23:17:16 +0000923 grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
Mike Frysingera46fbba2009-05-20 04:35:14 -0400924 LC_ALL=C sort
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900925System.map: u-boot
Masahiro Yamada9f36f062013-11-11 14:36:01 +0900926 @$(call SYSTEM_MAP,$<) > $@
wdenk7ebf7442002-11-02 23:17:16 +0000927
Tom Rini20eef6c2012-03-16 06:34:35 +0000928checkthumb:
929 @if test $(call cc-version) -lt 0404; then \
930 echo -n '*** Your GCC does not produce working '; \
931 echo 'binaries in THUMB mode.'; \
932 echo '*** Your board is configured for THUMB mode.'; \
933 false; \
934 fi
Scott Wood146f5062012-09-20 19:10:01 -0500935
936# GCC 3.x is reported to have problems generating the type of relocation
937# that U-Boot wants.
938# See http://lists.denx.de/pipermail/u-boot/2012-September/135156.html
939checkgcc4:
940 @if test $(call cc-version) -lt 0400; then \
941 echo -n '*** Your GCC is too old, please upgrade to GCC 4.x or newer'; \
942 false; \
943 fi
944
Stephen Warren1f78f062013-07-24 10:09:16 -0700945checkdtc:
946 @if test $(call dtc-version) -lt 0104; then \
947 echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \
948 false; \
949 fi
950
Grant Likely0f910192007-09-24 09:05:31 -0600951#
952# Auto-generate the autoconf.mk file (which is included by all makefiles)
953#
954# This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
955# the dep file is only include in this top level makefile to determine when
956# to regenerate the autoconf.mk file.
Masahiro Yamada4dd075d2014-02-04 17:24:31 +0900957
958quiet_cmd_autoconf_dep = GEN $@
959 cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M $(c_flags) \
960 -MQ include/autoconf.mk $(srctree)/include/common.h > $@ || rm $@
961
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900962include/autoconf.mk.dep: include/config.h include/common.h
Masahiro Yamada4dd075d2014-02-04 17:24:31 +0900963 $(call cmd,autoconf_dep)
Wolfgang Denk9046f3f2008-05-13 23:15:52 +0200964
Masahiro Yamada4dd075d2014-02-04 17:24:31 +0900965quiet_cmd_autoconf = GEN $@
966 cmd_autoconf = \
Masahiro Yamada0d68fb12014-02-04 17:24:28 +0900967 $(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
Masahiro Yamada4dd075d2014-02-04 17:24:31 +0900968 sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
Masahiro Yamadadab09922013-12-02 14:57:29 +0900969 rm $@.tmp
Grant Likely0f910192007-09-24 09:05:31 -0600970
Masahiro Yamada4dd075d2014-02-04 17:24:31 +0900971include/autoconf.mk: include/config.h
972 $(call cmd,autoconf)
973
Masahiro Yamada4dd075d2014-02-04 17:24:31 +0900974quiet_cmd_offsets = GEN $@
975 cmd_offsets = $(srctree)/tools/scripts/make-asm-offsets $< $@
976
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900977include/generated/generic-asm-offsets.h: lib/asm-offsets.s
Masahiro Yamada4dd075d2014-02-04 17:24:31 +0900978 $(call cmd,offsets)
Wolfgang Denk81aa2eb2010-10-26 00:08:35 +0200979
Masahiro Yamada4dd075d2014-02-04 17:24:31 +0900980quiet_cmd_asm-offsets.s = CC $@
981 cmd_asm-offsets.s = mkdir -p lib; \
982 $(CC) -DDO_DEPS_ONLY \
Masahiro Yamada0d68fb12014-02-04 17:24:28 +0900983 $(c_flags) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
Masahiro Yamada4dd075d2014-02-04 17:24:31 +0900984 -o $@ $< -c -S
985
986lib/asm-offsets.s: $(srctree)/lib/asm-offsets.c include/config.h
987 $(call cmd,asm-offsets.s)
Wolfgang Denk81aa2eb2010-10-26 00:08:35 +0200988
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900989include/generated/asm-offsets.h: $(CPUDIR)/$(SOC)/asm-offsets.s
Masahiro Yamada4dd075d2014-02-04 17:24:31 +0900990 $(call cmd,offsets)
Stefano Babic2a1f1ac2011-09-05 04:32:28 +0000991
Masahiro Yamada4dd075d2014-02-04 17:24:31 +0900992quiet_cmd_soc_asm-offsets.s = CC $@
993 cmd_soc_asm-offsets.s = mkdir -p $(CPUDIR)/$(SOC); \
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900994 if [ -f $(srctree)/$(CPUDIR)/$(SOC)/asm-offsets.c ];then \
Stefano Babic2a1f1ac2011-09-05 04:32:28 +0000995 $(CC) -DDO_DEPS_ONLY \
Masahiro Yamada0d68fb12014-02-04 17:24:28 +0900996 $(c_flags) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
Masahiro Yamada59f15f22014-02-04 17:24:24 +0900997 -o $@ $(srctree)/$(CPUDIR)/$(SOC)/asm-offsets.c -c -S; \
Stefano Babic2a1f1ac2011-09-05 04:32:28 +0000998 else \
999 touch $@; \
1000 fi
1001
Masahiro Yamada4dd075d2014-02-04 17:24:31 +09001002$(CPUDIR)/$(SOC)/asm-offsets.s: include/config.h
1003 $(call cmd,soc_asm-offsets.s)
1004
wdenk7ebf7442002-11-02 23:17:16 +00001005#########################################################################
Wolfgang Denk0a659ad2008-01-13 00:59:21 +01001006else # !config.mk
Masahiro Yamada59f15f22014-02-04 17:24:24 +09001007all u-boot.hex u-boot.srec u-boot.bin \
1008u-boot.img u-boot.dis u-boot \
Loïc Minier4fd86112011-10-03 11:57:10 +02001009$(filter-out tools,$(SUBDIRS)) \
Masahiro Yamada59f15f22014-02-04 17:24:24 +09001010depend dep tags ctags etags cscope System.map:
wdenk7ebf7442002-11-02 23:17:16 +00001011 @echo "System not configured - see README" >&2
1012 @ exit 1
Mike Frysinger39901cd2010-01-21 04:03:22 -05001013
Loïc Minier4fd86112011-10-03 11:57:10 +02001014tools: $(VERSION_FILE) $(TIMESTAMP_FILE)
Masahiro Yamada59f15f22014-02-04 17:24:24 +09001015 $(MAKE) $(build)=$@ all
Wolfgang Denk0a659ad2008-01-13 00:59:21 +01001016endif # config.mk
wdenk7ebf7442002-11-02 23:17:16 +00001017
Scott Wood4f62eb42013-12-14 11:47:34 +08001018# ARM relocations should all be R_ARM_RELATIVE (32-bit) or
1019# R_AARCH64_RELATIVE (64-bit).
Masahiro Yamada59f15f22014-02-04 17:24:24 +09001020checkarmreloc: u-boot
Scott Wood4f62eb42013-12-14 11:47:34 +08001021 @RELOC="`$(CROSS_COMPILE)readelf -r -W $< | cut -d ' ' -f 4 | \
1022 grep R_A | sort -u`"; \
1023 if test "$$RELOC" != "R_ARM_RELATIVE" -a \
1024 "$$RELOC" != "R_AARCH64_RELATIVE"; then \
1025 echo "$< contains unexpected relocations: $$RELOC"; \
1026 false; \
1027 fi
Albert ARIBAUD446dd122013-06-11 14:17:30 +02001028
Ilya Yanok3f153db2011-06-20 12:45:38 +00001029$(VERSION_FILE):
Mike Frysingere8969ab2011-06-30 16:56:20 +00001030 @mkdir -p $(dir $(VERSION_FILE))
Masahiro Yamada7935a822013-11-28 16:29:23 +09001031 @( localvers='$(shell $(TOPDIR)/scripts/setlocalversion $(TOPDIR))' ; \
Ilya Yanok3f153db2011-06-20 12:45:38 +00001032 printf '#define PLAIN_VERSION "%s%s"\n' \
1033 "$(U_BOOT_VERSION)" "$${localvers}" ; \
1034 printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' \
1035 "$(U_BOOT_VERSION)" "$${localvers}" ; \
1036 ) > $@.tmp
1037 @( printf '#define CC_VERSION_STRING "%s"\n' \
1038 '$(shell $(CC) --version | head -n 1)' )>> $@.tmp
1039 @( printf '#define LD_VERSION_STRING "%s"\n' \
1040 '$(shell $(LD) -v | head -n 1)' )>> $@.tmp
1041 @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
1042
Loïc Minier4fd86112011-10-03 11:57:10 +02001043$(TIMESTAMP_FILE):
1044 @mkdir -p $(dir $(TIMESTAMP_FILE))
Loïc Minieraf7c7e42011-10-03 11:57:11 +02001045 @LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > $@.tmp
1046 @LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> $@.tmp
1047 @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
Loïc Minier4fd86112011-10-03 11:57:10 +02001048
Mike Frysinger9bd7a6f2010-08-15 00:03:21 -04001049easylogo env gdb:
Masahiro Yamada0d68fb12014-02-04 17:24:28 +09001050 $(Q)$(MAKE) $(build)=tools/$@ MTD_VERSION=${MTD_VERSION}
Masahiro Yamadaf2431802014-02-04 17:24:10 +09001051
Mike Frysinger9bd7a6f2010-08-15 00:03:21 -04001052gdbtools: gdb
1053
Marek Vasut1f747c12012-10-06 14:04:58 +00001054xmldocs pdfdocs psdocs htmldocs mandocs: tools/kernel-doc/docproc
Masahiro Yamada0d68fb12014-02-04 17:24:28 +09001055 $(Q)$(MAKE) U_BOOT_VERSION=$(U_BOOT_VERSION) $(build)=doc/DocBook $@
Marek Vasut1f747c12012-10-06 14:04:58 +00001056
Loïc Minier4fd86112011-10-03 11:57:10 +02001057tools-all: easylogo env gdb $(VERSION_FILE) $(TIMESTAMP_FILE)
Masahiro Yamada0d68fb12014-02-04 17:24:28 +09001058 $(Q)$(MAKE) $(build)=tools HOST_TOOLS_ALL=y
Mike Frysinger9bd7a6f2010-08-15 00:03:21 -04001059
Wolfgang Denke5d99e22006-10-25 00:43:17 +02001060.PHONY : CHANGELOG
1061CHANGELOG:
Ben Warrendc43c9c2006-10-26 14:38:25 -04001062 git log --no-merges U-Boot-1_1_5.. | \
1063 unexpand -a | sed -e 's/\s\s*$$//' > $@
Wolfgang Denke5d99e22006-10-25 00:43:17 +02001064
Harald Welte5708dbf2008-07-09 22:30:30 +08001065include/license.h: tools/bin2header COPYING
Wolfgang Denk625bd332010-05-27 23:18:33 +02001066 cat COPYING | gzip -9 -c | ./tools/bin2header license_gzip > include/license.h
wdenk7ebf7442002-11-02 23:17:16 +00001067#########################################################################
1068
1069unconfig:
Masahiro Yamada59f15f22014-02-04 17:24:24 +09001070 @rm -f include/config.h include/config.mk \
1071 board/*/config.tmp board/*/*/config.tmp \
1072 include/autoconf.mk include/autoconf.mk.dep \
1073 include/spl-autoconf.mk \
1074 include/tpl-autoconf.mk
wdenk7ebf7442002-11-02 23:17:16 +00001075
Wolfgang Denkf2c7ea82010-05-27 23:18:36 +02001076%_config:: unconfig
1077 @$(MKCONFIG) -A $(@:_config=)
1078
wdenkb02744a2003-04-05 00:53:31 +00001079#########################################################################
wdenk7ebf7442002-11-02 23:17:16 +00001080
1081clean:
Masahiro Yamada59f15f22014-02-04 17:24:24 +09001082 @rm -f examples/standalone/atmel_df_pow2 \
1083 examples/standalone/hello_world \
1084 examples/standalone/interrupt \
1085 examples/standalone/mem_to_mem_idma2intr \
1086 examples/standalone/sched \
1087 $(addprefix examples/standalone/, smc91111_eeprom smc911x_eeprom) \
1088 examples/standalone/test_burst \
1089 examples/standalone/timer
1090 @rm -f $(addprefix examples/api/, demo demo.bin)
1091 @rm -f tools/bmp_logo tools/easylogo/easylogo \
1092 tools/env/fw_printenv \
1093 tools/envcrc \
1094 $(addprefix tools/gdb/, gdbcont gdbsend) \
1095 tools/gen_eth_addr tools/img2srec \
1096 tools/dumpimage \
1097 $(addprefix tools/, mkenvimage mkimage) \
1098 tools/mpc86x_clk \
1099 $(addprefix tools/, mk$(BOARD)spl mkexynosspl) \
1100 tools/mxsboot \
1101 tools/ncb tools/ubsha1 \
1102 tools/kernel-doc/docproc \
1103 tools/proftool
1104 @rm -f $(addprefix board/cray/L1/, bootscript.c bootscript.image) \
1105 board/matrix_vision/*/bootscript.img \
1106 spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl \
1107 u-boot.lds \
1108 $(addprefix arch/blackfin/cpu/, init.lds init.elf)
1109 @rm -f include/bmp_logo.h
1110 @rm -f include/bmp_logo_data.h
1111 @rm -f lib/asm-offsets.s
1112 @rm -f include/generated/asm-offsets.h
1113 @rm -f $(CPUDIR)/$(SOC)/asm-offsets.s
Peter Tyseracce4eb2009-07-20 19:02:21 -05001114 @rm -f $(TIMESTAMP_FILE) $(VERSION_FILE)
Masahiro Yamada59f15f22014-02-04 17:24:24 +09001115 @$(MAKE) -f $(srctree)/doc/DocBook/Makefile cleandocs
Wolfgang Denk0a659ad2008-01-13 00:59:21 +01001116 @find $(OBJTREE) -type f \
Tom Rinib7f34132012-02-20 13:50:10 +00001117 \( -name 'core' -o -name '*.bak' -o -name '*~' -o -name '*.su' \
Masahiro Yamada0d68fb12014-02-04 17:24:28 +09001118 -o -name '*.o' -o -name '*.a' -o -name '*.exe' -o -name '*.cmd' \
Troy Kiskya18d7862013-01-18 16:14:24 +00001119 -o -name '*.cfgtmp' \) -print \
wdenk7ebf7442002-11-02 23:17:16 +00001120 | xargs rm -f
wdenk7ebf7442002-11-02 23:17:16 +00001121
Masahiro Yamadad01ec132014-02-04 17:24:34 +09001122clobber: clean
Andy Flemingdef963d2011-11-21 13:40:43 +00001123 @find $(OBJTREE) -type f \( -name '*.srec' \
1124 -o -name '*.bin' -o -name u-boot.img \) \
1125 -print0 | xargs -0 rm -f
Masahiro Yamada59f15f22014-02-04 17:24:24 +09001126 @rm -f $(OBJS) *.bak ctags etags TAGS \
1127 cscope.* *.*~
1128 @rm -f u-boot u-boot.map u-boot.hex $(ALL-y)
1129 @rm -f u-boot.kwb
1130 @rm -f u-boot.pbl
1131 @rm -f u-boot.imx
1132 @rm -f u-boot-with-spl.imx
1133 @rm -f u-boot-with-nand-spl.imx
1134 @rm -f u-boot.ubl
1135 @rm -f u-boot.ais
1136 @rm -f u-boot.dtb
1137 @rm -f u-boot.sb
1138 @rm -f u-boot.spr
1139 @rm -f $(addprefix nand_spl/, u-boot.lds u-boot.lst System.map)
1140 @rm -f $(addprefix nand_spl/, u-boot-nand_spl.lds u-boot-spl u-boot-spl.map)
1141 @rm -f $(addprefix spl/, u-boot-spl u-boot-spl.bin u-boot-spl.map)
1142 @rm -f spl/u-boot-spl.lds
1143 @rm -f $(addprefix tpl/, u-boot-tpl u-boot-tpl.bin u-boot-tpl.map)
1144 @rm -f tpl/u-boot-spl.lds
1145 @rm -f MLO MLO.byteswap
1146 @rm -f SPL
1147 @rm -f tools/xway-swap-bytes
1148 @rm -fr include/asm/proc include/asm/arch include/asm
1149 @rm -fr include/generated
1150 @[ ! -d nand_spl ] || find nand_spl -name "*" -type l -print | xargs rm -f
1151 @rm -f dts/*.tmp
1152 @rm -f $(addprefix spl/, u-boot-spl.ais, u-boot-spl-pad.ais)
wdenk7ebf7442002-11-02 23:17:16 +00001153
Marian Balakowiczd62379d2006-09-01 19:49:50 +02001154mrproper \
1155distclean: clobber unconfig
Mike Frysinger0c115212011-06-24 18:37:55 +00001156ifneq ($(OBJTREE),$(SRCTREE))
Masahiro Yamada59f15f22014-02-04 17:24:24 +09001157 rm -rf *
Marian Balakowiczd62379d2006-09-01 19:49:50 +02001158endif
wdenk7ebf7442002-11-02 23:17:16 +00001159
1160backup:
1161 F=`basename $(TOPDIR)` ; cd .. ; \
Ilya Yanokd2b096d2010-06-21 18:13:21 +04001162 gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
wdenk7ebf7442002-11-02 23:17:16 +00001163
1164#########################################################################
Masahiro Yamada59f15f22014-02-04 17:24:24 +09001165
1166endif # skip-makefile
1167
1168PHONY += FORCE
1169FORCE:
1170
1171# Declare the contents of the .PHONY variable as phony. We keep that
1172# information in a variable so we can use it in if_changed and friends.
1173.PHONY: $(PHONY)