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