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