1# 2# SPDX-License-Identifier: GPL-2.0+ 3# 4 5VERSION = 2017 6PATCHLEVEL = 09 7SUBLEVEL = 8EXTRAVERSION = 9NAME = 10 11# *DOCUMENTATION* 12# To see a list of typical targets execute "make help" 13# More info can be located in ./README 14# Comments in this file are targeted only to the developer, do not 15# expect to learn how to build the kernel reading this file. 16 17# o Do not use make's built-in rules and variables 18# (this increases performance and avoids hard-to-debug behaviour); 19# o Look for make include files relative to root of kernel src 20MAKEFLAGS += -rR --include-dir=$(CURDIR) 21 22# Avoid funny character set dependencies 23unexport LC_ALL 24LC_COLLATE=C 25LC_NUMERIC=C 26export LC_COLLATE LC_NUMERIC 27 28# Avoid interference with shell env settings 29unexport GREP_OPTIONS 30 31# We are using a recursive build, so we need to do a little thinking 32# to get the ordering right. 33# 34# Most importantly: sub-Makefiles should only ever modify files in 35# their own directory. If in some directory we have a dependency on 36# a file in another dir (which doesn't happen often, but it's often 37# unavoidable when linking the built-in.o targets which finally 38# turn into vmlinux), we will call a sub make in that other dir, and 39# after that we are sure that everything which is in that other dir 40# is now up to date. 41# 42# The only cases where we need to modify files which have global 43# effects are thus separated out and done before the recursive 44# descending is started. They are now explicitly listed as the 45# prepare rule. 46 47# Beautify output 48# --------------------------------------------------------------------------- 49# 50# Normally, we echo the whole command before executing it. By making 51# that echo $($(quiet)$(cmd)), we now have the possibility to set 52# $(quiet) to choose other forms of output instead, e.g. 53# 54# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ 55# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< 56# 57# If $(quiet) is empty, the whole command will be printed. 58# If it is set to "quiet_", only the short version will be printed. 59# If it is set to "silent_", nothing will be printed at all, since 60# the variable $(silent_cmd_cc_o_c) doesn't exist. 61# 62# A simple variant is to prefix commands with $(Q) - that's useful 63# for commands that shall be hidden in non-verbose mode. 64# 65# $(Q)ln $@ :< 66# 67# If KBUILD_VERBOSE equals 0 then the above command will be hidden. 68# If KBUILD_VERBOSE equals 1 then the above command is displayed. 69# 70# To put more focus on warnings, be less verbose as default 71# Use 'make V=1' to see the full commands 72 73ifeq ("$(origin V)", "command line") 74 KBUILD_VERBOSE = $(V) 75endif 76ifndef KBUILD_VERBOSE 77 KBUILD_VERBOSE = 0 78endif 79 80ifeq ($(KBUILD_VERBOSE),1) 81 quiet = 82 Q = 83else 84 quiet=quiet_ 85 Q = @ 86endif 87 88ifeq ("$(origin FWVER)", "command line") 89 PLAT_FW_VERSION := $(FWVER) 90endif 91ifeq ("$(origin SPL_FWVER)", "command line") 92 PLAT_SPL_FW_VERSION := $(SPL_FWVER) 93endif 94 95# If the user is running make -s (silent mode), suppress echoing of 96# commands 97 98ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 99ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) 100 quiet=silent_ 101endif 102else # make-3.8x 103ifneq ($(filter s% -s%,$(MAKEFLAGS)),) 104 quiet=silent_ 105endif 106endif 107 108export quiet Q KBUILD_VERBOSE 109 110# kbuild supports saving output files in a separate directory. 111# To locate output files in a separate directory two syntaxes are supported. 112# In both cases the working directory must be the root of the kernel src. 113# 1) O= 114# Use "make O=dir/to/store/output/files/" 115# 116# 2) Set KBUILD_OUTPUT 117# Set the environment variable KBUILD_OUTPUT to point to the directory 118# where the output files shall be placed. 119# export KBUILD_OUTPUT=dir/to/store/output/files/ 120# make 121# 122# The O= assignment takes precedence over the KBUILD_OUTPUT environment 123# variable. 124 125# KBUILD_SRC is set on invocation of make in OBJ directory 126# KBUILD_SRC is not intended to be used by the regular user (for now) 127ifeq ($(KBUILD_SRC),) 128 129# OK, Make called in directory where kernel src resides 130# Do we want to locate output files in a separate directory? 131ifeq ("$(origin O)", "command line") 132 KBUILD_OUTPUT := $(O) 133endif 134 135# That's our default target when none is given on the command line 136PHONY := _all 137_all: 138 139# Cancel implicit rules on top Makefile 140$(CURDIR)/Makefile Makefile: ; 141 142ifneq ($(KBUILD_OUTPUT),) 143# Invoke a second make in the output directory, passing relevant variables 144# check that the output directory actually exists 145saved-output := $(KBUILD_OUTPUT) 146KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \ 147 && /bin/pwd) 148$(if $(KBUILD_OUTPUT),, \ 149 $(error failed to create output directory "$(saved-output)")) 150 151PHONY += $(MAKECMDGOALS) sub-make 152 153$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make 154 @: 155 156sub-make: FORCE 157 $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \ 158 -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) 159 160# Leave processing to above invocation of make 161skip-makefile := 1 162endif # ifneq ($(KBUILD_OUTPUT),) 163endif # ifeq ($(KBUILD_SRC),) 164 165# We process the rest of the Makefile if this is the final invocation of make 166ifeq ($(skip-makefile),) 167 168# Do not print "Entering directory ...", 169# but we want to display it when entering to the output directory 170# so that IDEs/editors are able to understand relative filenames. 171MAKEFLAGS += --no-print-directory 172 173# Call a source code checker (by default, "sparse") as part of the 174# C compilation. 175# 176# Use 'make C=1' to enable checking of only re-compiled files. 177# Use 'make C=2' to enable checking of *all* source files, regardless 178# of whether they are re-compiled or not. 179# 180# See the file "Documentation/sparse.txt" for more details, including 181# where to get the "sparse" utility. 182 183ifeq ("$(origin C)", "command line") 184 KBUILD_CHECKSRC = $(C) 185endif 186ifndef KBUILD_CHECKSRC 187 KBUILD_CHECKSRC = 0 188endif 189 190# Use make M=dir to specify directory of external module to build 191# Old syntax make ... SUBDIRS=$PWD is still supported 192# Setting the environment variable KBUILD_EXTMOD take precedence 193ifdef SUBDIRS 194 KBUILD_EXTMOD ?= $(SUBDIRS) 195endif 196 197ifeq ("$(origin M)", "command line") 198 KBUILD_EXTMOD := $(M) 199endif 200 201# If building an external module we do not care about the all: rule 202# but instead _all depend on modules 203PHONY += all 204ifeq ($(KBUILD_EXTMOD),) 205_all: all 206else 207_all: modules 208endif 209 210ifeq ($(KBUILD_SRC),) 211 # building in the source tree 212 srctree := . 213else 214 ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR))) 215 # building in a subdirectory of the source tree 216 srctree := .. 217 else 218 srctree := $(KBUILD_SRC) 219 endif 220endif 221objtree := . 222src := $(srctree) 223obj := $(objtree) 224 225VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) 226 227export srctree objtree VPATH 228 229# Make sure CDPATH settings don't interfere 230unexport CDPATH 231 232######################################################################### 233 234HOSTARCH := $(shell uname -m | \ 235 sed -e s/i.86/x86/ \ 236 -e s/sun4u/sparc64/ \ 237 -e s/arm.*/arm/ \ 238 -e s/sa110/arm/ \ 239 -e s/ppc64/powerpc/ \ 240 -e s/ppc/powerpc/ \ 241 -e s/macppc/powerpc/\ 242 -e s/sh.*/sh/) 243 244HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \ 245 sed -e 's/\(cygwin\).*/cygwin/') 246 247export HOSTARCH HOSTOS 248 249######################################################################### 250 251# set default to nothing for native builds 252ifeq ($(HOSTARCH),$(ARCH)) 253CROSS_COMPILE ?= 254endif 255 256KCONFIG_CONFIG ?= .config 257export KCONFIG_CONFIG 258 259# SHELL used by kbuild 260CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ 261 else if [ -x /bin/bash ]; then echo /bin/bash; \ 262 else echo sh; fi ; fi) 263 264HOSTCC = cc 265HOSTCXX = c++ 266HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \ 267 $(if $(CONFIG_TOOLS_DEBUG),-g) 268HOSTCXXFLAGS = -O2 269 270ifeq ($(HOSTOS),cygwin) 271HOSTCFLAGS += -ansi 272endif 273 274# Mac OS X / Darwin's C preprocessor is Apple specific. It 275# generates numerous errors and warnings. We want to bypass it 276# and use GNU C's cpp. To do this we pass the -traditional-cpp 277# option to the compiler. Note that the -traditional-cpp flag 278# DOES NOT have the same semantics as GNU C's flag, all it does 279# is invoke the GNU preprocessor in stock ANSI/ISO C fashion. 280# 281# Apple's linker is similar, thanks to the new 2 stage linking 282# multiple symbol definitions are treated as errors, hence the 283# -multiply_defined suppress option to turn off this error. 284# 285ifeq ($(HOSTOS),darwin) 286# get major and minor product version (e.g. '10' and '6' for Snow Leopard) 287DARWIN_MAJOR_VERSION = $(shell sw_vers -productVersion | cut -f 1 -d '.') 288DARWIN_MINOR_VERSION = $(shell sw_vers -productVersion | cut -f 2 -d '.') 289 290os_x_before = $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \ 291 $(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;) 292 293# Snow Leopards build environment has no longer restrictions as described above 294HOSTCC = $(call os_x_before, 10, 5, "cc", "gcc") 295HOSTCFLAGS += $(call os_x_before, 10, 4, "-traditional-cpp") 296HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress") 297 298# since Lion (10.7) ASLR is on by default, but we use linker generated lists 299# in some host tools which is a problem then ... so disable ASLR for these 300# tools 301HOSTLDFLAGS += $(call os_x_before, 10, 7, "", "-Xlinker -no_pie") 302endif 303 304# Decide whether to build built-in, modular, or both. 305# Normally, just do built-in. 306 307KBUILD_MODULES := 308KBUILD_BUILTIN := 1 309 310# If we have only "make modules", don't compile built-in objects. 311# When we're building modules with modversions, we need to consider 312# the built-in objects during the descend as well, in order to 313# make sure the checksums are up to date before we record them. 314 315ifeq ($(MAKECMDGOALS),modules) 316 KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1) 317endif 318 319# If we have "make <whatever> modules", compile modules 320# in addition to whatever we do anyway. 321# Just "make" or "make all" shall build modules as well 322 323# U-Boot does not need modules 324#ifneq ($(filter all _all modules,$(MAKECMDGOALS)),) 325# KBUILD_MODULES := 1 326#endif 327 328#ifeq ($(MAKECMDGOALS),) 329# KBUILD_MODULES := 1 330#endif 331 332export KBUILD_MODULES KBUILD_BUILTIN 333export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD 334 335# We need some generic definitions (do not try to remake the file). 336scripts/Kbuild.include: ; 337include scripts/Kbuild.include 338 339# Make variables (CC, etc...) 340 341AS = $(CROSS_COMPILE)as 342# Always use GNU ld 343ifneq ($(shell $(CROSS_COMPILE)ld.bfd -v 2> /dev/null),) 344LD = $(CROSS_COMPILE)ld.bfd 345else 346LD = $(CROSS_COMPILE)ld 347endif 348CC = $(CROSS_COMPILE)gcc 349CPP = $(CC) -E 350AR = $(CROSS_COMPILE)ar 351NM = $(CROSS_COMPILE)nm 352LDR = $(CROSS_COMPILE)ldr 353STRIP = $(CROSS_COMPILE)strip 354OBJCOPY = $(CROSS_COMPILE)objcopy 355OBJDUMP = $(CROSS_COMPILE)objdump 356AWK = awk 357PERL = perl 358PYTHON ?= python 359DTC ?= $(objtree)/scripts/dtc/dtc 360CHECK = sparse 361 362CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ 363 -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF) 364 365KBUILD_CPPFLAGS := -D__KERNEL__ -D__UBOOT__ 366 367KBUILD_CFLAGS := -Wall -Wstrict-prototypes \ 368 -Wno-format-security \ 369 -fno-builtin -ffreestanding 370KBUILD_CFLAGS += -fshort-wchar -Werror 371KBUILD_AFLAGS := -D__ASSEMBLY__ 372 373# Read UBOOTRELEASE from include/config/uboot.release (if it exists) 374UBOOTRELEASE = $(shell cat include/config/uboot.release 2> /dev/null) 375UBOOTVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) 376 377export VERSION PATCHLEVEL SUBLEVEL UBOOTRELEASE UBOOTVERSION 378export ARCH CPU BOARD VENDOR SOC CPUDIR BOARDDIR 379export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC 380export CPP AR NM LDR STRIP OBJCOPY OBJDUMP 381export MAKE AWK PERL PYTHON 382export HOSTCXX HOSTCXXFLAGS CHECK CHECKFLAGS DTC DTC_FLAGS 383 384export KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE OBJCOPYFLAGS LDFLAGS 385export KBUILD_CFLAGS KBUILD_AFLAGS 386 387# When compiling out-of-tree modules, put MODVERDIR in the module 388# tree rather than in the kernel tree. The kernel tree might 389# even be read-only. 390export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions 391 392# Files to ignore in find ... statements 393 394export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \ 395 -name CVS -o -name .pc -o -name .hg -o -name .git \) \ 396 -prune -o 397export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \ 398 --exclude CVS --exclude .pc --exclude .hg --exclude .git 399 400# =========================================================================== 401# Rules shared between *config targets and build targets 402 403# Basic helpers built in scripts/ 404PHONY += scripts_basic 405scripts_basic: 406 $(Q)$(MAKE) $(build)=scripts/basic 407 $(Q)rm -f .tmp_quiet_recordmcount 408 409# To avoid any implicit rule to kick in, define an empty command. 410scripts/basic/%: scripts_basic ; 411 412PHONY += outputmakefile 413# outputmakefile generates a Makefile in the output directory, if using a 414# separate output directory. This allows convenient use of make in the 415# output directory. 416outputmakefile: 417ifneq ($(KBUILD_SRC),) 418 $(Q)ln -fsn $(srctree) source 419 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ 420 $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) 421endif 422 423# To make sure we do not include .config for any of the *config targets 424# catch them early, and hand them over to scripts/kconfig/Makefile 425# It is allowed to specify more targets when calling make, including 426# mixing *config targets and build targets. 427# For example 'make oldconfig all'. 428# Detect when mixed targets is specified, and make a second invocation 429# of make so .config is not included in this case either (for *config). 430 431version_h := include/generated/version_autogenerated.h 432timestamp_h := include/generated/timestamp_autogenerated.h 433 434no-dot-config-targets := clean clobber mrproper distclean \ 435 help %docs check% coccicheck \ 436 ubootversion backup tests 437 438config-targets := 0 439mixed-targets := 0 440dot-config := 1 441 442ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) 443 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) 444 dot-config := 0 445 endif 446endif 447 448ifeq ($(KBUILD_EXTMOD),) 449 ifneq ($(filter config %config,$(MAKECMDGOALS)),) 450 config-targets := 1 451 ifneq ($(words $(MAKECMDGOALS)),1) 452 mixed-targets := 1 453 endif 454 endif 455endif 456 457ifeq ($(mixed-targets),1) 458# =========================================================================== 459# We're called with mixed targets (*config and build targets). 460# Handle them one by one. 461 462PHONY += $(MAKECMDGOALS) __build_one_by_one 463 464$(filter-out __build_one_by_one, $(MAKECMDGOALS)): __build_one_by_one 465 @: 466 467__build_one_by_one: 468 $(Q)set -e; \ 469 for i in $(MAKECMDGOALS); do \ 470 $(MAKE) -f $(srctree)/Makefile $$i; \ 471 done 472 473else 474ifeq ($(config-targets),1) 475# =========================================================================== 476# *config targets only - make sure prerequisites are updated, and descend 477# in scripts/kconfig to make the *config target 478 479KBUILD_DEFCONFIG := sandbox_defconfig 480export KBUILD_DEFCONFIG KBUILD_KCONFIG 481 482config: scripts_basic outputmakefile FORCE 483 $(Q)$(MAKE) $(build)=scripts/kconfig $@ 484 485%config: scripts_basic outputmakefile FORCE 486 $(Q)$(MAKE) $(build)=scripts/kconfig $@ 487 488else 489# =========================================================================== 490# Build targets only - this includes vmlinux, arch specific targets, clean 491# targets and others. In general all targets except *config targets. 492 493# Additional helpers built in scripts/ 494# Carefully list dependencies so we do not try to build scripts twice 495# in parallel 496PHONY += scripts 497scripts: scripts_basic include/config/auto.conf 498 $(Q)$(MAKE) $(build)=$(@) 499 500ifeq ($(dot-config),1) 501# Read in config 502-include include/config/auto.conf 503 504# Read in dependencies to all Kconfig* files, make sure to run 505# oldconfig if changes are detected. 506-include include/config/auto.conf.cmd 507 508# To avoid any implicit rule to kick in, define an empty command 509$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; 510 511# If .config is newer than include/config/auto.conf, someone tinkered 512# with it and forgot to run make oldconfig. 513# if auto.conf.cmd is missing then we are probably in a cleaned tree so 514# we execute the config step to be sure to catch updated Kconfig files 515include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd 516 $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig 517 @# If the following part fails, include/config/auto.conf should be 518 @# deleted so "make silentoldconfig" will be re-run on the next build. 519 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.autoconf || \ 520 { rm -f include/config/auto.conf; false; } 521 @# include/config.h has been updated after "make silentoldconfig". 522 @# We need to touch include/config/auto.conf so it gets newer 523 @# than include/config.h. 524 @# Otherwise, 'make silentoldconfig' would be invoked twice. 525 $(Q)touch include/config/auto.conf 526 527u-boot.cfg spl/u-boot.cfg tpl/u-boot.cfg: include/config.h FORCE 528 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.autoconf $(@) 529 530-include include/autoconf.mk 531-include include/autoconf.mk.dep 532 533# We want to include arch/$(ARCH)/config.mk only when include/config/auto.conf 534# is up-to-date. When we switch to a different board configuration, old CONFIG 535# macros are still remaining in include/config/auto.conf. Without the following 536# gimmick, wrong config.mk would be included leading nasty warnings/errors. 537ifneq ($(wildcard $(KCONFIG_CONFIG)),) 538ifneq ($(wildcard include/config/auto.conf),) 539autoconf_is_old := $(shell find . -path ./$(KCONFIG_CONFIG) -newer \ 540 include/config/auto.conf) 541ifeq ($(autoconf_is_old),) 542include config.mk 543include arch/$(ARCH)/Makefile 544endif 545endif 546endif 547 548# These are set by the arch-specific config.mk. Make sure they are exported 549# so they can be used when building an EFI application. 550export EFI_LDS # Filename of EFI link script in arch/$(ARCH)/lib 551export EFI_CRT0 # Filename of EFI CRT0 in arch/$(ARCH)/lib 552export EFI_RELOC # Filename of EFU relocation code in arch/$(ARCH)/lib 553export CFLAGS_EFI # Compiler flags to add when building EFI app 554export CFLAGS_NON_EFI # Compiler flags to remove when building EFI app 555export EFI_TARGET # binutils target if EFI is natively supported 556 557# If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use 558# that (or fail if absent). Otherwise, search for a linker script in a 559# standard location. 560 561ifndef LDSCRIPT 562 #LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot.lds.debug 563 ifdef CONFIG_SYS_LDSCRIPT 564 # need to strip off double quotes 565 LDSCRIPT := $(srctree)/$(CONFIG_SYS_LDSCRIPT:"%"=%) 566 endif 567endif 568 569# If there is no specified link script, we look in a number of places for it 570ifndef LDSCRIPT 571 ifeq ($(wildcard $(LDSCRIPT)),) 572 LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot.lds 573 endif 574 ifeq ($(wildcard $(LDSCRIPT)),) 575 LDSCRIPT := $(srctree)/$(CPUDIR)/u-boot.lds 576 endif 577 ifeq ($(wildcard $(LDSCRIPT)),) 578 LDSCRIPT := $(srctree)/arch/$(ARCH)/cpu/u-boot.lds 579 endif 580endif 581 582else 583# Dummy target needed, because used as prerequisite 584include/config/auto.conf: ; 585endif # $(dot-config) 586 587# 588# Xtensa linker script cannot be preprocessed with -ansi because of 589# preprocessor operations on strings that don't make C identifiers. 590# 591ifeq ($(CONFIG_XTENSA),) 592LDPPFLAGS += -ansi 593endif 594 595ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE 596KBUILD_CFLAGS += -Os 597else 598KBUILD_CFLAGS += -O2 599endif 600 601KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector) 602KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks) 603 604KBUILD_CFLAGS += -g 605# $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format> 606# option to the assembler. 607KBUILD_AFLAGS += -g 608 609# Report stack usage if supported 610ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-stack-usage.sh $(CC)),y) 611 KBUILD_CFLAGS += -fstack-usage 612endif 613 614KBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral) 615KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) 616 617# turn jbsr into jsr for m68k 618ifeq ($(ARCH),m68k) 619ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4) 620KBUILD_AFLAGS += -Wa,-gstabs,-S 621endif 622endif 623 624# Prohibit date/time macros, which would make the build non-deterministic 625KBUILD_CFLAGS += $(call cc-option,-Werror=date-time) 626 627include scripts/Makefile.extrawarn 628 629# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments 630KBUILD_CPPFLAGS += $(KCPPFLAGS) 631KBUILD_AFLAGS += $(KAFLAGS) 632KBUILD_CFLAGS += $(KCFLAGS) 633 634# Use UBOOTINCLUDE when you must reference the include/ directory. 635# Needed to be compatible with the O= option 636UBOOTINCLUDE := \ 637 -Iinclude \ 638 $(if $(KBUILD_SRC), -I$(srctree)/include) \ 639 $(if $(CONFIG_$(SPL_)SYS_THUMB_BUILD), \ 640 $(if $(CONFIG_HAS_THUMB2),, \ 641 -I$(srctree)/arch/$(ARCH)/thumb1/include),) \ 642 -I$(srctree)/arch/$(ARCH)/include \ 643 -include $(srctree)/include/linux/kconfig.h 644 645NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) 646CHECKFLAGS += $(NOSTDINC_FLAGS) 647 648# FIX ME 649cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \ 650 $(NOSTDINC_FLAGS) 651c_flags := $(KBUILD_CFLAGS) $(cpp_flags) 652 653######################################################################### 654# U-Boot objects....order is important (i.e. start must be first) 655 656HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n) 657 658libs-y += lib/ 659libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/ 660libs-$(CONFIG_OF_EMBED) += dts/ 661ifneq ($(CONFIG_SPL_BUILD)$(CONFIG_SPL_DECOMP_HEADER),yy) 662libs-y += fs/ 663libs-y += net/ 664libs-y += disk/ 665libs-y += drivers/ 666libs-y += drivers/cpu/ 667libs-y += drivers/dma/ 668libs-y += drivers/gpio/ 669libs-y += drivers/i2c/ 670libs-y += drivers/mtd/ 671libs-$(CONFIG_CMD_NAND) += drivers/mtd/nand/raw/ 672libs-y += drivers/mtd/onenand/ 673libs-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/ 674libs-y += drivers/mtd/spi/ 675libs-y += drivers/net/ 676libs-y += drivers/net/phy/ 677libs-y += drivers/pci/ 678libs-y += drivers/power/ \ 679 drivers/power/domain/ \ 680 drivers/power/fuel_gauge/ \ 681 drivers/power/mfd/ \ 682 drivers/power/pmic/ \ 683 drivers/power/battery/ \ 684 drivers/power/regulator/ \ 685 drivers/power/dvfs/ \ 686 drivers/power/io-domain/ \ 687 drivers/power/charge/ 688libs-y += drivers/spi/ 689libs-$(CONFIG_FMAN_ENET) += drivers/net/fm/ 690libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/ 691libs-$(CONFIG_SYS_FSL_MMDC) += drivers/ddr/fsl/ 692libs-$(CONFIG_ALTERA_SDRAM) += drivers/ddr/altera/ 693libs-y += drivers/serial/ 694libs-y += drivers/usb/cdns3/ 695libs-y += drivers/usb/dwc3/ 696libs-y += drivers/usb/common/ 697libs-y += drivers/usb/emul/ 698libs-y += drivers/usb/eth/ 699libs-y += drivers/usb/gadget/ 700libs-y += drivers/usb/gadget/udc/ 701libs-y += drivers/usb/host/ 702libs-y += drivers/usb/musb/ 703libs-y += drivers/usb/musb-new/ 704libs-y += drivers/usb/phy/ 705libs-y += drivers/usb/ulpi/ 706libs-y += cmd/ 707libs-y += common/ 708libs-y += env/ 709libs-$(CONFIG_API) += api/ 710libs-$(CONFIG_HAS_POST) += post/ 711endif 712libs-y += test/ 713libs-y += test/dm/ 714libs-$(CONFIG_UT_ENV) += test/env/ 715libs-$(CONFIG_UT_OVERLAY) += test/overlay/ 716 717libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/) 718 719libs-y := $(sort $(libs-y)) 720 721u-boot-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) tools examples 722 723u-boot-alldirs := $(sort $(u-boot-dirs) $(patsubst %/,%,$(filter %/, $(libs-)))) 724 725libs-y := $(patsubst %/, %/built-in.o, $(libs-y)) 726 727u-boot-init := $(head-y) 728u-boot-main := $(libs-y) 729 730 731# Add GCC lib 732ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y) 733PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a 734else 735PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`) -lgcc 736endif 737PLATFORM_LIBS += $(PLATFORM_LIBGCC) 738export PLATFORM_LIBS 739export PLATFORM_LIBGCC 740 741# Special flags for CPP when processing the linker script. 742# Pass the version down so we can handle backwards compatibility 743# on the fly. 744LDPPFLAGS += \ 745 -include $(srctree)/include/u-boot/u-boot.lds.h \ 746 -DCPUDIR=$(CPUDIR) \ 747 $(shell $(LD) --version | \ 748 sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p') 749 750######################################################################### 751######################################################################### 752 753ifneq ($(CONFIG_BOARD_SIZE_LIMIT),) 754BOARD_SIZE_CHECK = \ 755 @actual=`wc -c $@ | awk '{print $$1}'`; \ 756 limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \ 757 if test $$actual -gt $$limit; then \ 758 echo "$@ exceeds file size limit:" >&2 ; \ 759 echo " limit: $$limit bytes" >&2 ; \ 760 echo " actual: $$actual bytes" >&2 ; \ 761 echo " excess: $$((actual - limit)) bytes" >&2; \ 762 exit 1; \ 763 fi 764else 765BOARD_SIZE_CHECK = 766endif 767 768# Statically apply RELA-style relocations (currently arm64 only) 769# This is useful for arm64 where static relocation needs to be performed on 770# the raw binary, but certain simulators only accept an ELF file (but don't 771# do the relocation). 772ifneq ($(CONFIG_STATIC_RELA),) 773# $(1) is u-boot ELF, $(2) is u-boot bin, $(3) is text base 774DO_STATIC_RELA = \ 775 start=$$($(NM) $(1) | grep __rel_dyn_start | cut -f 1 -d ' '); \ 776 end=$$($(NM) $(1) | grep __rel_dyn_end | cut -f 1 -d ' '); \ 777 tools/relocate-rela $(2) $(3) $$start $$end 778else 779DO_STATIC_RELA = 780endif 781 782# Always append ALL so that arch config.mk's can add custom ones 783ALL-y += u-boot.srec u-boot.bin u-boot.sym System.map binary_size_check 784ALL-$(CONFIG_SUPPORT_USBPLUG) += usbplug.bin 785 786ALL-$(CONFIG_ONENAND_U_BOOT) += u-boot-onenand.bin 787ifeq ($(CONFIG_SPL_FSL_PBL),y) 788ALL-$(CONFIG_RAMBOOT_PBL) += u-boot-with-spl-pbl.bin 789else 790ifneq ($(CONFIG_SECURE_BOOT), y) 791# For Secure Boot The Image needs to be signed and Header must also 792# be included. So The image has to be built explicitly 793ALL-$(CONFIG_RAMBOOT_PBL) += u-boot.pbl 794endif 795endif 796ALL-$(CONFIG_SPL) += spl/u-boot-spl.bin 797ifeq ($(CONFIG_MX6)$(CONFIG_SECURE_BOOT), yy) 798ALL-$(CONFIG_SPL_FRAMEWORK) += u-boot-ivt.img 799else 800ALL-$(CONFIG_SPL_FRAMEWORK) += u-boot.img 801endif 802ALL-$(CONFIG_TPL) += tpl/u-boot-tpl.bin 803ALL-$(CONFIG_OF_SEPARATE) += u-boot.dtb 804ifeq ($(CONFIG_SPL_FRAMEWORK),y) 805ALL-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img 806endif 807ALL-$(CONFIG_OF_HOSTFILE) += u-boot.dtb 808ifneq ($(CONFIG_SPL_TARGET),) 809ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%) 810endif 811ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf 812ALL-$(CONFIG_EFI_APP) += u-boot-app.efi 813ALL-$(CONFIG_EFI_STUB) += u-boot-payload.efi 814 815ifneq ($(BUILD_ROM),) 816ALL-$(CONFIG_X86_RESET_VECTOR) += u-boot.rom 817endif 818 819# enable combined SPL/u-boot/dtb rules for tegra 820ifeq ($(CONFIG_TEGRA)$(CONFIG_SPL),yy) 821ALL-y += u-boot-tegra.bin u-boot-nodtb-tegra.bin 822ALL-$(CONFIG_OF_SEPARATE) += u-boot-dtb-tegra.bin 823endif 824 825# Add optional build target if defined in board/cpu/soc headers 826ifneq ($(CONFIG_BUILD_TARGET),) 827ALL-y += $(CONFIG_BUILD_TARGET:"%"=%) 828endif 829 830LDFLAGS_u-boot += $(LDFLAGS_FINAL) 831 832# Avoid 'Not enough room for program headers' error on binutils 2.28 onwards. 833LDFLAGS_u-boot += $(call ld-option, --no-dynamic-linker) 834 835ifneq ($(CONFIG_SYS_TEXT_BASE),) 836LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE) 837endif 838 839# Normally we fill empty space with 0xff 840quiet_cmd_objcopy = OBJCOPY $@ 841cmd_objcopy = $(OBJCOPY) --gap-fill=0xff $(OBJCOPYFLAGS) \ 842 $(OBJCOPYFLAGS_$(@F)) $< $@ 843 844# Provide a version which does not do this, for use by EFI 845quiet_cmd_zobjcopy = OBJCOPY $@ 846cmd_zobjcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ 847 848quiet_cmd_efipayload = OBJCOPY $@ 849cmd_efipayload = $(OBJCOPY) -I binary -O $(EFIPAYLOAD_BFDTARGET) -B $(EFIPAYLOAD_BFDARCH) $< $@ 850 851MKIMAGEOUTPUT ?= /dev/null 852 853quiet_cmd_mkimage = MKIMAGE $@ 854cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \ 855 $(if $(KBUILD_VERBOSE:1=), >$(MKIMAGEOUTPUT)) 856 857quiet_cmd_mkfitimage = MKIMAGE $@ 858cmd_mkfitimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -f $(U_BOOT_ITS) -E $@ \ 859 $(if $(KBUILD_VERBOSE:1=), >$(MKIMAGEOUTPUT)) 860 861quiet_cmd_cat = CAT $@ 862cmd_cat = cat $(filter-out $(PHONY), $^) > $@ 863 864append = cat $(filter-out $< $(PHONY), $^) >> $@ 865 866quiet_cmd_pad_cat = CAT $@ 867cmd_pad_cat = $(cmd_objcopy) && $(append) || rm -f $@ 868 869cfg: u-boot.cfg 870 871quiet_cmd_cfgcheck = CFGCHK $2 872cmd_cfgcheck = $(srctree)/scripts/check-config.sh $2 \ 873 $(srctree)/scripts/config_whitelist.txt $(srctree) 874 875all: $(ALL-y) cfg 876ifeq ($(CONFIG_DM_I2C_COMPAT)$(CONFIG_SANDBOX),y) 877 @echo "===================== WARNING ======================" 878 @echo "This board uses CONFIG_DM_I2C_COMPAT. Please remove" 879 @echo "(possibly in a subsequent patch in your series)" 880 @echo "before sending patches to the mailing list." 881 @echo "====================================================" 882endif 883 @# Check that this build does not use CONFIG options that we do not 884 @# know about unless they are in Kconfig. All the existing CONFIG 885 @# options are whitelisted, so new ones should not be added. 886 $(call cmd,cfgcheck,u-boot.cfg) 887 888PHONY += dtbs 889dtbs: dts/dt.dtb 890 @: 891dts/dt.dtb: u-boot 892 $(Q)$(MAKE) $(build)=dts dtbs 893 894quiet_cmd_copy = COPY $@ 895 cmd_copy = cp $< $@ 896 897quiet_cmd_truncate = ALIGN $@ 898 cmd_truncate = truncate -s "%8" $@ 899 900ifeq ($(CONFIG_MULTI_DTB_FIT),y) 901 902fit-dtb.blob: dts/dt.dtb FORCE 903 $(call if_changed,mkimage) 904 905MKIMAGEFLAGS_fit-dtb.blob = -f auto -A $(ARCH) -T firmware -C none -O u-boot \ 906 -a 0 -e 0 -E \ 907 $(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) -d /dev/null 908 909u-boot-fit-dtb.bin: u-boot-nodtb.bin fit-dtb.blob 910 $(call if_changed,cat) 911 912u-boot.bin: u-boot-fit-dtb.bin FORCE 913 $(call if_changed,copy) 914else ifeq ($(CONFIG_OF_SEPARATE),y) 915 916u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE 917 $(call if_changed,cat) 918 919EMBED_KERN_DTB := $(CONFIG_EMBED_KERNEL_DTB_PATH:"%"=%) 920ifneq ($(wildcard $(EMBED_KERN_DTB)),) 921u-boot-dtb-kern.bin: u-boot-dtb.bin FORCE 922 $(call if_changed,copy) 923 $(call if_changed,truncate) 924u-boot.bin: u-boot-dtb-kern.bin $(EMBED_KERN_DTB) FORCE 925 $(call if_changed,cat) 926else 927u-boot.bin: u-boot-dtb.bin FORCE 928 $(call if_changed,copy) 929 $(call if_changed,truncate) 930endif 931 932else 933u-boot.bin: u-boot-nodtb.bin FORCE 934 $(call if_changed,copy) 935endif 936 937ifeq ($(CONFIG_SUPPORT_USBPLUG),y) 938usbplug.bin: u-boot.bin 939 $(call if_changed,copy) 940endif 941 942%.imx: %.bin 943 $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@ 944 945%.vyb: %.imx 946 $(Q)$(MAKE) $(build)=arch/arm/cpu/armv7/vf610 $@ 947 948quiet_cmd_copy = COPY $@ 949 cmd_copy = cp $< $@ 950 951u-boot.dtb: dts/dt.dtb FORCE 952 $(call cmd,copy) 953 954OBJCOPYFLAGS_u-boot.hex := -O ihex 955 956OBJCOPYFLAGS_u-boot.srec := -O srec 957 958u-boot.hex u-boot.srec: u-boot FORCE 959 $(call if_changed,objcopy) 960 961OBJCOPYFLAGS_u-boot-nodtb.bin := -O binary \ 962 $(if $(CONFIG_X86_16BIT_INIT),-R .start16 -R .resetvec) 963 964binary_size_check: u-boot-nodtb.bin FORCE 965 @file_size=$(shell wc -c u-boot-nodtb.bin | awk '{print $$1}') ; \ 966 map_size=$(shell cat u-boot.map | \ 967 awk '/_image_copy_start/ {start = $$1} /_image_binary_end/ {end = $$1} END {if (start != "" && end != "") print "ibase=16; " toupper(end) " - " toupper(start)}' \ 968 | sed 's/0X//g' \ 969 | bc); \ 970 if [ "" != "$$map_size" ]; then \ 971 if test $$map_size -ne $$file_size; then \ 972 echo "u-boot.map shows a binary size of $$map_size" >&2 ; \ 973 echo " but u-boot-nodtb.bin shows $$file_size" >&2 ; \ 974 exit 1; \ 975 fi \ 976 fi 977 978u-boot-nodtb.bin: u-boot FORCE 979 $(call if_changed,objcopy) 980 $(call DO_STATIC_RELA,$<,$@,$(CONFIG_SYS_TEXT_BASE)) 981 $(BOARD_SIZE_CHECK) 982 983u-boot.ldr: u-boot 984 $(CREATE_LDR_ENV) 985 $(LDR) -T $(CONFIG_CPU) -c $@ $< $(LDR_FLAGS) 986 $(BOARD_SIZE_CHECK) 987 988# binman 989# --------------------------------------------------------------------------- 990quiet_cmd_binman = BINMAN $@ 991cmd_binman = $(srctree)/tools/binman/binman -d u-boot.dtb -O . \ 992 -I . -I $(srctree)/board/$(BOARDDIR) $< 993 994OBJCOPYFLAGS_u-boot.ldr.hex := -I binary -O ihex 995 996OBJCOPYFLAGS_u-boot.ldr.srec := -I binary -O srec 997 998u-boot.ldr.hex u-boot.ldr.srec: u-boot.ldr FORCE 999 $(call if_changed,objcopy) 1000 1001# 1002# U-Boot entry point, needed for booting of full-blown U-Boot 1003# from the SPL U-Boot version. 1004# 1005ifndef CONFIG_SYS_UBOOT_START 1006CONFIG_SYS_UBOOT_START := 0 1007endif 1008 1009# Create a file containing the configuration options the image was built with 1010quiet_cmd_cpp_cfg = CFG $@ 1011cmd_cpp_cfg = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \ 1012 -DDO_DEPS_ONLY -D__ASSEMBLY__ -x assembler-with-cpp -P -dM -E -o $@ $< 1013 1014# Boards with more complex image requirments can provide an .its source file 1015# or a generator script 1016ifneq ($(CONFIG_SPL_FIT_SOURCE),"") 1017U_BOOT_ITS = $(subst ",,$(CONFIG_SPL_FIT_SOURCE)) 1018else 1019ifneq ($(CONFIG_SPL_FIT_GENERATOR),"") 1020U_BOOT_ITS := u-boot.its 1021$(U_BOOT_ITS): FORCE 1022 $(srctree)/$(CONFIG_SPL_FIT_GENERATOR) \ 1023 $(patsubst %,arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) > $@ 1024endif 1025endif 1026 1027ifdef CONFIG_SPL_LOAD_FIT 1028MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T firmware -C none -O u-boot \ 1029 -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \ 1030 -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \ 1031 $(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) 1032else 1033MKIMAGEFLAGS_u-boot.img = -A $(ARCH) -T firmware -C none -O u-boot \ 1034 -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \ 1035 -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" 1036MKIMAGEFLAGS_u-boot-ivt.img = -A $(ARCH) -T firmware_ivt -C none -O u-boot \ 1037 -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \ 1038 -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" 1039u-boot-ivt.img: MKIMAGEOUTPUT = u-boot-ivt.img.log 1040CLEAN_FILES += u-boot-ivt.img.log u-boot-dtb.imx.log SPL.log u-boot.imx.log 1041endif 1042 1043MKIMAGEFLAGS_u-boot-dtb.img = $(MKIMAGEFLAGS_u-boot.img) 1044 1045MKIMAGEFLAGS_u-boot.kwb = -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) \ 1046 -T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) 1047 1048MKIMAGEFLAGS_u-boot-spl.kwb = -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) \ 1049 -T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) \ 1050 $(if $(KEYDIR),-k $(KEYDIR)) 1051 1052MKIMAGEFLAGS_u-boot.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \ 1053 -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimage 1054 1055u-boot-dtb.img u-boot.img u-boot.kwb u-boot.pbl u-boot-ivt.img: \ 1056 $(if $(CONFIG_SPL_LOAD_FIT),u-boot-nodtb.bin dts/dt.dtb,u-boot.bin) FORCE 1057 $(call if_changed,mkimage) 1058 1059u-boot.itb: u-boot-nodtb.bin dts/dt.dtb $(U_BOOT_ITS) FORCE 1060 $(call if_changed,mkfitimage) 1061 1062u-boot-spl.kwb: u-boot.img spl/u-boot-spl.bin FORCE 1063 $(call if_changed,mkimage) 1064 1065u-boot.sha1: u-boot.bin 1066 tools/ubsha1 u-boot.bin 1067 1068u-boot.dis: u-boot 1069 $(OBJDUMP) -d $< > $@ 1070 1071ifdef CONFIG_TPL 1072SPL_PAYLOAD := tpl/u-boot-with-tpl.bin 1073else 1074SPL_PAYLOAD := u-boot.bin 1075endif 1076 1077OBJCOPYFLAGS_u-boot-with-spl.bin = -I binary -O binary \ 1078 --pad-to=$(CONFIG_SPL_PAD_TO) 1079u-boot-with-spl.bin: spl/u-boot-spl.bin $(SPL_PAYLOAD) FORCE 1080 $(call if_changed,pad_cat) 1081 1082MKIMAGEFLAGS_lpc32xx-spl.img = -T lpc32xximage -a $(CONFIG_SPL_TEXT_BASE) 1083 1084lpc32xx-spl.img: spl/u-boot-spl.bin FORCE 1085 $(call if_changed,mkimage) 1086 1087OBJCOPYFLAGS_lpc32xx-boot-0.bin = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) 1088 1089lpc32xx-boot-0.bin: lpc32xx-spl.img FORCE 1090 $(call if_changed,objcopy) 1091 1092OBJCOPYFLAGS_lpc32xx-boot-1.bin = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) 1093 1094lpc32xx-boot-1.bin: lpc32xx-spl.img FORCE 1095 $(call if_changed,objcopy) 1096 1097lpc32xx-full.bin: lpc32xx-boot-0.bin lpc32xx-boot-1.bin u-boot.img FORCE 1098 $(call if_changed,cat) 1099 1100CLEAN_FILES += lpc32xx-* 1101 1102OBJCOPYFLAGS_u-boot-with-tpl.bin = -I binary -O binary \ 1103 --pad-to=$(CONFIG_TPL_PAD_TO) 1104tpl/u-boot-with-tpl.bin: tpl/u-boot-tpl.bin u-boot.bin FORCE 1105 $(call if_changed,pad_cat) 1106 1107SPL: spl/u-boot-spl.bin FORCE 1108 $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@ 1109 1110u-boot-with-spl.imx u-boot-with-nand-spl.imx: SPL u-boot.bin FORCE 1111 $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@ 1112 1113MKIMAGEFLAGS_u-boot.ubl = -n $(UBL_CONFIG) -T ublimage -e $(CONFIG_SYS_TEXT_BASE) 1114 1115u-boot.ubl: u-boot-with-spl.bin FORCE 1116 $(call if_changed,mkimage) 1117 1118MKIMAGEFLAGS_u-boot-spl.ais = -s -n $(if $(CONFIG_AIS_CONFIG_FILE), \ 1119 $(srctree)/$(CONFIG_AIS_CONFIG_FILE:"%"=%),"/dev/null") \ 1120 -T aisimage -e $(CONFIG_SPL_TEXT_BASE) 1121spl/u-boot-spl.ais: spl/u-boot-spl.bin FORCE 1122 $(call if_changed,mkimage) 1123 1124OBJCOPYFLAGS_u-boot.ais = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) 1125u-boot.ais: spl/u-boot-spl.ais u-boot.img FORCE 1126 $(call if_changed,pad_cat) 1127 1128u-boot-signed.sb: u-boot.bin spl/u-boot-spl.bin 1129 $(Q)$(MAKE) $(build)=arch/arm/cpu/arm926ejs/mxs u-boot-signed.sb 1130u-boot.sb: u-boot.bin spl/u-boot-spl.bin 1131 $(Q)$(MAKE) $(build)=arch/arm/cpu/arm926ejs/mxs u-boot.sb 1132 1133# On x600 (SPEAr600) U-Boot is appended to U-Boot SPL. 1134# Both images are created using mkimage (crc etc), so that the ROM 1135# bootloader can check its integrity. Padding needs to be done to the 1136# SPL image (with mkimage header) and not the binary. Otherwise the resulting image 1137# which is loaded/copied by the ROM bootloader to SRAM doesn't fit. 1138# The resulting image containing both U-Boot images is called u-boot.spr 1139MKIMAGEFLAGS_u-boot-spl.img = -A $(ARCH) -T firmware -C none \ 1140 -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER 1141spl/u-boot-spl.img: spl/u-boot-spl.bin FORCE 1142 $(call if_changed,mkimage) 1143 1144OBJCOPYFLAGS_u-boot.spr = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) \ 1145 --gap-fill=0xff 1146u-boot.spr: spl/u-boot-spl.img u-boot.img FORCE 1147 $(call if_changed,pad_cat) 1148 1149ifneq ($(CONFIG_ARCH_SOCFPGA),) 1150quiet_cmd_socboot = SOCBOOT $@ 1151cmd_socboot = cat spl/u-boot-spl.sfp spl/u-boot-spl.sfp \ 1152 spl/u-boot-spl.sfp spl/u-boot-spl.sfp \ 1153 u-boot.img > $@ || rm -f $@ 1154u-boot-with-spl.sfp: spl/u-boot-spl.sfp u-boot.img FORCE 1155 $(call if_changed,socboot) 1156endif 1157 1158# x86 uses a large ROM. We fill it with 0xff, put the 16-bit stuff (including 1159# reset vector) at the top, Intel ME descriptor at the bottom, and U-Boot in 1160# the middle. This is handled by binman based on an image description in the 1161# board's device tree. 1162ifneq ($(CONFIG_X86_RESET_VECTOR),) 1163rom: u-boot.rom FORCE 1164 1165refcode.bin: $(srctree)/board/$(BOARDDIR)/refcode.bin FORCE 1166 $(call if_changed,copy) 1167 1168quiet_cmd_ldr = LD $@ 1169cmd_ldr = $(LD) $(LDFLAGS_$(@F)) \ 1170 $(filter-out FORCE,$^) -o $@ 1171 1172u-boot.rom: u-boot-x86-16bit.bin u-boot.bin \ 1173 $(if $(CONFIG_SPL_X86_16BIT_INIT),spl/u-boot-spl.bin) \ 1174 $(if $(CONFIG_HAVE_REFCODE),refcode.bin) FORCE 1175 $(call if_changed,binman) 1176 1177OBJCOPYFLAGS_u-boot-x86-16bit.bin := -O binary -j .start16 -j .resetvec 1178u-boot-x86-16bit.bin: u-boot FORCE 1179 $(call if_changed,objcopy) 1180endif 1181 1182ifneq ($(CONFIG_ARCH_SUNXI),) 1183u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.img u-boot.dtb FORCE 1184 $(call if_changed,binman) 1185endif 1186 1187ifneq ($(CONFIG_TEGRA),) 1188OBJCOPYFLAGS_u-boot-nodtb-tegra.bin = -O binary --pad-to=$(CONFIG_SYS_TEXT_BASE) 1189u-boot-nodtb-tegra.bin: spl/u-boot-spl u-boot-nodtb.bin FORCE 1190 $(call if_changed,pad_cat) 1191 1192OBJCOPYFLAGS_u-boot-tegra.bin = -O binary --pad-to=$(CONFIG_SYS_TEXT_BASE) 1193u-boot-tegra.bin: spl/u-boot-spl u-boot.bin FORCE 1194 $(call if_changed,pad_cat) 1195 1196u-boot-dtb-tegra.bin: u-boot-tegra.bin FORCE 1197 $(call if_changed,copy) 1198endif 1199 1200OBJCOPYFLAGS_u-boot-app.efi := $(OBJCOPYFLAGS_EFI) 1201u-boot-app.efi: u-boot FORCE 1202 $(call if_changed,zobjcopy) 1203 1204u-boot.bin.o: u-boot.bin FORCE 1205 $(call if_changed,efipayload) 1206 1207u-boot-payload.lds: $(LDSCRIPT_EFI) FORCE 1208 $(call if_changed_dep,cpp_lds) 1209 1210# Rule to link the EFI payload which contains a stub and a U-Boot binary 1211quiet_cmd_u-boot_payload ?= LD $@ 1212 cmd_u-boot_payload ?= $(LD) $(LDFLAGS_EFI_PAYLOAD) -o $@ \ 1213 -T u-boot-payload.lds arch/x86/cpu/call32.o \ 1214 lib/efi/efi.o lib/efi/efi_stub.o u-boot.bin.o \ 1215 $(addprefix arch/$(ARCH)/lib/,$(EFISTUB)) 1216 1217u-boot-payload: u-boot.bin.o u-boot-payload.lds FORCE 1218 $(call if_changed,u-boot_payload) 1219 1220OBJCOPYFLAGS_u-boot-payload.efi := $(OBJCOPYFLAGS_EFI) 1221u-boot-payload.efi: u-boot-payload FORCE 1222 $(call if_changed,zobjcopy) 1223 1224u-boot-img.bin: spl/u-boot-spl.bin u-boot.img FORCE 1225 $(call if_changed,cat) 1226 1227#Add a target to create boot binary having SPL binary in PBI format 1228#concatenated with u-boot binary. It is need by PowerPC SoC having 1229#internal SRAM <= 512KB. 1230MKIMAGEFLAGS_u-boot-spl.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \ 1231 -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimage \ 1232 -A $(ARCH) -a $(CONFIG_SPL_TEXT_BASE) 1233 1234spl/u-boot-spl.pbl: spl/u-boot-spl.bin FORCE 1235 $(call if_changed,mkimage) 1236 1237ifeq ($(ARCH),arm) 1238UBOOT_BINLOAD := u-boot.img 1239else 1240UBOOT_BINLOAD := u-boot.bin 1241endif 1242 1243OBJCOPYFLAGS_u-boot-with-spl-pbl.bin = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) \ 1244 --gap-fill=0xff 1245 1246u-boot-with-spl-pbl.bin: spl/u-boot-spl.pbl $(UBOOT_BINLOAD) FORCE 1247 $(call if_changed,pad_cat) 1248 1249# PPC4xx needs the SPL at the end of the image, since the reset vector 1250# is located at 0xfffffffc. So we can't use the "u-boot-img.bin" target 1251# and need to introduce a new build target with the full blown U-Boot 1252# at the start padded up to the start of the SPL image. And then concat 1253# the SPL image to the end. 1254 1255OBJCOPYFLAGS_u-boot-img-spl-at-end.bin := -I binary -O binary \ 1256 --pad-to=$(CONFIG_UBOOT_PAD_TO) --gap-fill=0xff 1257u-boot-img-spl-at-end.bin: u-boot.img spl/u-boot-spl.bin FORCE 1258 $(call if_changed,pad_cat) 1259 1260# Create a new ELF from a raw binary file. 1261ifndef PLATFORM_ELFENTRY 1262 PLATFORM_ELFENTRY = "_start" 1263endif 1264quiet_cmd_u-boot-elf ?= LD $@ 1265 cmd_u-boot-elf ?= $(LD) u-boot-elf.o -o $@ \ 1266 --defsym=$(PLATFORM_ELFENTRY)=$(CONFIG_SYS_TEXT_BASE) \ 1267 -Ttext=$(CONFIG_SYS_TEXT_BASE) 1268u-boot.elf: u-boot.bin 1269 $(Q)$(OBJCOPY) -I binary $(PLATFORM_ELFFLAGS) $< u-boot-elf.o 1270 $(call if_changed,u-boot-elf) 1271 1272ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(ARCH)/Makefile.postlink) 1273 1274# Rule to link u-boot 1275# May be overridden by arch/$(ARCH)/config.mk 1276quiet_cmd_u-boot__ ?= LD $@ 1277 cmd_u-boot__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_u-boot) -o $@ \ 1278 -T u-boot.lds $(u-boot-init) \ 1279 --start-group $(u-boot-main) --end-group \ 1280 $(PLATFORM_LIBS) -Map u-boot.map; \ 1281 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) 1282 1283quiet_cmd_smap = GEN common/system_map.o 1284cmd_smap = \ 1285 smap=`$(call SYSTEM_MAP,u-boot) | \ 1286 awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \ 1287 $(CC) $(c_flags) -DSYSTEM_MAP="\"$${smap}\"" \ 1288 -c $(srctree)/common/system_map.c -o common/system_map.o 1289 1290u-boot: $(u-boot-init) $(u-boot-main) u-boot.lds FORCE 1291 +$(call if_changed,u-boot__) 1292ifeq ($(CONFIG_KALLSYMS),y) 1293 $(call cmd,smap) 1294 $(call cmd,u-boot__) common/system_map.o 1295endif 1296 1297quiet_cmd_sym ?= SYM $@ 1298 cmd_sym ?= $(OBJDUMP) -t $< > $@ 1299u-boot.sym: u-boot FORCE 1300 $(call if_changed,sym) 1301 1302# The actual objects are generated when descending, 1303# make sure no implicit rule kicks in 1304$(sort $(u-boot-init) $(u-boot-main)): $(u-boot-dirs) ; 1305 1306# Handle descending into subdirectories listed in $(vmlinux-dirs) 1307# Preset locale variables to speed up the build process. Limit locale 1308# tweaks to this spot to avoid wrong language settings when running 1309# make menuconfig etc. 1310# Error messages still appears in the original language 1311 1312PHONY += $(u-boot-dirs) 1313$(u-boot-dirs): prepare scripts 1314 $(Q)$(MAKE) $(build)=$@ 1315 1316tools: prepare 1317# The "tools" are needed early 1318$(filter-out tools, $(u-boot-dirs)): tools 1319# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC 1320# is "yes"), so compile examples after U-Boot is compiled. 1321examples: $(filter-out examples, $(u-boot-dirs)) 1322 1323define filechk_uboot.release 1324 echo "$(UBOOTVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" 1325endef 1326 1327# Store (new) UBOOTRELEASE string in include/config/uboot.release 1328include/config/uboot.release: include/config/auto.conf FORCE 1329 $(call filechk,uboot.release) 1330 1331 1332# Things we need to do before we recursively start building the kernel 1333# or the modules are listed in "prepare". 1334# A multi level approach is used. prepareN is processed before prepareN-1. 1335# archprepare is used in arch Makefiles and when processed asm symlink, 1336# version.h and scripts_basic is processed / created. 1337 1338# Listed in dependency order 1339PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3 1340 1341# prepare3 is used to check if we are building in a separate output directory, 1342# and if so do: 1343# 1) Check that make has not been executed in the kernel src $(srctree) 1344prepare3: include/config/uboot.release 1345ifneq ($(KBUILD_SRC),) 1346 @$(kecho) ' Using $(srctree) as source for U-Boot' 1347 $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \ 1348 echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \ 1349 echo >&2 " in the '$(srctree)' directory.";\ 1350 /bin/false; \ 1351 fi; 1352endif 1353 1354# prepare2 creates a makefile if using a separate output directory 1355prepare2: prepare3 outputmakefile 1356 1357prepare1: prepare2 $(version_h) $(timestamp_h) \ 1358 include/config/auto.conf 1359ifeq ($(wildcard $(LDSCRIPT)),) 1360 @echo >&2 " Could not find linker script." 1361 @/bin/false 1362endif 1363 1364archprepare: prepare1 scripts_basic 1365 1366prepare0: archprepare FORCE 1367 $(Q)$(MAKE) $(build)=. 1368 1369# All the preparing.. 1370prepare: prepare0 1371 1372# Generate some files 1373# --------------------------------------------------------------------------- 1374 1375ifeq ($(CONFIG_SUPPORT_USBPLUG),) 1376define filechk_version.h 1377 (echo \#define PLAIN_VERSION \"$(UBOOTRELEASE)\"; \ 1378 echo \#define U_BOOT_VERSION \"U-Boot \" PLAIN_VERSION; \ 1379 if [ -n "$(PLAT_SPL_FW_VERSION)" ]; then \ 1380 echo \#define BUILD_SPL_TAG \"$(PLAT_SPL_FW_VERSION)\"; \ 1381 fi; \ 1382 if [ -n "$(PLAT_FW_VERSION)" ]; then \ 1383 echo \#define BUILD_TAG \"$(PLAT_FW_VERSION)\"; \ 1384 fi; \ 1385 echo \#define CC_VERSION_STRING \"$$(LC_ALL=C $(CC) --version | head -n 1)\"; \ 1386 echo \#define LD_VERSION_STRING \"$$(LC_ALL=C $(LD) --version | head -n 1)\"; ) 1387endef 1388else 1389define filechk_version.h 1390 (echo \#define PLAIN_VERSION \"$(UBOOTRELEASE)\"; \ 1391 echo \#define U_BOOT_VERSION \"USB-PLUG \" PLAIN_VERSION; \ 1392 if [ -n "$(PLAT_SPL_FW_VERSION)" ]; then \ 1393 echo \#define BUILD_SPL_TAG \"$(PLAT_SPL_FW_VERSION)\"; \ 1394 fi; \ 1395 if [ -n "$(PLAT_FW_VERSION)" ]; then \ 1396 echo \#define BUILD_TAG \"$(PLAT_FW_VERSION)\"; \ 1397 fi; \ 1398 echo \#define CC_VERSION_STRING \"$$(LC_ALL=C $(CC) --version | head -n 1)\"; \ 1399 echo \#define LD_VERSION_STRING \"$$(LC_ALL=C $(LD) --version | head -n 1)\"; ) 1400endef 1401endif 1402 1403# The SOURCE_DATE_EPOCH mechanism requires a date that behaves like GNU date. 1404# The BSD date on the other hand behaves different and would produce errors 1405# with the misused '-d' switch. Respect that and search a working date with 1406# well known pre- and suffixes for the GNU variant of date. 1407define filechk_timestamp.h 1408 (if test -n "$${SOURCE_DATE_EPOCH}"; then \ 1409 SOURCE_DATE="@$${SOURCE_DATE_EPOCH}"; \ 1410 DATE=""; \ 1411 for date in gdate date.gnu date; do \ 1412 $${date} -u -d "$${SOURCE_DATE}" >/dev/null 2>&1 && DATE="$${date}"; \ 1413 done; \ 1414 if test -n "$${DATE}"; then \ 1415 LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_DATE "%b %d %C%y"'; \ 1416 LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_TIME "%T"'; \ 1417 LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_TZ "%z"'; \ 1418 LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_DMI_DATE "%m/%d/%Y"'; \ 1419 LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_BUILD_DATE 0x%Y%m%d'; \ 1420 else \ 1421 return 42; \ 1422 fi; \ 1423 else \ 1424 LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"'; \ 1425 LC_ALL=C date +'#define U_BOOT_TIME "%T"'; \ 1426 LC_ALL=C date +'#define U_BOOT_TZ "%z"'; \ 1427 LC_ALL=C date +'#define U_BOOT_DMI_DATE "%m/%d/%Y"'; \ 1428 LC_ALL=C date +'#define U_BOOT_BUILD_DATE 0x%Y%m%d'; \ 1429 fi) 1430endef 1431 1432$(version_h): include/config/uboot.release FORCE 1433 $(call filechk,version.h) 1434 1435$(timestamp_h): $(srctree)/Makefile FORCE 1436 $(call filechk,timestamp.h) 1437 1438# --------------------------------------------------------------------------- 1439quiet_cmd_cpp_lds = LDS $@ 1440cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) \ 1441 -D__ASSEMBLY__ -x assembler-with-cpp -P -o $@ $< 1442 1443u-boot.lds: $(LDSCRIPT) prepare FORCE 1444 $(call if_changed_dep,cpp_lds) 1445 1446spl/u-boot-spl.bin: spl/u-boot-spl 1447 @: 1448spl/u-boot-spl: tools prepare \ 1449 $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SPL_OF_PLATDATA),dts/dt.dtb) \ 1450 $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_TPL_OF_PLATDATA),dts/dt.dtb) 1451 $(Q)$(MAKE) obj=spl -f $(srctree)/scripts/Makefile.spl all 1452 1453spl/sunxi-spl.bin: spl/u-boot-spl 1454 @: 1455 1456spl/sunxi-spl-with-ecc.bin: spl/sunxi-spl.bin 1457 @: 1458 1459spl/u-boot-spl.sfp: spl/u-boot-spl 1460 @: 1461 1462spl/boot.bin: spl/u-boot-spl 1463 @: 1464 1465tpl/u-boot-tpl.bin: tools prepare \ 1466 $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SPL_OF_PLATDATA),dts/dt.dtb) 1467 $(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.spl all 1468 1469TAG_SUBDIRS := $(patsubst %,$(srctree)/%,$(u-boot-dirs) include) 1470 1471FIND := find 1472FINDFLAGS := -L 1473 1474tags ctags: 1475 ctags -w -o ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \ 1476 -name '*.[chS]' -print` 1477 ln -s ctags tags 1478 1479etags: 1480 etags -a -o etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \ 1481 -name '*.[chS]' -print` 1482cscope: 1483 $(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \ 1484 cscope.files 1485 cscope -b -q -k 1486 1487SYSTEM_MAP = \ 1488 $(NM) $1 | \ 1489 grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ 1490 LC_ALL=C sort 1491System.map: u-boot 1492 @$(call SYSTEM_MAP,$<) > $@ 1493 1494######################################################################### 1495 1496# ARM relocations should all be R_ARM_RELATIVE (32-bit) or 1497# R_AARCH64_RELATIVE (64-bit). 1498checkarmreloc: u-boot 1499 @RELOC="`$(CROSS_COMPILE)readelf -r -W $< | cut -d ' ' -f 4 | \ 1500 grep R_A | sort -u`"; \ 1501 if test "$$RELOC" != "R_ARM_RELATIVE" -a \ 1502 "$$RELOC" != "R_AARCH64_RELATIVE"; then \ 1503 echo "$< contains unexpected relocations: $$RELOC"; \ 1504 false; \ 1505 fi 1506 1507envtools: scripts_basic $(version_h) $(timestamp_h) 1508 $(Q)$(MAKE) $(build)=tools/env 1509 1510tools-only: scripts_basic $(version_h) $(timestamp_h) 1511 $(Q)$(MAKE) $(build)=tools 1512 1513tools-all: export HOST_TOOLS_ALL=y 1514tools-all: envtools tools ; 1515 1516cross_tools: export CROSS_BUILD_TOOLS=y 1517cross_tools: tools ; 1518 1519.PHONY : CHANGELOG 1520CHANGELOG: 1521 git log --no-merges U-Boot-1_1_5.. | \ 1522 unexpand -a | sed -e 's/\s\s*$$//' > $@ 1523 1524######################################################################### 1525 1526### 1527# Cleaning is done on three levels. 1528# make clean Delete most generated files 1529# Leave enough to build external modules 1530# make mrproper Delete the current configuration, and all generated files 1531# make distclean Remove editor backup files, patch leftover files and the like 1532 1533# Directories & files removed with 'make clean' 1534CLEAN_DIRS += $(MODVERDIR) \ 1535 $(foreach d, spl tpl, $(patsubst %,$d/%, \ 1536 $(filter-out include, $(shell ls -1 $d 2>/dev/null)))) 1537 1538CLEAN_FILES += include/bmp_logo.h include/bmp_logo_data.h \ 1539 boot* u-boot* MLO* SPL System.map fit-dtb.blob *.bin *.img *.gz .cc 1540 1541# Directories & files removed with 'make mrproper' 1542MRPROPER_DIRS += include/config include/generated spl tpl \ 1543 .tmp_objdiff 1544MRPROPER_FILES += .config .config.old include/autoconf.mk* include/config.h \ 1545 ctags etags tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS 1546 1547# clean - Delete most, but leave enough to build external modules 1548# 1549clean: rm-dirs := $(CLEAN_DIRS) 1550clean: rm-files := $(CLEAN_FILES) 1551 1552clean-dirs := $(foreach f,$(u-boot-alldirs),$(if $(wildcard $(srctree)/$f/Makefile),$f)) 1553 1554clean-dirs := $(addprefix _clean_, $(clean-dirs) doc/DocBook) 1555 1556PHONY += $(clean-dirs) clean archclean 1557$(clean-dirs): 1558 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) 1559 1560# TODO: Do not use *.cfgtmp 1561clean: $(clean-dirs) 1562 $(call cmd,rmdirs) 1563 $(call cmd,rmfiles) 1564 @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ 1565 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ 1566 -o -name '*.ko.*' -o -name '*.su' -o -name '*.cfgtmp' \ 1567 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ 1568 -o -name '*.symtypes' -o -name 'modules.order' \ 1569 -o -name modules.builtin -o -name '.tmp_*.o.*' \ 1570 -o -name 'dsdt.aml' -o -name 'dsdt.asl.tmp' -o -name 'dsdt.c' \ 1571 -o -name '*.gcno' \) -type f -print | xargs rm -f 1572 1573# mrproper - Delete all generated files, including .config 1574# 1575mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS)) 1576mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) 1577mrproper-dirs := $(addprefix _mrproper_,scripts) 1578 1579PHONY += $(mrproper-dirs) mrproper archmrproper 1580$(mrproper-dirs): 1581 $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) 1582 1583mrproper: clean $(mrproper-dirs) 1584 $(call cmd,rmdirs) 1585 $(call cmd,rmfiles) 1586 @rm -f arch/*/include/asm/arch 1587 1588# distclean 1589# 1590PHONY += distclean 1591 1592distclean: mrproper 1593 @find $(srctree) $(RCS_FIND_IGNORE) \ 1594 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ 1595 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ 1596 -o -name '.*.rej' -o -name '*%' -o -name 'core' \ 1597 -o -name '*.pyc' \) \ 1598 -type f -print | xargs rm -f 1599 @rm -f boards.cfg 1600 1601backup: 1602 F=`basename $(srctree)` ; cd .. ; \ 1603 gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F 1604 1605help: 1606 @echo 'Cleaning targets:' 1607 @echo ' clean - Remove most generated files but keep the config' 1608 @echo ' mrproper - Remove all generated files + config + various backup files' 1609 @echo ' distclean - mrproper + remove editor backup and patch files' 1610 @echo '' 1611 @echo 'Configuration targets:' 1612 @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help 1613 @echo '' 1614 @echo 'Other generic targets:' 1615 @echo ' all - Build all necessary images depending on configuration' 1616 @echo ' tests - Build U-Boot for sandbox and run tests' 1617 @echo '* u-boot - Build the bare u-boot' 1618 @echo ' dir/ - Build all files in dir and below' 1619 @echo ' dir/file.[oisS] - Build specified target only' 1620 @echo ' dir/file.lst - Build specified mixed source/assembly target only' 1621 @echo ' (requires a recent binutils and recent build (System.map))' 1622 @echo ' tags/ctags - Generate ctags file for editors' 1623 @echo ' etags - Generate etags file for editors' 1624 @echo ' cscope - Generate cscope index' 1625 @echo ' ubootrelease - Output the release version string (use with make -s)' 1626 @echo ' ubootversion - Output the version stored in Makefile (use with make -s)' 1627 @echo " cfg - Don't build, just create the .cfg files" 1628 @echo " envtools - Build only the target-side environment tools" 1629 @echo '' 1630 @echo 'Static analysers' 1631 @echo ' checkstack - Generate a list of stack hogs' 1632 @echo '' 1633 @echo 'Documentation targets:' 1634 @$(MAKE) -f $(srctree)/doc/DocBook/Makefile dochelp 1635 @echo '' 1636 @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' 1637 @echo ' make V=2 [targets] 2 => give reason for rebuild of target' 1638 @echo ' make O=dir [targets] Locate all output files in "dir", including .config' 1639 @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)' 1640 @echo ' make C=2 [targets] Force check of all c source with $$CHECK' 1641 @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections' 1642 @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where' 1643 @echo ' 1: warnings which may be relevant and do not occur too often' 1644 @echo ' 2: warnings which occur quite often but may still be relevant' 1645 @echo ' 3: more obscure warnings, can most likely be ignored' 1646 @echo ' Multiple levels can be combined with W=12 or W=123' 1647 @echo '' 1648 @echo 'Execute "make" or "make all" to build all targets marked with [*] ' 1649 @echo 'For further info see the ./README file' 1650 1651tests: 1652 $(srctree)/test/run 1653 1654# Documentation targets 1655# --------------------------------------------------------------------------- 1656%docs: scripts_basic FORCE 1657 $(Q)$(MAKE) $(build)=scripts build_docproc 1658 $(Q)$(MAKE) $(build)=doc/DocBook $@ 1659 1660endif #ifeq ($(config-targets),1) 1661endif #ifeq ($(mixed-targets),1) 1662 1663PHONY += checkstack ubootrelease ubootversion 1664 1665checkstack: 1666 $(OBJDUMP) -d u-boot $$(find . -name u-boot-spl) | \ 1667 $(PERL) $(src)/scripts/checkstack.pl $(ARCH) 1668 1669ubootrelease: 1670 @echo "$(UBOOTVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" 1671 1672ubootversion: 1673 @echo $(UBOOTVERSION) 1674 1675# Single targets 1676# --------------------------------------------------------------------------- 1677# Single targets are compatible with: 1678# - build with mixed source and output 1679# - build with separate output dir 'make O=...' 1680# - external modules 1681# 1682# target-dir => where to store outputfile 1683# build-dir => directory in kernel source tree to use 1684 1685ifeq ($(KBUILD_EXTMOD),) 1686 build-dir = $(patsubst %/,%,$(dir $@)) 1687 target-dir = $(dir $@) 1688else 1689 zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@))) 1690 build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash)) 1691 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@)) 1692endif 1693 1694%.s: %.c prepare scripts FORCE 1695 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1696%.i: %.c prepare scripts FORCE 1697 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1698%.o: %.c prepare scripts FORCE 1699 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1700%.lst: %.c prepare scripts FORCE 1701 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1702%.s: %.S prepare scripts FORCE 1703 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1704%.o: %.S prepare scripts FORCE 1705 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1706%.symtypes: %.c prepare scripts FORCE 1707 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1708 1709# Modules 1710/: prepare scripts FORCE 1711 $(cmd_crmodverdir) 1712 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1713 $(build)=$(build-dir) 1714%/: prepare scripts FORCE 1715 $(cmd_crmodverdir) 1716 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1717 $(build)=$(build-dir) 1718%.ko: prepare scripts FORCE 1719 $(cmd_crmodverdir) 1720 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1721 $(build)=$(build-dir) $(@:.ko=.o) 1722 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1723 1724quiet_cmd_genenv = GENENV $@ 1725cmd_genenv = $(OBJCOPY) --dump-section .rodata.default_environment=$@ env/common.o; \ 1726 sed --in-place -e 's/\x00/\x0A/g' $@ 1727 1728u-boot-initial-env: u-boot.bin 1729 $(call if_changed,genenv) 1730 1731# FIXME Should go into a make.lib or something 1732# =========================================================================== 1733 1734quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs))) 1735 cmd_rmdirs = rm -rf $(rm-dirs) 1736 1737quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) 1738 cmd_rmfiles = rm -f $(rm-files) 1739 1740# read all saved command lines 1741 1742targets := $(wildcard $(sort $(targets))) 1743cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) 1744 1745ifneq ($(cmd_files),) 1746 $(cmd_files): ; # Do not try to update included dependency files 1747 include $(cmd_files) 1748endif 1749 1750endif # skip-makefile 1751 1752PHONY += FORCE 1753FORCE: 1754 1755# Declare the contents of the .PHONY variable as phony. We keep that 1756# information in a variable so we can use it in if_changed and friends. 1757.PHONY: $(PHONY) 1758