Makefile 76 KB

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