Makefile 45 KB

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