1 9906090fSTom RiniVERSION = 2015 2 112db940STom RiniPATCHLEVEL = 04 3 211e4754SWolfgang DenkSUBLEVEL = 4 f33cdaa4STom RiniEXTRAVERSION = 5 5f30f3beSMasahiro YamadaNAME = 6 ae6d1056SWolfgang Denk 7 6825a95bSMasahiro Yamada# *DOCUMENTATION* 8 6825a95bSMasahiro Yamada# To see a list of typical targets execute "make help" 9 6825a95bSMasahiro Yamada# More info can be located in ./README 10 6825a95bSMasahiro Yamada# Comments in this file are targeted only to the developer, do not 11 6825a95bSMasahiro Yamada# expect to learn how to build the kernel reading this file. 12 6825a95bSMasahiro Yamada 13 ffe29ebcSMasahiro Yamada# Do not use make's built-in rules and variables 14 6825a95bSMasahiro Yamada# (this increases performance and avoids hard-to-debug behaviour); 15 ffe29ebcSMasahiro YamadaMAKEFLAGS += -rR 16 6825a95bSMasahiro Yamada 17 6825a95bSMasahiro Yamada# Avoid funny character set dependencies 18 6825a95bSMasahiro Yamadaunexport LC_ALL 19 6825a95bSMasahiro YamadaLC_COLLATE=C 20 6825a95bSMasahiro YamadaLC_NUMERIC=C 21 6825a95bSMasahiro Yamadaexport LC_COLLATE LC_NUMERIC 22 6825a95bSMasahiro Yamada 23 ffe29ebcSMasahiro Yamada# Avoid interference with shell env settings 24 ffe29ebcSMasahiro Yamadaunexport GREP_OPTIONS 25 ffe29ebcSMasahiro Yamada 26 6825a95bSMasahiro Yamada# We are using a recursive build, so we need to do a little thinking 27 6825a95bSMasahiro Yamada# to get the ordering right. 28 6825a95bSMasahiro Yamada# 29 6825a95bSMasahiro Yamada# Most importantly: sub-Makefiles should only ever modify files in 30 6825a95bSMasahiro Yamada# their own directory. If in some directory we have a dependency on 31 6825a95bSMasahiro Yamada# a file in another dir (which doesn't happen often, but it's often 32 6825a95bSMasahiro Yamada# unavoidable when linking the built-in.o targets which finally 33 6825a95bSMasahiro Yamada# turn into vmlinux), we will call a sub make in that other dir, and 34 6825a95bSMasahiro Yamada# after that we are sure that everything which is in that other dir 35 6825a95bSMasahiro Yamada# is now up to date. 36 6825a95bSMasahiro Yamada# 37 6825a95bSMasahiro Yamada# The only cases where we need to modify files which have global 38 6825a95bSMasahiro Yamada# effects are thus separated out and done before the recursive 39 6825a95bSMasahiro Yamada# descending is started. They are now explicitly listed as the 40 6825a95bSMasahiro Yamada# prepare rule. 41 6825a95bSMasahiro Yamada 42 ffe29ebcSMasahiro Yamada# Beautify output 43 ffe29ebcSMasahiro Yamada# --------------------------------------------------------------------------- 44 ffe29ebcSMasahiro Yamada# 45 ffe29ebcSMasahiro Yamada# Normally, we echo the whole command before executing it. By making 46 ffe29ebcSMasahiro Yamada# that echo $($(quiet)$(cmd)), we now have the possibility to set 47 ffe29ebcSMasahiro Yamada# $(quiet) to choose other forms of output instead, e.g. 48 ffe29ebcSMasahiro Yamada# 49 ffe29ebcSMasahiro Yamada# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ 50 ffe29ebcSMasahiro Yamada# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< 51 ffe29ebcSMasahiro Yamada# 52 ffe29ebcSMasahiro Yamada# If $(quiet) is empty, the whole command will be printed. 53 ffe29ebcSMasahiro Yamada# If it is set to "quiet_", only the short version will be printed. 54 ffe29ebcSMasahiro Yamada# If it is set to "silent_", nothing will be printed at all, since 55 ffe29ebcSMasahiro Yamada# the variable $(silent_cmd_cc_o_c) doesn't exist. 56 ffe29ebcSMasahiro Yamada# 57 ffe29ebcSMasahiro Yamada# A simple variant is to prefix commands with $(Q) - that's useful 58 ffe29ebcSMasahiro Yamada# for commands that shall be hidden in non-verbose mode. 59 ffe29ebcSMasahiro Yamada# 60 ffe29ebcSMasahiro Yamada# $(Q)ln $@ :< 61 ffe29ebcSMasahiro Yamada# 62 ffe29ebcSMasahiro Yamada# If KBUILD_VERBOSE equals 0 then the above command will be hidden. 63 ffe29ebcSMasahiro Yamada# If KBUILD_VERBOSE equals 1 then the above command is displayed. 64 ffe29ebcSMasahiro Yamada# 65 6825a95bSMasahiro Yamada# To put more focus on warnings, be less verbose as default 66 6825a95bSMasahiro Yamada# Use 'make V=1' to see the full commands 67 6825a95bSMasahiro Yamada 68 6825a95bSMasahiro Yamadaifeq ("$(origin V)", "command line") 69 6825a95bSMasahiro Yamada KBUILD_VERBOSE = $(V) 70 7ebf7443Swdenkendif 71 6825a95bSMasahiro Yamadaifndef KBUILD_VERBOSE 72 6825a95bSMasahiro Yamada KBUILD_VERBOSE = 0 73 6825a95bSMasahiro Yamadaendif 74 6825a95bSMasahiro Yamada 75 ffe29ebcSMasahiro Yamadaifeq ($(KBUILD_VERBOSE),1) 76 ffe29ebcSMasahiro Yamada quiet = 77 ffe29ebcSMasahiro Yamada Q = 78 ffe29ebcSMasahiro Yamadaelse 79 ffe29ebcSMasahiro Yamada quiet=quiet_ 80 ffe29ebcSMasahiro Yamada Q = @ 81 6825a95bSMasahiro Yamadaendif 82 6825a95bSMasahiro Yamada 83 ffe29ebcSMasahiro Yamada# If the user is running make -s (silent mode), suppress echoing of 84 ffe29ebcSMasahiro Yamada# commands 85 ffe29ebcSMasahiro Yamada 86 ffe29ebcSMasahiro Yamadaifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 87 ffe29ebcSMasahiro Yamadaifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) 88 ffe29ebcSMasahiro Yamada quiet=silent_ 89 ffe29ebcSMasahiro Yamadaendif 90 ffe29ebcSMasahiro Yamadaelse # make-3.8x 91 ffe29ebcSMasahiro Yamadaifneq ($(filter s% -s%,$(MAKEFLAGS)),) 92 ffe29ebcSMasahiro Yamada quiet=silent_ 93 ffe29ebcSMasahiro Yamadaendif 94 6825a95bSMasahiro Yamadaendif 95 6825a95bSMasahiro Yamada 96 ffe29ebcSMasahiro Yamadaexport quiet Q KBUILD_VERBOSE 97 6825a95bSMasahiro Yamada 98 9e414032SMasahiro Yamada# kbuild supports saving output files in a separate directory. 99 9e414032SMasahiro Yamada# To locate output files in a separate directory two syntaxes are supported. 100 9e414032SMasahiro Yamada# In both cases the working directory must be the root of the kernel src. 101 9e414032SMasahiro Yamada# 1) O= 102 9e414032SMasahiro Yamada# Use "make O=dir/to/store/output/files/" 103 f9328639SMarian Balakowicz# 104 9e414032SMasahiro Yamada# 2) Set KBUILD_OUTPUT 105 9e414032SMasahiro Yamada# Set the environment variable KBUILD_OUTPUT to point to the directory 106 9e414032SMasahiro Yamada# where the output files shall be placed. 107 9e414032SMasahiro Yamada# export KBUILD_OUTPUT=dir/to/store/output/files/ 108 9e414032SMasahiro Yamada# make 109 f9328639SMarian Balakowicz# 110 9e414032SMasahiro Yamada# The O= assignment takes precedence over the KBUILD_OUTPUT environment 111 9e414032SMasahiro Yamada# variable. 112 7ebf7443Swdenk 113 9e414032SMasahiro Yamada# KBUILD_SRC is set on invocation of make in OBJ directory 114 9e414032SMasahiro Yamada# KBUILD_SRC is not intended to be used by the regular user (for now) 115 9e414032SMasahiro Yamadaifeq ($(KBUILD_SRC),) 116 9e414032SMasahiro Yamada 117 9e414032SMasahiro Yamada# OK, Make called in directory where kernel src resides 118 9e414032SMasahiro Yamada# Do we want to locate output files in a separate directory? 119 f9328639SMarian Balakowiczifeq ("$(origin O)", "command line") 120 9e414032SMasahiro Yamada KBUILD_OUTPUT := $(O) 121 f9328639SMarian Balakowiczendif 122 7ebf7443Swdenk 123 9e414032SMasahiro Yamada# That's our default target when none is given on the command line 124 9e414032SMasahiro YamadaPHONY := _all 125 9e414032SMasahiro Yamada_all: 126 9e414032SMasahiro Yamada 127 9e414032SMasahiro Yamada# Cancel implicit rules on top Makefile 128 9e414032SMasahiro Yamada$(CURDIR)/Makefile Makefile: ; 129 9e414032SMasahiro Yamada 130 9e414032SMasahiro Yamadaifneq ($(KBUILD_OUTPUT),) 131 9e414032SMasahiro Yamada# Invoke a second make in the output directory, passing relevant variables 132 9e414032SMasahiro Yamada# check that the output directory actually exists 133 9e414032SMasahiro Yamadasaved-output := $(KBUILD_OUTPUT) 134 5a449d75SMasahiro YamadaKBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \ 135 5a449d75SMasahiro Yamada && /bin/pwd) 136 9e414032SMasahiro Yamada$(if $(KBUILD_OUTPUT),, \ 137 598e2d33SMasahiro Yamada $(error failed to create output directory "$(saved-output)")) 138 9e414032SMasahiro Yamada 139 9e414032SMasahiro YamadaPHONY += $(MAKECMDGOALS) sub-make 140 9e414032SMasahiro Yamada 141 9e414032SMasahiro Yamada$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make 142 9e414032SMasahiro Yamada @: 143 9e414032SMasahiro Yamada 144 9e414032SMasahiro Yamadasub-make: FORCE 145 ffe29ebcSMasahiro Yamada $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \ 146 ffe29ebcSMasahiro Yamada -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) 147 9e414032SMasahiro Yamada 148 9e414032SMasahiro Yamada# Leave processing to above invocation of make 149 9e414032SMasahiro Yamadaskip-makefile := 1 150 9e414032SMasahiro Yamadaendif # ifneq ($(KBUILD_OUTPUT),) 151 9e414032SMasahiro Yamadaendif # ifeq ($(KBUILD_SRC),) 152 9e414032SMasahiro Yamada 153 9e414032SMasahiro Yamada# We process the rest of the Makefile if this is the final invocation of make 154 9e414032SMasahiro Yamadaifeq ($(skip-makefile),) 155 9e414032SMasahiro Yamada 156 ffe29ebcSMasahiro Yamada# Do not print "Entering directory ...", 157 ffe29ebcSMasahiro Yamada# but we want to display it when entering to the output directory 158 ffe29ebcSMasahiro Yamada# so that IDEs/editors are able to understand relative filenames. 159 ffe29ebcSMasahiro YamadaMAKEFLAGS += --no-print-directory 160 ffe29ebcSMasahiro Yamada 161 ffe29ebcSMasahiro Yamada# Call a source code checker (by default, "sparse") as part of the 162 ffe29ebcSMasahiro Yamada# C compilation. 163 ffe29ebcSMasahiro Yamada# 164 ffe29ebcSMasahiro Yamada# Use 'make C=1' to enable checking of only re-compiled files. 165 ffe29ebcSMasahiro Yamada# Use 'make C=2' to enable checking of *all* source files, regardless 166 ffe29ebcSMasahiro Yamada# of whether they are re-compiled or not. 167 ffe29ebcSMasahiro Yamada# 168 ffe29ebcSMasahiro Yamada# See the file "Documentation/sparse.txt" for more details, including 169 ffe29ebcSMasahiro Yamada# where to get the "sparse" utility. 170 ffe29ebcSMasahiro Yamada 171 ffe29ebcSMasahiro Yamadaifeq ("$(origin C)", "command line") 172 ffe29ebcSMasahiro Yamada KBUILD_CHECKSRC = $(C) 173 ffe29ebcSMasahiro Yamadaendif 174 ffe29ebcSMasahiro Yamadaifndef KBUILD_CHECKSRC 175 ffe29ebcSMasahiro Yamada KBUILD_CHECKSRC = 0 176 ffe29ebcSMasahiro Yamadaendif 177 ffe29ebcSMasahiro Yamada 178 ffe29ebcSMasahiro Yamada# Use make M=dir to specify directory of external module to build 179 ffe29ebcSMasahiro Yamada# Old syntax make ... SUBDIRS=$PWD is still supported 180 ffe29ebcSMasahiro Yamada# Setting the environment variable KBUILD_EXTMOD take precedence 181 ffe29ebcSMasahiro Yamadaifdef SUBDIRS 182 ffe29ebcSMasahiro Yamada KBUILD_EXTMOD ?= $(SUBDIRS) 183 ffe29ebcSMasahiro Yamadaendif 184 ffe29ebcSMasahiro Yamada 185 ffe29ebcSMasahiro Yamadaifeq ("$(origin M)", "command line") 186 ffe29ebcSMasahiro Yamada KBUILD_EXTMOD := $(M) 187 ffe29ebcSMasahiro Yamadaendif 188 ffe29ebcSMasahiro Yamada 189 6825a95bSMasahiro Yamada# If building an external module we do not care about the all: rule 190 6825a95bSMasahiro Yamada# but instead _all depend on modules 191 9e414032SMasahiro YamadaPHONY += all 192 6825a95bSMasahiro Yamadaifeq ($(KBUILD_EXTMOD),) 193 9e414032SMasahiro Yamada_all: all 194 6825a95bSMasahiro Yamadaelse 195 6825a95bSMasahiro Yamada_all: modules 196 6825a95bSMasahiro Yamadaendif 197 9e414032SMasahiro Yamada 198 ffe29ebcSMasahiro Yamadaifeq ($(KBUILD_SRC),) 199 ffe29ebcSMasahiro Yamada # building in the source tree 200 ffe29ebcSMasahiro Yamada srctree := . 201 ffe29ebcSMasahiro Yamadaelse 202 ffe29ebcSMasahiro Yamada ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR))) 203 ffe29ebcSMasahiro Yamada # building in a subdirectory of the source tree 204 ffe29ebcSMasahiro Yamada srctree := .. 205 ffe29ebcSMasahiro Yamada else 206 ffe29ebcSMasahiro Yamada srctree := $(KBUILD_SRC) 207 ffe29ebcSMasahiro Yamada endif 208 ffe29ebcSMasahiro Yamadaendif 209 ffe29ebcSMasahiro Yamadaobjtree := . 210 9e414032SMasahiro Yamadasrc := $(srctree) 211 9e414032SMasahiro Yamadaobj := $(objtree) 212 9e414032SMasahiro Yamada 213 9e414032SMasahiro YamadaVPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) 214 9e414032SMasahiro Yamada 215 9e414032SMasahiro Yamadaexport srctree objtree VPATH 216 9e414032SMasahiro Yamada 217 5013c09fSWolfgang Denk# Make sure CDPATH settings don't interfere 218 5013c09fSWolfgang Denkunexport CDPATH 219 5013c09fSWolfgang Denk 220 f9328639SMarian Balakowicz######################################################################### 221 f9328639SMarian Balakowicz 222 7ebf7443SwdenkHOSTARCH := $(shell uname -m | \ 223 7ebf7443Swdenk sed -e s/i.86/x86/ \ 224 7ebf7443Swdenk -e s/sun4u/sparc64/ \ 225 7ebf7443Swdenk -e s/arm.*/arm/ \ 226 7ebf7443Swdenk -e s/sa110/arm/ \ 227 7ebf7443Swdenk -e s/ppc64/powerpc/ \ 228 7ebf7443Swdenk -e s/ppc/powerpc/ \ 229 7ebf7443Swdenk -e s/macppc/powerpc/\ 230 7ebf7443Swdenk -e s/sh.*/sh/) 231 7ebf7443Swdenk 232 7ebf7443SwdenkHOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \ 233 7ebf7443Swdenk sed -e 's/\(cygwin\).*/cygwin/') 234 7ebf7443Swdenk 235 7ebf7443Swdenkexport HOSTARCH HOSTOS 236 7ebf7443Swdenk 237 7ebf7443Swdenk######################################################################### 238 f9328639SMarian Balakowicz 239 1ea6bcd8SMike Frysinger# set default to nothing for native builds 240 a5284efdSWolfgang Denkifeq ($(HOSTARCH),$(ARCH)) 241 1ea6bcd8SMike FrysingerCROSS_COMPILE ?= 242 7ebf7443Swdenkendif 243 7ebf7443Swdenk 244 51148790SMasahiro YamadaKCONFIG_CONFIG ?= .config 245 51148790SMasahiro Yamadaexport KCONFIG_CONFIG 246 51148790SMasahiro Yamada 247 f6322eb7SMasahiro Yamada# SHELL used by kbuild 248 f6322eb7SMasahiro YamadaCONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ 249 f6322eb7SMasahiro Yamada else if [ -x /bin/bash ]; then echo /bin/bash; \ 250 f6322eb7SMasahiro Yamada else echo sh; fi ; fi) 251 f6322eb7SMasahiro Yamada 252 b477fe44SJeroen HofsteeHOSTCC = cc 253 b477fe44SJeroen HofsteeHOSTCXX = c++ 254 f6322eb7SMasahiro YamadaHOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer 255 598e2d33SMasahiro YamadaHOSTCXXFLAGS = -O2 256 598e2d33SMasahiro Yamada 257 f6322eb7SMasahiro Yamadaifeq ($(HOSTOS),cygwin) 258 f6322eb7SMasahiro YamadaHOSTCFLAGS += -ansi 259 f6322eb7SMasahiro Yamadaendif 260 f6322eb7SMasahiro Yamada 261 f6322eb7SMasahiro Yamada# Mac OS X / Darwin's C preprocessor is Apple specific. It 262 f6322eb7SMasahiro Yamada# generates numerous errors and warnings. We want to bypass it 263 f6322eb7SMasahiro Yamada# and use GNU C's cpp. To do this we pass the -traditional-cpp 264 f6322eb7SMasahiro Yamada# option to the compiler. Note that the -traditional-cpp flag 265 f6322eb7SMasahiro Yamada# DOES NOT have the same semantics as GNU C's flag, all it does 266 f6322eb7SMasahiro Yamada# is invoke the GNU preprocessor in stock ANSI/ISO C fashion. 267 f6322eb7SMasahiro Yamada# 268 f6322eb7SMasahiro Yamada# Apple's linker is similar, thanks to the new 2 stage linking 269 f6322eb7SMasahiro Yamada# multiple symbol definitions are treated as errors, hence the 270 f6322eb7SMasahiro Yamada# -multiply_defined suppress option to turn off this error. 271 f6322eb7SMasahiro Yamada# 272 f6322eb7SMasahiro Yamadaifeq ($(HOSTOS),darwin) 273 f6322eb7SMasahiro Yamada# get major and minor product version (e.g. '10' and '6' for Snow Leopard) 274 f6322eb7SMasahiro YamadaDARWIN_MAJOR_VERSION = $(shell sw_vers -productVersion | cut -f 1 -d '.') 275 f6322eb7SMasahiro YamadaDARWIN_MINOR_VERSION = $(shell sw_vers -productVersion | cut -f 2 -d '.') 276 f6322eb7SMasahiro Yamada 277 f6322eb7SMasahiro Yamadaos_x_before = $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \ 278 f6322eb7SMasahiro Yamada $(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;) 279 f6322eb7SMasahiro Yamada 280 f6322eb7SMasahiro Yamada# Snow Leopards build environment has no longer restrictions as described above 281 f6322eb7SMasahiro YamadaHOSTCC = $(call os_x_before, 10, 5, "cc", "gcc") 282 f6322eb7SMasahiro YamadaHOSTCFLAGS += $(call os_x_before, 10, 4, "-traditional-cpp") 283 f6322eb7SMasahiro YamadaHOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress") 284 1fddd7b6SAndreas Bießmann 285 1fddd7b6SAndreas Bießmann# since Lion (10.7) ASLR is on by default, but we use linker generated lists 286 1fddd7b6SAndreas Bießmann# in some host tools which is a problem then ... so disable ASLR for these 287 1fddd7b6SAndreas Bießmann# tools 288 1fddd7b6SAndreas BießmannHOSTLDFLAGS += $(call os_x_before, 10, 7, "", "-Xlinker -no_pie") 289 f6322eb7SMasahiro Yamadaendif 290 f6322eb7SMasahiro Yamada 291 6825a95bSMasahiro Yamada# Decide whether to build built-in, modular, or both. 292 6825a95bSMasahiro Yamada# Normally, just do built-in. 293 6825a95bSMasahiro Yamada 294 6825a95bSMasahiro YamadaKBUILD_MODULES := 295 6825a95bSMasahiro YamadaKBUILD_BUILTIN := 1 296 6825a95bSMasahiro Yamada 297 6825a95bSMasahiro Yamada# If we have only "make modules", don't compile built-in objects. 298 6825a95bSMasahiro Yamada# When we're building modules with modversions, we need to consider 299 6825a95bSMasahiro Yamada# the built-in objects during the descend as well, in order to 300 6825a95bSMasahiro Yamada# make sure the checksums are up to date before we record them. 301 6825a95bSMasahiro Yamada 302 6825a95bSMasahiro Yamadaifeq ($(MAKECMDGOALS),modules) 303 6825a95bSMasahiro Yamada KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1) 304 6825a95bSMasahiro Yamadaendif 305 6825a95bSMasahiro Yamada 306 6825a95bSMasahiro Yamada# If we have "make <whatever> modules", compile modules 307 6825a95bSMasahiro Yamada# in addition to whatever we do anyway. 308 6825a95bSMasahiro Yamada# Just "make" or "make all" shall build modules as well 309 6825a95bSMasahiro Yamada 310 6825a95bSMasahiro Yamada# U-Boot does not need modules 311 6825a95bSMasahiro Yamada#ifneq ($(filter all _all modules,$(MAKECMDGOALS)),) 312 6825a95bSMasahiro Yamada# KBUILD_MODULES := 1 313 6825a95bSMasahiro Yamada#endif 314 6825a95bSMasahiro Yamada 315 6825a95bSMasahiro Yamada#ifeq ($(MAKECMDGOALS),) 316 6825a95bSMasahiro Yamada# KBUILD_MODULES := 1 317 6825a95bSMasahiro Yamada#endif 318 6825a95bSMasahiro Yamada 319 6825a95bSMasahiro Yamadaexport KBUILD_MODULES KBUILD_BUILTIN 320 6825a95bSMasahiro Yamadaexport KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD 321 6825a95bSMasahiro Yamada 322 9e414032SMasahiro Yamada# Look for make include files relative to root of kernel src 323 9e414032SMasahiro YamadaMAKEFLAGS += --include-dir=$(srctree) 324 9e414032SMasahiro Yamada 325 bf4b3de1SMasahiro Yamada# We need some generic definitions (do not try to remake the file). 326 bf4b3de1SMasahiro Yamada$(srctree)/scripts/Kbuild.include: ; 327 bf4b3de1SMasahiro Yamadainclude $(srctree)/scripts/Kbuild.include 328 bf4b3de1SMasahiro Yamada 329 f6322eb7SMasahiro Yamada# Make variables (CC, etc...) 330 f6322eb7SMasahiro Yamada 331 f6322eb7SMasahiro YamadaAS = $(CROSS_COMPILE)as 332 f6322eb7SMasahiro Yamada# Always use GNU ld 333 f6322eb7SMasahiro Yamadaifneq ($(shell $(CROSS_COMPILE)ld.bfd -v 2> /dev/null),) 334 f6322eb7SMasahiro YamadaLD = $(CROSS_COMPILE)ld.bfd 335 f6322eb7SMasahiro Yamadaelse 336 f6322eb7SMasahiro YamadaLD = $(CROSS_COMPILE)ld 337 f6322eb7SMasahiro Yamadaendif 338 f6322eb7SMasahiro YamadaCC = $(CROSS_COMPILE)gcc 339 f6322eb7SMasahiro YamadaCPP = $(CC) -E 340 f6322eb7SMasahiro YamadaAR = $(CROSS_COMPILE)ar 341 f6322eb7SMasahiro YamadaNM = $(CROSS_COMPILE)nm 342 f6322eb7SMasahiro YamadaLDR = $(CROSS_COMPILE)ldr 343 f6322eb7SMasahiro YamadaSTRIP = $(CROSS_COMPILE)strip 344 f6322eb7SMasahiro YamadaOBJCOPY = $(CROSS_COMPILE)objcopy 345 f6322eb7SMasahiro YamadaOBJDUMP = $(CROSS_COMPILE)objdump 346 f6322eb7SMasahiro YamadaAWK = awk 347 f77d7096SMasahiro YamadaPERL = perl 348 51148790SMasahiro YamadaPYTHON = python 349 f6322eb7SMasahiro YamadaDTC = dtc 350 f6322eb7SMasahiro YamadaCHECK = sparse 351 f6322eb7SMasahiro Yamada 352 f6322eb7SMasahiro YamadaCHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ 353 f6322eb7SMasahiro Yamada -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF) 354 f6322eb7SMasahiro Yamada 355 3b612970SMasahiro YamadaKBUILD_CPPFLAGS := -D__KERNEL__ -D__UBOOT__ 356 2b3c9d3dSMasahiro Yamada 357 2b3c9d3dSMasahiro YamadaKBUILD_CFLAGS := -Wall -Wstrict-prototypes \ 358 2b3c9d3dSMasahiro Yamada -Wno-format-security \ 359 2b3c9d3dSMasahiro Yamada -fno-builtin -ffreestanding 360 2b3c9d3dSMasahiro YamadaKBUILD_AFLAGS := -D__ASSEMBLY__ 361 2b3c9d3dSMasahiro Yamada 362 7424145fSMasahiro Yamada# Read UBOOTRELEASE from include/config/uboot.release (if it exists) 363 7424145fSMasahiro YamadaUBOOTRELEASE = $(shell cat include/config/uboot.release 2> /dev/null) 364 7424145fSMasahiro YamadaUBOOTVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) 365 5f30f3beSMasahiro Yamada 366 7424145fSMasahiro Yamadaexport VERSION PATCHLEVEL SUBLEVEL UBOOTRELEASE UBOOTVERSION 367 026f9cf2SMasahiro Yamadaexport ARCH CPU BOARD VENDOR SOC CPUDIR BOARDDIR 368 f6322eb7SMasahiro Yamadaexport CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC 369 f6322eb7SMasahiro Yamadaexport CPP AR NM LDR STRIP OBJCOPY OBJDUMP 370 51148790SMasahiro Yamadaexport MAKE AWK PERL PYTHON 371 15c939f9SMasahiro Yamadaexport HOSTCXX HOSTCXXFLAGS DTC CHECK CHECKFLAGS 372 f6322eb7SMasahiro Yamada 373 026f9cf2SMasahiro Yamadaexport KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE OBJCOPYFLAGS LDFLAGS 374 2b3c9d3dSMasahiro Yamadaexport KBUILD_CFLAGS KBUILD_AFLAGS 375 2b3c9d3dSMasahiro Yamada 376 6825a95bSMasahiro Yamada# When compiling out-of-tree modules, put MODVERDIR in the module 377 6825a95bSMasahiro Yamada# tree rather than in the kernel tree. The kernel tree might 378 6825a95bSMasahiro Yamada# even be read-only. 379 6825a95bSMasahiro Yamadaexport MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions 380 6825a95bSMasahiro Yamada 381 6825a95bSMasahiro Yamada# Files to ignore in find ... statements 382 6825a95bSMasahiro Yamada 383 598e2d33SMasahiro Yamadaexport RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \ 384 598e2d33SMasahiro Yamada -name CVS -o -name .pc -o -name .hg -o -name .git \) \ 385 598e2d33SMasahiro Yamada -prune -o 386 6825a95bSMasahiro Yamadaexport RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \ 387 6825a95bSMasahiro Yamada --exclude CVS --exclude .pc --exclude .hg --exclude .git 388 6825a95bSMasahiro Yamada 389 6825a95bSMasahiro Yamada# =========================================================================== 390 6825a95bSMasahiro Yamada# Rules shared between *config targets and build targets 391 6825a95bSMasahiro Yamada 392 6825a95bSMasahiro Yamada# Basic helpers built in scripts/ 393 6825a95bSMasahiro YamadaPHONY += scripts_basic 394 6825a95bSMasahiro Yamadascripts_basic: 395 6825a95bSMasahiro Yamada $(Q)$(MAKE) $(build)=scripts/basic 396 6825a95bSMasahiro Yamada $(Q)rm -f .tmp_quiet_recordmcount 397 6825a95bSMasahiro Yamada 398 6825a95bSMasahiro Yamada# To avoid any implicit rule to kick in, define an empty command. 399 6825a95bSMasahiro Yamadascripts/basic/%: scripts_basic ; 400 6825a95bSMasahiro Yamada 401 3341bfecSMasahiro YamadaPHONY += outputmakefile 402 3341bfecSMasahiro Yamada# outputmakefile generates a Makefile in the output directory, if using a 403 3341bfecSMasahiro Yamada# separate output directory. This allows convenient use of make in the 404 3341bfecSMasahiro Yamada# output directory. 405 3341bfecSMasahiro Yamadaoutputmakefile: 406 3341bfecSMasahiro Yamadaifneq ($(KBUILD_SRC),) 407 3341bfecSMasahiro Yamada $(Q)ln -fsn $(srctree) source 408 3341bfecSMasahiro Yamada $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ 409 3341bfecSMasahiro Yamada $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) 410 3341bfecSMasahiro Yamadaendif 411 3341bfecSMasahiro Yamada 412 433b2f1eSMasahiro Yamada# To make sure we do not include .config for any of the *config targets 413 433b2f1eSMasahiro Yamada# catch them early, and hand them over to scripts/kconfig/Makefile 414 433b2f1eSMasahiro Yamada# It is allowed to specify more targets when calling make, including 415 433b2f1eSMasahiro Yamada# mixing *config targets and build targets. 416 433b2f1eSMasahiro Yamada# For example 'make oldconfig all'. 417 433b2f1eSMasahiro Yamada# Detect when mixed targets is specified, and make a second invocation 418 433b2f1eSMasahiro Yamada# of make so .config is not included in this case either (for *config). 419 6825a95bSMasahiro Yamada 420 7424145fSMasahiro Yamadaversion_h := include/generated/version_autogenerated.h 421 7424145fSMasahiro Yamadatimestamp_h := include/generated/timestamp_autogenerated.h 422 7424145fSMasahiro Yamada 423 433b2f1eSMasahiro Yamadano-dot-config-targets := clean clobber mrproper distclean \ 424 27651187SMasahiro Yamada help %docs check% coccicheck \ 425 c7ad5cbbSTom Rini ubootversion backup 426 2b3c9d3dSMasahiro Yamada 427 433b2f1eSMasahiro Yamadaconfig-targets := 0 428 433b2f1eSMasahiro Yamadamixed-targets := 0 429 433b2f1eSMasahiro Yamadadot-config := 1 430 2b3c9d3dSMasahiro Yamada 431 433b2f1eSMasahiro Yamadaifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) 432 433b2f1eSMasahiro Yamada ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) 433 433b2f1eSMasahiro Yamada dot-config := 0 434 2b3c9d3dSMasahiro Yamada endif 435 2b3c9d3dSMasahiro Yamadaendif 436 2b3c9d3dSMasahiro Yamada 437 433b2f1eSMasahiro Yamadaifeq ($(KBUILD_EXTMOD),) 438 433b2f1eSMasahiro Yamada ifneq ($(filter config %config,$(MAKECMDGOALS)),) 439 433b2f1eSMasahiro Yamada config-targets := 1 440 433b2f1eSMasahiro Yamada ifneq ($(filter-out config %config,$(MAKECMDGOALS)),) 441 433b2f1eSMasahiro Yamada mixed-targets := 1 442 433b2f1eSMasahiro Yamada endif 443 433b2f1eSMasahiro Yamada endif 444 433b2f1eSMasahiro Yamadaendif 445 433b2f1eSMasahiro Yamada 446 433b2f1eSMasahiro Yamadaifeq ($(mixed-targets),1) 447 433b2f1eSMasahiro Yamada# =========================================================================== 448 433b2f1eSMasahiro Yamada# We're called with mixed targets (*config and build targets). 449 433b2f1eSMasahiro Yamada# Handle them one by one. 450 433b2f1eSMasahiro Yamada 451 e7734404SMasahiro YamadaPHONY += $(MAKECMDGOALS) __build_one_by_one 452 53bca5abSMasahiro Yamada 453 e7734404SMasahiro Yamada$(filter-out __build_one_by_one, $(MAKECMDGOALS)): __build_one_by_one 454 53bca5abSMasahiro Yamada @: 455 53bca5abSMasahiro Yamada 456 e7734404SMasahiro Yamada__build_one_by_one: 457 53bca5abSMasahiro Yamada $(Q)set -e; \ 458 53bca5abSMasahiro Yamada for i in $(MAKECMDGOALS); do \ 459 53bca5abSMasahiro Yamada $(MAKE) -f $(srctree)/Makefile $$i; \ 460 53bca5abSMasahiro Yamada done 461 433b2f1eSMasahiro Yamada 462 433b2f1eSMasahiro Yamadaelse 463 433b2f1eSMasahiro Yamadaifeq ($(config-targets),1) 464 433b2f1eSMasahiro Yamada# =========================================================================== 465 433b2f1eSMasahiro Yamada# *config targets only - make sure prerequisites are updated, and descend 466 433b2f1eSMasahiro Yamada# in scripts/kconfig to make the *config target 467 433b2f1eSMasahiro Yamada 468 51148790SMasahiro YamadaKBUILD_DEFCONFIG := sandbox_defconfig 469 51148790SMasahiro Yamadaexport KBUILD_DEFCONFIG KBUILD_KCONFIG 470 433b2f1eSMasahiro Yamada 471 51148790SMasahiro Yamadaconfig: scripts_basic outputmakefile FORCE 472 5f9eb220SMasahiro Yamada $(Q)$(MAKE) $(build)=scripts/kconfig $@ 473 51148790SMasahiro Yamada 474 51148790SMasahiro Yamada%config: scripts_basic outputmakefile FORCE 475 5f9eb220SMasahiro Yamada $(Q)$(MAKE) $(build)=scripts/kconfig $@ 476 433b2f1eSMasahiro Yamada 477 433b2f1eSMasahiro Yamadaelse 478 433b2f1eSMasahiro Yamada# =========================================================================== 479 433b2f1eSMasahiro Yamada# Build targets only - this includes vmlinux, arch specific targets, clean 480 433b2f1eSMasahiro Yamada# targets and others. In general all targets except *config targets. 481 433b2f1eSMasahiro Yamada 482 433b2f1eSMasahiro Yamadaifeq ($(dot-config),1) 483 433b2f1eSMasahiro Yamada# Read in config 484 51148790SMasahiro Yamada-include include/config/auto.conf 485 51148790SMasahiro Yamada 486 51148790SMasahiro Yamada# Read in dependencies to all Kconfig* files, make sure to run 487 51148790SMasahiro Yamada# oldconfig if changes are detected. 488 51148790SMasahiro Yamada-include include/config/auto.conf.cmd 489 51148790SMasahiro Yamada 490 51148790SMasahiro Yamada# To avoid any implicit rule to kick in, define an empty command 491 51148790SMasahiro Yamada$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; 492 51148790SMasahiro Yamada 493 51148790SMasahiro Yamada# If .config is newer than include/config/auto.conf, someone tinkered 494 51148790SMasahiro Yamada# with it and forgot to run make oldconfig. 495 51148790SMasahiro Yamada# if auto.conf.cmd is missing then we are probably in a cleaned tree so 496 51148790SMasahiro Yamada# we execute the config step to be sure to catch updated Kconfig files 497 51148790SMasahiro Yamadainclude/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd 498 51148790SMasahiro Yamada $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig 499 5f9eb220SMasahiro Yamada @# If the following part fails, include/config/auto.conf should be 500 5f9eb220SMasahiro Yamada @# deleted so "make silentoldconfig" will be re-run on the next build. 501 5f9eb220SMasahiro Yamada $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.autoconf || \ 502 5f9eb220SMasahiro Yamada { rm -f include/config/auto.conf; false; } 503 5f9eb220SMasahiro Yamada @# include/config.h has been updated after "make silentoldconfig". 504 5f9eb220SMasahiro Yamada @# We need to touch include/config/auto.conf so it gets newer 505 5f9eb220SMasahiro Yamada @# than include/config.h. 506 5f9eb220SMasahiro Yamada @# Otherwise, 'make silentoldconfig' would be invoked twice. 507 5f9eb220SMasahiro Yamada $(Q)touch include/config/auto.conf 508 51148790SMasahiro Yamada 509 433b2f1eSMasahiro Yamada-include include/autoconf.mk 510 433b2f1eSMasahiro Yamada-include include/autoconf.mk.dep 511 433b2f1eSMasahiro Yamada 512 51148790SMasahiro Yamada# We want to include arch/$(ARCH)/config.mk only when include/config/auto.conf 513 51148790SMasahiro Yamada# is up-to-date. When we switch to a different board configuration, old CONFIG 514 51148790SMasahiro Yamada# macros are still remaining in include/config/auto.conf. Without the following 515 51148790SMasahiro Yamada# gimmick, wrong config.mk would be included leading nasty warnings/errors. 516 cffcd286SMasahiro Yamadaifneq ($(wildcard $(KCONFIG_CONFIG)),) 517 cffcd286SMasahiro Yamadaifneq ($(wildcard include/config/auto.conf),) 518 cffcd286SMasahiro Yamadaautoconf_is_old := $(shell find . -path ./$(KCONFIG_CONFIG) -newer \ 519 cffcd286SMasahiro Yamada include/config/auto.conf) 520 cffcd286SMasahiro Yamadaifeq ($(autoconf_is_old),) 521 433b2f1eSMasahiro Yamadainclude $(srctree)/config.mk 522 e19db555SDaniel Schwierzeckinclude $(srctree)/arch/$(ARCH)/Makefile 523 ced0715dSMasahiro Yamadaendif 524 cffcd286SMasahiro Yamadaendif 525 cffcd286SMasahiro Yamadaendif 526 fada9e20SSimon Glass 527 d51dfff7SIlya Yanok# If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use 528 d51dfff7SIlya Yanok# that (or fail if absent). Otherwise, search for a linker script in a 529 d51dfff7SIlya Yanok# standard location. 530 d51dfff7SIlya Yanok 531 d51dfff7SIlya Yanokifndef LDSCRIPT 532 4379ac61SMasahiro Yamada #LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot.lds.debug 533 d51dfff7SIlya Yanok ifdef CONFIG_SYS_LDSCRIPT 534 d51dfff7SIlya Yanok # need to strip off double quotes 535 4a377552SMasahiro Yamada LDSCRIPT := $(srctree)/$(CONFIG_SYS_LDSCRIPT:"%"=%) 536 d51dfff7SIlya Yanok endif 537 d51dfff7SIlya Yanokendif 538 d51dfff7SIlya Yanok 539 ee60197eSSimon Glass# If there is no specified link script, we look in a number of places for it 540 d51dfff7SIlya Yanokifndef LDSCRIPT 541 d51dfff7SIlya Yanok ifeq ($(wildcard $(LDSCRIPT)),) 542 4379ac61SMasahiro Yamada LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot.lds 543 d51dfff7SIlya Yanok endif 544 d51dfff7SIlya Yanok ifeq ($(wildcard $(LDSCRIPT)),) 545 4379ac61SMasahiro Yamada LDSCRIPT := $(srctree)/$(CPUDIR)/u-boot.lds 546 d51dfff7SIlya Yanok endif 547 d51dfff7SIlya Yanok ifeq ($(wildcard $(LDSCRIPT)),) 548 4379ac61SMasahiro Yamada LDSCRIPT := $(srctree)/arch/$(ARCH)/cpu/u-boot.lds 549 ee60197eSSimon Glass endif 550 d51dfff7SIlya Yanokendif 551 d51dfff7SIlya Yanok 552 433b2f1eSMasahiro Yamadaelse 553 51148790SMasahiro Yamada# Dummy target needed, because used as prerequisite 554 51148790SMasahiro Yamadainclude/config/auto.conf: ; 555 433b2f1eSMasahiro Yamadaendif # $(dot-config) 556 433b2f1eSMasahiro Yamada 557 4a8ed8e2SMasahiro Yamadaifdef CONFIG_CC_OPTIMIZE_FOR_SIZE 558 4a8ed8e2SMasahiro YamadaKBUILD_CFLAGS += -Os 559 4a8ed8e2SMasahiro Yamadaelse 560 4a8ed8e2SMasahiro YamadaKBUILD_CFLAGS += -O2 561 4a8ed8e2SMasahiro Yamadaendif 562 433b2f1eSMasahiro Yamada 563 433b2f1eSMasahiro Yamadaifdef BUILD_TAG 564 433b2f1eSMasahiro YamadaKBUILD_CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"' 565 433b2f1eSMasahiro Yamadaendif 566 433b2f1eSMasahiro Yamada 567 433b2f1eSMasahiro YamadaKBUILD_CFLAGS += $(call cc-option,-fno-stack-protector) 568 433b2f1eSMasahiro Yamada 569 433b2f1eSMasahiro YamadaKBUILD_CFLAGS += -g 570 433b2f1eSMasahiro Yamada# $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format> 571 433b2f1eSMasahiro Yamada# option to the assembler. 572 433b2f1eSMasahiro YamadaKBUILD_AFLAGS += -g 573 433b2f1eSMasahiro Yamada 574 433b2f1eSMasahiro Yamada# Report stack usage if supported 575 5b1f1f4aSMasahiro Yamadaifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-stack-usage.sh $(CC)),y) 576 5b1f1f4aSMasahiro Yamada KBUILD_CFLAGS += -fstack-usage 577 5b1f1f4aSMasahiro Yamadaendif 578 433b2f1eSMasahiro Yamada 579 433b2f1eSMasahiro YamadaKBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral) 580 433b2f1eSMasahiro Yamada 581 433b2f1eSMasahiro Yamada# turn jbsr into jsr for m68k 582 433b2f1eSMasahiro Yamadaifeq ($(ARCH),m68k) 583 433b2f1eSMasahiro Yamadaifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4) 584 433b2f1eSMasahiro YamadaKBUILD_AFLAGS += -Wa,-gstabs,-S 585 433b2f1eSMasahiro Yamadaendif 586 433b2f1eSMasahiro Yamadaendif 587 433b2f1eSMasahiro Yamada 588 65bb6d8dSMasahiro Yamada# Prohibit date/time macros, which would make the build non-deterministic 589 65bb6d8dSMasahiro YamadaKBUILD_CFLAGS += $(call cc-option,-Werror=date-time) 590 65bb6d8dSMasahiro Yamada 591 433b2f1eSMasahiro Yamadaifneq ($(CONFIG_SYS_TEXT_BASE),) 592 433b2f1eSMasahiro YamadaKBUILD_CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE) 593 433b2f1eSMasahiro Yamadaendif 594 433b2f1eSMasahiro Yamada 595 433b2f1eSMasahiro Yamadaexport CONFIG_SYS_TEXT_BASE 596 433b2f1eSMasahiro Yamada 597 6419e144SMasahiro Yamadainclude $(srctree)/scripts/Makefile.extrawarn 598 6419e144SMasahiro Yamada 599 0e6256d0SMasahiro Yamada# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments 600 0e6256d0SMasahiro YamadaKBUILD_CPPFLAGS += $(KCPPFLAGS) 601 0e6256d0SMasahiro YamadaKBUILD_AFLAGS += $(KAFLAGS) 602 0e6256d0SMasahiro YamadaKBUILD_CFLAGS += $(KCFLAGS) 603 0e6256d0SMasahiro Yamada 604 433b2f1eSMasahiro Yamada# Use UBOOTINCLUDE when you must reference the include/ directory. 605 433b2f1eSMasahiro Yamada# Needed to be compatible with the O= option 606 f5c66bdbSMasahiro YamadaUBOOTINCLUDE := \ 607 f5c66bdbSMasahiro Yamada -Iinclude \ 608 f5c66bdbSMasahiro Yamada $(if $(KBUILD_SRC), -I$(srctree)/include) \ 609 51148790SMasahiro Yamada -I$(srctree)/arch/$(ARCH)/include \ 610 51148790SMasahiro Yamada -include $(srctree)/include/linux/kconfig.h 611 433b2f1eSMasahiro Yamada 612 433b2f1eSMasahiro YamadaNOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) 613 433b2f1eSMasahiro YamadaCHECKFLAGS += $(NOSTDINC_FLAGS) 614 433b2f1eSMasahiro Yamada 615 433b2f1eSMasahiro Yamada# FIX ME 616 026f9cf2SMasahiro Yamadacpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \ 617 026f9cf2SMasahiro Yamada $(NOSTDINC_FLAGS) 618 433b2f1eSMasahiro Yamadac_flags := $(KBUILD_CFLAGS) $(cpp_flags) 619 433b2f1eSMasahiro Yamada 620 7ebf7443Swdenk######################################################################### 621 7ebf7443Swdenk# U-Boot objects....order is important (i.e. start must be first) 622 7ebf7443Swdenk 623 9e414032SMasahiro YamadaHAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n) 624 f9328639SMarian Balakowicz 625 656de6b8SMasahiro Yamadalibs-y += lib/ 626 656de6b8SMasahiro Yamadalibs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/ 627 656de6b8SMasahiro Yamadalibs-$(CONFIG_OF_EMBED) += dts/ 628 656de6b8SMasahiro Yamadalibs-y += fs/ 629 656de6b8SMasahiro Yamadalibs-y += net/ 630 656de6b8SMasahiro Yamadalibs-y += disk/ 631 656de6b8SMasahiro Yamadalibs-y += drivers/ 632 656de6b8SMasahiro Yamadalibs-y += drivers/dma/ 633 656de6b8SMasahiro Yamadalibs-y += drivers/gpio/ 634 656de6b8SMasahiro Yamadalibs-y += drivers/i2c/ 635 656de6b8SMasahiro Yamadalibs-y += drivers/mmc/ 636 656de6b8SMasahiro Yamadalibs-y += drivers/mtd/ 637 656de6b8SMasahiro Yamadalibs-$(CONFIG_CMD_NAND) += drivers/mtd/nand/ 638 656de6b8SMasahiro Yamadalibs-y += drivers/mtd/onenand/ 639 656de6b8SMasahiro Yamadalibs-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/ 640 656de6b8SMasahiro Yamadalibs-y += drivers/mtd/spi/ 641 656de6b8SMasahiro Yamadalibs-y += drivers/net/ 642 656de6b8SMasahiro Yamadalibs-y += drivers/net/phy/ 643 656de6b8SMasahiro Yamadalibs-y += drivers/pci/ 644 656de6b8SMasahiro Yamadalibs-y += drivers/power/ \ 645 e2906a59SMasahiro Yamada drivers/power/fuel_gauge/ \ 646 e2906a59SMasahiro Yamada drivers/power/mfd/ \ 647 e2906a59SMasahiro Yamada drivers/power/pmic/ \ 648 e2906a59SMasahiro Yamada drivers/power/battery/ 649 656de6b8SMasahiro Yamadalibs-y += drivers/spi/ 650 656de6b8SMasahiro Yamadalibs-$(CONFIG_FMAN_ENET) += drivers/net/fm/ 651 656de6b8SMasahiro Yamadalibs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/ 652 656de6b8SMasahiro Yamadalibs-y += drivers/serial/ 653 *5b9ce0e2SKishon Vijay Abraham Ilibs-y += drivers/usb/dwc3/ 654 656de6b8SMasahiro Yamadalibs-y += drivers/usb/eth/ 655 656de6b8SMasahiro Yamadalibs-y += drivers/usb/gadget/ 656 *5b9ce0e2SKishon Vijay Abraham Ilibs-y += drivers/usb/gadget/udc/ 657 656de6b8SMasahiro Yamadalibs-y += drivers/usb/host/ 658 656de6b8SMasahiro Yamadalibs-y += drivers/usb/musb/ 659 656de6b8SMasahiro Yamadalibs-y += drivers/usb/musb-new/ 660 656de6b8SMasahiro Yamadalibs-y += drivers/usb/phy/ 661 656de6b8SMasahiro Yamadalibs-y += drivers/usb/ulpi/ 662 656de6b8SMasahiro Yamadalibs-y += common/ 663 656de6b8SMasahiro Yamadalibs-$(CONFIG_API) += api/ 664 656de6b8SMasahiro Yamadalibs-$(CONFIG_HAS_POST) += post/ 665 656de6b8SMasahiro Yamadalibs-y += test/ 666 2e7d35d2SSimon Glasslibs-y += test/dm/ 667 f9328639SMarian Balakowicz 668 33a02da0SMasahiro Yamadalibs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/) 669 08e39a84SMasahiro Yamada 670 656de6b8SMasahiro Yamadalibs-y := $(sort $(libs-y)) 671 656de6b8SMasahiro Yamada 672 656de6b8SMasahiro Yamadau-boot-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) tools examples 673 656de6b8SMasahiro Yamada 674 656de6b8SMasahiro Yamadau-boot-alldirs := $(sort $(u-boot-dirs) $(patsubst %/,%,$(filter %/, $(libs-)))) 675 656de6b8SMasahiro Yamada 676 656de6b8SMasahiro Yamadalibs-y := $(patsubst %/, %/built-in.o, $(libs-y)) 677 656de6b8SMasahiro Yamada 678 656de6b8SMasahiro Yamadau-boot-init := $(head-y) 679 656de6b8SMasahiro Yamadau-boot-main := $(libs-y) 680 656de6b8SMasahiro Yamada 681 a8c7c708Swdenk 682 4f7cb08eSwdenk# Add GCC lib 683 cd2e46cbSMasahiro Yamadaifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y) 684 a86cf89cSMasahiro YamadaPLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a 685 52b1bf2cSWolfgang Denkelse 686 6825a95bSMasahiro YamadaPLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`) -lgcc 687 52b1bf2cSWolfgang Denkendif 688 52b1bf2cSWolfgang DenkPLATFORM_LIBS += $(PLATFORM_LIBGCC) 689 52b1bf2cSWolfgang Denkexport PLATFORM_LIBS 690 e75e73ddSAlexey Brodkinexport PLATFORM_LIBGCC 691 3d3befa7Swdenk 692 6ac9f479SMike Frysinger# Special flags for CPP when processing the linker script. 693 6ac9f479SMike Frysinger# Pass the version down so we can handle backwards compatibility 694 6ac9f479SMike Frysinger# on the fly. 695 6ac9f479SMike FrysingerLDPPFLAGS += \ 696 4379ac61SMasahiro Yamada -include $(srctree)/include/u-boot/u-boot.lds.h \ 697 7e6403a6SSimon Glass -DCPUDIR=$(CPUDIR) \ 698 6ac9f479SMike Frysinger $(shell $(LD) --version | \ 699 6ac9f479SMike Frysinger sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p') 700 6ac9f479SMike Frysinger 701 7ebf7443Swdenk######################################################################### 702 bdccc4feSwdenk######################################################################### 703 7ebf7443Swdenk 704 f3a14d37SMike Frysingerifneq ($(CONFIG_BOARD_SIZE_LIMIT),) 705 f3a14d37SMike FrysingerBOARD_SIZE_CHECK = \ 706 f3a14d37SMike Frysinger @actual=`wc -c $@ | awk '{print $$1}'`; \ 707 d060e6f4SJoe Hershberger limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \ 708 f3a14d37SMike Frysinger if test $$actual -gt $$limit; then \ 709 d060e6f4SJoe Hershberger echo "$@ exceeds file size limit:" >&2 ; \ 710 d060e6f4SJoe Hershberger echo " limit: $$limit bytes" >&2 ; \ 711 d060e6f4SJoe Hershberger echo " actual: $$actual bytes" >&2 ; \ 712 d060e6f4SJoe Hershberger echo " excess: $$((actual - limit)) bytes" >&2; \ 713 f3a14d37SMike Frysinger exit 1; \ 714 f3a14d37SMike Frysinger fi 715 f3a14d37SMike Frysingerelse 716 f3a14d37SMike FrysingerBOARD_SIZE_CHECK = 717 f3a14d37SMike Frysingerendif 718 f3a14d37SMike Frysinger 719 8137af19SScott Wood# Statically apply RELA-style relocations (currently arm64 only) 720 8137af19SScott Woodifneq ($(CONFIG_STATIC_RELA),) 721 8137af19SScott Wood# $(1) is u-boot ELF, $(2) is u-boot bin, $(3) is text base 722 8137af19SScott WoodDO_STATIC_RELA = \ 723 8137af19SScott Wood start=$$($(NM) $(1) | grep __rel_dyn_start | cut -f 1 -d ' '); \ 724 8137af19SScott Wood end=$$($(NM) $(1) | grep __rel_dyn_end | cut -f 1 -d ' '); \ 725 9e414032SMasahiro Yamada tools/relocate-rela $(2) $(3) $$start $$end 726 8137af19SScott Woodelse 727 8137af19SScott WoodDO_STATIC_RELA = 728 8137af19SScott Woodendif 729 8137af19SScott Wood 730 3e88337bSMike Frysinger# Always append ALL so that arch config.mk's can add custom ones 731 89742924SSimon GlassALL-y += u-boot.srec u-boot.bin System.map binary_size_check 732 e935a374SHaiying Wang 733 9e414032SMasahiro YamadaALL-$(CONFIG_ONENAND_U_BOOT) += u-boot-onenand.bin 734 89ad7be8SPrabhakar Kushwahaifeq ($(CONFIG_SPL_FSL_PBL),y) 735 89ad7be8SPrabhakar KushwahaALL-$(CONFIG_RAMBOOT_PBL) += u-boot-with-spl-pbl.bin 736 89ad7be8SPrabhakar Kushwahaelse 737 9e414032SMasahiro YamadaALL-$(CONFIG_RAMBOOT_PBL) += u-boot.pbl 738 89ad7be8SPrabhakar Kushwahaendif 739 9e414032SMasahiro YamadaALL-$(CONFIG_SPL) += spl/u-boot-spl.bin 740 9e414032SMasahiro YamadaALL-$(CONFIG_SPL_FRAMEWORK) += u-boot.img 741 9e414032SMasahiro YamadaALL-$(CONFIG_TPL) += tpl/u-boot-tpl.bin 742 0d1e8aacSMasahiro YamadaALL-$(CONFIG_OF_SEPARATE) += u-boot.dtb u-boot-dtb.bin 743 2405d09cSMasahiro Yamadaifeq ($(CONFIG_SPL_FRAMEWORK),y) 744 2405d09cSMasahiro YamadaALL-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img 745 2405d09cSMasahiro Yamadaendif 746 714a5621SSimon GlassALL-$(CONFIG_OF_HOSTFILE) += u-boot.dtb 747 b343bbb5SVadim Bendeburyifneq ($(CONFIG_SPL_TARGET),) 748 9e414032SMasahiro YamadaALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%) 749 b343bbb5SVadim Bendeburyendif 750 9e414032SMasahiro YamadaALL-$(CONFIG_REMAKE_ELF) += u-boot.elf 751 7ebf7443Swdenk 752 eea0f112SSimon Glassifneq ($(BUILD_ROM),) 753 eea0f112SSimon GlassALL-$(CONFIG_X86_RESET_VECTOR) += u-boot.rom 754 eea0f112SSimon Glassendif 755 fce7b276SSimon Glass 756 12b7b70cSAllen Martin# enable combined SPL/u-boot/dtb rules for tegra 757 6d6c0baeSTom Warrenifneq ($(CONFIG_TEGRA),) 758 7dcd3a21SVidya Sagarifeq ($(CONFIG_SPL),y) 759 12b7b70cSAllen Martinifeq ($(CONFIG_OF_SEPARATE),y) 760 9e414032SMasahiro YamadaALL-y += u-boot-dtb-tegra.bin 761 12b7b70cSAllen Martinelse 762 9e414032SMasahiro YamadaALL-y += u-boot-nodtb-tegra.bin 763 12b7b70cSAllen Martinendif 764 12b7b70cSAllen Martinendif 765 7dcd3a21SVidya Sagarendif 766 12b7b70cSAllen Martin 767 b2b8a696SStefan Roese# Add optional build target if defined in board/cpu/soc headers 768 b2b8a696SStefan Roeseifneq ($(CONFIG_BUILD_TARGET),) 769 b2b8a696SStefan RoeseALL-y += $(CONFIG_BUILD_TARGET:"%"=%) 770 b2b8a696SStefan Roeseendif 771 b2b8a696SStefan Roese 772 ad0fed46SMasahiro YamadaLDFLAGS_u-boot += $(LDFLAGS_FINAL) 773 433b2f1eSMasahiro Yamadaifneq ($(CONFIG_SYS_TEXT_BASE),) 774 433b2f1eSMasahiro YamadaLDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE) 775 433b2f1eSMasahiro Yamadaendif 776 71f84ef0SMasahiro Yamada 777 f9c235fdSMasahiro Yamadaquiet_cmd_objcopy = OBJCOPY $@ 778 f9c235fdSMasahiro Yamadacmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ 779 f9c235fdSMasahiro Yamada 780 b97241b3SMarek Vasutquiet_cmd_mkimage = MKIMAGE $@ 781 9bf215b0SMasahiro Yamadacmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \ 782 9bf215b0SMasahiro Yamada $(if $(KBUILD_VERBOSE:1=), >/dev/null) 783 9bf215b0SMasahiro Yamada 784 ee0acfa2SMasahiro Yamadaquiet_cmd_cat = CAT $@ 785 ee0acfa2SMasahiro Yamadacmd_cat = cat $(filter-out $(PHONY), $^) > $@ 786 ee0acfa2SMasahiro Yamada 787 982a1199SMasahiro Yamadaappend = cat $(filter-out $< $(PHONY), $^) >> $@ 788 982a1199SMasahiro Yamada 789 982a1199SMasahiro Yamadaquiet_cmd_pad_cat = CAT $@ 790 982a1199SMasahiro Yamadacmd_pad_cat = $(cmd_objcopy) && $(append) || rm -f $@ 791 982a1199SMasahiro Yamada 792 656de6b8SMasahiro Yamadaall: $(ALL-y) 793 5add293bSMasahiro Yamadaifneq ($(CONFIG_SYS_GENERIC_BOARD),y) 794 5add293bSMasahiro Yamada @echo "===================== WARNING ======================" 795 5add293bSMasahiro Yamada @echo "Please convert this board to generic board." 796 5add293bSMasahiro Yamada @echo "Otherwise it will be removed by the end of 2014." 797 5add293bSMasahiro Yamada @echo "See doc/README.generic-board for further information" 798 5add293bSMasahiro Yamada @echo "====================================================" 799 5add293bSMasahiro Yamadaendif 800 73845350SSimon Glassifeq ($(CONFIG_DM_I2C_COMPAT),y) 801 73845350SSimon Glass @echo "===================== WARNING ======================" 802 73845350SSimon Glass @echo "This board uses CONFIG_DM_I2C_COMPAT. Please remove" 803 73845350SSimon Glass @echo "(possibly in a subsequent patch in your series)" 804 73845350SSimon Glass @echo "before sending patches to the mailing list." 805 73845350SSimon Glass @echo "====================================================" 806 73845350SSimon Glassendif 807 7ebf7443Swdenk 808 6ab6b2afSMasahiro YamadaPHONY += dtbs 809 6ab6b2afSMasahiro Yamadadtbs dts/dt.dtb: checkdtc u-boot 810 6ab6b2afSMasahiro Yamada $(Q)$(MAKE) $(build)=dts dtbs 811 2c0f79e4SSimon Glass 812 ee0acfa2SMasahiro Yamadau-boot-dtb.bin: u-boot.bin dts/dt.dtb FORCE 813 ee0acfa2SMasahiro Yamada $(call if_changed,cat) 814 2c0f79e4SSimon Glass 815 e64348f5SStefano Babic%.imx: %.bin 816 e64348f5SStefano Babic $(Q)$(MAKE) $(build)=arch/arm/imx-common $@ 817 e64348f5SStefano Babic 818 0d1e8aacSMasahiro Yamadaquiet_cmd_copy = COPY $@ 819 0d1e8aacSMasahiro Yamada cmd_copy = cp $< $@ 820 0d1e8aacSMasahiro Yamada 821 0d1e8aacSMasahiro Yamadau-boot.dtb: dts/dt.dtb 822 0d1e8aacSMasahiro Yamada $(call cmd,copy) 823 0d1e8aacSMasahiro Yamada 824 f9c235fdSMasahiro YamadaOBJCOPYFLAGS_u-boot.hex := -O ihex 825 6310eb9dSwdenk 826 f9c235fdSMasahiro YamadaOBJCOPYFLAGS_u-boot.srec := -O srec 827 7ebf7443Swdenk 828 f9c235fdSMasahiro Yamadau-boot.hex u-boot.srec: u-boot FORCE 829 f9c235fdSMasahiro Yamada $(call if_changed,objcopy) 830 f9c235fdSMasahiro Yamada 831 fce7b276SSimon GlassOBJCOPYFLAGS_u-boot.bin := -O binary \ 832 fce7b276SSimon Glass $(if $(CONFIG_X86_RESET_VECTOR),-R .start16 -R .resetvec) 833 f9c235fdSMasahiro Yamada 834 3ce7a4feSChris Packhambinary_size_check: u-boot.bin FORCE 835 67b060b4SChris Packham @file_size=$(shell wc -c u-boot.bin | awk '{print $$1}') ; \ 836 3ce7a4feSChris Packham map_size=$(shell cat u-boot.map | \ 837 0b308f14SSimon Glass awk '/_image_copy_start/ {start = $$1} /_image_binary_end/ {end = $$1} END {if (start != "" && end != "") print "ibase=16; " toupper(end) " - " toupper(start)}' \ 838 3ce7a4feSChris Packham | sed 's/0X//g' \ 839 0b308f14SSimon Glass | bc); \ 840 89742924SSimon Glass if [ "" != "$$map_size" ]; then \ 841 89742924SSimon Glass if test $$map_size -ne $$file_size; then \ 842 3ce7a4feSChris Packham echo "u-boot.map shows a binary size of $$map_size" >&2 ; \ 843 89742924SSimon Glass echo " but u-boot.bin shows $$file_size" >&2 ; \ 844 89742924SSimon Glass exit 1; \ 845 89742924SSimon Glass fi \ 846 89742924SSimon Glass fi 847 89742924SSimon Glass 848 f9c235fdSMasahiro Yamadau-boot.bin: u-boot FORCE 849 f9c235fdSMasahiro Yamada $(call if_changed,objcopy) 850 8137af19SScott Wood $(call DO_STATIC_RELA,$<,$@,$(CONFIG_SYS_TEXT_BASE)) 851 f3a14d37SMike Frysinger $(BOARD_SIZE_CHECK) 852 7ebf7443Swdenk 853 9e414032SMasahiro Yamadau-boot.ldr: u-boot 854 76d82187SMike Frysinger $(CREATE_LDR_ENV) 855 240182d5SSonic Zhang $(LDR) -T $(CONFIG_CPU) -c $@ $< $(LDR_FLAGS) 856 f3a14d37SMike Frysinger $(BOARD_SIZE_CHECK) 857 94a91e24SMike Frysinger 858 f9c235fdSMasahiro YamadaOBJCOPYFLAGS_u-boot.ldr.hex := -I binary -O ihex 859 94a91e24SMike Frysinger 860 f9c235fdSMasahiro YamadaOBJCOPYFLAGS_u-boot.ldr.srec := -I binary -O srec 861 f9c235fdSMasahiro Yamada 862 f9c235fdSMasahiro Yamadau-boot.ldr.hex u-boot.ldr.srec: u-boot.ldr FORCE 863 f9c235fdSMasahiro Yamada $(call if_changed,objcopy) 864 94a91e24SMike Frysinger 865 b40bda6bSStefan Roese# 866 b40bda6bSStefan Roese# U-Boot entry point, needed for booting of full-blown U-Boot 867 b40bda6bSStefan Roese# from the SPL U-Boot version. 868 b40bda6bSStefan Roese# 869 b40bda6bSStefan Roeseifndef CONFIG_SYS_UBOOT_START 870 b40bda6bSStefan RoeseCONFIG_SYS_UBOOT_START := 0 871 b40bda6bSStefan Roeseendif 872 b40bda6bSStefan Roese 873 9bf215b0SMasahiro YamadaMKIMAGEFLAGS_u-boot.img = -A $(ARCH) -T firmware -C none -O u-boot \ 874 9bf215b0SMasahiro Yamada -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \ 875 9bf215b0SMasahiro Yamada -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" 876 9bf215b0SMasahiro Yamada 877 4ab3fc5eSMasahiro YamadaMKIMAGEFLAGS_u-boot.kwb = -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) \ 878 4ab3fc5eSMasahiro Yamada -T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) 879 9bf215b0SMasahiro Yamada 880 a90ffb56SStefan RoeseMKIMAGEFLAGS_u-boot-spl.kwb = -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) \ 881 a90ffb56SStefan Roese -T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) 882 a90ffb56SStefan Roese 883 e4536f8eSMasahiro YamadaMKIMAGEFLAGS_u-boot.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \ 884 e4536f8eSMasahiro Yamada -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimage 885 9bf215b0SMasahiro Yamada 886 d18926afSSimon Glassu-boot.img u-boot.kwb u-boot.pbl: u-boot.bin FORCE 887 9bf215b0SMasahiro Yamada $(call if_changed,mkimage) 888 bdccc4feSwdenk 889 a90ffb56SStefan Roeseu-boot-spl.kwb: u-boot.img spl/u-boot-spl.bin FORCE 890 a90ffb56SStefan Roese $(call if_changed,mkimage) 891 a90ffb56SStefan Roese 892 2405d09cSMasahiro YamadaMKIMAGEFLAGS_u-boot-dtb.img = $(MKIMAGEFLAGS_u-boot.img) 893 2405d09cSMasahiro Yamada 894 2405d09cSMasahiro Yamadau-boot-dtb.img: u-boot-dtb.bin FORCE 895 2405d09cSMasahiro Yamada $(call if_changed,mkimage) 896 2405d09cSMasahiro Yamada 897 9e414032SMasahiro Yamadau-boot.sha1: u-boot.bin 898 9e414032SMasahiro Yamada tools/ubsha1 u-boot.bin 899 566a494fSHeiko Schocher 900 9e414032SMasahiro Yamadau-boot.dis: u-boot 901 7ebf7443Swdenk $(OBJDUMP) -d $< > $@ 902 7ebf7443Swdenk 903 3aa29de0SYing Zhangifdef CONFIG_TPL 904 9e414032SMasahiro YamadaSPL_PAYLOAD := tpl/u-boot-with-tpl.bin 905 3aa29de0SYing Zhangelse 906 9e414032SMasahiro YamadaSPL_PAYLOAD := u-boot.bin 907 3aa29de0SYing Zhangendif 908 74752baaSScott Wood 909 982a1199SMasahiro YamadaOBJCOPYFLAGS_u-boot-with-spl.bin = -I binary -O binary \ 910 982a1199SMasahiro Yamada --pad-to=$(CONFIG_SPL_PAD_TO) 911 982a1199SMasahiro Yamadau-boot-with-spl.bin: spl/u-boot-spl.bin $(SPL_PAYLOAD) FORCE 912 982a1199SMasahiro Yamada $(call if_changed,pad_cat) 913 3aa29de0SYing Zhang 914 412ae53aSAlbert ARIBAUD \(3ADEV\)MKIMAGEFLAGS_lpc32xx-spl.img = -T lpc32xximage -a $(CONFIG_SPL_TEXT_BASE) 915 412ae53aSAlbert ARIBAUD \(3ADEV\) 916 412ae53aSAlbert ARIBAUD \(3ADEV\)lpc32xx-spl.img: spl/u-boot-spl.bin FORCE 917 412ae53aSAlbert ARIBAUD \(3ADEV\) $(call if_changed,mkimage) 918 412ae53aSAlbert ARIBAUD \(3ADEV\) 919 412ae53aSAlbert ARIBAUD \(3ADEV\)OBJCOPYFLAGS_lpc32xx-boot-0.bin = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) 920 412ae53aSAlbert ARIBAUD \(3ADEV\) 921 412ae53aSAlbert ARIBAUD \(3ADEV\)lpc32xx-boot-0.bin: lpc32xx-spl.img 922 412ae53aSAlbert ARIBAUD \(3ADEV\) $(call if_changed,objcopy) 923 412ae53aSAlbert ARIBAUD \(3ADEV\) 924 412ae53aSAlbert ARIBAUD \(3ADEV\)OBJCOPYFLAGS_lpc32xx-boot-1.bin = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) 925 412ae53aSAlbert ARIBAUD \(3ADEV\) 926 412ae53aSAlbert ARIBAUD \(3ADEV\)lpc32xx-boot-1.bin: lpc32xx-spl.img 927 412ae53aSAlbert ARIBAUD \(3ADEV\) $(call if_changed,objcopy) 928 412ae53aSAlbert ARIBAUD \(3ADEV\) 929 412ae53aSAlbert ARIBAUD \(3ADEV\)lpc32xx-full.bin: lpc32xx-boot-0.bin lpc32xx-boot-1.bin u-boot.img 930 412ae53aSAlbert ARIBAUD \(3ADEV\) $(call if_changed,cat) 931 412ae53aSAlbert ARIBAUD \(3ADEV\) 932 412ae53aSAlbert ARIBAUD \(3ADEV\)CLEAN_FILES += lpc32xx-* 933 412ae53aSAlbert ARIBAUD \(3ADEV\) 934 982a1199SMasahiro YamadaOBJCOPYFLAGS_u-boot-with-tpl.bin = -I binary -O binary \ 935 982a1199SMasahiro Yamada --pad-to=$(CONFIG_TPL_PAD_TO) 936 982a1199SMasahiro Yamadatpl/u-boot-with-tpl.bin: tpl/u-boot-tpl.bin u-boot.bin FORCE 937 982a1199SMasahiro Yamada $(call if_changed,pad_cat) 938 7816f2cfSHeiko Schocher 939 630d2345SMasahiro YamadaSPL: spl/u-boot-spl.bin FORCE 940 630d2345SMasahiro Yamada $(Q)$(MAKE) $(build)=arch/arm/imx-common $@ 941 630d2345SMasahiro Yamada 942 630d2345SMasahiro Yamadau-boot-with-spl.imx u-boot-with-nand-spl.imx: SPL u-boot.bin FORCE 943 4e0c8abcSMasahiro Yamada $(Q)$(MAKE) $(build)=arch/arm/imx-common $@ 944 7d5a5c79SBenoît Thébaudeau 945 9bf215b0SMasahiro YamadaMKIMAGEFLAGS_u-boot.ubl = -n $(UBL_CONFIG) -T ublimage -e $(CONFIG_SYS_TEXT_BASE) 946 9bf215b0SMasahiro Yamada 947 9bf215b0SMasahiro Yamadau-boot.ubl: u-boot-with-spl.bin FORCE 948 9bf215b0SMasahiro Yamada $(call if_changed,mkimage) 949 277f00f5SJosé Miguel Gonçalves 950 982a1199SMasahiro YamadaMKIMAGEFLAGS_u-boot-spl.ais = -s -n $(if $(CONFIG_AIS_CONFIG_FILE), \ 951 982a1199SMasahiro Yamada $(srctree)/$(CONFIG_AIS_CONFIG_FILE:"%"=%),"/dev/null") \ 952 982a1199SMasahiro Yamada -T aisimage -e $(CONFIG_SPL_TEXT_BASE) 953 982a1199SMasahiro Yamadaspl/u-boot-spl.ais: spl/u-boot-spl.bin FORCE 954 982a1199SMasahiro Yamada $(call if_changed,mkimage) 955 d36d8859SChristian Riesch 956 532d5318SChristian RieschOBJCOPYFLAGS_u-boot.ais = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) 957 982a1199SMasahiro Yamadau-boot.ais: spl/u-boot-spl.ais u-boot.img FORCE 958 982a1199SMasahiro Yamada $(call if_changed,pad_cat) 959 a5453555SOtavio Salvador 960 1a9df13dSMarek Vasutu-boot-signed.sb: u-boot.bin spl/u-boot-spl.bin 961 1a9df13dSMarek Vasut $(Q)$(MAKE) $(build)=arch/arm/cpu/arm926ejs/mxs u-boot-signed.sb 962 9e414032SMasahiro Yamadau-boot.sb: u-boot.bin spl/u-boot-spl.bin 963 07e27ce0SMasahiro Yamada $(Q)$(MAKE) $(build)=arch/arm/cpu/arm926ejs/mxs u-boot.sb 964 30b9b932SMarek Vasut 965 94aebe6cSStefan Roese# On x600 (SPEAr600) U-Boot is appended to U-Boot SPL. 966 94aebe6cSStefan Roese# Both images are created using mkimage (crc etc), so that the ROM 967 94aebe6cSStefan Roese# bootloader can check its integrity. Padding needs to be done to the 968 94aebe6cSStefan Roese# SPL image (with mkimage header) and not the binary. Otherwise the resulting image 969 94aebe6cSStefan Roese# which is loaded/copied by the ROM bootloader to SRAM doesn't fit. 970 94aebe6cSStefan Roese# The resulting image containing both U-Boot images is called u-boot.spr 971 982a1199SMasahiro YamadaMKIMAGEFLAGS_u-boot-spl.img = -A $(ARCH) -T firmware -C none \ 972 982a1199SMasahiro Yamada -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER 973 982a1199SMasahiro Yamadaspl/u-boot-spl.img: spl/u-boot-spl.bin FORCE 974 982a1199SMasahiro Yamada $(call if_changed,mkimage) 975 982a1199SMasahiro Yamada 976 982a1199SMasahiro YamadaOBJCOPYFLAGS_u-boot.spr = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) \ 977 982a1199SMasahiro Yamada --gap-fill=0xff 978 982a1199SMasahiro Yamadau-boot.spr: spl/u-boot-spl.img u-boot.img FORCE 979 982a1199SMasahiro Yamada $(call if_changed,pad_cat) 980 94aebe6cSStefan Roese 981 ef509b90SVitaly AndrianovMKIMAGEFLAGS_u-boot-spl.gph = -A $(ARCH) -T gpimage -C none \ 982 ef509b90SVitaly Andrianov -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n SPL 983 ef509b90SVitaly Andrianovspl/u-boot-spl.gph: spl/u-boot-spl.bin FORCE 984 ef509b90SVitaly Andrianov $(call if_changed,mkimage) 985 ef509b90SVitaly Andrianov 986 ef509b90SVitaly AndrianovOBJCOPYFLAGS_u-boot-spi.gph = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) \ 987 ef509b90SVitaly Andrianov --gap-fill=0 988 ef509b90SVitaly Andrianovu-boot-spi.gph: spl/u-boot-spl.gph u-boot.img FORCE 989 ef509b90SVitaly Andrianov $(call if_changed,pad_cat) 990 ef509b90SVitaly Andrianov 991 0e7f2dbaSKhoronzhuk, IvanMKIMAGEFLAGS_u-boot-nand.gph = -A $(ARCH) -T gpimage -C none \ 992 0e7f2dbaSKhoronzhuk, Ivan -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) -n U-Boot 993 0e7f2dbaSKhoronzhuk, Ivanu-boot-nand.gph: u-boot.bin FORCE 994 0e7f2dbaSKhoronzhuk, Ivan $(call if_changed,mkimage) 995 0e7f2dbaSKhoronzhuk, Ivan @dd if=/dev/zero bs=8 count=1 2>/dev/null >> $@ 996 0e7f2dbaSKhoronzhuk, Ivan 997 fce7b276SSimon Glass# x86 uses a large ROM. We fill it with 0xff, put the 16-bit stuff (including 998 fce7b276SSimon Glass# reset vector) at the top, Intel ME descriptor at the bottom, and U-Boot in 999 fce7b276SSimon Glass# the middle. 1000 fce7b276SSimon Glassifneq ($(CONFIG_X86_RESET_VECTOR),) 1001 fce7b276SSimon Glassrom: u-boot.rom FORCE 1002 fce7b276SSimon Glass 1003 c7016234SBin MengIFDTOOL=$(objtree)/tools/ifdtool 1004 0f61de8dSSimon GlassIFDTOOL_FLAGS = -f 0:$(objtree)/u-boot.dtb 1005 0f61de8dSSimon GlassIFDTOOL_FLAGS += -m 0x$(shell $(NM) u-boot |grep _dt_ucode_base_size |cut -d' ' -f1) 1006 0f61de8dSSimon GlassIFDTOOL_FLAGS += -U $(CONFIG_SYS_TEXT_BASE):$(objtree)/u-boot.bin 1007 c7016234SBin MengIFDTOOL_FLAGS += -w $(CONFIG_SYS_X86_START16):$(objtree)/u-boot-x86-16bit.bin 1008 c7016234SBin Meng 1009 c7016234SBin Mengifneq ($(CONFIG_HAVE_INTEL_ME),) 1010 c7016234SBin MengIFDTOOL_ME_FLAGS = -D $(srctree)/board/$(BOARDDIR)/descriptor.bin 1011 c7016234SBin MengIFDTOOL_ME_FLAGS += -i ME:$(srctree)/board/$(BOARDDIR)/me.bin 1012 c7016234SBin Mengendif 1013 c7016234SBin Meng 1014 c7016234SBin Mengifneq ($(CONFIG_HAVE_MRC),) 1015 8c5224c9SBin MengIFDTOOL_FLAGS += -w $(CONFIG_X86_MRC_ADDR):$(srctree)/board/$(BOARDDIR)/mrc.bin 1016 c7016234SBin Mengendif 1017 c7016234SBin Meng 1018 63faf250SBin Mengifneq ($(CONFIG_HAVE_FSP),) 1019 63faf250SBin MengIFDTOOL_FLAGS += -w $(CONFIG_FSP_ADDR):$(srctree)/board/$(BOARDDIR)/$(CONFIG_FSP_FILE) 1020 63faf250SBin Mengendif 1021 63faf250SBin Meng 1022 63faf250SBin Mengifneq ($(CONFIG_HAVE_CMC),) 1023 63faf250SBin MengIFDTOOL_FLAGS += -w $(CONFIG_CMC_ADDR):$(srctree)/board/$(BOARDDIR)/$(CONFIG_CMC_FILE) 1024 63faf250SBin Mengendif 1025 63faf250SBin Meng 1026 c7016234SBin Mengifneq ($(CONFIG_X86_OPTION_ROM_ADDR),) 1027 63faf250SBin MengIFDTOOL_FLAGS += -w $(CONFIG_X86_OPTION_ROM_ADDR):$(srctree)/board/$(BOARDDIR)/$(CONFIG_X86_OPTION_ROM_FILE) 1028 c7016234SBin Mengendif 1029 c7016234SBin Meng 1030 c7016234SBin Mengquiet_cmd_ifdtool = IFDTOOL $@ 1031 c7016234SBin Mengcmd_ifdtool = $(IFDTOOL) -c -r $(CONFIG_ROM_SIZE) u-boot.tmp; 1032 c7016234SBin Mengifneq ($(CONFIG_HAVE_INTEL_ME),) 1033 c7016234SBin Mengcmd_ifdtool += $(IFDTOOL) $(IFDTOOL_ME_FLAGS) u-boot.tmp; 1034 c7016234SBin Mengendif 1035 c7016234SBin Mengcmd_ifdtool += $(IFDTOOL) $(IFDTOOL_FLAGS) u-boot.tmp; 1036 c7016234SBin Mengcmd_ifdtool += mv u-boot.tmp $@ 1037 c7016234SBin Meng 1038 c7016234SBin Mengu-boot.rom: u-boot-x86-16bit.bin u-boot-dtb.bin 1039 c7016234SBin Meng $(call if_changed,ifdtool) 1040 fce7b276SSimon Glass 1041 fce7b276SSimon GlassOBJCOPYFLAGS_u-boot-x86-16bit.bin := -O binary -j .start16 -j .resetvec 1042 fce7b276SSimon Glassu-boot-x86-16bit.bin: u-boot FORCE 1043 fce7b276SSimon Glass $(call if_changed,objcopy) 1044 fce7b276SSimon Glassendif 1045 fce7b276SSimon Glass 1046 50827a59SIan Campbellifneq ($(CONFIG_SUNXI),) 1047 50827a59SIan CampbellOBJCOPYFLAGS_u-boot-sunxi-with-spl.bin = -I binary -O binary \ 1048 50827a59SIan Campbell --pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff 1049 57f878efSSimon Glassu-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin \ 1050 57f878efSSimon Glass u-boot$(if $(CONFIG_OF_CONTROL),-dtb,).img FORCE 1051 50827a59SIan Campbell $(call if_changed,pad_cat) 1052 50827a59SIan Campbellendif 1053 50827a59SIan Campbell 1054 6d6c0baeSTom Warrenifneq ($(CONFIG_TEGRA),) 1055 982a1199SMasahiro YamadaOBJCOPYFLAGS_u-boot-nodtb-tegra.bin = -O binary --pad-to=$(CONFIG_SYS_TEXT_BASE) 1056 982a1199SMasahiro Yamadau-boot-nodtb-tegra.bin: spl/u-boot-spl u-boot.bin FORCE 1057 982a1199SMasahiro Yamada $(call if_changed,pad_cat) 1058 9972db5cSStephen Warren 1059 9972db5cSStephen Warrenifeq ($(CONFIG_OF_SEPARATE),y) 1060 ee0acfa2SMasahiro Yamadau-boot-dtb-tegra.bin: u-boot-nodtb-tegra.bin dts/dt.dtb FORCE 1061 ee0acfa2SMasahiro Yamada $(call if_changed,cat) 1062 9972db5cSStephen Warrenendif 1063 984df4ecSAllen Martinendif 1064 984df4ecSAllen Martin 1065 ee0acfa2SMasahiro Yamadau-boot-img.bin: spl/u-boot-spl.bin u-boot.img FORCE 1066 ee0acfa2SMasahiro Yamada $(call if_changed,cat) 1067 fb3d2b8aSStefan Roese 1068 89ad7be8SPrabhakar Kushwaha#Add a target to create boot binary having SPL binary in PBI format 1069 89ad7be8SPrabhakar Kushwaha#concatenated with u-boot binary. It is need by PowerPC SoC having 1070 89ad7be8SPrabhakar Kushwaha#internal SRAM <= 512KB. 1071 89ad7be8SPrabhakar KushwahaMKIMAGEFLAGS_u-boot-spl.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \ 1072 94cb17d0SAlison Wang -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimage \ 1073 94cb17d0SAlison Wang -A $(ARCH) -a $(CONFIG_SPL_TEXT_BASE) 1074 89ad7be8SPrabhakar Kushwaha 1075 89ad7be8SPrabhakar Kushwahaspl/u-boot-spl.pbl: spl/u-boot-spl.bin FORCE 1076 89ad7be8SPrabhakar Kushwaha $(call if_changed,mkimage) 1077 89ad7be8SPrabhakar Kushwaha 1078 45c2e480SAlison Wangifeq ($(ARCH),arm) 1079 45c2e480SAlison WangUBOOT_BINLOAD := u-boot.img 1080 45c2e480SAlison Wangelse 1081 45c2e480SAlison WangUBOOT_BINLOAD := u-boot.bin 1082 45c2e480SAlison Wangendif 1083 45c2e480SAlison Wang 1084 89ad7be8SPrabhakar KushwahaOBJCOPYFLAGS_u-boot-with-spl-pbl.bin = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) \ 1085 89ad7be8SPrabhakar Kushwaha --gap-fill=0xff 1086 89ad7be8SPrabhakar Kushwaha 1087 45c2e480SAlison Wangu-boot-with-spl-pbl.bin: spl/u-boot-spl.pbl $(UBOOT_BINLOAD) FORCE 1088 89ad7be8SPrabhakar Kushwaha $(call if_changed,pad_cat) 1089 89ad7be8SPrabhakar Kushwaha 1090 ecddccd0SStefan Roese# PPC4xx needs the SPL at the end of the image, since the reset vector 1091 ecddccd0SStefan Roese# is located at 0xfffffffc. So we can't use the "u-boot-img.bin" target 1092 ecddccd0SStefan Roese# and need to introduce a new build target with the full blown U-Boot 1093 ecddccd0SStefan Roese# at the start padded up to the start of the SPL image. And then concat 1094 ecddccd0SStefan Roese# the SPL image to the end. 1095 982a1199SMasahiro Yamada 1096 982a1199SMasahiro YamadaOBJCOPYFLAGS_u-boot-img-spl-at-end.bin := -I binary -O binary \ 1097 982a1199SMasahiro Yamada --pad-to=$(CONFIG_UBOOT_PAD_TO) --gap-fill=0xff 1098 982a1199SMasahiro Yamadau-boot-img-spl-at-end.bin: u-boot.img spl/u-boot-spl.bin FORCE 1099 982a1199SMasahiro Yamada $(call if_changed,pad_cat) 1100 ecddccd0SStefan Roese 1101 f4dc714aSScott Wood# Create a new ELF from a raw binary file. This is useful for arm64 1102 f4dc714aSScott Wood# where static relocation needs to be performed on the raw binary, 1103 f4dc714aSScott Wood# but certain simulators only accept an ELF file (but don't do the 1104 f4dc714aSScott Wood# relocation). 1105 f4dc714aSScott Wood# FIXME refactor dts/Makefile to share target/arch detection 1106 9e414032SMasahiro Yamadau-boot.elf: u-boot.bin 1107 f4dc714aSScott Wood @$(OBJCOPY) -B aarch64 -I binary -O elf64-littleaarch64 \ 1108 9e414032SMasahiro Yamada $< u-boot-elf.o 1109 9e414032SMasahiro Yamada @$(LD) u-boot-elf.o -o $@ \ 1110 f4dc714aSScott Wood --defsym=_start=$(CONFIG_SYS_TEXT_BASE) \ 1111 f4dc714aSScott Wood -Ttext=$(CONFIG_SYS_TEXT_BASE) 1112 f4dc714aSScott Wood 1113 ad0fed46SMasahiro Yamada# Rule to link u-boot 1114 ad0fed46SMasahiro Yamada# May be overridden by arch/$(ARCH)/config.mk 1115 ad0fed46SMasahiro Yamadaquiet_cmd_u-boot__ ?= LD $@ 1116 ad0fed46SMasahiro Yamada cmd_u-boot__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_u-boot) -o $@ \ 1117 ad0fed46SMasahiro Yamada -T u-boot.lds $(u-boot-init) \ 1118 ad0fed46SMasahiro Yamada --start-group $(u-boot-main) --end-group \ 1119 ad0fed46SMasahiro Yamada $(PLATFORM_LIBS) -Map u-boot.map 1120 86eb49b3SSimon Glass 1121 cac8f38aSVasili Galkaquiet_cmd_smap = GEN common/system_map.o 1122 cac8f38aSVasili Galkacmd_smap = \ 1123 9e414032SMasahiro Yamada smap=`$(call SYSTEM_MAP,u-boot) | \ 1124 1aada9cdSWolfgang Denk awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \ 1125 6825a95bSMasahiro Yamada $(CC) $(c_flags) -DSYSTEM_MAP="\"$${smap}\"" \ 1126 9e414032SMasahiro Yamada -c $(srctree)/common/system_map.c -o common/system_map.o 1127 cac8f38aSVasili Galka 1128 cac8f38aSVasili Galkau-boot: $(u-boot-init) $(u-boot-main) u-boot.lds 1129 cac8f38aSVasili Galka $(call if_changed,u-boot__) 1130 cac8f38aSVasili Galkaifeq ($(CONFIG_KALLSYMS),y) 1131 cac8f38aSVasili Galka $(call cmd,smap) 1132 ad0fed46SMasahiro Yamada $(call cmd,u-boot__) common/system_map.o 1133 ecb1dc89SMike Frysingerendif 1134 7ebf7443Swdenk 1135 656de6b8SMasahiro Yamada# The actual objects are generated when descending, 1136 656de6b8SMasahiro Yamada# make sure no implicit rule kicks in 1137 656de6b8SMasahiro Yamada$(sort $(u-boot-init) $(u-boot-main)): $(u-boot-dirs) ; 1138 f9328639SMarian Balakowicz 1139 656de6b8SMasahiro Yamada# Handle descending into subdirectories listed in $(vmlinux-dirs) 1140 656de6b8SMasahiro Yamada# Preset locale variables to speed up the build process. Limit locale 1141 656de6b8SMasahiro Yamada# tweaks to this spot to avoid wrong language settings when running 1142 656de6b8SMasahiro Yamada# make menuconfig etc. 1143 656de6b8SMasahiro Yamada# Error messages still appears in the original language 1144 a8c7c708Swdenk 1145 656de6b8SMasahiro YamadaPHONY += $(u-boot-dirs) 1146 6378008aSMasahiro Yamada$(u-boot-dirs): prepare scripts 1147 6825a95bSMasahiro Yamada $(Q)$(MAKE) $(build)=$@ 1148 940db16dSMasahiro Yamada 1149 7424145fSMasahiro Yamadatools: prepare 1150 656de6b8SMasahiro Yamada# The "tools" are needed early 1151 656de6b8SMasahiro Yamada$(filter-out tools, $(u-boot-dirs)): tools 1152 656de6b8SMasahiro Yamada# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC 1153 656de6b8SMasahiro Yamada# is "yes"), so compile examples after U-Boot is compiled. 1154 656de6b8SMasahiro Yamadaexamples: $(filter-out examples, $(u-boot-dirs)) 1155 656de6b8SMasahiro Yamada 1156 7424145fSMasahiro Yamadadefine filechk_uboot.release 1157 7424145fSMasahiro Yamada echo "$(UBOOTVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" 1158 7424145fSMasahiro Yamadaendef 1159 7424145fSMasahiro Yamada 1160 7424145fSMasahiro Yamada# Store (new) UBOOTRELEASE string in include/config/uboot.release 1161 51148790SMasahiro Yamadainclude/config/uboot.release: include/config/auto.conf FORCE 1162 7424145fSMasahiro Yamada $(call filechk,uboot.release) 1163 7424145fSMasahiro Yamada 1164 7424145fSMasahiro Yamada 1165 3341bfecSMasahiro Yamada# Things we need to do before we recursively start building the kernel 1166 3341bfecSMasahiro Yamada# or the modules are listed in "prepare". 1167 3341bfecSMasahiro Yamada# A multi level approach is used. prepareN is processed before prepareN-1. 1168 3341bfecSMasahiro Yamada# archprepare is used in arch Makefiles and when processed asm symlink, 1169 3341bfecSMasahiro Yamada# version.h and scripts_basic is processed / created. 1170 3341bfecSMasahiro Yamada 1171 3341bfecSMasahiro Yamada# Listed in dependency order 1172 3341bfecSMasahiro YamadaPHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3 1173 3341bfecSMasahiro Yamada 1174 3341bfecSMasahiro Yamada# prepare3 is used to check if we are building in a separate output directory, 1175 3341bfecSMasahiro Yamada# and if so do: 1176 3341bfecSMasahiro Yamada# 1) Check that make has not been executed in the kernel src $(srctree) 1177 7424145fSMasahiro Yamadaprepare3: include/config/uboot.release 1178 3341bfecSMasahiro Yamadaifneq ($(KBUILD_SRC),) 1179 51148790SMasahiro Yamada @$(kecho) ' Using $(srctree) as source for U-Boot' 1180 51148790SMasahiro Yamada $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \ 1181 3341bfecSMasahiro Yamada echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \ 1182 3341bfecSMasahiro Yamada echo >&2 " in the '$(srctree)' directory.";\ 1183 3341bfecSMasahiro Yamada /bin/false; \ 1184 3341bfecSMasahiro Yamada fi; 1185 3341bfecSMasahiro Yamadaendif 1186 3341bfecSMasahiro Yamada 1187 3341bfecSMasahiro Yamada# prepare2 creates a makefile if using a separate output directory 1188 3341bfecSMasahiro Yamadaprepare2: prepare3 outputmakefile 1189 3341bfecSMasahiro Yamada 1190 51148790SMasahiro Yamadaprepare1: prepare2 $(version_h) $(timestamp_h) \ 1191 51148790SMasahiro Yamada include/config/auto.conf 1192 0a12e687SMasahiro Yamadaifeq ($(CONFIG_HAVE_GENERIC_BOARD),) 1193 331b45fbSMasahiro Yamadaifeq ($(CONFIG_SYS_GENERIC_BOARD),y) 1194 331b45fbSMasahiro Yamada @echo >&2 " Your architecture does not support generic board." 1195 331b45fbSMasahiro Yamada @echo >&2 " Please undefine CONFIG_SYS_GENERIC_BOARD in your board config file." 1196 331b45fbSMasahiro Yamada @/bin/false 1197 331b45fbSMasahiro Yamadaendif 1198 331b45fbSMasahiro Yamadaendif 1199 4a377552SMasahiro Yamadaifeq ($(wildcard $(LDSCRIPT)),) 1200 4a377552SMasahiro Yamada @echo >&2 " Could not find linker script." 1201 4a377552SMasahiro Yamada @/bin/false 1202 4a377552SMasahiro Yamadaendif 1203 7ebf7443Swdenk 1204 3341bfecSMasahiro Yamadaarchprepare: prepare1 scripts_basic 1205 a8c7c708Swdenk 1206 6a44d806SMasahiro Yamadaprepare0: archprepare FORCE 1207 6a44d806SMasahiro Yamada $(Q)$(MAKE) $(build)=. 1208 7ebf7443Swdenk 1209 3341bfecSMasahiro Yamada# All the preparing.. 1210 3341bfecSMasahiro Yamadaprepare: prepare0 1211 349e83f0SChe-liang Chiou 1212 7424145fSMasahiro Yamada# Generate some files 1213 7424145fSMasahiro Yamada# --------------------------------------------------------------------------- 1214 7424145fSMasahiro Yamada 1215 7424145fSMasahiro Yamadadefine filechk_version.h 1216 7424145fSMasahiro Yamada (echo \#define PLAIN_VERSION \"$(UBOOTRELEASE)\"; \ 1217 7424145fSMasahiro Yamada echo \#define U_BOOT_VERSION \"U-Boot \" PLAIN_VERSION; \ 1218 7424145fSMasahiro Yamada echo \#define CC_VERSION_STRING \"$$($(CC) --version | head -n 1)\"; \ 1219 7424145fSMasahiro Yamada echo \#define LD_VERSION_STRING \"$$($(LD) --version | head -n 1)\"; ) 1220 7424145fSMasahiro Yamadaendef 1221 7424145fSMasahiro Yamada 1222 7424145fSMasahiro Yamadadefine filechk_timestamp.h 1223 7424145fSMasahiro Yamada (LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"'; \ 1224 7424145fSMasahiro Yamada LC_ALL=C date +'#define U_BOOT_TIME "%T"') 1225 7424145fSMasahiro Yamadaendef 1226 7424145fSMasahiro Yamada 1227 2e6b2f6aSMasahiro Yamada$(version_h): include/config/uboot.release FORCE 1228 7424145fSMasahiro Yamada $(call filechk,version.h) 1229 7424145fSMasahiro Yamada 1230 7424145fSMasahiro Yamada$(timestamp_h): $(srctree)/Makefile FORCE 1231 7424145fSMasahiro Yamada $(call filechk,timestamp.h) 1232 7424145fSMasahiro Yamada 1233 6378008aSMasahiro Yamada# --------------------------------------------------------------------------- 1234 6378008aSMasahiro Yamada 1235 6378008aSMasahiro YamadaPHONY += depend dep 1236 6378008aSMasahiro Yamadadepend dep: 1237 6378008aSMasahiro Yamada @echo '*** Warning: make $@ is unnecessary now.' 1238 6378008aSMasahiro Yamada 1239 6378008aSMasahiro Yamada# --------------------------------------------------------------------------- 1240 04a34c96SMasahiro Yamadaquiet_cmd_cpp_lds = LDS $@ 1241 395e60cdSMasahiro Yamadacmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \ 1242 395e60cdSMasahiro Yamada -D__ASSEMBLY__ -x assembler-with-cpp -P -o $@ $< 1243 6378008aSMasahiro Yamada 1244 04a34c96SMasahiro Yamadau-boot.lds: $(LDSCRIPT) prepare FORCE 1245 395e60cdSMasahiro Yamada $(call if_changed_dep,cpp_lds) 1246 1aada9cdSWolfgang Denk 1247 982a1199SMasahiro Yamadaspl/u-boot-spl.bin: spl/u-boot-spl 1248 982a1199SMasahiro Yamada @: 1249 982a1199SMasahiro Yamadaspl/u-boot-spl: tools prepare 1250 c7163083SMasahiro Yamada $(Q)$(MAKE) obj=spl -f $(srctree)/scripts/Makefile.spl all 1251 5df2ee27SDaniel Schwierzeck 1252 50827a59SIan Campbellspl/sunxi-spl.bin: spl/u-boot-spl 1253 50827a59SIan Campbell @: 1254 50827a59SIan Campbell 1255 6378008aSMasahiro Yamadatpl/u-boot-tpl.bin: tools prepare 1256 51148790SMasahiro Yamada $(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.spl all 1257 3aa29de0SYing Zhang 1258 8d819ab5SIgor GrinbergTAG_SUBDIRS := $(patsubst %,$(srctree)/%,$(u-boot-dirs) include) 1259 a340c325SJean-Christophe PLAGNIOL-VILLARD 1260 857d9ea6SHorst KronstorferFIND := find 1261 857d9ea6SHorst KronstorferFINDFLAGS := -L 1262 857d9ea6SHorst Kronstorfer 1263 f9328639SMarian Balakowicztags ctags: 1264 9e414032SMasahiro Yamada ctags -w -o ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \ 1265 e5e4e705SLi Yang -name '*.[chS]' -print` 1266 7ebf7443Swdenk 1267 7ebf7443Swdenketags: 1268 8d819ab5SIgor Grinberg etags -a -o etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \ 1269 e5e4e705SLi Yang -name '*.[chS]' -print` 1270 ffda586fSLi Yangcscope: 1271 857d9ea6SHorst Kronstorfer $(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \ 1272 857d9ea6SHorst Kronstorfer cscope.files 1273 ffda586fSLi Yang cscope -b -q -k 1274 7ebf7443Swdenk 1275 ecb1dc89SMike FrysingerSYSTEM_MAP = \ 1276 ecb1dc89SMike Frysinger $(NM) $1 | \ 1277 7ebf7443Swdenk grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ 1278 ecb1dc89SMike Frysinger LC_ALL=C sort 1279 9e414032SMasahiro YamadaSystem.map: u-boot 1280 bc8bb6ecSMasahiro Yamada @$(call SYSTEM_MAP,$<) > $@ 1281 7ebf7443Swdenk 1282 501ebdf2SStephen Warrencheckdtc: 1283 501ebdf2SStephen Warren @if test $(call dtc-version) -lt 0104; then \ 1284 501ebdf2SStephen Warren echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \ 1285 501ebdf2SStephen Warren false; \ 1286 501ebdf2SStephen Warren fi 1287 501ebdf2SStephen Warren 1288 7ebf7443Swdenk######################################################################### 1289 7ebf7443Swdenk 1290 54799e45SScott Wood# ARM relocations should all be R_ARM_RELATIVE (32-bit) or 1291 54799e45SScott Wood# R_AARCH64_RELATIVE (64-bit). 1292 9e414032SMasahiro Yamadacheckarmreloc: u-boot 1293 54799e45SScott Wood @RELOC="`$(CROSS_COMPILE)readelf -r -W $< | cut -d ' ' -f 4 | \ 1294 54799e45SScott Wood grep R_A | sort -u`"; \ 1295 54799e45SScott Wood if test "$$RELOC" != "R_ARM_RELATIVE" -a \ 1296 54799e45SScott Wood "$$RELOC" != "R_AARCH64_RELATIVE"; then \ 1297 54799e45SScott Wood echo "$< contains unexpected relocations: $$RELOC"; \ 1298 54799e45SScott Wood false; \ 1299 54799e45SScott Wood fi 1300 c37980c3SAlbert ARIBAUD 1301 7424145fSMasahiro Yamadaenv: scripts_basic 1302 3f76e984SMasahiro Yamada $(Q)$(MAKE) $(build)=tools/$@ 1303 0358df42SMike Frysinger 1304 4642e002SMasahiro Yamadatools-only: scripts_basic $(version_h) $(timestamp_h) 1305 4642e002SMasahiro Yamada $(Q)$(MAKE) $(build)=tools 1306 4642e002SMasahiro Yamada 1307 1ec8b4efSMasahiro Yamadatools-all: export HOST_TOOLS_ALL=y 1308 2887c473SMasahiro Yamadatools-all: env tools ; 1309 0358df42SMike Frysinger 1310 db5b339cSMasahiro Yamadacross_tools: export CROSS_BUILD_TOOLS=y 1311 db5b339cSMasahiro Yamadacross_tools: tools ; 1312 db5b339cSMasahiro Yamada 1313 4e53a258SWolfgang Denk.PHONY : CHANGELOG 1314 4e53a258SWolfgang DenkCHANGELOG: 1315 b985b5d6SBen Warren git log --no-merges U-Boot-1_1_5.. | \ 1316 b985b5d6SBen Warren unexpand -a | sed -e 's/\s\s*$$//' > $@ 1317 4e53a258SWolfgang Denk 1318 0a823aa2SHarald Welteinclude/license.h: tools/bin2header COPYING 1319 0a823aa2SHarald Welte cat COPYING | gzip -9 -c | ./tools/bin2header license_gzip > include/license.h 1320 7ebf7443Swdenk######################################################################### 1321 7ebf7443Swdenk 1322 efcf8619SMasahiro Yamada### 1323 efcf8619SMasahiro Yamada# Cleaning is done on three levels. 1324 efcf8619SMasahiro Yamada# make clean Delete most generated files 1325 efcf8619SMasahiro Yamada# Leave enough to build external modules 1326 efcf8619SMasahiro Yamada# make mrproper Delete the current configuration, and all generated files 1327 efcf8619SMasahiro Yamada# make distclean Remove editor backup files, patch leftover files and the like 1328 7ebf7443Swdenk 1329 efcf8619SMasahiro Yamada# Directories & files removed with 'make clean' 1330 48aa812dSMasahiro YamadaCLEAN_DIRS += $(MODVERDIR) \ 1331 48aa812dSMasahiro Yamada $(foreach d, spl tpl, $(patsubst %,$d/%, \ 1332 51148790SMasahiro Yamada $(filter-out include, $(shell ls -1 $d 2>/dev/null)))) 1333 48aa812dSMasahiro Yamada 1334 48aa812dSMasahiro YamadaCLEAN_FILES += include/bmp_logo.h include/bmp_logo_data.h \ 1335 2a50712eSBo Shen boot* u-boot* MLO* SPL System.map 1336 9f4a4206SMike Frysinger 1337 efcf8619SMasahiro Yamada# Directories & files removed with 'make mrproper' 1338 51148790SMasahiro YamadaMRPROPER_DIRS += include/config include/generated spl tpl \ 1339 598e2d33SMasahiro Yamada .tmp_objdiff 1340 51148790SMasahiro YamadaMRPROPER_FILES += .config .config.old include/autoconf.mk* include/config.h \ 1341 51148790SMasahiro Yamada ctags etags TAGS cscope* GPATH GTAGS GRTAGS GSYMS 1342 7ebf7443Swdenk 1343 efcf8619SMasahiro Yamada# clean - Delete most, but leave enough to build external modules 1344 efcf8619SMasahiro Yamada# 1345 efcf8619SMasahiro Yamadaclean: rm-dirs := $(CLEAN_DIRS) 1346 efcf8619SMasahiro Yamadaclean: rm-files := $(CLEAN_FILES) 1347 7ebf7443Swdenk 1348 6bd04bb4SMasahiro Yamadaclean-dirs := $(foreach f,$(u-boot-alldirs),$(if $(wildcard $(srctree)/$f/Makefile),$f)) 1349 734329f9SAndy Fleming 1350 efcf8619SMasahiro Yamadaclean-dirs := $(addprefix _clean_, $(clean-dirs) doc/DocBook) 1351 7ebf7443Swdenk 1352 efcf8619SMasahiro YamadaPHONY += $(clean-dirs) clean archclean 1353 efcf8619SMasahiro Yamada$(clean-dirs): 1354 efcf8619SMasahiro Yamada $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) 1355 efcf8619SMasahiro Yamada 1356 efcf8619SMasahiro Yamada# TODO: Do not use *.cfgtmp 1357 efcf8619SMasahiro Yamadaclean: $(clean-dirs) 1358 efcf8619SMasahiro Yamada $(call cmd,rmdirs) 1359 efcf8619SMasahiro Yamada $(call cmd,rmfiles) 1360 efcf8619SMasahiro Yamada @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ 1361 efcf8619SMasahiro Yamada \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ 1362 efcf8619SMasahiro Yamada -o -name '*.ko.*' -o -name '*.su' -o -name '*.cfgtmp' \ 1363 efcf8619SMasahiro Yamada -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ 1364 efcf8619SMasahiro Yamada -o -name '*.symtypes' -o -name 'modules.order' \ 1365 efcf8619SMasahiro Yamada -o -name modules.builtin -o -name '.tmp_*.o.*' \ 1366 efcf8619SMasahiro Yamada -o -name '*.gcno' \) -type f -print | xargs rm -f 1367 efcf8619SMasahiro Yamada 1368 efcf8619SMasahiro Yamada# mrproper - Delete all generated files, including .config 1369 efcf8619SMasahiro Yamada# 1370 efcf8619SMasahiro Yamadamrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS)) 1371 efcf8619SMasahiro Yamadamrproper: rm-files := $(wildcard $(MRPROPER_FILES)) 1372 efcf8619SMasahiro Yamadamrproper-dirs := $(addprefix _mrproper_,scripts) 1373 efcf8619SMasahiro Yamada 1374 efcf8619SMasahiro YamadaPHONY += $(mrproper-dirs) mrproper archmrproper 1375 efcf8619SMasahiro Yamada$(mrproper-dirs): 1376 efcf8619SMasahiro Yamada $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) 1377 efcf8619SMasahiro Yamada 1378 48aa812dSMasahiro Yamadamrproper: clean $(mrproper-dirs) 1379 efcf8619SMasahiro Yamada $(call cmd,rmdirs) 1380 efcf8619SMasahiro Yamada $(call cmd,rmfiles) 1381 e9c16a80SMasahiro Yamada @rm -f arch/*/include/asm/arch 1382 efcf8619SMasahiro Yamada 1383 efcf8619SMasahiro Yamada# distclean 1384 efcf8619SMasahiro Yamada# 1385 efcf8619SMasahiro YamadaPHONY += distclean 1386 efcf8619SMasahiro Yamada 1387 433b2f1eSMasahiro Yamadadistclean: mrproper 1388 efcf8619SMasahiro Yamada @find $(srctree) $(RCS_FIND_IGNORE) \ 1389 efcf8619SMasahiro Yamada \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ 1390 efcf8619SMasahiro Yamada -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ 1391 598e2d33SMasahiro Yamada -o -name '.*.rej' -o -name '*%' -o -name 'core' \ 1392 598e2d33SMasahiro Yamada -o -name '*.pyc' \) \ 1393 efcf8619SMasahiro Yamada -type f -print | xargs rm -f 1394 fd18a89eSRoger Meier @rm -f boards.cfg 1395 7ebf7443Swdenk 1396 7ebf7443Swdenkbackup: 1397 4379ac61SMasahiro Yamada F=`basename $(srctree)` ; cd .. ; \ 1398 d6b93714SIlya Yanok gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F 1399 7ebf7443Swdenk 1400 ed1ca528SMasahiro Yamadahelp: 1401 ed1ca528SMasahiro Yamada @echo 'Cleaning targets:' 1402 48aa812dSMasahiro Yamada @echo ' clean - Remove most generated files but keep the config' 1403 ed1ca528SMasahiro Yamada @echo ' mrproper - Remove all generated files + config + various backup files' 1404 ed1ca528SMasahiro Yamada @echo ' distclean - mrproper + remove editor backup and patch files' 1405 ed1ca528SMasahiro Yamada @echo '' 1406 51148790SMasahiro Yamada @echo 'Configuration targets:' 1407 51148790SMasahiro Yamada @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help 1408 51148790SMasahiro Yamada @echo '' 1409 ed1ca528SMasahiro Yamada @echo 'Other generic targets:' 1410 ed1ca528SMasahiro Yamada @echo ' all - Build all necessary images depending on configuration' 1411 ffe29ebcSMasahiro Yamada @echo '* u-boot - Build the bare u-boot' 1412 ed1ca528SMasahiro Yamada @echo ' dir/ - Build all files in dir and below' 1413 ed1ca528SMasahiro Yamada @echo ' dir/file.[oisS] - Build specified target only' 1414 ed1ca528SMasahiro Yamada @echo ' dir/file.lst - Build specified mixed source/assembly target only' 1415 ed1ca528SMasahiro Yamada @echo ' (requires a recent binutils and recent build (System.map))' 1416 5fc2f924SIgor Grinberg @echo ' tags/ctags - Generate ctags file for editors' 1417 5fc2f924SIgor Grinberg @echo ' etags - Generate etags file for editors' 1418 ed1ca528SMasahiro Yamada @echo ' cscope - Generate cscope index' 1419 ffe29ebcSMasahiro Yamada @echo ' ubootrelease - Output the release version string (use with make -s)' 1420 ffe29ebcSMasahiro Yamada @echo ' ubootversion - Output the version stored in Makefile (use with make -s)' 1421 ed1ca528SMasahiro Yamada @echo '' 1422 ed1ca528SMasahiro Yamada @echo 'Static analysers' 1423 ed1ca528SMasahiro Yamada @echo ' checkstack - Generate a list of stack hogs' 1424 ed1ca528SMasahiro Yamada @echo '' 1425 ed1ca528SMasahiro Yamada @echo 'Documentation targets:' 1426 ed1ca528SMasahiro Yamada @$(MAKE) -f $(srctree)/doc/DocBook/Makefile dochelp 1427 ed1ca528SMasahiro Yamada @echo '' 1428 ed1ca528SMasahiro Yamada @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' 1429 ed1ca528SMasahiro Yamada @echo ' make V=2 [targets] 2 => give reason for rebuild of target' 1430 ed1ca528SMasahiro Yamada @echo ' make O=dir [targets] Locate all output files in "dir", including .config' 1431 ed1ca528SMasahiro Yamada @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)' 1432 ed1ca528SMasahiro Yamada @echo ' make C=2 [targets] Force check of all c source with $$CHECK' 1433 ed1ca528SMasahiro Yamada @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections' 1434 ed1ca528SMasahiro Yamada @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where' 1435 ed1ca528SMasahiro Yamada @echo ' 1: warnings which may be relevant and do not occur too often' 1436 ed1ca528SMasahiro Yamada @echo ' 2: warnings which occur quite often but may still be relevant' 1437 ed1ca528SMasahiro Yamada @echo ' 3: more obscure warnings, can most likely be ignored' 1438 ed1ca528SMasahiro Yamada @echo ' Multiple levels can be combined with W=12 or W=123' 1439 ed1ca528SMasahiro Yamada @echo '' 1440 ed1ca528SMasahiro Yamada @echo 'Execute "make" or "make all" to build all targets marked with [*] ' 1441 ed1ca528SMasahiro Yamada @echo 'For further info see the ./README file' 1442 ed1ca528SMasahiro Yamada 1443 8fac9c7bSMasahiro Yamada 1444 8fac9c7bSMasahiro Yamada# Documentation targets 1445 8fac9c7bSMasahiro Yamada# --------------------------------------------------------------------------- 1446 8fac9c7bSMasahiro Yamada%docs: scripts_basic FORCE 1447 8fac9c7bSMasahiro Yamada $(Q)$(MAKE) $(build)=scripts build_docproc 1448 8fac9c7bSMasahiro Yamada $(Q)$(MAKE) $(build)=doc/DocBook $@ 1449 8fac9c7bSMasahiro Yamada 1450 3341bfecSMasahiro Yamada# Dummies... 1451 3341bfecSMasahiro YamadaPHONY += prepare scripts 1452 3341bfecSMasahiro Yamadaprepare: ; 1453 3341bfecSMasahiro Yamadascripts: ; 1454 9e414032SMasahiro Yamada 1455 433b2f1eSMasahiro Yamadaendif #ifeq ($(config-targets),1) 1456 433b2f1eSMasahiro Yamadaendif #ifeq ($(mixed-targets),1) 1457 433b2f1eSMasahiro Yamada 1458 ed1ca528SMasahiro YamadaPHONY += checkstack ubootrelease ubootversion 1459 ed1ca528SMasahiro Yamada 1460 ed1ca528SMasahiro Yamadacheckstack: 1461 ed1ca528SMasahiro Yamada $(OBJDUMP) -d u-boot $$(find . -name u-boot-spl) | \ 1462 ed1ca528SMasahiro Yamada $(PERL) $(src)/scripts/checkstack.pl $(ARCH) 1463 ed1ca528SMasahiro Yamada 1464 ed1ca528SMasahiro Yamadaubootrelease: 1465 ed1ca528SMasahiro Yamada @echo "$(UBOOTVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" 1466 ed1ca528SMasahiro Yamada 1467 ed1ca528SMasahiro Yamadaubootversion: 1468 ed1ca528SMasahiro Yamada @echo $(UBOOTVERSION) 1469 ed1ca528SMasahiro Yamada 1470 886d86e8SMasahiro Yamada# Single targets 1471 886d86e8SMasahiro Yamada# --------------------------------------------------------------------------- 1472 886d86e8SMasahiro Yamada# Single targets are compatible with: 1473 886d86e8SMasahiro Yamada# - build with mixed source and output 1474 886d86e8SMasahiro Yamada# - build with separate output dir 'make O=...' 1475 886d86e8SMasahiro Yamada# - external modules 1476 886d86e8SMasahiro Yamada# 1477 886d86e8SMasahiro Yamada# target-dir => where to store outputfile 1478 886d86e8SMasahiro Yamada# build-dir => directory in kernel source tree to use 1479 886d86e8SMasahiro Yamada 1480 886d86e8SMasahiro Yamadaifeq ($(KBUILD_EXTMOD),) 1481 886d86e8SMasahiro Yamada build-dir = $(patsubst %/,%,$(dir $@)) 1482 886d86e8SMasahiro Yamada target-dir = $(dir $@) 1483 886d86e8SMasahiro Yamadaelse 1484 886d86e8SMasahiro Yamada zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@))) 1485 886d86e8SMasahiro Yamada build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash)) 1486 886d86e8SMasahiro Yamada target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@)) 1487 886d86e8SMasahiro Yamadaendif 1488 886d86e8SMasahiro Yamada 1489 886d86e8SMasahiro Yamada%.s: %.c prepare scripts FORCE 1490 886d86e8SMasahiro Yamada $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1491 886d86e8SMasahiro Yamada%.i: %.c prepare scripts FORCE 1492 886d86e8SMasahiro Yamada $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1493 886d86e8SMasahiro Yamada%.o: %.c prepare scripts FORCE 1494 886d86e8SMasahiro Yamada $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1495 886d86e8SMasahiro Yamada%.lst: %.c prepare scripts FORCE 1496 886d86e8SMasahiro Yamada $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1497 886d86e8SMasahiro Yamada%.s: %.S prepare scripts FORCE 1498 886d86e8SMasahiro Yamada $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1499 886d86e8SMasahiro Yamada%.o: %.S prepare scripts FORCE 1500 886d86e8SMasahiro Yamada $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1501 886d86e8SMasahiro Yamada%.symtypes: %.c prepare scripts FORCE 1502 886d86e8SMasahiro Yamada $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1503 886d86e8SMasahiro Yamada 1504 886d86e8SMasahiro Yamada# Modules 1505 886d86e8SMasahiro Yamada/: prepare scripts FORCE 1506 886d86e8SMasahiro Yamada $(cmd_crmodverdir) 1507 886d86e8SMasahiro Yamada $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1508 886d86e8SMasahiro Yamada $(build)=$(build-dir) 1509 886d86e8SMasahiro Yamada%/: prepare scripts FORCE 1510 886d86e8SMasahiro Yamada $(cmd_crmodverdir) 1511 886d86e8SMasahiro Yamada $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1512 886d86e8SMasahiro Yamada $(build)=$(build-dir) 1513 886d86e8SMasahiro Yamada%.ko: prepare scripts FORCE 1514 886d86e8SMasahiro Yamada $(cmd_crmodverdir) 1515 886d86e8SMasahiro Yamada $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1516 886d86e8SMasahiro Yamada $(build)=$(build-dir) $(@:.ko=.o) 1517 886d86e8SMasahiro Yamada $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1518 886d86e8SMasahiro Yamada 1519 886d86e8SMasahiro Yamada# FIXME Should go into a make.lib or something 1520 886d86e8SMasahiro Yamada# =========================================================================== 1521 886d86e8SMasahiro Yamada 1522 efcf8619SMasahiro Yamadaquiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs))) 1523 efcf8619SMasahiro Yamada cmd_rmdirs = rm -rf $(rm-dirs) 1524 efcf8619SMasahiro Yamada 1525 efcf8619SMasahiro Yamadaquiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) 1526 efcf8619SMasahiro Yamada cmd_rmfiles = rm -f $(rm-files) 1527 efcf8619SMasahiro Yamada 1528 f9c235fdSMasahiro Yamada# read all saved command lines 1529 f9c235fdSMasahiro Yamada 1530 f9c235fdSMasahiro Yamadatargets := $(wildcard $(sort $(targets))) 1531 f9c235fdSMasahiro Yamadacmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) 1532 f9c235fdSMasahiro Yamada 1533 f9c235fdSMasahiro Yamadaifneq ($(cmd_files),) 1534 f9c235fdSMasahiro Yamada $(cmd_files): ; # Do not try to update included dependency files 1535 f9c235fdSMasahiro Yamada include $(cmd_files) 1536 f9c235fdSMasahiro Yamadaendif 1537 f9c235fdSMasahiro Yamada 1538 efcf8619SMasahiro Yamada# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir 1539 efcf8619SMasahiro Yamada# Usage: 1540 efcf8619SMasahiro Yamada# $(Q)$(MAKE) $(clean)=dir 1541 176d0982SMasahiro Yamadaclean := -f $(srctree)/scripts/Makefile.clean obj 1542 efcf8619SMasahiro Yamada 1543 9e414032SMasahiro Yamadaendif # skip-makefile 1544 9e414032SMasahiro Yamada 1545 9e414032SMasahiro YamadaPHONY += FORCE 1546 9e414032SMasahiro YamadaFORCE: 1547 9e414032SMasahiro Yamada 1548 9e414032SMasahiro Yamada# Declare the contents of the .PHONY variable as phony. We keep that 1549 9e414032SMasahiro Yamada# information in a variable so we can use it in if_changed and friends. 1550 9e414032SMasahiro Yamada.PHONY: $(PHONY) 1551