Makefile 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292
  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 = 01
  9. SUBLEVEL =
  10. EXTRAVERSION =
  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. ifeq ("$(origin W)", "command line")
  97. export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
  98. endif
  99. # That's our default target when none is given on the command line
  100. PHONY := _all
  101. _all:
  102. # Cancel implicit rules on top Makefile
  103. $(CURDIR)/Makefile Makefile: ;
  104. ifneq ($(KBUILD_OUTPUT),)
  105. # Invoke a second make in the output directory, passing relevant variables
  106. # check that the output directory actually exists
  107. saved-output := $(KBUILD_OUTPUT)
  108. KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
  109. $(if $(KBUILD_OUTPUT),, \
  110. $(error output directory "$(saved-output)" does not exist))
  111. PHONY += $(MAKECMDGOALS) sub-make
  112. $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
  113. @:
  114. sub-make: FORCE
  115. $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
  116. KBUILD_SRC=$(CURDIR) \
  117. KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \
  118. $(filter-out _all sub-make,$(MAKECMDGOALS))
  119. # Leave processing to above invocation of make
  120. skip-makefile := 1
  121. endif # ifneq ($(KBUILD_OUTPUT),)
  122. endif # ifeq ($(KBUILD_SRC),)
  123. # We process the rest of the Makefile if this is the final invocation of make
  124. ifeq ($(skip-makefile),)
  125. # If building an external module we do not care about the all: rule
  126. # but instead _all depend on modules
  127. PHONY += all
  128. ifeq ($(KBUILD_EXTMOD),)
  129. _all: all
  130. else
  131. _all: modules
  132. endif
  133. srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
  134. objtree := $(CURDIR)
  135. src := $(srctree)
  136. obj := $(objtree)
  137. VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
  138. export srctree objtree VPATH
  139. OBJTREE := $(objtree)
  140. SPLTREE := $(OBJTREE)/spl
  141. TPLTREE := $(OBJTREE)/tpl
  142. SRCTREE := $(srctree)
  143. TOPDIR := $(SRCTREE)
  144. export TOPDIR SRCTREE OBJTREE SPLTREE TPLTREE
  145. MKCONFIG := $(SRCTREE)/mkconfig
  146. export MKCONFIG
  147. # Make sure CDPATH settings don't interfere
  148. unexport CDPATH
  149. #########################################################################
  150. TIMESTAMP_FILE = include/generated/timestamp_autogenerated.h
  151. VERSION_FILE = include/generated/version_autogenerated.h
  152. HOSTARCH := $(shell uname -m | \
  153. sed -e s/i.86/x86/ \
  154. -e s/sun4u/sparc64/ \
  155. -e s/arm.*/arm/ \
  156. -e s/sa110/arm/ \
  157. -e s/ppc64/powerpc/ \
  158. -e s/ppc/powerpc/ \
  159. -e s/macppc/powerpc/\
  160. -e s/sh.*/sh/)
  161. HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
  162. sed -e 's/\(cygwin\).*/cygwin/')
  163. export HOSTARCH HOSTOS
  164. # Deal with colliding definitions from tcsh etc.
  165. VENDOR=
  166. #########################################################################
  167. # set default to nothing for native builds
  168. ifeq ($(HOSTARCH),$(ARCH))
  169. CROSS_COMPILE ?=
  170. endif
  171. # SHELL used by kbuild
  172. CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
  173. else if [ -x /bin/bash ]; then echo /bin/bash; \
  174. else echo sh; fi ; fi)
  175. HOSTCC = gcc
  176. HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
  177. ifeq ($(HOSTOS),cygwin)
  178. HOSTCFLAGS += -ansi
  179. endif
  180. # Mac OS X / Darwin's C preprocessor is Apple specific. It
  181. # generates numerous errors and warnings. We want to bypass it
  182. # and use GNU C's cpp. To do this we pass the -traditional-cpp
  183. # option to the compiler. Note that the -traditional-cpp flag
  184. # DOES NOT have the same semantics as GNU C's flag, all it does
  185. # is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
  186. #
  187. # Apple's linker is similar, thanks to the new 2 stage linking
  188. # multiple symbol definitions are treated as errors, hence the
  189. # -multiply_defined suppress option to turn off this error.
  190. #
  191. ifeq ($(HOSTOS),darwin)
  192. # get major and minor product version (e.g. '10' and '6' for Snow Leopard)
  193. DARWIN_MAJOR_VERSION = $(shell sw_vers -productVersion | cut -f 1 -d '.')
  194. DARWIN_MINOR_VERSION = $(shell sw_vers -productVersion | cut -f 2 -d '.')
  195. os_x_before = $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \
  196. $(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;)
  197. # Snow Leopards build environment has no longer restrictions as described above
  198. HOSTCC = $(call os_x_before, 10, 5, "cc", "gcc")
  199. HOSTCFLAGS += $(call os_x_before, 10, 4, "-traditional-cpp")
  200. HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress")
  201. endif
  202. # Decide whether to build built-in, modular, or both.
  203. # Normally, just do built-in.
  204. KBUILD_MODULES :=
  205. KBUILD_BUILTIN := 1
  206. # If we have only "make modules", don't compile built-in objects.
  207. # When we're building modules with modversions, we need to consider
  208. # the built-in objects during the descend as well, in order to
  209. # make sure the checksums are up to date before we record them.
  210. ifeq ($(MAKECMDGOALS),modules)
  211. KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
  212. endif
  213. # If we have "make <whatever> modules", compile modules
  214. # in addition to whatever we do anyway.
  215. # Just "make" or "make all" shall build modules as well
  216. # U-Boot does not need modules
  217. #ifneq ($(filter all _all modules,$(MAKECMDGOALS)),)
  218. # KBUILD_MODULES := 1
  219. #endif
  220. #ifeq ($(MAKECMDGOALS),)
  221. # KBUILD_MODULES := 1
  222. #endif
  223. export KBUILD_MODULES KBUILD_BUILTIN
  224. export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD
  225. # Beautify output
  226. # ---------------------------------------------------------------------------
  227. #
  228. # Normally, we echo the whole command before executing it. By making
  229. # that echo $($(quiet)$(cmd)), we now have the possibility to set
  230. # $(quiet) to choose other forms of output instead, e.g.
  231. #
  232. # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
  233. # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
  234. #
  235. # If $(quiet) is empty, the whole command will be printed.
  236. # If it is set to "quiet_", only the short version will be printed.
  237. # If it is set to "silent_", nothing will be printed at all, since
  238. # the variable $(silent_cmd_cc_o_c) doesn't exist.
  239. #
  240. # A simple variant is to prefix commands with $(Q) - that's useful
  241. # for commands that shall be hidden in non-verbose mode.
  242. #
  243. # $(Q)ln $@ :<
  244. #
  245. # If KBUILD_VERBOSE equals 0 then the above command will be hidden.
  246. # If KBUILD_VERBOSE equals 1 then the above command is displayed.
  247. ifeq ($(KBUILD_VERBOSE),1)
  248. quiet =
  249. Q =
  250. else
  251. quiet=quiet_
  252. Q = @
  253. endif
  254. # If the user is running make -s (silent mode), suppress echoing of
  255. # commands
  256. ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
  257. quiet=silent_
  258. endif
  259. export quiet Q KBUILD_VERBOSE
  260. # Look for make include files relative to root of kernel src
  261. MAKEFLAGS += --include-dir=$(srctree)
  262. # We need some generic definitions (do not try to remake the file).
  263. $(srctree)/scripts/Kbuild.include: ;
  264. include $(srctree)/scripts/Kbuild.include
  265. # Make variables (CC, etc...)
  266. AS = $(CROSS_COMPILE)as
  267. # Always use GNU ld
  268. ifneq ($(shell $(CROSS_COMPILE)ld.bfd -v 2> /dev/null),)
  269. LD = $(CROSS_COMPILE)ld.bfd
  270. else
  271. LD = $(CROSS_COMPILE)ld
  272. endif
  273. CC = $(CROSS_COMPILE)gcc
  274. CPP = $(CC) -E
  275. AR = $(CROSS_COMPILE)ar
  276. NM = $(CROSS_COMPILE)nm
  277. LDR = $(CROSS_COMPILE)ldr
  278. STRIP = $(CROSS_COMPILE)strip
  279. OBJCOPY = $(CROSS_COMPILE)objcopy
  280. OBJDUMP = $(CROSS_COMPILE)objdump
  281. AWK = awk
  282. RANLIB = $(CROSS_COMPILE)RANLIB
  283. DTC = dtc
  284. CHECK = sparse
  285. CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
  286. -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
  287. KBUILD_CPPFLAGS := -D__KERNEL__
  288. KBUILD_CFLAGS := -Wall -Wstrict-prototypes \
  289. -Wno-format-security \
  290. -fno-builtin -ffreestanding
  291. KBUILD_AFLAGS := -D__ASSEMBLY__
  292. U_BOOT_VERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
  293. export VERSION PATCHLEVEL SUBLEVEL U_BOOT_VERSION
  294. export ARCH CPU BOARD VENDOR SOC
  295. export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC
  296. export CPP AR NM LDR STRIP OBJCOPY OBJDUMP
  297. export MAKE AWK
  298. export DTC CHECK CHECKFLAGS
  299. export KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE
  300. export KBUILD_CFLAGS KBUILD_AFLAGS
  301. # When compiling out-of-tree modules, put MODVERDIR in the module
  302. # tree rather than in the kernel tree. The kernel tree might
  303. # even be read-only.
  304. export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions
  305. # Files to ignore in find ... statements
  306. RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \
  307. -o -name .pc -o -name .hg -o -name .git \) -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. no-dot-config-targets := clean clobber mrproper distclean \
  337. cscope TAGS %tags help %docs check% coccicheck \
  338. backup
  339. config-targets := 0
  340. mixed-targets := 0
  341. dot-config := 1
  342. ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
  343. ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
  344. dot-config := 0
  345. endif
  346. endif
  347. ifeq ($(KBUILD_EXTMOD),)
  348. ifneq ($(filter config %config,$(MAKECMDGOALS)),)
  349. config-targets := 1
  350. ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)
  351. mixed-targets := 1
  352. endif
  353. endif
  354. endif
  355. ifeq ($(mixed-targets),1)
  356. # ===========================================================================
  357. # We're called with mixed targets (*config and build targets).
  358. # Handle them one by one.
  359. PHONY += $(MAKECMDGOALS) build-one-by-one
  360. $(MAKECMDGOALS): build-one-by-one
  361. @:
  362. build-one-by-one:
  363. $(Q)set -e; \
  364. for i in $(MAKECMDGOALS); do \
  365. $(MAKE) -f $(srctree)/Makefile $$i; \
  366. done
  367. else
  368. ifeq ($(config-targets),1)
  369. # ===========================================================================
  370. # *config targets only - make sure prerequisites are updated, and descend
  371. # in scripts/kconfig to make the *config target
  372. # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
  373. # KBUILD_DEFCONFIG may point out an alternative default configuration
  374. # used for 'make defconfig'
  375. %_config:: outputmakefile
  376. @$(MKCONFIG) -A $(@:_config=)
  377. else
  378. # ===========================================================================
  379. # Build targets only - this includes vmlinux, arch specific targets, clean
  380. # targets and others. In general all targets except *config targets.
  381. # load ARCH, BOARD, and CPU configuration
  382. -include include/config.mk
  383. ifeq ($(dot-config),1)
  384. # Read in config
  385. -include include/autoconf.mk
  386. -include include/autoconf.mk.dep
  387. # load other configuration
  388. include $(srctree)/config.mk
  389. ifeq ($(wildcard include/config.mk),)
  390. $(error "System not configured - see README")
  391. endif
  392. ifeq ($(__HAVE_ARCH_GENERIC_BOARD),)
  393. ifneq ($(CONFIG_SYS_GENERIC_BOARD),)
  394. $(error Your architecture does not support generic board. \
  395. Please undefined CONFIG_SYS_GENERIC_BOARD in your board config file)
  396. endif
  397. endif
  398. # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
  399. # that (or fail if absent). Otherwise, search for a linker script in a
  400. # standard location.
  401. LDSCRIPT_MAKEFILE_DIR = $(dir $(LDSCRIPT))
  402. ifndef LDSCRIPT
  403. #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
  404. ifdef CONFIG_SYS_LDSCRIPT
  405. # need to strip off double quotes
  406. LDSCRIPT := $(CONFIG_SYS_LDSCRIPT:"%"=%)
  407. endif
  408. endif
  409. # If there is no specified link script, we look in a number of places for it
  410. ifndef LDSCRIPT
  411. ifeq ($(CONFIG_NAND_U_BOOT),y)
  412. LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
  413. ifeq ($(wildcard $(LDSCRIPT)),)
  414. LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds
  415. endif
  416. endif
  417. ifeq ($(wildcard $(LDSCRIPT)),)
  418. LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
  419. endif
  420. ifeq ($(wildcard $(LDSCRIPT)),)
  421. LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot.lds
  422. endif
  423. ifeq ($(wildcard $(LDSCRIPT)),)
  424. LDSCRIPT := $(TOPDIR)/arch/$(ARCH)/cpu/u-boot.lds
  425. # We don't expect a Makefile here
  426. LDSCRIPT_MAKEFILE_DIR =
  427. endif
  428. ifeq ($(wildcard $(LDSCRIPT)),)
  429. $(error could not find linker script)
  430. endif
  431. endif
  432. else
  433. endif # $(dot-config)
  434. KBUILD_CFLAGS += -Os #-fomit-frame-pointer
  435. ifdef BUILD_TAG
  436. KBUILD_CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"'
  437. endif
  438. KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
  439. KBUILD_CFLAGS += -g
  440. # $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
  441. # option to the assembler.
  442. KBUILD_AFLAGS += -g
  443. # Report stack usage if supported
  444. KBUILD_CFLAGS += $(call cc-option,-fstack-usage)
  445. KBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral)
  446. # turn jbsr into jsr for m68k
  447. ifeq ($(ARCH),m68k)
  448. ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
  449. KBUILD_AFLAGS += -Wa,-gstabs,-S
  450. endif
  451. endif
  452. ifneq ($(CONFIG_SYS_TEXT_BASE),)
  453. KBUILD_CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
  454. endif
  455. export CONFIG_SYS_TEXT_BASE
  456. # Use UBOOTINCLUDE when you must reference the include/ directory.
  457. # Needed to be compatible with the O= option
  458. UBOOTINCLUDE :=
  459. ifneq ($(OBJTREE),$(SRCTREE))
  460. UBOOTINCLUDE += -I$(OBJTREE)/include
  461. endif
  462. UBOOTINCLUDE += -I$(srctree)/include \
  463. -I$(srctree)/arch/$(ARCH)/include
  464. NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
  465. CHECKFLAGS += $(NOSTDINC_FLAGS)
  466. # FIX ME
  467. cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
  468. c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
  469. .PHONY : $(VERSION_FILE) $(TIMESTAMP_FILE)
  470. #########################################################################
  471. # U-Boot objects....order is important (i.e. start must be first)
  472. head-y := $(CPUDIR)/start.o
  473. head-$(CONFIG_4xx) += arch/powerpc/cpu/ppc4xx/resetvec.o
  474. head-$(CONFIG_MPC85xx) += arch/powerpc/cpu/mpc85xx/resetvec.o
  475. HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)
  476. libs-y += lib/
  477. libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
  478. libs-y += $(CPUDIR)/
  479. ifdef SOC
  480. libs-y += $(CPUDIR)/$(SOC)/
  481. endif
  482. libs-$(CONFIG_IXP4XX_NPE) += drivers/net/npe/
  483. libs-$(CONFIG_OF_EMBED) += dts/
  484. libs-y += arch/$(ARCH)/lib/
  485. libs-y += fs/
  486. libs-y += net/
  487. libs-y += disk/
  488. libs-y += drivers/
  489. libs-y += drivers/dma/
  490. libs-y += drivers/gpio/
  491. libs-y += drivers/i2c/
  492. libs-y += drivers/input/
  493. libs-y += drivers/mmc/
  494. libs-y += drivers/mtd/
  495. libs-$(CONFIG_CMD_NAND) += drivers/mtd/nand/
  496. libs-y += drivers/mtd/onenand/
  497. libs-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/
  498. libs-y += drivers/mtd/spi/
  499. libs-y += drivers/net/
  500. libs-y += drivers/net/phy/
  501. libs-y += drivers/pci/
  502. libs-y += drivers/power/ \
  503. drivers/power/fuel_gauge/ \
  504. drivers/power/mfd/ \
  505. drivers/power/pmic/ \
  506. drivers/power/battery/
  507. libs-y += drivers/spi/
  508. libs-$(CONFIG_FMAN_ENET) += drivers/net/fm/
  509. libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/
  510. libs-y += drivers/serial/
  511. libs-y += drivers/usb/eth/
  512. libs-y += drivers/usb/gadget/
  513. libs-y += drivers/usb/host/
  514. libs-y += drivers/usb/musb/
  515. libs-y += drivers/usb/musb-new/
  516. libs-y += drivers/usb/phy/
  517. libs-y += drivers/usb/ulpi/
  518. libs-y += common/
  519. libs-y += lib/libfdt/
  520. libs-$(CONFIG_API) += api/
  521. libs-$(CONFIG_HAS_POST) += post/
  522. libs-y += test/
  523. ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610))
  524. libs-y += arch/$(ARCH)/imx-common/
  525. endif
  526. libs-$(CONFIG_ARM) += arch/arm/cpu/
  527. libs-$(CONFIG_PPC) += arch/powerpc/cpu/
  528. libs-y += board/$(BOARDDIR)/
  529. libs-y := $(sort $(libs-y))
  530. u-boot-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) tools examples
  531. u-boot-alldirs := $(sort $(u-boot-dirs) $(patsubst %/,%,$(filter %/, $(libs-))))
  532. libs-y := $(patsubst %/, %/built-in.o, $(libs-y))
  533. u-boot-init := $(head-y)
  534. u-boot-main := $(libs-y)
  535. # Add GCC lib
  536. ifdef USE_PRIVATE_LIBGCC
  537. ifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
  538. PLATFORM_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/lib.a
  539. else
  540. PLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc
  541. endif
  542. else
  543. PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`) -lgcc
  544. endif
  545. PLATFORM_LIBS += $(PLATFORM_LIBGCC)
  546. export PLATFORM_LIBS
  547. # Special flags for CPP when processing the linker script.
  548. # Pass the version down so we can handle backwards compatibility
  549. # on the fly.
  550. LDPPFLAGS += \
  551. -include $(TOPDIR)/include/u-boot/u-boot.lds.h \
  552. -DCPUDIR=$(CPUDIR) \
  553. $(shell $(LD) --version | \
  554. sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
  555. #########################################################################
  556. #########################################################################
  557. ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
  558. BOARD_SIZE_CHECK = \
  559. @actual=`wc -c $@ | awk '{print $$1}'`; \
  560. limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
  561. if test $$actual -gt $$limit; then \
  562. echo "$@ exceeds file size limit:" >&2 ; \
  563. echo " limit: $$limit bytes" >&2 ; \
  564. echo " actual: $$actual bytes" >&2 ; \
  565. echo " excess: $$((actual - limit)) bytes" >&2; \
  566. exit 1; \
  567. fi
  568. else
  569. BOARD_SIZE_CHECK =
  570. endif
  571. # Statically apply RELA-style relocations (currently arm64 only)
  572. ifneq ($(CONFIG_STATIC_RELA),)
  573. # $(1) is u-boot ELF, $(2) is u-boot bin, $(3) is text base
  574. DO_STATIC_RELA = \
  575. start=$$($(NM) $(1) | grep __rel_dyn_start | cut -f 1 -d ' '); \
  576. end=$$($(NM) $(1) | grep __rel_dyn_end | cut -f 1 -d ' '); \
  577. tools/relocate-rela $(2) $(3) $$start $$end
  578. else
  579. DO_STATIC_RELA =
  580. endif
  581. # Always append ALL so that arch config.mk's can add custom ones
  582. ALL-y += u-boot.srec u-boot.bin System.map
  583. ALL-$(CONFIG_NAND_U_BOOT) += u-boot-nand.bin
  584. ALL-$(CONFIG_ONENAND_U_BOOT) += u-boot-onenand.bin
  585. ALL-$(CONFIG_RAMBOOT_PBL) += u-boot.pbl
  586. ALL-$(CONFIG_SPL) += spl/u-boot-spl.bin
  587. ALL-$(CONFIG_SPL_FRAMEWORK) += u-boot.img
  588. ALL-$(CONFIG_TPL) += tpl/u-boot-tpl.bin
  589. ALL-$(CONFIG_OF_SEPARATE) += u-boot-dtb.bin
  590. ifneq ($(CONFIG_SPL_TARGET),)
  591. ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%)
  592. endif
  593. ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf
  594. # enable combined SPL/u-boot/dtb rules for tegra
  595. ifneq ($(CONFIG_TEGRA),)
  596. ifeq ($(CONFIG_SPL),y)
  597. ifeq ($(CONFIG_OF_SEPARATE),y)
  598. ALL-y += u-boot-dtb-tegra.bin
  599. else
  600. ALL-y += u-boot-nodtb-tegra.bin
  601. endif
  602. endif
  603. endif
  604. LDFLAGS_u-boot += -T u-boot.lds $(LDFLAGS_FINAL)
  605. ifneq ($(CONFIG_SYS_TEXT_BASE),)
  606. LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
  607. endif
  608. all: $(ALL-y)
  609. PHONY += dtbs
  610. dtbs dts/dt.dtb: checkdtc u-boot
  611. $(Q)$(MAKE) $(build)=dts dtbs
  612. u-boot-dtb.bin: u-boot.bin dts/dt.dtb
  613. cat $^ >$@
  614. u-boot.hex: u-boot
  615. $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
  616. u-boot.srec: u-boot
  617. $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@
  618. u-boot.bin: u-boot
  619. $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
  620. $(call DO_STATIC_RELA,$<,$@,$(CONFIG_SYS_TEXT_BASE))
  621. $(BOARD_SIZE_CHECK)
  622. u-boot.ldr: u-boot
  623. $(CREATE_LDR_ENV)
  624. $(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS)
  625. $(BOARD_SIZE_CHECK)
  626. u-boot.ldr.hex: u-boot.ldr
  627. $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ -I binary
  628. u-boot.ldr.srec: u-boot.ldr
  629. $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ -I binary
  630. #
  631. # U-Boot entry point, needed for booting of full-blown U-Boot
  632. # from the SPL U-Boot version.
  633. #
  634. ifndef CONFIG_SYS_UBOOT_START
  635. CONFIG_SYS_UBOOT_START := 0
  636. endif
  637. u-boot.img: u-boot.bin
  638. tools/mkimage -A $(ARCH) -T firmware -C none \
  639. -O u-boot -a $(CONFIG_SYS_TEXT_BASE) \
  640. -e $(CONFIG_SYS_UBOOT_START) \
  641. -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
  642. sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \
  643. -d $< $@
  644. u-boot.imx: u-boot.bin
  645. $(MAKE) $(build)=arch/arm/imx-common $(objtree)/u-boot.imx
  646. u-boot.kwb: u-boot.bin
  647. tools/mkimage -n $(CONFIG_SYS_KWD_CONFIG) -T kwbimage \
  648. -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) -d $< $@
  649. u-boot.pbl: u-boot.bin
  650. tools/mkimage -n $(CONFIG_SYS_FSL_PBL_RCW) \
  651. -R $(CONFIG_SYS_FSL_PBL_PBI) -T pblimage \
  652. -d $< $@
  653. u-boot.sha1: u-boot.bin
  654. tools/ubsha1 u-boot.bin
  655. u-boot.dis: u-boot
  656. $(OBJDUMP) -d $< > $@
  657. # $@ is output, $(1) and $(2) are inputs, $(3) is padded intermediate,
  658. # $(4) is pad-to
  659. SPL_PAD_APPEND = \
  660. $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(4) -I binary -O binary \
  661. $(1) $(3); \
  662. cat $(3) $(2) > $@; \
  663. rm $(3)
  664. ifdef CONFIG_TPL
  665. SPL_PAYLOAD := tpl/u-boot-with-tpl.bin
  666. else
  667. SPL_PAYLOAD := u-boot.bin
  668. endif
  669. u-boot-with-spl.bin: spl/u-boot-spl.bin $(SPL_PAYLOAD)
  670. $(call SPL_PAD_APPEND,$<,$(SPL_PAYLOAD),spl/u-boot-spl-pad.bin,$(CONFIG_SPL_PAD_TO))
  671. tpl/u-boot-with-tpl.bin: tpl/u-boot-tpl.bin u-boot.bin
  672. $(call SPL_PAD_APPEND,$<,u-boot.bin,tpl/u-boot-tpl-pad.bin,$(CONFIG_TPL_PAD_TO))
  673. u-boot-with-spl.imx: spl/u-boot-spl.bin u-boot.bin
  674. $(MAKE) $(build)=arch/arm/imx-common \
  675. $(OBJTREE)/u-boot-with-spl.imx
  676. u-boot-with-nand-spl.imx: spl/u-boot-spl.bin u-boot.bin
  677. $(MAKE) $(build)=arch/arm/imx-common \
  678. $(OBJTREE)/u-boot-with-nand-spl.imx
  679. u-boot.ubl: u-boot-with-spl.bin
  680. tools/mkimage -n $(UBL_CONFIG) -T ublimage \
  681. -e $(CONFIG_SYS_TEXT_BASE) -d $< u-boot.ubl
  682. u-boot.ais: spl/u-boot-spl.bin u-boot.img
  683. tools/mkimage -s -n $(if $(CONFIG_AIS_CONFIG_FILE),$(srctree)/$(CONFIG_AIS_CONFIG_FILE:"%"=%),"/dev/null") \
  684. -T aisimage \
  685. -e $(CONFIG_SPL_TEXT_BASE) \
  686. -d spl/u-boot-spl.bin \
  687. spl/u-boot-spl.ais
  688. $(OBJCOPY) ${OBJCFLAGS} -I binary \
  689. --pad-to=$(CONFIG_SPL_MAX_SIZE) -O binary \
  690. spl/u-boot-spl.ais spl/u-boot-spl-pad.ais
  691. cat spl/u-boot-spl-pad.ais u-boot.img > u-boot.ais
  692. u-boot.sb: u-boot.bin spl/u-boot-spl.bin
  693. $(MAKE) $(build)=$(CPUDIR)/$(SOC)/ $(OBJTREE)/u-boot.sb
  694. # On x600 (SPEAr600) U-Boot is appended to U-Boot SPL.
  695. # Both images are created using mkimage (crc etc), so that the ROM
  696. # bootloader can check its integrity. Padding needs to be done to the
  697. # SPL image (with mkimage header) and not the binary. Otherwise the resulting image
  698. # which is loaded/copied by the ROM bootloader to SRAM doesn't fit.
  699. # The resulting image containing both U-Boot images is called u-boot.spr
  700. u-boot.spr: u-boot.img spl/u-boot-spl.bin
  701. tools/mkimage -A $(ARCH) -T firmware -C none \
  702. -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER \
  703. -d spl/u-boot-spl.bin $@
  704. $(OBJCOPY) -I binary -O binary \
  705. --pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff $@
  706. cat u-boot.img >> $@
  707. ifneq ($(CONFIG_TEGRA),)
  708. u-boot-nodtb-tegra.bin: spl/u-boot-spl.bin u-boot.bin
  709. $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SYS_TEXT_BASE) -O binary spl/u-boot-spl spl/u-boot-spl-pad.bin
  710. cat spl/u-boot-spl-pad.bin u-boot.bin > $@
  711. rm spl/u-boot-spl-pad.bin
  712. ifeq ($(CONFIG_OF_SEPARATE),y)
  713. u-boot-dtb-tegra.bin: u-boot-nodtb-tegra.bin dts/dt.dtb
  714. cat $^ > $@
  715. endif
  716. endif
  717. u-boot-img.bin: spl/u-boot-spl.bin u-boot.img
  718. cat spl/u-boot-spl.bin u-boot.img > $@
  719. # PPC4xx needs the SPL at the end of the image, since the reset vector
  720. # is located at 0xfffffffc. So we can't use the "u-boot-img.bin" target
  721. # and need to introduce a new build target with the full blown U-Boot
  722. # at the start padded up to the start of the SPL image. And then concat
  723. # the SPL image to the end.
  724. u-boot-img-spl-at-end.bin: spl/u-boot-spl.bin u-boot.img
  725. $(OBJCOPY) -I binary -O binary --pad-to=$(CONFIG_UBOOT_PAD_TO) \
  726. --gap-fill=0xff u-boot.img $@
  727. cat spl/u-boot-spl.bin >> $@
  728. # Create a new ELF from a raw binary file. This is useful for arm64
  729. # where static relocation needs to be performed on the raw binary,
  730. # but certain simulators only accept an ELF file (but don't do the
  731. # relocation).
  732. # FIXME refactor dts/Makefile to share target/arch detection
  733. u-boot.elf: u-boot.bin
  734. @$(OBJCOPY) -B aarch64 -I binary -O elf64-littleaarch64 \
  735. $< u-boot-elf.o
  736. @$(LD) u-boot-elf.o -o $@ \
  737. --defsym=_start=$(CONFIG_SYS_TEXT_BASE) \
  738. -Ttext=$(CONFIG_SYS_TEXT_BASE)
  739. ifeq ($(CONFIG_SANDBOX),y)
  740. GEN_UBOOT = \
  741. $(CC) $(SYMS) -T u-boot.lds \
  742. -Wl,--start-group $(u-boot-main) -Wl,--end-group \
  743. $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot
  744. else
  745. GEN_UBOOT = \
  746. $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
  747. $(u-boot-init) \
  748. --start-group $(u-boot-main) --end-group $(PLATFORM_LIBS) \
  749. -Map u-boot.map -o u-boot
  750. endif
  751. u-boot: $(u-boot-init) $(u-boot-main) u-boot.lds
  752. $(GEN_UBOOT)
  753. ifeq ($(CONFIG_KALLSYMS),y)
  754. smap=`$(call SYSTEM_MAP,u-boot) | \
  755. awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \
  756. $(CC) $(c_flags) -DSYSTEM_MAP="\"$${smap}\"" \
  757. -c $(srctree)/common/system_map.c -o common/system_map.o
  758. $(GEN_UBOOT) common/system_map.o
  759. endif
  760. # The actual objects are generated when descending,
  761. # make sure no implicit rule kicks in
  762. $(sort $(u-boot-init) $(u-boot-main)): $(u-boot-dirs) ;
  763. # Handle descending into subdirectories listed in $(vmlinux-dirs)
  764. # Preset locale variables to speed up the build process. Limit locale
  765. # tweaks to this spot to avoid wrong language settings when running
  766. # make menuconfig etc.
  767. # Error messages still appears in the original language
  768. PHONY += $(u-boot-dirs)
  769. $(u-boot-dirs): depend prepare scripts
  770. $(Q)$(MAKE) $(build)=$@
  771. tools: $(TIMESTAMP_FILE) $(VERSION_FILE)
  772. # The "tools" are needed early
  773. $(filter-out tools, $(u-boot-dirs)): tools
  774. # The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
  775. # is "yes"), so compile examples after U-Boot is compiled.
  776. examples: $(filter-out examples, $(u-boot-dirs))
  777. # Things we need to do before we recursively start building the kernel
  778. # or the modules are listed in "prepare".
  779. # A multi level approach is used. prepareN is processed before prepareN-1.
  780. # archprepare is used in arch Makefiles and when processed asm symlink,
  781. # version.h and scripts_basic is processed / created.
  782. # Listed in dependency order
  783. PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
  784. # prepare3 is used to check if we are building in a separate output directory,
  785. # and if so do:
  786. # 1) Check that make has not been executed in the kernel src $(srctree)
  787. prepare3:
  788. ifneq ($(KBUILD_SRC),)
  789. @$(kecho) ' Using $(srctree) as source for u-boot'
  790. $(Q)if [ -f $(srctree)/include/config.mk ]; then \
  791. echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \
  792. echo >&2 " in the '$(srctree)' directory.";\
  793. /bin/false; \
  794. fi;
  795. endif
  796. # prepare2 creates a makefile if using a separate output directory
  797. prepare2: prepare3 outputmakefile
  798. prepare1: prepare2
  799. @:
  800. archprepare: prepare1 scripts_basic
  801. prepare0: archprepare FORCE
  802. @:
  803. # All the preparing..
  804. prepare: prepare0
  805. #
  806. # Auto-generate the autoconf.mk file (which is included by all makefiles)
  807. #
  808. # This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
  809. # the dep file is only include in this top level makefile to determine when
  810. # to regenerate the autoconf.mk file.
  811. quiet_cmd_autoconf_dep = GEN $@
  812. cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M $(c_flags) \
  813. -MQ include/autoconf.mk $(srctree)/include/common.h > $@ || rm $@
  814. include/autoconf.mk.dep: include/config.h include/common.h
  815. $(call cmd,autoconf_dep)
  816. quiet_cmd_autoconf = GEN $@
  817. cmd_autoconf = \
  818. $(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
  819. sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
  820. rm $@.tmp
  821. include/autoconf.mk: include/config.h
  822. $(call cmd,autoconf)
  823. u-boot.lds: $(LDSCRIPT) depend
  824. $(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
  825. nand_spl: $(TIMESTAMP_FILE) $(VERSION_FILE) depend prepare
  826. $(MAKE) $(build)=nand_spl/board/$(BOARDDIR) all
  827. u-boot-nand.bin: nand_spl u-boot.bin
  828. cat nand_spl/u-boot-spl-16k.bin u-boot.bin > u-boot-nand.bin
  829. spl/u-boot-spl.bin: tools depend prepare
  830. $(MAKE) obj=spl -f $(srctree)/spl/Makefile all
  831. tpl/u-boot-tpl.bin: tools depend prepare
  832. $(MAKE) obj=tpl -f $(srctree)/spl/Makefile all CONFIG_TPL_BUILD=y
  833. # Explicitly make _depend in subdirs containing multiple targets to prevent
  834. # parallel sub-makes creating .depend files simultaneously.
  835. depend dep: $(TIMESTAMP_FILE) $(VERSION_FILE) \
  836. include/generated/generic-asm-offsets.h \
  837. include/generated/asm-offsets.h
  838. TAG_SUBDIRS := $(u-boot-dirs) include
  839. FIND := find
  840. FINDFLAGS := -L
  841. PHONY += checkstack
  842. checkstack:
  843. $(OBJDUMP) -d u-boot $$(find . -name u-boot-spl) | \
  844. $(PERL) $(src)/scripts/checkstack.pl $(ARCH)
  845. tags ctags:
  846. ctags -w -o ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
  847. -name '*.[chS]' -print`
  848. etags:
  849. etags -a -o $(obj)etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
  850. -name '*.[chS]' -print`
  851. cscope:
  852. $(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \
  853. cscope.files
  854. cscope -b -q -k
  855. SYSTEM_MAP = \
  856. $(NM) $1 | \
  857. grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
  858. LC_ALL=C sort
  859. System.map: u-boot
  860. @$(call SYSTEM_MAP,$<) > $@
  861. checkthumb:
  862. @if test $(call cc-version) -lt 0404; then \
  863. echo -n '*** Your GCC does not produce working '; \
  864. echo 'binaries in THUMB mode.'; \
  865. echo '*** Your board is configured for THUMB mode.'; \
  866. false; \
  867. fi
  868. # GCC 3.x is reported to have problems generating the type of relocation
  869. # that U-Boot wants.
  870. # See http://lists.denx.de/pipermail/u-boot/2012-September/135156.html
  871. checkgcc4:
  872. @if test $(call cc-version) -lt 0400; then \
  873. echo -n '*** Your GCC is too old, please upgrade to GCC 4.x or newer'; \
  874. false; \
  875. fi
  876. checkdtc:
  877. @if test $(call dtc-version) -lt 0104; then \
  878. echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \
  879. false; \
  880. fi
  881. quiet_cmd_offsets = GEN $@
  882. cmd_offsets = $(srctree)/tools/scripts/make-asm-offsets $< $@
  883. include/generated/generic-asm-offsets.h: lib/asm-offsets.s
  884. $(call cmd,offsets)
  885. quiet_cmd_asm-offsets.s = CC $@
  886. cmd_asm-offsets.s = mkdir -p lib; \
  887. $(CC) -DDO_DEPS_ONLY \
  888. $(c_flags) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
  889. -o $@ $< -c -S
  890. lib/asm-offsets.s: $(srctree)/lib/asm-offsets.c include/config.h
  891. $(call cmd,asm-offsets.s)
  892. include/generated/asm-offsets.h: $(CPUDIR)/$(SOC)/asm-offsets.s
  893. $(call cmd,offsets)
  894. quiet_cmd_soc_asm-offsets.s = CC $@
  895. cmd_soc_asm-offsets.s = mkdir -p $(CPUDIR)/$(SOC); \
  896. if [ -f $(srctree)/$(CPUDIR)/$(SOC)/asm-offsets.c ];then \
  897. $(CC) -DDO_DEPS_ONLY \
  898. $(c_flags) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
  899. -o $@ $(srctree)/$(CPUDIR)/$(SOC)/asm-offsets.c -c -S; \
  900. else \
  901. touch $@; \
  902. fi
  903. $(CPUDIR)/$(SOC)/asm-offsets.s: include/config.h
  904. $(call cmd,soc_asm-offsets.s)
  905. #########################################################################
  906. # ARM relocations should all be R_ARM_RELATIVE (32-bit) or
  907. # R_AARCH64_RELATIVE (64-bit).
  908. checkarmreloc: u-boot
  909. @RELOC="`$(CROSS_COMPILE)readelf -r -W $< | cut -d ' ' -f 4 | \
  910. grep R_A | sort -u`"; \
  911. if test "$$RELOC" != "R_ARM_RELATIVE" -a \
  912. "$$RELOC" != "R_AARCH64_RELATIVE"; then \
  913. echo "$< contains unexpected relocations: $$RELOC"; \
  914. false; \
  915. fi
  916. $(VERSION_FILE):
  917. @mkdir -p $(dir $(VERSION_FILE))
  918. @( localvers='$(shell $(TOPDIR)/scripts/setlocalversion $(TOPDIR))' ; \
  919. printf '#define PLAIN_VERSION "%s%s"\n' \
  920. "$(U_BOOT_VERSION)" "$${localvers}" ; \
  921. printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' \
  922. "$(U_BOOT_VERSION)" "$${localvers}" ; \
  923. ) > $@.tmp
  924. @( printf '#define CC_VERSION_STRING "%s"\n' \
  925. '$(shell $(CC) --version | head -n 1)' )>> $@.tmp
  926. @( printf '#define LD_VERSION_STRING "%s"\n' \
  927. '$(shell $(LD) -v | head -n 1)' )>> $@.tmp
  928. @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
  929. $(TIMESTAMP_FILE):
  930. @mkdir -p $(dir $(TIMESTAMP_FILE))
  931. @LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > $@.tmp
  932. @LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> $@.tmp
  933. @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
  934. env: depend scripts_basic
  935. $(Q)$(MAKE) $(build)=tools/$@
  936. tools-all: HOST_TOOLS_ALL=y
  937. tools-all: env tools ;
  938. .PHONY : CHANGELOG
  939. CHANGELOG:
  940. git log --no-merges U-Boot-1_1_5.. | \
  941. unexpand -a | sed -e 's/\s\s*$$//' > $@
  942. include/license.h: tools/bin2header COPYING
  943. cat COPYING | gzip -9 -c | ./tools/bin2header license_gzip > include/license.h
  944. #########################################################################
  945. ###
  946. # Cleaning is done on three levels.
  947. # make clean Delete most generated files
  948. # Leave enough to build external modules
  949. # make mrproper Delete the current configuration, and all generated files
  950. # make distclean Remove editor backup files, patch leftover files and the like
  951. # Directories & files removed with 'make clean'
  952. CLEAN_DIRS += $(MODVERDIR)
  953. CLEAN_FILES += u-boot.lds include/bmp_logo.h include/bmp_logo_data.h \
  954. board/*/config.tmp board/*/*/config.tmp \
  955. include/autoconf.mk* include/spl-autoconf.mk \
  956. include/tpl-autoconf.mk
  957. # Directories & files removed with 'make clobber'
  958. CLOBBER_DIRS += $(patsubst %,spl/%, $(filter-out Makefile, \
  959. $(shell ls -1 spl 2>/dev/null))) \
  960. tpl
  961. CLOBBER_FILES += u-boot* MLO MLO* SPL System.map nand_spl/u-boot*
  962. # Directories & files removed with 'make mrproper'
  963. MRPROPER_DIRS += include/config include/generated
  964. MRPROPER_FILES += .config .config.old \
  965. tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
  966. include/config.h include/config.mk
  967. # clean - Delete most, but leave enough to build external modules
  968. #
  969. clean: rm-dirs := $(CLEAN_DIRS)
  970. clean: rm-files := $(CLEAN_FILES)
  971. clean-dirs := $(foreach f,$(u-boot-alldirs),$(if $(wildcard $f/Makefile),$f))
  972. clean-dirs := $(addprefix _clean_, $(clean-dirs) doc/DocBook)
  973. PHONY += $(clean-dirs) clean archclean
  974. $(clean-dirs):
  975. $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
  976. # TODO: Do not use *.cfgtmp
  977. clean: $(clean-dirs)
  978. $(call cmd,rmdirs)
  979. $(call cmd,rmfiles)
  980. @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
  981. \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
  982. -o -name '*.ko.*' -o -name '*.su' -o -name '*.cfgtmp' \
  983. -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
  984. -o -name '*.symtypes' -o -name 'modules.order' \
  985. -o -name modules.builtin -o -name '.tmp_*.o.*' \
  986. -o -name '*.gcno' \) -type f -print | xargs rm -f
  987. @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
  988. -path './nand_spl/*' -type l -print | xargs rm -f
  989. # clobber
  990. #
  991. clobber: rm-dirs := $(CLOBBER_DIRS)
  992. clobber: rm-files := $(CLOBBER_FILES)
  993. PHONY += clobber
  994. clobber: clean
  995. $(call cmd,rmdirs)
  996. $(call cmd,rmfiles)
  997. # mrproper - Delete all generated files, including .config
  998. #
  999. mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
  1000. mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
  1001. mrproper-dirs := $(addprefix _mrproper_,scripts)
  1002. PHONY += $(mrproper-dirs) mrproper archmrproper
  1003. $(mrproper-dirs):
  1004. $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
  1005. mrproper: clobber $(mrproper-dirs)
  1006. $(call cmd,rmdirs)
  1007. $(call cmd,rmfiles)
  1008. @rm -f arch/*/include/asm/arch arch/*/include/asm/proc
  1009. # distclean
  1010. #
  1011. PHONY += distclean
  1012. distclean: mrproper
  1013. @find $(srctree) $(RCS_FIND_IGNORE) \
  1014. \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
  1015. -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
  1016. -o -name '.*.rej' \
  1017. -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
  1018. -type f -print | xargs rm -f
  1019. backup:
  1020. F=`basename $(TOPDIR)` ; cd .. ; \
  1021. gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
  1022. # Documentation targets
  1023. # ---------------------------------------------------------------------------
  1024. %docs: scripts_basic FORCE
  1025. $(Q)$(MAKE) $(build)=scripts build_docproc
  1026. $(Q)$(MAKE) $(build)=doc/DocBook $@
  1027. # Dummies...
  1028. PHONY += prepare scripts
  1029. prepare: ;
  1030. scripts: ;
  1031. endif #ifeq ($(config-targets),1)
  1032. endif #ifeq ($(mixed-targets),1)
  1033. quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs)))
  1034. cmd_rmdirs = rm -rf $(rm-dirs)
  1035. quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
  1036. cmd_rmfiles = rm -f $(rm-files)
  1037. # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
  1038. # Usage:
  1039. # $(Q)$(MAKE) $(clean)=dir
  1040. clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
  1041. endif # skip-makefile
  1042. PHONY += FORCE
  1043. FORCE:
  1044. # Declare the contents of the .PHONY variable as phony. We keep that
  1045. # information in a variable so we can use it in if_changed and friends.
  1046. .PHONY: $(PHONY)