Makefile 46 KB

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