Makefile 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454
  1. #
  2. # (C) Copyright 2000-2013
  3. # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. #
  5. # SPDX-License-Identifier: GPL-2.0+
  6. #
  7. VERSION = 2014
  8. PATCHLEVEL = 10
  9. SUBLEVEL =
  10. EXTRAVERSION = -rc2
  11. NAME =
  12. # *DOCUMENTATION*
  13. # To see a list of typical targets execute "make help"
  14. # More info can be located in ./README
  15. # Comments in this file are targeted only to the developer, do not
  16. # expect to learn how to build the kernel reading this file.
  17. # Do not:
  18. # o use make's built-in rules and variables
  19. # (this increases performance and avoids hard-to-debug behaviour);
  20. # o print "Entering directory ...";
  21. MAKEFLAGS += -rR --no-print-directory
  22. # Avoid funny character set dependencies
  23. unexport LC_ALL
  24. LC_COLLATE=C
  25. LC_NUMERIC=C
  26. export LC_COLLATE LC_NUMERIC
  27. # We are using a recursive build, so we need to do a little thinking
  28. # to get the ordering right.
  29. #
  30. # Most importantly: sub-Makefiles should only ever modify files in
  31. # their own directory. If in some directory we have a dependency on
  32. # a file in another dir (which doesn't happen often, but it's often
  33. # unavoidable when linking the built-in.o targets which finally
  34. # turn into vmlinux), we will call a sub make in that other dir, and
  35. # after that we are sure that everything which is in that other dir
  36. # is now up to date.
  37. #
  38. # The only cases where we need to modify files which have global
  39. # effects are thus separated out and done before the recursive
  40. # descending is started. They are now explicitly listed as the
  41. # prepare rule.
  42. # To put more focus on warnings, be less verbose as default
  43. # Use 'make V=1' to see the full commands
  44. ifeq ("$(origin V)", "command line")
  45. KBUILD_VERBOSE = $(V)
  46. endif
  47. ifndef KBUILD_VERBOSE
  48. KBUILD_VERBOSE = 0
  49. endif
  50. # Call a source code checker (by default, "sparse") as part of the
  51. # C compilation.
  52. #
  53. # Use 'make C=1' to enable checking of only re-compiled files.
  54. # Use 'make C=2' to enable checking of *all* source files, regardless
  55. # of whether they are re-compiled or not.
  56. #
  57. # See the file "Documentation/sparse.txt" for more details, including
  58. # where to get the "sparse" utility.
  59. ifeq ("$(origin C)", "command line")
  60. KBUILD_CHECKSRC = $(C)
  61. endif
  62. ifndef KBUILD_CHECKSRC
  63. KBUILD_CHECKSRC = 0
  64. endif
  65. # Use make M=dir to specify directory of external module to build
  66. # Old syntax make ... SUBDIRS=$PWD is still supported
  67. # Setting the environment variable KBUILD_EXTMOD take precedence
  68. ifdef SUBDIRS
  69. KBUILD_EXTMOD ?= $(SUBDIRS)
  70. endif
  71. ifeq ("$(origin M)", "command line")
  72. KBUILD_EXTMOD := $(M)
  73. endif
  74. # kbuild supports saving output files in a separate directory.
  75. # To locate output files in a separate directory two syntaxes are supported.
  76. # In both cases the working directory must be the root of the kernel src.
  77. # 1) O=
  78. # Use "make O=dir/to/store/output/files/"
  79. #
  80. # 2) Set KBUILD_OUTPUT
  81. # Set the environment variable KBUILD_OUTPUT to point to the directory
  82. # where the output files shall be placed.
  83. # export KBUILD_OUTPUT=dir/to/store/output/files/
  84. # make
  85. #
  86. # The O= assignment takes precedence over the KBUILD_OUTPUT environment
  87. # variable.
  88. # KBUILD_SRC is set on invocation of make in OBJ directory
  89. # KBUILD_SRC is not intended to be used by the regular user (for now)
  90. ifeq ($(KBUILD_SRC),)
  91. # OK, Make called in directory where kernel src resides
  92. # Do we want to locate output files in a separate directory?
  93. ifeq ("$(origin O)", "command line")
  94. KBUILD_OUTPUT := $(O)
  95. endif
  96. # That's our default target when none is given on the command line
  97. PHONY := _all
  98. _all:
  99. # Cancel implicit rules on top Makefile
  100. $(CURDIR)/Makefile Makefile: ;
  101. ifneq ($(KBUILD_OUTPUT),)
  102. # Invoke a second make in the output directory, passing relevant variables
  103. # check that the output directory actually exists
  104. saved-output := $(KBUILD_OUTPUT)
  105. KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \
  106. && /bin/pwd)
  107. $(if $(KBUILD_OUTPUT),, \
  108. $(error failed to create output directory "$(saved-output)"))
  109. PHONY += $(MAKECMDGOALS) sub-make
  110. $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
  111. @:
  112. sub-make: FORCE
  113. $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
  114. KBUILD_SRC=$(CURDIR) \
  115. KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \
  116. $(filter-out _all sub-make,$(MAKECMDGOALS))
  117. # Leave processing to above invocation of make
  118. skip-makefile := 1
  119. endif # ifneq ($(KBUILD_OUTPUT),)
  120. endif # ifeq ($(KBUILD_SRC),)
  121. # We process the rest of the Makefile if this is the final invocation of make
  122. ifeq ($(skip-makefile),)
  123. # If building an external module we do not care about the all: rule
  124. # but instead _all depend on modules
  125. PHONY += all
  126. ifeq ($(KBUILD_EXTMOD),)
  127. _all: all
  128. else
  129. _all: modules
  130. endif
  131. srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
  132. objtree := $(CURDIR)
  133. src := $(srctree)
  134. obj := $(objtree)
  135. VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
  136. export srctree objtree VPATH
  137. # Make sure CDPATH settings don't interfere
  138. unexport CDPATH
  139. #########################################################################
  140. HOSTARCH := $(shell uname -m | \
  141. sed -e s/i.86/x86/ \
  142. -e s/sun4u/sparc64/ \
  143. -e s/arm.*/arm/ \
  144. -e s/sa110/arm/ \
  145. -e s/ppc64/powerpc/ \
  146. -e s/ppc/powerpc/ \
  147. -e s/macppc/powerpc/\
  148. -e s/sh.*/sh/)
  149. HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
  150. sed -e 's/\(cygwin\).*/cygwin/')
  151. export HOSTARCH HOSTOS
  152. #########################################################################
  153. # set default to nothing for native builds
  154. ifeq ($(HOSTARCH),$(ARCH))
  155. CROSS_COMPILE ?=
  156. endif
  157. KCONFIG_CONFIG ?= .config
  158. export KCONFIG_CONFIG
  159. # SHELL used by kbuild
  160. CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
  161. else if [ -x /bin/bash ]; then echo /bin/bash; \
  162. else echo sh; fi ; fi)
  163. HOSTCC = cc
  164. HOSTCXX = c++
  165. HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
  166. HOSTCXXFLAGS = -O2
  167. ifeq ($(HOSTOS),cygwin)
  168. HOSTCFLAGS += -ansi
  169. endif
  170. # Mac OS X / Darwin's C preprocessor is Apple specific. It
  171. # generates numerous errors and warnings. We want to bypass it
  172. # and use GNU C's cpp. To do this we pass the -traditional-cpp
  173. # option to the compiler. Note that the -traditional-cpp flag
  174. # DOES NOT have the same semantics as GNU C's flag, all it does
  175. # is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
  176. #
  177. # Apple's linker is similar, thanks to the new 2 stage linking
  178. # multiple symbol definitions are treated as errors, hence the
  179. # -multiply_defined suppress option to turn off this error.
  180. #
  181. ifeq ($(HOSTOS),darwin)
  182. # get major and minor product version (e.g. '10' and '6' for Snow Leopard)
  183. DARWIN_MAJOR_VERSION = $(shell sw_vers -productVersion | cut -f 1 -d '.')
  184. DARWIN_MINOR_VERSION = $(shell sw_vers -productVersion | cut -f 2 -d '.')
  185. os_x_before = $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \
  186. $(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;)
  187. # Snow Leopards build environment has no longer restrictions as described above
  188. HOSTCC = $(call os_x_before, 10, 5, "cc", "gcc")
  189. HOSTCFLAGS += $(call os_x_before, 10, 4, "-traditional-cpp")
  190. HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress")
  191. endif
  192. # Decide whether to build built-in, modular, or both.
  193. # Normally, just do built-in.
  194. KBUILD_MODULES :=
  195. KBUILD_BUILTIN := 1
  196. # If we have only "make modules", don't compile built-in objects.
  197. # When we're building modules with modversions, we need to consider
  198. # the built-in objects during the descend as well, in order to
  199. # make sure the checksums are up to date before we record them.
  200. ifeq ($(MAKECMDGOALS),modules)
  201. KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
  202. endif
  203. # If we have "make <whatever> modules", compile modules
  204. # in addition to whatever we do anyway.
  205. # Just "make" or "make all" shall build modules as well
  206. # U-Boot does not need modules
  207. #ifneq ($(filter all _all modules,$(MAKECMDGOALS)),)
  208. # KBUILD_MODULES := 1
  209. #endif
  210. #ifeq ($(MAKECMDGOALS),)
  211. # KBUILD_MODULES := 1
  212. #endif
  213. export KBUILD_MODULES KBUILD_BUILTIN
  214. export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD
  215. # Beautify output
  216. # ---------------------------------------------------------------------------
  217. #
  218. # Normally, we echo the whole command before executing it. By making
  219. # that echo $($(quiet)$(cmd)), we now have the possibility to set
  220. # $(quiet) to choose other forms of output instead, e.g.
  221. #
  222. # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
  223. # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
  224. #
  225. # If $(quiet) is empty, the whole command will be printed.
  226. # If it is set to "quiet_", only the short version will be printed.
  227. # If it is set to "silent_", nothing will be printed at all, since
  228. # the variable $(silent_cmd_cc_o_c) doesn't exist.
  229. #
  230. # A simple variant is to prefix commands with $(Q) - that's useful
  231. # for commands that shall be hidden in non-verbose mode.
  232. #
  233. # $(Q)ln $@ :<
  234. #
  235. # If KBUILD_VERBOSE equals 0 then the above command will be hidden.
  236. # If KBUILD_VERBOSE equals 1 then the above command is displayed.
  237. ifeq ($(KBUILD_VERBOSE),1)
  238. quiet =
  239. Q =
  240. else
  241. quiet=quiet_
  242. Q = @
  243. endif
  244. # If the user is running make -s (silent mode), suppress echoing of
  245. # commands
  246. ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4
  247. ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
  248. quiet=silent_
  249. endif
  250. else # make-3.8x
  251. ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
  252. quiet=silent_
  253. endif
  254. endif
  255. export quiet Q KBUILD_VERBOSE
  256. # Look for make include files relative to root of kernel src
  257. MAKEFLAGS += --include-dir=$(srctree)
  258. # We need some generic definitions (do not try to remake the file).
  259. $(srctree)/scripts/Kbuild.include: ;
  260. include $(srctree)/scripts/Kbuild.include
  261. # Make variables (CC, etc...)
  262. AS = $(CROSS_COMPILE)as
  263. # Always use GNU ld
  264. ifneq ($(shell $(CROSS_COMPILE)ld.bfd -v 2> /dev/null),)
  265. LD = $(CROSS_COMPILE)ld.bfd
  266. else
  267. LD = $(CROSS_COMPILE)ld
  268. endif
  269. CC = $(CROSS_COMPILE)gcc
  270. CPP = $(CC) -E
  271. AR = $(CROSS_COMPILE)ar
  272. NM = $(CROSS_COMPILE)nm
  273. LDR = $(CROSS_COMPILE)ldr
  274. STRIP = $(CROSS_COMPILE)strip
  275. OBJCOPY = $(CROSS_COMPILE)objcopy
  276. OBJDUMP = $(CROSS_COMPILE)objdump
  277. AWK = awk
  278. PERL = perl
  279. PYTHON = python
  280. DTC = dtc
  281. CHECK = sparse
  282. CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
  283. -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
  284. KBUILD_CPPFLAGS := -D__KERNEL__ -D__UBOOT__
  285. KBUILD_CFLAGS := -Wall -Wstrict-prototypes \
  286. -Wno-format-security \
  287. -fno-builtin -ffreestanding
  288. KBUILD_AFLAGS := -D__ASSEMBLY__
  289. # Read UBOOTRELEASE from include/config/uboot.release (if it exists)
  290. UBOOTRELEASE = $(shell cat include/config/uboot.release 2> /dev/null)
  291. UBOOTVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
  292. export VERSION PATCHLEVEL SUBLEVEL UBOOTRELEASE UBOOTVERSION
  293. export ARCH CPU BOARD VENDOR SOC CPUDIR BOARDDIR
  294. export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC
  295. export CPP AR NM LDR STRIP OBJCOPY OBJDUMP
  296. export MAKE AWK PERL PYTHON
  297. export HOSTCXX HOSTCXXFLAGS DTC CHECK CHECKFLAGS
  298. export KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE OBJCOPYFLAGS LDFLAGS
  299. export KBUILD_CFLAGS KBUILD_AFLAGS
  300. # When compiling out-of-tree modules, put MODVERDIR in the module
  301. # tree rather than in the kernel tree. The kernel tree might
  302. # even be read-only.
  303. export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions
  304. # Files to ignore in find ... statements
  305. export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \
  306. -name CVS -o -name .pc -o -name .hg -o -name .git \) \
  307. -prune -o
  308. export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
  309. --exclude CVS --exclude .pc --exclude .hg --exclude .git
  310. # ===========================================================================
  311. # Rules shared between *config targets and build targets
  312. # Basic helpers built in scripts/
  313. PHONY += scripts_basic
  314. scripts_basic:
  315. $(Q)$(MAKE) $(build)=scripts/basic
  316. $(Q)rm -f .tmp_quiet_recordmcount
  317. # To avoid any implicit rule to kick in, define an empty command.
  318. scripts/basic/%: scripts_basic ;
  319. PHONY += outputmakefile
  320. # outputmakefile generates a Makefile in the output directory, if using a
  321. # separate output directory. This allows convenient use of make in the
  322. # output directory.
  323. outputmakefile:
  324. ifneq ($(KBUILD_SRC),)
  325. $(Q)ln -fsn $(srctree) source
  326. $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \
  327. $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
  328. endif
  329. # To make sure we do not include .config for any of the *config targets
  330. # catch them early, and hand them over to scripts/kconfig/Makefile
  331. # It is allowed to specify more targets when calling make, including
  332. # mixing *config targets and build targets.
  333. # For example 'make oldconfig all'.
  334. # Detect when mixed targets is specified, and make a second invocation
  335. # of make so .config is not included in this case either (for *config).
  336. version_h := include/generated/version_autogenerated.h
  337. timestamp_h := include/generated/timestamp_autogenerated.h
  338. no-dot-config-targets := clean clobber mrproper distclean \
  339. help %docs check% coccicheck \
  340. ubootversion backup tools-only
  341. config-targets := 0
  342. mixed-targets := 0
  343. dot-config := 1
  344. ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
  345. ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
  346. dot-config := 0
  347. endif
  348. endif
  349. ifeq ($(KBUILD_EXTMOD),)
  350. ifneq ($(filter config %config,$(MAKECMDGOALS)),)
  351. config-targets := 1
  352. ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)
  353. mixed-targets := 1
  354. endif
  355. endif
  356. endif
  357. ifeq ($(mixed-targets),1)
  358. # ===========================================================================
  359. # We're called with mixed targets (*config and build targets).
  360. # Handle them one by one.
  361. PHONY += $(MAKECMDGOALS) __build_one_by_one
  362. $(filter-out __build_one_by_one, $(MAKECMDGOALS)): __build_one_by_one
  363. @:
  364. __build_one_by_one:
  365. $(Q)set -e; \
  366. for i in $(MAKECMDGOALS); do \
  367. $(MAKE) -f $(srctree)/Makefile $$i; \
  368. done
  369. else
  370. ifeq ($(config-targets),1)
  371. # ===========================================================================
  372. # *config targets only - make sure prerequisites are updated, and descend
  373. # in scripts/kconfig to make the *config target
  374. KBUILD_DEFCONFIG := sandbox_defconfig
  375. export KBUILD_DEFCONFIG KBUILD_KCONFIG
  376. config: scripts_basic outputmakefile FORCE
  377. (Q)$(MAKE) $(build)=scripts/kconfig $@
  378. %config: scripts_basic outputmakefile FORCE
  379. +$(Q)$(CONFIG_SHELL) $(srctree)/scripts/multiconfig.sh $@
  380. else
  381. # ===========================================================================
  382. # Build targets only - this includes vmlinux, arch specific targets, clean
  383. # targets and others. In general all targets except *config targets.
  384. ifeq ($(dot-config),1)
  385. # Read in config
  386. -include include/config/auto.conf
  387. # Read in dependencies to all Kconfig* files, make sure to run
  388. # oldconfig if changes are detected.
  389. -include include/config/auto.conf.cmd
  390. # To avoid any implicit rule to kick in, define an empty command
  391. $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
  392. # If .config is newer than include/config/auto.conf, someone tinkered
  393. # with it and forgot to run make oldconfig.
  394. # if auto.conf.cmd is missing then we are probably in a cleaned tree so
  395. # we execute the config step to be sure to catch updated Kconfig files
  396. include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
  397. $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
  398. -include include/autoconf.mk
  399. -include include/autoconf.mk.dep
  400. # We want to include arch/$(ARCH)/config.mk only when include/config/auto.conf
  401. # is up-to-date. When we switch to a different board configuration, old CONFIG
  402. # macros are still remaining in include/config/auto.conf. Without the following
  403. # gimmick, wrong config.mk would be included leading nasty warnings/errors.
  404. autoconf_is_current := $(if $(wildcard $(KCONFIG_CONFIG)),$(shell find . \
  405. -path ./include/config/auto.conf -newer $(KCONFIG_CONFIG)))
  406. ifneq ($(autoconf_is_current),)
  407. include $(srctree)/config.mk
  408. endif
  409. # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
  410. # that (or fail if absent). Otherwise, search for a linker script in a
  411. # standard location.
  412. ifndef LDSCRIPT
  413. #LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot.lds.debug
  414. ifdef CONFIG_SYS_LDSCRIPT
  415. # need to strip off double quotes
  416. LDSCRIPT := $(srctree)/$(CONFIG_SYS_LDSCRIPT:"%"=%)
  417. endif
  418. endif
  419. # If there is no specified link script, we look in a number of places for it
  420. ifndef LDSCRIPT
  421. ifeq ($(wildcard $(LDSCRIPT)),)
  422. LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot.lds
  423. endif
  424. ifeq ($(wildcard $(LDSCRIPT)),)
  425. LDSCRIPT := $(srctree)/$(CPUDIR)/u-boot.lds
  426. endif
  427. ifeq ($(wildcard $(LDSCRIPT)),)
  428. LDSCRIPT := $(srctree)/arch/$(ARCH)/cpu/u-boot.lds
  429. endif
  430. endif
  431. else
  432. # Dummy target needed, because used as prerequisite
  433. include/config/auto.conf: ;
  434. endif # $(dot-config)
  435. ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
  436. KBUILD_CFLAGS += -Os
  437. else
  438. KBUILD_CFLAGS += -O2
  439. endif
  440. ifdef BUILD_TAG
  441. KBUILD_CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"'
  442. endif
  443. KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
  444. KBUILD_CFLAGS += -g
  445. # $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
  446. # option to the assembler.
  447. KBUILD_AFLAGS += -g
  448. # Report stack usage if supported
  449. ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-stack-usage.sh $(CC)),y)
  450. KBUILD_CFLAGS += -fstack-usage
  451. endif
  452. KBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral)
  453. # turn jbsr into jsr for m68k
  454. ifeq ($(ARCH),m68k)
  455. ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
  456. KBUILD_AFLAGS += -Wa,-gstabs,-S
  457. endif
  458. endif
  459. # Prohibit date/time macros, which would make the build non-deterministic
  460. KBUILD_CFLAGS += $(call cc-option,-Werror=date-time)
  461. ifneq ($(CONFIG_SYS_TEXT_BASE),)
  462. KBUILD_CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
  463. endif
  464. export CONFIG_SYS_TEXT_BASE
  465. include $(srctree)/scripts/Makefile.extrawarn
  466. # Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
  467. KBUILD_CPPFLAGS += $(KCPPFLAGS)
  468. KBUILD_AFLAGS += $(KAFLAGS)
  469. KBUILD_CFLAGS += $(KCFLAGS)
  470. # Use UBOOTINCLUDE when you must reference the include/ directory.
  471. # Needed to be compatible with the O= option
  472. UBOOTINCLUDE := \
  473. -Iinclude \
  474. $(if $(KBUILD_SRC), -I$(srctree)/include) \
  475. -I$(srctree)/arch/$(ARCH)/include \
  476. -include $(srctree)/include/linux/kconfig.h
  477. NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
  478. CHECKFLAGS += $(NOSTDINC_FLAGS)
  479. # FIX ME
  480. cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \
  481. $(NOSTDINC_FLAGS)
  482. c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
  483. #########################################################################
  484. # U-Boot objects....order is important (i.e. start must be first)
  485. head-y := $(CPUDIR)/start.o
  486. head-$(CONFIG_4xx) += arch/powerpc/cpu/ppc4xx/resetvec.o
  487. head-$(CONFIG_MPC85xx) += arch/powerpc/cpu/mpc85xx/resetvec.o
  488. HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)
  489. libs-y += lib/
  490. libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
  491. libs-y += $(CPUDIR)/
  492. ifdef SOC
  493. libs-y += $(CPUDIR)/$(SOC)/
  494. endif
  495. libs-$(CONFIG_OF_EMBED) += dts/
  496. libs-y += arch/$(ARCH)/lib/
  497. libs-y += fs/
  498. libs-y += net/
  499. libs-y += disk/
  500. libs-y += drivers/
  501. libs-$(CONFIG_DM) += drivers/core/
  502. libs-y += drivers/dma/
  503. libs-y += drivers/gpio/
  504. libs-y += drivers/i2c/
  505. libs-y += drivers/input/
  506. libs-y += drivers/mmc/
  507. libs-y += drivers/mtd/
  508. libs-$(CONFIG_CMD_NAND) += drivers/mtd/nand/
  509. libs-y += drivers/mtd/onenand/
  510. libs-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/
  511. libs-y += drivers/mtd/spi/
  512. libs-y += drivers/net/
  513. libs-y += drivers/net/phy/
  514. libs-y += drivers/pci/
  515. libs-y += drivers/power/ \
  516. drivers/power/fuel_gauge/ \
  517. drivers/power/mfd/ \
  518. drivers/power/pmic/ \
  519. drivers/power/battery/
  520. libs-y += drivers/spi/
  521. libs-$(CONFIG_FMAN_ENET) += drivers/net/fm/
  522. libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/
  523. libs-y += drivers/serial/
  524. libs-y += drivers/usb/eth/
  525. libs-y += drivers/usb/gadget/
  526. libs-y += drivers/usb/host/
  527. libs-y += drivers/usb/musb/
  528. libs-y += drivers/usb/musb-new/
  529. libs-y += drivers/usb/phy/
  530. libs-y += drivers/usb/ulpi/
  531. libs-y += common/
  532. libs-y += lib/libfdt/
  533. libs-$(CONFIG_API) += api/
  534. libs-$(CONFIG_HAS_POST) += post/
  535. libs-y += test/
  536. libs-y += test/dm/
  537. libs-$(CONFIG_DM_DEMO) += drivers/demo/
  538. ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610))
  539. libs-y += arch/$(ARCH)/imx-common/
  540. endif
  541. libs-$(CONFIG_ARM) += arch/arm/cpu/
  542. libs-$(CONFIG_PPC) += arch/powerpc/cpu/
  543. libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/)
  544. libs-y := $(sort $(libs-y))
  545. u-boot-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) tools examples
  546. u-boot-alldirs := $(sort $(u-boot-dirs) $(patsubst %/,%,$(filter %/, $(libs-))))
  547. libs-y := $(patsubst %/, %/built-in.o, $(libs-y))
  548. u-boot-init := $(head-y)
  549. u-boot-main := $(libs-y)
  550. # Add GCC lib
  551. ifdef CONFIG_USE_PRIVATE_LIBGCC
  552. ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y)
  553. PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a
  554. else
  555. PLATFORM_LIBGCC = -L $(CONFIG_USE_PRIVATE_LIBGCC) -lgcc
  556. endif
  557. else
  558. PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`) -lgcc
  559. endif
  560. PLATFORM_LIBS += $(PLATFORM_LIBGCC)
  561. export PLATFORM_LIBS
  562. export PLATFORM_LIBGCC
  563. # Special flags for CPP when processing the linker script.
  564. # Pass the version down so we can handle backwards compatibility
  565. # on the fly.
  566. LDPPFLAGS += \
  567. -include $(srctree)/include/u-boot/u-boot.lds.h \
  568. -DCPUDIR=$(CPUDIR) \
  569. $(shell $(LD) --version | \
  570. sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
  571. #########################################################################
  572. #########################################################################
  573. ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
  574. BOARD_SIZE_CHECK = \
  575. @actual=`wc -c $@ | awk '{print $$1}'`; \
  576. limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
  577. if test $$actual -gt $$limit; then \
  578. echo "$@ exceeds file size limit:" >&2 ; \
  579. echo " limit: $$limit bytes" >&2 ; \
  580. echo " actual: $$actual bytes" >&2 ; \
  581. echo " excess: $$((actual - limit)) bytes" >&2; \
  582. exit 1; \
  583. fi
  584. else
  585. BOARD_SIZE_CHECK =
  586. endif
  587. # Statically apply RELA-style relocations (currently arm64 only)
  588. ifneq ($(CONFIG_STATIC_RELA),)
  589. # $(1) is u-boot ELF, $(2) is u-boot bin, $(3) is text base
  590. DO_STATIC_RELA = \
  591. start=$$($(NM) $(1) | grep __rel_dyn_start | cut -f 1 -d ' '); \
  592. end=$$($(NM) $(1) | grep __rel_dyn_end | cut -f 1 -d ' '); \
  593. tools/relocate-rela $(2) $(3) $$start $$end
  594. else
  595. DO_STATIC_RELA =
  596. endif
  597. # Always append ALL so that arch config.mk's can add custom ones
  598. ALL-y += u-boot.srec u-boot.bin System.map binary_size_check
  599. ALL-$(CONFIG_ONENAND_U_BOOT) += u-boot-onenand.bin
  600. ifeq ($(CONFIG_SPL_FSL_PBL),y)
  601. ALL-$(CONFIG_RAMBOOT_PBL) += u-boot-with-spl-pbl.bin
  602. else
  603. ALL-$(CONFIG_RAMBOOT_PBL) += u-boot.pbl
  604. endif
  605. ALL-$(CONFIG_SPL) += spl/u-boot-spl.bin
  606. ALL-$(CONFIG_SPL_FRAMEWORK) += u-boot.img
  607. ALL-$(CONFIG_TPL) += tpl/u-boot-tpl.bin
  608. ALL-$(CONFIG_OF_SEPARATE) += u-boot.dtb u-boot-dtb.bin
  609. ifeq ($(CONFIG_SPL_FRAMEWORK),y)
  610. ALL-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img
  611. endif
  612. ALL-$(CONFIG_OF_HOSTFILE) += u-boot.dtb
  613. ifneq ($(CONFIG_SPL_TARGET),)
  614. ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%)
  615. endif
  616. ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf
  617. # enable combined SPL/u-boot/dtb rules for tegra
  618. ifneq ($(CONFIG_TEGRA),)
  619. ifeq ($(CONFIG_SPL),y)
  620. ifeq ($(CONFIG_OF_SEPARATE),y)
  621. ALL-y += u-boot-dtb-tegra.bin
  622. else
  623. ALL-y += u-boot-nodtb-tegra.bin
  624. endif
  625. endif
  626. endif
  627. LDFLAGS_u-boot += $(LDFLAGS_FINAL)
  628. ifneq ($(CONFIG_SYS_TEXT_BASE),)
  629. LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
  630. endif
  631. quiet_cmd_objcopy = OBJCOPY $@
  632. cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
  633. quiet_cmd_mkimage = MKIMAGE $@
  634. cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \
  635. $(if $(KBUILD_VERBOSE:1=), >/dev/null)
  636. quiet_cmd_cat = CAT $@
  637. cmd_cat = cat $(filter-out $(PHONY), $^) > $@
  638. append = cat $(filter-out $< $(PHONY), $^) >> $@
  639. quiet_cmd_pad_cat = CAT $@
  640. cmd_pad_cat = $(cmd_objcopy) && $(append) || rm -f $@
  641. all: $(ALL-y)
  642. PHONY += dtbs
  643. dtbs dts/dt.dtb: checkdtc u-boot
  644. $(Q)$(MAKE) $(build)=dts dtbs
  645. u-boot-dtb.bin: u-boot.bin dts/dt.dtb FORCE
  646. $(call if_changed,cat)
  647. %.imx: %.bin
  648. $(Q)$(MAKE) $(build)=arch/arm/imx-common $@
  649. quiet_cmd_copy = COPY $@
  650. cmd_copy = cp $< $@
  651. u-boot.dtb: dts/dt.dtb
  652. $(call cmd,copy)
  653. OBJCOPYFLAGS_u-boot.hex := -O ihex
  654. OBJCOPYFLAGS_u-boot.srec := -O srec
  655. u-boot.hex u-boot.srec: u-boot FORCE
  656. $(call if_changed,objcopy)
  657. OBJCOPYFLAGS_u-boot.bin := -O binary
  658. binary_size_check: u-boot.bin FORCE
  659. @file_size=$(shell wc -c u-boot.bin | awk '{print $$1}') ; \
  660. map_size=$(shell cat u-boot.map | \
  661. awk '/_image_copy_start/ {start = $$1} /_image_binary_end/ {end = $$1} END {if (start != "" && end != "") print "ibase=16; " toupper(end) " - " toupper(start)}' \
  662. | sed 's/0X//g' \
  663. | bc); \
  664. if [ "" != "$$map_size" ]; then \
  665. if test $$map_size -ne $$file_size; then \
  666. echo "u-boot.map shows a binary size of $$map_size" >&2 ; \
  667. echo " but u-boot.bin shows $$file_size" >&2 ; \
  668. exit 1; \
  669. fi \
  670. fi
  671. u-boot.bin: u-boot FORCE
  672. $(call if_changed,objcopy)
  673. $(call DO_STATIC_RELA,$<,$@,$(CONFIG_SYS_TEXT_BASE))
  674. $(BOARD_SIZE_CHECK)
  675. u-boot.ldr: u-boot
  676. $(CREATE_LDR_ENV)
  677. $(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS)
  678. $(BOARD_SIZE_CHECK)
  679. OBJCOPYFLAGS_u-boot.ldr.hex := -I binary -O ihex
  680. OBJCOPYFLAGS_u-boot.ldr.srec := -I binary -O srec
  681. u-boot.ldr.hex u-boot.ldr.srec: u-boot.ldr FORCE
  682. $(call if_changed,objcopy)
  683. #
  684. # U-Boot entry point, needed for booting of full-blown U-Boot
  685. # from the SPL U-Boot version.
  686. #
  687. ifndef CONFIG_SYS_UBOOT_START
  688. CONFIG_SYS_UBOOT_START := 0
  689. endif
  690. MKIMAGEFLAGS_u-boot.img = -A $(ARCH) -T firmware -C none -O u-boot \
  691. -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
  692. -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"
  693. MKIMAGEFLAGS_u-boot.kwb = -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) \
  694. -T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE)
  695. MKIMAGEFLAGS_u-boot.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \
  696. -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimage
  697. u-boot.img u-boot.kwb u-boot.pbl: u-boot.bin FORCE
  698. $(call if_changed,mkimage)
  699. MKIMAGEFLAGS_u-boot-dtb.img = $(MKIMAGEFLAGS_u-boot.img)
  700. u-boot-dtb.img: u-boot-dtb.bin FORCE
  701. $(call if_changed,mkimage)
  702. u-boot.sha1: u-boot.bin
  703. tools/ubsha1 u-boot.bin
  704. u-boot.dis: u-boot
  705. $(OBJDUMP) -d $< > $@
  706. ifdef CONFIG_TPL
  707. SPL_PAYLOAD := tpl/u-boot-with-tpl.bin
  708. else
  709. SPL_PAYLOAD := u-boot.bin
  710. endif
  711. OBJCOPYFLAGS_u-boot-with-spl.bin = -I binary -O binary \
  712. --pad-to=$(CONFIG_SPL_PAD_TO)
  713. u-boot-with-spl.bin: spl/u-boot-spl.bin $(SPL_PAYLOAD) FORCE
  714. $(call if_changed,pad_cat)
  715. OBJCOPYFLAGS_u-boot-with-tpl.bin = -I binary -O binary \
  716. --pad-to=$(CONFIG_TPL_PAD_TO)
  717. tpl/u-boot-with-tpl.bin: tpl/u-boot-tpl.bin u-boot.bin FORCE
  718. $(call if_changed,pad_cat)
  719. SPL: spl/u-boot-spl.bin FORCE
  720. $(Q)$(MAKE) $(build)=arch/arm/imx-common $@
  721. u-boot-with-spl.imx u-boot-with-nand-spl.imx: SPL u-boot.bin FORCE
  722. $(Q)$(MAKE) $(build)=arch/arm/imx-common $@
  723. MKIMAGEFLAGS_u-boot.ubl = -n $(UBL_CONFIG) -T ublimage -e $(CONFIG_SYS_TEXT_BASE)
  724. u-boot.ubl: u-boot-with-spl.bin FORCE
  725. $(call if_changed,mkimage)
  726. MKIMAGEFLAGS_u-boot-spl.ais = -s -n $(if $(CONFIG_AIS_CONFIG_FILE), \
  727. $(srctree)/$(CONFIG_AIS_CONFIG_FILE:"%"=%),"/dev/null") \
  728. -T aisimage -e $(CONFIG_SPL_TEXT_BASE)
  729. spl/u-boot-spl.ais: spl/u-boot-spl.bin FORCE
  730. $(call if_changed,mkimage)
  731. OBJCOPYFLAGS_u-boot.ais = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO)
  732. u-boot.ais: spl/u-boot-spl.ais u-boot.img FORCE
  733. $(call if_changed,pad_cat)
  734. u-boot-signed.sb: u-boot.bin spl/u-boot-spl.bin
  735. $(Q)$(MAKE) $(build)=arch/arm/cpu/arm926ejs/mxs u-boot-signed.sb
  736. u-boot.sb: u-boot.bin spl/u-boot-spl.bin
  737. $(Q)$(MAKE) $(build)=arch/arm/cpu/arm926ejs/mxs u-boot.sb
  738. # On x600 (SPEAr600) U-Boot is appended to U-Boot SPL.
  739. # Both images are created using mkimage (crc etc), so that the ROM
  740. # bootloader can check its integrity. Padding needs to be done to the
  741. # SPL image (with mkimage header) and not the binary. Otherwise the resulting image
  742. # which is loaded/copied by the ROM bootloader to SRAM doesn't fit.
  743. # The resulting image containing both U-Boot images is called u-boot.spr
  744. MKIMAGEFLAGS_u-boot-spl.img = -A $(ARCH) -T firmware -C none \
  745. -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER
  746. spl/u-boot-spl.img: spl/u-boot-spl.bin FORCE
  747. $(call if_changed,mkimage)
  748. OBJCOPYFLAGS_u-boot.spr = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) \
  749. --gap-fill=0xff
  750. u-boot.spr: spl/u-boot-spl.img u-boot.img FORCE
  751. $(call if_changed,pad_cat)
  752. MKIMAGEFLAGS_u-boot-spl.gph = -A $(ARCH) -T gpimage -C none \
  753. -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n SPL
  754. spl/u-boot-spl.gph: spl/u-boot-spl.bin FORCE
  755. $(call if_changed,mkimage)
  756. OBJCOPYFLAGS_u-boot-spi.gph = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) \
  757. --gap-fill=0
  758. u-boot-spi.gph: spl/u-boot-spl.gph u-boot.img FORCE
  759. $(call if_changed,pad_cat)
  760. MKIMAGEFLAGS_u-boot-nand.gph = -A $(ARCH) -T gpimage -C none \
  761. -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) -n U-Boot
  762. u-boot-nand.gph: u-boot.bin FORCE
  763. $(call if_changed,mkimage)
  764. @dd if=/dev/zero bs=8 count=1 2>/dev/null >> $@
  765. ifneq ($(CONFIG_SUNXI),)
  766. OBJCOPYFLAGS_u-boot-sunxi-with-spl.bin = -I binary -O binary \
  767. --pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff
  768. u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.img FORCE
  769. $(call if_changed,pad_cat)
  770. endif
  771. ifneq ($(CONFIG_TEGRA),)
  772. OBJCOPYFLAGS_u-boot-nodtb-tegra.bin = -O binary --pad-to=$(CONFIG_SYS_TEXT_BASE)
  773. u-boot-nodtb-tegra.bin: spl/u-boot-spl u-boot.bin FORCE
  774. $(call if_changed,pad_cat)
  775. ifeq ($(CONFIG_OF_SEPARATE),y)
  776. u-boot-dtb-tegra.bin: u-boot-nodtb-tegra.bin dts/dt.dtb FORCE
  777. $(call if_changed,cat)
  778. endif
  779. endif
  780. u-boot-img.bin: spl/u-boot-spl.bin u-boot.img FORCE
  781. $(call if_changed,cat)
  782. #Add a target to create boot binary having SPL binary in PBI format
  783. #concatenated with u-boot binary. It is need by PowerPC SoC having
  784. #internal SRAM <= 512KB.
  785. MKIMAGEFLAGS_u-boot-spl.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \
  786. -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimage
  787. spl/u-boot-spl.pbl: spl/u-boot-spl.bin FORCE
  788. $(call if_changed,mkimage)
  789. OBJCOPYFLAGS_u-boot-with-spl-pbl.bin = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) \
  790. --gap-fill=0xff
  791. u-boot-with-spl-pbl.bin: spl/u-boot-spl.pbl u-boot.bin FORCE
  792. $(call if_changed,pad_cat)
  793. # PPC4xx needs the SPL at the end of the image, since the reset vector
  794. # is located at 0xfffffffc. So we can't use the "u-boot-img.bin" target
  795. # and need to introduce a new build target with the full blown U-Boot
  796. # at the start padded up to the start of the SPL image. And then concat
  797. # the SPL image to the end.
  798. OBJCOPYFLAGS_u-boot-img-spl-at-end.bin := -I binary -O binary \
  799. --pad-to=$(CONFIG_UBOOT_PAD_TO) --gap-fill=0xff
  800. u-boot-img-spl-at-end.bin: u-boot.img spl/u-boot-spl.bin FORCE
  801. $(call if_changed,pad_cat)
  802. # Create a new ELF from a raw binary file. This is useful for arm64
  803. # where static relocation needs to be performed on the raw binary,
  804. # but certain simulators only accept an ELF file (but don't do the
  805. # relocation).
  806. # FIXME refactor dts/Makefile to share target/arch detection
  807. u-boot.elf: u-boot.bin
  808. @$(OBJCOPY) -B aarch64 -I binary -O elf64-littleaarch64 \
  809. $< u-boot-elf.o
  810. @$(LD) u-boot-elf.o -o $@ \
  811. --defsym=_start=$(CONFIG_SYS_TEXT_BASE) \
  812. -Ttext=$(CONFIG_SYS_TEXT_BASE)
  813. # Rule to link u-boot
  814. # May be overridden by arch/$(ARCH)/config.mk
  815. quiet_cmd_u-boot__ ?= LD $@
  816. cmd_u-boot__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_u-boot) -o $@ \
  817. -T u-boot.lds $(u-boot-init) \
  818. --start-group $(u-boot-main) --end-group \
  819. $(PLATFORM_LIBS) -Map u-boot.map
  820. quiet_cmd_smap = GEN common/system_map.o
  821. cmd_smap = \
  822. smap=`$(call SYSTEM_MAP,u-boot) | \
  823. awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \
  824. $(CC) $(c_flags) -DSYSTEM_MAP="\"$${smap}\"" \
  825. -c $(srctree)/common/system_map.c -o common/system_map.o
  826. u-boot: $(u-boot-init) $(u-boot-main) u-boot.lds
  827. $(call if_changed,u-boot__)
  828. ifeq ($(CONFIG_KALLSYMS),y)
  829. $(call cmd,smap)
  830. $(call cmd,u-boot__) common/system_map.o
  831. endif
  832. # The actual objects are generated when descending,
  833. # make sure no implicit rule kicks in
  834. $(sort $(u-boot-init) $(u-boot-main)): $(u-boot-dirs) ;
  835. # Handle descending into subdirectories listed in $(vmlinux-dirs)
  836. # Preset locale variables to speed up the build process. Limit locale
  837. # tweaks to this spot to avoid wrong language settings when running
  838. # make menuconfig etc.
  839. # Error messages still appears in the original language
  840. PHONY += $(u-boot-dirs)
  841. $(u-boot-dirs): prepare scripts
  842. $(Q)$(MAKE) $(build)=$@
  843. tools: prepare
  844. # The "tools" are needed early
  845. $(filter-out tools, $(u-boot-dirs)): tools
  846. # The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
  847. # is "yes"), so compile examples after U-Boot is compiled.
  848. examples: $(filter-out examples, $(u-boot-dirs))
  849. define filechk_uboot.release
  850. echo "$(UBOOTVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
  851. endef
  852. # Store (new) UBOOTRELEASE string in include/config/uboot.release
  853. include/config/uboot.release: include/config/auto.conf FORCE
  854. $(call filechk,uboot.release)
  855. # Things we need to do before we recursively start building the kernel
  856. # or the modules are listed in "prepare".
  857. # A multi level approach is used. prepareN is processed before prepareN-1.
  858. # archprepare is used in arch Makefiles and when processed asm symlink,
  859. # version.h and scripts_basic is processed / created.
  860. # Listed in dependency order
  861. PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
  862. # prepare3 is used to check if we are building in a separate output directory,
  863. # and if so do:
  864. # 1) Check that make has not been executed in the kernel src $(srctree)
  865. prepare3: include/config/uboot.release
  866. ifneq ($(KBUILD_SRC),)
  867. @$(kecho) ' Using $(srctree) as source for U-Boot'
  868. $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
  869. echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \
  870. echo >&2 " in the '$(srctree)' directory.";\
  871. /bin/false; \
  872. fi;
  873. endif
  874. # prepare2 creates a makefile if using a separate output directory
  875. prepare2: prepare3 outputmakefile
  876. prepare1: prepare2 $(version_h) $(timestamp_h) \
  877. include/config/auto.conf
  878. ifeq ($(__HAVE_ARCH_GENERIC_BOARD),)
  879. ifeq ($(CONFIG_SYS_GENERIC_BOARD),y)
  880. @echo >&2 " Your architecture does not support generic board."
  881. @echo >&2 " Please undefine CONFIG_SYS_GENERIC_BOARD in your board config file."
  882. @/bin/false
  883. endif
  884. endif
  885. ifeq ($(wildcard $(LDSCRIPT)),)
  886. @echo >&2 " Could not find linker script."
  887. @/bin/false
  888. endif
  889. archprepare: prepare1 scripts_basic
  890. prepare0: archprepare FORCE
  891. $(Q)$(MAKE) $(build)=.
  892. # All the preparing..
  893. prepare: prepare0
  894. # Generate some files
  895. # ---------------------------------------------------------------------------
  896. define filechk_version.h
  897. (echo \#define PLAIN_VERSION \"$(UBOOTRELEASE)\"; \
  898. echo \#define U_BOOT_VERSION \"U-Boot \" PLAIN_VERSION; \
  899. echo \#define CC_VERSION_STRING \"$$($(CC) --version | head -n 1)\"; \
  900. echo \#define LD_VERSION_STRING \"$$($(LD) --version | head -n 1)\"; )
  901. endef
  902. define filechk_timestamp.h
  903. (LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"'; \
  904. LC_ALL=C date +'#define U_BOOT_TIME "%T"')
  905. endef
  906. $(version_h): include/config/uboot.release FORCE
  907. $(call filechk,version.h)
  908. $(timestamp_h): $(srctree)/Makefile FORCE
  909. $(call filechk,timestamp.h)
  910. # ---------------------------------------------------------------------------
  911. PHONY += depend dep
  912. depend dep:
  913. @echo '*** Warning: make $@ is unnecessary now.'
  914. # ---------------------------------------------------------------------------
  915. quiet_cmd_cpp_lds = LDS $@
  916. cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \
  917. -D__ASSEMBLY__ -x assembler-with-cpp -P -o $@ $<
  918. u-boot.lds: $(LDSCRIPT) prepare FORCE
  919. $(call if_changed_dep,cpp_lds)
  920. spl/u-boot-spl.bin: spl/u-boot-spl
  921. @:
  922. spl/u-boot-spl: tools prepare
  923. $(Q)$(MAKE) obj=spl -f $(srctree)/scripts/Makefile.spl all
  924. spl/sunxi-spl.bin: spl/u-boot-spl
  925. @:
  926. tpl/u-boot-tpl.bin: tools prepare
  927. $(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.spl all
  928. TAG_SUBDIRS := $(patsubst %,$(srctree)/%,$(u-boot-dirs) include)
  929. FIND := find
  930. FINDFLAGS := -L
  931. tags ctags:
  932. ctags -w -o ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
  933. -name '*.[chS]' -print`
  934. etags:
  935. etags -a -o etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
  936. -name '*.[chS]' -print`
  937. cscope:
  938. $(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \
  939. cscope.files
  940. cscope -b -q -k
  941. SYSTEM_MAP = \
  942. $(NM) $1 | \
  943. grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
  944. LC_ALL=C sort
  945. System.map: u-boot
  946. @$(call SYSTEM_MAP,$<) > $@
  947. checkdtc:
  948. @if test $(call dtc-version) -lt 0104; then \
  949. echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \
  950. false; \
  951. fi
  952. #########################################################################
  953. # ARM relocations should all be R_ARM_RELATIVE (32-bit) or
  954. # R_AARCH64_RELATIVE (64-bit).
  955. checkarmreloc: u-boot
  956. @RELOC="`$(CROSS_COMPILE)readelf -r -W $< | cut -d ' ' -f 4 | \
  957. grep R_A | sort -u`"; \
  958. if test "$$RELOC" != "R_ARM_RELATIVE" -a \
  959. "$$RELOC" != "R_AARCH64_RELATIVE"; then \
  960. echo "$< contains unexpected relocations: $$RELOC"; \
  961. false; \
  962. fi
  963. env: scripts_basic
  964. $(Q)$(MAKE) $(build)=tools/$@
  965. tools-only: scripts_basic $(version_h) $(timestamp_h)
  966. $(Q)$(MAKE) $(build)=tools
  967. tools-all: export HOST_TOOLS_ALL=y
  968. tools-all: env tools ;
  969. cross_tools: export CROSS_BUILD_TOOLS=y
  970. cross_tools: tools ;
  971. .PHONY : CHANGELOG
  972. CHANGELOG:
  973. git log --no-merges U-Boot-1_1_5.. | \
  974. unexpand -a | sed -e 's/\s\s*$$//' > $@
  975. include/license.h: tools/bin2header COPYING
  976. cat COPYING | gzip -9 -c | ./tools/bin2header license_gzip > include/license.h
  977. #########################################################################
  978. ###
  979. # Cleaning is done on three levels.
  980. # make clean Delete most generated files
  981. # Leave enough to build external modules
  982. # make mrproper Delete the current configuration, and all generated files
  983. # make distclean Remove editor backup files, patch leftover files and the like
  984. # Directories & files removed with 'make clean'
  985. CLEAN_DIRS += $(MODVERDIR)
  986. CLEAN_FILES += u-boot.lds include/bmp_logo.h include/bmp_logo_data.h
  987. # Directories & files removed with 'make clobber'
  988. CLOBBER_DIRS += $(foreach d, spl tpl, $(patsubst %,$d/%, \
  989. $(filter-out include, $(shell ls -1 $d 2>/dev/null))))
  990. CLOBBER_FILES += u-boot* MLO* SPL System.map
  991. # Directories & files removed with 'make mrproper'
  992. MRPROPER_DIRS += include/config include/generated spl tpl \
  993. .tmp_objdiff
  994. MRPROPER_FILES += .config .config.old include/autoconf.mk* include/config.h \
  995. ctags etags TAGS cscope* GPATH GTAGS GRTAGS GSYMS
  996. # clean - Delete most, but leave enough to build external modules
  997. #
  998. clean: rm-dirs := $(CLEAN_DIRS)
  999. clean: rm-files := $(CLEAN_FILES)
  1000. clean-dirs := $(foreach f,$(u-boot-alldirs),$(if $(wildcard $(srctree)/$f/Makefile),$f))
  1001. clean-dirs := $(addprefix _clean_, $(clean-dirs) doc/DocBook)
  1002. PHONY += $(clean-dirs) clean archclean
  1003. $(clean-dirs):
  1004. $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
  1005. # TODO: Do not use *.cfgtmp
  1006. clean: $(clean-dirs)
  1007. $(call cmd,rmdirs)
  1008. $(call cmd,rmfiles)
  1009. @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
  1010. \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
  1011. -o -name '*.ko.*' -o -name '*.su' -o -name '*.cfgtmp' \
  1012. -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
  1013. -o -name '*.symtypes' -o -name 'modules.order' \
  1014. -o -name modules.builtin -o -name '.tmp_*.o.*' \
  1015. -o -name '*.gcno' \) -type f -print | xargs rm -f
  1016. # clobber
  1017. #
  1018. clobber: rm-dirs := $(CLOBBER_DIRS)
  1019. clobber: rm-files := $(CLOBBER_FILES)
  1020. PHONY += clobber
  1021. clobber: clean
  1022. $(call cmd,rmdirs)
  1023. $(call cmd,rmfiles)
  1024. # mrproper - Delete all generated files, including .config
  1025. #
  1026. mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
  1027. mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
  1028. mrproper-dirs := $(addprefix _mrproper_,scripts)
  1029. PHONY += $(mrproper-dirs) mrproper archmrproper
  1030. $(mrproper-dirs):
  1031. $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
  1032. mrproper: clobber $(mrproper-dirs)
  1033. $(call cmd,rmdirs)
  1034. $(call cmd,rmfiles)
  1035. @rm -f arch/*/include/asm/arch
  1036. # distclean
  1037. #
  1038. PHONY += distclean
  1039. distclean: mrproper
  1040. @find $(srctree) $(RCS_FIND_IGNORE) \
  1041. \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
  1042. -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
  1043. -o -name '.*.rej' -o -name '*%' -o -name 'core' \
  1044. -o -name '*.pyc' \) \
  1045. -type f -print | xargs rm -f
  1046. @rm -f boards.cfg
  1047. backup:
  1048. F=`basename $(srctree)` ; cd .. ; \
  1049. gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
  1050. help:
  1051. @echo 'Cleaning targets:'
  1052. @echo ' clean - Remove most generated files but keep the config and'
  1053. @echo ' necessities for testing u-boot'
  1054. @echo ' clobber - Remove most generated files but keep the config'
  1055. @echo ' mrproper - Remove all generated files + config + various backup files'
  1056. @echo ' distclean - mrproper + remove editor backup and patch files'
  1057. @echo ''
  1058. @echo 'Configuration targets:'
  1059. @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
  1060. @echo ''
  1061. @echo 'Other generic targets:'
  1062. @echo ' all - Build all necessary images depending on configuration'
  1063. @echo ' u-boot - Build the bare u-boot'
  1064. @echo ' dir/ - Build all files in dir and below'
  1065. @echo ' dir/file.[oisS] - Build specified target only'
  1066. @echo ' dir/file.lst - Build specified mixed source/assembly target only'
  1067. @echo ' (requires a recent binutils and recent build (System.map))'
  1068. @echo ' tags/ctags - Generate ctags file for editors'
  1069. @echo ' etags - Generate etags file for editors'
  1070. @echo ' cscope - Generate cscope index'
  1071. @echo ' ubootrelease - Output the release version string'
  1072. @echo ' ubootversion - Output the version stored in Makefile'
  1073. @echo ''
  1074. @echo 'Static analysers'
  1075. @echo ' checkstack - Generate a list of stack hogs'
  1076. @echo ''
  1077. @echo 'Documentation targets:'
  1078. @$(MAKE) -f $(srctree)/doc/DocBook/Makefile dochelp
  1079. @echo ''
  1080. @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
  1081. @echo ' make V=2 [targets] 2 => give reason for rebuild of target'
  1082. @echo ' make O=dir [targets] Locate all output files in "dir", including .config'
  1083. @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)'
  1084. @echo ' make C=2 [targets] Force check of all c source with $$CHECK'
  1085. @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections'
  1086. @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where'
  1087. @echo ' 1: warnings which may be relevant and do not occur too often'
  1088. @echo ' 2: warnings which occur quite often but may still be relevant'
  1089. @echo ' 3: more obscure warnings, can most likely be ignored'
  1090. @echo ' Multiple levels can be combined with W=12 or W=123'
  1091. @echo ''
  1092. @echo 'Execute "make" or "make all" to build all targets marked with [*] '
  1093. @echo 'For further info see the ./README file'
  1094. # Documentation targets
  1095. # ---------------------------------------------------------------------------
  1096. %docs: scripts_basic FORCE
  1097. $(Q)$(MAKE) $(build)=scripts build_docproc
  1098. $(Q)$(MAKE) $(build)=doc/DocBook $@
  1099. # Dummies...
  1100. PHONY += prepare scripts
  1101. prepare: ;
  1102. scripts: ;
  1103. endif #ifeq ($(config-targets),1)
  1104. endif #ifeq ($(mixed-targets),1)
  1105. PHONY += checkstack ubootrelease ubootversion
  1106. checkstack:
  1107. $(OBJDUMP) -d u-boot $$(find . -name u-boot-spl) | \
  1108. $(PERL) $(src)/scripts/checkstack.pl $(ARCH)
  1109. ubootrelease:
  1110. @echo "$(UBOOTVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
  1111. ubootversion:
  1112. @echo $(UBOOTVERSION)
  1113. # Single targets
  1114. # ---------------------------------------------------------------------------
  1115. # Single targets are compatible with:
  1116. # - build with mixed source and output
  1117. # - build with separate output dir 'make O=...'
  1118. # - external modules
  1119. #
  1120. # target-dir => where to store outputfile
  1121. # build-dir => directory in kernel source tree to use
  1122. ifeq ($(KBUILD_EXTMOD),)
  1123. build-dir = $(patsubst %/,%,$(dir $@))
  1124. target-dir = $(dir $@)
  1125. else
  1126. zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@)))
  1127. build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash))
  1128. target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
  1129. endif
  1130. %.s: %.c prepare scripts FORCE
  1131. $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
  1132. %.i: %.c prepare scripts FORCE
  1133. $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
  1134. %.o: %.c prepare scripts FORCE
  1135. $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
  1136. %.lst: %.c prepare scripts FORCE
  1137. $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
  1138. %.s: %.S prepare scripts FORCE
  1139. $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
  1140. %.o: %.S prepare scripts FORCE
  1141. $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
  1142. %.symtypes: %.c prepare scripts FORCE
  1143. $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
  1144. # Modules
  1145. /: prepare scripts FORCE
  1146. $(cmd_crmodverdir)
  1147. $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
  1148. $(build)=$(build-dir)
  1149. %/: prepare scripts FORCE
  1150. $(cmd_crmodverdir)
  1151. $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
  1152. $(build)=$(build-dir)
  1153. %.ko: prepare scripts FORCE
  1154. $(cmd_crmodverdir)
  1155. $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
  1156. $(build)=$(build-dir) $(@:.ko=.o)
  1157. $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
  1158. # FIXME Should go into a make.lib or something
  1159. # ===========================================================================
  1160. quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs)))
  1161. cmd_rmdirs = rm -rf $(rm-dirs)
  1162. quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
  1163. cmd_rmfiles = rm -f $(rm-files)
  1164. # read all saved command lines
  1165. targets := $(wildcard $(sort $(targets)))
  1166. cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
  1167. ifneq ($(cmd_files),)
  1168. $(cmd_files): ; # Do not try to update included dependency files
  1169. include $(cmd_files)
  1170. endif
  1171. # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
  1172. # Usage:
  1173. # $(Q)$(MAKE) $(clean)=dir
  1174. clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
  1175. endif # skip-makefile
  1176. PHONY += FORCE
  1177. FORCE:
  1178. # Declare the contents of the .PHONY variable as phony. We keep that
  1179. # information in a variable so we can use it in if_changed and friends.
  1180. .PHONY: $(PHONY)