Makefile 44 KB

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