Makefile 43 KB

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