Makefile 46 KB

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