Makefile 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456
  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 =
  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 = cc
  164. HOSTCXX = c++
  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__ -D__UBOOT__
  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
  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)$(CONFIG_SHELL) $(srctree)/scripts/multiconfig.sh $@
  378. %config: scripts_basic outputmakefile FORCE
  379. +$(Q)$(CONFIG_SHELL) $(srctree)/scripts/multiconfig.sh $@
  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. ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
  436. KBUILD_CFLAGS += -Os
  437. else
  438. KBUILD_CFLAGS += -O2
  439. endif
  440. ifdef BUILD_TAG
  441. KBUILD_CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"'
  442. endif
  443. KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
  444. KBUILD_CFLAGS += -g
  445. # $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
  446. # option to the assembler.
  447. KBUILD_AFLAGS += -g
  448. # Report stack usage if supported
  449. ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-stack-usage.sh $(CC)),y)
  450. KBUILD_CFLAGS += -fstack-usage
  451. endif
  452. KBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral)
  453. # turn jbsr into jsr for m68k
  454. ifeq ($(ARCH),m68k)
  455. ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
  456. KBUILD_AFLAGS += -Wa,-gstabs,-S
  457. endif
  458. endif
  459. # Prohibit date/time macros, which would make the build non-deterministic
  460. KBUILD_CFLAGS += $(call cc-option,-Werror=date-time)
  461. ifneq ($(CONFIG_SYS_TEXT_BASE),)
  462. KBUILD_CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
  463. endif
  464. export CONFIG_SYS_TEXT_BASE
  465. include $(srctree)/scripts/Makefile.extrawarn
  466. # Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
  467. KBUILD_CPPFLAGS += $(KCPPFLAGS)
  468. KBUILD_AFLAGS += $(KAFLAGS)
  469. KBUILD_CFLAGS += $(KCFLAGS)
  470. # Use UBOOTINCLUDE when you must reference the include/ directory.
  471. # Needed to be compatible with the O= option
  472. UBOOTINCLUDE := \
  473. -Iinclude \
  474. $(if $(KBUILD_SRC), -I$(srctree)/include) \
  475. -I$(srctree)/arch/$(ARCH)/include \
  476. -include $(srctree)/include/linux/kconfig.h
  477. NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
  478. CHECKFLAGS += $(NOSTDINC_FLAGS)
  479. # FIX ME
  480. cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \
  481. $(NOSTDINC_FLAGS)
  482. c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
  483. #########################################################################
  484. # U-Boot objects....order is important (i.e. start must be first)
  485. head-y := $(CPUDIR)/start.o
  486. head-$(CONFIG_4xx) += arch/powerpc/cpu/ppc4xx/resetvec.o
  487. head-$(CONFIG_MPC85xx) += arch/powerpc/cpu/mpc85xx/resetvec.o
  488. HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)
  489. libs-y += lib/
  490. libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
  491. libs-y += $(CPUDIR)/
  492. ifdef SOC
  493. libs-y += $(CPUDIR)/$(SOC)/
  494. endif
  495. libs-$(CONFIG_OF_EMBED) += dts/
  496. libs-y += arch/$(ARCH)/lib/
  497. libs-y += fs/
  498. libs-y += net/
  499. libs-y += disk/
  500. libs-y += drivers/
  501. libs-y += drivers/dma/
  502. libs-y += drivers/gpio/
  503. libs-y += drivers/i2c/
  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. ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610))
  536. libs-y += arch/$(ARCH)/imx-common/
  537. endif
  538. ifneq (,$(filter $(SOC), armada-xp kirkwood))
  539. libs-y += arch/$(ARCH)/mvebu-common/
  540. endif
  541. libs-$(CONFIG_ARM) += arch/arm/cpu/
  542. libs-$(CONFIG_PPC) += arch/powerpc/cpu/
  543. libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/)
  544. libs-y := $(sort $(libs-y))
  545. u-boot-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) tools examples
  546. u-boot-alldirs := $(sort $(u-boot-dirs) $(patsubst %/,%,$(filter %/, $(libs-))))
  547. libs-y := $(patsubst %/, %/built-in.o, $(libs-y))
  548. u-boot-init := $(head-y)
  549. u-boot-main := $(libs-y)
  550. # Add GCC lib
  551. ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y)
  552. PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a
  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. # Add optional build target if defined in board/cpu/soc headers
  624. ifneq ($(CONFIG_BUILD_TARGET),)
  625. ALL-y += $(CONFIG_BUILD_TARGET:"%"=%)
  626. endif
  627. LDFLAGS_u-boot += $(LDFLAGS_FINAL)
  628. ifneq ($(CONFIG_SYS_TEXT_BASE),)
  629. LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
  630. endif
  631. quiet_cmd_objcopy = OBJCOPY $@
  632. cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
  633. quiet_cmd_mkimage = MKIMAGE $@
  634. cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \
  635. $(if $(KBUILD_VERBOSE:1=), >/dev/null)
  636. quiet_cmd_cat = CAT $@
  637. cmd_cat = cat $(filter-out $(PHONY), $^) > $@
  638. append = cat $(filter-out $< $(PHONY), $^) >> $@
  639. quiet_cmd_pad_cat = CAT $@
  640. cmd_pad_cat = $(cmd_objcopy) && $(append) || rm -f $@
  641. all: $(ALL-y)
  642. PHONY += dtbs
  643. dtbs dts/dt.dtb: checkdtc u-boot
  644. $(Q)$(MAKE) $(build)=dts dtbs
  645. u-boot-dtb.bin: u-boot.bin dts/dt.dtb FORCE
  646. $(call if_changed,cat)
  647. %.imx: %.bin
  648. $(Q)$(MAKE) $(build)=arch/arm/imx-common $@
  649. quiet_cmd_copy = COPY $@
  650. cmd_copy = cp $< $@
  651. u-boot.dtb: dts/dt.dtb
  652. $(call cmd,copy)
  653. OBJCOPYFLAGS_u-boot.hex := -O ihex
  654. OBJCOPYFLAGS_u-boot.srec := -O srec
  655. u-boot.hex u-boot.srec: u-boot FORCE
  656. $(call if_changed,objcopy)
  657. OBJCOPYFLAGS_u-boot.bin := -O binary
  658. binary_size_check: u-boot.bin FORCE
  659. @file_size=$(shell wc -c u-boot.bin | awk '{print $$1}') ; \
  660. map_size=$(shell cat u-boot.map | \
  661. awk '/_image_copy_start/ {start = $$1} /_image_binary_end/ {end = $$1} END {if (start != "" && end != "") print "ibase=16; " toupper(end) " - " toupper(start)}' \
  662. | sed 's/0X//g' \
  663. | bc); \
  664. if [ "" != "$$map_size" ]; then \
  665. if test $$map_size -ne $$file_size; then \
  666. echo "u-boot.map shows a binary size of $$map_size" >&2 ; \
  667. echo " but u-boot.bin shows $$file_size" >&2 ; \
  668. exit 1; \
  669. fi \
  670. fi
  671. u-boot.bin: u-boot FORCE
  672. $(call if_changed,objcopy)
  673. $(call DO_STATIC_RELA,$<,$@,$(CONFIG_SYS_TEXT_BASE))
  674. $(BOARD_SIZE_CHECK)
  675. u-boot.ldr: u-boot
  676. $(CREATE_LDR_ENV)
  677. $(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS)
  678. $(BOARD_SIZE_CHECK)
  679. OBJCOPYFLAGS_u-boot.ldr.hex := -I binary -O ihex
  680. OBJCOPYFLAGS_u-boot.ldr.srec := -I binary -O srec
  681. u-boot.ldr.hex u-boot.ldr.srec: u-boot.ldr FORCE
  682. $(call if_changed,objcopy)
  683. #
  684. # U-Boot entry point, needed for booting of full-blown U-Boot
  685. # from the SPL U-Boot version.
  686. #
  687. ifndef CONFIG_SYS_UBOOT_START
  688. CONFIG_SYS_UBOOT_START := 0
  689. endif
  690. MKIMAGEFLAGS_u-boot.img = -A $(ARCH) -T firmware -C none -O u-boot \
  691. -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
  692. -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"
  693. MKIMAGEFLAGS_u-boot.kwb = -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) \
  694. -T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE)
  695. MKIMAGEFLAGS_u-boot.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \
  696. -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimage
  697. u-boot.img u-boot.kwb u-boot.pbl: u-boot.bin FORCE
  698. $(call if_changed,mkimage)
  699. MKIMAGEFLAGS_u-boot-dtb.img = $(MKIMAGEFLAGS_u-boot.img)
  700. u-boot-dtb.img: u-boot-dtb.bin FORCE
  701. $(call if_changed,mkimage)
  702. u-boot.sha1: u-boot.bin
  703. tools/ubsha1 u-boot.bin
  704. u-boot.dis: u-boot
  705. $(OBJDUMP) -d $< > $@
  706. ifdef CONFIG_TPL
  707. SPL_PAYLOAD := tpl/u-boot-with-tpl.bin
  708. else
  709. SPL_PAYLOAD := u-boot.bin
  710. endif
  711. OBJCOPYFLAGS_u-boot-with-spl.bin = -I binary -O binary \
  712. --pad-to=$(CONFIG_SPL_PAD_TO)
  713. u-boot-with-spl.bin: spl/u-boot-spl.bin $(SPL_PAYLOAD) FORCE
  714. $(call if_changed,pad_cat)
  715. OBJCOPYFLAGS_u-boot-with-tpl.bin = -I binary -O binary \
  716. --pad-to=$(CONFIG_TPL_PAD_TO)
  717. tpl/u-boot-with-tpl.bin: tpl/u-boot-tpl.bin u-boot.bin FORCE
  718. $(call if_changed,pad_cat)
  719. SPL: spl/u-boot-spl.bin FORCE
  720. $(Q)$(MAKE) $(build)=arch/arm/imx-common $@
  721. u-boot-with-spl.imx u-boot-with-nand-spl.imx: SPL u-boot.bin FORCE
  722. $(Q)$(MAKE) $(build)=arch/arm/imx-common $@
  723. MKIMAGEFLAGS_u-boot.ubl = -n $(UBL_CONFIG) -T ublimage -e $(CONFIG_SYS_TEXT_BASE)
  724. u-boot.ubl: u-boot-with-spl.bin FORCE
  725. $(call if_changed,mkimage)
  726. MKIMAGEFLAGS_u-boot-spl.ais = -s -n $(if $(CONFIG_AIS_CONFIG_FILE), \
  727. $(srctree)/$(CONFIG_AIS_CONFIG_FILE:"%"=%),"/dev/null") \
  728. -T aisimage -e $(CONFIG_SPL_TEXT_BASE)
  729. spl/u-boot-spl.ais: spl/u-boot-spl.bin FORCE
  730. $(call if_changed,mkimage)
  731. OBJCOPYFLAGS_u-boot.ais = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO)
  732. u-boot.ais: spl/u-boot-spl.ais u-boot.img FORCE
  733. $(call if_changed,pad_cat)
  734. u-boot-signed.sb: u-boot.bin spl/u-boot-spl.bin
  735. $(Q)$(MAKE) $(build)=arch/arm/cpu/arm926ejs/mxs u-boot-signed.sb
  736. u-boot.sb: u-boot.bin spl/u-boot-spl.bin
  737. $(Q)$(MAKE) $(build)=arch/arm/cpu/arm926ejs/mxs u-boot.sb
  738. # On x600 (SPEAr600) U-Boot is appended to U-Boot SPL.
  739. # Both images are created using mkimage (crc etc), so that the ROM
  740. # bootloader can check its integrity. Padding needs to be done to the
  741. # SPL image (with mkimage header) and not the binary. Otherwise the resulting image
  742. # which is loaded/copied by the ROM bootloader to SRAM doesn't fit.
  743. # The resulting image containing both U-Boot images is called u-boot.spr
  744. MKIMAGEFLAGS_u-boot-spl.img = -A $(ARCH) -T firmware -C none \
  745. -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER
  746. spl/u-boot-spl.img: spl/u-boot-spl.bin FORCE
  747. $(call if_changed,mkimage)
  748. OBJCOPYFLAGS_u-boot.spr = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) \
  749. --gap-fill=0xff
  750. u-boot.spr: spl/u-boot-spl.img u-boot.img FORCE
  751. $(call if_changed,pad_cat)
  752. MKIMAGEFLAGS_u-boot-spl.gph = -A $(ARCH) -T gpimage -C none \
  753. -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n SPL
  754. spl/u-boot-spl.gph: spl/u-boot-spl.bin FORCE
  755. $(call if_changed,mkimage)
  756. OBJCOPYFLAGS_u-boot-spi.gph = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) \
  757. --gap-fill=0
  758. u-boot-spi.gph: spl/u-boot-spl.gph u-boot.img FORCE
  759. $(call if_changed,pad_cat)
  760. MKIMAGEFLAGS_u-boot-nand.gph = -A $(ARCH) -T gpimage -C none \
  761. -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) -n U-Boot
  762. u-boot-nand.gph: u-boot.bin FORCE
  763. $(call if_changed,mkimage)
  764. @dd if=/dev/zero bs=8 count=1 2>/dev/null >> $@
  765. ifneq ($(CONFIG_SUNXI),)
  766. OBJCOPYFLAGS_u-boot-sunxi-with-spl.bin = -I binary -O binary \
  767. --pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff
  768. u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.img FORCE
  769. $(call if_changed,pad_cat)
  770. endif
  771. ifneq ($(CONFIG_TEGRA),)
  772. OBJCOPYFLAGS_u-boot-nodtb-tegra.bin = -O binary --pad-to=$(CONFIG_SYS_TEXT_BASE)
  773. u-boot-nodtb-tegra.bin: spl/u-boot-spl u-boot.bin FORCE
  774. $(call if_changed,pad_cat)
  775. ifeq ($(CONFIG_OF_SEPARATE),y)
  776. u-boot-dtb-tegra.bin: u-boot-nodtb-tegra.bin dts/dt.dtb FORCE
  777. $(call if_changed,cat)
  778. endif
  779. endif
  780. u-boot-img.bin: spl/u-boot-spl.bin u-boot.img FORCE
  781. $(call if_changed,cat)
  782. #Add a target to create boot binary having SPL binary in PBI format
  783. #concatenated with u-boot binary. It is need by PowerPC SoC having
  784. #internal SRAM <= 512KB.
  785. MKIMAGEFLAGS_u-boot-spl.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \
  786. -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimage
  787. spl/u-boot-spl.pbl: spl/u-boot-spl.bin FORCE
  788. $(call if_changed,mkimage)
  789. OBJCOPYFLAGS_u-boot-with-spl-pbl.bin = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) \
  790. --gap-fill=0xff
  791. u-boot-with-spl-pbl.bin: spl/u-boot-spl.pbl u-boot.bin FORCE
  792. $(call if_changed,pad_cat)
  793. # PPC4xx needs the SPL at the end of the image, since the reset vector
  794. # is located at 0xfffffffc. So we can't use the "u-boot-img.bin" target
  795. # and need to introduce a new build target with the full blown U-Boot
  796. # at the start padded up to the start of the SPL image. And then concat
  797. # the SPL image to the end.
  798. OBJCOPYFLAGS_u-boot-img-spl-at-end.bin := -I binary -O binary \
  799. --pad-to=$(CONFIG_UBOOT_PAD_TO) --gap-fill=0xff
  800. u-boot-img-spl-at-end.bin: u-boot.img spl/u-boot-spl.bin FORCE
  801. $(call if_changed,pad_cat)
  802. # Create a new ELF from a raw binary file. This is useful for arm64
  803. # where static relocation needs to be performed on the raw binary,
  804. # but certain simulators only accept an ELF file (but don't do the
  805. # relocation).
  806. # FIXME refactor dts/Makefile to share target/arch detection
  807. u-boot.elf: u-boot.bin
  808. @$(OBJCOPY) -B aarch64 -I binary -O elf64-littleaarch64 \
  809. $< u-boot-elf.o
  810. @$(LD) u-boot-elf.o -o $@ \
  811. --defsym=_start=$(CONFIG_SYS_TEXT_BASE) \
  812. -Ttext=$(CONFIG_SYS_TEXT_BASE)
  813. # Rule to link u-boot
  814. # May be overridden by arch/$(ARCH)/config.mk
  815. quiet_cmd_u-boot__ ?= LD $@
  816. cmd_u-boot__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_u-boot) -o $@ \
  817. -T u-boot.lds $(u-boot-init) \
  818. --start-group $(u-boot-main) --end-group \
  819. $(PLATFORM_LIBS) -Map u-boot.map
  820. quiet_cmd_smap = GEN common/system_map.o
  821. cmd_smap = \
  822. smap=`$(call SYSTEM_MAP,u-boot) | \
  823. awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \
  824. $(CC) $(c_flags) -DSYSTEM_MAP="\"$${smap}\"" \
  825. -c $(srctree)/common/system_map.c -o common/system_map.o
  826. u-boot: $(u-boot-init) $(u-boot-main) u-boot.lds
  827. $(call if_changed,u-boot__)
  828. ifeq ($(CONFIG_KALLSYMS),y)
  829. $(call cmd,smap)
  830. $(call cmd,u-boot__) common/system_map.o
  831. endif
  832. # The actual objects are generated when descending,
  833. # make sure no implicit rule kicks in
  834. $(sort $(u-boot-init) $(u-boot-main)): $(u-boot-dirs) ;
  835. # Handle descending into subdirectories listed in $(vmlinux-dirs)
  836. # Preset locale variables to speed up the build process. Limit locale
  837. # tweaks to this spot to avoid wrong language settings when running
  838. # make menuconfig etc.
  839. # Error messages still appears in the original language
  840. PHONY += $(u-boot-dirs)
  841. $(u-boot-dirs): prepare scripts
  842. $(Q)$(MAKE) $(build)=$@
  843. tools: prepare
  844. # The "tools" are needed early
  845. $(filter-out tools, $(u-boot-dirs)): tools
  846. # The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
  847. # is "yes"), so compile examples after U-Boot is compiled.
  848. examples: $(filter-out examples, $(u-boot-dirs))
  849. define filechk_uboot.release
  850. echo "$(UBOOTVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
  851. endef
  852. # Store (new) UBOOTRELEASE string in include/config/uboot.release
  853. include/config/uboot.release: include/config/auto.conf FORCE
  854. $(call filechk,uboot.release)
  855. # Things we need to do before we recursively start building the kernel
  856. # or the modules are listed in "prepare".
  857. # A multi level approach is used. prepareN is processed before prepareN-1.
  858. # archprepare is used in arch Makefiles and when processed asm symlink,
  859. # version.h and scripts_basic is processed / created.
  860. # Listed in dependency order
  861. PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
  862. # prepare3 is used to check if we are building in a separate output directory,
  863. # and if so do:
  864. # 1) Check that make has not been executed in the kernel src $(srctree)
  865. prepare3: include/config/uboot.release
  866. ifneq ($(KBUILD_SRC),)
  867. @$(kecho) ' Using $(srctree) as source for U-Boot'
  868. $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
  869. echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \
  870. echo >&2 " in the '$(srctree)' directory.";\
  871. /bin/false; \
  872. fi;
  873. endif
  874. # prepare2 creates a makefile if using a separate output directory
  875. prepare2: prepare3 outputmakefile
  876. prepare1: prepare2 $(version_h) $(timestamp_h) \
  877. include/config/auto.conf
  878. ifeq ($(__HAVE_ARCH_GENERIC_BOARD),)
  879. ifeq ($(CONFIG_SYS_GENERIC_BOARD),y)
  880. @echo >&2 " Your architecture does not support generic board."
  881. @echo >&2 " Please undefine CONFIG_SYS_GENERIC_BOARD in your board config file."
  882. @/bin/false
  883. endif
  884. endif
  885. ifeq ($(wildcard $(LDSCRIPT)),)
  886. @echo >&2 " Could not find linker script."
  887. @/bin/false
  888. endif
  889. archprepare: prepare1 scripts_basic
  890. prepare0: archprepare FORCE
  891. $(Q)$(MAKE) $(build)=.
  892. # All the preparing..
  893. prepare: prepare0
  894. # Generate some files
  895. # ---------------------------------------------------------------------------
  896. define filechk_version.h
  897. (echo \#define PLAIN_VERSION \"$(UBOOTRELEASE)\"; \
  898. echo \#define U_BOOT_VERSION \"U-Boot \" PLAIN_VERSION; \
  899. echo \#define CC_VERSION_STRING \"$$($(CC) --version | head -n 1)\"; \
  900. echo \#define LD_VERSION_STRING \"$$($(LD) --version | head -n 1)\"; )
  901. endef
  902. define filechk_timestamp.h
  903. (LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"'; \
  904. LC_ALL=C date +'#define U_BOOT_TIME "%T"')
  905. endef
  906. $(version_h): include/config/uboot.release FORCE
  907. $(call filechk,version.h)
  908. $(timestamp_h): $(srctree)/Makefile FORCE
  909. $(call filechk,timestamp.h)
  910. # ---------------------------------------------------------------------------
  911. PHONY += depend dep
  912. depend dep:
  913. @echo '*** Warning: make $@ is unnecessary now.'
  914. # ---------------------------------------------------------------------------
  915. quiet_cmd_cpp_lds = LDS $@
  916. cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \
  917. -D__ASSEMBLY__ -x assembler-with-cpp -P -o $@ $<
  918. u-boot.lds: $(LDSCRIPT) prepare FORCE
  919. $(call if_changed_dep,cpp_lds)
  920. spl/u-boot-spl.bin: spl/u-boot-spl
  921. @:
  922. spl/u-boot-spl: tools prepare
  923. $(Q)$(MAKE) obj=spl -f $(srctree)/scripts/Makefile.spl all
  924. spl/sunxi-spl.bin: spl/u-boot-spl
  925. @:
  926. tpl/u-boot-tpl.bin: tools prepare
  927. $(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.spl all
  928. TAG_SUBDIRS := $(patsubst %,$(srctree)/%,$(u-boot-dirs) include)
  929. FIND := find
  930. FINDFLAGS := -L
  931. tags ctags:
  932. ctags -w -o ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
  933. -name '*.[chS]' -print`
  934. etags:
  935. etags -a -o etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
  936. -name '*.[chS]' -print`
  937. cscope:
  938. $(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \
  939. cscope.files
  940. cscope -b -q -k
  941. SYSTEM_MAP = \
  942. $(NM) $1 | \
  943. grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
  944. LC_ALL=C sort
  945. System.map: u-boot
  946. @$(call SYSTEM_MAP,$<) > $@
  947. checkdtc:
  948. @if test $(call dtc-version) -lt 0104; then \
  949. echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \
  950. false; \
  951. fi
  952. #########################################################################
  953. # ARM relocations should all be R_ARM_RELATIVE (32-bit) or
  954. # R_AARCH64_RELATIVE (64-bit).
  955. checkarmreloc: u-boot
  956. @RELOC="`$(CROSS_COMPILE)readelf -r -W $< | cut -d ' ' -f 4 | \
  957. grep R_A | sort -u`"; \
  958. if test "$$RELOC" != "R_ARM_RELATIVE" -a \
  959. "$$RELOC" != "R_AARCH64_RELATIVE"; then \
  960. echo "$< contains unexpected relocations: $$RELOC"; \
  961. false; \
  962. fi
  963. env: scripts_basic
  964. $(Q)$(MAKE) $(build)=tools/$@
  965. tools-only: scripts_basic $(version_h) $(timestamp_h)
  966. $(Q)$(MAKE) $(build)=tools
  967. tools-all: export HOST_TOOLS_ALL=y
  968. tools-all: env tools ;
  969. cross_tools: export CROSS_BUILD_TOOLS=y
  970. cross_tools: tools ;
  971. .PHONY : CHANGELOG
  972. CHANGELOG:
  973. git log --no-merges U-Boot-1_1_5.. | \
  974. unexpand -a | sed -e 's/\s\s*$$//' > $@
  975. include/license.h: tools/bin2header COPYING
  976. cat COPYING | gzip -9 -c | ./tools/bin2header license_gzip > include/license.h
  977. #########################################################################
  978. ###
  979. # Cleaning is done on three levels.
  980. # make clean Delete most generated files
  981. # Leave enough to build external modules
  982. # make mrproper Delete the current configuration, and all generated files
  983. # make distclean Remove editor backup files, patch leftover files and the like
  984. # Directories & files removed with 'make clean'
  985. CLEAN_DIRS += $(MODVERDIR)
  986. CLEAN_FILES += u-boot.lds include/bmp_logo.h include/bmp_logo_data.h
  987. # Directories & files removed with 'make clobber'
  988. CLOBBER_DIRS += $(foreach d, spl tpl, $(patsubst %,$d/%, \
  989. $(filter-out include, $(shell ls -1 $d 2>/dev/null))))
  990. CLOBBER_FILES += u-boot* MLO* SPL System.map
  991. # Directories & files removed with 'make mrproper'
  992. MRPROPER_DIRS += include/config include/generated spl tpl \
  993. .tmp_objdiff
  994. MRPROPER_FILES += .config .config.old include/autoconf.mk* include/config.h \
  995. ctags etags TAGS cscope* GPATH GTAGS GRTAGS GSYMS
  996. # clean - Delete most, but leave enough to build external modules
  997. #
  998. clean: rm-dirs := $(CLEAN_DIRS)
  999. clean: rm-files := $(CLEAN_FILES)
  1000. clean-dirs := $(foreach f,$(u-boot-alldirs),$(if $(wildcard $(srctree)/$f/Makefile),$f))
  1001. clean-dirs := $(addprefix _clean_, $(clean-dirs) doc/DocBook)
  1002. PHONY += $(clean-dirs) clean archclean
  1003. $(clean-dirs):
  1004. $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
  1005. # TODO: Do not use *.cfgtmp
  1006. clean: $(clean-dirs)
  1007. $(call cmd,rmdirs)
  1008. $(call cmd,rmfiles)
  1009. @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
  1010. \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
  1011. -o -name '*.ko.*' -o -name '*.su' -o -name '*.cfgtmp' \
  1012. -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
  1013. -o -name '*.symtypes' -o -name 'modules.order' \
  1014. -o -name modules.builtin -o -name '.tmp_*.o.*' \
  1015. -o -name '*.gcno' \) -type f -print | xargs rm -f
  1016. # clobber
  1017. #
  1018. clobber: rm-dirs := $(CLOBBER_DIRS)
  1019. clobber: rm-files := $(CLOBBER_FILES)
  1020. PHONY += clobber
  1021. clobber: clean
  1022. $(call cmd,rmdirs)
  1023. $(call cmd,rmfiles)
  1024. # mrproper - Delete all generated files, including .config
  1025. #
  1026. mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
  1027. mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
  1028. mrproper-dirs := $(addprefix _mrproper_,scripts)
  1029. PHONY += $(mrproper-dirs) mrproper archmrproper
  1030. $(mrproper-dirs):
  1031. $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
  1032. mrproper: clobber $(mrproper-dirs)
  1033. $(call cmd,rmdirs)
  1034. $(call cmd,rmfiles)
  1035. @rm -f arch/*/include/asm/arch
  1036. # distclean
  1037. #
  1038. PHONY += distclean
  1039. distclean: mrproper
  1040. @find $(srctree) $(RCS_FIND_IGNORE) \
  1041. \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
  1042. -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
  1043. -o -name '.*.rej' -o -name '*%' -o -name 'core' \
  1044. -o -name '*.pyc' \) \
  1045. -type f -print | xargs rm -f
  1046. @rm -f boards.cfg
  1047. backup:
  1048. F=`basename $(srctree)` ; cd .. ; \
  1049. gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
  1050. help:
  1051. @echo 'Cleaning targets:'
  1052. @echo ' clean - Remove most generated files but keep the config and'
  1053. @echo ' necessities for testing u-boot'
  1054. @echo ' clobber - Remove most generated files but keep the config'
  1055. @echo ' mrproper - Remove all generated files + config + various backup files'
  1056. @echo ' distclean - mrproper + remove editor backup and patch files'
  1057. @echo ''
  1058. @echo 'Configuration targets:'
  1059. @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
  1060. @echo ''
  1061. @echo 'Other generic targets:'
  1062. @echo ' all - Build all necessary images depending on configuration'
  1063. @echo ' u-boot - Build the bare u-boot'
  1064. @echo ' dir/ - Build all files in dir and below'
  1065. @echo ' dir/file.[oisS] - Build specified target only'
  1066. @echo ' dir/file.lst - Build specified mixed source/assembly target only'
  1067. @echo ' (requires a recent binutils and recent build (System.map))'
  1068. @echo ' tags/ctags - Generate ctags file for editors'
  1069. @echo ' etags - Generate etags file for editors'
  1070. @echo ' cscope - Generate cscope index'
  1071. @echo ' ubootrelease - Output the release version string'
  1072. @echo ' ubootversion - Output the version stored in Makefile'
  1073. @echo ''
  1074. @echo 'Static analysers'
  1075. @echo ' checkstack - Generate a list of stack hogs'
  1076. @echo ''
  1077. @echo 'Documentation targets:'
  1078. @$(MAKE) -f $(srctree)/doc/DocBook/Makefile dochelp
  1079. @echo ''
  1080. @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
  1081. @echo ' make V=2 [targets] 2 => give reason for rebuild of target'
  1082. @echo ' make O=dir [targets] Locate all output files in "dir", including .config'
  1083. @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)'
  1084. @echo ' make C=2 [targets] Force check of all c source with $$CHECK'
  1085. @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections'
  1086. @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where'
  1087. @echo ' 1: warnings which may be relevant and do not occur too often'
  1088. @echo ' 2: warnings which occur quite often but may still be relevant'
  1089. @echo ' 3: more obscure warnings, can most likely be ignored'
  1090. @echo ' Multiple levels can be combined with W=12 or W=123'
  1091. @echo ''
  1092. @echo 'Execute "make" or "make all" to build all targets marked with [*] '
  1093. @echo 'For further info see the ./README file'
  1094. # Documentation targets
  1095. # ---------------------------------------------------------------------------
  1096. %docs: scripts_basic FORCE
  1097. $(Q)$(MAKE) $(build)=scripts build_docproc
  1098. $(Q)$(MAKE) $(build)=doc/DocBook $@
  1099. # Dummies...
  1100. PHONY += prepare scripts
  1101. prepare: ;
  1102. scripts: ;
  1103. endif #ifeq ($(config-targets),1)
  1104. endif #ifeq ($(mixed-targets),1)
  1105. PHONY += checkstack ubootrelease ubootversion
  1106. checkstack:
  1107. $(OBJDUMP) -d u-boot $$(find . -name u-boot-spl) | \
  1108. $(PERL) $(src)/scripts/checkstack.pl $(ARCH)
  1109. ubootrelease:
  1110. @echo "$(UBOOTVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
  1111. ubootversion:
  1112. @echo $(UBOOTVERSION)
  1113. # Single targets
  1114. # ---------------------------------------------------------------------------
  1115. # Single targets are compatible with:
  1116. # - build with mixed source and output
  1117. # - build with separate output dir 'make O=...'
  1118. # - external modules
  1119. #
  1120. # target-dir => where to store outputfile
  1121. # build-dir => directory in kernel source tree to use
  1122. ifeq ($(KBUILD_EXTMOD),)
  1123. build-dir = $(patsubst %/,%,$(dir $@))
  1124. target-dir = $(dir $@)
  1125. else
  1126. zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@)))
  1127. build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash))
  1128. target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
  1129. endif
  1130. %.s: %.c prepare scripts FORCE
  1131. $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
  1132. %.i: %.c prepare scripts FORCE
  1133. $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
  1134. %.o: %.c prepare scripts FORCE
  1135. $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
  1136. %.lst: %.c prepare scripts FORCE
  1137. $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
  1138. %.s: %.S prepare scripts FORCE
  1139. $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
  1140. %.o: %.S prepare scripts FORCE
  1141. $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
  1142. %.symtypes: %.c prepare scripts FORCE
  1143. $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
  1144. # Modules
  1145. /: prepare scripts FORCE
  1146. $(cmd_crmodverdir)
  1147. $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
  1148. $(build)=$(build-dir)
  1149. %/: prepare scripts FORCE
  1150. $(cmd_crmodverdir)
  1151. $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
  1152. $(build)=$(build-dir)
  1153. %.ko: prepare scripts FORCE
  1154. $(cmd_crmodverdir)
  1155. $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
  1156. $(build)=$(build-dir) $(@:.ko=.o)
  1157. $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
  1158. # FIXME Should go into a make.lib or something
  1159. # ===========================================================================
  1160. quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs)))
  1161. cmd_rmdirs = rm -rf $(rm-dirs)
  1162. quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
  1163. cmd_rmfiles = rm -f $(rm-files)
  1164. # read all saved command lines
  1165. targets := $(wildcard $(sort $(targets)))
  1166. cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
  1167. ifneq ($(cmd_files),)
  1168. $(cmd_files): ; # Do not try to update included dependency files
  1169. include $(cmd_files)
  1170. endif
  1171. # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
  1172. # Usage:
  1173. # $(Q)$(MAKE) $(clean)=dir
  1174. clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
  1175. endif # skip-makefile
  1176. PHONY += FORCE
  1177. FORCE:
  1178. # Declare the contents of the .PHONY variable as phony. We keep that
  1179. # information in a variable so we can use it in if_changed and friends.
  1180. .PHONY: $(PHONY)